@makerdao/multicall
Version:
A blockchain state management library for dapps.
1 lines • 112 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).Multicall={})}(this,(function(t){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function n(t,e){return t(e={exports:{}},e.exports),e.exports}var i=n((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.version="4.0.27"}));r(i);var o=n((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.UNKNOWN_ERROR="UNKNOWN_ERROR",e.NOT_IMPLEMENTED="NOT_IMPLEMENTED",e.MISSING_NEW="MISSING_NEW",e.CALL_EXCEPTION="CALL_EXCEPTION",e.INVALID_ARGUMENT="INVALID_ARGUMENT",e.MISSING_ARGUMENT="MISSING_ARGUMENT",e.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",e.NUMERIC_FAULT="NUMERIC_FAULT",e.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",e.NONCE_EXPIRED="NONCE_EXPIRED",e.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",e.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION";var r=!1,n=!1;function o(t,r,o){if(n)throw Error("unknown error");r||(r=e.UNKNOWN_ERROR),o||(o={});var s=[];Object.keys(o).forEach((function(t){try{s.push(t+"="+JSON.stringify(o[t]))}catch(e){s.push(t+"="+JSON.stringify(""+o[t]))}})),s.push("version="+i.version);var a=t;s.length&&(t+=" ("+s.join(", ")+")");var u=Error(t);throw u.reason=a,u.code=r,Object.keys(o).forEach((function(t){u[t]=o[t]})),u}e.throwError=o,e.checkNew=function(t,r){t instanceof r||o("missing new",e.MISSING_NEW,{name:r.name})},e.checkArgumentCount=function(t,r,n){n||(n=""),r>t&&o("missing argument"+n,e.MISSING_ARGUMENT,{count:t,expectedCount:r}),t>r&&o("too many arguments"+n,e.UNEXPECTED_ARGUMENT,{count:t,expectedCount:r})},e.setCensorship=function(t,i){r&&o("error censorship permanent",e.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),n=!!t,r=!!i},e.checkNormalize=function(){try{if(["NFD","NFC","NFKD","NFKC"].forEach((function(t){try{"test".normalize(t)}catch(e){throw Error("missing "+t)}})),"é"!=="é".normalize("NFD"))throw Error("broken implementation")}catch(t){o("platform missing String.prototype.normalize",e.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:t.message})}};var s={debug:1,default:2,info:2,warn:3,error:4,off:5},a=s.default;function u(t,e){a>s[t]||console.log.apply(console,e)}function h(){for(var t=[],e=0;arguments.length>e;e++)t[e]=arguments[e];u("warn",t)}e.setLogLevel=function(t){var e=s[t];null!=e?a=e:h("invliad log level - "+t)},e.warn=h,e.info=function(){for(var t=[],e=0;arguments.length>e;e++)t[e]=arguments[e];u("info",t)}}));r(o);var s=n((function(t,r){var n=e&&e.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e};Object.defineProperty(r,"__esModule",{value:!0});var i=n(o);function s(t){return!!t.toHexString}function a(t){return t.slice?t:(t.slice=function(){var e=Array.prototype.slice.call(arguments);return a(new Uint8Array(Array.prototype.slice.apply(t,e)))},t)}function u(t){if(!t||parseInt(t.length+"")!=t.length||"string"==typeof t)return!1;for(var e=0;t.length>e;e++){var r=t[e];if(0>r||r>=256||parseInt(r+"")!=r)return!1}return!0}function h(t){if(null==t&&i.throwError("cannot convert null value to array",i.INVALID_ARGUMENT,{arg:"value",value:t}),s(t)&&(t=t.toHexString()),"string"==typeof t){var e=t.match(/^(0x)?[0-9a-fA-F]*$/);e||i.throwError("invalid hexidecimal string",i.INVALID_ARGUMENT,{arg:"value",value:t}),"0x"!==e[1]&&i.throwError("hex string must have 0x prefix",i.INVALID_ARGUMENT,{arg:"value",value:t}),(t=t.substring(2)).length%2&&(t="0"+t);for(var r=[],n=0;t.length>n;n+=2)r.push(parseInt(t.substr(n,2),16));return a(new Uint8Array(r))}return u(t)?a(new Uint8Array(t)):(i.throwError("invalid arrayify value",null,{arg:"value",value:t,type:typeof t}),null)}function l(t){for(var e=[],r=0,n=0;t.length>n;n++){var i=h(t[n]);e.push(i),r+=i.length}var o=new Uint8Array(r),s=0;for(n=0;e.length>n;n++)o.set(e[n],s),s+=e[n].length;return a(o)}function f(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))&&(!e||t.length===2+2*e)}r.isHexable=s,r.isArrayish=u,r.arrayify=h,r.concat=l,r.stripZeros=function(t){var e=h(t);if(0===e.length)return e;for(var r=0;0===e[r];)r++;return r&&(e=e.slice(r)),e},r.padZeros=function(t,e){if((t=h(t)).length>e)throw Error("cannot pad");var r=new Uint8Array(e);return r.set(t,e-t.length),a(r)},r.isHexString=f;function c(t){if(s(t))return t.toHexString();if("number"==typeof t){0>t&&i.throwError("cannot hexlify negative value",i.INVALID_ARGUMENT,{arg:"value",value:t}),9007199254740991>t||i.throwError("out-of-range",i.NUMERIC_FAULT,{operartion:"hexlify",fault:"out-of-safe-range"});for(var e="";t;)e="0123456789abcdef"[15&t]+e,t=Math.floor(t/16);return e.length?(e.length%2&&(e="0"+e),"0x"+e):"0x00"}if("string"==typeof t){var r=t.match(/^(0x)?[0-9a-fA-F]*$/);return r||i.throwError("invalid hexidecimal string",i.INVALID_ARGUMENT,{arg:"value",value:t}),"0x"!==r[1]&&i.throwError("hex string must have 0x prefix",i.INVALID_ARGUMENT,{arg:"value",value:t}),t.length%2&&(t="0x0"+t.substring(2)),t}if(u(t)){for(var n=[],o=0;t.length>o;o++){var a=t[o];n.push("0123456789abcdef"[(240&a)>>4]+"0123456789abcdef"[15&a])}return"0x"+n.join("")}return i.throwError("invalid hexlify value",null,{arg:"value",value:t}),"never"}function d(t,e){for(f(t)||i.throwError("invalid hex string",i.INVALID_ARGUMENT,{arg:"value",value:t});2*e+2>t.length;)t="0x0"+t.substring(2);return t}function p(t){var e,r=0,n="0x",o="0x";if((e=t)&&null!=e.r&&null!=e.s){null==t.v&&null==t.recoveryParam&&i.throwError("at least on of recoveryParam or v must be specified",i.INVALID_ARGUMENT,{argument:"signature",value:t}),n=d(t.r,32),o=d(t.s,32),"string"==typeof(r=t.v)&&(r=parseInt(r,16));var s=t.recoveryParam;null==s&&null!=t.v&&(s=1-r%2),r=27+s}else{var a=h(t);if(65!==a.length)throw Error("invalid signature");n=c(a.slice(0,32)),o=c(a.slice(32,64)),27!==(r=a[64])&&28!==r&&(r=27+r%2)}return{r:n,s:o,recoveryParam:r-27,v:r}}r.hexlify=c,r.hexDataLength=function(t){return f(t)&&t.length%2==0?(t.length-2)/2:null},r.hexDataSlice=function(t,e,r){return f(t)||i.throwError("invalid hex data",i.INVALID_ARGUMENT,{arg:"value",value:t}),t.length%2!=0&&i.throwError("hex data length must be even",i.INVALID_ARGUMENT,{arg:"value",value:t}),e=2+2*e,null!=r?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)},r.hexStripZeros=function(t){for(f(t)||i.throwError("invalid hex string",i.INVALID_ARGUMENT,{arg:"value",value:t});t.length>3&&"0x0"===t.substring(0,3);)t="0x"+t.substring(3);return t},r.hexZeroPad=d,r.splitSignature=p,r.joinSignature=function(t){return c(l([(t=p(t)).r,t.s,t.recoveryParam?"0x1c":"0x1b"]))}}));r(s);var a,u=(a=Object.freeze({__proto__:null,default:{}}))&&a.default||a,h=n((function(t){!function(t,e){function r(t,e){if(!t)throw 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 i(t,e,r){if(i.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 o;"object"==typeof t?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26;try{o=u.Buffer}catch(t){}function s(t,e,r){for(var n=0,i=Math.min(t.length,r),o=e;i>o;o++){var s=t.charCodeAt(o)-48;n<<=4,n|=49>s||s>54?17>s||s>22?15&s:s-17+10:s-49+10}return n}function a(t,e,r,n){for(var i=0,o=Math.min(t.length,r),s=e;o>s;s++){var a=t.charCodeAt(s)-48;i*=n,i+=49>a?17>a?a:a-17+10:a-49+10}return i}i.isBN=function(t){return t instanceof i||null!==t&&"object"==typeof t&&t.constructor.wordSize===i.wordSize&&Array.isArray(t.words)},i.max=function(t,e){return t.cmp(e)>0?t:e},i.min=function(t,e){return 0>t.cmp(e)?t:e},i.prototype._init=function(t,e,n){if("number"==typeof t)return this._initNumber(t,e,n);if("object"==typeof t)return this._initArray(t,e,n);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&36>=e);var i=0;"-"===(t=(""+t).replace(/\s+/g,""))[0]&&i++,16===e?this._parseHex(t,i):this._parseBase(t,e,i),"-"===t[0]&&(this.negative=1),this.strip(),"le"===n&&this._initArray(this.toArray(),e,n)},i.prototype._initNumber=function(t,e,n){0>t&&(this.negative=1,t=-t),67108864>t?(this.words=[67108863&t],this.length=1):4503599627370496>t?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(9007199254740992>t),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),e,n)},i.prototype._initArray=function(t,e,n){if(r("number"==typeof t.length),0>=t.length)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=Array(this.length);for(var i=0;this.length>i;i++)this.words[i]=0;var o,s,a=0;if("be"===n)for(i=t.length-1,o=0;i>=0;i-=3)this.words[o]|=(s=t[i]|t[i-1]<<8|t[i-2]<<16)<<a&67108863,this.words[o+1]=s>>>26-a&67108863,26>(a+=24)||(a-=26,o++);else if("le"===n)for(i=0,o=0;t.length>i;i+=3)this.words[o]|=(s=t[i]|t[i+1]<<8|t[i+2]<<16)<<a&67108863,this.words[o+1]=s>>>26-a&67108863,26>(a+=24)||(a-=26,o++);return this.strip()},i.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=Array(this.length);for(var r=0;this.length>r;r++)this.words[r]=0;var n,i,o=0;for(r=t.length-6,n=0;r>=e;r-=6)i=s(t,r,r+6),this.words[n]|=i<<o&67108863,this.words[n+1]|=i>>>26-o&4194303,26>(o+=24)||(o-=26,n++);r+6!==e&&(i=s(t,e,r+6),this.words[n]|=i<<o&67108863,this.words[n+1]|=i>>>26-o&4194303),this.strip()},i.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;67108863>=i;i*=e)n++;n--,i=i/e|0;for(var o=t.length-r,s=o%n,u=Math.min(o,o-s)+r,h=0,l=r;u>l;l+=n)h=a(t,l,l+n,e),this.imuln(i),67108864>this.words[0]+h?this.words[0]+=h:this._iaddn(h);if(0!==s){var f=1;for(h=a(t,l,t.length,e),l=0;s>l;l++)f*=e;this.imuln(f),67108864>this.words[0]+h?this.words[0]+=h:this._iaddn(h)}},i.prototype.copy=function(t){t.words=Array(this.length);for(var e=0;this.length>e;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},i.prototype.clone=function(){var t=new i(null);return this.copy(t),t},i.prototype._expand=function(t){for(;t>this.length;)this.words[this.length++]=0;return this},i.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var h=["","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],f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function c(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],o=0|e.words[0],s=i*o,a=s/67108864|0;r.words[0]=67108863&s;for(var u=1;n>u;u++){for(var h=a>>>26,l=67108863&a,f=Math.min(u,e.length-1),c=Math.max(0,u-t.length+1);f>=c;c++){h+=(s=(i=0|t.words[u-c|0])*(o=0|e.words[c])+l)/67108864|0,l=67108863&s}r.words[u]=0|l,a=0|h}return 0!==a?r.words[u]=0|a:r.length--,r.strip()}i.prototype.toString=function(t,e){var n;if(e=0|e||1,16===(t=t||10)||"hex"===t){n="";for(var i=0,o=0,s=0;this.length>s;s++){var a=this.words[s],u=(16777215&(a<<i|o)).toString(16);n=0!==(o=a>>>24-i&16777215)||s!==this.length-1?h[6-u.length]+u+n:u+n,26>(i+=2)||(i-=26,s--)}for(0!==o&&(n=o.toString(16)+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(t===(0|t)&&t>=2&&36>=t){var c=l[t],d=f[t];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(t);n=(p=p.idivn(d)).isZero()?m+n:h[c-m.length]+m+n}for(this.isZero()&&(n="0"+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.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&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(t,e){return r(void 0!==o),this.toArrayLike(o,t,e)},i.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},i.prototype.toArrayLike=function(t,e,n){var i=this.byteLength(),o=n||Math.max(1,i);r(o>=i,"byte array longer than desired length"),r(o>0,"Requested array length <= 0"),this.strip();var s,a,u="le"===e,h=new t(o),l=this.clone();if(u){for(a=0;!l.isZero();a++)s=l.andln(255),l.iushrn(8),h[a]=s;for(;o>a;a++)h[a]=0}else{for(a=0;o-i>a;a++)h[a]=0;for(a=0;!l.isZero();a++)s=l.andln(255),l.iushrn(8),h[o-a-1]=s}return h},i.prototype._countBits=Math.clz32?function(t){return 32-Math.clz32(t)}:function(t){var e=t,r=0;return 4096>e||(r+=13,e>>>=13),64>e||(r+=7,e>>>=7),8>e||(r+=4,e>>>=4),2>e||(r+=2,e>>>=2),r+e},i.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},i.prototype.bitLength=function(){var t=this._countBits(this.words[this.length-1]);return 26*(this.length-1)+t},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;this.length>e;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},i.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return 0!==this.negative},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(t){for(;t.length>this.length;)this.words[this.length++]=0;for(var e=0;t.length>e;e++)this.words[e]=this.words[e]|t.words[e];return this.strip()},i.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},i.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},i.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},i.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;e.length>r;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this.strip()},i.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},i.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},i.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},i.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;r.length>n;n++)this.words[n]=e.words[n]^r.words[n];if(this!==e)for(;e.length>n;n++)this.words[n]=e.words[n];return this.length=e.length,this.strip()},i.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},i.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},i.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},i.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),n=t%26;this._expand(e),n>0&&e--;for(var i=0;e>i;i++)this.words[i]=67108863&~this.words[i];return n>0&&(this.words[i]=~this.words[i]&67108863>>26-n),this.strip()},i.prototype.notn=function(t){return this.clone().inotn(t)},i.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var n=t/26|0,i=t%26;return this._expand(n+1),this.words[n]=e?this.words[n]|1<<i:this.words[n]&~(1<<i),this.strip()},i.prototype.iadd=function(t){var e,r,n;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,n=t):(r=t,n=this);for(var i=0,o=0;n.length>o;o++)this.words[o]=67108863&(e=(0|r.words[o])+(0|n.words[o])+i),i=e>>>26;for(;0!==i&&r.length>o;o++)this.words[o]=67108863&(e=(0|r.words[o])+i),i=e>>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;r.length>o;o++)this.words[o]=r.words[o];return this},i.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)},i.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var o=0,s=0;n.length>s;s++)o=(e=(0|r.words[s])-(0|n.words[s])+o)>>26,this.words[s]=67108863&e;for(;0!==o&&r.length>s;s++)o=(e=(0|r.words[s])+o)>>26,this.words[s]=67108863&e;if(0===o&&r.length>s&&r!==this)for(;r.length>s;s++)this.words[s]=r.words[s];return this.length=Math.max(this.length,s),r!==this&&(this.negative=1),this.strip()},i.prototype.sub=function(t){return this.clone().isub(t)};var d=function(t,e,r){var n,i,o,s=t.words,a=e.words,u=r.words,h=0,l=0|s[0],f=8191&l,c=l>>>13,d=0|s[1],p=8191&d,m=d>>>13,v=0|s[2],y=8191&v,g=v>>>13,w=0|s[3],b=8191&w,M=w>>>13,_=0|s[4],E=8191&_,N=_>>>13,A=0|s[5],x=8191&A,C=A>>>13,T=0|s[6],k=8191&T,I=T>>>13,R=0|s[7],F=8191&R,O=R>>>13,S=0|s[8],U=8191&S,P=S>>>13,B=0|s[9],j=8191&B,D=B>>>13,L=0|a[0],G=8191&L,z=L>>>13,V=0|a[1],Z=8191&V,q=V>>>13,H=0|a[2],W=8191&H,$=H>>>13,J=0|a[3],K=8191&J,X=J>>>13,Q=0|a[4],Y=8191&Q,tt=Q>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ut=8191&at,ht=at>>>13,lt=0|a[8],ft=8191<,ct=lt>>>13,dt=0|a[9],pt=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var vt=(h+(n=Math.imul(f,G))|0)+((8191&(i=(i=Math.imul(f,z))+Math.imul(c,G)|0))<<13)|0;h=((o=Math.imul(c,z))+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(p,G),i=(i=Math.imul(p,z))+Math.imul(m,G)|0,o=Math.imul(m,z);var yt=(h+(n=n+Math.imul(f,Z)|0)|0)+((8191&(i=(i=i+Math.imul(f,q)|0)+Math.imul(c,Z)|0))<<13)|0;h=((o=o+Math.imul(c,q)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(y,G),i=(i=Math.imul(y,z))+Math.imul(g,G)|0,o=Math.imul(g,z),n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,q)|0)+Math.imul(m,Z)|0,o=o+Math.imul(m,q)|0;var gt=(h+(n=n+Math.imul(f,W)|0)|0)+((8191&(i=(i=i+Math.imul(f,$)|0)+Math.imul(c,W)|0))<<13)|0;h=((o=o+Math.imul(c,$)|0)+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(b,G),i=(i=Math.imul(b,z))+Math.imul(M,G)|0,o=Math.imul(M,z),n=n+Math.imul(y,Z)|0,i=(i=i+Math.imul(y,q)|0)+Math.imul(g,Z)|0,o=o+Math.imul(g,q)|0,n=n+Math.imul(p,W)|0,i=(i=i+Math.imul(p,$)|0)+Math.imul(m,W)|0,o=o+Math.imul(m,$)|0;var wt=(h+(n=n+Math.imul(f,K)|0)|0)+((8191&(i=(i=i+Math.imul(f,X)|0)+Math.imul(c,K)|0))<<13)|0;h=((o=o+Math.imul(c,X)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(E,G),i=(i=Math.imul(E,z))+Math.imul(N,G)|0,o=Math.imul(N,z),n=n+Math.imul(b,Z)|0,i=(i=i+Math.imul(b,q)|0)+Math.imul(M,Z)|0,o=o+Math.imul(M,q)|0,n=n+Math.imul(y,W)|0,i=(i=i+Math.imul(y,$)|0)+Math.imul(g,W)|0,o=o+Math.imul(g,$)|0,n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,X)|0)+Math.imul(m,K)|0,o=o+Math.imul(m,X)|0;var bt=(h+(n=n+Math.imul(f,Y)|0)|0)+((8191&(i=(i=i+Math.imul(f,tt)|0)+Math.imul(c,Y)|0))<<13)|0;h=((o=o+Math.imul(c,tt)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(x,G),i=(i=Math.imul(x,z))+Math.imul(C,G)|0,o=Math.imul(C,z),n=n+Math.imul(E,Z)|0,i=(i=i+Math.imul(E,q)|0)+Math.imul(N,Z)|0,o=o+Math.imul(N,q)|0,n=n+Math.imul(b,W)|0,i=(i=i+Math.imul(b,$)|0)+Math.imul(M,W)|0,o=o+Math.imul(M,$)|0,n=n+Math.imul(y,K)|0,i=(i=i+Math.imul(y,X)|0)+Math.imul(g,K)|0,o=o+Math.imul(g,X)|0,n=n+Math.imul(p,Y)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(m,Y)|0,o=o+Math.imul(m,tt)|0;var Mt=(h+(n=n+Math.imul(f,rt)|0)|0)+((8191&(i=(i=i+Math.imul(f,nt)|0)+Math.imul(c,rt)|0))<<13)|0;h=((o=o+Math.imul(c,nt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(k,G),i=(i=Math.imul(k,z))+Math.imul(I,G)|0,o=Math.imul(I,z),n=n+Math.imul(x,Z)|0,i=(i=i+Math.imul(x,q)|0)+Math.imul(C,Z)|0,o=o+Math.imul(C,q)|0,n=n+Math.imul(E,W)|0,i=(i=i+Math.imul(E,$)|0)+Math.imul(N,W)|0,o=o+Math.imul(N,$)|0,n=n+Math.imul(b,K)|0,i=(i=i+Math.imul(b,X)|0)+Math.imul(M,K)|0,o=o+Math.imul(M,X)|0,n=n+Math.imul(y,Y)|0,i=(i=i+Math.imul(y,tt)|0)+Math.imul(g,Y)|0,o=o+Math.imul(g,tt)|0,n=n+Math.imul(p,rt)|0,i=(i=i+Math.imul(p,nt)|0)+Math.imul(m,rt)|0,o=o+Math.imul(m,nt)|0;var _t=(h+(n=n+Math.imul(f,ot)|0)|0)+((8191&(i=(i=i+Math.imul(f,st)|0)+Math.imul(c,ot)|0))<<13)|0;h=((o=o+Math.imul(c,st)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(F,G),i=(i=Math.imul(F,z))+Math.imul(O,G)|0,o=Math.imul(O,z),n=n+Math.imul(k,Z)|0,i=(i=i+Math.imul(k,q)|0)+Math.imul(I,Z)|0,o=o+Math.imul(I,q)|0,n=n+Math.imul(x,W)|0,i=(i=i+Math.imul(x,$)|0)+Math.imul(C,W)|0,o=o+Math.imul(C,$)|0,n=n+Math.imul(E,K)|0,i=(i=i+Math.imul(E,X)|0)+Math.imul(N,K)|0,o=o+Math.imul(N,X)|0,n=n+Math.imul(b,Y)|0,i=(i=i+Math.imul(b,tt)|0)+Math.imul(M,Y)|0,o=o+Math.imul(M,tt)|0,n=n+Math.imul(y,rt)|0,i=(i=i+Math.imul(y,nt)|0)+Math.imul(g,rt)|0,o=o+Math.imul(g,nt)|0,n=n+Math.imul(p,ot)|0,i=(i=i+Math.imul(p,st)|0)+Math.imul(m,ot)|0,o=o+Math.imul(m,st)|0;var Et=(h+(n=n+Math.imul(f,ut)|0)|0)+((8191&(i=(i=i+Math.imul(f,ht)|0)+Math.imul(c,ut)|0))<<13)|0;h=((o=o+Math.imul(c,ht)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(U,G),i=(i=Math.imul(U,z))+Math.imul(P,G)|0,o=Math.imul(P,z),n=n+Math.imul(F,Z)|0,i=(i=i+Math.imul(F,q)|0)+Math.imul(O,Z)|0,o=o+Math.imul(O,q)|0,n=n+Math.imul(k,W)|0,i=(i=i+Math.imul(k,$)|0)+Math.imul(I,W)|0,o=o+Math.imul(I,$)|0,n=n+Math.imul(x,K)|0,i=(i=i+Math.imul(x,X)|0)+Math.imul(C,K)|0,o=o+Math.imul(C,X)|0,n=n+Math.imul(E,Y)|0,i=(i=i+Math.imul(E,tt)|0)+Math.imul(N,Y)|0,o=o+Math.imul(N,tt)|0,n=n+Math.imul(b,rt)|0,i=(i=i+Math.imul(b,nt)|0)+Math.imul(M,rt)|0,o=o+Math.imul(M,nt)|0,n=n+Math.imul(y,ot)|0,i=(i=i+Math.imul(y,st)|0)+Math.imul(g,ot)|0,o=o+Math.imul(g,st)|0,n=n+Math.imul(p,ut)|0,i=(i=i+Math.imul(p,ht)|0)+Math.imul(m,ut)|0,o=o+Math.imul(m,ht)|0;var Nt=(h+(n=n+Math.imul(f,ft)|0)|0)+((8191&(i=(i=i+Math.imul(f,ct)|0)+Math.imul(c,ft)|0))<<13)|0;h=((o=o+Math.imul(c,ct)|0)+(i>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,n=Math.imul(j,G),i=(i=Math.imul(j,z))+Math.imul(D,G)|0,o=Math.imul(D,z),n=n+Math.imul(U,Z)|0,i=(i=i+Math.imul(U,q)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,q)|0,n=n+Math.imul(F,W)|0,i=(i=i+Math.imul(F,$)|0)+Math.imul(O,W)|0,o=o+Math.imul(O,$)|0,n=n+Math.imul(k,K)|0,i=(i=i+Math.imul(k,X)|0)+Math.imul(I,K)|0,o=o+Math.imul(I,X)|0,n=n+Math.imul(x,Y)|0,i=(i=i+Math.imul(x,tt)|0)+Math.imul(C,Y)|0,o=o+Math.imul(C,tt)|0,n=n+Math.imul(E,rt)|0,i=(i=i+Math.imul(E,nt)|0)+Math.imul(N,rt)|0,o=o+Math.imul(N,nt)|0,n=n+Math.imul(b,ot)|0,i=(i=i+Math.imul(b,st)|0)+Math.imul(M,ot)|0,o=o+Math.imul(M,st)|0,n=n+Math.imul(y,ut)|0,i=(i=i+Math.imul(y,ht)|0)+Math.imul(g,ut)|0,o=o+Math.imul(g,ht)|0,n=n+Math.imul(p,ft)|0,i=(i=i+Math.imul(p,ct)|0)+Math.imul(m,ft)|0,o=o+Math.imul(m,ct)|0;var At=(h+(n=n+Math.imul(f,pt)|0)|0)+((8191&(i=(i=i+Math.imul(f,mt)|0)+Math.imul(c,pt)|0))<<13)|0;h=((o=o+Math.imul(c,mt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(j,Z),i=(i=Math.imul(j,q))+Math.imul(D,Z)|0,o=Math.imul(D,q),n=n+Math.imul(U,W)|0,i=(i=i+Math.imul(U,$)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,$)|0,n=n+Math.imul(F,K)|0,i=(i=i+Math.imul(F,X)|0)+Math.imul(O,K)|0,o=o+Math.imul(O,X)|0,n=n+Math.imul(k,Y)|0,i=(i=i+Math.imul(k,tt)|0)+Math.imul(I,Y)|0,o=o+Math.imul(I,tt)|0,n=n+Math.imul(x,rt)|0,i=(i=i+Math.imul(x,nt)|0)+Math.imul(C,rt)|0,o=o+Math.imul(C,nt)|0,n=n+Math.imul(E,ot)|0,i=(i=i+Math.imul(E,st)|0)+Math.imul(N,ot)|0,o=o+Math.imul(N,st)|0,n=n+Math.imul(b,ut)|0,i=(i=i+Math.imul(b,ht)|0)+Math.imul(M,ut)|0,o=o+Math.imul(M,ht)|0,n=n+Math.imul(y,ft)|0,i=(i=i+Math.imul(y,ct)|0)+Math.imul(g,ft)|0,o=o+Math.imul(g,ct)|0;var xt=(h+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;h=((o=o+Math.imul(m,mt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(j,W),i=(i=Math.imul(j,$))+Math.imul(D,W)|0,o=Math.imul(D,$),n=n+Math.imul(U,K)|0,i=(i=i+Math.imul(U,X)|0)+Math.imul(P,K)|0,o=o+Math.imul(P,X)|0,n=n+Math.imul(F,Y)|0,i=(i=i+Math.imul(F,tt)|0)+Math.imul(O,Y)|0,o=o+Math.imul(O,tt)|0,n=n+Math.imul(k,rt)|0,i=(i=i+Math.imul(k,nt)|0)+Math.imul(I,rt)|0,o=o+Math.imul(I,nt)|0,n=n+Math.imul(x,ot)|0,i=(i=i+Math.imul(x,st)|0)+Math.imul(C,ot)|0,o=o+Math.imul(C,st)|0,n=n+Math.imul(E,ut)|0,i=(i=i+Math.imul(E,ht)|0)+Math.imul(N,ut)|0,o=o+Math.imul(N,ht)|0,n=n+Math.imul(b,ft)|0,i=(i=i+Math.imul(b,ct)|0)+Math.imul(M,ft)|0,o=o+Math.imul(M,ct)|0;var Ct=(h+(n=n+Math.imul(y,pt)|0)|0)+((8191&(i=(i=i+Math.imul(y,mt)|0)+Math.imul(g,pt)|0))<<13)|0;h=((o=o+Math.imul(g,mt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,n=Math.imul(j,K),i=(i=Math.imul(j,X))+Math.imul(D,K)|0,o=Math.imul(D,X),n=n+Math.imul(U,Y)|0,i=(i=i+Math.imul(U,tt)|0)+Math.imul(P,Y)|0,o=o+Math.imul(P,tt)|0,n=n+Math.imul(F,rt)|0,i=(i=i+Math.imul(F,nt)|0)+Math.imul(O,rt)|0,o=o+Math.imul(O,nt)|0,n=n+Math.imul(k,ot)|0,i=(i=i+Math.imul(k,st)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,st)|0,n=n+Math.imul(x,ut)|0,i=(i=i+Math.imul(x,ht)|0)+Math.imul(C,ut)|0,o=o+Math.imul(C,ht)|0,n=n+Math.imul(E,ft)|0,i=(i=i+Math.imul(E,ct)|0)+Math.imul(N,ft)|0,o=o+Math.imul(N,ct)|0;var Tt=(h+(n=n+Math.imul(b,pt)|0)|0)+((8191&(i=(i=i+Math.imul(b,mt)|0)+Math.imul(M,pt)|0))<<13)|0;h=((o=o+Math.imul(M,mt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(j,Y),i=(i=Math.imul(j,tt))+Math.imul(D,Y)|0,o=Math.imul(D,tt),n=n+Math.imul(U,rt)|0,i=(i=i+Math.imul(U,nt)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,nt)|0,n=n+Math.imul(F,ot)|0,i=(i=i+Math.imul(F,st)|0)+Math.imul(O,ot)|0,o=o+Math.imul(O,st)|0,n=n+Math.imul(k,ut)|0,i=(i=i+Math.imul(k,ht)|0)+Math.imul(I,ut)|0,o=o+Math.imul(I,ht)|0,n=n+Math.imul(x,ft)|0,i=(i=i+Math.imul(x,ct)|0)+Math.imul(C,ft)|0,o=o+Math.imul(C,ct)|0;var kt=(h+(n=n+Math.imul(E,pt)|0)|0)+((8191&(i=(i=i+Math.imul(E,mt)|0)+Math.imul(N,pt)|0))<<13)|0;h=((o=o+Math.imul(N,mt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(j,rt),i=(i=Math.imul(j,nt))+Math.imul(D,rt)|0,o=Math.imul(D,nt),n=n+Math.imul(U,ot)|0,i=(i=i+Math.imul(U,st)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,st)|0,n=n+Math.imul(F,ut)|0,i=(i=i+Math.imul(F,ht)|0)+Math.imul(O,ut)|0,o=o+Math.imul(O,ht)|0,n=n+Math.imul(k,ft)|0,i=(i=i+Math.imul(k,ct)|0)+Math.imul(I,ft)|0,o=o+Math.imul(I,ct)|0;var It=(h+(n=n+Math.imul(x,pt)|0)|0)+((8191&(i=(i=i+Math.imul(x,mt)|0)+Math.imul(C,pt)|0))<<13)|0;h=((o=o+Math.imul(C,mt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(j,ot),i=(i=Math.imul(j,st))+Math.imul(D,ot)|0,o=Math.imul(D,st),n=n+Math.imul(U,ut)|0,i=(i=i+Math.imul(U,ht)|0)+Math.imul(P,ut)|0,o=o+Math.imul(P,ht)|0,n=n+Math.imul(F,ft)|0,i=(i=i+Math.imul(F,ct)|0)+Math.imul(O,ft)|0,o=o+Math.imul(O,ct)|0;var Rt=(h+(n=n+Math.imul(k,pt)|0)|0)+((8191&(i=(i=i+Math.imul(k,mt)|0)+Math.imul(I,pt)|0))<<13)|0;h=((o=o+Math.imul(I,mt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(j,ut),i=(i=Math.imul(j,ht))+Math.imul(D,ut)|0,o=Math.imul(D,ht),n=n+Math.imul(U,ft)|0,i=(i=i+Math.imul(U,ct)|0)+Math.imul(P,ft)|0,o=o+Math.imul(P,ct)|0;var Ft=(h+(n=n+Math.imul(F,pt)|0)|0)+((8191&(i=(i=i+Math.imul(F,mt)|0)+Math.imul(O,pt)|0))<<13)|0;h=((o=o+Math.imul(O,mt)|0)+(i>>>13)|0)+(Ft>>>26)|0,Ft&=67108863,n=Math.imul(j,ft),i=(i=Math.imul(j,ct))+Math.imul(D,ft)|0,o=Math.imul(D,ct);var Ot=(h+(n=n+Math.imul(U,pt)|0)|0)+((8191&(i=(i=i+Math.imul(U,mt)|0)+Math.imul(P,pt)|0))<<13)|0;h=((o=o+Math.imul(P,mt)|0)+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863;var St=(h+(n=Math.imul(j,pt))|0)+((8191&(i=(i=Math.imul(j,mt))+Math.imul(D,pt)|0))<<13)|0;return h=((o=Math.imul(D,mt))+(i>>>13)|0)+(St>>>26)|0,St&=67108863,u[0]=vt,u[1]=yt,u[2]=gt,u[3]=wt,u[4]=bt,u[5]=Mt,u[6]=_t,u[7]=Et,u[8]=Nt,u[9]=At,u[10]=xt,u[11]=Ct,u[12]=Tt,u[13]=kt,u[14]=It,u[15]=Rt,u[16]=Ft,u[17]=Ot,u[18]=St,0!==h&&(u[19]=h,r.length++),r};function p(t,e,r){return(new m).mulp(t,e,r)}function m(t,e){this.x=t,this.y=e}Math.imul||(d=c),i.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?d(this,t,e):63>r?c(this,t,e):1024>r?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;r.length-1>o;o++){var s=i;i=0;for(var a=67108863&n,u=Math.min(o,e.length-1),h=Math.max(0,o-t.length+1);u>=h;h++){var l=(0|t.words[o-h])*(0|e.words[h]),f=67108863&l;a=67108863&(f=f+a|0),i+=(s=(s=s+(l/67108864|0)|0)+(f>>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,t,e):p(this,t,e)},m.prototype.makeRBT=function(t){for(var e=Array(t),r=i.prototype._countBits(t)-1,n=0;t>n;n++)e[n]=this.revBin(n,r,t);return e},m.prototype.revBin=function(t,e,r){if(0===t||t===r-1)return t;for(var n=0,i=0;e>i;i++)n|=(1&t)<<e-i-1,t>>=1;return n},m.prototype.permute=function(t,e,r,n,i,o){for(var s=0;o>s;s++)n[s]=e[t[s]],i[s]=r[t[s]]},m.prototype.transform=function(t,e,r,n,i,o){this.permute(o,t,e,r,n,i);for(var s=1;i>s;s<<=1)for(var a=s<<1,u=Math.cos(2*Math.PI/a),h=Math.sin(2*Math.PI/a),l=0;i>l;l+=a)for(var f=u,c=h,d=0;s>d;d++){var p=r[l+d],m=n[l+d],v=r[l+d+s],y=n[l+d+s],g=f*v-c*y;y=f*y+c*v,r[l+d]=p+(v=g),n[l+d]=m+y,r[l+d+s]=p-v,n[l+d+s]=m-y,d!==a&&(g=u*f-h*c,c=u*c+h*f,f=g)}},m.prototype.guessLen13b=function(t,e){var r=1|Math.max(e,t),n=1&r,i=0;for(r=r/2|0;r;r>>>=1)i++;return 1<<i+1+n},m.prototype.conjugate=function(t,e,r){if(r>1)for(var n=0;r/2>n;n++){var i=t[n];t[n]=t[r-n-1],t[r-n-1]=i,i=e[n],e[n]=-e[r-n-1],e[r-n-1]=-i}},m.prototype.normalize13b=function(t,e){for(var r=0,n=0;e/2>n;n++){var i=8192*Math.round(t[2*n+1]/e)+Math.round(t[2*n]/e)+r;t[n]=67108863&i,r=67108864>i?0:i/67108864|0}return t},m.prototype.convert13b=function(t,e,n,i){for(var o=0,s=0;e>s;s++)n[2*s]=8191&(o+=0|t[s]),n[2*s+1]=8191&(o>>>=13),o>>>=13;for(s=2*e;i>s;++s)n[s]=0;r(0===o),r(0==(-8192&o))},m.prototype.stub=function(t){for(var e=Array(t),r=0;t>r;r++)e[r]=0;return e},m.prototype.mulp=function(t,e,r){var n=2*this.guessLen13b(t.length,e.length),i=this.makeRBT(n),o=this.stub(n),s=Array(n),a=Array(n),u=Array(n),h=Array(n),l=Array(n),f=Array(n),c=r.words;c.length=n,this.convert13b(t.words,t.length,s,n),this.convert13b(e.words,e.length,h,n),this.transform(s,o,a,u,n,i),this.transform(h,o,l,f,n,i);for(var d=0;n>d;d++){var p=a[d]*l[d]-u[d]*f[d];u[d]=a[d]*f[d]+u[d]*l[d],a[d]=p}return this.conjugate(a,u,n),this.transform(a,u,c,o,n,i),this.conjugate(c,o,n),this.normalize13b(c,n),r.negative=t.negative^e.negative,r.length=t.length+e.length,r.strip()},i.prototype.mul=function(t){var e=new i(null);return e.words=Array(this.length+t.length),this.mulTo(t,e)},i.prototype.mulf=function(t){var e=new i(null);return e.words=Array(this.length+t.length),p(this,t,e)},i.prototype.imul=function(t){return this.clone().mulTo(t,this)},i.prototype.imuln=function(t){r("number"==typeof t),r(67108864>t);for(var e=0,n=0;this.length>n;n++){var i=(0|this.words[n])*t,o=(67108863&i)+(67108863&e);e>>=26,e+=i/67108864|0,e+=o>>>26,this.words[n]=67108863&o}return 0!==e&&(this.words[n]=e,this.length++),this},i.prototype.muln=function(t){return this.clone().imuln(t)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(t){var e=function(t){for(var e=Array(t.bitLength()),r=0;e.length>r;r++){var n=r%26;e[r]=(t.words[r/26|0]&1<<n)>>>n}return e}(t);if(0===e.length)return new i(1);for(var r=this,n=0;e.length>n&&0===e[n];n++,r=r.sqr());if(++n<e.length)for(var o=r.sqr();e.length>n;n++,o=o.sqr())0!==e[n]&&(r=r.mul(o));return r},i.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,n=t%26,i=(t-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var s=0;for(e=0;this.length>e;e++){var a=this.words[e]&o;this.words[e]=(0|this.words[e])-a<<n|s,s=a>>>26-n}s&&(this.words[e]=s,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;i>e;e++)this.words[e]=0;this.length+=i}return this.strip()},i.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},i.prototype.iushrn=function(t,e,n){var i;r("number"==typeof t&&t>=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<<o,u=n;if(i=Math.max(0,i-=s),u){for(var h=0;s>h;h++)u.words[h]=this.words[h];u.length=s}if(0===s);else if(this.length>s)for(this.length-=s,h=0;this.length>h;h++)this.words[h]=this.words[h+s];else this.words[0]=0,this.length=1;var l=0;for(h=this.length-1;!(0>h||0===l&&i>h);h--){var f=0|this.words[h];this.words[h]=l<<26-o|f>>>o,l=f&a}return u&&0!==l&&(u.words[u.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(t,e,n){return r(0===this.negative),this.iushrn(t,e,n)},i.prototype.shln=function(t){return this.clone().ishln(t)},i.prototype.ushln=function(t){return this.clone().iushln(t)},i.prototype.shrn=function(t){return this.clone().ishrn(t)},i.prototype.ushrn=function(t){return this.clone().iushrn(t)},i.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26;return this.length>n&&!!(this.words[n]&1<<e)},i.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),n>=this.length)return this;(0!==e&&n++,this.length=Math.min(n,this.length),0!==e)&&(this.words[this.length-1]&=67108863^67108863>>>e<<e);return this.strip()},i.prototype.maskn=function(t){return this.clone().imaskn(t)},i.prototype.iaddn=function(t){return r("number"==typeof t),r(67108864>t),0>t?this.isubn(-t):0!==this.negative?1===this.length&&t>(0|this.words[0])?(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)},i.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;this.length>e&&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},i.prototype.isubn=function(t){if(r("number"==typeof t),r(67108864>t),0>t)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&&0>this.words[0])this.words[0]=-this.words[0],this.negative=1;else for(var e=0;this.length>e&&0>this.words[e];e++)this.words[e]+=67108864,this.words[e+1]-=1;return this.strip()},i.prototype.addn=function(t){return this.clone().iaddn(t)},i.prototype.subn=function(t){return this.clone().isubn(t)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(t,e,n){var i,o;this._expand(t.length+n);var s=0;for(i=0;t.length>i;i++){o=(0|this.words[i+n])+s;var a=(0|t.words[i])*e;s=((o-=67108863&a)>>26)-(a/67108864|0),this.words[i+n]=67108863&o}for(;this.length-n>i;i++)s=(o=(0|this.words[i+n])+s)>>26,this.words[i+n]=67108863&o;if(0===s)return this.strip();for(r(-1===s),s=0,i=0;this.length>i;i++)s=(o=-(0|this.words[i])+s)>>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},i.prototype._wordDiv=function(t,e){var r,n=this.clone(),o=t,s=0|o.words[o.length-1];0!==(r=26-this._countBits(s))&&(o=o.ushln(r),n.iushln(r),s=0|o.words[o.length-1]);var a,u=n.length-o.length;if("mod"!==e){(a=new i(null)).length=u+1,a.words=Array(a.length);for(var h=0;a.length>h;h++)a.words[h]=0}var l=n.clone()._ishlnsubmul(o,1,u);0===l.negative&&(n=l,a&&(a.words[u]=1));for(var f=u-1;f>=0;f--){var c=67108864*(0|n.words[o.length+f])+(0|n.words[o.length+f-1]);for(n._ishlnsubmul(o,c=Math.min(c/s|0,67108863),f);0!==n.negative;)c--,n.negative=0,n._ishlnsubmul(o,1,f),n.isZero()||(n.negative^=1);a&&(a.words[f]=c)}return a&&a.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},i.prototype.divmod=function(t,e,n){return r(!t.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(o=a.div.neg()),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.iadd(t)),{div:o,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(o=a.div.neg()),{div:o,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||0>this.cmp(t)?{div:new i(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new i(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new i(this.modn(t.words[0]))}:this._wordDiv(t,e);var o,s,a},i.prototype.div=function(t){return this.divmod(t,"div",!1).div},i.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},i.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},i.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),o=r.cmp(n);return 0>o||1===i&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},i.prototype.modn=function(t){r(67108863>=t);for(var e=(1<<26)%t,n=0,i=this.length-1;i>=0;i--)n=(e*n+(0|this.words[i]))%t;return n},i.prototype.idivn=function(t){r(67108863>=t);for(var e=0,n=this.length-1;n>=0;n--){var i=(0|this.words[n])+67108864*e;this.words[n]=i/t|0,e=i%t}return this.strip()},i.prototype.divn=function(t){return this.clone().idivn(t)},i.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new i(1),s=new i(0),a=new i(0),u=new i(1),h=0;e.isEven()&&n.isEven();)e.iushrn(1),n.iushrn(1),++h;for(var l=n.clone(),f=e.clone();!e.isZero();){for(var c=0,d=1;0==(e.words[0]&d)&&26>c;++c,d<<=1);if(c>0)for(e.iushrn(c);c-- >0;)(o.isOdd()||s.isOdd())&&(o.iadd(l),s.isub(f)),o.iushrn(1),s.iushrn(1);for(var p=0,m=1;0==(n.words[0]&m)&&26>p;++p,m<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(l),u.isub(f)),a.iushrn(1),u.iushrn(1);0>e.cmp(n)?(n.isub(e),a.isub(o),u.isub(s)):(e.isub(n),o.isub(a),s.isub(u))}return{a:a,b:u,gcd:n.iushln(h)}},i.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,s=new i(1),a=new i(0),u=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(var h=0,l=1;0==(e.words[0]&l)&&26>h;++h,l<<=1);if(h>0)for(e.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var f=0,c=1;0==(n.words[0]&c)&&26>f;++f,c<<=1);if(f>0)for(n.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);0>e.cmp(n)?(n.isub(e),a.isub(s)):(e.isub(n),s.isub(a))}return 0>(o=0===e.cmpn(1)?s:a).cmpn(0)&&o.iadd(t),o},i.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(0>i){var o=e;e=r,r=o}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},i.prototype.invm=function(t){return this.egcd(t).a.umod(t)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(t){return this.words[0]&t},i.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<<e;if(n>=this.length)return this._expand(n+1),this.words[n]|=i,this;for(var o=i,s=n;0!==o&&this.length>s;s++){var a=0|this.words[s];o=(a+=o)>>>26,this.words[s]=a&=67108863}return 0!==o&&(this.words[s]=o,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(t){var e,n=0>t;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)e=1;else{n&&(t=-t),r(67108863>=t,"Number is too big");var i=0|this.words[0];e=i===t?0:t>i?-1:1}return 0!==this.negative?0|-e:e},i.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},i.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(t.length>this.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){i>n?e=-1:n>i&&(e=1);break}}return e},i.prototype.gtn=function(t){return 1===this.cmpn(t)},i.prototype.gt=function(t){return 1===this.cmp(t)},i.prototype.gten=function(t){return this.cmpn(t)>=0},i.prototype.gte=function(t){return this.cmp(t)>=0},i.prototype.ltn=function(t){return-1===this.cmpn(t)},i.prototype.lt=function(t){return-1===this.cmp(t)},i.prototype.lten=function(t){return 0>=this.cmpn(t)},i.prototype.lte=function(t){return 0>=this.cmp(t)},i.prototype.eqn=function(t){return 0===this.cmpn(t)},i.prototype.eq=function(t){return 0===this.cmp(t)},i.red=function(t){return new _(t)},i.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(t){return this.red=t,this},i.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},i.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},i.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},i.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},i.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},i.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},i.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},i.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var v={k256:null,p224:null,p192:null,p25519:null};function y(t,e){this.name=t,this.p=new i(e,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function g(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function w(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function M(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function _(t){if("string"==typeof t){var e=i._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function E(t){_.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(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)}y.prototype._tmp=function(){var t=new i(null);return t.words=Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=this.n>e?-1:r.ucmp(this.p);return 0===n?(r.words[0]=0,r.length=1):n>0?r.isub(this.p):r.strip(),r},y.prototype.split=function(t,e){t.iushrn(this.n,0,e)},y.prototype.imulK=function(t){return t.imul(this.k)},n(g,y),g.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;r>n;n++)e.words[n]=t.words[n];if(e.length=r,9>=t.length)return t.words[0]=0,void(t.length=1);var i=t.words[9];for(e.words[e.length++]=4194303&i,n=10;t.length>n;n++){var o=0|t.words[n];t.words[n-10]=(4194303&o)<<4|i>>>22,i=o}t.words[n-10]=i>>>=22,t.length-=0===i&&t.length>10?10:9},g.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;t.length>r;r++){var n=0|t.words[r];t.words[r]=67108863&(e+=977*n),e=64*n+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(w,y),n(b,y),n(M,y),M.prototype.imulK=function(t){for(var e=0,r=0;t.length>r;r++){var n=19*(0|t.words[r])+e,i=67108863&n;n>>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},i._prime=function(t){if(v[t])return v[t];var e;if("k256"===t)e=new g;else if("p224"===t)e=new w;else if("p192"===t)e=new b;else{if("p25519"!==t)throw Error("Unknown prime "+t);e=new M}return v[t]=e,e},_.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},_.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},_.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},_.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},_.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return 0>r.cmp(this.m)||r.isub(this.m),r._forceRed(this)},_.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return 0>r.cmp(this.m)||r.isub(this.m),r},_.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return 0>r.cmpn(0)&&r.iadd(this.m),r._forceRed(this)},_.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return 0>r.cmpn(0)&&r.iadd(this.m),r},_.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},_.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},_.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},_.prototype.isqr=function(t){return this.imul(t,t.clone())},_.prototype.sqr=function(t){return this.mul(t,t)},_.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var n=this.m.add(new i(1)).iushrn(2);return this.pow(t,n)}for(var o=this.m.subn(1),s=0;!o.isZero()&&0===o.andln(1);)s++,o.iushrn(1);r(!o.isZero());var a=new i(1).toRed(this),u=a.redNeg(),h=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new i(2*l*l).toRed(this);0!==this.pow(l,h).cmp(u);)l.redIAdd(u);for(var f=this.pow(l,o),c=this.pow(t,o.addn(1).iushrn(1)),d=this.pow(t,o),p=s;0!==d.cmp(a);){for(var m=d,v=0;0!==m.cmp(a);v++)m=m.redSqr();r(p>v);var y=this.pow(f,new i(1).iushln(p-v-1));c=c.redMul(y),f=y.redSqr(),d=d.redMul(f),p=v}return c},_.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},_.prototype.pow=function(t,e){if(e.isZero())return new i(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=Array(16);r[0]=new i(1).toRed(this),r[1]=t;for(var n=2;r.length>n;n++)r[n]=this.mul(r[n-1],t);var o=r[0],s=0,a=0,u=e.bitLength()%26;for(0===u&&(u=26),n=e.length-1;n>=0;n--){for(var h=e.words[n],l=u-1;l>=0;l--){var f=h>>l&1;o!==r[0]&&(o=this.sqr(o)),0!==f||0!==s?(s<<=1,s|=f,(4===++a||0===n&&0===l)&&(o=this.mul(o,r[s]),a=0,s=0)):a=0}u=26}return o},_.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},_.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},i.mont=function(t){return new E(t)},n(E,_),E.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},E.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},E.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return 0>i.cmp(this.m)?0>i.cmpn(0)&&(o=i.iadd(this.m)):o=i.isub(this.m),o._forceRed(this)},E.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new i(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(n).iushrn(this.shift),s=o;return 0>o.cmp(this.m)?0>o.cmpn(0)&&(s=o.iadd(this.m)):s=o.isub(this.m),s._forceRed(this)},E.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,e)})),l=n((function(t,r){var n=e&&e.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e};Object.defineProperty(r,"__esModule",{value:!0});var i=n(o);function s(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}function a(t,e){return t&&t.