bsv2 2.0.19 → 2.0.20
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/.babelrc +10 -0
- package/dist/770.module.js +1 -0
- package/dist/921.bundle.js +7 -0
- package/dist/921.mjs +7 -0
- package/dist/main.bundle.js +2 -0
- package/dist/{bsv2.cjs.js → main.cjs.js} +2 -3
- package/dist/main.mjs +2 -0
- package/dist/main.module.js +2 -0
- package/package.json +7 -5
- package/webpack.config.js +59 -8
- package/dist/bsv.bundle.js +0 -3
- package/dist/bsv.bundle.js.LICENSE.txt +0 -10
- package/dist/bsv.bundle.js.map +0 -1
- package/dist/bsv.cjs.js +0 -3
- package/dist/bsv.cjs.js.map +0 -1
- package/dist/bsv.module.js +0 -3
- package/dist/bsv.module.js.LICENSE.txt +0 -1
- package/dist/bsv.module.js.map +0 -1
- package/dist/bsv2.bundle.js +0 -3
- package/dist/bsv2.bundle.js.LICENSE.txt +0 -10
- package/dist/bsv2.bundle.js.map +0 -1
- package/dist/bsv2.cjs.js.LICENSE.txt +0 -1
- package/dist/bsv2.cjs.js.map +0 -1
- package/dist/bsv2.mjs +0 -3
- package/dist/bsv2.mjs.LICENSE.txt +0 -10
- package/dist/bsv2.mjs.map +0 -1
- package/dist/bsv2.module.js +0 -3
- package/dist/bsv2.module.js.LICENSE.txt +0 -1
- package/dist/bsv2.module.js.map +0 -1
- /package/dist/{bsv.cjs.js.LICENSE.txt → main.cjs.js.LICENSE.txt} +0 -0
package/dist/bsv.cjs.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
/*! For license information please see bsv.cjs.js.LICENSE.txt */
|
|
2
|
-
(()=>{var t={297:t=>{function e(t){var e,r,i;this._tables[0][0][0]||this._precompute();var s=this._tables[0][4],n=this._tables[1],a=t.length,o=1;if(4!==a&&6!==a&&8!==a)throw new Error("invalid aes key size");this._key=[r=t.slice(0),i=[]];for(var c=a;c<4*a+28;c++)e=r[c-1],(c%a==0||8===a&&c%a==4)&&(e=s[e>>>24]<<24^s[e>>16&255]<<16^s[e>>8&255]<<8^s[255&e],c%a==0&&(e=e<<8^e>>>24^o<<24,o=o<<1^283*(o>>7))),r[c]=r[c-a]^e;for(var h=0;c;h++,c--)e=r[3&h?c:c-4],i[h]=c<=4||h<4?e:n[0][s[e>>>24]]^n[1][s[e>>16&255]]^n[2][s[e>>8&255]]^n[3][s[255&e]]}t.exports=e,e.prototype={encrypt:function(t){return this._crypt(t,0)},decrypt:function(t){return this._crypt(t,1)},_tables:[[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)]],_precompute:function(){var t,e,r,i,s,n,a,o,c=this._tables[0],h=this._tables[1],f=c[4],u=h[4],d=new Uint8Array(256),l=new Uint8Array(256);for(t=0;t<256;t++)l[(d[t]=t<<1^283*(t>>7))^t]=t;for(e=r=0;!f[e];e^=i||1,r=l[r]||1)for(n=(n=r^r<<1^r<<2^r<<3^r<<4)>>8^255&n^99,f[e]=n,u[n]=e,o=16843009*d[s=d[i=d[e]]]^65537*s^257*i^16843008*e,a=257*d[n]^16843008*n,t=0;t<4;t++)c[t][e]=a=a<<24^a>>>8,h[t][n]=o=o<<24^o>>>8},_crypt:function(t,e){if(4!==t.length)throw new Error("invalid aes block size");var r,i,s,n,a=this._key[e],o=t[0]^a[0],c=t[e?3:1]^a[1],h=t[2]^a[2],f=t[e?1:3]^a[3],u=a.length/4-2,d=4,l=new Uint32Array(4),p=this._tables[e],b=p[0],m=p[1],g=p[2],y=p[3],v=p[4];for(n=0;n<u;n++)r=b[o>>>24]^m[c>>16&255]^g[h>>8&255]^y[255&f]^a[d],i=b[c>>>24]^m[h>>16&255]^g[f>>8&255]^y[255&o]^a[d+1],s=b[h>>>24]^m[f>>16&255]^g[o>>8&255]^y[255&c]^a[d+2],f=b[f>>>24]^m[o>>16&255]^g[c>>8&255]^y[255&h]^a[d+3],d+=4,o=r,c=i,h=s;for(n=0;n<4;n++)l[e?3&-n:n]=v[o>>>24]<<24^v[c>>16&255]<<16^v[h>>8&255]<<8^v[255&f]^a[d++],r=o,o=c,c=h,h=f,f=r;return l}}},162:t=>{"use strict";t.exports=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var i=0;i<t.length;i++){var s=t.charAt(i),n=s.charCodeAt(0);if(255!==e[n])throw new TypeError(s+" is ambiguous");e[n]=i}var a=t.length,o=t.charAt(0),c=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function f(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return new Uint8Array;for(var r=0,i=0,s=0;t[r]===o;)i++,r++;for(var n=(t.length-r)*c+1>>>0,h=new Uint8Array(n);t[r];){var f=e[t.charCodeAt(r)];if(255===f)return;for(var u=0,d=n-1;(0!==f||u<s)&&-1!==d;d--,u++)f+=a*h[d]>>>0,h[d]=f%256>>>0,f=f/256>>>0;if(0!==f)throw new Error("Non-zero carry");s=u,r++}for(var l=n-s;l!==n&&0===h[l];)l++;for(var p=new Uint8Array(i+(n-l)),b=i;l!==n;)p[b++]=h[l++];return p}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===e.length)return"";for(var r=0,i=0,s=0,n=e.length;s!==n&&0===e[s];)s++,r++;for(var c=(n-s)*h+1>>>0,f=new Uint8Array(c);s!==n;){for(var u=e[s],d=0,l=c-1;(0!==u||d<i)&&-1!==l;l--,d++)u+=256*f[l]>>>0,f[l]=u%a>>>0,u=u/a>>>0;if(0!==u)throw new Error("Non-zero carry");i=d,s++}for(var p=c-i;p!==c&&0===f[p];)p++;for(var b=o.repeat(r);p<c;++p)b+=t.charAt(f[p]);return b},decodeUnsafe:f,decode:function(t){var e=f(t);if(e)return e;throw new Error("Non-base"+a+" character")}}}},666:(t,e,r)=>{"use strict";var i=e;i.version=r(726).i8,i.utils=r(359),i.rand=r(931),i.curve=r(104),i.curves=r(626),i.ec=r(630)},15:(t,e,r)=>{"use strict";var i=r(550),s=r(359),n=s.getNAF,a=s.getJSF,o=s.assert;function c(t,e){this.type=t,this.p=new i(e.p,16),this.red=e.prime?i.red(e.prime):i.mont(this.p),this.zero=new i(0).toRed(this.red),this.one=new i(1).toRed(this.red),this.two=new i(2).toRed(this.red),this.n=e.n&&new i(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.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 r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function h(t,e){this.curve=t,this.type=e,this.precomputed=null}t.exports=c,c.prototype.point=function(){throw new Error("Not implemented")},c.prototype.validate=function(){throw new Error("Not implemented")},c.prototype._fixedNafMul=function(t,e){o(t.precomputed);var r=t._getDoubles(),i=n(e,1,this._bitLength),s=(1<<r.step+1)-(r.step%2==0?2:1);s/=3;for(var a=[],c=0;c<i.length;c+=r.step){var h=0;for(e=c+r.step-1;e>=c;e--)h=(h<<1)+i[e];a.push(h)}for(var f=this.jpoint(null,null,null),u=this.jpoint(null,null,null),d=s;d>0;d--){for(c=0;c<a.length;c++)(h=a[c])===d?u=u.mixedAdd(r.points[c]):h===-d&&(u=u.mixedAdd(r.points[c].neg()));f=f.add(u)}return f.toP()},c.prototype._wnafMul=function(t,e){var r=4,i=t._getNAFPoints(r);r=i.wnd;for(var s=i.points,a=n(e,r,this._bitLength),c=this.jpoint(null,null,null),h=a.length-1;h>=0;h--){for(e=0;h>=0&&0===a[h];h--)e++;if(h>=0&&e++,c=c.dblp(e),h<0)break;var f=a[h];o(0!==f),c="affine"===t.type?f>0?c.mixedAdd(s[f-1>>1]):c.mixedAdd(s[-f-1>>1].neg()):f>0?c.add(s[f-1>>1]):c.add(s[-f-1>>1].neg())}return"affine"===t.type?c.toP():c},c.prototype._wnafMulAdd=function(t,e,r,i,s){for(var o=this._wnafT1,c=this._wnafT2,h=this._wnafT3,f=0,u=0;u<i;u++){var d=(B=e[u])._getNAFPoints(t);o[u]=d.wnd,c[u]=d.points}for(u=i-1;u>=1;u-=2){var l=u-1,p=u;if(1===o[l]&&1===o[p]){var b=[e[l],null,null,e[p]];0===e[l].y.cmp(e[p].y)?(b[1]=e[l].add(e[p]),b[2]=e[l].toJ().mixedAdd(e[p].neg())):0===e[l].y.cmp(e[p].y.redNeg())?(b[1]=e[l].toJ().mixedAdd(e[p]),b[2]=e[l].add(e[p].neg())):(b[1]=e[l].toJ().mixedAdd(e[p]),b[2]=e[l].toJ().mixedAdd(e[p].neg()));var m=[-3,-1,-5,-7,0,7,5,1,3],g=a(r[l],r[p]);f=Math.max(g[0].length,f),h[l]=new Array(f),h[p]=new Array(f);for(var y=0;y<f;y++){var v=0|g[0][y],w=0|g[1][y];h[l][y]=m[3*(v+1)+(w+1)],h[p][y]=0,c[l]=b}}else h[l]=n(r[l],o[l],this._bitLength),h[p]=n(r[p],o[p],this._bitLength),f=Math.max(h[l].length,f),f=Math.max(h[p].length,f)}var S=this.jpoint(null,null,null),_=this._wnafT4;for(u=f;u>=0;u--){for(var I=0;u>=0;){var O=!0;for(y=0;y<i;y++)_[y]=0|h[y][u],0!==_[y]&&(O=!1);if(!O)break;I++,u--}if(u>=0&&I++,S=S.dblp(I),u<0)break;for(y=0;y<i;y++){var B,E=_[y];0!==E&&(E>0?B=c[y][E-1>>1]:E<0&&(B=c[y][-E-1>>1].neg()),S="affine"===B.type?S.mixedAdd(B):S.add(B))}}for(u=0;u<i;u++)c[u]=null;return s?S:S.toP()},c.BasePoint=h,h.prototype.eq=function(){throw new Error("Not implemented")},h.prototype.validate=function(){return this.curve.validate(this)},c.prototype.decodePoint=function(t,e){t=s.toArray(t,e);var r=this.p.byteLength();if((4===t[0]||6===t[0]||7===t[0])&&t.length-1==2*r)return 6===t[0]?o(t[t.length-1]%2==0):7===t[0]&&o(t[t.length-1]%2==1),this.point(t.slice(1,1+r),t.slice(1+r,1+2*r));if((2===t[0]||3===t[0])&&t.length-1===r)return this.pointFromX(t.slice(1,1+r),3===t[0]);throw new Error("Unknown point format")},h.prototype.encodeCompressed=function(t){return this.encode(t,!0)},h.prototype._encode=function(t){var e=this.curve.p.byteLength(),r=this.getX().toArray("be",e);return t?[this.getY().isEven()?2:3].concat(r):[4].concat(r,this.getY().toArray("be",e))},h.prototype.encode=function(t,e){return s.encode(this._encode(e),t)},h.prototype.precompute=function(t){if(this.precomputed)return this;var e={doubles:null,naf:null,beta:null};return e.naf=this._getNAFPoints(8),e.doubles=this._getDoubles(4,t),e.beta=this._getBeta(),this.precomputed=e,this},h.prototype._hasDoubles=function(t){if(!this.precomputed)return!1;var e=this.precomputed.doubles;return!!e&&e.points.length>=Math.ceil((t.bitLength()+1)/e.step)},h.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],i=this,s=0;s<e;s+=t){for(var n=0;n<t;n++)i=i.dbl();r.push(i)}return{step:t,points:r}},h.prototype._getNAFPoints=function(t){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var e=[this],r=(1<<t)-1,i=1===r?null:this.dbl(),s=1;s<r;s++)e[s]=e[s-1].add(i);return{wnd:t,points:e}},h.prototype._getBeta=function(){return null},h.prototype.dblp=function(t){for(var e=this,r=0;r<t;r++)e=e.dbl();return e}},104:(t,e,r)=>{"use strict";var i=e;i.base=r(15),i.short=r(505)},505:(t,e,r)=>{"use strict";var i=r(359),s=r(550),n=r(378),a=r(15),o=i.assert;function c(t){a.call(this,"short",t),this.a=new s(t.a,16).toRed(this.red),this.b=new s(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function h(t,e,r,i){a.BasePoint.call(this,t,"affine"),null===e&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new s(e,16),this.y=new s(r,16),i&&(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)}function f(t,e,r,i){a.BasePoint.call(this,t,"jacobian"),null===e&&null===r&&null===i?(this.x=this.curve.one,this.y=this.curve.one,this.z=new s(0)):(this.x=new s(e,16),this.y=new s(r,16),this.z=new s(i,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}n(c,a),t.exports=c,c.prototype._getEndomorphism=function(t){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var e,r;if(t.beta)e=new s(t.beta,16).toRed(this.red);else{var i=this._getEndoRoots(this.p);e=(e=i[0].cmp(i[1])<0?i[0]:i[1]).toRed(this.red)}if(t.lambda)r=new s(t.lambda,16);else{var n=this._getEndoRoots(this.n);0===this.g.mul(n[0]).x.cmp(this.g.x.redMul(e))?r=n[0]:(r=n[1],o(0===this.g.mul(r).x.cmp(this.g.x.redMul(e))))}return{beta:e,lambda:r,basis:t.basis?t.basis.map((function(t){return{a:new s(t.a,16),b:new s(t.b,16)}})):this._getEndoBasis(r)}}},c.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:s.mont(t),r=new s(2).toRed(e).redInvm(),i=r.redNeg(),n=new s(3).toRed(e).redNeg().redSqrt().redMul(r);return[i.redAdd(n).fromRed(),i.redSub(n).fromRed()]},c.prototype._getEndoBasis=function(t){for(var e,r,i,n,a,o,c,h,f,u=this.n.ushrn(Math.floor(this.n.bitLength()/2)),d=t,l=this.n.clone(),p=new s(1),b=new s(0),m=new s(0),g=new s(1),y=0;0!==d.cmpn(0);){var v=l.div(d);h=l.sub(v.mul(d)),f=m.sub(v.mul(p));var w=g.sub(v.mul(b));if(!i&&h.cmp(u)<0)e=c.neg(),r=p,i=h.neg(),n=f;else if(i&&2==++y)break;c=h,l=d,d=h,m=p,p=f,g=b,b=w}a=h.neg(),o=f;var S=i.sqr().add(n.sqr());return a.sqr().add(o.sqr()).cmp(S)>=0&&(a=e,o=r),i.negative&&(i=i.neg(),n=n.neg()),a.negative&&(a=a.neg(),o=o.neg()),[{a:i,b:n},{a,b:o}]},c.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],i=e[1],s=i.b.mul(t).divRound(this.n),n=r.b.neg().mul(t).divRound(this.n),a=s.mul(r.a),o=n.mul(i.a),c=s.mul(r.b),h=n.mul(i.b);return{k1:t.sub(a).sub(o),k2:c.add(h).neg()}},c.prototype.pointFromX=function(t,e){(t=new s(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),i=r.redSqrt();if(0!==i.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var n=i.fromRed().isOdd();return(e&&!n||!e&&n)&&(i=i.redNeg()),this.point(t,i)},c.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,i=this.a.redMul(e),s=e.redSqr().redMul(e).redIAdd(i).redIAdd(this.b);return 0===r.redSqr().redISub(s).cmpn(0)},c.prototype._endoWnafMulAdd=function(t,e,r){for(var i=this._endoWnafT1,s=this._endoWnafT2,n=0;n<t.length;n++){var a=this._endoSplit(e[n]),o=t[n],c=o._getBeta();a.k1.negative&&(a.k1.ineg(),o=o.neg(!0)),a.k2.negative&&(a.k2.ineg(),c=c.neg(!0)),i[2*n]=o,i[2*n+1]=c,s[2*n]=a.k1,s[2*n+1]=a.k2}for(var h=this._wnafMulAdd(1,i,s,2*n,r),f=0;f<2*n;f++)i[f]=null,s[f]=null;return h},n(h,a.BasePoint),c.prototype.point=function(t,e,r){return new h(this,t,e,r)},c.prototype.pointFromJSON=function(t,e){return h.fromJSON(this,t,e)},h.prototype._getBeta=function(){if(this.curve.endo){var t=this.precomputed;if(t&&t.beta)return t.beta;var e=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(t){var r=this.curve,i=function(t){return r.point(t.x.redMul(r.endo.beta),t.y)};t.beta=e,e.precomputed={beta:null,naf:t.naf&&{wnd:t.naf.wnd,points:t.naf.points.map(i)},doubles:t.doubles&&{step:t.doubles.step,points:t.doubles.points.map(i)}}}return e}},h.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]},h.fromJSON=function(t,e,r){"string"==typeof e&&(e=JSON.parse(e));var i=t.point(e[0],e[1],r);if(!e[2])return i;function s(e){return t.point(e[0],e[1],r)}var n=e[2];return i.precomputed={beta:null,doubles:n.doubles&&{step:n.doubles.step,points:[i].concat(n.doubles.points.map(s))},naf:n.naf&&{wnd:n.naf.wnd,points:[i].concat(n.naf.points.map(s))}},i},h.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)+">"},h.prototype.isInfinity=function(){return this.inf},h.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),i=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,i)},h.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),i=t.redInvm(),s=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(i),n=s.redSqr().redISub(this.x.redAdd(this.x)),a=s.redMul(this.x.redSub(n)).redISub(this.y);return this.curve.point(n,a)},h.prototype.getX=function(){return this.x.fromRed()},h.prototype.getY=function(){return this.y.fromRed()},h.prototype.mul=function(t){return t=new s(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},h.prototype.mulAdd=function(t,e,r){var i=[this,e],s=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,s):this.curve._wnafMulAdd(1,i,s,2)},h.prototype.jmulAdd=function(t,e,r){var i=[this,e],s=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,s,!0):this.curve._wnafMulAdd(1,i,s,2,!0)},h.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},h.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,i=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(i)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(i)}}}return e},h.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},n(f,a.BasePoint),c.prototype.jpoint=function(t,e,r){return new f(this,t,e,r)},f.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),i=this.y.redMul(e).redMul(t);return this.curve.point(r,i)},f.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},f.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),i=this.x.redMul(e),s=t.x.redMul(r),n=this.y.redMul(e.redMul(t.z)),a=t.y.redMul(r.redMul(this.z)),o=i.redSub(s),c=n.redSub(a);if(0===o.cmpn(0))return 0!==c.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h=o.redSqr(),f=h.redMul(o),u=i.redMul(h),d=c.redSqr().redIAdd(f).redISub(u).redISub(u),l=c.redMul(u.redISub(d)).redISub(n.redMul(f)),p=this.z.redMul(t.z).redMul(o);return this.curve.jpoint(d,l,p)},f.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,i=t.x.redMul(e),s=this.y,n=t.y.redMul(e).redMul(this.z),a=r.redSub(i),o=s.redSub(n);if(0===a.cmpn(0))return 0!==o.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=a.redSqr(),h=c.redMul(a),f=r.redMul(c),u=o.redSqr().redIAdd(h).redISub(f).redISub(f),d=o.redMul(f.redISub(u)).redISub(s.redMul(h)),l=this.z.redMul(a);return this.curve.jpoint(u,d,l)},f.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var e=this,r=0;r<t;r++)e=e.dbl();return e}var i=this.curve.a,s=this.curve.tinv,n=this.x,a=this.y,o=this.z,c=o.redSqr().redSqr(),h=a.redAdd(a);for(r=0;r<t;r++){var f=n.redSqr(),u=h.redSqr(),d=u.redSqr(),l=f.redAdd(f).redIAdd(f).redIAdd(i.redMul(c)),p=n.redMul(u),b=l.redSqr().redISub(p.redAdd(p)),m=p.redISub(b),g=l.redMul(m);g=g.redIAdd(g).redISub(d);var y=h.redMul(o);r+1<t&&(c=c.redMul(d)),n=b,o=y,h=g}return this.curve.jpoint(n,h.redMul(s),o)},f.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},f.prototype._zeroDbl=function(){var t,e,r;if(this.zOne){var i=this.x.redSqr(),s=this.y.redSqr(),n=s.redSqr(),a=this.x.redAdd(s).redSqr().redISub(i).redISub(n);a=a.redIAdd(a);var o=i.redAdd(i).redIAdd(i),c=o.redSqr().redISub(a).redISub(a),h=n.redIAdd(n);h=(h=h.redIAdd(h)).redIAdd(h),t=c,e=o.redMul(a.redISub(c)).redISub(h),r=this.y.redAdd(this.y)}else{var f=this.x.redSqr(),u=this.y.redSqr(),d=u.redSqr(),l=this.x.redAdd(u).redSqr().redISub(f).redISub(d);l=l.redIAdd(l);var p=f.redAdd(f).redIAdd(f),b=p.redSqr(),m=d.redIAdd(d);m=(m=m.redIAdd(m)).redIAdd(m),t=b.redISub(l).redISub(l),e=p.redMul(l.redISub(t)).redISub(m),r=(r=this.y.redMul(this.z)).redIAdd(r)}return this.curve.jpoint(t,e,r)},f.prototype._threeDbl=function(){var t,e,r;if(this.zOne){var i=this.x.redSqr(),s=this.y.redSqr(),n=s.redSqr(),a=this.x.redAdd(s).redSqr().redISub(i).redISub(n);a=a.redIAdd(a);var o=i.redAdd(i).redIAdd(i).redIAdd(this.curve.a),c=o.redSqr().redISub(a).redISub(a);t=c;var h=n.redIAdd(n);h=(h=h.redIAdd(h)).redIAdd(h),e=o.redMul(a.redISub(c)).redISub(h),r=this.y.redAdd(this.y)}else{var f=this.z.redSqr(),u=this.y.redSqr(),d=this.x.redMul(u),l=this.x.redSub(f).redMul(this.x.redAdd(f));l=l.redAdd(l).redIAdd(l);var p=d.redIAdd(d),b=(p=p.redIAdd(p)).redAdd(p);t=l.redSqr().redISub(b),r=this.y.redAdd(this.z).redSqr().redISub(u).redISub(f);var m=u.redSqr();m=(m=(m=m.redIAdd(m)).redIAdd(m)).redIAdd(m),e=l.redMul(p.redISub(t)).redISub(m)}return this.curve.jpoint(t,e,r)},f.prototype._dbl=function(){var t=this.curve.a,e=this.x,r=this.y,i=this.z,s=i.redSqr().redSqr(),n=e.redSqr(),a=r.redSqr(),o=n.redAdd(n).redIAdd(n).redIAdd(t.redMul(s)),c=e.redAdd(e),h=(c=c.redIAdd(c)).redMul(a),f=o.redSqr().redISub(h.redAdd(h)),u=h.redISub(f),d=a.redSqr();d=(d=(d=d.redIAdd(d)).redIAdd(d)).redIAdd(d);var l=o.redMul(u).redISub(d),p=r.redAdd(r).redMul(i);return this.curve.jpoint(f,l,p)},f.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr(),i=e.redSqr(),s=t.redAdd(t).redIAdd(t),n=s.redSqr(),a=this.x.redAdd(e).redSqr().redISub(t).redISub(i),o=(a=(a=(a=a.redIAdd(a)).redAdd(a).redIAdd(a)).redISub(n)).redSqr(),c=i.redIAdd(i);c=(c=(c=c.redIAdd(c)).redIAdd(c)).redIAdd(c);var h=s.redIAdd(a).redSqr().redISub(n).redISub(o).redISub(c),f=e.redMul(h);f=(f=f.redIAdd(f)).redIAdd(f);var u=this.x.redMul(o).redISub(f);u=(u=u.redIAdd(u)).redIAdd(u);var d=this.y.redMul(h.redMul(c.redISub(h)).redISub(a.redMul(o)));d=(d=(d=d.redIAdd(d)).redIAdd(d)).redIAdd(d);var l=this.z.redAdd(a).redSqr().redISub(r).redISub(o);return this.curve.jpoint(u,d,l)},f.prototype.mul=function(t,e){return t=new s(t,e),this.curve._wnafMul(this,t)},f.prototype.eq=function(t){if("affine"===t.type)return this.eq(t.toJ());if(this===t)return!0;var e=this.z.redSqr(),r=t.z.redSqr();if(0!==this.x.redMul(r).redISub(t.x.redMul(e)).cmpn(0))return!1;var i=e.redMul(this.z),s=r.redMul(t.z);return 0===this.y.redMul(s).redISub(t.y.redMul(i)).cmpn(0)},f.prototype.eqXToP=function(t){var e=this.z.redSqr(),r=t.toRed(this.curve.red).redMul(e);if(0===this.x.cmp(r))return!0;for(var i=t.clone(),s=this.curve.redN.redMul(e);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(r.redIAdd(s),0===this.x.cmp(r))return!0}},f.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)+">"},f.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},626:(t,e,r)=>{"use strict";var i,s,n,a=e,o=r(715),c=r(104),h=r(359).assert;function f(t){if("short"!==t.type)throw new Error("invalid curve type");this.curve=new c.short(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,h(this.g.validate(),"Invalid curve"),h(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}a.PresetCurve=f;try{i=r(59)}catch(t){i=void 0}s="secp256k1",n={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:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",i]},Object.defineProperty(a,s,{configurable:!0,enumerable:!0,get:function(){var t=new f(n);return Object.defineProperty(a,s,{configurable:!0,enumerable:!0,value:t}),t}})},630:(t,e,r)=>{"use strict";var i=r(550),s=r(156),n=r(359),a=r(626),o=r(931),c=n.assert,h=r(119),f=r(911);function u(t){if(!(this instanceof u))return new u(t);"string"==typeof t&&(c(a.hasOwnProperty(t),"Unknown curve "+t),t=a[t]),t instanceof a.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}t.exports=u,u.prototype.keyPair=function(t){return new h(this,t)},u.prototype.keyFromPrivate=function(t,e){return h.fromPrivate(this,t,e)},u.prototype.keyFromPublic=function(t,e){return h.fromPublic(this,t,e)},u.prototype.genKeyPair=function(t){t||(t={});for(var e=new s({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||o(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),n=this.n.sub(new i(2));;){var a=new i(e.generate(r));if(!(a.cmp(n)>0))return a.iaddn(1),this.keyFromPrivate(a)}},u.prototype._truncateToN=function(t,e){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},u.prototype.sign=function(t,e,r,n){"object"==typeof r&&(n=r,r=null),n||(n={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new i(t,16));for(var a=this.n.byteLength(),o=e.getPrivate().toArray("be",a),c=t.toArray("be",a),h=new s({hash:this.hash,entropy:o,nonce:c,pers:n.pers,persEnc:n.persEnc||"utf8"}),u=this.n.sub(new i(1)),d=0;;d++){var l=n.k?n.k(d):new i(h.generate(this.n.byteLength()));if(!((l=this._truncateToN(l,!0)).cmpn(1)<=0||l.cmp(u)>=0)){var p=this.g.mul(l);if(!p.isInfinity()){var b=p.getX(),m=b.umod(this.n);if(0!==m.cmpn(0)){var g=l.invm(this.n).mul(m.mul(e.getPrivate()).iadd(t));if(0!==(g=g.umod(this.n)).cmpn(0)){var y=(p.getY().isOdd()?1:0)|(0!==b.cmp(m)?2:0);return n.canonical&&g.cmp(this.nh)>0&&(g=this.n.sub(g),y^=1),new f({r:m,s:g,recoveryParam:y})}}}}}},u.prototype.verify=function(t,e,r,s){t=this._truncateToN(new i(t,16)),r=this.keyFromPublic(r,s);var n=(e=new f(e,"hex")).r,a=e.s;if(n.cmpn(1)<0||n.cmp(this.n)>=0)return!1;if(a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var o,c=a.invm(this.n),h=c.mul(t).umod(this.n),u=c.mul(n).umod(this.n);return this.curve._maxwellTrick?!(o=this.g.jmulAdd(h,r.getPublic(),u)).isInfinity()&&o.eqXToP(n):!(o=this.g.mulAdd(h,r.getPublic(),u)).isInfinity()&&0===o.getX().umod(this.n).cmp(n)},u.prototype.recoverPubKey=function(t,e,r,s){c((3&r)===r,"The recovery param is more than two bits"),e=new f(e,s);var n=this.n,a=new i(t),o=e.r,h=e.s,u=1&r,d=r>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&d)throw new Error("Unable to find sencond key candinate");o=d?this.curve.pointFromX(o.add(this.curve.n),u):this.curve.pointFromX(o,u);var l=e.r.invm(n),p=n.sub(a).mul(l).umod(n),b=h.mul(l).umod(n);return this.g.mulAdd(p,o,b)},u.prototype.getKeyRecoveryParam=function(t,e,r,i){if(null!==(e=new f(e,i)).recoveryParam)return e.recoveryParam;for(var s=0;s<4;s++){var n;try{n=this.recoverPubKey(t,e,s)}catch(t){continue}if(n.eq(r))return s}throw new Error("Unable to find valid recovery factor")}},119:(t,e,r)=>{"use strict";var i=r(550),s=r(359).assert;function n(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}t.exports=n,n.fromPublic=function(t,e,r){return e instanceof n?e:new n(t,{pub:e,pubEnc:r})},n.fromPrivate=function(t,e,r){return e instanceof n?e:new n(t,{priv:e,privEnc:r})},n.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:"Invalid public key"}:t.validate()?t.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(t,e){return"string"==typeof t&&(e=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,t):this.pub},n.prototype.getPrivate=function(t){return"hex"===t?this.priv.toString(16,2):this.priv},n.prototype._importPrivate=function(t,e){this.priv=new i(t,e||16),this.priv=this.priv.umod(this.ec.curve.n)},n.prototype._importPublic=function(t,e){if(t.x||t.y)return"mont"===this.ec.curve.type?s(t.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||s(t.x&&t.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(t.x,t.y));this.pub=this.ec.curve.decodePoint(t,e)},n.prototype.derive=function(t){return t.mul(this.priv).getX()},n.prototype.sign=function(t,e,r){return this.ec.sign(t,this,e,r)},n.prototype.verify=function(t,e){return this.ec.verify(t,e,this)},n.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"}},911:(t,e,r)=>{"use strict";var i=r(550),s=r(359),n=s.assert;function a(t,e){if(t instanceof a)return t;this._importDER(t,e)||(n(t.r&&t.s,"Signature without r or s"),this.r=new i(t.r,16),this.s=new i(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}function o(){this.place=0}function c(t,e){var r=t[e.place++];if(!(128&r))return r;for(var i=15&r,s=0,n=0,a=e.place;n<i;n++,a++)s<<=8,s|=t[a];return e.place=a,s}function h(t){for(var e=0,r=t.length-1;!t[e]&&!(128&t[e+1])&&e<r;)e++;return 0===e?t:t.slice(e)}function f(t,e){if(e<128)t.push(e);else{var r=1+(Math.log(e)/Math.LN2>>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}t.exports=a,a.prototype._importDER=function(t,e){t=s.toArray(t,e);var r=new o;if(48!==t[r.place++])return!1;if(c(t,r)+r.place!==t.length)return!1;if(2!==t[r.place++])return!1;var n=c(t,r),a=t.slice(r.place,n+r.place);if(r.place+=n,2!==t[r.place++])return!1;var h=c(t,r);if(t.length!==h+r.place)return!1;var f=t.slice(r.place,h+r.place);return 0===a[0]&&128&a[1]&&(a=a.slice(1)),0===f[0]&&128&f[1]&&(f=f.slice(1)),this.r=new i(a),this.s=new i(f),this.recoveryParam=null,!0},a.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=h(e),r=h(r);!(r[0]||128&r[1]);)r=r.slice(1);var i=[2];f(i,e.length),(i=i.concat(e)).push(2),f(i,r.length);var n=i.concat(r),a=[48];return f(a,n.length),a=a.concat(n),s.encode(a,t)}},59:t=>{t.exports={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"]]}}},359:(t,e,r)=>{"use strict";var i=e,s=r(550),n=r(746),a=r(504);i.assert=n,i.toArray=a.toArray,i.zero2=a.zero2,i.toHex=a.toHex,i.encode=a.encode,i.getNAF=function(t,e,r){var i=new Array(Math.max(t.bitLength(),r)+1);i.fill(0);for(var s=1<<e+1,n=t.clone(),a=0;a<i.length;a++){var o,c=n.andln(s-1);n.isOdd()?(o=c>(s>>1)-1?(s>>1)-c:c,n.isubn(o)):o=0,i[a]=o,n.iushrn(1)}return i},i.getJSF=function(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var i=0,s=0;t.cmpn(-i)>0||e.cmpn(-s)>0;){var n,a,o,c=t.andln(3)+i&3,h=e.andln(3)+s&3;3===c&&(c=-1),3===h&&(h=-1),n=0==(1&c)?0:3!=(o=t.andln(7)+i&7)&&5!==o||2!==h?c:-c,r[0].push(n),a=0==(1&h)?0:3!=(o=e.andln(7)+s&7)&&5!==o||2!==c?h:-h,r[1].push(a),2*i===n+1&&(i=1-i),2*s===a+1&&(s=1-s),t.iushrn(1),e.iushrn(1)}return r},i.cachedProperty=function(t,e,r){var i="_"+e;t.prototype[e]=function(){return void 0!==this[i]?this[i]:this[i]=r.call(this)}},i.parseBytes=function(t){return"string"==typeof t?i.toArray(t,"hex"):t},i.intFromLE=function(t){return new s(t,"hex","le")}},550:function(t,e,r){!function(t,e){"use strict";function i(t,e){if(!t)throw new Error(e||"Assertion failed")}function s(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var a;"object"==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{a="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:r(300).Buffer}catch(t){}function o(t,e){var r=t.charCodeAt(e);return r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void i(!1,"Invalid character in "+t)}function c(t,e,r){var i=o(t,r);return r-1>=e&&(i|=o(t,r-1)<<4),i}function h(t,e,r,s){for(var n=0,a=0,o=Math.min(t.length,r),c=e;c<o;c++){var h=t.charCodeAt(c)-48;n*=s,a=h>=49?h-49+10:h>=17?h-17+10:h,i(h>=0&&a<s,"Invalid character"),n+=a}return n}function f(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(n.isBN=function(t){return t instanceof n||null!==t&&"object"==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,e){return t.cmp(e)>0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),i(e===(0|e)&&e>=2&&e<=36);var s=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(s++,this.negative=1),s<t.length&&(16===e?this._parseHex(t,s,r):(this._parseBase(t,e,s),"le"===r&&this._initArray(this.toArray(),e,r)))},n.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(i(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},n.prototype._initArray=function(t,e,r){if(i("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var s=0;s<this.length;s++)this.words[s]=0;var n,a,o=0;if("be"===r)for(s=t.length-1,n=0;s>=0;s-=3)a=t[s]|t[s-1]<<8|t[s-2]<<16,this.words[n]|=a<<o&67108863,this.words[n+1]=a>>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===r)for(s=0,n=0;s<t.length;s+=3)a=t[s]|t[s+1]<<8|t[s+2]<<16,this.words[n]|=a<<o&67108863,this.words[n+1]=a>>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this._strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var s,n=0,a=0;if("be"===r)for(i=t.length-1;i>=e;i-=2)s=c(t,e,i)<<n,this.words[a]|=67108863&s,n>=18?(n-=18,a+=1,this.words[a]|=s>>>26):n+=8;else for(i=(t.length-e)%2==0?e+1:e;i<t.length;i+=2)s=c(t,e,i)<<n,this.words[a]|=67108863&s,n>=18?(n-=18,a+=1,this.words[a]|=s>>>26):n+=8;this._strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,s=1;s<=67108863;s*=e)i++;i--,s=s/e|0;for(var n=t.length-r,a=n%i,o=Math.min(n,n-a)+r,c=0,f=r;f<o;f+=i)c=h(t,f,f+i,e),this.imuln(s),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(0!==a){var u=1;for(c=h(t,f,t.length,e),f=0;f<a;f++)u*=e;this.imuln(u),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this._strip()},n.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},n.prototype._move=function(t){f(t,this)},n.prototype.clone=function(){var t=new n(null);return this.copy(t),t},n.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},n.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=u}catch(t){n.prototype.inspect=u}else n.prototype.inspect=u;function u(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var d=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],l=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],p=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function b(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var s=0|t.words[0],n=0|e.words[0],a=s*n,o=67108863&a,c=a/67108864|0;r.words[0]=o;for(var h=1;h<i;h++){for(var f=c>>>26,u=67108863&c,d=Math.min(h,e.length-1),l=Math.max(0,h-t.length+1);l<=d;l++){var p=h-l|0;f+=(a=(s=0|t.words[p])*(n=0|e.words[l])+u)/67108864|0,u=67108863&a}r.words[h]=0|u,c=0|f}return 0!==c?r.words[h]=0|c:r.length--,r._strip()}n.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var s=0,n=0,a=0;a<this.length;a++){var o=this.words[a],c=(16777215&(o<<s|n)).toString(16);n=o>>>24-s&16777215,(s+=2)>=26&&(s-=26,a--),r=0!==n||a!==this.length-1?d[6-c.length]+c+r:c+r}for(0!==n&&(r=n.toString(16)+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var h=l[t],f=p[t];r="";var u=this.clone();for(u.negative=0;!u.isZero();){var b=u.modrn(f).toString(t);r=(u=u.idivn(f)).isZero()?b+r:d[h-b.length]+b+r}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}i(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16,2)},a&&(n.prototype.toBuffer=function(t,e){return this.toArrayLike(a,t,e)}),n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},n.prototype.toArrayLike=function(t,e,r){this._strip();var s=this.byteLength(),n=r||Math.max(1,s);i(s<=n,"byte array longer than desired length"),i(n>0,"Requested array length <= 0");var a=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,n);return this["_toArrayLike"+("le"===e?"LE":"BE")](a,s),a},n.prototype._toArrayLikeLE=function(t,e){for(var r=0,i=0,s=0,n=0;s<this.length;s++){var a=this.words[s]<<n|i;t[r++]=255&a,r<t.length&&(t[r++]=a>>8&255),r<t.length&&(t[r++]=a>>16&255),6===n?(r<t.length&&(t[r++]=a>>24&255),i=0,n=0):(i=a>>>24,n+=2)}if(r<t.length)for(t[r++]=i;r<t.length;)t[r++]=0},n.prototype._toArrayLikeBE=function(t,e){for(var r=t.length-1,i=0,s=0,n=0;s<this.length;s++){var a=this.words[s]<<n|i;t[r--]=255&a,r>=0&&(t[r--]=a>>8&255),r>=0&&(t[r--]=a>>16&255),6===n?(r>=0&&(t[r--]=a>>24&255),i=0,n=0):(i=a>>>24,n+=2)}if(r>=0)for(t[r--]=i;r>=0;)t[r--]=0},Math.clz32?n.prototype._countBits=function(t){return 32-Math.clz32(t)}:n.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},n.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},n.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},n.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},n.prototype.isNeg=function(){return 0!==this.negative},n.prototype.neg=function(){return this.clone().ineg()},n.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},n.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},n.prototype.ior=function(t){return i(0==(this.negative|t.negative)),this.iuor(t)},n.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this._strip()},n.prototype.iand=function(t){return i(0==(this.negative|t.negative)),this.iuand(t)},n.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this._strip()},n.prototype.ixor=function(t){return i(0==(this.negative|t.negative)),this.iuxor(t)},n.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){i("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var s=0;s<e;s++)this.words[s]=67108863&~this.words[s];return r>0&&(this.words[s]=~this.words[s]&67108863>>26-r),this._strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){i("number"==typeof t&&t>=0);var r=t/26|0,s=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<<s:this.words[r]&~(1<<s),this._strip()},n.prototype.iadd=function(t){var e,r,i;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,i=t):(r=t,i=this);for(var s=0,n=0;n<i.length;n++)e=(0|r.words[n])+(0|i.words[n])+s,this.words[n]=67108863&e,s=e>>>26;for(;0!==s&&n<r.length;n++)e=(0|r.words[n])+s,this.words[n]=67108863&e,s=e>>>26;if(this.length=r.length,0!==s)this.words[this.length]=s,this.length++;else if(r!==this)for(;n<r.length;n++)this.words[n]=r.words[n];return this},n.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,s=this.cmp(t);if(0===s)return this.negative=0,this.length=1,this.words[0]=0,this;s>0?(r=this,i=t):(r=t,i=this);for(var n=0,a=0;a<i.length;a++)n=(e=(0|r.words[a])-(0|i.words[a])+n)>>26,this.words[a]=67108863&e;for(;0!==n&&a<r.length;a++)n=(e=(0|r.words[a])+n)>>26,this.words[a]=67108863&e;if(0===n&&a<r.length&&r!==this)for(;a<r.length;a++)this.words[a]=r.words[a];return this.length=Math.max(this.length,a),r!==this&&(this.negative=1),this._strip()},n.prototype.sub=function(t){return this.clone().isub(t)};var m=function(t,e,r){var i,s,n,a=t.words,o=e.words,c=r.words,h=0,f=0|a[0],u=8191&f,d=f>>>13,l=0|a[1],p=8191&l,b=l>>>13,m=0|a[2],g=8191&m,y=m>>>13,v=0|a[3],w=8191&v,S=v>>>13,_=0|a[4],I=8191&_,O=_>>>13,B=0|a[5],E=8191&B,P=B>>>13,N=0|a[6],A=8191&N,k=N>>>13,R=0|a[7],x=8191&R,M=R>>>13,T=0|a[8],C=8191&T,H=T>>>13,L=0|a[9],F=8191&L,K=L>>>13,U=0|o[0],D=8191&U,V=U>>>13,j=0|o[1],z=8191&j,q=j>>>13,G=0|o[2],Y=8191&G,J=G>>>13,W=0|o[3],Q=8191&W,X=W>>>13,Z=0|o[4],$=8191&Z,tt=Z>>>13,et=0|o[5],rt=8191&et,it=et>>>13,st=0|o[6],nt=8191&st,at=st>>>13,ot=0|o[7],ct=8191&ot,ht=ot>>>13,ft=0|o[8],ut=8191&ft,dt=ft>>>13,lt=0|o[9],pt=8191<,bt=lt>>>13;r.negative=t.negative^e.negative,r.length=19;var mt=(h+(i=Math.imul(u,D))|0)+((8191&(s=(s=Math.imul(u,V))+Math.imul(d,D)|0))<<13)|0;h=((n=Math.imul(d,V))+(s>>>13)|0)+(mt>>>26)|0,mt&=67108863,i=Math.imul(p,D),s=(s=Math.imul(p,V))+Math.imul(b,D)|0,n=Math.imul(b,V);var gt=(h+(i=i+Math.imul(u,z)|0)|0)+((8191&(s=(s=s+Math.imul(u,q)|0)+Math.imul(d,z)|0))<<13)|0;h=((n=n+Math.imul(d,q)|0)+(s>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(g,D),s=(s=Math.imul(g,V))+Math.imul(y,D)|0,n=Math.imul(y,V),i=i+Math.imul(p,z)|0,s=(s=s+Math.imul(p,q)|0)+Math.imul(b,z)|0,n=n+Math.imul(b,q)|0;var yt=(h+(i=i+Math.imul(u,Y)|0)|0)+((8191&(s=(s=s+Math.imul(u,J)|0)+Math.imul(d,Y)|0))<<13)|0;h=((n=n+Math.imul(d,J)|0)+(s>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(w,D),s=(s=Math.imul(w,V))+Math.imul(S,D)|0,n=Math.imul(S,V),i=i+Math.imul(g,z)|0,s=(s=s+Math.imul(g,q)|0)+Math.imul(y,z)|0,n=n+Math.imul(y,q)|0,i=i+Math.imul(p,Y)|0,s=(s=s+Math.imul(p,J)|0)+Math.imul(b,Y)|0,n=n+Math.imul(b,J)|0;var vt=(h+(i=i+Math.imul(u,Q)|0)|0)+((8191&(s=(s=s+Math.imul(u,X)|0)+Math.imul(d,Q)|0))<<13)|0;h=((n=n+Math.imul(d,X)|0)+(s>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(I,D),s=(s=Math.imul(I,V))+Math.imul(O,D)|0,n=Math.imul(O,V),i=i+Math.imul(w,z)|0,s=(s=s+Math.imul(w,q)|0)+Math.imul(S,z)|0,n=n+Math.imul(S,q)|0,i=i+Math.imul(g,Y)|0,s=(s=s+Math.imul(g,J)|0)+Math.imul(y,Y)|0,n=n+Math.imul(y,J)|0,i=i+Math.imul(p,Q)|0,s=(s=s+Math.imul(p,X)|0)+Math.imul(b,Q)|0,n=n+Math.imul(b,X)|0;var wt=(h+(i=i+Math.imul(u,$)|0)|0)+((8191&(s=(s=s+Math.imul(u,tt)|0)+Math.imul(d,$)|0))<<13)|0;h=((n=n+Math.imul(d,tt)|0)+(s>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(E,D),s=(s=Math.imul(E,V))+Math.imul(P,D)|0,n=Math.imul(P,V),i=i+Math.imul(I,z)|0,s=(s=s+Math.imul(I,q)|0)+Math.imul(O,z)|0,n=n+Math.imul(O,q)|0,i=i+Math.imul(w,Y)|0,s=(s=s+Math.imul(w,J)|0)+Math.imul(S,Y)|0,n=n+Math.imul(S,J)|0,i=i+Math.imul(g,Q)|0,s=(s=s+Math.imul(g,X)|0)+Math.imul(y,Q)|0,n=n+Math.imul(y,X)|0,i=i+Math.imul(p,$)|0,s=(s=s+Math.imul(p,tt)|0)+Math.imul(b,$)|0,n=n+Math.imul(b,tt)|0;var St=(h+(i=i+Math.imul(u,rt)|0)|0)+((8191&(s=(s=s+Math.imul(u,it)|0)+Math.imul(d,rt)|0))<<13)|0;h=((n=n+Math.imul(d,it)|0)+(s>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(A,D),s=(s=Math.imul(A,V))+Math.imul(k,D)|0,n=Math.imul(k,V),i=i+Math.imul(E,z)|0,s=(s=s+Math.imul(E,q)|0)+Math.imul(P,z)|0,n=n+Math.imul(P,q)|0,i=i+Math.imul(I,Y)|0,s=(s=s+Math.imul(I,J)|0)+Math.imul(O,Y)|0,n=n+Math.imul(O,J)|0,i=i+Math.imul(w,Q)|0,s=(s=s+Math.imul(w,X)|0)+Math.imul(S,Q)|0,n=n+Math.imul(S,X)|0,i=i+Math.imul(g,$)|0,s=(s=s+Math.imul(g,tt)|0)+Math.imul(y,$)|0,n=n+Math.imul(y,tt)|0,i=i+Math.imul(p,rt)|0,s=(s=s+Math.imul(p,it)|0)+Math.imul(b,rt)|0,n=n+Math.imul(b,it)|0;var _t=(h+(i=i+Math.imul(u,nt)|0)|0)+((8191&(s=(s=s+Math.imul(u,at)|0)+Math.imul(d,nt)|0))<<13)|0;h=((n=n+Math.imul(d,at)|0)+(s>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(x,D),s=(s=Math.imul(x,V))+Math.imul(M,D)|0,n=Math.imul(M,V),i=i+Math.imul(A,z)|0,s=(s=s+Math.imul(A,q)|0)+Math.imul(k,z)|0,n=n+Math.imul(k,q)|0,i=i+Math.imul(E,Y)|0,s=(s=s+Math.imul(E,J)|0)+Math.imul(P,Y)|0,n=n+Math.imul(P,J)|0,i=i+Math.imul(I,Q)|0,s=(s=s+Math.imul(I,X)|0)+Math.imul(O,Q)|0,n=n+Math.imul(O,X)|0,i=i+Math.imul(w,$)|0,s=(s=s+Math.imul(w,tt)|0)+Math.imul(S,$)|0,n=n+Math.imul(S,tt)|0,i=i+Math.imul(g,rt)|0,s=(s=s+Math.imul(g,it)|0)+Math.imul(y,rt)|0,n=n+Math.imul(y,it)|0,i=i+Math.imul(p,nt)|0,s=(s=s+Math.imul(p,at)|0)+Math.imul(b,nt)|0,n=n+Math.imul(b,at)|0;var It=(h+(i=i+Math.imul(u,ct)|0)|0)+((8191&(s=(s=s+Math.imul(u,ht)|0)+Math.imul(d,ct)|0))<<13)|0;h=((n=n+Math.imul(d,ht)|0)+(s>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(C,D),s=(s=Math.imul(C,V))+Math.imul(H,D)|0,n=Math.imul(H,V),i=i+Math.imul(x,z)|0,s=(s=s+Math.imul(x,q)|0)+Math.imul(M,z)|0,n=n+Math.imul(M,q)|0,i=i+Math.imul(A,Y)|0,s=(s=s+Math.imul(A,J)|0)+Math.imul(k,Y)|0,n=n+Math.imul(k,J)|0,i=i+Math.imul(E,Q)|0,s=(s=s+Math.imul(E,X)|0)+Math.imul(P,Q)|0,n=n+Math.imul(P,X)|0,i=i+Math.imul(I,$)|0,s=(s=s+Math.imul(I,tt)|0)+Math.imul(O,$)|0,n=n+Math.imul(O,tt)|0,i=i+Math.imul(w,rt)|0,s=(s=s+Math.imul(w,it)|0)+Math.imul(S,rt)|0,n=n+Math.imul(S,it)|0,i=i+Math.imul(g,nt)|0,s=(s=s+Math.imul(g,at)|0)+Math.imul(y,nt)|0,n=n+Math.imul(y,at)|0,i=i+Math.imul(p,ct)|0,s=(s=s+Math.imul(p,ht)|0)+Math.imul(b,ct)|0,n=n+Math.imul(b,ht)|0;var Ot=(h+(i=i+Math.imul(u,ut)|0)|0)+((8191&(s=(s=s+Math.imul(u,dt)|0)+Math.imul(d,ut)|0))<<13)|0;h=((n=n+Math.imul(d,dt)|0)+(s>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,i=Math.imul(F,D),s=(s=Math.imul(F,V))+Math.imul(K,D)|0,n=Math.imul(K,V),i=i+Math.imul(C,z)|0,s=(s=s+Math.imul(C,q)|0)+Math.imul(H,z)|0,n=n+Math.imul(H,q)|0,i=i+Math.imul(x,Y)|0,s=(s=s+Math.imul(x,J)|0)+Math.imul(M,Y)|0,n=n+Math.imul(M,J)|0,i=i+Math.imul(A,Q)|0,s=(s=s+Math.imul(A,X)|0)+Math.imul(k,Q)|0,n=n+Math.imul(k,X)|0,i=i+Math.imul(E,$)|0,s=(s=s+Math.imul(E,tt)|0)+Math.imul(P,$)|0,n=n+Math.imul(P,tt)|0,i=i+Math.imul(I,rt)|0,s=(s=s+Math.imul(I,it)|0)+Math.imul(O,rt)|0,n=n+Math.imul(O,it)|0,i=i+Math.imul(w,nt)|0,s=(s=s+Math.imul(w,at)|0)+Math.imul(S,nt)|0,n=n+Math.imul(S,at)|0,i=i+Math.imul(g,ct)|0,s=(s=s+Math.imul(g,ht)|0)+Math.imul(y,ct)|0,n=n+Math.imul(y,ht)|0,i=i+Math.imul(p,ut)|0,s=(s=s+Math.imul(p,dt)|0)+Math.imul(b,ut)|0,n=n+Math.imul(b,dt)|0;var Bt=(h+(i=i+Math.imul(u,pt)|0)|0)+((8191&(s=(s=s+Math.imul(u,bt)|0)+Math.imul(d,pt)|0))<<13)|0;h=((n=n+Math.imul(d,bt)|0)+(s>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,i=Math.imul(F,z),s=(s=Math.imul(F,q))+Math.imul(K,z)|0,n=Math.imul(K,q),i=i+Math.imul(C,Y)|0,s=(s=s+Math.imul(C,J)|0)+Math.imul(H,Y)|0,n=n+Math.imul(H,J)|0,i=i+Math.imul(x,Q)|0,s=(s=s+Math.imul(x,X)|0)+Math.imul(M,Q)|0,n=n+Math.imul(M,X)|0,i=i+Math.imul(A,$)|0,s=(s=s+Math.imul(A,tt)|0)+Math.imul(k,$)|0,n=n+Math.imul(k,tt)|0,i=i+Math.imul(E,rt)|0,s=(s=s+Math.imul(E,it)|0)+Math.imul(P,rt)|0,n=n+Math.imul(P,it)|0,i=i+Math.imul(I,nt)|0,s=(s=s+Math.imul(I,at)|0)+Math.imul(O,nt)|0,n=n+Math.imul(O,at)|0,i=i+Math.imul(w,ct)|0,s=(s=s+Math.imul(w,ht)|0)+Math.imul(S,ct)|0,n=n+Math.imul(S,ht)|0,i=i+Math.imul(g,ut)|0,s=(s=s+Math.imul(g,dt)|0)+Math.imul(y,ut)|0,n=n+Math.imul(y,dt)|0;var Et=(h+(i=i+Math.imul(p,pt)|0)|0)+((8191&(s=(s=s+Math.imul(p,bt)|0)+Math.imul(b,pt)|0))<<13)|0;h=((n=n+Math.imul(b,bt)|0)+(s>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(F,Y),s=(s=Math.imul(F,J))+Math.imul(K,Y)|0,n=Math.imul(K,J),i=i+Math.imul(C,Q)|0,s=(s=s+Math.imul(C,X)|0)+Math.imul(H,Q)|0,n=n+Math.imul(H,X)|0,i=i+Math.imul(x,$)|0,s=(s=s+Math.imul(x,tt)|0)+Math.imul(M,$)|0,n=n+Math.imul(M,tt)|0,i=i+Math.imul(A,rt)|0,s=(s=s+Math.imul(A,it)|0)+Math.imul(k,rt)|0,n=n+Math.imul(k,it)|0,i=i+Math.imul(E,nt)|0,s=(s=s+Math.imul(E,at)|0)+Math.imul(P,nt)|0,n=n+Math.imul(P,at)|0,i=i+Math.imul(I,ct)|0,s=(s=s+Math.imul(I,ht)|0)+Math.imul(O,ct)|0,n=n+Math.imul(O,ht)|0,i=i+Math.imul(w,ut)|0,s=(s=s+Math.imul(w,dt)|0)+Math.imul(S,ut)|0,n=n+Math.imul(S,dt)|0;var Pt=(h+(i=i+Math.imul(g,pt)|0)|0)+((8191&(s=(s=s+Math.imul(g,bt)|0)+Math.imul(y,pt)|0))<<13)|0;h=((n=n+Math.imul(y,bt)|0)+(s>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,i=Math.imul(F,Q),s=(s=Math.imul(F,X))+Math.imul(K,Q)|0,n=Math.imul(K,X),i=i+Math.imul(C,$)|0,s=(s=s+Math.imul(C,tt)|0)+Math.imul(H,$)|0,n=n+Math.imul(H,tt)|0,i=i+Math.imul(x,rt)|0,s=(s=s+Math.imul(x,it)|0)+Math.imul(M,rt)|0,n=n+Math.imul(M,it)|0,i=i+Math.imul(A,nt)|0,s=(s=s+Math.imul(A,at)|0)+Math.imul(k,nt)|0,n=n+Math.imul(k,at)|0,i=i+Math.imul(E,ct)|0,s=(s=s+Math.imul(E,ht)|0)+Math.imul(P,ct)|0,n=n+Math.imul(P,ht)|0,i=i+Math.imul(I,ut)|0,s=(s=s+Math.imul(I,dt)|0)+Math.imul(O,ut)|0,n=n+Math.imul(O,dt)|0;var Nt=(h+(i=i+Math.imul(w,pt)|0)|0)+((8191&(s=(s=s+Math.imul(w,bt)|0)+Math.imul(S,pt)|0))<<13)|0;h=((n=n+Math.imul(S,bt)|0)+(s>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(F,$),s=(s=Math.imul(F,tt))+Math.imul(K,$)|0,n=Math.imul(K,tt),i=i+Math.imul(C,rt)|0,s=(s=s+Math.imul(C,it)|0)+Math.imul(H,rt)|0,n=n+Math.imul(H,it)|0,i=i+Math.imul(x,nt)|0,s=(s=s+Math.imul(x,at)|0)+Math.imul(M,nt)|0,n=n+Math.imul(M,at)|0,i=i+Math.imul(A,ct)|0,s=(s=s+Math.imul(A,ht)|0)+Math.imul(k,ct)|0,n=n+Math.imul(k,ht)|0,i=i+Math.imul(E,ut)|0,s=(s=s+Math.imul(E,dt)|0)+Math.imul(P,ut)|0,n=n+Math.imul(P,dt)|0;var At=(h+(i=i+Math.imul(I,pt)|0)|0)+((8191&(s=(s=s+Math.imul(I,bt)|0)+Math.imul(O,pt)|0))<<13)|0;h=((n=n+Math.imul(O,bt)|0)+(s>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(F,rt),s=(s=Math.imul(F,it))+Math.imul(K,rt)|0,n=Math.imul(K,it),i=i+Math.imul(C,nt)|0,s=(s=s+Math.imul(C,at)|0)+Math.imul(H,nt)|0,n=n+Math.imul(H,at)|0,i=i+Math.imul(x,ct)|0,s=(s=s+Math.imul(x,ht)|0)+Math.imul(M,ct)|0,n=n+Math.imul(M,ht)|0,i=i+Math.imul(A,ut)|0,s=(s=s+Math.imul(A,dt)|0)+Math.imul(k,ut)|0,n=n+Math.imul(k,dt)|0;var kt=(h+(i=i+Math.imul(E,pt)|0)|0)+((8191&(s=(s=s+Math.imul(E,bt)|0)+Math.imul(P,pt)|0))<<13)|0;h=((n=n+Math.imul(P,bt)|0)+(s>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(F,nt),s=(s=Math.imul(F,at))+Math.imul(K,nt)|0,n=Math.imul(K,at),i=i+Math.imul(C,ct)|0,s=(s=s+Math.imul(C,ht)|0)+Math.imul(H,ct)|0,n=n+Math.imul(H,ht)|0,i=i+Math.imul(x,ut)|0,s=(s=s+Math.imul(x,dt)|0)+Math.imul(M,ut)|0,n=n+Math.imul(M,dt)|0;var Rt=(h+(i=i+Math.imul(A,pt)|0)|0)+((8191&(s=(s=s+Math.imul(A,bt)|0)+Math.imul(k,pt)|0))<<13)|0;h=((n=n+Math.imul(k,bt)|0)+(s>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,i=Math.imul(F,ct),s=(s=Math.imul(F,ht))+Math.imul(K,ct)|0,n=Math.imul(K,ht),i=i+Math.imul(C,ut)|0,s=(s=s+Math.imul(C,dt)|0)+Math.imul(H,ut)|0,n=n+Math.imul(H,dt)|0;var xt=(h+(i=i+Math.imul(x,pt)|0)|0)+((8191&(s=(s=s+Math.imul(x,bt)|0)+Math.imul(M,pt)|0))<<13)|0;h=((n=n+Math.imul(M,bt)|0)+(s>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(F,ut),s=(s=Math.imul(F,dt))+Math.imul(K,ut)|0,n=Math.imul(K,dt);var Mt=(h+(i=i+Math.imul(C,pt)|0)|0)+((8191&(s=(s=s+Math.imul(C,bt)|0)+Math.imul(H,pt)|0))<<13)|0;h=((n=n+Math.imul(H,bt)|0)+(s>>>13)|0)+(Mt>>>26)|0,Mt&=67108863;var Tt=(h+(i=Math.imul(F,pt))|0)+((8191&(s=(s=Math.imul(F,bt))+Math.imul(K,pt)|0))<<13)|0;return h=((n=Math.imul(K,bt))+(s>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,c[0]=mt,c[1]=gt,c[2]=yt,c[3]=vt,c[4]=wt,c[5]=St,c[6]=_t,c[7]=It,c[8]=Ot,c[9]=Bt,c[10]=Et,c[11]=Pt,c[12]=Nt,c[13]=At,c[14]=kt,c[15]=Rt,c[16]=xt,c[17]=Mt,c[18]=Tt,0!==h&&(c[19]=h,r.length++),r};function g(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,s=0,n=0;n<r.length-1;n++){var a=s;s=0;for(var o=67108863&i,c=Math.min(n,e.length-1),h=Math.max(0,n-t.length+1);h<=c;h++){var f=n-h,u=(0|t.words[f])*(0|e.words[h]),d=67108863&u;o=67108863&(d=d+o|0),s+=(a=(a=a+(u/67108864|0)|0)+(d>>>26)|0)>>>26,a&=67108863}r.words[n]=o,i=a,a=s}return 0!==i?r.words[n]=i:r.length--,r._strip()}function y(t,e,r){return g(t,e,r)}function v(t,e){this.x=t,this.y=e}Math.imul||(m=b),n.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?m(this,t,e):r<63?b(this,t,e):r<1024?g(this,t,e):y(this,t,e)},v.prototype.makeRBT=function(t){for(var e=new Array(t),r=n.prototype._countBits(t)-1,i=0;i<t;i++)e[i]=this.revBin(i,r,t);return e},v.prototype.revBin=function(t,e,r){if(0===t||t===r-1)return t;for(var i=0,s=0;s<e;s++)i|=(1&t)<<e-s-1,t>>=1;return i},v.prototype.permute=function(t,e,r,i,s,n){for(var a=0;a<n;a++)i[a]=e[t[a]],s[a]=r[t[a]]},v.prototype.transform=function(t,e,r,i,s,n){this.permute(n,t,e,r,i,s);for(var a=1;a<s;a<<=1)for(var o=a<<1,c=Math.cos(2*Math.PI/o),h=Math.sin(2*Math.PI/o),f=0;f<s;f+=o)for(var u=c,d=h,l=0;l<a;l++){var p=r[f+l],b=i[f+l],m=r[f+l+a],g=i[f+l+a],y=u*m-d*g;g=u*g+d*m,m=y,r[f+l]=p+m,i[f+l]=b+g,r[f+l+a]=p-m,i[f+l+a]=b-g,l!==o&&(y=c*u-h*d,d=c*d+h*u,u=y)}},v.prototype.guessLen13b=function(t,e){var r=1|Math.max(e,t),i=1&r,s=0;for(r=r/2|0;r;r>>>=1)s++;return 1<<s+1+i},v.prototype.conjugate=function(t,e,r){if(!(r<=1))for(var i=0;i<r/2;i++){var s=t[i];t[i]=t[r-i-1],t[r-i-1]=s,s=e[i],e[i]=-e[r-i-1],e[r-i-1]=-s}},v.prototype.normalize13b=function(t,e){for(var r=0,i=0;i<e/2;i++){var s=8192*Math.round(t[2*i+1]/e)+Math.round(t[2*i]/e)+r;t[i]=67108863&s,r=s<67108864?0:s/67108864|0}return t},v.prototype.convert13b=function(t,e,r,s){for(var n=0,a=0;a<e;a++)n+=0|t[a],r[2*a]=8191&n,n>>>=13,r[2*a+1]=8191&n,n>>>=13;for(a=2*e;a<s;++a)r[a]=0;i(0===n),i(0==(-8192&n))},v.prototype.stub=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=0;return e},v.prototype.mulp=function(t,e,r){var i=2*this.guessLen13b(t.length,e.length),s=this.makeRBT(i),n=this.stub(i),a=new Array(i),o=new Array(i),c=new Array(i),h=new Array(i),f=new Array(i),u=new Array(i),d=r.words;d.length=i,this.convert13b(t.words,t.length,a,i),this.convert13b(e.words,e.length,h,i),this.transform(a,n,o,c,i,s),this.transform(h,n,f,u,i,s);for(var l=0;l<i;l++){var p=o[l]*f[l]-c[l]*u[l];c[l]=o[l]*u[l]+c[l]*f[l],o[l]=p}return this.conjugate(o,c,i),this.transform(o,c,d,n,i,s),this.conjugate(d,n,i),this.normalize13b(d,i),r.negative=t.negative^e.negative,r.length=t.length+e.length,r._strip()},n.prototype.mul=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},n.prototype.mulf=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),y(this,t,e)},n.prototype.imul=function(t){return this.clone().mulTo(t,this)},n.prototype.imuln=function(t){var e=t<0;e&&(t=-t),i("number"==typeof t),i(t<67108864);for(var r=0,s=0;s<this.length;s++){var n=(0|this.words[s])*t,a=(67108863&n)+(67108863&r);r>>=26,r+=n/67108864|0,r+=a>>>26,this.words[s]=67108863&a}return 0!==r&&(this.words[s]=r,this.length++),e?this.ineg():this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,s=r%26;e[r]=t.words[i]>>>s&1}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var s=r.sqr();i<e.length;i++,s=s.sqr())0!==e[i]&&(r=r.mul(s));return r},n.prototype.iushln=function(t){i("number"==typeof t&&t>=0);var e,r=t%26,s=(t-r)/26,n=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(e=0;e<this.length;e++){var o=this.words[e]&n,c=(0|this.words[e])-o<<r;this.words[e]=c|a,a=o>>>26-r}a&&(this.words[e]=a,this.length++)}if(0!==s){for(e=this.length-1;e>=0;e--)this.words[e+s]=this.words[e];for(e=0;e<s;e++)this.words[e]=0;this.length+=s}return this._strip()},n.prototype.ishln=function(t){return i(0===this.negative),this.iushln(t)},n.prototype.iushrn=function(t,e,r){var s;i("number"==typeof t&&t>=0),s=e?(e-e%26)/26:0;var n=t%26,a=Math.min((t-n)/26,this.length),o=67108863^67108863>>>n<<n,c=r;if(s-=a,s=Math.max(0,s),c){for(var h=0;h<a;h++)c.words[h]=this.words[h];c.length=a}if(0===a);else if(this.length>a)for(this.length-=a,h=0;h<this.length;h++)this.words[h]=this.words[h+a];else this.words[0]=0,this.length=1;var f=0;for(h=this.length-1;h>=0&&(0!==f||h>=s);h--){var u=0|this.words[h];this.words[h]=f<<26-n|u>>>n,f=u&o}return c&&0!==f&&(c.words[c.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(t,e,r){return i(0===this.negative),this.iushrn(t,e,r)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){i("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,s=1<<e;return!(this.length<=r||!(this.words[r]&s))},n.prototype.imaskn=function(t){i("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26;if(i(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var s=67108863^67108863>>>e<<e;this.words[this.length-1]&=s}return this._strip()},n.prototype.maskn=function(t){return this.clone().imaskn(t)},n.prototype.iaddn=function(t){return i("number"==typeof t),i(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},n.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(i("number"==typeof t),i(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},n.prototype.addn=function(t){return this.clone().iaddn(t)},n.prototype.subn=function(t){return this.clone().isubn(t)},n.prototype.iabs=function(){return this.negative=0,this},n.prototype.abs=function(){return this.clone().iabs()},n.prototype._ishlnsubmul=function(t,e,r){var s,n,a=t.length+r;this._expand(a);var o=0;for(s=0;s<t.length;s++){n=(0|this.words[s+r])+o;var c=(0|t.words[s])*e;o=((n-=67108863&c)>>26)-(c/67108864|0),this.words[s+r]=67108863&n}for(;s<this.length-r;s++)o=(n=(0|this.words[s+r])+o)>>26,this.words[s+r]=67108863&n;if(0===o)return this._strip();for(i(-1===o),o=0,s=0;s<this.length;s++)o=(n=-(0|this.words[s])+o)>>26,this.words[s]=67108863&n;return this.negative=1,this._strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),s=t,a=0|s.words[s.length-1];0!=(r=26-this._countBits(a))&&(s=s.ushln(r),i.iushln(r),a=0|s.words[s.length-1]);var o,c=i.length-s.length;if("mod"!==e){(o=new n(null)).length=c+1,o.words=new Array(o.length);for(var h=0;h<o.length;h++)o.words[h]=0}var f=i.clone()._ishlnsubmul(s,1,c);0===f.negative&&(i=f,o&&(o.words[c]=1));for(var u=c-1;u>=0;u--){var d=67108864*(0|i.words[s.length+u])+(0|i.words[s.length+u-1]);for(d=Math.min(d/a|0,67108863),i._ishlnsubmul(s,d,u);0!==i.negative;)d--,i.negative=0,i._ishlnsubmul(s,1,u),i.isZero()||(i.negative^=1);o&&(o.words[u]=d)}return o&&o._strip(),i._strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:o||null,mod:i}},n.prototype.divmod=function(t,e,r){return i(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),"mod"!==e&&(s=o.div.neg()),"div"!==e&&(a=o.mod.neg(),r&&0!==a.negative&&a.iadd(t)),{div:s,mod:a}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),"mod"!==e&&(s=o.div.neg()),{div:s,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),e),"div"!==e&&(a=o.mod.neg(),r&&0!==a.negative&&a.isub(t)),{div:o.div,mod:a}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new n(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modrn(t.words[0]))}:this._wordDiv(t,e);var s,a,o},n.prototype.div=function(t){return this.divmod(t,"div",!1).div},n.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},n.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),s=t.andln(1),n=r.cmp(i);return n<0||1===s&&0===n?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modrn=function(t){var e=t<0;e&&(t=-t),i(t<=67108863);for(var r=(1<<26)%t,s=0,n=this.length-1;n>=0;n--)s=(r*s+(0|this.words[n]))%t;return e?-s:s},n.prototype.modn=function(t){return this.modrn(t)},n.prototype.idivn=function(t){var e=t<0;e&&(t=-t),i(t<=67108863);for(var r=0,s=this.length-1;s>=0;s--){var n=(0|this.words[s])+67108864*r;this.words[s]=n/t|0,r=n%t}return this._strip(),e?this.ineg():this},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var s=new n(1),a=new n(0),o=new n(0),c=new n(1),h=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++h;for(var f=r.clone(),u=e.clone();!e.isZero();){for(var d=0,l=1;0==(e.words[0]&l)&&d<26;++d,l<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(s.isOdd()||a.isOdd())&&(s.iadd(f),a.isub(u)),s.iushrn(1),a.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(o.isOdd()||c.isOdd())&&(o.iadd(f),c.isub(u)),o.iushrn(1),c.iushrn(1);e.cmp(r)>=0?(e.isub(r),s.isub(o),a.isub(c)):(r.isub(e),o.isub(s),c.isub(a))}return{a:o,b:c,gcd:r.iushln(h)}},n.prototype._invmp=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var s,a=new n(1),o=new n(0),c=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var h=0,f=1;0==(e.words[0]&f)&&h<26;++h,f<<=1);if(h>0)for(e.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);for(var u=0,d=1;0==(r.words[0]&d)&&u<26;++u,d<<=1);if(u>0)for(r.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(c),o.iushrn(1);e.cmp(r)>=0?(e.isub(r),a.isub(o)):(r.isub(e),o.isub(a))}return(s=0===e.cmpn(1)?a:o).cmpn(0)<0&&s.iadd(t),s},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var s=e.cmp(r);if(s<0){var n=e;e=r,r=n}else if(0===s||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return 0==(1&this.words[0])},n.prototype.isOdd=function(){return 1==(1&this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){i("number"==typeof t);var e=t%26,r=(t-e)/26,s=1<<e;if(this.length<=r)return this._expand(r+1),this.words[r]|=s,this;for(var n=s,a=r;0!==n&&a<this.length;a++){var o=0|this.words[a];n=(o+=n)>>>26,o&=67108863,this.words[a]=o}return 0!==n&&(this.words[a]=n,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)e=1;else{r&&(t=-t),i(t<=67108863,"Number is too big");var s=0|this.words[0];e=s===t?0:s<t?-1:1}return 0!==this.negative?0|-e:e},n.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},n.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],s=0|t.words[r];if(i!==s){i<s?e=-1:i>s&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new E(t)},n.prototype.toRed=function(t){return i(!this.red,"Already a number in reduction context"),i(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return i(!this.red,"Already a number in reduction context"),this._forceRed(t)},n.prototype.redAdd=function(t){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},n.prototype.redIAdd=function(t){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},n.prototype.redSub=function(t){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},n.prototype.redISub=function(t){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},n.prototype.redShl=function(t){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},n.prototype.redMul=function(t){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return i(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function S(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function _(){S.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function I(){S.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function O(){S.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function B(){S.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else i(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function P(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}S.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},S.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},S.prototype.split=function(t,e){t.iushrn(this.n,0,e)},S.prototype.imulK=function(t){return t.imul(this.k)},s(_,S),_.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),s=0;s<i;s++)e.words[s]=t.words[s];if(e.length=i,t.length<=9)return t.words[0]=0,void(t.length=1);var n=t.words[9];for(e.words[e.length++]=n&r,s=10;s<t.length;s++){var a=0|t.words[s];t.words[s-10]=(a&r)<<4|n>>>22,n=a}n>>>=22,t.words[s-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},_.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},s(I,S),s(O,S),s(B,S),B.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,s=67108863&i;i>>>=26,t.words[r]=s,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(w[t])return w[t];var e;if("k256"===t)e=new _;else if("p224"===t)e=new I;else if("p192"===t)e=new O;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new B}return w[t]=e,e},E.prototype._verify1=function(t){i(0===t.negative,"red works only with positives"),i(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){i(0==(t.negative|e.negative),"red works only with positives"),i(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(f(t,t.umod(this.m)._forceRed(this)),t)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(i(e%2==1),3===e){var r=this.m.add(new n(1)).iushrn(2);return this.pow(t,r)}for(var s=this.m.subn(1),a=0;!s.isZero()&&0===s.andln(1);)a++,s.iushrn(1);i(!s.isZero());var o=new n(1).toRed(this),c=o.redNeg(),h=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new n(2*f*f).toRed(this);0!==this.pow(f,h).cmp(c);)f.redIAdd(c);for(var u=this.pow(f,s),d=this.pow(t,s.addn(1).iushrn(1)),l=this.pow(t,s),p=a;0!==l.cmp(o);){for(var b=l,m=0;0!==b.cmp(o);m++)b=b.redSqr();i(m<p);var g=this.pow(u,new n(1).iushln(p-m-1));d=d.redMul(g),u=g.redSqr(),l=l.redMul(u),p=m}return d},E.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},E.prototype.pow=function(t,e){if(e.isZero())return new n(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new n(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var s=r[0],a=0,o=0,c=e.bitLength()%26;for(0===c&&(c=26),i=e.length-1;i>=0;i--){for(var h=e.words[i],f=c-1;f>=0;f--){var u=h>>f&1;s!==r[0]&&(s=this.sqr(s)),0!==u||0!==a?(a<<=1,a|=u,(4==++o||0===i&&0===f)&&(s=this.mul(s,r[a]),o=0,a=0)):o=0}c=26}return s},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new P(t)},s(P,E),P.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},P.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},P.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=r.isub(i).iushrn(this.shift),n=s;return s.cmp(this.m)>=0?n=s.isub(this.m):s.cmpn(0)<0&&(n=s.iadd(this.m)),n._forceRed(this)},P.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=r.isub(i).iushrn(this.shift),a=s;return s.cmp(this.m)>=0?a=s.isub(this.m):s.cmpn(0)<0&&(a=s.iadd(this.m)),a._forceRed(this)},P.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t=r.nmd(t),this)},931:(t,e,r)=>{var i;function s(t){this.rand=t}if(t.exports=function(t){return i||(i=new s(null)),i.generate(t)},t.exports.Rand=s,s.prototype.generate=function(t){return this._rand(t)},s.prototype._rand=function(t){if(this.rand.getBytes)return this.rand.getBytes(t);for(var e=new Uint8Array(t),r=0;r<e.length;r++)e[r]=this.rand.getByte();return e},"object"==typeof self)self.crypto&&self.crypto.getRandomValues?s.prototype._rand=function(t){var e=new Uint8Array(t);return self.crypto.getRandomValues(e),e}:self.msCrypto&&self.msCrypto.getRandomValues?s.prototype._rand=function(t){var e=new Uint8Array(t);return self.msCrypto.getRandomValues(e),e}:"object"==typeof window&&(s.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var n=r(113);if("function"!=typeof n.randomBytes)throw new Error("Not supported");s.prototype._rand=function(t){return n.randomBytes(t)}}catch(t){}},191:(t,e,r)=>{const i=r(162);t.exports=i("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},555:(t,e,r)=>{t.exports=r(113).createHmac},715:(t,e,r)=>{var i=e;i.utils=r(436),i.common=r(772),i.sha=r(41),i.ripemd=r(949),i.hmac=r(326),i.sha1=i.sha.sha1,i.sha256=i.sha.sha256,i.sha224=i.sha.sha224,i.sha384=i.sha.sha384,i.sha512=i.sha.sha512,i.ripemd160=i.ripemd.ripemd160},772:(t,e,r)=>{"use strict";var i=r(436),s=r(746);function n(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}e.BlockHash=n,n.prototype.update=function(t,e){if(t=i.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var r=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=i.join32(t,0,t.length-r,this.endian);for(var s=0;s<t.length;s+=this._delta32)this._update(t,s,s+this._delta32)}return this},n.prototype.digest=function(t){return this.update(this._pad()),s(null===this.pending),this._digest(t)},n.prototype._pad=function(){var t=this.pendingTotal,e=this._delta8,r=e-(t+this.padLength)%e,i=new Array(r+this.padLength);i[0]=128;for(var s=1;s<r;s++)i[s]=0;if(t<<=3,"big"===this.endian){for(var n=8;n<this.padLength;n++)i[s++]=0;i[s++]=0,i[s++]=0,i[s++]=0,i[s++]=0,i[s++]=t>>>24&255,i[s++]=t>>>16&255,i[s++]=t>>>8&255,i[s++]=255&t}else for(i[s++]=255&t,i[s++]=t>>>8&255,i[s++]=t>>>16&255,i[s++]=t>>>24&255,i[s++]=0,i[s++]=0,i[s++]=0,i[s++]=0,n=8;n<this.padLength;n++)i[s++]=0;return i}},326:(t,e,r)=>{"use strict";var i=r(436),s=r(746);function n(t,e,r){if(!(this instanceof n))return new n(t,e,r);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(i.toArray(e,r))}t.exports=n,n.prototype._init=function(t){t.length>this.blockSize&&(t=(new this.Hash).update(t).digest()),s(t.length<=this.blockSize);for(var e=t.length;e<this.blockSize;e++)t.push(0);for(e=0;e<t.length;e++)t[e]^=54;for(this.inner=(new this.Hash).update(t),e=0;e<t.length;e++)t[e]^=106;this.outer=(new this.Hash).update(t)},n.prototype.update=function(t,e){return this.inner.update(t,e),this},n.prototype.digest=function(t){return this.outer.update(this.inner.digest()),this.outer.digest(t)}},949:(t,e,r)=>{"use strict";var i=r(436),s=r(772),n=i.rotl32,a=i.sum32,o=i.sum32_3,c=i.sum32_4,h=s.BlockHash;function f(){if(!(this instanceof f))return new f;h.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}function u(t,e,r,i){return t<=15?e^r^i:t<=31?e&r|~e&i:t<=47?(e|~r)^i:t<=63?e&i|r&~i:e^(r|~i)}function d(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function l(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}i.inherits(f,h),e.ripemd160=f,f.blockSize=512,f.outSize=160,f.hmacStrength=192,f.padLength=64,f.prototype._update=function(t,e){for(var r=this.h[0],i=this.h[1],s=this.h[2],h=this.h[3],f=this.h[4],y=r,v=i,w=s,S=h,_=f,I=0;I<80;I++){var O=a(n(c(r,u(I,i,s,h),t[p[I]+e],d(I)),m[I]),f);r=f,f=h,h=n(s,10),s=i,i=O,O=a(n(c(y,u(79-I,v,w,S),t[b[I]+e],l(I)),g[I]),_),y=_,_=S,S=n(w,10),w=v,v=O}O=o(this.h[1],s,S),this.h[1]=o(this.h[2],h,_),this.h[2]=o(this.h[3],f,y),this.h[3]=o(this.h[4],r,v),this.h[4]=o(this.h[0],i,w),this.h[0]=O},f.prototype._digest=function(t){return"hex"===t?i.toHex32(this.h,"little"):i.split32(this.h,"little")};var p=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],b=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],m=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],g=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]},41:(t,e,r)=>{"use strict";e.sha1=r(761),e.sha224=r(799),e.sha256=r(344),e.sha384=r(978),e.sha512=r(900)},761:(t,e,r)=>{"use strict";var i=r(436),s=r(772),n=r(38),a=i.rotl32,o=i.sum32,c=i.sum32_5,h=n.ft_1,f=s.BlockHash,u=[1518500249,1859775393,2400959708,3395469782];function d(){if(!(this instanceof d))return new d;f.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}i.inherits(d,f),t.exports=d,d.blockSize=512,d.outSize=160,d.hmacStrength=80,d.padLength=64,d.prototype._update=function(t,e){for(var r=this.W,i=0;i<16;i++)r[i]=t[e+i];for(;i<r.length;i++)r[i]=a(r[i-3]^r[i-8]^r[i-14]^r[i-16],1);var s=this.h[0],n=this.h[1],f=this.h[2],d=this.h[3],l=this.h[4];for(i=0;i<r.length;i++){var p=~~(i/20),b=c(a(s,5),h(p,n,f,d),l,r[i],u[p]);l=d,d=f,f=a(n,30),n=s,s=b}this.h[0]=o(this.h[0],s),this.h[1]=o(this.h[1],n),this.h[2]=o(this.h[2],f),this.h[3]=o(this.h[3],d),this.h[4]=o(this.h[4],l)},d.prototype._digest=function(t){return"hex"===t?i.toHex32(this.h,"big"):i.split32(this.h,"big")}},799:(t,e,r)=>{"use strict";var i=r(436),s=r(344);function n(){if(!(this instanceof n))return new n;s.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}i.inherits(n,s),t.exports=n,n.blockSize=512,n.outSize=224,n.hmacStrength=192,n.padLength=64,n.prototype._digest=function(t){return"hex"===t?i.toHex32(this.h.slice(0,7),"big"):i.split32(this.h.slice(0,7),"big")}},344:(t,e,r)=>{"use strict";var i=r(436),s=r(772),n=r(38),a=r(746),o=i.sum32,c=i.sum32_4,h=i.sum32_5,f=n.ch32,u=n.maj32,d=n.s0_256,l=n.s1_256,p=n.g0_256,b=n.g1_256,m=s.BlockHash,g=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function y(){if(!(this instanceof y))return new y;m.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=g,this.W=new Array(64)}i.inherits(y,m),t.exports=y,y.blockSize=512,y.outSize=256,y.hmacStrength=192,y.padLength=64,y.prototype._update=function(t,e){for(var r=this.W,i=0;i<16;i++)r[i]=t[e+i];for(;i<r.length;i++)r[i]=c(b(r[i-2]),r[i-7],p(r[i-15]),r[i-16]);var s=this.h[0],n=this.h[1],m=this.h[2],g=this.h[3],y=this.h[4],v=this.h[5],w=this.h[6],S=this.h[7];for(a(this.k.length===r.length),i=0;i<r.length;i++){var _=h(S,l(y),f(y,v,w),this.k[i],r[i]),I=o(d(s),u(s,n,m));S=w,w=v,v=y,y=o(g,_),g=m,m=n,n=s,s=o(_,I)}this.h[0]=o(this.h[0],s),this.h[1]=o(this.h[1],n),this.h[2]=o(this.h[2],m),this.h[3]=o(this.h[3],g),this.h[4]=o(this.h[4],y),this.h[5]=o(this.h[5],v),this.h[6]=o(this.h[6],w),this.h[7]=o(this.h[7],S)},y.prototype._digest=function(t){return"hex"===t?i.toHex32(this.h,"big"):i.split32(this.h,"big")}},978:(t,e,r)=>{"use strict";var i=r(436),s=r(900);function n(){if(!(this instanceof n))return new n;s.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}i.inherits(n,s),t.exports=n,n.blockSize=1024,n.outSize=384,n.hmacStrength=192,n.padLength=128,n.prototype._digest=function(t){return"hex"===t?i.toHex32(this.h.slice(0,12),"big"):i.split32(this.h.slice(0,12),"big")}},900:(t,e,r)=>{"use strict";var i=r(436),s=r(772),n=r(746),a=i.rotr64_hi,o=i.rotr64_lo,c=i.shr64_hi,h=i.shr64_lo,f=i.sum64,u=i.sum64_hi,d=i.sum64_lo,l=i.sum64_4_hi,p=i.sum64_4_lo,b=i.sum64_5_hi,m=i.sum64_5_lo,g=s.BlockHash,y=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function v(){if(!(this instanceof v))return new v;g.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=y,this.W=new Array(160)}function w(t,e,r,i,s){var n=t&r^~t&s;return n<0&&(n+=4294967296),n}function S(t,e,r,i,s,n){var a=e&i^~e&n;return a<0&&(a+=4294967296),a}function _(t,e,r,i,s){var n=t&r^t&s^r&s;return n<0&&(n+=4294967296),n}function I(t,e,r,i,s,n){var a=e&i^e&n^i&n;return a<0&&(a+=4294967296),a}function O(t,e){var r=a(t,e,28)^a(e,t,2)^a(e,t,7);return r<0&&(r+=4294967296),r}function B(t,e){var r=o(t,e,28)^o(e,t,2)^o(e,t,7);return r<0&&(r+=4294967296),r}function E(t,e){var r=o(t,e,14)^o(t,e,18)^o(e,t,9);return r<0&&(r+=4294967296),r}function P(t,e){var r=a(t,e,1)^a(t,e,8)^c(t,e,7);return r<0&&(r+=4294967296),r}function N(t,e){var r=o(t,e,1)^o(t,e,8)^h(t,e,7);return r<0&&(r+=4294967296),r}function A(t,e){var r=o(t,e,19)^o(e,t,29)^h(t,e,6);return r<0&&(r+=4294967296),r}i.inherits(v,g),t.exports=v,v.blockSize=1024,v.outSize=512,v.hmacStrength=192,v.padLength=128,v.prototype._prepareBlock=function(t,e){for(var r=this.W,i=0;i<32;i++)r[i]=t[e+i];for(;i<r.length;i+=2){var s=(m=r[i-4],g=r[i-3],y=void 0,(y=a(m,g,19)^a(g,m,29)^c(m,g,6))<0&&(y+=4294967296),y),n=A(r[i-4],r[i-3]),o=r[i-14],h=r[i-13],f=P(r[i-30],r[i-29]),u=N(r[i-30],r[i-29]),d=r[i-32],b=r[i-31];r[i]=l(s,n,o,h,f,u,d,b),r[i+1]=p(s,n,o,h,f,u,d,b)}var m,g,y},v.prototype._update=function(t,e){this._prepareBlock(t,e);var r,i,s,o=this.W,c=this.h[0],h=this.h[1],l=this.h[2],p=this.h[3],g=this.h[4],y=this.h[5],v=this.h[6],P=this.h[7],N=this.h[8],A=this.h[9],k=this.h[10],R=this.h[11],x=this.h[12],M=this.h[13],T=this.h[14],C=this.h[15];n(this.k.length===o.length);for(var H=0;H<o.length;H+=2){var L=T,F=C,K=(s=void 0,(s=a(r=N,i=A,14)^a(r,i,18)^a(i,r,9))<0&&(s+=4294967296),s),U=E(N,A),D=w(N,0,k,0,x),V=S(0,A,0,R,0,M),j=this.k[H],z=this.k[H+1],q=o[H],G=o[H+1],Y=b(L,F,K,U,D,V,j,z,q,G),J=m(L,F,K,U,D,V,j,z,q,G);L=O(c,h),F=B(c,h),K=_(c,0,l,0,g),U=I(0,h,0,p,0,y);var W=u(L,F,K,U),Q=d(L,F,K,U);T=x,C=M,x=k,M=R,k=N,R=A,N=u(v,P,Y,J),A=d(P,P,Y,J),v=g,P=y,g=l,y=p,l=c,p=h,c=u(Y,J,W,Q),h=d(Y,J,W,Q)}f(this.h,0,c,h),f(this.h,2,l,p),f(this.h,4,g,y),f(this.h,6,v,P),f(this.h,8,N,A),f(this.h,10,k,R),f(this.h,12,x,M),f(this.h,14,T,C)},v.prototype._digest=function(t){return"hex"===t?i.toHex32(this.h,"big"):i.split32(this.h,"big")}},38:(t,e,r)=>{"use strict";var i=r(436).rotr32;function s(t,e,r){return t&e^~t&r}function n(t,e,r){return t&e^t&r^e&r}function a(t,e,r){return t^e^r}e.ft_1=function(t,e,r,i){return 0===t?s(e,r,i):1===t||3===t?a(e,r,i):2===t?n(e,r,i):void 0},e.ch32=s,e.maj32=n,e.p32=a,e.s0_256=function(t){return i(t,2)^i(t,13)^i(t,22)},e.s1_256=function(t){return i(t,6)^i(t,11)^i(t,25)},e.g0_256=function(t){return i(t,7)^i(t,18)^t>>>3},e.g1_256=function(t){return i(t,17)^i(t,19)^t>>>10}},436:(t,e,r)=>{"use strict";var i=r(746),s=r(378);function n(t,e){return 55296==(64512&t.charCodeAt(e))&&!(e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1))}function a(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function o(t){return 1===t.length?"0"+t:t}function c(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}e.inherits=s,e.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),s=0;s<t.length;s+=2)r.push(parseInt(t[s]+t[s+1],16))}else for(var i=0,s=0;s<t.length;s++){var a=t.charCodeAt(s);a<128?r[i++]=a:a<2048?(r[i++]=a>>6|192,r[i++]=63&a|128):n(t,s)?(a=65536+((1023&a)<<10)+(1023&t.charCodeAt(++s)),r[i++]=a>>18|240,r[i++]=a>>12&63|128,r[i++]=a>>6&63|128,r[i++]=63&a|128):(r[i++]=a>>12|224,r[i++]=a>>6&63|128,r[i++]=63&a|128)}else for(s=0;s<t.length;s++)r[s]=0|t[s];return r},e.toHex=function(t){for(var e="",r=0;r<t.length;r++)e+=o(t[r].toString(16));return e},e.htonl=a,e.toHex32=function(t,e){for(var r="",i=0;i<t.length;i++){var s=t[i];"little"===e&&(s=a(s)),r+=c(s.toString(16))}return r},e.zero2=o,e.zero8=c,e.join32=function(t,e,r,s){var n=r-e;i(n%4==0);for(var a=new Array(n/4),o=0,c=e;o<a.length;o++,c+=4){var h;h="big"===s?t[c]<<24|t[c+1]<<16|t[c+2]<<8|t[c+3]:t[c+3]<<24|t[c+2]<<16|t[c+1]<<8|t[c],a[o]=h>>>0}return a},e.split32=function(t,e){for(var r=new Array(4*t.length),i=0,s=0;i<t.length;i++,s+=4){var n=t[i];"big"===e?(r[s]=n>>>24,r[s+1]=n>>>16&255,r[s+2]=n>>>8&255,r[s+3]=255&n):(r[s+3]=n>>>24,r[s+2]=n>>>16&255,r[s+1]=n>>>8&255,r[s]=255&n)}return r},e.rotr32=function(t,e){return t>>>e|t<<32-e},e.rotl32=function(t,e){return t<<e|t>>>32-e},e.sum32=function(t,e){return t+e>>>0},e.sum32_3=function(t,e,r){return t+e+r>>>0},e.sum32_4=function(t,e,r,i){return t+e+r+i>>>0},e.sum32_5=function(t,e,r,i,s){return t+e+r+i+s>>>0},e.sum64=function(t,e,r,i){var s=t[e],n=i+t[e+1]>>>0,a=(n<i?1:0)+r+s;t[e]=a>>>0,t[e+1]=n},e.sum64_hi=function(t,e,r,i){return(e+i>>>0<e?1:0)+t+r>>>0},e.sum64_lo=function(t,e,r,i){return e+i>>>0},e.sum64_4_hi=function(t,e,r,i,s,n,a,o){var c=0,h=e;return c+=(h=h+i>>>0)<e?1:0,c+=(h=h+n>>>0)<n?1:0,t+r+s+a+(c+=(h=h+o>>>0)<o?1:0)>>>0},e.sum64_4_lo=function(t,e,r,i,s,n,a,o){return e+i+n+o>>>0},e.sum64_5_hi=function(t,e,r,i,s,n,a,o,c,h){var f=0,u=e;return f+=(u=u+i>>>0)<e?1:0,f+=(u=u+n>>>0)<n?1:0,f+=(u=u+o>>>0)<o?1:0,t+r+s+a+c+(f+=(u=u+h>>>0)<h?1:0)>>>0},e.sum64_5_lo=function(t,e,r,i,s,n,a,o,c,h){return e+i+n+o+h>>>0},e.rotr64_hi=function(t,e,r){return(e<<32-r|t>>>r)>>>0},e.rotr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0},e.shr64_hi=function(t,e,r){return t>>>r},e.shr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0}},156:(t,e,r)=>{"use strict";var i=r(715),s=r(504),n=r(746);function a(t){if(!(this instanceof a))return new a(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=s.toArray(t.entropy,t.entropyEnc||"hex"),r=s.toArray(t.nonce,t.nonceEnc||"hex"),i=s.toArray(t.pers,t.persEnc||"hex");n(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,i)}t.exports=a,a.prototype._init=function(t,e,r){var i=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s<this.V.length;s++)this.K[s]=0,this.V[s]=1;this._update(i),this._reseed=1,this.reseedInterval=281474976710656},a.prototype._hmac=function(){return new i.hmac(this.hash,this.K)},a.prototype._update=function(t){var e=this._hmac().update(this.V).update([0]);t&&(e=e.update(t)),this.K=e.digest(),this.V=this._hmac().update(this.V).digest(),t&&(this.K=this._hmac().update(this.V).update([1]).update(t).digest(),this.V=this._hmac().update(this.V).digest())},a.prototype.reseed=function(t,e,r,i){"string"!=typeof e&&(i=r,r=e,e=null),t=s.toArray(t,e),r=s.toArray(r,i),n(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},a.prototype.generate=function(t,e,r,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(i=r,r=e,e=null),r&&(r=s.toArray(r,i||"hex"),this._update(r));for(var n=[];n.length<t;)this.V=this._hmac().update(this.V).digest(),n=n.concat(this.V);var a=n.slice(0,t);return this._update(r),this._reseed++,s.encode(a,e)}},378:(t,e,r)=>{try{var i=r(837);if("function"!=typeof i.inherits)throw"";t.exports=i.inherits}catch(e){t.exports=r(717)}},717:t=>{"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},746:t=>{function e(t,e){if(!t)throw new Error(e||"Assertion failed")}t.exports=e,e.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)}},504:(t,e)=>{"use strict";var r=e;function i(t){return 1===t.length?"0"+t:t}function s(t){for(var e="",r=0;r<t.length;r++)e+=i(t[r].toString(16));return e}r.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"!=typeof t){for(var i=0;i<t.length;i++)r[i]=0|t[i];return r}if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),i=0;i<t.length;i+=2)r.push(parseInt(t[i]+t[i+1],16));else for(i=0;i<t.length;i++){var s=t.charCodeAt(i),n=s>>8,a=255&s;n?r.push(n,a):r.push(a)}return r},r.zero2=i,r.toHex=s,r.encode=function(t,e){return"hex"===e?s(t):t}},601:(t,e,r)=>{var i=r(113),s=r(357),n=r(368),a=r(777);i.pbkdf2Sync&&-1!==i.pbkdf2Sync.toString().indexOf("keylen, digest")?(e.pbkdf2Sync=function(t,e,r,o,c){return s(r,o),t=a(t,n,"Password"),e=a(e,n,"Salt"),c=c||"sha1",i.pbkdf2Sync(t,e,r,o,c)},e.pbkdf2=function(t,e,r,o,c,h){if(s(r,o),t=a(t,n,"Password"),e=a(e,n,"Salt"),"function"==typeof c&&(h=c,c="sha1"),"function"!=typeof h)throw new Error("No callback provided to pbkdf2");return i.pbkdf2(t,e,r,o,c,h)}):(e.pbkdf2Sync=r(493),e.pbkdf2=r(638))},638:(t,e,r)=>{var i,s,n=r(509).Buffer,a=r(357),o=r(368),c=r(493),h=r(777),f=global.crypto&&global.crypto.subtle,u={sha:"SHA-1","sha-1":"SHA-1",sha1:"SHA-1",sha256:"SHA-256","sha-256":"SHA-256",sha384:"SHA-384","sha-384":"SHA-384","sha-512":"SHA-512",sha512:"SHA-512"},d=[];function l(){return s||(s=global.process&&global.process.nextTick?global.process.nextTick:global.queueMicrotask?global.queueMicrotask:global.setImmediate?global.setImmediate:global.setTimeout)}function p(t,e,r,i,s){return f.importKey("raw",t,{name:"PBKDF2"},!1,["deriveBits"]).then((function(t){return f.deriveBits({name:"PBKDF2",salt:e,iterations:r,hash:{name:s}},t,i<<3)})).then((function(t){return n.from(t)}))}t.exports=function(t,e,r,s,b,m){"function"==typeof b&&(m=b,b=void 0);var g=u[(b=b||"sha1").toLowerCase()];if(g&&"function"==typeof global.Promise){if(a(r,s),t=h(t,o,"Password"),e=h(e,o,"Salt"),"function"!=typeof m)throw new Error("No callback provided to pbkdf2");!function(t,e){t.then((function(t){l()((function(){e(null,t)}))}),(function(t){l()((function(){e(t)}))}))}(function(t){if(global.process&&!global.process.browser)return Promise.resolve(!1);if(!f||!f.importKey||!f.deriveBits)return Promise.resolve(!1);if(void 0!==d[t])return d[t];var e=p(i=i||n.alloc(8),i,10,128,t).then((function(){return!0})).catch((function(){return!1}));return d[t]=e,e}(g).then((function(i){return i?p(t,e,r,s,g):c(t,e,r,s,b)})),m)}else l()((function(){var i;try{i=c(t,e,r,s,b)}catch(t){return m(t)}m(null,i)}))}},368:t=>{var e;e=global.process&&global.process.browser?"utf-8":global.process&&global.process.version?parseInt(process.version.split(".")[0].slice(1),10)>=6?"utf-8":"binary":"utf-8",t.exports=e},357:t=>{var e=Math.pow(2,30)-1;t.exports=function(t,r){if("number"!=typeof t)throw new TypeError("Iterations not a number");if(t<0)throw new TypeError("Bad iterations");if("number"!=typeof r)throw new TypeError("Key length not a number");if(r<0||r>e||r!=r)throw new TypeError("Bad key length")}},493:(t,e,r)=>{var i={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20},s=r(555),n=r(509).Buffer,a=r(357),o=r(368),c=r(777);t.exports=function(t,e,r,h,f){a(r,h),t=c(t,o,"Password"),e=c(e,o,"Salt"),f=f||"sha1";var u=n.allocUnsafe(h),d=n.allocUnsafe(e.length+4);e.copy(d,0,0,e.length);for(var l=0,p=i[f],b=Math.ceil(h/p),m=1;m<=b;m++){d.writeUInt32BE(m,e.length);for(var g=s(f,t).update(d).digest(),y=g,v=1;v<r;v++){y=s(f,t).update(y).digest();for(var w=0;w<p;w++)g[w]^=y[w]}g.copy(u,l),l+=p}return u}},777:(t,e,r)=>{var i=r(509).Buffer;t.exports=function(t,e,r){if(i.isBuffer(t))return t;if("string"==typeof t)return i.from(t,e);if(ArrayBuffer.isView(t))return i.from(t.buffer);throw new TypeError(r+" must be a string, a Buffer, a typed array or a DataView")}},353:(t,e,r)=>{t.exports=r(113).randomBytes},509:(t,e,r)=>{var i=r(300),s=i.Buffer;function n(t,e){for(var r in t)e[r]=t[r]}function a(t,e,r){return s(t,e,r)}s.from&&s.alloc&&s.allocUnsafe&&s.allocUnsafeSlow?t.exports=i:(n(i,e),e.Buffer=a),a.prototype=Object.create(s.prototype),n(s,a),a.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return s(t,e,r)},a.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var i=s(t);return void 0!==e?"string"==typeof r?i.fill(e,r):i.fill(e):i.fill(0),i},a.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return s(t)},a.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i.SlowBuffer(t)}},300:t=>{"use strict";t.exports=require("buffer")},113:t=>{"use strict";t.exports=require("crypto")},837:t=>{"use strict";t.exports=require("util")},726:t=>{"use strict";t.exports={i8:"7.0.1"}}},e={};function r(i){var s=e[i];if(void 0!==s)return s.exports;var n=e[i]={id:i,loaded:!1,exports:{}};return t[i].call(n.exports,n,n.exports,r),n.loaded=!0,n.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.nmd=t=>(t.paths=[],t.children||(t.children=[]),t);var i={};(()=>{"use strict";r.r(i),r.d(i,{Ach:()=>gt,Address:()=>q,Aes:()=>pt,Aescbc:()=>mt,Base58:()=>S,Base58Check:()=>P,Bip32:()=>G,Bip39:()=>Q,Block:()=>ot,BlockHeader:()=>tt,Bn:()=>p,Br:()=>g,Bsm:()=>$,Bw:()=>y,Cbc:()=>bt,Constants:()=>k,Ecdsa:()=>Z,Ecies:()=>yt,Hash:()=>E,Interp:()=>ct,KeyPair:()=>X,OpCode:()=>T,Point:()=>L,PrivKey:()=>V,PubKey:()=>F,Random:()=>D,Script:()=>z,Sig:()=>j,SigOperations:()=>ht,Struct:()=>w,Tx:()=>at,TxBuilder:()=>dt,TxIn:()=>st,TxOut:()=>nt,TxOutMap:()=>ft,TxVerifier:()=>lt,VarInt:()=>it,Workers:()=>B,WorkersResult:()=>I,cmp:()=>_,deps:()=>vt,en:()=>Y,es:()=>W,getConstants:()=>R,jp:()=>J,version:()=>wt});var t=r(297),e=r.n(t),s=r(550),n=r.n(s),a=r(191),o=r.n(a),c=r(666),h=r.n(c),f=r(715),u=r.n(f),d=r(601),l=r(300);function p(t,e,...r){if(!(this instanceof p))return new p(t,e,...r);n().call(this,t,e,...r)}function b(t){const e=Buffer.alloc(t.length);for(let r=0;r<t.length;r++)e[r]=t[t.length-1-r];return e}function m(t){p.prototype["_"+t]=p.prototype[t],p.prototype[t]=function(e){return"string"==typeof e?e=new p(e):"number"==typeof e&&(e=new p(e.toString())),this["_"+t](e)}}Object.keys(n()).forEach((function(t){p[t]=n()[t]})),p.prototype=Object.create(n().prototype),p.prototype.constructor=p,p.prototype.fromHex=function(t,e){return this.fromBuffer(Buffer.from(t,"hex"),e)},p.prototype.toHex=function(t){return this.toBuffer(t).toString("hex")},p.prototype.toJSON=function(){return this.toString()},p.prototype.fromJSON=function(t){return p(t).copy(this),this},p.prototype.fromNumber=function(t){return p(t).copy(this),this},p.prototype.toNumber=function(){return parseInt(this.toString(10),10)},p.prototype.fromString=function(t,e){return p(t,e).copy(this),this},p.fromBuffer=function(t,e={endian:"big"}){return"little"===e.endian&&(t=b(t)),new p(t.toString("hex"),16)},p.prototype.fromBuffer=function(t,e){return p.fromBuffer(t,e).copy(this),this},p.prototype.toBuffer=function(t={size:void 0,endian:"big"}){let e;if(t.size){const r=this.toString(16,2),i=r.length/2;if(e=Buffer.from(r,"hex"),i===t.size);else if(i>t.size)e=e.slice(i-e.length,e.length);else if(i<t.size){const r=Buffer.alloc(t.size);for(let t=0;t<e.length;t++)r[r.length-1-t]=e[e.length-1-t];for(let e=0;e<t.size-i;e++)r[e]=0;e=r}}else{const t=this.toString(16,2);e=Buffer.from(t,"hex")}"little"===t.endian&&(e=b(e));const r=Buffer.from([0]);return 0===Buffer.compare(e,r)?Buffer.from([]):e},p.prototype.toFastBuffer=p.prototype.toBuffer,p.fromFastBuffer=p.fromBuffer,p.prototype.fromFastBuffer=p.prototype.fromBuffer,p.prototype.fromSm=function(t,e={endian:"big"}){return 0===t.length&&this.fromBuffer(Buffer.from([0])),"little"===e.endian&&(t=b(t)),128&t[0]?(t[0]=127&t[0],this.fromBuffer(t),this.neg().copy(this)):this.fromBuffer(t),this},p.prototype.toSm=function(t={endian:"big"}){const e=t.endian;let r;return-1===this.cmp(0)?(r=this.neg().toBuffer(),128&r[0]?r=Buffer.concat([Buffer.from([128]),r]):r[0]=128|r[0]):(r=this.toBuffer(),128&r[0]&&(r=Buffer.concat([Buffer.from([0]),r]))),1===r.length&0===r[0]&&(r=Buffer.from([])),"little"===e&&(r=b(r)),r},p.prototype.fromBits=function(t,e={strict:!1}){let r=Buffer.alloc(4);if(r.writeUInt32BE(t,0),t=r.readInt32BE(0),e.strict&&8388608&t)throw new Error("negative bit set");const i=t>>24,s=8388607&t;if(r=Buffer.alloc(4),r.writeInt32BE(s),i<=3)r=r.slice(1,i+1);else{const t=Buffer.alloc(i-3);t.fill(0),r=Buffer.concat([r,t])}return this.fromBuffer(r),8388608&t&&p(0).sub(this).copy(this),this},p.prototype.toBits=function(){let t;t=this.lt(0)?this.neg().toBuffer():this.toBuffer();let e,r=t.length;if(r>3)e=Buffer.concat([Buffer.from([0]),t.slice(0,3)]).readUInt32BE(0);else if(r<=3){const i=Buffer.alloc(3-r+1);i.fill(0),e=Buffer.concat([i,t.slice(0,r)]).readUInt32BE(0)}8388608&e&&(e>>=8,r++),this.lt(0)&&(e|=8388608);const i=r<<24|e;return t=Buffer.alloc(4),t.writeInt32BE(i,0),t.readUInt32BE(0)},p.prototype.fromScriptNumBuffer=function(t,e,r,i=!1){if(void 0===r&&(r=4),t.length>r)throw new Error(`script number overflow nMaxNumSize: ${r}`);if(e&&t.length>0&&0==(127&t[t.length-1])&&(t.length<=1||0==(128&t[t.length-2])))throw new Error("non-minimally encoded script number");return 0===t.byteLength||t.byteLength,this.fromSm(t,{endian:"little"})},p.prototype.toScriptNumBuffer=function(t){return this.toSm({endian:"little"})},p.prototype.neg=function(){const t=n().prototype.neg.call(this),e=Object.create(p.prototype);return t.copy(e),e},p.prototype.add=function(t){const e=n().prototype.add.call(this,t);return t=Object.create(p.prototype),e.copy(t),t},p.prototype.sub=function(t){const e=n().prototype.sub.call(this,t);return t=Object.create(p.prototype),e.copy(t),t},p.prototype.mul=function(t){const e=n().prototype.mul.call(this,t);return t=Object.create(p.prototype),e.copy(t),t},p.prototype.mod=function(t){const e=n().prototype.mod.call(this,t);return t=Object.create(p.prototype),e.copy(t),t},p.prototype.umod=function(t){const e=n().prototype.umod.call(this,t);return t=Object.create(p.prototype),e.copy(t),t},p.prototype.invm=function(t){const e=n().prototype.invm.call(this,t);return t=Object.create(p.prototype),e.copy(t),t},p.prototype.div=function(t){const e=n().prototype.div.call(this,t);return t=Object.create(p.prototype),e.copy(t),t},p.prototype.ushln=function(t){const e=n().prototype.ushln.call(this,t),r=Object.create(p.prototype);return e.copy(r),r},p.prototype.ushrn=function(t){const e=n().prototype.ushrn.call(this,t),r=Object.create(p.prototype);return e.copy(r),r},p.prototype.cmp=function(t){return n().prototype.cmp.call(this,t)},p.prototype.eq=function(t){return 0===this.cmp(t)},p.prototype.neq=function(t){return 0!==this.cmp(t)},p.prototype.gt=function(t){return this.cmp(t)>0},p.prototype.geq=function(t){return this.cmp(t)>=0},p.prototype.lt=function(t){return this.cmp(t)<0},p.prototype.leq=function(t){return this.cmp(t)<=0},m("add"),m("sub"),m("mul"),m("mod"),m("invm"),m("div"),m("cmp"),m("gt"),m("geq"),m("lt"),m("leq");class g{constructor(t){this.fromObject({buf:t})}fromObject(t){return this.buf=t.buf||this.buf||void 0,this.pos=t.pos||this.pos||0,this}eof(){return this.pos>=this.buf.length}read(t=this.buf.length){const e=this.buf.slice(this.pos,this.pos+t);return this.pos=this.pos+t,e}readReverse(t=this.buf.length){const e=this.buf.slice(this.pos,this.pos+t);this.pos=this.pos+t;const r=Buffer.alloc(e.length);for(let t=0;t<r.length;t++)r[t]=e[e.length-1-t];return r}readUInt8(){const t=this.buf.readUInt8(this.pos);return this.pos=this.pos+1,t}readInt8(){const t=this.buf.readInt8(this.pos);return this.pos=this.pos+1,t}readUInt16BE(){const t=this.buf.readUInt16BE(this.pos);return this.pos=this.pos+2,t}readInt16BE(){const t=this.buf.readInt16BE(this.pos);return this.pos=this.pos+2,t}readUInt16LE(){const t=this.buf.readUInt16LE(this.pos);return this.pos=this.pos+2,t}readInt16LE(){const t=this.buf.readInt16LE(this.pos);return this.pos=this.pos+2,t}readUInt32BE(){const t=this.buf.readUInt32BE(this.pos);return this.pos=this.pos+4,t}readInt32BE(){const t=this.buf.readInt32BE(this.pos);return this.pos=this.pos+4,t}readUInt32LE(){const t=this.buf.readUInt32LE(this.pos);return this.pos=this.pos+4,t}readInt32LE(){const t=this.buf.readInt32LE(this.pos);return this.pos=this.pos+4,t}readUInt64BEBn(){const t=this.buf.slice(this.pos,this.pos+8),e=(new p).fromBuffer(t);return this.pos=this.pos+8,e}readUInt64LEBn(){const t=this.readReverse(8);return(new p).fromBuffer(t)}readVarIntNum(){const t=this.readUInt8();let e,r;switch(t){case 253:return this.readUInt16LE();case 254:return this.readUInt32LE();case 255:if(e=this.readUInt64LEBn(),r=e.toNumber(),r<=Math.pow(2,53))return r;throw new Error("number too large to retain precision - use readVarIntBn");default:return t}}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 t=this.readUInt8();switch(t){case 253:return new p(this.readUInt16LE());case 254:return new p(this.readUInt32LE());case 255:return this.readUInt64LEBn();default:return new p(t)}}}class y{constructor(t){this.fromObject({bufs:t})}fromObject(t){return this.bufs=t.bufs||this.bufs||[],this}getLength(){let t=0;for(const e in this.bufs)t+=this.bufs[e].length;return t}toBuffer(){return Buffer.concat(this.bufs)}write(t){return this.bufs.push(t),this}writeReverse(t){const e=Buffer.alloc(t.length);for(let r=0;r<e.length;r++)e[r]=t[t.length-1-r];return this.bufs.push(e),this}writeUInt8(t){const e=Buffer.alloc(1);return e.writeUInt8(t,0),this.write(e),this}writeInt8(t){const e=Buffer.alloc(1);return e.writeInt8(t,0),this.write(e),this}writeUInt16BE(t){const e=Buffer.alloc(2);return e.writeUInt16BE(t,0),this.write(e),this}writeInt16BE(t){const e=Buffer.alloc(2);return e.writeInt16BE(t,0),this.write(e),this}writeUInt16LE(t){const e=Buffer.alloc(2);return e.writeUInt16LE(t,0),this.write(e),this}writeInt16LE(t){const e=Buffer.alloc(2);return e.writeInt16LE(t,0),this.write(e),this}writeUInt32BE(t){const e=Buffer.alloc(4);return e.writeUInt32BE(t,0),this.write(e),this}writeInt32BE(t){const e=Buffer.alloc(4);return e.writeInt32BE(t,0),this.write(e),this}writeUInt32LE(t){const e=Buffer.alloc(4);return e.writeUInt32LE(t,0),this.write(e),this}writeInt32LE(t){const e=Buffer.alloc(4);return e.writeInt32LE(t,0),this.write(e),this}writeUInt64BEBn(t){const e=t.toBuffer({size:8});return this.write(e),this}writeUInt64LEBn(t){const e=t.toBuffer({size:8});return this.writeReverse(e),this}writeVarIntNum(t){const e=y.varIntBufNum(t);return this.write(e),this}writeVarIntBn(t){const e=y.varIntBufBn(t);return this.write(e),this}static varIntBufNum(t){let e;return t<253?(e=Buffer.alloc(1),e.writeUInt8(t,0)):t<65536?(e=Buffer.alloc(3),e.writeUInt8(253,0),e.writeUInt16LE(t,1)):t<4294967296?(e=Buffer.alloc(5),e.writeUInt8(254,0),e.writeUInt32LE(t,1)):(e=Buffer.alloc(9),e.writeUInt8(255,0),e.writeInt32LE(-1&t,1),e.writeUInt32LE(Math.floor(t/4294967296),5)),e}static varIntBufBn(t){let e;const r=t.toNumber();if(r<253)e=Buffer.alloc(1),e.writeUInt8(r,0);else if(r<65536)e=Buffer.alloc(3),e.writeUInt8(253,0),e.writeUInt16LE(r,1);else if(r<4294967296)e=Buffer.alloc(5),e.writeUInt8(254,0),e.writeUInt32LE(r,1);else{const r=new y;r.writeUInt8(255),r.writeUInt64LEBn(t),e=r.toBuffer()}return e}}const v=function(t){const e="string"==typeof t?t.charCodeAt(0):t;return e>=97&&e<=102||e>=65&&e<=70||e>=48&&e<=57};class w{constructor(t){this.fromObject(t)}fromObject(t){if(!t)return this;for(const e of Object.keys(t))void 0!==t[e]&&(this[e]=t[e]);return this}static fromObject(t){return(new this).fromObject(t)}fromBr(t){if(!(t instanceof g))throw new Error("br must be a buffer reader");throw new Error("not implemented")}static fromBr(t){return(new this).fromBr(t)}asyncFromBr(t){if(!(t instanceof g))throw new Error("br must be a buffer reader");throw new Error("not implemented")}static asyncFromBr(t){return(new this).asyncFromBr(t)}toBw(t){throw new Error("not implemented")}asyncToBw(t){throw new Error("not implemented")}*genFromBuffers(){throw new Error("not implemented")}*expect(t,e){let r=e;const i=new y;let s=0;for(e&&(i.write(e),s+=e.length);s<t;){const e=t-s;r=yield e,r&&(i.write(r),s+=r.length)}r=i.toBuffer();const n=s-t,a=r.slice(r.length-n,r.length);return r=r.slice(0,r.length-n),{buf:r,remainderbuf:a}}fromBuffer(t,...e){if(!Buffer.isBuffer(t))throw new Error("buf must be a buffer");const r=new g(t);return this.fromBr(r,...e)}static fromBuffer(...t){return(new this).fromBuffer(...t)}asyncFromBuffer(t,...e){if(!Buffer.isBuffer(t))throw new Error("buf must be a buffer");const r=new g(t);return this.asyncFromBr(r,...e)}static asyncFromBuffer(t,...e){return(new this).asyncFromBuffer(t,...e)}fromFastBuffer(t,...e){return 0===t.length?this:this.fromBuffer(t,...e)}static fromFastBuffer(...t){return(new this).fromFastBuffer(...t)}toBuffer(...t){return this.toBw(...t).toBuffer()}asyncToBuffer(...t){return this.asyncToBw(...t).then((t=>t.toBuffer()))}toFastBuffer(...t){return 0===Object.keys(this).length?Buffer.alloc(0):this.toBuffer(...t)}fromHex(t,...e){if(!v(t))throw new Error("invalid hex string");const r=Buffer.from(t,"hex");return this.fromBuffer(r,...e)}static fromHex(t,...e){return(new this).fromHex(t,...e)}asyncFromHex(t,...e){if(!v(t))throw new Error("invalid hex string");const r=Buffer.from(t,"hex");return this.asyncFromBuffer(r,...e)}static asyncFromHex(t,...e){return(new this).asyncFromHex(t,...e)}fromFastHex(t,...e){if(!v(t))throw new Error("invalid hex string");const r=Buffer.from(t,"hex");return this.fromFastBuffer(r,...e)}static fromFastHex(t,...e){return(new this).fromFastHex(t,...e)}toHex(...t){return this.toBuffer(...t).toString("hex")}asyncToHex(...t){return this.asyncToBuffer(...t).then((t=>t.toString("hex")))}toFastHex(...t){return this.toFastBuffer(...t).toString("hex")}fromString(t,...e){if("string"!=typeof t)throw new Error("str must be a string");return this.fromHex(t,...e)}static fromString(t,...e){return(new this).fromString(t,...e)}asyncFromString(t,...e){if("string"!=typeof t)throw new Error("str must be a string");return this.asyncFromHex(t,...e)}static asyncFromString(t,...e){return(new this).asyncFromString(t,...e)}toString(...t){return this.toHex(...t)}asyncToString(...t){return this.asyncToHex(...t)}fromJSON(t){throw new Error("not implemented")}static fromJSON(t,...e){return(new this).fromJSON(t,...e)}asyncFromJSON(t,...e){throw new Error("not implemented")}static asyncFromJSON(t,...e){return(new this).asyncFromJSON(t,...e)}toJSON(){var t={};for(var e in this)if(Array.isArray(this[e])){const i=[];for(var r in this[e])"function"==typeof this[e][r].toJSON?i.push(this[e][r].toJSON()):i.push(JSON.stringify(this[e][r]));t[e]=i}else if(null===this[e])t[e]=this[e];else if("object"==typeof this[e]&&"function"==typeof this[e].toJSON)t[e]=this[e].toJSON();else if("boolean"==typeof this[e]||"number"==typeof this[e]||"string"==typeof this[e])t[e]=this[e];else if(Buffer.isBuffer(this[e]))t[e]=this[e].toString("hex");else if(this[e]instanceof Map)t[e]=JSON.stringify(this[e]);else if("object"==typeof this[e])throw new Error("not implemented");return t}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 S extends w{constructor(t){super({buf:t})}fromHex(t){return this.fromBuffer(Buffer.from(t,"hex"))}toHex(){return this.toBuffer().toString("hex")}static encode(t){if(!Buffer.isBuffer(t))throw new Error("Input should be a buffer");return o().encode(t)}static decode(t){if("string"!=typeof t)throw new Error("Input should be a string");return Buffer.from(o().decode(t))}fromBuffer(t){return this.buf=t,this}fromString(t){const e=S.decode(t);return this.buf=e,this}toBuffer(){return this.buf}toString(){return S.encode(this.buf)}}const _=(t,e)=>{if(!Buffer.isBuffer(t)||!Buffer.isBuffer(e))throw new Error("buf1 and buf2 must be buffers");if(t.length!==e.length)return!1;let r=0;for(let i=0;i<t.length;i++)r|=t[i]^e[i];return 0===r};class I extends w{constructor(t,e,r){super({resbuf:t,isError:e,id:r})}fromResult(t,e){return t.toFastBuffer?this.resbuf=t.toFastBuffer():Buffer.isBuffer(t)?this.resbuf=t:this.resbuf=Buffer.from(JSON.stringify(t)),this.isError=!1,this.id=e,this}static fromResult(t,e){return(new this).fromResult(t,e)}fromError(t,e){return this.resbuf=Buffer.from(JSON.stringify(t.message)),this.isError=!0,this.id=e,this}toBw(t){return t||(t=new y),t.writeVarIntNum(this.resbuf.length),t.write(this.resbuf),t.writeUInt8(Number(this.isError)),t.writeVarIntNum(this.id),t}fromBr(t){const e=t.readVarIntNum();return this.resbuf=t.read(e),this.isError=Boolean(t.readUInt8()),this.id=t.readVarIntNum(),this}}let O;class B{constructor(t=[],e=0,r=[],i=new Map){this.nativeWorkers=t,this.lastid=e,this.incompconsteRes=r,this.promisemap=i}asyncObjectMethod(t,e,r,i=this.lastid+1){if(!r)throw new Error("must specify args");const s=t[e](...r);return(new I).fromResult(s,i)}static asyncObjectMethod(t,e,r,i){return O||(O=new B),O.asyncObjectMethod(t,e,r,i)}asyncClassMethod(t,e,r,i=this.lastid+1){if(!r)throw new Error("must specify args");const s=t[e](...r);return(new I).fromResult(s,i)}static asyncClassMethod(t,e,r,i){return O||(O=new B),O.asyncClassMethod(t,e,r,i)}static endGlobalWorkers(){O&&!process.browser&&(O=void 0)}}class E{}E.sha1=function(t){if(!Buffer.isBuffer(t))throw new Error("sha1 hash must be of a buffer");const e=(new(0,u().sha1)).update(t).digest();return Buffer.from(e)},E.sha1.blockSize=512,E.asyncSha1=async function(t){const e=[t];return(await B.asyncClassMethod(E,"sha1",e)).resbuf},E.sha256=function(t){if(!Buffer.isBuffer(t))throw new Error("sha256 hash must be of a buffer");const e=(new(0,u().sha256)).update(t).digest();return Buffer.from(e)},E.sha256.blockSize=512,E.asyncSha256=async function(t){const e=[t];return(await B.asyncClassMethod(E,"sha256",e)).resbuf},E.sha256Sha256=function(t){try{return E.sha256(E.sha256(t))}catch(t){throw new Error("sha256Sha256 hash must be of a buffer: "+t)}},E.asyncSha256Sha256=async function(t){const e=[t];return(await B.asyncClassMethod(E,"sha256Sha256",e)).resbuf},E.ripemd160=function(t){if(!Buffer.isBuffer(t))throw new Error("ripemd160 hash must be of a buffer");const e=(new(0,u().ripemd160)).update(t).digest();return Buffer.from(e)},E.asyncRipemd160=async function(t){const e=[t];return(await B.asyncClassMethod(E,"ripemd160",e)).resbuf},E.sha256Ripemd160=function(t){try{return E.ripemd160(E.sha256(t))}catch(t){throw new Error("sha256Ripemd160 hash must be of a buffer: "+t)}},E.asyncSha256Ripemd160=async function(t){const e=[t];return(await B.asyncClassMethod(E,"sha256Ripemd160",e)).resbuf},E.sha512=function(t){if(!Buffer.isBuffer(t))throw new Error("sha512 hash must be of a buffer");const e=(new(0,u().sha512)).update(t).digest();return Buffer.from(e)},E.asyncSha512=async function(t){const e=[t];return(await B.asyncClassMethod(E,"sha512",e)).resbuf},E.sha512.blockSize=1024,E.hmac=function(t,e,r){if("sha1"!==t&&"sha256"!==t&&"sha512"!==t)throw new Error("invalid choice of hash function");const i=E[t];if(!Buffer.isBuffer(e)||!Buffer.isBuffer(r))throw new Error("data and key must be buffers");const s=i.blockSize/8;if(r.length>s&&(r=i(r)),r.length<s){const t=Buffer.alloc(s);t.fill(0,r.length),r.copy(t),r=t}const n=Buffer.alloc(s),a=Buffer.alloc(s);for(let t=0;t<s;t++)n[t]=92^r[t],a[t]=54^r[t];return i(Buffer.concat([n,i(Buffer.concat([a,e]))]))},E.sha1Hmac=function(t,e){return E.hmac("sha1",t,e)},E.asyncSha1Hmac=async function(t,e){const r=[t,e];return(await B.asyncClassMethod(E,"sha1Hmac",r)).resbuf},E.sha1Hmac.bitsize=160,E.sha256Hmac=function(t,e){return E.hmac("sha256",t,e)},E.asyncSha256Hmac=async function(t,e){const r=[t,e];return(await B.asyncClassMethod(E,"sha256Hmac",r)).resbuf},E.sha256Hmac.bitsize=256,E.sha512Hmac=function(t,e){return E.hmac("sha512",t,e)},E.asyncSha512Hmac=async function(t,e){const r=[t,e];return(await B.asyncClassMethod(E,"sha512Hmac",r)).resbuf},E.sha512Hmac.bitsize=512;class P extends w{constructor(t){super({buf:t})}fromHex(t){return this.fromBuffer(Buffer.from(t,"hex"))}toHex(){return this.toBuffer().toString("hex")}static decode(t){if("string"!=typeof t)throw new Error("Input must be a string");const e=S.decode(t);if(e.length<4)throw new Error("Input string too short");const r=e.slice(0,-4),i=e.slice(-4),s=E.sha256Sha256(r).slice(0,4);if(!_(i,s))throw new Error("Checksum mismatch");return r}static encode(t){if(!Buffer.isBuffer(t))throw new Error("Input must be a buffer");const e=Buffer.alloc(t.length+4),r=E.sha256Sha256(t);return t.copy(e),r.copy(e,t.length),S.encode(e)}fromBuffer(t){return this.buf=t,this}fromString(t){const e=P.decode(t);return this.buf=e,this}toBuffer(){return this.buf}toString(){return P.encode(this.buf)}}class N{constructor(t){this.keyDefined=e=>e in t,this.getValue=e=>t[e]}get(t){if(this.keyDefined(t))return this.getValue(t);throw new Error(`Unknown configuration: ${t}`)}}const A=(new class{constructor(){this.variables={}}build(){return new N(this.variables)}addValue(t,e){if(void 0===e)throw new Error(`Failed to add "${t}" property. The value cannot be undefined`);if(t in this.variables)throw new Error(`"${t}" already has a value defined.`);return this.variables[t]=e,this}addValueWithDefault(t,e,r){if(void 0===r)throw new Error(`Failed to add "${t}" property. Default value cannot be undefined`);return this.addValue(t,void 0===e?r:e)}}).addValue("NETWORK",process.env.NETWORK||"mainnet").build(),k={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:50},Workers:{timeout:6e4}}};if(k.Testnet=Object.assign({},k.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}}),k.Regtest=Object.assign({},k.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}}),k.STN=Object.assign({},k.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}}),"testnet"===A.get("NETWORK"))k.Default=Object.assign({},k.Testnet);else if("mainnet"===A.get("NETWORK"))k.Default=Object.assign({},k.Mainnet);else if("regtest"===A.get("NETWORK"))k.Default=Object.assign({},k.Regtest);else{if("stn"!==A.get("NETWORK"))throw new Error(`must set network in environment variable - mainnet, testnet, regtest or stn?, received ${A.get("NETWORK")}`);k.Default=Object.assign({},k.STN)}const R=t=>k.Mainnet.Msg.magicNum===t?k.Mainnet:k.Testnet.Msg.magicNum===t?k.Testnet:k.Regtest.Msg.magicNum===t?k.Regtest:k.STN.Msg.magicNum===t?k.STN:k.Default,x={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},M={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 T extends w{constructor(t){super({num:t})}fromNumber(t){return this.num=t,this}static fromNumber(t){return(new this).fromNumber(t)}toNumber(){return this.num}fromString(t){const e=M[t];if(void 0===e)throw new Error("Invalid opCodeStr");return this.num=e,this}fromNoOpString(t){const e=x[t];if(void 0===e)throw new Error("Invalid opCodeStr");return this.num=e,this}static fromString(t){return(new this).fromString(t)}static fromNoOpString(t){return(new this).fromNoOpString(t)}toString(){const t=T.str[this.num];return void 0===t?this.num>0&&this.num<T.OP_PUSHDATA1?this.num.toString():"OP_"+this.num.toNumber():t}toNoOpString(){const t=T.noopstr[this.num];return void 0===t?this.num>0&&this.num<T.OP_PUSHDATA1?this.num.toString():this.num.toNumber():t}}T.str={},T.noopstr={};for(const t in M)T[t]=M[t],Object.prototype.hasOwnProperty.call(M,t)&&(T.str[M[t]]=t);for(const t in x)T[t]=x[t],Object.prototype.hasOwnProperty.call(x,t)&&(T.noopstr[x[t]]=t);const C=h().curves.secp256k1,H=C.curve.point().constructor;class L extends H{constructor(t,e,r){super(C.curve,t,e,r)}static fromX(t,e){const r=C.curve.pointFromX(e,t);return Object.create(L.prototype).copyFrom(r)}copyFrom(t){if(!(t instanceof H))throw new Error("point should be an external point");return Object.keys(t).forEach(function(e){this[e]=t[e]}.bind(this)),this}add(t){return t=H.prototype.add.call(this,t),Object.create(L.prototype).copyFrom(t)}mul(t){if(!t.lt(L.getN()))throw new Error("point mul out of range");const e=H.prototype.mul.call(this,t);return Object.create(L.prototype).copyFrom(e)}mulAdd(t,e,r){const i=H.prototype.mulAdd.call(this,t,e,r);return(e=Object.create(L.prototype)).copyFrom(i)}getX(){const t=H.prototype.getX.call(this),e=Object.create(p.prototype);return t.copy(e),e}getY(){const t=H.prototype.getY.call(this),e=Object.create(p.prototype);return t.copy(e),e}fromX(t,e){const r=L.fromX(t,e);return this.copyFrom(r)}toJSON(){return{x:this.getX().toString(),y:this.getY().toString()}}fromJSON(t){const e=(new p).fromString(t.x),r=(new p).fromString(t.y),i=new L(e,r);return this.copyFrom(i)}toString(){return JSON.stringify(this.toJSON())}fromString(t){const e=JSON.parse(t),r=(new L).fromJSON(e);return this.copyFrom(r)}static getG(){const t=C.curve.g;return Object.create(L.prototype).copyFrom(t)}static getN(){return new p(C.curve.n.toArray())}validate(){if(0!==L.fromX(this.getY().isOdd(),this.getX()).getY().cmp(this.getY()))throw new Error("Invalid y value of public key");if(!(this.getX().gt(-1)&&this.getX().lt(L.getN())&&this.getY().gt(-1)&&this.getY().lt(L.getN())))throw new Error("Point does not lie on the curve");return this}}class F extends w{constructor(t,e){super({point:t,compressed:e})}fromJSON(t){return this.fromFastHex(t),this}toJSON(){return this.toFastHex()}fromPrivKey(t){return this.fromObject({point:L.getG().mul(t.bn),compressed:t.compressed}),this}static fromPrivKey(t){return(new this).fromPrivKey(t)}async asyncFromPrivKey(t){const e=await B.asyncObjectMethod(this,"fromPrivKey",[t]);return this.fromFastBuffer(e.resbuf)}static asyncFromPrivKey(t){return(new this).asyncFromPrivKey(t)}fromBuffer(t,e){return this.fromDer(t,e)}async asyncFromBuffer(t,e){const r=[t,e],i=await B.asyncObjectMethod(this,"fromBuffer",r);return this.fromFastBuffer(i.resbuf)}fromFastBuffer(t){if(0===t.length)return this;const e=Boolean(t[0]);return t=t.slice(1),this.fromDer(t),this.compressed=e,this}fromDer(t,e){if(e=void 0===e,4!==t[0]&&(e||6!==t[0]&&7!==t[0]))if(3===t[0]){const e=new p(t.slice(1));this.fromX(!0,e),this.compressed=!0}else{if(2!==t[0])throw new Error("Invalid DER format pubKey");{const e=new p(t.slice(1));this.fromX(!1,e),this.compressed=!0}}else{const e=t.slice(1,33),r=t.slice(33,65);if(32!==e.length||32!==r.length||65!==t.length)throw new Error("LEngth of x and y must be 32 bytes");const i=new p(e),s=new p(r);this.point=new L(i,s),this.compressed=!1}return this}static fromDer(t,e){return(new this).fromDer(t,e)}fromString(t){return this.fromDer(Buffer.from(t,"hex")),this}fromX(t,e){if("boolean"!=typeof t)throw new Error("Must specify whether y is odd or not (true or false)");return this.point=L.fromX(t,e),this}static fromX(t,e){return(new this).fromX(t,e)}toBuffer(){const t=void 0===this.compressed||this.compressed;return this.toDer(t)}toFastBuffer(){if(!this.point)return Buffer.alloc(0);const t=new y,e=void 0===this.compressed||Boolean(this.compressed);return t.writeUInt8(Number(e)),t.write(this.toDer(!1)),t.toBuffer()}toDer(t){if("boolean"!=typeof(t=void 0===t?this.compressed:t))throw new Error("Must specify whether the public key is compressed or not (true or false)");const e=this.point.getX(),r=this.point.getY(),i=e.toBuffer({size:32}),s=r.toBuffer({size:32});let n;return t?(n=s[s.length-1]%2?Buffer.from([3]):Buffer.from([2]),Buffer.concat([n,i])):(n=Buffer.from([4]),Buffer.concat([n,i,s]))}toString(){const t=void 0===this.compressed||this.compressed;return this.toDer(t).toString("hex")}static isCompressedOrUncompressed(t){if(t.length<33)return!1;if(4===t[0]){if(65!==t.length)return!1}else{if(2!==t[0]&&3!==t[0])return!1;if(33!==t.length)return!1}return!0}validate(){if(this.point.isInfinity())throw new Error("point: Point cannot be equal to Infinity");if(this.point.eq(new L(new p(0),new p(0))))throw new Error("point: Point cannot be equal to 0, 0");return this.point.validate(),this}}var K=r(353),U=r.n(K);class D{}D.getRandomBuffer=function(t){return U()(t)};class V extends w{constructor(t,e,r=null){super({bn:t,compressed:e}),r=r||k.Default.PrivKey,this.Constants=r}fromJSON(t){return this.fromHex(t),this}toJSON(){return this.toHex()}fromRandom(){let t,e,r;do{t=D.getRandomBuffer(32),e=(new p).fromBuffer(t),r=e.lt(L.getN())}while(!r);return this.fromObject({bn:e,compressed:!0}),this}static fromRandom(){return(new this).fromRandom()}toBuffer(){let t=this.compressed;void 0===t&&(t=!0);const e=this.bn.toBuffer({size:32});let r;return r=t?Buffer.concat([Buffer.from([this.Constants.versionByteNum]),e,Buffer.from([1])]):Buffer.concat([Buffer.from([this.Constants.versionByteNum]),e]),r}fromBuffer(t){if(34===t.length&&1===t[33])this.compressed=!0;else{if(33!==t.length)throw new Error("Length of privKey buffer must be 33 (uncompressed pubKey) or 34 (compressed pubKey)");this.compressed=!1}if(t[0]!==this.Constants.versionByteNum)throw new Error("Invalid versionByteNum byte");return this.fromBn((new p).fromBuffer(t.slice(1,33)))}toBn(){return this.bn}fromBn(t){return this.bn=t,this}static fromBn(t){return(new this).fromBn(t)}validate(){if(!this.bn.lt(L.getN()))throw new Error("Number must be less than N");if("boolean"!=typeof this.compressed)throw new Error("Must specify whether the corresponding public key is compressed or not (true or false)");return this}toWif(){return P.encode(this.toBuffer())}fromWif(t){return this.fromBuffer(P.decode(t))}static fromWif(t){return(new this).fromWif(t)}toString(){return this.toWif()}fromString(t){return this.fromWif(t)}}V.Mainnet=class extends V{constructor(t,e){super(t,e,k.Mainnet.PrivKey)}},V.Testnet=class extends V{constructor(t,e){super(t,e,k.Testnet.PrivKey)}};class j extends w{constructor(t,e,r,i,s){super({r:t,s:e,nHashType:r,recovery:i,compressed:s})}fromBuffer(t){try{return this.fromDer(t,!0)}catch(t){}try{return this.fromCompact(t)}catch(t){}return this.fromTxFormat(t)}toBuffer(){return void 0!==this.nHashType?this.toTxFormat():void 0!==this.recovery?this.toCompact():this.toDer()}fromCompact(t){let e=!0,r=t.slice(0,1)[0]-27-4;if(r<0&&(e=!1,r+=4),0!==r&&1!==r&&2!==r&&3!==r)throw new Error("i must be 0, 1, 2, or 3");this.compressed=e,this.recovery=r;const i=t.slice(1);return this.fromRS(i),this}static fromCompact(t){return(new this).fromCompact(t)}fromRS(t){const e=t.slice(0,32),r=t.slice(32,64);if(32!==e.length)throw new Error("r must be 32 bytes");if(32!==r.length||t.length>64)throw new Error("s must be 32 bytes");return this.r=(new p).fromBuffer(e),this.s=(new p).fromBuffer(r),this}static fromRS(t){return(new this).fromRS(t)}fromDer(t,e){const r=j.parseDer(t,e);return this.r=r.r,this.s=r.s,this}static fromDer(t,e){return(new this).fromDer(t,e)}fromTxFormat(t){if(0===t.length)return this.r=new p(1),this.s=new p(1),this.nHashType=1,this;const e=t.readUInt8(t.length-1),r=t.slice(0,t.length-1);return this.fromDer(r,!1),this.nHashType=e,this}static fromTxFormat(t){return(new this).fromTxFormat(t)}fromString(t){return this.fromHex(t)}static parseDer(t,e){if(void 0===e&&(e=!0),!Buffer.isBuffer(t))throw new Error("DER formatted signature should be a buffer");const r=t[0];if(48!==r)throw new Error("Header byte should be 0x30");let i=t[1];const s=t.slice(2).length;if(e&&i!==s)throw new Error("LEngth byte should length of what follows");i=i<s?i:s;const n=t[2];if(2!==n)throw new Error("Integer byte for r should be 0x02");const a=t[3],o=t.slice(4,4+a),c=(new p).fromBuffer(o),h=0===t[4];if(a!==o.length)throw new Error("LEngth of r incorrect");const f=t[4+a+0];if(2!==f)throw new Error("Integer byte for s should be 0x02");const u=t[4+a+1],d=t.slice(4+a+2,4+a+2+u),l=(new p).fromBuffer(d),b=0===t[4+a+2+2];if(u!==d.length)throw new Error("LEngth of s incorrect");if(i!==4+a+2+u-2)throw new Error("LEngth of signature incorrect");return{header:r,length:i,rheader:n,rlength:a,rneg:h,rbuf:o,r:c,sheader:f,slength:u,sneg:b,sbuf:d,s:l}}static IsTxDer(t){if(t.length<9)return!1;if(t.length>73)return!1;if(48!==t[0])return!1;if(t[1]!==t.length-3)return!1;const e=t[3];if(5+e>=t.length)return!1;const r=t[5+e];if(e+r+7!==t.length)return!1;const i=t.slice(4);if(2!==t[2])return!1;if(0===e)return!1;if(128&i[0])return!1;if(e>1&&0===i[0]&&!(128&i[1]))return!1;const s=t.slice(6+e);return!(2!==t[6+e-2]||0===r||128&s[0]||r>1&&0===s[0]&&!(128&s[1]))}hasLowS(){return!this.s.lt(1)&&!this.s.gt(p.fromBuffer(Buffer.from("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))}hasDefinedHashType(){return!(this.nHashType<j.SIGHASH_ALL||this.nHashType>j.SIGHASH_SINGLE)}toCompact(t,e){if(t="number"==typeof t?t:this.recovery,e="boolean"==typeof e?e:this.compressed,0!==t&&1!==t&&2!==t&&3!==t)throw new Error("recovery must be equal to 0, 1, 2, or 3");let r=t+27+4;!1===e&&(r-=4);const i=Buffer.from([r]),s=this.r.toBuffer({size:32}),n=this.s.toBuffer({size:32});return Buffer.concat([i,s,n])}toRS(){return Buffer.concat([this.r.toBuffer({size:32}),this.s.toBuffer({size:32})])}toDer(){const t=this.r.toBuffer(),e=this.s.toBuffer(),r=128&t[0],i=128&e[0],s=r?Buffer.concat([Buffer.from([0]),t]):t,n=i?Buffer.concat([Buffer.from([0]),e]):e,a=2+s.length+2+n.length,o=s.length,c=n.length;return Buffer.concat([Buffer.from([48,a,2,o]),s,Buffer.from([2,c]),n])}toTxFormat(){const t=this.toDer(),e=Buffer.alloc(1);return e.writeUInt8(this.nHashType,0),Buffer.concat([t,e])}toString(){return this.toHex()}}j.SIGHASH_ALL=1,j.SIGHASH_NONE=2,j.SIGHASH_SINGLE=3,j.SIGHASH_FORKID=64,j.SIGHASH_ANYONECANPAY=128;class z extends w{constructor(t=[]){super({chunks:t})}fromJSON(t){return this.fromString(t)}toJSON(){return this.toString()}fromBuffer(t){this.chunks=[];const e=new g(t);for(;!e.eof();){const t=e.readUInt8();let r=0,i=Buffer.from([]);if(t>0&&t<T.OP_PUSHDATA1)r=t,this.chunks.push({buf:e.read(r),len:r,opCodeNum:t});else if(t===T.OP_PUSHDATA1){try{r=e.readUInt8(),i=e.read(r)}catch(t){e.read()}this.chunks.push({buf:i,len:r,opCodeNum:t})}else if(t===T.OP_PUSHDATA2){try{r=e.readUInt16LE(),i=e.read(r)}catch(t){e.read()}this.chunks.push({buf:i,len:r,opCodeNum:t})}else if(t===T.OP_PUSHDATA4){try{r=e.readUInt32LE(),i=e.read(r)}catch(t){e.read()}this.chunks.push({buf:i,len:r,opCodeNum:t})}else this.chunks.push({opCodeNum:t})}return this}toBuffer(){const t=new y;for(let e=0;e<this.chunks.length;e++){const r=this.chunks[e],i=r.opCodeNum;t.writeUInt8(i),r.buf&&(i<T.OP_PUSHDATA1?t.write(r.buf):i===T.OP_PUSHDATA1?(t.writeUInt8(r.len),t.write(r.buf)):i===T.OP_PUSHDATA2?(t.writeUInt16LE(r.len),t.write(r.buf)):i===T.OP_PUSHDATA4&&(t.writeUInt32LE(r.len),t.write(r.buf)))}return t.toBuffer()}fromString(t){if(this.chunks=[],""===t||void 0===t)return this;const e=t.split(" ");let r=0;for(;r<e.length;){const t=e[r];let i;try{i=(new T).fromString(t).toNumber()}catch(t){}if(void 0===i)if(i=parseInt(t,10),i>0&&i<T.OP_PUSHDATA1)this.chunks.push({buf:Buffer.from(e[r+1].slice(2),"hex"),len:i,opCodeNum:i}),r+=2;else{if(0!==i)throw new Error("Invalid script");this.chunks.push({opCodeNum:0}),r+=1}else if(i===T.OP_PUSHDATA1||i===T.OP_PUSHDATA2||i===T.OP_PUSHDATA4){if("0x"!==e[r+2].slice(0,2))throw new Error("Pushdata data must start with 0x");this.chunks.push({buf:Buffer.from(e[r+2].slice(2),"hex"),len:parseInt(e[r+1],10),opCodeNum:i}),r+=3}else this.chunks.push({opCodeNum:i}),r+=1}return this}toString(t={noOp:!1}){let e="";for(let r=0;r<this.chunks.length;r++){const i=this.chunks[r],s=i.opCodeNum.hasOwnProperty("num")?i.opCodeNum.num:i.opCodeNum;i.buf?(s!==T.OP_PUSHDATA1&&s!==T.OP_PUSHDATA2&&s!==T.OP_PUSHDATA4||(e=t.noOp?e+" "+new T(s).toNoOpString():e+" "+new T(s).toString()),e=e+" "+i.len,e=e+" 0x"+i.buf.toString("hex")):e=void 0!==T.str[s]||void 0!==T.noopstr[s]?t.noOp?e+" "+new T(s).toNoOpString():e+" "+new T(s).toString():e+" 0x"+s.toString(16)}return e.substr(1)}fromBitcoindString(t){const e=new y,r=t.split(" ");let i;for(i=0;i<r.length;i++){const t=r[i];if(""!==t)if("0"===t[0]&&"x"===t[1]){const r=t.slice(2);e.write(Buffer.from(r,"hex"))}else if("'"===t[0]){const r=t.slice(1,t.length-1),i=Buffer.from(r),s=(new z).writeBuffer(i).toBuffer();e.write(s)}else if(void 0!==T["OP_"+t]){const r=T["OP_"+t];e.writeUInt8(r)}else if("number"==typeof T[t]){const r=T[t];e.writeUInt8(r)}else{if(isNaN(parseInt(t,10)))throw new Error("Could not determine type of script value");{const r=new p(t),i=(new z).writeBn(r).toBuffer();e.write(i)}}}const s=e.toBuffer();return this.fromBuffer(s)}static fromBitcoindString(t){return(new this).fromBitcoindString(t)}toBitcoindString(){let t="";for(let e=0;e<this.chunks.length;e++){const r=this.chunks[e];t=r.buf?t+" 0x"+new z([r]).toBuffer().toString("hex"):void 0!==T.str[r.opCodeNum]?t+" "+new T(r.opCodeNum).toString().slice(3):t+" 0x"+r.opCodeNum.toString(16)}return t.substr(1)}fromAsmString(t){this.chunks=[];const e=t.split(" ");let r=0;for(;r<e.length;){const t=e[r];let i,s;try{i=T.fromString(t),s=i.toNumber()}catch(t){i=void 0,s=void 0}if("0"===t)s=0,this.chunks.push({opCodeNum:s}),r+=1;else if("-1"===t)s=T.OP_1NEGATE,this.chunks.push({opCodeNum:s}),r+=1;else if(void 0===i){const t=e[r],i=Buffer.from(t,"hex");if(i.toString("hex")!==t)throw new Error("invalid hex string in script");const n=i.length;n>=0&&n<T.OP_PUSHDATA1?s=n:n<Math.pow(2,8)?s=T.OP_PUSHDATA1:n<Math.pow(2,16)?s=T.OP_PUSHDATA2:n<Math.pow(2,32)&&(s=T.OP_PUSHDATA4),this.chunks.push({buf:i,len:i.length,opCodeNum:s}),r+=1}else this.chunks.push({opCodeNum:s}),r+=1}return this}static fromAsmString(t){return(new this).fromAsmString(t)}toAsmString(t={noOp:!1}){for(var e="",r=0;r<this.chunks.length;r++){var i=this.chunks[r];e+=this._chunkToString(i,t)}return e.substr(1)}_chunkToString(t,e={noOp:!1}){var r=t.opCodeNum,i="";if(t.buf)t.len>0&&(i=i+" "+t.buf.toString("hex"));else if(void 0!==T.str[r])0===r?i+=" 0":79===r?i+=" -1":i=e.noOp?i+" "+new T(r).toNoOpString():i+" "+new T(r).toString();else{var s=r.toString(16);s.length%2!=0&&(s="0"+s),i=i+" "+s}return i}fromOpReturnData(t){return this.writeOpCode(T.OP_RETURN),this.writeBuffer(t),this}static fromOpReturnData(t){return(new this).fromOpReturnData(t)}fromSafeData(t){return this.writeOpCode(T.OP_FALSE),this.writeOpCode(T.OP_RETURN),this.writeBuffer(t),this}static fromSafeData(t){return(new this).fromSafeData(t)}fromSafeDataArray(t){this.writeOpCode(T.OP_FALSE),this.writeOpCode(T.OP_RETURN);for(const e in t){const r=t[e];this.writeBuffer(r)}return this}static fromSafeDataArray(t){return(new this).fromSafeDataArray(t)}getData(){if(this.isSafeDataOut())return this.chunks.slice(2).map((t=>t.buf));if(this.isOpReturn())return this.chunks.slice(1).map((t=>t.buf));throw new Error("Unrecognized script type to get data from")}fromPubKeyHash(t){if(20!==t.length)throw new Error("hashBuf must be a 20 byte buffer");return this.writeOpCode(T.OP_DUP),this.writeOpCode(T.OP_HASH160),this.writeBuffer(t),this.writeOpCode(T.OP_EQUALVERIFY),this.writeOpCode(T.OP_CHECKSIG),this}static fromPubKeyHash(t){return(new this).fromPubKeyHash(t)}static sortPubKeys(t){return t.slice().sort(((t,e)=>{const r=t.toBuffer(),i=e.toBuffer(),s=Math.max(r.length,i.length);for(let t=0;t<=s;t++){if(void 0===r[t])return-1;if(void 0===i[t])return 1;if(r[t]<i[t])return-1;if(r[t]>i[t])return 1}}))}fromPubKeys(t,e,r=!0){if("number"!=typeof t)throw new Error("m must be a number");!0===r&&(e=z.sortPubKeys(e)),this.writeOpCode(t+T.OP_1-1);for(const t in e)this.writeBuffer(e[t].toBuffer());return this.writeOpCode(e.length+T.OP_1-1),this.writeOpCode(T.OP_CHECKMULTISIG),this}static fromPubKeys(t,e,r){return(new this).fromPubKeys(t,e,r)}removeCodeseparators(){const t=[];for(let e=0;e<this.chunks.length;e++)this.chunks[e].opCodeNum!==T.OP_CODESEPARATOR&&t.push(this.chunks[e]);return this.chunks=t,this}isPushOnly(){for(let t=0;t<this.chunks.length;t++)if(this.chunks[t].opCodeNum>T.OP_16)return!1;return!0}isNonSpendable(){const t=this.chunks[0].opCodeNum===T.OP_FALSE,e=this.chunks[1]&&this.chunks[1].opCodeNum===T.OP_RETURN;return!!t&&!!e}isOpReturn(){return this.chunks[0].opCodeNum===T.OP_RETURN&&this.chunks.filter((t=>Buffer.isBuffer(t.buf))).length===this.chunks.slice(1).length}isSafeDataOut(){if(this.chunks.length<2)return!1;if(this.chunks[0].opCodeNum!==T.OP_FALSE)return!1;var t=this.chunks.slice(1);return new z(t).isOpReturn()}isPubKeyHashOut(){return!!(this.chunks[0]&&this.chunks[0].opCodeNum===T.OP_DUP&&this.chunks[1]&&this.chunks[1].opCodeNum===T.OP_HASH160&&this.chunks[2].buf&&this.chunks[3]&&this.chunks[3].opCodeNum===T.OP_EQUALVERIFY&&this.chunks[4]&&this.chunks[4].opCodeNum===T.OP_CHECKSIG)}isPubKeyHashIn(){return!(2!==this.chunks.length||!this.chunks[0].buf&&this.chunks[0].opCodeNum!==T.OP_0||!this.chunks[1].buf&&this.chunks[0].opCodeNum!==T.OP_0)}isScriptHashOut(){const t=this.toBuffer();return 23===t.length&&t[0]===T.OP_HASH160&&20===t[1]&&t[22]===T.OP_EQUAL}isScriptHashIn(){if(!this.isPushOnly())return!1;try{(new z).fromBuffer(this.chunks[this.chunks.length-1].buf)}catch(t){return!1}return!0}isMultiSigOut(){const t=this.chunks[0].opCodeNum-T.OP_1+1;if(!(t>=1&&t<=16))return!1;if(!this.chunks.slice(1,this.chunks.length-2).every((t=>{try{const e=t.buf;return(new F).fromDer(e).validate(),!0}catch(t){return!1}})))return!1;const e=this.chunks[this.chunks.length-2].opCodeNum-T.OP_1+1;return e>=t&&e<=16&&this.chunks[1+e+1].opCodeNum===T.OP_CHECKMULTISIG}isMultiSigIn(){if(this.chunks[0].opCodeNum!==T.OP_0)return!1;const t=this.chunks.slice(1);return!(t.length<1)&&t.every((t=>Buffer.isBuffer(t.buf)&&j.IsTxDer(t.buf)))}findAndDelete(t){const e=t.toBuffer();for(let t=0;t<this.chunks.length;t++){const r=new z([this.chunks[t]]).toBuffer();_(e,r)&&this.chunks.splice(t,1)}return this}writeScript(t){return this.chunks=this.chunks.concat(t.chunks),this}static writeScript(t){return(new this).writeScript(t)}writeString(t){const e=(new z).fromString(t);return this.chunks=this.chunks.concat(e.chunks),this}static writeString(t){return(new this).writeString(t)}writeOpCode(t){return this.chunks.push({opCodeNum:t}),this}static writeOpCode(t){return(new this).writeOpCode(t)}setChunkOpCode(t,e){return this.chunks[t]={opCodeNum:e},this}writeBn(t){if(t.cmp(0)===T.OP_0)this.chunks.push({opCodeNum:T.OP_0});else if(0===t.cmp(-1))this.chunks.push({opCodeNum:T.OP_1NEGATE});else if(t.cmp(1)>=0&&t.cmp(16)<=0)this.chunks.push({opCodeNum:t.toNumber()+T.OP_1-1});else{const e=t.toSm({endian:"little"});this.writeBuffer(e)}return this}static writeBn(t){return(new this).writeBn(t)}writeNumber(t){return this.writeBn((new p).fromNumber(t)),this}static writeNumber(t){return(new this).writeNumber(t)}setChunkBn(t,e){return this.chunks[t]=(new z).writeBn(e).chunks[0],this}writeBuffer(t){let e;const r=t.length;if(t.length>0&&t.length<T.OP_PUSHDATA1)e=t.length;else if(0===t.length)e=T.OP_0;else if(t.length<Math.pow(2,8))e=T.OP_PUSHDATA1;else if(t.length<Math.pow(2,16))e=T.OP_PUSHDATA2;else{if(!(t.length<Math.pow(2,32)))throw new Error("You can't push that much data");e=T.OP_PUSHDATA4}return this.chunks.push({buf:t,len:r,opCodeNum:e}),this}static writeBuffer(t){return(new this).writeBuffer(t)}setChunkBuffer(t,e){return this.chunks[t]=(new z).writeBuffer(e).chunks[0],this}checkMinimalPush(t){const e=this.chunks[t],r=e.buf,i=e.opCodeNum;return!(r&&(0===r.length?i!==T.OP_0:1===r.length&&r[0]>=1&&r[0]<=16?i!==T.OP_1+(r[0]-1):1===r.length&&129===r[0]?i!==T.OP_1NEGATE:r.length<=75?i!==r.length:r.length<=255?i!==T.OP_PUSHDATA1:r.length<=65535&&i!==T.OP_PUSHDATA2))}}class q extends w{constructor(t,e,r=null){super({versionByteNum:t,hashBuf:e}),r=r||k.Default.Address,this.Constants=r}fromBuffer(t){if(21!==t.length)throw new Error("address buffers must be exactly 21 bytes");if(t[0]!==this.Constants.pubKeyHash)throw new Error("address: invalid versionByteNum byte");return this.versionByteNum=t[0],this.hashBuf=t.slice(1),this}fromPubKeyHashBuf(t){return this.hashBuf=t,this.versionByteNum=this.Constants.pubKeyHash,this}static fromPubKeyHashBuf(t){return(new this).fromPubKeyHashBuf(t)}fromPubKey(t){const e=E.sha256Ripemd160(t.toBuffer());return this.fromPubKeyHashBuf(e)}static fromPubKey(t){return(new this).fromPubKey(t)}async asyncFromPubKey(t){const e=[t],r=await B.asyncObjectMethod(this,"fromPubKey",e);return this.fromFastBuffer(r.resbuf)}static asyncFromPubKey(t){return(new this).asyncFromPubKey(t)}fromPrivKey(t){const e=(new F).fromPrivKey(t),r=E.sha256Ripemd160(e.toBuffer());return this.fromPubKeyHashBuf(r)}static fromPrivKey(t){return(new this).fromPrivKey(t)}async asyncFromPrivKey(t){const e=[t],r=await B.asyncObjectMethod(this,"fromPrivKey",e);return this.fromFastBuffer(r.resbuf)}static asyncFromPrivKey(t){return(new this).fromPrivKey(t)}fromRandom(){const t=(new V).fromRandom();return this.fromPrivKey(t)}static fromRandom(){return(new this).fromRandom()}async asyncFromRandom(){const t=await B.asyncObjectMethod(this,"fromRandom",[]);return this.fromFastBuffer(t.resbuf)}static asyncFromRandom(){return(new this).fromRandom()}fromString(t){const e=P.decode(t);return this.fromBuffer(e)}async asyncFromString(t){const e=[t],r=await B.asyncObjectMethod(this,"fromString",e);return this.fromFastBuffer(r.resbuf)}static asyncFromString(t){return(new this).asyncFromString(t)}static isValid(t){let e;try{e=(new q).fromString(t)}catch(t){return!1}return e.isValid()}isValid(){try{return this.validate(),!0}catch(t){return!1}}toTxOutScript(){const t=new z;return t.writeOpCode(T.OP_DUP),t.writeOpCode(T.OP_HASH160),t.writeBuffer(this.hashBuf),t.writeOpCode(T.OP_EQUALVERIFY),t.writeOpCode(T.OP_CHECKSIG),t}fromTxInScript(t){const e=E.sha256Ripemd160(t.chunks[1].buf||Buffer.from("00".repeat(32),"hex"));return this.fromPubKeyHashBuf(e)}static fromTxInScript(t){return(new this).fromTxInScript(t)}fromTxOutScript(t){return this.fromPubKeyHashBuf(t.chunks[2].buf)}static fromTxOutScript(t){return(new this).fromTxOutScript(t)}toBuffer(){const t=Buffer.from([this.versionByteNum]);return Buffer.concat([t,this.hashBuf])}toJSON(){const t={};return this.hashBuf&&(t.hashBuf=this.hashBuf.toString("hex")),void 0!==this.versionByteNum&&(t.versionByteNum=this.versionByteNum),t}fromJSON(t){return t.hashBuf&&(this.hashBuf=Buffer.from(t.hashBuf,"hex")),void 0!==t.versionByteNum&&(this.versionByteNum=t.versionByteNum),this}toString(){return P.encode(this.toBuffer())}async asyncToString(){const t=await B.asyncObjectMethod(this,"toString",[]);return JSON.parse(t.resbuf.toString())}validate(){if(!Buffer.isBuffer(this.hashBuf)||20!==this.hashBuf.length)throw new Error("hashBuf must be a buffer of 20 bytes");if(this.versionByteNum!==this.Constants.pubKeyHash)throw new Error("invalid versionByteNum");return this}}q.Mainnet=class extends q{constructor(t,e){super(t,e,k.Mainnet.Address)}},q.Testnet=class extends q{constructor(t,e){super(t,e,k.Testnet.Address)}};class G extends w{constructor(t,e,r,i,s,n,a,o=null,c=V){super({versionBytesNum:t,depth:e,parentFingerPrint:r,childIndex:i,chainCode:s,privKey:n,pubKey:a}),o=o||k.Default.Bip32,this.Constants=o,this.PrivKey=c}fromRandom(){return this.versionBytesNum=this.Constants.privKey,this.depth=0,this.parentFingerPrint=Buffer.from([0,0,0,0]),this.childIndex=0,this.chainCode=D.getRandomBuffer(32),this.privKey=(new this.PrivKey).fromRandom(),this.pubKey=(new F).fromPrivKey(this.privKey),this}static fromRandom(){return(new this).fromRandom()}fromString(t){return this.fromBuffer(P.decode(t))}async asyncFromString(t){const e=[t],r=await B.asyncObjectMethod(this,"fromString",e);return this.fromFastBuffer(r.resbuf)}fromSeed(t){if(!Buffer.isBuffer(t))throw new Error("bytes must be a buffer");if(t.length<16)throw new Error("Need more than 128 bits of entropy");if(t.length>64)throw new Error("More than 512 bits of entropy is nonstandard");const e=E.sha512Hmac(t,Buffer.from("Bitcoin seed"));return this.depth=0,this.parentFingerPrint=Buffer.from([0,0,0,0]),this.childIndex=0,this.chainCode=e.slice(32,64),this.versionBytesNum=this.Constants.privKey,this.privKey=(new this.PrivKey).fromBn(p().fromBuffer(e.slice(0,32))),this.pubKey=(new F).fromPrivKey(this.privKey),this}static fromSeed(t){return(new this).fromSeed(t)}async asyncFromSeed(t){const e=await B.asyncObjectMethod(this,"fromSeed",[t]);return this.fromFastBuffer(e.resbuf)}static asyncFromSeed(t){return(new this).asyncFromSeed(t)}fromBuffer(t){if(78!==t.length)throw new Error("incorrect bip32 data length");this.versionBytesNum=t.slice(0,4).readUInt32BE(0),this.depth=t.slice(4,5).readUInt8(0),this.parentFingerPrint=t.slice(5,9),this.childIndex=t.slice(9,13).readUInt32BE(0),this.chainCode=t.slice(13,45);const e=t.slice(45,78),r=this.versionBytesNum===this.Constants.privKey,i=this.versionBytesNum===this.Constants.pubKey;if(r&&0===e[0])this.privKey=(new this.PrivKey).fromBn(p().fromBuffer(e.slice(1,33))),this.pubKey=(new F).fromPrivKey(this.privKey);else{if(!i||2!==e[0]&&3!==e[0])throw new Error("Invalid key");this.pubKey=(new F).fromDer(e)}return this}fromFastBuffer(t){if(0===t.length)return this;if(78!==t.length&&111!==t.length)throw new Error("incorrect bip32 fastBuffer data length: "+t.length);this.versionBytesNum=t.slice(0,4).readUInt32BE(0),this.depth=t.slice(4,5).readUInt8(0),this.parentFingerPrint=t.slice(5,9),this.childIndex=t.slice(9,13).readUInt32BE(0),this.chainCode=t.slice(13,45);const e=t.slice(45,t.length),r=this.versionBytesNum===this.Constants.privKey,i=this.versionBytesNum===this.Constants.pubKey;if(r&&0===e[0]&&78===t.length)this.privKey=(new this.PrivKey).fromBn(p().fromBuffer(e.slice(1,33))),this.pubKey=(new F).fromPrivKey(this.privKey);else{if(!i||111!==t.length)throw new Error("Invalid key");this.pubKey=(new F).fromFastBuffer(e),this.pubKey.compressed=!0}return this}derive(t){const e=t.split("/");if("m"===t)return this;let r=this;for(const t in e){const i=e[t];if("0"===t){if("m"!==i)throw new Error("invalid path");continue}if(parseInt(i.replace("'",""),10).toString()!==i.replace("'",""))throw new Error("invalid path");const s=i.length>1&&"'"===i[i.length-1];let n=2147483647&parseInt(s?i.slice(0,i.length-1):i,10);s&&(n+=2147483648),r=r.deriveChild(n)}return r}async asyncDerive(t){const e=await B.asyncObjectMethod(this,"derive",[t]);return(new this.constructor).fromFastBuffer(e.resbuf)}deriveChild(t){if("number"!=typeof t)throw new Error("i must be a number");let e=[];e.push(t>>24&255),e.push(t>>16&255),e.push(t>>8&255),e.push(255&t),e=Buffer.from(e);const r=0!=(2147483648&t),i=this.versionBytesNum===this.Constants.privKey;if(r&&(!this.privKey||!i))throw new Error("Cannot do private key derivation without private key");let s=null;if(this.privKey){let t=null;t=r?Buffer.concat([Buffer.from([0]),this.privKey.bn.toBuffer({size:32}),e]):Buffer.concat([this.pubKey.toBuffer({size:32}),e]);const i=E.sha512Hmac(t,this.chainCode),n=p().fromBuffer(i.slice(0,32),{size:32}),a=i.slice(32,64),o=n.add(this.privKey.bn).mod(L.getN());s=new this.constructor,s.chainCode=a,s.privKey=(new this.PrivKey).fromBn(o),s.pubKey=(new F).fromPrivKey(s.privKey)}else{const t=Buffer.concat([this.pubKey.toBuffer(),e]),r=E.sha512Hmac(t,this.chainCode),i=p().fromBuffer(r.slice(0,32)),n=r.slice(32,64),a=L.getG().mul(i),o=this.pubKey.point,c=a.add(o),h=new F;h.point=c,s=new this.constructor,s.chainCode=n,s.pubKey=h}s.childIndex=t;const n=E.sha256Ripemd160(this.pubKey.toBuffer());return s.parentFingerPrint=n.slice(0,4),s.versionBytesNum=this.versionBytesNum,s.depth=this.depth+1,s}toPublic(){const t=(new this.constructor).fromObject(this);return t.versionBytesNum=this.Constants.pubKey,t.privKey=void 0,t}toBuffer(){const t=this.versionBytesNum===this.Constants.privKey,e=this.versionBytesNum===this.Constants.pubKey;if(t)return(new y).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(e){if(!1===this.pubKey.compressed)throw new Error("cannot convert bip32 to buffer if pubKey is not compressed");return(new y).writeUInt32BE(this.versionBytesNum).writeUInt8(this.depth).write(this.parentFingerPrint).writeUInt32BE(this.childIndex).write(this.chainCode).write(this.pubKey.toBuffer()).toBuffer()}throw new Error("bip32: invalid versionBytesNum byte")}toFastBuffer(){if(!this.versionBytesNum)return Buffer.alloc(0);const t=this.versionBytesNum===this.Constants.privKey,e=this.versionBytesNum===this.Constants.pubKey;if(t)return(new y).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(e)return(new y).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 P.encode(this.toBuffer())}async asyncToString(){const t=await B.asyncObjectMethod(this,"toString",[]);return JSON.parse(t.resbuf.toString())}toJSON(){return this.toFastHex()}fromJSON(t){return this.fromFastHex(t)}isPrivate(){return this.versionBytesNum===this.Constants.privKey}}G.Mainnet=class extends G{constructor(t,e,r,i,s,n,a){super(t,e,r,i,s,n,a,k.Mainnet.Bip32,V.Mainnet)}},G.Testnet=class extends G{constructor(t,e,r,i,s,n,a){super(t,e,r,i,s,n,a,k.Testnet.Bip32,V.Testnet)}};const Y=["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"];Y.space=" ";const J=["あいこくしん","あいさつ","あいだ","あおぞら","あかちゃん","あきる","あけがた","あける","あこがれる","あさい","あさひ","あしあと","あじわう","あずかる","あずき","あそぶ","あたえる","あたためる","あたりまえ","あたる","あつい","あつかう","あっしゅく","あつまり","あつめる","あてな","あてはまる","あひる","あぶら","あぶる","あふれる","あまい","あまど","あまやかす","あまり","あみもの","あめりか","あやまる","あゆむ","あらいぐま","あらし","あらすじ","あらためる","あらゆる","あらわす","ありがとう","あわせる","あわてる","あんい","あんがい","あんこ","あんぜん","あんてい","あんない","あんまり","いいだす","いおん","いがい","いがく","いきおい","いきなり","いきもの","いきる","いくじ","いくぶん","いけばな","いけん","いこう","いこく","いこつ","いさましい","いさん","いしき","いじゅう","いじょう","いじわる","いずみ","いずれ","いせい","いせえび","いせかい","いせき","いぜん","いそうろう","いそがしい","いだい","いだく","いたずら","いたみ","いたりあ","いちおう","いちじ","いちど","いちば","いちぶ","いちりゅう","いつか","いっしゅん","いっせい","いっそう","いったん","いっち","いってい","いっぽう","いてざ","いてん","いどう","いとこ","いない","いなか","いねむり","いのち","いのる","いはつ","いばる","いはん","いびき","いひん","いふく","いへん","いほう","いみん","いもうと","いもたれ","いもり","いやがる","いやす","いよかん","いよく","いらい","いらすと","いりぐち","いりょう","いれい","いれもの","いれる","いろえんぴつ","いわい","いわう","いわかん","いわば","いわゆる","いんげんまめ","いんさつ","いんしょう","いんよう","うえき","うえる","うおざ","うがい","うかぶ","うかべる","うきわ","うくらいな","うくれれ","うけたまわる","うけつけ","うけとる","うけもつ","うける","うごかす","うごく","うこん","うさぎ","うしなう","うしろがみ","うすい","うすぎ","うすぐらい","うすめる","うせつ","うちあわせ","うちがわ","うちき","うちゅう","うっかり","うつくしい","うったえる","うつる","うどん","うなぎ","うなじ","うなずく","うなる","うねる","うのう","うぶげ","うぶごえ","うまれる","うめる","うもう","うやまう","うよく","うらがえす","うらぐち","うらない","うりあげ","うりきれ","うるさい","うれしい","うれゆき","うれる","うろこ","うわき","うわさ","うんこう","うんちん","うんてん","うんどう","えいえん","えいが","えいきょう","えいご","えいせい","えいぶん","えいよう","えいわ","えおり","えがお","えがく","えきたい","えくせる","えしゃく","えすて","えつらん","えのぐ","えほうまき","えほん","えまき","えもじ","えもの","えらい","えらぶ","えりあ","えんえん","えんかい","えんぎ","えんげき","えんしゅう","えんぜつ","えんそく","えんちょう","えんとつ","おいかける","おいこす","おいしい","おいつく","おうえん","おうさま","おうじ","おうせつ","おうたい","おうふく","おうべい","おうよう","おえる","おおい","おおう","おおどおり","おおや","おおよそ","おかえり","おかず","おがむ","おかわり","おぎなう","おきる","おくさま","おくじょう","おくりがな","おくる","おくれる","おこす","おこなう","おこる","おさえる","おさない","おさめる","おしいれ","おしえる","おじぎ","おじさん","おしゃれ","おそらく","おそわる","おたがい","おたく","おだやか","おちつく","おっと","おつり","おでかけ","おとしもの","おとなしい","おどり","おどろかす","おばさん","おまいり","おめでとう","おもいで","おもう","おもたい","おもちゃ","おやつ","おやゆび","およぼす","おらんだ","おろす","おんがく","おんけい","おんしゃ","おんせん","おんだん","おんちゅう","おんどけい","かあつ","かいが","がいき","がいけん","がいこう","かいさつ","かいしゃ","かいすいよく","かいぜん","かいぞうど","かいつう","かいてん","かいとう","かいふく","がいへき","かいほう","かいよう","がいらい","かいわ","かえる","かおり","かかえる","かがく","かがし","かがみ","かくご","かくとく","かざる","がぞう","かたい","かたち","がちょう","がっきゅう","がっこう","がっさん","がっしょう","かなざわし","かのう","がはく","かぶか","かほう","かほご","かまう","かまぼこ","かめれおん","かゆい","かようび","からい","かるい","かろう","かわく","かわら","がんか","かんけい","かんこう","かんしゃ","かんそう","かんたん","かんち","がんばる","きあい","きあつ","きいろ","ぎいん","きうい","きうん","きえる","きおう","きおく","きおち","きおん","きかい","きかく","きかんしゃ","ききて","きくばり","きくらげ","きけんせい","きこう","きこえる","きこく","きさい","きさく","きさま","きさらぎ","ぎじかがく","ぎしき","ぎじたいけん","ぎじにってい","ぎじゅつしゃ","きすう","きせい","きせき","きせつ","きそう","きぞく","きぞん","きたえる","きちょう","きつえん","ぎっちり","きつつき","きつね","きてい","きどう","きどく","きない","きなが","きなこ","きぬごし","きねん","きのう","きのした","きはく","きびしい","きひん","きふく","きぶん","きぼう","きほん","きまる","きみつ","きむずかしい","きめる","きもだめし","きもち","きもの","きゃく","きやく","ぎゅうにく","きよう","きょうりゅう","きらい","きらく","きりん","きれい","きれつ","きろく","ぎろん","きわめる","ぎんいろ","きんかくじ","きんじょ","きんようび","ぐあい","くいず","くうかん","くうき","くうぐん","くうこう","ぐうせい","くうそう","ぐうたら","くうふく","くうぼ","くかん","くきょう","くげん","ぐこう","くさい","くさき","くさばな","くさる","くしゃみ","くしょう","くすのき","くすりゆび","くせげ","くせん","ぐたいてき","くださる","くたびれる","くちこみ","くちさき","くつした","ぐっすり","くつろぐ","くとうてん","くどく","くなん","くねくね","くのう","くふう","くみあわせ","くみたてる","くめる","くやくしょ","くらす","くらべる","くるま","くれる","くろう","くわしい","ぐんかん","ぐんしょく","ぐんたい","ぐんて","けあな","けいかく","けいけん","けいこ","けいさつ","げいじゅつ","けいたい","げいのうじん","けいれき","けいろ","けおとす","けおりもの","げきか","げきげん","げきだん","げきちん","げきとつ","げきは","げきやく","げこう","げこくじょう","げざい","けさき","げざん","けしき","けしごむ","けしょう","げすと","けたば","けちゃっぷ","けちらす","けつあつ","けつい","けつえき","けっこん","けつじょ","けっせき","けってい","けつまつ","げつようび","げつれい","けつろん","げどく","けとばす","けとる","けなげ","けなす","けなみ","けぬき","げねつ","けねん","けはい","げひん","けぶかい","げぼく","けまり","けみかる","けむし","けむり","けもの","けらい","けろけろ","けわしい","けんい","けんえつ","けんお","けんか","げんき","けんげん","けんこう","けんさく","けんしゅう","けんすう","げんそう","けんちく","けんてい","けんとう","けんない","けんにん","げんぶつ","けんま","けんみん","けんめい","けんらん","けんり","こあくま","こいぬ","こいびと","ごうい","こうえん","こうおん","こうかん","ごうきゅう","ごうけい","こうこう","こうさい","こうじ","こうすい","ごうせい","こうそく","こうたい","こうちゃ","こうつう","こうてい","こうどう","こうない","こうはい","ごうほう","ごうまん","こうもく","こうりつ","こえる","こおり","ごかい","ごがつ","ごかん","こくご","こくさい","こくとう","こくない","こくはく","こぐま","こけい","こける","ここのか","こころ","こさめ","こしつ","こすう","こせい","こせき","こぜん","こそだて","こたい","こたえる","こたつ","こちょう","こっか","こつこつ","こつばん","こつぶ","こてい","こてん","ことがら","ことし","ことば","ことり","こなごな","こねこね","このまま","このみ","このよ","ごはん","こひつじ","こふう","こふん","こぼれる","ごまあぶら","こまかい","ごますり","こまつな","こまる","こむぎこ","こもじ","こもち","こもの","こもん","こやく","こやま","こゆう","こゆび","こよい","こよう","こりる","これくしょん","ころっけ","こわもて","こわれる","こんいん","こんかい","こんき","こんしゅう","こんすい","こんだて","こんとん","こんなん","こんびに","こんぽん","こんまけ","こんや","こんれい","こんわく","ざいえき","さいかい","さいきん","ざいげん","ざいこ","さいしょ","さいせい","ざいたく","ざいちゅう","さいてき","ざいりょう","さうな","さかいし","さがす","さかな","さかみち","さがる","さぎょう","さくし","さくひん","さくら","さこく","さこつ","さずかる","ざせき","さたん","さつえい","ざつおん","ざっか","ざつがく","さっきょく","ざっし","さつじん","ざっそう","さつたば","さつまいも","さてい","さといも","さとう","さとおや","さとし","さとる","さのう","さばく","さびしい","さべつ","さほう","さほど","さます","さみしい","さみだれ","さむけ","さめる","さやえんどう","さゆう","さよう","さよく","さらだ","ざるそば","さわやか","さわる","さんいん","さんか","さんきゃく","さんこう","さんさい","ざんしょ","さんすう","さんせい","さんそ","さんち","さんま","さんみ","さんらん","しあい","しあげ","しあさって","しあわせ","しいく","しいん","しうち","しえい","しおけ","しかい","しかく","じかん","しごと","しすう","じだい","したうけ","したぎ","したて","したみ","しちょう","しちりん","しっかり","しつじ","しつもん","してい","してき","してつ","じてん","じどう","しなぎれ","しなもの","しなん","しねま","しねん","しのぐ","しのぶ","しはい","しばかり","しはつ","しはらい","しはん","しひょう","しふく","じぶん","しへい","しほう","しほん","しまう","しまる","しみん","しむける","じむしょ","しめい","しめる","しもん","しゃいん","しゃうん","しゃおん","じゃがいも","しやくしょ","しゃくほう","しゃけん","しゃこ","しゃざい","しゃしん","しゃせん","しゃそう","しゃたい","しゃちょう","しゃっきん","じゃま","しゃりん","しゃれい","じゆう","じゅうしょ","しゅくはく","じゅしん","しゅっせき","しゅみ","しゅらば","じゅんばん","しょうかい","しょくたく","しょっけん","しょどう","しょもつ","しらせる","しらべる","しんか","しんこう","じんじゃ","しんせいじ","しんちく","しんりん","すあげ","すあし","すあな","ずあん","すいえい","すいか","すいとう","ずいぶん","すいようび","すうがく","すうじつ","すうせん","すおどり","すきま","すくう","すくない","すける","すごい","すこし","ずさん","すずしい","すすむ","すすめる","すっかり","ずっしり","ずっと","すてき","すてる","すねる","すのこ","すはだ","すばらしい","ずひょう","ずぶぬれ","すぶり","すふれ","すべて","すべる","ずほう","すぼん","すまい","すめし","すもう","すやき","すらすら","するめ","すれちがう","すろっと","すわる","すんぜん","すんぽう","せあぶら","せいかつ","せいげん","せいじ","せいよう","せおう","せかいかん","せきにん","せきむ","せきゆ","せきらんうん","せけん","せこう","せすじ","せたい","せたけ","せっかく","せっきゃく","ぜっく","せっけん","せっこつ","せっさたくま","せつぞく","せつだん","せつでん","せっぱん","せつび","せつぶん","せつめい","せつりつ","せなか","せのび","せはば","せびろ","せぼね","せまい","せまる","せめる","せもたれ","せりふ","ぜんあく","せんい","せんえい","せんか","せんきょ","せんく","せんげん","ぜんご","せんさい","せんしゅ","せんすい","せんせい","せんぞ","せんたく","せんちょう","せんてい","せんとう","せんぬき","せんねん","せんぱい","ぜんぶ","ぜんぽう","せんむ","せんめんじょ","せんもん","せんやく","せんゆう","せんよう","ぜんら","ぜんりゃく","せんれい","せんろ","そあく","そいとげる","そいね","そうがんきょう","そうき","そうご","そうしん","そうだん","そうなん","そうび","そうめん","そうり","そえもの","そえん","そがい","そげき","そこう","そこそこ","そざい","そしな","そせい","そせん","そそぐ","そだてる","そつう","そつえん","そっかん","そつぎょう","そっけつ","そっこう","そっせん","そっと","そとがわ","そとづら","そなえる","そなた","そふぼ","そぼく","そぼろ","そまつ","そまる","そむく","そむりえ","そめる","そもそも","そよかぜ","そらまめ","そろう","そんかい","そんけい","そんざい","そんしつ","そんぞく","そんちょう","ぞんび","ぞんぶん","そんみん","たあい","たいいん","たいうん","たいえき","たいおう","だいがく","たいき","たいぐう","たいけん","たいこ","たいざい","だいじょうぶ","だいすき","たいせつ","たいそう","だいたい","たいちょう","たいてい","だいどころ","たいない","たいねつ","たいのう","たいはん","だいひょう","たいふう","たいへん","たいほ","たいまつばな","たいみんぐ","たいむ","たいめん","たいやき","たいよう","たいら","たいりょく","たいる","たいわん","たうえ","たえる","たおす","たおる","たおれる","たかい","たかね","たきび","たくさん","たこく","たこやき","たさい","たしざん","だじゃれ","たすける","たずさわる","たそがれ","たたかう","たたく","ただしい","たたみ","たちばな","だっかい","だっきゃく","だっこ","だっしゅつ","だったい","たてる","たとえる","たなばた","たにん","たぬき","たのしみ","たはつ","たぶん","たべる","たぼう","たまご","たまる","だむる","ためいき","ためす","ためる","たもつ","たやすい","たよる","たらす","たりきほんがん","たりょう","たりる","たると","たれる","たれんと","たろっと","たわむれる","だんあつ","たんい","たんおん","たんか","たんき","たんけん","たんご","たんさん","たんじょうび","だんせい","たんそく","たんたい","だんち","たんてい","たんとう","だんな","たんにん","だんねつ","たんのう","たんぴん","だんぼう","たんまつ","たんめい","だんれつ","だんろ","だんわ","ちあい","ちあん","ちいき","ちいさい","ちえん","ちかい","ちから","ちきゅう","ちきん","ちけいず","ちけん","ちこく","ちさい","ちしき","ちしりょう","ちせい","ちそう","ちたい","ちたん","ちちおや","ちつじょ","ちてき","ちてん","ちぬき","ちぬり","ちのう","ちひょう","ちへいせん","ちほう","ちまた","ちみつ","ちみどろ","ちめいど","ちゃんこなべ","ちゅうい","ちゆりょく","ちょうし","ちょさくけん","ちらし","ちらみ","ちりがみ","ちりょう","ちるど","ちわわ","ちんたい","ちんもく","ついか","ついたち","つうか","つうじょう","つうはん","つうわ","つかう","つかれる","つくね","つくる","つけね","つける","つごう","つたえる","つづく","つつじ","つつむ","つとめる","つながる","つなみ","つねづね","つのる","つぶす","つまらない","つまる","つみき","つめたい","つもり","つもる","つよい","つるぼ","つるみく","つわもの","つわり","てあし","てあて","てあみ","ていおん","ていか","ていき","ていけい","ていこく","ていさつ","ていし","ていせい","ていたい","ていど","ていねい","ていひょう","ていへん","ていぼう","てうち","ておくれ","てきとう","てくび","でこぼこ","てさぎょう","てさげ","てすり","てそう","てちがい","てちょう","てつがく","てつづき","でっぱ","てつぼう","てつや","でぬかえ","てぬき","てぬぐい","てのひら","てはい","てぶくろ","てふだ","てほどき","てほん","てまえ","てまきずし","てみじか","てみやげ","てらす","てれび","てわけ","てわたし","でんあつ","てんいん","てんかい","てんき","てんぐ","てんけん","てんごく","てんさい","てんし","てんすう","でんち","てんてき","てんとう","てんない","てんぷら","てんぼうだい","てんめつ","てんらんかい","でんりょく","でんわ","どあい","といれ","どうかん","とうきゅう","どうぐ","とうし","とうむぎ","とおい","とおか","とおく","とおす","とおる","とかい","とかす","ときおり","ときどき","とくい","とくしゅう","とくてん","とくに","とくべつ","とけい","とける","とこや","とさか","としょかん","とそう","とたん","とちゅう","とっきゅう","とっくん","とつぜん","とつにゅう","とどける","ととのえる","とない","となえる","となり","とのさま","とばす","どぶがわ","とほう","とまる","とめる","ともだち","ともる","どようび","とらえる","とんかつ","どんぶり","ないかく","ないこう","ないしょ","ないす","ないせん","ないそう","なおす","ながい","なくす","なげる","なこうど","なさけ","なたでここ","なっとう","なつやすみ","ななおし","なにごと","なにもの","なにわ","なのか","なふだ","なまいき","なまえ","なまみ","なみだ","なめらか","なめる","なやむ","ならう","ならび","ならぶ","なれる","なわとび","なわばり","にあう","にいがた","にうけ","におい","にかい","にがて","にきび","にくしみ","にくまん","にげる","にさんかたんそ","にしき","にせもの","にちじょう","にちようび","にっか","にっき","にっけい","にっこう","にっさん","にっしょく","にっすう","にっせき","にってい","になう","にほん","にまめ","にもつ","にやり","にゅういん","にりんしゃ","にわとり","にんい","にんか","にんき","にんげん","にんしき","にんずう","にんそう","にんたい","にんち","にんてい","にんにく","にんぷ","にんまり","にんむ","にんめい","にんよう","ぬいくぎ","ぬかす","ぬぐいとる","ぬぐう","ぬくもり","ぬすむ","ぬまえび","ぬめり","ぬらす","ぬんちゃく","ねあげ","ねいき","ねいる","ねいろ","ねぐせ","ねくたい","ねくら","ねこぜ","ねこむ","ねさげ","ねすごす","ねそべる","ねだん","ねつい","ねっしん","ねつぞう","ねったいぎょ","ねぶそく","ねふだ","ねぼう","ねほりはほり","ねまき","ねまわし","ねみみ","ねむい","ねむたい","ねもと","ねらう","ねわざ","ねんいり","ねんおし","ねんかん","ねんきん","ねんぐ","ねんざ","ねんし","ねんちゃく","ねんど","ねんぴ","ねんぶつ","ねんまつ","ねんりょう","ねんれい","のいず","のおづま","のがす","のきなみ","のこぎり","のこす","のこる","のせる","のぞく","のぞむ","のたまう","のちほど","のっく","のばす","のはら","のべる","のぼる","のみもの","のやま","のらいぬ","のらねこ","のりもの","のりゆき","のれん","のんき","ばあい","はあく","ばあさん","ばいか","ばいく","はいけん","はいご","はいしん","はいすい","はいせん","はいそう","はいち","ばいばい","はいれつ","はえる","はおる","はかい","ばかり","はかる","はくしゅ","はけん","はこぶ","はさみ","はさん","はしご","ばしょ","はしる","はせる","ぱそこん","はそん","はたん","はちみつ","はつおん","はっかく","はづき","はっきり","はっくつ","はっけん","はっこう","はっさん","はっしん","はったつ","はっちゅう","はってん","はっぴょう","はっぽう","はなす","はなび","はにかむ","はぶらし","はみがき","はむかう","はめつ","はやい","はやし","はらう","はろうぃん","はわい","はんい","はんえい","はんおん","はんかく","はんきょう","ばんぐみ","はんこ","はんしゃ","はんすう","はんだん","ぱんち","ぱんつ","はんてい","はんとし","はんのう","はんぱ","はんぶん","はんぺん","はんぼうき","はんめい","はんらん","はんろん","ひいき","ひうん","ひえる","ひかく","ひかり","ひかる","ひかん","ひくい","ひけつ","ひこうき","ひこく","ひさい","ひさしぶり","ひさん","びじゅつかん","ひしょ","ひそか","ひそむ","ひたむき","ひだり","ひたる","ひつぎ","ひっこし","ひっし","ひつじゅひん","ひっす","ひつぜん","ぴったり","ぴっちり","ひつよう","ひてい","ひとごみ","ひなまつり","ひなん","ひねる","ひはん","ひびく","ひひょう","ひほう","ひまわり","ひまん","ひみつ","ひめい","ひめじし","ひやけ","ひやす","ひよう","びょうき","ひらがな","ひらく","ひりつ","ひりょう","ひるま","ひるやすみ","ひれい","ひろい","ひろう","ひろき","ひろゆき","ひんかく","ひんけつ","ひんこん","ひんしゅ","ひんそう","ぴんち","ひんぱん","びんぼう","ふあん","ふいうち","ふうけい","ふうせん","ぷうたろう","ふうとう","ふうふ","ふえる","ふおん","ふかい","ふきん","ふくざつ","ふくぶくろ","ふこう","ふさい","ふしぎ","ふじみ","ふすま","ふせい","ふせぐ","ふそく","ぶたにく","ふたん","ふちょう","ふつう","ふつか","ふっかつ","ふっき","ふっこく","ぶどう","ふとる","ふとん","ふのう","ふはい","ふひょう","ふへん","ふまん","ふみん","ふめつ","ふめん","ふよう","ふりこ","ふりる","ふるい","ふんいき","ぶんがく","ぶんぐ","ふんしつ","ぶんせき","ふんそう","ぶんぽう","へいあん","へいおん","へいがい","へいき","へいげん","へいこう","へいさ","へいしゃ","へいせつ","へいそ","へいたく","へいてん","へいねつ","へいわ","へきが","へこむ","べにいろ","べにしょうが","へらす","へんかん","べんきょう","べんごし","へんさい","へんたい","べんり","ほあん","ほいく","ぼうぎょ","ほうこく","ほうそう","ほうほう","ほうもん","ほうりつ","ほえる","ほおん","ほかん","ほきょう","ぼきん","ほくろ","ほけつ","ほけん","ほこう","ほこる","ほしい","ほしつ","ほしゅ","ほしょう","ほせい","ほそい","ほそく","ほたて","ほたる","ぽちぶくろ","ほっきょく","ほっさ","ほったん","ほとんど","ほめる","ほんい","ほんき","ほんけ","ほんしつ","ほんやく","まいにち","まかい","まかせる","まがる","まける","まこと","まさつ","まじめ","ますく","まぜる","まつり","まとめ","まなぶ","まぬけ","まねく","まほう","まもる","まゆげ","まよう","まろやか","まわす","まわり","まわる","まんが","まんきつ","まんぞく","まんなか","みいら","みうち","みえる","みがく","みかた","みかん","みけん","みこん","みじかい","みすい","みすえる","みせる","みっか","みつかる","みつける","みてい","みとめる","みなと","みなみかさい","みねらる","みのう","みのがす","みほん","みもと","みやげ","みらい","みりょく","みわく","みんか","みんぞく","むいか","むえき","むえん","むかい","むかう","むかえ","むかし","むぎちゃ","むける","むげん","むさぼる","むしあつい","むしば","むじゅん","むしろ","むすう","むすこ","むすぶ","むすめ","むせる","むせん","むちゅう","むなしい","むのう","むやみ","むよう","むらさき","むりょう","むろん","めいあん","めいうん","めいえん","めいかく","めいきょく","めいさい","めいし","めいそう","めいぶつ","めいれい","めいわく","めぐまれる","めざす","めした","めずらしい","めだつ","めまい","めやす","めんきょ","めんせき","めんどう","もうしあげる","もうどうけん","もえる","もくし","もくてき","もくようび","もちろん","もどる","もらう","もんく","もんだい","やおや","やける","やさい","やさしい","やすい","やすたろう","やすみ","やせる","やそう","やたい","やちん","やっと","やっぱり","やぶる","やめる","ややこしい","やよい","やわらかい","ゆうき","ゆうびんきょく","ゆうべ","ゆうめい","ゆけつ","ゆしゅつ","ゆせん","ゆそう","ゆたか","ゆちゃく","ゆでる","ゆにゅう","ゆびわ","ゆらい","ゆれる","ようい","ようか","ようきゅう","ようじ","ようす","ようちえん","よかぜ","よかん","よきん","よくせい","よくぼう","よけい","よごれる","よさん","よしゅう","よそう","よそく","よっか","よてい","よどがわく","よねつ","よやく","よゆう","よろこぶ","よろしい","らいう","らくがき","らくご","らくさつ","らくだ","らしんばん","らせん","らぞく","らたい","らっか","られつ","りえき","りかい","りきさく","りきせつ","りくぐん","りくつ","りけん","りこう","りせい","りそう","りそく","りてん","りねん","りゆう","りゅうがく","りよう","りょうり","りょかん","りょくちゃ","りょこう","りりく","りれき","りろん","りんご","るいけい","るいさい","るいじ","るいせき","るすばん","るりがわら","れいかん","れいぎ","れいせい","れいぞうこ","れいとう","れいぼう","れきし","れきだい","れんあい","れんけい","れんこん","れんさい","れんしゅう","れんぞく","れんらく","ろうか","ろうご","ろうじん","ろうそく","ろくが","ろこつ","ろじうら","ろしゅつ","ろせん","ろてん","ろめん","ろれつ","ろんぎ","ろんぱ","ろんぶん","ろんり","わかす","わかめ","わかやま","わかれる","わしつ","わじまし","わすれもの","わらう","われる"];J.space=" ";const W=["á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"];W.space=" ";class Q extends w{constructor(t,e,r){super({mnemonic:t,seed:e,wordlist:r}),this.Wordlist=Y,this.es=W,this.jp=J}setLang(t){switch(t){default:case"en":this.Wordlist=Y;break;case"es":this.Wordlist=W;break;case"jp":this.Wordlist=J}}toBw(t){if(t||(t=new y),this.mnemonic){const e=Buffer.from(this.mnemonic);t.writeVarIntNum(e.length),t.write(e)}else t.writeVarIntNum(0);return this.seed?(t.writeVarIntNum(this.seed.length),t.write(this.seed)):t.writeVarIntNum(0),t}fromBr(t){const e=t.readVarIntNum();e>0&&(this.mnemonic=t.read(e).toString());const r=t.readVarIntNum();return r>0&&(this.seed=t.read(r)),this}fromRandom(t){if(t||(t=128),t%32!=0)throw new Error("bits must be multiple of 32");if(t<128)throw new Error("bits must be at least 128");const e=D.getRandomBuffer(t/8);return this.entropy2Mnemonic(e),this.mnemonic2Seed(),this}static fromRandom(t){return(new this).fromRandom(t)}async asyncFromRandom(t){t||(t=128);const e=D.getRandomBuffer(t/8);let r=await B.asyncObjectMethod(this,"entropy2Mnemonic",[e]);const i=(new Q).fromFastBuffer(r.resbuf);return r=await B.asyncObjectMethod(i,"mnemonic2Seed",[]),this.fromFastBuffer(r.resbuf)}static asyncFromRandom(t){return(new this).asyncFromRandom(t)}fromEntropy(t){return this.entropy2Mnemonic(t),this}static fromEntropy(t){return(new this).fromEntropy(t)}async asyncFromEntropy(t){const e=await B.asyncObjectMethod(this,"fromEntropy",[t]);return this.fromFastBuffer(e.resbuf)}static asyncFromEntropy(t){return(new this).asyncFromEntropy(t)}fromString(t){return this.mnemonic=t.trim(),this}toString(){return this.mnemonic}toSeed(t){return this.mnemonic2Seed(t),this.seed}async asyncToSeed(t){void 0===t&&(t="");const e=[t];return(await B.asyncObjectMethod(this,"toSeed",e)).resbuf}entropy2Mnemonic(t){if(!Buffer.isBuffer(t)||t.length<16)throw new Error("Entropy is less than 128 bits. It must be 128 bits or more.");const e=E.sha256(t);let r="";const i=8*t.length;for(let e=0;e<t.length;e++)r+=("00000000"+t[e].toString(2)).slice(-8);let s=e[0].toString(2);if(s=("00000000"+s).slice(-8).slice(0,i/32),r+=s,r.length%11!=0)throw new Error("internal error - entropy not an even multiple of 11 bits - "+r.length);let n="";for(let t=0;t<r.length/11;t++){""!==n&&(n+=this.Wordlist.space);const e=parseInt(r.slice(11*t,11*(t+1)),2);n+=this.Wordlist[e]}return this.mnemonic=n,this}check(){const t=this.mnemonic.split(this.Wordlist.space);let e="";for(let r=0;r<t.length;r++){const i=this.Wordlist.indexOf(t[r]);if(i<0)return!1;e+=("00000000000"+i.toString(2)).slice(-11)}if(e.length%11!=0)throw new Error("internal error - entropy not an even multiple of 11 bits - "+e.length);const r=e.length/33,i=e.slice(-r),s=e.slice(0,e.length-r),n=Buffer.alloc(s.length/8);for(let t=0;t<s.length/8;t++)n.writeUInt8(parseInt(e.slice(8*t,8*(t+1)),2),t);let a=E.sha256(n)[0].toString(2);return a=("00000000"+a).slice(-8).slice(0,r),a===i}mnemonic2Seed(t=""){let e=this.mnemonic;if(!this.check())throw new Error("Mnemonic does not pass the check - was the mnemonic typed incorrectly? Are there extra spaces?");if("string"!=typeof t)throw new Error("passphrase must be a string or undefined");e=e.normalize("NFKD"),t=t.normalize("NFKD");const r=Buffer.from(e),i=Buffer.concat([Buffer.from("mnemonic"),Buffer.from(t)]);return this.seed=d.pbkdf2Sync(r,i,2048,64,"sha512"),this}isValid(t=""){let e;try{e=!!this.mnemonic2Seed(t)}catch(t){e=!1}return e}static isValid(t,e=""){return new Q(t).isValid(e)}}class X extends w{constructor(t,e,r=V){super({privKey:t,pubKey:e}),this.PrivKey=r}fromJSON(t){return t.privKey&&(this.privKey=this.PrivKey.fromJSON(t.privKey)),t.pubKey&&(this.pubKey=F.fromJSON(t.pubKey)),this}fromBr(t){const e=t.readUInt8();e>0&&(this.privKey=(new this.PrivKey).fromFastBuffer(t.read(e)));const r=t.readUInt8();return r>0&&(this.pubKey=(new F).fromFastBuffer(t.read(r))),this}toBw(t){if(t||(t=new y),this.privKey){const e=this.privKey.toFastBuffer();t.writeUInt8(e.length),t.write(e)}else t.writeUInt8(0);if(this.pubKey){const e=this.pubKey.toFastBuffer();t.writeUInt8(e.length),t.write(e)}else t.writeUInt8(0);return t}fromString(t){return this.fromJSON(JSON.parse(t))}toString(){return JSON.stringify(this.toJSON())}toPublic(){const t=(new X).fromObject(this);return t.privKey=void 0,t}fromPrivKey(t){return this.privKey=t,this.pubKey=(new F).fromPrivKey(t),this}static fromPrivKey(t){return(new this).fromPrivKey(t)}async asyncFromPrivKey(t){return this.privKey=t,this.pubKey=await(new F).asyncFromPrivKey(t),this}static asyncFromPrivKey(t){return(new this).asyncFromPrivKey(t)}fromRandom(){return this.privKey=(new this.PrivKey).fromRandom(),this.pubKey=(new F).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()}}X.Mainnet=class extends X{constructor(t,e){super(t,e,V.Mainnet)}},X.Testnet=class extends X{constructor(t,e){super(t,e,V.Testnet)}};class Z extends w{constructor(t,e,r,i,s,n){super({sig:t,keyPair:e,hashBuf:r,k:i,endian:s,verified:n})}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(t){return this.sig=t.sig?(new j).fromString(t.sig):void 0,this.keyPair=t.keyPair?(new X).fromBuffer(Buffer.from(t.keyPair,"hex")):void 0,this.hashBuf=t.hashBuf?Buffer.from(t.hashBuf,"hex"):void 0,this.k=t.k?(new p).fromString(t.k):void 0,this.endian=t.endian,this.verified=t.verified,this}toBuffer(){const t=JSON.stringify(this.toJSON());return Buffer.from(t)}fromBuffer(t){const e=JSON.parse(t.toString());return this.fromJSON(e)}calcrecovery(){for(let t=0;t<4;t++){let e;this.sig.recovery=t;try{e=this.sig2PubKey()}catch(t){continue}if(e.point.eq(this.keyPair.pubKey.point)){const t=this.keyPair.pubKey.compressed;return this.sig.compressed=void 0===this.keyPair.pubKey.compressed||t,this}}throw this.sig.recovery=void 0,new Error("Unable to find valid recovery factor")}async asyncCalcrecovery(){const t=await B.asyncObjectMethod(this,"calcrecovery",[]);return this.fromFastBuffer(t.resbuf)}static calcrecovery(t,e,r){return(new Z).fromObject({sig:t,keyPair:(new X).fromObject({pubKey:e}),hashBuf:r}).calcrecovery().sig}static async asyncCalcrecovery(t,e,r){const i=await B.asyncClassMethod(Z,"calcrecovery",[t,e,r]);return(new j).fromFastBuffer(i.resbuf)}fromString(t){const e=JSON.parse(t);return e.hashBuf&&(this.hashBuf=Buffer.from(e.hashBuf,"hex")),e.keyPair&&(this.keyPair=(new X).fromString(e.keyPair)),e.sig&&(this.sig=(new j).fromString(e.sig)),e.k&&(this.k=new p(e.k,10)),this}randomK(){const t=L.getN();let e;do{e=(new p).fromBuffer(D.getRandomBuffer(32))}while(!e.lt(t)||!e.gt(0));return this.k=e,this}deterministicK(t){let e=Buffer.alloc(32);e.fill(1);let r=Buffer.alloc(32);r.fill(0);const i=this.keyPair.privKey.bn.toBuffer({size:32});r=E.sha256Hmac(Buffer.concat([e,Buffer.from([0]),i,this.hashBuf]),r),e=E.sha256Hmac(e,r),r=E.sha256Hmac(Buffer.concat([e,Buffer.from([1]),i,this.hashBuf]),r),e=E.sha256Hmac(e,r),e=E.sha256Hmac(e,r);let s=(new p).fromBuffer(e);const n=L.getN();void 0===t&&(t=0);for(let i=0;i<t||!s.lt(n)||!s.gt(0);i++)r=E.sha256Hmac(Buffer.concat([e,Buffer.from([0])]),r),e=E.sha256Hmac(e,r),e=E.sha256Hmac(e,r),s=(new p).fromBuffer(e);return this.k=s,this}sig2PubKey(){const t=this.sig.recovery;if(0!==t&&1!==t&&2!==t&&3!==t)throw new Error("i must be equal to 0, 1, 2, or 3");const e=(new p).fromBuffer(this.hashBuf),r=this.sig.r,i=this.sig.s,s=1&t,n=t>>1,a=L.getN(),o=L.getG(),c=n?r.add(a):r,h=L.fromX(s,c);let f="";try{h.mul(a)}catch(t){f=t.message}if("point mul out of range"!==f)throw new Error("nR is not a valid curve point");const u=e.neg().umod(a),d=r.invm(a),l=h.mul(i).add(o.mul(u)).mul(d),b=new F(l);return b.compressed=this.sig.compressed,b.validate(),b}async asyncSig2PubKey(){const t=await B.asyncObjectMethod(this,"sig2PubKey",[]);return F.fromFastBuffer(t.resbuf)}static sig2PubKey(t,e){return(new Z).fromObject({sig:t,hashBuf:e}).sig2PubKey()}static async asyncSig2PubKey(t,e){const r=(new Z).fromObject({sig:t,hashBuf:e});return await r.asyncSig2PubKey()}verifyStr(t=!0){if(!Buffer.isBuffer(this.hashBuf)||32!==this.hashBuf.length)return"hashBuf must be a 32 byte buffer";try{this.keyPair.pubKey.validate()}catch(i){return"Invalid pubKey: "+i}const e=this.sig.r,r=this.sig.s;if(!(e.gt(0)&&e.lt(L.getN())&&r.gt(0)&&r.lt(L.getN())))return"r and s not in range";if(t&&!this.sig.hasLowS())return"s is too high and does not satisfy low s contraint - see bip 62";const i=(new p).fromBuffer(this.hashBuf,this.endian?{endian:this.endian}:void 0),s=L.getN(),n=r.invm(s),a=n.mul(i).mod(s),o=n.mul(e).mod(s),c=L.getG().mulAdd(a,this.keyPair.pubKey.point,o);return c.isInfinity()?"p is infinity":0!==c.getX().mod(s).cmp(e)&&"Invalid signature"}sign(){const t="little"===this.endian?new g(this.hashBuf).readReverse():this.hashBuf,e=this.keyPair.privKey,r=e.bn;if(!t||!e||!r)throw new Error("invalid parameters");if(!Buffer.isBuffer(t)||32!==t.length)throw new Error("hashBuf must be a 32 byte buffer");const i=L.getN(),s=L.getG(),n=(new p).fromBuffer(t);let a,o,c,h,f=0;do{(!this.k||f>0)&&this.deterministicK(f),f++,a=this.k,o=s.mul(a),c=o.getX().mod(i),h=a.invm(i).mul(n.add(r.mul(c))).mod(i)}while(c.cmp(0)<=0||h.cmp(0)<=0);return h.gt((new p).fromBuffer(Buffer.from("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))&&(h=L.getN().sub(h)),this.sig=j.fromObject({r:c,s:h,compressed:this.keyPair.pubKey.compressed}),this}async asyncSign(){const t=await B.asyncObjectMethod(this,"sign",[]);return this.fromFastBuffer(t.resbuf)}signRandomK(){return this.randomK(),this.sign()}toString(){const t={};return this.hashBuf&&(t.hashBuf=this.hashBuf.toString("hex")),this.keyPair&&(t.keyPair=this.keyPair.toString()),this.sig&&(t.sig=this.sig.toString()),this.k&&(t.k=this.k.toString()),JSON.stringify(t)}verify(t=!0){return this.verifyStr(t)?this.verified=!1:this.verified=!0,this}async asyncVerify(t=!0){const e=await B.asyncObjectMethod(this,"verify",[t]);return this.fromFastBuffer(e.resbuf)}static sign(t,e,r){return(new Z).fromObject({hashBuf:t,endian:r,keyPair:e}).sign().sig}static async asyncSign(t,e,r){const i=(new Z).fromObject({hashBuf:t,endian:r,keyPair:e});return await i.asyncSign(),i.sig}static verify(t,e,r,i,s=!0){return(new Z).fromObject({hashBuf:t,endian:i,sig:e,keyPair:(new X).fromObject({pubKey:r})}).verify(s).verified}static async asyncVerify(t,e,r,i,s=!0){const n=(new Z).fromObject({hashBuf:t,endian:i,sig:e,keyPair:(new X).fromObject({pubKey:r})});return await n.asyncVerify(s),n.verified}}class $ extends w{constructor(t,e,r,i,s){super({messageBuf:t,keyPair:e,sig:r,address:i,verified:s})}static magicHash(t){if(!Buffer.isBuffer(t))throw new Error("messageBuf must be a buffer");const e=new y;e.writeVarIntNum($.magicBytes.length),e.write($.magicBytes),e.writeVarIntNum(t.length),e.write(t);const r=e.toBuffer();return E.sha256Sha256(r)}static async asyncMagicHash(t){const e=[t];return(await B.asyncClassMethod($,"magicHash",e)).resbuf}static sign(t,e){const r=new $(t,e);return r.sign(),r.sig.toCompact().toString("base64")}static async asyncSign(t,e){const r=[t,e],i=await B.asyncClassMethod($,"sign",r);return JSON.parse(i.resbuf.toString())}static verify(t,e,r){const i=Buffer.from(e,"base64"),s=new $;return s.messageBuf=t,s.sig=(new j).fromCompact(i),s.address=r,s.verify().verified}static async asyncVerify(t,e,r){const i=[t,e,r],s=await B.asyncClassMethod($,"verify",i);return JSON.parse(s.resbuf.toString())}sign(){const t=$.magicHash(this.messageBuf),e=(new Z).fromObject({hashBuf:t,keyPair:this.keyPair});return e.sign(),e.calcrecovery(),this.sig=e.sig,this}verify(){const t=$.magicHash(this.messageBuf),e=new Z;if(e.hashBuf=t,e.sig=this.sig,e.keyPair=new X,e.keyPair.pubKey=e.sig2PubKey(),!e.verify())return this.verified=!1,this;const r=(new q).fromPubKey(e.keyPair.pubKey,void 0,this.sig.compressed);return _(r.hashBuf,this.address.hashBuf)?this.verified=!0:this.verified=!1,this}}$.magicBytes=Buffer.from("Bitcoin Signed Message:\n");class tt extends w{constructor(t,e,r,i,s,n){super({versionBytesNum:t,prevBlockHashBuf:e,merkleRootBuf:r,time:i,bits:s,nonce:n})}fromJSON(t){return this.fromObject({versionBytesNum:t.versionBytesNum,prevBlockHashBuf:Buffer.from(t.prevBlockHashBuf,"hex"),merkleRootBuf:Buffer.from(t.merkleRootBuf,"hex"),time:t.time,bits:t.bits,nonce:t.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(t){return this.versionBytesNum=t.readUInt32LE(),this.prevBlockHashBuf=t.read(32),this.merkleRootBuf=t.read(32),this.time=t.readUInt32LE(),this.bits=t.readUInt32LE(),this.nonce=t.readUInt32LE(),this}toBw(t){return t||(t=new y),t.writeUInt32LE(this.versionBytesNum),t.write(this.prevBlockHashBuf),t.write(this.merkleRootBuf),t.writeUInt32LE(this.time),t.writeUInt32LE(this.bits),t.writeUInt32LE(this.nonce),t}}class et extends w{constructor(t,e,r,i){super({hashBuf:t,buf:e,merkle1:r,merkle2:i})}hash(){if(this.hashBuf)return this.hashBuf;if(this.buf)return E.sha256Sha256(this.buf);const t=this.merkle1.hash(),e=this.merkle2.hash();return this.buf=Buffer.concat([t,e]),E.sha256Sha256(this.buf)}fromBuffers(t){if(t.length<1)throw new Error("buffers must have a length");t=t.slice();const e=Math.log2(t.length);if(!Number.isInteger(e)){const i=t[t.length-1];var r=Math.pow(2,Math.ceil(e));for(let e=t.length;e<r;e++)t.push(i)}const i=t.slice(0,t.length/2),s=t.slice(t.length/2);return this.fromBufferArrays(i,s),this}static fromBuffers(t){return(new this).fromBuffers(t)}fromBufferArrays(t,e){if(1===t.length)return this.merkle1=new et(void 0,t[0]),this.merkle2=new et(void 0,e[0]),this;const r=t.slice(0,t.length/2),i=t.slice(t.length/2);this.merkle1=(new et).fromBufferArrays(r,i);const s=e.slice(0,e.length/2),n=e.slice(e.length/2);return this.merkle2=(new et).fromBufferArrays(s,n),this}static fromBufferArrays(t,e){return(new this).fromBufferArrays(t,e)}leavesNum(){if(this.merkle1)return this.merkle1.leavesNum()+this.merkle2.leavesNum();if(this.buf)return 1;throw new Error("invalid number of leaves")}}class rt extends w{constructor(t,e,r){super(),this.fromObject({prevoutsHashBuf:t,sequenceHashBuf:e,outputsHashBuf:r})}fromBuffer(t){return this.fromJSON(JSON.parse(t.toString()))}toBuffer(){return Buffer.from(JSON.stringify(this.toJSON()))}fromJSON(t){return this.prevoutsHashBuf=t.prevoutsHashBuf?Buffer.from(t.prevoutsHashBuf,"hex"):void 0,this.sequenceHashBuf=t.sequenceHashBuf?Buffer.from(t.sequenceHashBuf,"hex"):void 0,this.outputsHashBuf=t.outputsHashBuf?Buffer.from(t.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 it extends w{constructor(t){super({buf:t})}fromJSON(t){return this.fromObject({buf:Buffer.from(t,"hex")}),this}toJSON(){return this.buf.toString("hex")}fromBuffer(t){return this.buf=t,this}fromBr(t){return this.buf=t.readVarIntBuf(),this}fromBn(t){return this.buf=(new y).writeVarIntBn(t).toBuffer(),this}static fromBn(t){return(new this).fromBn(t)}fromNumber(t){return this.buf=(new y).writeVarIntNum(t).toBuffer(),this}static fromNumber(t){return(new this).fromNumber(t)}toBuffer(){return this.buf}toBn(){return new g(this.buf).readVarIntBn()}toNumber(){return new g(this.buf).readVarIntNum()}}class st extends w{constructor(t,e,r,i,s=4294967295){super({txHashBuf:t,txOutNum:e,scriptVi:r,script:i,nSequence:s})}setScript(t){return this.scriptVi=it.fromNumber(t.toBuffer().length),this.script=t,this}fromProperties(t,e,r,i){return this.fromObject({txHashBuf:t,txOutNum:e,nSequence:i}),this.setScript(r),this}static fromProperties(t,e,r,i){return(new this).fromProperties(t,e,r,i)}fromJSON(t){return this.fromObject({txHashBuf:void 0!==t.txHashBuf?Buffer.from(t.txHashBuf,"hex"):void 0,txOutNum:t.txOutNum,scriptVi:void 0!==t.scriptVi?it.fromJSON(t.scriptVi):void 0,script:void 0!==t.script?z.fromJSON(t.script):void 0,nSequence:t.nSequence}),this}toJSON(){return{txHashBuf:void 0!==this.txHashBuf?this.txHashBuf.toString("hex"):void 0,txOutNum:this.txOutNum,scriptVi:void 0!==this.scriptVi?this.scriptVi.toJSON():void 0,script:void 0!==this.script?this.script.toJSON():void 0,nSequence:this.nSequence}}fromBr(t){return this.txHashBuf=t.read(32),this.txOutNum=t.readUInt32LE(),this.scriptVi=it.fromBuffer(t.readVarIntBuf()),this.script=z.fromBuffer(t.read(this.scriptVi.toNumber())),this.nSequence=t.readUInt32LE(),this}toBw(t){return t||(t=new y),t.write(this.txHashBuf),t.writeUInt32LE(this.txOutNum),t.write(this.scriptVi.buf),t.write(this.script.toBuffer()),t.writeUInt32LE(this.nSequence),t}fromPubKeyHashTxOut(t,e,r,i){const s=new z;if(!r.script.isPubKeyHashOut())throw new Error("txOut must be of type pubKeyHash");return s.writeOpCode(T.OP_0),i?s.writeBuffer(i.toBuffer()):s.writeOpCode(T.OP_0),this.txHashBuf=t,this.txOutNum=e,this.setScript(s),this}hasNullInput(){return"0000000000000000000000000000000000000000000000000000000000000000"===this.txHashBuf.toString("hex")&&4294967295===this.txOutNum}setNullInput(){this.txHashBuf=Buffer.alloc(32),this.txHashBuf.fill(0),this.txOutNum=4294967295}}st.LOCKTIME_VERIFY_SEQUENCE=1,st.SEQUENCE_FINAL=4294967295,st.SEQUENCE_LOCKTIME_DISABLE_FLAG=1<<31,st.SEQUENCE_LOCKTIME_TYPE_FLAG=1<<22,st.SEQUENCE_LOCKTIME_MASK=65535,st.SEQUENCE_LOCKTIME_GRANULARITY=9;class nt extends w{constructor(t,e,r){super({valueBn:t,scriptVi:e,script:r})}setScript(t){return this.scriptVi=it.fromNumber(t.toBuffer().length),this.script=t,this}fromProperties(t,e){return this.fromObject({valueBn:t}),this.setScript(e),this}static fromProperties(t,e){return(new this).fromProperties(t,e)}fromJSON(t){return this.fromObject({valueBn:(new p).fromJSON(t.valueBn),scriptVi:(new it).fromJSON(t.scriptVi),script:(new z).fromJSON(t.script)}),this}toJSON(){return{valueBn:this.valueBn.toJSON(),scriptVi:this.scriptVi.toJSON(),script:this.script.toJSON()}}fromBr(t){return this.valueBn=t.readUInt64LEBn(),this.scriptVi=it.fromNumber(t.readVarIntNum()),this.script=(new z).fromBuffer(t.read(this.scriptVi.toNumber())),this}toBw(t){return t||(t=new y),t.writeUInt64LEBn(this.valueBn),t.write(this.scriptVi.buf),t.write(this.script.toBuffer()),t}}class at extends w{constructor(t=1,e=it.fromNumber(0),r=[],i=it.fromNumber(0),s=[],n=0){super({versionBytesNum:t,txInsVi:e,txIns:r,txOutsVi:i,txOuts:s,nLockTime:n})}fromJSON(t){const e=[];t.txIns.forEach((function(t){e.push((new st).fromJSON(t))}));const r=[];return t.txOuts.forEach((function(t){r.push((new nt).fromJSON(t))})),this.fromObject({versionBytesNum:t.versionBytesNum,txInsVi:(new it).fromJSON(t.txInsVi),txIns:e,txOutsVi:(new it).fromJSON(t.txOutsVi),txOuts:r,nLockTime:t.nLockTime}),this}toJSON(){const t=[];this.txIns.forEach((function(e){t.push(e.toJSON())}));const e=[];return this.txOuts.forEach((function(t){e.push(t.toJSON())})),{versionBytesNum:this.versionBytesNum,txInsVi:this.txInsVi.toJSON(),txIns:t,txOutsVi:this.txOutsVi.toJSON(),txOuts:e,nLockTime:this.nLockTime}}fromBr(t){this.versionBytesNum=t.readUInt32LE(),this.txInsVi=new it(t.readVarIntBuf());const e=this.txInsVi.toNumber();this.txIns=[];for(let r=0;r<e;r++)this.txIns.push((new st).fromBr(t));this.txOutsVi=new it(t.readVarIntBuf());const r=this.txOutsVi.toNumber();this.txOuts=[];for(let e=0;e<r;e++)this.txOuts.push((new nt).fromBr(t));return this.nLockTime=t.readUInt32LE(),this}toBw(t){t||(t=new y),t.writeUInt32LE(this.versionBytesNum),t.write(this.txInsVi.buf);for(let e=0;e<this.txIns.length;e++)this.txIns[e].toBw(t);t.write(this.txOutsVi.buf);for(let e=0;e<this.txOuts.length;e++)this.txOuts[e].toBw(t);return t.writeUInt32LE(this.nLockTime),t}hashPrevouts(){const t=new y;for(const e in this.txIns){const r=this.txIns[e];t.write(r.txHashBuf),t.writeUInt32LE(r.txOutNum)}return E.sha256Sha256(t.toBuffer())}hashSequence(){const t=new y;for(const e in this.txIns){const r=this.txIns[e];t.writeUInt32LE(r.nSequence)}return E.sha256Sha256(t.toBuffer())}hashOutputs(){const t=new y;for(const e in this.txOuts){const r=this.txOuts[e];t.write(r.toBuffer())}return E.sha256Sha256(t.toBuffer())}sighash(t,e,r,i,s=0,n=new rt){const a=this.sighashPreimage(t,e,r,i,s,n);return 0===a.compare(Buffer.from("0000000000000000000000000000000000000000000000000000000000000001","hex"))?a:new g(E.sha256Sha256(a)).readReverse()}async asyncSighash(t,e,r,i,s=0,n={}){return(await B.asyncObjectMethod(this,"sighash",[t,e,r,i,s,n])).resbuf}sighashPreimage(t,e,r,i,s=0,n=new rt){if(t&j.SIGHASH_FORKID&&s&at.SCRIPT_ENABLE_SIGHASH_FORKID){let s=Buffer.alloc(32,0),a=Buffer.alloc(32,0),o=Buffer.alloc(32,0);t&j.SIGHASH_ANYONECANPAY||(s=n.prevoutsHashBuf?n.prevoutsHashBuf:n.prevoutsHashBuf=this.hashPrevouts()),t&j.SIGHASH_ANYONECANPAY||(31&t)===j.SIGHASH_SINGLE||(31&t)===j.SIGHASH_NONE||(a=n.sequenceHashBuf?n.sequenceHashBuf:n.sequenceHashBuf=this.hashSequence()),(31&t)!==j.SIGHASH_SINGLE&&(31&t)!==j.SIGHASH_NONE?o=n.outputsHashBuf?n.outputsHashBuf:n.outputsHashBuf=this.hashOutputs():(31&t)===j.SIGHASH_SINGLE&&e<this.txOuts.length&&(o=E.sha256Sha256(this.txOuts[e].toBuffer()));const c=new y;return c.writeUInt32LE(this.versionBytesNum),c.write(s),c.write(a),c.write(this.txIns[e].txHashBuf),c.writeUInt32LE(this.txIns[e].txOutNum),c.writeVarIntNum(r.toBuffer().length),c.write(r.toBuffer()),c.writeUInt64LEBn(i),c.writeUInt32LE(this.txIns[e].nSequence),c.write(o),c.writeUInt32LE(this.nLockTime),c.writeUInt32LE(t>>>0),c.toBuffer()}const a=this.cloneByBuffer();(r=(new z).fromBuffer(r.toBuffer())).removeCodeseparators();for(let t=0;t<a.txIns.length;t++)a.txIns[t]=st.fromBuffer(a.txIns[t].toBuffer()).setScript(new z);if(a.txIns[e]=st.fromBuffer(a.txIns[e].toBuffer()).setScript(r),(31&t)===j.SIGHASH_NONE){a.txOuts.length=0,a.txOutsVi=it.fromNumber(0);for(let t=0;t<a.txIns.length;t++)t!==e&&(a.txIns[t].nSequence=0)}else if((31&t)===j.SIGHASH_SINGLE){if(e>a.txOuts.length-1)return Buffer.from("0000000000000000000000000000000000000000000000000000000000000001","hex");a.txOuts.length=e+1,a.txOutsVi=it.fromNumber(e+1);for(let t=0;t<a.txOuts.length;t++)t<e&&(a.txOuts[t]=nt.fromProperties((new p).fromBuffer(Buffer.from("ffffffffffffffff","hex")),new z));for(let t=0;t<a.txIns.length;t++)t!==e&&(a.txIns[t].nSequence=0)}return t&j.SIGHASH_ANYONECANPAY&&(a.txIns[0]=a.txIns[e],a.txIns.length=1,a.txInsVi=it.fromNumber(1)),(new y).write(a.toBuffer()).writeInt32LE(t).toBuffer()}async asyncSighashPreimage(t,e,r,i,s=0,n={}){return(await B.asyncObjectMethod(this,"sighashPreimage",[t,e,r,i,s,n])).resbuf}sign(t,e=j.SIGHASH_ALL|j.SIGHASH_FORKID,r,i,s,n=at.SCRIPT_ENABLE_SIGHASH_FORKID,a={}){const o=this.sighash(e,r,i,s,n,a);return Z.sign(o,t,"little").fromObject({nHashType:e})}async asyncSign(t,e=j.SIGHASH_ALL|j.SIGHASH_FORKID,r,i,s,n=at.SCRIPT_ENABLE_SIGHASH_FORKID,a={}){const o=await B.asyncObjectMethod(this,"sign",[t,e,r,i,s,n,a]);return(new j).fromFastBuffer(o.resbuf)}verify(t,e,r,i,s=!1,n,a=at.SCRIPT_ENABLE_SIGHASH_FORKID,o={}){const c=this.sighash(t.nHashType,r,i,n,a,o);return Z.verify(c,t,e,"little",s)}async asyncVerify(t,e,r,i,s=!1,n,a=at.SCRIPT_ENABLE_SIGHASH_FORKID,o={}){const c=await B.asyncObjectMethod(this,"verify",[t,e,r,i,s,n,a,o]);return JSON.parse(c.resbuf.toString())}hash(){return E.sha256Sha256(this.toBuffer())}async asyncHash(){return(await B.asyncObjectMethod(this,"hash",[])).resbuf}id(){return new g(this.hash()).readReverse().toString("hex")}async asyncId(){const t=await B.asyncObjectMethod(this,"id",[]);return JSON.parse(t.resbuf.toString())}addTxIn(t,e,r,i){let s;return s=t instanceof st?t:(new st).fromObject({txHashBuf:t,txOutNum:e,nSequence:i}).setScript(r),this.txIns.push(s),this.txInsVi=it.fromNumber(this.txInsVi.toNumber()+1),this}addTxOut(t,e){let r;return r=t instanceof nt?t:(new nt).fromObject({valueBn:t}).setScript(e),this.txOuts.push(r),this.txOutsVi=it.fromNumber(this.txOutsVi.toNumber()+1),this}isCoinbase(){return 1===this.txIns.length&&this.txIns[0].hasNullInput()}sort(){return this.txIns.sort(((t,e)=>new g(t.txHashBuf).readReverse().compare(new g(e.txHashBuf).readReverse())||t.txOutNum-e.txOutNum)),this.txOuts.sort(((t,e)=>t.valueBn.sub(e.valueBn).toNumber()||t.script.toBuffer().compare(e.script.toBuffer()))),this}}at.MAX_MONEY=21e14,at.SCRIPT_ENABLE_SIGHASH_FORKID=65536;class ot extends w{constructor(t,e,r){super({blockHeader:t,txsVi:e,txs:r})}fromJSON(t){const e=[];return t.txs.forEach((function(t){e.push((new at).fromJSON(t))})),this.fromObject({blockHeader:(new tt).fromJSON(t.blockHeader),txsVi:(new it).fromJSON(t.txsVi),txs:e}),this}toJSON(){const t=[];return this.txs.forEach((function(e){t.push(e.toJSON())})),{blockHeader:this.blockHeader.toJSON(),txsVi:this.txsVi.toJSON(),txs:t}}fromBr(t){this.blockHeader=(new tt).fromBr(t),this.txsVi=new it(t.readVarIntBuf());const e=this.txsVi.toNumber();this.txs=[];for(let r=0;r<e;r++)this.txs.push((new at).fromBr(t));return this}toBw(t){t||(t=new y),t.write(this.blockHeader.toBuffer()),t.write(this.txsVi.buf);const e=this.txsVi.toNumber();for(let r=0;r<e;r++)this.txs[r].toBw(t);return t}hash(){return E.sha256Sha256(this.blockHeader.toBuffer())}async asyncHash(){return(await B.asyncObjectMethod(this,"hash",[])).resbuf}id(){return new g(this.hash()).readReverse().toString("hex")}async asyncId(){const t=await B.asyncObjectMethod(this,"id",[]);return JSON.parse(t.resbuf.toString())}verifyMerkleRoot(){const t=this.txs.map((t=>t.toBuffer())),e=et.fromBuffers(t).hash();return Buffer.compare(e,this.blockHeader.merkleRootBuf)}static iterateTxs(t){const e=new g(t),r=(new tt).fromBr(e),i=new it(e.readVarIntBuf()),s=i.toNumber();return{blockHeader:r,txsVi:i,txsNum:s,*[Symbol.iterator](){for(let t=0;t<s;t++)yield(new at).fromBr(e)}}}}ot.MAX_BLOCK_SIZE=1e6;class ct extends w{constructor(t,e,r,i=[],s=[],n=0,a=0,o=0,c=[],h="",f=ct.defaultFlags,u=new p(0)){super({script:t,tx:e,nIn:r,stack:i,altStack:s,pc:n,pBeginCodeHash:a,nOpCount:o,ifStack:c,errStr:h,flags:f,valueBn:u})}initialize(){return this.script=new z,this.stack=[],this.altStack=[],this.pc=0,this.pBeginCodeHash=0,this.nOpCount=0,this.ifStack=[],this.errStr="",this.flags=ct.defaultFlags,this.scriptLimit=1e7,this.stackLimit=1e7,this}fromJSON(t){return this.fromJSONNoTx(t),this.tx=t.tx?(new at).fromJSON(t.tx):void 0,this}fromJSONNoTx(t){return this.fromObject({script:void 0!==t.script?(new z).fromJSON(t.script):void 0,nIn:t.nIn}),this.stack=[],t.stack.forEach(function(t){this.stack.push(Buffer.from(t,"hex"))}.bind(this)),this.altStack=[],t.altStack.forEach(function(t){this.altStack.push(Buffer.from(t,"hex"))}.bind(this)),this.fromObject({pc:t.pc,pBeginCodeHash:t.pBeginCodeHash,nOpCount:t.nOpCount,ifStack:t.ifStack,errStr:t.errStr,flags:t.flags}),this}fromBr(t){let e=t.readVarIntNum(),r=t.read(e);this.fromJSONNoTx(JSON.parse(r.toString()));let i=t.readVarIntNum();if(i>0){let e=t.read(i);this.tx=(new at).fromFastBuffer(e)}return this}toJSON(){let t=this.toJSONNoTx();return t.tx=this.tx?this.tx.toJSON():void 0,t}toJSONNoTx(){let t=[];this.stack.forEach((function(e){t.push(e.toString("hex"))}));let e=[];return this.altStack.forEach((function(t){e.push(t.toString("hex"))})),{script:this.script?this.script.toJSON():void 0,nIn:this.nIn,stack:t,altStack:e,pc:this.pc,pBeginCodeHash:this.pBeginCodeHash,nOpCount:this.nOpCount,ifStack:this.ifStack,errStr:this.errStr,flags:this.flags}}toBw(t){t||(t=new y);let e=Buffer.from(JSON.stringify(this.toJSONNoTx()));if(t.writeVarIntNum(e.length),t.write(e),this.tx){let e=this.tx.toFastBuffer();t.writeVarIntNum(e.length),t.write(e)}else t.writeVarIntNum(0);return t}static getFlags(t){let e=0;return-1!==t.indexOf("NONE")&&(e|=ct.SCRIPT_VERIFY_NONE),-1!==t.indexOf("P2SH")&&(e|=ct.SCRIPT_VERIFY_P2SH),-1!==t.indexOf("STRICTENC")&&(e|=ct.SCRIPT_VERIFY_STRICTENC),-1!==t.indexOf("DERSIG")&&(e|=ct.SCRIPT_VERIFY_DERSIG),-1!==t.indexOf("LOW_S")&&(e|=ct.SCRIPT_VERIFY_LOW_S),-1!==t.indexOf("NULLDUMMY")&&(e|=ct.SCRIPT_VERIFY_NULLDUMMY),-1!==t.indexOf("SIGPUSHONLY")&&(e|=ct.SCRIPT_VERIFY_SIGPUSHONLY),-1!==t.indexOf("MINIMALDATA")&&(e|=ct.SCRIPT_VERIFY_MINIMALDATA),-1!==t.indexOf("DISCOURAGE_UPGRADABLE_NOPS")&&(e|=ct.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS),-1!==t.indexOf("CLEANSTACK")&&(e|=ct.SCRIPT_VERIFY_CLEANSTACK),-1!==t.indexOf("CHECKLOCKTIMEVERIFY")&&(e|=ct.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY),-1!==t.indexOf("CHECKSEQUENCEVERIFY")&&(e|=ct.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY),-1!==t.indexOf("SIGHASH_FORKID")&&(e|=ct.SCRIPT_ENABLE_SIGHASH_FORKID),e}static castToBool(t){for(let e=0;e<t.length;e++)if(0!==t[e])return e!==t.length-1||128!==t[e];return!1}checkSigEncoding(t){if(0===t.length)return!0;if(0!=(this.flags&(ct.SCRIPT_VERIFY_DERSIG|ct.SCRIPT_VERIFY_LOW_S|ct.SCRIPT_VERIFY_STRICTENC))&&!j.IsTxDer(t))return this.errStr="SCRIPT_ERR_SIG_DER",!1;if(0!=(this.flags&ct.SCRIPT_VERIFY_LOW_S)){if(!(new j).fromTxFormat(t).hasLowS())return this.errStr="SCRIPT_ERR_SIG_DER",!1}else if(0!=(this.flags&ct.SCRIPT_VERIFY_STRICTENC)&&!(new j).fromTxFormat(t).hasDefinedHashType())return this.errStr="SCRIPT_ERR_SIG_HASHTYPE",!1;return!0}checkPubKeyEncoding(t){return!(0!=(this.flags&ct.SCRIPT_VERIFY_STRICTENC)&&!F.isCompressedOrUncompressed(t)&&(this.errStr="SCRIPT_ERR_PUBKEYTYPE",1))}checkLockTime(t){return(this.tx.nLockTime<ct.LOCKTIME_THRESHOLD&&t<ct.LOCKTIME_THRESHOLD||this.tx.nLockTime>=ct.LOCKTIME_THRESHOLD&&t>=ct.LOCKTIME_THRESHOLD)&&!(t>this.tx.nLockTime)&&st.SEQUENCE_FINAL!==this.tx.txIns[this.nIn].nSequence}checkSequence(t){let e=this.tx.txIns[this.nIn].nSequence;if(this.tx.versionBytesNum<2)return!1;if(e&st.SEQUENCE_LOCKTIME_DISABLE_FLAG)return!1;let r=st.SEQUENCE_LOCKTIME_TYPE_FLAG|st.SEQUENCE_LOCKTIME_MASK,i=e&r,s=t&r;return(i<st.SEQUENCE_LOCKTIME_TYPE_FLAG&&s<st.SEQUENCE_LOCKTIME_TYPE_FLAG||i>=st.SEQUENCE_LOCKTIME_TYPE_FLAG&&s>=st.SEQUENCE_LOCKTIME_TYPE_FLAG)&&!(s>i)}*eval(){this.script.toBuffer().length>this.scriptLimit&&(this.errStr="SCRIPT_ERR_SCRIPT_SIZE",yield!1);try{for(;this.pc<this.script.chunks.length;){let t=this.step();t?yield t:yield!1}this.stack.length+this.altStack.length>this.stackLimit&&(this.errStr="SCRIPT_ERR_STACK_SIZE",yield!1)}catch(t){this.errStr="SCRIPT_ERR_UNKNOWN_ERROR: "+t,yield!1}this.ifStack.length>0&&(this.errStr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",yield!1),yield!0}step(){let t=0!=(this.flags&ct.SCRIPT_VERIFY_MINIMALDATA),e=!(this.ifStack.indexOf(!1)+1),r=this.script.chunks[this.pc];this.pc++;let i=r.opCodeNum;if(void 0===i)return this.errStr="SCRIPT_ERR_BAD_OPCODE",!1;if(i>T.OP_16&&++this.nOpCount>201)return this.errStr="SCRIPT_ERR_OP_COUNT",!1;if(i===T.OP_LEFT||i===T.OP_RIGHT||i===T.OP_2MUL||i===T.OP_2DIV)return this.errStr="SCRIPT_ERR_DISABLED_OPCODE",!1;if(e&&i>=0&&i<=T.OP_PUSHDATA4){if(t&&!this.script.checkMinimalPush(this.pc-1))return this.errStr="SCRIPT_ERR_MINIMALDATA",!1;if(r.buf){if(r.len!==r.buf.length)throw new Error("LEngth of push value not equal to length of data");this.stack.push(r.buf)}else this.stack.push(ct.false)}else if(e||T.OP_IF<=i&&i<=T.OP_ENDIF)switch(i){case T.OP_1NEGATE:case T.OP_1:case T.OP_2:case T.OP_3:case T.OP_4:case T.OP_5:case T.OP_6:case T.OP_7:case T.OP_8:case T.OP_9:case T.OP_10:case T.OP_11:case T.OP_12:case T.OP_13:case T.OP_14:case T.OP_15:case T.OP_16:{let t=new p(i-(T.OP_1-1)).toScriptNumBuffer();this.stack.push(t)}break;case T.OP_NOP:break;case T.OP_CHECKLOCKTIMEVERIFY:{if(!(this.flags&ct.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY)){if(this.flags&ct.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 e=this.stack[this.stack.length-1],r=(new p).fromScriptNumBuffer(e,t,5).toNumber();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 T.OP_CHECKSEQUENCEVERIFY:{if(!(this.flags&ct.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY)){if(this.flags&ct.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 e=this.stack[this.stack.length-1],r=(new p).fromScriptNumBuffer(e,t,5).toNumber();if(r<0)return this.errStr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if(0!=(r&st.SEQUENCE_LOCKTIME_DISABLE_FLAG))break;if(!this.checkSequence(r))return this.errStr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1}break;case T.OP_NOP1:case T.OP_NOP3:case T.OP_NOP4:case T.OP_NOP5:case T.OP_NOP6:case T.OP_NOP7:case T.OP_NOP8:case T.OP_NOP9:case T.OP_NOP10:if(this.flags&ct.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errStr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break;case T.OP_IF:case T.OP_NOTIF:{let t=!1;if(e){if(this.stack.length<1)return this.errStr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;let e=this.stack.pop();t=ct.castToBool(e),i===T.OP_NOTIF&&(t=!t)}this.ifStack.push(t)}break;case T.OP_ELSE:if(0===this.ifStack.length)return this.errStr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.ifStack[this.ifStack.length-1]=!this.ifStack[this.ifStack.length-1];break;case T.OP_ENDIF:if(0===this.ifStack.length)return this.errStr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.ifStack.pop();break;case T.OP_VERIFY:{if(this.stack.length<1)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;let t=this.stack[this.stack.length-1];if(!ct.castToBool(t))return this.errStr="SCRIPT_ERR_VERIFY",!1;this.stack.pop()}break;case T.OP_RETURN:return this.errStr="SCRIPT_ERR_OP_RETURN",!1;case T.OP_TOALTSTACK:if(this.stack.length<1)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.altStack.push(this.stack.pop());break;case T.OP_FROMALTSTACK:if(this.altStack.length<1)return this.errStr="SCRIPT_ERR_INVALID_ALTSTACK_OPERATION",!1;this.stack.push(this.altStack.pop());break;case T.OP_2DROP:if(this.stack.length<2)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop(),this.stack.pop();break;case T.OP_2DUP:{if(this.stack.length<2)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;let t=this.stack[this.stack.length-2],e=this.stack[this.stack.length-1];this.stack.push(t),this.stack.push(e)}break;case T.OP_3DUP:{if(this.stack.length<3)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;let t=this.stack[this.stack.length-3],e=this.stack[this.stack.length-2],r=this.stack[this.stack.length-1];this.stack.push(t),this.stack.push(e),this.stack.push(r)}break;case T.OP_2OVER:{if(this.stack.length<4)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;let t=this.stack[this.stack.length-4],e=this.stack[this.stack.length-3];this.stack.push(t),this.stack.push(e)}break;case T.OP_2ROT:{if(this.stack.length<6)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;let t=this.stack.splice(this.stack.length-6,2);this.stack.push(t[0]),this.stack.push(t[1])}break;case T.OP_2SWAP:{if(this.stack.length<4)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;let t=this.stack.splice(this.stack.length-4,2);this.stack.push(t[0]),this.stack.push(t[1])}break;case T.OP_IFDUP:{if(this.stack.length<1)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;let t=this.stack[this.stack.length-1];ct.castToBool(t)&&this.stack.push(t)}break;case T.OP_DEPTH:{let t=new p(this.stack.length).toScriptNumBuffer();this.stack.push(t)}break;case T.OP_DROP:if(this.stack.length<1)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop();break;case T.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 T.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 T.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 T.OP_PICK:case T.OP_ROLL:{if(this.stack.length<2)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;let e=this.stack[this.stack.length-1],r=(new p).fromScriptNumBuffer(e,t,ct.DEFAULT_SCRIPT_NUM_LENGTH_POLICY_AFTER_GENESIS).toNumber();if(this.stack.pop(),r<0||r>=this.stack.length)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;e=this.stack[this.stack.length-r-1],i===T.OP_ROLL&&this.stack.splice(this.stack.length-r-1,1),this.stack.push(e)}break;case T.OP_ROT:{if(this.stack.length<3)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;let t=this.stack[this.stack.length-3],e=this.stack[this.stack.length-2],r=this.stack[this.stack.length-1];this.stack[this.stack.length-3]=e,this.stack[this.stack.length-2]=r,this.stack[this.stack.length-1]=t}break;case T.OP_SWAP:{if(this.stack.length<2)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;let t=this.stack[this.stack.length-2],e=this.stack[this.stack.length-1];this.stack[this.stack.length-2]=e,this.stack[this.stack.length-1]=t}break;case T.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 T.OP_SIZE:{if(this.stack.length<1)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;let t=new p(this.stack[this.stack.length-1].length);this.stack.push(t.toScriptNumBuffer())}break;case T.OP_OR:case T.OP_AND:case T.OP_XOR:if(this.stack.length<2)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;let 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(i){case T.OP_AND:for(let t=0;t<r.length;t++)r[t]&=s[t];break;case T.OP_OR:for(let t=0;t<r.length;t++)r[t]|=s[t];break;case T.OP_XOR:for(let t=0;t<r.length;t++)r[t]^=s[t]}this.stack.pop();break;case T.OP_INVERT:if(this.stack.length<1)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;let n=this.stack[this.stack.length-1];for(let t=0;t<n.length;t++)n[t]=~n[t];break;case T.OP_LSHIFT:case T.OP_RSHIFT:{if(this.stack.length<2)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;let e=this.stack[this.stack.length-2],r=new p(e),s=(new p).fromScriptNumBuffer(this.stack[this.stack.length-1],t,ct.DEFAULT_SCRIPT_NUM_LENGTH_POLICY_AFTER_GENESIS).toNumber();if(s<0)return this.errStr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;switch(this.stack.pop(),this.stack.pop(),i){case T.OP_LSHIFT:r=r.ushln(s);break;case T.OP_RSHIFT:r=r.ushrn(s)}let n=r.toBuffer().slice(-e.length);n.length<e.length&&(n=Buffer.concat([Buffer.alloc(e.length-n.length),n])),this.stack.push(n);break}case T.OP_EQUAL:case T.OP_EQUALVERIFY:{if(this.stack.length<2)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;let t=this.stack[this.stack.length-2],e=this.stack[this.stack.length-1],r=_(t,e);if(this.stack.pop(),this.stack.pop(),this.stack.push(r?ct.true:ct.false),i===T.OP_EQUALVERIFY){if(!r)return this.errStr="SCRIPT_ERR_EQUALVERIFY",!1;this.stack.pop()}}break;case T.OP_1ADD:case T.OP_1SUB:case T.OP_NEGATE:case T.OP_ABS:case T.OP_NOT:case T.OP_0NOTEQUAL:{if(this.stack.length<1)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;let e=this.stack[this.stack.length-1],r=(new p).fromScriptNumBuffer(e,t,ct.DEFAULT_SCRIPT_NUM_LENGTH_POLICY_AFTER_GENESIS);switch(i){case T.OP_1ADD:r=r.add(1);break;case T.OP_1SUB:r=r.sub(1);break;case T.OP_NEGATE:r=r.neg();break;case T.OP_ABS:r.lt(0)&&(r=r.neg());break;case T.OP_NOT:r=new p(r.eq(0)+0);break;case T.OP_0NOTEQUAL:r=new p(r.neq(0)+0)}this.stack.pop(),this.stack.push(r.toScriptNumBuffer())}break;case T.OP_ADD:case T.OP_SUB:case T.OP_MUL:case T.OP_DIV:case T.OP_MOD:case T.OP_BOOLAND:case T.OP_BOOLOR:case T.OP_NUMEQUAL:case T.OP_NUMEQUALVERIFY:case T.OP_NUMNOTEQUAL:case T.OP_LESSTHAN:case T.OP_GREATERTHAN:case T.OP_LESSTHANOREQUAL:case T.OP_GREATERTHANOREQUAL:case T.OP_MIN:case T.OP_MAX:{if(this.stack.length<2)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;let e=(new p).fromScriptNumBuffer(this.stack[this.stack.length-2],t,ct.DEFAULT_SCRIPT_NUM_LENGTH_POLICY_AFTER_GENESIS),r=(new p).fromScriptNumBuffer(this.stack[this.stack.length-1],t,ct.DEFAULT_SCRIPT_NUM_LENGTH_POLICY_AFTER_GENESIS),s=new p(0);switch(i){case T.OP_ADD:s=e.add(r);break;case T.OP_SUB:s=e.sub(r);break;case T.OP_MUL:s=e.mul(r);break;case T.OP_DIV:if(0==r)return this.errStr="SCRIPT_ERR_DIV_BY_ZERO",!1;s=e.div(r);break;case T.OP_MOD:if(0==r)return this.errStr="SCRIPT_ERR_DIV_BY_ZERO",!1;s=e.mod(r);break;case T.OP_BOOLAND:s=new p((e.neq(0)&&r.neq(0))+0);break;case T.OP_BOOLOR:s=new p((e.neq(0)||r.neq(0))+0);break;case T.OP_NUMEQUAL:case T.OP_NUMEQUALVERIFY:s=new p(e.eq(r)+0);break;case T.OP_NUMNOTEQUAL:s=new p(e.neq(r)+0);break;case T.OP_LESSTHAN:s=new p(e.lt(r)+0);break;case T.OP_GREATERTHAN:s=new p(e.gt(r)+0);break;case T.OP_LESSTHANOREQUAL:s=new p(e.leq(r)+0);break;case T.OP_GREATERTHANOREQUAL:s=new p(e.geq(r)+0);break;case T.OP_MIN:s=e.lt(r)?e:r;break;case T.OP_MAX:s=e.gt(r)?e:r}if(this.stack.pop(),this.stack.pop(),this.stack.push(s.toScriptNumBuffer()),i===T.OP_NUMEQUALVERIFY){if(!ct.castToBool(this.stack[this.stack.length-1]))return this.errStr="SCRIPT_ERR_NUMEQUALVERIFY",!1;this.stack.pop()}}break;case T.OP_WITHIN:{if(this.stack.length<3)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;let e=(new p).fromScriptNumBuffer(this.stack[this.stack.length-3],t,ct.DEFAULT_SCRIPT_NUM_LENGTH_POLICY_AFTER_GENESIS),r=(new p).fromScriptNumBuffer(this.stack[this.stack.length-2],t,ct.DEFAULT_SCRIPT_NUM_LENGTH_POLICY_AFTER_GENESIS),i=(new p).fromScriptNumBuffer(this.stack[this.stack.length-1],t,ct.DEFAULT_SCRIPT_NUM_LENGTH_POLICY_AFTER_GENESIS),s=r.leq(e)&&e.lt(i);this.stack.pop(),this.stack.pop(),this.stack.pop(),this.stack.push(s?ct.true:ct.false)}break;case T.OP_RIPEMD160:case T.OP_SHA1:case T.OP_SHA256:case T.OP_HASH160:case T.OP_HASH256:{if(this.stack.length<1)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;let t,e=this.stack[this.stack.length-1];i===T.OP_RIPEMD160?t=E.ripemd160(e):i===T.OP_SHA1?t=E.sha1(e):i===T.OP_SHA256?t=E.sha256(e):i===T.OP_HASH160?t=E.sha256Ripemd160(e):i===T.OP_HASH256&&(t=E.sha256Sha256(e)),this.stack.pop(),this.stack.push(t)}break;case T.OP_CODESEPARATOR:this.pBeginCodeHash=this.pc;break;case T.OP_CHECKSIG:case T.OP_CHECKSIGVERIFY:{if(this.stack.length<2)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;let t,e=this.stack[this.stack.length-2],r=this.stack[this.stack.length-1],s=(new z).fromObject({chunks:this.script.chunks.slice(this.pBeginCodeHash)});if((e.length>0?e.readUInt8(e.length-1):0)&j.SIGHASH_FORKID){if(!(this.flags&ct.SCRIPT_ENABLE_SIGHASH_FORKID))return this.errStr="SCRIPT_ERR_ILLEGAL_FORKID",!1}else s.findAndDelete((new z).writeBuffer(e));if(!this.checkSigEncoding(e)||!this.checkPubKeyEncoding(r))return!1;try{let i=(new j).fromTxFormat(e),n=(new F).fromBuffer(r,!1);t=this.tx.verify(i,n,this.nIn,s,Boolean(this.flags&ct.SCRIPT_VERIFY_LOW_S),this.valueBn,this.flags)}catch(e){t=!1}if(this.stack.pop(),this.stack.pop(),this.stack.push(t?ct.true:ct.false),i===T.OP_CHECKSIGVERIFY){if(!t)return this.errStr="SCRIPT_ERR_CHECKSIGVERIFY",!1;this.stack.pop()}}break;case T.OP_CHECKMULTISIG:case T.OP_CHECKMULTISIGVERIFY:{let e=1;if(this.stack.length<e)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;let r=(new p).fromScriptNumBuffer(this.stack[this.stack.length-e],t).toNumber();if(r<0||r>20)return this.errStr="SCRIPT_ERR_PUBKEY_COUNT",!1;if(this.nOpCount+=r,this.nOpCount>201)return this.errStr="SCRIPT_ERR_OP_COUNT",!1;let s=++e;if(e+=r,this.stack.length<e)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;let n=(new p).fromScriptNumBuffer(this.stack[this.stack.length-e],t).toNumber();if(n<0||n>r)return this.errStr="SCRIPT_ERR_SIG_COUNT",!1;let a=++e;if(e+=n,this.stack.length<e)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;let o=(new z).fromObject({chunks:this.script.chunks.slice(this.pBeginCodeHash)});for(let t=0;t<n;t++){let e=this.stack[this.stack.length-a-t];if((e.length>0?e.readUInt8(e.length-1):0)&j.SIGHASH_FORKID){if(!(this.flags&ct.SCRIPT_ENABLE_SIGHASH_FORKID))return this.errStr="SCRIPT_ERR_ILLEGAL_FORKID",!1}else o.findAndDelete((new z).writeBuffer(e))}let c=!0;for(;c&&n>0;){let t,e=this.stack[this.stack.length-a],i=this.stack[this.stack.length-s];if(!this.checkSigEncoding(e)||!this.checkPubKeyEncoding(i))return!1;try{let r=(new j).fromTxFormat(e),s=(new F).fromBuffer(i,!1);t=this.tx.verify(r,s,this.nIn,o,Boolean(this.flags&ct.SCRIPT_VERIFY_LOW_S),this.valueBn,this.flags)}catch(e){t=!1}t&&(a++,n--),s++,r--,n>r&&(c=!1)}for(;e-- >1;)this.stack.pop();if(this.stack.length<1)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(this.flags&ct.SCRIPT_VERIFY_NULLDUMMY&&this.stack[this.stack.length-1].length)return this.errStr="SCRIPT_ERR_SIG_NULLDUMMY",!1;if(this.stack.pop(),this.stack.push(c?ct.true:ct.false),i===T.OP_CHECKMULTISIGVERIFY){if(!c)return this.errStr="SCRIPT_ERR_CHECKMULTISIGVERIFY",!1;this.stack.pop()}}break;case T.OP_CAT:if(this.stack.length<2)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;let a=this.stack[this.stack.length-2],o=this.stack[this.stack.length-1];this.stack[this.stack.length-2]=Buffer.concat([a,o]),this.stack.pop();break;case T.OP_SPLIT:if(this.stack.length<2)return this.errStr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;let c=this.stack[this.stack.length-2],h=(new p).fromScriptNumBuffer(this.stack[this.stack.length-1],t);if(h.lt(0)||h.gt(c.length))return this.errStr="SCRIPT_ERR_INVALID_SPLIT_RANGE",!1;let f=c.slice(0,h),u=c.slice(h);this.stack.pop(),this.stack.pop(),this.stack.push(f),this.stack.push(u);break;default:return this.errStr="SCRIPT_ERR_BAD_OPCODE",!1}return!0}verify(t,e,r,i,s,n){let a=this.results(t,e,r,i,s,n);for(let t of a)if(!t)return!1;return!0}*results(t,e,r,i,s,n){let a;this.fromObject({script:t,tx:r,nIn:i,flags:s,valueBn:n}),0==(s&ct.SCRIPT_VERIFY_SIGPUSHONLY)||t.isPushOnly()||(this.errStr=this.errStr||"SCRIPT_ERR_SIG_PUSHONLY",yield!1),yield*this.eval(),s&ct.SCRIPT_VERIFY_P2SH&&(a=this.stack.slice());let o=this.stack;this.initialize(),this.fromObject({script:e,stack:o,tx:r,nIn:i,flags:s,valueBn:n}),yield*this.eval(),0===this.stack.length&&(this.errStr=this.errStr||"SCRIPT_ERR_EVAL_FALSE",yield!1);let c=this.stack[this.stack.length-1];if(ct.castToBool(c)||(this.errStr=this.errStr||"SCRIPT_ERR_EVAL_FALSE",yield!1),s&ct.SCRIPT_VERIFY_P2SH&&e.isScriptHashOut()){t.isPushOnly()||(this.errStr=this.errStr||"SCRIPT_ERR_SIG_PUSHONLY",yield!1);let e=o;if(o=a,a=e,0===o.length)throw new Error("internal error - stack copy empty");let c=o[o.length-1],h=(new z).fromBuffer(c);o.pop(),this.initialize(),this.fromObject({script:h,stack:o,tx:r,nIn:i,flags:s,valueBn:n}),yield*this.eval(),0===o.length&&(this.errStr=this.errStr||"SCRIPT_ERR_EVAL_FALSE",yield!1),ct.castToBool(o[o.length-1])?yield!0:(this.errStr=this.errStr||"SCRIPT_ERR_EVAL_FALSE",yield!1)}if(0!=(s&ct.SCRIPT_VERIFY_CLEANSTACK)){if(!(s&ct.SCRIPT_VERIFY_P2SH))throw new Error("cannot use CLEANSTACK without P2SH");1!==o.length&&(this.errStr=this.errStr||"SCRIPT_ERR_CLEANSTACK",yield!1)}yield!0}getDebugObject(){let t=this.pc-1;return{errStr:this.errStr,scriptStr:this.script?this.script.toString():"no script found",pc:t,stack:this.stack.map((t=>t.toString("hex"))),altStack:this.altStack.map((t=>t.toString("hex"))),opCodeStr:this.script?T.fromNumber(this.script.chunks[t].opCodeNum).toString():"no script found"}}getDebugString(){return JSON.stringify(this.getDebugObject(),null,2)}}ct.true=Buffer.from([1]),ct.false=Buffer.from([]),ct.DEFAULT_SCRIPT_NUM_LENGTH_POLICY_AFTER_GENESIS=1e4,ct.LOCKTIME_THRESHOLD=5e8,ct.SCRIPT_VERIFY_NONE=0,ct.SCRIPT_VERIFY_P2SH=1,ct.SCRIPT_VERIFY_STRICTENC=2,ct.SCRIPT_VERIFY_DERSIG=4,ct.SCRIPT_VERIFY_LOW_S=8,ct.SCRIPT_VERIFY_NULLDUMMY=16,ct.SCRIPT_VERIFY_SIGPUSHONLY=32,ct.SCRIPT_VERIFY_MINIMALDATA=64,ct.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS=128,ct.SCRIPT_VERIFY_CLEANSTACK=256,ct.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY=512,ct.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY=1024,ct.SCRIPT_ENABLE_SIGHASH_FORKID=65536,ct.defaultFlags=ct.SCRIPT_VERIFY_P2SH|ct.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY;class ht extends w{constructor(t=new Map){super({map:t})}toJSON(){const t={};return this.map.forEach(((e,r)=>{t[r]=e.map((t=>({nScriptChunk:t.nScriptChunk,type:t.type,addressStr:t.addressStr,nHashType:t.nHashType,log:t.log})))})),t}fromJSON(t){return Object.keys(t).forEach((e=>{this.map.set(e,t[e].map((t=>({nScriptChunk:t.nScriptChunk,type:t.type,addressStr:t.addressStr,nHashType:t.nHashType,log:t.log}))))})),this}setOne(t,e,r,i="sig",s,n=j.SIGHASH_ALL|j.SIGHASH_FORKID){const a=t.toString("hex")+":"+e,o={nScriptChunk:r,type:i,addressStr:s,nHashType:n};return this.map.set(a,[o]),this}setMany(t,e,r){const i=t.toString("hex")+":"+e;return r=r.map((t=>({type:t.type||"sig",nHashType:t.nHashType||j.SIGHASH_ALL|j.SIGHASH_FORKID,...t}))),this.map.set(i,r),this}addOne(t,e,r,i="sig",s,n=j.SIGHASH_ALL|j.SIGHASH_FORKID){const a=this.get(t,e)||[];return a.push({nScriptChunk:r,type:i,addressStr:s,nHashType:n}),this.setMany(t,e,a),this}get(t,e){const r=t.toString("hex")+":"+e;return this.map.get(r)||[]}}class ft extends w{constructor(t=new Map){super({map:t})}toJSON(){const t={};return this.map.forEach(((e,r)=>{t[r]=e.toHex()})),t}fromJSON(t){return Object.keys(t).forEach((e=>{this.map.set(e,nt.fromHex(t[e]))})),this}set(t,e,r){const i=t.toString("hex")+":"+e;return this.map.set(i,r),this}get(t,e){const r=t.toString("hex")+":"+e;return this.map.get(r)}setTx(t){const e=t.hash().toString("hex");return t.txOuts.forEach(((t,r)=>{const i=e+":"+r;this.map.set(i,t)})),this}}const ut=k.Default.TxBuilder;class dt extends w{constructor(t=new at,e=[],r=[],i=new ft,s=new ht,n,a,o,c=ut.feePerKbNum,h=0,f=1,u=1,d=ut.dust,l=!1,p=new rt){super({tx:t,txIns:e,txOuts:r,uTxOutMap:i,sigOperations:s,changeScript:n,changeAmountBn:a,feeAmountBn:o,feePerKbNum:c,nLockTime:h,versionBytesNum:f,sigsPerInput:u,dust:d,dustChangeToFees:l,hashCache:p})}toJSON(){const t={};return t.tx=this.tx.toHex(),t.txIns=this.txIns.map((t=>t.toHex())),t.txOuts=this.txOuts.map((t=>t.toHex())),t.uTxOutMap=this.uTxOutMap.toJSON(),t.sigOperations=this.sigOperations.toJSON(),t.changeScript=this.changeScript?this.changeScript.toHex():void 0,t.changeAmountBn=this.changeAmountBn?this.changeAmountBn.toNumber():void 0,t.feeAmountBn=this.feeAmountBn?this.feeAmountBn.toNumber():void 0,t.feePerKbNum=this.feePerKbNum,t.sigsPerInput=this.sigsPerInput,t.dust=this.dust,t.dustChangeToFees=this.dustChangeToFees,t.hashCache=this.hashCache.toJSON(),t}fromJSON(t){return this.tx=(new at).fromHex(t.tx),this.txIns=t.txIns.map((t=>st.fromHex(t))),this.txOuts=t.txOuts.map((t=>nt.fromHex(t))),this.uTxOutMap=(new ft).fromJSON(t.uTxOutMap),this.sigOperations=(new ht).fromJSON(t.sigOperations),this.changeScript=t.changeScript?(new z).fromHex(t.changeScript):void 0,this.changeAmountBn=t.changeAmountBn?new p(t.changeAmountBn):void 0,this.feeAmountBn=t.feeAmountBn?new p(t.feeAmountBn):void 0,this.feePerKbNum=t.feePerKbNum||this.feePerKbNum,this.sigsPerInput=t.sigsPerInput||this.sigsPerInput,this.dust=t.dust||this.dust,this.dustChangeToFees=t.dustChangeToFees||this.dustChangeToFees,this.hashCache=rt.fromJSON(t.hashCache),this}setFeePerKbNum(t){if("number"!=typeof t||t<0)throw new Error("cannot set a fee of zero or less");return this.feePerKbNum=t,this}setChangeAddress(t){return this.changeScript=t.toTxOutScript(),this}setChangeScript(t){return this.changeScript=t,this}setNLocktime(t){return this.nLockTime=t,this}setVersion(t){return this.versionBytesNum=t,this}setDust(t=ut.dust){return this.dust=t,this}sendDustChangeToFees(t=!1){return this.dustChangeToFees=t,this}importPartiallySignedTx(t,e=this.uTxOutMap,r=this.sigOperations){return this.tx=t,this.uTxOutMap=e,this.sigOperations=r,this}inputFromScript(t,e,r,i,s){if(!(Buffer.isBuffer(t)&&"number"==typeof e&&r instanceof nt&&i instanceof z))throw new Error("invalid one of: txHashBuf, txOutNum, txOut, script");return this.txIns.push(st.fromProperties(t,e,i,s)),this.uTxOutMap.set(t,e,r),this}addSigOperation(t,e,r,i,s,n){return this.sigOperations.addOne(t,e,r,i,s,n),this}inputFromPubKeyHash(t,e,r,i,s,n){if(!(Buffer.isBuffer(t)&&"number"==typeof e&&r instanceof nt))throw new Error("invalid one of: txHashBuf, txOutNum, txOut");this.txIns.push((new st).fromObject({nSequence:s}).fromPubKeyHashTxOut(t,e,r,i)),this.uTxOutMap.set(t,e,r);const a=q.fromTxOutScript(r.script).toString();return this.addSigOperation(t,e,0,"sig",a,n),this.addSigOperation(t,e,1,"pubKey",a),this}outputToAddress(t,e){if(!(e instanceof q&&t instanceof p))throw new Error("addr must be an Address, and valueBn must be a Bn");const r=(new z).fromPubKeyHash(e.hashBuf);return this.outputToScript(t,r),this}outputToScript(t,e){if(!(e instanceof z&&t instanceof p))throw new Error("script must be a Script, and valueBn must be a Bn");const r=nt.fromProperties(t,e);return this.txOuts.push(r),this}buildOutputs(){let t=new p(0);return this.txOuts.forEach((e=>{if(e.valueBn.lt(this.dust)&&!e.script.isNonSpendable())throw new Error("cannot create output lesser than dust");t=t.add(e.valueBn),this.tx.addTxOut(e)})),t}buildInputs(t,e=0){let r=new p(0);for(const i of this.txIns){const s=this.uTxOutMap.get(i.txHashBuf,i.txOutNum);if(r=r.add(s.valueBn),this.tx.addTxIn(i),r.geq(t)){if(e<=0)break;e--}}if(r.lt(t))throw new Error("not enough funds for outputs: inAmountBn "+r.toNumber()+" outAmountBn "+t.toNumber());return r}estimateSize(){let t=this.tx.toBuffer().length;return this.tx.txIns.forEach((e=>{const{txHashBuf:r,txOutNum:i}=e;this.sigOperations.get(r,i).forEach((r=>{const{nScriptChunk:i,type:s}=r,n=new z([e.script.chunks[i]]).toBuffer().length;if(t-=n,"sig"===s)t+=72;else{if("pubKey"!==r.type)throw new Error("unsupported sig operations type");t+=35}}))})),t+=1,Math.round(t)}estimateFee(t=new p(0)){return new p(Math.ceil(this.estimateSize()/1e3*this.feePerKbNum)).add(t)}build(t={useAllInputs:!1}){let e;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 r=t.useAllInputs?this.txIns.length-1:0;r<this.txIns.length;r++){this.tx=new at;const t=this.buildOutputs(),i=nt.fromProperties(new p(0),this.changeScript);let s;this.tx.addTxOut(i);try{s=this.buildInputs(t,r)}catch(t){throw t.message.includes("not enough funds for outputs")?new Error("unable to gather enough inputs for outputs and fee"):t}if(this.changeAmountBn=s.sub(t),i.valueBn=this.changeAmountBn,e=this.estimateFee(),this.changeAmountBn.geq(e)&&this.changeAmountBn.sub(e).gt(this.dust))break}if(this.changeAmountBn.geq(e)){if(this.feeAmountBn=e,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)throw new Error("unable to create change amount greater than dust");this.tx.txOuts.pop(),this.tx.txOutsVi=it.fromNumber(this.tx.txOutsVi.toNumber()-1),this.feeAmountBn=this.feeAmountBn.add(this.changeAmountBn),this.changeAmountBn=new p(0)}if(this.tx.nLockTime=this.nLockTime,this.tx.versionBytesNum=this.versionBytesNum,0===this.tx.txOuts.length)throw new Error("outputs length is zero - unable to create any outputs greater than dust");return this}throw new Error("unable to gather enough inputs for outputs and fee")}sort(){return this.tx.sort(),this}static allSigsPresent(t,e){let r=0;for(let t=1;t<e.chunks.length-1;t++)e.chunks[t].buf&&r++;return r===t}static removeBlankSigs(t){t=new z(t.chunks.slice());for(let e=1;e<t.chunks.length-1;e++)t.chunks[e].buf||t.chunks.splice(e,1);return t}fillSig(t,e,r){const i=this.tx.txIns[t];return i.script.chunks[e]=(new z).writeBuffer(r.toTxFormat()).chunks[0],i.scriptVi=it.fromNumber(i.script.toBuffer().length),this}getSig(t,e=j.SIGHASH_ALL|j.SIGHASH_FORKID,r,i,s=at.SCRIPT_ENABLE_SIGHASH_FORKID){let n;if(e&j.SIGHASH_FORKID&&s&at.SCRIPT_ENABLE_SIGHASH_FORKID){const t=this.tx.txIns[r].txHashBuf,e=this.tx.txIns[r].txOutNum,i=this.uTxOutMap.get(t,e);if(!i)throw new Error("for SIGHASH_FORKID must provide UTXOs");n=i.valueBn}return this.tx.sign(t,e,r,i,n,s,this.hashCache)}asyncGetSig(t,e=j.SIGHASH_ALL|j.SIGHASH_FORKID,r,i,s=at.SCRIPT_ENABLE_SIGHASH_FORKID){let n;if(e&j.SIGHASH_FORKID&&s&at.SCRIPT_ENABLE_SIGHASH_FORKID){const t=this.tx.txIns[r].txHashBuf,e=this.tx.txIns[r].txOutNum,i=this.uTxOutMap.get(t,e);if(!i)throw new Error("for SIGHASH_FORKID must provide UTXOs");n=i.valueBn}return this.tx.asyncSign(t,e,r,i,n,s,this.hashCache)}signTxIn(t,e,r,i,s=j.SIGHASH_ALL|j.SIGHASH_FORKID,n=at.SCRIPT_ENABLE_SIGHASH_FORKID){const a=this.tx.txIns[t],o=a.script;if(void 0===i&&o.isPubKeyHashIn()&&(i=0),void 0===i)throw new Error("cannot sign unknown script type for input "+t);const c=a.txHashBuf,h=a.txOutNum;r||(r=this.uTxOutMap.get(c,h));const f=r.script,u=this.getSig(e,s,t,f,n,this.hashCache);return this.fillSig(t,i,u),this}async asyncSignTxIn(t,e,r,i,s=j.SIGHASH_ALL|j.SIGHASH_FORKID,n=at.SCRIPT_ENABLE_SIGHASH_FORKID){const a=this.tx.txIns[t],o=a.script;if(void 0===i&&o.isPubKeyHashIn()&&(i=0),void 0===i)throw new Error("cannot sign unknown script type for input "+t);const c=a.txHashBuf,h=a.txOutNum;r||(r=this.uTxOutMap.get(c,h));const f=r.script,u=await this.asyncGetSig(e,s,t,f,n,this.hashCache);return this.fillSig(t,i,u),this}signWithKeyPairs(t){const e={};for(const r of t)e[q.fromPubKey(r.pubKey).toString()]=r;for(const t in this.tx.txIns){const r=this.tx.txIns[t],i=this.sigOperations.get(r.txHashBuf,r.txOutNum);for(const s of i){const{nScriptChunk:i,type:n,addressStr:a,nHashType:o}=s,c=e[a];if(!c){s.log=`cannot find keyPair for addressStr ${a}`;continue}const h=this.uTxOutMap.get(r.txHashBuf,r.txOutNum);if("sig"===n)this.signTxIn(t,c,h,i,o),s.log="successfully inserted signature";else{if("pubKey"!==n){s.log=`cannot perform operation of type ${n}`;continue}r.script.chunks[i]=(new z).writeBuffer(c.pubKey.toBuffer()).chunks[0],r.setScript(r.script),s.log="successfully inserted public key"}}}return this}}class lt extends w{constructor(t,e,r,i){super({tx:t,txOutMap:e,errStr:r,interp:i})}verify(t=ct.SCRIPT_ENABLE_SIGHASH_FORKID){return!this.checkStr()&&!this.verifyStr(t)}async asyncVerify(t){const e=await this.asyncVerifyStr(t);return!this.checkStr()&&!e}static verify(t,e,r){return new lt(t,e).verify(r)}static asyncVerify(t,e,r){return new lt(t,e).asyncVerify(r)}checkStr(){if(0===this.tx.txIns.length||0===this.tx.txInsVi.toNumber())return this.errStr="transaction txIns empty",this.errStr;if(0===this.tx.txOuts.length||0===this.tx.txOutsVi.toNumber())return this.errStr="transaction txOuts empty",this.errStr;if(this.tx.toBuffer().length>ot.MAX_BLOCK_SIZE)return this.errStr="transaction over the maximum block size",this.errStr;let t=new p(0);for(let e=0;e<this.tx.txOuts.length;e++){const r=this.tx.txOuts[e];if(r.valueBn.lt(0))return this.errStr="transaction txOut "+e+" negative",this.errStr;if(r.valueBn.gt(at.MAX_MONEY))return this.errStr="transaction txOut "+e+" greater than MAX_MONEY",this.errStr;if(t=t.add(r.valueBn),t.gt(at.MAX_MONEY))return this.errStr="transaction txOut "+e+" total output greater than MAX_MONEY",this.errStr}const e={};for(let t=0;t<this.tx.txIns.length;t++){const r=this.tx.txIns[t],i=r.txHashBuf.toString("hex")+":"+r.txOutNum;if(void 0!==e[i])return this.errStr="transaction input "+t+" duplicate input",this.errStr;e[i]=!0}if(this.tx.isCoinbase()){const t=this.tx.txIns[0].script.toBuffer();if(t.length<2||t.length>100)return this.errStr="coinbase trasaction script size invalid",this.errStr}else for(let t=0;t<this.tx.txIns.length;t++)if(this.tx.txIns[t].hasNullInput())return this.errStr="transaction input "+t+" has null input",this.errStr;return!1}verifyStr(t){for(let e=0;e<this.tx.txIns.length;e++)if(!this.verifyNIn(e,t))return this.errStr="input "+e+" failed script verify",this.errStr;return!1}async asyncVerifyStr(t){for(let e=0;e<this.tx.txIns.length;e++)if(!await this.asyncVerifyNIn(e,t))return this.errStr="input "+e+" failed script verify",this.errStr;return!1}verifyNIn(t,e){const r=this.tx.txIns[t],i=r.script,s=this.txOutMap.get(r.txHashBuf,r.txOutNum);if(!s)return console.log("output "+r.txOutNum+" not found"),!1;const n=s.script,a=s.valueBn;return this.interp=new ct,this.interp.verify(i,n,this.tx,t,e,a)}async asyncVerifyNIn(t,e){const r=this.tx.txIns[t],i=r.script,s=this.txOutMap.get(r.txHashBuf,r.txOutNum);if(!s)return console.log("output "+r.txOutNum+" not found"),!1;const n=s.script,a=s.valueBn;this.interp=new ct;const o=await B.asyncObjectMethod(this.interp,"verify",[i,n,this.tx,t,e,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 pt{}pt.encrypt=function(t,r){const i=pt.buf2Words(r),s=pt.buf2Words(t),n=new(e())(i).encrypt(s);return pt.words2Buf(n)},pt.decrypt=function(t,r){const i=pt.buf2Words(t),s=pt.buf2Words(r),n=new(e())(s).decrypt(i);return pt.words2Buf(n)},pt.buf2Words=function(t){if(t.length%4)throw new Error("buf length must be a multiple of 4");const e=[];for(let r=0;r<t.length/4;r++)e.push(t.readUInt32BE(4*r));return e},pt.words2Buf=function(t){const e=Buffer.alloc(4*t.length);for(let r=0;r<t.length;r++)e.writeUInt32BE(t[r],4*r);return e};class bt{}bt.buf2BlocksBuf=function(t,e){const r=e/8,i=[];for(let s=0;s<=t.length/r;s++){let n=t.slice(s*r,s*r+r);n.length<e&&(n=bt.pkcs7Pad(n,e)),i.push(n)}return i},bt.blockBufs2Buf=function(t){let e=t[t.length-1];return e=bt.pkcs7Unpad(e),t[t.length-1]=e,Buffer.concat(t)},bt.encrypt=function(t,e,r,i){const s=8*e.length,n=bt.buf2BlocksBuf(t,s),a=bt.encryptBlocks(n,e,r,i);return Buffer.concat(a)},bt.decrypt=function(t,e,r,i){const s=e.length,n=[];for(let e=0;e<t.length/s;e++)n.push(t.slice(e*s,e*s+s));const a=bt.decryptBlocks(n,e,r,i);return bt.blockBufs2Buf(a)},bt.encryptBlock=function(t,e,r,i){const s=bt.xorBufs(t,e);return r.encrypt(s,i)},bt.decryptBlock=function(t,e,r,i){const s=r.decrypt(t,i);return bt.xorBufs(s,e)},bt.encryptBlocks=function(t,e,r,i){const s=[];for(let n=0;n<t.length;n++){const a=t[n],o=bt.encryptBlock(a,e,r,i);s.push(o),e=o}return s},bt.decryptBlocks=function(t,e,r,i){const s=[];for(let n=0;n<t.length;n++){const a=t[n],o=bt.decryptBlock(a,e,r,i);s.push(o),e=a}return s},bt.pkcs7Pad=function(t,e){const r=e/8-t.length,i=Buffer.alloc(r);return i.fill(r),Buffer.concat([t,i])},bt.pkcs7Unpad=function(t){const e=t[t.length-1],r=t.slice(t.length-e,t.length),i=Buffer.alloc(e);if(i.fill(e),!_(r,i))throw new Error("invalid padding");return t.slice(0,t.length-e)},bt.xorBufs=function(t,e){if(t.length!==e.length)throw new Error("bufs must have the same length");const r=Buffer.alloc(t.length);for(let i=0;i<t.length;i++)r[i]=t[i]^e[i];return r};class mt{}mt.encrypt=function(t,e,r,i=!0){r=r||D.getRandomBuffer(16);const s=bt.encrypt(t,r,pt,e);return i?Buffer.concat([r,s]):s},mt.decrypt=function(t,e,r=!1){if(r){const i=t;return bt.decrypt(i,r,pt,e)}{const r=t.slice(0,16),i=t.slice(16);return bt.decrypt(i,r,pt,e)}};class gt{}gt.encrypt=function(t,e,r){const i=mt.encrypt(t,e,r),s=E.sha256Hmac(i,e);return Buffer.concat([s,i])},gt.asyncEncrypt=async function(t,e,r){r||(r=D.getRandomBuffer(16));const i=[t,e,r];return(await B.asyncClassMethod(gt,"encrypt",i)).resbuf},gt.decrypt=function(t,e){if(t.length<64)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 r=t.slice(0,32);t=t.slice(32,t.length);const i=E.sha256Hmac(t,e);if(!_(r,i))throw new Error("Message authentication failed - Hmacs are not equivalent");return mt.decrypt(t,e)},gt.asyncDecrypt=async function(t,e){const r=[t,e];return(await B.asyncClassMethod(gt,"decrypt",r)).resbuf};class yt{}yt.ivkEkM=function(t,e){const r=t.bn,i=e.point.mul(r),s=new F(i).toBuffer(),n=E.sha512(s);return{iv:n.slice(0,16),kE:n.slice(16,32),kM:n.slice(32,64)}},yt.electrumEncrypt=function(t,e,r,i=!1){if(!Buffer.isBuffer(t))throw new Error("messageBuf must be a buffer");let s;null===r&&(r=X.fromRandom()),i||(s=r.pubKey.toDer(!0));const{iv:n,kE:a,kM:o}=yt.ivkEkM(r.privKey,e),c=mt.encrypt(t,a,n,!1),h=Buffer.from("BIE1");let f;f=s?Buffer.concat([h,s,c]):Buffer.concat([h,c]);const u=E.sha256Hmac(f,o);return Buffer.concat([f,u])},yt.electrumDecrypt=function(t,e,r=null){if(!Buffer.isBuffer(t))throw new Error("encBuf must be a buffer");if(!t.slice(0,4).equals(Buffer.from("BIE1")))throw new Error("Invalid Magic");let i=4;if(null===r){const e=t.slice(4,37);r=F.fromDer(e),i=37}const{iv:s,kE:n,kM:a}=yt.ivkEkM(e,r),o=t.slice(i,t.length-32),c=t.slice(t.length-32,t.length),h=E.sha256Hmac(t.slice(0,t.length-32),a);if(!c.equals(h))throw new Error("Invalid checksum");return mt.decrypt(o,n,s)},yt.bitcoreEncrypt=function(t,e,r,i){r||(r=X.fromRandom());const s=r.privKey.bn,n=r.pubKey.toDer(!0),a=e.point.mul(s).getX().toBuffer({size:32}),o=E.sha512(a),c=o.slice(0,32),h=o.slice(32,64),f=mt.encrypt(t,c,i),u=E.sha256Hmac(f,h);return Buffer.concat([n,f,u])},yt.asyncBitcoreEncrypt=async function(t,e,r,i){r||(r=await X.asyncFromRandom()),i||(i=D.getRandomBuffer(16));const s=[t,e,r,i];return(await B.asyncClassMethod(yt,"bitcoreEncrypt",s)).resbuf},yt.bitcoreDecrypt=function(t,e){const r=e.bn,i=F.fromDer(t.slice(0,33)).point.mul(r);if(i.eq(new L))throw new Error("P equals 0");const s=i.getX().toBuffer({size:32}),n=E.sha512(s),a=n.slice(0,32),o=n.slice(32,64),c=t.slice(33,t.length-32),h=t.slice(t.length-32,t.length),f=E.sha256Hmac(c,o);if(!_(h,f))throw new Error("Invalid checksum");return mt.decrypt(c,a)},yt.asyncBitcoreDecrypt=async function(t,e){const r=[t,e];return(await B.asyncClassMethod(yt,"bitcoreDecrypt",r)).resbuf};const vt={aes:e(),bnjs:n(),bs58:o(),elliptic:h(),hashjs:u(),pbkdf2:d,Buffer:l.Buffer},wt="2.0.15"})(),module.exports.bsv2=i})();
|
|
3
|
-
//# sourceMappingURL=bsv.cjs.js.map
|