bsv2 2.2.2 → 2.3.0

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/dist/bsv2.cjs CHANGED
@@ -5,6 +5,6 @@ Use Chrome, Firefox or Internet Explorer 11`)}var n=_e().Buffer,u=Re.crypto||Re.
5
5
  `)},wf}var Xu;function Jl(){return Xu||(Xu=1,(function(l){var e=l;e.der=md(),e.pem=Yl()})(yf)),yf}var Qu;function dr(){return Qu||(Qu=1,(function(l){var e=l;e.bignum=Ce(),e.define=jl().define,e.base=er(),e.constants=pd(),e.decoders=Wl(),e.encoders=Jl()})(of)),of}var _f,Zu;function Xl(){if(Zu)return _f;Zu=1;var l=dr(),e=l.define("Time",function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})}),t=l.define("AttributeTypeValue",function(){this.seq().obj(this.key("type").objid(),this.key("value").any())}),n=l.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional(),this.key("curve").objid().optional())}),u=l.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(n),this.key("subjectPublicKey").bitstr())}),r=l.define("RelativeDistinguishedName",function(){this.setof(t)}),s=l.define("RDNSequence",function(){this.seqof(r)}),a=l.define("Name",function(){this.choice({rdnSequence:this.use(s)})}),o=l.define("Validity",function(){this.seq().obj(this.key("notBefore").use(e),this.key("notAfter").use(e))}),f=l.define("Extension",function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())}),i=l.define("TBSCertificate",function(){this.seq().obj(this.key("version").explicit(0).int().optional(),this.key("serialNumber").int(),this.key("signature").use(n),this.key("issuer").use(a),this.key("validity").use(o),this.key("subject").use(a),this.key("subjectPublicKeyInfo").use(u),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(f).optional())}),c=l.define("X509Certificate",function(){this.seq().obj(this.key("tbsCertificate").use(i),this.key("signatureAlgorithm").use(n),this.key("signatureValue").bitstr())});return _f=c,_f}var eh;function Ql(){if(eh)return vt;eh=1;var l=dr();vt.certificate=Xl();var e=l.define("RSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())});vt.RSAPrivateKey=e;var t=l.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())});vt.RSAPublicKey=t;var n=l.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p").int(),this.key("q").int(),this.key("g").int()).optional())}),u=l.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(n),this.key("subjectPublicKey").bitstr())});vt.PublicKey=u;var r=l.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(n),this.key("subjectPrivateKey").octstr())});vt.PrivateKey=r;var s=l.define("EncryptedPrivateKeyInfo",function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters").int())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())});vt.EncryptedPrivateKey=s;var a=l.define("DSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("p").int(),this.key("q").int(),this.key("g").int(),this.key("pub_key").int(),this.key("priv_key").int())});vt.DSAPrivateKey=a,vt.DSAparam=l.define("DSAparam",function(){this.int()});var o=l.define("ECParameters",function(){this.choice({namedCurve:this.objid()})}),f=l.define("ECPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(o),this.key("publicKey").optional().explicit(1).bitstr())});return vt.ECPrivateKey=f,vt.signature=l.define("signature",function(){this.seq().obj(this.key("r").int(),this.key("s").int())}),vt}const Zl={"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"};var Sf,th;function e1(){if(th)return Sf;th=1;var l=/Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m,e=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m,t=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m,n=jr(),u=ss(),r=_e().Buffer;return Sf=function(s,a){var o=s.toString(),f=o.match(l),i;if(f){var h="aes"+f[1],d=r.from(f[2],"hex"),b=r.from(f[3].replace(/[\r\n]/g,""),"base64"),p=n(a,d.slice(0,8),parseInt(f[1],10)).key,y=[],v=u.createDecipheriv(h,p,d);y.push(v.update(b)),y.push(v.final()),i=r.concat(y)}else{var c=o.match(t);i=r.from(c[2].replace(/[\r\n]/g,""),"base64")}var g=o.match(e)[1];return{tag:g,data:i}},Sf}var xf,rh;function Vr(){if(rh)return xf;rh=1;var l=Ql(),e=Zl,t=e1(),n=ss(),u=ns().pbkdf2Sync,r=_e().Buffer;function s(o,f){var i=o.algorithm.decrypt.kde.kdeparams.salt,c=parseInt(o.algorithm.decrypt.kde.kdeparams.iters.toString(),10),h=e[o.algorithm.decrypt.cipher.algo.join(".")],d=o.algorithm.decrypt.cipher.iv,b=o.subjectPrivateKey,p=parseInt(h.split("-")[1],10)/8,y=u(f,i,c,p,"sha1"),v=n.createDecipheriv(h,y,d),g=[];return g.push(v.update(b)),g.push(v.final()),r.concat(g)}function a(o){var f;typeof o=="object"&&!r.isBuffer(o)&&(f=o.passphrase,o=o.key),typeof o=="string"&&(o=r.from(o));var i=t(o,f),c=i.tag,h=i.data,d,b;switch(c){case"CERTIFICATE":b=l.certificate.decode(h,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(b||(b=l.PublicKey.decode(h,"der")),d=b.algorithm.algorithm.join("."),d){case"1.2.840.113549.1.1.1":return l.RSAPublicKey.decode(b.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return b.subjectPrivateKey=b.subjectPublicKey,{type:"ec",data:b};case"1.2.840.10040.4.1":return b.algorithm.params.pub_key=l.DSAparam.decode(b.subjectPublicKey.data,"der"),{type:"dsa",data:b.algorithm.params};default:throw new Error("unknown key id "+d)}case"ENCRYPTED PRIVATE KEY":h=l.EncryptedPrivateKey.decode(h,"der"),h=s(h,f);case"PRIVATE KEY":switch(b=l.PrivateKey.decode(h,"der"),d=b.algorithm.algorithm.join("."),d){case"1.2.840.113549.1.1.1":return l.RSAPrivateKey.decode(b.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:b.algorithm.curve,privateKey:l.ECPrivateKey.decode(b.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return b.algorithm.params.priv_key=l.DSAparam.decode(b.subjectPrivateKey,"der"),{type:"dsa",params:b.algorithm.params};default:throw new Error("unknown key id "+d)}case"RSA PUBLIC KEY":return l.RSAPublicKey.decode(h,"der");case"RSA PRIVATE KEY":return l.RSAPrivateKey.decode(h,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:l.DSAPrivateKey.decode(h,"der")};case"EC PRIVATE KEY":return h=l.ECPrivateKey.decode(h,"der"),{curve:h.parameters.value,privateKey:h.privateKey};default:throw new Error("unknown key type "+c)}}return a.signature=l.signature,xf=a,xf}const yd={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"};var ih;function t1(){if(ih)return Yt.exports;ih=1;var l=_e().Buffer,e=Jh(),t=os(),n=us().ec,u=Ce(),r=Vr(),s=yd,a=1;function o(v,g,x,B,I){var C=r(g);if(C.curve){if(B!=="ecdsa"&&B!=="ecdsa/rsa")throw new Error("wrong private key type");return f(v,C)}else if(C.type==="dsa"){if(B!=="dsa")throw new Error("wrong private key type");return i(v,C,x)}if(B!=="rsa"&&B!=="ecdsa/rsa")throw new Error("wrong private key type");if(g.padding!==void 0&&g.padding!==a)throw new Error("illegal or unsupported padding mode");v=l.concat([I,v]);for(var j=C.modulus.byteLength(),G=[0,1];v.length+G.length+1<j;)G.push(255);G.push(0);for(var z=-1;++z<v.length;)G.push(v[z]);var te=t(G,C);return te}function f(v,g){var x=s[g.curve.join(".")];if(!x)throw new Error("unknown curve "+g.curve.join("."));var B=new n(x),I=B.keyFromPrivate(g.privateKey),C=I.sign(v);return l.from(C.toDER())}function i(v,g,x){for(var B=g.params.priv_key,I=g.params.p,C=g.params.q,j=g.params.g,G=new u(0),z,te=d(v,C).mod(C),ne=!1,$=h(B,C,v,x);ne===!1;)z=p(C,$,x),G=y(j,z,I,C),ne=z.invm(C).imul(te.add(B.mul(G))).mod(C),ne.cmpn(0)===0&&(ne=!1,G=new u(0));return c(G,ne)}function c(v,g){v=v.toArray(),g=g.toArray(),v[0]&128&&(v=[0].concat(v)),g[0]&128&&(g=[0].concat(g));var x=v.length+g.length+4,B=[48,x,2,v.length];return B=B.concat(v,[2,g.length],g),l.from(B)}function h(v,g,x,B){if(v=l.from(v.toArray()),v.length<g.byteLength()){var I=l.alloc(g.byteLength()-v.length);v=l.concat([I,v])}var C=x.length,j=b(x,g),G=l.alloc(C);G.fill(1);var z=l.alloc(C);return z=e(B,z).update(G).update(l.from([0])).update(v).update(j).digest(),G=e(B,z).update(G).digest(),z=e(B,z).update(G).update(l.from([1])).update(v).update(j).digest(),G=e(B,z).update(G).digest(),{k:z,v:G}}function d(v,g){var x=new u(v),B=(v.length<<3)-g.bitLength();return B>0&&x.ishrn(B),x}function b(v,g){v=d(v,g),v=v.mod(g);var x=l.from(v.toArray());if(x.length<g.byteLength()){var B=l.alloc(g.byteLength()-x.length);x=l.concat([B,x])}return x}function p(v,g,x){var B,I;do{for(B=l.alloc(0);B.length*8<v.bitLength();)g.v=e(x,g.k).update(g.v).digest(),B=l.concat([B,g.v]);I=d(B,v),g.k=e(x,g.k).update(g.v).update(l.from([0])).digest(),g.v=e(x,g.k).update(g.v).digest()}while(I.cmp(v)!==-1);return I}function y(v,g,x,B){return v.toRed(u.mont(x)).redPow(g).fromRed().mod(B)}return Yt.exports=o,Yt.exports.getKey=h,Yt.exports.makeKey=p,Yt.exports}var Ef,nh;function r1(){if(nh)return Ef;nh=1;var l=_e().Buffer,e=Ce(),t=us().ec,n=Vr(),u=yd;function r(f,i,c,h,d){var b=n(c);if(b.type==="ec"){if(h!=="ecdsa"&&h!=="ecdsa/rsa")throw new Error("wrong public key type");return s(f,i,b)}else if(b.type==="dsa"){if(h!=="dsa")throw new Error("wrong public key type");return a(f,i,b)}if(h!=="rsa"&&h!=="ecdsa/rsa")throw new Error("wrong public key type");i=l.concat([d,i]);for(var p=b.modulus.byteLength(),y=[1],v=0;i.length+y.length+2<p;)y.push(255),v+=1;y.push(0);for(var g=-1;++g<i.length;)y.push(i[g]);y=l.from(y);var x=e.mont(b.modulus);f=new e(f).toRed(x),f=f.redPow(new e(b.publicExponent)),f=l.from(f.fromRed().toArray());var B=v<8?1:0;for(p=Math.min(f.length,y.length),f.length!==y.length&&(B=1),g=-1;++g<p;)B|=f[g]^y[g];return B===0}function s(f,i,c){var h=u[c.data.algorithm.curve.join(".")];if(!h)throw new Error("unknown curve "+c.data.algorithm.curve.join("."));var d=new t(h),b=c.data.subjectPrivateKey.data;return d.verify(i,f,b)}function a(f,i,c){var h=c.data.p,d=c.data.q,b=c.data.g,p=c.data.pub_key,y=n.signature.decode(f,"der"),v=y.s,g=y.r;o(v,d),o(g,d);var x=e.mont(h),B=v.invm(d),I=b.toRed(x).redPow(new e(i).mul(B).mod(d)).fromRed().mul(p.toRed(x).redPow(g.mul(B).mod(d)).fromRed()).mod(h).mod(d);return I.cmp(g)===0}function o(f,i){if(f.cmpn(0)<=0)throw new Error("invalid sig");if(f.cmp(i)>=0)throw new Error("invalid sig")}return Ef=r,Ef}var Bf,ah;function i1(){if(ah)return Bf;ah=1;var l=_e().Buffer,e=or(),t=Gh(),n=pe(),u=t1(),r=r1(),s=Xh;Object.keys(s).forEach(function(c){s[c].id=l.from(s[c].id,"hex"),s[c.toLowerCase()]=s[c]});function a(c){t.Writable.call(this);var h=s[c];if(!h)throw new Error("Unknown message digest");this._hashType=h.hash,this._hash=e(h.hash),this._tag=h.id,this._signType=h.sign}n(a,t.Writable),a.prototype._write=function(h,d,b){this._hash.update(h),b()},a.prototype.update=function(h,d){return this._hash.update(typeof h=="string"?l.from(h,d):h),this},a.prototype.sign=function(h,d){this.end();var b=this._hash.digest(),p=u(b,h,this._hashType,this._signType,this._tag);return d?p.toString(d):p};function o(c){t.Writable.call(this);var h=s[c];if(!h)throw new Error("Unknown message digest");this._hash=e(h.hash),this._tag=h.id,this._signType=h.sign}n(o,t.Writable),o.prototype._write=function(h,d,b){this._hash.update(h),b()},o.prototype.update=function(h,d){return this._hash.update(typeof h=="string"?l.from(h,d):h),this},o.prototype.verify=function(h,d,b){var p=typeof d=="string"?l.from(d,b):d;this.end();var y=this._hash.digest();return r(p,y,h,this._signType,this._tag)};function f(c){return new a(c)}function i(c){return new o(c)}return Bf={Sign:f,Verify:i,createSign:f,createVerify:i},Bf}var Rf,fh;function n1(){if(fh)return Rf;fh=1;var l=us(),e=Ce();Rf=function(s){return new n(s)};var t={secp256k1:{name:"secp256k1",byteLength:32},secp224r1:{name:"p224",byteLength:28},prime256v1:{name:"p256",byteLength:32},prime192v1:{name:"p192",byteLength:24},ed25519:{name:"ed25519",byteLength:32},secp384r1:{name:"p384",byteLength:48},secp521r1:{name:"p521",byteLength:66}};t.p224=t.secp224r1,t.p256=t.secp256r1=t.prime256v1,t.p192=t.secp192r1=t.prime192v1,t.p384=t.secp384r1,t.p521=t.secp521r1;function n(r){this.curveType=t[r],this.curveType||(this.curveType={name:r}),this.curve=new l.ec(this.curveType.name),this.keys=void 0}n.prototype.generateKeys=function(r,s){return this.keys=this.curve.genKeyPair(),this.getPublicKey(r,s)},n.prototype.computeSecret=function(r,s,a){s=s||"utf8",Buffer.isBuffer(r)||(r=new Buffer(r,s));var o=this.curve.keyFromPublic(r).getPublic(),f=o.mul(this.keys.getPrivate()).getX();return u(f,a,this.curveType.byteLength)},n.prototype.getPublicKey=function(r,s){var a=this.keys.getPublic(s==="compressed",!0);return s==="hybrid"&&(a[a.length-1]%2?a[0]=7:a[0]=6),u(a,r)},n.prototype.getPrivateKey=function(r){return u(this.keys.getPrivate(),r)},n.prototype.setPublicKey=function(r,s){return s=s||"utf8",Buffer.isBuffer(r)||(r=new Buffer(r,s)),this.keys._importPublic(r),this},n.prototype.setPrivateKey=function(r,s){s=s||"utf8",Buffer.isBuffer(r)||(r=new Buffer(r,s));var a=new e(r);return a=a.toString(16),this.keys=this.curve.genKeyPair(),this.keys._importPrivate(a),this};function u(r,s,a){Array.isArray(r)||(r=r.toArray());var o=new Buffer(r);if(a&&o.length<a){var f=new Buffer(a-o.length);f.fill(0),o=Buffer.concat([f,o])}return s?o.toString(s):o}return Rf}var If={},Af,sh;function gd(){if(sh)return Af;sh=1;var l=or(),e=_e().Buffer;Af=function(n,u){for(var r=e.alloc(0),s=0,a;r.length<u;)a=t(s++),r=e.concat([r,l("sha1").update(n).update(a).digest()]);return r.slice(0,u)};function t(n){var u=e.allocUnsafe(4);return u.writeUInt32BE(n,0),u}return Af}var Of,oh;function wd(){return oh||(oh=1,Of=function(e,t){for(var n=e.length,u=-1;++u<n;)e[u]^=t[u];return e}),Of}var Pf,ch;function _d(){if(ch)return Pf;ch=1;var l=Ce(),e=_e().Buffer;function t(n,u){return e.from(n.toRed(l.mont(u.modulus)).redPow(new l(u.publicExponent)).fromRed().toArray())}return Pf=t,Pf}var kf,uh;function a1(){if(uh)return kf;uh=1;var l=Vr(),e=qt(),t=or(),n=gd(),u=wd(),r=Ce(),s=_d(),a=os(),o=_e().Buffer;kf=function(d,b,p){var y;d.padding?y=d.padding:p?y=1:y=4;var v=l(d),g;if(y===4)g=f(v,b);else if(y===1)g=i(v,b,p);else if(y===3){if(g=new r(b),g.cmp(v.modulus)>=0)throw new Error("data too long for modulus")}else throw new Error("unknown padding");return p?a(g,v):s(g,v)};function f(h,d){var b=h.modulus.byteLength(),p=d.length,y=t("sha1").update(o.alloc(0)).digest(),v=y.length,g=2*v;if(p>b-g-2)throw new Error("message too long");var x=o.alloc(b-p-g-2),B=b-v-1,I=e(v),C=u(o.concat([y,x,o.alloc(1,1),d],B),n(I,B)),j=u(I,n(C,v));return new r(o.concat([o.alloc(1),j,C],b))}function i(h,d,b){var p=d.length,y=h.modulus.byteLength();if(p>y-11)throw new Error("message too long");var v;return b?v=o.alloc(y-p-3,255):v=c(y-p-3),new r(o.concat([o.from([0,b?1:2]),v,o.alloc(1),d],y))}function c(h){for(var d=o.allocUnsafe(h),b=0,p=e(h*2),y=0,v;b<h;)y===p.length&&(p=e(h*2),y=0),v=p[y++],v&&(d[b++]=v);return d}return kf}var Nf,hh;function f1(){if(hh)return Nf;hh=1;var l=Vr(),e=gd(),t=wd(),n=Ce(),u=os(),r=or(),s=_d(),a=_e().Buffer;Nf=function(h,d,b){var p;h.padding?p=h.padding:b?p=1:p=4;var y=l(h),v=y.modulus.byteLength();if(d.length>v||new n(d).cmp(y.modulus)>=0)throw new Error("decryption error");var g;b?g=s(new n(d),y):g=u(d,y);var x=a.alloc(v-g.length);if(g=a.concat([x,g],v),p===4)return o(y,g);if(p===1)return f(y,g,b);if(p===3)return g;throw new Error("unknown padding")};function o(c,h){var d=c.modulus.byteLength(),b=r("sha1").update(a.alloc(0)).digest(),p=b.length;if(h[0]!==0)throw new Error("decryption error");var y=h.slice(1,p+1),v=h.slice(p+1),g=t(y,e(v,p)),x=t(v,e(g,d-p-1));if(i(b,x.slice(0,p)))throw new Error("decryption error");for(var B=p;x[B]===0;)B++;if(x[B++]!==1)throw new Error("decryption error");return x.slice(B)}function f(c,h,d){for(var b=h.slice(0,2),p=2,y=0;h[p++]!==0;)if(p>=h.length){y++;break}var v=h.slice(2,p-1);if((b.toString("hex")!=="0002"&&!d||b.toString("hex")!=="0001"&&d)&&y++,v.length<8&&y++,y)throw new Error("decryption error");return h.slice(p)}function i(c,h){c=a.from(c),h=a.from(h);var d=0,b=c.length;c.length!==h.length&&(d++,b=Math.min(c.length,h.length));for(var p=-1;++p<b;)d+=c[p]^h[p];return d}return Nf}var dh;function s1(){return dh||(dh=1,(function(l){l.publicEncrypt=a1(),l.privateDecrypt=f1(),l.privateEncrypt=function(t,n){return l.publicEncrypt(t,n,!0)},l.publicDecrypt=function(t,n){return l.privateDecrypt(t,n,!0)}})(If)),If}var Ut={},lh;function o1(){if(lh)return Ut;lh=1;function l(){throw new Error(`secure random number generation not supported by this browser
6
6
  use chrome, FireFox or Internet Explorer 11`)}var e=_e(),t=qt(),n=e.Buffer,u=e.kMaxLength,r=Re.crypto||Re.msCrypto,s=Math.pow(2,32)-1;function a(h,d){if(typeof h!="number"||h!==h)throw new TypeError("offset must be a number");if(h>s||h<0)throw new TypeError("offset must be a uint32");if(h>u||h>d)throw new RangeError("offset out of range")}function o(h,d,b){if(typeof h!="number"||h!==h)throw new TypeError("size must be a number");if(h>s||h<0)throw new TypeError("size must be a uint32");if(h+d>b||h>u)throw new RangeError("buffer too small")}r&&r.getRandomValues||!process.browser?(Ut.randomFill=f,Ut.randomFillSync=c):(Ut.randomFill=l,Ut.randomFillSync=l);function f(h,d,b,p){if(!n.isBuffer(h)&&!(h instanceof Re.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if(typeof d=="function")p=d,d=0,b=h.length;else if(typeof b=="function")p=b,b=h.length-d;else if(typeof p!="function")throw new TypeError('"cb" argument must be a function');return a(d,h.length),o(b,d,h.length),i(h,d,b,p)}function i(h,d,b,p){if(process.browser){var y=h.buffer,v=new Uint8Array(y,d,b);if(r.getRandomValues(v),p){process.nextTick(function(){p(null,h)});return}return h}if(p){t(b,function(x,B){if(x)return p(x);B.copy(h,d),p(null,h)});return}var g=t(b);return g.copy(h,d),h}function c(h,d,b){if(typeof d>"u"&&(d=0),!n.isBuffer(h)&&!(h instanceof Re.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');return a(d,h.length),b===void 0&&(b=h.length-d),o(b,d,h.length),i(h,d,b)}return Ut}var bh;function c1(){if(bh)return xe;bh=1,xe.randomBytes=xe.rng=xe.pseudoRandomBytes=xe.prng=qt(),xe.createHash=xe.Hash=or(),xe.createHmac=xe.Hmac=Jh();var l=W0(),e=Object.keys(l),t=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(e);xe.getHashes=function(){return t};var n=ns();xe.pbkdf2=n.pbkdf2,xe.pbkdf2Sync=n.pbkdf2Sync;var u=ll();xe.Cipher=u.Cipher,xe.createCipher=u.createCipher,xe.Cipheriv=u.Cipheriv,xe.createCipheriv=u.createCipheriv,xe.Decipher=u.Decipher,xe.createDecipher=u.createDecipher,xe.Decipheriv=u.Decipheriv,xe.createDecipheriv=u.createDecipheriv,xe.getCiphers=u.getCiphers,xe.listCiphers=u.listCiphers;var r=El();xe.DiffieHellmanGroup=r.DiffieHellmanGroup,xe.createDiffieHellmanGroup=r.createDiffieHellmanGroup,xe.getDiffieHellman=r.getDiffieHellman,xe.createDiffieHellman=r.createDiffieHellman,xe.DiffieHellman=r.DiffieHellman;var s=i1();xe.createSign=s.createSign,xe.Sign=s.Sign,xe.createVerify=s.createVerify,xe.Verify=s.Verify,xe.createECDH=n1();var a=s1();xe.publicEncrypt=a.publicEncrypt,xe.privateEncrypt=a.privateEncrypt,xe.publicDecrypt=a.publicDecrypt,xe.privateDecrypt=a.privateDecrypt;var o=o1();return xe.randomFill=o.randomFill,xe.randomFillSync=o.randomFillSync,xe.createCredentials=function(){throw new Error(`sorry, createCredentials is not implemented yet
7
7
  we accept pull requests
8
- https://github.com/browserify/crypto-browserify`)},xe.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},xe}var ph;function lr(){if(ph)return vr.exports;ph=1;var l;vr.exports=function(u){return l||(l=new e(null)),l.generate(u)};function e(n){this.rand=n}if(vr.exports.Rand=e,e.prototype.generate=function(u){return this._rand(u)},e.prototype._rand=function(u){if(this.rand.getBytes)return this.rand.getBytes(u);for(var r=new Uint8Array(u),s=0;s<r.length;s++)r[s]=this.rand.getByte();return r},typeof self=="object")self.crypto&&self.crypto.getRandomValues?e.prototype._rand=function(u){var r=new Uint8Array(u);return self.crypto.getRandomValues(r),r}:self.msCrypto&&self.msCrypto.getRandomValues?e.prototype._rand=function(u){var r=new Uint8Array(u);return self.msCrypto.getRandomValues(r),r}:typeof window=="object"&&(e.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var t=c1();if(typeof t.randomBytes!="function")throw new Error("Not supported");e.prototype._rand=function(u){return t.randomBytes(u)}}catch{}return vr.exports}var Mf={},Tf,vh;function Sd(){if(vh)return Tf;vh=1;var l=Ce(),e=Ft(),t=e.getNAF,n=e.getJSF,u=e.assert;function r(a,o){this.type=a,this.p=new l(o.p,16),this.red=o.prime?l.red(o.prime):l.mont(this.p),this.zero=new l(0).toRed(this.red),this.one=new l(1).toRed(this.red),this.two=new l(2).toRed(this.red),this.n=o.n&&new l(o.n,16),this.g=o.g&&this.pointFromJSON(o.g,o.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var f=this.n&&this.p.div(this.n);!f||f.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}Tf=r,r.prototype.point=function(){throw new Error("Not implemented")},r.prototype.validate=function(){throw new Error("Not implemented")},r.prototype._fixedNafMul=function(o,f){u(o.precomputed);var i=o._getDoubles(),c=t(f,1,this._bitLength),h=(1<<i.step+1)-(i.step%2===0?2:1);h/=3;for(var d=[],b=0;b<c.length;b+=i.step){for(var p=0,f=b+i.step-1;f>=b;f--)p=(p<<1)+c[f];d.push(p)}for(var y=this.jpoint(null,null,null),v=this.jpoint(null,null,null),g=h;g>0;g--){for(var b=0;b<d.length;b++){var p=d[b];p===g?v=v.mixedAdd(i.points[b]):p===-g&&(v=v.mixedAdd(i.points[b].neg()))}y=y.add(v)}return y.toP()},r.prototype._wnafMul=function(o,f){var i=4,c=o._getNAFPoints(i);i=c.wnd;for(var h=c.points,d=t(f,i,this._bitLength),b=this.jpoint(null,null,null),p=d.length-1;p>=0;p--){for(var f=0;p>=0&&d[p]===0;p--)f++;if(p>=0&&f++,b=b.dblp(f),p<0)break;var y=d[p];u(y!==0),o.type==="affine"?y>0?b=b.mixedAdd(h[y-1>>1]):b=b.mixedAdd(h[-y-1>>1].neg()):y>0?b=b.add(h[y-1>>1]):b=b.add(h[-y-1>>1].neg())}return o.type==="affine"?b.toP():b},r.prototype._wnafMulAdd=function(o,f,i,c,h){for(var d=this._wnafT1,b=this._wnafT2,p=this._wnafT3,y=0,v=0;v<c;v++){var g=f[v],x=g._getNAFPoints(o);d[v]=x.wnd,b[v]=x.points}for(var v=c-1;v>=1;v-=2){var B=v-1,I=v;if(d[B]!==1||d[I]!==1){p[B]=t(i[B],d[B],this._bitLength),p[I]=t(i[I],d[I],this._bitLength),y=Math.max(p[B].length,y),y=Math.max(p[I].length,y);continue}var C=[f[B],null,null,f[I]];f[B].y.cmp(f[I].y)===0?(C[1]=f[B].add(f[I]),C[2]=f[B].toJ().mixedAdd(f[I].neg())):f[B].y.cmp(f[I].y.redNeg())===0?(C[1]=f[B].toJ().mixedAdd(f[I]),C[2]=f[B].add(f[I].neg())):(C[1]=f[B].toJ().mixedAdd(f[I]),C[2]=f[B].toJ().mixedAdd(f[I].neg()));var j=[-3,-1,-5,-7,0,7,5,1,3],G=n(i[B],i[I]);y=Math.max(G[0].length,y),p[B]=new Array(y),p[I]=new Array(y);for(var z=0;z<y;z++){var te=G[0][z]|0,ne=G[1][z]|0;p[B][z]=j[(te+1)*3+(ne+1)],p[I][z]=0,b[B]=C}}for(var $=this.jpoint(null,null,null),k=this._wnafT4,v=y;v>=0;v--){for(var m=0;v>=0;){for(var E=!0,z=0;z<c;z++)k[z]=p[z][v]|0,k[z]!==0&&(E=!1);if(!E)break;m++,v--}if(v>=0&&m++,$=$.dblp(m),v<0)break;for(var z=0;z<c;z++){var O=k[z],g;O!==0&&(O>0?g=b[z][O-1>>1]:O<0&&(g=b[z][-O-1>>1].neg()),g.type==="affine"?$=$.mixedAdd(g):$=$.add(g))}}for(var v=0;v<c;v++)b[v]=null;return h?$:$.toP()};function s(a,o){this.curve=a,this.type=o,this.precomputed=null}return r.BasePoint=s,s.prototype.eq=function(){throw new Error("Not implemented")},s.prototype.validate=function(){return this.curve.validate(this)},r.prototype.decodePoint=function(o,f){o=e.toArray(o,f);var i=this.p.byteLength();if((o[0]===4||o[0]===6||o[0]===7)&&o.length-1===2*i){o[0]===6?u(o[o.length-1]%2===0):o[0]===7&&u(o[o.length-1]%2===1);var c=this.point(o.slice(1,1+i),o.slice(1+i,1+2*i));return c}else if((o[0]===2||o[0]===3)&&o.length-1===i)return this.pointFromX(o.slice(1,1+i),o[0]===3);throw new Error("Unknown point format")},s.prototype.encodeCompressed=function(o){return this.encode(o,!0)},s.prototype._encode=function(o){var f=this.curve.p.byteLength(),i=this.getX().toArray("be",f);return o?[this.getY().isEven()?2:3].concat(i):[4].concat(i,this.getY().toArray("be",f))},s.prototype.encode=function(o,f){return e.encode(this._encode(f),o)},s.prototype.precompute=function(o){if(this.precomputed)return this;var f={doubles:null,naf:null,beta:null};return f.naf=this._getNAFPoints(8),f.doubles=this._getDoubles(4,o),f.beta=this._getBeta(),this.precomputed=f,this},s.prototype._hasDoubles=function(o){if(!this.precomputed)return!1;var f=this.precomputed.doubles;return f?f.points.length>=Math.ceil((o.bitLength()+1)/f.step):!1},s.prototype._getDoubles=function(o,f){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],c=this,h=0;h<f;h+=o){for(var d=0;d<o;d++)c=c.dbl();i.push(c)}return{step:o,points:i}},s.prototype._getNAFPoints=function(o){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var f=[this],i=(1<<o)-1,c=i===1?null:this.dbl(),h=1;h<i;h++)f[h]=f[h-1].add(c);return{wnd:o,points:f}},s.prototype._getBeta=function(){return null},s.prototype.dblp=function(o){for(var f=this,i=0;i<o;i++)f=f.dbl();return f},Tf}var Cf,mh;function u1(){if(mh)return Cf;mh=1;var l=Ft(),e=Ce(),t=pe(),n=Sd(),u=l.assert;function r(o){n.call(this,"short",o),this.a=new e(o.a,16).toRed(this.red),this.b=new e(o.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(o),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}t(r,n),Cf=r,r.prototype._getEndomorphism=function(f){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var i,c;if(f.beta)i=new e(f.beta,16).toRed(this.red);else{var h=this._getEndoRoots(this.p);i=h[0].cmp(h[1])<0?h[0]:h[1],i=i.toRed(this.red)}if(f.lambda)c=new e(f.lambda,16);else{var d=this._getEndoRoots(this.n);this.g.mul(d[0]).x.cmp(this.g.x.redMul(i))===0?c=d[0]:(c=d[1],u(this.g.mul(c).x.cmp(this.g.x.redMul(i))===0))}var b;return f.basis?b=f.basis.map(function(p){return{a:new e(p.a,16),b:new e(p.b,16)}}):b=this._getEndoBasis(c),{beta:i,lambda:c,basis:b}}},r.prototype._getEndoRoots=function(f){var i=f===this.p?this.red:e.mont(f),c=new e(2).toRed(i).redInvm(),h=c.redNeg(),d=new e(3).toRed(i).redNeg().redSqrt().redMul(c),b=h.redAdd(d).fromRed(),p=h.redSub(d).fromRed();return[b,p]},r.prototype._getEndoBasis=function(f){for(var i=this.n.ushrn(Math.floor(this.n.bitLength()/2)),c=f,h=this.n.clone(),d=new e(1),b=new e(0),p=new e(0),y=new e(1),v,g,x,B,I,C,j,G=0,z,te;c.cmpn(0)!==0;){var ne=h.div(c);z=h.sub(ne.mul(c)),te=p.sub(ne.mul(d));var $=y.sub(ne.mul(b));if(!x&&z.cmp(i)<0)v=j.neg(),g=d,x=z.neg(),B=te;else if(x&&++G===2)break;j=z,h=c,c=z,p=d,d=te,y=b,b=$}I=z.neg(),C=te;var k=x.sqr().add(B.sqr()),m=I.sqr().add(C.sqr());return m.cmp(k)>=0&&(I=v,C=g),x.negative&&(x=x.neg(),B=B.neg()),I.negative&&(I=I.neg(),C=C.neg()),[{a:x,b:B},{a:I,b:C}]},r.prototype._endoSplit=function(f){var i=this.endo.basis,c=i[0],h=i[1],d=h.b.mul(f).divRound(this.n),b=c.b.neg().mul(f).divRound(this.n),p=d.mul(c.a),y=b.mul(h.a),v=d.mul(c.b),g=b.mul(h.b),x=f.sub(p).sub(y),B=v.add(g).neg();return{k1:x,k2:B}},r.prototype.pointFromX=function(f,i){f=new e(f,16),f.red||(f=f.toRed(this.red));var c=f.redSqr().redMul(f).redIAdd(f.redMul(this.a)).redIAdd(this.b),h=c.redSqrt();if(h.redSqr().redSub(c).cmp(this.zero)!==0)throw new Error("invalid point");var d=h.fromRed().isOdd();return(i&&!d||!i&&d)&&(h=h.redNeg()),this.point(f,h)},r.prototype.validate=function(f){if(f.inf)return!0;var i=f.x,c=f.y,h=this.a.redMul(i),d=i.redSqr().redMul(i).redIAdd(h).redIAdd(this.b);return c.redSqr().redISub(d).cmpn(0)===0},r.prototype._endoWnafMulAdd=function(f,i,c){for(var h=this._endoWnafT1,d=this._endoWnafT2,b=0;b<f.length;b++){var p=this._endoSplit(i[b]),y=f[b],v=y._getBeta();p.k1.negative&&(p.k1.ineg(),y=y.neg(!0)),p.k2.negative&&(p.k2.ineg(),v=v.neg(!0)),h[b*2]=y,h[b*2+1]=v,d[b*2]=p.k1,d[b*2+1]=p.k2}for(var g=this._wnafMulAdd(1,h,d,b*2,c),x=0;x<b*2;x++)h[x]=null,d[x]=null;return g};function s(o,f,i,c){n.BasePoint.call(this,o,"affine"),f===null&&i===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new e(f,16),this.y=new e(i,16),c&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}t(s,n.BasePoint),r.prototype.point=function(f,i,c){return new s(this,f,i,c)},r.prototype.pointFromJSON=function(f,i){return s.fromJSON(this,f,i)},s.prototype._getBeta=function(){if(this.curve.endo){var f=this.precomputed;if(f&&f.beta)return f.beta;var i=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(f){var c=this.curve,h=function(d){return c.point(d.x.redMul(c.endo.beta),d.y)};f.beta=i,i.precomputed={beta:null,naf:f.naf&&{wnd:f.naf.wnd,points:f.naf.points.map(h)},doubles:f.doubles&&{step:f.doubles.step,points:f.doubles.points.map(h)}}}return i}},s.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},s.fromJSON=function(f,i,c){typeof i=="string"&&(i=JSON.parse(i));var h=f.point(i[0],i[1],c);if(!i[2])return h;function d(p){return f.point(p[0],p[1],c)}var b=i[2];return h.precomputed={beta:null,doubles:b.doubles&&{step:b.doubles.step,points:[h].concat(b.doubles.points.map(d))},naf:b.naf&&{wnd:b.naf.wnd,points:[h].concat(b.naf.points.map(d))}},h},s.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},s.prototype.isInfinity=function(){return this.inf},s.prototype.add=function(f){if(this.inf)return f;if(f.inf)return this;if(this.eq(f))return this.dbl();if(this.neg().eq(f))return this.curve.point(null,null);if(this.x.cmp(f.x)===0)return this.curve.point(null,null);var i=this.y.redSub(f.y);i.cmpn(0)!==0&&(i=i.redMul(this.x.redSub(f.x).redInvm()));var c=i.redSqr().redISub(this.x).redISub(f.x),h=i.redMul(this.x.redSub(c)).redISub(this.y);return this.curve.point(c,h)},s.prototype.dbl=function(){if(this.inf)return this;var f=this.y.redAdd(this.y);if(f.cmpn(0)===0)return this.curve.point(null,null);var i=this.curve.a,c=this.x.redSqr(),h=f.redInvm(),d=c.redAdd(c).redIAdd(c).redIAdd(i).redMul(h),b=d.redSqr().redISub(this.x.redAdd(this.x)),p=d.redMul(this.x.redSub(b)).redISub(this.y);return this.curve.point(b,p)},s.prototype.getX=function(){return this.x.fromRed()},s.prototype.getY=function(){return this.y.fromRed()},s.prototype.mul=function(f){return f=new e(f,16),this.isInfinity()?this:this._hasDoubles(f)?this.curve._fixedNafMul(this,f):this.curve.endo?this.curve._endoWnafMulAdd([this],[f]):this.curve._wnafMul(this,f)},s.prototype.mulAdd=function(f,i,c){var h=[this,i],d=[f,c];return this.curve.endo?this.curve._endoWnafMulAdd(h,d):this.curve._wnafMulAdd(1,h,d,2)},s.prototype.jmulAdd=function(f,i,c){var h=[this,i],d=[f,c];return this.curve.endo?this.curve._endoWnafMulAdd(h,d,!0):this.curve._wnafMulAdd(1,h,d,2,!0)},s.prototype.eq=function(f){return this===f||this.inf===f.inf&&(this.inf||this.x.cmp(f.x)===0&&this.y.cmp(f.y)===0)},s.prototype.neg=function(f){if(this.inf)return this;var i=this.curve.point(this.x,this.y.redNeg());if(f&&this.precomputed){var c=this.precomputed,h=function(d){return d.neg()};i.precomputed={naf:c.naf&&{wnd:c.naf.wnd,points:c.naf.points.map(h)},doubles:c.doubles&&{step:c.doubles.step,points:c.doubles.points.map(h)}}}return i},s.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var f=this.curve.jpoint(this.x,this.y,this.curve.one);return f};function a(o,f,i,c){n.BasePoint.call(this,o,"jacobian"),f===null&&i===null&&c===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new e(0)):(this.x=new e(f,16),this.y=new e(i,16),this.z=new e(c,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}return t(a,n.BasePoint),r.prototype.jpoint=function(f,i,c){return new a(this,f,i,c)},a.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var f=this.z.redInvm(),i=f.redSqr(),c=this.x.redMul(i),h=this.y.redMul(i).redMul(f);return this.curve.point(c,h)},a.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},a.prototype.add=function(f){if(this.isInfinity())return f;if(f.isInfinity())return this;var i=f.z.redSqr(),c=this.z.redSqr(),h=this.x.redMul(i),d=f.x.redMul(c),b=this.y.redMul(i.redMul(f.z)),p=f.y.redMul(c.redMul(this.z)),y=h.redSub(d),v=b.redSub(p);if(y.cmpn(0)===0)return v.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var g=y.redSqr(),x=g.redMul(y),B=h.redMul(g),I=v.redSqr().redIAdd(x).redISub(B).redISub(B),C=v.redMul(B.redISub(I)).redISub(b.redMul(x)),j=this.z.redMul(f.z).redMul(y);return this.curve.jpoint(I,C,j)},a.prototype.mixedAdd=function(f){if(this.isInfinity())return f.toJ();if(f.isInfinity())return this;var i=this.z.redSqr(),c=this.x,h=f.x.redMul(i),d=this.y,b=f.y.redMul(i).redMul(this.z),p=c.redSub(h),y=d.redSub(b);if(p.cmpn(0)===0)return y.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var v=p.redSqr(),g=v.redMul(p),x=c.redMul(v),B=y.redSqr().redIAdd(g).redISub(x).redISub(x),I=y.redMul(x.redISub(B)).redISub(d.redMul(g)),C=this.z.redMul(p);return this.curve.jpoint(B,I,C)},a.prototype.dblp=function(f){if(f===0)return this;if(this.isInfinity())return this;if(!f)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var i=this,c=0;c<f;c++)i=i.dbl();return i}for(var h=this.curve.a,d=this.curve.tinv,b=this.x,p=this.y,y=this.z,v=y.redSqr().redSqr(),g=p.redAdd(p),c=0;c<f;c++){var x=b.redSqr(),B=g.redSqr(),I=B.redSqr(),C=x.redAdd(x).redIAdd(x).redIAdd(h.redMul(v)),j=b.redMul(B),G=C.redSqr().redISub(j.redAdd(j)),z=j.redISub(G),te=C.redMul(z);te=te.redIAdd(te).redISub(I);var ne=g.redMul(y);c+1<f&&(v=v.redMul(I)),b=G,y=ne,g=te}return this.curve.jpoint(b,g.redMul(d),y)},a.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},a.prototype._zeroDbl=function(){var f,i,c;if(this.zOne){var h=this.x.redSqr(),d=this.y.redSqr(),b=d.redSqr(),p=this.x.redAdd(d).redSqr().redISub(h).redISub(b);p=p.redIAdd(p);var y=h.redAdd(h).redIAdd(h),v=y.redSqr().redISub(p).redISub(p),g=b.redIAdd(b);g=g.redIAdd(g),g=g.redIAdd(g),f=v,i=y.redMul(p.redISub(v)).redISub(g),c=this.y.redAdd(this.y)}else{var x=this.x.redSqr(),B=this.y.redSqr(),I=B.redSqr(),C=this.x.redAdd(B).redSqr().redISub(x).redISub(I);C=C.redIAdd(C);var j=x.redAdd(x).redIAdd(x),G=j.redSqr(),z=I.redIAdd(I);z=z.redIAdd(z),z=z.redIAdd(z),f=G.redISub(C).redISub(C),i=j.redMul(C.redISub(f)).redISub(z),c=this.y.redMul(this.z),c=c.redIAdd(c)}return this.curve.jpoint(f,i,c)},a.prototype._threeDbl=function(){var f,i,c;if(this.zOne){var h=this.x.redSqr(),d=this.y.redSqr(),b=d.redSqr(),p=this.x.redAdd(d).redSqr().redISub(h).redISub(b);p=p.redIAdd(p);var y=h.redAdd(h).redIAdd(h).redIAdd(this.curve.a),v=y.redSqr().redISub(p).redISub(p);f=v;var g=b.redIAdd(b);g=g.redIAdd(g),g=g.redIAdd(g),i=y.redMul(p.redISub(v)).redISub(g),c=this.y.redAdd(this.y)}else{var x=this.z.redSqr(),B=this.y.redSqr(),I=this.x.redMul(B),C=this.x.redSub(x).redMul(this.x.redAdd(x));C=C.redAdd(C).redIAdd(C);var j=I.redIAdd(I);j=j.redIAdd(j);var G=j.redAdd(j);f=C.redSqr().redISub(G),c=this.y.redAdd(this.z).redSqr().redISub(B).redISub(x);var z=B.redSqr();z=z.redIAdd(z),z=z.redIAdd(z),z=z.redIAdd(z),i=C.redMul(j.redISub(f)).redISub(z)}return this.curve.jpoint(f,i,c)},a.prototype._dbl=function(){var f=this.curve.a,i=this.x,c=this.y,h=this.z,d=h.redSqr().redSqr(),b=i.redSqr(),p=c.redSqr(),y=b.redAdd(b).redIAdd(b).redIAdd(f.redMul(d)),v=i.redAdd(i);v=v.redIAdd(v);var g=v.redMul(p),x=y.redSqr().redISub(g.redAdd(g)),B=g.redISub(x),I=p.redSqr();I=I.redIAdd(I),I=I.redIAdd(I),I=I.redIAdd(I);var C=y.redMul(B).redISub(I),j=c.redAdd(c).redMul(h);return this.curve.jpoint(x,C,j)},a.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var f=this.x.redSqr(),i=this.y.redSqr(),c=this.z.redSqr(),h=i.redSqr(),d=f.redAdd(f).redIAdd(f),b=d.redSqr(),p=this.x.redAdd(i).redSqr().redISub(f).redISub(h);p=p.redIAdd(p),p=p.redAdd(p).redIAdd(p),p=p.redISub(b);var y=p.redSqr(),v=h.redIAdd(h);v=v.redIAdd(v),v=v.redIAdd(v),v=v.redIAdd(v);var g=d.redIAdd(p).redSqr().redISub(b).redISub(y).redISub(v),x=i.redMul(g);x=x.redIAdd(x),x=x.redIAdd(x);var B=this.x.redMul(y).redISub(x);B=B.redIAdd(B),B=B.redIAdd(B);var I=this.y.redMul(g.redMul(v.redISub(g)).redISub(p.redMul(y)));I=I.redIAdd(I),I=I.redIAdd(I),I=I.redIAdd(I);var C=this.z.redAdd(p).redSqr().redISub(c).redISub(y);return this.curve.jpoint(B,I,C)},a.prototype.mul=function(f,i){return f=new e(f,i),this.curve._wnafMul(this,f)},a.prototype.eq=function(f){if(f.type==="affine")return this.eq(f.toJ());if(this===f)return!0;var i=this.z.redSqr(),c=f.z.redSqr();if(this.x.redMul(c).redISub(f.x.redMul(i)).cmpn(0)!==0)return!1;var h=i.redMul(this.z),d=c.redMul(f.z);return this.y.redMul(d).redISub(f.y.redMul(h)).cmpn(0)===0},a.prototype.eqXToP=function(f){var i=this.z.redSqr(),c=f.toRed(this.curve.red).redMul(i);if(this.x.cmp(c)===0)return!0;for(var h=f.clone(),d=this.curve.redN.redMul(i);;){if(h.iadd(this.curve.n),h.cmp(this.curve.p)>=0)return!1;if(c.redIAdd(d),this.x.cmp(c)===0)return!0}},a.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},a.prototype.isInfinity=function(){return this.z.cmpn(0)===0},Cf}var yh;function xd(){return yh||(yh=1,(function(l){var e=l;e.base=Sd(),e.short=u1()})(Mf)),Mf}var Lf={},Df,gh;function h1(){return gh||(gh=1,Df={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}),Df}var wh;function Ed(){return wh||(wh=1,(function(l){var e=l,t=hr(),n=xd(),u=Ft(),r=u.assert;function s(f){if(f.type!=="short")throw new Error("invalid curve type");this.curve=new n.short(f),this.g=this.curve.g,this.n=this.curve.n,this.hash=f.hash,r(this.g.validate(),"Invalid curve"),r(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}e.PresetCurve=s;function a(f,i){Object.defineProperty(e,f,{configurable:!0,enumerable:!0,get:function(){var c=new s(i);return Object.defineProperty(e,f,{configurable:!0,enumerable:!0,value:c}),c}})}var o;try{o=h1()}catch{o=void 0}a("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:t.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",o]})})(Lf)),Lf}var Ff,_h;function d1(){if(_h)return Ff;_h=1;var l=Ce(),e=Ft(),t=e.assert;function n(u,r){this.ec=u,this.priv=null,this.pub=null,r.priv&&this._importPrivate(r.priv,r.privEnc),r.pub&&this._importPublic(r.pub,r.pubEnc)}return Ff=n,n.fromPublic=function(r,s,a){return s instanceof n?s:new n(r,{pub:s,pubEnc:a})},n.fromPrivate=function(r,s,a){return s instanceof n?s:new n(r,{priv:s,privEnc:a})},n.prototype.validate=function(){var r=this.getPublic();return r.isInfinity()?{result:!1,reason:"Invalid public key"}:r.validate()?r.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},n.prototype.getPublic=function(r,s){return typeof r=="string"&&(s=r,r=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),s?this.pub.encode(s,r):this.pub},n.prototype.getPrivate=function(r){return r==="hex"?this.priv.toString(16,2):this.priv},n.prototype._importPrivate=function(r,s){this.priv=new l(r,s||16),this.priv=this.priv.umod(this.ec.curve.n)},n.prototype._importPublic=function(r,s){if(r.x||r.y){this.ec.curve.type==="mont"?t(r.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&t(r.x&&r.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(r.x,r.y);return}this.pub=this.ec.curve.decodePoint(r,s)},n.prototype.derive=function(r){return r.mul(this.priv).getX()},n.prototype.sign=function(r,s,a){return this.ec.sign(r,this,s,a)},n.prototype.verify=function(r,s){return this.ec.verify(r,s,this)},n.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"},Ff}var qf,Sh;function l1(){if(Sh)return qf;Sh=1;var l=Ce(),e=Ft(),t=e.assert;function n(o,f){if(o instanceof n)return o;this._importDER(o,f)||(t(o.r&&o.s,"Signature without r or s"),this.r=new l(o.r,16),this.s=new l(o.s,16),o.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=o.recoveryParam)}qf=n;function u(){this.place=0}function r(o,f){var i=o[f.place++];if(!(i&128))return i;for(var c=i&15,h=0,d=0,b=f.place;d<c;d++,b++)h<<=8,h|=o[b];return f.place=b,h}function s(o){for(var f=0,i=o.length-1;!o[f]&&!(o[f+1]&128)&&f<i;)f++;return f===0?o:o.slice(f)}n.prototype._importDER=function(f,i){f=e.toArray(f,i);var c=new u;if(f[c.place++]!==48)return!1;var h=r(f,c);if(h+c.place!==f.length||f[c.place++]!==2)return!1;var d=r(f,c),b=f.slice(c.place,d+c.place);if(c.place+=d,f[c.place++]!==2)return!1;var p=r(f,c);if(f.length!==p+c.place)return!1;var y=f.slice(c.place,p+c.place);return b[0]===0&&b[1]&128&&(b=b.slice(1)),y[0]===0&&y[1]&128&&(y=y.slice(1)),this.r=new l(b),this.s=new l(y),this.recoveryParam=null,!0};function a(o,f){if(f<128){o.push(f);return}var i=1+(Math.log(f)/Math.LN2>>>3);for(o.push(i|128);--i;)o.push(f>>>(i<<3)&255);o.push(f)}return n.prototype.toDER=function(f){var i=this.r.toArray(),c=this.s.toArray();for(i[0]&128&&(i=[0].concat(i)),c[0]&128&&(c=[0].concat(c)),i=s(i),c=s(c);!c[0]&&!(c[1]&128);)c=c.slice(1);var h=[2];a(h,i.length),h=h.concat(i),h.push(2),a(h,c.length);var d=h.concat(c),b=[48];return a(b,d.length),b=b.concat(d),e.encode(b,f)},qf}var Uf,xh;function b1(){if(xh)return Uf;xh=1;var l=Ce(),e=bd(),t=Ft(),n=Ed(),u=lr(),r=t.assert,s=d1(),a=l1();function o(f){if(!(this instanceof o))return new o(f);typeof f=="string"&&(r(n.hasOwnProperty(f),"Unknown curve "+f),f=n[f]),f instanceof n.PresetCurve&&(f={curve:f}),this.curve=f.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=f.curve.g,this.g.precompute(f.curve.n.bitLength()+1),this.hash=f.hash||f.curve.hash}return Uf=o,o.prototype.keyPair=function(i){return new s(this,i)},o.prototype.keyFromPrivate=function(i,c){return s.fromPrivate(this,i,c)},o.prototype.keyFromPublic=function(i,c){return s.fromPublic(this,i,c)},o.prototype.genKeyPair=function(i){i||(i={});var c=new e({hash:this.hash,pers:i.pers,persEnc:i.persEnc||"utf8",entropy:i.entropy||u(this.hash.hmacStrength),entropyEnc:i.entropy&&i.entropyEnc||"utf8",nonce:this.n.toArray()}),h=this.n.byteLength(),d=this.n.sub(new l(2));do{var b=new l(c.generate(h));if(!(b.cmp(d)>0))return b.iaddn(1),this.keyFromPrivate(b)}while(!0)},o.prototype._truncateToN=function(i,c){var h=i.byteLength()*8-this.n.bitLength();return h>0&&(i=i.ushrn(h)),!c&&i.cmp(this.n)>=0?i.sub(this.n):i},o.prototype.sign=function(i,c,h,d){typeof h=="object"&&(d=h,h=null),d||(d={}),c=this.keyFromPrivate(c,h),i=this._truncateToN(new l(i,16));for(var b=this.n.byteLength(),p=c.getPrivate().toArray("be",b),y=i.toArray("be",b),v=new e({hash:this.hash,entropy:p,nonce:y,pers:d.pers,persEnc:d.persEnc||"utf8"}),g=this.n.sub(new l(1)),x=0;;x++){var B=d.k?d.k(x):new l(v.generate(this.n.byteLength()));if(B=this._truncateToN(B,!0),!(B.cmpn(1)<=0||B.cmp(g)>=0)){var I=this.g.mul(B);if(!I.isInfinity()){var C=I.getX(),j=C.umod(this.n);if(j.cmpn(0)!==0){var G=B.invm(this.n).mul(j.mul(c.getPrivate()).iadd(i));if(G=G.umod(this.n),G.cmpn(0)!==0){var z=(I.getY().isOdd()?1:0)|(C.cmp(j)!==0?2:0);return d.canonical&&G.cmp(this.nh)>0&&(G=this.n.sub(G),z^=1),new a({r:j,s:G,recoveryParam:z})}}}}}},o.prototype.verify=function(i,c,h,d){i=this._truncateToN(new l(i,16)),h=this.keyFromPublic(h,d),c=new a(c,"hex");var b=c.r,p=c.s;if(b.cmpn(1)<0||b.cmp(this.n)>=0||p.cmpn(1)<0||p.cmp(this.n)>=0)return!1;var y=p.invm(this.n),v=y.mul(i).umod(this.n),g=y.mul(b).umod(this.n);if(!this.curve._maxwellTrick){var x=this.g.mulAdd(v,h.getPublic(),g);return x.isInfinity()?!1:x.getX().umod(this.n).cmp(b)===0}var x=this.g.jmulAdd(v,h.getPublic(),g);return x.isInfinity()?!1:x.eqXToP(b)},o.prototype.recoverPubKey=function(f,i,c,h){r((3&c)===c,"The recovery param is more than two bits"),i=new a(i,h);var d=this.n,b=new l(f),p=i.r,y=i.s,v=c&1,g=c>>1;if(p.cmp(this.curve.p.umod(this.curve.n))>=0&&g)throw new Error("Unable to find sencond key candinate");g?p=this.curve.pointFromX(p.add(this.curve.n),v):p=this.curve.pointFromX(p,v);var x=i.r.invm(d),B=d.sub(b).mul(x).umod(d),I=y.mul(x).umod(d);return this.g.mulAdd(B,p,I)},o.prototype.getKeyRecoveryParam=function(f,i,c,h){if(i=new a(i,h),i.recoveryParam!==null)return i.recoveryParam;for(var d=0;d<4;d++){var b;try{b=this.recoverPubKey(f,i,d)}catch{continue}if(b.eq(c))return d}throw new Error("Unable to find valid recovery factor")},Uf}var Eh;function p1(){return Eh||(Eh=1,(function(l){var e=l;e.version=Fd.version,e.utils=Ft(),e.rand=lr(),e.curve=xd(),e.curves=Ed(),e.ec=b1()})(bi)),bi}var v1=p1();const Bd=zt(v1);var m1=hr();const br=zt(m1);var y1=ns();const Rd=zt(y1);var g1=xt();const w1="2.2.2",_1={version:w1};function Z(l,e,t){if(!(this instanceof Z))return new Z(l,e,t);if(l&&(l instanceof ct||l.constructor.name==="BN"||l.constructor.name==="Bn")){ct.call(this,0),l.copy(this),this.negative=l.negative,this.length=l.length,this.red=l.red;return}ct.call(this,l,e,t)}Z.prototype=Object.create(ct.prototype);Z.prototype.constructor=Z;Object.keys(ct).forEach(function(l){Z[l]||(Z[l]=ct[l])});function Gr(l){const e=Buffer.alloc(l.length);for(let t=0;t<l.length;t++)e[t]=l[l.length-1-t];return e}Z.prototype.fromHex=function(l,e){return this.fromBuffer(Buffer.from(l,"hex"),e)};Z.prototype.toHex=function(l){return this.toBuffer(l).toString("hex")};Z.prototype.toJSON=function(){return this.toString()};Z.prototype.fromJSON=function(l){return new Z(l).copy(this),this};Z.prototype.fromNumber=function(l){return new Z(l).copy(this),this};Z.prototype.toNumber=function(){return parseInt(this.toString(10),10)};Z.prototype.fromString=function(l,e){return new Z(l,e).copy(this),this};Z.fromBuffer=function(l,e={endian:"big"}){e.endian==="little"&&(l=Gr(l));const t=l.toString("hex");return new Z(t,16)};Z.prototype.fromBuffer=function(l,e){return Z.fromBuffer(l,e).copy(this),this};Z.prototype.toBuffer=function(l={size:void 0,endian:"big"}){let e;if(l.size){const n=this.toString(16,2),u=n.length/2;if(e=Buffer.from(n,"hex"),u!==l.size){if(u>l.size)e=e.slice(u-e.length,e.length);else if(u<l.size){const r=Buffer.alloc(l.size);for(let s=0;s<e.length;s++)r[r.length-1-s]=e[e.length-1-s];for(let s=0;s<l.size-u;s++)r[s]=0;e=r}}}else{const n=this.toString(16,2);e=Buffer.from(n,"hex")}l.endian==="little"&&(e=Gr(e));const t=Buffer.from([0]);return Buffer.compare(e,t)===0?Buffer.from([]):e};Z.prototype.toFastBuffer=function(l){return this.toBuffer(l)};Z.fromFastBuffer=Z.fromBuffer;Z.prototype.fromFastBuffer=Z.prototype.fromBuffer;Z.prototype.fromSm=function(l,e={endian:"big"}){if(l.length===0)return this.fromBuffer(Buffer.from([0])),this.negative=0,this;let t=Buffer.from(l);return e.endian==="little"&&(t=Gr(t)),t[0]&128?(t[0]=t[0]&127,this.fromBuffer(t),this.ineg()):(this.fromBuffer(t),this.negative=0),this};Z.prototype.toSm=function(l={endian:"big"}){const e=l.endian;let t;return this.negative?(t=this.abs().toBuffer(),t.length>0&&t[0]&128?t=Buffer.concat([Buffer.from([128]),t]):t.length>0?t[0]=t[0]|128:t=Buffer.from([128])):(t=this.toBuffer(),t.length>0&&t[0]&128&&(t=Buffer.concat([Buffer.from([0]),t]))),t.length===1&&t[0]===0&&(t=Buffer.from([])),e==="little"&&(t=Gr(t)),t};Z.prototype.fromBits=function(l,e={strict:!1}){let t=Buffer.alloc(4);if(t.writeUInt32BE(l,0),l=t.readInt32BE(0),e.strict&&l&8388608)throw new Error("negative bit set");const n=l>>24,u=l&8388607;if(t=Buffer.alloc(4),t.writeInt32BE(u),n<=3)t=t.slice(1,n+1);else{const r=Buffer.alloc(n-3);r.fill(0),t=Buffer.concat([t,r])}return this.fromBuffer(t),l&8388608&&this.ineg(),this};Z.prototype.toBits=function(){const l=this.negative,t=this.abs().toBuffer();let n=t.length,u;if(n>3)u=Buffer.concat([Buffer.from([0]),t.slice(0,3)]).readUInt32BE(0);else if(n<=3){const a=Buffer.alloc(3-n+1);a.fill(0),u=Buffer.concat([a,t.slice(0,n)]).readUInt32BE(0)}u&8388608&&(u>>=8,n++),l&&(u|=8388608);const r=n<<24|u,s=Buffer.alloc(4);return s.writeInt32BE(r,0),s.readUInt32BE(0)};Z.prototype.fromScriptNumBuffer=function(l,e,t){if(t===void 0&&(t=4),l.length>t)throw new Error(`script number overflow nMaxNumSize: ${t}`);if(e&&l.length>0&&(l[l.length-1]&127)===0&&(l.length<=1||(l[l.length-2]&128)===0))throw new Error("non-minimally encoded script number");return this.fromSm(l,{endian:"little"})};Z.prototype.toScriptNumBuffer=function(){return this.toSm({endian:"little"})};const pr=function(l){return l&&(l instanceof ct||l.constructor.name==="BN"||l.constructor.name==="Bn")&&!(l instanceof Z)?new Z(l):l},S1=["add","sub","mul","div","mod","umod","invm","and","or","xor","redAdd","redSub","redMul","redPow","gcd","egcd","lcm"];S1.forEach(l=>{const e=ct.prototype[l];Z.prototype[l]=function(t,...n){return(typeof t=="string"||typeof t=="number")&&(t=new Z(t)),pr(e.call(this,t,...n))}});const x1=["ushln","ushrn","shln","shrn","testn","maskn","setn","clrn","bincn"];x1.forEach(l=>{const e=ct.prototype[l];Z.prototype[l]=function(t,...n){return t&&(t instanceof ct||t.constructor.name==="BN"||t.constructor.name==="Bn")&&(t=t.toNumber()),pr(e.call(this,t,...n))}});const E1=["sqr","neg","abs","not","redSqr","redSqrt","redNeg"];E1.forEach(l=>{const e=ct.prototype[l];Z.prototype[l]=function(){return pr(e.call(this))}});Z.prototype.toRed=function(l){return pr(ct.prototype.toRed.call(this,l))};Z.prototype.fromRed=function(){return pr(ct.prototype.fromRed.call(this))};const B1=["cmp","gt","geq","lt","leq","eq","neq"];B1.forEach(l=>{const e=ct.prototype.cmp;Z.prototype[l]=function(t){(typeof t=="string"||typeof t=="number")&&(t=new Z(t));const n=e.call(this,t);return l==="eq"?n===0:l==="neq"?n!==0:l==="gt"?n>0:l==="geq"?n>=0:l==="lt"?n<0:l==="leq"?n<=0:n}});class ot{constructor(e){this.fromObject({buf:e})}fromObject(e){return this.buf=e.buf||this.buf||void 0,this.pos=e.pos||this.pos||0,this}eof(){return this.pos>=this.buf.length}read(e=this.buf.length){const t=this.buf.slice(this.pos,this.pos+e);return this.pos=this.pos+e,t}readReverse(e=this.buf.length){const t=this.buf.slice(this.pos,this.pos+e);this.pos=this.pos+e;const n=Buffer.alloc(t.length);for(let u=0;u<n.length;u++)n[u]=t[t.length-1-u];return n}readUInt8(){const e=this.buf.readUInt8(this.pos);return this.pos=this.pos+1,e}readInt8(){const e=this.buf.readInt8(this.pos);return this.pos=this.pos+1,e}readUInt16BE(){const e=this.buf.readUInt16BE(this.pos);return this.pos=this.pos+2,e}readInt16BE(){const e=this.buf.readInt16BE(this.pos);return this.pos=this.pos+2,e}readUInt16LE(){const e=this.buf.readUInt16LE(this.pos);return this.pos=this.pos+2,e}readInt16LE(){const e=this.buf.readInt16LE(this.pos);return this.pos=this.pos+2,e}readUInt32BE(){const e=this.buf.readUInt32BE(this.pos);return this.pos=this.pos+4,e}readInt32BE(){const e=this.buf.readInt32BE(this.pos);return this.pos=this.pos+4,e}readUInt32LE(){const e=this.buf.readUInt32LE(this.pos);return this.pos=this.pos+4,e}readInt32LE(){const e=this.buf.readInt32LE(this.pos);return this.pos=this.pos+4,e}readUInt64BEBn(){const e=this.buf.slice(this.pos,this.pos+8),t=new Z().fromBuffer(e);return this.pos=this.pos+8,t}readUInt64LEBn(){const e=this.readReverse(8);return new Z().fromBuffer(e)}readVarIntNum(){const e=this.readUInt8();let t,n;switch(e){case 253:return this.readUInt16LE();case 254:return this.readUInt32LE();case 255:if(t=this.readUInt64LEBn(),n=t.toNumber(),n<=Math.pow(2,53))return n;throw new Error("number too large to retain precision - use readVarIntBn");default:return e}}readVarIntBuf(){switch(this.buf.readUInt8(this.pos)){case 253:return this.read(3);case 254:return this.read(5);case 255:return this.read(9);default:return this.read(1)}}readVarIntBn(){const e=this.readUInt8();switch(e){case 253:return new Z(this.readUInt16LE());case 254:return new Z(this.readUInt32LE());case 255:return this.readUInt64LEBn();default:return new Z(e)}}}class ke{constructor(e){this.fromObject({bufs:e})}fromObject(e){return this.bufs=e.bufs||this.bufs||[],this}getLength(){let e=0;for(const t in this.bufs){const n=this.bufs[t];e=e+n.length}return e}toBuffer(){return Buffer.concat(this.bufs)}write(e){return this.bufs.push(e),this}writeReverse(e){const t=Buffer.alloc(e.length);for(let n=0;n<t.length;n++)t[n]=e[e.length-1-n];return this.bufs.push(t),this}writeUInt8(e){const t=Buffer.alloc(1);return t.writeUInt8(e,0),this.write(t),this}writeInt8(e){const t=Buffer.alloc(1);return t.writeInt8(e,0),this.write(t),this}writeUInt16BE(e){const t=Buffer.alloc(2);return t.writeUInt16BE(e,0),this.write(t),this}writeInt16BE(e){const t=Buffer.alloc(2);return t.writeInt16BE(e,0),this.write(t),this}writeUInt16LE(e){const t=Buffer.alloc(2);return t.writeUInt16LE(e,0),this.write(t),this}writeInt16LE(e){const t=Buffer.alloc(2);return t.writeInt16LE(e,0),this.write(t),this}writeUInt32BE(e){const t=Buffer.alloc(4);return t.writeUInt32BE(e,0),this.write(t),this}writeInt32BE(e){const t=Buffer.alloc(4);return t.writeInt32BE(e,0),this.write(t),this}writeUInt32LE(e){const t=Buffer.alloc(4);return t.writeUInt32LE(e,0),this.write(t),this}writeInt32LE(e){const t=Buffer.alloc(4);return t.writeInt32LE(e,0),this.write(t),this}writeUInt64BEBn(e){const t=e.toBuffer({size:8});return this.write(t),this}writeUInt64LEBn(e){const t=e.toBuffer({size:8});return this.writeReverse(t),this}writeVarIntNum(e){const t=ke.varIntBufNum(e);return this.write(t),this}writeVarIntBn(e){const t=ke.varIntBufBn(e);return this.write(t),this}static varIntBufNum(e){let t;return e<253?(t=Buffer.alloc(1),t.writeUInt8(e,0)):e<65536?(t=Buffer.alloc(3),t.writeUInt8(253,0),t.writeUInt16LE(e,1)):e<4294967296?(t=Buffer.alloc(5),t.writeUInt8(254,0),t.writeUInt32LE(e,1)):(t=Buffer.alloc(9),t.writeUInt8(255,0),t.writeInt32LE(e&-1,1),t.writeUInt32LE(Math.floor(e/4294967296),5)),t}static varIntBufBn(e){let t;const n=e.toNumber();if(n<253)t=Buffer.alloc(1),t.writeUInt8(n,0);else if(n<65536)t=Buffer.alloc(3),t.writeUInt8(253,0),t.writeUInt16LE(n,1);else if(n<4294967296)t=Buffer.alloc(5),t.writeUInt8(254,0),t.writeUInt32LE(n,1);else{const u=new ke;u.writeUInt8(255),u.writeUInt64LEBn(e),t=u.toBuffer()}return t}}function R1(l){const e=typeof l=="string"?l.charCodeAt(0):l;return e>=97&&e<=102||e>=65&&e<=70||e>=48&&e<=57}const Hf=R1;class Te{constructor(e){this.fromObject(e)}fromObject(e){if(!e)return this;for(const t of Object.keys(e))e[t]!==void 0&&(this[t]=e[t]);return this}static fromObject(e){return new this().fromObject(e)}fromBr(e){throw e instanceof ot?new Error("not implemented"):new Error("br must be a buffer reader")}static fromBr(e){return new this().fromBr(e)}asyncFromBr(e){throw e instanceof ot?new Error("not implemented"):new Error("br must be a buffer reader")}static asyncFromBr(e){return new this().asyncFromBr(e)}toBw(e){throw new Error("not implemented")}asyncToBw(e){throw new Error("not implemented")}*genFromBuffers(){throw new Error("not implemented")}*expect(e,t){let n=t;const u=new ke;let r=0;for(t&&(u.write(t),r+=t.length);r<e;)n=yield e-r,n&&(u.write(n),r+=n.length);n=u.toBuffer();const s=r-e,a=n.slice(n.length-s,n.length);return n=n.slice(0,n.length-s),{buf:n,remainderbuf:a}}fromBuffer(e,...t){if(!Buffer.isBuffer(e))throw new Error("buf must be a buffer");const n=new ot(e);return this.fromBr(n,...t)}static fromBuffer(...e){return new this().fromBuffer(...e)}asyncFromBuffer(e,...t){if(!Buffer.isBuffer(e))throw new Error("buf must be a buffer");const n=new ot(e);return this.asyncFromBr(n,...t)}static asyncFromBuffer(e,...t){return new this().asyncFromBuffer(e,...t)}fromFastBuffer(e,...t){return e.length===0?this:this.fromBuffer(e,...t)}static fromFastBuffer(...e){return new this().fromFastBuffer(...e)}toBuffer(...e){return this.toBw(...e).toBuffer()}asyncToBuffer(...e){return this.asyncToBw(...e).then(t=>t.toBuffer())}toFastBuffer(...e){return Object.keys(this).length===0?Buffer.alloc(0):this.toBuffer(...e)}fromHex(e,...t){if(!Hf(e))throw new Error("invalid hex string");const n=Buffer.from(e,"hex");return this.fromBuffer(n,...t)}static fromHex(e,...t){return new this().fromHex(e,...t)}asyncFromHex(e,...t){if(!Hf(e))throw new Error("invalid hex string");const n=Buffer.from(e,"hex");return this.asyncFromBuffer(n,...t)}static asyncFromHex(e,...t){return new this().asyncFromHex(e,...t)}fromFastHex(e,...t){if(!Hf(e))throw new Error("invalid hex string");const n=Buffer.from(e,"hex");return this.fromFastBuffer(n,...t)}static fromFastHex(e,...t){return new this().fromFastHex(e,...t)}toHex(...e){return this.toBuffer(...e).toString("hex")}asyncToHex(...e){return this.asyncToBuffer(...e).then(t=>t.toString("hex"))}toFastHex(...e){return this.toFastBuffer(...e).toString("hex")}fromString(e,...t){if(typeof e!="string")throw new Error("str must be a string");return this.fromHex(e,...t)}static fromString(e,...t){return new this().fromString(e,...t)}asyncFromString(e,...t){if(typeof e!="string")throw new Error("str must be a string");return this.asyncFromHex(e,...t)}static asyncFromString(e,...t){return new this().asyncFromString(e,...t)}toString(...e){return this.toHex(...e)}asyncToString(...e){return this.asyncToHex(...e)}fromJSON(e){throw new Error("not implemented")}static fromJSON(e,...t){return new this().fromJSON(e,...t)}asyncFromJSON(e,...t){throw new Error("not implemented")}static asyncFromJSON(e,...t){return new this().asyncFromJSON(e,...t)}toJSON(){let e={};for(const t in this)if(Array.isArray(this[t])){const n=[];for(const u in this[t])typeof this[t][u].toJSON=="function"?n.push(this[t][u].toJSON()):n.push(JSON.stringify(this[t][u]));e[t]=n}else if(this[t]===null)e[t]=this[t];else if(typeof this[t]=="object"&&typeof this[t].toJSON=="function")e[t]=this[t].toJSON();else if(typeof this[t]=="boolean"||typeof this[t]=="number"||typeof this[t]=="string")e[t]=this[t];else if(Buffer.isBuffer(this[t]))e[t]=this[t].toString("hex");else if(this[t]instanceof Map)e[t]=JSON.stringify(this[t]);else if(typeof this[t]=="object")throw new Error("not implemented");return e}asyncToJSON(){throw new Error("not implemented")}clone(){return this.cloneByJSON()}cloneByBuffer(){return new this.constructor().fromBuffer(this.toBuffer())}cloneByFastBuffer(){return new this.constructor().fromFastBuffer(this.toFastBuffer())}cloneByHex(){return new this.constructor().fromHex(this.toHex())}cloneByString(){return new this.constructor().fromString(this.toString())}cloneByJSON(){return new this.constructor().fromJSON(this.toJSON())}}class jt extends Te{constructor(e){super({buf:e})}fromHex(e){return this.fromBuffer(Buffer.from(e,"hex"))}toHex(){return this.toBuffer().toString("hex")}static encode(e){if(!Buffer.isBuffer(e))throw new Error("Input should be a buffer");return jf.encode(e)}static decode(e){if(typeof e!="string")throw new Error("Input should be a string");return Buffer.from(jf.decode(e))}fromBuffer(e){return this.buf=e,this}fromString(e){const t=jt.decode(e);return this.buf=t,this}toBuffer(){return this.buf}toString(){return jt.encode(this.buf)}}const kt=(l,e)=>{if(!Buffer.isBuffer(l)||!Buffer.isBuffer(e))throw new Error("buf1 and buf2 must be buffers");if(l.length!==e.length)return!1;let t=0;for(let n=0;n<l.length;n++){const u=l[n],r=e[n];t|=u^r}return t===0};class Vf extends Te{constructor(e,t,n){super({resbuf:e,isError:t,id:n})}fromResult(e,t){return e.toFastBuffer?this.resbuf=e.toFastBuffer():Buffer.isBuffer(e)?this.resbuf=e:this.resbuf=Buffer.from(JSON.stringify(e)),this.isError=!1,this.id=t,this}static fromResult(e,t){return new this().fromResult(e,t)}fromError(e,t){return this.resbuf=Buffer.from(JSON.stringify(e.message)),this.isError=!0,this.id=t,this}toBw(e){return e||(e=new ke),e.writeVarIntNum(this.resbuf.length),e.write(this.resbuf),e.writeUInt8(Number(this.isError)),e.writeVarIntNum(this.id),e}fromBr(e){const t=e.readVarIntNum();return this.resbuf=e.read(t),this.isError=!!e.readUInt8(),this.id=e.readVarIntNum(),this}}let Ot;class le{constructor(e=[],t=0,n=[],u=new Map){this.nativeWorkers=e,this.lastid=t,this.incompconsteRes=n,this.promisemap=u}asyncObjectMethod(e,t,n,u=this.lastid+1){if(!n)throw new Error("must specify args");const r=e[t](...n);return new Vf().fromResult(r,u)}static asyncObjectMethod(e,t,n,u){return Ot||(Ot=new le),Ot.asyncObjectMethod(e,t,n,u)}asyncClassMethod(e,t,n,u=this.lastid+1){if(!n)throw new Error("must specify args");const r=e[t](...n);return new Vf().fromResult(r,u)}static asyncClassMethod(e,t,n,u){return Ot||(Ot=new le),Ot.asyncClassMethod(e,t,n,u)}static endGlobalWorkers(){Ot&&!process.browser&&(Ot=void 0)}}class ae{}ae.sha1=function(l){if(!Buffer.isBuffer(l))throw new Error("sha1 hash must be of a buffer");const e=br.sha1,t=new e().update(l).digest();return Buffer.from(t)};ae.sha1.blockSize=512;ae.asyncSha1=async function(l){const e=[l];return(await le.asyncClassMethod(ae,"sha1",e)).resbuf};ae.sha256=function(l){if(!Buffer.isBuffer(l))throw new Error("sha256 hash must be of a buffer");const e=br.sha256,t=new e().update(l).digest();return Buffer.from(t)};ae.sha256.blockSize=512;ae.asyncSha256=async function(l){const e=[l];return(await le.asyncClassMethod(ae,"sha256",e)).resbuf};ae.sha256Sha256=function(l){try{return ae.sha256(ae.sha256(l))}catch(e){throw new Error("sha256Sha256 hash must be of a buffer: "+e)}};ae.asyncSha256Sha256=async function(l){const e=[l];return(await le.asyncClassMethod(ae,"sha256Sha256",e)).resbuf};ae.ripemd160=function(l){if(!Buffer.isBuffer(l))throw new Error("ripemd160 hash must be of a buffer");const e=br.ripemd160,t=new e().update(l).digest();return Buffer.from(t)};ae.asyncRipemd160=async function(l){const e=[l];return(await le.asyncClassMethod(ae,"ripemd160",e)).resbuf};ae.sha256Ripemd160=function(l){try{return ae.ripemd160(ae.sha256(l))}catch(e){throw new Error("sha256Ripemd160 hash must be of a buffer: "+e)}};ae.asyncSha256Ripemd160=async function(l){const e=[l];return(await le.asyncClassMethod(ae,"sha256Ripemd160",e)).resbuf};ae.sha512=function(l){if(!Buffer.isBuffer(l))throw new Error("sha512 hash must be of a buffer");const e=br.sha512,t=new e().update(l).digest();return Buffer.from(t)};ae.asyncSha512=async function(l){const e=[l];return(await le.asyncClassMethod(ae,"sha512",e)).resbuf};ae.sha512.blockSize=1024;ae.hmac=function(l,e,t){if(l!=="sha1"&&l!=="sha256"&&l!=="sha512")throw new Error("invalid choice of hash function");const n=ae[l];if(!Buffer.isBuffer(e)||!Buffer.isBuffer(t))throw new Error("data and key must be buffers");const u=n.blockSize/8;if(t.length>u&&(t=n(t)),t.length<u){const a=Buffer.alloc(u);a.fill(0,t.length),t.copy(a),t=a}const r=Buffer.alloc(u),s=Buffer.alloc(u);for(let a=0;a<u;a++)r[a]=92^t[a],s[a]=54^t[a];return n(Buffer.concat([r,n(Buffer.concat([s,e]))]))};ae.sha1Hmac=function(l,e){return ae.hmac("sha1",l,e)};ae.asyncSha1Hmac=async function(l,e){const t=[l,e];return(await le.asyncClassMethod(ae,"sha1Hmac",t)).resbuf};ae.sha1Hmac.bitsize=160;ae.sha256Hmac=function(l,e){return ae.hmac("sha256",l,e)};ae.asyncSha256Hmac=async function(l,e){const t=[l,e];return(await le.asyncClassMethod(ae,"sha256Hmac",t)).resbuf};ae.sha256Hmac.bitsize=256;ae.sha512Hmac=function(l,e){return ae.hmac("sha512",l,e)};ae.asyncSha512Hmac=async function(l,e){const t=[l,e];return(await le.asyncClassMethod(ae,"sha512Hmac",t)).resbuf};ae.sha512Hmac.bitsize=512;class Bt extends Te{constructor(e){super({buf:e})}fromHex(e){return this.fromBuffer(Buffer.from(e,"hex"))}toHex(){return this.toBuffer().toString("hex")}static decode(e){if(typeof e!="string")throw new Error("Input must be a string");const t=jt.decode(e);if(t.length<4)throw new Error("Input string too short");const n=t.slice(0,-4),u=t.slice(-4),s=ae.sha256Sha256(n).slice(0,4);if(!kt(u,s))throw new Error("Checksum mismatch");return n}static encode(e){if(!Buffer.isBuffer(e))throw new Error("Input must be a buffer");const t=Buffer.alloc(e.length+4),n=ae.sha256Sha256(e);return e.copy(t),n.copy(t,e.length),jt.encode(t)}fromBuffer(e){return this.buf=e,this}fromString(e){const t=Bt.decode(e);return this.buf=t,this}toBuffer(){return this.buf}toString(){return Bt.encode(this.buf)}}class I1{constructor(e){this.keyDefined=t=>t in e,this.getValue=t=>e[t]}get(e){if(this.keyDefined(e))return this.getValue(e);throw new Error(`Unknown configuration: ${e}`)}}class A1{constructor(){this.variables={}}build(){return new I1(this.variables)}addValue(e,t){if(t===void 0)throw new Error(`Failed to add "${e}" property. The value cannot be undefined`);if(e in this.variables)throw new Error(`"${e}" already has a value defined.`);return this.variables[e]=t,this}addValueWithDefault(e,t,n){if(n===void 0)throw new Error(`Failed to add "${e}" property. Default value cannot be undefined`);return this.addValue(e,t===void 0?n:t)}}const Jt=new A1().addValue("NETWORK","mainnet").build(),Oe={};Oe.Mainnet={MaxSize:33554432,Port:8333,Address:{pubKeyHash:0,payToScriptHash:5},Bip32:{pubKey:76067358,privKey:76066276},Block:{maxNBits:486604799,magicNum:3823236072},Msg:{magicNum:3823236072,versionBytesNum:70015},PrivKey:{versionByteNum:128},TxBuilder:{dust:0,feePerKbNum:1},Workers:{timeout:6e4}};Oe.Testnet=Object.assign({},Oe.Mainnet,{Port:18333,Address:{pubKeyHash:111,payToScriptHash:196},Bip32:{pubKey:70617039,privKey:70615956},Block:{maxNBits:486604799,magicNum:4108710900},Msg:{magicNum:4108710900,versionBytesNum:70015},PrivKey:{versionByteNum:239}});Oe.Regtest=Object.assign({},Oe.Mainnet,{Port:18444,Address:{pubKeyHash:111,payToScriptHash:196},Bip32:{pubKey:70617039,privKey:70615956},Block:{maxNBits:545259519,magicNum:3669344250},Msg:{magicNum:3669344250,versionBytesNum:70015},PrivKey:{versionByteNum:239}});Oe.STN=Object.assign({},Oe.Mainnet,{Port:9333,Address:{pubKeyHash:111,payToScriptHash:196},Bip32:{pubKey:70617039,privKey:70615956},Block:{maxNBits:486604799,magicNum:4224632057},Msg:{magicNum:4224632057,versionBytesNum:70015},PrivKey:{versionByteNum:239}});if(Jt.get("NETWORK")==="testnet")Oe.Default=Object.assign({},Oe.Testnet);else if(Jt.get("NETWORK")==="mainnet")Oe.Default=Object.assign({},Oe.Mainnet);else if(Jt.get("NETWORK")==="regtest")Oe.Default=Object.assign({},Oe.Regtest);else if(Jt.get("NETWORK")==="stn")Oe.Default=Object.assign({},Oe.STN);else throw new Error(`must set network in environment variable - mainnet, testnet, regtest or stn?, received ${Jt.get("NETWORK")}`);const O1=l=>Oe.Mainnet.Msg.magicNum===l?Oe.Mainnet:Oe.Testnet.Msg.magicNum===l?Oe.Testnet:Oe.Regtest.Msg.magicNum===l?Oe.Regtest:Oe.STN.Msg.magicNum===l?Oe.STN:Oe.Default,Xt={FALSE:0,0:0,PUSHDATA1:76,PUSHDATA2:77,PUSHDATA4:78,"1NEGATE":79,RESERVED:80,TRUE:81,1:81,2:82,3:83,4:84,5:85,6:86,7:87,8:88,9:89,10:90,11:91,12:92,13:93,14:94,15:95,16:96,NOP:97,VER:98,IF:99,NOTIF:100,VERIF:101,VERNOTIF:102,ELSE:103,ENDIF:104,VERIFY:105,RETURN:106,TOALTSTACK:107,FROMALTSTACK:108,"2DROP":109,"2DUP":110,"3DUP":111,"2OVER":112,"2ROT":113,"2SWAP":114,IFDUP:115,DEPTH:116,DROP:117,DUP:118,NIP:119,OVER:120,PICK:121,ROLL:122,ROT:123,SWAP:124,TUCK:125,CAT:126,SUBSTR:127,SPLIT:127,LEFT:128,NUM2BIN:128,RIGHT:129,BIN2NUM:129,SIZE:130,INVERT:131,AND:132,OR:133,XOR:134,EQUAL:135,EQUALVERIFY:136,RESERVED1:137,RESERVED2:138,"1ADD":139,"1SUB":140,"2MUL":141,"2DIV":142,NEGATE:143,ABS:144,NOT:145,"0NOTEQUAL":146,ADD:147,SUB:148,MUL:149,DIV:150,MOD:151,LSHIFT:152,RSHIFT:153,BOOLAND:154,BOOLOR:155,NUMEQUAL:156,NUMEQUALVERIFY:157,NUMNOTEQUAL:158,LESSTHAN:159,GREATERTHAN:160,LESSTHANOREQUAL:161,GREATERTHANOREQUAL:162,MIN:163,MAX:164,WITHIN:165,RIPEMD160:166,SHA1:167,SHA256:168,HASH160:169,HASH256:170,CODESEPARATOR:171,CHECKSIG:172,CHECKSIGVERIFY:173,CHECKMULTISIG:174,CHECKMULTISIGVERIFY:175,NOP1:176,NOP2:177,CHECKLOCKTIMEVERIFY:177,NOP3:178,CHECKSEQUENCEVERIFY:178,NOP4:179,NOP5:180,NOP6:181,NOP7:182,NOP8:183,NOP9:184,NOP10:185,SMALLDATA:249,SMALLINTEGER:250,PUBKEYS:251,PUBKEYHASH:253,PUBKEY:254,INVALIDOPCODE:255},Qt={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_SPLIT:127,OP_LEFT:128,OP_NUM2BIN:128,OP_RIGHT:129,OP_BIN2NUM:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_SMALLDATA:249,OP_SMALLINTEGER:250,OP_PUBKEYS:251,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255};class q extends Te{constructor(e){super({num:e})}fromNumber(e){return this.num=e,this}static fromNumber(e){return new this().fromNumber(e)}toNumber(){return this.num}fromString(e){const t=Qt[e];if(t===void 0)throw new Error("Invalid opCodeStr");return this.num=t,this}fromNoOpString(e){const t=Xt[e];if(t===void 0)throw new Error("Invalid opCodeStr");return this.num=t,this}static fromString(e){return new this().fromString(e)}static fromNoOpString(e){return new this().fromNoOpString(e)}toString(){const e=q.str[this.num];return e===void 0?this.num>0&&this.num<q.OP_PUSHDATA1?this.num.toString():"OP_"+this.num.toNumber():e}toNoOpString(){const e=q.noopstr[this.num];return e===void 0?this.num>0&&this.num<q.OP_PUSHDATA1?this.num.toString():this.num.toNumber():e}}q.str={};q.noopstr={};for(const l in Qt)q[l]=Qt[l],Object.prototype.hasOwnProperty.call(Qt,l)&&(q.str[Qt[l]]=l);for(const l in Xt)q[l]=Xt[l],Object.prototype.hasOwnProperty.call(Xt,l)&&(q.noopstr[Xt[l]]=l);q.OP_SUBSTR_CHRONICLE=179;q.OP_LEFT_CHRONICLE=180;q.OP_RIGHT_CHRONICLE=181;q.OP_LSHIFTNUM=182;q.OP_RSHIFTNUM=183;const Zt=Bd.curves.secp256k1,P1=Zt.curve.point(),Ct=P1.constructor;class Ie extends Ct{constructor(e,t,n){super(Zt.curve,e,t,n)}static fromX(e,t){const n=Zt.curve.pointFromX(t,e);return Object.create(Ie.prototype).copyFrom(n)}copyFrom(e){if(!(e instanceof Ct))throw new Error("point should be an external point");return Object.keys(e).forEach((function(t){this[t]=e[t]}).bind(this)),this}add(e){return e=Ct.prototype.add.call(this,e),Object.create(Ie.prototype).copyFrom(e)}mul(e){if(!e.lt(Ie.getN()))throw new Error("point mul out of range");const t=Ct.prototype.mul.call(this,e);return Object.create(Ie.prototype).copyFrom(t)}mulAdd(e,t,n){const u=Ct.prototype.mulAdd.call(this,e,t,n);return t=Object.create(Ie.prototype),t.copyFrom(u)}getX(){const e=Ct.prototype.getX.call(this),t=Object.create(Z.prototype);return e.copy(t),t}getY(){const e=Ct.prototype.getY.call(this),t=Object.create(Z.prototype);return e.copy(t),t}fromX(e,t){const n=Ie.fromX(e,t);return this.copyFrom(n)}toJSON(){return{x:this.getX().toString(),y:this.getY().toString()}}fromJSON(e){const t=new Z().fromString(e.x),n=new Z().fromString(e.y),u=new Ie(t,n);return this.copyFrom(u)}toString(){return JSON.stringify(this.toJSON())}fromString(e){const t=JSON.parse(e),n=new Ie().fromJSON(t);return this.copyFrom(n)}static getG(){const e=Zt.curve.g;return Object.create(Ie.prototype).copyFrom(e)}static getN(){return new Z(Zt.curve.n.toArray())}validate(){if(Ie.fromX(this.getY().isOdd(),this.getX()).getY().cmp(this.getY())!==0)throw new Error("Invalid y value of public key");if(!(this.getX().gt(-1)&&this.getX().lt(Ie.getN()))||!(this.getY().gt(-1)&&this.getY().lt(Ie.getN())))throw new Error("Point does not lie on the curve");return this}}class Ue extends Te{constructor(e,t){super({point:e,compressed:t})}fromJSON(e){return this.fromFastHex(e),this}toJSON(){return this.toFastHex()}fromPrivKey(e){return this.fromObject({point:Ie.getG().mul(e.bn),compressed:e.compressed}),this}static fromPrivKey(e){return new this().fromPrivKey(e)}async asyncFromPrivKey(e){const t=await le.asyncObjectMethod(this,"fromPrivKey",[e]);return this.fromFastBuffer(t.resbuf)}static asyncFromPrivKey(e){return new this().asyncFromPrivKey(e)}fromBuffer(e,t){return this.fromDer(e,t)}async asyncFromBuffer(e,t){const n=[e,t],u=await le.asyncObjectMethod(this,"fromBuffer",n);return this.fromFastBuffer(u.resbuf)}fromFastBuffer(e){if(e.length===0)return this;const t=!!e[0];return e=e.slice(1),this.fromDer(e),this.compressed=t,this}fromDer(e,t){if(t===void 0?t=!0:t=!1,e[0]===4||!t&&(e[0]===6||e[0]===7)){const n=e.slice(1,33),u=e.slice(33,65);if(n.length!==32||u.length!==32||e.length!==65)throw new Error("LEngth of x and y must be 32 bytes");const r=new Z(n),s=new Z(u);this.point=new Ie(r,s),this.compressed=!1}else if(e[0]===3){const n=e.slice(1),u=new Z(n);this.fromX(!0,u),this.compressed=!0}else if(e[0]===2){const n=e.slice(1),u=new Z(n);this.fromX(!1,u),this.compressed=!0}else throw new Error("Invalid DER format pubKey");return this}static fromDer(e,t){return new this().fromDer(e,t)}fromString(e){return this.fromDer(Buffer.from(e,"hex")),this}fromX(e,t){if(typeof e!="boolean")throw new Error("Must specify whether y is odd or not (true or false)");return this.point=Ie.fromX(e,t),this}static fromX(e,t){return new this().fromX(e,t)}toBuffer(){const e=this.compressed===void 0?!0:this.compressed;return this.toDer(e)}toFastBuffer(){if(!this.point)return Buffer.alloc(0);const e=new ke,t=this.compressed===void 0?!0:!!this.compressed;return e.writeUInt8(Number(t)),e.write(this.toDer(!1)),e.toBuffer()}toDer(e){if(e=e===void 0?this.compressed:e,typeof e!="boolean")throw new Error("Must specify whether the public key is compressed or not (true or false)");const t=this.point.getX(),n=this.point.getY(),u=t.toBuffer({size:32}),r=n.toBuffer({size:32});let s;return e?(r[r.length-1]%2?s=Buffer.from([3]):s=Buffer.from([2]),Buffer.concat([s,u])):(s=Buffer.from([4]),Buffer.concat([s,u,r]))}toString(){const e=this.compressed===void 0?!0:this.compressed;return this.toDer(e).toString("hex")}static isCompressedOrUncompressed(e){if(e.length<33)return!1;if(e[0]===4){if(e.length!==65)return!1}else if(e[0]===2||e[0]===3){if(e.length!==33)return!1}else return!1;return!0}validate(){if(this.point.isInfinity())throw new Error("point: Point cannot be equal to Infinity");if(this.point.eq(new Ie(new Z(0),new Z(0))))throw new Error("point: Point cannot be equal to 0, 0");return this.point.validate(),this}}var k1=qt();const N1=zt(k1);class Rt{}Rt.getRandomBuffer=function(l){return Buffer.from(N1(l))};class gt extends Te{constructor(e,t,n=null){super({bn:e,compressed:t}),n=n||Oe.Default.PrivKey,this.Constants=n}fromJSON(e){return this.fromHex(e),this}toJSON(){return this.toHex()}fromRandom(){let e,t,n;do e=Rt.getRandomBuffer(32),t=new Z().fromBuffer(e),n=t.lt(Ie.getN());while(!n);return this.fromObject({bn:t,compressed:!0}),this}static fromRandom(){return new this().fromRandom()}toBuffer(){let e=this.compressed;e===void 0&&(e=!0);const t=this.bn.toBuffer({size:32});let n;return e?n=Buffer.concat([Buffer.from([this.Constants.versionByteNum]),t,Buffer.from([1])]):n=Buffer.concat([Buffer.from([this.Constants.versionByteNum]),t]),n}fromBuffer(e){if(e.length===34&&e[33]===1)this.compressed=!0;else if(e.length===33)this.compressed=!1;else throw new Error("Length of privKey buffer must be 33 (uncompressed pubKey) or 34 (compressed pubKey)");if(e[0]!==this.Constants.versionByteNum)throw new Error("Invalid versionByteNum byte");return this.fromBn(new Z().fromBuffer(e.slice(1,33)))}toBn(){return this.bn}fromBn(e){return this.bn=e,this}static fromBn(e){return new this().fromBn(e)}validate(){if(!this.bn.lt(Ie.getN()))throw new Error("Number must be less than N");if(typeof this.compressed!="boolean")throw new Error("Must specify whether the corresponding public key is compressed or not (true or false)");return this}toWif(){return Bt.encode(this.toBuffer())}fromWif(e){return this.fromBuffer(Bt.decode(e))}static fromWif(e){return new this().fromWif(e)}toString(){return this.toWif()}fromString(e){return this.fromWif(e)}}gt.Mainnet=class extends gt{constructor(l,e){super(l,e,Oe.Mainnet.PrivKey)}};gt.Testnet=class extends gt{constructor(l,e){super(l,e,Oe.Testnet.PrivKey)}};class he extends Te{constructor(e,t,n,u,r){super({r:e,s:t,nHashType:n,recovery:u,compressed:r})}fromBuffer(e){try{return this.fromDer(e,!0)}catch{}try{return this.fromCompact(e)}catch{}return this.fromTxFormat(e)}toBuffer(){return this.nHashType!==void 0?this.toTxFormat():this.recovery!==void 0?this.toCompact():this.toDer()}fromCompact(e){let t=!0,n=e.slice(0,1)[0]-27-4;if(n<0&&(t=!1,n=n+4),!(n===0||n===1||n===2||n===3))throw new Error("i must be 0, 1, 2, or 3");this.compressed=t,this.recovery=n;const u=e.slice(1);return this.fromRS(u),this}static fromCompact(e){return new this().fromCompact(e)}fromRS(e){const t=e.slice(0,32),n=e.slice(32,64);if(t.length!==32)throw new Error("r must be 32 bytes");if(n.length!==32||e.length>64)throw new Error("s must be 32 bytes");return this.r=new Z().fromBuffer(t),this.s=new Z().fromBuffer(n),this}static fromRS(e){return new this().fromRS(e)}fromDer(e,t){const n=he.parseDer(e,t);return this.r=n.r,this.s=n.s,this}static fromDer(e,t){return new this().fromDer(e,t)}fromTxFormat(e){if(e.length===0)return this.r=new Z(1),this.s=new Z(1),this.nHashType=1,this;const t=e.readUInt8(e.length-1),n=e.slice(0,e.length-1);return this.fromDer(n,!1),this.nHashType=t,this}static fromTxFormat(e){return new this().fromTxFormat(e)}fromString(e){return this.fromHex(e)}static parseDer(e,t){if(t===void 0&&(t=!0),!Buffer.isBuffer(e))throw new Error("DER formatted signature should be a buffer");const n=e[0];if(n!==48)throw new Error("Header byte should be 0x30");let u=e[1];const r=e.slice(2).length;if(t&&u!==r)throw new Error("LEngth byte should length of what follows");u=u<r?u:r;const s=e[2];if(s!==2)throw new Error("Integer byte for r should be 0x02");const a=e[3],o=e.slice(4,4+a),f=new Z().fromBuffer(o),i=e[4]===0;if(a!==o.length)throw new Error("LEngth of r incorrect");const c=e[4+a+0];if(c!==2)throw new Error("Integer byte for s should be 0x02");const h=e[4+a+1],d=e.slice(4+a+2,4+a+2+h),b=new Z().fromBuffer(d),p=e[4+a+2+2]===0;if(h!==d.length)throw new Error("LEngth of s incorrect");const y=4+a+2+h;if(u!==y-2)throw new Error("LEngth of signature incorrect");return{header:n,length:u,rheader:s,rlength:a,rneg:i,rbuf:o,r:f,sheader:c,slength:h,sneg:p,sbuf:d,s:b}}static IsTxDer(e){if(e.length<9||e.length>73||e[0]!==48||e[1]!==e.length-3)return!1;const t=e[3];if(5+t>=e.length)return!1;const n=e[5+t];if(t+n+7!==e.length)return!1;const u=e.slice(4);if(e[2]!==2||t===0||u[0]&128||t>1&&u[0]===0&&!(u[1]&128))return!1;const r=e.slice(6+t);return!(e[6+t-2]!==2||n===0||r[0]&128||n>1&&r[0]===0&&!(r[1]&128))}hasLowS(){return!(this.s.lt(1)||this.s.gt(Z.fromBuffer(Buffer.from("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex"))))}isChronicle(){return(this.nHashType&he.SIGHASH_CHRONICLE)!==0}hasDefinedHashType(){const e=this.nHashType&~(he.SIGHASH_CHRONICLE|he.SIGHASH_FORKID|he.SIGHASH_ANYONECANPAY);return!(e<he.SIGHASH_ALL||e>he.SIGHASH_SINGLE)}toCompact(e,t){if(e=typeof e=="number"?e:this.recovery,t=typeof t=="boolean"?t:this.compressed,!(e===0||e===1||e===2||e===3))throw new Error("recovery must be equal to 0, 1, 2, or 3");let n=e+27+4;t===!1&&(n=n-4);const u=Buffer.from([n]),r=this.r.toBuffer({size:32}),s=this.s.toBuffer({size:32});return Buffer.concat([u,r,s])}toRS(){return Buffer.concat([this.r.toBuffer({size:32}),this.s.toBuffer({size:32})])}toDer(){const e=this.r.toBuffer(),t=this.s.toBuffer(),n=e[0]&128,u=t[0]&128,r=n?Buffer.concat([Buffer.from([0]),e]):e,s=u?Buffer.concat([Buffer.from([0]),t]):t,a=2+r.length+2+s.length,o=r.length,f=s.length;return Buffer.concat([Buffer.from([48,a,2,o]),r,Buffer.from([2,f]),s])}toTxFormat(){const e=this.toDer(),t=Buffer.alloc(1);return t.writeUInt8(this.nHashType,0),Buffer.concat([e,t])}toString(){return this.toHex()}}he.SIGHASH_ALL=1;he.SIGHASH_NONE=2;he.SIGHASH_SINGLE=3;he.SIGHASH_CHRONICLE=32;he.SIGHASH_FORKID=64;he.SIGHASH_ANYONECANPAY=128;class Ae extends Te{constructor(e=[]){super({chunks:e})}fromJSON(e){return this.fromString(e)}toJSON(){return this.toString()}fromBuffer(e){this.chunks=[];const t=new ot(e);for(;!t.eof();){const n=t.readUInt8();let u=0,r=Buffer.from([]);if(n>0&&n<q.OP_PUSHDATA1)u=n,this.chunks.push({buf:t.read(u),len:u,opCodeNum:n});else if(n===q.OP_PUSHDATA1){try{u=t.readUInt8(),r=t.read(u)}catch{t.read()}this.chunks.push({buf:r,len:u,opCodeNum:n})}else if(n===q.OP_PUSHDATA2){try{u=t.readUInt16LE(),r=t.read(u)}catch{t.read()}this.chunks.push({buf:r,len:u,opCodeNum:n})}else if(n===q.OP_PUSHDATA4){try{u=t.readUInt32LE(),r=t.read(u)}catch{t.read()}this.chunks.push({buf:r,len:u,opCodeNum:n})}else this.chunks.push({opCodeNum:n})}return this}toBuffer(){const e=new ke;for(let t=0;t<this.chunks.length;t++){const n=this.chunks[t],u=n.opCodeNum;e.writeUInt8(u),n.buf&&(u<q.OP_PUSHDATA1?e.write(n.buf):u===q.OP_PUSHDATA1?(e.writeUInt8(n.len),e.write(n.buf)):u===q.OP_PUSHDATA2?(e.writeUInt16LE(n.len),e.write(n.buf)):u===q.OP_PUSHDATA4&&(e.writeUInt32LE(n.len),e.write(n.buf)))}return e.toBuffer()}fromString(e){if(this.chunks=[],e===""||e===void 0)return this;const t=e.split(" ");let n=0;for(;n<t.length;){const u=t[n];let r;try{r=new q().fromString(u).toNumber()}catch{}if(r===void 0)if(r=parseInt(u,10),r>0&&r<q.OP_PUSHDATA1)this.chunks.push({buf:Buffer.from(t[n+1].slice(2),"hex"),len:r,opCodeNum:r}),n=n+2;else if(r===0)this.chunks.push({opCodeNum:0}),n=n+1;else throw new Error("Invalid script");else if(r===q.OP_PUSHDATA1||r===q.OP_PUSHDATA2||r===q.OP_PUSHDATA4){if(t[n+2].slice(0,2)!=="0x")throw new Error("Pushdata data must start with 0x");this.chunks.push({buf:Buffer.from(t[n+2].slice(2),"hex"),len:parseInt(t[n+1],10),opCodeNum:r}),n=n+3}else this.chunks.push({opCodeNum:r}),n=n+1}return this}toString(e={noOp:!1}){let t="";for(let n=0;n<this.chunks.length;n++){const u=this.chunks[n],r=u.opCodeNum?.num?u.opCodeNum.num:u.opCodeNum;u.buf?((r===q.OP_PUSHDATA1||r===q.OP_PUSHDATA2||r===q.OP_PUSHDATA4)&&(t=e.noOp?t+" "+new q(r).toNoOpString():t+" "+new q(r).toString()),t=t+" "+u.len,t=t+" 0x"+u.buf.toString("hex")):q.str[r]!==void 0||q.noopstr[r]!==void 0?t=e.noOp?t+" "+new q(r).toNoOpString():t+" "+new q(r).toString():t=t+" 0x"+r.toString(16)}return t.substr(1)}fromBitcoindString(e){const t=new ke,n=e.split(" ");let u;for(u=0;u<n.length;u++){const s=n[u];if(s!=="")if(s[0]==="0"&&s[1]==="x"){const a=s.slice(2);t.write(Buffer.from(a,"hex"))}else if(s[0]==="'"){const a=s.slice(1,s.length-1),o=Buffer.from(a),f=new Ae().writeBuffer(o).toBuffer();t.write(f)}else if(q["OP_"+s]!==void 0){const a="OP_"+s,o=q[a];t.writeUInt8(o)}else if(typeof q[s]=="number"){const o=q[s];t.writeUInt8(o)}else{if(isNaN(parseInt(s,10)))throw new Error("Could not determine type of script value");{const a=new Z(s),f=new Ae().writeBn(a).toBuffer();t.write(f)}}}const r=t.toBuffer();return this.fromBuffer(r)}static fromBitcoindString(e){return new this().fromBitcoindString(e)}toBitcoindString(){let e="";for(let t=0;t<this.chunks.length;t++){const n=this.chunks[t];if(n.buf){const r=new Ae([n]).toBuffer().toString("hex");e=e+" 0x"+r}else if(q.str[n.opCodeNum]!==void 0){const u=new q(n.opCodeNum).toString();e=e+" "+u.slice(3)}else e=e+" 0x"+n.opCodeNum.toString(16)}return e.substr(1)}fromAsmString(e){this.chunks=[];const t=e.split(" ");let n=0;for(;n<t.length;){const u=t[n];let r,s;try{r=q.fromString(u),s=r.toNumber()}catch{r=void 0,s=void 0}if(u==="0")s=0,this.chunks.push({opCodeNum:s}),n=n+1;else if(u==="-1")s=q.OP_1NEGATE,this.chunks.push({opCodeNum:s}),n=n+1;else if(r===void 0){const a=t[n],o=Buffer.from(a,"hex");if(o.toString("hex")!==a)throw new Error("invalid hex string in script");const f=o.length;f>=0&&f<q.OP_PUSHDATA1?s=f:f<Math.pow(2,8)?s=q.OP_PUSHDATA1:f<Math.pow(2,16)?s=q.OP_PUSHDATA2:f<Math.pow(2,32)&&(s=q.OP_PUSHDATA4),this.chunks.push({buf:o,len:o.length,opCodeNum:s}),n=n+1}else this.chunks.push({opCodeNum:s}),n=n+1}return this}static fromAsmString(e){return new this().fromAsmString(e)}toAsmString(e={noOp:!1}){let t="";for(let n=0;n<this.chunks.length;n++){const u=this.chunks[n];t+=this._chunkToString(u,e)}return t.substr(1)}_chunkToString(e,t={noOp:!1}){const n=e.opCodeNum;let u="";if(e.buf)e.len>0&&(u=u+" "+e.buf.toString("hex"));else if(typeof q.str[n]<"u")n===0?u=u+" 0":n===79?u=u+" -1":u=t.noOp?u+" "+new q(n).toNoOpString():u+" "+new q(n).toString();else{let r=n.toString(16);r.length%2!==0&&(r="0"+r),u=u+" "+r}return u}fromOpReturnData(e){return this.writeOpCode(q.OP_RETURN),this.writeBuffer(e),this}static fromOpReturnData(e){return new this().fromOpReturnData(e)}fromSafeData(e){return this.writeOpCode(q.OP_FALSE),this.writeOpCode(q.OP_RETURN),this.writeBuffer(e),this}static fromSafeData(e){return new this().fromSafeData(e)}fromSafeDataArray(e){this.writeOpCode(q.OP_FALSE),this.writeOpCode(q.OP_RETURN);for(const t in e){const n=e[t];this.writeBuffer(n)}return this}static fromSafeDataArray(e){return new this().fromSafeDataArray(e)}getData(){if(this.isSafeDataOut())return this.chunks.slice(2).map(n=>n.buf);if(this.isOpReturn())return this.chunks.slice(1).map(n=>n.buf);throw new Error("Unrecognized script type to get data from")}fromPubKeyHash(e){if(e.length!==20)throw new Error("hashBuf must be a 20 byte buffer");return this.writeOpCode(q.OP_DUP),this.writeOpCode(q.OP_HASH160),this.writeBuffer(e),this.writeOpCode(q.OP_EQUALVERIFY),this.writeOpCode(q.OP_CHECKSIG),this}static fromPubKeyHash(e){return new this().fromPubKeyHash(e)}static sortPubKeys(e){return e.slice().sort((t,n)=>{const u=t.toBuffer(),r=n.toBuffer(),s=Math.max(u.length,r.length);for(let a=0;a<=s;a++){if(u[a]===void 0)return-1;if(r[a]===void 0)return 1;if(u[a]<r[a])return-1;if(u[a]>r[a])return 1}})}fromPubKeys(e,t,n=!0){if(typeof e!="number")throw new Error("m must be a number");n===!0&&(t=Ae.sortPubKeys(t)),this.writeOpCode(e+q.OP_1-1);for(const u in t)this.writeBuffer(t[u].toBuffer());return this.writeOpCode(t.length+q.OP_1-1),this.writeOpCode(q.OP_CHECKMULTISIG),this}static fromPubKeys(e,t,n){return new this().fromPubKeys(e,t,n)}removeCodeseparators(){const e=[];for(let t=0;t<this.chunks.length;t++)this.chunks[t].opCodeNum!==q.OP_CODESEPARATOR&&e.push(this.chunks[t]);return this.chunks=e,this}isPushOnly(){for(let e=0;e<this.chunks.length;e++)if(this.chunks[e].opCodeNum>q.OP_16)return!1;return!0}isNonSpendable(){const e=this.chunks[0].opCodeNum===q.OP_FALSE,t=this.chunks[1]&&this.chunks[1].opCodeNum===q.OP_RETURN;return!!e&&!!t}isOpReturn(){return this.chunks[0].opCodeNum===q.OP_RETURN&&this.chunks.filter(e=>Buffer.isBuffer(e.buf)).length===this.chunks.slice(1).length}isSafeDataOut(){if(this.chunks.length<2||this.chunks[0].opCodeNum!==q.OP_FALSE)return!1;const e=this.chunks.slice(1);return new Ae(e).isOpReturn()}isPubKeyHashOut(){return!!(this.chunks[0]&&this.chunks[0].opCodeNum===q.OP_DUP&&this.chunks[1]&&this.chunks[1].opCodeNum===q.OP_HASH160&&this.chunks[2].buf&&this.chunks[3]&&this.chunks[3].opCodeNum===q.OP_EQUALVERIFY&&this.chunks[4]&&this.chunks[4].opCodeNum===q.OP_CHECKSIG)}isPubKeyHashIn(){return!!(this.chunks.length===2&&(this.chunks[0].buf||this.chunks[0].opCodeNum===q.OP_0)&&(this.chunks[1].buf||this.chunks[0].opCodeNum===q.OP_0))}isScriptHashOut(){const e=this.toBuffer();return e.length===23&&e[0]===q.OP_HASH160&&e[1]===20&&e[22]===q.OP_EQUAL}isScriptHashIn(){if(!this.isPushOnly())return!1;try{new Ae().fromBuffer(this.chunks[this.chunks.length-1].buf)}catch{return!1}return!0}isMultiSigOut(){const e=this.chunks[0].opCodeNum-q.OP_1+1;if(!(e>=1&&e<=16)||!this.chunks.slice(1,this.chunks.length-2).every(u=>{try{const r=u.buf;return new Ue().fromDer(r).validate(),!0}catch{return!1}}))return!1;const n=this.chunks[this.chunks.length-2].opCodeNum-q.OP_1+1;return!(!(n>=e&&n<=16)||this.chunks[1+n+1].opCodeNum!==q.OP_CHECKMULTISIG)}isMultiSigIn(){if(this.chunks[0].opCodeNum!==q.OP_0)return!1;const e=this.chunks.slice(1);return e.length<1?!1:e.every(t=>Buffer.isBuffer(t.buf)&&he.IsTxDer(t.buf))}findAndDelete(e){const t=e.toBuffer();for(let n=0;n<this.chunks.length;n++){const r=new Ae([this.chunks[n]]).toBuffer();kt(t,r)&&this.chunks.splice(n,1)}return this}writeScript(e){return this.chunks=this.chunks.concat(e.chunks),this}static writeScript(e){return new this().writeScript(e)}writeString(e){const t=new Ae().fromString(e);return this.chunks=this.chunks.concat(t.chunks),this}static writeString(e){return new this().writeString(e)}writeOpCode(e){return this.chunks.push({opCodeNum:e}),this}static writeOpCode(e){return new this().writeOpCode(e)}setChunkOpCode(e,t){return this.chunks[e]={opCodeNum:t},this}writeBn(e){if(e.cmp(0)===q.OP_0)this.chunks.push({opCodeNum:q.OP_0});else if(e.cmp(-1)===0)this.chunks.push({opCodeNum:q.OP_1NEGATE});else if(e.cmp(1)>=0&&e.cmp(16)<=0)this.chunks.push({opCodeNum:e.toNumber()+q.OP_1-1});else{const t=e.toSm({endian:"little"});this.writeBuffer(t)}return this}static writeBn(e){return new this().writeBn(e)}writeNumber(e){return this.writeBn(new Z().fromNumber(e)),this}static writeNumber(e){return new this().writeNumber(e)}setChunkBn(e,t){return this.chunks[e]=new Ae().writeBn(t).chunks[0],this}writeBuffer(e){let t;const n=e.length;if(e.length>0&&e.length<q.OP_PUSHDATA1)t=e.length;else if(e.length===0)t=q.OP_0;else if(e.length<Math.pow(2,8))t=q.OP_PUSHDATA1;else if(e.length<Math.pow(2,16))t=q.OP_PUSHDATA2;else if(e.length<Math.pow(2,32))t=q.OP_PUSHDATA4;else throw new Error("You can't push that much data");return this.chunks.push({buf:e,len:n,opCodeNum:t}),this}static writeBuffer(e){return new this().writeBuffer(e)}setChunkBuffer(e,t){return this.chunks[e]=new Ae().writeBuffer(t).chunks[0],this}checkMinimalPush(e){const t=this.chunks[e],n=t.buf,u=t.opCodeNum;return n?n.length===0?u===q.OP_0:n.length===1&&n[0]>=1&&n[0]<=16?u===q.OP_1+(n[0]-1):n.length===1&&n[0]===129?u===q.OP_1NEGATE:n.length<=75?u===n.length:n.length<=255?u===q.OP_PUSHDATA1:n.length<=65535?u===q.OP_PUSHDATA2:!0:!0}}class St extends Te{constructor(e,t,n=null){super({versionByteNum:e,hashBuf:t}),n=n||Oe.Default.Address,this.Constants=n}fromBuffer(e){if(e.length!==21)throw new Error("address buffers must be exactly 21 bytes");if(e[0]!==this.Constants.pubKeyHash)throw new Error("address: invalid versionByteNum byte");return this.versionByteNum=e[0],this.hashBuf=e.slice(1),this}fromPubKeyHashBuf(e){return this.hashBuf=e,this.versionByteNum=this.Constants.pubKeyHash,this}static fromPubKeyHashBuf(e){return new this().fromPubKeyHashBuf(e)}fromPubKey(e){const t=ae.sha256Ripemd160(e.toBuffer());return this.fromPubKeyHashBuf(t)}static fromPubKey(e){return new this().fromPubKey(e)}async asyncFromPubKey(e){const t=[e],n=await le.asyncObjectMethod(this,"fromPubKey",t);return this.fromFastBuffer(n.resbuf)}static asyncFromPubKey(e){return new this().asyncFromPubKey(e)}fromPrivKey(e){const t=new Ue().fromPrivKey(e),n=ae.sha256Ripemd160(t.toBuffer());return this.fromPubKeyHashBuf(n)}static fromPrivKey(e){return new this().fromPrivKey(e)}async asyncFromPrivKey(e){const t=[e],n=await le.asyncObjectMethod(this,"fromPrivKey",t);return this.fromFastBuffer(n.resbuf)}static asyncFromPrivKey(e){return new this().fromPrivKey(e)}fromRandom(){const e=new gt().fromRandom();return this.fromPrivKey(e)}static fromRandom(){return new this().fromRandom()}async asyncFromRandom(){const e=[],t=await le.asyncObjectMethod(this,"fromRandom",e);return this.fromFastBuffer(t.resbuf)}static asyncFromRandom(){return new this().fromRandom()}fromString(e){const t=Bt.decode(e);return this.fromBuffer(t)}async asyncFromString(e){const t=[e],n=await le.asyncObjectMethod(this,"fromString",t);return this.fromFastBuffer(n.resbuf)}static asyncFromString(e){return new this().asyncFromString(e)}static isValid(e){let t;try{t=new St().fromString(e)}catch{return!1}return t.isValid()}isValid(){try{return this.validate(),!0}catch{return!1}}toTxOutScript(){const e=new Ae;return e.writeOpCode(q.OP_DUP),e.writeOpCode(q.OP_HASH160),e.writeBuffer(this.hashBuf),e.writeOpCode(q.OP_EQUALVERIFY),e.writeOpCode(q.OP_CHECKSIG),e}fromTxInScript(e){const t=ae.sha256Ripemd160(e.chunks[1].buf||Buffer.from("00".repeat(32),"hex"));return this.fromPubKeyHashBuf(t)}static fromTxInScript(e){return new this().fromTxInScript(e)}fromTxOutScript(e){return this.fromPubKeyHashBuf(e.chunks[2].buf)}static fromTxOutScript(e){return new this().fromTxOutScript(e)}toBuffer(){const e=Buffer.from([this.versionByteNum]);return Buffer.concat([e,this.hashBuf])}toJSON(){const e={};return this.hashBuf&&(e.hashBuf=this.hashBuf.toString("hex")),typeof this.versionByteNum<"u"&&(e.versionByteNum=this.versionByteNum),e}fromJSON(e){return e.hashBuf&&(this.hashBuf=Buffer.from(e.hashBuf,"hex")),typeof e.versionByteNum<"u"&&(this.versionByteNum=e.versionByteNum),this}toString(){return Bt.encode(this.toBuffer())}async asyncToString(){const e=[],t=await le.asyncObjectMethod(this,"toString",e);return JSON.parse(t.resbuf.toString())}validate(){if(!Buffer.isBuffer(this.hashBuf)||this.hashBuf.length!==20)throw new Error("hashBuf must be a buffer of 20 bytes");if(this.versionByteNum!==this.Constants.pubKeyHash)throw new Error("invalid versionByteNum");return this}}St.Mainnet=class extends St{constructor(l,e){super(l,e,Oe.Mainnet.Address)}};St.Testnet=class extends St{constructor(l,e){super(l,e,Oe.Testnet.Address)}};class rr extends Te{constructor(e,t,n,u,r,s,a,o=null,f=gt){super({versionBytesNum:e,depth:t,parentFingerPrint:n,childIndex:u,chainCode:r,privKey:s,pubKey:a}),o=o||Oe.Default.Bip32,this.Constants=o,this.PrivKey=f}fromRandom(){return this.versionBytesNum=this.Constants.privKey,this.depth=0,this.parentFingerPrint=Buffer.from([0,0,0,0]),this.childIndex=0,this.chainCode=Rt.getRandomBuffer(32),this.privKey=new this.PrivKey().fromRandom(),this.pubKey=new Ue().fromPrivKey(this.privKey),this}static fromRandom(){return new this().fromRandom()}fromString(e){return this.fromBuffer(Bt.decode(e))}async asyncFromString(e){const t=[e],n=await le.asyncObjectMethod(this,"fromString",t);return this.fromFastBuffer(n.resbuf)}fromSeed(e){if(!Buffer.isBuffer(e))throw new Error("bytes must be a buffer");if(e.length<128/8)throw new Error("Need more than 128 bits of entropy");if(e.length>512/8)throw new Error("More than 512 bits of entropy is nonstandard");const t=ae.sha512Hmac(e,Buffer.from("Bitcoin seed"));return this.depth=0,this.parentFingerPrint=Buffer.from([0,0,0,0]),this.childIndex=0,this.chainCode=t.slice(32,64),this.versionBytesNum=this.Constants.privKey,this.privKey=new this.PrivKey().fromBn(Z().fromBuffer(t.slice(0,32))),this.pubKey=new Ue().fromPrivKey(this.privKey),this}static fromSeed(e){return new this().fromSeed(e)}async asyncFromSeed(e){const t=await le.asyncObjectMethod(this,"fromSeed",[e]);return this.fromFastBuffer(t.resbuf)}static asyncFromSeed(e){return new this().asyncFromSeed(e)}fromBuffer(e){if(e.length!==78)throw new Error("incorrect bip32 data length");this.versionBytesNum=e.slice(0,4).readUInt32BE(0),this.depth=e.slice(4,5).readUInt8(0),this.parentFingerPrint=e.slice(5,9),this.childIndex=e.slice(9,13).readUInt32BE(0),this.chainCode=e.slice(13,45);const t=e.slice(45,78),n=this.versionBytesNum===this.Constants.privKey,u=this.versionBytesNum===this.Constants.pubKey;if(n&&t[0]===0)this.privKey=new this.PrivKey().fromBn(Z().fromBuffer(t.slice(1,33))),this.pubKey=new Ue().fromPrivKey(this.privKey);else if(u&&(t[0]===2||t[0]===3))this.pubKey=new Ue().fromDer(t);else throw new Error("Invalid key");return this}fromFastBuffer(e){if(e.length===0)return this;if(e.length!==78&&e.length!==111)throw new Error("incorrect bip32 fastBuffer data length: "+e.length);this.versionBytesNum=e.slice(0,4).readUInt32BE(0),this.depth=e.slice(4,5).readUInt8(0),this.parentFingerPrint=e.slice(5,9),this.childIndex=e.slice(9,13).readUInt32BE(0),this.chainCode=e.slice(13,45);const t=e.slice(45,e.length),n=this.versionBytesNum===this.Constants.privKey,u=this.versionBytesNum===this.Constants.pubKey;if(n&&t[0]===0&&e.length===78)this.privKey=new this.PrivKey().fromBn(Z().fromBuffer(t.slice(1,33))),this.pubKey=new Ue().fromPrivKey(this.privKey);else if(u&&e.length===111)this.pubKey=new Ue().fromFastBuffer(t),this.pubKey.compressed=!0;else throw new Error("Invalid key");return this}derive(e){const t=e.split("/");if(e==="m")return this;let n=this;for(const u in t){const r=t[u];if(u==="0"){if(r!=="m")throw new Error("invalid path");continue}if(parseInt(r.replace("'",""),10).toString()!==r.replace("'",""))throw new Error("invalid path");const s=r.length>1&&r[r.length-1]==="'";let a=parseInt(s?r.slice(0,r.length-1):r,10)&2147483647;s&&(a+=2147483648),n=n.deriveChild(a)}return n}async asyncDerive(e){const t=await le.asyncObjectMethod(this,"derive",[e]);return new this.constructor().fromFastBuffer(t.resbuf)}deriveChild(e){if(typeof e!="number")throw new Error("i must be a number");let t=[];t.push(e>>24&255),t.push(e>>16&255),t.push(e>>8&255),t.push(e&255),t=Buffer.from(t);const n=(e&2147483648)!==0,u=this.versionBytesNum===this.Constants.privKey;if(n&&(!this.privKey||!u))throw new Error("Cannot do private key derivation without private key");let r=null;if(this.privKey){let a=null;n?a=Buffer.concat([Buffer.from([0]),this.privKey.bn.toBuffer({size:32}),t]):a=Buffer.concat([this.pubKey.toBuffer({size:32}),t]);const o=ae.sha512Hmac(a,this.chainCode),f=Z().fromBuffer(o.slice(0,32),{size:32}),i=o.slice(32,64),c=f.add(this.privKey.bn).mod(Ie.getN());r=new this.constructor,r.chainCode=i,r.privKey=new this.PrivKey().fromBn(c),r.pubKey=new Ue().fromPrivKey(r.privKey)}else{const a=Buffer.concat([this.pubKey.toBuffer(),t]),o=ae.sha512Hmac(a,this.chainCode),f=Z().fromBuffer(o.slice(0,32)),i=o.slice(32,64),c=Ie.getG().mul(f),h=this.pubKey.point,d=c.add(h),b=new Ue;b.point=d,r=new this.constructor,r.chainCode=i,r.pubKey=b}r.childIndex=e;const s=ae.sha256Ripemd160(this.pubKey.toBuffer());return r.parentFingerPrint=s.slice(0,4),r.versionBytesNum=this.versionBytesNum,r.depth=this.depth+1,r}toPublic(){const e=new this.constructor().fromObject(this);return e.versionBytesNum=this.Constants.pubKey,e.privKey=void 0,e}toBuffer(){const e=this.versionBytesNum===this.Constants.privKey,t=this.versionBytesNum===this.Constants.pubKey;if(e)return new ke().writeUInt32BE(this.versionBytesNum).writeUInt8(this.depth).write(this.parentFingerPrint).writeUInt32BE(this.childIndex).write(this.chainCode).writeUInt8(0).write(this.privKey.bn.toBuffer({size:32})).toBuffer();if(t){if(this.pubKey.compressed===!1)throw new Error("cannot convert bip32 to buffer if pubKey is not compressed");return new ke().writeUInt32BE(this.versionBytesNum).writeUInt8(this.depth).write(this.parentFingerPrint).writeUInt32BE(this.childIndex).write(this.chainCode).write(this.pubKey.toBuffer()).toBuffer()}else throw new Error("bip32: invalid versionBytesNum byte")}toFastBuffer(){if(!this.versionBytesNum)return Buffer.alloc(0);const e=this.versionBytesNum===this.Constants.privKey,t=this.versionBytesNum===this.Constants.pubKey;if(e)return new ke().writeUInt32BE(this.versionBytesNum).writeUInt8(this.depth).write(this.parentFingerPrint).writeUInt32BE(this.childIndex).write(this.chainCode).writeUInt8(0).write(this.privKey.bn.toBuffer({size:32})).toBuffer();if(t)return new ke().writeUInt32BE(this.versionBytesNum).writeUInt8(this.depth).write(this.parentFingerPrint).writeUInt32BE(this.childIndex).write(this.chainCode).write(this.pubKey.toFastBuffer()).toBuffer();throw new Error("bip32: invalid versionBytesNum byte")}toString(){return Bt.encode(this.toBuffer())}async asyncToString(){const e=await le.asyncObjectMethod(this,"toString",[]);return JSON.parse(e.resbuf.toString())}toJSON(){return this.toFastHex()}fromJSON(e){return this.fromFastHex(e)}isPrivate(){return this.versionBytesNum===this.Constants.privKey}}rr.Mainnet=class extends rr{constructor(l,e,t,n,u,r,s){super(l,e,t,n,u,r,s,Oe.Mainnet.Bip32,gt.Mainnet)}};rr.Testnet=class extends rr{constructor(l,e,t,n,u,r,s){super(l,e,t,n,u,r,s,Oe.Testnet.Bip32,gt.Testnet)}};const Nr=["abandon","ability","able","about","above","absent","absorb","abstract","absurd","abuse","access","accident","account","accuse","achieve","acid","acoustic","acquire","across","act","action","actor","actress","actual","adapt","add","addict","address","adjust","admit","adult","advance","advice","aerobic","affair","afford","afraid","again","age","agent","agree","ahead","aim","air","airport","aisle","alarm","album","alcohol","alert","alien","all","alley","allow","almost","alone","alpha","already","also","alter","always","amateur","amazing","among","amount","amused","analyst","anchor","ancient","anger","angle","angry","animal","ankle","announce","annual","another","answer","antenna","antique","anxiety","any","apart","apology","appear","apple","approve","april","arch","arctic","area","arena","argue","arm","armed","armor","army","around","arrange","arrest","arrive","arrow","art","artefact","artist","artwork","ask","aspect","assault","asset","assist","assume","asthma","athlete","atom","attack","attend","attitude","attract","auction","audit","august","aunt","author","auto","autumn","average","avocado","avoid","awake","aware","away","awesome","awful","awkward","axis","baby","bachelor","bacon","badge","bag","balance","balcony","ball","bamboo","banana","banner","bar","barely","bargain","barrel","base","basic","basket","battle","beach","bean","beauty","because","become","beef","before","begin","behave","behind","believe","below","belt","bench","benefit","best","betray","better","between","beyond","bicycle","bid","bike","bind","biology","bird","birth","bitter","black","blade","blame","blanket","blast","bleak","bless","blind","blood","blossom","blouse","blue","blur","blush","board","boat","body","boil","bomb","bone","bonus","book","boost","border","boring","borrow","boss","bottom","bounce","box","boy","bracket","brain","brand","brass","brave","bread","breeze","brick","bridge","brief","bright","bring","brisk","broccoli","broken","bronze","broom","brother","brown","brush","bubble","buddy","budget","buffalo","build","bulb","bulk","bullet","bundle","bunker","burden","burger","burst","bus","business","busy","butter","buyer","buzz","cabbage","cabin","cable","cactus","cage","cake","call","calm","camera","camp","can","canal","cancel","candy","cannon","canoe","canvas","canyon","capable","capital","captain","car","carbon","card","cargo","carpet","carry","cart","case","cash","casino","castle","casual","cat","catalog","catch","category","cattle","caught","cause","caution","cave","ceiling","celery","cement","census","century","cereal","certain","chair","chalk","champion","change","chaos","chapter","charge","chase","chat","cheap","check","cheese","chef","cherry","chest","chicken","chief","child","chimney","choice","choose","chronic","chuckle","chunk","churn","cigar","cinnamon","circle","citizen","city","civil","claim","clap","clarify","claw","clay","clean","clerk","clever","click","client","cliff","climb","clinic","clip","clock","clog","close","cloth","cloud","clown","club","clump","cluster","clutch","coach","coast","coconut","code","coffee","coil","coin","collect","color","column","combine","come","comfort","comic","common","company","concert","conduct","confirm","congress","connect","consider","control","convince","cook","cool","copper","copy","coral","core","corn","correct","cost","cotton","couch","country","couple","course","cousin","cover","coyote","crack","cradle","craft","cram","crane","crash","crater","crawl","crazy","cream","credit","creek","crew","cricket","crime","crisp","critic","crop","cross","crouch","crowd","crucial","cruel","cruise","crumble","crunch","crush","cry","crystal","cube","culture","cup","cupboard","curious","current","curtain","curve","cushion","custom","cute","cycle","dad","damage","damp","dance","danger","daring","dash","daughter","dawn","day","deal","debate","debris","decade","december","decide","decline","decorate","decrease","deer","defense","define","defy","degree","delay","deliver","demand","demise","denial","dentist","deny","depart","depend","deposit","depth","deputy","derive","describe","desert","design","desk","despair","destroy","detail","detect","develop","device","devote","diagram","dial","diamond","diary","dice","diesel","diet","differ","digital","dignity","dilemma","dinner","dinosaur","direct","dirt","disagree","discover","disease","dish","dismiss","disorder","display","distance","divert","divide","divorce","dizzy","doctor","document","dog","doll","dolphin","domain","donate","donkey","donor","door","dose","double","dove","draft","dragon","drama","drastic","draw","dream","dress","drift","drill","drink","drip","drive","drop","drum","dry","duck","dumb","dune","during","dust","dutch","duty","dwarf","dynamic","eager","eagle","early","earn","earth","easily","east","easy","echo","ecology","economy","edge","edit","educate","effort","egg","eight","either","elbow","elder","electric","elegant","element","elephant","elevator","elite","else","embark","embody","embrace","emerge","emotion","employ","empower","empty","enable","enact","end","endless","endorse","enemy","energy","enforce","engage","engine","enhance","enjoy","enlist","enough","enrich","enroll","ensure","enter","entire","entry","envelope","episode","equal","equip","era","erase","erode","erosion","error","erupt","escape","essay","essence","estate","eternal","ethics","evidence","evil","evoke","evolve","exact","example","excess","exchange","excite","exclude","excuse","execute","exercise","exhaust","exhibit","exile","exist","exit","exotic","expand","expect","expire","explain","expose","express","extend","extra","eye","eyebrow","fabric","face","faculty","fade","faint","faith","fall","false","fame","family","famous","fan","fancy","fantasy","farm","fashion","fat","fatal","father","fatigue","fault","favorite","feature","february","federal","fee","feed","feel","female","fence","festival","fetch","fever","few","fiber","fiction","field","figure","file","film","filter","final","find","fine","finger","finish","fire","firm","first","fiscal","fish","fit","fitness","fix","flag","flame","flash","flat","flavor","flee","flight","flip","float","flock","floor","flower","fluid","flush","fly","foam","focus","fog","foil","fold","follow","food","foot","force","forest","forget","fork","fortune","forum","forward","fossil","foster","found","fox","fragile","frame","frequent","fresh","friend","fringe","frog","front","frost","frown","frozen","fruit","fuel","fun","funny","furnace","fury","future","gadget","gain","galaxy","gallery","game","gap","garage","garbage","garden","garlic","garment","gas","gasp","gate","gather","gauge","gaze","general","genius","genre","gentle","genuine","gesture","ghost","giant","gift","giggle","ginger","giraffe","girl","give","glad","glance","glare","glass","glide","glimpse","globe","gloom","glory","glove","glow","glue","goat","goddess","gold","good","goose","gorilla","gospel","gossip","govern","gown","grab","grace","grain","grant","grape","grass","gravity","great","green","grid","grief","grit","grocery","group","grow","grunt","guard","guess","guide","guilt","guitar","gun","gym","habit","hair","half","hammer","hamster","hand","happy","harbor","hard","harsh","harvest","hat","have","hawk","hazard","head","health","heart","heavy","hedgehog","height","hello","helmet","help","hen","hero","hidden","high","hill","hint","hip","hire","history","hobby","hockey","hold","hole","holiday","hollow","home","honey","hood","hope","horn","horror","horse","hospital","host","hotel","hour","hover","hub","huge","human","humble","humor","hundred","hungry","hunt","hurdle","hurry","hurt","husband","hybrid","ice","icon","idea","identify","idle","ignore","ill","illegal","illness","image","imitate","immense","immune","impact","impose","improve","impulse","inch","include","income","increase","index","indicate","indoor","industry","infant","inflict","inform","inhale","inherit","initial","inject","injury","inmate","inner","innocent","input","inquiry","insane","insect","inside","inspire","install","intact","interest","into","invest","invite","involve","iron","island","isolate","issue","item","ivory","jacket","jaguar","jar","jazz","jealous","jeans","jelly","jewel","job","join","joke","journey","joy","judge","juice","jump","jungle","junior","junk","just","kangaroo","keen","keep","ketchup","key","kick","kid","kidney","kind","kingdom","kiss","kit","kitchen","kite","kitten","kiwi","knee","knife","knock","know","lab","label","labor","ladder","lady","lake","lamp","language","laptop","large","later","latin","laugh","laundry","lava","law","lawn","lawsuit","layer","lazy","leader","leaf","learn","leave","lecture","left","leg","legal","legend","leisure","lemon","lend","length","lens","leopard","lesson","letter","level","liar","liberty","library","license","life","lift","light","like","limb","limit","link","lion","liquid","list","little","live","lizard","load","loan","lobster","local","lock","logic","lonely","long","loop","lottery","loud","lounge","love","loyal","lucky","luggage","lumber","lunar","lunch","luxury","lyrics","machine","mad","magic","magnet","maid","mail","main","major","make","mammal","man","manage","mandate","mango","mansion","manual","maple","marble","march","margin","marine","market","marriage","mask","mass","master","match","material","math","matrix","matter","maximum","maze","meadow","mean","measure","meat","mechanic","medal","media","melody","melt","member","memory","mention","menu","mercy","merge","merit","merry","mesh","message","metal","method","middle","midnight","milk","million","mimic","mind","minimum","minor","minute","miracle","mirror","misery","miss","mistake","mix","mixed","mixture","mobile","model","modify","mom","moment","monitor","monkey","monster","month","moon","moral","more","morning","mosquito","mother","motion","motor","mountain","mouse","move","movie","much","muffin","mule","multiply","muscle","museum","mushroom","music","must","mutual","myself","mystery","myth","naive","name","napkin","narrow","nasty","nation","nature","near","neck","need","negative","neglect","neither","nephew","nerve","nest","net","network","neutral","never","news","next","nice","night","noble","noise","nominee","noodle","normal","north","nose","notable","note","nothing","notice","novel","now","nuclear","number","nurse","nut","oak","obey","object","oblige","obscure","observe","obtain","obvious","occur","ocean","october","odor","off","offer","office","often","oil","okay","old","olive","olympic","omit","once","one","onion","online","only","open","opera","opinion","oppose","option","orange","orbit","orchard","order","ordinary","organ","orient","original","orphan","ostrich","other","outdoor","outer","output","outside","oval","oven","over","own","owner","oxygen","oyster","ozone","pact","paddle","page","pair","palace","palm","panda","panel","panic","panther","paper","parade","parent","park","parrot","party","pass","patch","path","patient","patrol","pattern","pause","pave","payment","peace","peanut","pear","peasant","pelican","pen","penalty","pencil","people","pepper","perfect","permit","person","pet","phone","photo","phrase","physical","piano","picnic","picture","piece","pig","pigeon","pill","pilot","pink","pioneer","pipe","pistol","pitch","pizza","place","planet","plastic","plate","play","please","pledge","pluck","plug","plunge","poem","poet","point","polar","pole","police","pond","pony","pool","popular","portion","position","possible","post","potato","pottery","poverty","powder","power","practice","praise","predict","prefer","prepare","present","pretty","prevent","price","pride","primary","print","priority","prison","private","prize","problem","process","produce","profit","program","project","promote","proof","property","prosper","protect","proud","provide","public","pudding","pull","pulp","pulse","pumpkin","punch","pupil","puppy","purchase","purity","purpose","purse","push","put","puzzle","pyramid","quality","quantum","quarter","question","quick","quit","quiz","quote","rabbit","raccoon","race","rack","radar","radio","rail","rain","raise","rally","ramp","ranch","random","range","rapid","rare","rate","rather","raven","raw","razor","ready","real","reason","rebel","rebuild","recall","receive","recipe","record","recycle","reduce","reflect","reform","refuse","region","regret","regular","reject","relax","release","relief","rely","remain","remember","remind","remove","render","renew","rent","reopen","repair","repeat","replace","report","require","rescue","resemble","resist","resource","response","result","retire","retreat","return","reunion","reveal","review","reward","rhythm","rib","ribbon","rice","rich","ride","ridge","rifle","right","rigid","ring","riot","ripple","risk","ritual","rival","river","road","roast","robot","robust","rocket","romance","roof","rookie","room","rose","rotate","rough","round","route","royal","rubber","rude","rug","rule","run","runway","rural","sad","saddle","sadness","safe","sail","salad","salmon","salon","salt","salute","same","sample","sand","satisfy","satoshi","sauce","sausage","save","say","scale","scan","scare","scatter","scene","scheme","school","science","scissors","scorpion","scout","scrap","screen","script","scrub","sea","search","season","seat","second","secret","section","security","seed","seek","segment","select","sell","seminar","senior","sense","sentence","series","service","session","settle","setup","seven","shadow","shaft","shallow","share","shed","shell","sheriff","shield","shift","shine","ship","shiver","shock","shoe","shoot","shop","short","shoulder","shove","shrimp","shrug","shuffle","shy","sibling","sick","side","siege","sight","sign","silent","silk","silly","silver","similar","simple","since","sing","siren","sister","situate","six","size","skate","sketch","ski","skill","skin","skirt","skull","slab","slam","sleep","slender","slice","slide","slight","slim","slogan","slot","slow","slush","small","smart","smile","smoke","smooth","snack","snake","snap","sniff","snow","soap","soccer","social","sock","soda","soft","solar","soldier","solid","solution","solve","someone","song","soon","sorry","sort","soul","sound","soup","source","south","space","spare","spatial","spawn","speak","special","speed","spell","spend","sphere","spice","spider","spike","spin","spirit","split","spoil","sponsor","spoon","sport","spot","spray","spread","spring","spy","square","squeeze","squirrel","stable","stadium","staff","stage","stairs","stamp","stand","start","state","stay","steak","steel","stem","step","stereo","stick","still","sting","stock","stomach","stone","stool","story","stove","strategy","street","strike","strong","struggle","student","stuff","stumble","style","subject","submit","subway","success","such","sudden","suffer","sugar","suggest","suit","summer","sun","sunny","sunset","super","supply","supreme","sure","surface","surge","surprise","surround","survey","suspect","sustain","swallow","swamp","swap","swarm","swear","sweet","swift","swim","swing","switch","sword","symbol","symptom","syrup","system","table","tackle","tag","tail","talent","talk","tank","tape","target","task","taste","tattoo","taxi","teach","team","tell","ten","tenant","tennis","tent","term","test","text","thank","that","theme","then","theory","there","they","thing","this","thought","three","thrive","throw","thumb","thunder","ticket","tide","tiger","tilt","timber","time","tiny","tip","tired","tissue","title","toast","tobacco","today","toddler","toe","together","toilet","token","tomato","tomorrow","tone","tongue","tonight","tool","tooth","top","topic","topple","torch","tornado","tortoise","toss","total","tourist","toward","tower","town","toy","track","trade","traffic","tragic","train","transfer","trap","trash","travel","tray","treat","tree","trend","trial","tribe","trick","trigger","trim","trip","trophy","trouble","truck","true","truly","trumpet","trust","truth","try","tube","tuition","tumble","tuna","tunnel","turkey","turn","turtle","twelve","twenty","twice","twin","twist","two","type","typical","ugly","umbrella","unable","unaware","uncle","uncover","under","undo","unfair","unfold","unhappy","uniform","unique","unit","universe","unknown","unlock","until","unusual","unveil","update","upgrade","uphold","upon","upper","upset","urban","urge","usage","use","used","useful","useless","usual","utility","vacant","vacuum","vague","valid","valley","valve","van","vanish","vapor","various","vast","vault","vehicle","velvet","vendor","venture","venue","verb","verify","version","very","vessel","veteran","viable","vibrant","vicious","victory","video","view","village","vintage","violin","virtual","virus","visa","visit","visual","vital","vivid","vocal","voice","void","volcano","volume","vote","voyage","wage","wagon","wait","walk","wall","walnut","want","warfare","warm","warrior","wash","wasp","waste","water","wave","way","wealth","weapon","wear","weasel","weather","web","wedding","weekend","weird","welcome","west","wet","whale","what","wheat","wheel","when","where","whip","whisper","wide","width","wife","wild","will","win","window","wine","wing","wink","winner","winter","wire","wisdom","wise","wish","witness","wolf","woman","wonder","wood","wool","word","work","world","worry","worth","wrap","wreck","wrestle","wrist","write","wrong","yard","year","yellow","you","young","youth","zebra","zero","zone","zoo"];Nr.space=" ";const Mr=["あいこくしん","あいさつ","あいだ","あおぞら","あかちゃん","あきる","あけがた","あける","あこがれる","あさい","あさひ","あしあと","あじわう","あずかる","あずき","あそぶ","あたえる","あたためる","あたりまえ","あたる","あつい","あつかう","あっしゅく","あつまり","あつめる","あてな","あてはまる","あひる","あぶら","あぶる","あふれる","あまい","あまど","あまやかす","あまり","あみもの","あめりか","あやまる","あゆむ","あらいぐま","あらし","あらすじ","あらためる","あらゆる","あらわす","ありがとう","あわせる","あわてる","あんい","あんがい","あんこ","あんぜん","あんてい","あんない","あんまり","いいだす","いおん","いがい","いがく","いきおい","いきなり","いきもの","いきる","いくじ","いくぶん","いけばな","いけん","いこう","いこく","いこつ","いさましい","いさん","いしき","いじゅう","いじょう","いじわる","いずみ","いずれ","いせい","いせえび","いせかい","いせき","いぜん","いそうろう","いそがしい","いだい","いだく","いたずら","いたみ","いたりあ","いちおう","いちじ","いちど","いちば","いちぶ","いちりゅう","いつか","いっしゅん","いっせい","いっそう","いったん","いっち","いってい","いっぽう","いてざ","いてん","いどう","いとこ","いない","いなか","いねむり","いのち","いのる","いはつ","いばる","いはん","いびき","いひん","いふく","いへん","いほう","いみん","いもうと","いもたれ","いもり","いやがる","いやす","いよかん","いよく","いらい","いらすと","いりぐち","いりょう","いれい","いれもの","いれる","いろえんぴつ","いわい","いわう","いわかん","いわば","いわゆる","いんげんまめ","いんさつ","いんしょう","いんよう","うえき","うえる","うおざ","うがい","うかぶ","うかべる","うきわ","うくらいな","うくれれ","うけたまわる","うけつけ","うけとる","うけもつ","うける","うごかす","うごく","うこん","うさぎ","うしなう","うしろがみ","うすい","うすぎ","うすぐらい","うすめる","うせつ","うちあわせ","うちがわ","うちき","うちゅう","うっかり","うつくしい","うったえる","うつる","うどん","うなぎ","うなじ","うなずく","うなる","うねる","うのう","うぶげ","うぶごえ","うまれる","うめる","うもう","うやまう","うよく","うらがえす","うらぐち","うらない","うりあげ","うりきれ","うるさい","うれしい","うれゆき","うれる","うろこ","うわき","うわさ","うんこう","うんちん","うんてん","うんどう","えいえん","えいが","えいきょう","えいご","えいせい","えいぶん","えいよう","えいわ","えおり","えがお","えがく","えきたい","えくせる","えしゃく","えすて","えつらん","えのぐ","えほうまき","えほん","えまき","えもじ","えもの","えらい","えらぶ","えりあ","えんえん","えんかい","えんぎ","えんげき","えんしゅう","えんぜつ","えんそく","えんちょう","えんとつ","おいかける","おいこす","おいしい","おいつく","おうえん","おうさま","おうじ","おうせつ","おうたい","おうふく","おうべい","おうよう","おえる","おおい","おおう","おおどおり","おおや","おおよそ","おかえり","おかず","おがむ","おかわり","おぎなう","おきる","おくさま","おくじょう","おくりがな","おくる","おくれる","おこす","おこなう","おこる","おさえる","おさない","おさめる","おしいれ","おしえる","おじぎ","おじさん","おしゃれ","おそらく","おそわる","おたがい","おたく","おだやか","おちつく","おっと","おつり","おでかけ","おとしもの","おとなしい","おどり","おどろかす","おばさん","おまいり","おめでとう","おもいで","おもう","おもたい","おもちゃ","おやつ","おやゆび","およぼす","おらんだ","おろす","おんがく","おんけい","おんしゃ","おんせん","おんだん","おんちゅう","おんどけい","かあつ","かいが","がいき","がいけん","がいこう","かいさつ","かいしゃ","かいすいよく","かいぜん","かいぞうど","かいつう","かいてん","かいとう","かいふく","がいへき","かいほう","かいよう","がいらい","かいわ","かえる","かおり","かかえる","かがく","かがし","かがみ","かくご","かくとく","かざる","がぞう","かたい","かたち","がちょう","がっきゅう","がっこう","がっさん","がっしょう","かなざわし","かのう","がはく","かぶか","かほう","かほご","かまう","かまぼこ","かめれおん","かゆい","かようび","からい","かるい","かろう","かわく","かわら","がんか","かんけい","かんこう","かんしゃ","かんそう","かんたん","かんち","がんばる","きあい","きあつ","きいろ","ぎいん","きうい","きうん","きえる","きおう","きおく","きおち","きおん","きかい","きかく","きかんしゃ","ききて","きくばり","きくらげ","きけんせい","きこう","きこえる","きこく","きさい","きさく","きさま","きさらぎ","ぎじかがく","ぎしき","ぎじたいけん","ぎじにってい","ぎじゅつしゃ","きすう","きせい","きせき","きせつ","きそう","きぞく","きぞん","きたえる","きちょう","きつえん","ぎっちり","きつつき","きつね","きてい","きどう","きどく","きない","きなが","きなこ","きぬごし","きねん","きのう","きのした","きはく","きびしい","きひん","きふく","きぶん","きぼう","きほん","きまる","きみつ","きむずかしい","きめる","きもだめし","きもち","きもの","きゃく","きやく","ぎゅうにく","きよう","きょうりゅう","きらい","きらく","きりん","きれい","きれつ","きろく","ぎろん","きわめる","ぎんいろ","きんかくじ","きんじょ","きんようび","ぐあい","くいず","くうかん","くうき","くうぐん","くうこう","ぐうせい","くうそう","ぐうたら","くうふく","くうぼ","くかん","くきょう","くげん","ぐこう","くさい","くさき","くさばな","くさる","くしゃみ","くしょう","くすのき","くすりゆび","くせげ","くせん","ぐたいてき","くださる","くたびれる","くちこみ","くちさき","くつした","ぐっすり","くつろぐ","くとうてん","くどく","くなん","くねくね","くのう","くふう","くみあわせ","くみたてる","くめる","くやくしょ","くらす","くらべる","くるま","くれる","くろう","くわしい","ぐんかん","ぐんしょく","ぐんたい","ぐんて","けあな","けいかく","けいけん","けいこ","けいさつ","げいじゅつ","けいたい","げいのうじん","けいれき","けいろ","けおとす","けおりもの","げきか","げきげん","げきだん","げきちん","げきとつ","げきは","げきやく","げこう","げこくじょう","げざい","けさき","げざん","けしき","けしごむ","けしょう","げすと","けたば","けちゃっぷ","けちらす","けつあつ","けつい","けつえき","けっこん","けつじょ","けっせき","けってい","けつまつ","げつようび","げつれい","けつろん","げどく","けとばす","けとる","けなげ","けなす","けなみ","けぬき","げねつ","けねん","けはい","げひん","けぶかい","げぼく","けまり","けみかる","けむし","けむり","けもの","けらい","けろけろ","けわしい","けんい","けんえつ","けんお","けんか","げんき","けんげん","けんこう","けんさく","けんしゅう","けんすう","げんそう","けんちく","けんてい","けんとう","けんない","けんにん","げんぶつ","けんま","けんみん","けんめい","けんらん","けんり","こあくま","こいぬ","こいびと","ごうい","こうえん","こうおん","こうかん","ごうきゅう","ごうけい","こうこう","こうさい","こうじ","こうすい","ごうせい","こうそく","こうたい","こうちゃ","こうつう","こうてい","こうどう","こうない","こうはい","ごうほう","ごうまん","こうもく","こうりつ","こえる","こおり","ごかい","ごがつ","ごかん","こくご","こくさい","こくとう","こくない","こくはく","こぐま","こけい","こける","ここのか","こころ","こさめ","こしつ","こすう","こせい","こせき","こぜん","こそだて","こたい","こたえる","こたつ","こちょう","こっか","こつこつ","こつばん","こつぶ","こてい","こてん","ことがら","ことし","ことば","ことり","こなごな","こねこね","このまま","このみ","このよ","ごはん","こひつじ","こふう","こふん","こぼれる","ごまあぶら","こまかい","ごますり","こまつな","こまる","こむぎこ","こもじ","こもち","こもの","こもん","こやく","こやま","こゆう","こゆび","こよい","こよう","こりる","これくしょん","ころっけ","こわもて","こわれる","こんいん","こんかい","こんき","こんしゅう","こんすい","こんだて","こんとん","こんなん","こんびに","こんぽん","こんまけ","こんや","こんれい","こんわく","ざいえき","さいかい","さいきん","ざいげん","ざいこ","さいしょ","さいせい","ざいたく","ざいちゅう","さいてき","ざいりょう","さうな","さかいし","さがす","さかな","さかみち","さがる","さぎょう","さくし","さくひん","さくら","さこく","さこつ","さずかる","ざせき","さたん","さつえい","ざつおん","ざっか","ざつがく","さっきょく","ざっし","さつじん","ざっそう","さつたば","さつまいも","さてい","さといも","さとう","さとおや","さとし","さとる","さのう","さばく","さびしい","さべつ","さほう","さほど","さます","さみしい","さみだれ","さむけ","さめる","さやえんどう","さゆう","さよう","さよく","さらだ","ざるそば","さわやか","さわる","さんいん","さんか","さんきゃく","さんこう","さんさい","ざんしょ","さんすう","さんせい","さんそ","さんち","さんま","さんみ","さんらん","しあい","しあげ","しあさって","しあわせ","しいく","しいん","しうち","しえい","しおけ","しかい","しかく","じかん","しごと","しすう","じだい","したうけ","したぎ","したて","したみ","しちょう","しちりん","しっかり","しつじ","しつもん","してい","してき","してつ","じてん","じどう","しなぎれ","しなもの","しなん","しねま","しねん","しのぐ","しのぶ","しはい","しばかり","しはつ","しはらい","しはん","しひょう","しふく","じぶん","しへい","しほう","しほん","しまう","しまる","しみん","しむける","じむしょ","しめい","しめる","しもん","しゃいん","しゃうん","しゃおん","じゃがいも","しやくしょ","しゃくほう","しゃけん","しゃこ","しゃざい","しゃしん","しゃせん","しゃそう","しゃたい","しゃちょう","しゃっきん","じゃま","しゃりん","しゃれい","じゆう","じゅうしょ","しゅくはく","じゅしん","しゅっせき","しゅみ","しゅらば","じゅんばん","しょうかい","しょくたく","しょっけん","しょどう","しょもつ","しらせる","しらべる","しんか","しんこう","じんじゃ","しんせいじ","しんちく","しんりん","すあげ","すあし","すあな","ずあん","すいえい","すいか","すいとう","ずいぶん","すいようび","すうがく","すうじつ","すうせん","すおどり","すきま","すくう","すくない","すける","すごい","すこし","ずさん","すずしい","すすむ","すすめる","すっかり","ずっしり","ずっと","すてき","すてる","すねる","すのこ","すはだ","すばらしい","ずひょう","ずぶぬれ","すぶり","すふれ","すべて","すべる","ずほう","すぼん","すまい","すめし","すもう","すやき","すらすら","するめ","すれちがう","すろっと","すわる","すんぜん","すんぽう","せあぶら","せいかつ","せいげん","せいじ","せいよう","せおう","せかいかん","せきにん","せきむ","せきゆ","せきらんうん","せけん","せこう","せすじ","せたい","せたけ","せっかく","せっきゃく","ぜっく","せっけん","せっこつ","せっさたくま","せつぞく","せつだん","せつでん","せっぱん","せつび","せつぶん","せつめい","せつりつ","せなか","せのび","せはば","せびろ","せぼね","せまい","せまる","せめる","せもたれ","せりふ","ぜんあく","せんい","せんえい","せんか","せんきょ","せんく","せんげん","ぜんご","せんさい","せんしゅ","せんすい","せんせい","せんぞ","せんたく","せんちょう","せんてい","せんとう","せんぬき","せんねん","せんぱい","ぜんぶ","ぜんぽう","せんむ","せんめんじょ","せんもん","せんやく","せんゆう","せんよう","ぜんら","ぜんりゃく","せんれい","せんろ","そあく","そいとげる","そいね","そうがんきょう","そうき","そうご","そうしん","そうだん","そうなん","そうび","そうめん","そうり","そえもの","そえん","そがい","そげき","そこう","そこそこ","そざい","そしな","そせい","そせん","そそぐ","そだてる","そつう","そつえん","そっかん","そつぎょう","そっけつ","そっこう","そっせん","そっと","そとがわ","そとづら","そなえる","そなた","そふぼ","そぼく","そぼろ","そまつ","そまる","そむく","そむりえ","そめる","そもそも","そよかぜ","そらまめ","そろう","そんかい","そんけい","そんざい","そんしつ","そんぞく","そんちょう","ぞんび","ぞんぶん","そんみん","たあい","たいいん","たいうん","たいえき","たいおう","だいがく","たいき","たいぐう","たいけん","たいこ","たいざい","だいじょうぶ","だいすき","たいせつ","たいそう","だいたい","たいちょう","たいてい","だいどころ","たいない","たいねつ","たいのう","たいはん","だいひょう","たいふう","たいへん","たいほ","たいまつばな","たいみんぐ","たいむ","たいめん","たいやき","たいよう","たいら","たいりょく","たいる","たいわん","たうえ","たえる","たおす","たおる","たおれる","たかい","たかね","たきび","たくさん","たこく","たこやき","たさい","たしざん","だじゃれ","たすける","たずさわる","たそがれ","たたかう","たたく","ただしい","たたみ","たちばな","だっかい","だっきゃく","だっこ","だっしゅつ","だったい","たてる","たとえる","たなばた","たにん","たぬき","たのしみ","たはつ","たぶん","たべる","たぼう","たまご","たまる","だむる","ためいき","ためす","ためる","たもつ","たやすい","たよる","たらす","たりきほんがん","たりょう","たりる","たると","たれる","たれんと","たろっと","たわむれる","だんあつ","たんい","たんおん","たんか","たんき","たんけん","たんご","たんさん","たんじょうび","だんせい","たんそく","たんたい","だんち","たんてい","たんとう","だんな","たんにん","だんねつ","たんのう","たんぴん","だんぼう","たんまつ","たんめい","だんれつ","だんろ","だんわ","ちあい","ちあん","ちいき","ちいさい","ちえん","ちかい","ちから","ちきゅう","ちきん","ちけいず","ちけん","ちこく","ちさい","ちしき","ちしりょう","ちせい","ちそう","ちたい","ちたん","ちちおや","ちつじょ","ちてき","ちてん","ちぬき","ちぬり","ちのう","ちひょう","ちへいせん","ちほう","ちまた","ちみつ","ちみどろ","ちめいど","ちゃんこなべ","ちゅうい","ちゆりょく","ちょうし","ちょさくけん","ちらし","ちらみ","ちりがみ","ちりょう","ちるど","ちわわ","ちんたい","ちんもく","ついか","ついたち","つうか","つうじょう","つうはん","つうわ","つかう","つかれる","つくね","つくる","つけね","つける","つごう","つたえる","つづく","つつじ","つつむ","つとめる","つながる","つなみ","つねづね","つのる","つぶす","つまらない","つまる","つみき","つめたい","つもり","つもる","つよい","つるぼ","つるみく","つわもの","つわり","てあし","てあて","てあみ","ていおん","ていか","ていき","ていけい","ていこく","ていさつ","ていし","ていせい","ていたい","ていど","ていねい","ていひょう","ていへん","ていぼう","てうち","ておくれ","てきとう","てくび","でこぼこ","てさぎょう","てさげ","てすり","てそう","てちがい","てちょう","てつがく","てつづき","でっぱ","てつぼう","てつや","でぬかえ","てぬき","てぬぐい","てのひら","てはい","てぶくろ","てふだ","てほどき","てほん","てまえ","てまきずし","てみじか","てみやげ","てらす","てれび","てわけ","てわたし","でんあつ","てんいん","てんかい","てんき","てんぐ","てんけん","てんごく","てんさい","てんし","てんすう","でんち","てんてき","てんとう","てんない","てんぷら","てんぼうだい","てんめつ","てんらんかい","でんりょく","でんわ","どあい","といれ","どうかん","とうきゅう","どうぐ","とうし","とうむぎ","とおい","とおか","とおく","とおす","とおる","とかい","とかす","ときおり","ときどき","とくい","とくしゅう","とくてん","とくに","とくべつ","とけい","とける","とこや","とさか","としょかん","とそう","とたん","とちゅう","とっきゅう","とっくん","とつぜん","とつにゅう","とどける","ととのえる","とない","となえる","となり","とのさま","とばす","どぶがわ","とほう","とまる","とめる","ともだち","ともる","どようび","とらえる","とんかつ","どんぶり","ないかく","ないこう","ないしょ","ないす","ないせん","ないそう","なおす","ながい","なくす","なげる","なこうど","なさけ","なたでここ","なっとう","なつやすみ","ななおし","なにごと","なにもの","なにわ","なのか","なふだ","なまいき","なまえ","なまみ","なみだ","なめらか","なめる","なやむ","ならう","ならび","ならぶ","なれる","なわとび","なわばり","にあう","にいがた","にうけ","におい","にかい","にがて","にきび","にくしみ","にくまん","にげる","にさんかたんそ","にしき","にせもの","にちじょう","にちようび","にっか","にっき","にっけい","にっこう","にっさん","にっしょく","にっすう","にっせき","にってい","になう","にほん","にまめ","にもつ","にやり","にゅういん","にりんしゃ","にわとり","にんい","にんか","にんき","にんげん","にんしき","にんずう","にんそう","にんたい","にんち","にんてい","にんにく","にんぷ","にんまり","にんむ","にんめい","にんよう","ぬいくぎ","ぬかす","ぬぐいとる","ぬぐう","ぬくもり","ぬすむ","ぬまえび","ぬめり","ぬらす","ぬんちゃく","ねあげ","ねいき","ねいる","ねいろ","ねぐせ","ねくたい","ねくら","ねこぜ","ねこむ","ねさげ","ねすごす","ねそべる","ねだん","ねつい","ねっしん","ねつぞう","ねったいぎょ","ねぶそく","ねふだ","ねぼう","ねほりはほり","ねまき","ねまわし","ねみみ","ねむい","ねむたい","ねもと","ねらう","ねわざ","ねんいり","ねんおし","ねんかん","ねんきん","ねんぐ","ねんざ","ねんし","ねんちゃく","ねんど","ねんぴ","ねんぶつ","ねんまつ","ねんりょう","ねんれい","のいず","のおづま","のがす","のきなみ","のこぎり","のこす","のこる","のせる","のぞく","のぞむ","のたまう","のちほど","のっく","のばす","のはら","のべる","のぼる","のみもの","のやま","のらいぬ","のらねこ","のりもの","のりゆき","のれん","のんき","ばあい","はあく","ばあさん","ばいか","ばいく","はいけん","はいご","はいしん","はいすい","はいせん","はいそう","はいち","ばいばい","はいれつ","はえる","はおる","はかい","ばかり","はかる","はくしゅ","はけん","はこぶ","はさみ","はさん","はしご","ばしょ","はしる","はせる","ぱそこん","はそん","はたん","はちみつ","はつおん","はっかく","はづき","はっきり","はっくつ","はっけん","はっこう","はっさん","はっしん","はったつ","はっちゅう","はってん","はっぴょう","はっぽう","はなす","はなび","はにかむ","はぶらし","はみがき","はむかう","はめつ","はやい","はやし","はらう","はろうぃん","はわい","はんい","はんえい","はんおん","はんかく","はんきょう","ばんぐみ","はんこ","はんしゃ","はんすう","はんだん","ぱんち","ぱんつ","はんてい","はんとし","はんのう","はんぱ","はんぶん","はんぺん","はんぼうき","はんめい","はんらん","はんろん","ひいき","ひうん","ひえる","ひかく","ひかり","ひかる","ひかん","ひくい","ひけつ","ひこうき","ひこく","ひさい","ひさしぶり","ひさん","びじゅつかん","ひしょ","ひそか","ひそむ","ひたむき","ひだり","ひたる","ひつぎ","ひっこし","ひっし","ひつじゅひん","ひっす","ひつぜん","ぴったり","ぴっちり","ひつよう","ひてい","ひとごみ","ひなまつり","ひなん","ひねる","ひはん","ひびく","ひひょう","ひほう","ひまわり","ひまん","ひみつ","ひめい","ひめじし","ひやけ","ひやす","ひよう","びょうき","ひらがな","ひらく","ひりつ","ひりょう","ひるま","ひるやすみ","ひれい","ひろい","ひろう","ひろき","ひろゆき","ひんかく","ひんけつ","ひんこん","ひんしゅ","ひんそう","ぴんち","ひんぱん","びんぼう","ふあん","ふいうち","ふうけい","ふうせん","ぷうたろう","ふうとう","ふうふ","ふえる","ふおん","ふかい","ふきん","ふくざつ","ふくぶくろ","ふこう","ふさい","ふしぎ","ふじみ","ふすま","ふせい","ふせぐ","ふそく","ぶたにく","ふたん","ふちょう","ふつう","ふつか","ふっかつ","ふっき","ふっこく","ぶどう","ふとる","ふとん","ふのう","ふはい","ふひょう","ふへん","ふまん","ふみん","ふめつ","ふめん","ふよう","ふりこ","ふりる","ふるい","ふんいき","ぶんがく","ぶんぐ","ふんしつ","ぶんせき","ふんそう","ぶんぽう","へいあん","へいおん","へいがい","へいき","へいげん","へいこう","へいさ","へいしゃ","へいせつ","へいそ","へいたく","へいてん","へいねつ","へいわ","へきが","へこむ","べにいろ","べにしょうが","へらす","へんかん","べんきょう","べんごし","へんさい","へんたい","べんり","ほあん","ほいく","ぼうぎょ","ほうこく","ほうそう","ほうほう","ほうもん","ほうりつ","ほえる","ほおん","ほかん","ほきょう","ぼきん","ほくろ","ほけつ","ほけん","ほこう","ほこる","ほしい","ほしつ","ほしゅ","ほしょう","ほせい","ほそい","ほそく","ほたて","ほたる","ぽちぶくろ","ほっきょく","ほっさ","ほったん","ほとんど","ほめる","ほんい","ほんき","ほんけ","ほんしつ","ほんやく","まいにち","まかい","まかせる","まがる","まける","まこと","まさつ","まじめ","ますく","まぜる","まつり","まとめ","まなぶ","まぬけ","まねく","まほう","まもる","まゆげ","まよう","まろやか","まわす","まわり","まわる","まんが","まんきつ","まんぞく","まんなか","みいら","みうち","みえる","みがく","みかた","みかん","みけん","みこん","みじかい","みすい","みすえる","みせる","みっか","みつかる","みつける","みてい","みとめる","みなと","みなみかさい","みねらる","みのう","みのがす","みほん","みもと","みやげ","みらい","みりょく","みわく","みんか","みんぞく","むいか","むえき","むえん","むかい","むかう","むかえ","むかし","むぎちゃ","むける","むげん","むさぼる","むしあつい","むしば","むじゅん","むしろ","むすう","むすこ","むすぶ","むすめ","むせる","むせん","むちゅう","むなしい","むのう","むやみ","むよう","むらさき","むりょう","むろん","めいあん","めいうん","めいえん","めいかく","めいきょく","めいさい","めいし","めいそう","めいぶつ","めいれい","めいわく","めぐまれる","めざす","めした","めずらしい","めだつ","めまい","めやす","めんきょ","めんせき","めんどう","もうしあげる","もうどうけん","もえる","もくし","もくてき","もくようび","もちろん","もどる","もらう","もんく","もんだい","やおや","やける","やさい","やさしい","やすい","やすたろう","やすみ","やせる","やそう","やたい","やちん","やっと","やっぱり","やぶる","やめる","ややこしい","やよい","やわらかい","ゆうき","ゆうびんきょく","ゆうべ","ゆうめい","ゆけつ","ゆしゅつ","ゆせん","ゆそう","ゆたか","ゆちゃく","ゆでる","ゆにゅう","ゆびわ","ゆらい","ゆれる","ようい","ようか","ようきゅう","ようじ","ようす","ようちえん","よかぜ","よかん","よきん","よくせい","よくぼう","よけい","よごれる","よさん","よしゅう","よそう","よそく","よっか","よてい","よどがわく","よねつ","よやく","よゆう","よろこぶ","よろしい","らいう","らくがき","らくご","らくさつ","らくだ","らしんばん","らせん","らぞく","らたい","らっか","られつ","りえき","りかい","りきさく","りきせつ","りくぐん","りくつ","りけん","りこう","りせい","りそう","りそく","りてん","りねん","りゆう","りゅうがく","りよう","りょうり","りょかん","りょくちゃ","りょこう","りりく","りれき","りろん","りんご","るいけい","るいさい","るいじ","るいせき","るすばん","るりがわら","れいかん","れいぎ","れいせい","れいぞうこ","れいとう","れいぼう","れきし","れきだい","れんあい","れんけい","れんこん","れんさい","れんしゅう","れんぞく","れんらく","ろうか","ろうご","ろうじん","ろうそく","ろくが","ろこつ","ろじうら","ろしゅつ","ろせん","ろてん","ろめん","ろれつ","ろんぎ","ろんぱ","ろんぶん","ろんり","わかす","わかめ","わかやま","わかれる","わしつ","わじまし","わすれもの","わらう","われる"];Mr.space=" ";const Tr=["ábaco","abdomen","abeja","abierto","abogado","abono","aborto","abrazo","abrir","abuelo","abuso","acabar","academia","acceso","acción","aceite","acelga","acento","aceptar","ácido","aclarar","acné","acoger","acoso","activo","acto","actriz","actuar","acudir","acuerdo","acusar","adicto","admitir","adoptar","adorno","aduana","adulto","aéreo","afectar","afición","afinar","afirmar","ágil","agitar","agonía","agosto","agotar","agregar","agrio","agua","agudo","águila","aguja","ahogo","ahorro","aire","aislar","ajedrez","ajeno","ajuste","alacrán","alambre","alarma","alba","álbum","alcalde","aldea","alegre","alejar","alerta","aleta","alfiler","alga","algodón","aliado","aliento","alivio","alma","almeja","almíbar","altar","alteza","altivo","alto","altura","alumno","alzar","amable","amante","amapola","amargo","amasar","ámbar","ámbito","ameno","amigo","amistad","amor","amparo","amplio","ancho","anciano","ancla","andar","andén","anemia","ángulo","anillo","ánimo","anís","anotar","antena","antiguo","antojo","anual","anular","anuncio","añadir","añejo","año","apagar","aparato","apetito","apio","aplicar","apodo","aporte","apoyo","aprender","aprobar","apuesta","apuro","arado","araña","arar","árbitro","árbol","arbusto","archivo","arco","arder","ardilla","arduo","área","árido","aries","armonía","arnés","aroma","arpa","arpón","arreglo","arroz","arruga","arte","artista","asa","asado","asalto","ascenso","asegurar","aseo","asesor","asiento","asilo","asistir","asno","asombro","áspero","astilla","astro","astuto","asumir","asunto","atajo","ataque","atar","atento","ateo","ático","atleta","átomo","atraer","atroz","atún","audaz","audio","auge","aula","aumento","ausente","autor","aval","avance","avaro","ave","avellana","avena","avestruz","avión","aviso","ayer","ayuda","ayuno","azafrán","azar","azote","azúcar","azufre","azul","baba","babor","bache","bahía","baile","bajar","balanza","balcón","balde","bambú","banco","banda","baño","barba","barco","barniz","barro","báscula","bastón","basura","batalla","batería","batir","batuta","baúl","bazar","bebé","bebida","bello","besar","beso","bestia","bicho","bien","bingo","blanco","bloque","blusa","boa","bobina","bobo","boca","bocina","boda","bodega","boina","bola","bolero","bolsa","bomba","bondad","bonito","bono","bonsái","borde","borrar","bosque","bote","botín","bóveda","bozal","bravo","brazo","brecha","breve","brillo","brinco","brisa","broca","broma","bronce","brote","bruja","brusco","bruto","buceo","bucle","bueno","buey","bufanda","bufón","búho","buitre","bulto","burbuja","burla","burro","buscar","butaca","buzón","caballo","cabeza","cabina","cabra","cacao","cadáver","cadena","caer","café","caída","caimán","caja","cajón","cal","calamar","calcio","caldo","calidad","calle","calma","calor","calvo","cama","cambio","camello","camino","campo","cáncer","candil","canela","canguro","canica","canto","caña","cañón","caoba","caos","capaz","capitán","capote","captar","capucha","cara","carbón","cárcel","careta","carga","cariño","carne","carpeta","carro","carta","casa","casco","casero","caspa","castor","catorce","catre","caudal","causa","cazo","cebolla","ceder","cedro","celda","célebre","celoso","célula","cemento","ceniza","centro","cerca","cerdo","cereza","cero","cerrar","certeza","césped","cetro","chacal","chaleco","champú","chancla","chapa","charla","chico","chiste","chivo","choque","choza","chuleta","chupar","ciclón","ciego","cielo","cien","cierto","cifra","cigarro","cima","cinco","cine","cinta","ciprés","circo","ciruela","cisne","cita","ciudad","clamor","clan","claro","clase","clave","cliente","clima","clínica","cobre","cocción","cochino","cocina","coco","código","codo","cofre","coger","cohete","cojín","cojo","cola","colcha","colegio","colgar","colina","collar","colmo","columna","combate","comer","comida","cómodo","compra","conde","conejo","conga","conocer","consejo","contar","copa","copia","corazón","corbata","corcho","cordón","corona","correr","coser","cosmos","costa","cráneo","cráter","crear","crecer","creído","crema","cría","crimen","cripta","crisis","cromo","crónica","croqueta","crudo","cruz","cuadro","cuarto","cuatro","cubo","cubrir","cuchara","cuello","cuento","cuerda","cuesta","cueva","cuidar","culebra","culpa","culto","cumbre","cumplir","cuna","cuneta","cuota","cupón","cúpula","curar","curioso","curso","curva","cutis","dama","danza","dar","dardo","dátil","deber","débil","década","decir","dedo","defensa","definir","dejar","delfín","delgado","delito","demora","denso","dental","deporte","derecho","derrota","desayuno","deseo","desfile","desnudo","destino","desvío","detalle","detener","deuda","día","diablo","diadema","diamante","diana","diario","dibujo","dictar","diente","dieta","diez","difícil","digno","dilema","diluir","dinero","directo","dirigir","disco","diseño","disfraz","diva","divino","doble","doce","dolor","domingo","don","donar","dorado","dormir","dorso","dos","dosis","dragón","droga","ducha","duda","duelo","dueño","dulce","dúo","duque","durar","dureza","duro","ébano","ebrio","echar","eco","ecuador","edad","edición","edificio","editor","educar","efecto","eficaz","eje","ejemplo","elefante","elegir","elemento","elevar","elipse","élite","elixir","elogio","eludir","embudo","emitir","emoción","empate","empeño","empleo","empresa","enano","encargo","enchufe","encía","enemigo","enero","enfado","enfermo","engaño","enigma","enlace","enorme","enredo","ensayo","enseñar","entero","entrar","envase","envío","época","equipo","erizo","escala","escena","escolar","escribir","escudo","esencia","esfera","esfuerzo","espada","espejo","espía","esposa","espuma","esquí","estar","este","estilo","estufa","etapa","eterno","ética","etnia","evadir","evaluar","evento","evitar","exacto","examen","exceso","excusa","exento","exigir","exilio","existir","éxito","experto","explicar","exponer","extremo","fábrica","fábula","fachada","fácil","factor","faena","faja","falda","fallo","falso","faltar","fama","familia","famoso","faraón","farmacia","farol","farsa","fase","fatiga","fauna","favor","fax","febrero","fecha","feliz","feo","feria","feroz","fértil","fervor","festín","fiable","fianza","fiar","fibra","ficción","ficha","fideo","fiebre","fiel","fiera","fiesta","figura","fijar","fijo","fila","filete","filial","filtro","fin","finca","fingir","finito","firma","flaco","flauta","flecha","flor","flota","fluir","flujo","flúor","fobia","foca","fogata","fogón","folio","folleto","fondo","forma","forro","fortuna","forzar","fosa","foto","fracaso","frágil","franja","frase","fraude","freír","freno","fresa","frío","frito","fruta","fuego","fuente","fuerza","fuga","fumar","función","funda","furgón","furia","fusil","fútbol","futuro","gacela","gafas","gaita","gajo","gala","galería","gallo","gamba","ganar","gancho","ganga","ganso","garaje","garza","gasolina","gastar","gato","gavilán","gemelo","gemir","gen","género","genio","gente","geranio","gerente","germen","gesto","gigante","gimnasio","girar","giro","glaciar","globo","gloria","gol","golfo","goloso","golpe","goma","gordo","gorila","gorra","gota","goteo","gozar","grada","gráfico","grano","grasa","gratis","grave","grieta","grillo","gripe","gris","grito","grosor","grúa","grueso","grumo","grupo","guante","guapo","guardia","guerra","guía","guiño","guion","guiso","guitarra","gusano","gustar","haber","hábil","hablar","hacer","hacha","hada","hallar","hamaca","harina","haz","hazaña","hebilla","hebra","hecho","helado","helio","hembra","herir","hermano","héroe","hervir","hielo","hierro","hígado","higiene","hijo","himno","historia","hocico","hogar","hoguera","hoja","hombre","hongo","honor","honra","hora","hormiga","horno","hostil","hoyo","hueco","huelga","huerta","hueso","huevo","huida","huir","humano","húmedo","humilde","humo","hundir","huracán","hurto","icono","ideal","idioma","ídolo","iglesia","iglú","igual","ilegal","ilusión","imagen","imán","imitar","impar","imperio","imponer","impulso","incapaz","índice","inerte","infiel","informe","ingenio","inicio","inmenso","inmune","innato","insecto","instante","interés","íntimo","intuir","inútil","invierno","ira","iris","ironía","isla","islote","jabalí","jabón","jamón","jarabe","jardín","jarra","jaula","jazmín","jefe","jeringa","jinete","jornada","joroba","joven","joya","juerga","jueves","juez","jugador","jugo","juguete","juicio","junco","jungla","junio","juntar","júpiter","jurar","justo","juvenil","juzgar","kilo","koala","labio","lacio","lacra","lado","ladrón","lagarto","lágrima","laguna","laico","lamer","lámina","lámpara","lana","lancha","langosta","lanza","lápiz","largo","larva","lástima","lata","látex","latir","laurel","lavar","lazo","leal","lección","leche","lector","leer","legión","legumbre","lejano","lengua","lento","leña","león","leopardo","lesión","letal","letra","leve","leyenda","libertad","libro","licor","líder","lidiar","lienzo","liga","ligero","lima","límite","limón","limpio","lince","lindo","línea","lingote","lino","linterna","líquido","liso","lista","litera","litio","litro","llaga","llama","llanto","llave","llegar","llenar","llevar","llorar","llover","lluvia","lobo","loción","loco","locura","lógica","logro","lombriz","lomo","lonja","lote","lucha","lucir","lugar","lujo","luna","lunes","lupa","lustro","luto","luz","maceta","macho","madera","madre","maduro","maestro","mafia","magia","mago","maíz","maldad","maleta","malla","malo","mamá","mambo","mamut","manco","mando","manejar","manga","maniquí","manjar","mano","manso","manta","mañana","mapa","máquina","mar","marco","marea","marfil","margen","marido","mármol","marrón","martes","marzo","masa","máscara","masivo","matar","materia","matiz","matriz","máximo","mayor","mazorca","mecha","medalla","medio","médula","mejilla","mejor","melena","melón","memoria","menor","mensaje","mente","menú","mercado","merengue","mérito","mes","mesón","meta","meter","método","metro","mezcla","miedo","miel","miembro","miga","mil","milagro","militar","millón","mimo","mina","minero","mínimo","minuto","miope","mirar","misa","miseria","misil","mismo","mitad","mito","mochila","moción","moda","modelo","moho","mojar","molde","moler","molino","momento","momia","monarca","moneda","monja","monto","moño","morada","morder","moreno","morir","morro","morsa","mortal","mosca","mostrar","motivo","mover","móvil","mozo","mucho","mudar","mueble","muela","muerte","muestra","mugre","mujer","mula","muleta","multa","mundo","muñeca","mural","muro","músculo","museo","musgo","música","muslo","nácar","nación","nadar","naipe","naranja","nariz","narrar","nasal","natal","nativo","natural","náusea","naval","nave","navidad","necio","néctar","negar","negocio","negro","neón","nervio","neto","neutro","nevar","nevera","nicho","nido","niebla","nieto","niñez","niño","nítido","nivel","nobleza","noche","nómina","noria","norma","norte","nota","noticia","novato","novela","novio","nube","nuca","núcleo","nudillo","nudo","nuera","nueve","nuez","nulo","número","nutria","oasis","obeso","obispo","objeto","obra","obrero","observar","obtener","obvio","oca","ocaso","océano","ochenta","ocho","ocio","ocre","octavo","octubre","oculto","ocupar","ocurrir","odiar","odio","odisea","oeste","ofensa","oferta","oficio","ofrecer","ogro","oído","oír","ojo","ola","oleada","olfato","olivo","olla","olmo","olor","olvido","ombligo","onda","onza","opaco","opción","ópera","opinar","oponer","optar","óptica","opuesto","oración","orador","oral","órbita","orca","orden","oreja","órgano","orgía","orgullo","oriente","origen","orilla","oro","orquesta","oruga","osadía","oscuro","osezno","oso","ostra","otoño","otro","oveja","óvulo","óxido","oxígeno","oyente","ozono","pacto","padre","paella","página","pago","país","pájaro","palabra","palco","paleta","pálido","palma","paloma","palpar","pan","panal","pánico","pantera","pañuelo","papá","papel","papilla","paquete","parar","parcela","pared","parir","paro","párpado","parque","párrafo","parte","pasar","paseo","pasión","paso","pasta","pata","patio","patria","pausa","pauta","pavo","payaso","peatón","pecado","pecera","pecho","pedal","pedir","pegar","peine","pelar","peldaño","pelea","peligro","pellejo","pelo","peluca","pena","pensar","peñón","peón","peor","pepino","pequeño","pera","percha","perder","pereza","perfil","perico","perla","permiso","perro","persona","pesa","pesca","pésimo","pestaña","pétalo","petróleo","pez","pezuña","picar","pichón","pie","piedra","pierna","pieza","pijama","pilar","piloto","pimienta","pino","pintor","pinza","piña","piojo","pipa","pirata","pisar","piscina","piso","pista","pitón","pizca","placa","plan","plata","playa","plaza","pleito","pleno","plomo","pluma","plural","pobre","poco","poder","podio","poema","poesía","poeta","polen","policía","pollo","polvo","pomada","pomelo","pomo","pompa","poner","porción","portal","posada","poseer","posible","poste","potencia","potro","pozo","prado","precoz","pregunta","premio","prensa","preso","previo","primo","príncipe","prisión","privar","proa","probar","proceso","producto","proeza","profesor","programa","prole","promesa","pronto","propio","próximo","prueba","público","puchero","pudor","pueblo","puerta","puesto","pulga","pulir","pulmón","pulpo","pulso","puma","punto","puñal","puño","pupa","pupila","puré","quedar","queja","quemar","querer","queso","quieto","química","quince","quitar","rábano","rabia","rabo","ración","radical","raíz","rama","rampa","rancho","rango","rapaz","rápido","rapto","rasgo","raspa","rato","rayo","raza","razón","reacción","realidad","rebaño","rebote","recaer","receta","rechazo","recoger","recreo","recto","recurso","red","redondo","reducir","reflejo","reforma","refrán","refugio","regalo","regir","regla","regreso","rehén","reino","reír","reja","relato","relevo","relieve","relleno","reloj","remar","remedio","remo","rencor","rendir","renta","reparto","repetir","reposo","reptil","res","rescate","resina","respeto","resto","resumen","retiro","retorno","retrato","reunir","revés","revista","rey","rezar","rico","riego","rienda","riesgo","rifa","rígido","rigor","rincón","riñón","río","riqueza","risa","ritmo","rito","rizo","roble","roce","rociar","rodar","rodeo","rodilla","roer","rojizo","rojo","romero","romper","ron","ronco","ronda","ropa","ropero","rosa","rosca","rostro","rotar","rubí","rubor","rudo","rueda","rugir","ruido","ruina","ruleta","rulo","rumbo","rumor","ruptura","ruta","rutina","sábado","saber","sabio","sable","sacar","sagaz","sagrado","sala","saldo","salero","salir","salmón","salón","salsa","salto","salud","salvar","samba","sanción","sandía","sanear","sangre","sanidad","sano","santo","sapo","saque","sardina","sartén","sastre","satán","sauna","saxofón","sección","seco","secreto","secta","sed","seguir","seis","sello","selva","semana","semilla","senda","sensor","señal","señor","separar","sepia","sequía","ser","serie","sermón","servir","sesenta","sesión","seta","setenta","severo","sexo","sexto","sidra","siesta","siete","siglo","signo","sílaba","silbar","silencio","silla","símbolo","simio","sirena","sistema","sitio","situar","sobre","socio","sodio","sol","solapa","soldado","soledad","sólido","soltar","solución","sombra","sondeo","sonido","sonoro","sonrisa","sopa","soplar","soporte","sordo","sorpresa","sorteo","sostén","sótano","suave","subir","suceso","sudor","suegra","suelo","sueño","suerte","sufrir","sujeto","sultán","sumar","superar","suplir","suponer","supremo","sur","surco","sureño","surgir","susto","sutil","tabaco","tabique","tabla","tabú","taco","tacto","tajo","talar","talco","talento","talla","talón","tamaño","tambor","tango","tanque","tapa","tapete","tapia","tapón","taquilla","tarde","tarea","tarifa","tarjeta","tarot","tarro","tarta","tatuaje","tauro","taza","tazón","teatro","techo","tecla","técnica","tejado","tejer","tejido","tela","teléfono","tema","temor","templo","tenaz","tender","tener","tenis","tenso","teoría","terapia","terco","término","ternura","terror","tesis","tesoro","testigo","tetera","texto","tez","tibio","tiburón","tiempo","tienda","tierra","tieso","tigre","tijera","tilde","timbre","tímido","timo","tinta","tío","típico","tipo","tira","tirón","titán","títere","título","tiza","toalla","tobillo","tocar","tocino","todo","toga","toldo","tomar","tono","tonto","topar","tope","toque","tórax","torero","tormenta","torneo","toro","torpedo","torre","torso","tortuga","tos","tosco","toser","tóxico","trabajo","tractor","traer","tráfico","trago","traje","tramo","trance","trato","trauma","trazar","trébol","tregua","treinta","tren","trepar","tres","tribu","trigo","tripa","triste","triunfo","trofeo","trompa","tronco","tropa","trote","trozo","truco","trueno","trufa","tubería","tubo","tuerto","tumba","tumor","túnel","túnica","turbina","turismo","turno","tutor","ubicar","úlcera","umbral","unidad","unir","universo","uno","untar","uña","urbano","urbe","urgente","urna","usar","usuario","útil","utopía","uva","vaca","vacío","vacuna","vagar","vago","vaina","vajilla","vale","válido","valle","valor","válvula","vampiro","vara","variar","varón","vaso","vecino","vector","vehículo","veinte","vejez","vela","velero","veloz","vena","vencer","venda","veneno","vengar","venir","venta","venus","ver","verano","verbo","verde","vereda","verja","verso","verter","vía","viaje","vibrar","vicio","víctima","vida","vídeo","vidrio","viejo","viernes","vigor","vil","villa","vinagre","vino","viñedo","violín","viral","virgo","virtud","visor","víspera","vista","vitamina","viudo","vivaz","vivero","vivir","vivo","volcán","volumen","volver","voraz","votar","voto","voz","vuelo","vulgar","yacer","yate","yegua","yema","yerno","yeso","yodo","yoga","yogur","zafiro","zanja","zapato","zarza","zona","zorro","zumo","zurdo"];Tr.space=" ";class Cr extends Te{constructor(e,t,n){super({mnemonic:e,seed:t,wordlist:n}),this.Wordlist=n||Nr,this.es=Tr,this.jp=Mr}setLang(e){switch(e){case"es":this.Wordlist=Tr;break;case"jp":this.Wordlist=Mr;break;default:this.Wordlist=Nr;break}}toBw(e){if(e||(e=new ke),this.mnemonic){const t=Buffer.from(this.mnemonic);e.writeVarIntNum(t.length),e.write(t)}else e.writeVarIntNum(0);return this.seed?(e.writeVarIntNum(this.seed.length),e.write(this.seed)):e.writeVarIntNum(0),e}fromBr(e){const t=e.readVarIntNum();t>0&&(this.mnemonic=e.read(t).toString());const n=e.readVarIntNum();return n>0&&(this.seed=e.read(n)),this}fromRandom(e){if(e||(e=128),e%32!==0)throw new Error("bits must be multiple of 32");if(e<128)throw new Error("bits must be at least 128");const t=Rt.getRandomBuffer(e/8);return this.entropy2Mnemonic(t),this.mnemonic2Seed(),this}static fromRandom(e){return new this().fromRandom(e)}async asyncFromRandom(e){e||(e=128);const t=Rt.getRandomBuffer(e/8);let n=await le.asyncObjectMethod(this,"entropy2Mnemonic",[t]);const u=new Cr().fromFastBuffer(n.resbuf);return n=await le.asyncObjectMethod(u,"mnemonic2Seed",[]),this.fromFastBuffer(n.resbuf)}static asyncFromRandom(e){return new this().asyncFromRandom(e)}fromEntropy(e){return this.entropy2Mnemonic(e),this}static fromEntropy(e){return new this().fromEntropy(e)}async asyncFromEntropy(e){const t=await le.asyncObjectMethod(this,"fromEntropy",[e]);return this.fromFastBuffer(t.resbuf)}static asyncFromEntropy(e){return new this().asyncFromEntropy(e)}fromString(e){return this.mnemonic=e,this}toString(){return this.mnemonic}toSeed(e){return this.mnemonic2Seed(e),this.seed}async asyncToSeed(e){e===void 0&&(e="");const t=[e];return(await le.asyncObjectMethod(this,"toSeed",t)).resbuf}entropy2Mnemonic(e){if(!Buffer.isBuffer(e)||e.length<128/8)throw new Error("Entropy is less than 128 bits. It must be 128 bits or more.");const t=ae.sha256(e);let n="";const u=e.length*8;for(let a=0;a<e.length;a++)n=n+("00000000"+e[a].toString(2)).slice(-8);let r=t[0].toString(2);if(r=("00000000"+r).slice(-8).slice(0,u/32),n=n+r,n.length%11!==0)throw new Error("internal error - entropy not an even multiple of 11 bits - "+n.length);let s="";for(let a=0;a<n.length/11;a++){s!==""&&(s=s+this.Wordlist.space);const o=parseInt(n.slice(a*11,(a+1)*11),2);s=s+this.Wordlist[o]}return this.mnemonic=s,this}check(){const t=this.mnemonic.split(this.Wordlist.space);let n="";for(let i=0;i<t.length;i++){const c=this.Wordlist.indexOf(t[i]);if(c<0)return!1;n=n+("00000000000"+c.toString(2)).slice(-11)}if(n.length%11!==0)throw new Error("internal error - entropy not an even multiple of 11 bits - "+n.length);const u=n.length/33,r=n.slice(-u),s=n.slice(0,n.length-u),a=Buffer.alloc(s.length/8);for(let i=0;i<s.length/8;i++)a.writeUInt8(parseInt(n.slice(i*8,(i+1)*8),2),i);let f=ae.sha256(a)[0].toString(2);return f=("00000000"+f).slice(-8).slice(0,u),f===r}mnemonic2Seed(e=""){let t=this.mnemonic;if(!this.check())throw new Error("Mnemonic does not pass the check - was the mnemonic typed incorrectly? Are there extra spaces?");if(typeof e!="string")throw new Error("passphrase must be a string or undefined");t=t.normalize("NFKD"),e=e.normalize("NFKD");const n=Buffer.from(t),u=Buffer.concat([Buffer.from("mnemonic"),Buffer.from(e)]);return this.seed=Buffer.from(Rd.pbkdf2Sync(n,u,2048,64,"sha512")),this}isValid(e=""){let t;try{t=!!this.mnemonic2Seed(e)}catch{t=!1}return t}static isValid(e,t=""){return new Cr(e).isValid(t)}}class st extends Te{constructor(e,t,n=gt){super({privKey:e,pubKey:t}),this.PrivKey=n}fromJSON(e){return e.privKey&&(this.privKey=this.PrivKey.fromJSON(e.privKey)),e.pubKey&&(this.pubKey=Ue.fromJSON(e.pubKey)),this}fromBr(e){const t=e.readUInt8();t>0&&(this.privKey=new this.PrivKey().fromFastBuffer(e.read(t)));const n=e.readUInt8();return n>0&&(this.pubKey=new Ue().fromFastBuffer(e.read(n))),this}toBw(e){if(e||(e=new ke),this.privKey){const t=this.privKey.toFastBuffer();e.writeUInt8(t.length),e.write(t)}else e.writeUInt8(0);if(this.pubKey){const t=this.pubKey.toFastBuffer();e.writeUInt8(t.length),e.write(t)}else e.writeUInt8(0);return e}fromString(e){return this.fromJSON(JSON.parse(e))}toString(){return JSON.stringify(this.toJSON())}toPublic(){const e=new st().fromObject(this);return e.privKey=void 0,e}fromPrivKey(e){return this.privKey=e,this.pubKey=new Ue().fromPrivKey(e),this}static fromPrivKey(e){return new this().fromPrivKey(e)}async asyncFromPrivKey(e){return this.privKey=e,this.pubKey=await new Ue().asyncFromPrivKey(e),this}static asyncFromPrivKey(e){return new this().asyncFromPrivKey(e)}fromRandom(){return this.privKey=new this.PrivKey().fromRandom(),this.pubKey=new Ue().fromPrivKey(this.privKey),this}static fromRandom(){return new this().fromRandom()}async asyncFromRandom(){return this.privKey=new this.PrivKey().fromRandom(),this.asyncFromPrivKey(this.privKey)}static asyncFromRandom(){return new this().asyncFromRandom()}}st.Mainnet=class extends st{constructor(l,e){super(l,e,gt.Mainnet)}};st.Testnet=class extends st{constructor(l,e){super(l,e,gt.Testnet)}};class ut extends Te{constructor(e,t,n,u,r,s){super({sig:e,keyPair:t,hashBuf:n,k:u,endian:r,verified:s})}toJSON(){return{sig:this.sig?this.sig.toString():void 0,keyPair:this.keyPair?this.keyPair.toBuffer().toString("hex"):void 0,hashBuf:this.hashBuf?this.hashBuf.toString("hex"):void 0,k:this.k?this.k.toString():void 0,endian:this.endian,verified:this.verified}}fromJSON(e){return this.sig=e.sig?new he().fromString(e.sig):void 0,this.keyPair=e.keyPair?new st().fromBuffer(Buffer.from(e.keyPair,"hex")):void 0,this.hashBuf=e.hashBuf?Buffer.from(e.hashBuf,"hex"):void 0,this.k=e.k?new Z().fromString(e.k):void 0,this.endian=e.endian,this.verified=e.verified,this}toBuffer(){const e=JSON.stringify(this.toJSON());return Buffer.from(e)}fromBuffer(e){const t=JSON.parse(e.toString());return this.fromJSON(t)}calcrecovery(){for(let e=0;e<4;e++){let t;this.sig.recovery=e;try{t=this.sig2PubKey()}catch{continue}if(t.point.eq(this.keyPair.pubKey.point)){const n=this.keyPair.pubKey.compressed;return this.sig.compressed=this.keyPair.pubKey.compressed===void 0?!0:n,this}}throw this.sig.recovery=void 0,new Error("Unable to find valid recovery factor")}async asyncCalcrecovery(){const e=await le.asyncObjectMethod(this,"calcrecovery",[]);return this.fromFastBuffer(e.resbuf)}static calcrecovery(e,t,n){return new ut().fromObject({sig:e,keyPair:new st().fromObject({pubKey:t}),hashBuf:n}).calcrecovery().sig}static async asyncCalcrecovery(e,t,n){const u=await le.asyncClassMethod(ut,"calcrecovery",[e,t,n]);return new he().fromFastBuffer(u.resbuf)}fromString(e){const t=JSON.parse(e);return t.hashBuf&&(this.hashBuf=Buffer.from(t.hashBuf,"hex")),t.keyPair&&(this.keyPair=new st().fromString(t.keyPair)),t.sig&&(this.sig=new he().fromString(t.sig)),t.k&&(this.k=new Z(t.k,10)),this}randomK(){const e=Ie.getN();let t;do t=new Z().fromBuffer(Rt.getRandomBuffer(32));while(!(t.lt(e)&&t.gt(0)));return this.k=t,this}deterministicK(e){let t=Buffer.alloc(32);t.fill(1);let n=Buffer.alloc(32);n.fill(0);const u=this.keyPair.privKey.bn.toBuffer({size:32});n=ae.sha256Hmac(Buffer.concat([t,Buffer.from([0]),u,this.hashBuf]),n),t=ae.sha256Hmac(t,n),n=ae.sha256Hmac(Buffer.concat([t,Buffer.from([1]),u,this.hashBuf]),n),t=ae.sha256Hmac(t,n),t=ae.sha256Hmac(t,n);let r=new Z().fromBuffer(t);const s=Ie.getN();e===void 0&&(e=0);for(let a=0;a<e||!(r.lt(s)&&r.gt(0));a++)n=ae.sha256Hmac(Buffer.concat([t,Buffer.from([0])]),n),t=ae.sha256Hmac(t,n),t=ae.sha256Hmac(t,n),r=new Z().fromBuffer(t);return this.k=r,this}sig2PubKey(){const e=this.sig.recovery;if(!(e===0||e===1||e===2||e===3))throw new Error("i must be equal to 0, 1, 2, or 3");const t=new Z().fromBuffer(this.hashBuf),n=this.sig.r,u=this.sig.s,r=e&1,s=e>>1,a=Ie.getN(),o=Ie.getG(),f=s?n.add(a):n,i=Ie.fromX(r,f);let c="";try{i.mul(a)}catch(y){c=y.message}if(c!=="point mul out of range")throw new Error("nR is not a valid curve point");const h=t.neg().umod(a),d=n.invm(a),b=i.mul(u).add(o.mul(h)).mul(d),p=new Ue(b);return p.compressed=this.sig.compressed,p.validate(),p}async asyncSig2PubKey(){const e=await le.asyncObjectMethod(this,"sig2PubKey",[]);return Ue.fromFastBuffer(e.resbuf)}static sig2PubKey(e,t){return new ut().fromObject({sig:e,hashBuf:t}).sig2PubKey()}static async asyncSig2PubKey(e,t){return await new ut().fromObject({sig:e,hashBuf:t}).asyncSig2PubKey()}verifyStr(e=!0){if(!Buffer.isBuffer(this.hashBuf)||this.hashBuf.length!==32)return"hashBuf must be a 32 byte buffer";try{this.keyPair.pubKey.validate()}catch(i){return"Invalid pubKey: "+i}const t=this.sig.r,n=this.sig.s;if(!(t.gt(0)&&t.lt(Ie.getN()))||!(n.gt(0)&&n.lt(Ie.getN())))return"r and s not in range";if(e&&!this.sig.hasLowS())return"s is too high and does not satisfy low s contraint - see bip 62";const u=new Z().fromBuffer(this.hashBuf,this.endian?{endian:this.endian}:void 0),r=Ie.getN(),s=n.invm(r),a=s.mul(u).mod(r),o=s.mul(t).mod(r),f=Ie.getG().mulAdd(a,this.keyPair.pubKey.point,o);return f.isInfinity()?"p is infinity":f.getX().mod(r).cmp(t)!==0?"Invalid signature":!1}sign(){const e=this.endian==="little"?new ot(this.hashBuf).readReverse():this.hashBuf,t=this.keyPair.privKey,n=t.bn;if(!e||!t||!n)throw new Error("invalid parameters");if(!Buffer.isBuffer(e)||e.length!==32)throw new Error("hashBuf must be a 32 byte buffer");const u=Ie.getN(),r=Ie.getG(),s=new Z().fromBuffer(e);let a=0,o,f,i,c;do(!this.k||a>0)&&this.deterministicK(a),a++,o=this.k,f=r.mul(o),i=f.getX().mod(u),c=o.invm(u).mul(s.add(n.mul(i))).mod(u);while(i.cmp(0)<=0||c.cmp(0)<=0);return c.gt(new Z().fromBuffer(Buffer.from("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))&&(c=Ie.getN().sub(c)),this.sig=he.fromObject({r:i,s:c,compressed:this.keyPair.pubKey.compressed}),this}async asyncSign(){const e=await le.asyncObjectMethod(this,"sign",[]);return this.fromFastBuffer(e.resbuf)}signRandomK(){return this.randomK(),this.sign()}toString(){const e={};return this.hashBuf&&(e.hashBuf=this.hashBuf.toString("hex")),this.keyPair&&(e.keyPair=this.keyPair.toString()),this.sig&&(e.sig=this.sig.toString()),this.k&&(e.k=this.k.toString()),JSON.stringify(e)}verify(e=!0){return this.verifyStr(e)?this.verified=!1:this.verified=!0,this}async asyncVerify(e=!0){const t=await le.asyncObjectMethod(this,"verify",[e]);return this.fromFastBuffer(t.resbuf)}static sign(e,t,n){return new ut().fromObject({hashBuf:e,endian:n,keyPair:t}).sign().sig}static async asyncSign(e,t,n){const u=new ut().fromObject({hashBuf:e,endian:n,keyPair:t});return await u.asyncSign(),u.sig}static verify(e,t,n,u,r=!0){return new ut().fromObject({hashBuf:e,endian:u,sig:t,keyPair:new st().fromObject({pubKey:n})}).verify(r).verified}static async asyncVerify(e,t,n,u,r=!0){const s=new ut().fromObject({hashBuf:e,endian:u,sig:t,keyPair:new st().fromObject({pubKey:n})});return await s.asyncVerify(r),s.verified}}class mt extends Te{constructor(e,t,n,u,r){super({messageBuf:e,keyPair:t,sig:n,address:u,verified:r})}static magicHash(e){if(!Buffer.isBuffer(e))throw new Error("messageBuf must be a buffer");const t=new ke;t.writeVarIntNum(mt.magicBytes.length),t.write(mt.magicBytes),t.writeVarIntNum(e.length),t.write(e);const n=t.toBuffer();return ae.sha256Sha256(n)}static async asyncMagicHash(e){const t=[e];return(await le.asyncClassMethod(mt,"magicHash",t)).resbuf}static sign(e,t){const n=new mt(e,t);return n.sign(),n.sig.toCompact().toString("base64")}static async asyncSign(e,t){const n=[e,t],u=await le.asyncClassMethod(mt,"sign",n);return JSON.parse(u.resbuf.toString())}static verify(e,t,n){const u=Buffer.from(t,"base64"),r=new mt;return r.messageBuf=e,r.sig=new he().fromCompact(u),r.address=n,r.verify().verified}static async asyncVerify(e,t,n){const u=[e,t,n],r=await le.asyncClassMethod(mt,"verify",u);return JSON.parse(r.resbuf.toString())}sign(){const e=mt.magicHash(this.messageBuf),t=new ut().fromObject({hashBuf:e,keyPair:this.keyPair});return t.sign(),t.calcrecovery(),this.sig=t.sig,this}verify(){const e=mt.magicHash(this.messageBuf),t=new ut;if(t.hashBuf=e,t.sig=this.sig,t.keyPair=new st,t.keyPair.pubKey=t.sig2PubKey(),!t.verify())return this.verified=!1,this;const n=new St().fromPubKey(t.keyPair.pubKey,void 0,this.sig.compressed);return kt(n.hashBuf,this.address.hashBuf)?this.verified=!0:this.verified=!1,this}}mt.magicBytes=Buffer.from(`Bitcoin Signed Message:
8
+ https://github.com/browserify/crypto-browserify`)},xe.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},xe}var ph;function lr(){if(ph)return vr.exports;ph=1;var l;vr.exports=function(u){return l||(l=new e(null)),l.generate(u)};function e(n){this.rand=n}if(vr.exports.Rand=e,e.prototype.generate=function(u){return this._rand(u)},e.prototype._rand=function(u){if(this.rand.getBytes)return this.rand.getBytes(u);for(var r=new Uint8Array(u),s=0;s<r.length;s++)r[s]=this.rand.getByte();return r},typeof self=="object")self.crypto&&self.crypto.getRandomValues?e.prototype._rand=function(u){var r=new Uint8Array(u);return self.crypto.getRandomValues(r),r}:self.msCrypto&&self.msCrypto.getRandomValues?e.prototype._rand=function(u){var r=new Uint8Array(u);return self.msCrypto.getRandomValues(r),r}:typeof window=="object"&&(e.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var t=c1();if(typeof t.randomBytes!="function")throw new Error("Not supported");e.prototype._rand=function(u){return t.randomBytes(u)}}catch{}return vr.exports}var Mf={},Tf,vh;function Sd(){if(vh)return Tf;vh=1;var l=Ce(),e=Ft(),t=e.getNAF,n=e.getJSF,u=e.assert;function r(a,o){this.type=a,this.p=new l(o.p,16),this.red=o.prime?l.red(o.prime):l.mont(this.p),this.zero=new l(0).toRed(this.red),this.one=new l(1).toRed(this.red),this.two=new l(2).toRed(this.red),this.n=o.n&&new l(o.n,16),this.g=o.g&&this.pointFromJSON(o.g,o.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var f=this.n&&this.p.div(this.n);!f||f.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}Tf=r,r.prototype.point=function(){throw new Error("Not implemented")},r.prototype.validate=function(){throw new Error("Not implemented")},r.prototype._fixedNafMul=function(o,f){u(o.precomputed);var i=o._getDoubles(),c=t(f,1,this._bitLength),h=(1<<i.step+1)-(i.step%2===0?2:1);h/=3;for(var d=[],b=0;b<c.length;b+=i.step){for(var p=0,f=b+i.step-1;f>=b;f--)p=(p<<1)+c[f];d.push(p)}for(var y=this.jpoint(null,null,null),v=this.jpoint(null,null,null),g=h;g>0;g--){for(var b=0;b<d.length;b++){var p=d[b];p===g?v=v.mixedAdd(i.points[b]):p===-g&&(v=v.mixedAdd(i.points[b].neg()))}y=y.add(v)}return y.toP()},r.prototype._wnafMul=function(o,f){var i=4,c=o._getNAFPoints(i);i=c.wnd;for(var h=c.points,d=t(f,i,this._bitLength),b=this.jpoint(null,null,null),p=d.length-1;p>=0;p--){for(var f=0;p>=0&&d[p]===0;p--)f++;if(p>=0&&f++,b=b.dblp(f),p<0)break;var y=d[p];u(y!==0),o.type==="affine"?y>0?b=b.mixedAdd(h[y-1>>1]):b=b.mixedAdd(h[-y-1>>1].neg()):y>0?b=b.add(h[y-1>>1]):b=b.add(h[-y-1>>1].neg())}return o.type==="affine"?b.toP():b},r.prototype._wnafMulAdd=function(o,f,i,c,h){for(var d=this._wnafT1,b=this._wnafT2,p=this._wnafT3,y=0,v=0;v<c;v++){var g=f[v],x=g._getNAFPoints(o);d[v]=x.wnd,b[v]=x.points}for(var v=c-1;v>=1;v-=2){var B=v-1,I=v;if(d[B]!==1||d[I]!==1){p[B]=t(i[B],d[B],this._bitLength),p[I]=t(i[I],d[I],this._bitLength),y=Math.max(p[B].length,y),y=Math.max(p[I].length,y);continue}var C=[f[B],null,null,f[I]];f[B].y.cmp(f[I].y)===0?(C[1]=f[B].add(f[I]),C[2]=f[B].toJ().mixedAdd(f[I].neg())):f[B].y.cmp(f[I].y.redNeg())===0?(C[1]=f[B].toJ().mixedAdd(f[I]),C[2]=f[B].add(f[I].neg())):(C[1]=f[B].toJ().mixedAdd(f[I]),C[2]=f[B].toJ().mixedAdd(f[I].neg()));var j=[-3,-1,-5,-7,0,7,5,1,3],G=n(i[B],i[I]);y=Math.max(G[0].length,y),p[B]=new Array(y),p[I]=new Array(y);for(var z=0;z<y;z++){var te=G[0][z]|0,ne=G[1][z]|0;p[B][z]=j[(te+1)*3+(ne+1)],p[I][z]=0,b[B]=C}}for(var $=this.jpoint(null,null,null),k=this._wnafT4,v=y;v>=0;v--){for(var m=0;v>=0;){for(var E=!0,z=0;z<c;z++)k[z]=p[z][v]|0,k[z]!==0&&(E=!1);if(!E)break;m++,v--}if(v>=0&&m++,$=$.dblp(m),v<0)break;for(var z=0;z<c;z++){var O=k[z],g;O!==0&&(O>0?g=b[z][O-1>>1]:O<0&&(g=b[z][-O-1>>1].neg()),g.type==="affine"?$=$.mixedAdd(g):$=$.add(g))}}for(var v=0;v<c;v++)b[v]=null;return h?$:$.toP()};function s(a,o){this.curve=a,this.type=o,this.precomputed=null}return r.BasePoint=s,s.prototype.eq=function(){throw new Error("Not implemented")},s.prototype.validate=function(){return this.curve.validate(this)},r.prototype.decodePoint=function(o,f){o=e.toArray(o,f);var i=this.p.byteLength();if((o[0]===4||o[0]===6||o[0]===7)&&o.length-1===2*i){o[0]===6?u(o[o.length-1]%2===0):o[0]===7&&u(o[o.length-1]%2===1);var c=this.point(o.slice(1,1+i),o.slice(1+i,1+2*i));return c}else if((o[0]===2||o[0]===3)&&o.length-1===i)return this.pointFromX(o.slice(1,1+i),o[0]===3);throw new Error("Unknown point format")},s.prototype.encodeCompressed=function(o){return this.encode(o,!0)},s.prototype._encode=function(o){var f=this.curve.p.byteLength(),i=this.getX().toArray("be",f);return o?[this.getY().isEven()?2:3].concat(i):[4].concat(i,this.getY().toArray("be",f))},s.prototype.encode=function(o,f){return e.encode(this._encode(f),o)},s.prototype.precompute=function(o){if(this.precomputed)return this;var f={doubles:null,naf:null,beta:null};return f.naf=this._getNAFPoints(8),f.doubles=this._getDoubles(4,o),f.beta=this._getBeta(),this.precomputed=f,this},s.prototype._hasDoubles=function(o){if(!this.precomputed)return!1;var f=this.precomputed.doubles;return f?f.points.length>=Math.ceil((o.bitLength()+1)/f.step):!1},s.prototype._getDoubles=function(o,f){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],c=this,h=0;h<f;h+=o){for(var d=0;d<o;d++)c=c.dbl();i.push(c)}return{step:o,points:i}},s.prototype._getNAFPoints=function(o){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var f=[this],i=(1<<o)-1,c=i===1?null:this.dbl(),h=1;h<i;h++)f[h]=f[h-1].add(c);return{wnd:o,points:f}},s.prototype._getBeta=function(){return null},s.prototype.dblp=function(o){for(var f=this,i=0;i<o;i++)f=f.dbl();return f},Tf}var Cf,mh;function u1(){if(mh)return Cf;mh=1;var l=Ft(),e=Ce(),t=pe(),n=Sd(),u=l.assert;function r(o){n.call(this,"short",o),this.a=new e(o.a,16).toRed(this.red),this.b=new e(o.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(o),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}t(r,n),Cf=r,r.prototype._getEndomorphism=function(f){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var i,c;if(f.beta)i=new e(f.beta,16).toRed(this.red);else{var h=this._getEndoRoots(this.p);i=h[0].cmp(h[1])<0?h[0]:h[1],i=i.toRed(this.red)}if(f.lambda)c=new e(f.lambda,16);else{var d=this._getEndoRoots(this.n);this.g.mul(d[0]).x.cmp(this.g.x.redMul(i))===0?c=d[0]:(c=d[1],u(this.g.mul(c).x.cmp(this.g.x.redMul(i))===0))}var b;return f.basis?b=f.basis.map(function(p){return{a:new e(p.a,16),b:new e(p.b,16)}}):b=this._getEndoBasis(c),{beta:i,lambda:c,basis:b}}},r.prototype._getEndoRoots=function(f){var i=f===this.p?this.red:e.mont(f),c=new e(2).toRed(i).redInvm(),h=c.redNeg(),d=new e(3).toRed(i).redNeg().redSqrt().redMul(c),b=h.redAdd(d).fromRed(),p=h.redSub(d).fromRed();return[b,p]},r.prototype._getEndoBasis=function(f){for(var i=this.n.ushrn(Math.floor(this.n.bitLength()/2)),c=f,h=this.n.clone(),d=new e(1),b=new e(0),p=new e(0),y=new e(1),v,g,x,B,I,C,j,G=0,z,te;c.cmpn(0)!==0;){var ne=h.div(c);z=h.sub(ne.mul(c)),te=p.sub(ne.mul(d));var $=y.sub(ne.mul(b));if(!x&&z.cmp(i)<0)v=j.neg(),g=d,x=z.neg(),B=te;else if(x&&++G===2)break;j=z,h=c,c=z,p=d,d=te,y=b,b=$}I=z.neg(),C=te;var k=x.sqr().add(B.sqr()),m=I.sqr().add(C.sqr());return m.cmp(k)>=0&&(I=v,C=g),x.negative&&(x=x.neg(),B=B.neg()),I.negative&&(I=I.neg(),C=C.neg()),[{a:x,b:B},{a:I,b:C}]},r.prototype._endoSplit=function(f){var i=this.endo.basis,c=i[0],h=i[1],d=h.b.mul(f).divRound(this.n),b=c.b.neg().mul(f).divRound(this.n),p=d.mul(c.a),y=b.mul(h.a),v=d.mul(c.b),g=b.mul(h.b),x=f.sub(p).sub(y),B=v.add(g).neg();return{k1:x,k2:B}},r.prototype.pointFromX=function(f,i){f=new e(f,16),f.red||(f=f.toRed(this.red));var c=f.redSqr().redMul(f).redIAdd(f.redMul(this.a)).redIAdd(this.b),h=c.redSqrt();if(h.redSqr().redSub(c).cmp(this.zero)!==0)throw new Error("invalid point");var d=h.fromRed().isOdd();return(i&&!d||!i&&d)&&(h=h.redNeg()),this.point(f,h)},r.prototype.validate=function(f){if(f.inf)return!0;var i=f.x,c=f.y,h=this.a.redMul(i),d=i.redSqr().redMul(i).redIAdd(h).redIAdd(this.b);return c.redSqr().redISub(d).cmpn(0)===0},r.prototype._endoWnafMulAdd=function(f,i,c){for(var h=this._endoWnafT1,d=this._endoWnafT2,b=0;b<f.length;b++){var p=this._endoSplit(i[b]),y=f[b],v=y._getBeta();p.k1.negative&&(p.k1.ineg(),y=y.neg(!0)),p.k2.negative&&(p.k2.ineg(),v=v.neg(!0)),h[b*2]=y,h[b*2+1]=v,d[b*2]=p.k1,d[b*2+1]=p.k2}for(var g=this._wnafMulAdd(1,h,d,b*2,c),x=0;x<b*2;x++)h[x]=null,d[x]=null;return g};function s(o,f,i,c){n.BasePoint.call(this,o,"affine"),f===null&&i===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new e(f,16),this.y=new e(i,16),c&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}t(s,n.BasePoint),r.prototype.point=function(f,i,c){return new s(this,f,i,c)},r.prototype.pointFromJSON=function(f,i){return s.fromJSON(this,f,i)},s.prototype._getBeta=function(){if(this.curve.endo){var f=this.precomputed;if(f&&f.beta)return f.beta;var i=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(f){var c=this.curve,h=function(d){return c.point(d.x.redMul(c.endo.beta),d.y)};f.beta=i,i.precomputed={beta:null,naf:f.naf&&{wnd:f.naf.wnd,points:f.naf.points.map(h)},doubles:f.doubles&&{step:f.doubles.step,points:f.doubles.points.map(h)}}}return i}},s.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},s.fromJSON=function(f,i,c){typeof i=="string"&&(i=JSON.parse(i));var h=f.point(i[0],i[1],c);if(!i[2])return h;function d(p){return f.point(p[0],p[1],c)}var b=i[2];return h.precomputed={beta:null,doubles:b.doubles&&{step:b.doubles.step,points:[h].concat(b.doubles.points.map(d))},naf:b.naf&&{wnd:b.naf.wnd,points:[h].concat(b.naf.points.map(d))}},h},s.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},s.prototype.isInfinity=function(){return this.inf},s.prototype.add=function(f){if(this.inf)return f;if(f.inf)return this;if(this.eq(f))return this.dbl();if(this.neg().eq(f))return this.curve.point(null,null);if(this.x.cmp(f.x)===0)return this.curve.point(null,null);var i=this.y.redSub(f.y);i.cmpn(0)!==0&&(i=i.redMul(this.x.redSub(f.x).redInvm()));var c=i.redSqr().redISub(this.x).redISub(f.x),h=i.redMul(this.x.redSub(c)).redISub(this.y);return this.curve.point(c,h)},s.prototype.dbl=function(){if(this.inf)return this;var f=this.y.redAdd(this.y);if(f.cmpn(0)===0)return this.curve.point(null,null);var i=this.curve.a,c=this.x.redSqr(),h=f.redInvm(),d=c.redAdd(c).redIAdd(c).redIAdd(i).redMul(h),b=d.redSqr().redISub(this.x.redAdd(this.x)),p=d.redMul(this.x.redSub(b)).redISub(this.y);return this.curve.point(b,p)},s.prototype.getX=function(){return this.x.fromRed()},s.prototype.getY=function(){return this.y.fromRed()},s.prototype.mul=function(f){return f=new e(f,16),this.isInfinity()?this:this._hasDoubles(f)?this.curve._fixedNafMul(this,f):this.curve.endo?this.curve._endoWnafMulAdd([this],[f]):this.curve._wnafMul(this,f)},s.prototype.mulAdd=function(f,i,c){var h=[this,i],d=[f,c];return this.curve.endo?this.curve._endoWnafMulAdd(h,d):this.curve._wnafMulAdd(1,h,d,2)},s.prototype.jmulAdd=function(f,i,c){var h=[this,i],d=[f,c];return this.curve.endo?this.curve._endoWnafMulAdd(h,d,!0):this.curve._wnafMulAdd(1,h,d,2,!0)},s.prototype.eq=function(f){return this===f||this.inf===f.inf&&(this.inf||this.x.cmp(f.x)===0&&this.y.cmp(f.y)===0)},s.prototype.neg=function(f){if(this.inf)return this;var i=this.curve.point(this.x,this.y.redNeg());if(f&&this.precomputed){var c=this.precomputed,h=function(d){return d.neg()};i.precomputed={naf:c.naf&&{wnd:c.naf.wnd,points:c.naf.points.map(h)},doubles:c.doubles&&{step:c.doubles.step,points:c.doubles.points.map(h)}}}return i},s.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var f=this.curve.jpoint(this.x,this.y,this.curve.one);return f};function a(o,f,i,c){n.BasePoint.call(this,o,"jacobian"),f===null&&i===null&&c===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new e(0)):(this.x=new e(f,16),this.y=new e(i,16),this.z=new e(c,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}return t(a,n.BasePoint),r.prototype.jpoint=function(f,i,c){return new a(this,f,i,c)},a.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var f=this.z.redInvm(),i=f.redSqr(),c=this.x.redMul(i),h=this.y.redMul(i).redMul(f);return this.curve.point(c,h)},a.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},a.prototype.add=function(f){if(this.isInfinity())return f;if(f.isInfinity())return this;var i=f.z.redSqr(),c=this.z.redSqr(),h=this.x.redMul(i),d=f.x.redMul(c),b=this.y.redMul(i.redMul(f.z)),p=f.y.redMul(c.redMul(this.z)),y=h.redSub(d),v=b.redSub(p);if(y.cmpn(0)===0)return v.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var g=y.redSqr(),x=g.redMul(y),B=h.redMul(g),I=v.redSqr().redIAdd(x).redISub(B).redISub(B),C=v.redMul(B.redISub(I)).redISub(b.redMul(x)),j=this.z.redMul(f.z).redMul(y);return this.curve.jpoint(I,C,j)},a.prototype.mixedAdd=function(f){if(this.isInfinity())return f.toJ();if(f.isInfinity())return this;var i=this.z.redSqr(),c=this.x,h=f.x.redMul(i),d=this.y,b=f.y.redMul(i).redMul(this.z),p=c.redSub(h),y=d.redSub(b);if(p.cmpn(0)===0)return y.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var v=p.redSqr(),g=v.redMul(p),x=c.redMul(v),B=y.redSqr().redIAdd(g).redISub(x).redISub(x),I=y.redMul(x.redISub(B)).redISub(d.redMul(g)),C=this.z.redMul(p);return this.curve.jpoint(B,I,C)},a.prototype.dblp=function(f){if(f===0)return this;if(this.isInfinity())return this;if(!f)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var i=this,c=0;c<f;c++)i=i.dbl();return i}for(var h=this.curve.a,d=this.curve.tinv,b=this.x,p=this.y,y=this.z,v=y.redSqr().redSqr(),g=p.redAdd(p),c=0;c<f;c++){var x=b.redSqr(),B=g.redSqr(),I=B.redSqr(),C=x.redAdd(x).redIAdd(x).redIAdd(h.redMul(v)),j=b.redMul(B),G=C.redSqr().redISub(j.redAdd(j)),z=j.redISub(G),te=C.redMul(z);te=te.redIAdd(te).redISub(I);var ne=g.redMul(y);c+1<f&&(v=v.redMul(I)),b=G,y=ne,g=te}return this.curve.jpoint(b,g.redMul(d),y)},a.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},a.prototype._zeroDbl=function(){var f,i,c;if(this.zOne){var h=this.x.redSqr(),d=this.y.redSqr(),b=d.redSqr(),p=this.x.redAdd(d).redSqr().redISub(h).redISub(b);p=p.redIAdd(p);var y=h.redAdd(h).redIAdd(h),v=y.redSqr().redISub(p).redISub(p),g=b.redIAdd(b);g=g.redIAdd(g),g=g.redIAdd(g),f=v,i=y.redMul(p.redISub(v)).redISub(g),c=this.y.redAdd(this.y)}else{var x=this.x.redSqr(),B=this.y.redSqr(),I=B.redSqr(),C=this.x.redAdd(B).redSqr().redISub(x).redISub(I);C=C.redIAdd(C);var j=x.redAdd(x).redIAdd(x),G=j.redSqr(),z=I.redIAdd(I);z=z.redIAdd(z),z=z.redIAdd(z),f=G.redISub(C).redISub(C),i=j.redMul(C.redISub(f)).redISub(z),c=this.y.redMul(this.z),c=c.redIAdd(c)}return this.curve.jpoint(f,i,c)},a.prototype._threeDbl=function(){var f,i,c;if(this.zOne){var h=this.x.redSqr(),d=this.y.redSqr(),b=d.redSqr(),p=this.x.redAdd(d).redSqr().redISub(h).redISub(b);p=p.redIAdd(p);var y=h.redAdd(h).redIAdd(h).redIAdd(this.curve.a),v=y.redSqr().redISub(p).redISub(p);f=v;var g=b.redIAdd(b);g=g.redIAdd(g),g=g.redIAdd(g),i=y.redMul(p.redISub(v)).redISub(g),c=this.y.redAdd(this.y)}else{var x=this.z.redSqr(),B=this.y.redSqr(),I=this.x.redMul(B),C=this.x.redSub(x).redMul(this.x.redAdd(x));C=C.redAdd(C).redIAdd(C);var j=I.redIAdd(I);j=j.redIAdd(j);var G=j.redAdd(j);f=C.redSqr().redISub(G),c=this.y.redAdd(this.z).redSqr().redISub(B).redISub(x);var z=B.redSqr();z=z.redIAdd(z),z=z.redIAdd(z),z=z.redIAdd(z),i=C.redMul(j.redISub(f)).redISub(z)}return this.curve.jpoint(f,i,c)},a.prototype._dbl=function(){var f=this.curve.a,i=this.x,c=this.y,h=this.z,d=h.redSqr().redSqr(),b=i.redSqr(),p=c.redSqr(),y=b.redAdd(b).redIAdd(b).redIAdd(f.redMul(d)),v=i.redAdd(i);v=v.redIAdd(v);var g=v.redMul(p),x=y.redSqr().redISub(g.redAdd(g)),B=g.redISub(x),I=p.redSqr();I=I.redIAdd(I),I=I.redIAdd(I),I=I.redIAdd(I);var C=y.redMul(B).redISub(I),j=c.redAdd(c).redMul(h);return this.curve.jpoint(x,C,j)},a.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var f=this.x.redSqr(),i=this.y.redSqr(),c=this.z.redSqr(),h=i.redSqr(),d=f.redAdd(f).redIAdd(f),b=d.redSqr(),p=this.x.redAdd(i).redSqr().redISub(f).redISub(h);p=p.redIAdd(p),p=p.redAdd(p).redIAdd(p),p=p.redISub(b);var y=p.redSqr(),v=h.redIAdd(h);v=v.redIAdd(v),v=v.redIAdd(v),v=v.redIAdd(v);var g=d.redIAdd(p).redSqr().redISub(b).redISub(y).redISub(v),x=i.redMul(g);x=x.redIAdd(x),x=x.redIAdd(x);var B=this.x.redMul(y).redISub(x);B=B.redIAdd(B),B=B.redIAdd(B);var I=this.y.redMul(g.redMul(v.redISub(g)).redISub(p.redMul(y)));I=I.redIAdd(I),I=I.redIAdd(I),I=I.redIAdd(I);var C=this.z.redAdd(p).redSqr().redISub(c).redISub(y);return this.curve.jpoint(B,I,C)},a.prototype.mul=function(f,i){return f=new e(f,i),this.curve._wnafMul(this,f)},a.prototype.eq=function(f){if(f.type==="affine")return this.eq(f.toJ());if(this===f)return!0;var i=this.z.redSqr(),c=f.z.redSqr();if(this.x.redMul(c).redISub(f.x.redMul(i)).cmpn(0)!==0)return!1;var h=i.redMul(this.z),d=c.redMul(f.z);return this.y.redMul(d).redISub(f.y.redMul(h)).cmpn(0)===0},a.prototype.eqXToP=function(f){var i=this.z.redSqr(),c=f.toRed(this.curve.red).redMul(i);if(this.x.cmp(c)===0)return!0;for(var h=f.clone(),d=this.curve.redN.redMul(i);;){if(h.iadd(this.curve.n),h.cmp(this.curve.p)>=0)return!1;if(c.redIAdd(d),this.x.cmp(c)===0)return!0}},a.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},a.prototype.isInfinity=function(){return this.z.cmpn(0)===0},Cf}var yh;function xd(){return yh||(yh=1,(function(l){var e=l;e.base=Sd(),e.short=u1()})(Mf)),Mf}var Lf={},Df,gh;function h1(){return gh||(gh=1,Df={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}),Df}var wh;function Ed(){return wh||(wh=1,(function(l){var e=l,t=hr(),n=xd(),u=Ft(),r=u.assert;function s(f){if(f.type!=="short")throw new Error("invalid curve type");this.curve=new n.short(f),this.g=this.curve.g,this.n=this.curve.n,this.hash=f.hash,r(this.g.validate(),"Invalid curve"),r(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}e.PresetCurve=s;function a(f,i){Object.defineProperty(e,f,{configurable:!0,enumerable:!0,get:function(){var c=new s(i);return Object.defineProperty(e,f,{configurable:!0,enumerable:!0,value:c}),c}})}var o;try{o=h1()}catch{o=void 0}a("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:t.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",o]})})(Lf)),Lf}var Ff,_h;function d1(){if(_h)return Ff;_h=1;var l=Ce(),e=Ft(),t=e.assert;function n(u,r){this.ec=u,this.priv=null,this.pub=null,r.priv&&this._importPrivate(r.priv,r.privEnc),r.pub&&this._importPublic(r.pub,r.pubEnc)}return Ff=n,n.fromPublic=function(r,s,a){return s instanceof n?s:new n(r,{pub:s,pubEnc:a})},n.fromPrivate=function(r,s,a){return s instanceof n?s:new n(r,{priv:s,privEnc:a})},n.prototype.validate=function(){var r=this.getPublic();return r.isInfinity()?{result:!1,reason:"Invalid public key"}:r.validate()?r.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},n.prototype.getPublic=function(r,s){return typeof r=="string"&&(s=r,r=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),s?this.pub.encode(s,r):this.pub},n.prototype.getPrivate=function(r){return r==="hex"?this.priv.toString(16,2):this.priv},n.prototype._importPrivate=function(r,s){this.priv=new l(r,s||16),this.priv=this.priv.umod(this.ec.curve.n)},n.prototype._importPublic=function(r,s){if(r.x||r.y){this.ec.curve.type==="mont"?t(r.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&t(r.x&&r.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(r.x,r.y);return}this.pub=this.ec.curve.decodePoint(r,s)},n.prototype.derive=function(r){return r.mul(this.priv).getX()},n.prototype.sign=function(r,s,a){return this.ec.sign(r,this,s,a)},n.prototype.verify=function(r,s){return this.ec.verify(r,s,this)},n.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"},Ff}var qf,Sh;function l1(){if(Sh)return qf;Sh=1;var l=Ce(),e=Ft(),t=e.assert;function n(o,f){if(o instanceof n)return o;this._importDER(o,f)||(t(o.r&&o.s,"Signature without r or s"),this.r=new l(o.r,16),this.s=new l(o.s,16),o.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=o.recoveryParam)}qf=n;function u(){this.place=0}function r(o,f){var i=o[f.place++];if(!(i&128))return i;for(var c=i&15,h=0,d=0,b=f.place;d<c;d++,b++)h<<=8,h|=o[b];return f.place=b,h}function s(o){for(var f=0,i=o.length-1;!o[f]&&!(o[f+1]&128)&&f<i;)f++;return f===0?o:o.slice(f)}n.prototype._importDER=function(f,i){f=e.toArray(f,i);var c=new u;if(f[c.place++]!==48)return!1;var h=r(f,c);if(h+c.place!==f.length||f[c.place++]!==2)return!1;var d=r(f,c),b=f.slice(c.place,d+c.place);if(c.place+=d,f[c.place++]!==2)return!1;var p=r(f,c);if(f.length!==p+c.place)return!1;var y=f.slice(c.place,p+c.place);return b[0]===0&&b[1]&128&&(b=b.slice(1)),y[0]===0&&y[1]&128&&(y=y.slice(1)),this.r=new l(b),this.s=new l(y),this.recoveryParam=null,!0};function a(o,f){if(f<128){o.push(f);return}var i=1+(Math.log(f)/Math.LN2>>>3);for(o.push(i|128);--i;)o.push(f>>>(i<<3)&255);o.push(f)}return n.prototype.toDER=function(f){var i=this.r.toArray(),c=this.s.toArray();for(i[0]&128&&(i=[0].concat(i)),c[0]&128&&(c=[0].concat(c)),i=s(i),c=s(c);!c[0]&&!(c[1]&128);)c=c.slice(1);var h=[2];a(h,i.length),h=h.concat(i),h.push(2),a(h,c.length);var d=h.concat(c),b=[48];return a(b,d.length),b=b.concat(d),e.encode(b,f)},qf}var Uf,xh;function b1(){if(xh)return Uf;xh=1;var l=Ce(),e=bd(),t=Ft(),n=Ed(),u=lr(),r=t.assert,s=d1(),a=l1();function o(f){if(!(this instanceof o))return new o(f);typeof f=="string"&&(r(n.hasOwnProperty(f),"Unknown curve "+f),f=n[f]),f instanceof n.PresetCurve&&(f={curve:f}),this.curve=f.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=f.curve.g,this.g.precompute(f.curve.n.bitLength()+1),this.hash=f.hash||f.curve.hash}return Uf=o,o.prototype.keyPair=function(i){return new s(this,i)},o.prototype.keyFromPrivate=function(i,c){return s.fromPrivate(this,i,c)},o.prototype.keyFromPublic=function(i,c){return s.fromPublic(this,i,c)},o.prototype.genKeyPair=function(i){i||(i={});var c=new e({hash:this.hash,pers:i.pers,persEnc:i.persEnc||"utf8",entropy:i.entropy||u(this.hash.hmacStrength),entropyEnc:i.entropy&&i.entropyEnc||"utf8",nonce:this.n.toArray()}),h=this.n.byteLength(),d=this.n.sub(new l(2));do{var b=new l(c.generate(h));if(!(b.cmp(d)>0))return b.iaddn(1),this.keyFromPrivate(b)}while(!0)},o.prototype._truncateToN=function(i,c){var h=i.byteLength()*8-this.n.bitLength();return h>0&&(i=i.ushrn(h)),!c&&i.cmp(this.n)>=0?i.sub(this.n):i},o.prototype.sign=function(i,c,h,d){typeof h=="object"&&(d=h,h=null),d||(d={}),c=this.keyFromPrivate(c,h),i=this._truncateToN(new l(i,16));for(var b=this.n.byteLength(),p=c.getPrivate().toArray("be",b),y=i.toArray("be",b),v=new e({hash:this.hash,entropy:p,nonce:y,pers:d.pers,persEnc:d.persEnc||"utf8"}),g=this.n.sub(new l(1)),x=0;;x++){var B=d.k?d.k(x):new l(v.generate(this.n.byteLength()));if(B=this._truncateToN(B,!0),!(B.cmpn(1)<=0||B.cmp(g)>=0)){var I=this.g.mul(B);if(!I.isInfinity()){var C=I.getX(),j=C.umod(this.n);if(j.cmpn(0)!==0){var G=B.invm(this.n).mul(j.mul(c.getPrivate()).iadd(i));if(G=G.umod(this.n),G.cmpn(0)!==0){var z=(I.getY().isOdd()?1:0)|(C.cmp(j)!==0?2:0);return d.canonical&&G.cmp(this.nh)>0&&(G=this.n.sub(G),z^=1),new a({r:j,s:G,recoveryParam:z})}}}}}},o.prototype.verify=function(i,c,h,d){i=this._truncateToN(new l(i,16)),h=this.keyFromPublic(h,d),c=new a(c,"hex");var b=c.r,p=c.s;if(b.cmpn(1)<0||b.cmp(this.n)>=0||p.cmpn(1)<0||p.cmp(this.n)>=0)return!1;var y=p.invm(this.n),v=y.mul(i).umod(this.n),g=y.mul(b).umod(this.n);if(!this.curve._maxwellTrick){var x=this.g.mulAdd(v,h.getPublic(),g);return x.isInfinity()?!1:x.getX().umod(this.n).cmp(b)===0}var x=this.g.jmulAdd(v,h.getPublic(),g);return x.isInfinity()?!1:x.eqXToP(b)},o.prototype.recoverPubKey=function(f,i,c,h){r((3&c)===c,"The recovery param is more than two bits"),i=new a(i,h);var d=this.n,b=new l(f),p=i.r,y=i.s,v=c&1,g=c>>1;if(p.cmp(this.curve.p.umod(this.curve.n))>=0&&g)throw new Error("Unable to find sencond key candinate");g?p=this.curve.pointFromX(p.add(this.curve.n),v):p=this.curve.pointFromX(p,v);var x=i.r.invm(d),B=d.sub(b).mul(x).umod(d),I=y.mul(x).umod(d);return this.g.mulAdd(B,p,I)},o.prototype.getKeyRecoveryParam=function(f,i,c,h){if(i=new a(i,h),i.recoveryParam!==null)return i.recoveryParam;for(var d=0;d<4;d++){var b;try{b=this.recoverPubKey(f,i,d)}catch{continue}if(b.eq(c))return d}throw new Error("Unable to find valid recovery factor")},Uf}var Eh;function p1(){return Eh||(Eh=1,(function(l){var e=l;e.version=Fd.version,e.utils=Ft(),e.rand=lr(),e.curve=xd(),e.curves=Ed(),e.ec=b1()})(bi)),bi}var v1=p1();const Bd=zt(v1);var m1=hr();const br=zt(m1);var y1=ns();const Rd=zt(y1);var g1=xt();const w1="2.3.0",_1={version:w1};function Z(l,e,t){if(!(this instanceof Z))return new Z(l,e,t);if(l&&(l instanceof ct||l.constructor.name==="BN"||l.constructor.name==="Bn")){ct.call(this,0),l.copy(this),this.negative=l.negative,this.length=l.length,this.red=l.red;return}ct.call(this,l,e,t)}Z.prototype=Object.create(ct.prototype);Z.prototype.constructor=Z;Object.keys(ct).forEach(function(l){Z[l]||(Z[l]=ct[l])});function Gr(l){const e=Buffer.alloc(l.length);for(let t=0;t<l.length;t++)e[t]=l[l.length-1-t];return e}Z.prototype.fromHex=function(l,e){return this.fromBuffer(Buffer.from(l,"hex"),e)};Z.prototype.toHex=function(l){return this.toBuffer(l).toString("hex")};Z.prototype.toJSON=function(){return this.toString()};Z.prototype.fromJSON=function(l){return new Z(l).copy(this),this};Z.prototype.fromNumber=function(l){return new Z(l).copy(this),this};Z.prototype.toNumber=function(){return parseInt(this.toString(10),10)};Z.prototype.fromString=function(l,e){return new Z(l,e).copy(this),this};Z.fromBuffer=function(l,e={endian:"big"}){e.endian==="little"&&(l=Gr(l));const t=l.toString("hex");return new Z(t,16)};Z.prototype.fromBuffer=function(l,e){return Z.fromBuffer(l,e).copy(this),this};Z.prototype.toBuffer=function(l={size:void 0,endian:"big"}){let e;if(l.size){const n=this.toString(16,2),u=n.length/2;if(e=Buffer.from(n,"hex"),u!==l.size){if(u>l.size)e=e.slice(u-e.length,e.length);else if(u<l.size){const r=Buffer.alloc(l.size);for(let s=0;s<e.length;s++)r[r.length-1-s]=e[e.length-1-s];for(let s=0;s<l.size-u;s++)r[s]=0;e=r}}}else{const n=this.toString(16,2);e=Buffer.from(n,"hex")}l.endian==="little"&&(e=Gr(e));const t=Buffer.from([0]);return Buffer.compare(e,t)===0?Buffer.from([]):e};Z.prototype.toFastBuffer=function(l){return this.toBuffer(l)};Z.fromFastBuffer=Z.fromBuffer;Z.prototype.fromFastBuffer=Z.prototype.fromBuffer;Z.prototype.fromSm=function(l,e={endian:"big"}){if(l.length===0)return this.fromBuffer(Buffer.from([0])),this.negative=0,this;let t=Buffer.from(l);return e.endian==="little"&&(t=Gr(t)),t[0]&128?(t[0]=t[0]&127,this.fromBuffer(t),this.ineg()):(this.fromBuffer(t),this.negative=0),this};Z.prototype.toSm=function(l={endian:"big"}){const e=l.endian;let t;return this.negative?(t=this.abs().toBuffer(),t.length>0&&t[0]&128?t=Buffer.concat([Buffer.from([128]),t]):t.length>0?t[0]=t[0]|128:t=Buffer.from([128])):(t=this.toBuffer(),t.length>0&&t[0]&128&&(t=Buffer.concat([Buffer.from([0]),t]))),t.length===1&&t[0]===0&&(t=Buffer.from([])),e==="little"&&(t=Gr(t)),t};Z.prototype.fromBits=function(l,e={strict:!1}){let t=Buffer.alloc(4);if(t.writeUInt32BE(l,0),l=t.readInt32BE(0),e.strict&&l&8388608)throw new Error("negative bit set");const n=l>>24,u=l&8388607;if(t=Buffer.alloc(4),t.writeInt32BE(u),n<=3)t=t.slice(1,n+1);else{const r=Buffer.alloc(n-3);r.fill(0),t=Buffer.concat([t,r])}return this.fromBuffer(t),l&8388608&&this.ineg(),this};Z.prototype.toBits=function(){const l=this.negative,t=this.abs().toBuffer();let n=t.length,u;if(n>3)u=Buffer.concat([Buffer.from([0]),t.slice(0,3)]).readUInt32BE(0);else if(n<=3){const a=Buffer.alloc(3-n+1);a.fill(0),u=Buffer.concat([a,t.slice(0,n)]).readUInt32BE(0)}u&8388608&&(u>>=8,n++),l&&(u|=8388608);const r=n<<24|u,s=Buffer.alloc(4);return s.writeInt32BE(r,0),s.readUInt32BE(0)};Z.prototype.fromScriptNumBuffer=function(l,e,t){if(t===void 0&&(t=4),l.length>t)throw new Error(`script number overflow nMaxNumSize: ${t}`);if(e&&l.length>0&&(l[l.length-1]&127)===0&&(l.length<=1||(l[l.length-2]&128)===0))throw new Error("non-minimally encoded script number");return this.fromSm(l,{endian:"little"})};Z.prototype.toScriptNumBuffer=function(){return this.toSm({endian:"little"})};const pr=function(l){return l&&(l instanceof ct||l.constructor.name==="BN"||l.constructor.name==="Bn")&&!(l instanceof Z)?new Z(l):l},S1=["add","sub","mul","div","mod","umod","invm","and","or","xor","redAdd","redSub","redMul","redPow","gcd","egcd","lcm"];S1.forEach(l=>{const e=ct.prototype[l];Z.prototype[l]=function(t,...n){return(typeof t=="string"||typeof t=="number")&&(t=new Z(t)),pr(e.call(this,t,...n))}});const x1=["ushln","ushrn","shln","shrn","testn","maskn","setn","clrn","bincn"];x1.forEach(l=>{const e=ct.prototype[l];Z.prototype[l]=function(t,...n){return t&&(t instanceof ct||t.constructor.name==="BN"||t.constructor.name==="Bn")&&(t=t.toNumber()),pr(e.call(this,t,...n))}});const E1=["sqr","neg","abs","not","redSqr","redSqrt","redNeg"];E1.forEach(l=>{const e=ct.prototype[l];Z.prototype[l]=function(){return pr(e.call(this))}});Z.prototype.toRed=function(l){return pr(ct.prototype.toRed.call(this,l))};Z.prototype.fromRed=function(){return pr(ct.prototype.fromRed.call(this))};const B1=["cmp","gt","geq","lt","leq","eq","neq"];B1.forEach(l=>{const e=ct.prototype.cmp;Z.prototype[l]=function(t){(typeof t=="string"||typeof t=="number")&&(t=new Z(t));const n=e.call(this,t);return l==="eq"?n===0:l==="neq"?n!==0:l==="gt"?n>0:l==="geq"?n>=0:l==="lt"?n<0:l==="leq"?n<=0:n}});class ot{constructor(e){this.fromObject({buf:e})}fromObject(e){return this.buf=e.buf||this.buf||void 0,this.pos=e.pos||this.pos||0,this}eof(){return this.pos>=this.buf.length}read(e=this.buf.length){const t=this.buf.slice(this.pos,this.pos+e);return this.pos=this.pos+e,t}readReverse(e=this.buf.length){const t=this.buf.slice(this.pos,this.pos+e);this.pos=this.pos+e;const n=Buffer.alloc(t.length);for(let u=0;u<n.length;u++)n[u]=t[t.length-1-u];return n}readUInt8(){const e=this.buf.readUInt8(this.pos);return this.pos=this.pos+1,e}readInt8(){const e=this.buf.readInt8(this.pos);return this.pos=this.pos+1,e}readUInt16BE(){const e=this.buf.readUInt16BE(this.pos);return this.pos=this.pos+2,e}readInt16BE(){const e=this.buf.readInt16BE(this.pos);return this.pos=this.pos+2,e}readUInt16LE(){const e=this.buf.readUInt16LE(this.pos);return this.pos=this.pos+2,e}readInt16LE(){const e=this.buf.readInt16LE(this.pos);return this.pos=this.pos+2,e}readUInt32BE(){const e=this.buf.readUInt32BE(this.pos);return this.pos=this.pos+4,e}readInt32BE(){const e=this.buf.readInt32BE(this.pos);return this.pos=this.pos+4,e}readUInt32LE(){const e=this.buf.readUInt32LE(this.pos);return this.pos=this.pos+4,e}readInt32LE(){const e=this.buf.readInt32LE(this.pos);return this.pos=this.pos+4,e}readUInt64BEBn(){const e=this.buf.slice(this.pos,this.pos+8),t=new Z().fromBuffer(e);return this.pos=this.pos+8,t}readUInt64LEBn(){const e=this.readReverse(8);return new Z().fromBuffer(e)}readVarIntNum(){const e=this.readUInt8();let t,n;switch(e){case 253:return this.readUInt16LE();case 254:return this.readUInt32LE();case 255:if(t=this.readUInt64LEBn(),n=t.toNumber(),n<=Math.pow(2,53))return n;throw new Error("number too large to retain precision - use readVarIntBn");default:return e}}readVarIntBuf(){switch(this.buf.readUInt8(this.pos)){case 253:return this.read(3);case 254:return this.read(5);case 255:return this.read(9);default:return this.read(1)}}readVarIntBn(){const e=this.readUInt8();switch(e){case 253:return new Z(this.readUInt16LE());case 254:return new Z(this.readUInt32LE());case 255:return this.readUInt64LEBn();default:return new Z(e)}}}class ke{constructor(e){this.fromObject({bufs:e})}fromObject(e){return this.bufs=e.bufs||this.bufs||[],this}getLength(){let e=0;for(const t in this.bufs){const n=this.bufs[t];e=e+n.length}return e}toBuffer(){return Buffer.concat(this.bufs)}write(e){return this.bufs.push(e),this}writeReverse(e){const t=Buffer.alloc(e.length);for(let n=0;n<t.length;n++)t[n]=e[e.length-1-n];return this.bufs.push(t),this}writeUInt8(e){const t=Buffer.alloc(1);return t.writeUInt8(e,0),this.write(t),this}writeInt8(e){const t=Buffer.alloc(1);return t.writeInt8(e,0),this.write(t),this}writeUInt16BE(e){const t=Buffer.alloc(2);return t.writeUInt16BE(e,0),this.write(t),this}writeInt16BE(e){const t=Buffer.alloc(2);return t.writeInt16BE(e,0),this.write(t),this}writeUInt16LE(e){const t=Buffer.alloc(2);return t.writeUInt16LE(e,0),this.write(t),this}writeInt16LE(e){const t=Buffer.alloc(2);return t.writeInt16LE(e,0),this.write(t),this}writeUInt32BE(e){const t=Buffer.alloc(4);return t.writeUInt32BE(e,0),this.write(t),this}writeInt32BE(e){const t=Buffer.alloc(4);return t.writeInt32BE(e,0),this.write(t),this}writeUInt32LE(e){const t=Buffer.alloc(4);return t.writeUInt32LE(e,0),this.write(t),this}writeInt32LE(e){const t=Buffer.alloc(4);return t.writeInt32LE(e,0),this.write(t),this}writeUInt64BEBn(e){const t=e.toBuffer({size:8});return this.write(t),this}writeUInt64LEBn(e){const t=e.toBuffer({size:8});return this.writeReverse(t),this}writeVarIntNum(e){const t=ke.varIntBufNum(e);return this.write(t),this}writeVarIntBn(e){const t=ke.varIntBufBn(e);return this.write(t),this}static varIntBufNum(e){let t;return e<253?(t=Buffer.alloc(1),t.writeUInt8(e,0)):e<65536?(t=Buffer.alloc(3),t.writeUInt8(253,0),t.writeUInt16LE(e,1)):e<4294967296?(t=Buffer.alloc(5),t.writeUInt8(254,0),t.writeUInt32LE(e,1)):(t=Buffer.alloc(9),t.writeUInt8(255,0),t.writeInt32LE(e&-1,1),t.writeUInt32LE(Math.floor(e/4294967296),5)),t}static varIntBufBn(e){let t;const n=e.toNumber();if(n<253)t=Buffer.alloc(1),t.writeUInt8(n,0);else if(n<65536)t=Buffer.alloc(3),t.writeUInt8(253,0),t.writeUInt16LE(n,1);else if(n<4294967296)t=Buffer.alloc(5),t.writeUInt8(254,0),t.writeUInt32LE(n,1);else{const u=new ke;u.writeUInt8(255),u.writeUInt64LEBn(e),t=u.toBuffer()}return t}}function R1(l){const e=typeof l=="string"?l.charCodeAt(0):l;return e>=97&&e<=102||e>=65&&e<=70||e>=48&&e<=57}const Hf=R1;class Te{constructor(e){this.fromObject(e)}fromObject(e){if(!e)return this;for(const t of Object.keys(e))e[t]!==void 0&&(this[t]=e[t]);return this}static fromObject(e){return new this().fromObject(e)}fromBr(e){throw e instanceof ot?new Error("not implemented"):new Error("br must be a buffer reader")}static fromBr(e){return new this().fromBr(e)}asyncFromBr(e){throw e instanceof ot?new Error("not implemented"):new Error("br must be a buffer reader")}static asyncFromBr(e){return new this().asyncFromBr(e)}toBw(e){throw new Error("not implemented")}asyncToBw(e){throw new Error("not implemented")}*genFromBuffers(){throw new Error("not implemented")}*expect(e,t){let n=t;const u=new ke;let r=0;for(t&&(u.write(t),r+=t.length);r<e;)n=yield e-r,n&&(u.write(n),r+=n.length);n=u.toBuffer();const s=r-e,a=n.slice(n.length-s,n.length);return n=n.slice(0,n.length-s),{buf:n,remainderbuf:a}}fromBuffer(e,...t){if(!Buffer.isBuffer(e))throw new Error("buf must be a buffer");const n=new ot(e);return this.fromBr(n,...t)}static fromBuffer(...e){return new this().fromBuffer(...e)}asyncFromBuffer(e,...t){if(!Buffer.isBuffer(e))throw new Error("buf must be a buffer");const n=new ot(e);return this.asyncFromBr(n,...t)}static asyncFromBuffer(e,...t){return new this().asyncFromBuffer(e,...t)}fromFastBuffer(e,...t){return e.length===0?this:this.fromBuffer(e,...t)}static fromFastBuffer(...e){return new this().fromFastBuffer(...e)}toBuffer(...e){return this.toBw(...e).toBuffer()}asyncToBuffer(...e){return this.asyncToBw(...e).then(t=>t.toBuffer())}toFastBuffer(...e){return Object.keys(this).length===0?Buffer.alloc(0):this.toBuffer(...e)}fromHex(e,...t){if(!Hf(e))throw new Error("invalid hex string");const n=Buffer.from(e,"hex");return this.fromBuffer(n,...t)}static fromHex(e,...t){return new this().fromHex(e,...t)}asyncFromHex(e,...t){if(!Hf(e))throw new Error("invalid hex string");const n=Buffer.from(e,"hex");return this.asyncFromBuffer(n,...t)}static asyncFromHex(e,...t){return new this().asyncFromHex(e,...t)}fromFastHex(e,...t){if(!Hf(e))throw new Error("invalid hex string");const n=Buffer.from(e,"hex");return this.fromFastBuffer(n,...t)}static fromFastHex(e,...t){return new this().fromFastHex(e,...t)}toHex(...e){return this.toBuffer(...e).toString("hex")}asyncToHex(...e){return this.asyncToBuffer(...e).then(t=>t.toString("hex"))}toFastHex(...e){return this.toFastBuffer(...e).toString("hex")}fromString(e,...t){if(typeof e!="string")throw new Error("str must be a string");return this.fromHex(e,...t)}static fromString(e,...t){return new this().fromString(e,...t)}asyncFromString(e,...t){if(typeof e!="string")throw new Error("str must be a string");return this.asyncFromHex(e,...t)}static asyncFromString(e,...t){return new this().asyncFromString(e,...t)}toString(...e){return this.toHex(...e)}asyncToString(...e){return this.asyncToHex(...e)}fromJSON(e){throw new Error("not implemented")}static fromJSON(e,...t){return new this().fromJSON(e,...t)}asyncFromJSON(e,...t){throw new Error("not implemented")}static asyncFromJSON(e,...t){return new this().asyncFromJSON(e,...t)}toJSON(){let e={};for(const t in this)if(Array.isArray(this[t])){const n=[];for(const u in this[t])typeof this[t][u].toJSON=="function"?n.push(this[t][u].toJSON()):n.push(JSON.stringify(this[t][u]));e[t]=n}else if(this[t]===null)e[t]=this[t];else if(typeof this[t]=="object"&&typeof this[t].toJSON=="function")e[t]=this[t].toJSON();else if(typeof this[t]=="boolean"||typeof this[t]=="number"||typeof this[t]=="string")e[t]=this[t];else if(Buffer.isBuffer(this[t]))e[t]=this[t].toString("hex");else if(this[t]instanceof Map)e[t]=JSON.stringify(this[t]);else if(typeof this[t]=="object")throw new Error("not implemented");return e}asyncToJSON(){throw new Error("not implemented")}clone(){return this.cloneByJSON()}cloneByBuffer(){return new this.constructor().fromBuffer(this.toBuffer())}cloneByFastBuffer(){return new this.constructor().fromFastBuffer(this.toFastBuffer())}cloneByHex(){return new this.constructor().fromHex(this.toHex())}cloneByString(){return new this.constructor().fromString(this.toString())}cloneByJSON(){return new this.constructor().fromJSON(this.toJSON())}}class jt extends Te{constructor(e){super({buf:e})}fromHex(e){return this.fromBuffer(Buffer.from(e,"hex"))}toHex(){return this.toBuffer().toString("hex")}static encode(e){if(!Buffer.isBuffer(e))throw new Error("Input should be a buffer");return jf.encode(e)}static decode(e){if(typeof e!="string")throw new Error("Input should be a string");return Buffer.from(jf.decode(e))}fromBuffer(e){return this.buf=e,this}fromString(e){const t=jt.decode(e);return this.buf=t,this}toBuffer(){return this.buf}toString(){return jt.encode(this.buf)}}const kt=(l,e)=>{if(!Buffer.isBuffer(l)||!Buffer.isBuffer(e))throw new Error("buf1 and buf2 must be buffers");if(l.length!==e.length)return!1;let t=0;for(let n=0;n<l.length;n++){const u=l[n],r=e[n];t|=u^r}return t===0};class Vf extends Te{constructor(e,t,n){super({resbuf:e,isError:t,id:n})}fromResult(e,t){return e.toFastBuffer?this.resbuf=e.toFastBuffer():Buffer.isBuffer(e)?this.resbuf=e:this.resbuf=Buffer.from(JSON.stringify(e)),this.isError=!1,this.id=t,this}static fromResult(e,t){return new this().fromResult(e,t)}fromError(e,t){return this.resbuf=Buffer.from(JSON.stringify(e.message)),this.isError=!0,this.id=t,this}toBw(e){return e||(e=new ke),e.writeVarIntNum(this.resbuf.length),e.write(this.resbuf),e.writeUInt8(Number(this.isError)),e.writeVarIntNum(this.id),e}fromBr(e){const t=e.readVarIntNum();return this.resbuf=e.read(t),this.isError=!!e.readUInt8(),this.id=e.readVarIntNum(),this}}let Ot;class le{constructor(e=[],t=0,n=[],u=new Map){this.nativeWorkers=e,this.lastid=t,this.incompconsteRes=n,this.promisemap=u}asyncObjectMethod(e,t,n,u=this.lastid+1){if(!n)throw new Error("must specify args");const r=e[t](...n);return new Vf().fromResult(r,u)}static asyncObjectMethod(e,t,n,u){return Ot||(Ot=new le),Ot.asyncObjectMethod(e,t,n,u)}asyncClassMethod(e,t,n,u=this.lastid+1){if(!n)throw new Error("must specify args");const r=e[t](...n);return new Vf().fromResult(r,u)}static asyncClassMethod(e,t,n,u){return Ot||(Ot=new le),Ot.asyncClassMethod(e,t,n,u)}static endGlobalWorkers(){Ot&&!process.browser&&(Ot=void 0)}}class ae{}ae.sha1=function(l){if(!Buffer.isBuffer(l))throw new Error("sha1 hash must be of a buffer");const e=br.sha1,t=new e().update(l).digest();return Buffer.from(t)};ae.sha1.blockSize=512;ae.asyncSha1=async function(l){const e=[l];return(await le.asyncClassMethod(ae,"sha1",e)).resbuf};ae.sha256=function(l){if(!Buffer.isBuffer(l))throw new Error("sha256 hash must be of a buffer");const e=br.sha256,t=new e().update(l).digest();return Buffer.from(t)};ae.sha256.blockSize=512;ae.asyncSha256=async function(l){const e=[l];return(await le.asyncClassMethod(ae,"sha256",e)).resbuf};ae.sha256Sha256=function(l){try{return ae.sha256(ae.sha256(l))}catch(e){throw new Error("sha256Sha256 hash must be of a buffer: "+e)}};ae.asyncSha256Sha256=async function(l){const e=[l];return(await le.asyncClassMethod(ae,"sha256Sha256",e)).resbuf};ae.ripemd160=function(l){if(!Buffer.isBuffer(l))throw new Error("ripemd160 hash must be of a buffer");const e=br.ripemd160,t=new e().update(l).digest();return Buffer.from(t)};ae.asyncRipemd160=async function(l){const e=[l];return(await le.asyncClassMethod(ae,"ripemd160",e)).resbuf};ae.sha256Ripemd160=function(l){try{return ae.ripemd160(ae.sha256(l))}catch(e){throw new Error("sha256Ripemd160 hash must be of a buffer: "+e)}};ae.asyncSha256Ripemd160=async function(l){const e=[l];return(await le.asyncClassMethod(ae,"sha256Ripemd160",e)).resbuf};ae.sha512=function(l){if(!Buffer.isBuffer(l))throw new Error("sha512 hash must be of a buffer");const e=br.sha512,t=new e().update(l).digest();return Buffer.from(t)};ae.asyncSha512=async function(l){const e=[l];return(await le.asyncClassMethod(ae,"sha512",e)).resbuf};ae.sha512.blockSize=1024;ae.hmac=function(l,e,t){if(l!=="sha1"&&l!=="sha256"&&l!=="sha512")throw new Error("invalid choice of hash function");const n=ae[l];if(!Buffer.isBuffer(e)||!Buffer.isBuffer(t))throw new Error("data and key must be buffers");const u=n.blockSize/8;if(t.length>u&&(t=n(t)),t.length<u){const a=Buffer.alloc(u);a.fill(0,t.length),t.copy(a),t=a}const r=Buffer.alloc(u),s=Buffer.alloc(u);for(let a=0;a<u;a++)r[a]=92^t[a],s[a]=54^t[a];return n(Buffer.concat([r,n(Buffer.concat([s,e]))]))};ae.sha1Hmac=function(l,e){return ae.hmac("sha1",l,e)};ae.asyncSha1Hmac=async function(l,e){const t=[l,e];return(await le.asyncClassMethod(ae,"sha1Hmac",t)).resbuf};ae.sha1Hmac.bitsize=160;ae.sha256Hmac=function(l,e){return ae.hmac("sha256",l,e)};ae.asyncSha256Hmac=async function(l,e){const t=[l,e];return(await le.asyncClassMethod(ae,"sha256Hmac",t)).resbuf};ae.sha256Hmac.bitsize=256;ae.sha512Hmac=function(l,e){return ae.hmac("sha512",l,e)};ae.asyncSha512Hmac=async function(l,e){const t=[l,e];return(await le.asyncClassMethod(ae,"sha512Hmac",t)).resbuf};ae.sha512Hmac.bitsize=512;class Bt extends Te{constructor(e){super({buf:e})}fromHex(e){return this.fromBuffer(Buffer.from(e,"hex"))}toHex(){return this.toBuffer().toString("hex")}static decode(e){if(typeof e!="string")throw new Error("Input must be a string");const t=jt.decode(e);if(t.length<4)throw new Error("Input string too short");const n=t.slice(0,-4),u=t.slice(-4),s=ae.sha256Sha256(n).slice(0,4);if(!kt(u,s))throw new Error("Checksum mismatch");return n}static encode(e){if(!Buffer.isBuffer(e))throw new Error("Input must be a buffer");const t=Buffer.alloc(e.length+4),n=ae.sha256Sha256(e);return e.copy(t),n.copy(t,e.length),jt.encode(t)}fromBuffer(e){return this.buf=e,this}fromString(e){const t=Bt.decode(e);return this.buf=t,this}toBuffer(){return this.buf}toString(){return Bt.encode(this.buf)}}class I1{constructor(e){this.keyDefined=t=>t in e,this.getValue=t=>e[t]}get(e){if(this.keyDefined(e))return this.getValue(e);throw new Error(`Unknown configuration: ${e}`)}}class A1{constructor(){this.variables={}}build(){return new I1(this.variables)}addValue(e,t){if(t===void 0)throw new Error(`Failed to add "${e}" property. The value cannot be undefined`);if(e in this.variables)throw new Error(`"${e}" already has a value defined.`);return this.variables[e]=t,this}addValueWithDefault(e,t,n){if(n===void 0)throw new Error(`Failed to add "${e}" property. Default value cannot be undefined`);return this.addValue(e,t===void 0?n:t)}}const Jt=new A1().addValue("NETWORK","mainnet").build(),Oe={};Oe.Mainnet={MaxSize:33554432,Port:8333,Address:{pubKeyHash:0,payToScriptHash:5},Bip32:{pubKey:76067358,privKey:76066276},Block:{maxNBits:486604799,magicNum:3823236072},Msg:{magicNum:3823236072,versionBytesNum:70015},PrivKey:{versionByteNum:128},TxBuilder:{dust:0,feePerKbNum:1},Workers:{timeout:6e4}};Oe.Testnet=Object.assign({},Oe.Mainnet,{Port:18333,Address:{pubKeyHash:111,payToScriptHash:196},Bip32:{pubKey:70617039,privKey:70615956},Block:{maxNBits:486604799,magicNum:4108710900},Msg:{magicNum:4108710900,versionBytesNum:70015},PrivKey:{versionByteNum:239}});Oe.Regtest=Object.assign({},Oe.Mainnet,{Port:18444,Address:{pubKeyHash:111,payToScriptHash:196},Bip32:{pubKey:70617039,privKey:70615956},Block:{maxNBits:545259519,magicNum:3669344250},Msg:{magicNum:3669344250,versionBytesNum:70015},PrivKey:{versionByteNum:239}});Oe.STN=Object.assign({},Oe.Mainnet,{Port:9333,Address:{pubKeyHash:111,payToScriptHash:196},Bip32:{pubKey:70617039,privKey:70615956},Block:{maxNBits:486604799,magicNum:4224632057},Msg:{magicNum:4224632057,versionBytesNum:70015},PrivKey:{versionByteNum:239}});if(Jt.get("NETWORK")==="testnet")Oe.Default=Object.assign({},Oe.Testnet);else if(Jt.get("NETWORK")==="mainnet")Oe.Default=Object.assign({},Oe.Mainnet);else if(Jt.get("NETWORK")==="regtest")Oe.Default=Object.assign({},Oe.Regtest);else if(Jt.get("NETWORK")==="stn")Oe.Default=Object.assign({},Oe.STN);else throw new Error(`must set network in environment variable - mainnet, testnet, regtest or stn?, received ${Jt.get("NETWORK")}`);const O1=l=>Oe.Mainnet.Msg.magicNum===l?Oe.Mainnet:Oe.Testnet.Msg.magicNum===l?Oe.Testnet:Oe.Regtest.Msg.magicNum===l?Oe.Regtest:Oe.STN.Msg.magicNum===l?Oe.STN:Oe.Default,Xt={FALSE:0,0:0,PUSHDATA1:76,PUSHDATA2:77,PUSHDATA4:78,"1NEGATE":79,RESERVED:80,TRUE:81,1:81,2:82,3:83,4:84,5:85,6:86,7:87,8:88,9:89,10:90,11:91,12:92,13:93,14:94,15:95,16:96,NOP:97,VER:98,IF:99,NOTIF:100,VERIF:101,VERNOTIF:102,ELSE:103,ENDIF:104,VERIFY:105,RETURN:106,TOALTSTACK:107,FROMALTSTACK:108,"2DROP":109,"2DUP":110,"3DUP":111,"2OVER":112,"2ROT":113,"2SWAP":114,IFDUP:115,DEPTH:116,DROP:117,DUP:118,NIP:119,OVER:120,PICK:121,ROLL:122,ROT:123,SWAP:124,TUCK:125,CAT:126,SUBSTR:127,SPLIT:127,LEFT:128,NUM2BIN:128,RIGHT:129,BIN2NUM:129,SIZE:130,INVERT:131,AND:132,OR:133,XOR:134,EQUAL:135,EQUALVERIFY:136,RESERVED1:137,RESERVED2:138,"1ADD":139,"1SUB":140,"2MUL":141,"2DIV":142,NEGATE:143,ABS:144,NOT:145,"0NOTEQUAL":146,ADD:147,SUB:148,MUL:149,DIV:150,MOD:151,LSHIFT:152,RSHIFT:153,BOOLAND:154,BOOLOR:155,NUMEQUAL:156,NUMEQUALVERIFY:157,NUMNOTEQUAL:158,LESSTHAN:159,GREATERTHAN:160,LESSTHANOREQUAL:161,GREATERTHANOREQUAL:162,MIN:163,MAX:164,WITHIN:165,RIPEMD160:166,SHA1:167,SHA256:168,HASH160:169,HASH256:170,CODESEPARATOR:171,CHECKSIG:172,CHECKSIGVERIFY:173,CHECKMULTISIG:174,CHECKMULTISIGVERIFY:175,NOP1:176,NOP2:177,CHECKLOCKTIMEVERIFY:177,NOP3:178,CHECKSEQUENCEVERIFY:178,NOP4:179,NOP5:180,NOP6:181,NOP7:182,NOP8:183,NOP9:184,NOP10:185,SMALLDATA:249,SMALLINTEGER:250,PUBKEYS:251,PUBKEYHASH:253,PUBKEY:254,INVALIDOPCODE:255},Qt={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_SPLIT:127,OP_LEFT:128,OP_NUM2BIN:128,OP_RIGHT:129,OP_BIN2NUM:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_SMALLDATA:249,OP_SMALLINTEGER:250,OP_PUBKEYS:251,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255};class q extends Te{constructor(e){super({num:e})}fromNumber(e){return this.num=e,this}static fromNumber(e){return new this().fromNumber(e)}toNumber(){return this.num}fromString(e){const t=Qt[e];if(t===void 0)throw new Error("Invalid opCodeStr");return this.num=t,this}fromNoOpString(e){const t=Xt[e];if(t===void 0)throw new Error("Invalid opCodeStr");return this.num=t,this}static fromString(e){return new this().fromString(e)}static fromNoOpString(e){return new this().fromNoOpString(e)}toString(){const e=q.str[this.num];return e===void 0?this.num>0&&this.num<q.OP_PUSHDATA1?this.num.toString():"OP_"+this.num.toNumber():e}toNoOpString(){const e=q.noopstr[this.num];return e===void 0?this.num>0&&this.num<q.OP_PUSHDATA1?this.num.toString():this.num.toNumber():e}}q.str={};q.noopstr={};for(const l in Qt)q[l]=Qt[l],Object.prototype.hasOwnProperty.call(Qt,l)&&(q.str[Qt[l]]=l);for(const l in Xt)q[l]=Xt[l],Object.prototype.hasOwnProperty.call(Xt,l)&&(q.noopstr[Xt[l]]=l);q.OP_SUBSTR_CHRONICLE=179;q.OP_LEFT_CHRONICLE=180;q.OP_RIGHT_CHRONICLE=181;q.OP_LSHIFTNUM=182;q.OP_RSHIFTNUM=183;const Zt=Bd.curves.secp256k1,P1=Zt.curve.point(),Ct=P1.constructor;class Ie extends Ct{constructor(e,t,n){super(Zt.curve,e,t,n)}static fromX(e,t){const n=Zt.curve.pointFromX(t,e);return Object.create(Ie.prototype).copyFrom(n)}copyFrom(e){if(!(e instanceof Ct))throw new Error("point should be an external point");return Object.keys(e).forEach((function(t){this[t]=e[t]}).bind(this)),this}add(e){return e=Ct.prototype.add.call(this,e),Object.create(Ie.prototype).copyFrom(e)}mul(e){if(!e.lt(Ie.getN()))throw new Error("point mul out of range");const t=Ct.prototype.mul.call(this,e);return Object.create(Ie.prototype).copyFrom(t)}mulAdd(e,t,n){const u=Ct.prototype.mulAdd.call(this,e,t,n);return t=Object.create(Ie.prototype),t.copyFrom(u)}getX(){const e=Ct.prototype.getX.call(this),t=Object.create(Z.prototype);return e.copy(t),t}getY(){const e=Ct.prototype.getY.call(this),t=Object.create(Z.prototype);return e.copy(t),t}fromX(e,t){const n=Ie.fromX(e,t);return this.copyFrom(n)}toJSON(){return{x:this.getX().toString(),y:this.getY().toString()}}fromJSON(e){const t=new Z().fromString(e.x),n=new Z().fromString(e.y),u=new Ie(t,n);return this.copyFrom(u)}toString(){return JSON.stringify(this.toJSON())}fromString(e){const t=JSON.parse(e),n=new Ie().fromJSON(t);return this.copyFrom(n)}static getG(){const e=Zt.curve.g;return Object.create(Ie.prototype).copyFrom(e)}static getN(){return new Z(Zt.curve.n.toArray())}validate(){if(Ie.fromX(this.getY().isOdd(),this.getX()).getY().cmp(this.getY())!==0)throw new Error("Invalid y value of public key");if(!(this.getX().gt(-1)&&this.getX().lt(Ie.getN()))||!(this.getY().gt(-1)&&this.getY().lt(Ie.getN())))throw new Error("Point does not lie on the curve");return this}}class Ue extends Te{constructor(e,t){super({point:e,compressed:t})}fromJSON(e){return this.fromFastHex(e),this}toJSON(){return this.toFastHex()}fromPrivKey(e){return this.fromObject({point:Ie.getG().mul(e.bn),compressed:e.compressed}),this}static fromPrivKey(e){return new this().fromPrivKey(e)}async asyncFromPrivKey(e){const t=await le.asyncObjectMethod(this,"fromPrivKey",[e]);return this.fromFastBuffer(t.resbuf)}static asyncFromPrivKey(e){return new this().asyncFromPrivKey(e)}fromBuffer(e,t){return this.fromDer(e,t)}async asyncFromBuffer(e,t){const n=[e,t],u=await le.asyncObjectMethod(this,"fromBuffer",n);return this.fromFastBuffer(u.resbuf)}fromFastBuffer(e){if(e.length===0)return this;const t=!!e[0];return e=e.slice(1),this.fromDer(e),this.compressed=t,this}fromDer(e,t){if(t===void 0?t=!0:t=!1,e[0]===4||!t&&(e[0]===6||e[0]===7)){const n=e.slice(1,33),u=e.slice(33,65);if(n.length!==32||u.length!==32||e.length!==65)throw new Error("LEngth of x and y must be 32 bytes");const r=new Z(n),s=new Z(u);this.point=new Ie(r,s),this.compressed=!1}else if(e[0]===3){const n=e.slice(1),u=new Z(n);this.fromX(!0,u),this.compressed=!0}else if(e[0]===2){const n=e.slice(1),u=new Z(n);this.fromX(!1,u),this.compressed=!0}else throw new Error("Invalid DER format pubKey");return this}static fromDer(e,t){return new this().fromDer(e,t)}fromString(e){return this.fromDer(Buffer.from(e,"hex")),this}fromX(e,t){if(typeof e!="boolean")throw new Error("Must specify whether y is odd or not (true or false)");return this.point=Ie.fromX(e,t),this}static fromX(e,t){return new this().fromX(e,t)}toBuffer(){const e=this.compressed===void 0?!0:this.compressed;return this.toDer(e)}toFastBuffer(){if(!this.point)return Buffer.alloc(0);const e=new ke,t=this.compressed===void 0?!0:!!this.compressed;return e.writeUInt8(Number(t)),e.write(this.toDer(!1)),e.toBuffer()}toDer(e){if(e=e===void 0?this.compressed:e,typeof e!="boolean")throw new Error("Must specify whether the public key is compressed or not (true or false)");const t=this.point.getX(),n=this.point.getY(),u=t.toBuffer({size:32}),r=n.toBuffer({size:32});let s;return e?(r[r.length-1]%2?s=Buffer.from([3]):s=Buffer.from([2]),Buffer.concat([s,u])):(s=Buffer.from([4]),Buffer.concat([s,u,r]))}toString(){const e=this.compressed===void 0?!0:this.compressed;return this.toDer(e).toString("hex")}static isCompressedOrUncompressed(e){if(e.length<33)return!1;if(e[0]===4){if(e.length!==65)return!1}else if(e[0]===2||e[0]===3){if(e.length!==33)return!1}else return!1;return!0}validate(){if(this.point.isInfinity())throw new Error("point: Point cannot be equal to Infinity");if(this.point.eq(new Ie(new Z(0),new Z(0))))throw new Error("point: Point cannot be equal to 0, 0");return this.point.validate(),this}}var k1=qt();const N1=zt(k1);class Rt{}Rt.getRandomBuffer=function(l){return Buffer.from(N1(l))};class gt extends Te{constructor(e,t,n=null){super({bn:e,compressed:t}),n=n||Oe.Default.PrivKey,this.Constants=n}fromJSON(e){return this.fromHex(e),this}toJSON(){return this.toHex()}fromRandom(){let e,t,n;do e=Rt.getRandomBuffer(32),t=new Z().fromBuffer(e),n=t.lt(Ie.getN());while(!n);return this.fromObject({bn:t,compressed:!0}),this}static fromRandom(){return new this().fromRandom()}toBuffer(){let e=this.compressed;e===void 0&&(e=!0);const t=this.bn.toBuffer({size:32});let n;return e?n=Buffer.concat([Buffer.from([this.Constants.versionByteNum]),t,Buffer.from([1])]):n=Buffer.concat([Buffer.from([this.Constants.versionByteNum]),t]),n}fromBuffer(e){if(e.length===34&&e[33]===1)this.compressed=!0;else if(e.length===33)this.compressed=!1;else throw new Error("Length of privKey buffer must be 33 (uncompressed pubKey) or 34 (compressed pubKey)");if(e[0]!==this.Constants.versionByteNum)throw new Error("Invalid versionByteNum byte");return this.fromBn(new Z().fromBuffer(e.slice(1,33)))}toBn(){return this.bn}fromBn(e){return this.bn=e,this}static fromBn(e){return new this().fromBn(e)}validate(){if(!this.bn.lt(Ie.getN()))throw new Error("Number must be less than N");if(typeof this.compressed!="boolean")throw new Error("Must specify whether the corresponding public key is compressed or not (true or false)");return this}toWif(){return Bt.encode(this.toBuffer())}fromWif(e){return this.fromBuffer(Bt.decode(e))}static fromWif(e){return new this().fromWif(e)}toString(){return this.toWif()}fromString(e){return this.fromWif(e)}}gt.Mainnet=class extends gt{constructor(l,e){super(l,e,Oe.Mainnet.PrivKey)}};gt.Testnet=class extends gt{constructor(l,e){super(l,e,Oe.Testnet.PrivKey)}};class he extends Te{constructor(e,t,n,u,r){super({r:e,s:t,nHashType:n,recovery:u,compressed:r})}fromBuffer(e){try{return this.fromDer(e,!0)}catch{}try{return this.fromCompact(e)}catch{}return this.fromTxFormat(e)}toBuffer(){return this.nHashType!==void 0?this.toTxFormat():this.recovery!==void 0?this.toCompact():this.toDer()}fromCompact(e){let t=!0,n=e.slice(0,1)[0]-27-4;if(n<0&&(t=!1,n=n+4),!(n===0||n===1||n===2||n===3))throw new Error("i must be 0, 1, 2, or 3");this.compressed=t,this.recovery=n;const u=e.slice(1);return this.fromRS(u),this}static fromCompact(e){return new this().fromCompact(e)}fromRS(e){const t=e.slice(0,32),n=e.slice(32,64);if(t.length!==32)throw new Error("r must be 32 bytes");if(n.length!==32||e.length>64)throw new Error("s must be 32 bytes");return this.r=new Z().fromBuffer(t),this.s=new Z().fromBuffer(n),this}static fromRS(e){return new this().fromRS(e)}fromDer(e,t){const n=he.parseDer(e,t);return this.r=n.r,this.s=n.s,this}static fromDer(e,t){return new this().fromDer(e,t)}fromTxFormat(e){if(e.length===0)return this.r=new Z(1),this.s=new Z(1),this.nHashType=1,this;const t=e.readUInt8(e.length-1),n=e.slice(0,e.length-1);return this.fromDer(n,!1),this.nHashType=t,this}static fromTxFormat(e){return new this().fromTxFormat(e)}fromString(e){return this.fromHex(e)}static parseDer(e,t){if(t===void 0&&(t=!0),!Buffer.isBuffer(e))throw new Error("DER formatted signature should be a buffer");const n=e[0];if(n!==48)throw new Error("Header byte should be 0x30");let u=e[1];const r=e.slice(2).length;if(t&&u!==r)throw new Error("LEngth byte should length of what follows");u=u<r?u:r;const s=e[2];if(s!==2)throw new Error("Integer byte for r should be 0x02");const a=e[3],o=e.slice(4,4+a),f=new Z().fromBuffer(o),i=e[4]===0;if(a!==o.length)throw new Error("LEngth of r incorrect");const c=e[4+a+0];if(c!==2)throw new Error("Integer byte for s should be 0x02");const h=e[4+a+1],d=e.slice(4+a+2,4+a+2+h),b=new Z().fromBuffer(d),p=e[4+a+2+2]===0;if(h!==d.length)throw new Error("LEngth of s incorrect");const y=4+a+2+h;if(u!==y-2)throw new Error("LEngth of signature incorrect");return{header:n,length:u,rheader:s,rlength:a,rneg:i,rbuf:o,r:f,sheader:c,slength:h,sneg:p,sbuf:d,s:b}}static IsTxDer(e){if(e.length<9||e.length>73||e[0]!==48||e[1]!==e.length-3)return!1;const t=e[3];if(5+t>=e.length)return!1;const n=e[5+t];if(t+n+7!==e.length)return!1;const u=e.slice(4);if(e[2]!==2||t===0||u[0]&128||t>1&&u[0]===0&&!(u[1]&128))return!1;const r=e.slice(6+t);return!(e[6+t-2]!==2||n===0||r[0]&128||n>1&&r[0]===0&&!(r[1]&128))}hasLowS(){return!(this.s.lt(1)||this.s.gt(Z.fromBuffer(Buffer.from("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex"))))}isChronicle(){return(this.nHashType&he.SIGHASH_CHRONICLE)!==0}hasDefinedHashType(){const e=this.nHashType&~(he.SIGHASH_CHRONICLE|he.SIGHASH_FORKID|he.SIGHASH_ANYONECANPAY);return!(e<he.SIGHASH_ALL||e>he.SIGHASH_SINGLE)}toCompact(e,t){if(e=typeof e=="number"?e:this.recovery,t=typeof t=="boolean"?t:this.compressed,!(e===0||e===1||e===2||e===3))throw new Error("recovery must be equal to 0, 1, 2, or 3");let n=e+27+4;t===!1&&(n=n-4);const u=Buffer.from([n]),r=this.r.toBuffer({size:32}),s=this.s.toBuffer({size:32});return Buffer.concat([u,r,s])}toRS(){return Buffer.concat([this.r.toBuffer({size:32}),this.s.toBuffer({size:32})])}toDer(){const e=this.r.toBuffer(),t=this.s.toBuffer(),n=e[0]&128,u=t[0]&128,r=n?Buffer.concat([Buffer.from([0]),e]):e,s=u?Buffer.concat([Buffer.from([0]),t]):t,a=2+r.length+2+s.length,o=r.length,f=s.length;return Buffer.concat([Buffer.from([48,a,2,o]),r,Buffer.from([2,f]),s])}toTxFormat(){const e=this.toDer(),t=Buffer.alloc(1);return t.writeUInt8(this.nHashType,0),Buffer.concat([e,t])}toString(){return this.toHex()}}he.SIGHASH_ALL=1;he.SIGHASH_NONE=2;he.SIGHASH_SINGLE=3;he.SIGHASH_CHRONICLE=32;he.SIGHASH_FORKID=64;he.SIGHASH_ANYONECANPAY=128;class Ae extends Te{constructor(e=[]){super({chunks:e})}fromJSON(e){return this.fromString(e)}toJSON(){return this.toString()}fromBuffer(e){this.chunks=[];const t=new ot(e);for(;!t.eof();){const n=t.readUInt8();let u=0,r=Buffer.from([]);if(n>0&&n<q.OP_PUSHDATA1)u=n,this.chunks.push({buf:t.read(u),len:u,opCodeNum:n});else if(n===q.OP_PUSHDATA1){try{u=t.readUInt8(),r=t.read(u)}catch{t.read()}this.chunks.push({buf:r,len:u,opCodeNum:n})}else if(n===q.OP_PUSHDATA2){try{u=t.readUInt16LE(),r=t.read(u)}catch{t.read()}this.chunks.push({buf:r,len:u,opCodeNum:n})}else if(n===q.OP_PUSHDATA4){try{u=t.readUInt32LE(),r=t.read(u)}catch{t.read()}this.chunks.push({buf:r,len:u,opCodeNum:n})}else this.chunks.push({opCodeNum:n})}return this}toBuffer(){const e=new ke;for(let t=0;t<this.chunks.length;t++){const n=this.chunks[t],u=n.opCodeNum;e.writeUInt8(u),n.buf&&(u<q.OP_PUSHDATA1?e.write(n.buf):u===q.OP_PUSHDATA1?(e.writeUInt8(n.len),e.write(n.buf)):u===q.OP_PUSHDATA2?(e.writeUInt16LE(n.len),e.write(n.buf)):u===q.OP_PUSHDATA4&&(e.writeUInt32LE(n.len),e.write(n.buf)))}return e.toBuffer()}fromString(e){if(this.chunks=[],e===""||e===void 0)return this;const t=e.split(" ");let n=0;for(;n<t.length;){const u=t[n];let r;try{r=new q().fromString(u).toNumber()}catch{}if(r===void 0)if(r=parseInt(u,10),r>0&&r<q.OP_PUSHDATA1)this.chunks.push({buf:Buffer.from(t[n+1].slice(2),"hex"),len:r,opCodeNum:r}),n=n+2;else if(r===0)this.chunks.push({opCodeNum:0}),n=n+1;else throw new Error("Invalid script");else if(r===q.OP_PUSHDATA1||r===q.OP_PUSHDATA2||r===q.OP_PUSHDATA4){if(t[n+2].slice(0,2)!=="0x")throw new Error("Pushdata data must start with 0x");this.chunks.push({buf:Buffer.from(t[n+2].slice(2),"hex"),len:parseInt(t[n+1],10),opCodeNum:r}),n=n+3}else this.chunks.push({opCodeNum:r}),n=n+1}return this}toString(e={noOp:!1}){let t="";for(let n=0;n<this.chunks.length;n++){const u=this.chunks[n],r=u.opCodeNum?.num?u.opCodeNum.num:u.opCodeNum;u.buf?((r===q.OP_PUSHDATA1||r===q.OP_PUSHDATA2||r===q.OP_PUSHDATA4)&&(t=e.noOp?t+" "+new q(r).toNoOpString():t+" "+new q(r).toString()),t=t+" "+u.len,t=t+" 0x"+u.buf.toString("hex")):q.str[r]!==void 0||q.noopstr[r]!==void 0?t=e.noOp?t+" "+new q(r).toNoOpString():t+" "+new q(r).toString():t=t+" 0x"+r.toString(16)}return t.substr(1)}fromBitcoindString(e){const t=new ke,n=e.split(" ");let u;for(u=0;u<n.length;u++){const s=n[u];if(s!=="")if(s[0]==="0"&&s[1]==="x"){const a=s.slice(2);t.write(Buffer.from(a,"hex"))}else if(s[0]==="'"){const a=s.slice(1,s.length-1),o=Buffer.from(a),f=new Ae().writeBuffer(o).toBuffer();t.write(f)}else if(q["OP_"+s]!==void 0){const a="OP_"+s,o=q[a];t.writeUInt8(o)}else if(typeof q[s]=="number"){const o=q[s];t.writeUInt8(o)}else{if(isNaN(parseInt(s,10)))throw new Error("Could not determine type of script value");{const a=new Z(s),f=new Ae().writeBn(a).toBuffer();t.write(f)}}}const r=t.toBuffer();return this.fromBuffer(r)}static fromBitcoindString(e){return new this().fromBitcoindString(e)}toBitcoindString(){let e="";for(let t=0;t<this.chunks.length;t++){const n=this.chunks[t];if(n.buf){const r=new Ae([n]).toBuffer().toString("hex");e=e+" 0x"+r}else if(q.str[n.opCodeNum]!==void 0){const u=new q(n.opCodeNum).toString();e=e+" "+u.slice(3)}else e=e+" 0x"+n.opCodeNum.toString(16)}return e.substr(1)}fromAsmString(e){this.chunks=[];const t=e.split(" ");let n=0;for(;n<t.length;){const u=t[n];let r,s;try{r=q.fromString(u),s=r.toNumber()}catch{r=void 0,s=void 0}if(u==="0")s=0,this.chunks.push({opCodeNum:s}),n=n+1;else if(u==="-1")s=q.OP_1NEGATE,this.chunks.push({opCodeNum:s}),n=n+1;else if(r===void 0){const a=t[n],o=Buffer.from(a,"hex");if(o.toString("hex")!==a)throw new Error("invalid hex string in script");const f=o.length;f>=0&&f<q.OP_PUSHDATA1?s=f:f<Math.pow(2,8)?s=q.OP_PUSHDATA1:f<Math.pow(2,16)?s=q.OP_PUSHDATA2:f<Math.pow(2,32)&&(s=q.OP_PUSHDATA4),this.chunks.push({buf:o,len:o.length,opCodeNum:s}),n=n+1}else this.chunks.push({opCodeNum:s}),n=n+1}return this}static fromAsmString(e){return new this().fromAsmString(e)}toAsmString(e={noOp:!1}){let t="";for(let n=0;n<this.chunks.length;n++){const u=this.chunks[n];t+=this._chunkToString(u,e)}return t.substr(1)}_chunkToString(e,t={noOp:!1}){const n=e.opCodeNum;let u="";if(e.buf)e.len>0&&(u=u+" "+e.buf.toString("hex"));else if(typeof q.str[n]<"u")n===0?u=u+" 0":n===79?u=u+" -1":u=t.noOp?u+" "+new q(n).toNoOpString():u+" "+new q(n).toString();else{let r=n.toString(16);r.length%2!==0&&(r="0"+r),u=u+" "+r}return u}fromOpReturnData(e){return this.writeOpCode(q.OP_RETURN),this.writeBuffer(e),this}static fromOpReturnData(e){return new this().fromOpReturnData(e)}fromSafeData(e){return this.writeOpCode(q.OP_FALSE),this.writeOpCode(q.OP_RETURN),this.writeBuffer(e),this}static fromSafeData(e){return new this().fromSafeData(e)}fromSafeDataArray(e){this.writeOpCode(q.OP_FALSE),this.writeOpCode(q.OP_RETURN);for(const t in e){const n=e[t];this.writeBuffer(n)}return this}static fromSafeDataArray(e){return new this().fromSafeDataArray(e)}getData(){if(this.isSafeDataOut())return this.chunks.slice(2).map(n=>n.buf);if(this.isOpReturn())return this.chunks.slice(1).map(n=>n.buf);throw new Error("Unrecognized script type to get data from")}fromPubKeyHash(e){if(e.length!==20)throw new Error("hashBuf must be a 20 byte buffer");return this.writeOpCode(q.OP_DUP),this.writeOpCode(q.OP_HASH160),this.writeBuffer(e),this.writeOpCode(q.OP_EQUALVERIFY),this.writeOpCode(q.OP_CHECKSIG),this}static fromPubKeyHash(e){return new this().fromPubKeyHash(e)}static sortPubKeys(e){return e.slice().sort((t,n)=>{const u=t.toBuffer(),r=n.toBuffer(),s=Math.max(u.length,r.length);for(let a=0;a<=s;a++){if(u[a]===void 0)return-1;if(r[a]===void 0)return 1;if(u[a]<r[a])return-1;if(u[a]>r[a])return 1}})}fromPubKeys(e,t,n=!0){if(typeof e!="number")throw new Error("m must be a number");n===!0&&(t=Ae.sortPubKeys(t)),this.writeOpCode(e+q.OP_1-1);for(const u in t)this.writeBuffer(t[u].toBuffer());return this.writeOpCode(t.length+q.OP_1-1),this.writeOpCode(q.OP_CHECKMULTISIG),this}static fromPubKeys(e,t,n){return new this().fromPubKeys(e,t,n)}removeCodeseparators(){const e=[];for(let t=0;t<this.chunks.length;t++)this.chunks[t].opCodeNum!==q.OP_CODESEPARATOR&&e.push(this.chunks[t]);return this.chunks=e,this}isPushOnly(){for(let e=0;e<this.chunks.length;e++)if(this.chunks[e].opCodeNum>q.OP_16)return!1;return!0}isNonSpendable(){const e=this.chunks[0].opCodeNum===q.OP_FALSE,t=this.chunks[1]&&this.chunks[1].opCodeNum===q.OP_RETURN;return!!e&&!!t}isOpReturn(){return this.chunks[0].opCodeNum===q.OP_RETURN&&this.chunks.filter(e=>Buffer.isBuffer(e.buf)).length===this.chunks.slice(1).length}isSafeDataOut(){if(this.chunks.length<2||this.chunks[0].opCodeNum!==q.OP_FALSE)return!1;const e=this.chunks.slice(1);return new Ae(e).isOpReturn()}isPubKeyHashOut(){return!!(this.chunks[0]&&this.chunks[0].opCodeNum===q.OP_DUP&&this.chunks[1]&&this.chunks[1].opCodeNum===q.OP_HASH160&&this.chunks[2].buf&&this.chunks[3]&&this.chunks[3].opCodeNum===q.OP_EQUALVERIFY&&this.chunks[4]&&this.chunks[4].opCodeNum===q.OP_CHECKSIG)}isPubKeyHashIn(){return!!(this.chunks.length===2&&(this.chunks[0].buf||this.chunks[0].opCodeNum===q.OP_0)&&(this.chunks[1].buf||this.chunks[0].opCodeNum===q.OP_0))}isScriptHashOut(){const e=this.toBuffer();return e.length===23&&e[0]===q.OP_HASH160&&e[1]===20&&e[22]===q.OP_EQUAL}isScriptHashIn(){if(!this.isPushOnly())return!1;try{new Ae().fromBuffer(this.chunks[this.chunks.length-1].buf)}catch{return!1}return!0}isMultiSigOut(){const e=this.chunks[0].opCodeNum-q.OP_1+1;if(!(e>=1&&e<=16)||!this.chunks.slice(1,this.chunks.length-2).every(u=>{try{const r=u.buf;return new Ue().fromDer(r).validate(),!0}catch{return!1}}))return!1;const n=this.chunks[this.chunks.length-2].opCodeNum-q.OP_1+1;return!(!(n>=e&&n<=16)||this.chunks[1+n+1].opCodeNum!==q.OP_CHECKMULTISIG)}isMultiSigIn(){if(this.chunks[0].opCodeNum!==q.OP_0)return!1;const e=this.chunks.slice(1);return e.length<1?!1:e.every(t=>Buffer.isBuffer(t.buf)&&he.IsTxDer(t.buf))}findAndDelete(e){const t=e.toBuffer();for(let n=0;n<this.chunks.length;n++){const r=new Ae([this.chunks[n]]).toBuffer();kt(t,r)&&this.chunks.splice(n,1)}return this}writeScript(e){return this.chunks=this.chunks.concat(e.chunks),this}static writeScript(e){return new this().writeScript(e)}writeString(e){const t=new Ae().fromString(e);return this.chunks=this.chunks.concat(t.chunks),this}static writeString(e){return new this().writeString(e)}writeOpCode(e){return this.chunks.push({opCodeNum:e}),this}static writeOpCode(e){return new this().writeOpCode(e)}setChunkOpCode(e,t){return this.chunks[e]={opCodeNum:t},this}writeBn(e){if(e.cmp(0)===q.OP_0)this.chunks.push({opCodeNum:q.OP_0});else if(e.cmp(-1)===0)this.chunks.push({opCodeNum:q.OP_1NEGATE});else if(e.cmp(1)>=0&&e.cmp(16)<=0)this.chunks.push({opCodeNum:e.toNumber()+q.OP_1-1});else{const t=e.toSm({endian:"little"});this.writeBuffer(t)}return this}static writeBn(e){return new this().writeBn(e)}writeNumber(e){return this.writeBn(new Z().fromNumber(e)),this}static writeNumber(e){return new this().writeNumber(e)}setChunkBn(e,t){return this.chunks[e]=new Ae().writeBn(t).chunks[0],this}writeBuffer(e){let t;const n=e.length;if(e.length>0&&e.length<q.OP_PUSHDATA1)t=e.length;else if(e.length===0)t=q.OP_0;else if(e.length<Math.pow(2,8))t=q.OP_PUSHDATA1;else if(e.length<Math.pow(2,16))t=q.OP_PUSHDATA2;else if(e.length<Math.pow(2,32))t=q.OP_PUSHDATA4;else throw new Error("You can't push that much data");return this.chunks.push({buf:e,len:n,opCodeNum:t}),this}static writeBuffer(e){return new this().writeBuffer(e)}setChunkBuffer(e,t){return this.chunks[e]=new Ae().writeBuffer(t).chunks[0],this}checkMinimalPush(e){const t=this.chunks[e],n=t.buf,u=t.opCodeNum;return n?n.length===0?u===q.OP_0:n.length===1&&n[0]>=1&&n[0]<=16?u===q.OP_1+(n[0]-1):n.length===1&&n[0]===129?u===q.OP_1NEGATE:n.length<=75?u===n.length:n.length<=255?u===q.OP_PUSHDATA1:n.length<=65535?u===q.OP_PUSHDATA2:!0:!0}}class St extends Te{constructor(e,t,n=null){super({versionByteNum:e,hashBuf:t}),n=n||Oe.Default.Address,this.Constants=n}fromBuffer(e){if(e.length!==21)throw new Error("address buffers must be exactly 21 bytes");if(e[0]!==this.Constants.pubKeyHash)throw new Error("address: invalid versionByteNum byte");return this.versionByteNum=e[0],this.hashBuf=e.slice(1),this}fromPubKeyHashBuf(e){return this.hashBuf=e,this.versionByteNum=this.Constants.pubKeyHash,this}static fromPubKeyHashBuf(e){return new this().fromPubKeyHashBuf(e)}fromPubKey(e){const t=ae.sha256Ripemd160(e.toBuffer());return this.fromPubKeyHashBuf(t)}static fromPubKey(e){return new this().fromPubKey(e)}async asyncFromPubKey(e){const t=[e],n=await le.asyncObjectMethod(this,"fromPubKey",t);return this.fromFastBuffer(n.resbuf)}static asyncFromPubKey(e){return new this().asyncFromPubKey(e)}fromPrivKey(e){const t=new Ue().fromPrivKey(e),n=ae.sha256Ripemd160(t.toBuffer());return this.fromPubKeyHashBuf(n)}static fromPrivKey(e){return new this().fromPrivKey(e)}async asyncFromPrivKey(e){const t=[e],n=await le.asyncObjectMethod(this,"fromPrivKey",t);return this.fromFastBuffer(n.resbuf)}static asyncFromPrivKey(e){return new this().fromPrivKey(e)}fromRandom(){const e=new gt().fromRandom();return this.fromPrivKey(e)}static fromRandom(){return new this().fromRandom()}async asyncFromRandom(){const e=[],t=await le.asyncObjectMethod(this,"fromRandom",e);return this.fromFastBuffer(t.resbuf)}static asyncFromRandom(){return new this().fromRandom()}fromString(e){const t=Bt.decode(e);return this.fromBuffer(t)}async asyncFromString(e){const t=[e],n=await le.asyncObjectMethod(this,"fromString",t);return this.fromFastBuffer(n.resbuf)}static asyncFromString(e){return new this().asyncFromString(e)}static isValid(e){let t;try{t=new St().fromString(e)}catch{return!1}return t.isValid()}isValid(){try{return this.validate(),!0}catch{return!1}}toTxOutScript(){const e=new Ae;return e.writeOpCode(q.OP_DUP),e.writeOpCode(q.OP_HASH160),e.writeBuffer(this.hashBuf),e.writeOpCode(q.OP_EQUALVERIFY),e.writeOpCode(q.OP_CHECKSIG),e}fromTxInScript(e){const t=ae.sha256Ripemd160(e.chunks[1].buf||Buffer.from("00".repeat(32),"hex"));return this.fromPubKeyHashBuf(t)}static fromTxInScript(e){return new this().fromTxInScript(e)}fromTxOutScript(e){return this.fromPubKeyHashBuf(e.chunks[2].buf)}static fromTxOutScript(e){return new this().fromTxOutScript(e)}toBuffer(){const e=Buffer.from([this.versionByteNum]);return Buffer.concat([e,this.hashBuf])}toJSON(){const e={};return this.hashBuf&&(e.hashBuf=this.hashBuf.toString("hex")),typeof this.versionByteNum<"u"&&(e.versionByteNum=this.versionByteNum),e}fromJSON(e){return e.hashBuf&&(this.hashBuf=Buffer.from(e.hashBuf,"hex")),typeof e.versionByteNum<"u"&&(this.versionByteNum=e.versionByteNum),this}toString(){return Bt.encode(this.toBuffer())}async asyncToString(){const e=[],t=await le.asyncObjectMethod(this,"toString",e);return JSON.parse(t.resbuf.toString())}validate(){if(!Buffer.isBuffer(this.hashBuf)||this.hashBuf.length!==20)throw new Error("hashBuf must be a buffer of 20 bytes");if(this.versionByteNum!==this.Constants.pubKeyHash)throw new Error("invalid versionByteNum");return this}}St.Mainnet=class extends St{constructor(l,e){super(l,e,Oe.Mainnet.Address)}};St.Testnet=class extends St{constructor(l,e){super(l,e,Oe.Testnet.Address)}};class rr extends Te{constructor(e,t,n,u,r,s,a,o=null,f=gt){super({versionBytesNum:e,depth:t,parentFingerPrint:n,childIndex:u,chainCode:r,privKey:s,pubKey:a}),o=o||Oe.Default.Bip32,this.Constants=o,this.PrivKey=f}fromRandom(){return this.versionBytesNum=this.Constants.privKey,this.depth=0,this.parentFingerPrint=Buffer.from([0,0,0,0]),this.childIndex=0,this.chainCode=Rt.getRandomBuffer(32),this.privKey=new this.PrivKey().fromRandom(),this.pubKey=new Ue().fromPrivKey(this.privKey),this}static fromRandom(){return new this().fromRandom()}fromString(e){return this.fromBuffer(Bt.decode(e))}async asyncFromString(e){const t=[e],n=await le.asyncObjectMethod(this,"fromString",t);return this.fromFastBuffer(n.resbuf)}fromSeed(e){if(!Buffer.isBuffer(e))throw new Error("bytes must be a buffer");if(e.length<128/8)throw new Error("Need more than 128 bits of entropy");if(e.length>512/8)throw new Error("More than 512 bits of entropy is nonstandard");const t=ae.sha512Hmac(e,Buffer.from("Bitcoin seed"));return this.depth=0,this.parentFingerPrint=Buffer.from([0,0,0,0]),this.childIndex=0,this.chainCode=t.slice(32,64),this.versionBytesNum=this.Constants.privKey,this.privKey=new this.PrivKey().fromBn(Z().fromBuffer(t.slice(0,32))),this.pubKey=new Ue().fromPrivKey(this.privKey),this}static fromSeed(e){return new this().fromSeed(e)}async asyncFromSeed(e){const t=await le.asyncObjectMethod(this,"fromSeed",[e]);return this.fromFastBuffer(t.resbuf)}static asyncFromSeed(e){return new this().asyncFromSeed(e)}fromBuffer(e){if(e.length!==78)throw new Error("incorrect bip32 data length");this.versionBytesNum=e.slice(0,4).readUInt32BE(0),this.depth=e.slice(4,5).readUInt8(0),this.parentFingerPrint=e.slice(5,9),this.childIndex=e.slice(9,13).readUInt32BE(0),this.chainCode=e.slice(13,45);const t=e.slice(45,78),n=this.versionBytesNum===this.Constants.privKey,u=this.versionBytesNum===this.Constants.pubKey;if(n&&t[0]===0)this.privKey=new this.PrivKey().fromBn(Z().fromBuffer(t.slice(1,33))),this.pubKey=new Ue().fromPrivKey(this.privKey);else if(u&&(t[0]===2||t[0]===3))this.pubKey=new Ue().fromDer(t);else throw new Error("Invalid key");return this}fromFastBuffer(e){if(e.length===0)return this;if(e.length!==78&&e.length!==111)throw new Error("incorrect bip32 fastBuffer data length: "+e.length);this.versionBytesNum=e.slice(0,4).readUInt32BE(0),this.depth=e.slice(4,5).readUInt8(0),this.parentFingerPrint=e.slice(5,9),this.childIndex=e.slice(9,13).readUInt32BE(0),this.chainCode=e.slice(13,45);const t=e.slice(45,e.length),n=this.versionBytesNum===this.Constants.privKey,u=this.versionBytesNum===this.Constants.pubKey;if(n&&t[0]===0&&e.length===78)this.privKey=new this.PrivKey().fromBn(Z().fromBuffer(t.slice(1,33))),this.pubKey=new Ue().fromPrivKey(this.privKey);else if(u&&e.length===111)this.pubKey=new Ue().fromFastBuffer(t),this.pubKey.compressed=!0;else throw new Error("Invalid key");return this}derive(e){const t=e.split("/");if(e==="m")return this;let n=this;for(const u in t){const r=t[u];if(u==="0"){if(r!=="m")throw new Error("invalid path");continue}if(parseInt(r.replace("'",""),10).toString()!==r.replace("'",""))throw new Error("invalid path");const s=r.length>1&&r[r.length-1]==="'";let a=parseInt(s?r.slice(0,r.length-1):r,10)&2147483647;s&&(a+=2147483648),n=n.deriveChild(a)}return n}async asyncDerive(e){const t=await le.asyncObjectMethod(this,"derive",[e]);return new this.constructor().fromFastBuffer(t.resbuf)}deriveChild(e){if(typeof e!="number")throw new Error("i must be a number");let t=[];t.push(e>>24&255),t.push(e>>16&255),t.push(e>>8&255),t.push(e&255),t=Buffer.from(t);const n=(e&2147483648)!==0,u=this.versionBytesNum===this.Constants.privKey;if(n&&(!this.privKey||!u))throw new Error("Cannot do private key derivation without private key");let r=null;if(this.privKey){let a=null;n?a=Buffer.concat([Buffer.from([0]),this.privKey.bn.toBuffer({size:32}),t]):a=Buffer.concat([this.pubKey.toBuffer({size:32}),t]);const o=ae.sha512Hmac(a,this.chainCode),f=Z().fromBuffer(o.slice(0,32),{size:32}),i=o.slice(32,64),c=f.add(this.privKey.bn).mod(Ie.getN());r=new this.constructor,r.chainCode=i,r.privKey=new this.PrivKey().fromBn(c),r.pubKey=new Ue().fromPrivKey(r.privKey)}else{const a=Buffer.concat([this.pubKey.toBuffer(),t]),o=ae.sha512Hmac(a,this.chainCode),f=Z().fromBuffer(o.slice(0,32)),i=o.slice(32,64),c=Ie.getG().mul(f),h=this.pubKey.point,d=c.add(h),b=new Ue;b.point=d,r=new this.constructor,r.chainCode=i,r.pubKey=b}r.childIndex=e;const s=ae.sha256Ripemd160(this.pubKey.toBuffer());return r.parentFingerPrint=s.slice(0,4),r.versionBytesNum=this.versionBytesNum,r.depth=this.depth+1,r}toPublic(){const e=new this.constructor().fromObject(this);return e.versionBytesNum=this.Constants.pubKey,e.privKey=void 0,e}toBuffer(){const e=this.versionBytesNum===this.Constants.privKey,t=this.versionBytesNum===this.Constants.pubKey;if(e)return new ke().writeUInt32BE(this.versionBytesNum).writeUInt8(this.depth).write(this.parentFingerPrint).writeUInt32BE(this.childIndex).write(this.chainCode).writeUInt8(0).write(this.privKey.bn.toBuffer({size:32})).toBuffer();if(t){if(this.pubKey.compressed===!1)throw new Error("cannot convert bip32 to buffer if pubKey is not compressed");return new ke().writeUInt32BE(this.versionBytesNum).writeUInt8(this.depth).write(this.parentFingerPrint).writeUInt32BE(this.childIndex).write(this.chainCode).write(this.pubKey.toBuffer()).toBuffer()}else throw new Error("bip32: invalid versionBytesNum byte")}toFastBuffer(){if(!this.versionBytesNum)return Buffer.alloc(0);const e=this.versionBytesNum===this.Constants.privKey,t=this.versionBytesNum===this.Constants.pubKey;if(e)return new ke().writeUInt32BE(this.versionBytesNum).writeUInt8(this.depth).write(this.parentFingerPrint).writeUInt32BE(this.childIndex).write(this.chainCode).writeUInt8(0).write(this.privKey.bn.toBuffer({size:32})).toBuffer();if(t)return new ke().writeUInt32BE(this.versionBytesNum).writeUInt8(this.depth).write(this.parentFingerPrint).writeUInt32BE(this.childIndex).write(this.chainCode).write(this.pubKey.toFastBuffer()).toBuffer();throw new Error("bip32: invalid versionBytesNum byte")}toString(){return Bt.encode(this.toBuffer())}async asyncToString(){const e=await le.asyncObjectMethod(this,"toString",[]);return JSON.parse(e.resbuf.toString())}toJSON(){return this.toFastHex()}fromJSON(e){return this.fromFastHex(e)}isPrivate(){return this.versionBytesNum===this.Constants.privKey}}rr.Mainnet=class extends rr{constructor(l,e,t,n,u,r,s){super(l,e,t,n,u,r,s,Oe.Mainnet.Bip32,gt.Mainnet)}};rr.Testnet=class extends rr{constructor(l,e,t,n,u,r,s){super(l,e,t,n,u,r,s,Oe.Testnet.Bip32,gt.Testnet)}};const Nr=["abandon","ability","able","about","above","absent","absorb","abstract","absurd","abuse","access","accident","account","accuse","achieve","acid","acoustic","acquire","across","act","action","actor","actress","actual","adapt","add","addict","address","adjust","admit","adult","advance","advice","aerobic","affair","afford","afraid","again","age","agent","agree","ahead","aim","air","airport","aisle","alarm","album","alcohol","alert","alien","all","alley","allow","almost","alone","alpha","already","also","alter","always","amateur","amazing","among","amount","amused","analyst","anchor","ancient","anger","angle","angry","animal","ankle","announce","annual","another","answer","antenna","antique","anxiety","any","apart","apology","appear","apple","approve","april","arch","arctic","area","arena","argue","arm","armed","armor","army","around","arrange","arrest","arrive","arrow","art","artefact","artist","artwork","ask","aspect","assault","asset","assist","assume","asthma","athlete","atom","attack","attend","attitude","attract","auction","audit","august","aunt","author","auto","autumn","average","avocado","avoid","awake","aware","away","awesome","awful","awkward","axis","baby","bachelor","bacon","badge","bag","balance","balcony","ball","bamboo","banana","banner","bar","barely","bargain","barrel","base","basic","basket","battle","beach","bean","beauty","because","become","beef","before","begin","behave","behind","believe","below","belt","bench","benefit","best","betray","better","between","beyond","bicycle","bid","bike","bind","biology","bird","birth","bitter","black","blade","blame","blanket","blast","bleak","bless","blind","blood","blossom","blouse","blue","blur","blush","board","boat","body","boil","bomb","bone","bonus","book","boost","border","boring","borrow","boss","bottom","bounce","box","boy","bracket","brain","brand","brass","brave","bread","breeze","brick","bridge","brief","bright","bring","brisk","broccoli","broken","bronze","broom","brother","brown","brush","bubble","buddy","budget","buffalo","build","bulb","bulk","bullet","bundle","bunker","burden","burger","burst","bus","business","busy","butter","buyer","buzz","cabbage","cabin","cable","cactus","cage","cake","call","calm","camera","camp","can","canal","cancel","candy","cannon","canoe","canvas","canyon","capable","capital","captain","car","carbon","card","cargo","carpet","carry","cart","case","cash","casino","castle","casual","cat","catalog","catch","category","cattle","caught","cause","caution","cave","ceiling","celery","cement","census","century","cereal","certain","chair","chalk","champion","change","chaos","chapter","charge","chase","chat","cheap","check","cheese","chef","cherry","chest","chicken","chief","child","chimney","choice","choose","chronic","chuckle","chunk","churn","cigar","cinnamon","circle","citizen","city","civil","claim","clap","clarify","claw","clay","clean","clerk","clever","click","client","cliff","climb","clinic","clip","clock","clog","close","cloth","cloud","clown","club","clump","cluster","clutch","coach","coast","coconut","code","coffee","coil","coin","collect","color","column","combine","come","comfort","comic","common","company","concert","conduct","confirm","congress","connect","consider","control","convince","cook","cool","copper","copy","coral","core","corn","correct","cost","cotton","couch","country","couple","course","cousin","cover","coyote","crack","cradle","craft","cram","crane","crash","crater","crawl","crazy","cream","credit","creek","crew","cricket","crime","crisp","critic","crop","cross","crouch","crowd","crucial","cruel","cruise","crumble","crunch","crush","cry","crystal","cube","culture","cup","cupboard","curious","current","curtain","curve","cushion","custom","cute","cycle","dad","damage","damp","dance","danger","daring","dash","daughter","dawn","day","deal","debate","debris","decade","december","decide","decline","decorate","decrease","deer","defense","define","defy","degree","delay","deliver","demand","demise","denial","dentist","deny","depart","depend","deposit","depth","deputy","derive","describe","desert","design","desk","despair","destroy","detail","detect","develop","device","devote","diagram","dial","diamond","diary","dice","diesel","diet","differ","digital","dignity","dilemma","dinner","dinosaur","direct","dirt","disagree","discover","disease","dish","dismiss","disorder","display","distance","divert","divide","divorce","dizzy","doctor","document","dog","doll","dolphin","domain","donate","donkey","donor","door","dose","double","dove","draft","dragon","drama","drastic","draw","dream","dress","drift","drill","drink","drip","drive","drop","drum","dry","duck","dumb","dune","during","dust","dutch","duty","dwarf","dynamic","eager","eagle","early","earn","earth","easily","east","easy","echo","ecology","economy","edge","edit","educate","effort","egg","eight","either","elbow","elder","electric","elegant","element","elephant","elevator","elite","else","embark","embody","embrace","emerge","emotion","employ","empower","empty","enable","enact","end","endless","endorse","enemy","energy","enforce","engage","engine","enhance","enjoy","enlist","enough","enrich","enroll","ensure","enter","entire","entry","envelope","episode","equal","equip","era","erase","erode","erosion","error","erupt","escape","essay","essence","estate","eternal","ethics","evidence","evil","evoke","evolve","exact","example","excess","exchange","excite","exclude","excuse","execute","exercise","exhaust","exhibit","exile","exist","exit","exotic","expand","expect","expire","explain","expose","express","extend","extra","eye","eyebrow","fabric","face","faculty","fade","faint","faith","fall","false","fame","family","famous","fan","fancy","fantasy","farm","fashion","fat","fatal","father","fatigue","fault","favorite","feature","february","federal","fee","feed","feel","female","fence","festival","fetch","fever","few","fiber","fiction","field","figure","file","film","filter","final","find","fine","finger","finish","fire","firm","first","fiscal","fish","fit","fitness","fix","flag","flame","flash","flat","flavor","flee","flight","flip","float","flock","floor","flower","fluid","flush","fly","foam","focus","fog","foil","fold","follow","food","foot","force","forest","forget","fork","fortune","forum","forward","fossil","foster","found","fox","fragile","frame","frequent","fresh","friend","fringe","frog","front","frost","frown","frozen","fruit","fuel","fun","funny","furnace","fury","future","gadget","gain","galaxy","gallery","game","gap","garage","garbage","garden","garlic","garment","gas","gasp","gate","gather","gauge","gaze","general","genius","genre","gentle","genuine","gesture","ghost","giant","gift","giggle","ginger","giraffe","girl","give","glad","glance","glare","glass","glide","glimpse","globe","gloom","glory","glove","glow","glue","goat","goddess","gold","good","goose","gorilla","gospel","gossip","govern","gown","grab","grace","grain","grant","grape","grass","gravity","great","green","grid","grief","grit","grocery","group","grow","grunt","guard","guess","guide","guilt","guitar","gun","gym","habit","hair","half","hammer","hamster","hand","happy","harbor","hard","harsh","harvest","hat","have","hawk","hazard","head","health","heart","heavy","hedgehog","height","hello","helmet","help","hen","hero","hidden","high","hill","hint","hip","hire","history","hobby","hockey","hold","hole","holiday","hollow","home","honey","hood","hope","horn","horror","horse","hospital","host","hotel","hour","hover","hub","huge","human","humble","humor","hundred","hungry","hunt","hurdle","hurry","hurt","husband","hybrid","ice","icon","idea","identify","idle","ignore","ill","illegal","illness","image","imitate","immense","immune","impact","impose","improve","impulse","inch","include","income","increase","index","indicate","indoor","industry","infant","inflict","inform","inhale","inherit","initial","inject","injury","inmate","inner","innocent","input","inquiry","insane","insect","inside","inspire","install","intact","interest","into","invest","invite","involve","iron","island","isolate","issue","item","ivory","jacket","jaguar","jar","jazz","jealous","jeans","jelly","jewel","job","join","joke","journey","joy","judge","juice","jump","jungle","junior","junk","just","kangaroo","keen","keep","ketchup","key","kick","kid","kidney","kind","kingdom","kiss","kit","kitchen","kite","kitten","kiwi","knee","knife","knock","know","lab","label","labor","ladder","lady","lake","lamp","language","laptop","large","later","latin","laugh","laundry","lava","law","lawn","lawsuit","layer","lazy","leader","leaf","learn","leave","lecture","left","leg","legal","legend","leisure","lemon","lend","length","lens","leopard","lesson","letter","level","liar","liberty","library","license","life","lift","light","like","limb","limit","link","lion","liquid","list","little","live","lizard","load","loan","lobster","local","lock","logic","lonely","long","loop","lottery","loud","lounge","love","loyal","lucky","luggage","lumber","lunar","lunch","luxury","lyrics","machine","mad","magic","magnet","maid","mail","main","major","make","mammal","man","manage","mandate","mango","mansion","manual","maple","marble","march","margin","marine","market","marriage","mask","mass","master","match","material","math","matrix","matter","maximum","maze","meadow","mean","measure","meat","mechanic","medal","media","melody","melt","member","memory","mention","menu","mercy","merge","merit","merry","mesh","message","metal","method","middle","midnight","milk","million","mimic","mind","minimum","minor","minute","miracle","mirror","misery","miss","mistake","mix","mixed","mixture","mobile","model","modify","mom","moment","monitor","monkey","monster","month","moon","moral","more","morning","mosquito","mother","motion","motor","mountain","mouse","move","movie","much","muffin","mule","multiply","muscle","museum","mushroom","music","must","mutual","myself","mystery","myth","naive","name","napkin","narrow","nasty","nation","nature","near","neck","need","negative","neglect","neither","nephew","nerve","nest","net","network","neutral","never","news","next","nice","night","noble","noise","nominee","noodle","normal","north","nose","notable","note","nothing","notice","novel","now","nuclear","number","nurse","nut","oak","obey","object","oblige","obscure","observe","obtain","obvious","occur","ocean","october","odor","off","offer","office","often","oil","okay","old","olive","olympic","omit","once","one","onion","online","only","open","opera","opinion","oppose","option","orange","orbit","orchard","order","ordinary","organ","orient","original","orphan","ostrich","other","outdoor","outer","output","outside","oval","oven","over","own","owner","oxygen","oyster","ozone","pact","paddle","page","pair","palace","palm","panda","panel","panic","panther","paper","parade","parent","park","parrot","party","pass","patch","path","patient","patrol","pattern","pause","pave","payment","peace","peanut","pear","peasant","pelican","pen","penalty","pencil","people","pepper","perfect","permit","person","pet","phone","photo","phrase","physical","piano","picnic","picture","piece","pig","pigeon","pill","pilot","pink","pioneer","pipe","pistol","pitch","pizza","place","planet","plastic","plate","play","please","pledge","pluck","plug","plunge","poem","poet","point","polar","pole","police","pond","pony","pool","popular","portion","position","possible","post","potato","pottery","poverty","powder","power","practice","praise","predict","prefer","prepare","present","pretty","prevent","price","pride","primary","print","priority","prison","private","prize","problem","process","produce","profit","program","project","promote","proof","property","prosper","protect","proud","provide","public","pudding","pull","pulp","pulse","pumpkin","punch","pupil","puppy","purchase","purity","purpose","purse","push","put","puzzle","pyramid","quality","quantum","quarter","question","quick","quit","quiz","quote","rabbit","raccoon","race","rack","radar","radio","rail","rain","raise","rally","ramp","ranch","random","range","rapid","rare","rate","rather","raven","raw","razor","ready","real","reason","rebel","rebuild","recall","receive","recipe","record","recycle","reduce","reflect","reform","refuse","region","regret","regular","reject","relax","release","relief","rely","remain","remember","remind","remove","render","renew","rent","reopen","repair","repeat","replace","report","require","rescue","resemble","resist","resource","response","result","retire","retreat","return","reunion","reveal","review","reward","rhythm","rib","ribbon","rice","rich","ride","ridge","rifle","right","rigid","ring","riot","ripple","risk","ritual","rival","river","road","roast","robot","robust","rocket","romance","roof","rookie","room","rose","rotate","rough","round","route","royal","rubber","rude","rug","rule","run","runway","rural","sad","saddle","sadness","safe","sail","salad","salmon","salon","salt","salute","same","sample","sand","satisfy","satoshi","sauce","sausage","save","say","scale","scan","scare","scatter","scene","scheme","school","science","scissors","scorpion","scout","scrap","screen","script","scrub","sea","search","season","seat","second","secret","section","security","seed","seek","segment","select","sell","seminar","senior","sense","sentence","series","service","session","settle","setup","seven","shadow","shaft","shallow","share","shed","shell","sheriff","shield","shift","shine","ship","shiver","shock","shoe","shoot","shop","short","shoulder","shove","shrimp","shrug","shuffle","shy","sibling","sick","side","siege","sight","sign","silent","silk","silly","silver","similar","simple","since","sing","siren","sister","situate","six","size","skate","sketch","ski","skill","skin","skirt","skull","slab","slam","sleep","slender","slice","slide","slight","slim","slogan","slot","slow","slush","small","smart","smile","smoke","smooth","snack","snake","snap","sniff","snow","soap","soccer","social","sock","soda","soft","solar","soldier","solid","solution","solve","someone","song","soon","sorry","sort","soul","sound","soup","source","south","space","spare","spatial","spawn","speak","special","speed","spell","spend","sphere","spice","spider","spike","spin","spirit","split","spoil","sponsor","spoon","sport","spot","spray","spread","spring","spy","square","squeeze","squirrel","stable","stadium","staff","stage","stairs","stamp","stand","start","state","stay","steak","steel","stem","step","stereo","stick","still","sting","stock","stomach","stone","stool","story","stove","strategy","street","strike","strong","struggle","student","stuff","stumble","style","subject","submit","subway","success","such","sudden","suffer","sugar","suggest","suit","summer","sun","sunny","sunset","super","supply","supreme","sure","surface","surge","surprise","surround","survey","suspect","sustain","swallow","swamp","swap","swarm","swear","sweet","swift","swim","swing","switch","sword","symbol","symptom","syrup","system","table","tackle","tag","tail","talent","talk","tank","tape","target","task","taste","tattoo","taxi","teach","team","tell","ten","tenant","tennis","tent","term","test","text","thank","that","theme","then","theory","there","they","thing","this","thought","three","thrive","throw","thumb","thunder","ticket","tide","tiger","tilt","timber","time","tiny","tip","tired","tissue","title","toast","tobacco","today","toddler","toe","together","toilet","token","tomato","tomorrow","tone","tongue","tonight","tool","tooth","top","topic","topple","torch","tornado","tortoise","toss","total","tourist","toward","tower","town","toy","track","trade","traffic","tragic","train","transfer","trap","trash","travel","tray","treat","tree","trend","trial","tribe","trick","trigger","trim","trip","trophy","trouble","truck","true","truly","trumpet","trust","truth","try","tube","tuition","tumble","tuna","tunnel","turkey","turn","turtle","twelve","twenty","twice","twin","twist","two","type","typical","ugly","umbrella","unable","unaware","uncle","uncover","under","undo","unfair","unfold","unhappy","uniform","unique","unit","universe","unknown","unlock","until","unusual","unveil","update","upgrade","uphold","upon","upper","upset","urban","urge","usage","use","used","useful","useless","usual","utility","vacant","vacuum","vague","valid","valley","valve","van","vanish","vapor","various","vast","vault","vehicle","velvet","vendor","venture","venue","verb","verify","version","very","vessel","veteran","viable","vibrant","vicious","victory","video","view","village","vintage","violin","virtual","virus","visa","visit","visual","vital","vivid","vocal","voice","void","volcano","volume","vote","voyage","wage","wagon","wait","walk","wall","walnut","want","warfare","warm","warrior","wash","wasp","waste","water","wave","way","wealth","weapon","wear","weasel","weather","web","wedding","weekend","weird","welcome","west","wet","whale","what","wheat","wheel","when","where","whip","whisper","wide","width","wife","wild","will","win","window","wine","wing","wink","winner","winter","wire","wisdom","wise","wish","witness","wolf","woman","wonder","wood","wool","word","work","world","worry","worth","wrap","wreck","wrestle","wrist","write","wrong","yard","year","yellow","you","young","youth","zebra","zero","zone","zoo"];Nr.space=" ";const Mr=["あいこくしん","あいさつ","あいだ","あおぞら","あかちゃん","あきる","あけがた","あける","あこがれる","あさい","あさひ","あしあと","あじわう","あずかる","あずき","あそぶ","あたえる","あたためる","あたりまえ","あたる","あつい","あつかう","あっしゅく","あつまり","あつめる","あてな","あてはまる","あひる","あぶら","あぶる","あふれる","あまい","あまど","あまやかす","あまり","あみもの","あめりか","あやまる","あゆむ","あらいぐま","あらし","あらすじ","あらためる","あらゆる","あらわす","ありがとう","あわせる","あわてる","あんい","あんがい","あんこ","あんぜん","あんてい","あんない","あんまり","いいだす","いおん","いがい","いがく","いきおい","いきなり","いきもの","いきる","いくじ","いくぶん","いけばな","いけん","いこう","いこく","いこつ","いさましい","いさん","いしき","いじゅう","いじょう","いじわる","いずみ","いずれ","いせい","いせえび","いせかい","いせき","いぜん","いそうろう","いそがしい","いだい","いだく","いたずら","いたみ","いたりあ","いちおう","いちじ","いちど","いちば","いちぶ","いちりゅう","いつか","いっしゅん","いっせい","いっそう","いったん","いっち","いってい","いっぽう","いてざ","いてん","いどう","いとこ","いない","いなか","いねむり","いのち","いのる","いはつ","いばる","いはん","いびき","いひん","いふく","いへん","いほう","いみん","いもうと","いもたれ","いもり","いやがる","いやす","いよかん","いよく","いらい","いらすと","いりぐち","いりょう","いれい","いれもの","いれる","いろえんぴつ","いわい","いわう","いわかん","いわば","いわゆる","いんげんまめ","いんさつ","いんしょう","いんよう","うえき","うえる","うおざ","うがい","うかぶ","うかべる","うきわ","うくらいな","うくれれ","うけたまわる","うけつけ","うけとる","うけもつ","うける","うごかす","うごく","うこん","うさぎ","うしなう","うしろがみ","うすい","うすぎ","うすぐらい","うすめる","うせつ","うちあわせ","うちがわ","うちき","うちゅう","うっかり","うつくしい","うったえる","うつる","うどん","うなぎ","うなじ","うなずく","うなる","うねる","うのう","うぶげ","うぶごえ","うまれる","うめる","うもう","うやまう","うよく","うらがえす","うらぐち","うらない","うりあげ","うりきれ","うるさい","うれしい","うれゆき","うれる","うろこ","うわき","うわさ","うんこう","うんちん","うんてん","うんどう","えいえん","えいが","えいきょう","えいご","えいせい","えいぶん","えいよう","えいわ","えおり","えがお","えがく","えきたい","えくせる","えしゃく","えすて","えつらん","えのぐ","えほうまき","えほん","えまき","えもじ","えもの","えらい","えらぶ","えりあ","えんえん","えんかい","えんぎ","えんげき","えんしゅう","えんぜつ","えんそく","えんちょう","えんとつ","おいかける","おいこす","おいしい","おいつく","おうえん","おうさま","おうじ","おうせつ","おうたい","おうふく","おうべい","おうよう","おえる","おおい","おおう","おおどおり","おおや","おおよそ","おかえり","おかず","おがむ","おかわり","おぎなう","おきる","おくさま","おくじょう","おくりがな","おくる","おくれる","おこす","おこなう","おこる","おさえる","おさない","おさめる","おしいれ","おしえる","おじぎ","おじさん","おしゃれ","おそらく","おそわる","おたがい","おたく","おだやか","おちつく","おっと","おつり","おでかけ","おとしもの","おとなしい","おどり","おどろかす","おばさん","おまいり","おめでとう","おもいで","おもう","おもたい","おもちゃ","おやつ","おやゆび","およぼす","おらんだ","おろす","おんがく","おんけい","おんしゃ","おんせん","おんだん","おんちゅう","おんどけい","かあつ","かいが","がいき","がいけん","がいこう","かいさつ","かいしゃ","かいすいよく","かいぜん","かいぞうど","かいつう","かいてん","かいとう","かいふく","がいへき","かいほう","かいよう","がいらい","かいわ","かえる","かおり","かかえる","かがく","かがし","かがみ","かくご","かくとく","かざる","がぞう","かたい","かたち","がちょう","がっきゅう","がっこう","がっさん","がっしょう","かなざわし","かのう","がはく","かぶか","かほう","かほご","かまう","かまぼこ","かめれおん","かゆい","かようび","からい","かるい","かろう","かわく","かわら","がんか","かんけい","かんこう","かんしゃ","かんそう","かんたん","かんち","がんばる","きあい","きあつ","きいろ","ぎいん","きうい","きうん","きえる","きおう","きおく","きおち","きおん","きかい","きかく","きかんしゃ","ききて","きくばり","きくらげ","きけんせい","きこう","きこえる","きこく","きさい","きさく","きさま","きさらぎ","ぎじかがく","ぎしき","ぎじたいけん","ぎじにってい","ぎじゅつしゃ","きすう","きせい","きせき","きせつ","きそう","きぞく","きぞん","きたえる","きちょう","きつえん","ぎっちり","きつつき","きつね","きてい","きどう","きどく","きない","きなが","きなこ","きぬごし","きねん","きのう","きのした","きはく","きびしい","きひん","きふく","きぶん","きぼう","きほん","きまる","きみつ","きむずかしい","きめる","きもだめし","きもち","きもの","きゃく","きやく","ぎゅうにく","きよう","きょうりゅう","きらい","きらく","きりん","きれい","きれつ","きろく","ぎろん","きわめる","ぎんいろ","きんかくじ","きんじょ","きんようび","ぐあい","くいず","くうかん","くうき","くうぐん","くうこう","ぐうせい","くうそう","ぐうたら","くうふく","くうぼ","くかん","くきょう","くげん","ぐこう","くさい","くさき","くさばな","くさる","くしゃみ","くしょう","くすのき","くすりゆび","くせげ","くせん","ぐたいてき","くださる","くたびれる","くちこみ","くちさき","くつした","ぐっすり","くつろぐ","くとうてん","くどく","くなん","くねくね","くのう","くふう","くみあわせ","くみたてる","くめる","くやくしょ","くらす","くらべる","くるま","くれる","くろう","くわしい","ぐんかん","ぐんしょく","ぐんたい","ぐんて","けあな","けいかく","けいけん","けいこ","けいさつ","げいじゅつ","けいたい","げいのうじん","けいれき","けいろ","けおとす","けおりもの","げきか","げきげん","げきだん","げきちん","げきとつ","げきは","げきやく","げこう","げこくじょう","げざい","けさき","げざん","けしき","けしごむ","けしょう","げすと","けたば","けちゃっぷ","けちらす","けつあつ","けつい","けつえき","けっこん","けつじょ","けっせき","けってい","けつまつ","げつようび","げつれい","けつろん","げどく","けとばす","けとる","けなげ","けなす","けなみ","けぬき","げねつ","けねん","けはい","げひん","けぶかい","げぼく","けまり","けみかる","けむし","けむり","けもの","けらい","けろけろ","けわしい","けんい","けんえつ","けんお","けんか","げんき","けんげん","けんこう","けんさく","けんしゅう","けんすう","げんそう","けんちく","けんてい","けんとう","けんない","けんにん","げんぶつ","けんま","けんみん","けんめい","けんらん","けんり","こあくま","こいぬ","こいびと","ごうい","こうえん","こうおん","こうかん","ごうきゅう","ごうけい","こうこう","こうさい","こうじ","こうすい","ごうせい","こうそく","こうたい","こうちゃ","こうつう","こうてい","こうどう","こうない","こうはい","ごうほう","ごうまん","こうもく","こうりつ","こえる","こおり","ごかい","ごがつ","ごかん","こくご","こくさい","こくとう","こくない","こくはく","こぐま","こけい","こける","ここのか","こころ","こさめ","こしつ","こすう","こせい","こせき","こぜん","こそだて","こたい","こたえる","こたつ","こちょう","こっか","こつこつ","こつばん","こつぶ","こてい","こてん","ことがら","ことし","ことば","ことり","こなごな","こねこね","このまま","このみ","このよ","ごはん","こひつじ","こふう","こふん","こぼれる","ごまあぶら","こまかい","ごますり","こまつな","こまる","こむぎこ","こもじ","こもち","こもの","こもん","こやく","こやま","こゆう","こゆび","こよい","こよう","こりる","これくしょん","ころっけ","こわもて","こわれる","こんいん","こんかい","こんき","こんしゅう","こんすい","こんだて","こんとん","こんなん","こんびに","こんぽん","こんまけ","こんや","こんれい","こんわく","ざいえき","さいかい","さいきん","ざいげん","ざいこ","さいしょ","さいせい","ざいたく","ざいちゅう","さいてき","ざいりょう","さうな","さかいし","さがす","さかな","さかみち","さがる","さぎょう","さくし","さくひん","さくら","さこく","さこつ","さずかる","ざせき","さたん","さつえい","ざつおん","ざっか","ざつがく","さっきょく","ざっし","さつじん","ざっそう","さつたば","さつまいも","さてい","さといも","さとう","さとおや","さとし","さとる","さのう","さばく","さびしい","さべつ","さほう","さほど","さます","さみしい","さみだれ","さむけ","さめる","さやえんどう","さゆう","さよう","さよく","さらだ","ざるそば","さわやか","さわる","さんいん","さんか","さんきゃく","さんこう","さんさい","ざんしょ","さんすう","さんせい","さんそ","さんち","さんま","さんみ","さんらん","しあい","しあげ","しあさって","しあわせ","しいく","しいん","しうち","しえい","しおけ","しかい","しかく","じかん","しごと","しすう","じだい","したうけ","したぎ","したて","したみ","しちょう","しちりん","しっかり","しつじ","しつもん","してい","してき","してつ","じてん","じどう","しなぎれ","しなもの","しなん","しねま","しねん","しのぐ","しのぶ","しはい","しばかり","しはつ","しはらい","しはん","しひょう","しふく","じぶん","しへい","しほう","しほん","しまう","しまる","しみん","しむける","じむしょ","しめい","しめる","しもん","しゃいん","しゃうん","しゃおん","じゃがいも","しやくしょ","しゃくほう","しゃけん","しゃこ","しゃざい","しゃしん","しゃせん","しゃそう","しゃたい","しゃちょう","しゃっきん","じゃま","しゃりん","しゃれい","じゆう","じゅうしょ","しゅくはく","じゅしん","しゅっせき","しゅみ","しゅらば","じゅんばん","しょうかい","しょくたく","しょっけん","しょどう","しょもつ","しらせる","しらべる","しんか","しんこう","じんじゃ","しんせいじ","しんちく","しんりん","すあげ","すあし","すあな","ずあん","すいえい","すいか","すいとう","ずいぶん","すいようび","すうがく","すうじつ","すうせん","すおどり","すきま","すくう","すくない","すける","すごい","すこし","ずさん","すずしい","すすむ","すすめる","すっかり","ずっしり","ずっと","すてき","すてる","すねる","すのこ","すはだ","すばらしい","ずひょう","ずぶぬれ","すぶり","すふれ","すべて","すべる","ずほう","すぼん","すまい","すめし","すもう","すやき","すらすら","するめ","すれちがう","すろっと","すわる","すんぜん","すんぽう","せあぶら","せいかつ","せいげん","せいじ","せいよう","せおう","せかいかん","せきにん","せきむ","せきゆ","せきらんうん","せけん","せこう","せすじ","せたい","せたけ","せっかく","せっきゃく","ぜっく","せっけん","せっこつ","せっさたくま","せつぞく","せつだん","せつでん","せっぱん","せつび","せつぶん","せつめい","せつりつ","せなか","せのび","せはば","せびろ","せぼね","せまい","せまる","せめる","せもたれ","せりふ","ぜんあく","せんい","せんえい","せんか","せんきょ","せんく","せんげん","ぜんご","せんさい","せんしゅ","せんすい","せんせい","せんぞ","せんたく","せんちょう","せんてい","せんとう","せんぬき","せんねん","せんぱい","ぜんぶ","ぜんぽう","せんむ","せんめんじょ","せんもん","せんやく","せんゆう","せんよう","ぜんら","ぜんりゃく","せんれい","せんろ","そあく","そいとげる","そいね","そうがんきょう","そうき","そうご","そうしん","そうだん","そうなん","そうび","そうめん","そうり","そえもの","そえん","そがい","そげき","そこう","そこそこ","そざい","そしな","そせい","そせん","そそぐ","そだてる","そつう","そつえん","そっかん","そつぎょう","そっけつ","そっこう","そっせん","そっと","そとがわ","そとづら","そなえる","そなた","そふぼ","そぼく","そぼろ","そまつ","そまる","そむく","そむりえ","そめる","そもそも","そよかぜ","そらまめ","そろう","そんかい","そんけい","そんざい","そんしつ","そんぞく","そんちょう","ぞんび","ぞんぶん","そんみん","たあい","たいいん","たいうん","たいえき","たいおう","だいがく","たいき","たいぐう","たいけん","たいこ","たいざい","だいじょうぶ","だいすき","たいせつ","たいそう","だいたい","たいちょう","たいてい","だいどころ","たいない","たいねつ","たいのう","たいはん","だいひょう","たいふう","たいへん","たいほ","たいまつばな","たいみんぐ","たいむ","たいめん","たいやき","たいよう","たいら","たいりょく","たいる","たいわん","たうえ","たえる","たおす","たおる","たおれる","たかい","たかね","たきび","たくさん","たこく","たこやき","たさい","たしざん","だじゃれ","たすける","たずさわる","たそがれ","たたかう","たたく","ただしい","たたみ","たちばな","だっかい","だっきゃく","だっこ","だっしゅつ","だったい","たてる","たとえる","たなばた","たにん","たぬき","たのしみ","たはつ","たぶん","たべる","たぼう","たまご","たまる","だむる","ためいき","ためす","ためる","たもつ","たやすい","たよる","たらす","たりきほんがん","たりょう","たりる","たると","たれる","たれんと","たろっと","たわむれる","だんあつ","たんい","たんおん","たんか","たんき","たんけん","たんご","たんさん","たんじょうび","だんせい","たんそく","たんたい","だんち","たんてい","たんとう","だんな","たんにん","だんねつ","たんのう","たんぴん","だんぼう","たんまつ","たんめい","だんれつ","だんろ","だんわ","ちあい","ちあん","ちいき","ちいさい","ちえん","ちかい","ちから","ちきゅう","ちきん","ちけいず","ちけん","ちこく","ちさい","ちしき","ちしりょう","ちせい","ちそう","ちたい","ちたん","ちちおや","ちつじょ","ちてき","ちてん","ちぬき","ちぬり","ちのう","ちひょう","ちへいせん","ちほう","ちまた","ちみつ","ちみどろ","ちめいど","ちゃんこなべ","ちゅうい","ちゆりょく","ちょうし","ちょさくけん","ちらし","ちらみ","ちりがみ","ちりょう","ちるど","ちわわ","ちんたい","ちんもく","ついか","ついたち","つうか","つうじょう","つうはん","つうわ","つかう","つかれる","つくね","つくる","つけね","つける","つごう","つたえる","つづく","つつじ","つつむ","つとめる","つながる","つなみ","つねづね","つのる","つぶす","つまらない","つまる","つみき","つめたい","つもり","つもる","つよい","つるぼ","つるみく","つわもの","つわり","てあし","てあて","てあみ","ていおん","ていか","ていき","ていけい","ていこく","ていさつ","ていし","ていせい","ていたい","ていど","ていねい","ていひょう","ていへん","ていぼう","てうち","ておくれ","てきとう","てくび","でこぼこ","てさぎょう","てさげ","てすり","てそう","てちがい","てちょう","てつがく","てつづき","でっぱ","てつぼう","てつや","でぬかえ","てぬき","てぬぐい","てのひら","てはい","てぶくろ","てふだ","てほどき","てほん","てまえ","てまきずし","てみじか","てみやげ","てらす","てれび","てわけ","てわたし","でんあつ","てんいん","てんかい","てんき","てんぐ","てんけん","てんごく","てんさい","てんし","てんすう","でんち","てんてき","てんとう","てんない","てんぷら","てんぼうだい","てんめつ","てんらんかい","でんりょく","でんわ","どあい","といれ","どうかん","とうきゅう","どうぐ","とうし","とうむぎ","とおい","とおか","とおく","とおす","とおる","とかい","とかす","ときおり","ときどき","とくい","とくしゅう","とくてん","とくに","とくべつ","とけい","とける","とこや","とさか","としょかん","とそう","とたん","とちゅう","とっきゅう","とっくん","とつぜん","とつにゅう","とどける","ととのえる","とない","となえる","となり","とのさま","とばす","どぶがわ","とほう","とまる","とめる","ともだち","ともる","どようび","とらえる","とんかつ","どんぶり","ないかく","ないこう","ないしょ","ないす","ないせん","ないそう","なおす","ながい","なくす","なげる","なこうど","なさけ","なたでここ","なっとう","なつやすみ","ななおし","なにごと","なにもの","なにわ","なのか","なふだ","なまいき","なまえ","なまみ","なみだ","なめらか","なめる","なやむ","ならう","ならび","ならぶ","なれる","なわとび","なわばり","にあう","にいがた","にうけ","におい","にかい","にがて","にきび","にくしみ","にくまん","にげる","にさんかたんそ","にしき","にせもの","にちじょう","にちようび","にっか","にっき","にっけい","にっこう","にっさん","にっしょく","にっすう","にっせき","にってい","になう","にほん","にまめ","にもつ","にやり","にゅういん","にりんしゃ","にわとり","にんい","にんか","にんき","にんげん","にんしき","にんずう","にんそう","にんたい","にんち","にんてい","にんにく","にんぷ","にんまり","にんむ","にんめい","にんよう","ぬいくぎ","ぬかす","ぬぐいとる","ぬぐう","ぬくもり","ぬすむ","ぬまえび","ぬめり","ぬらす","ぬんちゃく","ねあげ","ねいき","ねいる","ねいろ","ねぐせ","ねくたい","ねくら","ねこぜ","ねこむ","ねさげ","ねすごす","ねそべる","ねだん","ねつい","ねっしん","ねつぞう","ねったいぎょ","ねぶそく","ねふだ","ねぼう","ねほりはほり","ねまき","ねまわし","ねみみ","ねむい","ねむたい","ねもと","ねらう","ねわざ","ねんいり","ねんおし","ねんかん","ねんきん","ねんぐ","ねんざ","ねんし","ねんちゃく","ねんど","ねんぴ","ねんぶつ","ねんまつ","ねんりょう","ねんれい","のいず","のおづま","のがす","のきなみ","のこぎり","のこす","のこる","のせる","のぞく","のぞむ","のたまう","のちほど","のっく","のばす","のはら","のべる","のぼる","のみもの","のやま","のらいぬ","のらねこ","のりもの","のりゆき","のれん","のんき","ばあい","はあく","ばあさん","ばいか","ばいく","はいけん","はいご","はいしん","はいすい","はいせん","はいそう","はいち","ばいばい","はいれつ","はえる","はおる","はかい","ばかり","はかる","はくしゅ","はけん","はこぶ","はさみ","はさん","はしご","ばしょ","はしる","はせる","ぱそこん","はそん","はたん","はちみつ","はつおん","はっかく","はづき","はっきり","はっくつ","はっけん","はっこう","はっさん","はっしん","はったつ","はっちゅう","はってん","はっぴょう","はっぽう","はなす","はなび","はにかむ","はぶらし","はみがき","はむかう","はめつ","はやい","はやし","はらう","はろうぃん","はわい","はんい","はんえい","はんおん","はんかく","はんきょう","ばんぐみ","はんこ","はんしゃ","はんすう","はんだん","ぱんち","ぱんつ","はんてい","はんとし","はんのう","はんぱ","はんぶん","はんぺん","はんぼうき","はんめい","はんらん","はんろん","ひいき","ひうん","ひえる","ひかく","ひかり","ひかる","ひかん","ひくい","ひけつ","ひこうき","ひこく","ひさい","ひさしぶり","ひさん","びじゅつかん","ひしょ","ひそか","ひそむ","ひたむき","ひだり","ひたる","ひつぎ","ひっこし","ひっし","ひつじゅひん","ひっす","ひつぜん","ぴったり","ぴっちり","ひつよう","ひてい","ひとごみ","ひなまつり","ひなん","ひねる","ひはん","ひびく","ひひょう","ひほう","ひまわり","ひまん","ひみつ","ひめい","ひめじし","ひやけ","ひやす","ひよう","びょうき","ひらがな","ひらく","ひりつ","ひりょう","ひるま","ひるやすみ","ひれい","ひろい","ひろう","ひろき","ひろゆき","ひんかく","ひんけつ","ひんこん","ひんしゅ","ひんそう","ぴんち","ひんぱん","びんぼう","ふあん","ふいうち","ふうけい","ふうせん","ぷうたろう","ふうとう","ふうふ","ふえる","ふおん","ふかい","ふきん","ふくざつ","ふくぶくろ","ふこう","ふさい","ふしぎ","ふじみ","ふすま","ふせい","ふせぐ","ふそく","ぶたにく","ふたん","ふちょう","ふつう","ふつか","ふっかつ","ふっき","ふっこく","ぶどう","ふとる","ふとん","ふのう","ふはい","ふひょう","ふへん","ふまん","ふみん","ふめつ","ふめん","ふよう","ふりこ","ふりる","ふるい","ふんいき","ぶんがく","ぶんぐ","ふんしつ","ぶんせき","ふんそう","ぶんぽう","へいあん","へいおん","へいがい","へいき","へいげん","へいこう","へいさ","へいしゃ","へいせつ","へいそ","へいたく","へいてん","へいねつ","へいわ","へきが","へこむ","べにいろ","べにしょうが","へらす","へんかん","べんきょう","べんごし","へんさい","へんたい","べんり","ほあん","ほいく","ぼうぎょ","ほうこく","ほうそう","ほうほう","ほうもん","ほうりつ","ほえる","ほおん","ほかん","ほきょう","ぼきん","ほくろ","ほけつ","ほけん","ほこう","ほこる","ほしい","ほしつ","ほしゅ","ほしょう","ほせい","ほそい","ほそく","ほたて","ほたる","ぽちぶくろ","ほっきょく","ほっさ","ほったん","ほとんど","ほめる","ほんい","ほんき","ほんけ","ほんしつ","ほんやく","まいにち","まかい","まかせる","まがる","まける","まこと","まさつ","まじめ","ますく","まぜる","まつり","まとめ","まなぶ","まぬけ","まねく","まほう","まもる","まゆげ","まよう","まろやか","まわす","まわり","まわる","まんが","まんきつ","まんぞく","まんなか","みいら","みうち","みえる","みがく","みかた","みかん","みけん","みこん","みじかい","みすい","みすえる","みせる","みっか","みつかる","みつける","みてい","みとめる","みなと","みなみかさい","みねらる","みのう","みのがす","みほん","みもと","みやげ","みらい","みりょく","みわく","みんか","みんぞく","むいか","むえき","むえん","むかい","むかう","むかえ","むかし","むぎちゃ","むける","むげん","むさぼる","むしあつい","むしば","むじゅん","むしろ","むすう","むすこ","むすぶ","むすめ","むせる","むせん","むちゅう","むなしい","むのう","むやみ","むよう","むらさき","むりょう","むろん","めいあん","めいうん","めいえん","めいかく","めいきょく","めいさい","めいし","めいそう","めいぶつ","めいれい","めいわく","めぐまれる","めざす","めした","めずらしい","めだつ","めまい","めやす","めんきょ","めんせき","めんどう","もうしあげる","もうどうけん","もえる","もくし","もくてき","もくようび","もちろん","もどる","もらう","もんく","もんだい","やおや","やける","やさい","やさしい","やすい","やすたろう","やすみ","やせる","やそう","やたい","やちん","やっと","やっぱり","やぶる","やめる","ややこしい","やよい","やわらかい","ゆうき","ゆうびんきょく","ゆうべ","ゆうめい","ゆけつ","ゆしゅつ","ゆせん","ゆそう","ゆたか","ゆちゃく","ゆでる","ゆにゅう","ゆびわ","ゆらい","ゆれる","ようい","ようか","ようきゅう","ようじ","ようす","ようちえん","よかぜ","よかん","よきん","よくせい","よくぼう","よけい","よごれる","よさん","よしゅう","よそう","よそく","よっか","よてい","よどがわく","よねつ","よやく","よゆう","よろこぶ","よろしい","らいう","らくがき","らくご","らくさつ","らくだ","らしんばん","らせん","らぞく","らたい","らっか","られつ","りえき","りかい","りきさく","りきせつ","りくぐん","りくつ","りけん","りこう","りせい","りそう","りそく","りてん","りねん","りゆう","りゅうがく","りよう","りょうり","りょかん","りょくちゃ","りょこう","りりく","りれき","りろん","りんご","るいけい","るいさい","るいじ","るいせき","るすばん","るりがわら","れいかん","れいぎ","れいせい","れいぞうこ","れいとう","れいぼう","れきし","れきだい","れんあい","れんけい","れんこん","れんさい","れんしゅう","れんぞく","れんらく","ろうか","ろうご","ろうじん","ろうそく","ろくが","ろこつ","ろじうら","ろしゅつ","ろせん","ろてん","ろめん","ろれつ","ろんぎ","ろんぱ","ろんぶん","ろんり","わかす","わかめ","わかやま","わかれる","わしつ","わじまし","わすれもの","わらう","われる"];Mr.space=" ";const Tr=["ábaco","abdomen","abeja","abierto","abogado","abono","aborto","abrazo","abrir","abuelo","abuso","acabar","academia","acceso","acción","aceite","acelga","acento","aceptar","ácido","aclarar","acné","acoger","acoso","activo","acto","actriz","actuar","acudir","acuerdo","acusar","adicto","admitir","adoptar","adorno","aduana","adulto","aéreo","afectar","afición","afinar","afirmar","ágil","agitar","agonía","agosto","agotar","agregar","agrio","agua","agudo","águila","aguja","ahogo","ahorro","aire","aislar","ajedrez","ajeno","ajuste","alacrán","alambre","alarma","alba","álbum","alcalde","aldea","alegre","alejar","alerta","aleta","alfiler","alga","algodón","aliado","aliento","alivio","alma","almeja","almíbar","altar","alteza","altivo","alto","altura","alumno","alzar","amable","amante","amapola","amargo","amasar","ámbar","ámbito","ameno","amigo","amistad","amor","amparo","amplio","ancho","anciano","ancla","andar","andén","anemia","ángulo","anillo","ánimo","anís","anotar","antena","antiguo","antojo","anual","anular","anuncio","añadir","añejo","año","apagar","aparato","apetito","apio","aplicar","apodo","aporte","apoyo","aprender","aprobar","apuesta","apuro","arado","araña","arar","árbitro","árbol","arbusto","archivo","arco","arder","ardilla","arduo","área","árido","aries","armonía","arnés","aroma","arpa","arpón","arreglo","arroz","arruga","arte","artista","asa","asado","asalto","ascenso","asegurar","aseo","asesor","asiento","asilo","asistir","asno","asombro","áspero","astilla","astro","astuto","asumir","asunto","atajo","ataque","atar","atento","ateo","ático","atleta","átomo","atraer","atroz","atún","audaz","audio","auge","aula","aumento","ausente","autor","aval","avance","avaro","ave","avellana","avena","avestruz","avión","aviso","ayer","ayuda","ayuno","azafrán","azar","azote","azúcar","azufre","azul","baba","babor","bache","bahía","baile","bajar","balanza","balcón","balde","bambú","banco","banda","baño","barba","barco","barniz","barro","báscula","bastón","basura","batalla","batería","batir","batuta","baúl","bazar","bebé","bebida","bello","besar","beso","bestia","bicho","bien","bingo","blanco","bloque","blusa","boa","bobina","bobo","boca","bocina","boda","bodega","boina","bola","bolero","bolsa","bomba","bondad","bonito","bono","bonsái","borde","borrar","bosque","bote","botín","bóveda","bozal","bravo","brazo","brecha","breve","brillo","brinco","brisa","broca","broma","bronce","brote","bruja","brusco","bruto","buceo","bucle","bueno","buey","bufanda","bufón","búho","buitre","bulto","burbuja","burla","burro","buscar","butaca","buzón","caballo","cabeza","cabina","cabra","cacao","cadáver","cadena","caer","café","caída","caimán","caja","cajón","cal","calamar","calcio","caldo","calidad","calle","calma","calor","calvo","cama","cambio","camello","camino","campo","cáncer","candil","canela","canguro","canica","canto","caña","cañón","caoba","caos","capaz","capitán","capote","captar","capucha","cara","carbón","cárcel","careta","carga","cariño","carne","carpeta","carro","carta","casa","casco","casero","caspa","castor","catorce","catre","caudal","causa","cazo","cebolla","ceder","cedro","celda","célebre","celoso","célula","cemento","ceniza","centro","cerca","cerdo","cereza","cero","cerrar","certeza","césped","cetro","chacal","chaleco","champú","chancla","chapa","charla","chico","chiste","chivo","choque","choza","chuleta","chupar","ciclón","ciego","cielo","cien","cierto","cifra","cigarro","cima","cinco","cine","cinta","ciprés","circo","ciruela","cisne","cita","ciudad","clamor","clan","claro","clase","clave","cliente","clima","clínica","cobre","cocción","cochino","cocina","coco","código","codo","cofre","coger","cohete","cojín","cojo","cola","colcha","colegio","colgar","colina","collar","colmo","columna","combate","comer","comida","cómodo","compra","conde","conejo","conga","conocer","consejo","contar","copa","copia","corazón","corbata","corcho","cordón","corona","correr","coser","cosmos","costa","cráneo","cráter","crear","crecer","creído","crema","cría","crimen","cripta","crisis","cromo","crónica","croqueta","crudo","cruz","cuadro","cuarto","cuatro","cubo","cubrir","cuchara","cuello","cuento","cuerda","cuesta","cueva","cuidar","culebra","culpa","culto","cumbre","cumplir","cuna","cuneta","cuota","cupón","cúpula","curar","curioso","curso","curva","cutis","dama","danza","dar","dardo","dátil","deber","débil","década","decir","dedo","defensa","definir","dejar","delfín","delgado","delito","demora","denso","dental","deporte","derecho","derrota","desayuno","deseo","desfile","desnudo","destino","desvío","detalle","detener","deuda","día","diablo","diadema","diamante","diana","diario","dibujo","dictar","diente","dieta","diez","difícil","digno","dilema","diluir","dinero","directo","dirigir","disco","diseño","disfraz","diva","divino","doble","doce","dolor","domingo","don","donar","dorado","dormir","dorso","dos","dosis","dragón","droga","ducha","duda","duelo","dueño","dulce","dúo","duque","durar","dureza","duro","ébano","ebrio","echar","eco","ecuador","edad","edición","edificio","editor","educar","efecto","eficaz","eje","ejemplo","elefante","elegir","elemento","elevar","elipse","élite","elixir","elogio","eludir","embudo","emitir","emoción","empate","empeño","empleo","empresa","enano","encargo","enchufe","encía","enemigo","enero","enfado","enfermo","engaño","enigma","enlace","enorme","enredo","ensayo","enseñar","entero","entrar","envase","envío","época","equipo","erizo","escala","escena","escolar","escribir","escudo","esencia","esfera","esfuerzo","espada","espejo","espía","esposa","espuma","esquí","estar","este","estilo","estufa","etapa","eterno","ética","etnia","evadir","evaluar","evento","evitar","exacto","examen","exceso","excusa","exento","exigir","exilio","existir","éxito","experto","explicar","exponer","extremo","fábrica","fábula","fachada","fácil","factor","faena","faja","falda","fallo","falso","faltar","fama","familia","famoso","faraón","farmacia","farol","farsa","fase","fatiga","fauna","favor","fax","febrero","fecha","feliz","feo","feria","feroz","fértil","fervor","festín","fiable","fianza","fiar","fibra","ficción","ficha","fideo","fiebre","fiel","fiera","fiesta","figura","fijar","fijo","fila","filete","filial","filtro","fin","finca","fingir","finito","firma","flaco","flauta","flecha","flor","flota","fluir","flujo","flúor","fobia","foca","fogata","fogón","folio","folleto","fondo","forma","forro","fortuna","forzar","fosa","foto","fracaso","frágil","franja","frase","fraude","freír","freno","fresa","frío","frito","fruta","fuego","fuente","fuerza","fuga","fumar","función","funda","furgón","furia","fusil","fútbol","futuro","gacela","gafas","gaita","gajo","gala","galería","gallo","gamba","ganar","gancho","ganga","ganso","garaje","garza","gasolina","gastar","gato","gavilán","gemelo","gemir","gen","género","genio","gente","geranio","gerente","germen","gesto","gigante","gimnasio","girar","giro","glaciar","globo","gloria","gol","golfo","goloso","golpe","goma","gordo","gorila","gorra","gota","goteo","gozar","grada","gráfico","grano","grasa","gratis","grave","grieta","grillo","gripe","gris","grito","grosor","grúa","grueso","grumo","grupo","guante","guapo","guardia","guerra","guía","guiño","guion","guiso","guitarra","gusano","gustar","haber","hábil","hablar","hacer","hacha","hada","hallar","hamaca","harina","haz","hazaña","hebilla","hebra","hecho","helado","helio","hembra","herir","hermano","héroe","hervir","hielo","hierro","hígado","higiene","hijo","himno","historia","hocico","hogar","hoguera","hoja","hombre","hongo","honor","honra","hora","hormiga","horno","hostil","hoyo","hueco","huelga","huerta","hueso","huevo","huida","huir","humano","húmedo","humilde","humo","hundir","huracán","hurto","icono","ideal","idioma","ídolo","iglesia","iglú","igual","ilegal","ilusión","imagen","imán","imitar","impar","imperio","imponer","impulso","incapaz","índice","inerte","infiel","informe","ingenio","inicio","inmenso","inmune","innato","insecto","instante","interés","íntimo","intuir","inútil","invierno","ira","iris","ironía","isla","islote","jabalí","jabón","jamón","jarabe","jardín","jarra","jaula","jazmín","jefe","jeringa","jinete","jornada","joroba","joven","joya","juerga","jueves","juez","jugador","jugo","juguete","juicio","junco","jungla","junio","juntar","júpiter","jurar","justo","juvenil","juzgar","kilo","koala","labio","lacio","lacra","lado","ladrón","lagarto","lágrima","laguna","laico","lamer","lámina","lámpara","lana","lancha","langosta","lanza","lápiz","largo","larva","lástima","lata","látex","latir","laurel","lavar","lazo","leal","lección","leche","lector","leer","legión","legumbre","lejano","lengua","lento","leña","león","leopardo","lesión","letal","letra","leve","leyenda","libertad","libro","licor","líder","lidiar","lienzo","liga","ligero","lima","límite","limón","limpio","lince","lindo","línea","lingote","lino","linterna","líquido","liso","lista","litera","litio","litro","llaga","llama","llanto","llave","llegar","llenar","llevar","llorar","llover","lluvia","lobo","loción","loco","locura","lógica","logro","lombriz","lomo","lonja","lote","lucha","lucir","lugar","lujo","luna","lunes","lupa","lustro","luto","luz","maceta","macho","madera","madre","maduro","maestro","mafia","magia","mago","maíz","maldad","maleta","malla","malo","mamá","mambo","mamut","manco","mando","manejar","manga","maniquí","manjar","mano","manso","manta","mañana","mapa","máquina","mar","marco","marea","marfil","margen","marido","mármol","marrón","martes","marzo","masa","máscara","masivo","matar","materia","matiz","matriz","máximo","mayor","mazorca","mecha","medalla","medio","médula","mejilla","mejor","melena","melón","memoria","menor","mensaje","mente","menú","mercado","merengue","mérito","mes","mesón","meta","meter","método","metro","mezcla","miedo","miel","miembro","miga","mil","milagro","militar","millón","mimo","mina","minero","mínimo","minuto","miope","mirar","misa","miseria","misil","mismo","mitad","mito","mochila","moción","moda","modelo","moho","mojar","molde","moler","molino","momento","momia","monarca","moneda","monja","monto","moño","morada","morder","moreno","morir","morro","morsa","mortal","mosca","mostrar","motivo","mover","móvil","mozo","mucho","mudar","mueble","muela","muerte","muestra","mugre","mujer","mula","muleta","multa","mundo","muñeca","mural","muro","músculo","museo","musgo","música","muslo","nácar","nación","nadar","naipe","naranja","nariz","narrar","nasal","natal","nativo","natural","náusea","naval","nave","navidad","necio","néctar","negar","negocio","negro","neón","nervio","neto","neutro","nevar","nevera","nicho","nido","niebla","nieto","niñez","niño","nítido","nivel","nobleza","noche","nómina","noria","norma","norte","nota","noticia","novato","novela","novio","nube","nuca","núcleo","nudillo","nudo","nuera","nueve","nuez","nulo","número","nutria","oasis","obeso","obispo","objeto","obra","obrero","observar","obtener","obvio","oca","ocaso","océano","ochenta","ocho","ocio","ocre","octavo","octubre","oculto","ocupar","ocurrir","odiar","odio","odisea","oeste","ofensa","oferta","oficio","ofrecer","ogro","oído","oír","ojo","ola","oleada","olfato","olivo","olla","olmo","olor","olvido","ombligo","onda","onza","opaco","opción","ópera","opinar","oponer","optar","óptica","opuesto","oración","orador","oral","órbita","orca","orden","oreja","órgano","orgía","orgullo","oriente","origen","orilla","oro","orquesta","oruga","osadía","oscuro","osezno","oso","ostra","otoño","otro","oveja","óvulo","óxido","oxígeno","oyente","ozono","pacto","padre","paella","página","pago","país","pájaro","palabra","palco","paleta","pálido","palma","paloma","palpar","pan","panal","pánico","pantera","pañuelo","papá","papel","papilla","paquete","parar","parcela","pared","parir","paro","párpado","parque","párrafo","parte","pasar","paseo","pasión","paso","pasta","pata","patio","patria","pausa","pauta","pavo","payaso","peatón","pecado","pecera","pecho","pedal","pedir","pegar","peine","pelar","peldaño","pelea","peligro","pellejo","pelo","peluca","pena","pensar","peñón","peón","peor","pepino","pequeño","pera","percha","perder","pereza","perfil","perico","perla","permiso","perro","persona","pesa","pesca","pésimo","pestaña","pétalo","petróleo","pez","pezuña","picar","pichón","pie","piedra","pierna","pieza","pijama","pilar","piloto","pimienta","pino","pintor","pinza","piña","piojo","pipa","pirata","pisar","piscina","piso","pista","pitón","pizca","placa","plan","plata","playa","plaza","pleito","pleno","plomo","pluma","plural","pobre","poco","poder","podio","poema","poesía","poeta","polen","policía","pollo","polvo","pomada","pomelo","pomo","pompa","poner","porción","portal","posada","poseer","posible","poste","potencia","potro","pozo","prado","precoz","pregunta","premio","prensa","preso","previo","primo","príncipe","prisión","privar","proa","probar","proceso","producto","proeza","profesor","programa","prole","promesa","pronto","propio","próximo","prueba","público","puchero","pudor","pueblo","puerta","puesto","pulga","pulir","pulmón","pulpo","pulso","puma","punto","puñal","puño","pupa","pupila","puré","quedar","queja","quemar","querer","queso","quieto","química","quince","quitar","rábano","rabia","rabo","ración","radical","raíz","rama","rampa","rancho","rango","rapaz","rápido","rapto","rasgo","raspa","rato","rayo","raza","razón","reacción","realidad","rebaño","rebote","recaer","receta","rechazo","recoger","recreo","recto","recurso","red","redondo","reducir","reflejo","reforma","refrán","refugio","regalo","regir","regla","regreso","rehén","reino","reír","reja","relato","relevo","relieve","relleno","reloj","remar","remedio","remo","rencor","rendir","renta","reparto","repetir","reposo","reptil","res","rescate","resina","respeto","resto","resumen","retiro","retorno","retrato","reunir","revés","revista","rey","rezar","rico","riego","rienda","riesgo","rifa","rígido","rigor","rincón","riñón","río","riqueza","risa","ritmo","rito","rizo","roble","roce","rociar","rodar","rodeo","rodilla","roer","rojizo","rojo","romero","romper","ron","ronco","ronda","ropa","ropero","rosa","rosca","rostro","rotar","rubí","rubor","rudo","rueda","rugir","ruido","ruina","ruleta","rulo","rumbo","rumor","ruptura","ruta","rutina","sábado","saber","sabio","sable","sacar","sagaz","sagrado","sala","saldo","salero","salir","salmón","salón","salsa","salto","salud","salvar","samba","sanción","sandía","sanear","sangre","sanidad","sano","santo","sapo","saque","sardina","sartén","sastre","satán","sauna","saxofón","sección","seco","secreto","secta","sed","seguir","seis","sello","selva","semana","semilla","senda","sensor","señal","señor","separar","sepia","sequía","ser","serie","sermón","servir","sesenta","sesión","seta","setenta","severo","sexo","sexto","sidra","siesta","siete","siglo","signo","sílaba","silbar","silencio","silla","símbolo","simio","sirena","sistema","sitio","situar","sobre","socio","sodio","sol","solapa","soldado","soledad","sólido","soltar","solución","sombra","sondeo","sonido","sonoro","sonrisa","sopa","soplar","soporte","sordo","sorpresa","sorteo","sostén","sótano","suave","subir","suceso","sudor","suegra","suelo","sueño","suerte","sufrir","sujeto","sultán","sumar","superar","suplir","suponer","supremo","sur","surco","sureño","surgir","susto","sutil","tabaco","tabique","tabla","tabú","taco","tacto","tajo","talar","talco","talento","talla","talón","tamaño","tambor","tango","tanque","tapa","tapete","tapia","tapón","taquilla","tarde","tarea","tarifa","tarjeta","tarot","tarro","tarta","tatuaje","tauro","taza","tazón","teatro","techo","tecla","técnica","tejado","tejer","tejido","tela","teléfono","tema","temor","templo","tenaz","tender","tener","tenis","tenso","teoría","terapia","terco","término","ternura","terror","tesis","tesoro","testigo","tetera","texto","tez","tibio","tiburón","tiempo","tienda","tierra","tieso","tigre","tijera","tilde","timbre","tímido","timo","tinta","tío","típico","tipo","tira","tirón","titán","títere","título","tiza","toalla","tobillo","tocar","tocino","todo","toga","toldo","tomar","tono","tonto","topar","tope","toque","tórax","torero","tormenta","torneo","toro","torpedo","torre","torso","tortuga","tos","tosco","toser","tóxico","trabajo","tractor","traer","tráfico","trago","traje","tramo","trance","trato","trauma","trazar","trébol","tregua","treinta","tren","trepar","tres","tribu","trigo","tripa","triste","triunfo","trofeo","trompa","tronco","tropa","trote","trozo","truco","trueno","trufa","tubería","tubo","tuerto","tumba","tumor","túnel","túnica","turbina","turismo","turno","tutor","ubicar","úlcera","umbral","unidad","unir","universo","uno","untar","uña","urbano","urbe","urgente","urna","usar","usuario","útil","utopía","uva","vaca","vacío","vacuna","vagar","vago","vaina","vajilla","vale","válido","valle","valor","válvula","vampiro","vara","variar","varón","vaso","vecino","vector","vehículo","veinte","vejez","vela","velero","veloz","vena","vencer","venda","veneno","vengar","venir","venta","venus","ver","verano","verbo","verde","vereda","verja","verso","verter","vía","viaje","vibrar","vicio","víctima","vida","vídeo","vidrio","viejo","viernes","vigor","vil","villa","vinagre","vino","viñedo","violín","viral","virgo","virtud","visor","víspera","vista","vitamina","viudo","vivaz","vivero","vivir","vivo","volcán","volumen","volver","voraz","votar","voto","voz","vuelo","vulgar","yacer","yate","yegua","yema","yerno","yeso","yodo","yoga","yogur","zafiro","zanja","zapato","zarza","zona","zorro","zumo","zurdo"];Tr.space=" ";class Cr extends Te{constructor(e,t,n){super({mnemonic:e,seed:t,wordlist:n}),this.Wordlist=n||Nr,this.es=Tr,this.jp=Mr}setLang(e){switch(e){case"es":this.Wordlist=Tr;break;case"jp":this.Wordlist=Mr;break;default:this.Wordlist=Nr;break}}toBw(e){if(e||(e=new ke),this.mnemonic){const t=Buffer.from(this.mnemonic);e.writeVarIntNum(t.length),e.write(t)}else e.writeVarIntNum(0);return this.seed?(e.writeVarIntNum(this.seed.length),e.write(this.seed)):e.writeVarIntNum(0),e}fromBr(e){const t=e.readVarIntNum();t>0&&(this.mnemonic=e.read(t).toString());const n=e.readVarIntNum();return n>0&&(this.seed=e.read(n)),this}fromRandom(e){if(e||(e=128),e%32!==0)throw new Error("bits must be multiple of 32");if(e<128)throw new Error("bits must be at least 128");const t=Rt.getRandomBuffer(e/8);return this.entropy2Mnemonic(t),this.mnemonic2Seed(),this}static fromRandom(e){return new this().fromRandom(e)}async asyncFromRandom(e){e||(e=128);const t=Rt.getRandomBuffer(e/8);let n=await le.asyncObjectMethod(this,"entropy2Mnemonic",[t]);const u=new Cr().fromFastBuffer(n.resbuf);return n=await le.asyncObjectMethod(u,"mnemonic2Seed",[]),this.fromFastBuffer(n.resbuf)}static asyncFromRandom(e){return new this().asyncFromRandom(e)}fromEntropy(e){return this.entropy2Mnemonic(e),this}static fromEntropy(e){return new this().fromEntropy(e)}async asyncFromEntropy(e){const t=await le.asyncObjectMethod(this,"fromEntropy",[e]);return this.fromFastBuffer(t.resbuf)}static asyncFromEntropy(e){return new this().asyncFromEntropy(e)}fromString(e){return this.mnemonic=e,this}toString(){return this.mnemonic}toSeed(e){return this.mnemonic2Seed(e),this.seed}async asyncToSeed(e){e===void 0&&(e="");const t=[e];return(await le.asyncObjectMethod(this,"toSeed",t)).resbuf}entropy2Mnemonic(e){if(!Buffer.isBuffer(e)||e.length<128/8)throw new Error("Entropy is less than 128 bits. It must be 128 bits or more.");const t=ae.sha256(e);let n="";const u=e.length*8;for(let a=0;a<e.length;a++)n=n+("00000000"+e[a].toString(2)).slice(-8);let r=t[0].toString(2);if(r=("00000000"+r).slice(-8).slice(0,u/32),n=n+r,n.length%11!==0)throw new Error("internal error - entropy not an even multiple of 11 bits - "+n.length);let s="";for(let a=0;a<n.length/11;a++){s!==""&&(s=s+this.Wordlist.space);const o=parseInt(n.slice(a*11,(a+1)*11),2);s=s+this.Wordlist[o]}return this.mnemonic=s,this}check(){const t=this.mnemonic.split(this.Wordlist.space);let n="";for(let i=0;i<t.length;i++){const c=this.Wordlist.indexOf(t[i]);if(c<0)return!1;n=n+("00000000000"+c.toString(2)).slice(-11)}if(n.length%11!==0)throw new Error("internal error - entropy not an even multiple of 11 bits - "+n.length);const u=n.length/33,r=n.slice(-u),s=n.slice(0,n.length-u),a=Buffer.alloc(s.length/8);for(let i=0;i<s.length/8;i++)a.writeUInt8(parseInt(n.slice(i*8,(i+1)*8),2),i);let f=ae.sha256(a)[0].toString(2);return f=("00000000"+f).slice(-8).slice(0,u),f===r}mnemonic2Seed(e=""){let t=this.mnemonic;if(!this.check())throw new Error("Mnemonic does not pass the check - was the mnemonic typed incorrectly? Are there extra spaces?");if(typeof e!="string")throw new Error("passphrase must be a string or undefined");t=t.normalize("NFKD"),e=e.normalize("NFKD");const n=Buffer.from(t),u=Buffer.concat([Buffer.from("mnemonic"),Buffer.from(e)]);return this.seed=Buffer.from(Rd.pbkdf2Sync(n,u,2048,64,"sha512")),this}isValid(e=""){let t;try{t=!!this.mnemonic2Seed(e)}catch{t=!1}return t}static isValid(e,t=""){return new Cr(e).isValid(t)}}class st extends Te{constructor(e,t,n=gt){super({privKey:e,pubKey:t}),this.PrivKey=n}fromJSON(e){return e.privKey&&(this.privKey=this.PrivKey.fromJSON(e.privKey)),e.pubKey&&(this.pubKey=Ue.fromJSON(e.pubKey)),this}fromBr(e){const t=e.readUInt8();t>0&&(this.privKey=new this.PrivKey().fromFastBuffer(e.read(t)));const n=e.readUInt8();return n>0&&(this.pubKey=new Ue().fromFastBuffer(e.read(n))),this}toBw(e){if(e||(e=new ke),this.privKey){const t=this.privKey.toFastBuffer();e.writeUInt8(t.length),e.write(t)}else e.writeUInt8(0);if(this.pubKey){const t=this.pubKey.toFastBuffer();e.writeUInt8(t.length),e.write(t)}else e.writeUInt8(0);return e}fromString(e){return this.fromJSON(JSON.parse(e))}toString(){return JSON.stringify(this.toJSON())}toPublic(){const e=new st().fromObject(this);return e.privKey=void 0,e}fromPrivKey(e){return this.privKey=e,this.pubKey=new Ue().fromPrivKey(e),this}static fromPrivKey(e){return new this().fromPrivKey(e)}async asyncFromPrivKey(e){return this.privKey=e,this.pubKey=await new Ue().asyncFromPrivKey(e),this}static asyncFromPrivKey(e){return new this().asyncFromPrivKey(e)}fromRandom(){return this.privKey=new this.PrivKey().fromRandom(),this.pubKey=new Ue().fromPrivKey(this.privKey),this}static fromRandom(){return new this().fromRandom()}async asyncFromRandom(){return this.privKey=new this.PrivKey().fromRandom(),this.asyncFromPrivKey(this.privKey)}static asyncFromRandom(){return new this().asyncFromRandom()}}st.Mainnet=class extends st{constructor(l,e){super(l,e,gt.Mainnet)}};st.Testnet=class extends st{constructor(l,e){super(l,e,gt.Testnet)}};class ut extends Te{constructor(e,t,n,u,r,s){super({sig:e,keyPair:t,hashBuf:n,k:u,endian:r,verified:s})}toJSON(){return{sig:this.sig?this.sig.toString():void 0,keyPair:this.keyPair?this.keyPair.toBuffer().toString("hex"):void 0,hashBuf:this.hashBuf?this.hashBuf.toString("hex"):void 0,k:this.k?this.k.toString():void 0,endian:this.endian,verified:this.verified}}fromJSON(e){return this.sig=e.sig?new he().fromString(e.sig):void 0,this.keyPair=e.keyPair?new st().fromBuffer(Buffer.from(e.keyPair,"hex")):void 0,this.hashBuf=e.hashBuf?Buffer.from(e.hashBuf,"hex"):void 0,this.k=e.k?new Z().fromString(e.k):void 0,this.endian=e.endian,this.verified=e.verified,this}toBuffer(){const e=JSON.stringify(this.toJSON());return Buffer.from(e)}fromBuffer(e){const t=JSON.parse(e.toString());return this.fromJSON(t)}calcrecovery(){for(let e=0;e<4;e++){let t;this.sig.recovery=e;try{t=this.sig2PubKey()}catch{continue}if(t.point.eq(this.keyPair.pubKey.point)){const n=this.keyPair.pubKey.compressed;return this.sig.compressed=this.keyPair.pubKey.compressed===void 0?!0:n,this}}throw this.sig.recovery=void 0,new Error("Unable to find valid recovery factor")}async asyncCalcrecovery(){const e=await le.asyncObjectMethod(this,"calcrecovery",[]);return this.fromFastBuffer(e.resbuf)}static calcrecovery(e,t,n){return new ut().fromObject({sig:e,keyPair:new st().fromObject({pubKey:t}),hashBuf:n}).calcrecovery().sig}static async asyncCalcrecovery(e,t,n){const u=await le.asyncClassMethod(ut,"calcrecovery",[e,t,n]);return new he().fromFastBuffer(u.resbuf)}fromString(e){const t=JSON.parse(e);return t.hashBuf&&(this.hashBuf=Buffer.from(t.hashBuf,"hex")),t.keyPair&&(this.keyPair=new st().fromString(t.keyPair)),t.sig&&(this.sig=new he().fromString(t.sig)),t.k&&(this.k=new Z(t.k,10)),this}randomK(){const e=Ie.getN();let t;do t=new Z().fromBuffer(Rt.getRandomBuffer(32));while(!(t.lt(e)&&t.gt(0)));return this.k=t,this}deterministicK(e){let t=Buffer.alloc(32);t.fill(1);let n=Buffer.alloc(32);n.fill(0);const u=this.keyPair.privKey.bn.toBuffer({size:32});n=ae.sha256Hmac(Buffer.concat([t,Buffer.from([0]),u,this.hashBuf]),n),t=ae.sha256Hmac(t,n),n=ae.sha256Hmac(Buffer.concat([t,Buffer.from([1]),u,this.hashBuf]),n),t=ae.sha256Hmac(t,n),t=ae.sha256Hmac(t,n);let r=new Z().fromBuffer(t);const s=Ie.getN();e===void 0&&(e=0);for(let a=0;a<e||!(r.lt(s)&&r.gt(0));a++)n=ae.sha256Hmac(Buffer.concat([t,Buffer.from([0])]),n),t=ae.sha256Hmac(t,n),t=ae.sha256Hmac(t,n),r=new Z().fromBuffer(t);return this.k=r,this}sig2PubKey(){const e=this.sig.recovery;if(!(e===0||e===1||e===2||e===3))throw new Error("i must be equal to 0, 1, 2, or 3");const t=new Z().fromBuffer(this.hashBuf),n=this.sig.r,u=this.sig.s,r=e&1,s=e>>1,a=Ie.getN(),o=Ie.getG(),f=s?n.add(a):n,i=Ie.fromX(r,f);let c="";try{i.mul(a)}catch(y){c=y.message}if(c!=="point mul out of range")throw new Error("nR is not a valid curve point");const h=t.neg().umod(a),d=n.invm(a),b=i.mul(u).add(o.mul(h)).mul(d),p=new Ue(b);return p.compressed=this.sig.compressed,p.validate(),p}async asyncSig2PubKey(){const e=await le.asyncObjectMethod(this,"sig2PubKey",[]);return Ue.fromFastBuffer(e.resbuf)}static sig2PubKey(e,t){return new ut().fromObject({sig:e,hashBuf:t}).sig2PubKey()}static async asyncSig2PubKey(e,t){return await new ut().fromObject({sig:e,hashBuf:t}).asyncSig2PubKey()}verifyStr(e=!0){if(!Buffer.isBuffer(this.hashBuf)||this.hashBuf.length!==32)return"hashBuf must be a 32 byte buffer";try{this.keyPair.pubKey.validate()}catch(i){return"Invalid pubKey: "+i}const t=this.sig.r,n=this.sig.s;if(!(t.gt(0)&&t.lt(Ie.getN()))||!(n.gt(0)&&n.lt(Ie.getN())))return"r and s not in range";if(e&&!this.sig.hasLowS())return"s is too high and does not satisfy low s contraint - see bip 62";const u=new Z().fromBuffer(this.hashBuf,this.endian?{endian:this.endian}:void 0),r=Ie.getN(),s=n.invm(r),a=s.mul(u).mod(r),o=s.mul(t).mod(r),f=Ie.getG().mulAdd(a,this.keyPair.pubKey.point,o);return f.isInfinity()?"p is infinity":f.getX().mod(r).cmp(t)!==0?"Invalid signature":!1}sign(){const e=this.endian==="little"?new ot(this.hashBuf).readReverse():this.hashBuf,t=this.keyPair.privKey,n=t.bn;if(!e||!t||!n)throw new Error("invalid parameters");if(!Buffer.isBuffer(e)||e.length!==32)throw new Error("hashBuf must be a 32 byte buffer");const u=Ie.getN(),r=Ie.getG(),s=new Z().fromBuffer(e);let a=0,o,f,i,c;do(!this.k||a>0)&&this.deterministicK(a),a++,o=this.k,f=r.mul(o),i=f.getX().mod(u),c=o.invm(u).mul(s.add(n.mul(i))).mod(u);while(i.cmp(0)<=0||c.cmp(0)<=0);return c.gt(new Z().fromBuffer(Buffer.from("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))&&(c=Ie.getN().sub(c)),this.sig=he.fromObject({r:i,s:c,compressed:this.keyPair.pubKey.compressed}),this}async asyncSign(){const e=await le.asyncObjectMethod(this,"sign",[]);return this.fromFastBuffer(e.resbuf)}signRandomK(){return this.randomK(),this.sign()}toString(){const e={};return this.hashBuf&&(e.hashBuf=this.hashBuf.toString("hex")),this.keyPair&&(e.keyPair=this.keyPair.toString()),this.sig&&(e.sig=this.sig.toString()),this.k&&(e.k=this.k.toString()),JSON.stringify(e)}verify(e=!0){return this.verifyStr(e)?this.verified=!1:this.verified=!0,this}async asyncVerify(e=!0){const t=await le.asyncObjectMethod(this,"verify",[e]);return this.fromFastBuffer(t.resbuf)}static sign(e,t,n){return new ut().fromObject({hashBuf:e,endian:n,keyPair:t}).sign().sig}static async asyncSign(e,t,n){const u=new ut().fromObject({hashBuf:e,endian:n,keyPair:t});return await u.asyncSign(),u.sig}static verify(e,t,n,u,r=!0){return new ut().fromObject({hashBuf:e,endian:u,sig:t,keyPair:new st().fromObject({pubKey:n})}).verify(r).verified}static async asyncVerify(e,t,n,u,r=!0){const s=new ut().fromObject({hashBuf:e,endian:u,sig:t,keyPair:new st().fromObject({pubKey:n})});return await s.asyncVerify(r),s.verified}}class mt extends Te{constructor(e,t,n,u,r){super({messageBuf:e,keyPair:t,sig:n,address:u,verified:r})}static magicHash(e){if(!Buffer.isBuffer(e))throw new Error("messageBuf must be a buffer");const t=new ke;t.writeVarIntNum(mt.magicBytes.length),t.write(mt.magicBytes),t.writeVarIntNum(e.length),t.write(e);const n=t.toBuffer();return ae.sha256Sha256(n)}static async asyncMagicHash(e){const t=[e];return(await le.asyncClassMethod(mt,"magicHash",t)).resbuf}static sign(e,t){const n=new mt(e,t);return n.sign(),n.sig.toCompact().toString("base64")}static async asyncSign(e,t){const n=[e,t],u=await le.asyncClassMethod(mt,"sign",n);return JSON.parse(u.resbuf.toString())}static verify(e,t,n){const u=Buffer.from(t,"base64"),r=new mt;return r.messageBuf=e,r.sig=new he().fromCompact(u),r.address=n,r.verify().verified}static async asyncVerify(e,t,n){const u=[e,t,n],r=await le.asyncClassMethod(mt,"verify",u);return JSON.parse(r.resbuf.toString())}sign(){const e=mt.magicHash(this.messageBuf),t=new ut().fromObject({hashBuf:e,keyPair:this.keyPair});return t.sign(),t.calcrecovery(),this.sig=t.sig,this}verify(){const e=mt.magicHash(this.messageBuf),t=new ut;if(t.hashBuf=e,t.sig=this.sig,t.keyPair=new st,t.keyPair.pubKey=t.sig2PubKey(),!t.verify())return this.verified=!1,this;const n=new St().fromPubKey(t.keyPair.pubKey,void 0,this.sig.compressed);return kt(n.hashBuf,this.address.hashBuf)?this.verified=!0:this.verified=!1,this}}mt.magicBytes=Buffer.from(`Bitcoin Signed Message:
9
9
  `);class tr extends Te{constructor(e,t,n,u,r,s){super({versionBytesNum:e,prevBlockHashBuf:t,merkleRootBuf:n,time:u,bits:r,nonce:s})}fromJSON(e){return this.fromObject({versionBytesNum:e.versionBytesNum,prevBlockHashBuf:Buffer.from(e.prevBlockHashBuf,"hex"),merkleRootBuf:Buffer.from(e.merkleRootBuf,"hex"),time:e.time,bits:e.bits,nonce:e.nonce}),this}toJSON(){return{versionBytesNum:this.versionBytesNum,prevBlockHashBuf:this.prevBlockHashBuf.toString("hex"),merkleRootBuf:this.merkleRootBuf.toString("hex"),time:this.time,bits:this.bits,nonce:this.nonce}}fromBr(e){return this.versionBytesNum=e.readUInt32LE(),this.prevBlockHashBuf=e.read(32),this.merkleRootBuf=e.read(32),this.time=e.readUInt32LE(),this.bits=e.readUInt32LE(),this.nonce=e.readUInt32LE(),this}toBw(e){return e||(e=new ke),e.writeUInt32LE(this.versionBytesNum),e.write(this.prevBlockHashBuf),e.write(this.merkleRootBuf),e.writeUInt32LE(this.time),e.writeUInt32LE(this.bits),e.writeUInt32LE(this.nonce),e}}class Lt extends Te{constructor(e,t,n,u){super({hashBuf:e,buf:t,merkle1:n,merkle2:u})}hash(){if(this.hashBuf)return this.hashBuf;if(this.buf)return ae.sha256Sha256(this.buf);const e=this.merkle1.hash(),t=this.merkle2.hash();return this.buf=Buffer.concat([e,t]),ae.sha256Sha256(this.buf)}fromBuffers(e){if(e.length<1)throw new Error("buffers must have a length");e=e.slice();const t=Math.log2(e.length);if(!Number.isInteger(t)){const r=e[e.length-1],s=Math.pow(2,Math.ceil(t));for(let a=e.length;a<s;a++)e.push(r)}const n=e.slice(0,e.length/2),u=e.slice(e.length/2);return this.fromBufferArrays(n,u),this}static fromBuffers(e){return new this().fromBuffers(e)}fromBufferArrays(e,t){if(e.length===1)return this.merkle1=new Lt(void 0,e[0]),this.merkle2=new Lt(void 0,t[0]),this;const n=e.slice(0,e.length/2),u=e.slice(e.length/2);this.merkle1=new Lt().fromBufferArrays(n,u);const r=t.slice(0,t.length/2),s=t.slice(t.length/2);return this.merkle2=new Lt().fromBufferArrays(r,s),this}static fromBufferArrays(e,t){return new this().fromBufferArrays(e,t)}leavesNum(){if(this.merkle1)return this.merkle1.leavesNum()+this.merkle2.leavesNum();if(this.buf)return 1;throw new Error("invalid number of leaves")}}class Lr extends Te{constructor(e,t,n){super(),this.fromObject({prevoutsHashBuf:e,sequenceHashBuf:t,outputsHashBuf:n})}fromBuffer(e){return this.fromJSON(JSON.parse(e.toString()))}toBuffer(){return Buffer.from(JSON.stringify(this.toJSON()))}fromJSON(e){return this.prevoutsHashBuf=e.prevoutsHashBuf?Buffer.from(e.prevoutsHashBuf,"hex"):void 0,this.sequenceHashBuf=e.sequenceHashBuf?Buffer.from(e.sequenceHashBuf,"hex"):void 0,this.outputsHashBuf=e.outputsHashBuf?Buffer.from(e.outputsHashBuf,"hex"):void 0,this}toJSON(){return{prevoutsHashBuf:this.prevoutsHashBuf?this.prevoutsHashBuf.toString("hex"):void 0,sequenceHashBuf:this.sequenceHashBuf?this.sequenceHashBuf.toString("hex"):void 0,outputsHashBuf:this.outputsHashBuf?this.outputsHashBuf.toString("hex"):void 0}}}class qe extends Te{constructor(e){super({buf:e})}fromJSON(e){return this.fromObject({buf:Buffer.from(e,"hex")}),this}toJSON(){return this.buf.toString("hex")}fromBuffer(e){return this.buf=e,this}fromBr(e){return this.buf=e.readVarIntBuf(),this}fromBn(e){return this.buf=new ke().writeVarIntBn(e).toBuffer(),this}static fromBn(e){return new this().fromBn(e)}fromNumber(e){return this.buf=new ke().writeVarIntNum(e).toBuffer(),this}static fromNumber(e){return new this().fromNumber(e)}toBuffer(){return this.buf}toBn(){return new ot(this.buf).readVarIntBn()}toNumber(){return new ot(this.buf).readVarIntNum()}}class He extends Te{constructor(e,t,n,u,r=4294967295){super({txHashBuf:e,txOutNum:t,scriptVi:n,script:u,nSequence:r})}setScript(e){return this.scriptVi=qe.fromNumber(e.toBuffer().length),this.script=e,this}fromProperties(e,t,n,u){return this.fromObject({txHashBuf:e,txOutNum:t,nSequence:u}),this.setScript(n),this}static fromProperties(e,t,n,u){return new this().fromProperties(e,t,n,u)}fromJSON(e){return this.fromObject({txHashBuf:typeof e.txHashBuf<"u"?Buffer.from(e.txHashBuf,"hex"):void 0,txOutNum:e.txOutNum,scriptVi:typeof e.scriptVi<"u"?qe.fromJSON(e.scriptVi):void 0,script:typeof e.script<"u"?Ae.fromJSON(e.script):void 0,nSequence:e.nSequence}),this}toJSON(){return{txHashBuf:typeof this.txHashBuf<"u"?this.txHashBuf.toString("hex"):void 0,txOutNum:this.txOutNum,scriptVi:typeof this.scriptVi<"u"?this.scriptVi.toJSON():void 0,script:typeof this.script<"u"?this.script.toJSON():void 0,nSequence:this.nSequence}}fromBr(e){return this.txHashBuf=e.read(32),this.txOutNum=e.readUInt32LE(),this.scriptVi=qe.fromBuffer(e.readVarIntBuf()),this.script=Ae.fromBuffer(e.read(this.scriptVi.toNumber())),this.nSequence=e.readUInt32LE(),this}toBw(e){return e||(e=new ke),e.write(this.txHashBuf),e.writeUInt32LE(this.txOutNum),e.write(this.scriptVi.buf),e.write(this.script.toBuffer()),e.writeUInt32LE(this.nSequence),e}fromPubKeyHashTxOut(e,t,n,u){const r=new Ae;if(n.script.isPubKeyHashOut())r.writeOpCode(q.OP_0),u?r.writeBuffer(u.toBuffer()):r.writeOpCode(q.OP_0);else throw new Error("txOut must be of type pubKeyHash");return this.txHashBuf=e,this.txOutNum=t,this.setScript(r),this}hasNullInput(){return this.txHashBuf.toString("hex")==="0000000000000000000000000000000000000000000000000000000000000000"&&this.txOutNum===4294967295}setNullInput(){this.txHashBuf=Buffer.alloc(32),this.txHashBuf.fill(0),this.txOutNum=4294967295}}He.LOCKTIME_VERIFY_SEQUENCE=1;He.SEQUENCE_FINAL=4294967295;He.SEQUENCE_LOCKTIME_DISABLE_FLAG=1<<31;He.SEQUENCE_LOCKTIME_TYPE_FLAG=1<<22;He.SEQUENCE_LOCKTIME_MASK=65535;He.SEQUENCE_LOCKTIME_GRANULARITY=9;class yt extends Te{constructor(e,t,n){super({valueBn:e,scriptVi:t,script:n})}setScript(e){return this.scriptVi=qe.fromNumber(e.toBuffer().length),this.script=e,this}fromProperties(e,t){return this.fromObject({valueBn:e}),this.setScript(t),this}static fromProperties(e,t){return new this().fromProperties(e,t)}fromJSON(e){return this.fromObject({valueBn:new Z().fromJSON(e.valueBn),scriptVi:new qe().fromJSON(e.scriptVi),script:new Ae().fromJSON(e.script)}),this}toJSON(){return{valueBn:this.valueBn.toJSON(),scriptVi:this.scriptVi.toJSON(),script:this.script.toJSON()}}fromBr(e){return this.valueBn=e.readUInt64LEBn(),this.scriptVi=qe.fromNumber(e.readVarIntNum()),this.script=new Ae().fromBuffer(e.read(this.scriptVi.toNumber())),this}toBw(e){return e||(e=new ke),e.writeUInt64LEBn(this.valueBn),e.write(this.scriptVi.buf),e.write(this.script.toBuffer()),e}}class Me extends Te{constructor(e=1,t=qe.fromNumber(0),n=[],u=qe.fromNumber(0),r=[],s=0){super({versionBytesNum:e,txInsVi:t,txIns:n,txOutsVi:u,txOuts:r,nLockTime:s})}fromJSON(e){const t=[];e.txIns.forEach(function(u){t.push(new He().fromJSON(u))});const n=[];return e.txOuts.forEach(function(u){n.push(new yt().fromJSON(u))}),this.fromObject({versionBytesNum:e.versionBytesNum,txInsVi:new qe().fromJSON(e.txInsVi),txIns:t,txOutsVi:new qe().fromJSON(e.txOutsVi),txOuts:n,nLockTime:e.nLockTime}),this}toJSON(){const e=[];this.txIns.forEach(function(n){e.push(n.toJSON())});const t=[];return this.txOuts.forEach(function(n){t.push(n.toJSON())}),{versionBytesNum:this.versionBytesNum,txInsVi:this.txInsVi.toJSON(),txIns:e,txOutsVi:this.txOutsVi.toJSON(),txOuts:t,nLockTime:this.nLockTime}}fromBr(e){this.versionBytesNum=e.readUInt32LE(),this.txInsVi=new qe(e.readVarIntBuf());const t=this.txInsVi.toNumber();this.txIns=[];for(let u=0;u<t;u++)this.txIns.push(new He().fromBr(e));this.txOutsVi=new qe(e.readVarIntBuf());const n=this.txOutsVi.toNumber();this.txOuts=[];for(let u=0;u<n;u++)this.txOuts.push(new yt().fromBr(e));return this.nLockTime=e.readUInt32LE(),this}toBw(e){e||(e=new ke),e.writeUInt32LE(this.versionBytesNum),e.write(this.txInsVi.buf);for(let t=0;t<this.txIns.length;t++)this.txIns[t].toBw(e);e.write(this.txOutsVi.buf);for(let t=0;t<this.txOuts.length;t++)this.txOuts[t].toBw(e);return e.writeUInt32LE(this.nLockTime),e}hashPrevouts(){const e=new ke;for(const t in this.txIns){const n=this.txIns[t];e.write(n.txHashBuf),e.writeUInt32LE(n.txOutNum)}return ae.sha256Sha256(e.toBuffer())}hashSequence(){const e=new ke;for(const t in this.txIns){const n=this.txIns[t];e.writeUInt32LE(n.nSequence)}return ae.sha256Sha256(e.toBuffer())}hashOutputs(){const e=new ke;for(const t in this.txOuts){const n=this.txOuts[t];e.write(n.toBuffer())}return ae.sha256Sha256(e.toBuffer())}sighash(e,t,n,u,r=Me.SCRIPT_ENABLE_SIGHASH_FORKID,s=new Lr){const a=this.sighashPreimage(e,t,n,u,r,s);return a.compare(Buffer.from("0000000000000000000000000000000000000000000000000000000000000001","hex"))===0?a:new ot(ae.sha256Sha256(a)).readReverse()}async asyncSighash(e,t,n,u,r=0,s={}){return(await le.asyncObjectMethod(this,"sighash",[e,t,n,u,r,s])).resbuf}sighashPreimage(e,t,n,u,r=Me.SCRIPT_ENABLE_SIGHASH_FORKID,s=new Lr){if(u===void 0&&(u=new Z(0)),e&he.SIGHASH_FORKID&&!(e&he.SIGHASH_CHRONICLE)&&r&Me.SCRIPT_ENABLE_SIGHASH_FORKID){let f=Buffer.alloc(32,0),i=Buffer.alloc(32,0),c=Buffer.alloc(32,0);e&he.SIGHASH_ANYONECANPAY||(f=s.prevoutsHashBuf?s.prevoutsHashBuf:s.prevoutsHashBuf=this.hashPrevouts()),!(e&he.SIGHASH_ANYONECANPAY)&&(e&31)!==he.SIGHASH_SINGLE&&(e&31)!==he.SIGHASH_NONE&&(i=s.sequenceHashBuf?s.sequenceHashBuf:s.sequenceHashBuf=this.hashSequence()),(e&31)!==he.SIGHASH_SINGLE&&(e&31)!==he.SIGHASH_NONE?c=s.outputsHashBuf?s.outputsHashBuf:s.outputsHashBuf=this.hashOutputs():(e&31)===he.SIGHASH_SINGLE&&t<this.txOuts.length&&(c=ae.sha256Sha256(this.txOuts[t].toBuffer()));const h=new ke;return h.writeUInt32LE(this.versionBytesNum),h.write(f),h.write(i),h.write(this.txIns[t].txHashBuf),h.writeUInt32LE(this.txIns[t].txOutNum),h.writeVarIntNum(n.toBuffer().length),h.write(n.toBuffer()),h.writeUInt64LEBn(u),h.writeUInt32LE(this.txIns[t].nSequence),h.write(c),h.writeUInt32LE(this.nLockTime),h.writeUInt32LE(e>>>0),h.toBuffer()}const a=this.cloneByBuffer();n=new Ae().fromBuffer(n.toBuffer()),n.removeCodeseparators();for(let f=0;f<a.txIns.length;f++)a.txIns[f]=He.fromBuffer(a.txIns[f].toBuffer()).setScript(new Ae);if(a.txIns[t]=He.fromBuffer(a.txIns[t].toBuffer()).setScript(n),(e&31)===he.SIGHASH_NONE){a.txOuts.length=0,a.txOutsVi=qe.fromNumber(0);for(let f=0;f<a.txIns.length;f++)f!==t&&(a.txIns[f].nSequence=0)}else if((e&31)===he.SIGHASH_SINGLE){if(t>a.txOuts.length-1)return Buffer.from("0000000000000000000000000000000000000000000000000000000000000001","hex");a.txOuts.length=t+1,a.txOutsVi=qe.fromNumber(t+1);for(let f=0;f<a.txOuts.length;f++)f<t&&(a.txOuts[f]=yt.fromProperties(new Z().fromBuffer(Buffer.from("ffffffffffffffff","hex")),new Ae));for(let f=0;f<a.txIns.length;f++)f!==t&&(a.txIns[f].nSequence=0)}return e&he.SIGHASH_ANYONECANPAY&&(a.txIns[0]=a.txIns[t],a.txIns.length=1,a.txInsVi=qe.fromNumber(1)),new ke().write(a.toBuffer()).writeUInt32LE(e>>>0).toBuffer()}async asyncSighashPreimage(e,t,n,u,r=0,s={}){return(await le.asyncObjectMethod(this,"sighashPreimage",[e,t,n,u,r,s])).resbuf}sign(e,t=he.SIGHASH_ALL|he.SIGHASH_FORKID,n,u,r,s=Me.SCRIPT_ENABLE_SIGHASH_FORKID,a={}){const o=this.sighash(t,n,u,r,s,a);return this.preImageBuf=o,ut.sign(o,e,"little").fromObject({nHashType:t})}async asyncSign(e,t=he.SIGHASH_ALL|he.SIGHASH_FORKID,n,u,r,s=Me.SCRIPT_ENABLE_SIGHASH_FORKID,a={}){const o=await le.asyncObjectMethod(this,"sign",[e,t,n,u,r,s,a]);return new he().fromFastBuffer(o.resbuf)}verify(e,t,n,u,r=!1,s,a=Me.SCRIPT_ENABLE_SIGHASH_FORKID,o={}){const f=this.sighash(e.nHashType,n,u,s,a,o);return ut.verify(f,e,t,"little",r)}async asyncVerify(e,t,n,u,r=!1,s,a=Me.SCRIPT_ENABLE_SIGHASH_FORKID,o={}){const f=await le.asyncObjectMethod(this,"verify",[e,t,n,u,r,s,a,o]);return JSON.parse(f.resbuf.toString())}hash(){return ae.sha256Sha256(this.toBuffer())}async asyncHash(){return(await le.asyncObjectMethod(this,"hash",[])).resbuf}id(){return new ot(this.hash()).readReverse().toString("hex")}async asyncId(){const e=await le.asyncObjectMethod(this,"id",[]);return JSON.parse(e.resbuf.toString())}addTxIn(e,t,n,u){let r;return e instanceof He?r=e:r=new He().fromObject({txHashBuf:e,txOutNum:t,nSequence:u}).setScript(n),this.txIns.push(r),this.txInsVi=qe.fromNumber(this.txInsVi.toNumber()+1),this}addTxOut(e,t){let n;return e instanceof yt?n=e:n=new yt().fromObject({valueBn:e}).setScript(t),this.txOuts.push(n),this.txOutsVi=qe.fromNumber(this.txOutsVi.toNumber()+1),this}isCoinbase(){return this.txIns.length===1&&this.txIns[0].hasNullInput()}sort(){return this.txIns.sort((e,t)=>new ot(e.txHashBuf).readReverse().compare(new ot(t.txHashBuf).readReverse())||e.txOutNum-t.txOutNum),this.txOuts.sort((e,t)=>e.valueBn.sub(t.valueBn).toNumber()||e.script.toBuffer().compare(t.script.toBuffer())),this}}Me.MAX_MONEY=21e6*1e8;Me.SCRIPT_ENABLE_SIGHASH_FORKID=65536;class $r extends Te{constructor(e,t,n){super({blockHeader:e,txsVi:t,txs:n})}fromJSON(e){const t=[];return e.txs.forEach(function(n){t.push(new Me().fromJSON(n))}),this.fromObject({blockHeader:new tr().fromJSON(e.blockHeader),txsVi:new qe().fromJSON(e.txsVi),txs:t}),this}toJSON(){const e=[];return this.txs.forEach(function(t){e.push(t.toJSON())}),{blockHeader:this.blockHeader.toJSON(),txsVi:this.txsVi.toJSON(),txs:e}}fromBr(e){this.blockHeader=new tr().fromBr(e),this.txsVi=new qe(e.readVarIntBuf());const t=this.txsVi.toNumber();this.txs=[];for(let n=0;n<t;n++)this.txs.push(new Me().fromBr(e));return this}toBw(e){e||(e=new ke),e.write(this.blockHeader.toBuffer()),e.write(this.txsVi.buf);const t=this.txsVi.toNumber();for(let n=0;n<t;n++)this.txs[n].toBw(e);return e}hash(){return ae.sha256Sha256(this.blockHeader.toBuffer())}async asyncHash(){return(await le.asyncObjectMethod(this,"hash",[])).resbuf}id(){return new ot(this.hash()).readReverse().toString("hex")}async asyncId(){const e=await le.asyncObjectMethod(this,"id",[]);return JSON.parse(e.resbuf.toString())}verifyMerkleRoot(){const e=this.txs.map(n=>n.toBuffer()),t=Lt.fromBuffers(e).hash();return Buffer.compare(t,this.blockHeader.merkleRootBuf)}static iterateTxs(e){const t=new ot(e),n=new tr().fromBr(t),u=new qe(t.readVarIntBuf()),r=u.toNumber();return{blockHeader:n,txsVi:u,txsNum:r,*[Symbol.iterator](){for(let s=0;s<r;s++)yield new Me().fromBr(t)}}}}$r.MAX_BLOCK_SIZE=1e6;class Id extends $r{constructor(e,t,n){super(e,t,n)}async mine(e,t=0,n=null){return new Promise(u=>{const r=Date.now(),s=e.toString("hex");let a=0;const o=this.blockHeader.toBuffer(),f=()=>{for(;;){if(t&&a>=t)return u(!1);a++;let i=o.readUInt32LE(76)+1;o.writeUInt32LE(i,76),a%1e5===0&&o.writeUInt32LE(Math.floor(Date.now()/1e3),68);const c=ae.sha256Sha256(o);if(c.toString("hex")<s)return this.blockHeader.fromBuffer(o),n?.({success:!0,nonce:i,iterations:a,hashrate:a/((Date.now()-r)/1e3),hash:c.toString("hex")}),u(!0);if(n&&a%5e5===0&&n({success:!1,iterations:a,hashrate:a/((Date.now()-r)/1e3)}),a%1e6===0)return setImmediate(f)}};f()})}mineSync(e,t=0){const n=e.toString("hex");let u=0;const r=this.blockHeader.toBuffer();for(;!t||u<t;){u++;let s=r.readUInt32LE(76)+1;r.writeUInt32LE(s,76);const a=ae.sha256Sha256(r);if(a.toString("hex")<n)return this.blockHeader.fromBuffer(r),{success:!0,nonce:s,iterations:u,hashrate:u/10,hash:a.toString("hex")}}return{success:!1,iterations:u,hashrate:u/10}}verifyProofOfWork(e){return this.hash().toString("hex")<e.toString("hex")}hash(){return ae.sha256Sha256(this.blockHeader.toBuffer())}id(){return new ot(this.hash()).readReverse().toString("hex")}}class M1{static createBlock(e,t,n){const u=new tr({version:536870912,prevBlockHashBuf:t,merkleRootBuf:this.calcMerkleRoot(e),time:Math.floor(Date.now()/1e3),bits:n,nonce:0}),r=[this.createCoinbaseTx(),...e],s=new qe().fromNumber(r.length);return new Id(u,s,r)}static calcMerkleRoot(e){return Lt.fromBuffers(e.map(t=>t.hash())).hash()}static createCoinbaseTx(){return new Me}static validateBlock(e,t){if(!e.verifyProofOfWork(t))throw new Error("Invalid POW");if(e.verifyMerkleRoot()!==0)throw new Error("Invalid merkle root");return!0}}const T1=[q.OP_CAT,q.OP_SUBSTR,q.OP_LEFT,q.OP_RIGHT,q.OP_INVERT,q.OP_AND,q.OP_OR,q.OP_XOR,q.OP_2MUL,q.OP_2DIV,q.OP_MUL,q.OP_DIV,q.OP_MOD,q.OP_LSHIFT,q.OP_RSHIFT];function Gf(l){return l.length===0||(l[l.length-1]&127)!==0?l:l.length===1?[]:(l[l.length-2]&128)===0?Gf(l.slice(0,l.length-1)):l}class re extends Te{constructor(e,t,n,u=[],r=[],s=0,a=0,o=0,f=[],i="",c=re.defaultFlags,h=new Z(0)){super({script:e,tx:t,nIn:n,stack:u,altStack:r,pc:s,pBeginCodeHash:a,nOpCount:o,ifStack:f,errStr:i,flags:c,valueBn:h})}initialize(){return this.script=new Ae,this.stack=[],this.altStack=[],this.pc=0,this.pBeginCodeHash=0,this.nOpCount=0,this.ifStack=[],this.errStr="",this.flags=re.defaultFlags,this.setLimits(),this}setLimits(){return this.scriptLimit=this.isPreGenesis()?re.PREGENESIS_SCRIPT_LIMIT:1e7,this.stackLimit=this.isPreGenesis()?re.PREGENESIS_STACK_LIMIT:1e7,this}isPreGenesis(){return(this.flags&re.SCRIPT_VERIFY_PREGENESIS_LIMITS)!==0}isChronicle(){return(this.flags&re.SCRIPT_VERIFY_CHRONICLE)!==0||this.tx!==void 0&&this.tx.versionBytesNum>1}scriptNumMaxSize(){return this.isPreGenesis()?re.PREGENESIS_SCRIPT_NUM_LENGTH:this.isChronicle()?re.DEFAULT_SCRIPT_NUM_LENGTH_POLICY_AFTER_CHRONICLE:re.DEFAULT_SCRIPT_NUM_LENGTH_POLICY_AFTER_GENESIS}maxScriptElementSize(){return this.isPreGenesis()?re.PREGENESIS_MAX_SCRIPT_ELEMENT_SIZE:re.MAX_SCRIPT_ELEMENT_SIZE}versionBuf(){const e=Buffer.alloc(4);return e.writeUInt32LE(this.tx?this.tx.versionBytesNum:0,0),e}buildSubScript(){let e=this.script.chunks.slice(this.pBeginCodeHash);return this.isUnlockingScript&&this.isChronicle()&&this.lockingScript&&(e=e.concat(this.lockingScript.chunks)),new Ae().fromObject({chunks:e})}stepChronicleOp(e,t){const n=e===q.OP_SUBSTR_CHRONICLE;if(this.stack.length<(n?3:2))return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;let u,r=0,s,a;try{const c=this.stack[this.stack.length-1],h=new Z().fromScriptNumBuffer(c,t,this.scriptNumMaxSize());if(n||e===q.OP_LEFT_CHRONICLE||e===q.OP_RIGHT_CHRONICLE?u=h.toNumber():s=h.toNumber(),n){const d=this.stack[this.stack.length-2];r=new Z().fromScriptNumBuffer(d,t,this.scriptNumMaxSize()).toNumber()}else if(!n){const d=this.stack[this.stack.length-2];a=new Z().fromScriptNumBuffer(d,t,this.scriptNumMaxSize())}}catch(c){return this.errStr=c.message.includes("overflow")?"SCRIPTNUM_OVERFLOW":"SCRIPT_ERR_UNKNOWN_ERROR",!1}if(n||e===q.OP_LEFT_CHRONICLE||e===q.OP_RIGHT_CHRONICLE){const c=this.stack.length-(n?3:2),h=this.stack[c],d=h.length;if(u<0||u>d||n&&(r<0||r>=d||u>d-r))return this.errStr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;const b=n?r:e===q.OP_LEFT_CHRONICLE?0:d-u;return this.stack[c]=h.slice(b,b+u),this.stack.pop(),n&&this.stack.pop(),!0}if(s<0)return this.errStr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;const o=a.negative,f=a.abs();let i;if(e===q.OP_LSHIFTNUM)i=f.ushln(s);else{const c=new Z(1).ushln(s);i=f.add(c.sub(1)).div(c)}return o&&(i=i.ineg()),this.stack.pop(),this.stack.pop(),this.stack.push(i.toScriptNumBuffer()),!0}static castToBool(e){for(let t=0;t<e.length;t++)if(e[t]!==0)return!(t===e.length-1&&e[t]===128);return!1}checkSigEncoding(e){if(e.length===0)return!0;if((this.flags&(re.SCRIPT_VERIFY_DERSIG|re.SCRIPT_VERIFY_LOW_S|re.SCRIPT_VERIFY_STRICTENC))!==0&&!he.IsTxDer(e))return this.errStr="SCRIPT_ERR_SIG_DER",!1;if((this.flags&re.SCRIPT_VERIFY_LOW_S)!==0&&!this.isChronicle()){if(!new he().fromTxFormat(e).hasLowS())return this.errStr="SCRIPT_ERR_SIG_DER",!1}else if((this.flags&re.SCRIPT_VERIFY_STRICTENC)!==0){const t=new he().fromTxFormat(e);if(!t.hasDefinedHashType())return this.errStr="SCRIPT_ERR_SIG_HASHTYPE",!1;if(!(this.flags&re.SCRIPT_ENABLE_SIGHASH_FORKID)&&t.nHashType&he.SIGHASH_FORKID)return this.errStr="SCRIPT_ERR_ILLEGAL_FORKID",!1;if(t.isChronicle()&&!this.isChronicle())return this.errStr="SCRIPT_ERR_ILLEGAL_CHRONICLE",!1;if(this.flags&re.SCRIPT_ENABLE_SIGHASH_FORKID&&!(t.nHashType&he.SIGHASH_FORKID)&&this.flags&re.SCRIPT_VERIFY_STRICTENC)return this.errStr="SCRIPT_ERR_MUST_USE_FORKID",!1}return!0}checkPubKeyEncoding(e){return(this.flags&re.SCRIPT_VERIFY_STRICTENC)!==0&&!Ue.isCompressedOrUncompressed(e)?(this.errStr="SCRIPT_ERR_PUBKEYTYPE",!1):!0}checkLockTime(e){return!(!(this.tx.nLockTime<re.LOCKTIME_THRESHOLD&&e<re.LOCKTIME_THRESHOLD||this.tx.nLockTime>=re.LOCKTIME_THRESHOLD&&e>=re.LOCKTIME_THRESHOLD)||e>this.tx.nLockTime||this.tx.txIns[this.nIn].nSequence===4294967295)}checkSequence(e){if(this.tx.versionBytesNum<2||(this.tx.txIns[this.nIn].nSequence&He.SEQUENCE_LOCKTIME_DISABLE_FLAG)!==0)return!1;const t=He.SEQUENCE_LOCKTIME_TYPE_FLAG|He.SEQUENCE_LOCKTIME_MASK,n=this.tx.txIns[this.nIn].nSequence&t,u=e&t;return!(!(n<He.SEQUENCE_LOCKTIME_TYPE_FLAG&&u<He.SEQUENCE_LOCKTIME_TYPE_FLAG||n>=He.SEQUENCE_LOCKTIME_TYPE_FLAG&&u>=He.SEQUENCE_LOCKTIME_TYPE_FLAG)||u>n)}*step(){const e=(this.flags&re.SCRIPT_VERIFY_MINIMALDATA)!==0&&!this.isChronicle();if(this.pc>=this.script.chunks.length)return!0;const t=this.script.chunks[this.pc];this.pc++;const n=t.opCodeNum,u=this.ifStack.indexOf(!1)===-1;if(t.buf&&t.buf.length>this.maxScriptElementSize())return this.errStr="SCRIPT_ERR_PUSH_SIZE",!1;if(n>q.OP_16&&++this.nOpCount>201)return this.errStr="SCRIPT_ERR_OP_COUNT",!1;if((n===q.OP_2MUL||n===q.OP_2DIV)&&!this.isChronicle())return this.errStr="SCRIPT_ERR_DISABLED_OPCODE",!1;if(u&&n>=0&&n<=q.OP_PUSHDATA4){if(e&&!this.script.checkMinimalPush(this.pc-1))return this.errStr="SCRIPT_ERR_MINIMALDATA",!1;if(!t.buf)this.stack.push(re.false);else{if(t.len!==t.buf.length)throw new Error("length of push value not equal to length of data");this.stack.push(t.buf)}}else if(u||q.OP_IF<=n&&n<=q.OP_ENDIF)switch(n){case q.OP_1NEGATE:case q.OP_1:case q.OP_2:case q.OP_3:case q.OP_4:case q.OP_5:case q.OP_6:case q.OP_7:case q.OP_8:case q.OP_9:case q.OP_10:case q.OP_11:case q.OP_12:case q.OP_13:case q.OP_14:case q.OP_15:case q.OP_16:{let r=n-(q.OP_1-1),s=new Z(r).toScriptNumBuffer();this.stack.push(s)}break;case q.OP_NOP:break;case q.OP_CHECKLOCKTIMEVERIFY:{if(!(this.flags&re.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY)){if(this.flags&re.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errStr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;let r;try{const s=this.stack[this.stack.length-1];r=new Z().fromScriptNumBuffer(s,e,5).toNumber()}catch(s){return this.errStr=(s.message.includes("minimal"),"SCRIPT_ERR_UNKNOWN_ERROR"),s.message.includes("overflow")&&(this.errStr="SCRIPTNUM_OVERFLOW"),s.message.includes("minimal")&&(this.errStr="SCRIPT_ERR_MINIMALDATA"),!1}if(r<0)return this.errStr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if(!this.checkLockTime(r))return this.errStr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1}break;case q.OP_CHECKSEQUENCEVERIFY:{if(!(this.flags&re.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY)){if(this.flags&re.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errStr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;let r;try{const s=this.stack[this.stack.length-1];r=new Z().fromScriptNumBuffer(s,e,5).toNumber()}catch{return this.errStr="SCRIPTNUM_OVERFLOW",!1}if(r<0)return this.errStr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if((r&He.SEQUENCE_LOCKTIME_DISABLE_FLAG)!==0)break;if(!this.checkSequence(r))return this.errStr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1}break;case q.OP_NOP1:case q.OP_NOP3:case q.OP_NOP4:case q.OP_NOP5:case q.OP_NOP6:case q.OP_NOP7:case q.OP_NOP8:case q.OP_NOP9:case q.OP_NOP10:if(this.isChronicle()&&(n===q.OP_SUBSTR_CHRONICLE||n===q.OP_LEFT_CHRONICLE||n===q.OP_RIGHT_CHRONICLE||n===q.OP_LSHIFTNUM||n===q.OP_RSHIFTNUM))return this.stepChronicleOp(n,e);if(this.flags&re.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errStr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break;case q.OP_IF:case q.OP_NOTIF:case q.OP_VERIF:case q.OP_VERNOTIF:{if((n===q.OP_VERIF||n===q.OP_VERNOTIF)&&!this.isChronicle())return this.errStr="SCRIPT_ERR_BAD_OPCODE",!1;let r=!1;if(u){if(this.stack.length<1)return this.errStr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;const s=this.stack.pop();if((n===q.OP_IF||n===q.OP_NOTIF)&&(this.flags&re.SCRIPT_VERIFY_MINIMALIF)!==0&&!this.isChronicle()&&(s.length>1||s.length===1&&s[0]!==1))return this.errStr="SCRIPT_ERR_MINIMALIF",!1;n===q.OP_VERIF||n===q.OP_VERNOTIF?r=s.length===4&&s.equals(this.versionBuf()):r=re.castToBool(s),(n===q.OP_NOTIF||n===q.OP_VERNOTIF)&&(r=!r)}this.ifStack.push(r)}break;case q.OP_ELSE:if(this.ifStack.length===0)return this.errStr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.ifStack[this.ifStack.length-1]=!this.ifStack[this.ifStack.length-1];break;case q.OP_ENDIF:if(this.ifStack.length===0)return this.errStr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.ifStack.pop();break;case q.OP_VER:{if(!this.isChronicle())return this.errStr="SCRIPT_ERR_BAD_OPCODE",!1;this.stack.push(this.versionBuf())}break;case q.OP_VERIFY:{if(this.stack.length<1)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;const r=this.stack[this.stack.length-1];if(re.castToBool(r))this.stack.pop();else return this.errStr="SCRIPT_ERR_VERIFY",!1}break;case q.OP_RETURN:return this.isUnlockingScript&&this.isChronicle()?(this.pc=this.script.chunks.length,this.ifStack=[],!0):(this.errStr="SCRIPT_ERR_OP_RETURN",!1);case q.OP_TOALTSTACK:if(this.stack.length<1)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.altStack.push(this.stack.pop());break;case q.OP_FROMALTSTACK:if(this.altStack.length<1)return this.errStr="SCRIPT_ERR_INVALID_ALTSTACK_OPERATION",!1;this.stack.push(this.altStack.pop());break;case q.OP_2DROP:if(this.stack.length<2)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop(),this.stack.pop();break;case q.OP_2DUP:{if(this.stack.length<2)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;const r=this.stack[this.stack.length-2],s=this.stack[this.stack.length-1];this.stack.push(r),this.stack.push(s)}break;case q.OP_3DUP:{if(this.stack.length<3)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;const r=this.stack[this.stack.length-3],s=this.stack[this.stack.length-2],a=this.stack[this.stack.length-1];this.stack.push(r),this.stack.push(s),this.stack.push(a)}break;case q.OP_2OVER:{if(this.stack.length<4)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;const r=this.stack[this.stack.length-4],s=this.stack[this.stack.length-3];this.stack.push(r),this.stack.push(s)}break;case q.OP_2ROT:{if(this.stack.length<6)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;const r=this.stack.splice(this.stack.length-6,2);this.stack.push(r[0]),this.stack.push(r[1])}break;case q.OP_2SWAP:{if(this.stack.length<4)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;const r=this.stack.splice(this.stack.length-4,2);this.stack.push(r[0]),this.stack.push(r[1])}break;case q.OP_IFDUP:{if(this.stack.length<1)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;const r=this.stack[this.stack.length-1];re.castToBool(r)&&this.stack.push(r)}break;case q.OP_DEPTH:{const r=new Z(this.stack.length).toScriptNumBuffer();this.stack.push(r)}break;case q.OP_DROP:if(this.stack.length<1)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop();break;case q.OP_DUP:if(this.stack.length<1)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(this.stack[this.stack.length-1]);break;case q.OP_NIP:if(this.stack.length<2)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,1);break;case q.OP_OVER:if(this.stack.length<2)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(this.stack[this.stack.length-2]);break;case q.OP_PICK:case q.OP_ROLL:{if(this.stack.length<2)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;let r;try{const a=this.stack[this.stack.length-1];r=new Z().fromScriptNumBuffer(a,e,this.scriptNumMaxSize()).toNumber()}catch(a){return this.errStr=a.message.includes("overflow")?"SCRIPTNUM_OVERFLOW":"SCRIPT_ERR_UNKNOWN_ERROR",!1}if(this.stack.pop(),r<0||r>=this.stack.length)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;const s=this.stack[this.stack.length-r-1];n===q.OP_ROLL&&this.stack.splice(this.stack.length-r-1,1),this.stack.push(s)}break;case q.OP_ROT:{if(this.stack.length<3)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;const r=this.stack[this.stack.length-3],s=this.stack[this.stack.length-2],a=this.stack[this.stack.length-1];this.stack[this.stack.length-3]=s,this.stack[this.stack.length-2]=a,this.stack[this.stack.length-1]=r}break;case q.OP_SWAP:{if(this.stack.length<2)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;const r=this.stack[this.stack.length-2],s=this.stack[this.stack.length-1];this.stack[this.stack.length-2]=s,this.stack[this.stack.length-1]=r}break;case q.OP_TUCK:if(this.stack.length<2)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,0,this.stack[this.stack.length-1]);break;case q.OP_SIZE:{if(this.stack.length<1)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;const r=new Z(this.stack[this.stack.length-1].length);this.stack.push(r.toScriptNumBuffer())}break;case q.OP_AND:case q.OP_OR:case q.OP_XOR:{if(this.stack.length<2)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;const r=this.stack[this.stack.length-2],s=this.stack[this.stack.length-1];if(r.length!==s.length)return this.errStr="SCRIPT_ERR_INVALID_OPERAND_SIZE",!1;switch(n){case q.OP_AND:for(let a=0;a<r.length;a++)r[a]&=s[a];break;case q.OP_OR:for(let a=0;a<r.length;a++)r[a]|=s[a];break;case q.OP_XOR:for(let a=0;a<r.length;a++)r[a]^=s[a];break}this.stack.pop()}break;case q.OP_INVERT:{if(this.stack.length<1)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;const r=this.stack[this.stack.length-1];for(let s=0;s<r.length;s++)r[s]=~r[s]}break;case q.OP_LSHIFT:case q.OP_RSHIFT:{if(this.stack.length<2)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;const r=this.stack[this.stack.length-2];let s=new Z(r),a;try{const f=this.stack[this.stack.length-1];a=new Z().fromScriptNumBuffer(f,e,this.scriptNumMaxSize()).toNumber()}catch(f){return this.errStr=f.message.includes("overflow")?"SCRIPTNUM_OVERFLOW":"SCRIPT_ERR_UNKNOWN_ERROR",!1}if(a<0)return this.errStr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;switch(this.stack.pop(),this.stack.pop(),n){case q.OP_LSHIFT:s=s.shln(a);break;case q.OP_RSHIFT:s=s.shrn(a);break}let o=s.toBuffer({endian:"big"});o.length>r.length?o=o.slice(o.length-r.length):o.length<r.length&&(o=Buffer.concat([Buffer.alloc(r.length-o.length),o])),this.stack.push(o)}break;case q.OP_EQUAL:case q.OP_EQUALVERIFY:{if(this.stack.length<2)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;const r=this.stack[this.stack.length-2],s=this.stack[this.stack.length-1],a=kt(r,s);if(this.stack.pop(),this.stack.pop(),this.stack.push(a?re.true:re.false),n===q.OP_EQUALVERIFY)if(a)this.stack.pop();else return this.errStr="SCRIPT_ERR_EQUALVERIFY",!1}break;case q.OP_1ADD:case q.OP_1SUB:case q.OP_2MUL:case q.OP_2DIV:case q.OP_NEGATE:case q.OP_ABS:case q.OP_NOT:case q.OP_0NOTEQUAL:{if((n===q.OP_2MUL||n===q.OP_2DIV)&&!this.isChronicle())return this.errStr="SCRIPT_ERR_BAD_OPCODE",!1;if(this.stack.length<1)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;const r=this.stack[this.stack.length-1];let s;try{s=new Z().fromScriptNumBuffer(r,e,this.scriptNumMaxSize())}catch(a){return this.errStr=a.message.includes("overflow")?"SCRIPTNUM_OVERFLOW":"SCRIPT_ERR_UNKNOWN_ERROR",!1}switch(n){case q.OP_1ADD:s=s.add(1);break;case q.OP_1SUB:s=s.sub(1);break;case q.OP_2MUL:s=s.add(s);break;case q.OP_2DIV:s=s.div(new Z(2));break;case q.OP_NEGATE:s=s.neg();break;case q.OP_ABS:s.lt(0)&&(s=s.neg());break;case q.OP_NOT:s=new Z(s.eq(0)?1:0);break;case q.OP_0NOTEQUAL:s=new Z(s.neq(0)?1:0);break}this.stack.pop(),this.stack.push(s.toScriptNumBuffer())}break;case q.OP_ADD:case q.OP_SUB:case q.OP_MUL:case q.OP_DIV:case q.OP_MOD:case q.OP_BOOLAND:case q.OP_BOOLOR:case q.OP_NUMEQUAL:case q.OP_NUMEQUALVERIFY:case q.OP_NUMNOTEQUAL:case q.OP_LESSTHAN:case q.OP_GREATERTHAN:case q.OP_LESSTHANOREQUAL:case q.OP_GREATERTHANOREQUAL:case q.OP_MIN:case q.OP_MAX:{if(this.stack.length<2)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;let r,s;try{r=new Z().fromScriptNumBuffer(this.stack[this.stack.length-2],e,this.scriptNumMaxSize()),s=new Z().fromScriptNumBuffer(this.stack[this.stack.length-1],e,this.scriptNumMaxSize())}catch(o){return this.errStr=o.message.includes("overflow")?"SCRIPTNUM_OVERFLOW":"SCRIPT_ERR_UNKNOWN_ERROR",!1}let a=new Z(0);switch(n){case q.OP_ADD:a=r.add(s);break;case q.OP_SUB:a=r.sub(s);break;case q.OP_MUL:a=r.mul(s);break;case q.OP_DIV:if(s.eq(0))return this.errStr="SCRIPT_ERR_DIV_BY_ZERO",!1;a=r.div(s);break;case q.OP_MOD:if(s.eq(0))return this.errStr="SCRIPT_ERR_DIV_BY_ZERO",!1;a=r.mod(s);break;case q.OP_BOOLAND:a=new Z(r.neq(0)&&s.neq(0)?1:0);break;case q.OP_BOOLOR:a=new Z(r.neq(0)||s.neq(0)?1:0);break;case q.OP_NUMEQUAL:a=new Z(r.eq(s)?1:0);break;case q.OP_NUMEQUALVERIFY:a=new Z(r.eq(s)?1:0);break;case q.OP_NUMNOTEQUAL:a=new Z(r.neq(s)?1:0);break;case q.OP_LESSTHAN:a=new Z(r.lt(s)?1:0);break;case q.OP_GREATERTHAN:a=new Z(r.gt(s)?1:0);break;case q.OP_LESSTHANOREQUAL:a=new Z(r.leq(s)?1:0);break;case q.OP_GREATERTHANOREQUAL:a=new Z(r.geq(s)?1:0);break;case q.OP_MIN:a=r.lt(s)?r:s;break;case q.OP_MAX:a=r.gt(s)?r:s;break}if(this.stack.pop(),this.stack.pop(),this.stack.push(a.toScriptNumBuffer()),n===q.OP_NUMEQUALVERIFY)if(re.castToBool(this.stack[this.stack.length-1]))this.stack.pop();else return this.errStr="SCRIPT_ERR_NUMEQUALVERIFY",!1}break;case q.OP_WITHIN:{if(this.stack.length<3)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;let r,s,a;try{r=new Z().fromScriptNumBuffer(this.stack[this.stack.length-3],e,this.scriptNumMaxSize()),s=new Z().fromScriptNumBuffer(this.stack[this.stack.length-2],e,this.scriptNumMaxSize()),a=new Z().fromScriptNumBuffer(this.stack[this.stack.length-1],e,this.scriptNumMaxSize())}catch(f){return this.errStr=f.message.includes("overflow")?"SCRIPTNUM_OVERFLOW":"SCRIPT_ERR_UNKNOWN_ERROR",!1}const o=s.leq(r)&&r.lt(a);this.stack.pop(),this.stack.pop(),this.stack.pop(),this.stack.push(o?re.true:re.false)}break;case q.OP_RIPEMD160:case q.OP_SHA1:case q.OP_SHA256:case q.OP_HASH160:case q.OP_HASH256:{if(this.stack.length<1)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;const r=this.stack[this.stack.length-1];let s;n===q.OP_RIPEMD160?s=ae.ripemd160(r):n===q.OP_SHA1?s=ae.sha1(r):n===q.OP_SHA256?s=ae.sha256(r):n===q.OP_HASH160?s=ae.sha256Ripemd160(r):n===q.OP_HASH256&&(s=ae.sha256Sha256(r)),this.stack.pop(),this.stack.push(s)}break;case q.OP_CODESEPARATOR:this.pBeginCodeHash=this.pc;break;case q.OP_CHECKSIG:case q.OP_CHECKSIGVERIFY:{if(this.stack.length<2)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;const r=this.stack[this.stack.length-2],s=this.stack[this.stack.length-1];if(!this.checkSigEncoding(r)||!this.checkPubKeyEncoding(s))return!1;const a=this.buildSubScript();if((r.length>0?r.readUInt8(r.length-1):0)&he.SIGHASH_FORKID){if(!(this.flags&re.SCRIPT_ENABLE_SIGHASH_FORKID))return this.errStr="SCRIPT_ERR_ILLEGAL_FORKID",!1}else a.findAndDelete(new Ae().writeBuffer(r));let f;try{const i=new he().fromTxFormat(r),c=new Ue().fromBuffer(s,!1);f=this.tx.verify(i,c,this.nIn,a,!!(this.flags&re.SCRIPT_VERIFY_LOW_S)&&!this.isChronicle(),this.valueBn,this.flags)}catch{f=!1}if(!f&&(this.flags&re.SCRIPT_VERIFY_NULLFAIL)!==0&&!this.isChronicle()&&r.length>0)return this.errStr="SCRIPT_ERR_SIG_NULLFAIL",!1;if(this.stack.pop(),this.stack.pop(),this.stack.push(f?re.true:re.false),n===q.OP_CHECKSIGVERIFY)if(f)this.stack.pop();else return this.errStr="SCRIPT_ERR_CHECKSIGVERIFY",!1}break;case q.OP_CHECKMULTISIG:case q.OP_CHECKMULTISIGVERIFY:{let r=1;if(this.stack.length<r)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;let s;try{const d=this.stack[this.stack.length-r];s=new Z().fromScriptNumBuffer(d,e).toNumber()}catch(d){return this.errStr=d.message.includes("overflow")?"SCRIPTNUM_OVERFLOW":"SCRIPT_ERR_UNKNOWN_ERROR",!1}if(s<0||s>20)return this.errStr="SCRIPT_ERR_PUBKEY_COUNT",!1;if(this.nOpCount+=s,this.nOpCount>201)return this.errStr="SCRIPT_ERR_OP_COUNT",!1;let a=++r;if(r+=s,this.stack.length<r)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;let o;try{const d=this.stack[this.stack.length-r];o=new Z().fromScriptNumBuffer(d,e).toNumber()}catch(d){return this.errStr=d.message.includes("overflow")?"SCRIPTNUM_OVERFLOW":"SCRIPT_ERR_UNKNOWN_ERROR",!1}if(o<0||o>s)return this.errStr="SCRIPT_ERR_SIG_COUNT",!1;let f=++r;if(r+=o,this.stack.length<r)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;const i=this.buildSubScript();for(let d=0;d<o;d++){const b=this.stack[this.stack.length-f-d];if((b.length>0?b.readUInt8(b.length-1):0)&he.SIGHASH_FORKID){if(!(this.flags&re.SCRIPT_ENABLE_SIGHASH_FORKID))return this.errStr="SCRIPT_ERR_ILLEGAL_FORKID",!1}else i.findAndDelete(new Ae().writeBuffer(b))}let c=!0,h=Buffer.alloc(0);for(;c&&o>0;){const d=this.stack[this.stack.length-f];h=d;const b=this.stack[this.stack.length-a];if(!this.checkSigEncoding(d)||!this.checkPubKeyEncoding(b))return!1;let p;try{const y=new he().fromTxFormat(d),v=new Ue().fromBuffer(b,!1);p=this.tx.verify(y,v,this.nIn,i,!!(this.flags&re.SCRIPT_VERIFY_LOW_S)&&!this.isChronicle(),this.valueBn,this.flags)}catch{p=!1}p&&(f++,o--),a++,s--,o>s&&(c=!1)}if(!c&&s===0&&(this.flags&re.SCRIPT_VERIFY_NULLFAIL)!==0&&!this.isChronicle()&&h.length>0)return this.errStr="SCRIPT_ERR_SIG_NULLFAIL",!1;for(;r-- >1;)this.stack.pop();if(this.stack.length<1)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(this.flags&re.SCRIPT_VERIFY_NULLDUMMY&&!this.isChronicle()&&this.stack[this.stack.length-1].length)return this.errStr="SCRIPT_ERR_SIG_NULLDUMMY",!1;if(this.stack.pop(),this.stack.push(c?re.true:re.false),n===q.OP_CHECKMULTISIGVERIFY)if(c)this.stack.pop();else return this.errStr="SCRIPT_ERR_CHECKMULTISIGVERIFY",!1}break;case q.OP_CAT:{if(this.stack.length<2)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;const r=this.stack[this.stack.length-2],s=this.stack[this.stack.length-1];this.stack[this.stack.length-2]=Buffer.concat([r,s]),this.stack.pop()}break;case q.OP_SPLIT:{if(this.stack.length<2)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;const r=this.stack[this.stack.length-2];let s;try{const f=this.stack[this.stack.length-1];s=new Z().fromScriptNumBuffer(f,e).toNumber()}catch(f){return this.errStr=f.message.includes("overflow")?"SCRIPTNUM_OVERFLOW":"SCRIPT_ERR_UNKNOWN_ERROR",!1}if(s<0||s>r.length)return this.errStr="SCRIPT_ERR_INVALID_SPLIT_RANGE",!1;const a=r.slice(0,s),o=r.slice(s);this.stack.pop(),this.stack.pop(),this.stack.push(a),this.stack.push(o)}break;case q.OP_NUM2BIN:{if(this.stack.length<2)return this.errStr="OP_NUM2BIN requires at least two items to be on the stack.",!1;let r;try{const f=this.stack[this.stack.length-1];r=new Z().fromScriptNumBuffer(f,e,this.scriptNumMaxSize()).toNumber()}catch(f){return this.errStr=f.message.includes("overflow")?"SCRIPTNUM_OVERFLOW":"SCRIPT_ERR_UNKNOWN_ERROR",!1}if(r>this.maxScriptElementSize())return this.errStr=`It's not currently possible to push data larger than ${re.MAX_SCRIPT_ELEMENT_SIZE} bytes.`,!1;this.stack.pop();let s=this.stack[this.stack.length-1];if(s=Gf(s),s.length>r)return this.errStr="OP_NUM2BIN requires that the size expressed in the top stack item is large enough to hold the value expressed in the second-from-top stack item.",!1;if(s.length===r)break;let a=0;s.length>0&&(a=s[s.length-1]&128,s[s.length-1]&=127);const o=Buffer.alloc(r);s.copy(o),r>0&&(o[r-1]|=a),this.stack[this.stack.length-1]=o}break;case q.OP_BIN2NUM:{if(this.stack.length<1)return this.errStr="OP_BIN2NUM requires at least one item to be on the stack.",!1;const r=this.stack[this.stack.length-1],s=Gf(r);try{this.stack[this.stack.length-1]=new Z().fromScriptNumBuffer(s,e,this.scriptNumMaxSize()).toScriptNumBuffer()}catch(a){return this.errStr=a.message.includes("overflow")?"SCRIPTNUM_OVERFLOW":"SCRIPT_ERR_UNKNOWN_ERROR",!1}}break;default:return this.errStr="SCRIPT_ERR_BAD_OPCODE",!1}return!0}fromJSON(e){return this.fromJSONNoTx(e),this.tx=e.tx?new Me().fromJSON(e.tx):void 0,this}fromJSONNoTx(e){return this.fromObject({script:e.script!==void 0?new Ae().fromJSON(e.script):void 0,nIn:e.nIn}),this.stack=[],e.stack.forEach((function(t){this.stack.push(Buffer.from(t,"hex"))}).bind(this)),this.altStack=[],e.altStack.forEach((function(t){this.altStack.push(Buffer.from(t,"hex"))}).bind(this)),this.fromObject({pc:e.pc,pBeginCodeHash:e.pBeginCodeHash,nOpCount:e.nOpCount,ifStack:e.ifStack,errStr:e.errStr,flags:e.flags}),this}fromBr(e){let t=e.readVarIntNum(),n=e.read(t);this.fromJSONNoTx(JSON.parse(n.toString()));let u=e.readVarIntNum();if(u>0){let r=e.read(u);this.tx=new Me().fromFastBuffer(r)}return this}toJSON(){let e=this.toJSONNoTx();return e.tx=this.tx?this.tx.toJSON():void 0,e}toJSONNoTx(){let e=[];this.stack.forEach(function(n){e.push(n.toString("hex"))});let t=[];return this.altStack.forEach(function(n){t.push(n.toString("hex"))}),{script:this.script?this.script.toJSON():void 0,nIn:this.nIn,stack:e,altStack:t,pc:this.pc,pBeginCodeHash:this.pBeginCodeHash,nOpCount:this.nOpCount,ifStack:this.ifStack,errStr:this.errStr,flags:this.flags,preImage:this?.preImage?this.preImage.toString("hex"):"",hashBuf:this?.hashBuf?this.hashBuf.toString("hex"):""}}toBw(e){e||(e=new ke);let t=Buffer.from(JSON.stringify(this.toJSONNoTx()));if(e.writeVarIntNum(t.length),e.write(t),this.tx){let n=this.tx.toFastBuffer();e.writeVarIntNum(n.length),e.write(n)}else e.writeVarIntNum(0);return e}static getFlags(e){let t=0;return e.indexOf("NONE")!==-1&&(t=t|re.SCRIPT_VERIFY_NONE),e.indexOf("P2SH")!==-1&&(t=t|re.SCRIPT_VERIFY_P2SH),e.indexOf("STRICTENC")!==-1&&(t=t|re.SCRIPT_VERIFY_STRICTENC),e.indexOf("DERSIG")!==-1&&(t=t|re.SCRIPT_VERIFY_DERSIG),e.indexOf("LOW_S")!==-1&&(t=t|re.SCRIPT_VERIFY_LOW_S),e.indexOf("NULLDUMMY")!==-1&&(t=t|re.SCRIPT_VERIFY_NULLDUMMY),e.indexOf("SIGPUSHONLY")!==-1&&(t=t|re.SCRIPT_VERIFY_SIGPUSHONLY),e.indexOf("MINIMALDATA")!==-1&&(t=t|re.SCRIPT_VERIFY_MINIMALDATA),e.indexOf("DISCOURAGE_UPGRADABLE_NOPS")!==-1&&(t=t|re.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS),e.indexOf("CLEANSTACK")!==-1&&(t=t|re.SCRIPT_VERIFY_CLEANSTACK),e.indexOf("CHECKLOCKTIMEVERIFY")!==-1&&(t=t|re.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY),e.indexOf("CHECKSEQUENCEVERIFY")!==-1&&(t=t|re.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY),e.indexOf("SIGHASH_FORKID")!==-1&&(t=t|re.SCRIPT_ENABLE_SIGHASH_FORKID),e.indexOf("MINIMALIF")!==-1&&(t=t|re.SCRIPT_VERIFY_MINIMALIF),e.indexOf("NULLFAIL")!==-1&&(t=t|re.SCRIPT_VERIFY_NULLFAIL),e.indexOf("CHRONICLE")!==-1&&(t=t|re.SCRIPT_VERIFY_CHRONICLE),t}*eval(){if(this.isPreGenesis())for(const e of this.script.chunks)T1.includes(e.opCodeNum)&&(this.errStr="SCRIPT_ERR_DISABLED_OPCODE",yield!1);this.script.toBuffer().length>this.scriptLimit&&(this.errStr="SCRIPT_ERR_SCRIPT_SIZE",yield!1);try{for(;this.pc<this.script.chunks.length;){const e=yield*this.step();e?yield e:yield!1}this.stack.length+this.altStack.length>this.stackLimit&&(this.errStr="SCRIPT_ERR_STACK_SIZE",yield!1)}catch(e){this.errStr="SCRIPT_ERR_UNKNOWN_ERROR: "+e,yield!1}this.ifStack.length>0&&(this.errStr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",yield!1),yield!0}verify(e,t,n,u,r,s){const a=this.results(e,t,n,u,r,s);for(const o of a)if(!o)return!1;return!0}*results(e,t,n,u,r,s){let a;this.fromObject({script:e,tx:n,nIn:u,flags:r,valueBn:s}),this.setLimits(),this.isUnlockingScript=!0,this.lockingScript=t,(r&re.SCRIPT_VERIFY_SIGPUSHONLY)!==0&&!this.isChronicle()&&!e.isPushOnly()&&(this.errStr=this.errStr||"SCRIPT_ERR_SIG_PUSHONLY",yield!1),yield*this.eval(),r&re.SCRIPT_VERIFY_P2SH&&(a=this.stack.slice());const o=this.stack;this.initialize(),this.fromObject({script:t,stack:o,tx:n,nIn:u,flags:r,valueBn:s}),this.setLimits(),this.isUnlockingScript=!1,yield*this.eval(),this.stack.length===0&&(this.errStr=this.errStr||"SCRIPT_ERR_EVAL_FALSE",yield!1);const f=this.stack[this.stack.length-1];if(re.castToBool(f)||(this.errStr=this.errStr||"SCRIPT_ERR_EVAL_FALSE",yield!1),r&re.SCRIPT_VERIFY_P2SH&&t.isScriptHashOut()){e.isPushOnly()||(this.errStr=this.errStr||"SCRIPT_ERR_SIG_PUSHONLY",yield!1);const i=this.stack;if(this.stack=a,a=i,this.stack.length===0)throw new Error("internal error - stack copy empty");const c=this.stack[this.stack.length-1],h=new Ae().fromBuffer(c);this.stack.pop();const d=this.stack;this.initialize(),this.fromObject({script:h,stack:d,tx:n,nIn:u,flags:r,valueBn:s}),this.setLimits(),yield*this.eval(),this.stack.length===0&&(this.errStr=this.errStr||"SCRIPT_ERR_EVAL_FALSE",yield!1),re.castToBool(this.stack[this.stack.length-1])?yield!0:(this.errStr=this.errStr||"SCRIPT_ERR_EVAL_FALSE",yield!1)}if((r&re.SCRIPT_VERIFY_CLEANSTACK)!==0&&!this.isChronicle()){if(!(r&re.SCRIPT_VERIFY_P2SH))throw new Error("cannot use CLEANSTACK without P2SH");this.stack.length!==1&&(this.errStr=this.errStr||"SCRIPT_ERR_CLEANSTACK",yield!1)}yield!0}getDebugObject(){const e=this.pc-1;return{errStr:this.errStr,scriptStr:this.script?this.script.toString():"no script found",pc:e,stack:this.stack.map(t=>t.toString("hex")),altStack:this.altStack.map(t=>t.toString("hex")),opCodeStr:this.script&&this.script.chunks&&this.script.chunks[e]?q.fromNumber(this.script.chunks[e].opCodeNum).toString():"no script or chunk found"}}getDebugString(){return JSON.stringify(this.getDebugObject(),null,2)}}re.true=Buffer.from([1]);re.false=Buffer.from([]);re.MAX_SCRIPT_ELEMENT_SIZE=500*1e3;re.DEFAULT_SCRIPT_NUM_LENGTH_POLICY_AFTER_GENESIS=10*1e3;re.LOCKTIME_THRESHOLD=5e8;re.SCRIPT_VERIFY_NONE=0;re.SCRIPT_VERIFY_P2SH=1;re.SCRIPT_VERIFY_STRICTENC=2;re.SCRIPT_VERIFY_DERSIG=4;re.SCRIPT_VERIFY_LOW_S=8;re.SCRIPT_VERIFY_NULLDUMMY=16;re.SCRIPT_VERIFY_SIGPUSHONLY=32;re.SCRIPT_VERIFY_MINIMALDATA=64;re.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS=128;re.SCRIPT_VERIFY_CLEANSTACK=256;re.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY=512;re.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY=1024;re.SCRIPT_VERIFY_MINIMALIF=8192;re.SCRIPT_VERIFY_NULLFAIL=16384;re.SCRIPT_ENABLE_SIGHASH_FORKID=65536;re.SCRIPT_VERIFY_PREGENESIS_LIMITS=1<<17;re.PREGENESIS_SCRIPT_NUM_LENGTH=4;re.PREGENESIS_MAX_SCRIPT_ELEMENT_SIZE=520;re.PREGENESIS_SCRIPT_LIMIT=1e4;re.PREGENESIS_STACK_LIMIT=1e3;re.SCRIPT_VERIFY_CHRONICLE=1<<18;re.DEFAULT_SCRIPT_NUM_LENGTH_POLICY_AFTER_CHRONICLE=32*1024*1024;re.defaultFlags=re.SCRIPT_VERIFY_P2SH|re.SCRIPT_VERIFY_STRICTENC|re.SCRIPT_ENABLE_SIGHASH_FORKID|re.SCRIPT_VERIFY_LOW_S|re.SCRIPT_VERIFY_NULLDUMMY|re.SCRIPT_VERIFY_DERSIG|re.SCRIPT_VERIFY_MINIMALDATA|re.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS|re.SCRIPT_VERIFY_CLEANSTACK|re.SCRIPT_VERIFY_SIGPUSHONLY|re.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY|re.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY;class $f extends Te{constructor(e=new Map){super({map:e})}toJSON(){const e={};return this.map.forEach((t,n)=>{e[n]=t.map(u=>({nScriptChunk:u.nScriptChunk,type:u.type,addressStr:u.addressStr,nHashType:u.nHashType,log:u.log}))}),e}fromJSON(e){return Object.keys(e).forEach(t=>{this.map.set(t,e[t].map(n=>({nScriptChunk:n.nScriptChunk,type:n.type,addressStr:n.addressStr,nHashType:n.nHashType,log:n.log})))}),this}setOne(e,t,n,u="sig",r,s=he.SIGHASH_ALL|he.SIGHASH_FORKID){const a=e.toString("hex")+":"+t,o={nScriptChunk:n,type:u,addressStr:r,nHashType:s};return this.map.set(a,[o]),this}setMany(e,t,n){const u=e.toString("hex")+":"+t;return n=n.map(r=>({type:r.type||"sig",nHashType:r.nHashType||he.SIGHASH_ALL|he.SIGHASH_FORKID,...r})),this.map.set(u,n),this}addOne(e,t,n,u="sig",r,s=he.SIGHASH_ALL|he.SIGHASH_FORKID){const a=this.get(e,t)||[];return a.push({nScriptChunk:n,type:u,addressStr:r,nHashType:s}),this.setMany(e,t,a),this}get(e,t){const n=e.toString("hex")+":"+t;return this.map.get(n)||[]}}class Wf extends Te{constructor(e=new Map){super({map:e})}toJSON(){const e={};return this.map.forEach((t,n)=>{e[n]=t.toHex()}),e}fromJSON(e){return Object.keys(e).forEach(t=>{this.map.set(t,yt.fromHex(e[t]))}),this}set(e,t,n){const u=e.toString("hex")+":"+t;return this.map.set(u,n),this}get(e,t){const n=e.toString("hex")+":"+t;return this.map.get(n)}setTx(e){const t=e.hash().toString("hex");return e.txOuts.forEach((n,u)=>{const r=t+":"+u;this.map.set(r,n)}),this}}const Kf=Oe.Default.TxBuilder;class C1 extends Te{constructor(e=new Me,t=[],n=[],u=new Wf,r=new $f,s,a,o,f=Kf.feePerKbNum,i=0,c=1,h=1,d=Kf.dust,b=!1,p=new Lr){super({tx:e,txIns:t,txOuts:n,uTxOutMap:u,sigOperations:r,changeScript:s,changeAmountBn:a,feeAmountBn:o,feePerKbNum:f,nLockTime:i,versionBytesNum:c,sigsPerInput:h,dust:d,dustChangeToFees:b,hashCache:p})}toJSON(){const e={};return e.tx=this.tx.toHex(),e.txIns=this.txIns.map(t=>t.toHex()),e.txOuts=this.txOuts.map(t=>t.toHex()),e.uTxOutMap=this.uTxOutMap.toJSON(),e.sigOperations=this.sigOperations.toJSON(),e.changeScript=this.changeScript?this.changeScript.toHex():void 0,e.changeAmountBn=this.changeAmountBn?this.changeAmountBn.toNumber():void 0,e.feeAmountBn=this.feeAmountBn?this.feeAmountBn.toNumber():void 0,e.feePerKbNum=this.feePerKbNum,e.sigsPerInput=this.sigsPerInput,e.dust=this.dust,e.dustChangeToFees=this.dustChangeToFees,e.hashCache=this.hashCache.toJSON(),e}fromJSON(e){return this.tx=new Me().fromHex(e.tx),this.txIns=e.txIns.map(t=>He.fromHex(t)),this.txOuts=e.txOuts.map(t=>yt.fromHex(t)),this.uTxOutMap=new Wf().fromJSON(e.uTxOutMap),this.sigOperations=new $f().fromJSON(e.sigOperations),this.changeScript=e.changeScript?new Ae().fromHex(e.changeScript):void 0,this.changeAmountBn=e.changeAmountBn?new Z(e.changeAmountBn):void 0,this.feeAmountBn=e.feeAmountBn?new Z(e.feeAmountBn):void 0,this.feePerKbNum=e.feePerKbNum||this.feePerKbNum,this.sigsPerInput=e.sigsPerInput||this.sigsPerInput,this.dust=e.dust||this.dust,this.dustChangeToFees=e.dustChangeToFees||this.dustChangeToFees,this.hashCache=Lr.fromJSON(e.hashCache),this}setFeePerKbNum(e){if(typeof e!="number"||e<0)throw new Error("cannot set a fee of zero or less");return this.feePerKbNum=e,this}setChangeAddress(e){return this.changeScript=e.toTxOutScript(),this}setChangeScript(e){return this.changeScript=e,this}setNLocktime(e){return this.nLockTime=e,this}setVersion(e){return this.versionBytesNum=e,this}setDust(e=Kf.dust){return this.dust=e,this}sendDustChangeToFees(e=!1){return this.dustChangeToFees=e,this}importPartiallySignedTx(e,t=this.uTxOutMap,n=this.sigOperations){return this.tx=e,this.uTxOutMap=t,this.sigOperations=n,this}inputFromScript(e,t,n,u,r){if(!Buffer.isBuffer(e)||typeof t!="number"||!(n instanceof yt)||!(u instanceof Ae))throw new Error("invalid one of: txHashBuf, txOutNum, txOut, script");return this.txIns.push(He.fromProperties(e,t,u,r)),this.uTxOutMap.set(e,t,n),this}addSigOperation(e,t,n,u,r,s){return this.sigOperations.addOne(e,t,n,u,r,s),this}inputFromPubKeyHash(e,t,n,u,r,s){if(!Buffer.isBuffer(e)||typeof t!="number"||!(n instanceof yt))throw new Error("invalid one of: txHashBuf, txOutNum, txOut");this.txIns.push(new He().fromObject({nSequence:r}).fromPubKeyHashTxOut(e,t,n,u)),this.uTxOutMap.set(e,t,n);const a=St.fromTxOutScript(n.script).toString();return this.addSigOperation(e,t,0,"sig",a,s),this.addSigOperation(e,t,1,"pubKey",a),this}outputToAddress(e,t){if(!(t instanceof St)||!(e instanceof Z))throw new Error("addr must be an Address, and valueBn must be a Bn");const n=new Ae().fromPubKeyHash(t.hashBuf);return this.outputToScript(e,n),this}outputToScript(e,t){if(!(t instanceof Ae)||!(e instanceof Z))throw new Error("script must be a Script, and valueBn must be a Bn");const n=yt.fromProperties(e,t);return this.txOuts.push(n),this}buildOutputs(){let e=new Z(0);return this.txOuts.forEach(t=>{if(t.valueBn.lt(this.dust)&&!t.script.isNonSpendable())throw new Error("cannot create output lesser than dust");e=e.add(t.valueBn),this.tx.addTxOut(t)}),e}buildInputs(e,t=0){let n=new Z(0);for(const u of this.txIns){const r=this.uTxOutMap.get(u.txHashBuf,u.txOutNum);if(n=n.add(r.valueBn),this.tx.addTxIn(u),n.geq(e)){if(t<=0)break;t--}}if(n.lt(e))throw new Error("not enough funds for outputs: inAmountBn "+n.toNumber()+" outAmountBn "+e.toNumber());return n}estimateSize(){let n=this.tx.toBuffer().length;return this.tx.txIns.forEach(u=>{const{txHashBuf:r,txOutNum:s}=u;this.sigOperations.get(r,s).forEach(o=>{const{nScriptChunk:f,type:i}=o,h=new Ae([u.script.chunks[f]]).toBuffer().length;if(n-=h,i==="sig")n+=72;else if(o.type==="pubKey")n+=35;else throw new Error("unsupported sig operations type")})}),n=n+1,Math.round(n)}estimateFee(e=new Z(0)){const t=Math.ceil(this.estimateSize()/1e3*this.feePerKbNum);return new Z(t).add(e)}build(e={useAllInputs:!1}){let t;if(this.txIns.length<=0)throw Error("tx-builder number of inputs must be greater than 0");if(!this.changeScript)throw new Error("must specify change script to use build method");for(let n=e.useAllInputs?this.txIns.length-1:0;n<this.txIns.length;n++){this.tx=new Me;const u=this.buildOutputs(),r=yt.fromProperties(new Z(0),this.changeScript);this.tx.addTxOut(r);let s;try{s=this.buildInputs(u,n)}catch(a){throw a.message.includes("not enough funds for outputs")?new Error("unable to gather enough inputs for outputs and fee"):a}if(this.changeAmountBn=s.sub(u),r.valueBn=this.changeAmountBn,t=this.estimateFee(),this.changeAmountBn.geq(t)&&this.changeAmountBn.sub(t).gt(this.dust))break}if(this.changeAmountBn.geq(t)){if(this.feeAmountBn=t,this.changeAmountBn=this.changeAmountBn.sub(this.feeAmountBn),this.tx.txOuts[this.tx.txOuts.length-1].valueBn=this.changeAmountBn,this.changeAmountBn.lt(this.dust))if(this.dustChangeToFees)this.tx.txOuts.pop(),this.tx.txOutsVi=qe.fromNumber(this.tx.txOutsVi.toNumber()-1),this.feeAmountBn=this.feeAmountBn.add(this.changeAmountBn),this.changeAmountBn=new Z(0);else throw new Error("unable to create change amount greater than dust");if(this.tx.nLockTime=this.nLockTime,this.tx.versionBytesNum=this.versionBytesNum,this.tx.txOuts.length===0)throw new Error("outputs length is zero - unable to create any outputs greater than dust");return this}else throw new Error("unable to gather enough inputs for outputs and fee")}sort(){return this.tx.sort(),this}static allSigsPresent(e,t){let n=0;for(let u=1;u<t.chunks.length-1;u++)t.chunks[u].buf&&n++;return n===e}static removeBlankSigs(e){e=new Ae(e.chunks.slice());for(let t=1;t<e.chunks.length-1;t++)e.chunks[t].buf||e.chunks.splice(t,1);return e}fillSig(e,t,n){const u=this.tx.txIns[e];return u.script.chunks[t]=new Ae().writeBuffer(n.toTxFormat()).chunks[0],u.scriptVi=qe.fromNumber(u.script.toBuffer().length),this}getSig(e,t=he.SIGHASH_ALL|he.SIGHASH_FORKID,n,u,r=Me.SCRIPT_ENABLE_SIGHASH_FORKID){let s;if(t&he.SIGHASH_FORKID&&r&Me.SCRIPT_ENABLE_SIGHASH_FORKID){const a=this.tx.txIns[n].txHashBuf,o=this.tx.txIns[n].txOutNum,f=this.uTxOutMap.get(a,o);if(!f)throw new Error("for SIGHASH_FORKID must provide UTXOs");s=f.valueBn}return this.tx.sign(e,t,n,u,s,r,this.hashCache)}asyncGetSig(e,t=he.SIGHASH_ALL|he.SIGHASH_FORKID,n,u,r=Me.SCRIPT_ENABLE_SIGHASH_FORKID){let s;if(t&he.SIGHASH_FORKID&&r&Me.SCRIPT_ENABLE_SIGHASH_FORKID){const a=this.tx.txIns[n].txHashBuf,o=this.tx.txIns[n].txOutNum,f=this.uTxOutMap.get(a,o);if(!f)throw new Error("for SIGHASH_FORKID must provide UTXOs");s=f.valueBn}return this.tx.asyncSign(e,t,n,u,s,r,this.hashCache)}signTxIn(e,t,n,u,r=he.SIGHASH_ALL|he.SIGHASH_FORKID,s=Me.SCRIPT_ENABLE_SIGHASH_FORKID){const a=this.tx.txIns[e],o=a.script;if(u===void 0&&o.isPubKeyHashIn()&&(u=0),u===void 0)throw new Error("cannot sign unknown script type for input "+e);const f=a.txHashBuf,i=a.txOutNum;n||(n=this.uTxOutMap.get(f,i));const h=n.script,d=this.getSig(t,r,e,h,s,this.hashCache);return this.fillSig(e,u,d),this}async asyncSignTxIn(e,t,n,u,r=he.SIGHASH_ALL|he.SIGHASH_FORKID,s=Me.SCRIPT_ENABLE_SIGHASH_FORKID){const a=this.tx.txIns[e],o=a.script;if(u===void 0&&o.isPubKeyHashIn()&&(u=0),u===void 0)throw new Error("cannot sign unknown script type for input "+e);const f=a.txHashBuf,i=a.txOutNum;n||(n=this.uTxOutMap.get(f,i));const h=n.script,d=await this.asyncGetSig(t,r,e,h,s,this.hashCache);return this.fillSig(e,u,d),this}signWithKeyPairs(e){const t={};for(const n of e){const u=St.fromPubKey(n.pubKey).toString();t[u]=n}for(const n in this.tx.txIns){const u=this.tx.txIns[n],r=this.sigOperations.get(u.txHashBuf,u.txOutNum);for(const s of r){const{nScriptChunk:a,type:o,addressStr:f,nHashType:i}=s,c=t[f];if(!c){s.log=`cannot find keyPair for addressStr ${f}`;continue}const h=this.uTxOutMap.get(u.txHashBuf,u.txOutNum);if(o==="sig")this.signTxIn(n,c,h,a,i),s.log="successfully inserted signature";else if(o==="pubKey")u.script.chunks[a]=new Ae().writeBuffer(c.pubKey.toBuffer()).chunks[0],u.setScript(u.script),s.log="successfully inserted public key";else{s.log=`cannot perform operation of type ${o}`;continue}}}return this}}class Dr extends Te{constructor(e,t,n,u){super({tx:e,txOutMap:t,errStr:n,interp:u})}verify(e=re.SCRIPT_ENABLE_SIGHASH_FORKID){return!this.checkStr()&&!this.verifyStr(e)}async asyncVerify(e){const t=await this.asyncVerifyStr(e);return!this.checkStr()&&!t}static verify(e,t,n){return new Dr(e,t).verify(n)}static asyncVerify(e,t,n){return new Dr(e,t).asyncVerify(n)}checkStr(){if(this.tx.txIns.length===0||this.tx.txInsVi.toNumber()===0)return this.errStr="transaction txIns empty",this.errStr;if(this.tx.txOuts.length===0||this.tx.txOutsVi.toNumber()===0)return this.errStr="transaction txOuts empty",this.errStr;if(this.tx.toBuffer().length>$r.MAX_BLOCK_SIZE)return this.errStr="transaction over the maximum block size",this.errStr;let e=new Z(0);for(let n=0;n<this.tx.txOuts.length;n++){const u=this.tx.txOuts[n];if(u.valueBn.lt(0))return this.errStr="transaction txOut "+n+" negative",this.errStr;if(u.valueBn.gt(Me.MAX_MONEY))return this.errStr="transaction txOut "+n+" greater than MAX_MONEY",this.errStr;if(e=e.add(u.valueBn),e.gt(Me.MAX_MONEY))return this.errStr="transaction txOut "+n+" total output greater than MAX_MONEY",this.errStr}const t={};for(let n=0;n<this.tx.txIns.length;n++){const u=this.tx.txIns[n],r=u.txHashBuf.toString("hex")+":"+u.txOutNum;if(t[r]!==void 0)return this.errStr="transaction input "+n+" duplicate input",this.errStr;t[r]=!0}if(this.tx.isCoinbase()){const n=this.tx.txIns[0].script.toBuffer();if(n.length<2||n.length>100)return this.errStr="coinbase trasaction script size invalid",this.errStr}else for(let n=0;n<this.tx.txIns.length;n++)if(this.tx.txIns[n].hasNullInput())return this.errStr="transaction input "+n+" has null input",this.errStr;return!1}verifyStr(e){for(let t=0;t<this.tx.txIns.length;t++)if(!this.verifyNIn(t,e))return this.errStr="input "+t+" failed script verify",this.errStr;return!1}async asyncVerifyStr(e){for(let t=0;t<this.tx.txIns.length;t++)if(!await this.asyncVerifyNIn(t,e))return this.errStr="input "+t+" failed script verify",this.errStr;return!1}verifyNIn(e,t){const n=this.tx.txIns[e],u=n.script,r=this.txOutMap.get(n.txHashBuf,n.txOutNum);if(!r)return console.log("output "+n.txOutNum+" not found"),!1;const s=r.script,a=r.valueBn;return this.interp=new re,this.interp.verify(u,s,this.tx,e,t,a)}async asyncVerifyNIn(e,t){const n=this.tx.txIns[e],u=n.script,r=this.txOutMap.get(n.txHashBuf,n.txOutNum);if(!r)return console.log("output "+n.txOutNum+" not found"),!1;const s=r.script,a=r.valueBn;this.interp=new re;const o=await le.asyncObjectMethod(this.interp,"verify",[u,s,this.tx,e,t,a]);return JSON.parse(o.resbuf.toString())}getDebugObject(){return{errStr:this.errStr,interpFailure:this.interp?this.interp.getDebugObject():void 0}}getDebugString(){return JSON.stringify(this.getDebugObject(),null,2)}}class ht{}ht.encrypt=function(l,e){const t=ht.buf2Words(e),n=ht.buf2Words(l),r=new Yf(t).encrypt(n);return ht.words2Buf(r)};ht.decrypt=function(l,e){const t=ht.buf2Words(l),n=ht.buf2Words(e),r=new Yf(n).decrypt(t);return ht.words2Buf(r)};ht.buf2Words=function(l){if(l.length%4)throw new Error("buf length must be a multiple of 4");const e=[];for(let t=0;t<l.length/4;t++)e.push(l.readUInt32BE(t*4));return e};ht.words2Buf=function(l){const e=Buffer.alloc(l.length*4);for(let t=0;t<l.length;t++)e.writeUInt32BE(l[t],t*4);return e};class Fe{}Fe.buf2BlocksBuf=function(l,e){const t=e/8,n=[];for(let u=0;u<=l.length/t;u++){let r=l.slice(u*t,u*t+t);r.length<e&&(r=Fe.pkcs7Pad(r,e)),n.push(r)}return n};Fe.blockBufs2Buf=function(l){let e=l[l.length-1];return e=Fe.pkcs7Unpad(e),l[l.length-1]=e,Buffer.concat(l)};Fe.encrypt=function(l,e,t,n){const u=e.length*8,r=Fe.buf2BlocksBuf(l,u),s=Fe.encryptBlocks(r,e,t,n);return Buffer.concat(s)};Fe.decrypt=function(l,e,t,n){const u=e.length,r=[];for(let o=0;o<l.length/u;o++)r.push(l.slice(o*u,o*u+u));const s=Fe.decryptBlocks(r,e,t,n);return Fe.blockBufs2Buf(s)};Fe.encryptBlock=function(l,e,t,n){const u=Fe.xorBufs(l,e);return t.encrypt(u,n)};Fe.decryptBlock=function(l,e,t,n){const u=t.decrypt(l,n);return Fe.xorBufs(u,e)};Fe.encryptBlocks=function(l,e,t,n){const u=[];for(let r=0;r<l.length;r++){const s=l[r],a=Fe.encryptBlock(s,e,t,n);u.push(a),e=a}return u};Fe.decryptBlocks=function(l,e,t,n){const u=[];for(let r=0;r<l.length;r++){const s=l[r],a=Fe.decryptBlock(s,e,t,n);u.push(a),e=s}return u};Fe.pkcs7Pad=function(l,e){const n=e/8-l.length,u=Buffer.alloc(n);return u.fill(n),Buffer.concat([l,u])};Fe.pkcs7Unpad=function(l){const e=l[l.length-1],t=l.slice(l.length-e,l.length),n=Buffer.alloc(e);if(n.fill(e),!kt(t,n))throw new Error("invalid padding");return l.slice(0,l.length-e)};Fe.xorBufs=function(l,e){if(l.length!==e.length)throw new Error("bufs must have the same length");const t=Buffer.alloc(l.length);for(let n=0;n<l.length;n++)t[n]=l[n]^e[n];return t};class At{}At.encrypt=function(l,e,t,n=!0){t=t||Rt.getRandomBuffer(128/8);const u=Fe.encrypt(l,t,ht,e);return n?Buffer.concat([t,u]):u};At.decrypt=function(l,e,t=!1){if(t){const n=l;return Fe.decrypt(n,t,ht,e)}else{const n=l.slice(0,16),u=l.slice(128/8);return Fe.decrypt(u,n,ht,e)}};class Dt{}Dt.encrypt=function(l,e,t){const n=At.encrypt(l,e,t),u=ae.sha256Hmac(n,e);return Buffer.concat([u,n])};Dt.asyncEncrypt=async function(l,e,t){t||(t=Rt.getRandomBuffer(128/8));const n=[l,e,t];return(await le.asyncClassMethod(Dt,"encrypt",n)).resbuf};Dt.decrypt=function(l,e){if(l.length<512/8)throw new Error("The encrypted data must be at least 256+128+128 bits, which is the length of the Hmac plus the iv plus the smallest encrypted data size");const t=l.slice(0,256/8);l=l.slice(256/8,l.length);const n=ae.sha256Hmac(l,e);if(!kt(t,n))throw new Error("Message authentication failed - Hmacs are not equivalent");return At.decrypt(l,e)};Dt.asyncDecrypt=async function(l,e){const t=[l,e];return(await le.asyncClassMethod(Dt,"decrypt",t)).resbuf};class wt{}wt.ivkEkM=function(l,e){const t=l.bn,u=e.point.mul(t),s=new Ue(u).toBuffer(),a=ae.sha512(s);return{iv:a.slice(0,16),kE:a.slice(16,32),kM:a.slice(32,64)}};wt.electrumEncrypt=function(l,e,t,n=!1){if(!Buffer.isBuffer(l))throw new Error("messageBuf must be a buffer");let u;t===null&&(t=st.fromRandom()),n||(u=t.pubKey.toDer(!0));const{iv:r,kE:s,kM:a}=wt.ivkEkM(t.privKey,e),o=At.encrypt(l,s,r,!1),f=Buffer.from("BIE1");let i;u?i=Buffer.concat([f,u,o]):i=Buffer.concat([f,o]);const c=ae.sha256Hmac(i,a);return Buffer.concat([i,c])};wt.electrumDecrypt=function(l,e,t=null){if(!Buffer.isBuffer(l))throw new Error("encBuf must be a buffer");const n=32;if(!l.slice(0,4).equals(Buffer.from("BIE1")))throw new Error("Invalid Magic");let r=4;if(t===null){const h=l.slice(4,37);t=Ue.fromDer(h),r=37}const{iv:s,kE:a,kM:o}=wt.ivkEkM(e,t),f=l.slice(r,l.length-n),i=l.slice(l.length-n,l.length),c=ae.sha256Hmac(l.slice(0,l.length-n),o);if(!i.equals(c))throw new Error("Invalid checksum");return At.decrypt(f,a,s)};wt.bitcoreEncrypt=function(l,e,t,n){t||(t=st.fromRandom());const u=t.privKey.bn,s=t.pubKey.toDer(!0),i=e.point.mul(u).getX().toBuffer({size:32}),c=ae.sha512(i),h=c.slice(0,32),d=c.slice(32,64),b=At.encrypt(l,h,n),p=ae.sha256Hmac(b,d);return Buffer.concat([s,b,p])};wt.asyncBitcoreEncrypt=async function(l,e,t,n){t||(t=await st.asyncFromRandom()),n||(n=Rt.getRandomBuffer(128/8));const u=[l,e,t,n];return(await le.asyncClassMethod(wt,"bitcoreEncrypt",u)).resbuf};wt.bitcoreDecrypt=function(l,e){const t=e.bn,r=Ue.fromDer(l.slice(0,33)).point.mul(t);if(r.eq(new Ie))throw new Error("P equals 0");const a=r.getX().toBuffer({size:32}),o=ae.sha512(a),f=o.slice(0,32),i=o.slice(32,64),c=l.slice(33,l.length-32),h=l.slice(l.length-32,l.length),d=ae.sha256Hmac(c,i);if(!kt(h,d))throw new Error("Invalid checksum");return At.decrypt(c,f)};wt.asyncBitcoreDecrypt=async function(l,e){const t=[l,e];return(await le.asyncClassMethod(wt,"bitcoreDecrypt",t)).resbuf};const L1={aes:Yf,bnjs:ct,bs58:jf,elliptic:Bd,hashjs:br,pbkdf2:Rd,Buffer:g1.Buffer},D1=_1.version;exports.Ach=Dt;exports.Address=St;exports.Aes=ht;exports.Aescbc=At;exports.Base58=jt;exports.Base58Check=Bt;exports.Bip32=rr;exports.Bip39=Cr;exports.Block=$r;exports.BlockHeader=tr;exports.Bn=Z;exports.Br=ot;exports.Bsm=mt;exports.Bw=ke;exports.Cbc=Fe;exports.Constants=Oe;exports.Ecdsa=ut;exports.Ecies=wt;exports.Hash=ae;exports.Interp=re;exports.KeyPair=st;exports.MinableBlock=Id;exports.MiningUtils=M1;exports.OpCode=q;exports.Point=Ie;exports.PrivKey=gt;exports.PubKey=Ue;exports.Random=Rt;exports.Script=Ae;exports.Sig=he;exports.SigOperations=$f;exports.Struct=Te;exports.Tx=Me;exports.TxBuilder=C1;exports.TxIn=He;exports.TxOut=yt;exports.TxOutMap=Wf;exports.TxVerifier=Dr;exports.VarInt=qe;exports.Workers=le;exports.WorkersResult=Vf;exports.cmp=kt;exports.deps=L1;exports.en=Nr;exports.es=Tr;exports.getConstants=O1;exports.jp=Mr;exports.version=D1;
10
10
  //# sourceMappingURL=bsv2.cjs.map