@smartledger/bsv 7.5.4 → 7.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +76 -0
- package/README.md +38 -38
- package/bsv-gdaf.min.js +39 -39
- package/bsv-ltp.min.js +39 -39
- package/bsv-mnemonic.min.js +1 -1
- package/bsv-shamir.min.js +1 -1
- package/bsv-smartcontract.min.js +2 -2
- package/bsv.bundle.js +39 -39
- package/bsv.min.js +39 -39
- package/docs/BN_JS_V5_REVIEW.md +94 -0
- package/docs/MODULE_REFERENCE_COMPLETE.md +27 -27
- package/docs/advanced/UTXO_MANAGER_GUIDE.md +1 -1
- package/docs/getting-started/INSTALLATION.md +23 -23
- package/docs/getting-started/QUICK_START.md +7 -7
- package/docs/migration/FROM_BSV_1_5_6.md +5 -5
- package/lib/crypto/bn.js +3 -1
- package/lib/crypto/hash.browser.js +6 -1
- package/lib/crypto/hash.node.js +6 -1
- package/lib/networks.js +3 -1
- package/lib/privatekey.js +35 -1
- package/package.json +6 -4
- package/test/networks.js +45 -0
- package/test/privatekey.js +35 -2
- package/version.js +1 -1
package/bsv-shamir.min.js
CHANGED
|
@@ -16,5 +16,5 @@ use chrome, FireFox or Internet Explorer 11`)}var xm=ke(),_m=ui(),Mm=xm.Buffer,E
|
|
|
16
16
|
we accept pull requests
|
|
17
17
|
https://github.com/browserify/crypto-browserify`)};Te.constants={DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6}});var il=R((qk,Tm)=>{"use strict";w();function En(){}En.getRandomBuffer=function(t){return S.default.browser?En.getRandomBufferBrowser(t):En.getRandomBufferNode(t)};En.getRandomBufferNode=function(t){var e=ja();return e.randomBytes(t)};En.getRandomBufferBrowser=function(t){if(!window.crypto&&!window.msCrypto)throw new Error("window.crypto not available");var e;if(window.crypto&&window.crypto.getRandomValues)e=window.crypto;else if(window.msCrypto&&window.msCrypto.getRandomValues)e=window.msCrypto;else throw new Error("window.crypto.getRandomValues not available");var r=new Uint8Array(t);e.getRandomValues(r);var n=B.Buffer.from(r);return n};Tm.exports=En});var Hf=R((kk,Cm)=>{"use strict";w();var iS=il(),We={};We.isArray=t=>Array.isArray(t);We.isNumber=t=>typeof t=="number";We.isObject=t=>t&&typeof t=="object";We.isString=t=>typeof t=="string";We.isUndefined=t=>typeof t>"u";We.isFunction=t=>typeof t=="function";We.isNull=t=>t===null;We.isDate=t=>t instanceof Date;We.extend=(t,e)=>Object.assign(t,e);We.noop=()=>{};We.every=(t,e)=>t.every(e||(r=>r));We.map=(t,e)=>Array.from(t).map(e||(r=>r));We.includes=(t,e)=>t.includes(e);We.each=(t,e)=>t.forEach(e);We.clone=t=>Object.assign({},t);We.pick=(t,e)=>{let r={};return e.forEach(n=>{typeof t[n]<"u"&&(r[n]=t[n])}),r};We.values=t=>Object.values(t);We.filter=(t,e)=>t.filter(e);We.reduce=(t,e,r)=>t.reduce(e,r);We.without=(t,e)=>t.filter(r=>r!==e);We.shuffle=t=>{let e=t.slice(0);for(let r=e.length-1;r>0;r--){let i=iS.getRandomBuffer(4).readUInt32BE(0)/4294967296,a=Math.floor(i*(r+1));[e[r],e[a]]=[e[a],e[r]]}return e};We.difference=(t,e)=>t.filter(r=>!e.includes(r));We.findIndex=(t,e)=>t.findIndex(e);We.some=(t,e)=>t.some(e);We.range=t=>[...Array(t).keys()];Cm.exports=We});var Pm=R((Ck,Om)=>{"use strict";w();var nS="https://docs.moneybutton.com/";Om.exports=[{name:"InvalidB58Char",message:"Invalid Base58 character: {0} in {1}"},{name:"InvalidB58Checksum",message:"Invalid Base58 checksum for {0}"},{name:"InvalidNetwork",message:"Invalid version for network: got {0}"},{name:"InvalidState",message:"Invalid state: {0}"},{name:"NotImplemented",message:"Function {0} was not implemented yet"},{name:"InvalidNetworkArgument",message:'Invalid network: must be "livenet" or "testnet", got {0}'},{name:"InvalidArgument",message:function(){return"Invalid Argument"+(arguments[0]?": "+arguments[0]:"")+(arguments[1]?" Documentation: "+nS+arguments[1]:"")}},{name:"AbstractMethodInvoked",message:"Abstract Method Invocation: {0}"},{name:"InvalidArgumentType",message:function(){return"Invalid Argument for "+arguments[2]+", expected "+arguments[1]+" but got "+typeof arguments[0]}},{name:"Unit",message:"Internal Error on Unit {0}",errors:[{name:"UnknownCode",message:"Unrecognized unit code: {0}"},{name:"InvalidRate",message:"Invalid exchange rate: {0}"}]},{name:"MerkleBlock",message:"Internal Error on MerkleBlock {0}",errors:[{name:"InvalidMerkleTree",message:"This MerkleBlock contain an invalid Merkle Tree"}]},{name:"Transaction",message:"Internal Error on Transaction {0}",errors:[{name:"Input",message:"Internal Error on Input {0}",errors:[{name:"MissingScript",message:"Need a script to create an input"},{name:"UnsupportedScript",message:"Unsupported input script type: {0}"},{name:"MissingPreviousOutput",message:"No previous output information."}]},{name:"NeedMoreInfo",message:"{0}"},{name:"InvalidSorting",message:"The sorting function provided did not return the change output as one of the array elements"},{name:"InvalidOutputAmountSum",message:"{0}"},{name:"MissingSignatures",message:"Some inputs have not been fully signed"},{name:"InvalidIndex",message:"Invalid index: {0} is not between 0, {1}"},{name:"UnableToVerifySignature",message:"Unable to verify signature: {0}"},{name:"DustOutputs",message:"Dust amount detected in one output"},{name:"InvalidSatoshis",message:"Output satoshis are invalid"},{name:"FeeError",message:"Internal Error on Fee {0}",errors:[{name:"TooSmall",message:"Fee is too small: {0}"},{name:"TooLarge",message:"Fee is too large: {0}"},{name:"Different",message:"Unspent value is different from specified fee: {0}"}]},{name:"ChangeAddressMissing",message:"Change address is missing"},{name:"BlockHeightTooHigh",message:"Block Height can be at most 2^32 -1"},{name:"NLockTimeOutOfRange",message:"Block Height can only be between 0 and 499 999 999"},{name:"LockTimeTooEarly",message:"Lock Time can't be earlier than UNIX date 500 000 000"}]},{name:"Script",message:"Internal Error on Script {0}",errors:[{name:"UnrecognizedAddress",message:"Expected argument {0} to be an address"},{name:"CantDeriveAddress",message:"Can't derive address associated with script {0}, needs to be p2pkh in, p2pkh out, p2sh in, or p2sh out."},{name:"InvalidBuffer",message:"Invalid script buffer: can't parse valid script from given buffer {0}"}]},{name:"HDPrivateKey",message:"Internal Error on HDPrivateKey {0}",errors:[{name:"InvalidDerivationArgument",message:"Invalid derivation argument {0}, expected string, or number and boolean"},{name:"InvalidEntropyArgument",message:"Invalid entropy: must be an hexa string or binary buffer, got {0}",errors:[{name:"TooMuchEntropy",message:'Invalid entropy: more than 512 bits is non standard, got "{0}"'},{name:"NotEnoughEntropy",message:'Invalid entropy: at least 128 bits needed, got "{0}"'}]},{name:"InvalidLength",message:"Invalid length for xprivkey string in {0}"},{name:"InvalidPath",message:"Invalid derivation path: {0}"},{name:"UnrecognizedArgument",message:'Invalid argument: creating a HDPrivateKey requires a string, buffer, json or object, got "{0}"'}]},{name:"HDPublicKey",message:"Internal Error on HDPublicKey {0}",errors:[{name:"ArgumentIsPrivateExtended",message:"Argument is an extended private key: {0}"},{name:"InvalidDerivationArgument",message:"Invalid derivation argument: got {0}"},{name:"InvalidLength",message:'Invalid length for xpubkey: got "{0}"'},{name:"InvalidPath",message:'Invalid derivation path, it should look like: "m/1/100", got "{0}"'},{name:"InvalidIndexCantDeriveHardened",message:"Invalid argument: creating a hardened path requires an HDPrivateKey"},{name:"MustSupplyArgument",message:"Must supply an argument to create a HDPublicKey"},{name:"UnrecognizedArgument",message:"Invalid argument for creation, must be string, json, buffer, or object"}]}]});var Nm=R((Pk,al)=>{"use strict";w();var nl=Hf();function aS(t,e){return t.replace("{0}",e[0]).replace("{1}",e[1]).replace("{2}",e[2])}var Dm=function(t,e){var r=function(){if(nl.isString(e.message))this.message=aS(e.message,arguments);else if(nl.isFunction(e.message))this.message=e.message.apply(null,arguments);else throw new Error("Invalid error definition for "+e.name);this.stack=this.message+`
|
|
18
18
|
`+new Error().stack};return r.prototype=Object.create(t.prototype),r.prototype.name=t.prototype.name+e.name,t[e.name]=r,e.errors&&Um(r,e.errors),r},Um=function(t,e){nl.each(e,function(r){Dm(t,r)})},oS=function(t,e){return Um(t,e),t},Sn={};Sn.Error=function(){this.message="Internal error",this.stack=this.message+`
|
|
19
|
-
`+new Error().stack};Sn.Error.prototype=Object.create(Error.prototype);Sn.Error.prototype.name="bsv.Error";var fS=Pm();oS(Sn.Error,fS);al.exports=Sn.Error;al.exports.extend=function(t){return Dm(Sn.Error,t)}});var Kf=R((Uk,Lm)=>{"use strict";w();var Ga=Nm(),sS=Hf();Lm.exports={checkState:function(t,e){if(!t)throw new Ga.InvalidState(e)},checkArgument:function(t,e,r,n){if(!t)throw new Ga.InvalidArgument(e,r,n)},checkArgumentType:function(t,e,r){if(r=r||"(unknown name)",sS.isString(e)){if(e==="Buffer"){var n=ft();if(!n.Buffer.isBuffer(t))throw new Ga.InvalidArgumentType(t,e,r)}else if(typeof t!==e)throw new Ga.InvalidArgumentType(t,e,r)}else if(!(t instanceof e))throw new Ga.InvalidArgumentType(t,e.name,r)}}});var Hm=R((Lk,jm)=>{"use strict";w();var Ne=lr(),ol=Kf(),Fm=Hf(),Wf=function(t){for(var e=B.Buffer.alloc(t.length),r=0;r<t.length;r++)e[r]=t[t.length-1-r];return e};Ne.Zero=new Ne(0);Ne.One=new Ne(1);Ne.Minus1=new Ne(-1);Ne.fromNumber=function(t){return ol.checkArgument(Fm.isNumber(t)),new Ne(t)};Ne.fromString=function(t,e){return ol.checkArgument(Fm.isString(t)),new Ne(t,e)};Ne.fromBuffer=function(t,e){typeof e<"u"&&e.endian==="little"&&(t=Wf(t));var r=t.toString("hex"),n=new Ne(r,16);return n};Ne.fromSM=function(t,e){var r;if(t.length===0)return Ne.fromBuffer(B.Buffer.from([0]));var n="big";return e&&(n=e.endian),n==="little"&&(t=Wf(t)),t[0]&128?(t[0]=t[0]&127,r=Ne.fromBuffer(t),r.neg().copy(r)):r=Ne.fromBuffer(t),r};Ne.prototype.toNumber=function(){return parseInt(this.toString(10),10)};Ne.prototype.toBuffer=function(t){var e,r;if(t&&t.size){r=this.toString(16,2);var n=r.length/2;e=B.Buffer.from(r,"hex"),n===t.size||(n>t.size?e=Ne.trim(e,n):n<t.size&&(e=Ne.pad(e,n,t.size)))}else r=this.toString(16,2),e=B.Buffer.from(r,"hex");return typeof t<"u"&&t.endian==="little"&&(e=Wf(e)),e};Ne.prototype.toSMBigEndian=function(){var t;return this.cmp(Ne.Zero)===-1?(t=this.neg().toBuffer(),t[0]&128?t=B.Buffer.concat([B.Buffer.from([128]),t]):t[0]=t[0]|128):(t=this.toBuffer(),t[0]&128&&(t=B.Buffer.concat([B.Buffer.from([0]),t]))),t.length===1&t[0]===0&&(t=B.Buffer.from([])),t};Ne.prototype.toSM=function(t){var e=t?t.endian:"big",r=this.toSMBigEndian();return e==="little"&&(r=Wf(r)),r};Ne.fromScriptNumBuffer=function(t,e,r){var n=r||4;if(ol.checkArgument(t.length<=n,new Error("script number overflow")),e&&t.length>0&&(t[t.length-1]&127)===0&&(t.length<=1||(t[t.length-2]&128)===0))throw new Error("non-minimally encoded script number");return Ne.fromSM(t,{endian:"little"})};Ne.prototype.toScriptNumBuffer=function(){return this.toSM({endian:"little"})};Ne.trim=function(t,e){return t.slice(e-t.length,t.length)};Ne.pad=function(t,e,r){for(var n=B.Buffer.alloc(r),i=0;i<t.length;i++)n[n.length-1-i]=t[t.length-1-i];for(i=0;i<r-e;i++)n[i]=0;return n};Ne.prototype.toHex=function(...t){return this.toBuffer(...t).toString("hex")};Ne.fromHex=function(t,...e){return Ne.fromBuffer(B.Buffer.from(t,"hex"),...e)};jm.exports=Ne});var Ht=R(Ke=>{"use strict";w();var uS=Ot(),hS=J();Ke.inherits=hS;function lS(t,e){return(t.charCodeAt(e)&64512)!==55296||e<0||e+1>=t.length?!1:(t.charCodeAt(e+1)&64512)===56320}function cS(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if(typeof t=="string")if(e){if(e==="hex")for(t=t.replace(/[^a-z0-9]+/ig,""),t.length%2!==0&&(t="0"+t),i=0;i<t.length;i+=2)r.push(parseInt(t[i]+t[i+1],16))}else for(var n=0,i=0;i<t.length;i++){var a=t.charCodeAt(i);a<128?r[n++]=a:a<2048?(r[n++]=a>>6|192,r[n++]=a&63|128):lS(t,i)?(a=65536+((a&1023)<<10)+(t.charCodeAt(++i)&1023),r[n++]=a>>18|240,r[n++]=a>>12&63|128,r[n++]=a>>6&63|128,r[n++]=a&63|128):(r[n++]=a>>12|224,r[n++]=a>>6&63|128,r[n++]=a&63|128)}else for(i=0;i<t.length;i++)r[i]=t[i]|0;return r}Ke.toArray=cS;function dS(t){for(var e="",r=0;r<t.length;r++)e+=Wm(t[r].toString(16));return e}Ke.toHex=dS;function Km(t){var e=t>>>24|t>>>8&65280|t<<8&16711680|(t&255)<<24;return e>>>0}Ke.htonl=Km;function pS(t,e){for(var r="",n=0;n<t.length;n++){var i=t[n];e==="little"&&(i=Km(i)),r+=zm(i.toString(16))}return r}Ke.toHex32=pS;function Wm(t){return t.length===1?"0"+t:t}Ke.zero2=Wm;function zm(t){return t.length===7?"0"+t:t.length===6?"00"+t:t.length===5?"000"+t:t.length===4?"0000"+t:t.length===3?"00000"+t:t.length===2?"000000"+t:t.length===1?"0000000"+t:t}Ke.zero8=zm;function vS(t,e,r,n){var i=r-e;uS(i%4===0);for(var a=new Array(i/4),f=0,v=e;f<a.length;f++,v+=4){var m;n==="big"?m=t[v]<<24|t[v+1]<<16|t[v+2]<<8|t[v+3]:m=t[v+3]<<24|t[v+2]<<16|t[v+1]<<8|t[v],a[f]=m>>>0}return a}Ke.join32=vS;function yS(t,e){for(var r=new Array(t.length*4),n=0,i=0;n<t.length;n++,i+=4){var a=t[n];e==="big"?(r[i]=a>>>24,r[i+1]=a>>>16&255,r[i+2]=a>>>8&255,r[i+3]=a&255):(r[i+3]=a>>>24,r[i+2]=a>>>16&255,r[i+1]=a>>>8&255,r[i]=a&255)}return r}Ke.split32=yS;function gS(t,e){return t>>>e|t<<32-e}Ke.rotr32=gS;function mS(t,e){return t<<e|t>>>32-e}Ke.rotl32=mS;function bS(t,e){return t+e>>>0}Ke.sum32=bS;function wS(t,e,r){return t+e+r>>>0}Ke.sum32_3=wS;function _S(t,e,r,n){return t+e+r+n>>>0}Ke.sum32_4=_S;function xS(t,e,r,n,i){return t+e+r+n+i>>>0}Ke.sum32_5=xS;function MS(t,e,r,n){var i=t[e],a=t[e+1],f=n+a>>>0,v=(f<n?1:0)+r+i;t[e]=v>>>0,t[e+1]=f}Ke.sum64=MS;function ES(t,e,r,n){var i=e+n>>>0,a=(i<e?1:0)+t+r;return a>>>0}Ke.sum64_hi=ES;function SS(t,e,r,n){var i=e+n;return i>>>0}Ke.sum64_lo=SS;function BS(t,e,r,n,i,a,f,v){var m=0,E=e;E=E+n>>>0,m+=E<e?1:0,E=E+a>>>0,m+=E<a?1:0,E=E+v>>>0,m+=E<v?1:0;var A=t+r+i+f+m;return A>>>0}Ke.sum64_4_hi=BS;function AS(t,e,r,n,i,a,f,v){var m=e+n+a+v;return m>>>0}Ke.sum64_4_lo=AS;function RS(t,e,r,n,i,a,f,v,m,E){var A=0,q=e;q=q+n>>>0,A+=q<e?1:0,q=q+a>>>0,A+=q<a?1:0,q=q+v>>>0,A+=q<v?1:0,q=q+E>>>0,A+=q<E?1:0;var I=t+r+i+f+m+A;return I>>>0}Ke.sum64_5_hi=RS;function qS(t,e,r,n,i,a,f,v,m,E){var A=e+n+a+v+E;return A>>>0}Ke.sum64_5_lo=qS;function IS(t,e,r){var n=e<<32-r|t>>>r;return n>>>0}Ke.rotr64_hi=IS;function kS(t,e,r){var n=t<<32-r|e>>>r;return n>>>0}Ke.rotr64_lo=kS;function TS(t,e,r){return t>>>r}Ke.shr64_hi=TS;function CS(t,e,r){var n=t<<32-r|e>>>r;return n>>>0}Ke.shr64_lo=CS});var Bn=R(Vm=>{"use strict";w();var Gm=Ht(),OS=Ot();function zf(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}Vm.BlockHash=zf;zf.prototype.update=function(e,r){if(e=Gm.toArray(e,r),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var n=e.length%this._delta8;this.pending=e.slice(e.length-n,e.length),this.pending.length===0&&(this.pending=null),e=Gm.join32(e,0,e.length-n,this.endian);for(var i=0;i<e.length;i+=this._delta32)this._update(e,i,i+this._delta32)}return this};zf.prototype.digest=function(e){return this.update(this._pad()),OS(this.pending===null),this._digest(e)};zf.prototype._pad=function(){var e=this.pendingTotal,r=this._delta8,n=r-(e+this.padLength)%r,i=new Array(n+this.padLength);i[0]=128;for(var a=1;a<n;a++)i[a]=0;if(e<<=3,this.endian==="big"){for(var f=8;f<this.padLength;f++)i[a++]=0;i[a++]=0,i[a++]=0,i[a++]=0,i[a++]=0,i[a++]=e>>>24&255,i[a++]=e>>>16&255,i[a++]=e>>>8&255,i[a++]=e&255}else for(i[a++]=e&255,i[a++]=e>>>8&255,i[a++]=e>>>16&255,i[a++]=e>>>24&255,i[a++]=0,i[a++]=0,i[a++]=0,i[a++]=0,f=8;f<this.padLength;f++)i[a++]=0;return i}});var fl=R(Sr=>{"use strict";w();var PS=Ht(),rr=PS.rotr32;function DS(t,e,r,n){if(t===0)return $m(e,r,n);if(t===1||t===3)return Ym(e,r,n);if(t===2)return Zm(e,r,n)}Sr.ft_1=DS;function $m(t,e,r){return t&e^~t&r}Sr.ch32=$m;function Zm(t,e,r){return t&e^t&r^e&r}Sr.maj32=Zm;function Ym(t,e,r){return t^e^r}Sr.p32=Ym;function US(t){return rr(t,2)^rr(t,13)^rr(t,22)}Sr.s0_256=US;function NS(t){return rr(t,6)^rr(t,11)^rr(t,25)}Sr.s1_256=NS;function LS(t){return rr(t,7)^rr(t,18)^t>>>3}Sr.g0_256=LS;function FS(t){return rr(t,17)^rr(t,19)^t>>>10}Sr.g1_256=FS});var Qm=R((Vk,Jm)=>{"use strict";w();var An=Ht(),jS=Bn(),HS=fl(),sl=An.rotl32,Va=An.sum32,KS=An.sum32_5,WS=HS.ft_1,Xm=jS.BlockHash,zS=[1518500249,1859775393,2400959708,3395469782];function ir(){if(!(this instanceof ir))return new ir;Xm.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}An.inherits(ir,Xm);Jm.exports=ir;ir.blockSize=512;ir.outSize=160;ir.hmacStrength=80;ir.padLength=64;ir.prototype._update=function(e,r){for(var n=this.W,i=0;i<16;i++)n[i]=e[r+i];for(;i<n.length;i++)n[i]=sl(n[i-3]^n[i-8]^n[i-14]^n[i-16],1);var a=this.h[0],f=this.h[1],v=this.h[2],m=this.h[3],E=this.h[4];for(i=0;i<n.length;i++){var A=~~(i/20),q=KS(sl(a,5),WS(A,f,v,m),E,n[i],zS[A]);E=m,m=v,v=sl(f,30),f=a,a=q}this.h[0]=Va(this.h[0],a),this.h[1]=Va(this.h[1],f),this.h[2]=Va(this.h[2],v),this.h[3]=Va(this.h[3],m),this.h[4]=Va(this.h[4],E)};ir.prototype._digest=function(e){return e==="hex"?An.toHex32(this.h,"big"):An.split32(this.h,"big")}});var ul=R((Zk,tb)=>{"use strict";w();var Rn=Ht(),GS=Bn(),qn=fl(),VS=Ot(),Kt=Rn.sum32,$S=Rn.sum32_4,ZS=Rn.sum32_5,YS=qn.ch32,XS=qn.maj32,JS=qn.s0_256,QS=qn.s1_256,eB=qn.g0_256,tB=qn.g1_256,eb=GS.BlockHash,rB=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function nr(){if(!(this instanceof nr))return new nr;eb.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=rB,this.W=new Array(64)}Rn.inherits(nr,eb);tb.exports=nr;nr.blockSize=512;nr.outSize=256;nr.hmacStrength=192;nr.padLength=64;nr.prototype._update=function(e,r){for(var n=this.W,i=0;i<16;i++)n[i]=e[r+i];for(;i<n.length;i++)n[i]=$S(tB(n[i-2]),n[i-7],eB(n[i-15]),n[i-16]);var a=this.h[0],f=this.h[1],v=this.h[2],m=this.h[3],E=this.h[4],A=this.h[5],q=this.h[6],I=this.h[7];for(VS(this.k.length===n.length),i=0;i<n.length;i++){var C=ZS(I,QS(E),YS(E,A,q),this.k[i],n[i]),j=Kt(JS(a),XS(a,f,v));I=q,q=A,A=E,E=Kt(m,C),m=v,v=f,f=a,a=Kt(C,j)}this.h[0]=Kt(this.h[0],a),this.h[1]=Kt(this.h[1],f),this.h[2]=Kt(this.h[2],v),this.h[3]=Kt(this.h[3],m),this.h[4]=Kt(this.h[4],E),this.h[5]=Kt(this.h[5],A),this.h[6]=Kt(this.h[6],q),this.h[7]=Kt(this.h[7],I)};nr.prototype._digest=function(e){return e==="hex"?Rn.toHex32(this.h,"big"):Rn.split32(this.h,"big")}});var nb=R((Xk,ib)=>{"use strict";w();var hl=Ht(),rb=ul();function Br(){if(!(this instanceof Br))return new Br;rb.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}hl.inherits(Br,rb);ib.exports=Br;Br.blockSize=512;Br.outSize=224;Br.hmacStrength=192;Br.padLength=64;Br.prototype._digest=function(e){return e==="hex"?hl.toHex32(this.h.slice(0,7),"big"):hl.split32(this.h.slice(0,7),"big")}});var dl=R((Qk,sb)=>{"use strict";w();var mt=Ht(),iB=Bn(),nB=Ot(),ar=mt.rotr64_hi,or=mt.rotr64_lo,ab=mt.shr64_hi,ob=mt.shr64_lo,jr=mt.sum64,ll=mt.sum64_hi,cl=mt.sum64_lo,aB=mt.sum64_4_hi,oB=mt.sum64_4_lo,fB=mt.sum64_5_hi,sB=mt.sum64_5_lo,fb=iB.BlockHash,uB=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Wt(){if(!(this instanceof Wt))return new Wt;fb.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=uB,this.W=new Array(160)}mt.inherits(Wt,fb);sb.exports=Wt;Wt.blockSize=1024;Wt.outSize=512;Wt.hmacStrength=192;Wt.padLength=128;Wt.prototype._prepareBlock=function(e,r){for(var n=this.W,i=0;i<32;i++)n[i]=e[r+i];for(;i<n.length;i+=2){var a=wB(n[i-4],n[i-3]),f=_B(n[i-4],n[i-3]),v=n[i-14],m=n[i-13],E=mB(n[i-30],n[i-29]),A=bB(n[i-30],n[i-29]),q=n[i-32],I=n[i-31];n[i]=aB(a,f,v,m,E,A,q,I),n[i+1]=oB(a,f,v,m,E,A,q,I)}};Wt.prototype._update=function(e,r){this._prepareBlock(e,r);var n=this.W,i=this.h[0],a=this.h[1],f=this.h[2],v=this.h[3],m=this.h[4],E=this.h[5],A=this.h[6],q=this.h[7],I=this.h[8],C=this.h[9],j=this.h[10],V=this.h[11],X=this.h[12],z=this.h[13],$=this.h[14],Fe=this.h[15];nB(this.k.length===n.length);for(var k=0;k<n.length;k+=2){var O=$,D=Fe,L=yB(I,C),F=gB(I,C),H=hB(I,C,j,V,X,z),M=lB(I,C,j,V,X,z),h=this.k[k],y=this.k[k+1],l=n[k],o=n[k+1],s=fB(O,D,L,F,H,M,h,y,l,o),d=sB(O,D,L,F,H,M,h,y,l,o);O=pB(i,a),D=vB(i,a),L=cB(i,a,f,v,m,E),F=dB(i,a,f,v,m,E);var g=ll(O,D,L,F),p=cl(O,D,L,F);$=X,Fe=z,X=j,z=V,j=I,V=C,I=ll(A,q,s,d),C=cl(q,q,s,d),A=m,q=E,m=f,E=v,f=i,v=a,i=ll(s,d,g,p),a=cl(s,d,g,p)}jr(this.h,0,i,a),jr(this.h,2,f,v),jr(this.h,4,m,E),jr(this.h,6,A,q),jr(this.h,8,I,C),jr(this.h,10,j,V),jr(this.h,12,X,z),jr(this.h,14,$,Fe)};Wt.prototype._digest=function(e){return e==="hex"?mt.toHex32(this.h,"big"):mt.split32(this.h,"big")};function hB(t,e,r,n,i){var a=t&r^~t&i;return a<0&&(a+=4294967296),a}function lB(t,e,r,n,i,a){var f=e&n^~e&a;return f<0&&(f+=4294967296),f}function cB(t,e,r,n,i){var a=t&r^t&i^r&i;return a<0&&(a+=4294967296),a}function dB(t,e,r,n,i,a){var f=e&n^e&a^n&a;return f<0&&(f+=4294967296),f}function pB(t,e){var r=ar(t,e,28),n=ar(e,t,2),i=ar(e,t,7),a=r^n^i;return a<0&&(a+=4294967296),a}function vB(t,e){var r=or(t,e,28),n=or(e,t,2),i=or(e,t,7),a=r^n^i;return a<0&&(a+=4294967296),a}function yB(t,e){var r=ar(t,e,14),n=ar(t,e,18),i=ar(e,t,9),a=r^n^i;return a<0&&(a+=4294967296),a}function gB(t,e){var r=or(t,e,14),n=or(t,e,18),i=or(e,t,9),a=r^n^i;return a<0&&(a+=4294967296),a}function mB(t,e){var r=ar(t,e,1),n=ar(t,e,8),i=ab(t,e,7),a=r^n^i;return a<0&&(a+=4294967296),a}function bB(t,e){var r=or(t,e,1),n=or(t,e,8),i=ob(t,e,7),a=r^n^i;return a<0&&(a+=4294967296),a}function wB(t,e){var r=ar(t,e,19),n=ar(e,t,29),i=ab(t,e,6),a=r^n^i;return a<0&&(a+=4294967296),a}function _B(t,e){var r=or(t,e,19),n=or(e,t,29),i=ob(t,e,6),a=r^n^i;return a<0&&(a+=4294967296),a}});var lb=R((tT,hb)=>{"use strict";w();var pl=Ht(),ub=dl();function Ar(){if(!(this instanceof Ar))return new Ar;ub.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}pl.inherits(Ar,ub);hb.exports=Ar;Ar.blockSize=1024;Ar.outSize=384;Ar.hmacStrength=192;Ar.padLength=128;Ar.prototype._digest=function(e){return e==="hex"?pl.toHex32(this.h.slice(0,12),"big"):pl.split32(this.h.slice(0,12),"big")}});var cb=R(In=>{"use strict";w();In.sha1=Qm();In.sha224=nb();In.sha256=ul();In.sha384=lb();In.sha512=dl()});var mb=R(gb=>{"use strict";w();var Di=Ht(),xB=Bn(),Gf=Di.rotl32,db=Di.sum32,$a=Di.sum32_3,pb=Di.sum32_4,yb=xB.BlockHash;function fr(){if(!(this instanceof fr))return new fr;yb.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}Di.inherits(fr,yb);gb.ripemd160=fr;fr.blockSize=512;fr.outSize=160;fr.hmacStrength=192;fr.padLength=64;fr.prototype._update=function(e,r){for(var n=this.h[0],i=this.h[1],a=this.h[2],f=this.h[3],v=this.h[4],m=n,E=i,A=a,q=f,I=v,C=0;C<80;C++){var j=db(Gf(pb(n,vb(C,i,a,f),e[SB[C]+r],MB(C)),AB[C]),v);n=v,v=f,f=Gf(a,10),a=i,i=j,j=db(Gf(pb(m,vb(79-C,E,A,q),e[BB[C]+r],EB(C)),RB[C]),I),m=I,I=q,q=Gf(A,10),A=E,E=j}j=$a(this.h[1],a,q),this.h[1]=$a(this.h[2],f,I),this.h[2]=$a(this.h[3],v,m),this.h[3]=$a(this.h[4],n,E),this.h[4]=$a(this.h[0],i,A),this.h[0]=j};fr.prototype._digest=function(e){return e==="hex"?Di.toHex32(this.h,"little"):Di.split32(this.h,"little")};function vb(t,e,r,n){return t<=15?e^r^n:t<=31?e&r|~e&n:t<=47?(e|~r)^n:t<=63?e&n|r&~n:e^(r|~n)}function MB(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function EB(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}var SB=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],BB=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],AB=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],RB=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]});var wb=R((fT,bb)=>{"use strict";w();var qB=Ht(),IB=Ot();function kn(t,e,r){if(!(this instanceof kn))return new kn(t,e,r);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(qB.toArray(e,r))}bb.exports=kn;kn.prototype._init=function(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),IB(e.length<=this.blockSize);for(var r=e.length;r<this.blockSize;r++)e.push(0);for(r=0;r<e.length;r++)e[r]^=54;for(this.inner=new this.Hash().update(e),r=0;r<e.length;r++)e[r]^=106;this.outer=new this.Hash().update(e)};kn.prototype.update=function(e,r){return this.inner.update(e,r),this};kn.prototype.digest=function(e){return this.outer.update(this.inner.digest()),this.outer.digest(e)}});var xb=R(_b=>{w();var ot=_b;ot.utils=Ht();ot.common=Bn();ot.sha=cb();ot.ripemd=mb();ot.hmac=wb();ot.sha1=ot.sha.sha1;ot.sha256=ot.sha.sha256;ot.sha224=ot.sha.sha224;ot.sha384=ot.sha.sha384;ot.sha512=ot.sha.sha512;ot.ripemd160=ot.ripemd.ripemd160});var Eb=R((lT,Mb)=>{"use strict";w();var Vf=xb(),Rr=Kf(),Je=Mb.exports;Je.sha1=function(t){return Rr.checkArgument(B.Buffer.isBuffer(t)),B.Buffer.from(Vf.sha1().update(t).digest("hex"),"hex")};Je.sha1.blocksize=512;Je.sha256=function(t){return Rr.checkArgument(B.Buffer.isBuffer(t)),B.Buffer.from(Vf.sha256().update(t).digest("hex"),"hex")};Je.sha256.blocksize=512;Je.sha256sha256=function(t){return Rr.checkArgument(B.Buffer.isBuffer(t)),Je.sha256(Je.sha256(t))};Je.ripemd160=function(t){return Rr.checkArgument(B.Buffer.isBuffer(t)),B.Buffer.from(Vf.ripemd160().update(t).digest("hex"),"hex")};Je.sha256ripemd160=function(t){return Rr.checkArgument(B.Buffer.isBuffer(t)),Je.ripemd160(Je.sha256(t))};Je.sha512=function(t){return Rr.checkArgument(B.Buffer.isBuffer(t)),B.Buffer.from(Vf.sha512().update(t).digest("hex"),"hex")};Je.sha512.blocksize=1024;Je.hmac=function(t,e,r){Rr.checkArgument(B.Buffer.isBuffer(e)),Rr.checkArgument(B.Buffer.isBuffer(r)),Rr.checkArgument(t.blocksize);var n=t.blocksize/8;if(r.length>n)r=t(r);else if(r<n){var i=B.Buffer.alloc(n);i.fill(0),r.copy(i),r=i}var a=B.Buffer.alloc(n);a.fill(92);var f=B.Buffer.alloc(n);f.fill(54);for(var v=B.Buffer.alloc(n),m=B.Buffer.alloc(n),E=0;E<n;E++)v[E]=a[E]^r[E],m[E]=f[E]^r[E];return t(B.Buffer.concat([v,t(B.Buffer.concat([m,e]))]))};Je.sha256hmac=function(t,e){return Je.hmac(Je.sha256,t,e)};Je.sha512hmac=function(t,e){return Je.hmac(Je.sha512,t,e)}});var Bb=R((dT,Sb)=>{"use strict";w();var $f=ja(),qr=Kf(),Qe=Sb.exports;Qe.sha1=function(t){return qr.checkArgument(B.Buffer.isBuffer(t)),$f.createHash("sha1").update(t).digest()};Qe.sha1.blocksize=512;Qe.sha256=function(t){return qr.checkArgument(B.Buffer.isBuffer(t)),$f.createHash("sha256").update(t).digest()};Qe.sha256.blocksize=512;Qe.sha256sha256=function(t){return qr.checkArgument(B.Buffer.isBuffer(t)),Qe.sha256(Qe.sha256(t))};Qe.ripemd160=function(t){return qr.checkArgument(B.Buffer.isBuffer(t)),$f.createHash("ripemd160").update(t).digest()};Qe.sha256ripemd160=function(t){return qr.checkArgument(B.Buffer.isBuffer(t)),Qe.ripemd160(Qe.sha256(t))};Qe.sha512=function(t){return qr.checkArgument(B.Buffer.isBuffer(t)),$f.createHash("sha512").update(t).digest()};Qe.sha512.blocksize=1024;Qe.hmac=function(t,e,r){qr.checkArgument(B.Buffer.isBuffer(e)),qr.checkArgument(B.Buffer.isBuffer(r)),qr.checkArgument(t.blocksize);var n=t.blocksize/8;if(r.length>n)r=t(r);else if(r<n){var i=B.Buffer.alloc(n);i.fill(0),r.copy(i),r=i}var a=B.Buffer.alloc(n);a.fill(92);var f=B.Buffer.alloc(n);f.fill(54);for(var v=B.Buffer.alloc(n),m=B.Buffer.alloc(n),E=0;E<n;E++)v[E]=a[E]^r[E],m[E]=f[E]^r[E];return t(B.Buffer.concat([v,t(B.Buffer.concat([m,e]))]))};Qe.sha256hmac=function(t,e){return Qe.hmac(Qe.sha256,t,e)};Qe.sha512hmac=function(t,e){return Qe.hmac(Qe.sha512,t,e)}});var Ab=R((vT,vl)=>{w();S.default.browser?vl.exports=Eb():vl.exports=Bb()});var qb=R((yl,Rb)=>{w();(function(t,e){"use strict";typeof define=="function"&&define.amd?define([],function(){return t.secrets=e()}):typeof yl=="object"?Rb.exports=e(ja()):t.secrets=e(t.crypto)})(yl,function(t){"use strict";var e,r,n,i,a;function f(){e={bits:8,radix:16,minBits:3,maxBits:20,bytesPerChar:2,maxBytesPerChar:6,primitivePolynomials:[null,null,1,3,3,5,3,3,29,17,9,5,83,27,43,3,45,9,39,39,9,5,3,33,27,9,71,39,9,5,83]},r={},n=new Array(1024).join("0"),i=!0,a=["nodeCryptoRandomBytes","browserCryptoGetRandomValues","testRandom"]}function v(){return!!(r&&r.rng&&typeof r.rng=="function")}function m(k,O){var D;if(O===0||O===1)return k;if(O&&O>1024)throw new Error("Padding must be multiples of no larger than 1024 bits.");return O=O||r.bits,k&&(D=k.length%O),D?(n+k).slice(-(O-D+k.length)):k}function E(k){var O="",D,L;for(L=k.length-1;L>=0;L--){if(D=parseInt(k[L],16),isNaN(D))throw new Error("Invalid hex character.");O=m(D.toString(2),4)+O}return O}function A(k){var O="",D,L;for(k=m(k,4),L=k.length;L>=4;L-=4){if(D=parseInt(k.slice(L-4,L),2),isNaN(D))throw new Error("Invalid binary character.");O=D.toString(16)+O}return O}function q(){return!!(t&&typeof t=="object"&&(typeof t.getRandomValues=="function"||typeof t.getRandomValues=="object")&&(typeof Uint32Array=="function"||typeof Uint32Array=="object"))}function I(){return typeof t=="object"&&typeof t.randomBytes=="function"}function C(k){function O(H,M,h,y){var l=0,o,s="",d;for(M&&(o=M.length-1);l<o||s.length<H;)d=Math.abs(parseInt(M[l],h)),s=s+m(d.toString(2),y),l++;return s=s.substr(-H),(s.match(/0/g)||[]).length===s.length?null:s}function D(H){var M,h,y,l,o=null;for(y=16,l=4,h=Math.ceil(H/8);o===null;)M=t.randomBytes(h),o=O(H,M.toString("hex"),y,l);return o}function L(H){var M,h,y,l=null;for(h=10,y=32,M=Math.ceil(H/32);l===null;)l=O(H,t.getRandomValues(new Uint32Array(M)),h,y);return l}function F(H){var M,h,y,l,o,s=null;l=10,o=32,h=Math.ceil(H/32),y=123456789,M=new Uint32Array(h);for(var d=0;d<M.length;d++)M[d]=y;for(;s===null;)s=O(H,M,l,o);return s}if(k&&k==="testRandom")return r.typeCSPRNG=k,F;if(k&&k==="nodeCryptoRandomBytes")return r.typeCSPRNG=k,D;if(k&&k==="browserCryptoGetRandomValues")return r.typeCSPRNG=k,L;if(I())return r.typeCSPRNG="nodeCryptoRandomBytes",D;if(q())return r.typeCSPRNG="browserCryptoGetRandomValues",L}function j(k,O){var D=[],L;for(O&&(k=m(k,O)),L=k.length;L>r.bits;L-=r.bits)D.push(parseInt(k.slice(L-r.bits,L),2));return D.push(parseInt(k.slice(0,L),2)),D}function V(k,O){var D=r.logs[k],L=0,F;for(F=O.length-1;F>=0;F--)L!==0?L=r.exps[(D+r.logs[L])%r.maxShares]^O[F]:L=O[F];return L}function X(k,O,D){var L=0,F,H,M,h;for(M=0,F=O.length;M<F;M++)if(D[M]){for(H=r.logs[D[M]],h=0;h<F;h++)if(M!==h){if(k===O[h]){H=-1;break}H=(H+r.logs[k^O[h]]-r.logs[O[M]^O[h]]+r.maxShares)%r.maxShares}L=H===-1?L:L^r.exps[H]}return L}function z(k,O,D){var L=[],F=[k],H,M;for(H=1;H<D;H++)F[H]=parseInt(r.rng(r.bits),2);for(H=1,M=O+1;H<M;H++)L[H-1]={x:H,y:V(H,F)};return L}function $(k,O,D){var L,F,H,M,h;if(O=parseInt(O,r.radix),k=parseInt(k,10)||r.bits,L=k.toString(36).toUpperCase(),H=Math.pow(2,k)-1,M=H.toString(r.radix).length,F=m(O.toString(r.radix),M),typeof O!="number"||O%1!==0||O<1||O>H)throw new Error("Share id must be an integer between 1 and "+H+", inclusive.");return h=L+F+D,h}var Fe={init:function(k,O){var D=[],L=[],F=1,H,M;if(f(),k&&(typeof k!="number"||k%1!==0||k<e.minBits||k>e.maxBits))throw new Error("Number of bits must be an integer between "+e.minBits+" and "+e.maxBits+", inclusive.");if(O&&a.indexOf(O)===-1)throw new Error("Invalid RNG type argument : '"+O+"'");for(r.radix=e.radix,r.bits=k||e.bits,r.size=Math.pow(2,r.bits),r.maxShares=r.size-1,H=e.primitivePolynomials[r.bits],M=0;M<r.size;M++)L[M]=F,D[F]=M,F=F<<1,F>=r.size&&(F=F^H,F=F&r.maxShares);if(r.logs=D,r.exps=L,O&&this.setRNG(O),v()||this.setRNG(),!v()||!r.bits||!r.size||!r.maxShares||!r.logs||!r.exps||r.logs.length!==r.size||r.exps.length!==r.size)throw new Error("Initialization failed.")},combine:function(k,O){var D,L,F,H,M="",h,y,l,o=[],s=[];for(O=O||0,D=0,F=k.length;D<F;D++){if(y=this.extractShareComponents(k[D]),h===void 0)h=y.bits;else if(y.bits!==h)throw new Error("Mismatched shares: Different bit settings.");if(r.bits!==h&&this.init(h),o.indexOf(y.id)===-1)for(o.push(y.id),l=j(E(y.data)),L=0,H=l.length;L<H;L++)s[L]=s[L]||[],s[L][o.length-1]=l[L]}for(D=0,F=s.length;D<F;D++)M=m(X(O,o,s[D]).toString(2))+M;return A(O>=1?M:M.slice(M.indexOf("1")+1))},getConfig:function(){var k={};return k.radix=r.radix,k.bits=r.bits,k.maxShares=r.maxShares,k.hasCSPRNG=v(),k.typeCSPRNG=r.typeCSPRNG,k},extractShareComponents:function(k){var O,D,L,F,H={},M,h;if(O=parseInt(k.substr(0,1),36),O&&(typeof O!="number"||O%1!==0||O<e.minBits||O>e.maxBits))throw new Error("Invalid share : Number of bits must be an integer between "+e.minBits+" and "+e.maxBits+", inclusive.");if(F=Math.pow(2,O)-1,L=(Math.pow(2,O)-1).toString(r.radix).length,M="^([a-kA-K3-9]{1})([a-fA-F0-9]{"+L+"})([a-fA-F0-9]+)$",h=new RegExp(M).exec(k),h&&(D=parseInt(h[2],r.radix)),typeof D!="number"||D%1!==0||D<1||D>F)throw new Error("Invalid share : Share id must be an integer between 1 and "+r.maxShares+", inclusive.");if(h&&h[3])return H.bits=O,H.id=D,H.data=h[3],H;throw new Error("The share data provided is invalid : "+k)},setRNG:function(k){var O="Random number generator is invalid ",D=" Supply an CSPRNG of the form function(bits){} that returns a string containing 'bits' number of random 1's and 0's.";if(k&&typeof k=="string"&&a.indexOf(k)===-1)throw new Error("Invalid RNG type argument : '"+k+"'");if(k||(k=C()),k&&typeof k=="string"&&(k=C(k)),i){if(k&&typeof k!="function")throw new Error(O+"(Not a function)."+D);if(k&&typeof k(r.bits)!="string")throw new Error(O+"(Output is not a string)."+D);if(k&&!parseInt(k(r.bits),2))throw new Error(O+"(Binary string output not parseable to an Integer)."+D);if(k&&k(r.bits).length>r.bits)throw new Error(O+"(Output length is greater than config.bits)."+D);if(k&&k(r.bits).length<r.bits)throw new Error(O+"(Output length is less than config.bits)."+D)}return r.rng=k,!0},str2hex:function(k,O){var D,L,F="",H,M,h,y;if(typeof k!="string")throw new Error("Input must be a character string.");if(O||(O=e.bytesPerChar),typeof O!="number"||O<1||O>e.maxBytesPerChar||O%1!==0)throw new Error("Bytes per character must be an integer between 1 and "+e.maxBytesPerChar+", inclusive.");for(D=2*O,L=Math.pow(16,D)-1,h=0,y=k.length;h<y;h++){if(M=k[h].charCodeAt(),isNaN(M))throw new Error("Invalid character: "+k[h]);if(M>L)throw H=Math.ceil(Math.log(M+1)/Math.log(256)),new Error("Invalid character code ("+M+"). Maximum allowable is 256^bytes-1 ("+L+"). To convert this character, use at least "+H+" bytes.");F=m(M.toString(16),D)+F}return F},hex2str:function(k,O){var D,L="",F,H;if(typeof k!="string")throw new Error("Input must be a hexadecimal string.");if(O=O||e.bytesPerChar,typeof O!="number"||O%1!==0||O<1||O>e.maxBytesPerChar)throw new Error("Bytes per character must be an integer between 1 and "+e.maxBytesPerChar+", inclusive.");for(D=2*O,k=m(k,D),F=0,H=k.length;F<H;F+=D)L=String.fromCharCode(parseInt(k.slice(F,F+D),16))+L;return L},random:function(k){if(typeof k!="number"||k%1!==0||k<2||k>65536)throw new Error("Number of bits must be an Integer between 1 and 65536.");return A(r.rng(k))},share:function(k,O,D,L){var F,H,M=new Array(O),h=new Array(O),y,l,o;if(L=L||128,typeof k!="string")throw new Error("Secret must be a string.");if(typeof O!="number"||O%1!==0||O<2)throw new Error("Number of shares must be an integer between 2 and 2^bits-1 ("+r.maxShares+"), inclusive.");if(O>r.maxShares)throw F=Math.ceil(Math.log(O+1)/Math.LN2),new Error("Number of shares must be an integer between 2 and 2^bits-1 ("+r.maxShares+"), inclusive. To create "+O+" shares, use at least "+F+" bits.");if(typeof D!="number"||D%1!==0||D<2)throw new Error("Threshold number of shares must be an integer between 2 and 2^bits-1 ("+r.maxShares+"), inclusive.");if(D>r.maxShares)throw F=Math.ceil(Math.log(D+1)/Math.LN2),new Error("Threshold number of shares must be an integer between 2 and 2^bits-1 ("+r.maxShares+"), inclusive. To use a threshold of "+D+", use at least "+F+" bits.");if(D>O)throw new Error("Threshold number of shares was "+D+" but must be less than or equal to the "+O+" shares specified as the total to generate.");if(typeof L!="number"||L%1!==0||L<0||L>1024)throw new Error("Zero-pad length must be an integer between 0 and 1024 inclusive.");for(k="1"+E(k),k=j(k,L),y=0,o=k.length;y<o;y++)for(H=z(k[y],O,D),l=0;l<O;l++)M[l]=M[l]||H[l].x.toString(r.radix),h[l]=m(H[l].y.toString(2))+(h[l]||"");for(y=0;y<O;y++)M[y]=$(r.bits,M[y],A(h[y]));return M},newShare:function(k,O){var D,L;if(k&&typeof k=="string"&&(k=parseInt(k,r.radix)),L=k.toString(r.radix),k&&L&&O&&O[0])return D=this.extractShareComponents(O[0]),$(D.bits,L,this.combine(O,k));throw new Error("Invalid 'id' or 'shares' Array argument to newShare().")},_reset:f,_padLeft:m,_hex2bin:E,_bin2hex:A,_hasCryptoGetRandomValues:q,_hasCryptoRandomBytes:I,_getRNG:C,_isSetRNG:v,_splitNumStringToIntArray:j,_horner:V,_lagrange:X,_getShares:z,_constructPublicShareString:$};return Fe.init(),Fe})});var Ob=R((mT,Cb)=>{"use strict";w();var dt=Hm(),Ib=il(),kb=Ab(),Zf=null;function gl(){if(Zf)return Zf;var t=qb();return t.setRNG(function(e){for(var r=64,n=0;n<r;n++){for(var i=Ib.getRandomBuffer(Math.ceil(e/8)),a="",f=0;f<i.length;f++)a+=("00000000"+i[f].toString(2)).slice(-8);if(a=a.slice(0,e),/1/.test(a))return a}throw new Error("shamir: CSPRNG returned all-zero draws "+r+" times in a row \u2014 refusing to hang on a degenerate/stubbed random source")}),Zf=t,Zf}var Yf="ff",Tb=2;function et(t){return this instanceof et?(this.options=t||{},this):new et(t)}et.split=function(t,e,r,n){if(n=n||{},t==null)throw new Error("Secret is required");if(e<2)throw new Error("Threshold must be at least 2");if(r<e)throw new Error("Number of shares must be at least threshold");if(e>255||r>255)throw new Error("Threshold and shares must be <= 255");for(var i=B.Buffer.isBuffer(t)?t:B.Buffer.from(t,"utf8"),a=Yf+i.toString("hex"),f=gl().share(a,r,e),v=Ib.getRandomBuffer(8).toString("hex"),m=n.checksum===!0,E=m?kb.sha256(i).slice(0,4).toString("hex"):null,A=[],q=0;q<f.length;q++)A.push({v:Tb,id:q+1,threshold:e,shares:r,length:i.length,splitId:v,share:f[q],checksum:E});return A};et.combine=function(t){if(!t||t.length===0)throw new Error("Shares array is required");if(t[0]&&Array.isArray(t[0].bytes)&&t[0].share===void 0)return et._combineLegacy(t);var e=t[0].threshold,r=t[0].splitId;if(t.length<e)throw new Error("Insufficient shares: need "+e+", got "+t.length);for(var n=[],i=0;i<t.length;i++){var a=t[i];if(!a||typeof a.share!="string")throw new Error("Invalid share at index "+i);if(r!==void 0&&a.splitId!==r)throw new Error("Shares are from different splits (splitId mismatch)");if(a.threshold!==e)throw new Error("Shares have inconsistent threshold");n.push(a.share)}var f=gl().combine(n);if(f.slice(0,Yf.length)!==Yf)throw new Error("Reconstruction failed: invalid or insufficient shares");var v=B.Buffer.from(f.slice(Yf.length),"hex"),m=t[0].checksum;if(m){var E=kb.sha256(v).slice(0,4).toString("hex");if(E!==m)throw new Error("Integrity check failed: shares are inconsistent or tampered")}return v};et.verifyShare=function(t){try{return!t||typeof t!="object"?!1:Array.isArray(t.bytes)&&t.share===void 0?et._verifyLegacyShare(t):t.v!==Tb||typeof t.share!="string"||!/^[0-9a-fA-F]+$/.test(t.share)||typeof t.threshold!="number"||typeof t.shares!="number"||t.threshold<2||t.shares<t.threshold||t.shares>255||t.id<1||t.id>t.shares||t.checksum!==null&&t.checksum!==void 0&&!/^[0-9a-fA-F]{8}$/.test(t.checksum)?!1:(gl().extractShareComponents(t.share),!0)}catch{return!1}};et.generateTestVectors=function(){var t="Hello, Bitcoin SV!",e=3,r=5,n=et.split(t,e,r),i=et.combine(n.slice(0,e));return{secret:t,threshold:e,totalShares:r,shares:n,reconstructed:i.toString("utf8"),valid:i.toString("utf8")===t}};var Hr=new dt(2147483647);et._combineLegacy=function(t){var e=t[0].threshold,r=t[0].shares,n=t[0].length;if(t.length<e)throw new Error("Insufficient shares: need "+e+", got "+t.length);for(var i=0;i<t.length;i++){if(t[i].threshold!==e||t[i].shares!==r)throw new Error("Shares have inconsistent parameters");if(t[i].length!==n)throw new Error("Shares have different secret lengths")}for(var a=[],f=0;f<n;f++){for(var v=[],m=0;m<Math.min(t.length,e);m++)v.push(t[m].bytes[f]);a.push(et._combineByteLegacy(v))}return B.Buffer.from(a)};et._combineByteLegacy=function(t){for(var e=new dt(0),r=0;r<t.length;r++){for(var n=new dt(t[r].x),i=new dt(t[r].y,16),a=new dt(1),f=new dt(1),v=0;v<t.length;v++)if(r!==v){var m=new dt(t[v].x),E=new dt(0).sub(m);E.lt(new dt(0))&&(E=E.add(Hr)),a=a.mul(E).mod(Hr);var A=n.sub(m);A.lt(new dt(0))&&(A=A.add(Hr)),f=f.mul(A).mod(Hr)}var q=et._modInverseLegacy(f,Hr),I=a.mul(q).mod(Hr);e=e.add(i.mul(I)).mod(Hr)}return e.mod(Hr).mod(new dt(256)).toNumber()};et._modInverseLegacy=function(t,e){t.lt(new dt(0))&&(t=t.mod(e).add(e));var r=et._extendedGCDLegacy(t,e);if(!r.gcd.eq(new dt(1)))throw new Error("Modular inverse does not exist");return r.x.mod(e).add(e).mod(e)};et._extendedGCDLegacy=function(t,e){if(t.eq(new dt(0)))return{gcd:e,x:new dt(0),y:new dt(1)};var r=et._extendedGCDLegacy(e.mod(t),t);return{gcd:r.gcd,x:r.y.sub(e.div(t).mul(r.x)),y:r.x}};et._verifyLegacyShare=function(t){if(!t.id||!t.threshold||!t.shares||!t.bytes||typeof t.length!="number"||t.threshold<2||t.shares<t.threshold||!Array.isArray(t.bytes)||t.bytes.length!==t.length)return!1;for(var e=0;e<t.bytes.length;e++){var r=t.bytes[e];if(!r||!r.x||!r.y||r.x<1||r.x>t.shares||!/^[0-9a-fA-F]+$/.test(r.y))return!1}return!0};Cb.exports=et});var kB=R((wT,Pb)=>{w();Pb.exports=Ob()});return kB();})();
|
|
19
|
+
`+new Error().stack};Sn.Error.prototype=Object.create(Error.prototype);Sn.Error.prototype.name="bsv.Error";var fS=Pm();oS(Sn.Error,fS);al.exports=Sn.Error;al.exports.extend=function(t){return Dm(Sn.Error,t)}});var Kf=R((Uk,Lm)=>{"use strict";w();var Ga=Nm(),sS=Hf();Lm.exports={checkState:function(t,e){if(!t)throw new Ga.InvalidState(e)},checkArgument:function(t,e,r,n){if(!t)throw new Ga.InvalidArgument(e,r,n)},checkArgumentType:function(t,e,r){if(r=r||"(unknown name)",sS.isString(e)){if(e==="Buffer"){var n=ft();if(!n.Buffer.isBuffer(t))throw new Ga.InvalidArgumentType(t,e,r)}else if(typeof t!==e)throw new Ga.InvalidArgumentType(t,e,r)}else if(!(t instanceof e))throw new Ga.InvalidArgumentType(t,e.name,r)}}});var Hm=R((Lk,jm)=>{"use strict";w();var Ne=lr(),ol=Kf(),Fm=Hf(),Wf=function(t){for(var e=B.Buffer.alloc(t.length),r=0;r<t.length;r++)e[r]=t[t.length-1-r];return e};Ne.Zero=new Ne(0);Ne.One=new Ne(1);Ne.Minus1=new Ne(-1);Ne.fromNumber=function(t){return ol.checkArgument(Fm.isNumber(t)),new Ne(t)};Ne.fromString=function(t,e){return ol.checkArgument(Fm.isString(t)),new Ne(t,e)};Ne.fromBuffer=function(t,e){typeof e<"u"&&e.endian==="little"&&(t=Wf(t));var r=t.toString("hex"),n=new Ne(r,16);return n};Ne.fromSM=function(t,e){var r;if(t.length===0)return Ne.fromBuffer(B.Buffer.from([0]));var n="big";return e&&(n=e.endian),n==="little"&&(t=Wf(t)),t[0]&128?(t[0]=t[0]&127,r=Ne.fromBuffer(t),r.neg().copy(r)):r=Ne.fromBuffer(t),r};Ne.prototype.toNumber=function(){return parseInt(this.toString(10),10)};Ne.prototype.toBuffer=function(t){var e,r;if(t&&t.size){r=this.toString(16,2);var n=r.length/2;e=B.Buffer.from(r,"hex"),n===t.size||(n>t.size?e=Ne.trim(e,n):n<t.size&&(e=Ne.pad(e,n,t.size)))}else r=this.toString(16,2),e=B.Buffer.from(r,"hex");return typeof t<"u"&&t.endian==="little"&&(e=Wf(e)),e};Ne.prototype.toSMBigEndian=function(){var t;return this.cmp(Ne.Zero)===-1?(t=this.neg().toBuffer(),t[0]&128?t=B.Buffer.concat([B.Buffer.from([128]),t]):t[0]=t[0]|128):(t=this.toBuffer(),t[0]&128&&(t=B.Buffer.concat([B.Buffer.from([0]),t]))),t.length===1&&t[0]===0&&(t=B.Buffer.from([])),t};Ne.prototype.toSM=function(t){var e=t?t.endian:"big",r=this.toSMBigEndian();return e==="little"&&(r=Wf(r)),r};Ne.fromScriptNumBuffer=function(t,e,r){var n=r||4;if(ol.checkArgument(t.length<=n,new Error("script number overflow")),e&&t.length>0&&(t[t.length-1]&127)===0&&(t.length<=1||(t[t.length-2]&128)===0))throw new Error("non-minimally encoded script number");return Ne.fromSM(t,{endian:"little"})};Ne.prototype.toScriptNumBuffer=function(){return this.toSM({endian:"little"})};Ne.trim=function(t,e){return t.slice(e-t.length,t.length)};Ne.pad=function(t,e,r){for(var n=B.Buffer.alloc(r),i=0;i<t.length;i++)n[n.length-1-i]=t[t.length-1-i];for(i=0;i<r-e;i++)n[i]=0;return n};Ne.prototype.toHex=function(...t){return this.toBuffer(...t).toString("hex")};Ne.fromHex=function(t,...e){return Ne.fromBuffer(B.Buffer.from(t,"hex"),...e)};jm.exports=Ne});var Ht=R(Ke=>{"use strict";w();var uS=Ot(),hS=J();Ke.inherits=hS;function lS(t,e){return(t.charCodeAt(e)&64512)!==55296||e<0||e+1>=t.length?!1:(t.charCodeAt(e+1)&64512)===56320}function cS(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if(typeof t=="string")if(e){if(e==="hex")for(t=t.replace(/[^a-z0-9]+/ig,""),t.length%2!==0&&(t="0"+t),i=0;i<t.length;i+=2)r.push(parseInt(t[i]+t[i+1],16))}else for(var n=0,i=0;i<t.length;i++){var a=t.charCodeAt(i);a<128?r[n++]=a:a<2048?(r[n++]=a>>6|192,r[n++]=a&63|128):lS(t,i)?(a=65536+((a&1023)<<10)+(t.charCodeAt(++i)&1023),r[n++]=a>>18|240,r[n++]=a>>12&63|128,r[n++]=a>>6&63|128,r[n++]=a&63|128):(r[n++]=a>>12|224,r[n++]=a>>6&63|128,r[n++]=a&63|128)}else for(i=0;i<t.length;i++)r[i]=t[i]|0;return r}Ke.toArray=cS;function dS(t){for(var e="",r=0;r<t.length;r++)e+=Wm(t[r].toString(16));return e}Ke.toHex=dS;function Km(t){var e=t>>>24|t>>>8&65280|t<<8&16711680|(t&255)<<24;return e>>>0}Ke.htonl=Km;function pS(t,e){for(var r="",n=0;n<t.length;n++){var i=t[n];e==="little"&&(i=Km(i)),r+=zm(i.toString(16))}return r}Ke.toHex32=pS;function Wm(t){return t.length===1?"0"+t:t}Ke.zero2=Wm;function zm(t){return t.length===7?"0"+t:t.length===6?"00"+t:t.length===5?"000"+t:t.length===4?"0000"+t:t.length===3?"00000"+t:t.length===2?"000000"+t:t.length===1?"0000000"+t:t}Ke.zero8=zm;function vS(t,e,r,n){var i=r-e;uS(i%4===0);for(var a=new Array(i/4),f=0,v=e;f<a.length;f++,v+=4){var m;n==="big"?m=t[v]<<24|t[v+1]<<16|t[v+2]<<8|t[v+3]:m=t[v+3]<<24|t[v+2]<<16|t[v+1]<<8|t[v],a[f]=m>>>0}return a}Ke.join32=vS;function yS(t,e){for(var r=new Array(t.length*4),n=0,i=0;n<t.length;n++,i+=4){var a=t[n];e==="big"?(r[i]=a>>>24,r[i+1]=a>>>16&255,r[i+2]=a>>>8&255,r[i+3]=a&255):(r[i+3]=a>>>24,r[i+2]=a>>>16&255,r[i+1]=a>>>8&255,r[i]=a&255)}return r}Ke.split32=yS;function gS(t,e){return t>>>e|t<<32-e}Ke.rotr32=gS;function mS(t,e){return t<<e|t>>>32-e}Ke.rotl32=mS;function bS(t,e){return t+e>>>0}Ke.sum32=bS;function wS(t,e,r){return t+e+r>>>0}Ke.sum32_3=wS;function _S(t,e,r,n){return t+e+r+n>>>0}Ke.sum32_4=_S;function xS(t,e,r,n,i){return t+e+r+n+i>>>0}Ke.sum32_5=xS;function MS(t,e,r,n){var i=t[e],a=t[e+1],f=n+a>>>0,v=(f<n?1:0)+r+i;t[e]=v>>>0,t[e+1]=f}Ke.sum64=MS;function ES(t,e,r,n){var i=e+n>>>0,a=(i<e?1:0)+t+r;return a>>>0}Ke.sum64_hi=ES;function SS(t,e,r,n){var i=e+n;return i>>>0}Ke.sum64_lo=SS;function BS(t,e,r,n,i,a,f,v){var m=0,E=e;E=E+n>>>0,m+=E<e?1:0,E=E+a>>>0,m+=E<a?1:0,E=E+v>>>0,m+=E<v?1:0;var A=t+r+i+f+m;return A>>>0}Ke.sum64_4_hi=BS;function AS(t,e,r,n,i,a,f,v){var m=e+n+a+v;return m>>>0}Ke.sum64_4_lo=AS;function RS(t,e,r,n,i,a,f,v,m,E){var A=0,q=e;q=q+n>>>0,A+=q<e?1:0,q=q+a>>>0,A+=q<a?1:0,q=q+v>>>0,A+=q<v?1:0,q=q+E>>>0,A+=q<E?1:0;var I=t+r+i+f+m+A;return I>>>0}Ke.sum64_5_hi=RS;function qS(t,e,r,n,i,a,f,v,m,E){var A=e+n+a+v+E;return A>>>0}Ke.sum64_5_lo=qS;function IS(t,e,r){var n=e<<32-r|t>>>r;return n>>>0}Ke.rotr64_hi=IS;function kS(t,e,r){var n=t<<32-r|e>>>r;return n>>>0}Ke.rotr64_lo=kS;function TS(t,e,r){return t>>>r}Ke.shr64_hi=TS;function CS(t,e,r){var n=t<<32-r|e>>>r;return n>>>0}Ke.shr64_lo=CS});var Bn=R(Vm=>{"use strict";w();var Gm=Ht(),OS=Ot();function zf(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}Vm.BlockHash=zf;zf.prototype.update=function(e,r){if(e=Gm.toArray(e,r),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var n=e.length%this._delta8;this.pending=e.slice(e.length-n,e.length),this.pending.length===0&&(this.pending=null),e=Gm.join32(e,0,e.length-n,this.endian);for(var i=0;i<e.length;i+=this._delta32)this._update(e,i,i+this._delta32)}return this};zf.prototype.digest=function(e){return this.update(this._pad()),OS(this.pending===null),this._digest(e)};zf.prototype._pad=function(){var e=this.pendingTotal,r=this._delta8,n=r-(e+this.padLength)%r,i=new Array(n+this.padLength);i[0]=128;for(var a=1;a<n;a++)i[a]=0;if(e<<=3,this.endian==="big"){for(var f=8;f<this.padLength;f++)i[a++]=0;i[a++]=0,i[a++]=0,i[a++]=0,i[a++]=0,i[a++]=e>>>24&255,i[a++]=e>>>16&255,i[a++]=e>>>8&255,i[a++]=e&255}else for(i[a++]=e&255,i[a++]=e>>>8&255,i[a++]=e>>>16&255,i[a++]=e>>>24&255,i[a++]=0,i[a++]=0,i[a++]=0,i[a++]=0,f=8;f<this.padLength;f++)i[a++]=0;return i}});var fl=R(Sr=>{"use strict";w();var PS=Ht(),rr=PS.rotr32;function DS(t,e,r,n){if(t===0)return $m(e,r,n);if(t===1||t===3)return Ym(e,r,n);if(t===2)return Zm(e,r,n)}Sr.ft_1=DS;function $m(t,e,r){return t&e^~t&r}Sr.ch32=$m;function Zm(t,e,r){return t&e^t&r^e&r}Sr.maj32=Zm;function Ym(t,e,r){return t^e^r}Sr.p32=Ym;function US(t){return rr(t,2)^rr(t,13)^rr(t,22)}Sr.s0_256=US;function NS(t){return rr(t,6)^rr(t,11)^rr(t,25)}Sr.s1_256=NS;function LS(t){return rr(t,7)^rr(t,18)^t>>>3}Sr.g0_256=LS;function FS(t){return rr(t,17)^rr(t,19)^t>>>10}Sr.g1_256=FS});var Qm=R((Vk,Jm)=>{"use strict";w();var An=Ht(),jS=Bn(),HS=fl(),sl=An.rotl32,Va=An.sum32,KS=An.sum32_5,WS=HS.ft_1,Xm=jS.BlockHash,zS=[1518500249,1859775393,2400959708,3395469782];function ir(){if(!(this instanceof ir))return new ir;Xm.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}An.inherits(ir,Xm);Jm.exports=ir;ir.blockSize=512;ir.outSize=160;ir.hmacStrength=80;ir.padLength=64;ir.prototype._update=function(e,r){for(var n=this.W,i=0;i<16;i++)n[i]=e[r+i];for(;i<n.length;i++)n[i]=sl(n[i-3]^n[i-8]^n[i-14]^n[i-16],1);var a=this.h[0],f=this.h[1],v=this.h[2],m=this.h[3],E=this.h[4];for(i=0;i<n.length;i++){var A=~~(i/20),q=KS(sl(a,5),WS(A,f,v,m),E,n[i],zS[A]);E=m,m=v,v=sl(f,30),f=a,a=q}this.h[0]=Va(this.h[0],a),this.h[1]=Va(this.h[1],f),this.h[2]=Va(this.h[2],v),this.h[3]=Va(this.h[3],m),this.h[4]=Va(this.h[4],E)};ir.prototype._digest=function(e){return e==="hex"?An.toHex32(this.h,"big"):An.split32(this.h,"big")}});var ul=R((Zk,tb)=>{"use strict";w();var Rn=Ht(),GS=Bn(),qn=fl(),VS=Ot(),Kt=Rn.sum32,$S=Rn.sum32_4,ZS=Rn.sum32_5,YS=qn.ch32,XS=qn.maj32,JS=qn.s0_256,QS=qn.s1_256,eB=qn.g0_256,tB=qn.g1_256,eb=GS.BlockHash,rB=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function nr(){if(!(this instanceof nr))return new nr;eb.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=rB,this.W=new Array(64)}Rn.inherits(nr,eb);tb.exports=nr;nr.blockSize=512;nr.outSize=256;nr.hmacStrength=192;nr.padLength=64;nr.prototype._update=function(e,r){for(var n=this.W,i=0;i<16;i++)n[i]=e[r+i];for(;i<n.length;i++)n[i]=$S(tB(n[i-2]),n[i-7],eB(n[i-15]),n[i-16]);var a=this.h[0],f=this.h[1],v=this.h[2],m=this.h[3],E=this.h[4],A=this.h[5],q=this.h[6],I=this.h[7];for(VS(this.k.length===n.length),i=0;i<n.length;i++){var C=ZS(I,QS(E),YS(E,A,q),this.k[i],n[i]),j=Kt(JS(a),XS(a,f,v));I=q,q=A,A=E,E=Kt(m,C),m=v,v=f,f=a,a=Kt(C,j)}this.h[0]=Kt(this.h[0],a),this.h[1]=Kt(this.h[1],f),this.h[2]=Kt(this.h[2],v),this.h[3]=Kt(this.h[3],m),this.h[4]=Kt(this.h[4],E),this.h[5]=Kt(this.h[5],A),this.h[6]=Kt(this.h[6],q),this.h[7]=Kt(this.h[7],I)};nr.prototype._digest=function(e){return e==="hex"?Rn.toHex32(this.h,"big"):Rn.split32(this.h,"big")}});var nb=R((Xk,ib)=>{"use strict";w();var hl=Ht(),rb=ul();function Br(){if(!(this instanceof Br))return new Br;rb.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}hl.inherits(Br,rb);ib.exports=Br;Br.blockSize=512;Br.outSize=224;Br.hmacStrength=192;Br.padLength=64;Br.prototype._digest=function(e){return e==="hex"?hl.toHex32(this.h.slice(0,7),"big"):hl.split32(this.h.slice(0,7),"big")}});var dl=R((Qk,sb)=>{"use strict";w();var mt=Ht(),iB=Bn(),nB=Ot(),ar=mt.rotr64_hi,or=mt.rotr64_lo,ab=mt.shr64_hi,ob=mt.shr64_lo,jr=mt.sum64,ll=mt.sum64_hi,cl=mt.sum64_lo,aB=mt.sum64_4_hi,oB=mt.sum64_4_lo,fB=mt.sum64_5_hi,sB=mt.sum64_5_lo,fb=iB.BlockHash,uB=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Wt(){if(!(this instanceof Wt))return new Wt;fb.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=uB,this.W=new Array(160)}mt.inherits(Wt,fb);sb.exports=Wt;Wt.blockSize=1024;Wt.outSize=512;Wt.hmacStrength=192;Wt.padLength=128;Wt.prototype._prepareBlock=function(e,r){for(var n=this.W,i=0;i<32;i++)n[i]=e[r+i];for(;i<n.length;i+=2){var a=wB(n[i-4],n[i-3]),f=_B(n[i-4],n[i-3]),v=n[i-14],m=n[i-13],E=mB(n[i-30],n[i-29]),A=bB(n[i-30],n[i-29]),q=n[i-32],I=n[i-31];n[i]=aB(a,f,v,m,E,A,q,I),n[i+1]=oB(a,f,v,m,E,A,q,I)}};Wt.prototype._update=function(e,r){this._prepareBlock(e,r);var n=this.W,i=this.h[0],a=this.h[1],f=this.h[2],v=this.h[3],m=this.h[4],E=this.h[5],A=this.h[6],q=this.h[7],I=this.h[8],C=this.h[9],j=this.h[10],V=this.h[11],X=this.h[12],z=this.h[13],$=this.h[14],Fe=this.h[15];nB(this.k.length===n.length);for(var k=0;k<n.length;k+=2){var O=$,D=Fe,L=yB(I,C),F=gB(I,C),H=hB(I,C,j,V,X,z),M=lB(I,C,j,V,X,z),h=this.k[k],y=this.k[k+1],l=n[k],o=n[k+1],s=fB(O,D,L,F,H,M,h,y,l,o),d=sB(O,D,L,F,H,M,h,y,l,o);O=pB(i,a),D=vB(i,a),L=cB(i,a,f,v,m,E),F=dB(i,a,f,v,m,E);var g=ll(O,D,L,F),p=cl(O,D,L,F);$=X,Fe=z,X=j,z=V,j=I,V=C,I=ll(A,q,s,d),C=cl(q,q,s,d),A=m,q=E,m=f,E=v,f=i,v=a,i=ll(s,d,g,p),a=cl(s,d,g,p)}jr(this.h,0,i,a),jr(this.h,2,f,v),jr(this.h,4,m,E),jr(this.h,6,A,q),jr(this.h,8,I,C),jr(this.h,10,j,V),jr(this.h,12,X,z),jr(this.h,14,$,Fe)};Wt.prototype._digest=function(e){return e==="hex"?mt.toHex32(this.h,"big"):mt.split32(this.h,"big")};function hB(t,e,r,n,i){var a=t&r^~t&i;return a<0&&(a+=4294967296),a}function lB(t,e,r,n,i,a){var f=e&n^~e&a;return f<0&&(f+=4294967296),f}function cB(t,e,r,n,i){var a=t&r^t&i^r&i;return a<0&&(a+=4294967296),a}function dB(t,e,r,n,i,a){var f=e&n^e&a^n&a;return f<0&&(f+=4294967296),f}function pB(t,e){var r=ar(t,e,28),n=ar(e,t,2),i=ar(e,t,7),a=r^n^i;return a<0&&(a+=4294967296),a}function vB(t,e){var r=or(t,e,28),n=or(e,t,2),i=or(e,t,7),a=r^n^i;return a<0&&(a+=4294967296),a}function yB(t,e){var r=ar(t,e,14),n=ar(t,e,18),i=ar(e,t,9),a=r^n^i;return a<0&&(a+=4294967296),a}function gB(t,e){var r=or(t,e,14),n=or(t,e,18),i=or(e,t,9),a=r^n^i;return a<0&&(a+=4294967296),a}function mB(t,e){var r=ar(t,e,1),n=ar(t,e,8),i=ab(t,e,7),a=r^n^i;return a<0&&(a+=4294967296),a}function bB(t,e){var r=or(t,e,1),n=or(t,e,8),i=ob(t,e,7),a=r^n^i;return a<0&&(a+=4294967296),a}function wB(t,e){var r=ar(t,e,19),n=ar(e,t,29),i=ab(t,e,6),a=r^n^i;return a<0&&(a+=4294967296),a}function _B(t,e){var r=or(t,e,19),n=or(e,t,29),i=ob(t,e,6),a=r^n^i;return a<0&&(a+=4294967296),a}});var lb=R((tT,hb)=>{"use strict";w();var pl=Ht(),ub=dl();function Ar(){if(!(this instanceof Ar))return new Ar;ub.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}pl.inherits(Ar,ub);hb.exports=Ar;Ar.blockSize=1024;Ar.outSize=384;Ar.hmacStrength=192;Ar.padLength=128;Ar.prototype._digest=function(e){return e==="hex"?pl.toHex32(this.h.slice(0,12),"big"):pl.split32(this.h.slice(0,12),"big")}});var cb=R(In=>{"use strict";w();In.sha1=Qm();In.sha224=nb();In.sha256=ul();In.sha384=lb();In.sha512=dl()});var mb=R(gb=>{"use strict";w();var Di=Ht(),xB=Bn(),Gf=Di.rotl32,db=Di.sum32,$a=Di.sum32_3,pb=Di.sum32_4,yb=xB.BlockHash;function fr(){if(!(this instanceof fr))return new fr;yb.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}Di.inherits(fr,yb);gb.ripemd160=fr;fr.blockSize=512;fr.outSize=160;fr.hmacStrength=192;fr.padLength=64;fr.prototype._update=function(e,r){for(var n=this.h[0],i=this.h[1],a=this.h[2],f=this.h[3],v=this.h[4],m=n,E=i,A=a,q=f,I=v,C=0;C<80;C++){var j=db(Gf(pb(n,vb(C,i,a,f),e[SB[C]+r],MB(C)),AB[C]),v);n=v,v=f,f=Gf(a,10),a=i,i=j,j=db(Gf(pb(m,vb(79-C,E,A,q),e[BB[C]+r],EB(C)),RB[C]),I),m=I,I=q,q=Gf(A,10),A=E,E=j}j=$a(this.h[1],a,q),this.h[1]=$a(this.h[2],f,I),this.h[2]=$a(this.h[3],v,m),this.h[3]=$a(this.h[4],n,E),this.h[4]=$a(this.h[0],i,A),this.h[0]=j};fr.prototype._digest=function(e){return e==="hex"?Di.toHex32(this.h,"little"):Di.split32(this.h,"little")};function vb(t,e,r,n){return t<=15?e^r^n:t<=31?e&r|~e&n:t<=47?(e|~r)^n:t<=63?e&n|r&~n:e^(r|~n)}function MB(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function EB(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}var SB=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],BB=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],AB=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],RB=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]});var wb=R((fT,bb)=>{"use strict";w();var qB=Ht(),IB=Ot();function kn(t,e,r){if(!(this instanceof kn))return new kn(t,e,r);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(qB.toArray(e,r))}bb.exports=kn;kn.prototype._init=function(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),IB(e.length<=this.blockSize);for(var r=e.length;r<this.blockSize;r++)e.push(0);for(r=0;r<e.length;r++)e[r]^=54;for(this.inner=new this.Hash().update(e),r=0;r<e.length;r++)e[r]^=106;this.outer=new this.Hash().update(e)};kn.prototype.update=function(e,r){return this.inner.update(e,r),this};kn.prototype.digest=function(e){return this.outer.update(this.inner.digest()),this.outer.digest(e)}});var xb=R(_b=>{w();var ot=_b;ot.utils=Ht();ot.common=Bn();ot.sha=cb();ot.ripemd=mb();ot.hmac=wb();ot.sha1=ot.sha.sha1;ot.sha256=ot.sha.sha256;ot.sha224=ot.sha.sha224;ot.sha384=ot.sha.sha384;ot.sha512=ot.sha.sha512;ot.ripemd160=ot.ripemd.ripemd160});var Eb=R((lT,Mb)=>{"use strict";w();var Vf=xb(),Rr=Kf(),Je=Mb.exports;Je.sha1=function(t){return Rr.checkArgument(B.Buffer.isBuffer(t)),B.Buffer.from(Vf.sha1().update(t).digest("hex"),"hex")};Je.sha1.blocksize=512;Je.sha256=function(t){return Rr.checkArgument(B.Buffer.isBuffer(t)),B.Buffer.from(Vf.sha256().update(t).digest("hex"),"hex")};Je.sha256.blocksize=512;Je.sha256sha256=function(t){return Rr.checkArgument(B.Buffer.isBuffer(t)),Je.sha256(Je.sha256(t))};Je.ripemd160=function(t){return Rr.checkArgument(B.Buffer.isBuffer(t)),B.Buffer.from(Vf.ripemd160().update(t).digest("hex"),"hex")};Je.sha256ripemd160=function(t){return Rr.checkArgument(B.Buffer.isBuffer(t)),Je.ripemd160(Je.sha256(t))};Je.sha512=function(t){return Rr.checkArgument(B.Buffer.isBuffer(t)),B.Buffer.from(Vf.sha512().update(t).digest("hex"),"hex")};Je.sha512.blocksize=1024;Je.hmac=function(t,e,r){Rr.checkArgument(B.Buffer.isBuffer(e)),Rr.checkArgument(B.Buffer.isBuffer(r)),Rr.checkArgument(t.blocksize);var n=t.blocksize/8;if(r.length>n)r=t(r);else if(r.length<n){var i=B.Buffer.alloc(n);i.fill(0),r.copy(i),r=i}var a=B.Buffer.alloc(n);a.fill(92);var f=B.Buffer.alloc(n);f.fill(54);for(var v=B.Buffer.alloc(n),m=B.Buffer.alloc(n),E=0;E<n;E++)v[E]=a[E]^r[E],m[E]=f[E]^r[E];return t(B.Buffer.concat([v,t(B.Buffer.concat([m,e]))]))};Je.sha256hmac=function(t,e){return Je.hmac(Je.sha256,t,e)};Je.sha512hmac=function(t,e){return Je.hmac(Je.sha512,t,e)}});var Bb=R((dT,Sb)=>{"use strict";w();var $f=ja(),qr=Kf(),Qe=Sb.exports;Qe.sha1=function(t){return qr.checkArgument(B.Buffer.isBuffer(t)),$f.createHash("sha1").update(t).digest()};Qe.sha1.blocksize=512;Qe.sha256=function(t){return qr.checkArgument(B.Buffer.isBuffer(t)),$f.createHash("sha256").update(t).digest()};Qe.sha256.blocksize=512;Qe.sha256sha256=function(t){return qr.checkArgument(B.Buffer.isBuffer(t)),Qe.sha256(Qe.sha256(t))};Qe.ripemd160=function(t){return qr.checkArgument(B.Buffer.isBuffer(t)),$f.createHash("ripemd160").update(t).digest()};Qe.sha256ripemd160=function(t){return qr.checkArgument(B.Buffer.isBuffer(t)),Qe.ripemd160(Qe.sha256(t))};Qe.sha512=function(t){return qr.checkArgument(B.Buffer.isBuffer(t)),$f.createHash("sha512").update(t).digest()};Qe.sha512.blocksize=1024;Qe.hmac=function(t,e,r){qr.checkArgument(B.Buffer.isBuffer(e)),qr.checkArgument(B.Buffer.isBuffer(r)),qr.checkArgument(t.blocksize);var n=t.blocksize/8;if(r.length>n)r=t(r);else if(r.length<n){var i=B.Buffer.alloc(n);i.fill(0),r.copy(i),r=i}var a=B.Buffer.alloc(n);a.fill(92);var f=B.Buffer.alloc(n);f.fill(54);for(var v=B.Buffer.alloc(n),m=B.Buffer.alloc(n),E=0;E<n;E++)v[E]=a[E]^r[E],m[E]=f[E]^r[E];return t(B.Buffer.concat([v,t(B.Buffer.concat([m,e]))]))};Qe.sha256hmac=function(t,e){return Qe.hmac(Qe.sha256,t,e)};Qe.sha512hmac=function(t,e){return Qe.hmac(Qe.sha512,t,e)}});var Ab=R((vT,vl)=>{w();S.default.browser?vl.exports=Eb():vl.exports=Bb()});var qb=R((yl,Rb)=>{w();(function(t,e){"use strict";typeof define=="function"&&define.amd?define([],function(){return t.secrets=e()}):typeof yl=="object"?Rb.exports=e(ja()):t.secrets=e(t.crypto)})(yl,function(t){"use strict";var e,r,n,i,a;function f(){e={bits:8,radix:16,minBits:3,maxBits:20,bytesPerChar:2,maxBytesPerChar:6,primitivePolynomials:[null,null,1,3,3,5,3,3,29,17,9,5,83,27,43,3,45,9,39,39,9,5,3,33,27,9,71,39,9,5,83]},r={},n=new Array(1024).join("0"),i=!0,a=["nodeCryptoRandomBytes","browserCryptoGetRandomValues","testRandom"]}function v(){return!!(r&&r.rng&&typeof r.rng=="function")}function m(k,O){var D;if(O===0||O===1)return k;if(O&&O>1024)throw new Error("Padding must be multiples of no larger than 1024 bits.");return O=O||r.bits,k&&(D=k.length%O),D?(n+k).slice(-(O-D+k.length)):k}function E(k){var O="",D,L;for(L=k.length-1;L>=0;L--){if(D=parseInt(k[L],16),isNaN(D))throw new Error("Invalid hex character.");O=m(D.toString(2),4)+O}return O}function A(k){var O="",D,L;for(k=m(k,4),L=k.length;L>=4;L-=4){if(D=parseInt(k.slice(L-4,L),2),isNaN(D))throw new Error("Invalid binary character.");O=D.toString(16)+O}return O}function q(){return!!(t&&typeof t=="object"&&(typeof t.getRandomValues=="function"||typeof t.getRandomValues=="object")&&(typeof Uint32Array=="function"||typeof Uint32Array=="object"))}function I(){return typeof t=="object"&&typeof t.randomBytes=="function"}function C(k){function O(H,M,h,y){var l=0,o,s="",d;for(M&&(o=M.length-1);l<o||s.length<H;)d=Math.abs(parseInt(M[l],h)),s=s+m(d.toString(2),y),l++;return s=s.substr(-H),(s.match(/0/g)||[]).length===s.length?null:s}function D(H){var M,h,y,l,o=null;for(y=16,l=4,h=Math.ceil(H/8);o===null;)M=t.randomBytes(h),o=O(H,M.toString("hex"),y,l);return o}function L(H){var M,h,y,l=null;for(h=10,y=32,M=Math.ceil(H/32);l===null;)l=O(H,t.getRandomValues(new Uint32Array(M)),h,y);return l}function F(H){var M,h,y,l,o,s=null;l=10,o=32,h=Math.ceil(H/32),y=123456789,M=new Uint32Array(h);for(var d=0;d<M.length;d++)M[d]=y;for(;s===null;)s=O(H,M,l,o);return s}if(k&&k==="testRandom")return r.typeCSPRNG=k,F;if(k&&k==="nodeCryptoRandomBytes")return r.typeCSPRNG=k,D;if(k&&k==="browserCryptoGetRandomValues")return r.typeCSPRNG=k,L;if(I())return r.typeCSPRNG="nodeCryptoRandomBytes",D;if(q())return r.typeCSPRNG="browserCryptoGetRandomValues",L}function j(k,O){var D=[],L;for(O&&(k=m(k,O)),L=k.length;L>r.bits;L-=r.bits)D.push(parseInt(k.slice(L-r.bits,L),2));return D.push(parseInt(k.slice(0,L),2)),D}function V(k,O){var D=r.logs[k],L=0,F;for(F=O.length-1;F>=0;F--)L!==0?L=r.exps[(D+r.logs[L])%r.maxShares]^O[F]:L=O[F];return L}function X(k,O,D){var L=0,F,H,M,h;for(M=0,F=O.length;M<F;M++)if(D[M]){for(H=r.logs[D[M]],h=0;h<F;h++)if(M!==h){if(k===O[h]){H=-1;break}H=(H+r.logs[k^O[h]]-r.logs[O[M]^O[h]]+r.maxShares)%r.maxShares}L=H===-1?L:L^r.exps[H]}return L}function z(k,O,D){var L=[],F=[k],H,M;for(H=1;H<D;H++)F[H]=parseInt(r.rng(r.bits),2);for(H=1,M=O+1;H<M;H++)L[H-1]={x:H,y:V(H,F)};return L}function $(k,O,D){var L,F,H,M,h;if(O=parseInt(O,r.radix),k=parseInt(k,10)||r.bits,L=k.toString(36).toUpperCase(),H=Math.pow(2,k)-1,M=H.toString(r.radix).length,F=m(O.toString(r.radix),M),typeof O!="number"||O%1!==0||O<1||O>H)throw new Error("Share id must be an integer between 1 and "+H+", inclusive.");return h=L+F+D,h}var Fe={init:function(k,O){var D=[],L=[],F=1,H,M;if(f(),k&&(typeof k!="number"||k%1!==0||k<e.minBits||k>e.maxBits))throw new Error("Number of bits must be an integer between "+e.minBits+" and "+e.maxBits+", inclusive.");if(O&&a.indexOf(O)===-1)throw new Error("Invalid RNG type argument : '"+O+"'");for(r.radix=e.radix,r.bits=k||e.bits,r.size=Math.pow(2,r.bits),r.maxShares=r.size-1,H=e.primitivePolynomials[r.bits],M=0;M<r.size;M++)L[M]=F,D[F]=M,F=F<<1,F>=r.size&&(F=F^H,F=F&r.maxShares);if(r.logs=D,r.exps=L,O&&this.setRNG(O),v()||this.setRNG(),!v()||!r.bits||!r.size||!r.maxShares||!r.logs||!r.exps||r.logs.length!==r.size||r.exps.length!==r.size)throw new Error("Initialization failed.")},combine:function(k,O){var D,L,F,H,M="",h,y,l,o=[],s=[];for(O=O||0,D=0,F=k.length;D<F;D++){if(y=this.extractShareComponents(k[D]),h===void 0)h=y.bits;else if(y.bits!==h)throw new Error("Mismatched shares: Different bit settings.");if(r.bits!==h&&this.init(h),o.indexOf(y.id)===-1)for(o.push(y.id),l=j(E(y.data)),L=0,H=l.length;L<H;L++)s[L]=s[L]||[],s[L][o.length-1]=l[L]}for(D=0,F=s.length;D<F;D++)M=m(X(O,o,s[D]).toString(2))+M;return A(O>=1?M:M.slice(M.indexOf("1")+1))},getConfig:function(){var k={};return k.radix=r.radix,k.bits=r.bits,k.maxShares=r.maxShares,k.hasCSPRNG=v(),k.typeCSPRNG=r.typeCSPRNG,k},extractShareComponents:function(k){var O,D,L,F,H={},M,h;if(O=parseInt(k.substr(0,1),36),O&&(typeof O!="number"||O%1!==0||O<e.minBits||O>e.maxBits))throw new Error("Invalid share : Number of bits must be an integer between "+e.minBits+" and "+e.maxBits+", inclusive.");if(F=Math.pow(2,O)-1,L=(Math.pow(2,O)-1).toString(r.radix).length,M="^([a-kA-K3-9]{1})([a-fA-F0-9]{"+L+"})([a-fA-F0-9]+)$",h=new RegExp(M).exec(k),h&&(D=parseInt(h[2],r.radix)),typeof D!="number"||D%1!==0||D<1||D>F)throw new Error("Invalid share : Share id must be an integer between 1 and "+r.maxShares+", inclusive.");if(h&&h[3])return H.bits=O,H.id=D,H.data=h[3],H;throw new Error("The share data provided is invalid : "+k)},setRNG:function(k){var O="Random number generator is invalid ",D=" Supply an CSPRNG of the form function(bits){} that returns a string containing 'bits' number of random 1's and 0's.";if(k&&typeof k=="string"&&a.indexOf(k)===-1)throw new Error("Invalid RNG type argument : '"+k+"'");if(k||(k=C()),k&&typeof k=="string"&&(k=C(k)),i){if(k&&typeof k!="function")throw new Error(O+"(Not a function)."+D);if(k&&typeof k(r.bits)!="string")throw new Error(O+"(Output is not a string)."+D);if(k&&!parseInt(k(r.bits),2))throw new Error(O+"(Binary string output not parseable to an Integer)."+D);if(k&&k(r.bits).length>r.bits)throw new Error(O+"(Output length is greater than config.bits)."+D);if(k&&k(r.bits).length<r.bits)throw new Error(O+"(Output length is less than config.bits)."+D)}return r.rng=k,!0},str2hex:function(k,O){var D,L,F="",H,M,h,y;if(typeof k!="string")throw new Error("Input must be a character string.");if(O||(O=e.bytesPerChar),typeof O!="number"||O<1||O>e.maxBytesPerChar||O%1!==0)throw new Error("Bytes per character must be an integer between 1 and "+e.maxBytesPerChar+", inclusive.");for(D=2*O,L=Math.pow(16,D)-1,h=0,y=k.length;h<y;h++){if(M=k[h].charCodeAt(),isNaN(M))throw new Error("Invalid character: "+k[h]);if(M>L)throw H=Math.ceil(Math.log(M+1)/Math.log(256)),new Error("Invalid character code ("+M+"). Maximum allowable is 256^bytes-1 ("+L+"). To convert this character, use at least "+H+" bytes.");F=m(M.toString(16),D)+F}return F},hex2str:function(k,O){var D,L="",F,H;if(typeof k!="string")throw new Error("Input must be a hexadecimal string.");if(O=O||e.bytesPerChar,typeof O!="number"||O%1!==0||O<1||O>e.maxBytesPerChar)throw new Error("Bytes per character must be an integer between 1 and "+e.maxBytesPerChar+", inclusive.");for(D=2*O,k=m(k,D),F=0,H=k.length;F<H;F+=D)L=String.fromCharCode(parseInt(k.slice(F,F+D),16))+L;return L},random:function(k){if(typeof k!="number"||k%1!==0||k<2||k>65536)throw new Error("Number of bits must be an Integer between 1 and 65536.");return A(r.rng(k))},share:function(k,O,D,L){var F,H,M=new Array(O),h=new Array(O),y,l,o;if(L=L||128,typeof k!="string")throw new Error("Secret must be a string.");if(typeof O!="number"||O%1!==0||O<2)throw new Error("Number of shares must be an integer between 2 and 2^bits-1 ("+r.maxShares+"), inclusive.");if(O>r.maxShares)throw F=Math.ceil(Math.log(O+1)/Math.LN2),new Error("Number of shares must be an integer between 2 and 2^bits-1 ("+r.maxShares+"), inclusive. To create "+O+" shares, use at least "+F+" bits.");if(typeof D!="number"||D%1!==0||D<2)throw new Error("Threshold number of shares must be an integer between 2 and 2^bits-1 ("+r.maxShares+"), inclusive.");if(D>r.maxShares)throw F=Math.ceil(Math.log(D+1)/Math.LN2),new Error("Threshold number of shares must be an integer between 2 and 2^bits-1 ("+r.maxShares+"), inclusive. To use a threshold of "+D+", use at least "+F+" bits.");if(D>O)throw new Error("Threshold number of shares was "+D+" but must be less than or equal to the "+O+" shares specified as the total to generate.");if(typeof L!="number"||L%1!==0||L<0||L>1024)throw new Error("Zero-pad length must be an integer between 0 and 1024 inclusive.");for(k="1"+E(k),k=j(k,L),y=0,o=k.length;y<o;y++)for(H=z(k[y],O,D),l=0;l<O;l++)M[l]=M[l]||H[l].x.toString(r.radix),h[l]=m(H[l].y.toString(2))+(h[l]||"");for(y=0;y<O;y++)M[y]=$(r.bits,M[y],A(h[y]));return M},newShare:function(k,O){var D,L;if(k&&typeof k=="string"&&(k=parseInt(k,r.radix)),L=k.toString(r.radix),k&&L&&O&&O[0])return D=this.extractShareComponents(O[0]),$(D.bits,L,this.combine(O,k));throw new Error("Invalid 'id' or 'shares' Array argument to newShare().")},_reset:f,_padLeft:m,_hex2bin:E,_bin2hex:A,_hasCryptoGetRandomValues:q,_hasCryptoRandomBytes:I,_getRNG:C,_isSetRNG:v,_splitNumStringToIntArray:j,_horner:V,_lagrange:X,_getShares:z,_constructPublicShareString:$};return Fe.init(),Fe})});var Ob=R((mT,Cb)=>{"use strict";w();var dt=Hm(),Ib=il(),kb=Ab(),Zf=null;function gl(){if(Zf)return Zf;var t=qb();return t.setRNG(function(e){for(var r=64,n=0;n<r;n++){for(var i=Ib.getRandomBuffer(Math.ceil(e/8)),a="",f=0;f<i.length;f++)a+=("00000000"+i[f].toString(2)).slice(-8);if(a=a.slice(0,e),/1/.test(a))return a}throw new Error("shamir: CSPRNG returned all-zero draws "+r+" times in a row \u2014 refusing to hang on a degenerate/stubbed random source")}),Zf=t,Zf}var Yf="ff",Tb=2;function et(t){return this instanceof et?(this.options=t||{},this):new et(t)}et.split=function(t,e,r,n){if(n=n||{},t==null)throw new Error("Secret is required");if(e<2)throw new Error("Threshold must be at least 2");if(r<e)throw new Error("Number of shares must be at least threshold");if(e>255||r>255)throw new Error("Threshold and shares must be <= 255");for(var i=B.Buffer.isBuffer(t)?t:B.Buffer.from(t,"utf8"),a=Yf+i.toString("hex"),f=gl().share(a,r,e),v=Ib.getRandomBuffer(8).toString("hex"),m=n.checksum===!0,E=m?kb.sha256(i).slice(0,4).toString("hex"):null,A=[],q=0;q<f.length;q++)A.push({v:Tb,id:q+1,threshold:e,shares:r,length:i.length,splitId:v,share:f[q],checksum:E});return A};et.combine=function(t){if(!t||t.length===0)throw new Error("Shares array is required");if(t[0]&&Array.isArray(t[0].bytes)&&t[0].share===void 0)return et._combineLegacy(t);var e=t[0].threshold,r=t[0].splitId;if(t.length<e)throw new Error("Insufficient shares: need "+e+", got "+t.length);for(var n=[],i=0;i<t.length;i++){var a=t[i];if(!a||typeof a.share!="string")throw new Error("Invalid share at index "+i);if(r!==void 0&&a.splitId!==r)throw new Error("Shares are from different splits (splitId mismatch)");if(a.threshold!==e)throw new Error("Shares have inconsistent threshold");n.push(a.share)}var f=gl().combine(n);if(f.slice(0,Yf.length)!==Yf)throw new Error("Reconstruction failed: invalid or insufficient shares");var v=B.Buffer.from(f.slice(Yf.length),"hex"),m=t[0].checksum;if(m){var E=kb.sha256(v).slice(0,4).toString("hex");if(E!==m)throw new Error("Integrity check failed: shares are inconsistent or tampered")}return v};et.verifyShare=function(t){try{return!t||typeof t!="object"?!1:Array.isArray(t.bytes)&&t.share===void 0?et._verifyLegacyShare(t):t.v!==Tb||typeof t.share!="string"||!/^[0-9a-fA-F]+$/.test(t.share)||typeof t.threshold!="number"||typeof t.shares!="number"||t.threshold<2||t.shares<t.threshold||t.shares>255||t.id<1||t.id>t.shares||t.checksum!==null&&t.checksum!==void 0&&!/^[0-9a-fA-F]{8}$/.test(t.checksum)?!1:(gl().extractShareComponents(t.share),!0)}catch{return!1}};et.generateTestVectors=function(){var t="Hello, Bitcoin SV!",e=3,r=5,n=et.split(t,e,r),i=et.combine(n.slice(0,e));return{secret:t,threshold:e,totalShares:r,shares:n,reconstructed:i.toString("utf8"),valid:i.toString("utf8")===t}};var Hr=new dt(2147483647);et._combineLegacy=function(t){var e=t[0].threshold,r=t[0].shares,n=t[0].length;if(t.length<e)throw new Error("Insufficient shares: need "+e+", got "+t.length);for(var i=0;i<t.length;i++){if(t[i].threshold!==e||t[i].shares!==r)throw new Error("Shares have inconsistent parameters");if(t[i].length!==n)throw new Error("Shares have different secret lengths")}for(var a=[],f=0;f<n;f++){for(var v=[],m=0;m<Math.min(t.length,e);m++)v.push(t[m].bytes[f]);a.push(et._combineByteLegacy(v))}return B.Buffer.from(a)};et._combineByteLegacy=function(t){for(var e=new dt(0),r=0;r<t.length;r++){for(var n=new dt(t[r].x),i=new dt(t[r].y,16),a=new dt(1),f=new dt(1),v=0;v<t.length;v++)if(r!==v){var m=new dt(t[v].x),E=new dt(0).sub(m);E.lt(new dt(0))&&(E=E.add(Hr)),a=a.mul(E).mod(Hr);var A=n.sub(m);A.lt(new dt(0))&&(A=A.add(Hr)),f=f.mul(A).mod(Hr)}var q=et._modInverseLegacy(f,Hr),I=a.mul(q).mod(Hr);e=e.add(i.mul(I)).mod(Hr)}return e.mod(Hr).mod(new dt(256)).toNumber()};et._modInverseLegacy=function(t,e){t.lt(new dt(0))&&(t=t.mod(e).add(e));var r=et._extendedGCDLegacy(t,e);if(!r.gcd.eq(new dt(1)))throw new Error("Modular inverse does not exist");return r.x.mod(e).add(e).mod(e)};et._extendedGCDLegacy=function(t,e){if(t.eq(new dt(0)))return{gcd:e,x:new dt(0),y:new dt(1)};var r=et._extendedGCDLegacy(e.mod(t),t);return{gcd:r.gcd,x:r.y.sub(e.div(t).mul(r.x)),y:r.x}};et._verifyLegacyShare=function(t){if(!t.id||!t.threshold||!t.shares||!t.bytes||typeof t.length!="number"||t.threshold<2||t.shares<t.threshold||!Array.isArray(t.bytes)||t.bytes.length!==t.length)return!1;for(var e=0;e<t.bytes.length;e++){var r=t.bytes[e];if(!r||!r.x||!r.y||r.x<1||r.x>t.shares||!/^[0-9a-fA-F]+$/.test(r.y))return!1}return!0};Cb.exports=et});var kB=R((wT,Pb)=>{w();Pb.exports=Ob()});return kB();})();
|
|
20
20
|
if(typeof module!=="undefined"&&module.exports){module.exports=bsvShamir}else if(typeof define==="function"&&define.amd){define([],function(){return bsvShamir})}
|