@stricahq/bip32ed25519
Version:
Pure javascript implementation of Bip32Ed25519, used for Cardano blockchain key pair.
1 lines • 287 kB
JavaScript
var bip32ed25519;(()=>{var t={9742:(t,e)=>{"use strict";e.byteLength=function(t){var e=a(t),r=e[0],i=e[1];return 3*(r+i)/4-i},e.toByteArray=function(t){var e,r,o=a(t),s=o[0],f=o[1],h=new n(function(t,e,r){return 3*(e+r)/4-r}(0,s,f)),u=0,d=f>0?s-4:s;for(r=0;r<d;r+=4)e=i[t.charCodeAt(r)]<<18|i[t.charCodeAt(r+1)]<<12|i[t.charCodeAt(r+2)]<<6|i[t.charCodeAt(r+3)],h[u++]=e>>16&255,h[u++]=e>>8&255,h[u++]=255&e;2===f&&(e=i[t.charCodeAt(r)]<<2|i[t.charCodeAt(r+1)]>>4,h[u++]=255&e);1===f&&(e=i[t.charCodeAt(r)]<<10|i[t.charCodeAt(r+1)]<<4|i[t.charCodeAt(r+2)]>>2,h[u++]=e>>8&255,h[u++]=255&e);return h},e.fromByteArray=function(t){for(var e,i=t.length,n=i%3,o=[],s=16383,f=0,a=i-n;f<a;f+=s)o.push(h(t,f,f+s>a?a:f+s));1===n?(e=t[i-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===n&&(e=(t[i-2]<<8)+t[i-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"="));return o.join("")};for(var r=[],i=[],n="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,f=o.length;s<f;++s)r[s]=o[s],i[o.charCodeAt(s)]=s;function a(t){var e=t.length;if(e%4>0)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,i){for(var n,o,s=[],f=e;f<i;f+=3)n=(t[f]<<16&16711680)+(t[f+1]<<8&65280)+(255&t[f+2]),s.push(r[(o=n)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},8442:(t,e,r)=>{const i=r(9488);function n(t,e,r){const i=t[e]+t[r];let n=t[e+1]+t[r+1];i>=4294967296&&n++,t[e]=i,t[e+1]=n}function o(t,e,r,i){let n=t[e]+r;r<0&&(n+=4294967296);let o=t[e+1]+i;n>=4294967296&&o++,t[e]=n,t[e+1]=o}function s(t,e){return t[e]^t[e+1]<<8^t[e+2]<<16^t[e+3]<<24}function f(t,e,r,i,s,f){const a=d[s],h=d[s+1],c=d[f],l=d[f+1];n(u,t,e),o(u,t,a,h);let p=u[i]^u[t],b=u[i+1]^u[t+1];u[i]=b,u[i+1]=p,n(u,r,i),p=u[e]^u[r],b=u[e+1]^u[r+1],u[e]=p>>>24^b<<8,u[e+1]=b>>>24^p<<8,n(u,t,e),o(u,t,c,l),p=u[i]^u[t],b=u[i+1]^u[t+1],u[i]=p>>>16^b<<16,u[i+1]=b>>>16^p<<16,n(u,r,i),p=u[e]^u[r],b=u[e+1]^u[r+1],u[e]=b>>>31^p<<1,u[e+1]=p>>>31^b<<1}const a=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),h=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3].map((function(t){return 2*t}))),u=new Uint32Array(32),d=new Uint32Array(32);function c(t,e){let r=0;for(r=0;r<16;r++)u[r]=t.h[r],u[r+16]=a[r];for(u[24]=u[24]^t.t,u[25]=u[25]^t.t/4294967296,e&&(u[28]=~u[28],u[29]=~u[29]),r=0;r<32;r++)d[r]=s(t.b,4*r);for(r=0;r<12;r++)f(0,8,16,24,h[16*r+0],h[16*r+1]),f(2,10,18,26,h[16*r+2],h[16*r+3]),f(4,12,20,28,h[16*r+4],h[16*r+5]),f(6,14,22,30,h[16*r+6],h[16*r+7]),f(0,10,20,30,h[16*r+8],h[16*r+9]),f(2,12,22,24,h[16*r+10],h[16*r+11]),f(4,14,16,26,h[16*r+12],h[16*r+13]),f(6,8,18,28,h[16*r+14],h[16*r+15]);for(r=0;r<16;r++)t.h[r]=t.h[r]^u[r]^u[r+16]}function l(t,e){if(0===t||t>64)throw new Error("Illegal output length, expected 0 < length <= 64");if(e&&e.length>64)throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");const r={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:t};for(let t=0;t<16;t++)r.h[t]=a[t];const i=e?e.length:0;return r.h[0]^=16842752^i<<8^t,e&&(p(r,e),r.c=128),r}function p(t,e){for(let r=0;r<e.length;r++)128===t.c&&(t.t+=t.c,c(t,!1),t.c=0),t.b[t.c++]=e[r]}function b(t){for(t.t+=t.c;t.c<128;)t.b[t.c++]=0;c(t,!0);const e=new Uint8Array(t.outlen);for(let r=0;r<t.outlen;r++)e[r]=t.h[r>>2]>>8*(3&r);return e}function m(t,e,r){r=r||64,t=i.normalizeInput(t);const n=l(r,e);return p(n,t),b(n)}t.exports={blake2b:m,blake2bHex:function(t,e,r){const n=m(t,e,r);return i.toHex(n)},blake2bInit:l,blake2bUpdate:p,blake2bFinal:b}},5297:(t,e,r)=>{const i=r(9488);function n(t,e){return t[e]^t[e+1]<<8^t[e+2]<<16^t[e+3]<<24}function o(t,e,r,i,n,o){h[t]=h[t]+h[e]+n,h[i]=s(h[i]^h[t],16),h[r]=h[r]+h[i],h[e]=s(h[e]^h[r],12),h[t]=h[t]+h[e]+o,h[i]=s(h[i]^h[t],8),h[r]=h[r]+h[i],h[e]=s(h[e]^h[r],7)}function s(t,e){return t>>>e^t<<32-e}const f=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0]),h=new Uint32Array(16),u=new Uint32Array(16);function d(t,e){let r=0;for(r=0;r<8;r++)h[r]=t.h[r],h[r+8]=f[r];for(h[12]^=t.t,h[13]^=t.t/4294967296,e&&(h[14]=~h[14]),r=0;r<16;r++)u[r]=n(t.b,4*r);for(r=0;r<10;r++)o(0,4,8,12,u[a[16*r+0]],u[a[16*r+1]]),o(1,5,9,13,u[a[16*r+2]],u[a[16*r+3]]),o(2,6,10,14,u[a[16*r+4]],u[a[16*r+5]]),o(3,7,11,15,u[a[16*r+6]],u[a[16*r+7]]),o(0,5,10,15,u[a[16*r+8]],u[a[16*r+9]]),o(1,6,11,12,u[a[16*r+10]],u[a[16*r+11]]),o(2,7,8,13,u[a[16*r+12]],u[a[16*r+13]]),o(3,4,9,14,u[a[16*r+14]],u[a[16*r+15]]);for(r=0;r<8;r++)t.h[r]^=h[r]^h[r+8]}function c(t,e){if(!(t>0&&t<=32))throw new Error("Incorrect output length, should be in [1, 32]");const r=e?e.length:0;if(e&&!(r>0&&r<=32))throw new Error("Incorrect key length, should be in [1, 32]");const i={h:new Uint32Array(f),b:new Uint8Array(64),c:0,t:0,outlen:t};return i.h[0]^=16842752^r<<8^t,r>0&&(l(i,e),i.c=64),i}function l(t,e){for(let r=0;r<e.length;r++)64===t.c&&(t.t+=t.c,d(t,!1),t.c=0),t.b[t.c++]=e[r]}function p(t){for(t.t+=t.c;t.c<64;)t.b[t.c++]=0;d(t,!0);const e=new Uint8Array(t.outlen);for(let r=0;r<t.outlen;r++)e[r]=t.h[r>>2]>>8*(3&r)&255;return e}function b(t,e,r){r=r||32,t=i.normalizeInput(t);const n=c(r,e);return l(n,t),p(n)}t.exports={blake2s:b,blake2sHex:function(t,e,r){const n=b(t,e,r);return i.toHex(n)},blake2sInit:c,blake2sUpdate:l,blake2sFinal:p}},1191:(t,e,r)=>{const i=r(8442),n=r(5297);t.exports={blake2b:i.blake2b,blake2bHex:i.blake2bHex,blake2bInit:i.blake2bInit,blake2bUpdate:i.blake2bUpdate,blake2bFinal:i.blake2bFinal,blake2s:n.blake2s,blake2sHex:n.blake2sHex,blake2sInit:n.blake2sInit,blake2sUpdate:n.blake2sUpdate,blake2sFinal:n.blake2sFinal}},9488:t=>{function e(t){return(4294967296+t).toString(16).substring(1)}t.exports={normalizeInput:function(t){let e;if(t instanceof Uint8Array)e=t;else if(t instanceof Buffer)e=new Uint8Array(t);else{if("string"!=typeof t)throw new Error("Input must be an string, Buffer or Uint8Array");e=new Uint8Array(Buffer.from(t,"utf8"))}return e},toHex:function(t){return Array.prototype.map.call(t,(function(t){return(t<16?"0":"")+t.toString(16)})).join("")},debugPrint:function(t,r,i){let n="\n"+t+" = ";for(let o=0;o<r.length;o+=2){if(32===i)n+=e(r[o]).toUpperCase(),n+=" ",n+=e(r[o+1]).toUpperCase();else{if(64!==i)throw new Error("Invalid size "+i);n+=e(r[o+1]).toUpperCase(),n+=e(r[o]).toUpperCase()}o%6==4?n+="\n"+new Array(t.length+4).join(" "):o<r.length-2&&(n+=" ")}console.log(n)},testSpeed:function(t,e,r){let i=(new Date).getTime();const n=new Uint8Array(e);for(let t=0;t<e;t++)n[t]=t%256;const o=(new Date).getTime();console.log("Generated random input in "+(o-i)+"ms"),i=o;for(let o=0;o<r;o++){const r=t(n),o=(new Date).getTime(),s=o-i;i=o,console.log("Hashed in "+s+"ms: "+r.substring(0,20)+"..."),console.log(Math.round(e/(1<<20)/(s/1e3)*100)/100+" MB PER SECOND")}}}},3550:function(t,e,r){!function(t,e){"use strict";function i(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function o(t,e,r){if(o.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var s;"object"==typeof t?t.exports=o:e.BN=o,o.BN=o,o.wordSize=26;try{s="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:r(6601).Buffer}catch(t){}function f(t,e){var r=t.charCodeAt(e);return r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void i(!1,"Invalid character in "+t)}function a(t,e,r){var i=f(t,r);return r-1>=e&&(i|=f(t,r-1)<<4),i}function h(t,e,r,n){for(var o=0,s=0,f=Math.min(t.length,r),a=e;a<f;a++){var h=t.charCodeAt(a)-48;o*=n,s=h>=49?h-49+10:h>=17?h-17+10:h,i(h>=0&&s<n,"Invalid character"),o+=s}return o}function u(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(o.isBN=function(t){return t instanceof o||null!==t&&"object"==typeof t&&t.constructor.wordSize===o.wordSize&&Array.isArray(t.words)},o.max=function(t,e){return t.cmp(e)>0?t:e},o.min=function(t,e){return t.cmp(e)<0?t:e},o.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),i(e===(0|e)&&e>=2&&e<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<t.length&&(16===e?this._parseHex(t,n,r):(this._parseBase(t,e,n),"le"===r&&this._initArray(this.toArray(),e,r)))},o.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(i(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},o.prototype._initArray=function(t,e,r){if(i("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var o,s,f=0;if("be"===r)for(n=t.length-1,o=0;n>=0;n-=3)s=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[o]|=s<<f&67108863,this.words[o+1]=s>>>26-f&67108863,(f+=24)>=26&&(f-=26,o++);else if("le"===r)for(n=0,o=0;n<t.length;n+=3)s=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[o]|=s<<f&67108863,this.words[o+1]=s>>>26-f&67108863,(f+=24)>=26&&(f-=26,o++);return this._strip()},o.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,o=0,s=0;if("be"===r)for(i=t.length-1;i>=e;i-=2)n=a(t,e,i)<<o,this.words[s]|=67108863&n,o>=18?(o-=18,s+=1,this.words[s]|=n>>>26):o+=8;else for(i=(t.length-e)%2==0?e+1:e;i<t.length;i+=2)n=a(t,e,i)<<o,this.words[s]|=67108863&n,o>=18?(o-=18,s+=1,this.words[s]|=n>>>26):o+=8;this._strip()},o.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var o=t.length-r,s=o%i,f=Math.min(o,o-s)+r,a=0,u=r;u<f;u+=i)a=h(t,u,u+i,e),this.imuln(n),this.words[0]+a<67108864?this.words[0]+=a:this._iaddn(a);if(0!==s){var d=1;for(a=h(t,u,t.length,e),u=0;u<s;u++)d*=e;this.imuln(d),this.words[0]+a<67108864?this.words[0]+=a:this._iaddn(a)}this._strip()},o.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},o.prototype._move=function(t){u(t,this)},o.prototype.clone=function(){var t=new o(null);return this.copy(t),t},o.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},o.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=d}catch(t){o.prototype.inspect=d}else o.prototype.inspect=d;function d(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],l=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],p=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];o.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var n=0,o=0,s=0;s<this.length;s++){var f=this.words[s],a=(16777215&(f<<n|o)).toString(16);r=0!==(o=f>>>24-n&16777215)||s!==this.length-1?c[6-a.length]+a+r:a+r,(n+=2)>=26&&(n-=26,s--)}for(0!==o&&(r=o.toString(16)+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var h=l[t],u=p[t];r="";var d=this.clone();for(d.negative=0;!d.isZero();){var b=d.modrn(u).toString(t);r=(d=d.idivn(u)).isZero()?b+r:c[h-b.length]+b+r}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}i(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},o.prototype.toJSON=function(){return this.toString(16,2)},s&&(o.prototype.toBuffer=function(t,e){return this.toArrayLike(s,t,e)}),o.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function b(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],o=0|e.words[0],s=n*o,f=67108863&s,a=s/67108864|0;r.words[0]=f;for(var h=1;h<i;h++){for(var u=a>>>26,d=67108863&a,c=Math.min(h,e.length-1),l=Math.max(0,h-t.length+1);l<=c;l++){var p=h-l|0;u+=(s=(n=0|t.words[p])*(o=0|e.words[l])+d)/67108864|0,d=67108863&s}r.words[h]=0|d,a=0|u}return 0!==a?r.words[h]=0|a:r.length--,r._strip()}o.prototype.toArrayLike=function(t,e,r){this._strip();var n=this.byteLength(),o=r||Math.max(1,n);i(n<=o,"byte array longer than desired length"),i(o>0,"Requested array length <= 0");var s=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](s,n),s},o.prototype._toArrayLikeLE=function(t,e){for(var r=0,i=0,n=0,o=0;n<this.length;n++){var s=this.words[n]<<o|i;t[r++]=255&s,r<t.length&&(t[r++]=s>>8&255),r<t.length&&(t[r++]=s>>16&255),6===o?(r<t.length&&(t[r++]=s>>24&255),i=0,o=0):(i=s>>>24,o+=2)}if(r<t.length)for(t[r++]=i;r<t.length;)t[r++]=0},o.prototype._toArrayLikeBE=function(t,e){for(var r=t.length-1,i=0,n=0,o=0;n<this.length;n++){var s=this.words[n]<<o|i;t[r--]=255&s,r>=0&&(t[r--]=s>>8&255),r>=0&&(t[r--]=s>>16&255),6===o?(r>=0&&(t[r--]=s>>24&255),i=0,o=0):(i=s>>>24,o+=2)}if(r>=0)for(t[r--]=i;r>=0;)t[r--]=0},Math.clz32?o.prototype._countBits=function(t){return 32-Math.clz32(t)}:o.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},o.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},o.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},o.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return 0!==this.negative},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},o.prototype.ior=function(t){return i(0==(this.negative|t.negative)),this.iuor(t)},o.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},o.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},o.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this._strip()},o.prototype.iand=function(t){return i(0==(this.negative|t.negative)),this.iuand(t)},o.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},o.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},o.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this._strip()},o.prototype.ixor=function(t){return i(0==(this.negative|t.negative)),this.iuxor(t)},o.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},o.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},o.prototype.inotn=function(t){i("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var n=0;n<e;n++)this.words[n]=67108863&~this.words[n];return r>0&&(this.words[n]=~this.words[n]&67108863>>26-r),this._strip()},o.prototype.notn=function(t){return this.clone().inotn(t)},o.prototype.setn=function(t,e){i("number"==typeof t&&t>=0);var r=t/26|0,n=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<<n:this.words[r]&~(1<<n),this._strip()},o.prototype.iadd=function(t){var e,r,i;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,i=t):(r=t,i=this);for(var n=0,o=0;o<i.length;o++)e=(0|r.words[o])+(0|i.words[o])+n,this.words[o]=67108863&e,n=e>>>26;for(;0!==n&&o<r.length;o++)e=(0|r.words[o])+n,this.words[o]=67108863&e,n=e>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},o.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},o.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var o=0,s=0;s<i.length;s++)o=(e=(0|r.words[s])-(0|i.words[s])+o)>>26,this.words[s]=67108863&e;for(;0!==o&&s<r.length;s++)o=(e=(0|r.words[s])+o)>>26,this.words[s]=67108863&e;if(0===o&&s<r.length&&r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this.length=Math.max(this.length,s),r!==this&&(this.negative=1),this._strip()},o.prototype.sub=function(t){return this.clone().isub(t)};var m=function(t,e,r){var i,n,o,s=t.words,f=e.words,a=r.words,h=0,u=0|s[0],d=8191&u,c=u>>>13,l=0|s[1],p=8191&l,b=l>>>13,m=0|s[2],g=8191&m,y=m>>>13,v=0|s[3],w=8191&v,M=v>>>13,_=0|s[4],S=8191&_,A=_>>>13,E=0|s[5],x=8191&E,I=E>>>13,R=0|s[6],k=8191&R,B=R>>>13,L=0|s[7],P=8191&L,O=L>>>13,T=0|s[8],N=8191&T,q=T>>>13,z=0|s[9],U=8191&z,j=z>>>13,C=0|f[0],D=8191&C,F=C>>>13,H=0|f[1],K=8191&H,W=H>>>13,Z=0|f[2],V=8191&Z,$=Z>>>13,Y=0|f[3],J=8191&Y,X=Y>>>13,G=0|f[4],Q=8191&G,tt=G>>>13,et=0|f[5],rt=8191&et,it=et>>>13,nt=0|f[6],ot=8191&nt,st=nt>>>13,ft=0|f[7],at=8191&ft,ht=ft>>>13,ut=0|f[8],dt=8191&ut,ct=ut>>>13,lt=0|f[9],pt=8191<,bt=lt>>>13;r.negative=t.negative^e.negative,r.length=19;var mt=(h+(i=Math.imul(d,D))|0)+((8191&(n=(n=Math.imul(d,F))+Math.imul(c,D)|0))<<13)|0;h=((o=Math.imul(c,F))+(n>>>13)|0)+(mt>>>26)|0,mt&=67108863,i=Math.imul(p,D),n=(n=Math.imul(p,F))+Math.imul(b,D)|0,o=Math.imul(b,F);var gt=(h+(i=i+Math.imul(d,K)|0)|0)+((8191&(n=(n=n+Math.imul(d,W)|0)+Math.imul(c,K)|0))<<13)|0;h=((o=o+Math.imul(c,W)|0)+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(g,D),n=(n=Math.imul(g,F))+Math.imul(y,D)|0,o=Math.imul(y,F),i=i+Math.imul(p,K)|0,n=(n=n+Math.imul(p,W)|0)+Math.imul(b,K)|0,o=o+Math.imul(b,W)|0;var yt=(h+(i=i+Math.imul(d,V)|0)|0)+((8191&(n=(n=n+Math.imul(d,$)|0)+Math.imul(c,V)|0))<<13)|0;h=((o=o+Math.imul(c,$)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(w,D),n=(n=Math.imul(w,F))+Math.imul(M,D)|0,o=Math.imul(M,F),i=i+Math.imul(g,K)|0,n=(n=n+Math.imul(g,W)|0)+Math.imul(y,K)|0,o=o+Math.imul(y,W)|0,i=i+Math.imul(p,V)|0,n=(n=n+Math.imul(p,$)|0)+Math.imul(b,V)|0,o=o+Math.imul(b,$)|0;var vt=(h+(i=i+Math.imul(d,J)|0)|0)+((8191&(n=(n=n+Math.imul(d,X)|0)+Math.imul(c,J)|0))<<13)|0;h=((o=o+Math.imul(c,X)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(S,D),n=(n=Math.imul(S,F))+Math.imul(A,D)|0,o=Math.imul(A,F),i=i+Math.imul(w,K)|0,n=(n=n+Math.imul(w,W)|0)+Math.imul(M,K)|0,o=o+Math.imul(M,W)|0,i=i+Math.imul(g,V)|0,n=(n=n+Math.imul(g,$)|0)+Math.imul(y,V)|0,o=o+Math.imul(y,$)|0,i=i+Math.imul(p,J)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(b,J)|0,o=o+Math.imul(b,X)|0;var wt=(h+(i=i+Math.imul(d,Q)|0)|0)+((8191&(n=(n=n+Math.imul(d,tt)|0)+Math.imul(c,Q)|0))<<13)|0;h=((o=o+Math.imul(c,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(x,D),n=(n=Math.imul(x,F))+Math.imul(I,D)|0,o=Math.imul(I,F),i=i+Math.imul(S,K)|0,n=(n=n+Math.imul(S,W)|0)+Math.imul(A,K)|0,o=o+Math.imul(A,W)|0,i=i+Math.imul(w,V)|0,n=(n=n+Math.imul(w,$)|0)+Math.imul(M,V)|0,o=o+Math.imul(M,$)|0,i=i+Math.imul(g,J)|0,n=(n=n+Math.imul(g,X)|0)+Math.imul(y,J)|0,o=o+Math.imul(y,X)|0,i=i+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,tt)|0;var Mt=(h+(i=i+Math.imul(d,rt)|0)|0)+((8191&(n=(n=n+Math.imul(d,it)|0)+Math.imul(c,rt)|0))<<13)|0;h=((o=o+Math.imul(c,it)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(k,D),n=(n=Math.imul(k,F))+Math.imul(B,D)|0,o=Math.imul(B,F),i=i+Math.imul(x,K)|0,n=(n=n+Math.imul(x,W)|0)+Math.imul(I,K)|0,o=o+Math.imul(I,W)|0,i=i+Math.imul(S,V)|0,n=(n=n+Math.imul(S,$)|0)+Math.imul(A,V)|0,o=o+Math.imul(A,$)|0,i=i+Math.imul(w,J)|0,n=(n=n+Math.imul(w,X)|0)+Math.imul(M,J)|0,o=o+Math.imul(M,X)|0,i=i+Math.imul(g,Q)|0,n=(n=n+Math.imul(g,tt)|0)+Math.imul(y,Q)|0,o=o+Math.imul(y,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(b,rt)|0,o=o+Math.imul(b,it)|0;var _t=(h+(i=i+Math.imul(d,ot)|0)|0)+((8191&(n=(n=n+Math.imul(d,st)|0)+Math.imul(c,ot)|0))<<13)|0;h=((o=o+Math.imul(c,st)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(P,D),n=(n=Math.imul(P,F))+Math.imul(O,D)|0,o=Math.imul(O,F),i=i+Math.imul(k,K)|0,n=(n=n+Math.imul(k,W)|0)+Math.imul(B,K)|0,o=o+Math.imul(B,W)|0,i=i+Math.imul(x,V)|0,n=(n=n+Math.imul(x,$)|0)+Math.imul(I,V)|0,o=o+Math.imul(I,$)|0,i=i+Math.imul(S,J)|0,n=(n=n+Math.imul(S,X)|0)+Math.imul(A,J)|0,o=o+Math.imul(A,X)|0,i=i+Math.imul(w,Q)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,tt)|0,i=i+Math.imul(g,rt)|0,n=(n=n+Math.imul(g,it)|0)+Math.imul(y,rt)|0,o=o+Math.imul(y,it)|0,i=i+Math.imul(p,ot)|0,n=(n=n+Math.imul(p,st)|0)+Math.imul(b,ot)|0,o=o+Math.imul(b,st)|0;var St=(h+(i=i+Math.imul(d,at)|0)|0)+((8191&(n=(n=n+Math.imul(d,ht)|0)+Math.imul(c,at)|0))<<13)|0;h=((o=o+Math.imul(c,ht)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(N,D),n=(n=Math.imul(N,F))+Math.imul(q,D)|0,o=Math.imul(q,F),i=i+Math.imul(P,K)|0,n=(n=n+Math.imul(P,W)|0)+Math.imul(O,K)|0,o=o+Math.imul(O,W)|0,i=i+Math.imul(k,V)|0,n=(n=n+Math.imul(k,$)|0)+Math.imul(B,V)|0,o=o+Math.imul(B,$)|0,i=i+Math.imul(x,J)|0,n=(n=n+Math.imul(x,X)|0)+Math.imul(I,J)|0,o=o+Math.imul(I,X)|0,i=i+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(A,Q)|0,o=o+Math.imul(A,tt)|0,i=i+Math.imul(w,rt)|0,n=(n=n+Math.imul(w,it)|0)+Math.imul(M,rt)|0,o=o+Math.imul(M,it)|0,i=i+Math.imul(g,ot)|0,n=(n=n+Math.imul(g,st)|0)+Math.imul(y,ot)|0,o=o+Math.imul(y,st)|0,i=i+Math.imul(p,at)|0,n=(n=n+Math.imul(p,ht)|0)+Math.imul(b,at)|0,o=o+Math.imul(b,ht)|0;var At=(h+(i=i+Math.imul(d,dt)|0)|0)+((8191&(n=(n=n+Math.imul(d,ct)|0)+Math.imul(c,dt)|0))<<13)|0;h=((o=o+Math.imul(c,ct)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(U,D),n=(n=Math.imul(U,F))+Math.imul(j,D)|0,o=Math.imul(j,F),i=i+Math.imul(N,K)|0,n=(n=n+Math.imul(N,W)|0)+Math.imul(q,K)|0,o=o+Math.imul(q,W)|0,i=i+Math.imul(P,V)|0,n=(n=n+Math.imul(P,$)|0)+Math.imul(O,V)|0,o=o+Math.imul(O,$)|0,i=i+Math.imul(k,J)|0,n=(n=n+Math.imul(k,X)|0)+Math.imul(B,J)|0,o=o+Math.imul(B,X)|0,i=i+Math.imul(x,Q)|0,n=(n=n+Math.imul(x,tt)|0)+Math.imul(I,Q)|0,o=o+Math.imul(I,tt)|0,i=i+Math.imul(S,rt)|0,n=(n=n+Math.imul(S,it)|0)+Math.imul(A,rt)|0,o=o+Math.imul(A,it)|0,i=i+Math.imul(w,ot)|0,n=(n=n+Math.imul(w,st)|0)+Math.imul(M,ot)|0,o=o+Math.imul(M,st)|0,i=i+Math.imul(g,at)|0,n=(n=n+Math.imul(g,ht)|0)+Math.imul(y,at)|0,o=o+Math.imul(y,ht)|0,i=i+Math.imul(p,dt)|0,n=(n=n+Math.imul(p,ct)|0)+Math.imul(b,dt)|0,o=o+Math.imul(b,ct)|0;var Et=(h+(i=i+Math.imul(d,pt)|0)|0)+((8191&(n=(n=n+Math.imul(d,bt)|0)+Math.imul(c,pt)|0))<<13)|0;h=((o=o+Math.imul(c,bt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(U,K),n=(n=Math.imul(U,W))+Math.imul(j,K)|0,o=Math.imul(j,W),i=i+Math.imul(N,V)|0,n=(n=n+Math.imul(N,$)|0)+Math.imul(q,V)|0,o=o+Math.imul(q,$)|0,i=i+Math.imul(P,J)|0,n=(n=n+Math.imul(P,X)|0)+Math.imul(O,J)|0,o=o+Math.imul(O,X)|0,i=i+Math.imul(k,Q)|0,n=(n=n+Math.imul(k,tt)|0)+Math.imul(B,Q)|0,o=o+Math.imul(B,tt)|0,i=i+Math.imul(x,rt)|0,n=(n=n+Math.imul(x,it)|0)+Math.imul(I,rt)|0,o=o+Math.imul(I,it)|0,i=i+Math.imul(S,ot)|0,n=(n=n+Math.imul(S,st)|0)+Math.imul(A,ot)|0,o=o+Math.imul(A,st)|0,i=i+Math.imul(w,at)|0,n=(n=n+Math.imul(w,ht)|0)+Math.imul(M,at)|0,o=o+Math.imul(M,ht)|0,i=i+Math.imul(g,dt)|0,n=(n=n+Math.imul(g,ct)|0)+Math.imul(y,dt)|0,o=o+Math.imul(y,ct)|0;var xt=(h+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,bt)|0)+Math.imul(b,pt)|0))<<13)|0;h=((o=o+Math.imul(b,bt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(U,V),n=(n=Math.imul(U,$))+Math.imul(j,V)|0,o=Math.imul(j,$),i=i+Math.imul(N,J)|0,n=(n=n+Math.imul(N,X)|0)+Math.imul(q,J)|0,o=o+Math.imul(q,X)|0,i=i+Math.imul(P,Q)|0,n=(n=n+Math.imul(P,tt)|0)+Math.imul(O,Q)|0,o=o+Math.imul(O,tt)|0,i=i+Math.imul(k,rt)|0,n=(n=n+Math.imul(k,it)|0)+Math.imul(B,rt)|0,o=o+Math.imul(B,it)|0,i=i+Math.imul(x,ot)|0,n=(n=n+Math.imul(x,st)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,st)|0,i=i+Math.imul(S,at)|0,n=(n=n+Math.imul(S,ht)|0)+Math.imul(A,at)|0,o=o+Math.imul(A,ht)|0,i=i+Math.imul(w,dt)|0,n=(n=n+Math.imul(w,ct)|0)+Math.imul(M,dt)|0,o=o+Math.imul(M,ct)|0;var It=(h+(i=i+Math.imul(g,pt)|0)|0)+((8191&(n=(n=n+Math.imul(g,bt)|0)+Math.imul(y,pt)|0))<<13)|0;h=((o=o+Math.imul(y,bt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(U,J),n=(n=Math.imul(U,X))+Math.imul(j,J)|0,o=Math.imul(j,X),i=i+Math.imul(N,Q)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(q,Q)|0,o=o+Math.imul(q,tt)|0,i=i+Math.imul(P,rt)|0,n=(n=n+Math.imul(P,it)|0)+Math.imul(O,rt)|0,o=o+Math.imul(O,it)|0,i=i+Math.imul(k,ot)|0,n=(n=n+Math.imul(k,st)|0)+Math.imul(B,ot)|0,o=o+Math.imul(B,st)|0,i=i+Math.imul(x,at)|0,n=(n=n+Math.imul(x,ht)|0)+Math.imul(I,at)|0,o=o+Math.imul(I,ht)|0,i=i+Math.imul(S,dt)|0,n=(n=n+Math.imul(S,ct)|0)+Math.imul(A,dt)|0,o=o+Math.imul(A,ct)|0;var Rt=(h+(i=i+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,bt)|0)+Math.imul(M,pt)|0))<<13)|0;h=((o=o+Math.imul(M,bt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,i=Math.imul(U,Q),n=(n=Math.imul(U,tt))+Math.imul(j,Q)|0,o=Math.imul(j,tt),i=i+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(q,rt)|0,o=o+Math.imul(q,it)|0,i=i+Math.imul(P,ot)|0,n=(n=n+Math.imul(P,st)|0)+Math.imul(O,ot)|0,o=o+Math.imul(O,st)|0,i=i+Math.imul(k,at)|0,n=(n=n+Math.imul(k,ht)|0)+Math.imul(B,at)|0,o=o+Math.imul(B,ht)|0,i=i+Math.imul(x,dt)|0,n=(n=n+Math.imul(x,ct)|0)+Math.imul(I,dt)|0,o=o+Math.imul(I,ct)|0;var kt=(h+(i=i+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,bt)|0)+Math.imul(A,pt)|0))<<13)|0;h=((o=o+Math.imul(A,bt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(U,rt),n=(n=Math.imul(U,it))+Math.imul(j,rt)|0,o=Math.imul(j,it),i=i+Math.imul(N,ot)|0,n=(n=n+Math.imul(N,st)|0)+Math.imul(q,ot)|0,o=o+Math.imul(q,st)|0,i=i+Math.imul(P,at)|0,n=(n=n+Math.imul(P,ht)|0)+Math.imul(O,at)|0,o=o+Math.imul(O,ht)|0,i=i+Math.imul(k,dt)|0,n=(n=n+Math.imul(k,ct)|0)+Math.imul(B,dt)|0,o=o+Math.imul(B,ct)|0;var Bt=(h+(i=i+Math.imul(x,pt)|0)|0)+((8191&(n=(n=n+Math.imul(x,bt)|0)+Math.imul(I,pt)|0))<<13)|0;h=((o=o+Math.imul(I,bt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,i=Math.imul(U,ot),n=(n=Math.imul(U,st))+Math.imul(j,ot)|0,o=Math.imul(j,st),i=i+Math.imul(N,at)|0,n=(n=n+Math.imul(N,ht)|0)+Math.imul(q,at)|0,o=o+Math.imul(q,ht)|0,i=i+Math.imul(P,dt)|0,n=(n=n+Math.imul(P,ct)|0)+Math.imul(O,dt)|0,o=o+Math.imul(O,ct)|0;var Lt=(h+(i=i+Math.imul(k,pt)|0)|0)+((8191&(n=(n=n+Math.imul(k,bt)|0)+Math.imul(B,pt)|0))<<13)|0;h=((o=o+Math.imul(B,bt)|0)+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,i=Math.imul(U,at),n=(n=Math.imul(U,ht))+Math.imul(j,at)|0,o=Math.imul(j,ht),i=i+Math.imul(N,dt)|0,n=(n=n+Math.imul(N,ct)|0)+Math.imul(q,dt)|0,o=o+Math.imul(q,ct)|0;var Pt=(h+(i=i+Math.imul(P,pt)|0)|0)+((8191&(n=(n=n+Math.imul(P,bt)|0)+Math.imul(O,pt)|0))<<13)|0;h=((o=o+Math.imul(O,bt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,i=Math.imul(U,dt),n=(n=Math.imul(U,ct))+Math.imul(j,dt)|0,o=Math.imul(j,ct);var Ot=(h+(i=i+Math.imul(N,pt)|0)|0)+((8191&(n=(n=n+Math.imul(N,bt)|0)+Math.imul(q,pt)|0))<<13)|0;h=((o=o+Math.imul(q,bt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863;var Tt=(h+(i=Math.imul(U,pt))|0)+((8191&(n=(n=Math.imul(U,bt))+Math.imul(j,pt)|0))<<13)|0;return h=((o=Math.imul(j,bt))+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,a[0]=mt,a[1]=gt,a[2]=yt,a[3]=vt,a[4]=wt,a[5]=Mt,a[6]=_t,a[7]=St,a[8]=At,a[9]=Et,a[10]=xt,a[11]=It,a[12]=Rt,a[13]=kt,a[14]=Bt,a[15]=Lt,a[16]=Pt,a[17]=Ot,a[18]=Tt,0!==h&&(a[19]=h,r.length++),r};function g(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,o=0;o<r.length-1;o++){var s=n;n=0;for(var f=67108863&i,a=Math.min(o,e.length-1),h=Math.max(0,o-t.length+1);h<=a;h++){var u=o-h,d=(0|t.words[u])*(0|e.words[h]),c=67108863&d;f=67108863&(c=c+f|0),n+=(s=(s=s+(d/67108864|0)|0)+(c>>>26)|0)>>>26,s&=67108863}r.words[o]=f,i=s,s=n}return 0!==i?r.words[o]=i:r.length--,r._strip()}function y(t,e,r){return g(t,e,r)}function v(t,e){this.x=t,this.y=e}Math.imul||(m=b),o.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?m(this,t,e):r<63?b(this,t,e):r<1024?g(this,t,e):y(this,t,e)},v.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,i=0;i<t;i++)e[i]=this.revBin(i,r,t);return e},v.prototype.revBin=function(t,e,r){if(0===t||t===r-1)return t;for(var i=0,n=0;n<e;n++)i|=(1&t)<<e-n-1,t>>=1;return i},v.prototype.permute=function(t,e,r,i,n,o){for(var s=0;s<o;s++)i[s]=e[t[s]],n[s]=r[t[s]]},v.prototype.transform=function(t,e,r,i,n,o){this.permute(o,t,e,r,i,n);for(var s=1;s<n;s<<=1)for(var f=s<<1,a=Math.cos(2*Math.PI/f),h=Math.sin(2*Math.PI/f),u=0;u<n;u+=f)for(var d=a,c=h,l=0;l<s;l++){var p=r[u+l],b=i[u+l],m=r[u+l+s],g=i[u+l+s],y=d*m-c*g;g=d*g+c*m,m=y,r[u+l]=p+m,i[u+l]=b+g,r[u+l+s]=p-m,i[u+l+s]=b-g,l!==f&&(y=a*d-h*c,c=a*c+h*d,d=y)}},v.prototype.guessLen13b=function(t,e){var r=1|Math.max(e,t),i=1&r,n=0;for(r=r/2|0;r;r>>>=1)n++;return 1<<n+1+i},v.prototype.conjugate=function(t,e,r){if(!(r<=1))for(var i=0;i<r/2;i++){var n=t[i];t[i]=t[r-i-1],t[r-i-1]=n,n=e[i],e[i]=-e[r-i-1],e[r-i-1]=-n}},v.prototype.normalize13b=function(t,e){for(var r=0,i=0;i<e/2;i++){var n=8192*Math.round(t[2*i+1]/e)+Math.round(t[2*i]/e)+r;t[i]=67108863&n,r=n<67108864?0:n/67108864|0}return t},v.prototype.convert13b=function(t,e,r,n){for(var o=0,s=0;s<e;s++)o+=0|t[s],r[2*s]=8191&o,o>>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*e;s<n;++s)r[s]=0;i(0===o),i(0==(-8192&o))},v.prototype.stub=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=0;return e},v.prototype.mulp=function(t,e,r){var i=2*this.guessLen13b(t.length,e.length),n=this.makeRBT(i),o=this.stub(i),s=new Array(i),f=new Array(i),a=new Array(i),h=new Array(i),u=new Array(i),d=new Array(i),c=r.words;c.length=i,this.convert13b(t.words,t.length,s,i),this.convert13b(e.words,e.length,h,i),this.transform(s,o,f,a,i,n),this.transform(h,o,u,d,i,n);for(var l=0;l<i;l++){var p=f[l]*u[l]-a[l]*d[l];a[l]=f[l]*d[l]+a[l]*u[l],f[l]=p}return this.conjugate(f,a,i),this.transform(f,a,c,o,i,n),this.conjugate(c,o,i),this.normalize13b(c,i),r.negative=t.negative^e.negative,r.length=t.length+e.length,r._strip()},o.prototype.mul=function(t){var e=new o(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},o.prototype.mulf=function(t){var e=new o(null);return e.words=new Array(this.length+t.length),y(this,t,e)},o.prototype.imul=function(t){return this.clone().mulTo(t,this)},o.prototype.imuln=function(t){var e=t<0;e&&(t=-t),i("number"==typeof t),i(t<67108864);for(var r=0,n=0;n<this.length;n++){var o=(0|this.words[n])*t,s=(67108863&o)+(67108863&r);r>>=26,r+=o/67108864|0,r+=s>>>26,this.words[n]=67108863&s}return 0!==r&&(this.words[n]=r,this.length++),e?this.ineg():this},o.prototype.muln=function(t){return this.clone().imuln(t)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,n=r%26;e[r]=t.words[i]>>>n&1}return e}(t);if(0===e.length)return new o(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var n=r.sqr();i<e.length;i++,n=n.sqr())0!==e[i]&&(r=r.mul(n));return r},o.prototype.iushln=function(t){i("number"==typeof t&&t>=0);var e,r=t%26,n=(t-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var s=0;for(e=0;e<this.length;e++){var f=this.words[e]&o,a=(0|this.words[e])-f<<r;this.words[e]=a|s,s=f>>>26-r}s&&(this.words[e]=s,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e<n;e++)this.words[e]=0;this.length+=n}return this._strip()},o.prototype.ishln=function(t){return i(0===this.negative),this.iushln(t)},o.prototype.iushrn=function(t,e,r){var n;i("number"==typeof t&&t>=0),n=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),f=67108863^67108863>>>o<<o,a=r;if(n-=s,n=Math.max(0,n),a){for(var h=0;h<s;h++)a.words[h]=this.words[h];a.length=s}if(0===s);else if(this.length>s)for(this.length-=s,h=0;h<this.length;h++)this.words[h]=this.words[h+s];else this.words[0]=0,this.length=1;var u=0;for(h=this.length-1;h>=0&&(0!==u||h>=n);h--){var d=0|this.words[h];this.words[h]=u<<26-o|d>>>o,u=d&f}return a&&0!==u&&(a.words[a.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},o.prototype.ishrn=function(t,e,r){return i(0===this.negative),this.iushrn(t,e,r)},o.prototype.shln=function(t){return this.clone().ishln(t)},o.prototype.ushln=function(t){return this.clone().iushln(t)},o.prototype.shrn=function(t){return this.clone().ishrn(t)},o.prototype.ushrn=function(t){return this.clone().iushrn(t)},o.prototype.testn=function(t){i("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,n=1<<e;return!(this.length<=r)&&!!(this.words[r]&n)},o.prototype.imaskn=function(t){i("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26;if(i(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var n=67108863^67108863>>>e<<e;this.words[this.length-1]&=n}return this._strip()},o.prototype.maskn=function(t){return this.clone().imaskn(t)},o.prototype.iaddn=function(t){return i("number"==typeof t),i(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},o.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},o.prototype.isubn=function(t){if(i("number"==typeof t),i(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},o.prototype.addn=function(t){return this.clone().iaddn(t)},o.prototype.subn=function(t){return this.clone().isubn(t)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(t,e,r){var n,o,s=t.length+r;this._expand(s);var f=0;for(n=0;n<t.length;n++){o=(0|this.words[n+r])+f;var a=(0|t.words[n])*e;f=((o-=67108863&a)>>26)-(a/67108864|0),this.words[n+r]=67108863&o}for(;n<this.length-r;n++)f=(o=(0|this.words[n+r])+f)>>26,this.words[n+r]=67108863&o;if(0===f)return this._strip();for(i(-1===f),f=0,n=0;n<this.length;n++)f=(o=-(0|this.words[n])+f)>>26,this.words[n]=67108863&o;return this.negative=1,this._strip()},o.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),n=t,s=0|n.words[n.length-1];0!==(r=26-this._countBits(s))&&(n=n.ushln(r),i.iushln(r),s=0|n.words[n.length-1]);var f,a=i.length-n.length;if("mod"!==e){(f=new o(null)).length=a+1,f.words=new Array(f.length);for(var h=0;h<f.length;h++)f.words[h]=0}var u=i.clone()._ishlnsubmul(n,1,a);0===u.negative&&(i=u,f&&(f.words[a]=1));for(var d=a-1;d>=0;d--){var c=67108864*(0|i.words[n.length+d])+(0|i.words[n.length+d-1]);for(c=Math.min(c/s|0,67108863),i._ishlnsubmul(n,c,d);0!==i.negative;)c--,i.negative=0,i._ishlnsubmul(n,1,d),i.isZero()||(i.negative^=1);f&&(f.words[d]=c)}return f&&f._strip(),i._strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:f||null,mod:i}},o.prototype.divmod=function(t,e,r){return i(!t.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===t.negative?(f=this.neg().divmod(t,e),"mod"!==e&&(n=f.div.neg()),"div"!==e&&(s=f.mod.neg(),r&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(f=this.divmod(t.neg(),e),"mod"!==e&&(n=f.div.neg()),{div:n,mod:f.mod}):0!=(this.negative&t.negative)?(f=this.neg().divmod(t.neg(),e),"div"!==e&&(s=f.mod.neg(),r&&0!==s.negative&&s.isub(t)),{div:f.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new o(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new o(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new o(this.modrn(t.words[0]))}:this._wordDiv(t,e);var n,s,f},o.prototype.div=function(t){return this.divmod(t,"div",!1).div},o.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},o.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},o.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),o=r.cmp(i);return o<0||1===n&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},o.prototype.modrn=function(t){var e=t<0;e&&(t=-t),i(t<=67108863);for(var r=(1<<26)%t,n=0,o=this.length-1;o>=0;o--)n=(r*n+(0|this.words[o]))%t;return e?-n:n},o.prototype.modn=function(t){return this.modrn(t)},o.prototype.idivn=function(t){var e=t<0;e&&(t=-t),i(t<=67108863);for(var r=0,n=this.length-1;n>=0;n--){var o=(0|this.words[n])+67108864*r;this.words[n]=o/t|0,r=o%t}return this._strip(),e?this.ineg():this},o.prototype.divn=function(t){return this.clone().idivn(t)},o.prototype.egcd=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new o(1),s=new o(0),f=new o(0),a=new o(1),h=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++h;for(var u=r.clone(),d=e.clone();!e.isZero();){for(var c=0,l=1;0==(e.words[0]&l)&&c<26;++c,l<<=1);if(c>0)for(e.iushrn(c);c-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(u),s.isub(d)),n.iushrn(1),s.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(f.isOdd()||a.isOdd())&&(f.iadd(u),a.isub(d)),f.iushrn(1),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),n.isub(f),s.isub(a)):(r.isub(e),f.isub(n),a.isub(s))}return{a:f,b:a,gcd:r.iushln(h)}},o.prototype._invmp=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new o(1),f=new o(0),a=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var h=0,u=1;0==(e.words[0]&u)&&h<26;++h,u<<=1);if(h>0)for(e.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(a),s.iushrn(1);for(var d=0,c=1;0==(r.words[0]&c)&&d<26;++d,c<<=1);if(d>0)for(r.iushrn(d);d-- >0;)f.isOdd()&&f.iadd(a),f.iushrn(1);e.cmp(r)>=0?(e.isub(r),s.isub(f)):(r.isub(e),f.isub(s))}return(n=0===e.cmpn(1)?s:f).cmpn(0)<0&&n.iadd(t),n},o.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var o=e;e=r,r=o}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},o.prototype.invm=function(t){return this.egcd(t).a.umod(t)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(t){return this.words[0]&t},o.prototype.bincn=function(t){i("number"==typeof t);var e=t%26,r=(t-e)/26,n=1<<e;if(this.length<=r)return this._expand(r+1),this.words[r]|=n,this;for(var o=n,s=r;0!==o&&s<this.length;s++){var f=0|this.words[s];o=(f+=o)>>>26,f&=67108863,this.words[s]=f}return 0!==o&&(this.words[s]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)e=1;else{r&&(t=-t),i(t<=67108863,"Number is too big");var n=0|this.words[0];e=n===t?0:n<t?-1:1}return 0!==this.negative?0|-e:e},o.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},o.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){i<n?e=-1:i>n&&(e=1);break}}return e},o.prototype.gtn=function(t){return 1===this.cmpn(t)},o.prototype.gt=function(t){return 1===this.cmp(t)},o.prototype.gten=function(t){return this.cmpn(t)>=0},o.prototype.gte=function(t){return this.cmp(t)>=0},o.prototype.ltn=function(t){return-1===this.cmpn(t)},o.prototype.lt=function(t){return-1===this.cmp(t)},o.prototype.lten=function(t){return this.cmpn(t)<=0},o.prototype.lte=function(t){return this.cmp(t)<=0},o.prototype.eqn=function(t){return 0===this.cmpn(t)},o.prototype.eq=function(t){return 0===this.cmp(t)},o.red=function(t){return new x(t)},o.prototype.toRed=function(t){return i(!this.red,"Already a number in reduction context"),i(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},o.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(t){return this.red=t,this},o.prototype.forceRed=function(t){return i(!this.red,"Already a number in reduction context"),this._forceRed(t)},o.prototype.redAdd=function(t){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return i(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function M(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function _(){M.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function S(){M.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function A(){M.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){M.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function x(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else i(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function I(t){x.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(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)}M.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},M.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},M.prototype.split=function(t,e){t.iushrn(this.n,0,e)},M.prototype.imulK=function(t){return t.imul(this.k)},n(_,M),_.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n<i;n++)e.words[n]=t.words[n];if(e.length=i,t.length<=9)return t.words[0]=0,void(t.length=1);var o=t.words[9];for(e.words[e.length++]=o&r,n=10;n<t.length;n++){var s=0|t.words[n];t.words[n-10]=(s&r)<<4|o>>>22,o=s}o>>>=22,t.words[n-10]=o,0===o&&t.length>10?t.length-=10:t.length-=9},_.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(S,M),n(A,M),n(E,M),E.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,n=67108863&i;i>>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(w[t])return w[t];var e;if("k256"===t)e=new _;else if("p224"===t)e=new S;else if("p192"===t)e=new A;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new E}return w[t]=e,e},x.prototype._verify1=function(t){i(0===t.negative,"red works only with positives"),i(t.red,"red works only with red numbers")},x.prototype._verify2=function(t,e){i(0==(t.negative|e.negative),"red works only with positives"),i(t.red&&t.red===e.red,"red works only with red numbers")},x.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(u(t,t.umod(this.m)._forceRed(this)),t)},x.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},x.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)},x.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},x.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)},x.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},x.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},x.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},x.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},x.prototype.isqr=function(t){return this.imul(t,t.clone())},x.prototype.sqr=function(t){return this.mul(t,t)},x.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(i(e%2==1),3===e){var r=this.m.add(new o(1)).iushrn(2);return this.pow(t,r)}for(var n=this.m.subn(1),s=0;!n.isZero()&&0===n.andln(1);)s++,n.iushrn(1);i(!n.isZero());var f=new o(1).toRed(this),a=f.redNeg(),h=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new o(2*u*u).toRe