UNPKG

@tendermint/sig

Version:

A signing library for Cosmos

8 lines 386 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Sig=t():e.Sig=t()}(window,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=65)}([function(e,t){"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}},function(e,t,r){(function(e){!function(e,t){"use strict";function n(e,t){if(!e)throw new Error(t||"Assertion failed")}function i(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function f(e,t,r){if(f.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var o;"object"==typeof e?e.exports=f:t.BN=f,f.BN=f,f.wordSize=26;try{o=r(96).Buffer}catch(e){}function a(e,t,r){for(var n=0,i=Math.min(e.length,r),f=t;f<i;f++){var o=e.charCodeAt(f)-48;n<<=4,n|=o>=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return n}function c(e,t,r,n){for(var i=0,f=Math.min(e.length,r),o=t;o<f;o++){var a=e.charCodeAt(o)-48;i*=n,i+=a>=49?a-49+10:a>=17?a-17+10:a}return i}f.isBN=function(e){return e instanceof f||null!==e&&"object"==typeof e&&e.constructor.wordSize===f.wordSize&&Array.isArray(e.words)},f.max=function(e,t){return e.cmp(t)>0?e:t},f.min=function(e,t){return e.cmp(t)<0?e:t},f.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),t,r)},f.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},f.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var f,o,a=0;if("be"===r)for(i=e.length-1,f=0;i>=0;i-=3)o=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[f]|=o<<a&67108863,this.words[f+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,f++);else if("le"===r)for(i=0,f=0;i<e.length;i+=3)o=e[i]|e[i+1]<<8|e[i+2]<<16,this.words[f]|=o<<a&67108863,this.words[f+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,f++);return this.strip()},f.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var n,i,f=0;for(r=e.length-6,n=0;r>=t;r-=6)i=a(e,r,r+6),this.words[n]|=i<<f&67108863,this.words[n+1]|=i>>>26-f&4194303,(f+=24)>=26&&(f-=26,n++);r+6!==t&&(i=a(e,t,r+6),this.words[n]|=i<<f&67108863,this.words[n+1]|=i>>>26-f&4194303),this.strip()},f.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var f=e.length-r,o=f%n,a=Math.min(f,f-o)+r,d=0,s=r;s<a;s+=n)d=c(e,s,s+n,t),this.imuln(i),this.words[0]+d<67108864?this.words[0]+=d:this._iaddn(d);if(0!==o){var u=1;for(d=c(e,s,e.length,t),s=0;s<o;s++)u*=t;this.imuln(u),this.words[0]+d<67108864?this.words[0]+=d:this._iaddn(d)}},f.prototype.copy=function(e){e.words=new Array(this.length);for(var t=0;t<this.length;t++)e.words[t]=this.words[t];e.length=this.length,e.negative=this.negative,e.red=this.red},f.prototype.clone=function(){var e=new f(null);return this.copy(e),e},f.prototype._expand=function(e){for(;this.length<e;)this.words[this.length++]=0;return this},f.prototype.strip=function(){for(;this.length>1&&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?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var d=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],s=[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],u=[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 h(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],f=0|t.words[0],o=i*f,a=67108863&o,c=o/67108864|0;r.words[0]=a;for(var d=1;d<n;d++){for(var s=c>>>26,u=67108863&c,h=Math.min(d,t.length-1),b=Math.max(0,d-e.length+1);b<=h;b++){var l=d-b|0;s+=(o=(i=0|e.words[l])*(f=0|t.words[b])+u)/67108864|0,u=67108863&o}r.words[d]=0|u,c=0|s}return 0!==c?r.words[d]=0|c:r.length--,r.strip()}f.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,f=0,o=0;o<this.length;o++){var a=this.words[o],c=(16777215&(a<<i|f)).toString(16);r=0!==(f=a>>>24-i&16777215)||o!==this.length-1?d[6-c.length]+c+r:c+r,(i+=2)>=26&&(i-=26,o--)}for(0!==f&&(r=f.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var h=s[e],b=u[e];r="";var l=this.clone();for(l.negative=0;!l.isZero();){var p=l.modn(b).toString(e);r=(l=l.idivn(b)).isZero()?p+r:d[h-p.length]+p+r}for(this.isZero()&&(r="0"+r);r.length%t!=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 e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},f.prototype.toJSON=function(){return this.toString(16)},f.prototype.toBuffer=function(e,t){return n(void 0!==o),this.toArrayLike(o,e,t)},f.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},f.prototype.toArrayLike=function(e,t,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,c="le"===t,d=new e(f),s=this.clone();if(c){for(a=0;!s.isZero();a++)o=s.andln(255),s.iushrn(8),d[a]=o;for(;a<f;a++)d[a]=0}else{for(a=0;a<f-i;a++)d[a]=0;for(a=0;!s.isZero();a++)o=s.andln(255),s.iushrn(8),d[f-a-1]=o}return d},Math.clz32?f.prototype._countBits=function(e){return 32-Math.clz32(e)}:f.prototype._countBits=function(e){var t=e,r=0;return t>=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},f.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},f.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},f.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;t<this.length;t++){var r=this._zeroBits(this.words[t]);if(e+=r,26!==r)break}return e},f.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},f.prototype.toTwos=function(e){return 0!==this.negative?this.abs().inotn(e).iaddn(1):this.clone()},f.prototype.fromTwos=function(e){return this.testn(e-1)?this.notn(e).iaddn(1).ineg():this.clone()},f.prototype.isNeg=function(){return 0!==this.negative},f.prototype.neg=function(){return this.clone().ineg()},f.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},f.prototype.iuor=function(e){for(;this.length<e.length;)this.words[this.length++]=0;for(var t=0;t<e.length;t++)this.words[t]=this.words[t]|e.words[t];return this.strip()},f.prototype.ior=function(e){return n(0==(this.negative|e.negative)),this.iuor(e)},f.prototype.or=function(e){return this.length>e.length?this.clone().ior(e):e.clone().ior(this)},f.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},f.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;r<t.length;r++)this.words[r]=this.words[r]&e.words[r];return this.length=t.length,this.strip()},f.prototype.iand=function(e){return n(0==(this.negative|e.negative)),this.iuand(e)},f.prototype.and=function(e){return this.length>e.length?this.clone().iand(e):e.clone().iand(this)},f.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},f.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;n<r.length;n++)this.words[n]=t.words[n]^r.words[n];if(this!==t)for(;n<t.length;n++)this.words[n]=t.words[n];return this.length=t.length,this.strip()},f.prototype.ixor=function(e){return n(0==(this.negative|e.negative)),this.iuxor(e)},f.prototype.xor=function(e){return this.length>e.length?this.clone().ixor(e):e.clone().ixor(this)},f.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},f.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i<t;i++)this.words[i]=67108863&~this.words[i];return r>0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},f.prototype.notn=function(e){return this.clone().inotn(e)},f.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<<i:this.words[r]&~(1<<i),this.strip()},f.prototype.iadd=function(e){var t,r,n;if(0!==this.negative&&0===e.negative)return this.negative=0,t=this.isub(e),this.negative^=1,this._normSign();if(0===this.negative&&0!==e.negative)return e.negative=0,t=this.isub(e),e.negative=1,t._normSign();this.length>e.length?(r=this,n=e):(r=e,n=this);for(var i=0,f=0;f<n.length;f++)t=(0|r.words[f])+(0|n.words[f])+i,this.words[f]=67108863&t,i=t>>>26;for(;0!==i&&f<r.length;f++)t=(0|r.words[f])+i,this.words[f]=67108863&t,i=t>>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;f<r.length;f++)this.words[f]=r.words[f];return this},f.prototype.add=function(e){var t;return 0!==e.negative&&0===this.negative?(e.negative=0,t=this.sub(e),e.negative^=1,t):0===e.negative&&0!==this.negative?(this.negative=0,t=e.sub(this),this.negative=1,t):this.length>e.length?this.clone().iadd(e):e.clone().iadd(this)},f.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var f=0,o=0;o<n.length;o++)f=(t=(0|r.words[o])-(0|n.words[o])+f)>>26,this.words[o]=67108863&t;for(;0!==f&&o<r.length;o++)f=(t=(0|r.words[o])+f)>>26,this.words[o]=67108863&t;if(0===f&&o<r.length&&r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this.length=Math.max(this.length,o),r!==this&&(this.negative=1),this.strip()},f.prototype.sub=function(e){return this.clone().isub(e)};var b=function(e,t,r){var n,i,f,o=e.words,a=t.words,c=r.words,d=0,s=0|o[0],u=8191&s,h=s>>>13,b=0|o[1],l=8191&b,p=b>>>13,y=0|o[2],g=8191&y,v=y>>>13,m=0|o[3],w=8191&m,_=m>>>13,S=0|o[4],M=8191&S,A=S>>>13,x=0|o[5],E=8191&x,I=x>>>13,O=0|o[6],T=8191&O,R=O>>>13,P=0|o[7],k=8191&P,j=P>>>13,B=0|o[8],z=8191&B,N=B>>>13,L=0|o[9],C=8191&L,q=L>>>13,U=0|a[0],D=8191&U,F=U>>>13,K=0|a[1],Y=8191&K,J=K>>>13,W=0|a[2],H=8191&W,X=W>>>13,Z=0|a[3],V=8191&Z,$=Z>>>13,G=0|a[4],Q=8191&G,ee=G>>>13,te=0|a[5],re=8191&te,ne=te>>>13,ie=0|a[6],fe=8191&ie,oe=ie>>>13,ae=0|a[7],ce=8191&ae,de=ae>>>13,se=0|a[8],ue=8191&se,he=se>>>13,be=0|a[9],le=8191&be,pe=be>>>13;r.negative=e.negative^t.negative,r.length=19;var ye=(d+(n=Math.imul(u,D))|0)+((8191&(i=(i=Math.imul(u,F))+Math.imul(h,D)|0))<<13)|0;d=((f=Math.imul(h,F))+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(l,D),i=(i=Math.imul(l,F))+Math.imul(p,D)|0,f=Math.imul(p,F);var ge=(d+(n=n+Math.imul(u,Y)|0)|0)+((8191&(i=(i=i+Math.imul(u,J)|0)+Math.imul(h,Y)|0))<<13)|0;d=((f=f+Math.imul(h,J)|0)+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(g,D),i=(i=Math.imul(g,F))+Math.imul(v,D)|0,f=Math.imul(v,F),n=n+Math.imul(l,Y)|0,i=(i=i+Math.imul(l,J)|0)+Math.imul(p,Y)|0,f=f+Math.imul(p,J)|0;var ve=(d+(n=n+Math.imul(u,H)|0)|0)+((8191&(i=(i=i+Math.imul(u,X)|0)+Math.imul(h,H)|0))<<13)|0;d=((f=f+Math.imul(h,X)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(w,D),i=(i=Math.imul(w,F))+Math.imul(_,D)|0,f=Math.imul(_,F),n=n+Math.imul(g,Y)|0,i=(i=i+Math.imul(g,J)|0)+Math.imul(v,Y)|0,f=f+Math.imul(v,J)|0,n=n+Math.imul(l,H)|0,i=(i=i+Math.imul(l,X)|0)+Math.imul(p,H)|0,f=f+Math.imul(p,X)|0;var me=(d+(n=n+Math.imul(u,V)|0)|0)+((8191&(i=(i=i+Math.imul(u,$)|0)+Math.imul(h,V)|0))<<13)|0;d=((f=f+Math.imul(h,$)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(M,D),i=(i=Math.imul(M,F))+Math.imul(A,D)|0,f=Math.imul(A,F),n=n+Math.imul(w,Y)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,Y)|0,f=f+Math.imul(_,J)|0,n=n+Math.imul(g,H)|0,i=(i=i+Math.imul(g,X)|0)+Math.imul(v,H)|0,f=f+Math.imul(v,X)|0,n=n+Math.imul(l,V)|0,i=(i=i+Math.imul(l,$)|0)+Math.imul(p,V)|0,f=f+Math.imul(p,$)|0;var we=(d+(n=n+Math.imul(u,Q)|0)|0)+((8191&(i=(i=i+Math.imul(u,ee)|0)+Math.imul(h,Q)|0))<<13)|0;d=((f=f+Math.imul(h,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(E,D),i=(i=Math.imul(E,F))+Math.imul(I,D)|0,f=Math.imul(I,F),n=n+Math.imul(M,Y)|0,i=(i=i+Math.imul(M,J)|0)+Math.imul(A,Y)|0,f=f+Math.imul(A,J)|0,n=n+Math.imul(w,H)|0,i=(i=i+Math.imul(w,X)|0)+Math.imul(_,H)|0,f=f+Math.imul(_,X)|0,n=n+Math.imul(g,V)|0,i=(i=i+Math.imul(g,$)|0)+Math.imul(v,V)|0,f=f+Math.imul(v,$)|0,n=n+Math.imul(l,Q)|0,i=(i=i+Math.imul(l,ee)|0)+Math.imul(p,Q)|0,f=f+Math.imul(p,ee)|0;var _e=(d+(n=n+Math.imul(u,re)|0)|0)+((8191&(i=(i=i+Math.imul(u,ne)|0)+Math.imul(h,re)|0))<<13)|0;d=((f=f+Math.imul(h,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(T,D),i=(i=Math.imul(T,F))+Math.imul(R,D)|0,f=Math.imul(R,F),n=n+Math.imul(E,Y)|0,i=(i=i+Math.imul(E,J)|0)+Math.imul(I,Y)|0,f=f+Math.imul(I,J)|0,n=n+Math.imul(M,H)|0,i=(i=i+Math.imul(M,X)|0)+Math.imul(A,H)|0,f=f+Math.imul(A,X)|0,n=n+Math.imul(w,V)|0,i=(i=i+Math.imul(w,$)|0)+Math.imul(_,V)|0,f=f+Math.imul(_,$)|0,n=n+Math.imul(g,Q)|0,i=(i=i+Math.imul(g,ee)|0)+Math.imul(v,Q)|0,f=f+Math.imul(v,ee)|0,n=n+Math.imul(l,re)|0,i=(i=i+Math.imul(l,ne)|0)+Math.imul(p,re)|0,f=f+Math.imul(p,ne)|0;var Se=(d+(n=n+Math.imul(u,fe)|0)|0)+((8191&(i=(i=i+Math.imul(u,oe)|0)+Math.imul(h,fe)|0))<<13)|0;d=((f=f+Math.imul(h,oe)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(k,D),i=(i=Math.imul(k,F))+Math.imul(j,D)|0,f=Math.imul(j,F),n=n+Math.imul(T,Y)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(R,Y)|0,f=f+Math.imul(R,J)|0,n=n+Math.imul(E,H)|0,i=(i=i+Math.imul(E,X)|0)+Math.imul(I,H)|0,f=f+Math.imul(I,X)|0,n=n+Math.imul(M,V)|0,i=(i=i+Math.imul(M,$)|0)+Math.imul(A,V)|0,f=f+Math.imul(A,$)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,Q)|0,f=f+Math.imul(_,ee)|0,n=n+Math.imul(g,re)|0,i=(i=i+Math.imul(g,ne)|0)+Math.imul(v,re)|0,f=f+Math.imul(v,ne)|0,n=n+Math.imul(l,fe)|0,i=(i=i+Math.imul(l,oe)|0)+Math.imul(p,fe)|0,f=f+Math.imul(p,oe)|0;var Me=(d+(n=n+Math.imul(u,ce)|0)|0)+((8191&(i=(i=i+Math.imul(u,de)|0)+Math.imul(h,ce)|0))<<13)|0;d=((f=f+Math.imul(h,de)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(z,D),i=(i=Math.imul(z,F))+Math.imul(N,D)|0,f=Math.imul(N,F),n=n+Math.imul(k,Y)|0,i=(i=i+Math.imul(k,J)|0)+Math.imul(j,Y)|0,f=f+Math.imul(j,J)|0,n=n+Math.imul(T,H)|0,i=(i=i+Math.imul(T,X)|0)+Math.imul(R,H)|0,f=f+Math.imul(R,X)|0,n=n+Math.imul(E,V)|0,i=(i=i+Math.imul(E,$)|0)+Math.imul(I,V)|0,f=f+Math.imul(I,$)|0,n=n+Math.imul(M,Q)|0,i=(i=i+Math.imul(M,ee)|0)+Math.imul(A,Q)|0,f=f+Math.imul(A,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,f=f+Math.imul(_,ne)|0,n=n+Math.imul(g,fe)|0,i=(i=i+Math.imul(g,oe)|0)+Math.imul(v,fe)|0,f=f+Math.imul(v,oe)|0,n=n+Math.imul(l,ce)|0,i=(i=i+Math.imul(l,de)|0)+Math.imul(p,ce)|0,f=f+Math.imul(p,de)|0;var Ae=(d+(n=n+Math.imul(u,ue)|0)|0)+((8191&(i=(i=i+Math.imul(u,he)|0)+Math.imul(h,ue)|0))<<13)|0;d=((f=f+Math.imul(h,he)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(C,D),i=(i=Math.imul(C,F))+Math.imul(q,D)|0,f=Math.imul(q,F),n=n+Math.imul(z,Y)|0,i=(i=i+Math.imul(z,J)|0)+Math.imul(N,Y)|0,f=f+Math.imul(N,J)|0,n=n+Math.imul(k,H)|0,i=(i=i+Math.imul(k,X)|0)+Math.imul(j,H)|0,f=f+Math.imul(j,X)|0,n=n+Math.imul(T,V)|0,i=(i=i+Math.imul(T,$)|0)+Math.imul(R,V)|0,f=f+Math.imul(R,$)|0,n=n+Math.imul(E,Q)|0,i=(i=i+Math.imul(E,ee)|0)+Math.imul(I,Q)|0,f=f+Math.imul(I,ee)|0,n=n+Math.imul(M,re)|0,i=(i=i+Math.imul(M,ne)|0)+Math.imul(A,re)|0,f=f+Math.imul(A,ne)|0,n=n+Math.imul(w,fe)|0,i=(i=i+Math.imul(w,oe)|0)+Math.imul(_,fe)|0,f=f+Math.imul(_,oe)|0,n=n+Math.imul(g,ce)|0,i=(i=i+Math.imul(g,de)|0)+Math.imul(v,ce)|0,f=f+Math.imul(v,de)|0,n=n+Math.imul(l,ue)|0,i=(i=i+Math.imul(l,he)|0)+Math.imul(p,ue)|0,f=f+Math.imul(p,he)|0;var xe=(d+(n=n+Math.imul(u,le)|0)|0)+((8191&(i=(i=i+Math.imul(u,pe)|0)+Math.imul(h,le)|0))<<13)|0;d=((f=f+Math.imul(h,pe)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(C,Y),i=(i=Math.imul(C,J))+Math.imul(q,Y)|0,f=Math.imul(q,J),n=n+Math.imul(z,H)|0,i=(i=i+Math.imul(z,X)|0)+Math.imul(N,H)|0,f=f+Math.imul(N,X)|0,n=n+Math.imul(k,V)|0,i=(i=i+Math.imul(k,$)|0)+Math.imul(j,V)|0,f=f+Math.imul(j,$)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,ee)|0)+Math.imul(R,Q)|0,f=f+Math.imul(R,ee)|0,n=n+Math.imul(E,re)|0,i=(i=i+Math.imul(E,ne)|0)+Math.imul(I,re)|0,f=f+Math.imul(I,ne)|0,n=n+Math.imul(M,fe)|0,i=(i=i+Math.imul(M,oe)|0)+Math.imul(A,fe)|0,f=f+Math.imul(A,oe)|0,n=n+Math.imul(w,ce)|0,i=(i=i+Math.imul(w,de)|0)+Math.imul(_,ce)|0,f=f+Math.imul(_,de)|0,n=n+Math.imul(g,ue)|0,i=(i=i+Math.imul(g,he)|0)+Math.imul(v,ue)|0,f=f+Math.imul(v,he)|0;var Ee=(d+(n=n+Math.imul(l,le)|0)|0)+((8191&(i=(i=i+Math.imul(l,pe)|0)+Math.imul(p,le)|0))<<13)|0;d=((f=f+Math.imul(p,pe)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(C,H),i=(i=Math.imul(C,X))+Math.imul(q,H)|0,f=Math.imul(q,X),n=n+Math.imul(z,V)|0,i=(i=i+Math.imul(z,$)|0)+Math.imul(N,V)|0,f=f+Math.imul(N,$)|0,n=n+Math.imul(k,Q)|0,i=(i=i+Math.imul(k,ee)|0)+Math.imul(j,Q)|0,f=f+Math.imul(j,ee)|0,n=n+Math.imul(T,re)|0,i=(i=i+Math.imul(T,ne)|0)+Math.imul(R,re)|0,f=f+Math.imul(R,ne)|0,n=n+Math.imul(E,fe)|0,i=(i=i+Math.imul(E,oe)|0)+Math.imul(I,fe)|0,f=f+Math.imul(I,oe)|0,n=n+Math.imul(M,ce)|0,i=(i=i+Math.imul(M,de)|0)+Math.imul(A,ce)|0,f=f+Math.imul(A,de)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,he)|0)+Math.imul(_,ue)|0,f=f+Math.imul(_,he)|0;var Ie=(d+(n=n+Math.imul(g,le)|0)|0)+((8191&(i=(i=i+Math.imul(g,pe)|0)+Math.imul(v,le)|0))<<13)|0;d=((f=f+Math.imul(v,pe)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(C,V),i=(i=Math.imul(C,$))+Math.imul(q,V)|0,f=Math.imul(q,$),n=n+Math.imul(z,Q)|0,i=(i=i+Math.imul(z,ee)|0)+Math.imul(N,Q)|0,f=f+Math.imul(N,ee)|0,n=n+Math.imul(k,re)|0,i=(i=i+Math.imul(k,ne)|0)+Math.imul(j,re)|0,f=f+Math.imul(j,ne)|0,n=n+Math.imul(T,fe)|0,i=(i=i+Math.imul(T,oe)|0)+Math.imul(R,fe)|0,f=f+Math.imul(R,oe)|0,n=n+Math.imul(E,ce)|0,i=(i=i+Math.imul(E,de)|0)+Math.imul(I,ce)|0,f=f+Math.imul(I,de)|0,n=n+Math.imul(M,ue)|0,i=(i=i+Math.imul(M,he)|0)+Math.imul(A,ue)|0,f=f+Math.imul(A,he)|0;var Oe=(d+(n=n+Math.imul(w,le)|0)|0)+((8191&(i=(i=i+Math.imul(w,pe)|0)+Math.imul(_,le)|0))<<13)|0;d=((f=f+Math.imul(_,pe)|0)+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,n=Math.imul(C,Q),i=(i=Math.imul(C,ee))+Math.imul(q,Q)|0,f=Math.imul(q,ee),n=n+Math.imul(z,re)|0,i=(i=i+Math.imul(z,ne)|0)+Math.imul(N,re)|0,f=f+Math.imul(N,ne)|0,n=n+Math.imul(k,fe)|0,i=(i=i+Math.imul(k,oe)|0)+Math.imul(j,fe)|0,f=f+Math.imul(j,oe)|0,n=n+Math.imul(T,ce)|0,i=(i=i+Math.imul(T,de)|0)+Math.imul(R,ce)|0,f=f+Math.imul(R,de)|0,n=n+Math.imul(E,ue)|0,i=(i=i+Math.imul(E,he)|0)+Math.imul(I,ue)|0,f=f+Math.imul(I,he)|0;var Te=(d+(n=n+Math.imul(M,le)|0)|0)+((8191&(i=(i=i+Math.imul(M,pe)|0)+Math.imul(A,le)|0))<<13)|0;d=((f=f+Math.imul(A,pe)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(C,re),i=(i=Math.imul(C,ne))+Math.imul(q,re)|0,f=Math.imul(q,ne),n=n+Math.imul(z,fe)|0,i=(i=i+Math.imul(z,oe)|0)+Math.imul(N,fe)|0,f=f+Math.imul(N,oe)|0,n=n+Math.imul(k,ce)|0,i=(i=i+Math.imul(k,de)|0)+Math.imul(j,ce)|0,f=f+Math.imul(j,de)|0,n=n+Math.imul(T,ue)|0,i=(i=i+Math.imul(T,he)|0)+Math.imul(R,ue)|0,f=f+Math.imul(R,he)|0;var Re=(d+(n=n+Math.imul(E,le)|0)|0)+((8191&(i=(i=i+Math.imul(E,pe)|0)+Math.imul(I,le)|0))<<13)|0;d=((f=f+Math.imul(I,pe)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863,n=Math.imul(C,fe),i=(i=Math.imul(C,oe))+Math.imul(q,fe)|0,f=Math.imul(q,oe),n=n+Math.imul(z,ce)|0,i=(i=i+Math.imul(z,de)|0)+Math.imul(N,ce)|0,f=f+Math.imul(N,de)|0,n=n+Math.imul(k,ue)|0,i=(i=i+Math.imul(k,he)|0)+Math.imul(j,ue)|0,f=f+Math.imul(j,he)|0;var Pe=(d+(n=n+Math.imul(T,le)|0)|0)+((8191&(i=(i=i+Math.imul(T,pe)|0)+Math.imul(R,le)|0))<<13)|0;d=((f=f+Math.imul(R,pe)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,n=Math.imul(C,ce),i=(i=Math.imul(C,de))+Math.imul(q,ce)|0,f=Math.imul(q,de),n=n+Math.imul(z,ue)|0,i=(i=i+Math.imul(z,he)|0)+Math.imul(N,ue)|0,f=f+Math.imul(N,he)|0;var ke=(d+(n=n+Math.imul(k,le)|0)|0)+((8191&(i=(i=i+Math.imul(k,pe)|0)+Math.imul(j,le)|0))<<13)|0;d=((f=f+Math.imul(j,pe)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(C,ue),i=(i=Math.imul(C,he))+Math.imul(q,ue)|0,f=Math.imul(q,he);var je=(d+(n=n+Math.imul(z,le)|0)|0)+((8191&(i=(i=i+Math.imul(z,pe)|0)+Math.imul(N,le)|0))<<13)|0;d=((f=f+Math.imul(N,pe)|0)+(i>>>13)|0)+(je>>>26)|0,je&=67108863;var Be=(d+(n=Math.imul(C,le))|0)+((8191&(i=(i=Math.imul(C,pe))+Math.imul(q,le)|0))<<13)|0;return d=((f=Math.imul(q,pe))+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,c[0]=ye,c[1]=ge,c[2]=ve,c[3]=me,c[4]=we,c[5]=_e,c[6]=Se,c[7]=Me,c[8]=Ae,c[9]=xe,c[10]=Ee,c[11]=Ie,c[12]=Oe,c[13]=Te,c[14]=Re,c[15]=Pe,c[16]=ke,c[17]=je,c[18]=Be,0!==d&&(c[19]=d,r.length++),r};function l(e,t,r){return(new p).mulp(e,t,r)}function p(e,t){this.x=e,this.y=t}Math.imul||(b=h),f.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?b(this,e,t):r<63?h(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,f=0;f<r.length-1;f++){var o=i;i=0;for(var a=67108863&n,c=Math.min(f,t.length-1),d=Math.max(0,f-e.length+1);d<=c;d++){var s=f-d,u=(0|e.words[s])*(0|t.words[d]),h=67108863&u;a=67108863&(h=h+a|0),i+=(o=(o=o+(u/67108864|0)|0)+(h>>>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,e,t):l(this,e,t)},p.prototype.makeRBT=function(e){for(var t=new Array(e),r=f.prototype._countBits(e)-1,n=0;n<e;n++)t[n]=this.revBin(n,r,e);return t},p.prototype.revBin=function(e,t,r){if(0===e||e===r-1)return e;for(var n=0,i=0;i<t;i++)n|=(1&e)<<t-i-1,e>>=1;return n},p.prototype.permute=function(e,t,r,n,i,f){for(var o=0;o<f;o++)n[o]=t[e[o]],i[o]=r[e[o]]},p.prototype.transform=function(e,t,r,n,i,f){this.permute(f,e,t,r,n,i);for(var o=1;o<i;o<<=1)for(var a=o<<1,c=Math.cos(2*Math.PI/a),d=Math.sin(2*Math.PI/a),s=0;s<i;s+=a)for(var u=c,h=d,b=0;b<o;b++){var l=r[s+b],p=n[s+b],y=r[s+b+o],g=n[s+b+o],v=u*y-h*g;g=u*g+h*y,y=v,r[s+b]=l+y,n[s+b]=p+g,r[s+b+o]=l-y,n[s+b+o]=p-g,b!==a&&(v=c*u-d*h,h=c*h+d*u,u=v)}},p.prototype.guessLen13b=function(e,t){var r=1|Math.max(t,e),n=1&r,i=0;for(r=r/2|0;r;r>>>=1)i++;return 1<<i+1+n},p.prototype.conjugate=function(e,t,r){if(!(r<=1))for(var n=0;n<r/2;n++){var i=e[n];e[n]=e[r-n-1],e[r-n-1]=i,i=t[n],t[n]=-t[r-n-1],t[r-n-1]=-i}},p.prototype.normalize13b=function(e,t){for(var r=0,n=0;n<t/2;n++){var i=8192*Math.round(e[2*n+1]/t)+Math.round(e[2*n]/t)+r;e[n]=67108863&i,r=i<67108864?0:i/67108864|0}return e},p.prototype.convert13b=function(e,t,r,i){for(var f=0,o=0;o<t;o++)f+=0|e[o],r[2*o]=8191&f,f>>>=13,r[2*o+1]=8191&f,f>>>=13;for(o=2*t;o<i;++o)r[o]=0;n(0===f),n(0==(-8192&f))},p.prototype.stub=function(e){for(var t=new Array(e),r=0;r<e;r++)t[r]=0;return t},p.prototype.mulp=function(e,t,r){var n=2*this.guessLen13b(e.length,t.length),i=this.makeRBT(n),f=this.stub(n),o=new Array(n),a=new Array(n),c=new Array(n),d=new Array(n),s=new Array(n),u=new Array(n),h=r.words;h.length=n,this.convert13b(e.words,e.length,o,n),this.convert13b(t.words,t.length,d,n),this.transform(o,f,a,c,n,i),this.transform(d,f,s,u,n,i);for(var b=0;b<n;b++){var l=a[b]*s[b]-c[b]*u[b];c[b]=a[b]*u[b]+c[b]*s[b],a[b]=l}return this.conjugate(a,c,n),this.transform(a,c,h,f,n,i),this.conjugate(h,f,n),this.normalize13b(h,n),r.negative=e.negative^t.negative,r.length=e.length+t.length,r.strip()},f.prototype.mul=function(e){var t=new f(null);return t.words=new Array(this.length+e.length),this.mulTo(e,t)},f.prototype.mulf=function(e){var t=new f(null);return t.words=new Array(this.length+e.length),l(this,e,t)},f.prototype.imul=function(e){return this.clone().mulTo(e,this)},f.prototype.imuln=function(e){n("number"==typeof e),n(e<67108864);for(var t=0,r=0;r<this.length;r++){var i=(0|this.words[r])*e,f=(67108863&i)+(67108863&t);t>>=26,t+=i/67108864|0,t+=f>>>26,this.words[r]=67108863&f}return 0!==t&&(this.words[r]=t,this.length++),this},f.prototype.muln=function(e){return this.clone().imuln(e)},f.prototype.sqr=function(){return this.mul(this)},f.prototype.isqr=function(){return this.imul(this.clone())},f.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r<t.length;r++){var n=r/26|0,i=r%26;t[r]=(e.words[n]&1<<i)>>>i}return t}(e);if(0===t.length)return new f(1);for(var r=this,n=0;n<t.length&&0===t[n];n++,r=r.sqr());if(++n<t.length)for(var i=r.sqr();n<t.length;n++,i=i.sqr())0!==t[n]&&(r=r.mul(i));return r},f.prototype.iushln=function(e){n("number"==typeof e&&e>=0);var t,r=e%26,i=(e-r)/26,f=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(t=0;t<this.length;t++){var a=this.words[t]&f,c=(0|this.words[t])-a<<r;this.words[t]=c|o,o=a>>>26-r}o&&(this.words[t]=o,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t<i;t++)this.words[t]=0;this.length+=i}return this.strip()},f.prototype.ishln=function(e){return n(0===this.negative),this.iushln(e)},f.prototype.iushrn=function(e,t,r){var i;n("number"==typeof e&&e>=0),i=t?(t-t%26)/26:0;var f=e%26,o=Math.min((e-f)/26,this.length),a=67108863^67108863>>>f<<f,c=r;if(i-=o,i=Math.max(0,i),c){for(var d=0;d<o;d++)c.words[d]=this.words[d];c.length=o}if(0===o);else if(this.length>o)for(this.length-=o,d=0;d<this.length;d++)this.words[d]=this.words[d+o];else this.words[0]=0,this.length=1;var s=0;for(d=this.length-1;d>=0&&(0!==s||d>=i);d--){var u=0|this.words[d];this.words[d]=s<<26-f|u>>>f,s=u&a}return c&&0!==s&&(c.words[c.length++]=s),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},f.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},f.prototype.shln=function(e){return this.clone().ishln(e)},f.prototype.ushln=function(e){return this.clone().iushln(e)},f.prototype.shrn=function(e){return this.clone().ishrn(e)},f.prototype.ushrn=function(e){return this.clone().iushrn(e)},f.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<<t;return!(this.length<=r)&&!!(this.words[r]&i)},f.prototype.imaskn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<<t;this.words[this.length-1]&=i}return this.strip()},f.prototype.maskn=function(e){return this.clone().imaskn(e)},f.prototype.iaddn=function(e){return n("number"==typeof e),n(e<67108864),e<0?this.isubn(-e):0!==this.negative?1===this.length&&(0|this.words[0])<e?(this.words[0]=e-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(e),this.negative=1,this):this._iaddn(e)},f.prototype._iaddn=function(e){this.words[0]+=e;for(var t=0;t<this.length&&this.words[t]>=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},f.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t<this.length&&this.words[t]<0;t++)this.words[t]+=67108864,this.words[t+1]-=1;return this.strip()},f.prototype.addn=function(e){return this.clone().iaddn(e)},f.prototype.subn=function(e){return this.clone().isubn(e)},f.prototype.iabs=function(){return this.negative=0,this},f.prototype.abs=function(){return this.clone().iabs()},f.prototype._ishlnsubmul=function(e,t,r){var i,f,o=e.length+r;this._expand(o);var a=0;for(i=0;i<e.length;i++){f=(0|this.words[i+r])+a;var c=(0|e.words[i])*t;a=((f-=67108863&c)>>26)-(c/67108864|0),this.words[i+r]=67108863&f}for(;i<this.length-r;i++)a=(f=(0|this.words[i+r])+a)>>26,this.words[i+r]=67108863&f;if(0===a)return this.strip();for(n(-1===a),a=0,i=0;i<this.length;i++)a=(f=-(0|this.words[i])+a)>>26,this.words[i]=67108863&f;return this.negative=1,this.strip()},f.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,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,c=n.length-i.length;if("mod"!==t){(a=new f(null)).length=c+1,a.words=new Array(a.length);for(var d=0;d<a.length;d++)a.words[d]=0}var s=n.clone()._ishlnsubmul(i,1,c);0===s.negative&&(n=s,a&&(a.words[c]=1));for(var u=c-1;u>=0;u--){var h=67108864*(0|n.words[i.length+u])+(0|n.words[i.length+u-1]);for(h=Math.min(h/o|0,67108863),n._ishlnsubmul(i,h,u);0!==n.negative;)h--,n.negative=0,n._ishlnsubmul(i,1,u),n.isZero()||(n.negative^=1);a&&(a.words[u]=h)}return a&&a.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},f.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new f(0),mod:new f(0)}:0!==this.negative&&0===e.negative?(a=this.neg().divmod(e,t),"mod"!==t&&(i=a.div.neg()),"div"!==t&&(o=a.mod.neg(),r&&0!==o.negative&&o.iadd(e)),{div:i,mod:o}):0===this.negative&&0!==e.negative?(a=this.divmod(e.neg(),t),"mod"!==t&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&e.negative)?(a=this.neg().divmod(e.neg(),t),"div"!==t&&(o=a.mod.neg(),r&&0!==o.negative&&o.isub(e)),{div:a.div,mod:o}):e.length>this.length||this.cmp(e)<0?{div:new f(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new f(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new f(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,o,a},f.prototype.div=function(e){return this.divmod(e,"div",!1).div},f.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},f.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},f.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),f=r.cmp(n);return f<0||1===i&&0===f?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},f.prototype.modn=function(e){n(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;i>=0;i--)r=(t*r+(0|this.words[i]))%e;return r},f.prototype.idivn=function(e){n(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*t;this.words[r]=i/e|0,t=i%e}return this.strip()},f.prototype.divn=function(e){return this.clone().idivn(e)},f.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new f(1),o=new f(0),a=new f(0),c=new f(1),d=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++d;for(var s=r.clone(),u=t.clone();!t.isZero();){for(var h=0,b=1;0==(t.words[0]&b)&&h<26;++h,b<<=1);if(h>0)for(t.iushrn(h);h-- >0;)(i.isOdd()||o.isOdd())&&(i.iadd(s),o.isub(u)),i.iushrn(1),o.iushrn(1);for(var l=0,p=1;0==(r.words[0]&p)&&l<26;++l,p<<=1);if(l>0)for(r.iushrn(l);l-- >0;)(a.isOdd()||c.isOdd())&&(a.iadd(s),c.isub(u)),a.iushrn(1),c.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(a),o.isub(c)):(r.isub(t),a.isub(i),c.isub(o))}return{a:a,b:c,gcd:r.iushln(d)}},f.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,o=new f(1),a=new f(0),c=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var d=0,s=1;0==(t.words[0]&s)&&d<26;++d,s<<=1);if(d>0)for(t.iushrn(d);d-- >0;)o.isOdd()&&o.iadd(c),o.iushrn(1);for(var u=0,h=1;0==(r.words[0]&h)&&u<26;++u,h<<=1);if(u>0)for(r.iushrn(u);u-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);t.cmp(r)>=0?(t.isub(r),o.isub(a)):(r.isub(t),a.isub(o))}return(i=0===t.cmpn(1)?o:a).cmpn(0)<0&&i.iadd(e),i},f.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var f=t;t=r,r=f}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},f.prototype.invm=function(e){return this.egcd(e).a.umod(e)},f.prototype.isEven=function(){return 0==(1&this.words[0])},f.prototype.isOdd=function(){return 1==(1&this.words[0])},f.prototype.andln=function(e){return this.words[0]&e},f.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<<t;if(this.length<=r)return this._expand(r+1),this.words[r]|=i,this;for(var f=i,o=r;0!==f&&o<this.length;o++){var a=0|this.words[o];f=(a+=f)>>>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(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:i<e?-1:1}return 0!==this.negative?0|-t:t},f.prototype.cmp=function(e){if(0!==this.negative&&0===e.negative)return-1;if(0===this.negative&&0!==e.negative)return 1;var t=this.ucmp(e);return 0!==this.negative?0|-t:t},f.prototype.ucmp=function(e){if(this.length>e.length)return 1;if(this.length<e.length)return-1;for(var t=0,r=this.length-1;r>=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){n<i?t=-1:n>i&&(t=1);break}}return t},f.prototype.gtn=function(e){return 1===this.cmpn(e)},f.prototype.gt=function(e){return 1===this.cmp(e)},f.prototype.gten=function(e){return this.cmpn(e)>=0},f.prototype.gte=function(e){return this.cmp(e)>=0},f.prototype.ltn=function(e){return-1===this.cmpn(e)},f.prototype.lt=function(e){return-1===this.cmp(e)},f.prototype.lten=function(e){return this.cmpn(e)<=0},f.prototype.lte=function(e){return this.cmp(e)<=0},f.prototype.eqn=function(e){return 0===this.cmpn(e)},f.prototype.eq=function(e){return 0===this.cmp(e)},f.red=function(e){return new S(e)},f.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},f.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},f.prototype._forceRed=function(e){return this.red=e,this},f.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},f.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},f.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},f.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},f.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},f.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},f.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},f.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},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(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var y={k256:null,p224:null,p192:null,p25519:null};function g(e,t){this.name=e,this.p=new f(t,16),this.n=this.p.bitLength(),this.k=new f(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){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 _(){g.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function S(e){if("string"==typeof e){var t=f._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function M(e){S.call(this,e),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 e=new f(null);return e.words=new Array(Math.ceil(this.n/13)),e},g.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t<this.n?-1:r.ucmp(this.p);return 0===n?(r.words[0]=0,r.length=1):n>0?r.isub(this.p):r.strip(),r},g.prototype.split=function(e,t){e.iushrn(this.n,0,t)},g.prototype.imulK=function(e){return e.imul(this.k)},i(v,g),v.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n<r;n++)t.words[n]=e.words[n];if(t.length=r,e.length<=9)return e.words[0]=0,void(e.length=1);var i=e.words[9];for(t.words[t.length++]=4194303&i,n=10;n<e.length;n++){var f=0|e.words[n];e.words[n-10]=(4194303&f)<<4|i>>>22,i=f}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r<e.length;r++){var n=0|e.words[r];t+=977*n,e.words[r]=67108863&t,t=64*n+(t/67108864|0)}return 0===e.words[e.length-1]&&(e.length--,0===e.words[e.length-1]&&e.length--),e},i(m,g),i(w,g),i(_,g),_.prototype.imulK=function(e){for(var t=0,r=0;r<e.length;r++){var n=19*(0|e.words[r])+t,i=67108863&n;n>>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},f._prime=function(e){if(y[e])return y[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new m;else if("p192"===e)t=new w;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new _}return y[e]=t,t},S.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},S.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},S.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},S.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},S.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},S.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},S.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},S.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},S.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},S.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},S.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},S.prototype.isqr=function(e){return this.imul(e,e.clone())},S.prototype.sqr=function(e){return this.mul(e,e)},S.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new f(1)).iushrn(2);return this.pow(e,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),c=a.redNeg(),d=this.m.subn(1).iushrn(1),s=this.m.bitLength();for(s=new f(2*s*s).toRed(this);0!==this.pow(s,d).cmp(c);)s.redIAdd(c);for(var u=this.pow(s,i),h=this.pow(e,i.addn(1).iushrn(1)),b=this.pow(e,i),l=o;0!==b.cmp(a);){for(var p=b,y=0;0!==p.cmp(a);y++)p=p.redSqr();n(y<l);var g=this.pow(u,new f(1).iushln(l-y-1));h=h.redMul(g),u=g.redSqr(),b=b.redMul(u),l=y}return h},S.prototype.invm=function(e){var t=e._invmp(this.m);return 0!==t.negative?(t.negative=0,this.imod(t).redNeg()):this.imod(t)},S.prototype.pow=function(e,t){if(t.isZero())return new f(1).toRed(this);if(0===t.cmpn(1))return e.clone();var r=new Array(16);r[0]=new f(1).toRed(this),r[1]=e;for(var n=2;n<r.length;n++)r[n]=this.mul(r[n-1],e);var i=r[0],o=0,a=0,c=t.bitLength()%26;for(0===c&&(c=26),n=t.length-1;n>=0;n--){for(var d=t.words[n],s=c-1;s>=0;s--){var u=d>>s&1;i!==r[0]&&(i=this.sqr(i)),0!==u||0!==o?(o<<=1,o|=u,(4===++a||0===n&&0===s)&&(i=this.mul(i,r[o]),a=0,o=0)):a=0}c=26}return i},S.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},S.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},f.mont=function(e){return new M(e)},i(M,S),M.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},M.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},M.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),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)},M.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new f(0)._forceRed(this);var r=e.mul(t),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)},M.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,this)}).call(this,r(95)(e))},function(e,t,r){var n=r(3),i=n.Buffer;function f(e,t){for(var r in e)t[r]=e[r]}function o(e,t,r){return i(e,t,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=n:(f(n,t),t.Buffer=o),o.prototype=Object.create(i.prototype),f(i,o),o.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,r)},o.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=i(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},function(e,t,r){"use strict";(function(e){ /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh <http://feross.org> * @license MIT */ var n=r(67),i=r(68),f=r(38);function o(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(o()<t)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=c.prototype:(null===e&&(e=new c(t)),e.length=t),e}function c(e,t,r){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return u(this,e)}return d(this,e,t,r)}function d(e,t,r,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");t=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n);c.TYPED_ARRAY_SUPPORT?(e=t).__proto__=c.prototype:e=h(e,t);return e}(e,t,r,n):"string"==typeof t?function(e,t,r){"string"==typeof r&&""!==r||(r="utf8");if(!c.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|l(t,r),i=(e=a(e,n)).write(t,r);i!==n&&(e=e.slice(0,i));return e}(e,t,r):function(e,t){if(c.isBuffer(t)){var r=0|b(t.length);return 0===(e=a(e,r)).length?e:(t.copy(e,0,0,r),e)}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(n=t.length)!=n?a(e,0):h(e,t);if("Buffer"===t.type&&f(t.data))return h(e,t.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function s(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function u(e,t){if(s(t),e=a(e,t<0?0:0|b(t)),!c.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function h(e,t){var r=t.length<0?0:0|b(t.length);e=a(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function b(e){if(e>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|e}function l(e,t){if(c.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return D(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(e).length;default:if(n)return D(e).length;t=(""+t).toLowerCase(),n=!0}}function p(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return R(this,t,r);case"utf8":case"utf-8":return E(this,t,r);case"ascii":return O(this,t,r);case"latin1":case"binary":return T(this,t,r);case"base64":return x(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function y(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function g(e,t,r,n,i){if(0===e.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:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=c.from(t,n)),c.isBuffer(t))return 0===t.length?-1:v(e,t,r,n,i);if("number"==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):v(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function v(e,t,r,n,i){var f,o=1,a=e.length,c=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;o=2,a/=2,c/=2,r/=2}function d(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(i){var s=-1;for(f=r;f<a;f++)if(d(e,f)===d(t,-1===s?0:f-s)){if(-1===s&&(s=f),f-s+1===c)return s*o}else-1!==s&&(f-=f-s),s=-1}else for(r+c>a&&(r=a-c),f=r;f>=0;f--){for(var u=!0,h=0;h<c;h++)if(d(e,f+h)!==d(t,h)){u=!1;break}if(u)return f}return-1}function m(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var f=t