diff --git a/.babelrc b/.babelrc new file mode 100644 index 00000000..1cc515eb --- /dev/null +++ b/.babelrc @@ -0,0 +1,16 @@ +{ + "presets": [ + [ "@babel/preset-env", + { + "modules": "umd", + "targets": { + "ie": "9", + }, + }, + ], + ], + "plugins": [ + "@babel/plugin-transform-runtime", + "@babel/plugin-transform-async-to-generator" + ], +} \ No newline at end of file diff --git a/dist/iost.min.js b/dist/iost.min.js new file mode 100644 index 00000000..b6546304 --- /dev/null +++ b/dist/iost.min.js @@ -0,0 +1,15 @@ +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("IOST",[],e):"object"==typeof exports?exports.IOST=e():t.IOST=e()}(window,function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=36)}([function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e){function r(t,e){for(var r=0;r=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return n}function s(t,e,r,n){for(var i=0,f=Math.min(t.length,r),o=e;o=49?a-49+10:a>=17?a-17+10:a}return i}f.isBN=function(t){return t instanceof f||null!==t&&"object"==typeof t&&t.constructor.wordSize===f.wordSize&&Array.isArray(t.words)},f.max=function(t,e){return t.cmp(e)>0?t:e},f.min=function(t,e){return t.cmp(e)<0?t:e},f.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),n(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&i++,16===e?this._parseHex(t,i):this._parseBase(t,e,i),"-"===t[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),e,r)},f.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):(n(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},f.prototype._initArray=function(t,e,r){if(n("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 i=0;i=0;i-=3)o=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[f]|=o<>>26-a&67108863,(a+=24)>=26&&(a-=26,f++);else if("le"===r)for(i=0,f=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,f++);return this.strip()},f.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r=e;r-=6)i=a(t,r,r+6),this.words[n]|=i<>>26-f&4194303,(f+=24)>=26&&(f-=26,n++);r+6!==e&&(i=a(t,e,r+6),this.words[n]|=i<>>26-f&4194303),this.strip()},f.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var f=t.length-r,o=f%n,a=Math.min(f,f-o)+r,u=0,h=r;h1&&0===this.words[this.length-1];)this.length--;return this._normSign()},f.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},f.prototype.inspect=function(){return(this.red?""};var u=["","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"],h=[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],c=[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 d(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],f=0|e.words[0],o=i*f,a=67108863&o,s=o/67108864|0;r.words[0]=a;for(var u=1;u>>26,c=67108863&s,d=Math.min(u,e.length-1),l=Math.max(0,u-t.length+1);l<=d;l++){var b=u-l|0;h+=(o=(i=0|t.words[b])*(f=0|e.words[l])+c)/67108864|0,c=67108863&o}r.words[u]=0|c,s=0|h}return 0!==s?r.words[u]=0|s:r.length--,r.strip()}f.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var i=0,f=0,o=0;o>>24-i&16777215)||o!==this.length-1?u[6-s.length]+s+r:s+r,(i+=2)>=26&&(i-=26,o--)}for(0!==f&&(r=f.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 d=h[t],l=c[t];r="";var b=this.clone();for(b.negative=0;!b.isZero();){var p=b.modn(l).toString(t);r=(b=b.idivn(l)).isZero()?p+r:u[d-p.length]+p+r}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},f.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&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},f.prototype.toJSON=function(){return this.toString(16)},f.prototype.toBuffer=function(t,e){return n(void 0!==o),this.toArrayLike(o,t,e)},f.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},f.prototype.toArrayLike=function(t,e,r){var i=this.byteLength(),f=r||Math.max(1,i);n(i<=f,"byte array longer than desired length"),n(f>0,"Requested array length <= 0"),this.strip();var o,a,s="le"===e,u=new t(f),h=this.clone();if(s){for(a=0;!h.isZero();a++)o=h.andln(255),h.iushrn(8),u[a]=o;for(;a=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},f.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},f.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},f.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},f.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},f.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},f.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},f.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;nt.length?this.clone().ixor(t):t.clone().ixor(this)},f.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},f.prototype.inotn=function(t){n("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},f.prototype.notn=function(t){return this.clone().inotn(t)},f.prototype.setn=function(t,e){n("number"==typeof t&&t>=0);var r=t/26|0,i=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,f=0;f>>26;for(;0!==i&&f>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;ft.length?this.clone().iadd(t):t.clone().iadd(this)},f.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,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var f=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==f&&o>26,this.words[o]=67108863&e;if(0===f&&o>>13,l=0|o[1],b=8191&l,p=l>>>13,v=0|o[2],g=8191&v,y=v>>>13,m=0|o[3],w=8191&m,M=m>>>13,_=0|o[4],A=8191&_,S=_>>>13,x=0|o[5],E=8191&x,I=x>>>13,k=0|o[6],R=8191&k,P=k>>>13,B=0|o[7],T=8191&B,q=B>>>13,L=0|o[8],U=8191&L,N=L>>>13,z=0|o[9],O=8191&z,C=z>>>13,j=0|a[0],F=8191&j,D=j>>>13,Y=0|a[1],K=8191&Y,H=Y>>>13,J=0|a[2],Z=8191&J,X=J>>>13,V=0|a[3],W=8191&V,G=V>>>13,$=0|a[4],Q=8191&$,tt=$>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ft=8191&it,ot=it>>>13,at=0|a[7],st=8191&at,ut=at>>>13,ht=0|a[8],ct=8191&ht,dt=ht>>>13,lt=0|a[9],bt=8191<,pt=lt>>>13;r.negative=t.negative^e.negative,r.length=19;var vt=(u+(n=Math.imul(c,F))|0)+((8191&(i=(i=Math.imul(c,D))+Math.imul(d,F)|0))<<13)|0;u=((f=Math.imul(d,D))+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(b,F),i=(i=Math.imul(b,D))+Math.imul(p,F)|0,f=Math.imul(p,D);var gt=(u+(n=n+Math.imul(c,K)|0)|0)+((8191&(i=(i=i+Math.imul(c,H)|0)+Math.imul(d,K)|0))<<13)|0;u=((f=f+Math.imul(d,H)|0)+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(g,F),i=(i=Math.imul(g,D))+Math.imul(y,F)|0,f=Math.imul(y,D),n=n+Math.imul(b,K)|0,i=(i=i+Math.imul(b,H)|0)+Math.imul(p,K)|0,f=f+Math.imul(p,H)|0;var yt=(u+(n=n+Math.imul(c,Z)|0)|0)+((8191&(i=(i=i+Math.imul(c,X)|0)+Math.imul(d,Z)|0))<<13)|0;u=((f=f+Math.imul(d,X)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(w,F),i=(i=Math.imul(w,D))+Math.imul(M,F)|0,f=Math.imul(M,D),n=n+Math.imul(g,K)|0,i=(i=i+Math.imul(g,H)|0)+Math.imul(y,K)|0,f=f+Math.imul(y,H)|0,n=n+Math.imul(b,Z)|0,i=(i=i+Math.imul(b,X)|0)+Math.imul(p,Z)|0,f=f+Math.imul(p,X)|0;var mt=(u+(n=n+Math.imul(c,W)|0)|0)+((8191&(i=(i=i+Math.imul(c,G)|0)+Math.imul(d,W)|0))<<13)|0;u=((f=f+Math.imul(d,G)|0)+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(A,F),i=(i=Math.imul(A,D))+Math.imul(S,F)|0,f=Math.imul(S,D),n=n+Math.imul(w,K)|0,i=(i=i+Math.imul(w,H)|0)+Math.imul(M,K)|0,f=f+Math.imul(M,H)|0,n=n+Math.imul(g,Z)|0,i=(i=i+Math.imul(g,X)|0)+Math.imul(y,Z)|0,f=f+Math.imul(y,X)|0,n=n+Math.imul(b,W)|0,i=(i=i+Math.imul(b,G)|0)+Math.imul(p,W)|0,f=f+Math.imul(p,G)|0;var wt=(u+(n=n+Math.imul(c,Q)|0)|0)+((8191&(i=(i=i+Math.imul(c,tt)|0)+Math.imul(d,Q)|0))<<13)|0;u=((f=f+Math.imul(d,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(E,F),i=(i=Math.imul(E,D))+Math.imul(I,F)|0,f=Math.imul(I,D),n=n+Math.imul(A,K)|0,i=(i=i+Math.imul(A,H)|0)+Math.imul(S,K)|0,f=f+Math.imul(S,H)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,X)|0)+Math.imul(M,Z)|0,f=f+Math.imul(M,X)|0,n=n+Math.imul(g,W)|0,i=(i=i+Math.imul(g,G)|0)+Math.imul(y,W)|0,f=f+Math.imul(y,G)|0,n=n+Math.imul(b,Q)|0,i=(i=i+Math.imul(b,tt)|0)+Math.imul(p,Q)|0,f=f+Math.imul(p,tt)|0;var Mt=(u+(n=n+Math.imul(c,rt)|0)|0)+((8191&(i=(i=i+Math.imul(c,nt)|0)+Math.imul(d,rt)|0))<<13)|0;u=((f=f+Math.imul(d,nt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(R,F),i=(i=Math.imul(R,D))+Math.imul(P,F)|0,f=Math.imul(P,D),n=n+Math.imul(E,K)|0,i=(i=i+Math.imul(E,H)|0)+Math.imul(I,K)|0,f=f+Math.imul(I,H)|0,n=n+Math.imul(A,Z)|0,i=(i=i+Math.imul(A,X)|0)+Math.imul(S,Z)|0,f=f+Math.imul(S,X)|0,n=n+Math.imul(w,W)|0,i=(i=i+Math.imul(w,G)|0)+Math.imul(M,W)|0,f=f+Math.imul(M,G)|0,n=n+Math.imul(g,Q)|0,i=(i=i+Math.imul(g,tt)|0)+Math.imul(y,Q)|0,f=f+Math.imul(y,tt)|0,n=n+Math.imul(b,rt)|0,i=(i=i+Math.imul(b,nt)|0)+Math.imul(p,rt)|0,f=f+Math.imul(p,nt)|0;var _t=(u+(n=n+Math.imul(c,ft)|0)|0)+((8191&(i=(i=i+Math.imul(c,ot)|0)+Math.imul(d,ft)|0))<<13)|0;u=((f=f+Math.imul(d,ot)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(T,F),i=(i=Math.imul(T,D))+Math.imul(q,F)|0,f=Math.imul(q,D),n=n+Math.imul(R,K)|0,i=(i=i+Math.imul(R,H)|0)+Math.imul(P,K)|0,f=f+Math.imul(P,H)|0,n=n+Math.imul(E,Z)|0,i=(i=i+Math.imul(E,X)|0)+Math.imul(I,Z)|0,f=f+Math.imul(I,X)|0,n=n+Math.imul(A,W)|0,i=(i=i+Math.imul(A,G)|0)+Math.imul(S,W)|0,f=f+Math.imul(S,G)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(M,Q)|0,f=f+Math.imul(M,tt)|0,n=n+Math.imul(g,rt)|0,i=(i=i+Math.imul(g,nt)|0)+Math.imul(y,rt)|0,f=f+Math.imul(y,nt)|0,n=n+Math.imul(b,ft)|0,i=(i=i+Math.imul(b,ot)|0)+Math.imul(p,ft)|0,f=f+Math.imul(p,ot)|0;var At=(u+(n=n+Math.imul(c,st)|0)|0)+((8191&(i=(i=i+Math.imul(c,ut)|0)+Math.imul(d,st)|0))<<13)|0;u=((f=f+Math.imul(d,ut)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(U,F),i=(i=Math.imul(U,D))+Math.imul(N,F)|0,f=Math.imul(N,D),n=n+Math.imul(T,K)|0,i=(i=i+Math.imul(T,H)|0)+Math.imul(q,K)|0,f=f+Math.imul(q,H)|0,n=n+Math.imul(R,Z)|0,i=(i=i+Math.imul(R,X)|0)+Math.imul(P,Z)|0,f=f+Math.imul(P,X)|0,n=n+Math.imul(E,W)|0,i=(i=i+Math.imul(E,G)|0)+Math.imul(I,W)|0,f=f+Math.imul(I,G)|0,n=n+Math.imul(A,Q)|0,i=(i=i+Math.imul(A,tt)|0)+Math.imul(S,Q)|0,f=f+Math.imul(S,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(M,rt)|0,f=f+Math.imul(M,nt)|0,n=n+Math.imul(g,ft)|0,i=(i=i+Math.imul(g,ot)|0)+Math.imul(y,ft)|0,f=f+Math.imul(y,ot)|0,n=n+Math.imul(b,st)|0,i=(i=i+Math.imul(b,ut)|0)+Math.imul(p,st)|0,f=f+Math.imul(p,ut)|0;var St=(u+(n=n+Math.imul(c,ct)|0)|0)+((8191&(i=(i=i+Math.imul(c,dt)|0)+Math.imul(d,ct)|0))<<13)|0;u=((f=f+Math.imul(d,dt)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(O,F),i=(i=Math.imul(O,D))+Math.imul(C,F)|0,f=Math.imul(C,D),n=n+Math.imul(U,K)|0,i=(i=i+Math.imul(U,H)|0)+Math.imul(N,K)|0,f=f+Math.imul(N,H)|0,n=n+Math.imul(T,Z)|0,i=(i=i+Math.imul(T,X)|0)+Math.imul(q,Z)|0,f=f+Math.imul(q,X)|0,n=n+Math.imul(R,W)|0,i=(i=i+Math.imul(R,G)|0)+Math.imul(P,W)|0,f=f+Math.imul(P,G)|0,n=n+Math.imul(E,Q)|0,i=(i=i+Math.imul(E,tt)|0)+Math.imul(I,Q)|0,f=f+Math.imul(I,tt)|0,n=n+Math.imul(A,rt)|0,i=(i=i+Math.imul(A,nt)|0)+Math.imul(S,rt)|0,f=f+Math.imul(S,nt)|0,n=n+Math.imul(w,ft)|0,i=(i=i+Math.imul(w,ot)|0)+Math.imul(M,ft)|0,f=f+Math.imul(M,ot)|0,n=n+Math.imul(g,st)|0,i=(i=i+Math.imul(g,ut)|0)+Math.imul(y,st)|0,f=f+Math.imul(y,ut)|0,n=n+Math.imul(b,ct)|0,i=(i=i+Math.imul(b,dt)|0)+Math.imul(p,ct)|0,f=f+Math.imul(p,dt)|0;var xt=(u+(n=n+Math.imul(c,bt)|0)|0)+((8191&(i=(i=i+Math.imul(c,pt)|0)+Math.imul(d,bt)|0))<<13)|0;u=((f=f+Math.imul(d,pt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(O,K),i=(i=Math.imul(O,H))+Math.imul(C,K)|0,f=Math.imul(C,H),n=n+Math.imul(U,Z)|0,i=(i=i+Math.imul(U,X)|0)+Math.imul(N,Z)|0,f=f+Math.imul(N,X)|0,n=n+Math.imul(T,W)|0,i=(i=i+Math.imul(T,G)|0)+Math.imul(q,W)|0,f=f+Math.imul(q,G)|0,n=n+Math.imul(R,Q)|0,i=(i=i+Math.imul(R,tt)|0)+Math.imul(P,Q)|0,f=f+Math.imul(P,tt)|0,n=n+Math.imul(E,rt)|0,i=(i=i+Math.imul(E,nt)|0)+Math.imul(I,rt)|0,f=f+Math.imul(I,nt)|0,n=n+Math.imul(A,ft)|0,i=(i=i+Math.imul(A,ot)|0)+Math.imul(S,ft)|0,f=f+Math.imul(S,ot)|0,n=n+Math.imul(w,st)|0,i=(i=i+Math.imul(w,ut)|0)+Math.imul(M,st)|0,f=f+Math.imul(M,ut)|0,n=n+Math.imul(g,ct)|0,i=(i=i+Math.imul(g,dt)|0)+Math.imul(y,ct)|0,f=f+Math.imul(y,dt)|0;var Et=(u+(n=n+Math.imul(b,bt)|0)|0)+((8191&(i=(i=i+Math.imul(b,pt)|0)+Math.imul(p,bt)|0))<<13)|0;u=((f=f+Math.imul(p,pt)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(O,Z),i=(i=Math.imul(O,X))+Math.imul(C,Z)|0,f=Math.imul(C,X),n=n+Math.imul(U,W)|0,i=(i=i+Math.imul(U,G)|0)+Math.imul(N,W)|0,f=f+Math.imul(N,G)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,tt)|0)+Math.imul(q,Q)|0,f=f+Math.imul(q,tt)|0,n=n+Math.imul(R,rt)|0,i=(i=i+Math.imul(R,nt)|0)+Math.imul(P,rt)|0,f=f+Math.imul(P,nt)|0,n=n+Math.imul(E,ft)|0,i=(i=i+Math.imul(E,ot)|0)+Math.imul(I,ft)|0,f=f+Math.imul(I,ot)|0,n=n+Math.imul(A,st)|0,i=(i=i+Math.imul(A,ut)|0)+Math.imul(S,st)|0,f=f+Math.imul(S,ut)|0,n=n+Math.imul(w,ct)|0,i=(i=i+Math.imul(w,dt)|0)+Math.imul(M,ct)|0,f=f+Math.imul(M,dt)|0;var It=(u+(n=n+Math.imul(g,bt)|0)|0)+((8191&(i=(i=i+Math.imul(g,pt)|0)+Math.imul(y,bt)|0))<<13)|0;u=((f=f+Math.imul(y,pt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(O,W),i=(i=Math.imul(O,G))+Math.imul(C,W)|0,f=Math.imul(C,G),n=n+Math.imul(U,Q)|0,i=(i=i+Math.imul(U,tt)|0)+Math.imul(N,Q)|0,f=f+Math.imul(N,tt)|0,n=n+Math.imul(T,rt)|0,i=(i=i+Math.imul(T,nt)|0)+Math.imul(q,rt)|0,f=f+Math.imul(q,nt)|0,n=n+Math.imul(R,ft)|0,i=(i=i+Math.imul(R,ot)|0)+Math.imul(P,ft)|0,f=f+Math.imul(P,ot)|0,n=n+Math.imul(E,st)|0,i=(i=i+Math.imul(E,ut)|0)+Math.imul(I,st)|0,f=f+Math.imul(I,ut)|0,n=n+Math.imul(A,ct)|0,i=(i=i+Math.imul(A,dt)|0)+Math.imul(S,ct)|0,f=f+Math.imul(S,dt)|0;var kt=(u+(n=n+Math.imul(w,bt)|0)|0)+((8191&(i=(i=i+Math.imul(w,pt)|0)+Math.imul(M,bt)|0))<<13)|0;u=((f=f+Math.imul(M,pt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(O,Q),i=(i=Math.imul(O,tt))+Math.imul(C,Q)|0,f=Math.imul(C,tt),n=n+Math.imul(U,rt)|0,i=(i=i+Math.imul(U,nt)|0)+Math.imul(N,rt)|0,f=f+Math.imul(N,nt)|0,n=n+Math.imul(T,ft)|0,i=(i=i+Math.imul(T,ot)|0)+Math.imul(q,ft)|0,f=f+Math.imul(q,ot)|0,n=n+Math.imul(R,st)|0,i=(i=i+Math.imul(R,ut)|0)+Math.imul(P,st)|0,f=f+Math.imul(P,ut)|0,n=n+Math.imul(E,ct)|0,i=(i=i+Math.imul(E,dt)|0)+Math.imul(I,ct)|0,f=f+Math.imul(I,dt)|0;var Rt=(u+(n=n+Math.imul(A,bt)|0)|0)+((8191&(i=(i=i+Math.imul(A,pt)|0)+Math.imul(S,bt)|0))<<13)|0;u=((f=f+Math.imul(S,pt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(O,rt),i=(i=Math.imul(O,nt))+Math.imul(C,rt)|0,f=Math.imul(C,nt),n=n+Math.imul(U,ft)|0,i=(i=i+Math.imul(U,ot)|0)+Math.imul(N,ft)|0,f=f+Math.imul(N,ot)|0,n=n+Math.imul(T,st)|0,i=(i=i+Math.imul(T,ut)|0)+Math.imul(q,st)|0,f=f+Math.imul(q,ut)|0,n=n+Math.imul(R,ct)|0,i=(i=i+Math.imul(R,dt)|0)+Math.imul(P,ct)|0,f=f+Math.imul(P,dt)|0;var Pt=(u+(n=n+Math.imul(E,bt)|0)|0)+((8191&(i=(i=i+Math.imul(E,pt)|0)+Math.imul(I,bt)|0))<<13)|0;u=((f=f+Math.imul(I,pt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(O,ft),i=(i=Math.imul(O,ot))+Math.imul(C,ft)|0,f=Math.imul(C,ot),n=n+Math.imul(U,st)|0,i=(i=i+Math.imul(U,ut)|0)+Math.imul(N,st)|0,f=f+Math.imul(N,ut)|0,n=n+Math.imul(T,ct)|0,i=(i=i+Math.imul(T,dt)|0)+Math.imul(q,ct)|0,f=f+Math.imul(q,dt)|0;var Bt=(u+(n=n+Math.imul(R,bt)|0)|0)+((8191&(i=(i=i+Math.imul(R,pt)|0)+Math.imul(P,bt)|0))<<13)|0;u=((f=f+Math.imul(P,pt)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(O,st),i=(i=Math.imul(O,ut))+Math.imul(C,st)|0,f=Math.imul(C,ut),n=n+Math.imul(U,ct)|0,i=(i=i+Math.imul(U,dt)|0)+Math.imul(N,ct)|0,f=f+Math.imul(N,dt)|0;var Tt=(u+(n=n+Math.imul(T,bt)|0)|0)+((8191&(i=(i=i+Math.imul(T,pt)|0)+Math.imul(q,bt)|0))<<13)|0;u=((f=f+Math.imul(q,pt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(O,ct),i=(i=Math.imul(O,dt))+Math.imul(C,ct)|0,f=Math.imul(C,dt);var qt=(u+(n=n+Math.imul(U,bt)|0)|0)+((8191&(i=(i=i+Math.imul(U,pt)|0)+Math.imul(N,bt)|0))<<13)|0;u=((f=f+Math.imul(N,pt)|0)+(i>>>13)|0)+(qt>>>26)|0,qt&=67108863;var Lt=(u+(n=Math.imul(O,bt))|0)+((8191&(i=(i=Math.imul(O,pt))+Math.imul(C,bt)|0))<<13)|0;return u=((f=Math.imul(C,pt))+(i>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,s[0]=vt,s[1]=gt,s[2]=yt,s[3]=mt,s[4]=wt,s[5]=Mt,s[6]=_t,s[7]=At,s[8]=St,s[9]=xt,s[10]=Et,s[11]=It,s[12]=kt,s[13]=Rt,s[14]=Pt,s[15]=Bt,s[16]=Tt,s[17]=qt,s[18]=Lt,0!==u&&(s[19]=u,r.length++),r};function b(t,e,r){return(new p).mulp(t,e,r)}function p(t,e){this.x=t,this.y=e}Math.imul||(l=d),f.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?l(this,t,e):r<63?d(this,t,e):r<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,f=0;f>>26)|0)>>>26,o&=67108863}r.words[f]=a,n=o,o=i}return 0!==n?r.words[f]=n:r.length--,r.strip()}(this,t,e):b(this,t,e)},p.prototype.makeRBT=function(t){for(var e=new Array(t),r=f.prototype._countBits(t)-1,n=0;n>=1;return n},p.prototype.permute=function(t,e,r,n,i,f){for(var o=0;o>>=1)i++;return 1<>>=13,r[2*o+1]=8191&f,f>>>=13;for(o=2*e;o>=26,e+=i/67108864|0,e+=f>>>26,this.words[r]=67108863&f}return 0!==e&&(this.words[r]=e,this.length++),this},f.prototype.muln=function(t){return this.clone().imuln(t)},f.prototype.sqr=function(){return this.mul(this)},f.prototype.isqr=function(){return this.imul(this.clone())},f.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>i}return e}(t);if(0===e.length)return new f(1);for(var r=this,n=0;n=0);var e,r=t%26,i=(t-r)/26,f=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(e=0;e>>26-r}o&&(this.words[e]=o,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e=0),i=e?(e-e%26)/26:0;var f=t%26,o=Math.min((t-f)/26,this.length),a=67108863^67108863>>>f<o)for(this.length-=o,u=0;u=0&&(0!==h||u>=i);u--){var c=0|this.words[u];this.words[u]=h<<26-f|c>>>f,h=c&a}return s&&0!==h&&(s.words[s.length++]=h),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},f.prototype.ishrn=function(t,e,r){return n(0===this.negative),this.iushrn(t,e,r)},f.prototype.shln=function(t){return this.clone().ishln(t)},f.prototype.ushln=function(t){return this.clone().iushln(t)},f.prototype.shrn=function(t){return this.clone().ishrn(t)},f.prototype.ushrn=function(t){return this.clone().iushrn(t)},f.prototype.testn=function(t){n("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,i=1<=0);var e=t%26,r=(t-e)/26;if(n(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 i=67108863^67108863>>>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},f.prototype.isubn=function(t){if(n("number"==typeof t),n(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>26)-(s/67108864|0),this.words[i+r]=67108863&f}for(;i>26,this.words[i+r]=67108863&f;if(0===a)return this.strip();for(n(-1===a),a=0,i=0;i>26,this.words[i]=67108863&f;return this.negative=1,this.strip()},f.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),i=t,o=0|i.words[i.length-1];0!==(r=26-this._countBits(o))&&(i=i.ushln(r),n.iushln(r),o=0|i.words[i.length-1]);var a,s=n.length-i.length;if("mod"!==e){(a=new f(null)).length=s+1,a.words=new Array(a.length);for(var u=0;u=0;c--){var d=67108864*(0|n.words[i.length+c])+(0|n.words[i.length+c-1]);for(d=Math.min(d/o|0,67108863),n._ishlnsubmul(i,d,c);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(i,1,c),n.isZero()||(n.negative^=1);a&&(a.words[c]=d)}return a&&a.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},f.prototype.divmod=function(t,e,r){return n(!t.isZero()),this.isZero()?{div:new f(0),mod:new f(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(i=a.div.neg()),"div"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.iadd(t)),{div:i,mod:o}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.isub(t)),{div:a.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new f(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new f(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new f(this.modn(t.words[0]))}:this._wordDiv(t,e);var i,o,a},f.prototype.div=function(t){return this.divmod(t,"div",!1).div},f.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},f.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},f.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,n=t.ushrn(1),i=t.andln(1),f=r.cmp(n);return f<0||1===i&&0===f?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},f.prototype.modn=function(t){n(t<=67108863);for(var e=(1<<26)%t,r=0,i=this.length-1;i>=0;i--)r=(e*r+(0|this.words[i]))%t;return r},f.prototype.idivn=function(t){n(t<=67108863);for(var e=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*e;this.words[r]=i/t|0,e=i%t}return this.strip()},f.prototype.divn=function(t){return this.clone().idivn(t)},f.prototype.egcd=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i=new f(1),o=new f(0),a=new f(0),s=new f(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var h=r.clone(),c=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;)(i.isOdd()||o.isOdd())&&(i.iadd(h),o.isub(c)),i.iushrn(1),o.iushrn(1);for(var b=0,p=1;0==(r.words[0]&p)&&b<26;++b,p<<=1);if(b>0)for(r.iushrn(b);b-- >0;)(a.isOdd()||s.isOdd())&&(a.iadd(h),s.isub(c)),a.iushrn(1),s.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(a),o.isub(s)):(r.isub(e),a.isub(i),s.isub(o))}return{a:a,b:s,gcd:r.iushln(u)}},f.prototype._invmp=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i,o=new f(1),a=new f(0),s=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,h=1;0==(e.words[0]&h)&&u<26;++u,h<<=1);if(u>0)for(e.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(s),o.iushrn(1);for(var c=0,d=1;0==(r.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(r.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(s),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),o.isub(a)):(r.isub(e),a.isub(o))}return(i=0===e.cmpn(1)?o:a).cmpn(0)<0&&i.iadd(t),i},f.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 n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var f=e;e=r,r=f}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},f.prototype.invm=function(t){return this.egcd(t).a.umod(t)},f.prototype.isEven=function(){return 0==(1&this.words[0])},f.prototype.isOdd=function(){return 1==(1&this.words[0])},f.prototype.andln=function(t){return this.words[0]&t},f.prototype.bincn=function(t){n("number"==typeof t);var e=t%26,r=(t-e)/26,i=1<>>26,a&=67108863,this.words[o]=a}return 0!==f&&(this.words[o]=f,this.length++),this},f.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},f.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),n(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(e=1);break}}return e},f.prototype.gtn=function(t){return 1===this.cmpn(t)},f.prototype.gt=function(t){return 1===this.cmp(t)},f.prototype.gten=function(t){return this.cmpn(t)>=0},f.prototype.gte=function(t){return this.cmp(t)>=0},f.prototype.ltn=function(t){return-1===this.cmpn(t)},f.prototype.lt=function(t){return-1===this.cmp(t)},f.prototype.lten=function(t){return this.cmpn(t)<=0},f.prototype.lte=function(t){return this.cmp(t)<=0},f.prototype.eqn=function(t){return 0===this.cmpn(t)},f.prototype.eq=function(t){return 0===this.cmp(t)},f.red=function(t){return new _(t)},f.prototype.toRed=function(t){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},f.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},f.prototype._forceRed=function(t){return this.red=t,this},f.prototype.forceRed=function(t){return n(!this.red,"Already a number in reduction context"),this._forceRed(t)},f.prototype.redAdd=function(t){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},f.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},f.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},f.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},f.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},f.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},f.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},f.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},f.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},f.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},f.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},f.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},f.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var v={k256:null,p224:null,p192:null,p25519:null};function g(t,e){this.name=t,this.p=new f(e,16),this.n=this.p.bitLength(),this.k=new f(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function y(){g.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function m(){g.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){g.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function M(){g.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function _(t){if("string"==typeof t){var e=f._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function A(t){_.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new f(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)}g.prototype._tmp=function(){var t=new f(null);return t.words=new Array(Math.ceil(this.n/13)),t},g.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 n=e0?r.isub(this.p):r.strip(),r},g.prototype.split=function(t,e){t.iushrn(this.n,0,e)},g.prototype.imulK=function(t){return t.imul(this.k)},i(y,g),y.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=f}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},y.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>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},f._prime=function(t){if(v[t])return v[t];var e;if("k256"===t)e=new y;else if("p224"===t)e=new m;else if("p192"===t)e=new w;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new M}return v[t]=e,e},_.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},_.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},_.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},_.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},_.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)},_.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},_.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)},_.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},_.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},_.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},_.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},_.prototype.isqr=function(t){return this.imul(t,t.clone())},_.prototype.sqr=function(t){return this.mul(t,t)},_.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new f(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),o=0;!i.isZero()&&0===i.andln(1);)o++,i.iushrn(1);n(!i.isZero());var a=new f(1).toRed(this),s=a.redNeg(),u=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new f(2*h*h).toRed(this);0!==this.pow(h,u).cmp(s);)h.redIAdd(s);for(var c=this.pow(h,i),d=this.pow(t,i.addn(1).iushrn(1)),l=this.pow(t,i),b=o;0!==l.cmp(a);){for(var p=l,v=0;0!==p.cmp(a);v++)p=p.redSqr();n(v=0;n--){for(var u=e.words[n],h=s-1;h>=0;h--){var c=u>>h&1;i!==r[0]&&(i=this.sqr(i)),0!==c||0!==o?(o<<=1,o|=c,(4===++a||0===n&&0===h)&&(i=this.mul(i,r[o]),a=0,o=0)):a=0}s=26}return i},_.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},_.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},f.mont=function(t){return new A(t)},i(A,_),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),f=i;return i.cmp(this.m)>=0?f=i.isub(this.m):i.cmpn(0)<0&&(f=i.iadd(this.m)),f._forceRed(this)},A.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new f(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,this)}).call(this,r(79)(t))},function(t,e,r){"use strict";var n=r(7),i=r(11);function f(t,e){return 55296==(64512&t.charCodeAt(e))&&(!(e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1)))}function o(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function a(t){return 1===t.length?"0"+t:t}function s(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=i,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),i=0;i>6|192,r[n++]=63&o|128):f(t,i)?(o=65536+((1023&o)<<10)+(1023&t.charCodeAt(++i)),r[n++]=o>>18|240,r[n++]=o>>12&63|128,r[n++]=o>>6&63|128,r[n++]=63&o|128):(r[n++]=o>>12|224,r[n++]=o>>6&63|128,r[n++]=63&o|128)}else for(i=0;i>>0}return o},e.split32=function(t,e){for(var r=new Array(4*t.length),n=0,i=0;n>>24,r[i+1]=f>>>16&255,r[i+2]=f>>>8&255,r[i+3]=255&f):(r[i+3]=f>>>24,r[i+2]=f>>>16&255,r[i+1]=f>>>8&255,r[i]=255&f)}return r},e.rotr32=function(t,e){return t>>>e|t<<32-e},e.rotl32=function(t,e){return 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,n){return t+e+r+n>>>0},e.sum32_5=function(t,e,r,n,i){return t+e+r+n+i>>>0},e.sum64=function(t,e,r,n){var i=t[e],f=n+t[e+1]>>>0,o=(f>>0,t[e+1]=f},e.sum64_hi=function(t,e,r,n){return(e+n>>>0>>0},e.sum64_lo=function(t,e,r,n){return e+n>>>0},e.sum64_4_hi=function(t,e,r,n,i,f,o,a){var s=0,u=e;return s+=(u=u+n>>>0)>>0)>>0)>>0},e.sum64_4_lo=function(t,e,r,n,i,f,o,a){return e+n+f+a>>>0},e.sum64_5_hi=function(t,e,r,n,i,f,o,a,s,u){var h=0,c=e;return h+=(c=c+n>>>0)>>0)>>0)>>0)>>0},e.sum64_5_lo=function(t,e,r,n,i,f,o,a,s,u){return e+n+f+a+u>>>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}},function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}t.exports=r,r.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)}},function(t,e,r){"use strict";(function(t){ +/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ +var n=r(66),i=r(67),f=r(68);function o(){return s.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(o()=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function b(t,e){if(s.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return j(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(n)return j(t).length;e=(""+e).toLowerCase(),n=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:g(t,e,r,n,i);if("number"==typeof e)return e&=255,s.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):g(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function g(t,e,r,n,i){var f,o=1,a=t.length,s=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,a/=2,s/=2,r/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(i){var h=-1;for(f=r;fa&&(r=a-s),f=r;f>=0;f--){for(var c=!0,d=0;di&&(n=i):n=i;var f=e.length;if(f%2!=0)throw new TypeError("Invalid hex string");n>f/2&&(n=f/2);for(var o=0;o>8,i=r%256,f.push(i),f.push(n);return f}(e,t.length-r),t,r,n)}function S(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function x(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:u>223?3:u>191?2:1;if(i+c<=r)switch(c){case 1:u<128&&(h=u);break;case 2:128==(192&(f=t[i+1]))&&(s=(31&u)<<6|63&f)>127&&(h=s);break;case 3:f=t[i+1],o=t[i+2],128==(192&f)&&128==(192&o)&&(s=(15&u)<<12|(63&f)<<6|63&o)>2047&&(s<55296||s>57343)&&(h=s);break;case 4:f=t[i+1],o=t[i+2],a=t[i+3],128==(192&f)&&128==(192&o)&&128==(192&a)&&(s=(15&u)<<18|(63&f)<<12|(63&o)<<6|63&a)>65535&&s<1114112&&(h=s)}null===h?(h=65533,c=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),i+=c}return function(t){var e=t.length;if(e<=E)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return R(this,e,r);case"utf8":case"utf-8":return x(this,e,r);case"ascii":return I(this,e,r);case"latin1":case"binary":return k(this,e,r);case"base64":return S(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),""},s.prototype.compare=function(t,e,r,n,i){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;for(var f=(i>>>=0)-(n>>>=0),o=(r>>>=0)-(e>>>=0),a=Math.min(f,o),u=this.slice(n,i),h=t.slice(e,r),c=0;ci)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var f=!1;;)switch(n){case"hex":return y(this,t,e,r);case"utf8":case"utf-8":return m(this,t,e,r);case"ascii":return w(this,t,e,r);case"latin1":case"binary":return M(this,t,e,r);case"base64":return _(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(f)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),f=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var E=4096;function I(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",f=e;fr)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,r,n,i,f){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function q(t,e,r,n){e<0&&(e=65535+e+1);for(var i=0,f=Math.min(t.length-r,2);i>>8*(n?i:1-i)}function L(t,e,r,n){e<0&&(e=4294967295+e+1);for(var i=0,f=Math.min(t.length-r,4);i>>8*(n?i:3-i)&255}function U(t,e,r,n,i,f){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function N(t,e,r,n,f){return f||U(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function z(t,e,r,n,f){return f||U(t,0,r,8),i.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e0&&(i*=256);)n+=this[t+--e]*i;return n},s.prototype.readUInt8=function(t,e){return e||B(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return e||B(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return e||B(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return e||B(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return e||B(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||B(t,e,this.length);for(var n=this[t],i=1,f=0;++f=(i*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||B(t,e,this.length);for(var n=e,i=1,f=this[t+--n];n>0&&(i*=256);)f+=this[t+--n]*i;return f>=(i*=128)&&(f-=Math.pow(2,8*e)),f},s.prototype.readInt8=function(t,e){return e||B(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){e||B(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){e||B(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return e||B(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return e||B(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return e||B(t,4,this.length),i.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return e||B(t,4,this.length),i.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return e||B(t,8,this.length),i.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return e||B(t,8,this.length),i.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||T(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,f=0;for(this[e]=255&t;++f=0&&(f*=256);)this[e+i]=t/f&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||T(this,t,e,1,255,0),s.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||T(this,t,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):q(this,t,e,!0),e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||T(this,t,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):q(this,t,e,!1),e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||T(this,t,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):L(this,t,e,!0),e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||T(this,t,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):L(this,t,e,!1),e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);T(this,t,e,r,i-1,-i)}var f=0,o=1,a=0;for(this[e]=255&t;++f>0)-a&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);T(this,t,e,r,i-1,-i)}var f=r-1,o=1,a=0;for(this[e+f]=255&t;--f>=0&&(o*=256);)t<0&&0===a&&0!==this[e+f+1]&&(a=1),this[e+f]=(t/o>>0)-a&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||T(this,t,e,1,127,-128),s.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||T(this,t,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):q(this,t,e,!0),e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||T(this,t,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):q(this,t,e,!1),e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||T(this,t,e,4,2147483647,-2147483648),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):L(this,t,e,!0),e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):L(this,t,e,!1),e+4},s.prototype.writeFloatLE=function(t,e,r){return N(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return N(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return z(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return z(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else if(f<1e3||!s.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(f=e;f55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&f.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&f.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&f.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&f.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;f.push(r)}else if(r<2048){if((e-=2)<0)break;f.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;f.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;f.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return f}function F(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(O,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function D(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}}).call(this,r(65))},function(t,e,r){"use strict";var n=r(6),i=r(7);function f(){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=f,f.prototype.update=function(t,e){if(t=n.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=n.join32(t,0,t.length-r,this.endian);for(var i=0;i>>24&255,n[i++]=t>>>16&255,n[i++]=t>>>8&255,n[i++]=255&t}else for(n[i++]=255&t,n[i++]=t>>>8&255,n[i++]=t>>>16&255,n[i++]=t>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,f=8;f=200&&t<300}};s.headers={common:{Accept:"application/json, text/plain, */*"}},n.forEach(["delete","get","head"],function(t){s.headers[t]={}}),n.forEach(["post","put","patch"],function(t){s.headers[t]=n.merge(f)}),t.exports=s}).call(this,r(45))},function(t,e,r){var n,i,f;i=[r(0),r(1)],void 0===(f="function"==typeof(n=function(e,n){"use strict";var i=r(2);e=i(e),n=i(n);var f=r(24),o=r(28),a=r(25),s=(r(34),function(){function t(r,n){(0,e.default)(this,t),this.gasRatio=r,this.gasLimit=parseInt(n),this.actions=[],this.signers=[],this.signatures=[],this.publisher="",this.publisher_sigs=[],this.amount_limit=[],this.chain_id=1024,this.reserved=null}return(0,n.default)(t,[{key:"setChainID",value:function(t){this.chain_id=t}},{key:"addSigner",value:function(t,e){this.signers.push(t+"@"+e)}},{key:"addApprove",value:function(t,e){this.amount_limit.push({token:t,value:e})}},{key:"addAction",value:function(t,e,r){this.actions.push({contract:t,actionName:e,data:r})}},{key:"setTime",value:function(t,e,r){var n=new Date;this.time=1e6*n.getTime()+r,this.expiration=this.time+1e9*t,this.delay=e}},{key:"setGas",value:function(t,e){if("number"!=typeof e||e>4e6||e<6e3)throw"gas limit should be in [6000, 4000000]";if("number"!=typeof t||t<1||t>100)throw"gas limit should be in [1, 100]";this.gasLimit=e,this.gasRatio=t}},{key:"_base_hash",value:function(){var t=a.SHA3(256);return t.update(this._bytes(0)),t.digest("binary")}},{key:"addSign",value:function(t){var e=new o(this._base_hash(),t);this.signatures.push(e)}},{key:"_publish_hash",value:function(){var t=a.SHA3(256);return t.update(this._bytes(1)),t.digest("binary")}},{key:"addPublishSign",value:function(t,e){this.publisher=t;var r=this._publish_hash(),n=new o(r,e);this.publisher_sigs.push(n)}},{key:"_bytes",value:function(t){var e=new f;e.pushInt64(this.time),e.pushInt64(this.expiration),e.pushInt64(parseInt(100*this.gasRatio)),e.pushInt64(100*this.gasLimit),e.pushInt64(this.delay),e.pushInt(this.chain_id),this.reserved||e.pushInt(0),e.pushInt(this.signers.length);for(var r=0;r0){e.pushInt(this.signatures.length);for(var s=0;s0&&void 0!==arguments[0]?arguments[0]:512;if(!this||this.constructor!==t)return new t(n);var o=new f.default({capacity:n,padding:e});return this.update=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";if(i.Buffer.isBuffer(t))return o.absorb(t),r;if("string"==typeof t)return r.update(i.Buffer.from(t,e));throw new TypeError("Not a string or buffer")},this.digest=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"binary",e=o.squeeze();return t&&"binary"!==t?e.toString(t):e},this.reset=function(){return o.reset(),r},this}},a=o({padding:1});e.Keccak=a;var s=o({padding:6});e.SHA3=s;var u=a;e.SHA3Hash=u,s.SHA3Hash=u;var h=s;e.default=h},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=function(t,e){return function(){for(var r=2*e,n=arguments.length,i=new Array(n),f=0;f=2){var o=2*i[1];t[r]=i[0][o],t[r+1]=i[0][o+1]}for(var a=2;a>>32-e,t[a]=f<>>32-e,t};e.default=i},function(t,e,r){(function(n){var i,f,o;f=[r(0),r(1)],void 0===(o="function"==typeof(i=function(e,i){"use strict";var f=r(2);e=f(e),i=f(i);var o=r(5),a=r(15),s=r(3).ec,u=r(33),h=r(24),c=new s("secp256k1"),d=function(){function t(r,i){if((0,e.default)(this,t),!r)return this.algorithm=void 0,this.pubkey=void 0,void(this.sig=void 0);if(this.algorithm=i.t,this.algorithm===a.Ed25519)this.sig=n.from(u.sign(r,i.seckey)).slice(0,64),this.pubkey=i.pubkey;else{if(this.algorithm!==a.Secp256k1)throw"type error!";var f=c.keyFromPrivate(i.seckey);this.pubkey=i.pubkey;var s=f.sign(r),h=s.r,d=new o("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141",16),l=d.sub(s.s);l.gt(s.s)&&(l=s.s),this.sig=n.concat([n.from(h.toArray()),n.from(l.toArray())])}}return(0,i.default)(t,[{key:"_bytes",value:function(){var t=new h;return t.pushByte(this.algorithm),t.pushBytes(this.sig),t.pushBytes(this.pubkey),t._buf}},{key:"toJSON",value:function(){return{algorithm:1===this.algorithm?"SECP256K1":"ED25519",public_key:this.pubkey.toString("base64"),signature:this.sig.toString("base64")}}},{key:"verify",value:function(t){if(this.algorithm===a.Ed25519)return u.sign.detached.verify(t,this.sig,this.pubkey);if(this.algorithm===a.Secp256k1){var e=new o(this.sig.slice(0,32).toString("hex"),16),r=new o(this.sig.slice(32,64).toString("hex"),16),n={r:e,s:r};return c.verify(t,n,this.pubkey)}}}],[{key:"fromJSON",value:function(e){var r=JSON.parse(e),i={algorithm:"ED25519"===r.algorithm?2:1,pubkey:n.from(r.public_key,"base64"),sig:n.from(r.signature,"base64")};return Object.assign(new t,i)}}]),t}();t.exports=d})?i.apply(e,f):i)||(t.exports=o)}).call(this,r(8).Buffer)},function(t,e,r){"use strict";var n=e;function i(t){return 1===t.length?"0"+t:t}function f(t){for(var e="",r=0;r>8,o=255&i;f?r.push(f,o):r.push(o)}return r},n.zero2=i,n.toHex=f,n.encode=function(t,e){return"hex"===e?f(t):t}},function(t,e,r){"use strict";var n=r(6).rotr32;function i(t,e,r){return t&e^~t&r}function f(t,e,r){return t&e^t&r^e&r}function o(t,e,r){return t^e^r}e.ft_1=function(t,e,r,n){return 0===t?i(e,r,n):1===t||3===t?o(e,r,n):2===t?f(e,r,n):void 0},e.ch32=i,e.maj32=f,e.p32=o,e.s0_256=function(t){return n(t,2)^n(t,13)^n(t,22)},e.s1_256=function(t){return n(t,6)^n(t,11)^n(t,25)},e.g0_256=function(t){return n(t,7)^n(t,18)^t>>>3},e.g1_256=function(t){return n(t,17)^n(t,19)^t>>>10}},function(t,e,r){"use strict";var n=r(6),i=r(9),f=r(30),o=r(7),a=n.sum32,s=n.sum32_4,u=n.sum32_5,h=f.ch32,c=f.maj32,d=f.s0_256,l=f.s1_256,b=f.g0_256,p=f.g1_256,v=i.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;v.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=g,this.W=new Array(64)}n.inherits(y,v),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,n=0;n<16;n++)r[n]=t[e+n];for(;n>24&255,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=255&r,t[e+4]=n>>24&255,t[e+5]=n>>16&255,t[e+6]=n>>8&255,t[e+7]=255&n}function p(t,e,r,n,i){var f,o=0;for(f=0;f>>8)-1}function v(t,e,r,n){return p(t,e,r,n,16)}function g(t,e,r,n){return p(t,e,r,n,32)}function y(t,e,r,n){!function(t,e,r,n){for(var i,f=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,o=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,a=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,s=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,u=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,h=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,l=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,b=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,p=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,v=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,g=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,y=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,m=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,w=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,M=f,_=o,A=a,S=s,x=u,E=h,I=c,k=d,R=l,P=b,B=p,T=v,q=g,L=y,U=m,N=w,z=0;z<20;z+=2)M^=(i=(q^=(i=(R^=(i=(x^=(i=M+q|0)<<7|i>>>25)+M|0)<<9|i>>>23)+x|0)<<13|i>>>19)+R|0)<<18|i>>>14,E^=(i=(_^=(i=(L^=(i=(P^=(i=E+_|0)<<7|i>>>25)+E|0)<<9|i>>>23)+P|0)<<13|i>>>19)+L|0)<<18|i>>>14,B^=(i=(I^=(i=(A^=(i=(U^=(i=B+I|0)<<7|i>>>25)+B|0)<<9|i>>>23)+U|0)<<13|i>>>19)+A|0)<<18|i>>>14,N^=(i=(T^=(i=(k^=(i=(S^=(i=N+T|0)<<7|i>>>25)+N|0)<<9|i>>>23)+S|0)<<13|i>>>19)+k|0)<<18|i>>>14,M^=(i=(S^=(i=(A^=(i=(_^=(i=M+S|0)<<7|i>>>25)+M|0)<<9|i>>>23)+_|0)<<13|i>>>19)+A|0)<<18|i>>>14,E^=(i=(x^=(i=(k^=(i=(I^=(i=E+x|0)<<7|i>>>25)+E|0)<<9|i>>>23)+I|0)<<13|i>>>19)+k|0)<<18|i>>>14,B^=(i=(P^=(i=(R^=(i=(T^=(i=B+P|0)<<7|i>>>25)+B|0)<<9|i>>>23)+T|0)<<13|i>>>19)+R|0)<<18|i>>>14,N^=(i=(U^=(i=(L^=(i=(q^=(i=N+U|0)<<7|i>>>25)+N|0)<<9|i>>>23)+q|0)<<13|i>>>19)+L|0)<<18|i>>>14;M=M+f|0,_=_+o|0,A=A+a|0,S=S+s|0,x=x+u|0,E=E+h|0,I=I+c|0,k=k+d|0,R=R+l|0,P=P+b|0,B=B+p|0,T=T+v|0,q=q+g|0,L=L+y|0,U=U+m|0,N=N+w|0,t[0]=M>>>0&255,t[1]=M>>>8&255,t[2]=M>>>16&255,t[3]=M>>>24&255,t[4]=_>>>0&255,t[5]=_>>>8&255,t[6]=_>>>16&255,t[7]=_>>>24&255,t[8]=A>>>0&255,t[9]=A>>>8&255,t[10]=A>>>16&255,t[11]=A>>>24&255,t[12]=S>>>0&255,t[13]=S>>>8&255,t[14]=S>>>16&255,t[15]=S>>>24&255,t[16]=x>>>0&255,t[17]=x>>>8&255,t[18]=x>>>16&255,t[19]=x>>>24&255,t[20]=E>>>0&255,t[21]=E>>>8&255,t[22]=E>>>16&255,t[23]=E>>>24&255,t[24]=I>>>0&255,t[25]=I>>>8&255,t[26]=I>>>16&255,t[27]=I>>>24&255,t[28]=k>>>0&255,t[29]=k>>>8&255,t[30]=k>>>16&255,t[31]=k>>>24&255,t[32]=R>>>0&255,t[33]=R>>>8&255,t[34]=R>>>16&255,t[35]=R>>>24&255,t[36]=P>>>0&255,t[37]=P>>>8&255,t[38]=P>>>16&255,t[39]=P>>>24&255,t[40]=B>>>0&255,t[41]=B>>>8&255,t[42]=B>>>16&255,t[43]=B>>>24&255,t[44]=T>>>0&255,t[45]=T>>>8&255,t[46]=T>>>16&255,t[47]=T>>>24&255,t[48]=q>>>0&255,t[49]=q>>>8&255,t[50]=q>>>16&255,t[51]=q>>>24&255,t[52]=L>>>0&255,t[53]=L>>>8&255,t[54]=L>>>16&255,t[55]=L>>>24&255,t[56]=U>>>0&255,t[57]=U>>>8&255,t[58]=U>>>16&255,t[59]=U>>>24&255,t[60]=N>>>0&255,t[61]=N>>>8&255,t[62]=N>>>16&255,t[63]=N>>>24&255}(t,e,r,n)}function m(t,e,r,n){!function(t,e,r,n){for(var i,f=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,o=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,a=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,s=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,u=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,h=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,l=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,b=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,p=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,v=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,g=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,y=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,m=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,w=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,M=0;M<20;M+=2)f^=(i=(g^=(i=(l^=(i=(u^=(i=f+g|0)<<7|i>>>25)+f|0)<<9|i>>>23)+u|0)<<13|i>>>19)+l|0)<<18|i>>>14,h^=(i=(o^=(i=(y^=(i=(b^=(i=h+o|0)<<7|i>>>25)+h|0)<<9|i>>>23)+b|0)<<13|i>>>19)+y|0)<<18|i>>>14,p^=(i=(c^=(i=(a^=(i=(m^=(i=p+c|0)<<7|i>>>25)+p|0)<<9|i>>>23)+m|0)<<13|i>>>19)+a|0)<<18|i>>>14,w^=(i=(v^=(i=(d^=(i=(s^=(i=w+v|0)<<7|i>>>25)+w|0)<<9|i>>>23)+s|0)<<13|i>>>19)+d|0)<<18|i>>>14,f^=(i=(s^=(i=(a^=(i=(o^=(i=f+s|0)<<7|i>>>25)+f|0)<<9|i>>>23)+o|0)<<13|i>>>19)+a|0)<<18|i>>>14,h^=(i=(u^=(i=(d^=(i=(c^=(i=h+u|0)<<7|i>>>25)+h|0)<<9|i>>>23)+c|0)<<13|i>>>19)+d|0)<<18|i>>>14,p^=(i=(b^=(i=(l^=(i=(v^=(i=p+b|0)<<7|i>>>25)+p|0)<<9|i>>>23)+v|0)<<13|i>>>19)+l|0)<<18|i>>>14,w^=(i=(m^=(i=(y^=(i=(g^=(i=w+m|0)<<7|i>>>25)+w|0)<<9|i>>>23)+g|0)<<13|i>>>19)+y|0)<<18|i>>>14;t[0]=f>>>0&255,t[1]=f>>>8&255,t[2]=f>>>16&255,t[3]=f>>>24&255,t[4]=h>>>0&255,t[5]=h>>>8&255,t[6]=h>>>16&255,t[7]=h>>>24&255,t[8]=p>>>0&255,t[9]=p>>>8&255,t[10]=p>>>16&255,t[11]=p>>>24&255,t[12]=w>>>0&255,t[13]=w>>>8&255,t[14]=w>>>16&255,t[15]=w>>>24&255,t[16]=c>>>0&255,t[17]=c>>>8&255,t[18]=c>>>16&255,t[19]=c>>>24&255,t[20]=d>>>0&255,t[21]=d>>>8&255,t[22]=d>>>16&255,t[23]=d>>>24&255,t[24]=l>>>0&255,t[25]=l>>>8&255,t[26]=l>>>16&255,t[27]=l>>>24&255,t[28]=b>>>0&255,t[29]=b>>>8&255,t[30]=b>>>16&255,t[31]=b>>>24&255}(t,e,r,n)}var w=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function M(t,e,r,n,i,f,o){var a,s,u=new Uint8Array(16),h=new Uint8Array(64);for(s=0;s<16;s++)u[s]=0;for(s=0;s<8;s++)u[s]=f[s];for(;i>=64;){for(y(h,u,o,w),s=0;s<64;s++)t[e+s]=r[n+s]^h[s];for(a=1,s=8;s<16;s++)a=a+(255&u[s])|0,u[s]=255&a,a>>>=8;i-=64,e+=64,n+=64}if(i>0)for(y(h,u,o,w),s=0;s=64;){for(y(s,a,i,w),o=0;o<64;o++)t[e+o]=s[o];for(f=1,o=8;o<16;o++)f=f+(255&a[o])|0,a[o]=255&f,f>>>=8;r-=64,e+=64}if(r>0)for(y(s,a,i,w),o=0;o>>13|r<<3),n=255&t[4]|(255&t[5])<<8,this.r[2]=7939&(r>>>10|n<<6),i=255&t[6]|(255&t[7])<<8,this.r[3]=8191&(n>>>7|i<<9),f=255&t[8]|(255&t[9])<<8,this.r[4]=255&(i>>>4|f<<12),this.r[5]=f>>>1&8190,o=255&t[10]|(255&t[11])<<8,this.r[6]=8191&(f>>>14|o<<2),a=255&t[12]|(255&t[13])<<8,this.r[7]=8065&(o>>>11|a<<5),s=255&t[14]|(255&t[15])<<8,this.r[8]=8191&(a>>>8|s<<8),this.r[9]=s>>>5&127,this.pad[0]=255&t[16]|(255&t[17])<<8,this.pad[1]=255&t[18]|(255&t[19])<<8,this.pad[2]=255&t[20]|(255&t[21])<<8,this.pad[3]=255&t[22]|(255&t[23])<<8,this.pad[4]=255&t[24]|(255&t[25])<<8,this.pad[5]=255&t[26]|(255&t[27])<<8,this.pad[6]=255&t[28]|(255&t[29])<<8,this.pad[7]=255&t[30]|(255&t[31])<<8};function E(t,e,r,n,i,f){var o=new x(f);return o.update(r,n,i),o.finish(t,e),0}function I(t,e,r,n,i,f){var o=new Uint8Array(16);return E(o,0,r,n,i,f),v(t,e,o,0)}function k(t,e,r,n,i){var f;if(r<32)return-1;for(S(t,0,e,0,r,n,i),E(t,16,t,32,r-32,t),f=0;f<16;f++)t[f]=0;return 0}function R(t,e,r,n,i){var f,o=new Uint8Array(32);if(r<32)return-1;if(A(o,0,32,n,i),0!==I(e,16,e,32,r-32,o))return-1;for(S(t,0,e,0,r,n,i),f=0;f<32;f++)t[f]=0;return 0}function P(t,e){var r;for(r=0;r<16;r++)t[r]=0|e[r]}function B(t){var e,r,n=1;for(e=0;e<16;e++)r=t[e]+n+65535,n=Math.floor(r/65536),t[e]=r-65536*n;t[0]+=n-1+37*(n-1)}function T(t,e,r){for(var n,i=~(r-1),f=0;f<16;f++)n=i&(t[f]^e[f]),t[f]^=n,e[f]^=n}function q(t,r){var n,i,f,o=e(),a=e();for(n=0;n<16;n++)a[n]=r[n];for(B(a),B(a),B(a),i=0;i<2;i++){for(o[0]=a[0]-65517,n=1;n<15;n++)o[n]=a[n]-65535-(o[n-1]>>16&1),o[n-1]&=65535;o[15]=a[15]-32767-(o[14]>>16&1),f=o[15]>>16&1,o[14]&=65535,T(a,o,1-f)}for(n=0;n<16;n++)t[2*n]=255&a[n],t[2*n+1]=a[n]>>8}function L(t,e){var r=new Uint8Array(32),n=new Uint8Array(32);return q(r,t),q(n,e),g(r,0,n,0)}function U(t){var e=new Uint8Array(32);return q(e,t),1&e[0]}function N(t,e){var r;for(r=0;r<16;r++)t[r]=e[2*r]+(e[2*r+1]<<8);t[15]&=32767}function z(t,e,r){for(var n=0;n<16;n++)t[n]=e[n]+r[n]}function O(t,e,r){for(var n=0;n<16;n++)t[n]=e[n]-r[n]}function C(t,e,r){var n,i,f=0,o=0,a=0,s=0,u=0,h=0,c=0,d=0,l=0,b=0,p=0,v=0,g=0,y=0,m=0,w=0,M=0,_=0,A=0,S=0,x=0,E=0,I=0,k=0,R=0,P=0,B=0,T=0,q=0,L=0,U=0,N=r[0],z=r[1],O=r[2],C=r[3],j=r[4],F=r[5],D=r[6],Y=r[7],K=r[8],H=r[9],J=r[10],Z=r[11],X=r[12],V=r[13],W=r[14],G=r[15];f+=(n=e[0])*N,o+=n*z,a+=n*O,s+=n*C,u+=n*j,h+=n*F,c+=n*D,d+=n*Y,l+=n*K,b+=n*H,p+=n*J,v+=n*Z,g+=n*X,y+=n*V,m+=n*W,w+=n*G,o+=(n=e[1])*N,a+=n*z,s+=n*O,u+=n*C,h+=n*j,c+=n*F,d+=n*D,l+=n*Y,b+=n*K,p+=n*H,v+=n*J,g+=n*Z,y+=n*X,m+=n*V,w+=n*W,M+=n*G,a+=(n=e[2])*N,s+=n*z,u+=n*O,h+=n*C,c+=n*j,d+=n*F,l+=n*D,b+=n*Y,p+=n*K,v+=n*H,g+=n*J,y+=n*Z,m+=n*X,w+=n*V,M+=n*W,_+=n*G,s+=(n=e[3])*N,u+=n*z,h+=n*O,c+=n*C,d+=n*j,l+=n*F,b+=n*D,p+=n*Y,v+=n*K,g+=n*H,y+=n*J,m+=n*Z,w+=n*X,M+=n*V,_+=n*W,A+=n*G,u+=(n=e[4])*N,h+=n*z,c+=n*O,d+=n*C,l+=n*j,b+=n*F,p+=n*D,v+=n*Y,g+=n*K,y+=n*H,m+=n*J,w+=n*Z,M+=n*X,_+=n*V,A+=n*W,S+=n*G,h+=(n=e[5])*N,c+=n*z,d+=n*O,l+=n*C,b+=n*j,p+=n*F,v+=n*D,g+=n*Y,y+=n*K,m+=n*H,w+=n*J,M+=n*Z,_+=n*X,A+=n*V,S+=n*W,x+=n*G,c+=(n=e[6])*N,d+=n*z,l+=n*O,b+=n*C,p+=n*j,v+=n*F,g+=n*D,y+=n*Y,m+=n*K,w+=n*H,M+=n*J,_+=n*Z,A+=n*X,S+=n*V,x+=n*W,E+=n*G,d+=(n=e[7])*N,l+=n*z,b+=n*O,p+=n*C,v+=n*j,g+=n*F,y+=n*D,m+=n*Y,w+=n*K,M+=n*H,_+=n*J,A+=n*Z,S+=n*X,x+=n*V,E+=n*W,I+=n*G,l+=(n=e[8])*N,b+=n*z,p+=n*O,v+=n*C,g+=n*j,y+=n*F,m+=n*D,w+=n*Y,M+=n*K,_+=n*H,A+=n*J,S+=n*Z,x+=n*X,E+=n*V,I+=n*W,k+=n*G,b+=(n=e[9])*N,p+=n*z,v+=n*O,g+=n*C,y+=n*j,m+=n*F,w+=n*D,M+=n*Y,_+=n*K,A+=n*H,S+=n*J,x+=n*Z,E+=n*X,I+=n*V,k+=n*W,R+=n*G,p+=(n=e[10])*N,v+=n*z,g+=n*O,y+=n*C,m+=n*j,w+=n*F,M+=n*D,_+=n*Y,A+=n*K,S+=n*H,x+=n*J,E+=n*Z,I+=n*X,k+=n*V,R+=n*W,P+=n*G,v+=(n=e[11])*N,g+=n*z,y+=n*O,m+=n*C,w+=n*j,M+=n*F,_+=n*D,A+=n*Y,S+=n*K,x+=n*H,E+=n*J,I+=n*Z,k+=n*X,R+=n*V,P+=n*W,B+=n*G,g+=(n=e[12])*N,y+=n*z,m+=n*O,w+=n*C,M+=n*j,_+=n*F,A+=n*D,S+=n*Y,x+=n*K,E+=n*H,I+=n*J,k+=n*Z,R+=n*X,P+=n*V,B+=n*W,T+=n*G,y+=(n=e[13])*N,m+=n*z,w+=n*O,M+=n*C,_+=n*j,A+=n*F,S+=n*D,x+=n*Y,E+=n*K,I+=n*H,k+=n*J,R+=n*Z,P+=n*X,B+=n*V,T+=n*W,q+=n*G,m+=(n=e[14])*N,w+=n*z,M+=n*O,_+=n*C,A+=n*j,S+=n*F,x+=n*D,E+=n*Y,I+=n*K,k+=n*H,R+=n*J,P+=n*Z,B+=n*X,T+=n*V,q+=n*W,L+=n*G,w+=(n=e[15])*N,o+=38*(_+=n*O),a+=38*(A+=n*C),s+=38*(S+=n*j),u+=38*(x+=n*F),h+=38*(E+=n*D),c+=38*(I+=n*Y),d+=38*(k+=n*K),l+=38*(R+=n*H),b+=38*(P+=n*J),p+=38*(B+=n*Z),v+=38*(T+=n*X),g+=38*(q+=n*V),y+=38*(L+=n*W),m+=38*(U+=n*G),f=(n=(f+=38*(M+=n*z))+(i=1)+65535)-65536*(i=Math.floor(n/65536)),o=(n=o+i+65535)-65536*(i=Math.floor(n/65536)),a=(n=a+i+65535)-65536*(i=Math.floor(n/65536)),s=(n=s+i+65535)-65536*(i=Math.floor(n/65536)),u=(n=u+i+65535)-65536*(i=Math.floor(n/65536)),h=(n=h+i+65535)-65536*(i=Math.floor(n/65536)),c=(n=c+i+65535)-65536*(i=Math.floor(n/65536)),d=(n=d+i+65535)-65536*(i=Math.floor(n/65536)),l=(n=l+i+65535)-65536*(i=Math.floor(n/65536)),b=(n=b+i+65535)-65536*(i=Math.floor(n/65536)),p=(n=p+i+65535)-65536*(i=Math.floor(n/65536)),v=(n=v+i+65535)-65536*(i=Math.floor(n/65536)),g=(n=g+i+65535)-65536*(i=Math.floor(n/65536)),y=(n=y+i+65535)-65536*(i=Math.floor(n/65536)),m=(n=m+i+65535)-65536*(i=Math.floor(n/65536)),w=(n=w+i+65535)-65536*(i=Math.floor(n/65536)),f=(n=(f+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(n/65536)),o=(n=o+i+65535)-65536*(i=Math.floor(n/65536)),a=(n=a+i+65535)-65536*(i=Math.floor(n/65536)),s=(n=s+i+65535)-65536*(i=Math.floor(n/65536)),u=(n=u+i+65535)-65536*(i=Math.floor(n/65536)),h=(n=h+i+65535)-65536*(i=Math.floor(n/65536)),c=(n=c+i+65535)-65536*(i=Math.floor(n/65536)),d=(n=d+i+65535)-65536*(i=Math.floor(n/65536)),l=(n=l+i+65535)-65536*(i=Math.floor(n/65536)),b=(n=b+i+65535)-65536*(i=Math.floor(n/65536)),p=(n=p+i+65535)-65536*(i=Math.floor(n/65536)),v=(n=v+i+65535)-65536*(i=Math.floor(n/65536)),g=(n=g+i+65535)-65536*(i=Math.floor(n/65536)),y=(n=y+i+65535)-65536*(i=Math.floor(n/65536)),m=(n=m+i+65535)-65536*(i=Math.floor(n/65536)),w=(n=w+i+65535)-65536*(i=Math.floor(n/65536)),f+=i-1+37*(i-1),t[0]=f,t[1]=o,t[2]=a,t[3]=s,t[4]=u,t[5]=h,t[6]=c,t[7]=d,t[8]=l,t[9]=b,t[10]=p,t[11]=v,t[12]=g,t[13]=y,t[14]=m,t[15]=w}function j(t,e){C(t,e,e)}function F(t,r){var n,i=e();for(n=0;n<16;n++)i[n]=r[n];for(n=253;n>=0;n--)j(i,i),2!==n&&4!==n&&C(i,i,r);for(n=0;n<16;n++)t[n]=i[n]}function D(t,r,n){var i,f,o=new Uint8Array(32),a=new Float64Array(80),u=e(),h=e(),c=e(),d=e(),l=e(),b=e();for(f=0;f<31;f++)o[f]=r[f];for(o[31]=127&r[31]|64,o[0]&=248,N(a,n),f=0;f<16;f++)h[f]=a[f],d[f]=u[f]=c[f]=0;for(u[0]=d[0]=1,f=254;f>=0;--f)T(u,h,i=o[f>>>3]>>>(7&f)&1),T(c,d,i),z(l,u,c),O(u,u,c),z(c,h,d),O(h,h,d),j(d,l),j(b,u),C(u,c,u),C(c,h,l),z(l,u,c),O(u,u,c),j(h,u),O(c,d,b),C(u,c,s),z(u,u,d),C(c,c,u),C(u,d,b),C(d,h,a),j(h,l),T(u,h,i),T(c,d,i);for(f=0;f<16;f++)a[f+16]=u[f],a[f+32]=c[f],a[f+48]=h[f],a[f+64]=d[f];var p=a.subarray(32),v=a.subarray(16);return F(p,p),C(v,v,p),q(t,v),0}function Y(t,e){return D(t,e,f)}function K(t,e){return n(e,32),Y(t,e)}function H(t,e,r){var n=new Uint8Array(32);return D(n,r,e),m(t,i,n,w)}x.prototype.blocks=function(t,e,r){for(var n,i,f,o,a,s,u,h,c,d,l,b,p,v,g,y,m,w,M,_=this.fin?0:2048,A=this.h[0],S=this.h[1],x=this.h[2],E=this.h[3],I=this.h[4],k=this.h[5],R=this.h[6],P=this.h[7],B=this.h[8],T=this.h[9],q=this.r[0],L=this.r[1],U=this.r[2],N=this.r[3],z=this.r[4],O=this.r[5],C=this.r[6],j=this.r[7],F=this.r[8],D=this.r[9];r>=16;)d=c=0,d+=(A+=8191&(n=255&t[e+0]|(255&t[e+1])<<8))*q,d+=(S+=8191&(n>>>13|(i=255&t[e+2]|(255&t[e+3])<<8)<<3))*(5*D),d+=(x+=8191&(i>>>10|(f=255&t[e+4]|(255&t[e+5])<<8)<<6))*(5*F),d+=(E+=8191&(f>>>7|(o=255&t[e+6]|(255&t[e+7])<<8)<<9))*(5*j),c=(d+=(I+=8191&(o>>>4|(a=255&t[e+8]|(255&t[e+9])<<8)<<12))*(5*C))>>>13,d&=8191,d+=(k+=a>>>1&8191)*(5*O),d+=(R+=8191&(a>>>14|(s=255&t[e+10]|(255&t[e+11])<<8)<<2))*(5*z),d+=(P+=8191&(s>>>11|(u=255&t[e+12]|(255&t[e+13])<<8)<<5))*(5*N),d+=(B+=8191&(u>>>8|(h=255&t[e+14]|(255&t[e+15])<<8)<<8))*(5*U),l=c+=(d+=(T+=h>>>5|_)*(5*L))>>>13,l+=A*L,l+=S*q,l+=x*(5*D),l+=E*(5*F),c=(l+=I*(5*j))>>>13,l&=8191,l+=k*(5*C),l+=R*(5*O),l+=P*(5*z),l+=B*(5*N),c+=(l+=T*(5*U))>>>13,l&=8191,b=c,b+=A*U,b+=S*L,b+=x*q,b+=E*(5*D),c=(b+=I*(5*F))>>>13,b&=8191,b+=k*(5*j),b+=R*(5*C),b+=P*(5*O),b+=B*(5*z),p=c+=(b+=T*(5*N))>>>13,p+=A*N,p+=S*U,p+=x*L,p+=E*q,c=(p+=I*(5*D))>>>13,p&=8191,p+=k*(5*F),p+=R*(5*j),p+=P*(5*C),p+=B*(5*O),v=c+=(p+=T*(5*z))>>>13,v+=A*z,v+=S*N,v+=x*U,v+=E*L,c=(v+=I*q)>>>13,v&=8191,v+=k*(5*D),v+=R*(5*F),v+=P*(5*j),v+=B*(5*C),g=c+=(v+=T*(5*O))>>>13,g+=A*O,g+=S*z,g+=x*N,g+=E*U,c=(g+=I*L)>>>13,g&=8191,g+=k*q,g+=R*(5*D),g+=P*(5*F),g+=B*(5*j),y=c+=(g+=T*(5*C))>>>13,y+=A*C,y+=S*O,y+=x*z,y+=E*N,c=(y+=I*U)>>>13,y&=8191,y+=k*L,y+=R*q,y+=P*(5*D),y+=B*(5*F),m=c+=(y+=T*(5*j))>>>13,m+=A*j,m+=S*C,m+=x*O,m+=E*z,c=(m+=I*N)>>>13,m&=8191,m+=k*U,m+=R*L,m+=P*q,m+=B*(5*D),w=c+=(m+=T*(5*F))>>>13,w+=A*F,w+=S*j,w+=x*C,w+=E*O,c=(w+=I*z)>>>13,w&=8191,w+=k*N,w+=R*U,w+=P*L,w+=B*q,M=c+=(w+=T*(5*D))>>>13,M+=A*D,M+=S*F,M+=x*j,M+=E*C,c=(M+=I*O)>>>13,M&=8191,M+=k*z,M+=R*N,M+=P*U,M+=B*L,A=d=8191&(c=(c=((c+=(M+=T*q)>>>13)<<2)+c|0)+(d&=8191)|0),S=l+=c>>>=13,x=b&=8191,E=p&=8191,I=v&=8191,k=g&=8191,R=y&=8191,P=m&=8191,B=w&=8191,T=M&=8191,e+=16,r-=16;this.h[0]=A,this.h[1]=S,this.h[2]=x,this.h[3]=E,this.h[4]=I,this.h[5]=k,this.h[6]=R,this.h[7]=P,this.h[8]=B,this.h[9]=T},x.prototype.finish=function(t,e){var r,n,i,f,o=new Uint16Array(10);if(this.leftover){for(f=this.leftover,this.buffer[f++]=1;f<16;f++)this.buffer[f]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(r=this.h[1]>>>13,this.h[1]&=8191,f=2;f<10;f++)this.h[f]+=r,r=this.h[f]>>>13,this.h[f]&=8191;for(this.h[0]+=5*r,r=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=r,r=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=r,o[0]=this.h[0]+5,r=o[0]>>>13,o[0]&=8191,f=1;f<10;f++)o[f]=this.h[f]+r,r=o[f]>>>13,o[f]&=8191;for(o[9]-=8192,n=(1^r)-1,f=0;f<10;f++)o[f]&=n;for(n=~n,f=0;f<10;f++)this.h[f]=this.h[f]&n|o[f];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),i=this.h[0]+this.pad[0],this.h[0]=65535&i,f=1;f<8;f++)i=(this.h[f]+this.pad[f]|0)+(i>>>16)|0,this.h[f]=65535&i;t[e+0]=this.h[0]>>>0&255,t[e+1]=this.h[0]>>>8&255,t[e+2]=this.h[1]>>>0&255,t[e+3]=this.h[1]>>>8&255,t[e+4]=this.h[2]>>>0&255,t[e+5]=this.h[2]>>>8&255,t[e+6]=this.h[3]>>>0&255,t[e+7]=this.h[3]>>>8&255,t[e+8]=this.h[4]>>>0&255,t[e+9]=this.h[4]>>>8&255,t[e+10]=this.h[5]>>>0&255,t[e+11]=this.h[5]>>>8&255,t[e+12]=this.h[6]>>>0&255,t[e+13]=this.h[6]>>>8&255,t[e+14]=this.h[7]>>>0&255,t[e+15]=this.h[7]>>>8&255},x.prototype.update=function(t,e,r){var n,i;if(this.leftover){for((i=16-this.leftover)>r&&(i=r),n=0;n=16&&(i=r-r%16,this.blocks(t,e,i),e+=i,r-=i),r){for(n=0;n=128;){for(_=0;_<16;_++)A=8*_+V,P[_]=r[A+0]<<24|r[A+1]<<16|r[A+2]<<8|r[A+3],B[_]=r[A+4]<<24|r[A+5]<<16|r[A+6]<<8|r[A+7];for(_=0;_<80;_++)if(i=T,f=q,o=L,a=U,s=N,u=z,h=O,C,d=j,l=F,b=D,p=Y,v=K,g=H,y=J,Z,E=65535&(x=Z),I=x>>>16,k=65535&(S=C),R=S>>>16,E+=65535&(x=(K>>>14|N<<18)^(K>>>18|N<<14)^(N>>>9|K<<23)),I+=x>>>16,k+=65535&(S=(N>>>14|K<<18)^(N>>>18|K<<14)^(K>>>9|N<<23)),R+=S>>>16,E+=65535&(x=K&H^~K&J),I+=x>>>16,k+=65535&(S=N&z^~N&O),R+=S>>>16,S=X[2*_],E+=65535&(x=X[2*_+1]),I+=x>>>16,k+=65535&S,R+=S>>>16,S=P[_%16],I+=(x=B[_%16])>>>16,k+=65535&S,R+=S>>>16,k+=(I+=(E+=65535&x)>>>16)>>>16,E=65535&(x=M=65535&E|I<<16),I=x>>>16,k=65535&(S=w=65535&k|(R+=k>>>16)<<16),R=S>>>16,E+=65535&(x=(j>>>28|T<<4)^(T>>>2|j<<30)^(T>>>7|j<<25)),I+=x>>>16,k+=65535&(S=(T>>>28|j<<4)^(j>>>2|T<<30)^(j>>>7|T<<25)),R+=S>>>16,I+=(x=j&F^j&D^F&D)>>>16,k+=65535&(S=T&q^T&L^q&L),R+=S>>>16,c=65535&(k+=(I+=(E+=65535&x)>>>16)>>>16)|(R+=k>>>16)<<16,m=65535&E|I<<16,E=65535&(x=p),I=x>>>16,k=65535&(S=a),R=S>>>16,I+=(x=M)>>>16,k+=65535&(S=w),R+=S>>>16,q=i,L=f,U=o,N=a=65535&(k+=(I+=(E+=65535&x)>>>16)>>>16)|(R+=k>>>16)<<16,z=s,O=u,C=h,T=c,F=d,D=l,Y=b,K=p=65535&E|I<<16,H=v,J=g,Z=y,j=m,_%16==15)for(A=0;A<16;A++)S=P[A],E=65535&(x=B[A]),I=x>>>16,k=65535&S,R=S>>>16,S=P[(A+9)%16],E+=65535&(x=B[(A+9)%16]),I+=x>>>16,k+=65535&S,R+=S>>>16,w=P[(A+1)%16],E+=65535&(x=((M=B[(A+1)%16])>>>1|w<<31)^(M>>>8|w<<24)^(M>>>7|w<<25)),I+=x>>>16,k+=65535&(S=(w>>>1|M<<31)^(w>>>8|M<<24)^w>>>7),R+=S>>>16,w=P[(A+14)%16],I+=(x=((M=B[(A+14)%16])>>>19|w<<13)^(w>>>29|M<<3)^(M>>>6|w<<26))>>>16,k+=65535&(S=(w>>>19|M<<13)^(M>>>29|w<<3)^w>>>6),R+=S>>>16,R+=(k+=(I+=(E+=65535&x)>>>16)>>>16)>>>16,P[A]=65535&k|R<<16,B[A]=65535&E|I<<16;E=65535&(x=j),I=x>>>16,k=65535&(S=T),R=S>>>16,S=t[0],I+=(x=e[0])>>>16,k+=65535&S,R+=S>>>16,R+=(k+=(I+=(E+=65535&x)>>>16)>>>16)>>>16,t[0]=T=65535&k|R<<16,e[0]=j=65535&E|I<<16,E=65535&(x=F),I=x>>>16,k=65535&(S=q),R=S>>>16,S=t[1],I+=(x=e[1])>>>16,k+=65535&S,R+=S>>>16,R+=(k+=(I+=(E+=65535&x)>>>16)>>>16)>>>16,t[1]=q=65535&k|R<<16,e[1]=F=65535&E|I<<16,E=65535&(x=D),I=x>>>16,k=65535&(S=L),R=S>>>16,S=t[2],I+=(x=e[2])>>>16,k+=65535&S,R+=S>>>16,R+=(k+=(I+=(E+=65535&x)>>>16)>>>16)>>>16,t[2]=L=65535&k|R<<16,e[2]=D=65535&E|I<<16,E=65535&(x=Y),I=x>>>16,k=65535&(S=U),R=S>>>16,S=t[3],I+=(x=e[3])>>>16,k+=65535&S,R+=S>>>16,R+=(k+=(I+=(E+=65535&x)>>>16)>>>16)>>>16,t[3]=U=65535&k|R<<16,e[3]=Y=65535&E|I<<16,E=65535&(x=K),I=x>>>16,k=65535&(S=N),R=S>>>16,S=t[4],I+=(x=e[4])>>>16,k+=65535&S,R+=S>>>16,R+=(k+=(I+=(E+=65535&x)>>>16)>>>16)>>>16,t[4]=N=65535&k|R<<16,e[4]=K=65535&E|I<<16,E=65535&(x=H),I=x>>>16,k=65535&(S=z),R=S>>>16,S=t[5],I+=(x=e[5])>>>16,k+=65535&S,R+=S>>>16,R+=(k+=(I+=(E+=65535&x)>>>16)>>>16)>>>16,t[5]=z=65535&k|R<<16,e[5]=H=65535&E|I<<16,E=65535&(x=J),I=x>>>16,k=65535&(S=O),R=S>>>16,S=t[6],I+=(x=e[6])>>>16,k+=65535&S,R+=S>>>16,R+=(k+=(I+=(E+=65535&x)>>>16)>>>16)>>>16,t[6]=O=65535&k|R<<16,e[6]=J=65535&E|I<<16,E=65535&(x=Z),I=x>>>16,k=65535&(S=C),R=S>>>16,S=t[7],I+=(x=e[7])>>>16,k+=65535&S,R+=S>>>16,R+=(k+=(I+=(E+=65535&x)>>>16)>>>16)>>>16,t[7]=C=65535&k|R<<16,e[7]=Z=65535&E|I<<16,V+=128,n-=128}return n}function W(t,e,r){var n,i=new Int32Array(8),f=new Int32Array(8),o=new Uint8Array(256),a=r;for(i[0]=1779033703,i[1]=3144134277,i[2]=1013904242,i[3]=2773480762,i[4]=1359893119,i[5]=2600822924,i[6]=528734635,i[7]=1541459225,f[0]=4089235720,f[1]=2227873595,f[2]=4271175723,f[3]=1595750129,f[4]=2917565137,f[5]=725511199,f[6]=4215389547,f[7]=327033209,V(i,f,e,r),r%=128,n=0;n=0;--i)$(t,e,n=r[i/8|0]>>(7&i)&1),G(e,t),G(t,t),$(t,e,n)}function et(t,r){var n=[e(),e(),e(),e()];P(n[0],c),P(n[1],d),P(n[2],a),C(n[3],c,d),tt(t,n,r)}function rt(t,r,i){var f,o=new Uint8Array(64),a=[e(),e(),e(),e()];for(i||n(r,32),W(o,r,32),o[0]&=248,o[31]&=127,o[31]|=64,et(a,o),Q(t,a),f=0;f<32;f++)r[f+32]=t[f];return 0}var nt=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function it(t,e){var r,n,i,f;for(n=63;n>=32;--n){for(r=0,i=n-32,f=n-12;i>8,e[i]-=256*r;e[i]+=r,e[n]=0}for(r=0,i=0;i<32;i++)e[i]+=r-(e[31]>>4)*nt[i],r=e[i]>>8,e[i]&=255;for(i=0;i<32;i++)e[i]-=r*nt[i];for(n=0;n<32;n++)e[n+1]+=e[n]>>8,t[n]=255&e[n]}function ft(t){var e,r=new Float64Array(64);for(e=0;e<64;e++)r[e]=t[e];for(e=0;e<64;e++)t[e]=0;it(t,r)}function ot(t,r,n,i){var f,o,a=new Uint8Array(64),s=new Uint8Array(64),u=new Uint8Array(64),h=new Float64Array(64),c=[e(),e(),e(),e()];W(a,i,32),a[0]&=248,a[31]&=127,a[31]|=64;var d=n+64;for(f=0;f=0;n--)j(i,i),1!==n&&C(i,i,r);for(n=0;n<16;n++)t[n]=i[n]}(n,n),C(n,n,f),C(n,n,s),C(n,n,s),C(t[0],n,s),j(i,t[0]),C(i,i,s),L(i,f)&&C(t[0],t[0],l),j(i,t[0]),C(i,i,s),L(i,f)?-1:(U(t[0])===r[31]>>7&&O(t[0],o,t[0]),C(t[3],t[0],t[1]),0)}function st(t,r,n,i){var f,o=new Uint8Array(32),a=new Uint8Array(64),s=[e(),e(),e(),e()],u=[e(),e(),e(),e()];if(-1,n<64)return-1;if(at(u,i))return-1;for(f=0;f=0},t.sign.keyPair=function(){var t=new Uint8Array(32),e=new Uint8Array(64);return rt(t,e),{publicKey:t,secretKey:e}},t.sign.keyPair.fromSecretKey=function(t){if(pt(t),64!==t.length)throw new Error("bad secret key size");for(var e=new Uint8Array(32),r=0;r1&&void 0!==arguments[1]?arguments[1]:o.Ed25519;if((0,e.default)(this,t),this.t=f,this.seckey=r,this.t===o.Ed25519){var a=s.sign.keyPair.fromSeed(r.slice(0,32));this.seckey=n.from(a.secretKey.buffer),this.pubkey=this.seckey.slice(this.seckey.length/2)}else if(this.t===o.Secp256k1){var c=h.keyFromPrivate(r);this.pubkey=n.from(c.getPublic(!0,"hex"),"hex"),this.seckey=r}this.id=(i=this.pubkey,u.encode(i))}return(0,i.default)(t,[{key:"B58SecKey",value:function(){return u.encode(this.seckey)}},{key:"B58PubKey",value:function(){return u.encode(this.pubkey)}}],[{key:"newKeyPair",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:o.Ed25519;if(e===o.Ed25519){var r=s.sign.keyPair();return new t(n.from(r.secretKey.buffer),e)}if(e===o.Secp256k1){var i=h.genKeyPair(),f=n.from(i.getPrivate("hex"),"hex");return new t(f,e)}throw"invalid account type"}}]),t}();t.exports=c})?i.apply(e,f):i)||(t.exports=o)}).call(this,r(8).Buffer)},function(t,e,r){var n,i,f;i=[r(108),r(0),r(1)],void 0===(f="function"==typeof(n=function(e,n,i){"use strict";var f=r(2);e=f(e),n=f(n),i=f(i);var o=r(13).Tx,a=function(){function t(e,r){(0,n.default)(this,t),this.tx=e;var i=this;this.Pending=function(t){console.log("Pending... tx: "+t.hash+", "+JSON.stringify(i.tx.actions)),i.status="pending"},this.Success=function(t){console.log("Success... tx, receipt: "+JSON.stringify(t)),i.status="success"},this.Failed=function(t){console.log("Error... tx failed, res: "+JSON.stringify(t)+", tx: "+JSON.stringify(i.tx)),i.status="failed"},this._rpc=r,this._hash="",this.status="idle"}return(0,i.default)(t,[{key:"onPending",value:function(t){var r=this;return this.Pending=function(n){r.status="pending";try{var i=t(n);"object"===(0,e.default)(i)&&"function"==typeof i.catch&&i.catch(function(t){return console.error("on pending failed. ",t)})}catch(t){console.error("on pending failed. ",t)}},this}},{key:"onSuccess",value:function(t){var r=this;return this.Success=function(n){r.status="success";try{var i=t(n);"object"===(0,e.default)(i)&&"function"==typeof i.catch&&i.catch(function(t){return console.error("on success failed. ",t)})}catch(t){console.error("on success failed. ",t)}},this}},{key:"onFailed",value:function(t){var r=this;return this.Failed=function(n){r.status="failed";try{var i=t(n);"object"===(0,e.default)(i)&&"function"==typeof i.catch&&i.catch(function(t){return console.log("on failed failed. ",t)})}catch(t){console.log("on failed failed. ",t)}},this}},{key:"send",value:function(){var t=this;return t._rpc.transaction.sendTx(t.tx).then(function(e){t._hash=e.hash,t.Pending(e)}).catch(function(e){t.Failed("send tx failed. "+e)}),t}},{key:"listen",value:function(t,e){t&&e||(t=1e3,e=90);var r=this,n=1,i=setInterval(function(){if("idle"!==r.status){if("success"===r.status||"failed"===r.status||n>parseInt(e))return clearInterval(i),void("success"!==r.status&&"failed"!==r.status&&n>parseInt(e)&&r.Failed("Error: tx "+r._hash+" on chain timeout."));n++,r._rpc.transaction.getTxReceiptByTxHash(r._hash).then(function(t){"SUCCESS"===t.status_code&&"pending"===r.status?r.Success(t):void 0!==t.status_code&&"pending"===r.status&&r.Failed(t)}).catch(function(t){})}},parseInt(t))}}],[{key:"SimpleTx",value:function(t,e,r,n){var i=new o(n.gasRatio,n.gasLimit,n.delay);return i.addAction(t,e,JSON.stringify(r)),i}}]),t}();t.exports=a})?n.apply(e,i):n)||(t.exports=f)},function(t,e,r){var n,i,f;i=[],void 0===(f="function"==typeof(n=function(){"use strict";var e=r(18),n=r(40),i=r(61),f=r(34),o=r(28),a=r(13).Tx,s=r(15),u=r(110),h=r(35),c=r(17);t.exports={IOST:i,RPC:e,HTTPProvider:n,KeyPair:f,Tx:a,Algorithm:s,Account:u,TxHandler:h,Bs58:c,Signature:o}})?n.apply(e,i):n)||(t.exports=f)},function(t,e,r){var n,i,f;i=[r(0),r(1)],void 0===(f="function"==typeof(n=function(e,n){"use strict";var i=r(2);e=i(e),n=i(n);var f=function(){function t(r){(0,e.default)(this,t),this._provider=r.getProvider()}return(0,n.default)(t,[{key:"getProvider",value:function(){return this._provider}},{key:"getNodeInfo",value:function(){return this._provider.send("get","getNodeInfo")}}]),t}();t.exports=f})?n.apply(e,i):n)||(t.exports=f)},function(t,e,r){var n,i,f;i=[r(0),r(1)],void 0===(f="function"==typeof(n=function(e,n){"use strict";var i=r(2);e=i(e),n=i(n);var f=function(){function t(r){(0,e.default)(this,t),this._provider=r.getProvider()}return(0,n.default)(t,[{key:"getChainInfo",value:function(){return this._provider.send("get","getChainInfo")}},{key:"getBlockByHash",value:function(t,e){var r="getBlockByHash/"+t+"/"+e;return this._provider.send("get",r)}},{key:"getBlockByNum",value:function(t,e){var r="getBlockByNumber/"+t+"/"+e;return this._provider.send("get",r)}},{key:"getBalance",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"iost",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n="getTokenBalance/"+t+"/"+e+"/"+r;return this._provider.send("get",n)}},{key:"getToken721Balance",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n="getToken721Balance/"+t+"/"+e+"/"+r;return this._provider.send("get",n)}},{key:"getToken721Metadata",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n="getToken721Metadata/"+t+"/"+e+"/"+r;return this._provider.send("get",n)}},{key:"getToken721Owner",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n="getToken721Owner/"+t+"/"+e+"/"+r;return this._provider.send("get",n)}},{key:"getContract",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r="getContract/"+t+"/"+e;return this._provider.send("get",r)}},{key:"getContractStorage",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];"boolean"==typeof r&&(n=r,r="");var i={id:t,key:e,field:r,by_longest_chain:n};return this._provider.send("post","getContractStorage",i)}},{key:"getContractStorageFields",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n={id:t,key:e,by_longest_chain:r};return this._provider.send("post","getContractStorageFields",n)}},{key:"getAccountInfo",value:function(t,e){var r="getAccount/"+t+"/"+(e?1:0);return this._provider.send("get",r)}},{key:"getGasRatio",value:function(){return this._provider.send("get","getGasRatio")}},{key:"getGasUsage",value:function(t){switch(t){case"transfer":return 7800;case"newAccount":return 115e3}}},{key:"getExchangeContractInfo",value:function(){return{contractID:"ContractZGVqhY3c65xRs8aoC4dUdACVCKSwhMMsg2negSFxpr3",minAmount:100,initialRAM:1e3,initialGasPledged:10}}}]),t}();t.exports=f})?n.apply(e,i):n)||(t.exports=f)},function(t,e,r){var n,i,f;i=[r(0),r(1)],void 0===(f="function"==typeof(n=function(e,n){"use strict";var i=r(2);e=i(e),n=i(n);var f=function(){function t(r){(0,e.default)(this,t),this._provider=r.getProvider()}return(0,n.default)(t,[{key:"sendTx",value:function(t){return this._provider.send("post","sendTx",JSON.parse(JSON.stringify(t)))}},{key:"getTxByHash",value:function(t){var e="getTxByHash/"+t;return this._provider.send("get",e)}},{key:"getTxReceiptByHash",value:function(t){var e="getTxReceiptByHash/"+t;return this._provider.send("get",e)}},{key:"getTxReceiptByTxHash",value:function(t){var e="getTxReceiptByTxHash/"+t;return this._provider.send("get",e)}}]),t}();t.exports=f})?n.apply(e,i):n)||(t.exports=f)},function(t,e,r){var n,i,f;i=[r(0),r(1)],void 0===(f="function"==typeof(n=function(e,n){"use strict";var i=r(2);e=i(e),n=i(n);var f=r(41),o=function(){function t(r,n){(0,e.default)(this,t),this._host=r||"http://localhost:30000",this._timeout=n}return(0,n.default)(t,[{key:"send",value:function(t,e,r){var n={method:t,url:this._host+"/"+e,data:r,timeout:this._timeout,headers:{"Content-Type":"text/plain"}};return f(n).then(function(t){return t.data}).catch(function(t){throw void 0!==t.response?new Error("error: "+JSON.stringify(t.response.data)):new Error("error: "+t)})}}]),t}();t.exports=o})?n.apply(e,i):n)||(t.exports=f)},function(t,e,r){t.exports=r(42)},function(t,e,r){"use strict";var n=r(4),i=r(19),f=r(44),o=r(12);function a(t){var e=new f(t),r=i(f.prototype.request,e);return n.extend(r,f.prototype,e),n.extend(r,e),r}var s=a(o);s.Axios=f,s.create=function(t){return a(n.merge(o,t))},s.Cancel=r(23),s.CancelToken=r(59),s.isCancel=r(22),s.all=function(t){return Promise.all(t)},s.spread=r(60),t.exports=s,t.exports.default=s},function(t,e){function r(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)} +/*! + * Determine if an object is a Buffer + * + * @author Feross Aboukhadijeh + * @license MIT + */ +t.exports=function(t){return null!=t&&(r(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&r(t.slice(0,0))}(t)||!!t._isBuffer)}},function(t,e,r){"use strict";var n=r(12),i=r(4),f=r(54),o=r(55);function a(t){this.defaults=t,this.interceptors={request:new f,response:new f}}a.prototype.request=function(t){"string"==typeof t&&(t=i.merge({url:arguments[0]},arguments[1])),(t=i.merge(n,{method:"get"},this.defaults,t)).method=t.method.toLowerCase();var e=[o,void 0],r=Promise.resolve(t);for(this.interceptors.request.forEach(function(t){e.unshift(t.fulfilled,t.rejected)}),this.interceptors.response.forEach(function(t){e.push(t.fulfilled,t.rejected)});e.length;)r=r.then(e.shift(),e.shift());return r},i.forEach(["delete","get","head","options"],function(t){a.prototype[t]=function(e,r){return this.request(i.merge(r||{},{method:t,url:e}))}}),i.forEach(["post","put","patch"],function(t){a.prototype[t]=function(e,r,n){return this.request(i.merge(n||{},{method:t,url:e,data:r}))}}),t.exports=a},function(t,e){var r,n,i=t.exports={};function f(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(t){if(r===setTimeout)return setTimeout(t,0);if((r===f||!r)&&setTimeout)return r=setTimeout,setTimeout(t,0);try{return r(t,0)}catch(e){try{return r.call(null,t,0)}catch(e){return r.call(this,t,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:f}catch(t){r=f}try{n="function"==typeof clearTimeout?clearTimeout:o}catch(t){n=o}}();var s,u=[],h=!1,c=-1;function d(){h&&s&&(h=!1,s.length?u=s.concat(u):c=-1,u.length&&l())}function l(){if(!h){var t=a(d);h=!0;for(var e=u.length;e;){for(s=u,u=[];++c1)for(var r=1;r=0)return;o[e]="set-cookie"===e?(o[e]?o[e]:[]).concat([r]):o[e]?o[e]+", "+r:r}}),o):o}},function(t,e,r){"use strict";var n=r(4);t.exports=n.isStandardBrowserEnv()?function(){var t,e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function i(t){var n=t;return e&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return t=i(window.location.href),function(e){var r=n.isString(e)?i(e):e;return r.protocol===t.protocol&&r.host===t.host}}():function(){return!0}},function(t,e,r){"use strict";var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function i(){this.message="String contains an invalid character"}i.prototype=new Error,i.prototype.code=5,i.prototype.name="InvalidCharacterError",t.exports=function(t){for(var e,r,f=String(t),o="",a=0,s=n;f.charAt(0|a)||(s="=",a%1);o+=s.charAt(63&e>>8-a%1*8)){if((r=f.charCodeAt(a+=.75))>255)throw new i;e=e<<8|r}return o}},function(t,e,r){"use strict";var n=r(4);t.exports=n.isStandardBrowserEnv()?{write:function(t,e,r,i,f,o){var a=[];a.push(t+"="+encodeURIComponent(e)),n.isNumber(r)&&a.push("expires="+new Date(r).toGMTString()),n.isString(i)&&a.push("path="+i),n.isString(f)&&a.push("domain="+f),!0===o&&a.push("secure"),document.cookie=a.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(t,e,r){"use strict";var n=r(4);function i(){this.handlers=[]}i.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},i.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},i.prototype.forEach=function(t){n.forEach(this.handlers,function(e){null!==e&&t(e)})},t.exports=i},function(t,e,r){"use strict";var n=r(4),i=r(56),f=r(22),o=r(12),a=r(57),s=r(58);function u(t){t.cancelToken&&t.cancelToken.throwIfRequested()}t.exports=function(t){return u(t),t.baseURL&&!a(t.url)&&(t.url=s(t.baseURL,t.url)),t.headers=t.headers||{},t.data=i(t.data,t.headers,t.transformRequest),t.headers=n.merge(t.headers.common||{},t.headers[t.method]||{},t.headers||{}),n.forEach(["delete","get","head","post","put","patch","common"],function(e){delete t.headers[e]}),(t.adapter||o.adapter)(t).then(function(e){return u(t),e.data=i(e.data,e.headers,t.transformResponse),e},function(e){return f(e)||(u(t),e&&e.response&&(e.response.data=i(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)})}},function(t,e,r){"use strict";var n=r(4);t.exports=function(t,e,r){return n.forEach(r,function(r){t=r(t,e)}),t}},function(t,e,r){"use strict";t.exports=function(t){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(t)}},function(t,e,r){"use strict";t.exports=function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}},function(t,e,r){"use strict";var n=r(23);function i(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(t){e=t});var r=this;t(function(t){r.reason||(r.reason=new n(t),e(r.reason))})}i.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},i.source=function(){var t;return{token:new i(function(e){t=e}),cancel:t}},t.exports=i},function(t,e,r){"use strict";t.exports=function(t){return function(e){return t.apply(null,e)}}},function(t,e,r){var n,i,f;i=[r(62),r(64),r(0),r(1)],void 0===(f="function"==typeof(n=function(e,n,i,f){"use strict";var o=r(2);e=o(e),n=o(n),i=o(i),f=o(f),r(18);var a=r(13).Tx,s=(r(35),r(109)),u=r(17),h={gasRatio:1,gasLimit:2e6,delay:0,expiration:90,defaultLimit:"unlimited"},c=function(){function t(e){(0,i.default)(this,t),this.config=h,e&&(Object.assign(this.config,e),this.rpc=void 0,this.account=void 0,this.serverTimeDiff=0)}return(0,f.default)(t,[{key:"callABI",value:function(t,e,r){var n=new a(this.config.gasRatio,this.config.gasLimit);return n.addAction(t,e,JSON.stringify(r)),n.setTime(this.config.expiration,this.config.delay,this.serverTimeDiff),n.addApprove("*",this.config.defaultLimit),n}},{key:"transfer",value:function(t,e,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",f=this.callABI("token.iost","transfer",[t,e,r,n,i]);return f.addApprove("*",this.config.defaultLimit),f.addApprove("iost",n),f}},{key:"newAccount",value:function(t,e,r,n,i,f){if(!this._checkPublicKey(r)||!this._checkPublicKey(n))throw"error public key";var o=new a(this.config.gasRatio,this.config.gasLimit);return o.addAction("auth.iost","signUp",JSON.stringify([t,r,n])),i>10&&o.addAction("ram.iost","buy",JSON.stringify([e,t,i])),f>0&&o.addAction("gas.iost","pledge",JSON.stringify([e,t,f+""])),o.setTime(this.config.expiration,this.config.delay,this.serverTimeDiff),o.addApprove("*",this.config.defaultLimit),o}},{key:"_checkPublicKey",value:function(t){var e=u.decode(t);return 32===e.length}},{key:"signAndSend",value:function(t){var e=new s(this.currentRPC.transaction),r="",n=this;return n.currentAccount.signTx(t),setTimeout(function(){n.currentRPC.transaction.sendTx(t).then(function(t){r=t.hash,e.pushMsg("pending",r),e.hash=r}).catch(function(t){e.pushMsg("failed",t)})},50),e}},{key:"currentAccount",value:function(){return this.currentAccount}},{key:"currentRPC",value:function(){return this.currentRPC}},{key:"setRPC",value:(r=(0,n.default)(e.default.mark(function t(r){var n,i;return e.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return this.currentRPC=r,n=1e6*(new Date).getTime(),t.next=4,this.currentRPC.net.getNodeInfo();case 4:i=t.sent,this.serverTimeDiff=i.server_time-n,console.log(this.serverTimeDiff);case 7:case"end":return t.stop()}},t,this)})),function(t){return r.apply(this,arguments)})},{key:"setAccount",value:function(t){this.currentAccount=t}}]),t;var r}();t.exports=c})?n.apply(e,i):n)||(t.exports=f)},function(t,e,r){t.exports=r(63)},function(t,e,r){var n=function(t){"use strict";var e,r=Object.prototype,n=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},f=i.iterator||"@@iterator",o=i.asyncIterator||"@@asyncIterator",a=i.toStringTag||"@@toStringTag";function s(t,e,r,n){var i=e&&e.prototype instanceof p?e:p,f=Object.create(i.prototype),o=new I(n||[]);return f._invoke=function(t,e,r){var n=h;return function(i,f){if(n===d)throw new Error("Generator is already running");if(n===l){if("throw"===i)throw f;return R()}for(r.method=i,r.arg=f;;){var o=r.delegate;if(o){var a=S(o,r);if(a){if(a===b)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===h)throw n=l,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=d;var s=u(t,e,r);if("normal"===s.type){if(n=r.done?l:c,s.arg===b)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n=l,r.method="throw",r.arg=s.arg)}}}(t,r,o),f}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var h="suspendedStart",c="suspendedYield",d="executing",l="completed",b={};function p(){}function v(){}function g(){}var y={};y[f]=function(){return this};var m=Object.getPrototypeOf,w=m&&m(m(k([])));w&&w!==r&&n.call(w,f)&&(y=w);var M=g.prototype=p.prototype=Object.create(y);function _(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function A(t){var e;this._invoke=function(r,i){function f(){return new Promise(function(e,f){!function e(r,i,f,o){var a=u(t[r],t,i);if("throw"!==a.type){var s=a.arg,h=s.value;return h&&"object"==typeof h&&n.call(h,"__await")?Promise.resolve(h.__await).then(function(t){e("next",t,f,o)},function(t){e("throw",t,f,o)}):Promise.resolve(h).then(function(t){s.value=t,f(s)},function(t){return e("throw",t,f,o)})}o(a.arg)}(r,i,e,f)})}return e=e?e.then(f,f):f()}}function S(t,r){var n=t.iterator[r.method];if(n===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=e,S(t,r),"throw"===r.method))return b;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return b}var i=u(n,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,b;var f=i.arg;return f?f.done?(r[t.resultName]=f.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,b):f:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function x(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function k(t){if(t){var r=t[f];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function r(){for(;++i=0;--f){var o=this.tryEntries[f],a=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(this.prev=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;E(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:k(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),b}},t}(t.exports);try{regeneratorRuntime=n}catch(t){Function("r","regeneratorRuntime = r")(n)}},function(t,e){function r(t,e,r,n,i,f,o){try{var a=t[f](o),s=a.value}catch(t){return void r(t)}a.done?e(s):Promise.resolve(s).then(n,i)}t.exports=function(t){return function(){var e=this,n=arguments;return new Promise(function(i,f){var o=t.apply(e,n);function a(t){r(o,i,f,a,s,"next",t)}function s(t){r(o,i,f,a,s,"throw",t)}a(void 0)})}}},function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e,r){"use strict";e.byteLength=function(t){var e=u(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){for(var e,r=u(t),n=r[0],o=r[1],a=new f(function(t,e,r){return 3*(e+r)/4-r}(0,n,o)),s=0,h=o>0?n-4:n,c=0;c>16&255,a[s++]=e>>8&255,a[s++]=255&e;2===o&&(e=i[t.charCodeAt(c)]<<2|i[t.charCodeAt(c+1)]>>4,a[s++]=255&e);1===o&&(e=i[t.charCodeAt(c)]<<10|i[t.charCodeAt(c+1)]<<4|i[t.charCodeAt(c+2)]>>2,a[s++]=e>>8&255,a[s++]=255&e);return a},e.fromByteArray=function(t){for(var e,r=t.length,i=r%3,f=[],o=0,a=r-i;oa?a:o+16383));1===i?(e=t[r-1],f.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],f.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return f.join("")};for(var n=[],i=[],f="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,s=o.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function h(t,e,r){for(var i,f,o=[],a=e;a>18&63]+n[f>>12&63]+n[f>>6&63]+n[63&f]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,r,n,i){var f,o,a=8*i-n-1,s=(1<>1,h=-7,c=r?i-1:0,d=r?-1:1,l=t[e+c];for(c+=d,f=l&(1<<-h)-1,l>>=-h,h+=a;h>0;f=256*f+t[e+c],c+=d,h-=8);for(o=f&(1<<-h)-1,f>>=-h,h+=n;h>0;o=256*o+t[e+c],c+=d,h-=8);if(0===f)f=1-u;else{if(f===s)return o?NaN:1/0*(l?-1:1);o+=Math.pow(2,n),f-=u}return(l?-1:1)*o*Math.pow(2,f-n)},e.write=function(t,e,r,n,i,f){var o,a,s,u=8*f-i-1,h=(1<>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,l=n?0:f-1,b=n?1:-1,p=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=h):(o=Math.floor(Math.log(e)/Math.LN2),e*(s=Math.pow(2,-o))<1&&(o--,s*=2),(e+=o+c>=1?d/s:d*Math.pow(2,1-c))*s>=2&&(o++,s/=2),o+c>=h?(a=0,o=h):o+c>=1?(a=(e*s-1)*Math.pow(2,i),o+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,i),o=0));i>=8;t[r+l]=255&a,l+=b,a/=256,i-=8);for(o=o<0;t[r+l]=255&o,l+=b,o/=256,u-=8);t[r+l-b]|=128*p}},function(t,e){var r={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},function(t,e){t.exports=n;var r=null;try{r=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(t){}function n(t,e,r){this.low=0|t,this.high=0|e,this.unsigned=!!r}function i(t){return!0===(t&&t.__isLong__)}n.prototype.__isLong__,Object.defineProperty(n.prototype,"__isLong__",{value:!0}),n.isLong=i;var f={},o={};function a(t,e){var r,n,i;return e?(i=0<=(t>>>=0)&&t<256)&&(n=o[t])?n:(r=u(t,(0|t)<0?-1:0,!0),i&&(o[t]=r),r):(i=-128<=(t|=0)&&t<128)&&(n=f[t])?n:(r=u(t,t<0?-1:0,!1),i&&(f[t]=r),r)}function s(t,e){if(isNaN(t))return e?y:g;if(e){if(t<0)return y;if(t>=b)return A}else{if(t<=-p)return S;if(t+1>=p)return _}return t<0?s(-t,e).neg():u(t%l|0,t/l|0,e)}function u(t,e,r){return new n(t,e,r)}n.fromInt=a,n.fromNumber=s,n.fromBits=u;var h=Math.pow;function c(t,e,r){if(0===t.length)throw Error("empty string");if("NaN"===t||"Infinity"===t||"+Infinity"===t||"-Infinity"===t)return g;if("number"==typeof e?(r=e,e=!1):e=!!e,(r=r||10)<2||360)throw Error("interior hyphen");if(0===n)return c(t.substring(1),e,r).neg();for(var i=s(h(r,8)),f=g,o=0;o>>0:this.low},x.toNumber=function(){return this.unsigned?(this.high>>>0)*l+(this.low>>>0):this.high*l+(this.low>>>0)},x.toString=function(t){if((t=t||10)<2||36>>0).toString(t);if((f=a).isZero())return u+o;for(;u.length<6;)u="0"+u;o=""+u+o}},x.getHighBits=function(){return this.high},x.getHighBitsUnsigned=function(){return this.high>>>0},x.getLowBits=function(){return this.low},x.getLowBitsUnsigned=function(){return this.low>>>0},x.getNumBitsAbs=function(){if(this.isNegative())return this.eq(S)?64:this.neg().getNumBitsAbs();for(var t=0!=this.high?this.high:this.low,e=31;e>0&&0==(t&1<=0},x.isOdd=function(){return 1==(1&this.low)},x.isEven=function(){return 0==(1&this.low)},x.equals=function(t){return i(t)||(t=d(t)),(this.unsigned===t.unsigned||this.high>>>31!=1||t.high>>>31!=1)&&(this.high===t.high&&this.low===t.low)},x.eq=x.equals,x.notEquals=function(t){return!this.eq(t)},x.neq=x.notEquals,x.ne=x.notEquals,x.lessThan=function(t){return this.comp(t)<0},x.lt=x.lessThan,x.lessThanOrEqual=function(t){return this.comp(t)<=0},x.lte=x.lessThanOrEqual,x.le=x.lessThanOrEqual,x.greaterThan=function(t){return this.comp(t)>0},x.gt=x.greaterThan,x.greaterThanOrEqual=function(t){return this.comp(t)>=0},x.gte=x.greaterThanOrEqual,x.ge=x.greaterThanOrEqual,x.compare=function(t){if(i(t)||(t=d(t)),this.eq(t))return 0;var e=this.isNegative(),r=t.isNegative();return e&&!r?-1:!e&&r?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1},x.comp=x.compare,x.negate=function(){return!this.unsigned&&this.eq(S)?S:this.not().add(m)},x.neg=x.negate,x.add=function(t){i(t)||(t=d(t));var e=this.high>>>16,r=65535&this.high,n=this.low>>>16,f=65535&this.low,o=t.high>>>16,a=65535&t.high,s=t.low>>>16,h=0,c=0,l=0,b=0;return l+=(b+=f+(65535&t.low))>>>16,c+=(l+=n+s)>>>16,h+=(c+=r+a)>>>16,h+=e+o,u((l&=65535)<<16|(b&=65535),(h&=65535)<<16|(c&=65535),this.unsigned)},x.subtract=function(t){return i(t)||(t=d(t)),this.add(t.neg())},x.sub=x.subtract,x.multiply=function(t){if(this.isZero())return g;if(i(t)||(t=d(t)),r)return u(r.mul(this.low,this.high,t.low,t.high),r.get_high(),this.unsigned);if(t.isZero())return g;if(this.eq(S))return t.isOdd()?S:g;if(t.eq(S))return this.isOdd()?S:g;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(v)&&t.lt(v))return s(this.toNumber()*t.toNumber(),this.unsigned);var e=this.high>>>16,n=65535&this.high,f=this.low>>>16,o=65535&this.low,a=t.high>>>16,h=65535&t.high,c=t.low>>>16,l=65535&t.low,b=0,p=0,y=0,m=0;return y+=(m+=o*l)>>>16,p+=(y+=f*l)>>>16,y&=65535,p+=(y+=o*c)>>>16,b+=(p+=n*l)>>>16,p&=65535,b+=(p+=f*c)>>>16,p&=65535,b+=(p+=o*h)>>>16,b+=e*l+n*c+f*h+o*a,u((y&=65535)<<16|(m&=65535),(b&=65535)<<16|(p&=65535),this.unsigned)},x.mul=x.multiply,x.divide=function(t){if(i(t)||(t=d(t)),t.isZero())throw Error("division by zero");var e,n,f;if(r)return this.unsigned||-2147483648!==this.high||-1!==t.low||-1!==t.high?u((this.unsigned?r.div_u:r.div_s)(this.low,this.high,t.low,t.high),r.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?y:g;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return y;if(t.gt(this.shru(1)))return w;f=y}else{if(this.eq(S))return t.eq(m)||t.eq(M)?S:t.eq(S)?m:(e=this.shr(1).div(t).shl(1)).eq(g)?t.isNegative()?m:M:(n=this.sub(t.mul(e)),f=e.add(n.div(t)));if(t.eq(S))return this.unsigned?y:g;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();f=g}for(n=this;n.gte(t);){e=Math.max(1,Math.floor(n.toNumber()/t.toNumber()));for(var o=Math.ceil(Math.log(e)/Math.LN2),a=o<=48?1:h(2,o-48),c=s(e),l=c.mul(t);l.isNegative()||l.gt(n);)l=(c=s(e-=a,this.unsigned)).mul(t);c.isZero()&&(c=m),f=f.add(c),n=n.sub(l)}return f},x.div=x.divide,x.modulo=function(t){return i(t)||(t=d(t)),r?u((this.unsigned?r.rem_u:r.rem_s)(this.low,this.high,t.low,t.high),r.get_high(),this.unsigned):this.sub(this.div(t).mul(t))},x.mod=x.modulo,x.rem=x.modulo,x.not=function(){return u(~this.low,~this.high,this.unsigned)},x.and=function(t){return i(t)||(t=d(t)),u(this.low&t.low,this.high&t.high,this.unsigned)},x.or=function(t){return i(t)||(t=d(t)),u(this.low|t.low,this.high|t.high,this.unsigned)},x.xor=function(t){return i(t)||(t=d(t)),u(this.low^t.low,this.high^t.high,this.unsigned)},x.shiftLeft=function(t){return i(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?u(this.low<>>32-t,this.unsigned):u(0,this.low<>>t|this.high<<32-t,this.high>>t,this.unsigned):u(this.high>>t-32,this.high>=0?0:-1,this.unsigned)},x.shr=x.shiftRight,x.shiftRightUnsigned=function(t){if(i(t)&&(t=t.toInt()),0===(t&=63))return this;var e=this.high;return t<32?u(this.low>>>t|e<<32-t,e>>>t,this.unsigned):u(32===t?e:e>>>t-32,0,this.unsigned)},x.shru=x.shiftRightUnsigned,x.shr_u=x.shiftRightUnsigned,x.toSigned=function(){return this.unsigned?u(this.low,this.high,!1):this},x.toUnsigned=function(){return this.unsigned?this:u(this.low,this.high,!0)},x.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()},x.toBytesLE=function(){var t=this.high,e=this.low;return[255&e,e>>>8&255,e>>>16&255,e>>>24,255&t,t>>>8&255,t>>>16&255,t>>>24]},x.toBytesBE=function(){var t=this.high,e=this.low;return[t>>>24,t>>>16&255,t>>>8&255,255&t,e>>>24,e>>>16&255,e>>>8&255,255&e]},n.fromBytes=function(t,e,r){return r?n.fromBytesLE(t,e):n.fromBytesBE(t,e)},n.fromBytesLE=function(t,e){return new n(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,e)},n.fromBytesBE=function(t,e){return new n(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],e)}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n,i=r(8),f=(n=r(71))&&n.__esModule?n:{default:n};var o=[224,256,384,512],a=function(t,e){for(var r=0;r=h&&(a(l,d),s(d),c=0);return e},this.squeeze=function(){var t={queue:i.Buffer.allocUnsafe(h),state:new Uint32Array(50)};l.copy(t.queue);for(var e=0;e>>8,r[n+2]=t[f+1]>>>16,r[n+3]=t[f+1]>>>24,r[n+4]=t[f],r[n+5]=t[f]>>>8,r[n+6]=t[f]>>>16,r[n+7]=t[f]>>>24}return r}(t.state,u)},this.reset=function(){return l.fill(0),d.fill(0),c=0,e},this};e.default=s},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=a(r(72)),i=a(r(73)),f=a(r(75)),o=a(r(78));function a(t){return t&&t.__esModule?t:{default:t}}var s=function(){var t=new Uint32Array(10),e=new Uint32Array(10),r=new Uint32Array(2);return function(a){for(var s=0;s<24;s++)(0,o.default)({A:a,C:t,D:e,W:r}),(0,f.default)({A:a,C:t,W:r}),(0,n.default)({A:a,C:t}),(0,i.default)({A:a,roundIndex:s});!function(){for(var t=arguments.length,e=new Array(t),r=0;r",license:"MIT",bugs:{url:"https://github.com/indutny/elliptic/issues"},homepage:"https://github.com/indutny/elliptic",devDependencies:{brfs:"^1.4.3",coveralls:"^2.11.3",grunt:"^0.4.5","grunt-browserify":"^5.0.0","grunt-cli":"^1.2.0","grunt-contrib-connect":"^1.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^1.0.1","grunt-mocha-istanbul":"^3.0.1","grunt-saucelabs":"^8.6.2",istanbul:"^0.4.2",jscs:"^2.9.0",jshint:"^2.6.0",mocha:"^2.1.0"},dependencies:{"bn.js":"^4.4.0",brorand:"^1.0.1","hash.js":"^1.0.0","hmac-drbg":"^1.0.0",inherits:"^2.0.1","minimalistic-assert":"^1.0.0","minimalistic-crypto-utils":"^1.0.0"}}},function(t,e,r){"use strict";var n=e,i=r(5),f=r(7),o=r(29);n.assert=f,n.toArray=o.toArray,n.zero2=o.zero2,n.toHex=o.toHex,n.encode=o.encode,n.getNAF=function(t,e){for(var r=[],n=1<=0;){var f;if(i.isOdd()){var o=i.andln(n-1);f=o>(n>>1)-1?(n>>1)-o:o,i.isubn(f)}else f=0;r.push(f);for(var a=0!==i.cmpn(0)&&0===i.andln(n-1)?e+1:1,s=1;s0||e.cmpn(-i)>0;){var f,o,a,s=t.andln(3)+n&3,u=e.andln(3)+i&3;3===s&&(s=-1),3===u&&(u=-1),f=0==(1&s)?0:3!=(a=t.andln(7)+n&7)&&5!==a||2!==u?s:-s,r[0].push(f),o=0==(1&u)?0:3!=(a=e.andln(7)+i&7)&&5!==a||2!==s?u:-u,r[1].push(o),2*n===f+1&&(n=1-n),2*i===o+1&&(i=1-i),t.iushrn(1),e.iushrn(1)}return r},n.cachedProperty=function(t,e,r){var n="_"+e;t.prototype[e]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(t){return"string"==typeof t?n.toArray(t,"hex"):t},n.intFromLE=function(t){return new i(t,"hex","le")}},function(t,e,r){var n;function i(t){this.rand=t}if(t.exports=function(t){return n||(n=new i(null)),n.generate(t)},t.exports.Rand=i,i.prototype.generate=function(t){return this._rand(t)},i.prototype._rand=function(t){if(this.rand.getBytes)return this.rand.getBytes(t);for(var e=new Uint8Array(t),r=0;r0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function u(t,e){this.curve=t,this.type=e,this.precomputed=null}t.exports=s,s.prototype.point=function(){throw new Error("Not implemented")},s.prototype.validate=function(){throw new Error("Not implemented")},s.prototype._fixedNafMul=function(t,e){a(t.precomputed);var r=t._getDoubles(),n=f(e,1),i=(1<=s;e--)u=(u<<1)+n[e];o.push(u)}for(var h=this.jpoint(null,null,null),c=this.jpoint(null,null,null),d=i;d>0;d--){for(s=0;s=0;u--){for(e=0;u>=0&&0===o[u];u--)e++;if(u>=0&&e++,s=s.dblp(e),u<0)break;var h=o[u];a(0!==h),s="affine"===t.type?h>0?s.mixedAdd(i[h-1>>1]):s.mixedAdd(i[-h-1>>1].neg()):h>0?s.add(i[h-1>>1]):s.add(i[-h-1>>1].neg())}return"affine"===t.type?s.toP():s},s.prototype._wnafMulAdd=function(t,e,r,n,i){for(var a=this._wnafT1,s=this._wnafT2,u=this._wnafT3,h=0,c=0;c=1;c-=2){var l=c-1,b=c;if(1===a[l]&&1===a[b]){var p=[e[l],null,null,e[b]];0===e[l].y.cmp(e[b].y)?(p[1]=e[l].add(e[b]),p[2]=e[l].toJ().mixedAdd(e[b].neg())):0===e[l].y.cmp(e[b].y.redNeg())?(p[1]=e[l].toJ().mixedAdd(e[b]),p[2]=e[l].add(e[b].neg())):(p[1]=e[l].toJ().mixedAdd(e[b]),p[2]=e[l].toJ().mixedAdd(e[b].neg()));var v=[-3,-1,-5,-7,0,7,5,1,3],g=o(r[l],r[b]);h=Math.max(g[0].length,h),u[l]=new Array(h),u[b]=new Array(h);for(var y=0;y=0;c--){for(var A=0;c>=0;){var S=!0;for(y=0;y=0&&A++,M=M.dblp(A),c<0)break;for(y=0;y0?x=s[y][E-1>>1]:E<0&&(x=s[y][-E-1>>1].neg()),M="affine"===x.type?M.mixedAdd(x):M.add(x))}}for(c=0;c=Math.ceil((t.bitLength()+1)/e.step)},u.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i=0&&(o=e,a=r),n.negative&&(n=n.neg(),i=i.neg()),o.negative&&(o=o.neg(),a=a.neg()),[{a:n,b:i},{a:o,b:a}]},u.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],n=e[1],i=n.b.mul(t).divRound(this.n),f=r.b.neg().mul(t).divRound(this.n),o=i.mul(r.a),a=f.mul(n.a),s=i.mul(r.b),u=f.mul(n.b);return{k1:t.sub(o).sub(a),k2:s.add(u).neg()}},u.prototype.pointFromX=function(t,e){(t=new f(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(e&&!i||!e&&i)&&(n=n.redNeg()),this.point(t,n)},u.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,n=this.a.redMul(e),i=e.redSqr().redMul(e).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},u.prototype._endoWnafMulAdd=function(t,e,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,f=0;f":""},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),n=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},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(),n=t.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(n),f=i.redSqr().redISub(this.x.redAdd(this.x)),o=i.redMul(this.x.redSub(f)).redISub(this.y);return this.curve.point(f,o)},h.prototype.getX=function(){return this.x.fromRed()},h.prototype.getY=function(){return this.y.fromRed()},h.prototype.mul=function(t){return t=new f(t,16),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 n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},h.prototype.jmulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,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,n=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}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)},o(c,a.BasePoint),u.prototype.jpoint=function(t,e,r){return new c(this,t,e,r)},c.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),n=this.y.redMul(e).redMul(t);return this.curve.point(r,n)},c.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},c.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(e),i=t.x.redMul(r),f=this.y.redMul(e.redMul(t.z)),o=t.y.redMul(r.redMul(this.z)),a=n.redSub(i),s=f.redSub(o);if(0===a.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),h=u.redMul(a),c=n.redMul(u),d=s.redSqr().redIAdd(h).redISub(c).redISub(c),l=s.redMul(c.redISub(d)).redISub(f.redMul(h)),b=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(d,l,b)},c.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,n=t.x.redMul(e),i=this.y,f=t.y.redMul(e).redMul(this.z),o=r.redSub(n),a=i.redSub(f);if(0===o.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var s=o.redSqr(),u=s.redMul(o),h=r.redMul(s),c=a.redSqr().redIAdd(u).redISub(h).redISub(h),d=a.redMul(h.redISub(c)).redISub(i.redMul(u)),l=this.z.redMul(o);return this.curve.jpoint(c,d,l)},c.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=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},c.prototype.inspect=function(){return this.isInfinity()?"":""},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},function(t,e,r){"use strict";var n=r(10),i=r(5),f=r(11),o=n.base,a=r(3).utils;function s(t){o.call(this,"mont",t),this.a=new i(t.a,16).toRed(this.red),this.b=new i(t.b,16).toRed(this.red),this.i4=new i(4).toRed(this.red).redInvm(),this.two=new i(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function u(t,e,r){o.BasePoint.call(this,t,"projective"),null===e&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new i(e,16),this.z=new i(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}f(s,o),t.exports=s,s.prototype.validate=function(t){var e=t.normalize().x,r=e.redSqr(),n=r.redMul(e).redAdd(r.redMul(this.a)).redAdd(e);return 0===n.redSqrt().redSqr().cmp(n)},f(u,o.BasePoint),s.prototype.decodePoint=function(t,e){return this.point(a.toArray(t,e),1)},s.prototype.point=function(t,e){return new u(this,t,e)},s.prototype.pointFromJSON=function(t){return u.fromJSON(this,t)},u.prototype.precompute=function(){},u.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},u.fromJSON=function(t,e){return new u(t,e[0],e[1]||t.one)},u.prototype.inspect=function(){return this.isInfinity()?"":""},u.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},u.prototype.dbl=function(){var t=this.x.redAdd(this.z).redSqr(),e=this.x.redSub(this.z).redSqr(),r=t.redSub(e),n=t.redMul(e),i=r.redMul(e.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},u.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},u.prototype.diffAdd=function(t,e){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=t.x.redAdd(t.z),f=t.x.redSub(t.z).redMul(r),o=i.redMul(n),a=e.z.redMul(f.redAdd(o).redSqr()),s=e.x.redMul(f.redISub(o).redSqr());return this.curve.point(a,s)},u.prototype.mul=function(t){for(var e=t.clone(),r=this,n=this.curve.point(null,null),i=[];0!==e.cmpn(0);e.iushrn(1))i.push(e.andln(1));for(var f=i.length-1;f>=0;f--)0===i[f]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},u.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},u.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},u.prototype.eq=function(t){return 0===this.getX().cmp(t.getX())},u.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},u.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},function(t,e,r){"use strict";var n=r(10),i=r(3),f=r(5),o=r(11),a=n.base,s=i.utils.assert;function u(t){this.twisted=1!=(0|t.a),this.mOneA=this.twisted&&-1==(0|t.a),this.extended=this.mOneA,a.call(this,"edwards",t),this.a=new f(t.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new f(t.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new f(t.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),s(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|t.c)}function h(t,e,r,n,i){a.BasePoint.call(this,t,"projective"),null===e&&null===r&&null===n?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new f(e,16),this.y=new f(r,16),this.z=n?new f(n,16):this.curve.one,this.t=i&&new f(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.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}o(u,a),t.exports=u,u.prototype._mulA=function(t){return this.mOneA?t.redNeg():this.a.redMul(t)},u.prototype._mulC=function(t){return this.oneC?t:this.c.redMul(t)},u.prototype.jpoint=function(t,e,r,n){return this.point(t,e,r,n)},u.prototype.pointFromX=function(t,e){(t=new f(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr(),n=this.c2.redSub(this.a.redMul(r)),i=this.one.redSub(this.c2.redMul(this.d).redMul(r)),o=n.redMul(i.redInvm()),a=o.redSqrt();if(0!==a.redSqr().redSub(o).cmp(this.zero))throw new Error("invalid point");var s=a.fromRed().isOdd();return(e&&!s||!e&&s)&&(a=a.redNeg()),this.point(t,a)},u.prototype.pointFromY=function(t,e){(t=new f(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr(),n=r.redSub(this.c2),i=r.redMul(this.d).redMul(this.c2).redSub(this.a),o=n.redMul(i.redInvm());if(0===o.cmp(this.zero)){if(e)throw new Error("invalid point");return this.point(this.zero,t)}var a=o.redSqrt();if(0!==a.redSqr().redSub(o).cmp(this.zero))throw new Error("invalid point");return a.fromRed().isOdd()!==e&&(a=a.redNeg()),this.point(a,t)},u.prototype.validate=function(t){if(t.isInfinity())return!0;t.normalize();var e=t.x.redSqr(),r=t.y.redSqr(),n=e.redMul(this.a).redAdd(r),i=this.c2.redMul(this.one.redAdd(this.d.redMul(e).redMul(r)));return 0===n.cmp(i)},o(h,a.BasePoint),u.prototype.pointFromJSON=function(t){return h.fromJSON(this,t)},u.prototype.point=function(t,e,r,n){return new h(this,t,e,r,n)},h.fromJSON=function(t,e){return new h(t,e[0],e[1],e[2])},h.prototype.inspect=function(){return this.isInfinity()?"":""},h.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},h.prototype._extDbl=function(){var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(t),i=this.x.redAdd(this.y).redSqr().redISub(t).redISub(e),f=n.redAdd(e),o=f.redSub(r),a=n.redSub(e),s=i.redMul(o),u=f.redMul(a),h=i.redMul(a),c=o.redMul(f);return this.curve.point(s,u,c,h)},h.prototype._projDbl=function(){var t,e,r,n=this.x.redAdd(this.y).redSqr(),i=this.x.redSqr(),f=this.y.redSqr();if(this.curve.twisted){var o=(u=this.curve._mulA(i)).redAdd(f);if(this.zOne)t=n.redSub(i).redSub(f).redMul(o.redSub(this.curve.two)),e=o.redMul(u.redSub(f)),r=o.redSqr().redSub(o).redSub(o);else{var a=this.z.redSqr(),s=o.redSub(a).redISub(a);t=n.redSub(i).redISub(f).redMul(s),e=o.redMul(u.redSub(f)),r=o.redMul(s)}}else{var u=i.redAdd(f);a=this.curve._mulC(this.z).redSqr(),s=u.redSub(a).redSub(a);t=this.curve._mulC(n.redISub(u)).redMul(s),e=this.curve._mulC(u).redMul(i.redISub(f)),r=u.redMul(s)}return this.curve.point(t,e,r)},h.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},h.prototype._extAdd=function(t){var e=this.y.redSub(this.x).redMul(t.y.redSub(t.x)),r=this.y.redAdd(this.x).redMul(t.y.redAdd(t.x)),n=this.t.redMul(this.curve.dd).redMul(t.t),i=this.z.redMul(t.z.redAdd(t.z)),f=r.redSub(e),o=i.redSub(n),a=i.redAdd(n),s=r.redAdd(e),u=f.redMul(o),h=a.redMul(s),c=f.redMul(s),d=o.redMul(a);return this.curve.point(u,h,d,c)},h.prototype._projAdd=function(t){var e,r,n=this.z.redMul(t.z),i=n.redSqr(),f=this.x.redMul(t.x),o=this.y.redMul(t.y),a=this.curve.d.redMul(f).redMul(o),s=i.redSub(a),u=i.redAdd(a),h=this.x.redAdd(this.y).redMul(t.x.redAdd(t.y)).redISub(f).redISub(o),c=n.redMul(s).redMul(h);return this.curve.twisted?(e=n.redMul(u).redMul(o.redSub(this.curve._mulA(f))),r=s.redMul(u)):(e=n.redMul(u).redMul(o.redSub(f)),r=this.curve._mulC(s).redMul(u)),this.curve.point(c,e,r)},h.prototype.add=function(t){return this.isInfinity()?t:t.isInfinity()?this:this.curve.extended?this._extAdd(t):this._projAdd(t)},h.prototype.mul=function(t){return this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve._wnafMul(this,t)},h.prototype.mulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!1)},h.prototype.jmulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!0)},h.prototype.normalize=function(){if(this.zOne)return this;var t=this.z.redInvm();return this.x=this.x.redMul(t),this.y=this.y.redMul(t),this.t&&(this.t=this.t.redMul(t)),this.z=this.curve.one,this.zOne=!0,this},h.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},h.prototype.getX=function(){return this.normalize(),this.x.fromRed()},h.prototype.getY=function(){return this.normalize(),this.y.fromRed()},h.prototype.eq=function(t){return this===t||0===this.getX().cmp(t.getX())&&0===this.getY().cmp(t.getY())},h.prototype.eqXToP=function(t){var e=t.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(e))return!0;for(var r=t.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(e.redIAdd(n),0===this.x.cmp(e))return!0}},h.prototype.toP=h.prototype.normalize,h.prototype.mixedAdd=h.prototype.add},function(t,e,r){"use strict";var n,i=e,f=r(16),o=r(3),a=o.utils.assert;function s(t){"short"===t.type?this.curve=new o.curve.short(t):"edwards"===t.type?this.curve=new o.curve.edwards(t):this.curve=new o.curve.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,a(this.g.validate(),"Invalid curve"),a(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function u(t,e){Object.defineProperty(i,t,{configurable:!0,enumerable:!0,get:function(){var r=new s(e);return Object.defineProperty(i,t,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=s,u("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:f.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),u("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:f.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),u("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:f.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),u("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:f.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),u("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:f.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),u("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:f.sha256,gRed:!1,g:["9"]}),u("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:f.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=r(96)}catch(t){n=void 0}u("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:f.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})},function(t,e,r){"use strict";e.sha1=r(91),e.sha224=r(92),e.sha256=r(31),e.sha384=r(93),e.sha512=r(32)},function(t,e,r){"use strict";var n=r(6),i=r(9),f=r(30),o=n.rotl32,a=n.sum32,s=n.sum32_5,u=f.ft_1,h=i.BlockHash,c=[1518500249,1859775393,2400959708,3395469782];function d(){if(!(this instanceof d))return new d;h.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}n.inherits(d,h),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,n=0;n<16;n++)r[n]=t[e+n];for(;nthis.blockSize&&(t=(new this.Hash).update(t).digest()),i(t.length<=this.blockSize);for(var e=t.length;e0))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,f){"object"==typeof r&&(f=r,r=null),f||(f={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new n(t,16));for(var o=this.n.byteLength(),a=e.getPrivate().toArray("be",o),u=t.toArray("be",o),h=new i({hash:this.hash,entropy:a,nonce:u,pers:f.pers,persEnc:f.persEnc||"utf8"}),c=this.n.sub(new n(1)),d=0;;d++){var l=f.k?f.k(d):new n(h.generate(this.n.byteLength()));if(!((l=this._truncateToN(l,!0)).cmpn(1)<=0||l.cmp(c)>=0)){var b=this.g.mul(l);if(!b.isInfinity()){var p=b.getX(),v=p.umod(this.n);if(0!==v.cmpn(0)){var g=l.invm(this.n).mul(v.mul(e.getPrivate()).iadd(t));if(0!==(g=g.umod(this.n)).cmpn(0)){var y=(b.getY().isOdd()?1:0)|(0!==p.cmp(v)?2:0);return f.canonical&&g.cmp(this.nh)>0&&(g=this.n.sub(g),y^=1),new s({r:v,s:g,recoveryParam:y})}}}}}},u.prototype.verify=function(t,e,r,i){t=this._truncateToN(new n(t,16)),r=this.keyFromPublic(r,i);var f=(e=new s(e,"hex")).r,o=e.s;if(f.cmpn(1)<0||f.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a,u=o.invm(this.n),h=u.mul(t).umod(this.n),c=u.mul(f).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(h,r.getPublic(),c)).isInfinity()&&a.eqXToP(f):!(a=this.g.mulAdd(h,r.getPublic(),c)).isInfinity()&&0===a.getX().umod(this.n).cmp(f)},u.prototype.recoverPubKey=function(t,e,r,i){o((3&r)===r,"The recovery param is more than two bits"),e=new s(e,i);var f=this.n,a=new n(t),u=e.r,h=e.s,c=1&r,d=r>>1;if(u.cmp(this.curve.p.umod(this.curve.n))>=0&&d)throw new Error("Unable to find sencond key candinate");u=d?this.curve.pointFromX(u.add(this.curve.n),c):this.curve.pointFromX(u,c);var l=e.r.invm(f),b=f.sub(a).mul(l).umod(f),p=h.mul(l).umod(f);return this.g.mulAdd(b,u,p)},u.prototype.getKeyRecoveryParam=function(t,e,r,n){if(null!==(e=new s(e,n)).recoveryParam)return e.recoveryParam;for(var i=0;i<4;i++){var f;try{f=this.recoverPubKey(t,e,i)}catch(t){continue}if(f.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},function(t,e,r){"use strict";var n=r(16),i=r(29),f=r(7);function o(t){if(!(this instanceof o))return new o(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=i.toArray(t.entropy,t.entropyEnc||"hex"),r=i.toArray(t.nonce,t.nonceEnc||"hex"),n=i.toArray(t.pers,t.persEnc||"hex");f(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}t.exports=o,o.prototype._init=function(t,e,r){var n=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},o.prototype.generate=function(t,e,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(n=r,r=e,e=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var f=[];f.length"}},function(t,e,r){"use strict";var n=r(5),i=r(3).utils,f=i.assert;function o(t,e){if(t instanceof o)return t;this._importDER(t,e)||(f(t.r&&t.s,"Signature without r or s"),this.r=new n(t.r,16),this.s=new n(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}function a(){this.place=0}function s(t,e){var r=t[e.place++];if(!(128&r))return r;for(var n=15&r,i=0,f=0,o=e.place;f>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}t.exports=o,o.prototype._importDER=function(t,e){t=i.toArray(t,e);var r=new a;if(48!==t[r.place++])return!1;if(s(t,r)+r.place!==t.length)return!1;if(2!==t[r.place++])return!1;var f=s(t,r),o=t.slice(r.place,f+r.place);if(r.place+=f,2!==t[r.place++])return!1;var u=s(t,r);if(t.length!==u+r.place)return!1;var h=t.slice(r.place,u+r.place);return 0===o[0]&&128&o[1]&&(o=o.slice(1)),0===h[0]&&128&h[1]&&(h=h.slice(1)),this.r=new n(o),this.s=new n(h),this.recoveryParam=null,!0},o.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=u(e),r=u(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];h(n,e.length),(n=n.concat(e)).push(2),h(n,r.length);var f=n.concat(r),o=[48];return h(o,f.length),o=o.concat(f),i.encode(o,t)}},function(t,e,r){"use strict";var n=r(16),i=r(3),f=i.utils,o=f.assert,a=f.parseBytes,s=r(102),u=r(103);function h(t){if(o("ed25519"===t,"only tested with ed25519 so far"),!(this instanceof h))return new h(t);t=i.curves[t].curve;this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=n.sha512}t.exports=h,h.prototype.sign=function(t,e){t=a(t);var r=this.keyFromSecret(e),n=this.hashInt(r.messagePrefix(),t),i=this.g.mul(n),f=this.encodePoint(i),o=this.hashInt(f,r.pubBytes(),t).mul(r.priv()),s=n.add(o).umod(this.curve.n);return this.makeSignature({R:i,S:s,Rencoded:f})},h.prototype.verify=function(t,e,r){t=a(t),e=this.makeSignature(e);var n=this.keyFromPublic(r),i=this.hashInt(e.Rencoded(),n.pubBytes(),t),f=this.g.mul(e.S());return e.R().add(n.pub().mul(i)).eq(f)},h.prototype.hashInt=function(){for(var t=this.hash(),e=0;e=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);e.fill(255);for(let r=0;r>>0,h=new Uint8Array(u);for(;t[o];){let n=e[t.charCodeAt(o)];if(255===n)return;let i=0;for(let t=u-1;(0!==n||i>>0,h[t]=n%256>>>0,n=n/256>>>0;if(0!==n)throw new Error("Non-zero carry");s=i,o++}if(" "===t[o])return;let c=u-s;for(;c!==u&&0===h[c];)c++;const d=n.allocUnsafe(a+(u-c));d.fill(0,0,a);let l=a;for(;c!==u;)d[l++]=h[c++];return d}return{encode:function(e){if(!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";let f=0,a=0,s=0;const u=e.length;for(;s!==u&&0===e[s];)s++,f++;const h=(u-s)*o+1>>>0,c=new Uint8Array(h);for(;s!==u;){let t=e[s],n=0;for(let e=h-1;(0!==t||n>>0,c[e]=t%r>>>0,t=t/r>>>0;if(0!==t)throw new Error("Non-zero carry");a=n,s++}let d=h-a;for(;d!==h&&0===c[d];)d++;let l=i.repeat(f);for(;d>>1^r:f>>>=1;o=o>>>8^f}return-1^o}function i(t,r){var n,f,o;if(void 0!==i.crc&&r&&t||(i.crc=-1,t)){for(n=i.crc,f=0,o=t.length;f>>8^e[255&(n^t[f])];return i.crc=n,-1^n}}!function(){var t,n,i;for(n=0;n<256;n+=1){for(t=n,i=0;i<8;i+=1)1&t?t=r^t>>>1:t>>>=1;e[n]=t>>>0}}(),t.exports=function(t,e){var r,t="string"==typeof t?(r=t,Array.prototype.map.call(r,function(t){return t.charCodeAt(0)})):t,f=e?n(t):i(t);return(f>>>0).toString(16)},t.exports.direct=n,t.exports.table=i}()})?n.apply(e,i):n)||(t.exports=f)},function(t,e){function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(e){return"function"==typeof Symbol&&"symbol"===r(Symbol.iterator)?t.exports=n=function(t){return r(t)}:t.exports=n=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":r(t)},n(e)}t.exports=n},function(t,e,r){var n,i,f;i=[r(0),r(1)],void 0===(f="function"==typeof(n=function(e,n){"use strict";var i=r(2);e=i(e),n=i(n);var f=function(){function t(r){(0,e.default)(this,t),this.transaction=r,this.map={},this.status="",this.hash=""}return(0,n.default)(t,[{key:"on",value:function(t,e){return this.map[t]=e,"success"===t&&this._start(),this}},{key:"pushMsg",value:function(t,e){var r=this.map[t];void 0!==r&&r(e)}},{key:"_start",value:function(){this.status="pending";var t=1,e=this,r=setInterval(function(){if("success"===e.status||"failed"===e.status||t>90)return clearInterval(r),void("success"!==e.status&&"failed"!==e.status&&t>90&&e.pushMsg("failed","Error: tx "+e.hash+" on chain timeout."));t++,e.transaction.getTxReceiptByTxHash(e.hash).then(function(t){"SUCCESS"===t.status_code&&"pending"===e.status?(e.pushMsg("success",t),e.status="success"):void 0!==t.status_code&&"pending"===e.status&&(e.pushMsg("failed",t),e.status="failed")}).catch(function(t){})},1e3)}}]),t}();t.exports=f})?n.apply(e,i):n)||(t.exports=f)},function(t,e,r){var n,i,f;i=[r(0),r(1)],void 0===(f="function"==typeof(n=function(e,n){"use strict";var i=r(2);e=i(e),n=i(n);var f=function(){function t(r){(0,e.default)(this,t),this._id=r,this._key_id={},this._key_pair={}}return(0,n.default)(t,[{key:"addKeyPair",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(""===e&&!(e=this._key_id[t.id]))throw"key pair not exist";this._key_pair[e]=t}},{key:"getID",value:function(){return this._id}},{key:"getKeyPair",value:function(t){return this._kp[t]}},{key:"sign",value:function(t,e){t.addSign(this._key_pair[e])}},{key:"signTx",value:function(t){t.addPublishSign(this._id,this._key_pair.active)}}],[{key:"import",value:function(t){JSON.parse(t)}}]),t}();t.exports=f})?n.apply(e,i):n)||(t.exports=f)}])}); \ No newline at end of file diff --git a/index.js b/index.js index b14da1e2..ec02256f 100644 --- a/index.js +++ b/index.js @@ -20,10 +20,4 @@ module.exports = { TxHandler: TxHandler, Bs58: base58, Signature: Signature, -}; - -(function(){ - if(typeof window !== 'undefined'){ - window.IOST = module.exports - } -})(); \ No newline at end of file +}; \ No newline at end of file diff --git a/package.json b/package.json index 1978f69f..00f9de57 100644 --- a/package.json +++ b/package.json @@ -2,8 +2,11 @@ "name": "iost", "version": "0.1.10", "description": "iost JavaScript SDK", - "main": "index.js", + "main": "dist/iost.min.js", "author": "IOST.IO", + "scripts": { + "dist": "webpack" + }, "dependencies": { "atob": "^2.1.2", "axios": "^0.18.0", @@ -18,6 +21,14 @@ "tweetnacl": "^1.0.0" }, "devDependencies": { - "browserify": "^16.2.3" + "@babel/core": "^7.4.0", + "@babel/plugin-transform-async-to-generator": "^7.4.0", + "@babel/plugin-transform-runtime": "^7.4.0", + "@babel/preset-env": "^7.4.2", + "@babel/runtime": "^7.4.2", + "babel-loader": "^8.0.5", + "browserify": "^16.2.3", + "webpack": "^4.29.6", + "webpack-cli": "^3.3.0" } } diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 00000000..6d5b1152 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,24 @@ +var path = require('path'); + +module.exports = { + mode: 'production', + devtool: false, + entry: { + iost : path.resolve(__dirname, './index.js') + }, + output: { + path: path.resolve(__dirname, './dist'), + filename: '[name].min.js', + library: 'IOST', + libraryTarget: 'umd', + umdNamedDefine: true + }, + module: { + rules: [ + { + test: /\.js$/, + loader: 'babel-loader' + }, + ] + }, +}; \ No newline at end of file