UNPKG

@0xsequence/google-kms-signer

Version:

an ethers.js- and sequence.js-compatible signer using Google Cloud Key Management Service keys

1 lines 2.91 MB
"use strict";var XZ=Object.create;var Z2=Object.defineProperty;var $Z=Object.getOwnPropertyDescriptor;var YZ=Object.getOwnPropertyNames;var WZ=Object.getPrototypeOf,ZZ=Object.prototype.hasOwnProperty;var QZ=(r,e)=>()=>(r&&(e=r(r=0)),e);var J=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Q2=(r,e)=>{for(var t in e)Z2(r,t,{get:e[t],enumerable:!0})},TR=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of YZ(e))!ZZ.call(r,a)&&a!==t&&Z2(r,a,{get:()=>e[a],enumerable:!(i=$Z(e,a))||i.enumerable});return r};var gi=(r,e,t)=>(t=r!=null?XZ(WZ(r)):{},TR(e||!r||!r.__esModule?Z2(t,"default",{value:r,enumerable:!0}):t,r)),Ie=r=>TR(Z2({},"__esModule",{value:!0}),r);var ER=J(eb=>{"use strict";Object.defineProperty(eb,"__esModule",{value:!0});eb.version=void 0;eb.version="logger/5.7.0"});var Qs=J(Va=>{"use strict";Object.defineProperty(Va,"__esModule",{value:!0});Va.Logger=Va.ErrorCode=Va.LogLevel=void 0;var PR=!1,CR=!1,tb={debug:1,default:2,info:2,warning:3,error:4,off:5},kR=tb.default,eQ=ER(),E9=null;function tQ(){try{var r=[];if(["NFD","NFC","NFKD","NFKC"].forEach(function(e){try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{r.push(e)}}),r.length)throw new Error("missing "+r.join(", "));if("\xE9".normalize("NFD")!=="e\u0301")throw new Error("broken implementation")}catch(e){return e.message}return null}var RR=tQ(),DR;(function(r){r.DEBUG="DEBUG",r.INFO="INFO",r.WARNING="WARNING",r.ERROR="ERROR",r.OFF="OFF"})(DR=Va.LogLevel||(Va.LogLevel={}));var Ua;(function(r){r.UNKNOWN_ERROR="UNKNOWN_ERROR",r.NOT_IMPLEMENTED="NOT_IMPLEMENTED",r.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",r.NETWORK_ERROR="NETWORK_ERROR",r.SERVER_ERROR="SERVER_ERROR",r.TIMEOUT="TIMEOUT",r.BUFFER_OVERRUN="BUFFER_OVERRUN",r.NUMERIC_FAULT="NUMERIC_FAULT",r.MISSING_NEW="MISSING_NEW",r.INVALID_ARGUMENT="INVALID_ARGUMENT",r.MISSING_ARGUMENT="MISSING_ARGUMENT",r.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",r.CALL_EXCEPTION="CALL_EXCEPTION",r.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",r.NONCE_EXPIRED="NONCE_EXPIRED",r.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",r.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",r.TRANSACTION_REPLACED="TRANSACTION_REPLACED",r.ACTION_REJECTED="ACTION_REJECTED"})(Ua=Va.ErrorCode||(Va.ErrorCode={}));var NR="0123456789abcdef",rQ=function(){function r(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}return r.prototype._log=function(e,t){var i=e.toLowerCase();tb[i]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(kR>tb[i])&&console.log.apply(console,t)},r.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._log(r.levels.DEBUG,e)},r.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._log(r.levels.INFO,e)},r.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._log(r.levels.WARNING,e)},r.prototype.makeError=function(e,t,i){if(CR)return this.makeError("censored error",t,{});t||(t=r.errors.UNKNOWN_ERROR),i||(i={});var a=[];Object.keys(i).forEach(function(o){var s=i[o];try{if(s instanceof Uint8Array){for(var n="",u=0;u<s.length;u++)n+=NR[s[u]>>4],n+=NR[s[u]&15];a.push(o+"=Uint8Array(0x"+n+")")}else a.push(o+"="+JSON.stringify(s))}catch{a.push(o+"="+JSON.stringify(i[o].toString()))}}),a.push("code="+t),a.push("version="+this.version);var c=e,g="";switch(t){case Ua.NUMERIC_FAULT:{g="NUMERIC_FAULT";var h=e;switch(h){case"overflow":case"underflow":case"division-by-zero":g+="-"+h;break;case"negative-power":case"negative-width":g+="-unsupported";break;case"unbound-bitwise-result":g+="-unbound-result";break}break}case Ua.CALL_EXCEPTION:case Ua.INSUFFICIENT_FUNDS:case Ua.MISSING_NEW:case Ua.NONCE_EXPIRED:case Ua.REPLACEMENT_UNDERPRICED:case Ua.TRANSACTION_REPLACED:case Ua.UNPREDICTABLE_GAS_LIMIT:g=t;break}g&&(e+=" [ See: https://links.ethers.org/v5-errors-"+g+" ]"),a.length&&(e+=" ("+a.join(", ")+")");var f=new Error(e);return f.reason=c,f.code=t,Object.keys(i).forEach(function(o){f[o]=i[o]}),f},r.prototype.throwError=function(e,t,i){throw this.makeError(e,t,i)},r.prototype.throwArgumentError=function(e,t,i){return this.throwError(e,r.errors.INVALID_ARGUMENT,{argument:t,value:i})},r.prototype.assert=function(e,t,i,a){e||this.throwError(t,i,a)},r.prototype.assertArgument=function(e,t,i,a){e||this.throwArgumentError(t,i,a)},r.prototype.checkNormalize=function(e){e==null&&(e="platform missing String.prototype.normalize"),RR&&this.throwError("platform missing String.prototype.normalize",r.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:RR})},r.prototype.checkSafeUint53=function(e,t){typeof e=="number"&&(t==null&&(t="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(t,r.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(t,r.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))},r.prototype.checkArgumentCount=function(e,t,i){i?i=": "+i:i="",e<t&&this.throwError("missing argument"+i,r.errors.MISSING_ARGUMENT,{count:e,expectedCount:t}),e>t&&this.throwError("too many arguments"+i,r.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})},r.prototype.checkNew=function(e,t){(e===Object||e==null)&&this.throwError("missing new",r.errors.MISSING_NEW,{name:t.name})},r.prototype.checkAbstract=function(e,t){e===t?this.throwError("cannot instantiate abstract class "+JSON.stringify(t.name)+" directly; use a sub-class",r.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",r.errors.MISSING_NEW,{name:t.name})},r.globalLogger=function(){return E9||(E9=new r(eQ.version)),E9},r.setCensorship=function(e,t){if(!e&&t&&this.globalLogger().throwError("cannot permanently disable censorship",r.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),PR){if(!e)return;this.globalLogger().throwError("error censorship permanent",r.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}CR=!!e,PR=!!t},r.setLogLevel=function(e){var t=tb[e.toLowerCase()];if(t==null){r.globalLogger().warn("invalid log level - "+e);return}kR=t},r.from=function(e){return new r(e)},r.errors=Ua,r.levels=DR,r}();Va.Logger=rQ});var IR=J(rb=>{"use strict";Object.defineProperty(rb,"__esModule",{value:!0});rb.version=void 0;rb.version="bytes/5.7.0"});var lc=J(ft=>{"use strict";Object.defineProperty(ft,"__esModule",{value:!0});ft.joinSignature=ft.splitSignature=ft.hexZeroPad=ft.hexStripZeros=ft.hexValue=ft.hexConcat=ft.hexDataSlice=ft.hexDataLength=ft.hexlify=ft.isHexString=ft.zeroPad=ft.stripZeros=ft.concat=ft.arrayify=ft.isBytes=ft.isBytesLike=void 0;var nQ=Qs(),iQ=IR(),pr=new nQ.Logger(iQ.version);function MR(r){return!!r.toHexString}function lf(r){return r.slice||(r.slice=function(){var e=Array.prototype.slice.call(arguments);return lf(new Uint8Array(Array.prototype.slice.apply(r,e)))}),r}function BR(r){return Io(r)&&!(r.length%2)||ib(r)}ft.isBytesLike=BR;function LR(r){return typeof r=="number"&&r==r&&r%1===0}function ib(r){if(r==null)return!1;if(r.constructor===Uint8Array)return!0;if(typeof r=="string"||!LR(r.length)||r.length<0)return!1;for(var e=0;e<r.length;e++){var t=r[e];if(!LR(t)||t<0||t>=256)return!1}return!0}ft.isBytes=ib;function cp(r,e){if(e||(e={}),typeof r=="number"){pr.checkSafeUint53(r,"invalid arrayify value");for(var t=[];r;)t.unshift(r&255),r=parseInt(String(r/256));return t.length===0&&t.push(0),lf(new Uint8Array(t))}if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),MR(r)&&(r=r.toHexString()),Io(r)){var i=r.substring(2);i.length%2&&(e.hexPad==="left"?i="0"+i:e.hexPad==="right"?i+="0":pr.throwArgumentError("hex data is odd-length","value",r));for(var t=[],a=0;a<i.length;a+=2)t.push(parseInt(i.substring(a,a+2),16));return lf(new Uint8Array(t))}return ib(r)?lf(new Uint8Array(r)):pr.throwArgumentError("invalid arrayify value","value",r)}ft.arrayify=cp;function jR(r){var e=r.map(function(a){return cp(a)}),t=e.reduce(function(a,c){return a+c.length},0),i=new Uint8Array(t);return e.reduce(function(a,c){return i.set(c,a),a+c.length},0),lf(i)}ft.concat=jR;function oQ(r){var e=cp(r);if(e.length===0)return e;for(var t=0;t<e.length&&e[t]===0;)t++;return t&&(e=e.slice(t)),e}ft.stripZeros=oQ;function FR(r,e){r=cp(r),r.length>e&&pr.throwArgumentError("value out of range","value",arguments[0]);var t=new Uint8Array(e);return t.set(r,e-r.length),lf(t)}ft.zeroPad=FR;function Io(r,e){return!(typeof r!="string"||!r.match(/^0x[0-9A-Fa-f]*$/)||e&&r.length!==2+2*e)}ft.isHexString=Io;var P9="0123456789abcdef";function On(r,e){if(e||(e={}),typeof r=="number"){pr.checkSafeUint53(r,"invalid hexlify value");for(var t="";r;)t=P9[r&15]+t,r=Math.floor(r/16);return t.length?(t.length%2&&(t="0"+t),"0x"+t):"0x00"}if(typeof r=="bigint")return r=r.toString(16),r.length%2?"0x0"+r:"0x"+r;if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),MR(r))return r.toHexString();if(Io(r))return r.length%2&&(e.hexPad==="left"?r="0x0"+r.substring(2):e.hexPad==="right"?r+="0":pr.throwArgumentError("hex data is odd-length","value",r)),r.toLowerCase();if(ib(r)){for(var i="0x",a=0;a<r.length;a++){var c=r[a];i+=P9[(c&240)>>4]+P9[c&15]}return i}return pr.throwArgumentError("invalid hexlify value","value",r)}ft.hexlify=On;function aQ(r){if(typeof r!="string")r=On(r);else if(!Io(r)||r.length%2)return null;return(r.length-2)/2}ft.hexDataLength=aQ;function sQ(r,e,t){return typeof r!="string"?r=On(r):(!Io(r)||r.length%2)&&pr.throwArgumentError("invalid hexData","value",r),e=2+2*e,t!=null?"0x"+r.substring(e,2+2*t):"0x"+r.substring(e)}ft.hexDataSlice=sQ;function lQ(r){var e="0x";return r.forEach(function(t){e+=On(t).substring(2)}),e}ft.hexConcat=lQ;function cQ(r){var e=UR(On(r,{hexPad:"left"}));return e==="0x"?"0x0":e}ft.hexValue=cQ;function UR(r){typeof r!="string"&&(r=On(r)),Io(r)||pr.throwArgumentError("invalid hex string","value",r),r=r.substring(2);for(var e=0;e<r.length&&r[e]==="0";)e++;return"0x"+r.substring(e)}ft.hexStripZeros=UR;function nb(r,e){for(typeof r!="string"?r=On(r):Io(r)||pr.throwArgumentError("invalid hex string","value",r),r.length>2*e+2&&pr.throwArgumentError("value out of range","value",arguments[1]);r.length<2*e+2;)r="0x0"+r.substring(2);return r}ft.hexZeroPad=nb;function VR(r){var e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(BR(r)){var t=cp(r);t.length===64?(e.v=27+(t[32]>>7),t[32]&=127,e.r=On(t.slice(0,32)),e.s=On(t.slice(32,64))):t.length===65?(e.r=On(t.slice(0,32)),e.s=On(t.slice(32,64)),e.v=t[64]):pr.throwArgumentError("invalid signature string","signature",r),e.v<27&&(e.v===0||e.v===1?e.v+=27:pr.throwArgumentError("signature invalid v byte","signature",r)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(t[32]|=128),e._vs=On(t.slice(32,64))}else{if(e.r=r.r,e.s=r.s,e.v=r.v,e.recoveryParam=r.recoveryParam,e._vs=r._vs,e._vs!=null){var i=FR(cp(e._vs),32);e._vs=On(i);var a=i[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=a:e.recoveryParam!==a&&pr.throwArgumentError("signature recoveryParam mismatch _vs","signature",r),i[0]&=127;var c=On(i);e.s==null?e.s=c:e.s!==c&&pr.throwArgumentError("signature v mismatch _vs","signature",r)}if(e.recoveryParam==null)e.v==null?pr.throwArgumentError("signature missing v and recoveryParam","signature",r):e.v===0||e.v===1?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2;else if(e.v==null)e.v=27+e.recoveryParam;else{var g=e.v===0||e.v===1?e.v:1-e.v%2;e.recoveryParam!==g&&pr.throwArgumentError("signature recoveryParam mismatch v","signature",r)}e.r==null||!Io(e.r)?pr.throwArgumentError("signature missing or invalid r","signature",r):e.r=nb(e.r,32),e.s==null||!Io(e.s)?pr.throwArgumentError("signature missing or invalid s","signature",r):e.s=nb(e.s,32);var h=cp(e.s);h[0]>=128&&pr.throwArgumentError("signature s out of range","signature",r),e.recoveryParam&&(h[0]|=128);var f=On(h);e._vs&&(Io(e._vs)||pr.throwArgumentError("signature invalid _vs","signature",r),e._vs=nb(e._vs,32)),e._vs==null?e._vs=f:e._vs!==f&&pr.throwArgumentError("signature _vs mismatch v and s","signature",r)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}ft.splitSignature=VR;function uQ(r){return r=VR(r),On(jR([r.r,r.s,r.recoveryParam?"0x1c":"0x1b"]))}ft.joinSignature=uQ});var GR=J((JR,C9)=>{(function(r,e){"use strict";function t(R,S){if(!R)throw new Error(S||"Assertion failed")}function i(R,S){R.super_=S;var T=function(){};T.prototype=S.prototype,R.prototype=new T,R.prototype.constructor=R}function a(R,S,T){if(a.isBN(R))return R;this.negative=0,this.words=null,this.length=0,this.red=null,R!==null&&((S==="le"||S==="be")&&(T=S,S=10),this._init(R||0,S||10,T||"be"))}typeof r=="object"?r.exports=a:e.BN=a,a.BN=a,a.wordSize=26;var c;try{typeof window<"u"&&typeof window.Buffer<"u"?c=window.Buffer:c=require("buffer").Buffer}catch{}a.isBN=function(S){return S instanceof a?!0:S!==null&&typeof S=="object"&&S.constructor.wordSize===a.wordSize&&Array.isArray(S.words)},a.max=function(S,T){return S.cmp(T)>0?S:T},a.min=function(S,T){return S.cmp(T)<0?S:T},a.prototype._init=function(S,T,N){if(typeof S=="number")return this._initNumber(S,T,N);if(typeof S=="object")return this._initArray(S,T,N);T==="hex"&&(T=16),t(T===(T|0)&&T>=2&&T<=36),S=S.toString().replace(/\s+/g,"");var L=0;S[0]==="-"&&(L++,this.negative=1),L<S.length&&(T===16?this._parseHex(S,L,N):(this._parseBase(S,T,L),N==="le"&&this._initArray(this.toArray(),T,N)))},a.prototype._initNumber=function(S,T,N){S<0&&(this.negative=1,S=-S),S<67108864?(this.words=[S&67108863],this.length=1):S<4503599627370496?(this.words=[S&67108863,S/67108864&67108863],this.length=2):(t(S<9007199254740992),this.words=[S&67108863,S/67108864&67108863,1],this.length=3),N==="le"&&this._initArray(this.toArray(),T,N)},a.prototype._initArray=function(S,T,N){if(t(typeof S.length=="number"),S.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(S.length/3),this.words=new Array(this.length);for(var L=0;L<this.length;L++)this.words[L]=0;var I,C,B=0;if(N==="be")for(L=S.length-1,I=0;L>=0;L-=3)C=S[L]|S[L-1]<<8|S[L-2]<<16,this.words[I]|=C<<B&67108863,this.words[I+1]=C>>>26-B&67108863,B+=24,B>=26&&(B-=26,I++);else if(N==="le")for(L=0,I=0;L<S.length;L+=3)C=S[L]|S[L+1]<<8|S[L+2]<<16,this.words[I]|=C<<B&67108863,this.words[I+1]=C>>>26-B&67108863,B+=24,B>=26&&(B-=26,I++);return this._strip()};function g(R,S){var T=R.charCodeAt(S);if(T>=48&&T<=57)return T-48;if(T>=65&&T<=70)return T-55;if(T>=97&&T<=102)return T-87;t(!1,"Invalid character in "+R)}function h(R,S,T){var N=g(R,T);return T-1>=S&&(N|=g(R,T-1)<<4),N}a.prototype._parseHex=function(S,T,N){this.length=Math.ceil((S.length-T)/6),this.words=new Array(this.length);for(var L=0;L<this.length;L++)this.words[L]=0;var I=0,C=0,B;if(N==="be")for(L=S.length-1;L>=T;L-=2)B=h(S,T,L)<<I,this.words[C]|=B&67108863,I>=18?(I-=18,C+=1,this.words[C]|=B>>>26):I+=8;else{var G=S.length-T;for(L=G%2===0?T+1:T;L<S.length;L+=2)B=h(S,T,L)<<I,this.words[C]|=B&67108863,I>=18?(I-=18,C+=1,this.words[C]|=B>>>26):I+=8}this._strip()};function f(R,S,T,N){for(var L=0,I=0,C=Math.min(R.length,T),B=S;B<C;B++){var G=R.charCodeAt(B)-48;L*=N,G>=49?I=G-49+10:G>=17?I=G-17+10:I=G,t(G>=0&&I<N,"Invalid character"),L+=I}return L}a.prototype._parseBase=function(S,T,N){this.words=[0],this.length=1;for(var L=0,I=1;I<=67108863;I*=T)L++;L--,I=I/T|0;for(var C=S.length-N,B=C%L,G=Math.min(C,C-B)+N,D=0,U=N;U<G;U+=L)D=f(S,U,U+L,T),this.imuln(I),this.words[0]+D<67108864?this.words[0]+=D:this._iaddn(D);if(B!==0){var ae=1;for(D=f(S,U,S.length,T),U=0;U<B;U++)ae*=T;this.imuln(ae),this.words[0]+D<67108864?this.words[0]+=D:this._iaddn(D)}this._strip()},a.prototype.copy=function(S){S.words=new Array(this.length);for(var T=0;T<this.length;T++)S.words[T]=this.words[T];S.length=this.length,S.negative=this.negative,S.red=this.red};function o(R,S){R.words=S.words,R.length=S.length,R.negative=S.negative,R.red=S.red}if(a.prototype._move=function(S){o(S,this)},a.prototype.clone=function(){var S=new a(null);return this.copy(S),S},a.prototype._expand=function(S){for(;this.length<S;)this.words[this.length++]=0;return this},a.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},a.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{a.prototype[Symbol.for("nodejs.util.inspect.custom")]=s}catch{a.prototype.inspect=s}else a.prototype.inspect=s;function s(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var n=["","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"],u=[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],m=[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];a.prototype.toString=function(S,T){S=S||10,T=T|0||1;var N;if(S===16||S==="hex"){N="";for(var L=0,I=0,C=0;C<this.length;C++){var B=this.words[C],G=((B<<L|I)&16777215).toString(16);I=B>>>24-L&16777215,L+=2,L>=26&&(L-=26,C--),I!==0||C!==this.length-1?N=n[6-G.length]+G+N:N=G+N}for(I!==0&&(N=I.toString(16)+N);N.length%T!==0;)N="0"+N;return this.negative!==0&&(N="-"+N),N}if(S===(S|0)&&S>=2&&S<=36){var D=u[S],U=m[S];N="";var ae=this.clone();for(ae.negative=0;!ae.isZero();){var j=ae.modrn(U).toString(S);ae=ae.idivn(U),ae.isZero()?N=j+N:N=n[D-j.length]+j+N}for(this.isZero()&&(N="0"+N);N.length%T!==0;)N="0"+N;return this.negative!==0&&(N="-"+N),N}t(!1,"Base should be between 2 and 36")},a.prototype.toNumber=function(){var S=this.words[0];return this.length===2?S+=this.words[1]*67108864:this.length===3&&this.words[2]===1?S+=4503599627370496+this.words[1]*67108864:this.length>2&&t(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-S:S},a.prototype.toJSON=function(){return this.toString(16,2)},c&&(a.prototype.toBuffer=function(S,T){return this.toArrayLike(c,S,T)}),a.prototype.toArray=function(S,T){return this.toArrayLike(Array,S,T)};var A=function(S,T){return S.allocUnsafe?S.allocUnsafe(T):new S(T)};a.prototype.toArrayLike=function(S,T,N){this._strip();var L=this.byteLength(),I=N||Math.max(1,L);t(L<=I,"byte array longer than desired length"),t(I>0,"Requested array length <= 0");var C=A(S,I),B=T==="le"?"LE":"BE";return this["_toArrayLike"+B](C,L),C},a.prototype._toArrayLikeLE=function(S,T){for(var N=0,L=0,I=0,C=0;I<this.length;I++){var B=this.words[I]<<C|L;S[N++]=B&255,N<S.length&&(S[N++]=B>>8&255),N<S.length&&(S[N++]=B>>16&255),C===6?(N<S.length&&(S[N++]=B>>24&255),L=0,C=0):(L=B>>>24,C+=2)}if(N<S.length)for(S[N++]=L;N<S.length;)S[N++]=0},a.prototype._toArrayLikeBE=function(S,T){for(var N=S.length-1,L=0,I=0,C=0;I<this.length;I++){var B=this.words[I]<<C|L;S[N--]=B&255,N>=0&&(S[N--]=B>>8&255),N>=0&&(S[N--]=B>>16&255),C===6?(N>=0&&(S[N--]=B>>24&255),L=0,C=0):(L=B>>>24,C+=2)}if(N>=0)for(S[N--]=L;N>=0;)S[N--]=0},Math.clz32?a.prototype._countBits=function(S){return 32-Math.clz32(S)}:a.prototype._countBits=function(S){var T=S,N=0;return T>=4096&&(N+=13,T>>>=13),T>=64&&(N+=7,T>>>=7),T>=8&&(N+=4,T>>>=4),T>=2&&(N+=2,T>>>=2),N+T},a.prototype._zeroBits=function(S){if(S===0)return 26;var T=S,N=0;return T&8191||(N+=13,T>>>=13),T&127||(N+=7,T>>>=7),T&15||(N+=4,T>>>=4),T&3||(N+=2,T>>>=2),T&1||N++,N},a.prototype.bitLength=function(){var S=this.words[this.length-1],T=this._countBits(S);return(this.length-1)*26+T};function P(R){for(var S=new Array(R.bitLength()),T=0;T<S.length;T++){var N=T/26|0,L=T%26;S[T]=R.words[N]>>>L&1}return S}a.prototype.zeroBits=function(){if(this.isZero())return 0;for(var S=0,T=0;T<this.length;T++){var N=this._zeroBits(this.words[T]);if(S+=N,N!==26)break}return S},a.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},a.prototype.toTwos=function(S){return this.negative!==0?this.abs().inotn(S).iaddn(1):this.clone()},a.prototype.fromTwos=function(S){return this.testn(S-1)?this.notn(S).iaddn(1).ineg():this.clone()},a.prototype.isNeg=function(){return this.negative!==0},a.prototype.neg=function(){return this.clone().ineg()},a.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},a.prototype.iuor=function(S){for(;this.length<S.length;)this.words[this.length++]=0;for(var T=0;T<S.length;T++)this.words[T]=this.words[T]|S.words[T];return this._strip()},a.prototype.ior=function(S){return t((this.negative|S.negative)===0),this.iuor(S)},a.prototype.or=function(S){return this.length>S.length?this.clone().ior(S):S.clone().ior(this)},a.prototype.uor=function(S){return this.length>S.length?this.clone().iuor(S):S.clone().iuor(this)},a.prototype.iuand=function(S){var T;this.length>S.length?T=S:T=this;for(var N=0;N<T.length;N++)this.words[N]=this.words[N]&S.words[N];return this.length=T.length,this._strip()},a.prototype.iand=function(S){return t((this.negative|S.negative)===0),this.iuand(S)},a.prototype.and=function(S){return this.length>S.length?this.clone().iand(S):S.clone().iand(this)},a.prototype.uand=function(S){return this.length>S.length?this.clone().iuand(S):S.clone().iuand(this)},a.prototype.iuxor=function(S){var T,N;this.length>S.length?(T=this,N=S):(T=S,N=this);for(var L=0;L<N.length;L++)this.words[L]=T.words[L]^N.words[L];if(this!==T)for(;L<T.length;L++)this.words[L]=T.words[L];return this.length=T.length,this._strip()},a.prototype.ixor=function(S){return t((this.negative|S.negative)===0),this.iuxor(S)},a.prototype.xor=function(S){return this.length>S.length?this.clone().ixor(S):S.clone().ixor(this)},a.prototype.uxor=function(S){return this.length>S.length?this.clone().iuxor(S):S.clone().iuxor(this)},a.prototype.inotn=function(S){t(typeof S=="number"&&S>=0);var T=Math.ceil(S/26)|0,N=S%26;this._expand(T),N>0&&T--;for(var L=0;L<T;L++)this.words[L]=~this.words[L]&67108863;return N>0&&(this.words[L]=~this.words[L]&67108863>>26-N),this._strip()},a.prototype.notn=function(S){return this.clone().inotn(S)},a.prototype.setn=function(S,T){t(typeof S=="number"&&S>=0);var N=S/26|0,L=S%26;return this._expand(N+1),T?this.words[N]=this.words[N]|1<<L:this.words[N]=this.words[N]&~(1<<L),this._strip()},a.prototype.iadd=function(S){var T;if(this.negative!==0&&S.negative===0)return this.negative=0,T=this.isub(S),this.negative^=1,this._normSign();if(this.negative===0&&S.negative!==0)return S.negative=0,T=this.isub(S),S.negative=1,T._normSign();var N,L;this.length>S.length?(N=this,L=S):(N=S,L=this);for(var I=0,C=0;C<L.length;C++)T=(N.words[C]|0)+(L.words[C]|0)+I,this.words[C]=T&67108863,I=T>>>26;for(;I!==0&&C<N.length;C++)T=(N.words[C]|0)+I,this.words[C]=T&67108863,I=T>>>26;if(this.length=N.length,I!==0)this.words[this.length]=I,this.length++;else if(N!==this)for(;C<N.length;C++)this.words[C]=N.words[C];return this},a.prototype.add=function(S){var T;return S.negative!==0&&this.negative===0?(S.negative=0,T=this.sub(S),S.negative^=1,T):S.negative===0&&this.negative!==0?(this.negative=0,T=S.sub(this),this.negative=1,T):this.length>S.length?this.clone().iadd(S):S.clone().iadd(this)},a.prototype.isub=function(S){if(S.negative!==0){S.negative=0;var T=this.iadd(S);return S.negative=1,T._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(S),this.negative=1,this._normSign();var N=this.cmp(S);if(N===0)return this.negative=0,this.length=1,this.words[0]=0,this;var L,I;N>0?(L=this,I=S):(L=S,I=this);for(var C=0,B=0;B<I.length;B++)T=(L.words[B]|0)-(I.words[B]|0)+C,C=T>>26,this.words[B]=T&67108863;for(;C!==0&&B<L.length;B++)T=(L.words[B]|0)+C,C=T>>26,this.words[B]=T&67108863;if(C===0&&B<L.length&&L!==this)for(;B<L.length;B++)this.words[B]=L.words[B];return this.length=Math.max(this.length,B),L!==this&&(this.negative=1),this._strip()},a.prototype.sub=function(S){return this.clone().isub(S)};function F(R,S,T){T.negative=S.negative^R.negative;var N=R.length+S.length|0;T.length=N,N=N-1|0;var L=R.words[0]|0,I=S.words[0]|0,C=L*I,B=C&67108863,G=C/67108864|0;T.words[0]=B;for(var D=1;D<N;D++){for(var U=G>>>26,ae=G&67108863,j=Math.min(D,S.length-1),Z=Math.max(0,D-R.length+1);Z<=j;Z++){var ne=D-Z|0;L=R.words[ne]|0,I=S.words[Z]|0,C=L*I+ae,U+=C/67108864|0,ae=C&67108863}T.words[D]=ae|0,G=U|0}return G!==0?T.words[D]=G|0:T.length--,T._strip()}var V=function(S,T,N){var L=S.words,I=T.words,C=N.words,B=0,G,D,U,ae=L[0]|0,j=ae&8191,Z=ae>>>13,ne=L[1]|0,ie=ne&8191,d=ne>>>13,b=L[2]|0,O=b&8191,_=b>>>13,q=L[3]|0,z=q&8191,Q=q>>>13,p=L[4]|0,v=p&8191,x=p>>>13,l=L[5]|0,y=l&8191,w=l>>>13,k=L[6]|0,re=k&8191,he=k>>>13,Tt=L[7]|0,ge=Tt&8191,me=Tt>>>13,Mt=L[8]|0,ke=Mt&8191,Re=Mt>>>13,Yn=L[9]|0,_e=Yn&8191,Ce=Yn>>>13,or=I[0]|0,Se=or&8191,be=or>>>13,Na=I[1]|0,Be=Na&8191,je=Na>>>13,Da=I[2]|0,Fe=Da&8191,Ue=Da>>>13,Ia=I[3]|0,Ve=Ia&8191,Je=Ia>>>13,La=I[4]|0,Ge=La&8191,qe=La>>>13,Ma=I[5]|0,He=Ma&8191,Ke=Ma>>>13,Ba=I[6]|0,ze=Ba&8191,Xe=Ba>>>13,ja=I[7]|0,$e=ja&8191,Ye=ja>>>13,Fa=I[8]|0,We=Fa&8191,Ze=Fa>>>13,Do=I[9]|0,Pt=Do&8191,Ct=Do>>>13;N.negative=S.negative^T.negative,N.length=19,G=Math.imul(j,Se),D=Math.imul(j,be),D=D+Math.imul(Z,Se)|0,U=Math.imul(Z,be);var Bi=(B+G|0)+((D&8191)<<13)|0;B=(U+(D>>>13)|0)+(Bi>>>26)|0,Bi&=67108863,G=Math.imul(ie,Se),D=Math.imul(ie,be),D=D+Math.imul(d,Se)|0,U=Math.imul(d,be),G=G+Math.imul(j,Be)|0,D=D+Math.imul(j,je)|0,D=D+Math.imul(Z,Be)|0,U=U+Math.imul(Z,je)|0;var ji=(B+G|0)+((D&8191)<<13)|0;B=(U+(D>>>13)|0)+(ji>>>26)|0,ji&=67108863,G=Math.imul(O,Se),D=Math.imul(O,be),D=D+Math.imul(_,Se)|0,U=Math.imul(_,be),G=G+Math.imul(ie,Be)|0,D=D+Math.imul(ie,je)|0,D=D+Math.imul(d,Be)|0,U=U+Math.imul(d,je)|0,G=G+Math.imul(j,Fe)|0,D=D+Math.imul(j,Ue)|0,D=D+Math.imul(Z,Fe)|0,U=U+Math.imul(Z,Ue)|0;var Fi=(B+G|0)+((D&8191)<<13)|0;B=(U+(D>>>13)|0)+(Fi>>>26)|0,Fi&=67108863,G=Math.imul(z,Se),D=Math.imul(z,be),D=D+Math.imul(Q,Se)|0,U=Math.imul(Q,be),G=G+Math.imul(O,Be)|0,D=D+Math.imul(O,je)|0,D=D+Math.imul(_,Be)|0,U=U+Math.imul(_,je)|0,G=G+Math.imul(ie,Fe)|0,D=D+Math.imul(ie,Ue)|0,D=D+Math.imul(d,Fe)|0,U=U+Math.imul(d,Ue)|0,G=G+Math.imul(j,Ve)|0,D=D+Math.imul(j,Je)|0,D=D+Math.imul(Z,Ve)|0,U=U+Math.imul(Z,Je)|0;var Ui=(B+G|0)+((D&8191)<<13)|0;B=(U+(D>>>13)|0)+(Ui>>>26)|0,Ui&=67108863,G=Math.imul(v,Se),D=Math.imul(v,be),D=D+Math.imul(x,Se)|0,U=Math.imul(x,be),G=G+Math.imul(z,Be)|0,D=D+Math.imul(z,je)|0,D=D+Math.imul(Q,Be)|0,U=U+Math.imul(Q,je)|0,G=G+Math.imul(O,Fe)|0,D=D+Math.imul(O,Ue)|0,D=D+Math.imul(_,Fe)|0,U=U+Math.imul(_,Ue)|0,G=G+Math.imul(ie,Ve)|0,D=D+Math.imul(ie,Je)|0,D=D+Math.imul(d,Ve)|0,U=U+Math.imul(d,Je)|0,G=G+Math.imul(j,Ge)|0,D=D+Math.imul(j,qe)|0,D=D+Math.imul(Z,Ge)|0,U=U+Math.imul(Z,qe)|0;var Vi=(B+G|0)+((D&8191)<<13)|0;B=(U+(D>>>13)|0)+(Vi>>>26)|0,Vi&=67108863,G=Math.imul(y,Se),D=Math.imul(y,be),D=D+Math.imul(w,Se)|0,U=Math.imul(w,be),G=G+Math.imul(v,Be)|0,D=D+Math.imul(v,je)|0,D=D+Math.imul(x,Be)|0,U=U+Math.imul(x,je)|0,G=G+Math.imul(z,Fe)|0,D=D+Math.imul(z,Ue)|0,D=D+Math.imul(Q,Fe)|0,U=U+Math.imul(Q,Ue)|0,G=G+Math.imul(O,Ve)|0,D=D+Math.imul(O,Je)|0,D=D+Math.imul(_,Ve)|0,U=U+Math.imul(_,Je)|0,G=G+Math.imul(ie,Ge)|0,D=D+Math.imul(ie,qe)|0,D=D+Math.imul(d,Ge)|0,U=U+Math.imul(d,qe)|0,G=G+Math.imul(j,He)|0,D=D+Math.imul(j,Ke)|0,D=D+Math.imul(Z,He)|0,U=U+Math.imul(Z,Ke)|0;var Zu=(B+G|0)+((D&8191)<<13)|0;B=(U+(D>>>13)|0)+(Zu>>>26)|0,Zu&=67108863,G=Math.imul(re,Se),D=Math.imul(re,be),D=D+Math.imul(he,Se)|0,U=Math.imul(he,be),G=G+Math.imul(y,Be)|0,D=D+Math.imul(y,je)|0,D=D+Math.imul(w,Be)|0,U=U+Math.imul(w,je)|0,G=G+Math.imul(v,Fe)|0,D=D+Math.imul(v,Ue)|0,D=D+Math.imul(x,Fe)|0,U=U+Math.imul(x,Ue)|0,G=G+Math.imul(z,Ve)|0,D=D+Math.imul(z,Je)|0,D=D+Math.imul(Q,Ve)|0,U=U+Math.imul(Q,Je)|0,G=G+Math.imul(O,Ge)|0,D=D+Math.imul(O,qe)|0,D=D+Math.imul(_,Ge)|0,U=U+Math.imul(_,qe)|0,G=G+Math.imul(ie,He)|0,D=D+Math.imul(ie,Ke)|0,D=D+Math.imul(d,He)|0,U=U+Math.imul(d,Ke)|0,G=G+Math.imul(j,ze)|0,D=D+Math.imul(j,Xe)|0,D=D+Math.imul(Z,ze)|0,U=U+Math.imul(Z,Xe)|0;var Qu=(B+G|0)+((D&8191)<<13)|0;B=(U+(D>>>13)|0)+(Qu>>>26)|0,Qu&=67108863,G=Math.imul(ge,Se),D=Math.imul(ge,be),D=D+Math.imul(me,Se)|0,U=Math.imul(me,be),G=G+Math.imul(re,Be)|0,D=D+Math.imul(re,je)|0,D=D+Math.imul(he,Be)|0,U=U+Math.imul(he,je)|0,G=G+Math.imul(y,Fe)|0,D=D+Math.imul(y,Ue)|0,D=D+Math.imul(w,Fe)|0,U=U+Math.imul(w,Ue)|0,G=G+Math.imul(v,Ve)|0,D=D+Math.imul(v,Je)|0,D=D+Math.imul(x,Ve)|0,U=U+Math.imul(x,Je)|0,G=G+Math.imul(z,Ge)|0,D=D+Math.imul(z,qe)|0,D=D+Math.imul(Q,Ge)|0,U=U+Math.imul(Q,qe)|0,G=G+Math.imul(O,He)|0,D=D+Math.imul(O,Ke)|0,D=D+Math.imul(_,He)|0,U=U+Math.imul(_,Ke)|0,G=G+Math.imul(ie,ze)|0,D=D+Math.imul(ie,Xe)|0,D=D+Math.imul(d,ze)|0,U=U+Math.imul(d,Xe)|0,G=G+Math.imul(j,$e)|0,D=D+Math.imul(j,Ye)|0,D=D+Math.imul(Z,$e)|0,U=U+Math.imul(Z,Ye)|0;var ep=(B+G|0)+((D&8191)<<13)|0;B=(U+(D>>>13)|0)+(ep>>>26)|0,ep&=67108863,G=Math.imul(ke,Se),D=Math.imul(ke,be),D=D+Math.imul(Re,Se)|0,U=Math.imul(Re,be),G=G+Math.imul(ge,Be)|0,D=D+Math.imul(ge,je)|0,D=D+Math.imul(me,Be)|0,U=U+Math.imul(me,je)|0,G=G+Math.imul(re,Fe)|0,D=D+Math.imul(re,Ue)|0,D=D+Math.imul(he,Fe)|0,U=U+Math.imul(he,Ue)|0,G=G+Math.imul(y,Ve)|0,D=D+Math.imul(y,Je)|0,D=D+Math.imul(w,Ve)|0,U=U+Math.imul(w,Je)|0,G=G+Math.imul(v,Ge)|0,D=D+Math.imul(v,qe)|0,D=D+Math.imul(x,Ge)|0,U=U+Math.imul(x,qe)|0,G=G+Math.imul(z,He)|0,D=D+Math.imul(z,Ke)|0,D=D+Math.imul(Q,He)|0,U=U+Math.imul(Q,Ke)|0,G=G+Math.imul(O,ze)|0,D=D+Math.imul(O,Xe)|0,D=D+Math.imul(_,ze)|0,U=U+Math.imul(_,Xe)|0,G=G+Math.imul(ie,$e)|0,D=D+Math.imul(ie,Ye)|0,D=D+Math.imul(d,$e)|0,U=U+Math.imul(d,Ye)|0,G=G+Math.imul(j,We)|0,D=D+Math.imul(j,Ze)|0,D=D+Math.imul(Z,We)|0,U=U+Math.imul(Z,Ze)|0;var tp=(B+G|0)+((D&8191)<<13)|0;B=(U+(D>>>13)|0)+(tp>>>26)|0,tp&=67108863,G=Math.imul(_e,Se),D=Math.imul(_e,be),D=D+Math.imul(Ce,Se)|0,U=Math.imul(Ce,be),G=G+Math.imul(ke,Be)|0,D=D+Math.imul(ke,je)|0,D=D+Math.imul(Re,Be)|0,U=U+Math.imul(Re,je)|0,G=G+Math.imul(ge,Fe)|0,D=D+Math.imul(ge,Ue)|0,D=D+Math.imul(me,Fe)|0,U=U+Math.imul(me,Ue)|0,G=G+Math.imul(re,Ve)|0,D=D+Math.imul(re,Je)|0,D=D+Math.imul(he,Ve)|0,U=U+Math.imul(he,Je)|0,G=G+Math.imul(y,Ge)|0,D=D+Math.imul(y,qe)|0,D=D+Math.imul(w,Ge)|0,U=U+Math.imul(w,qe)|0,G=G+Math.imul(v,He)|0,D=D+Math.imul(v,Ke)|0,D=D+Math.imul(x,He)|0,U=U+Math.imul(x,Ke)|0,G=G+Math.imul(z,ze)|0,D=D+Math.imul(z,Xe)|0,D=D+Math.imul(Q,ze)|0,U=U+Math.imul(Q,Xe)|0,G=G+Math.imul(O,$e)|0,D=D+Math.imul(O,Ye)|0,D=D+Math.imul(_,$e)|0,U=U+Math.imul(_,Ye)|0,G=G+Math.imul(ie,We)|0,D=D+Math.imul(ie,Ze)|0,D=D+Math.imul(d,We)|0,U=U+Math.imul(d,Ze)|0,G=G+Math.imul(j,Pt)|0,D=D+Math.imul(j,Ct)|0,D=D+Math.imul(Z,Pt)|0,U=U+Math.imul(Z,Ct)|0;var rp=(B+G|0)+((D&8191)<<13)|0;B=(U+(D>>>13)|0)+(rp>>>26)|0,rp&=67108863,G=Math.imul(_e,Be),D=Math.imul(_e,je),D=D+Math.imul(Ce,Be)|0,U=Math.imul(Ce,je),G=G+Math.imul(ke,Fe)|0,D=D+Math.imul(ke,Ue)|0,D=D+Math.imul(Re,Fe)|0,U=U+Math.imul(Re,Ue)|0,G=G+Math.imul(ge,Ve)|0,D=D+Math.imul(ge,Je)|0,D=D+Math.imul(me,Ve)|0,U=U+Math.imul(me,Je)|0,G=G+Math.imul(re,Ge)|0,D=D+Math.imul(re,qe)|0,D=D+Math.imul(he,Ge)|0,U=U+Math.imul(he,qe)|0,G=G+Math.imul(y,He)|0,D=D+Math.imul(y,Ke)|0,D=D+Math.imul(w,He)|0,U=U+Math.imul(w,Ke)|0,G=G+Math.imul(v,ze)|0,D=D+Math.imul(v,Xe)|0,D=D+Math.imul(x,ze)|0,U=U+Math.imul(x,Xe)|0,G=G+Math.imul(z,$e)|0,D=D+Math.imul(z,Ye)|0,D=D+Math.imul(Q,$e)|0,U=U+Math.imul(Q,Ye)|0,G=G+Math.imul(O,We)|0,D=D+Math.imul(O,Ze)|0,D=D+Math.imul(_,We)|0,U=U+Math.imul(_,Ze)|0,G=G+Math.imul(ie,Pt)|0,D=D+Math.imul(ie,Ct)|0,D=D+Math.imul(d,Pt)|0,U=U+Math.imul(d,Ct)|0;var np=(B+G|0)+((D&8191)<<13)|0;B=(U+(D>>>13)|0)+(np>>>26)|0,np&=67108863,G=Math.imul(_e,Fe),D=Math.imul(_e,Ue),D=D+Math.imul(Ce,Fe)|0,U=Math.imul(Ce,Ue),G=G+Math.imul(ke,Ve)|0,D=D+Math.imul(ke,Je)|0,D=D+Math.imul(Re,Ve)|0,U=U+Math.imul(Re,Je)|0,G=G+Math.imul(ge,Ge)|0,D=D+Math.imul(ge,qe)|0,D=D+Math.imul(me,Ge)|0,U=U+Math.imul(me,qe)|0,G=G+Math.imul(re,He)|0,D=D+Math.imul(re,Ke)|0,D=D+Math.imul(he,He)|0,U=U+Math.imul(he,Ke)|0,G=G+Math.imul(y,ze)|0,D=D+Math.imul(y,Xe)|0,D=D+Math.imul(w,ze)|0,U=U+Math.imul(w,Xe)|0,G=G+Math.imul(v,$e)|0,D=D+Math.imul(v,Ye)|0,D=D+Math.imul(x,$e)|0,U=U+Math.imul(x,Ye)|0,G=G+Math.imul(z,We)|0,D=D+Math.imul(z,Ze)|0,D=D+Math.imul(Q,We)|0,U=U+Math.imul(Q,Ze)|0,G=G+Math.imul(O,Pt)|0,D=D+Math.imul(O,Ct)|0,D=D+Math.imul(_,Pt)|0,U=U+Math.imul(_,Ct)|0;var ip=(B+G|0)+((D&8191)<<13)|0;B=(U+(D>>>13)|0)+(ip>>>26)|0,ip&=67108863,G=Math.imul(_e,Ve),D=Math.imul(_e,Je),D=D+Math.imul(Ce,Ve)|0,U=Math.imul(Ce,Je),G=G+Math.imul(ke,Ge)|0,D=D+Math.imul(ke,qe)|0,D=D+Math.imul(Re,Ge)|0,U=U+Math.imul(Re,qe)|0,G=G+Math.imul(ge,He)|0,D=D+Math.imul(ge,Ke)|0,D=D+Math.imul(me,He)|0,U=U+Math.imul(me,Ke)|0,G=G+Math.imul(re,ze)|0,D=D+Math.imul(re,Xe)|0,D=D+Math.imul(he,ze)|0,U=U+Math.imul(he,Xe)|0,G=G+Math.imul(y,$e)|0,D=D+Math.imul(y,Ye)|0,D=D+Math.imul(w,$e)|0,U=U+Math.imul(w,Ye)|0,G=G+Math.imul(v,We)|0,D=D+Math.imul(v,Ze)|0,D=D+Math.imul(x,We)|0,U=U+Math.imul(x,Ze)|0,G=G+Math.imul(z,Pt)|0,D=D+Math.imul(z,Ct)|0,D=D+Math.imul(Q,Pt)|0,U=U+Math.imul(Q,Ct)|0;var op=(B+G|0)+((D&8191)<<13)|0;B=(U+(D>>>13)|0)+(op>>>26)|0,op&=67108863,G=Math.imul(_e,Ge),D=Math.imul(_e,qe),D=D+Math.imul(Ce,Ge)|0,U=Math.imul(Ce,qe),G=G+Math.imul(ke,He)|0,D=D+Math.imul(ke,Ke)|0,D=D+Math.imul(Re,He)|0,U=U+Math.imul(Re,Ke)|0,G=G+Math.imul(ge,ze)|0,D=D+Math.imul(ge,Xe)|0,D=D+Math.imul(me,ze)|0,U=U+Math.imul(me,Xe)|0,G=G+Math.imul(re,$e)|0,D=D+Math.imul(re,Ye)|0,D=D+Math.imul(he,$e)|0,U=U+Math.imul(he,Ye)|0,G=G+Math.imul(y,We)|0,D=D+Math.imul(y,Ze)|0,D=D+Math.imul(w,We)|0,U=U+Math.imul(w,Ze)|0,G=G+Math.imul(v,Pt)|0,D=D+Math.imul(v,Ct)|0,D=D+Math.imul(x,Pt)|0,U=U+Math.imul(x,Ct)|0;var ap=(B+G|0)+((D&8191)<<13)|0;B=(U+(D>>>13)|0)+(ap>>>26)|0,ap&=67108863,G=Math.imul(_e,He),D=Math.imul(_e,Ke),D=D+Math.imul(Ce,He)|0,U=Math.imul(Ce,Ke),G=G+Math.imul(ke,ze)|0,D=D+Math.imul(ke,Xe)|0,D=D+Math.imul(Re,ze)|0,U=U+Math.imul(Re,Xe)|0,G=G+Math.imul(ge,$e)|0,D=D+Math.imul(ge,Ye)|0,D=D+Math.imul(me,$e)|0,U=U+Math.imul(me,Ye)|0,G=G+Math.imul(re,We)|0,D=D+Math.imul(re,Ze)|0,D=D+Math.imul(he,We)|0,U=U+Math.imul(he,Ze)|0,G=G+Math.imul(y,Pt)|0,D=D+Math.imul(y,Ct)|0,D=D+Math.imul(w,Pt)|0,U=U+Math.imul(w,Ct)|0;var sp=(B+G|0)+((D&8191)<<13)|0;B=(U+(D>>>13)|0)+(sp>>>26)|0,sp&=67108863,G=Math.imul(_e,ze),D=Math.imul(_e,Xe),D=D+Math.imul(Ce,ze)|0,U=Math.imul(Ce,Xe),G=G+Math.imul(ke,$e)|0,D=D+Math.imul(ke,Ye)|0,D=D+Math.imul(Re,$e)|0,U=U+Math.imul(Re,Ye)|0,G=G+Math.imul(ge,We)|0,D=D+Math.imul(ge,Ze)|0,D=D+Math.imul(me,We)|0,U=U+Math.imul(me,Ze)|0,G=G+Math.imul(re,Pt)|0,D=D+Math.imul(re,Ct)|0,D=D+Math.imul(he,Pt)|0,U=U+Math.imul(he,Ct)|0;var lp=(B+G|0)+((D&8191)<<13)|0;B=(U+(D>>>13)|0)+(lp>>>26)|0,lp&=67108863,G=Math.imul(_e,$e),D=Math.imul(_e,Ye),D=D+Math.imul(Ce,$e)|0,U=Math.imul(Ce,Ye),G=G+Math.imul(ke,We)|0,D=D+Math.imul(ke,Ze)|0,D=D+Math.imul(Re,We)|0,U=U+Math.imul(Re,Ze)|0,G=G+Math.imul(ge,Pt)|0,D=D+Math.imul(ge,Ct)|0,D=D+Math.imul(me,Pt)|0,U=U+Math.imul(me,Ct)|0;var A9=(B+G|0)+((D&8191)<<13)|0;B=(U+(D>>>13)|0)+(A9>>>26)|0,A9&=67108863,G=Math.imul(_e,We),D=Math.imul(_e,Ze),D=D+Math.imul(Ce,We)|0,U=Math.imul(Ce,Ze),G=G+Math.imul(ke,Pt)|0,D=D+Math.imul(ke,Ct)|0,D=D+Math.imul(Re,Pt)|0,U=U+Math.imul(Re,Ct)|0;var _9=(B+G|0)+((D&8191)<<13)|0;B=(U+(D>>>13)|0)+(_9>>>26)|0,_9&=67108863,G=Math.imul(_e,Pt),D=Math.imul(_e,Ct),D=D+Math.imul(Ce,Pt)|0,U=Math.imul(Ce,Ct);var T9=(B+G|0)+((D&8191)<<13)|0;return B=(U+(D>>>13)|0)+(T9>>>26)|0,T9&=67108863,C[0]=Bi,C[1]=ji,C[2]=Fi,C[3]=Ui,C[4]=Vi,C[5]=Zu,C[6]=Qu,C[7]=ep,C[8]=tp,C[9]=rp,C[10]=np,C[11]=ip,C[12]=op,C[13]=ap,C[14]=sp,C[15]=lp,C[16]=A9,C[17]=_9,C[18]=T9,B!==0&&(C[19]=B,N.length++),N};Math.imul||(V=F);function K(R,S,T){T.negative=S.negative^R.negative,T.length=R.length+S.length;for(var N=0,L=0,I=0;I<T.length-1;I++){var C=L;L=0;for(var B=N&67108863,G=Math.min(I,S.length-1),D=Math.max(0,I-R.length+1);D<=G;D++){var U=I-D,ae=R.words[U]|0,j=S.words[D]|0,Z=ae*j,ne=Z&67108863;C=C+(Z/67108864|0)|0,ne=ne+B|0,B=ne&67108863,C=C+(ne>>>26)|0,L+=C>>>26,C&=67108863}T.words[I]=B,N=C,C=L}return N!==0?T.words[I]=N:T.length--,T._strip()}function $(R,S,T){return K(R,S,T)}a.prototype.mulTo=function(S,T){var N,L=this.length+S.length;return this.length===10&&S.length===10?N=V(this,S,T):L<63?N=F(this,S,T):L<1024?N=K(this,S,T):N=$(this,S,T),N};function Y(R,S){this.x=R,this.y=S}Y.prototype.makeRBT=function(S){for(var T=new Array(S),N=a.prototype._countBits(S)-1,L=0;L<S;L++)T[L]=this.revBin(L,N,S);return T},Y.prototype.revBin=function(S,T,N){if(S===0||S===N-1)return S;for(var L=0,I=0;I<T;I++)L|=(S&1)<<T-I-1,S>>=1;return L},Y.prototype.permute=function(S,T,N,L,I,C){for(var B=0;B<C;B++)L[B]=T[S[B]],I[B]=N[S[B]]},Y.prototype.transform=function(S,T,N,L,I,C){this.permute(C,S,T,N,L,I);for(var B=1;B<I;B<<=1)for(var G=B<<1,D=Math.cos(2*Math.PI/G),U=Math.sin(2*Math.PI/G),ae=0;ae<I;ae+=G)for(var j=D,Z=U,ne=0;ne<B;ne++){var ie=N[ae+ne],d=L[ae+ne],b=N[ae+ne+B],O=L[ae+ne+B],_=j*b-Z*O;O=j*O+Z*b,b=_,N[ae+ne]=ie+b,L[ae+ne]=d+O,N[ae+ne+B]=ie-b,L[ae+ne+B]=d-O,ne!==G&&(_=D*j-U*Z,Z=D*Z+U*j,j=_)}},Y.prototype.guessLen13b=function(S,T){var N=Math.max(T,S)|1,L=N&1,I=0;for(N=N/2|0;N;N=N>>>1)I++;return 1<<I+1+L},Y.prototype.conjugate=function(S,T,N){if(!(N<=1))for(var L=0;L<N/2;L++){var I=S[L];S[L]=S[N-L-1],S[N-L-1]=I,I=T[L],T[L]=-T[N-L-1],T[N-L-1]=-I}},Y.prototype.normalize13b=function(S,T){for(var N=0,L=0;L<T/2;L++){var I=Math.round(S[2*L+1]/T)*8192+Math.round(S[2*L]/T)+N;S[L]=I&67108863,I<67108864?N=0:N=I/67108864|0}return S},Y.prototype.convert13b=function(S,T,N,L){for(var I=0,C=0;C<T;C++)I=I+(S[C]|0),N[2*C]=I&8191,I=I>>>13,N[2*C+1]=I&8191,I=I>>>13;for(C=2*T;C<L;++C)N[C]=0;t(I===0),t((I&-8192)===0)},Y.prototype.stub=function(S){for(var T=new Array(S),N=0;N<S;N++)T[N]=0;return T},Y.prototype.mulp=function(S,T,N){var L=2*this.guessLen13b(S.length,T.length),I=this.makeRBT(L),C=this.stub(L),B=new Array(L),G=new Array(L),D=new Array(L),U=new Array(L),ae=new Array(L),j=new Array(L),Z=N.words;Z.length=L,this.convert13b(S.words,S.length,B,L),this.convert13b(T.words,T.length,U,L),this.transform(B,C,G,D,L,I),this.transform(U,C,ae,j,L,I);for(var ne=0;ne<L;ne++){var ie=G[ne]*ae[ne]-D[ne]*j[ne];D[ne]=G[ne]*j[ne]+D[ne]*ae[ne],G[ne]=ie}return this.conjugate(G,D,L),this.transform(G,D,Z,C,L,I),this.conjugate(Z,C,L),this.normalize13b(Z,L),N.negative=S.negative^T.negative,N.length=S.length+T.length,N._strip()},a.prototype.mul=function(S){var T=new a(null);return T.words=new Array(this.length+S.length),this.mulTo(S,T)},a.prototype.mulf=function(S){var T=new a(null);return T.words=new Array(this.length+S.length),$(this,S,T)},a.prototype.imul=function(S){return this.clone().mulTo(S,this)},a.prototype.imuln=function(S){var T=S<0;T&&(S=-S),t(typeof S=="number"),t(S<67108864);for(var N=0,L=0;L<this.length;L++){var I=(this.words[L]|0)*S,C=(I&67108863)+(N&67108863);N>>=26,N+=I/67108864|0,N+=C>>>26,this.words[L]=C&67108863}return N!==0&&(this.words[L]=N,this.length++),T?this.ineg():this},a.prototype.muln=function(S){return this.clone().imuln(S)},a.prototype.sqr=function(){return this.mul(this)},a.prototype.isqr=function(){return this.imul(this.clone())},a.prototype.pow=function(S){var T=P(S);if(T.length===0)return new a(1);for(var N=this,L=0;L<T.length&&T[L]===0;L++,N=N.sqr());if(++L<T.length)for(var I=N.sqr();L<T.length;L++,I=I.sqr())T[L]!==0&&(N=N.mul(I));return N},a.prototype.iushln=function(S){t(typeof S=="number"&&S>=0);var T=S%26,N=(S-T)/26,L=67108863>>>26-T<<26-T,I;if(T!==0){var C=0;for(I=0;I<this.length;I++){var B=this.words[I]&L,G=(this.words[I]|0)-B<<T;this.words[I]=G|C,C=B>>>26-T}C&&(this.words[I]=C,this.length++)}if(N!==0){for(I=this.length-1;I>=0;I--)this.words[I+N]=this.words[I];for(I=0;I<N;I++)this.words[I]=0;this.length+=N}return this._strip()},a.prototype.ishln=function(S){return t(this.negative===0),this.iushln(S)},a.prototype.iushrn=function(S,T,N){t(typeof S=="number"&&S>=0);var L;T?L=(T-T%26)/26:L=0;var I=S%26,C=Math.min((S-I)/26,this.length),B=67108863^67108863>>>I<<I,G=N;if(L-=C,L=Math.max(0,L),G){for(var D=0;D<C;D++)G.words[D]=this.words[D];G.length=C}if(C!==0)if(this.length>C)for(this.length-=C,D=0;D<this.length;D++)this.words[D]=this.words[D+C];else this.words[0]=0,this.length=1;var U=0;for(D=this.length-1;D>=0&&(U!==0||D>=L);D--){var ae=this.words[D]|0;this.words[D]=U<<26-I|ae>>>I,U=ae&B}return G&&U!==0&&(G.words[G.length++]=U),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},a.prototype.ishrn=function(S,T,N){return t(this.negative===0),this.iushrn(S,T,N)},a.prototype.shln=function(S){return this.clone().ishln(S)},a.prototype.ushln=function(S){return this.clone().iushln(S)},a.prototype.shrn=function(S){return this.clone().ishrn(S)},a.prototype.ushrn=function(S){return this.clone().iushrn(S)},a.prototype.testn=function(S){t(typeof S=="number"&&S>=0);var T=S%26,N=(S-T)/26,L=1<<T;if(this.length<=N)return!1;var I=this.words[N];return!!(I&L)},a.prototype.imaskn=function(S){t(typeof S=="number"&&S>=0);var T=S%26,N=(S-T)/26;if(t(this.negative===0,"imaskn works only with positive numbers"),this.length<=N)return this;if(T!==0&&N++,this.length=Math.min(N,this.length),T!==0){var L=67108863^67108863>>>T<<T;this.words[this.length-1]&=L}return this._strip()},a.prototype.maskn=function(S){return this.clone().imaskn(S)},a.prototype.iaddn=function(S){return t(typeof S=="number"),t(S<67108864),S<0?this.isubn(-S):this.negative!==0?this.length===1&&(this.words[0]|0)<=S?(this.words[0]=S-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(S),this.negative=1,this):this._iaddn(S)},a.prototype._iaddn=function(S){this.words[0]+=S;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},a.prototype.isubn=function(S){if(t(typeof S=="number"),t(S<67108864),S<0)return this.iaddn(-S);if(this.negative!==0)return this.negative=0,this.iaddn(S),this.negative=1,this;if(this.words[0]-=S,this.length===1&&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()},a.prototype.addn=function(S){return this.clone().iaddn(S)},a.prototype.subn=function(S){return this.clone().isubn(S)},a.prototype.iabs=function(){return this.negative=0,this},a.prototype.abs=function(){return this.clone().iabs()},a.prototype._ishlnsubmul=function(S,T,N){var L=S.length+N,I;this._expand(L);var C,B=0;for(I=0;I<S.length;I++){C=(this.words[I+N]|0)+B;var G=(S.words[I]|0)*T;C-=G&67108863,B=(C>>26)-(G/67108864|0),this.words[I+N]=C&67108863}for(;I<this.length-N;I++)C=(this.words[I+N]|0)+B,B=C>>26,this.words[I+N]=C&67108863;if(B===0)return this._strip();for(t(B===-1),B=0,I=0;I<this.length;I++)C=-(this.words[I]|0)+B,B=C>>26,this.words[I]=C&67108863;return this.negative=1,this._strip()},a.prototype._wordDiv=function(S,T){var N=this.length-S.length,L=this.clone(),I=S,C=I.words[I.length-1]|0,B=this._countBits(C);N=26-B,N!==0&&(I=I.ushln(N),L.iushln(N),C=I.words[I.length-1]|0);var G=L.length-I.length,D;if(T!=="mod"){D=new a(null),D.length=G+1,D.words=new Array(D.length);for(var U=0;U<D.length;U++)D.words[U]=0}var ae=L.clone()._ishlnsubmul(I,1,G);ae.negative===0&&(L=ae,D&&(D.words[G]=1));for(var j=G-1;j>=0;j--){var Z=(L.words[I.length+j]|0)*67108864+(L.words[I.length+j-1]|0);for(Z=Math.min(Z/C|0,67108863),L._ishlnsubmul(I,Z,j);L.negative!==0;)Z--,L.negative=0,L._ishlnsubmul(I,1,j),L.isZero()||(L.negative^=1);D&&(D.words[j]=Z)}return D&&D._strip(),L._strip(),T!=="div"&&N!==0&&L.iushrn(N),{div:D||null,mod:L}},a.prototype.divmod=function(S,T,N){if(t(!S.isZero()),this.isZero())return{div:new a(0),mod:new a(0)};var L,I,C;return this.negative!==0&&S.negative===0?(C=this.neg().divmod(S,T),T!=="mod"&&(L=C.div.neg()),T!=="div"&&(I=C.mod.neg(),N&&I.negative!==0&&I.iadd(S)),{div:L,mod:I}):this.negative===0&&S.negative!==0?(C=this.divmod(S.neg(),T),T!=="mod"&&(L=C.div.neg()),{div:L,mod:C.mod}):this.negative&S.negative?(C=this.neg().divmod(S.neg(),T),T!=="div"&&(I=C.mod.neg(),N&&I.negative!==0&&I.isub(S)),{div:C.div,mod:I}):S.length>this.length||this.cmp(S)<0?{div:new a(0),mod:this}:S.length===1?T==="div"?{div:this.divn(S.words[0]),mod:null}:T==="mod"?{div:null,mod:new a(this.modrn(S.words[0]))}:{div:this.divn(S.words[0]),mod:new a(this.modrn(S.words[0]))}:this._wordDiv(S,T)},a.prototype.div=function(S){return this.divmod(S,"div",!1).div},a.prototype.mod=function(S){return this.divmod(S,"mod",!1).mod},a.prototype.umod=function(S){return this.divmod(S,"mod",!0).mod},a.prototype.divRound=function(S){var T=this.divmod(S);if(T.mod.isZero())return T.div;var N=T.div.negative!==0?T.mod.isub(S):T.mod,L=S.ushrn(1),I=S.andln(1),C=N.cmp(L);return C<0||I===1&&C===0?T.div:T.div.negative!==0?T.div.isubn(1):T.div.iaddn(1)},a.prototype.modrn=function(S){var T=S<0;T&&(S=-S),t(S<=67108863);for(var N=(1<<26)%S,L=0,I=this.length-1;I>=0;I--)L=(N*L+(this.words[I]|0))%S;return T?-L:L},a.prototype.modn=function(S){return this.modrn(S)},a.prototype.idivn=function(S){var T=S<0;T&&(S=-S),t(S<=67108863);for(var N=0,L=this.length-1;L>=0;L--){var I=(this.words[L]|0)+N*67108864;this.words[L]=I/S|0,N=I%S}return this._strip(),T?this.ineg():this},a.prototype.divn=function(S){return this.clone().idivn(S)},a.prototype.egcd=function(S){t(S.negative===0),t(!S.isZero());var T=this,N=S.clone();T.negative!==0?T=T.umod(S):T=T.clone();for(var L=new a(1),I=new a(0),C=new a(0),B=new a(1),G=0;T.isEven()&&N.isEven();)T.iushrn(1),N.iushrn(1),++G;for(var D=N.clone(),U=T.clone();!T.isZero();){for(var ae=0,j=1;!(T.words[0]&j)&&ae<26;++ae,j<<=1);if(ae>0)for(T.iushrn(ae);ae-- >0;)(L.isOdd()||I.isOdd())&&(L.iadd(D),I.isub(U)),L.iushrn(1),I.iushrn(1);for(var Z=0,ne=1;!(N.words[0]&ne)&&Z<26;++Z,ne<<=1);if(Z>0)for(N.iushrn(Z);Z-- >0;)(C.isOdd()||B.isOdd())&&(C.iadd(D),B.isub(U)),C.iushrn(1),B.iushrn(1);T.cmp(N)>=0?(T.isub(N),L.isub(C),I.isub(B)):(N.isub(T),C.isub(L),B.isub(I))}return{a:C,b:B,gcd:N.iushln(G)}},a.prototype._invmp=function(S){t(S.negative===0),t(!S.isZero());var T=this,N=S.clone();T.negative!==0?T=T.umod(S):T=T.clone();for(var L=new a(1),I=new a(0),C=N.clone();T.cmpn(1)>0&&N.cmpn(1)>0;){for(var B=0,G=1;!(T.words[0]&G)&&B<26;++B,G<<=1);if(B>0)for(T.iushrn(B);B-- >0;)L.isOdd()&&L.iadd(C),L.iushrn(1);for(var D=0,U=1;!(N.words[0]&U)&&D<26;++D,U<<=1);if(D>0)for(N.iushrn(D);D-- >0;)I.isOdd()&&I.iadd(C),I.iushrn(1);T.cmp(N)>=0?(T.isub(N),L.isub(I)):(N.isub(T),I.isub(L))}var ae;return T.cmpn(1)===0?ae=L:ae=I,ae.cmpn(0)<0&&ae.iadd(S),ae},a.prototype.gcd=function(S){if(this.isZero())return S.abs();if(S.isZero())return this.abs();var T=this.clone(),N=S.clone();T.negative=0,N.negative=0;for(var L=0;T.isEven()&&N.isEven();L++)T.iushrn(1),N.iushrn(1);do{for(;T.isEven();)T.iushrn(1);for(;N.isEven();)N.iushrn(1);var I=T.cmp(N);if(I<0){var C=T;T=N,N=C}else if(I===0||N.cmpn(1)===0)break;T.isub(N)}while(!0);return N.iushln(L)},a.prototype.invm=function(S){return this.egcd(S).a.umod(S)},a.prototype.isEven=function(){return(this.words[0]&1)===0},a.prototype.isOdd=function(){return(this.words[0]&1)===1},a.prototype.andln=function(S){return this.words[0]&S},a.prototype.bincn=function(S){t(typeof S=="number");var T=S%26,N=(S-T)/26,L=1<<T;if(this.length<=N)return this._expand(N+1),this.words[N]|=L,this;for(var I=L,C=N;I!==0&&C<this.length;C++){var B=this.words[C]|0;B+=I,I=B>>>26,B&=67108863,this.words[C]=B}return I!==0&&(this.words[C]=I,this.length++),this},a.prototype.isZero=function(){return this.length===1&&this.words[0]===0},a.prototype.cmpn=function(S){var T=S<0;if(this.negative!==0&&!T)return-1;if(this.negative===0&&T)return 1;this._strip();var N;if(this.length>1)N=1;else{T&&(S=-S),t(S<=67108863,"Number is too big");var L=this.words[0]|0;N=L===S?0:L<S?-1:1}return this.negative!==0?-N|0:N},a.prototype.cmp=function(S){if(this.negative!==0&&S.negative===0)return-1;if(this.negative===0&&S.negative!==0)return 1;var T=this.ucmp(S);return this.negative!==0?-T|0:T},a.prototype.ucmp=function(S){if(this.length>S.length)return 1;if(this.length<S.length)return-1;for(var T=0,N=this.length-1;N>=0;N--){var L=this.words[N]|0,I=S.words[N]|0;if(L!==I){L<I?T=-1:L>I&&(T=1);break}}return T},a.prototype.gtn=function(S){return this.cmpn(S)===1},a.prototype.gt=function(S){return this.cmp(S)===1},a.prototype.gten=function(S){return this.cmpn(S)>=0},a.prototype.gte=function(S){return this.cmp(S)>=0},a.prototype.ltn=function(S){return this.cmpn(S)===-1},a.prototype.lt=function(S){return this.cmp(S)===-1},a.prototype.lten=function(S){return this.cmpn(S)<=0},a.prototype.lte=function(S){return this.cmp(S)<=0},a.prototype.eqn=function(S){return this.cmpn(S)===0},a.prototype.eq=function(S){return this.cmp(S)===0},a.red=function(S){return new E(S)},a.prototype.toRed=function(S){return t(!this.red,"Already a number in reduction context"),t(this.negative===0,"red works only with positives"),S.convertTo(this)._forceRed(S)},a.prototype.fromRed=function(){return t(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},a.prototype._forceRed=function(S){return this.red=S,this},a.prototype.forceRed=function(S){return t(!this.red,"Already a number in reduction context"),this._forceRed(S)},a.prototype.redAdd=function(S){return t(this.red,"redAdd works only with red numbers"),this.red.add(this,S)},a.prototype.redIAdd=function(S){return t(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,S)},a.prototype.redSub=function(S){return t(this.red,"redSub works only with red numbers"),this.red.sub(this,S)},a.prototype.redISub=function(S){return t(this.red,"redISub works only with red numbers"),this.red.isub(this,S)},a.prototype.redShl=function(S){return t(this.red,"redShl works only with red numbers"),this.red.shl(this,S)},a.prototype.redMul=function(S){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,S),this.red.mul(this,S)},a.prototype.redIMul=function(S){return t(this.red,"redMu