UNPKG

@lunie/cosmos-keys

Version:

js version of cosmos wallet signer and address generation

15 lines 1.5 MB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("cosmos-keys",[],t):"object"==typeof exports?exports["cosmos-keys"]=t():e["cosmos-keys"]=t()}("undefined"!=typeof self?self:this,(function(){return function(e){var t={};function r(i){if(t[i])return t[i].exports;var n=t[i]={i:i,l:!1,exports:{}};return e[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(i,n,function(t){return e[t]}.bind(null,n));return i},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=203)}([function(e,t,r){"use strict";(function(e){ /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh <http://feross.org> * @license MIT */ var i=r(205),n=r(206),s=r(99);function o(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(o()<t)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=c.prototype:(null===e&&(e=new c(t)),e.length=t),e}function c(e,t,r){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return u(this,e)}return f(this,e,t,r)}function f(e,t,r,i){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,i){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(i||0))throw new RangeError("'length' is out of bounds");t=void 0===r&&void 0===i?new Uint8Array(t):void 0===i?new Uint8Array(t,r):new Uint8Array(t,r,i);c.TYPED_ARRAY_SUPPORT?(e=t).__proto__=c.prototype:e=d(e,t);return e}(e,t,r,i):"string"==typeof t?function(e,t,r){"string"==typeof r&&""!==r||(r="utf8");if(!c.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var i=0|p(t,r),n=(e=a(e,i)).write(t,r);n!==i&&(e=e.slice(0,n));return e}(e,t,r):function(e,t){if(c.isBuffer(t)){var r=0|l(t.length);return 0===(e=a(e,r)).length||t.copy(e,0,0,r),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(i=t.length)!=i?a(e,0):d(e,t);if("Buffer"===t.type&&s(t.data))return d(e,t.data)}var i;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function h(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function u(e,t){if(h(t),e=a(e,t<0?0:0|l(t)),!c.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function d(e,t){var r=t.length<0?0:0|l(t.length);e=a(e,r);for(var i=0;i<r;i+=1)e[i]=255&t[i];return e}function l(e){if(e>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|e}function p(e,t){if(c.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return j(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return L(e).length;default:if(i)return j(e).length;t=(""+t).toLowerCase(),i=!0}}function b(e,t,r){var i=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return B(this,t,r);case"utf8":case"utf-8":return k(this,t,r);case"ascii":return x(this,t,r);case"latin1":case"binary":return I(this,t,r);case"base64":return A(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return z(this,t,r);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}function m(e,t,r){var i=e[t];e[t]=e[r],e[r]=i}function g(e,t,r,i,n){if(0===e.length)return-1;if("string"==typeof r?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=n?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(n)return-1;r=e.length-1}else if(r<0){if(!n)return-1;r=0}if("string"==typeof t&&(t=c.from(t,i)),c.isBuffer(t))return 0===t.length?-1:y(e,t,r,i,n);if("number"==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):y(e,[t],r,i,n);throw new TypeError("val must be string, number or Buffer")}function y(e,t,r,i,n){var s,o=1,a=e.length,c=t.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(e.length<2||t.length<2)return-1;o=2,a/=2,c/=2,r/=2}function f(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(n){var h=-1;for(s=r;s<a;s++)if(f(e,s)===f(t,-1===h?0:s-h)){if(-1===h&&(h=s),s-h+1===c)return h*o}else-1!==h&&(s-=s-h),h=-1}else for(r+c>a&&(r=a-c),s=r;s>=0;s--){for(var u=!0,d=0;d<c;d++)if(f(e,s+d)!==f(t,d)){u=!1;break}if(u)return s}return-1}function v(e,t,r,i){r=Number(r)||0;var n=e.length-r;i?(i=Number(i))>n&&(i=n):i=n;var s=t.length;if(s%2!=0)throw new TypeError("Invalid hex string");i>s/2&&(i=s/2);for(var o=0;o<i;++o){var a=parseInt(t.substr(2*o,2),16);if(isNaN(a))return o;e[r+o]=a}return o}function w(e,t,r,i){return K(j(t,e.length-r),e,r,i)}function S(e,t,r,i){return K(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,i)}function _(e,t,r,i){return S(e,t,r,i)}function E(e,t,r,i){return K(L(t),e,r,i)}function M(e,t,r,i){return K(function(e,t){for(var r,i,n,s=[],o=0;o<e.length&&!((t-=2)<0);++o)r=e.charCodeAt(o),i=r>>8,n=r%256,s.push(n),s.push(i);return s}(t,e.length-r),e,r,i)}function A(e,t,r){return 0===t&&r===e.length?i.fromByteArray(e):i.fromByteArray(e.slice(t,r))}function k(e,t,r){r=Math.min(e.length,r);for(var i=[],n=t;n<r;){var s,o,a,c,f=e[n],h=null,u=f>239?4:f>223?3:f>191?2:1;if(n+u<=r)switch(u){case 1:f<128&&(h=f);break;case 2:128==(192&(s=e[n+1]))&&(c=(31&f)<<6|63&s)>127&&(h=c);break;case 3:s=e[n+1],o=e[n+2],128==(192&s)&&128==(192&o)&&(c=(15&f)<<12|(63&s)<<6|63&o)>2047&&(c<55296||c>57343)&&(h=c);break;case 4:s=e[n+1],o=e[n+2],a=e[n+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(c=(15&f)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&c<1114112&&(h=c)}null===h?(h=65533,u=1):h>65535&&(h-=65536,i.push(h>>>10&1023|55296),h=56320|1023&h),i.push(h),n+=u}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",i=0;for(;i<t;)r+=String.fromCharCode.apply(String,e.slice(i,i+=4096));return r}(i)}t.Buffer=c,t.SlowBuffer=function(e){+e!=e&&(e=0);return c.alloc(+e)},t.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=o(),c.poolSize=8192,c._augment=function(e){return e.__proto__=c.prototype,e},c.from=function(e,t,r){return f(null,e,t,r)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(e,t,r){return function(e,t,r,i){return h(t),t<=0?a(e,t):void 0!==r?"string"==typeof i?a(e,t).fill(r,i):a(e,t).fill(r):a(e,t)}(null,e,t,r)},c.allocUnsafe=function(e){return u(null,e)},c.allocUnsafeSlow=function(e){return u(null,e)},c.isBuffer=function(e){return!(null==e||!e._isBuffer)},c.compare=function(e,t){if(!c.isBuffer(e)||!c.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,i=t.length,n=0,s=Math.min(r,i);n<s;++n)if(e[n]!==t[n]){r=e[n],i=t[n];break}return r<i?-1:i<r?1:0},c.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(e,t){if(!s(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var i=c.allocUnsafe(t),n=0;for(r=0;r<e.length;++r){var o=e[r];if(!c.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(i,n),n+=o.length}return i},c.byteLength=p,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)m(this,t,t+1);return this},c.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)m(this,t,t+3),m(this,t+1,t+2);return this},c.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)m(this,t,t+7),m(this,t+1,t+6),m(this,t+2,t+5),m(this,t+3,t+4);return this},c.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?k(this,0,e):b.apply(this,arguments)},c.prototype.equals=function(e){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===c.compare(this,e)},c.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),"<Buffer "+e+">"},c.prototype.compare=function(e,t,r,i,n){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===i&&(i=0),void 0===n&&(n=this.length),t<0||r>e.length||i<0||n>this.length)throw new RangeError("out of range index");if(i>=n&&t>=r)return 0;if(i>=n)return-1;if(t>=r)return 1;if(this===e)return 0;for(var s=(n>>>=0)-(i>>>=0),o=(r>>>=0)-(t>>>=0),a=Math.min(s,o),f=this.slice(i,n),h=e.slice(t,r),u=0;u<a;++u)if(f[u]!==h[u]){s=f[u],o=h[u];break}return s<o?-1:o<s?1:0},c.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},c.prototype.indexOf=function(e,t,r){return g(this,e,t,r,!0)},c.prototype.lastIndexOf=function(e,t,r){return g(this,e,t,r,!1)},c.prototype.write=function(e,t,r,i){if(void 0===t)i="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)i=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(r)?(r|=0,void 0===i&&(i="utf8")):(i=r,r=void 0)}var n=this.length-t;if((void 0===r||r>n)&&(r=n),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var s=!1;;)switch(i){case"hex":return v(this,e,t,r);case"utf8":case"utf-8":return w(this,e,t,r);case"ascii":return S(this,e,t,r);case"latin1":case"binary":return _(this,e,t,r);case"base64":return E(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,e,t,r);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function x(e,t,r){var i="";r=Math.min(e.length,r);for(var n=t;n<r;++n)i+=String.fromCharCode(127&e[n]);return i}function I(e,t,r){var i="";r=Math.min(e.length,r);for(var n=t;n<r;++n)i+=String.fromCharCode(e[n]);return i}function B(e,t,r){var i=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>i)&&(r=i);for(var n="",s=t;s<r;++s)n+=D(e[s]);return n}function z(e,t,r){for(var i=e.slice(t,r),n="",s=0;s<i.length;s+=2)n+=String.fromCharCode(i[s]+256*i[s+1]);return n}function R(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function P(e,t,r,i,n,s){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||t<s)throw new RangeError('"value" argument is out of bounds');if(r+i>e.length)throw new RangeError("Index out of range")}function N(e,t,r,i){t<0&&(t=65535+t+1);for(var n=0,s=Math.min(e.length-r,2);n<s;++n)e[r+n]=(t&255<<8*(i?n:1-n))>>>8*(i?n:1-n)}function q(e,t,r,i){t<0&&(t=4294967295+t+1);for(var n=0,s=Math.min(e.length-r,4);n<s;++n)e[r+n]=t>>>8*(i?n:3-n)&255}function C(e,t,r,i,n,s){if(r+i>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function O(e,t,r,i,s){return s||C(e,0,r,4),n.write(e,t,r,i,23,4),r+4}function T(e,t,r,i,s){return s||C(e,0,r,8),n.write(e,t,r,i,52,8),r+8}c.prototype.slice=function(e,t){var r,i=this.length;if((e=~~e)<0?(e+=i)<0&&(e=0):e>i&&(e=i),(t=void 0===t?i:~~t)<0?(t+=i)<0&&(t=0):t>i&&(t=i),t<e&&(t=e),c.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=c.prototype;else{var n=t-e;r=new c(n,void 0);for(var s=0;s<n;++s)r[s]=this[s+e]}return r},c.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||R(e,t,this.length);for(var i=this[e],n=1,s=0;++s<t&&(n*=256);)i+=this[e+s]*n;return i},c.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||R(e,t,this.length);for(var i=this[e+--t],n=1;t>0&&(n*=256);)i+=this[e+--t]*n;return i},c.prototype.readUInt8=function(e,t){return t||R(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||R(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||R(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||R(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return t||R(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||R(e,t,this.length);for(var i=this[e],n=1,s=0;++s<t&&(n*=256);)i+=this[e+s]*n;return i>=(n*=128)&&(i-=Math.pow(2,8*t)),i},c.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||R(e,t,this.length);for(var i=t,n=1,s=this[e+--i];i>0&&(n*=256);)s+=this[e+--i]*n;return s>=(n*=128)&&(s-=Math.pow(2,8*t)),s},c.prototype.readInt8=function(e,t){return t||R(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||R(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(e,t){t||R(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(e,t){return t||R(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return t||R(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return t||R(e,4,this.length),n.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||R(e,4,this.length),n.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||R(e,8,this.length),n.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||R(e,8,this.length),n.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,r,i){(e=+e,t|=0,r|=0,i)||P(this,e,t,r,Math.pow(2,8*r)-1,0);var n=1,s=0;for(this[t]=255&e;++s<r&&(n*=256);)this[t+s]=e/n&255;return t+r},c.prototype.writeUIntBE=function(e,t,r,i){(e=+e,t|=0,r|=0,i)||P(this,e,t,r,Math.pow(2,8*r)-1,0);var n=r-1,s=1;for(this[t+n]=255&e;--n>=0&&(s*=256);)this[t+n]=e/s&255;return t+r},c.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,1,255,0),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):N(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):N(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):q(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):q(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,r,i){if(e=+e,t|=0,!i){var n=Math.pow(2,8*r-1);P(this,e,t,r,n-1,-n)}var s=0,o=1,a=0;for(this[t]=255&e;++s<r&&(o*=256);)e<0&&0===a&&0!==this[t+s-1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+r},c.prototype.writeIntBE=function(e,t,r,i){if(e=+e,t|=0,!i){var n=Math.pow(2,8*r-1);P(this,e,t,r,n-1,-n)}var s=r-1,o=1,a=0;for(this[t+s]=255&e;--s>=0&&(o*=256);)e<0&&0===a&&0!==this[t+s+1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+r},c.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,1,127,-128),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):N(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):N(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):q(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):q(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,r){return O(this,e,t,!0,r)},c.prototype.writeFloatBE=function(e,t,r){return O(this,e,t,!1,r)},c.prototype.writeDoubleLE=function(e,t,r){return T(this,e,t,!0,r)},c.prototype.writeDoubleBE=function(e,t,r){return T(this,e,t,!1,r)},c.prototype.copy=function(e,t,r,i){if(r||(r=0),i||0===i||(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i<r&&(i=r),i===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t<i-r&&(i=e.length-t+r);var n,s=i-r;if(this===e&&r<t&&t<i)for(n=s-1;n>=0;--n)e[n+t]=this[n+r];else if(s<1e3||!c.TYPED_ARRAY_SUPPORT)for(n=0;n<s;++n)e[n+t]=this[n+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+s),t);return s},c.prototype.fill=function(e,t,r,i){if("string"==typeof e){if("string"==typeof t?(i=t,t=0,r=this.length):"string"==typeof r&&(i=r,r=this.length),1===e.length){var n=e.charCodeAt(0);n<256&&(e=n)}if(void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!c.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var s;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(s=t;s<r;++s)this[s]=e;else{var o=c.isBuffer(e)?e:j(new c(e,i).toString()),a=o.length;for(s=0;s<r-t;++s)this[s+t]=o[s%a]}return this};var U=/[^+\/0-9A-Za-z-_]/g;function D(e){return e<16?"0"+e.toString(16):e.toString(16)}function j(e,t){var r;t=t||1/0;for(var i=e.length,n=null,s=[],o=0;o<i;++o){if((r=e.charCodeAt(o))>55295&&r<57344){if(!n){if(r>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===i){(t-=3)>-1&&s.push(239,191,189);continue}n=r;continue}if(r<56320){(t-=3)>-1&&s.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&(t-=3)>-1&&s.push(239,191,189);if(n=null,r<128){if((t-=1)<0)break;s.push(r)}else if(r<2048){if((t-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function L(e){return i.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(U,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function K(e,t,r,i){for(var n=0;n<i&&!(n+r>=t.length||n>=e.length);++n)t[n+r]=e[n];return n}}).call(this,r(8))},function(e,t,r){"use strict"; /*! * assert.js - assert for bcrypto * Copyright (c) 2020, Christopher Jeffrey (MIT License). * https://github.com/bcoin-org/bcrypto */e.exports=function e(t,r){if(!t){const t=new Error(r||"Assertion failed");throw Error.captureStackTrace&&Error.captureStackTrace(t,e),t}}},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}},function(e,t,r){ /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */ var i=r(0),n=i.Buffer;function s(e,t){for(var r in e)t[r]=e[r]}function o(e,t,r){return n(e,t,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=i:(s(i,t),t.Buffer=o),o.prototype=Object.create(n.prototype),s(n,o),o.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return n(e,t,r)},o.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var i=n(e);return void 0!==t?"string"==typeof r?i.fill(t,r):i.fill(t):i.fill(0),i},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i.SlowBuffer(e)}},function(e,t,r){(function(t){var i;e.exports=(i=i||function(e,i){var n;if("undefined"!=typeof window&&window.crypto&&(n=window.crypto),!n&&"undefined"!=typeof window&&window.msCrypto&&(n=window.msCrypto),!n&&void 0!==t&&t.crypto&&(n=t.crypto),!n)try{n=r(172)}catch(e){}var s=function(){if(n){if("function"==typeof n.getRandomValues)try{return n.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof n.randomBytes)try{return n.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),a={},c=a.lib={},f=c.Base={extend:function(e){var t=o(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},h=c.WordArray=f.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||d).stringify(this)},concat:function(e){var t=this.words,r=e.words,i=this.sigBytes,n=e.sigBytes;if(this.clamp(),i%4)for(var s=0;s<n;s++){var o=r[s>>>2]>>>24-s%4*8&255;t[i+s>>>2]|=o<<24-(i+s)%4*8}else for(s=0;s<n;s+=4)t[i+s>>>2]=r[s>>>2];return this.sigBytes+=n,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=f.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],r=0;r<e;r+=4)t.push(s());return new h.init(t,e)}}),u=a.enc={},d=u.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,i=[],n=0;n<r;n++){var s=t[n>>>2]>>>24-n%4*8&255;i.push((s>>>4).toString(16)),i.push((15&s).toString(16))}return i.join("")},parse:function(e){for(var t=e.length,r=[],i=0;i<t;i+=2)r[i>>>3]|=parseInt(e.substr(i,2),16)<<24-i%8*4;return new h.init(r,t/2)}},l=u.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,i=[],n=0;n<r;n++){var s=t[n>>>2]>>>24-n%4*8&255;i.push(String.fromCharCode(s))}return i.join("")},parse:function(e){for(var t=e.length,r=[],i=0;i<t;i++)r[i>>>2]|=(255&e.charCodeAt(i))<<24-i%4*8;return new h.init(r,t)}},p=u.Utf8={stringify:function(e){try{return decodeURIComponent(escape(l.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return l.parse(unescape(encodeURIComponent(e)))}},b=c.BufferedBlockAlgorithm=f.extend({reset:function(){this._data=new h.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=p.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r,i=this._data,n=i.words,s=i.sigBytes,o=this.blockSize,a=s/(4*o),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,f=e.min(4*c,s);if(c){for(var u=0;u<c;u+=o)this._doProcessBlock(n,u);r=n.splice(0,c),i.sigBytes-=f}return new h.init(r,f)},clone:function(){var e=f.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),m=(c.Hasher=b.extend({cfg:f.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){b.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new m.HMAC.init(e,r).finalize(t)}}}),a.algo={});return a}(Math),i)}).call(this,r(8))},function(e,t){var r,i,n=e.exports={};function s(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(e){if(r===setTimeout)return setTimeout(e,0);if((r===s||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:s}catch(e){r=s}try{i="function"==typeof clearTimeout?clearTimeout:o}catch(e){i=o}}();var c,f=[],h=!1,u=-1;function d(){h&&c&&(h=!1,c.length?f=c.concat(f):u=-1,f.length&&l())}function l(){if(!h){var e=a(d);h=!0;for(var t=f.length;t;){for(c=f,f=[];++u<t;)c&&c[u].run();u=-1,t=f.length}c=null,h=!1,function(e){if(i===clearTimeout)return clearTimeout(e);if((i===o||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(e);try{i(e)}catch(t){try{return i.call(null,e)}catch(t){return i.call(this,e)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function b(){}n.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];f.push(new p(e,t)),1!==f.length||h||a(l)},p.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=b,n.addListener=b,n.once=b,n.off=b,n.removeListener=b,n.removeAllListeners=b,n.emit=b,n.prependListener=b,n.prependOnceListener=b,n.listeners=function(e){return[]},n.binding=function(e){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(e){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},function(e,t,r){(function(e){!function(e,t){"use strict";function i(e,t){if(!e)throw new Error(t||"Assertion failed")}function n(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function s(e,t,r){if(s.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var o;"object"==typeof e?e.exports=s:t.BN=s,s.BN=s,s.wordSize=26;try{o=r(245).Buffer}catch(e){}function a(e,t,r){for(var i=0,n=Math.min(e.length,r),s=t;s<n;s++){var o=e.charCodeAt(s)-48;i<<=4,i|=o>=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return i}function c(e,t,r,i){for(var n=0,s=Math.min(e.length,r),o=t;o<s;o++){var a=e.charCodeAt(o)-48;n*=i,n+=a>=49?a-49+10:a>=17?a-17+10:a}return n}s.isBN=function(e){return e instanceof s||null!==e&&"object"==typeof e&&e.constructor.wordSize===s.wordSize&&Array.isArray(e.words)},s.max=function(e,t){return e.cmp(t)>0?e:t},s.min=function(e,t){return e.cmp(t)<0?e:t},s.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),i(t===(0|t)&&t>=2&&t<=36);var n=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&n++,16===t?this._parseHex(e,n):this._parseBase(e,t,n),"-"===e[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),t,r)},s.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(i(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},s.prototype._initArray=function(e,t,r){if(i("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var s,o,a=0;if("be"===r)for(n=e.length-1,s=0;n>=0;n-=3)o=e[n]|e[n-1]<<8|e[n-2]<<16,this.words[s]|=o<<a&67108863,this.words[s+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);else if("le"===r)for(n=0,s=0;n<e.length;n+=3)o=e[n]|e[n+1]<<8|e[n+2]<<16,this.words[s]|=o<<a&67108863,this.words[s+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);return this.strip()},s.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var i,n,s=0;for(r=e.length-6,i=0;r>=t;r-=6)n=a(e,r,r+6),this.words[i]|=n<<s&67108863,this.words[i+1]|=n>>>26-s&4194303,(s+=24)>=26&&(s-=26,i++);r+6!==t&&(n=a(e,t,r+6),this.words[i]|=n<<s&67108863,this.words[i+1]|=n>>>26-s&4194303),this.strip()},s.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=t)i++;i--,n=n/t|0;for(var s=e.length-r,o=s%i,a=Math.min(s,s-o)+r,f=0,h=r;h<a;h+=i)f=c(e,h,h+i,t),this.imuln(n),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f);if(0!==o){var u=1;for(f=c(e,h,e.length,t),h=0;h<o;h++)u*=t;this.imuln(u),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f)}},s.prototype.copy=function(e){e.words=new Array(this.length);for(var t=0;t<this.length;t++)e.words[t]=this.words[t];e.length=this.length,e.negative=this.negative,e.red=this.red},s.prototype.clone=function(){var e=new s(null);return this.copy(e),e},s.prototype._expand=function(e){for(;this.length<e;)this.words[this.length++]=0;return this},s.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},s.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},s.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var f=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],h=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],u=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function d(e,t,r){r.negative=t.negative^e.negative;var i=e.length+t.length|0;r.length=i,i=i-1|0;var n=0|e.words[0],s=0|t.words[0],o=n*s,a=67108863&o,c=o/67108864|0;r.words[0]=a;for(var f=1;f<i;f++){for(var h=c>>>26,u=67108863&c,d=Math.min(f,t.length-1),l=Math.max(0,f-e.length+1);l<=d;l++){var p=f-l|0;h+=(o=(n=0|e.words[p])*(s=0|t.words[l])+u)/67108864|0,u=67108863&o}r.words[f]=0|u,c=0|h}return 0!==c?r.words[f]=0|c:r.length--,r.strip()}s.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var n=0,s=0,o=0;o<this.length;o++){var a=this.words[o],c=(16777215&(a<<n|s)).toString(16);r=0!==(s=a>>>24-n&16777215)||o!==this.length-1?f[6-c.length]+c+r:c+r,(n+=2)>=26&&(n-=26,o--)}for(0!==s&&(r=s.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var d=h[e],l=u[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(l).toString(e);r=(p=p.idivn(l)).isZero()?b+r:f[d-b.length]+b+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}i(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},s.prototype.toJSON=function(){return this.toString(16)},s.prototype.toBuffer=function(e,t){return i(void 0!==o),this.toArrayLike(o,e,t)},s.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},s.prototype.toArrayLike=function(e,t,r){var n=this.byteLength(),s=r||Math.max(1,n);i(n<=s,"byte array longer than desired length"),i(s>0,"Requested array length <= 0"),this.strip();var o,a,c="le"===t,f=new e(s),h=this.clone();if(c){for(a=0;!h.isZero();a++)o=h.andln(255),h.iushrn(8),f[a]=o;for(;a<s;a++)f[a]=0}else{for(a=0;a<s-n;a++)f[a]=0;for(a=0;!h.isZero();a++)o=h.andln(255),h.iushrn(8),f[s-a-1]=o}return f},Math.clz32?s.prototype._countBits=function(e){return 32-Math.clz32(e)}:s.prototype._countBits=function(e){var t=e,r=0;return t>=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},s.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},s.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;t<this.length;t++){var r=this._zeroBits(this.words[t]);if(e+=r,26!==r)break}return e},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(e){return 0!==this.negative?this.abs().inotn(e).iaddn(1):this.clone()},s.prototype.fromTwos=function(e){return this.testn(e-1)?this.notn(e).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return 0!==this.negative},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.prototype.iuor=function(e){for(;this.length<e.length;)this.words[this.length++]=0;for(var t=0;t<e.length;t++)this.words[t]=this.words[t]|e.words[t];return this.strip()},s.prototype.ior=function(e){return i(0==(this.negative|e.negative)),this.iuor(e)},s.prototype.or=function(e){return this.length>e.length?this.clone().ior(e):e.clone().ior(this)},s.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},s.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;r<t.length;r++)this.words[r]=this.words[r]&e.words[r];return this.length=t.length,this.strip()},s.prototype.iand=function(e){return i(0==(this.negative|e.negative)),this.iuand(e)},s.prototype.and=function(e){return this.length>e.length?this.clone().iand(e):e.clone().iand(this)},s.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},s.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var i=0;i<r.length;i++)this.words[i]=t.words[i]^r.words[i];if(this!==t)for(;i<t.length;i++)this.words[i]=t.words[i];return this.length=t.length,this.strip()},s.prototype.ixor=function(e){return i(0==(this.negative|e.negative)),this.iuxor(e)},s.prototype.xor=function(e){return this.length>e.length?this.clone().ixor(e):e.clone().ixor(this)},s.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},s.prototype.inotn=function(e){i("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var n=0;n<t;n++)this.words[n]=67108863&~this.words[n];return r>0&&(this.words[n]=~this.words[n]&67108863>>26-r),this.strip()},s.prototype.notn=function(e){return this.clone().inotn(e)},s.prototype.setn=function(e,t){i("number"==typeof e&&e>=0);var r=e/26|0,n=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<<n:this.words[r]&~(1<<n),this.strip()},s.prototype.iadd=function(e){var t,r,i;if(0!==this.negative&&0===e.negative)return this.negative=0,t=this.isub(e),this.negative^=1,this._normSign();if(0===this.negative&&0!==e.negative)return e.negative=0,t=this.isub(e),e.negative=1,t._normSign();this.length>e.length?(r=this,i=e):(r=e,i=this);for(var n=0,s=0;s<i.length;s++)t=(0|r.words[s])+(0|i.words[s])+n,this.words[s]=67108863&t,n=t>>>26;for(;0!==n&&s<r.length;s++)t=(0|r.words[s])+n,this.words[s]=67108863&t,n=t>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this},s.prototype.add=function(e){var t;return 0!==e.negative&&0===this.negative?(e.negative=0,t=this.sub(e),e.negative^=1,t):0===e.negative&&0!==this.negative?(this.negative=0,t=e.sub(this),this.negative=1,t):this.length>e.length?this.clone().iadd(e):e.clone().iadd(this)},s.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,i,n=this.cmp(e);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=e):(r=e,i=this);for(var s=0,o=0;o<i.length;o++)s=(t=(0|r.words[o])-(0|i.words[o])+s)>>26,this.words[o]=67108863&t;for(;0!==s&&o<r.length;o++)s=(t=(0|r.words[o])+s)>>26,this.words[o]=67108863&t;if(0===s&&o<r.length&&r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this.length=Math.max(this.length,o),r!==this&&(this.negative=1),this.strip()},s.prototype.sub=function(e){return this.clone().isub(e)};var l=function(e,t,r){var i,n,s,o=e.words,a=t.words,c=r.words,f=0,h=0|o[0],u=8191&h,d=h>>>13,l=0|o[1],p=8191&l,b=l>>>13,m=0|o[2],g=8191&m,y=m>>>13,v=0|o[3],w=8191&v,S=v>>>13,_=0|o[4],E=8191&_,M=_>>>13,A=0|o[5],k=8191&A,x=A>>>13,I=0|o[6],B=8191&I,z=I>>>13,R=0|o[7],P=8191&R,N=R>>>13,q=0|o[8],C=8191&q,O=q>>>13,T=0|o[9],U=8191&T,D=T>>>13,j=0|a[0],L=8191&j,K=j>>>13,H=0|a[1],F=8191&H,V=H>>>13,J=0|a[2],Z=8191&J,G=J>>>13,Y=0|a[3],W=8191&Y,X=Y>>>13,$=0|a[4],Q=8191&$,ee=$>>>13,te=0|a[5],re=8191&te,ie=te>>>13,ne=0|a[6],se=8191&ne,oe=ne>>>13,ae=0|a[7],ce=8191&ae,fe=ae>>>13,he=0|a[8],ue=8191&he,de=he>>>13,le=0|a[9],pe=8191&le,be=le>>>13;r.negative=e.negative^t.negative,r.length=19;var me=(f+(i=Math.imul(u,L))|0)+((8191&(n=(n=Math.imul(u,K))+Math.imul(d,L)|0))<<13)|0;f=((s=Math.imul(d,K))+(n>>>13)|0)+(me>>>26)|0,me&=67108863,i=Math.imul(p,L),n=(n=Math.imul(p,K))+Math.imul(b,L)|0,s=Math.imul(b,K);var ge=(f+(i=i+Math.imul(u,F)|0)|0)+((8191&(n=(n=n+Math.imul(u,V)|0)+Math.imul(d,F)|0))<<13)|0;f=((s=s+Math.imul(d,V)|0)+(n>>>13)|0)+(ge>>>26)|0,ge&=67108863,i=Math.imul(g,L),n=(n=Math.imul(g,K))+Math.imul(y,L)|0,s=Math.imul(y,K),i=i+Math.imul(p,F)|0,n=(n=n+Math.imul(p,V)|0)+Math.imul(b,F)|0,s=s+Math.imul(b,V)|0;var ye=(f+(i=i+Math.imul(u,Z)|0)|0)+((8191&(n=(n=n+Math.imul(u,G)|0)+Math.imul(d,Z)|0))<<13)|0;f=((s=s+Math.imul(d,G)|0)+(n>>>13)|0)+(ye>>>26)|0,ye&=67108863,i=Math.imul(w,L),n=(n=Math.imul(w,K))+Math.imul(S,L)|0,s=Math.imul(S,K),i=i+Math.imul(g,F)|0,n=(n=n+Math.imul(g,V)|0)+Math.imul(y,F)|0,s=s+Math.imul(y,V)|0,i=i+Math.imul(p,Z)|0,n=(n=n+Math.imul(p,G)|0)+Math.imul(b,Z)|0,s=s+Math.imul(b,G)|0;var ve=(f+(i=i+Math.imul(u,W)|0)|0)+((8191&(n=(n=n+Math.imul(u,X)|0)+Math.imul(d,W)|0))<<13)|0;f=((s=s+Math.imul(d,X)|0)+(n>>>13)|0)+(ve>>>26)|0,ve&=67108863,i=Math.imul(E,L),n=(n=Math.imul(E,K))+Math.imul(M,L)|0,s=Math.imul(M,K),i=i+Math.imul(w,F)|0,n=(n=n+Math.imul(w,V)|0)+Math.imul(S,F)|0,s=s+Math.imul(S,V)|0,i=i+Math.imul(g,Z)|0,n=(n=n+Math.imul(g,G)|0)+Math.imul(y,Z)|0,s=s+Math.imul(y,G)|0,i=i+Math.imul(p,W)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(b,W)|0,s=s+Math.imul(b,X)|0;var we=(f+(i=i+Math.imul(u,Q)|0)|0)+((8191&(n=(n=n+Math.imul(u,ee)|0)+Math.imul(d,Q)|0))<<13)|0;f=((s=s+Math.imul(d,ee)|0)+(n>>>13)|0)+(we>>>26)|0,we&=67108863,i=Math.imul(k,L),n=(n=Math.imul(k,K))+Math.imul(x,L)|0,s=Math.imul(x,K),i=i+Math.imul(E,F)|0,n=(n=n+Math.imul(E,V)|0)+Math.imul(M,F)|0,s=s+Math.imul(M,V)|0,i=i+Math.imul(w,Z)|0,n=(n=n+Math.imul(w,G)|0)+Math.imul(S,Z)|0,s=s+Math.imul(S,G)|0,i=i+Math.imul(g,W)|0,n=(n=n+Math.imul(g,X)|0)+Math.imul(y,W)|0,s=s+Math.imul(y,X)|0,i=i+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,ee)|0)+Math.imul(b,Q)|0,s=s+Math.imul(b,ee)|0;var Se=(f+(i=i+Math.imul(u,re)|0)|0)+((8191&(n=(n=n+Math.imul(u,ie)|0)+Math.imul(d,re)|0))<<13)|0;f=((s=s+Math.imul(d,ie)|0)+(n>>>13)|0)+(Se>>>26)|0,Se&=67108863,i=Math.imul(B,L),n=(n=Math.imul(B,K))+Math.imul(z,L)|0,s=Math.imul(z,K),i=i+Math.imul(k,F)|0,n=(n=n+Math.imul(k,V)|0)+Math.imul(x,F)|0,s=s+Math.imul(x,V)|0,i=i+Math.imul(E,Z)|0,n=(n=n+Math.imul(E,G)|0)+Math.imul(M,Z)|0,s=s+Math.imul(M,G)|0,i=i+Math.imul(w,W)|0,n=(n=n+Math.imul(w,X)|0)+Math.imul(S,W)|0,s=s+Math.imul(S,X)|0,i=i+Math.imul(g,Q)|0,n=(n=n+Math.imul(g,ee)|0)+Math.imul(y,Q)|0,s=s+Math.imul(y,ee)|0,i=i+Math.imul(p,re)|0,n=(n=n+Math.imul(p,ie)|0)+Math.imul(b,re)|0,s=s+Math.imul(b,ie)|0;var _e=(f+(i=i+Math.imul(u,se)|0)|0)+((8191&(n=(n=n+Math.imul(u,oe)|0)+Math.imul(d,se)|0))<<13)|0;f=((s=s+Math.imul(d,oe)|0)+(n>>>13)|0)+(_e>>>26)|0,_e&=67108863,i=Math.imul(P,L),n=(n=Math.imul(P,K))+Math.imul(N,L)|0,s=Math.imul(N,K),i=i+Math.imul(B,F)|0,n=(n=n+Math.imul(B,V)|0)+Math.imul(z,F)|0,s=s+Math.imul(z,V)|0,i=i+Math.imul(k,Z)|0,n=(n=n+Math.imul(k,G)|0)+Math.imul(x,Z)|0,s=s+Math.imul(x,G)|0,i=i+Math.imul(E,W)|0,n=(n=n+Math.imul(E,X)|0)+Math.imul(M,W)|0,s=s+Math.imul(M,X)|0,i=i+Math.imul(w,Q)|0,n=(n=n+Math.imul(w,ee)|0)+Math.imul(S,Q)|0,s=s+Math.imul(S,ee)|0,i=i+Math.imul(g,re)|0,n=(n=n+Math.imul(g,ie)|0)+Math.imul(y,re)|0,s=s+Math.imul(y,ie)|0,i=i+Math.imul(p,se)|0,n=(n=n+Math.imul(p,oe)|0)+Math.imul(b,se)|0,s=s+Math.imul(b,oe)|0;var Ee=(f+(i=i+Math.imul(u,ce)|0)|0)+((8191&(n=(n=n+Math.imul(u,fe)|0)+Math.imul(d,ce)|0))<<13)|0;f=((s=s+Math.imul(d,fe)|0)+(n>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,i=Math.imul(C,L),n=(n=Math.imul(C,K))+Math.imul(O,L)|0,s=Math.imul(O,K),i=i+Math.imul(P,F)|0,n=(n=n+Math.imul(P,V)|0)+Math.imul(N,F)|0,s=s+Math.imul(N,V)|0,i=i+Math.imul(B,Z)|0,n=(n=n+Math.imul(B,G)|0)+Math.imul(z,Z)|0,s=s+Math.imul(z,G)|0,i=i+Math.imul(k,W)|0,n=(n=n+Math.imul(k,X)|0)+Math.imul(x,W)|0,s=s+Math.imul(x,X)|0,i=i+Math.imul(E,Q)|0,n=(n=n+Math.imul(E,ee)|0)+Math.imul(M,Q)|0,s=s+Math.imul(M,ee)|0,i=i+Math.imul(w,re)|0,n=(n=n+Math.imul(w,ie)|0)+Math.imul(S,re)|0,s=s+Math.imul(S,ie)|0,i=i+Math.imul(g,se)|0,n=(n=n+Math.imul(g,oe)|0)+Math.imul(y,se)|0,s=s+Math.imul(y,oe)|0,i=i+Math.imul(p,ce)|0,n=(n=n+Math.imul(p,fe)|0)+Math.imul(b,ce)|0,s=s+Math.imul(b,fe)|0;var Me=(f+(i=i+Math.imul(u,ue)|0)|0)+((8191&(n=(n=n+Math.imul(u,de)|0)+Math.imul(d,ue)|0))<<13)|0;f=((s=s+Math.imul(d,de)|0)+(n>>>13)|0)+(Me>>>26)|0,Me&=67108863,i=Math.imul(U,L),n=(n=Math.imul(U,K))+Math.imul(D,L)|0,s=Math.imul(D,K),i=i+Math.imul(C,F)|0,n=(n=n+Math.imul(C,V)|0)+Math.imul(O,F)|0,s=s+Math.imul(O,V)|0,i=i+Math.imul(P,Z)|0,n=(n=n+Math.imul(P,G)|0)+Math.imul(N,Z)|0,s=s+Math.imul(N,G)|0,i=i+Math.imul(B,W)|0,n=(n=n+Math.imul(B,X)|0)+Math.imul(z,W)|0,s=s+Math.imul(z,X)|0,i=i+Math.imul(k,Q)|0,n=(n=n+Math.imul(k,ee)|0)+Math.imul(x,Q)|0,s=s+Math.imul(x,ee)|0,i=i+Math.imul(E,re)|0,n=(n=n+Math.imul(E,ie)|0)+Math.imul(M,re)|0,s=s+Math.imul(M,ie)|0,i=i+Math.imul(w,se)|0,n=(n=n+Math.imul(w,oe)|0)+Math.imul(S,se)|0,s=s+Math.imul(S,oe)|0,i=i+Math.imul(g,ce)|0,n=(n=n+Math.imul(g,fe)|0)+Math.imul(y,ce)|0,s=s+Math.imul(y,fe)|0,i=i+Math.imul(p,ue)|0,n=(n=n+Math.imul(p,de)|0)+Math.imul(b,ue)|0,s=s+Math.imul(b,de)|0;var Ae=(f+(i=i+Math.imul(u,pe)|0)|0)+((8191&(n=(n=n+Math.imul(u,be)|0)+Math.imul(d,pe)|0))<<13)|0;f=((s=s+Math.imul(d,be)|0)+(n>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,i=Math.imul(U,F),n=(n=Math.imul(U,V))+Math.imul(D,F)|0,s=Math.imul(D,V),i=i+Math.imul(C,Z)|0,n=(n=n+Math.imul(C,G)|0)+Math.imul(O,Z)|0,s=s+Math.imul(O,G)|0,i=i+Math.imul(P,W)|0,n=(n=n+Math.imul(P,X)|0)+Math.imul(N,W)|0,s=s+Math.imul(N,X)|0,i=i+Math.imul(B,Q)|0,n=(n=n+Math.imul(B,ee)|0)+Math.imul(z,Q)|0,s=s+Math.imul(z,ee)|0,i=i+Math.imul(k,re)|0,n=(n=n+Math.imul(k,ie)|0)+Math.imul(x,re)|0,s=s+Math.imul(x,ie)|0,i=i+Math.imul(E,se)|0,n=(n=n+Math.imul(E,oe)|0)+Math.imul(M,se)|0,s=s+Math.imul(M,oe)|0,i=i+Math.imul(w,ce)|0,n=(n=n+Math.imul(w,fe)|0)+Math.imul(S,ce)|0,s=s+Math.imul(S,fe)|0,i=i+Math.imul(g,ue)|0,n=(n=n+Math.imul(g,de)|0)+Math.imul(y,ue)|0,s=s+Math.imul(y,de)|0;var ke=(f+(i=i+Math.imul(p,pe)|0)|0)+((8191&(n=(n=n+Math.imul(p,be)|0)+Math.imul(b,pe)|0))<<13)|0;f=((s=s+Math.imul(b,be)|0)+(n>>>13)|0)+(ke>>>26)|0,ke&=67108863,i=Math.imul(U,Z),n=(n=Math.imul(U,G))+Math.imul(D,Z)|0,s=Math.imul(D,G),i=i+Math.imul(C,W)|0,n=(n=n+Math.imul(C,X)|0)+Math.imul(O,W)|0,s=s+Math.imul(O,X)|0,i=i+Math.imul(P,Q)|0,n=(n=n+Math.imul(P,ee)|0)+Math.imul(N,Q)|0,s=s+Math.imul(N,ee)|0,i=i+Math.imul(B,re)|0,n=(n=n+Math.imul(B,ie)|0)+Math.imul(z,re)|0,s=s+Math.imul(z,ie)|0,i=i+Math.imul(k,se)|0,n=(n=n+Math.imul(k,oe)|0)+Math.imul(x,se)|0,s=s+Math.imul(x,oe)|0,i=i+Math.imul(E,ce)|0,n=(n=n+Math.imul(E,fe)|0)+Math.imul(M,ce)|0,s=s+Math.imul(M,fe)|0,i=i+Math.imul(w,ue)|0,n=(n=n+Math.imul(w,de)|0)+Math.imul(S,ue)|0,s=s+Math.imul(S,de)|0;var xe=(f+(i=i+Math.imul(g,pe)|0)|0)+((8191&(n=(n=n+Math.imul(g,be)|0)+Math.imul(y,pe)|0))<<13)|0;f=((s=s+Math.imul(y,be)|0)+(n>>>13)|0)+(xe>>>26)|0,xe&=67108863,i=Math.imul(U,W),n=(n=Math.imul(U,X))+Math.imul(D,W)|0,s=Math.imul(D,X),i=i+Math.imul(C,Q)|0,n=(n=n+Math.imul(C,ee)|0)+Math.imul(O,Q)|0,s=s+Math.imul(O,ee)|0,i=i+Math.imul(P,re)|0,n=(n=n+Math.imul(P,ie)|0)+Math.imul(N,re)|0,s=s+Math.imul(N,ie)|0,i=i+Math.imul(B,se)|0,n=(n=n+Math.imul(B,oe)|0)+Math.imul(z,se)|0,s=s+Math.imul(z,oe)|0,i=i+Math.imul(k,ce)|0,n=(n=n+Math.imul(k,fe)|0)+Math.imul(x,ce)|0,s=s+Math.imul(x,fe)|0,i=i+Math.imul(E,ue)|0,n=(n=n+Math.imul(E,de)|0)+Math.imul(M,ue)|0,s=s+Math.imul(M,de)|0;var Ie=(f+(i=i+Math.imul(w,pe)|0)|0)+((8191&(n=(n=n+Math.imul(w,be)|0)+Math.imul(S,pe)|0))<<13)|0;f=((s=s+Math.imul(S,be)|0)+(n>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,i=Math.imul(U,Q),n=(n=Math.imul(U,ee))+Math.imul(D,Q)|0,s=Math.imul(D,ee),i=i+Math.imul(C,re)|0,n=(n=n+Math.imul(C,ie)|0)+Math.imul(O,re)|0,s=s+Math.imul(O,ie)|0,i=i+Math.imul(P,se)|0,n=(n=n+Math.imul(P,oe)|0)+Math.imul(N,se)|0,s=s+Math.imul(N,oe)|0,i=i+Math.imul(B,ce)|0,n=(n=n+Math.imul(B,fe)|0)+Math.imul(z,ce)|0,s=s+Math.imul(z,fe)|0,i=i+Math.imul(k,ue)|0,n=(n=n+Math.imul(k,de)|0)+Math.imul(x,ue)|0,s=s+Math.imul(x,de)|0;var Be=(f+(i=i+Math.imul(E,pe)|0)|0)+((8191&(n=(n=n+Math.imul(E,be)|0)+Math.imul(M,pe)|0))<<13)|0;f=((s=s+Math.imul(M,be)|0)+(n>>>13)|0)+(Be>>>26)|0,Be&=67108863,i=Math.imul(U,re),n=(n=Math.imul(U,ie))+Math.imul(D,re)|0,s=Math.imul(D,ie),i=i+Math.imul(C,se)|0,n=(n=n+Math.imul(C,oe)|0)+Math.imul(O,se)|0,s=s+Math.imul(O,oe)|0,i=i+Math.imul(P,ce)|0,n=(n=n+Math.imul(P,fe)|0)+Math.imul(N,ce)|0,s=s+Math.imul(N,fe)|0,i=i+Math.imul(B,ue)|0,n=(n=n+Math.imul(B,de)|0)+Math.imul(z,ue)|0,s=s+Math.imul(z,de)|0;var ze=(f+(i=i+Math.imul(k,pe)|0)|0)+((8191&(n=(n=n+Math.imul(k,be)|0)+Math.imul(x,pe)|0))<<13)|0;f=((s=s+Math.imul(x,be)|0)+(n>>>13)|0)+(ze>>>26)|0,ze&=67108863,i=Math.imul(U,se),n=(n=Math.imul(U,oe))+Math.imul(D,se)|0,s=Math.imul(D,oe),i=i+Math.imul(C,ce)|0,n=(n=n+Math.imul(C,fe)|0)+Math.imul(O,ce)|0,s=s+Math.imul(O,fe)|0,i=i+Math.imul(P,ue)|0,n=(n=n+Math.imul(P,de)|0)+Math.imul(N,ue)|0,s=s+Math.imul(N,de)|0;var Re=(f+(i=i+Math.imul(B,pe)|0)|0)+((8191&(n=(n=n+Math.imul(B,be)|0)+Math.imul(z,pe)|0))<<13)|0;f=((s=s+Math.imul(z,be)|0)+(n>>>13)|0)+(Re>>>26)|0,Re&=67108863,i=Math.imul(U,ce),n=(n=Math.imul(U,fe))+Math.imul(D,ce)|0,s=Math.imul(D,fe),i=i+Math.imul(C,ue)|0,n=(n=n+Math.imul(C,de)|0)+Math.imul(O,ue)|0,s=s+Math.imul(O,de)|0;var Pe=(f+(i=i+Math.imul(P,pe)|0)|0)+((8191&(n=(n=n+Math.imul(P,be)|0)+Math.imul(N,pe)|0))<<13)|0;f=((s=s+Math.imul(N,be)|0)+(n>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,i=Math.imul(U,ue),n=(n=Math.imul(U,de))+Math.imul(D,ue)|0,s=Math.imul(D,de);var Ne=(f+(i=i+Math.imul(C,pe)|0)|0)+((8191&(n=(n=n+Math.imul(C,be)|0)+Math.imul(O,pe)|0))<<13)|0;f=((s=s+Math.imul(O,be)|0)+(n>>>13)|0)+(Ne>>>26)|0,Ne&=67108863;var qe=(f+(i=Math.imul(U,pe))|0)+((8191&(n=(n=Math.imul(U,be))+Math.imul(D,pe)|0))<<13)|0;return f=((s=Math.imul(D,be))+(n>>>13)|0)+(qe>>>26)|0,qe&=67108863,c[0]=me,c[1]=ge,c[2]=ye,c[3]=ve,c[4]=we,c[5]=Se,c[6]=_e,c[7]=Ee,c[8]=Me,c[9]=Ae,c[10]=ke,c[11]=xe,c[12]=Ie,c[13]=Be,c[14]=ze,c[15]=Re,c[16]=Pe,c[17]=Ne,c[18]=qe,0!==f&&(c[19]=f,r.length++),r};function p(e,t,r){return(new b).mulp(e,t,r)}function b(e,t){this.x=e,this.y=t}Math.imul||(l=d),s.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===t