@vostokplatform/crypto-gost-js
Version:
Pure Javascript implementation of WebCrypto API interfaces and Public Key Infrastructure for GOST algorithms (Russian Cryptographic Standards)
8 lines • 626 kB
JavaScript
(function webpackUniversalModuleDefinition(e,t){if(typeof exports==="object"&&typeof module==="object")module.exports=t();else if(typeof define==="function"&&define.amd)define([],t);else if(typeof exports==="object")exports["CryptoGost"]=t();else e["CryptoGost"]=t()})(this,function(){return function(e){var t={};function __webpack_require__(r){if(t[r]){return t[r].exports}var n=t[r]={i:r,l:false,exports:{}};e[r].call(n.exports,n,n.exports,__webpack_require__);n.l=true;return n.exports}__webpack_require__.m=e;__webpack_require__.c=t;__webpack_require__.d=function(e,t,r){if(!__webpack_require__.o(e,t)){Object.defineProperty(e,t,{enumerable:true,get:r})}};__webpack_require__.r=function(e){if(typeof Symbol!=="undefined"&&Symbol.toStringTag){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}Object.defineProperty(e,"__esModule",{value:true})};__webpack_require__.t=function(e,t){if(t&1)e=__webpack_require__(e);if(t&8)return e;if(t&4&&typeof e==="object"&&e&&e.__esModule)return e;var r=Object.create(null);__webpack_require__.r(r);Object.defineProperty(r,"default",{enumerable:true,value:e});if(t&2&&typeof e!="string")for(var n in e)__webpack_require__.d(r,n,function(t){return e[t]}.bind(null,n));return r};__webpack_require__.n=function(e){var t=e&&e.__esModule?function getDefault(){return e["default"]}:function getModuleExports(){return e};__webpack_require__.d(t,"a",t);return t};__webpack_require__.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};__webpack_require__.p="";return __webpack_require__(__webpack_require__.s=177)}([function(e,t){if(typeof Object.create==="function"){e.exports=function inherits(e,t){e.super_=t;e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:false,writable:true,configurable:true}})}}else{e.exports=function inherits(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype;e.prototype=new r;e.prototype.constructor=e}}},function(e,t,r){var n=r(2);var i=n.Buffer;function copyProps(e,t){for(var r in e){t[r]=e[r]}}if(i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow){e.exports=n}else{copyProps(n,t);t.Buffer=SafeBuffer}function SafeBuffer(e,t,r){return i(e,t,r)}copyProps(i,SafeBuffer);SafeBuffer.from=function(e,t,r){if(typeof e==="number"){throw new TypeError("Argument must not be a number")}return i(e,t,r)};SafeBuffer.alloc=function(e,t,r){if(typeof e!=="number"){throw new TypeError("Argument must be a number")}var n=i(e);if(t!==undefined){if(typeof r==="string"){n.fill(t,r)}else{n.fill(t)}}else{n.fill(0)}return n};SafeBuffer.allocUnsafe=function(e){if(typeof e!=="number"){throw new TypeError("Argument must be a number")}return i(e)};SafeBuffer.allocUnsafeSlow=function(e){if(typeof e!=="number"){throw new TypeError("Argument must be a number")}return n.SlowBuffer(e)}},function(e,t,r){"use strict";(function(e){
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
* @license MIT
*/
var n=r(169);var i=r(168);var a=r(76);t.Buffer=Buffer;t.SlowBuffer=SlowBuffer;t.INSPECT_MAX_BYTES=50;Buffer.TYPED_ARRAY_SUPPORT=e.TYPED_ARRAY_SUPPORT!==undefined?e.TYPED_ARRAY_SUPPORT:typedArraySupport();t.kMaxLength=kMaxLength();function typedArraySupport(){try{var e=new Uint8Array(1);e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}};return e.foo()===42&&typeof e.subarray==="function"&&e.subarray(1,1).byteLength===0}catch(e){return false}}function kMaxLength(){return Buffer.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function createBuffer(e,t){if(kMaxLength()<t){throw new RangeError("Invalid typed array length")}if(Buffer.TYPED_ARRAY_SUPPORT){e=new Uint8Array(t);e.__proto__=Buffer.prototype}else{if(e===null){e=new Buffer(t)}e.length=t}return e}function Buffer(e,t,r){if(!Buffer.TYPED_ARRAY_SUPPORT&&!(this instanceof Buffer)){return new Buffer(e,t,r)}if(typeof e==="number"){if(typeof t==="string"){throw new Error("If encoding is specified then the first argument must be a string")}return allocUnsafe(this,e)}return from(this,e,t,r)}Buffer.poolSize=8192;Buffer._augment=function(e){e.__proto__=Buffer.prototype;return e};function from(e,t,r,n){if(typeof t==="number"){throw new TypeError('"value" argument must not be a number')}if(typeof ArrayBuffer!=="undefined"&&t instanceof ArrayBuffer){return fromArrayBuffer(e,t,r,n)}if(typeof t==="string"){return fromString(e,t,r)}return fromObject(e,t)}Buffer.from=function(e,t,r){return from(null,e,t,r)};if(Buffer.TYPED_ARRAY_SUPPORT){Buffer.prototype.__proto__=Uint8Array.prototype;Buffer.__proto__=Uint8Array;if(typeof Symbol!=="undefined"&&Symbol.species&&Buffer[Symbol.species]===Buffer){Object.defineProperty(Buffer,Symbol.species,{value:null,configurable:true})}}function assertSize(e){if(typeof e!=="number"){throw new TypeError('"size" argument must be a number')}else if(e<0){throw new RangeError('"size" argument must not be negative')}}function alloc(e,t,r,n){assertSize(t);if(t<=0){return createBuffer(e,t)}if(r!==undefined){return typeof n==="string"?createBuffer(e,t).fill(r,n):createBuffer(e,t).fill(r)}return createBuffer(e,t)}Buffer.alloc=function(e,t,r){return alloc(null,e,t,r)};function allocUnsafe(e,t){assertSize(t);e=createBuffer(e,t<0?0:checked(t)|0);if(!Buffer.TYPED_ARRAY_SUPPORT){for(var r=0;r<t;++r){e[r]=0}}return e}Buffer.allocUnsafe=function(e){return allocUnsafe(null,e)};Buffer.allocUnsafeSlow=function(e){return allocUnsafe(null,e)};function fromString(e,t,r){if(typeof r!=="string"||r===""){r="utf8"}if(!Buffer.isEncoding(r)){throw new TypeError('"encoding" must be a valid string encoding')}var n=byteLength(t,r)|0;e=createBuffer(e,n);var i=e.write(t,r);if(i!==n){e=e.slice(0,i)}return e}function fromArrayLike(e,t){var r=t.length<0?0:checked(t.length)|0;e=createBuffer(e,r);for(var n=0;n<r;n+=1){e[n]=t[n]&255}return e}function fromArrayBuffer(e,t,r,n){t.byteLength;if(r<0||t.byteLength<r){throw new RangeError("'offset' is out of bounds")}if(t.byteLength<r+(n||0)){throw new RangeError("'length' is out of bounds")}if(r===undefined&&n===undefined){t=new Uint8Array(t)}else if(n===undefined){t=new Uint8Array(t,r)}else{t=new Uint8Array(t,r,n)}if(Buffer.TYPED_ARRAY_SUPPORT){e=t;e.__proto__=Buffer.prototype}else{e=fromArrayLike(e,t)}return e}function fromObject(e,t){if(Buffer.isBuffer(t)){var r=checked(t.length)|0;e=createBuffer(e,r);if(e.length===0){return e}t.copy(e,0,0,r);return e}if(t){if(typeof ArrayBuffer!=="undefined"&&t.buffer instanceof ArrayBuffer||"length"in t){if(typeof t.length!=="number"||isnan(t.length)){return createBuffer(e,0)}return fromArrayLike(e,t)}if(t.type==="Buffer"&&a(t.data)){return fromArrayLike(e,t.data)}}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function checked(e){if(e>=kMaxLength()){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+kMaxLength().toString(16)+" bytes")}return e|0}function SlowBuffer(e){if(+e!=e){e=0}return Buffer.alloc(+e)}Buffer.isBuffer=function isBuffer(e){return!!(e!=null&&e._isBuffer)};Buffer.compare=function compare(e,t){if(!Buffer.isBuffer(e)||!Buffer.isBuffer(t)){throw new TypeError("Arguments must be Buffers")}if(e===t)return 0;var r=e.length;var n=t.length;for(var i=0,a=Math.min(r,n);i<a;++i){if(e[i]!==t[i]){r=e[i];n=t[i];break}}if(r<n)return-1;if(n<r)return 1;return 0};Buffer.isEncoding=function isEncoding(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 true;default:return false}};Buffer.concat=function concat(e,t){if(!a(e)){throw new TypeError('"list" argument must be an Array of Buffers')}if(e.length===0){return Buffer.alloc(0)}var r;if(t===undefined){t=0;for(r=0;r<e.length;++r){t+=e[r].length}}var n=Buffer.allocUnsafe(t);var i=0;for(r=0;r<e.length;++r){var o=e[r];if(!Buffer.isBuffer(o)){throw new TypeError('"list" argument must be an Array of Buffers')}o.copy(n,i);i+=o.length}return n};function byteLength(e,t){if(Buffer.isBuffer(e)){return e.length}if(typeof ArrayBuffer!=="undefined"&&typeof ArrayBuffer.isView==="function"&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer)){return e.byteLength}if(typeof e!=="string"){e=""+e}var r=e.length;if(r===0)return 0;var n=false;for(;;){switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case undefined:return utf8ToBytes(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return base64ToBytes(e).length;default:if(n)return utf8ToBytes(e).length;t=(""+t).toLowerCase();n=true}}}Buffer.byteLength=byteLength;function slowToString(e,t,r){var n=false;if(t===undefined||t<0){t=0}if(t>this.length){return""}if(r===undefined||r>this.length){r=this.length}if(r<=0){return""}r>>>=0;t>>>=0;if(r<=t){return""}if(!e)e="utf8";while(true){switch(e){case"hex":return hexSlice(this,t,r);case"utf8":case"utf-8":return utf8Slice(this,t,r);case"ascii":return asciiSlice(this,t,r);case"latin1":case"binary":return latin1Slice(this,t,r);case"base64":return base64Slice(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase();n=true}}}Buffer.prototype._isBuffer=true;function swap(e,t,r){var n=e[t];e[t]=e[r];e[r]=n}Buffer.prototype.swap16=function swap16(){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){swap(this,t,t+1)}return this};Buffer.prototype.swap32=function swap32(){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){swap(this,t,t+3);swap(this,t+1,t+2)}return this};Buffer.prototype.swap64=function swap64(){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){swap(this,t,t+7);swap(this,t+1,t+6);swap(this,t+2,t+5);swap(this,t+3,t+4)}return this};Buffer.prototype.toString=function toString(){var e=this.length|0;if(e===0)return"";if(arguments.length===0)return utf8Slice(this,0,e);return slowToString.apply(this,arguments)};Buffer.prototype.equals=function equals(e){if(!Buffer.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(this===e)return true;return Buffer.compare(this,e)===0};Buffer.prototype.inspect=function inspect(){var e="";var r=t.INSPECT_MAX_BYTES;if(this.length>0){e=this.toString("hex",0,r).match(/.{2}/g).join(" ");if(this.length>r)e+=" ... "}return"<Buffer "+e+">"};Buffer.prototype.compare=function compare(e,t,r,n,i){if(!Buffer.isBuffer(e)){throw new TypeError("Argument must be a Buffer")}if(t===undefined){t=0}if(r===undefined){r=e?e.length:0}if(n===undefined){n=0}if(i===undefined){i=this.length}if(t<0||r>e.length||n<0||i>this.length){throw new RangeError("out of range index")}if(n>=i&&t>=r){return 0}if(n>=i){return-1}if(t>=r){return 1}t>>>=0;r>>>=0;n>>>=0;i>>>=0;if(this===e)return 0;var a=i-n;var o=r-t;var s=Math.min(a,o);var f=this.slice(n,i);var c=e.slice(t,r);for(var u=0;u<s;++u){if(f[u]!==c[u]){a=f[u];o=c[u];break}}if(a<o)return-1;if(o<a)return 1;return 0};function bidirectionalIndexOf(e,t,r,n,i){if(e.length===0)return-1;if(typeof r==="string"){n=r;r=0}else if(r>2147483647){r=2147483647}else if(r<-2147483648){r=-2147483648}r=+r;if(isNaN(r)){r=i?0:e.length-1}if(r<0)r=e.length+r;if(r>=e.length){if(i)return-1;else r=e.length-1}else if(r<0){if(i)r=0;else return-1}if(typeof t==="string"){t=Buffer.from(t,n)}if(Buffer.isBuffer(t)){if(t.length===0){return-1}return arrayIndexOf(e,t,r,n,i)}else if(typeof t==="number"){t=t&255;if(Buffer.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf==="function"){if(i){return Uint8Array.prototype.indexOf.call(e,t,r)}else{return Uint8Array.prototype.lastIndexOf.call(e,t,r)}}return arrayIndexOf(e,[t],r,n,i)}throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(e,t,r,n,i){var a=1;var o=e.length;var s=t.length;if(n!==undefined){n=String(n).toLowerCase();if(n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le"){if(e.length<2||t.length<2){return-1}a=2;o/=2;s/=2;r/=2}}function read(e,t){if(a===1){return e[t]}else{return e.readUInt16BE(t*a)}}var f;if(i){var c=-1;for(f=r;f<o;f++){if(read(e,f)===read(t,c===-1?0:f-c)){if(c===-1)c=f;if(f-c+1===s)return c*a}else{if(c!==-1)f-=f-c;c=-1}}}else{if(r+s>o)r=o-s;for(f=r;f>=0;f--){var u=true;for(var d=0;d<s;d++){if(read(e,f+d)!==read(t,d)){u=false;break}}if(u)return f}}return-1}Buffer.prototype.includes=function includes(e,t,r){return this.indexOf(e,t,r)!==-1};Buffer.prototype.indexOf=function indexOf(e,t,r){return bidirectionalIndexOf(this,e,t,r,true)};Buffer.prototype.lastIndexOf=function lastIndexOf(e,t,r){return bidirectionalIndexOf(this,e,t,r,false)};function hexWrite(e,t,r,n){r=Number(r)||0;var i=e.length-r;if(!n){n=i}else{n=Number(n);if(n>i){n=i}}var a=t.length;if(a%2!==0)throw new TypeError("Invalid hex string");if(n>a/2){n=a/2}for(var o=0;o<n;++o){var s=parseInt(t.substr(o*2,2),16);if(isNaN(s))return o;e[r+o]=s}return o}function utf8Write(e,t,r,n){return blitBuffer(utf8ToBytes(t,e.length-r),e,r,n)}function asciiWrite(e,t,r,n){return blitBuffer(asciiToBytes(t),e,r,n)}function latin1Write(e,t,r,n){return asciiWrite(e,t,r,n)}function base64Write(e,t,r,n){return blitBuffer(base64ToBytes(t),e,r,n)}function ucs2Write(e,t,r,n){return blitBuffer(utf16leToBytes(t,e.length-r),e,r,n)}Buffer.prototype.write=function write(e,t,r,n){if(t===undefined){n="utf8";r=this.length;t=0}else if(r===undefined&&typeof t==="string"){n=t;r=this.length;t=0}else if(isFinite(t)){t=t|0;if(isFinite(r)){r=r|0;if(n===undefined)n="utf8"}else{n=r;r=undefined}}else{throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported")}var i=this.length-t;if(r===undefined||r>i)r=i;if(e.length>0&&(r<0||t<0)||t>this.length){throw new RangeError("Attempt to write outside buffer bounds")}if(!n)n="utf8";var a=false;for(;;){switch(n){case"hex":return hexWrite(this,e,t,r);case"utf8":case"utf-8":return utf8Write(this,e,t,r);case"ascii":return asciiWrite(this,e,t,r);case"latin1":case"binary":return latin1Write(this,e,t,r);case"base64":return base64Write(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,e,t,r);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase();a=true}}};Buffer.prototype.toJSON=function toJSON(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(e,t,r){if(t===0&&r===e.length){return n.fromByteArray(e)}else{return n.fromByteArray(e.slice(t,r))}}function utf8Slice(e,t,r){r=Math.min(e.length,r);var n=[];var i=t;while(i<r){var a=e[i];var o=null;var s=a>239?4:a>223?3:a>191?2:1;if(i+s<=r){var f,c,u,d;switch(s){case 1:if(a<128){o=a}break;case 2:f=e[i+1];if((f&192)===128){d=(a&31)<<6|f&63;if(d>127){o=d}}break;case 3:f=e[i+1];c=e[i+2];if((f&192)===128&&(c&192)===128){d=(a&15)<<12|(f&63)<<6|c&63;if(d>2047&&(d<55296||d>57343)){o=d}}break;case 4:f=e[i+1];c=e[i+2];u=e[i+3];if((f&192)===128&&(c&192)===128&&(u&192)===128){d=(a&15)<<18|(f&63)<<12|(c&63)<<6|u&63;if(d>65535&&d<1114112){o=d}}}}if(o===null){o=65533;s=1}else if(o>65535){o-=65536;n.push(o>>>10&1023|55296);o=56320|o&1023}n.push(o);i+=s}return decodeCodePointsArray(n)}var o=4096;function decodeCodePointsArray(e){var t=e.length;if(t<=o){return String.fromCharCode.apply(String,e)}var r="";var n=0;while(n<t){r+=String.fromCharCode.apply(String,e.slice(n,n+=o))}return r}function asciiSlice(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i){n+=String.fromCharCode(e[i]&127)}return n}function latin1Slice(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i){n+=String.fromCharCode(e[i])}return n}function hexSlice(e,t,r){var n=e.length;if(!t||t<0)t=0;if(!r||r<0||r>n)r=n;var i="";for(var a=t;a<r;++a){i+=toHex(e[a])}return i}function utf16leSlice(e,t,r){var n=e.slice(t,r);var i="";for(var a=0;a<n.length;a+=2){i+=String.fromCharCode(n[a]+n[a+1]*256)}return i}Buffer.prototype.slice=function slice(e,t){var r=this.length;e=~~e;t=t===undefined?r:~~t;if(e<0){e+=r;if(e<0)e=0}else if(e>r){e=r}if(t<0){t+=r;if(t<0)t=0}else if(t>r){t=r}if(t<e)t=e;var n;if(Buffer.TYPED_ARRAY_SUPPORT){n=this.subarray(e,t);n.__proto__=Buffer.prototype}else{var i=t-e;n=new Buffer(i,undefined);for(var a=0;a<i;++a){n[a]=this[a+e]}}return n};function checkOffset(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")}Buffer.prototype.readUIntLE=function readUIntLE(e,t,r){e=e|0;t=t|0;if(!r)checkOffset(e,t,this.length);var n=this[e];var i=1;var a=0;while(++a<t&&(i*=256)){n+=this[e+a]*i}return n};Buffer.prototype.readUIntBE=function readUIntBE(e,t,r){e=e|0;t=t|0;if(!r){checkOffset(e,t,this.length)}var n=this[e+--t];var i=1;while(t>0&&(i*=256)){n+=this[e+--t]*i}return n};Buffer.prototype.readUInt8=function readUInt8(e,t){if(!t)checkOffset(e,1,this.length);return this[e]};Buffer.prototype.readUInt16LE=function readUInt16LE(e,t){if(!t)checkOffset(e,2,this.length);return this[e]|this[e+1]<<8};Buffer.prototype.readUInt16BE=function readUInt16BE(e,t){if(!t)checkOffset(e,2,this.length);return this[e]<<8|this[e+1]};Buffer.prototype.readUInt32LE=function readUInt32LE(e,t){if(!t)checkOffset(e,4,this.length);return(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};Buffer.prototype.readUInt32BE=function readUInt32BE(e,t){if(!t)checkOffset(e,4,this.length);return this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};Buffer.prototype.readIntLE=function readIntLE(e,t,r){e=e|0;t=t|0;if(!r)checkOffset(e,t,this.length);var n=this[e];var i=1;var a=0;while(++a<t&&(i*=256)){n+=this[e+a]*i}i*=128;if(n>=i)n-=Math.pow(2,8*t);return n};Buffer.prototype.readIntBE=function readIntBE(e,t,r){e=e|0;t=t|0;if(!r)checkOffset(e,t,this.length);var n=t;var i=1;var a=this[e+--n];while(n>0&&(i*=256)){a+=this[e+--n]*i}i*=128;if(a>=i)a-=Math.pow(2,8*t);return a};Buffer.prototype.readInt8=function readInt8(e,t){if(!t)checkOffset(e,1,this.length);if(!(this[e]&128))return this[e];return(255-this[e]+1)*-1};Buffer.prototype.readInt16LE=function readInt16LE(e,t){if(!t)checkOffset(e,2,this.length);var r=this[e]|this[e+1]<<8;return r&32768?r|4294901760:r};Buffer.prototype.readInt16BE=function readInt16BE(e,t){if(!t)checkOffset(e,2,this.length);var r=this[e+1]|this[e]<<8;return r&32768?r|4294901760:r};Buffer.prototype.readInt32LE=function readInt32LE(e,t){if(!t)checkOffset(e,4,this.length);return this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};Buffer.prototype.readInt32BE=function readInt32BE(e,t){if(!t)checkOffset(e,4,this.length);return this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};Buffer.prototype.readFloatLE=function readFloatLE(e,t){if(!t)checkOffset(e,4,this.length);return i.read(this,e,true,23,4)};Buffer.prototype.readFloatBE=function readFloatBE(e,t){if(!t)checkOffset(e,4,this.length);return i.read(this,e,false,23,4)};Buffer.prototype.readDoubleLE=function readDoubleLE(e,t){if(!t)checkOffset(e,8,this.length);return i.read(this,e,true,52,8)};Buffer.prototype.readDoubleBE=function readDoubleBE(e,t){if(!t)checkOffset(e,8,this.length);return i.read(this,e,false,52,8)};function checkInt(e,t,r,n,i,a){if(!Buffer.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<a)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}Buffer.prototype.writeUIntLE=function writeUIntLE(e,t,r,n){e=+e;t=t|0;r=r|0;if(!n){var i=Math.pow(2,8*r)-1;checkInt(this,e,t,r,i,0)}var a=1;var o=0;this[t]=e&255;while(++o<r&&(a*=256)){this[t+o]=e/a&255}return t+r};Buffer.prototype.writeUIntBE=function writeUIntBE(e,t,r,n){e=+e;t=t|0;r=r|0;if(!n){var i=Math.pow(2,8*r)-1;checkInt(this,e,t,r,i,0)}var a=r-1;var o=1;this[t+a]=e&255;while(--a>=0&&(o*=256)){this[t+a]=e/o&255}return t+r};Buffer.prototype.writeUInt8=function writeUInt8(e,t,r){e=+e;t=t|0;if(!r)checkInt(this,e,t,1,255,0);if(!Buffer.TYPED_ARRAY_SUPPORT)e=Math.floor(e);this[t]=e&255;return t+1};function objectWriteUInt16(e,t,r,n){if(t<0)t=65535+t+1;for(var i=0,a=Math.min(e.length-r,2);i<a;++i){e[r+i]=(t&255<<8*(n?i:1-i))>>>(n?i:1-i)*8}}Buffer.prototype.writeUInt16LE=function writeUInt16LE(e,t,r){e=+e;t=t|0;if(!r)checkInt(this,e,t,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[t]=e&255;this[t+1]=e>>>8}else{objectWriteUInt16(this,e,t,true)}return t+2};Buffer.prototype.writeUInt16BE=function writeUInt16BE(e,t,r){e=+e;t=t|0;if(!r)checkInt(this,e,t,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[t]=e>>>8;this[t+1]=e&255}else{objectWriteUInt16(this,e,t,false)}return t+2};function objectWriteUInt32(e,t,r,n){if(t<0)t=4294967295+t+1;for(var i=0,a=Math.min(e.length-r,4);i<a;++i){e[r+i]=t>>>(n?i:3-i)*8&255}}Buffer.prototype.writeUInt32LE=function writeUInt32LE(e,t,r){e=+e;t=t|0;if(!r)checkInt(this,e,t,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[t+3]=e>>>24;this[t+2]=e>>>16;this[t+1]=e>>>8;this[t]=e&255}else{objectWriteUInt32(this,e,t,true)}return t+4};Buffer.prototype.writeUInt32BE=function writeUInt32BE(e,t,r){e=+e;t=t|0;if(!r)checkInt(this,e,t,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[t]=e>>>24;this[t+1]=e>>>16;this[t+2]=e>>>8;this[t+3]=e&255}else{objectWriteUInt32(this,e,t,false)}return t+4};Buffer.prototype.writeIntLE=function writeIntLE(e,t,r,n){e=+e;t=t|0;if(!n){var i=Math.pow(2,8*r-1);checkInt(this,e,t,r,i-1,-i)}var a=0;var o=1;var s=0;this[t]=e&255;while(++a<r&&(o*=256)){if(e<0&&s===0&&this[t+a-1]!==0){s=1}this[t+a]=(e/o>>0)-s&255}return t+r};Buffer.prototype.writeIntBE=function writeIntBE(e,t,r,n){e=+e;t=t|0;if(!n){var i=Math.pow(2,8*r-1);checkInt(this,e,t,r,i-1,-i)}var a=r-1;var o=1;var s=0;this[t+a]=e&255;while(--a>=0&&(o*=256)){if(e<0&&s===0&&this[t+a+1]!==0){s=1}this[t+a]=(e/o>>0)-s&255}return t+r};Buffer.prototype.writeInt8=function writeInt8(e,t,r){e=+e;t=t|0;if(!r)checkInt(this,e,t,1,127,-128);if(!Buffer.TYPED_ARRAY_SUPPORT)e=Math.floor(e);if(e<0)e=255+e+1;this[t]=e&255;return t+1};Buffer.prototype.writeInt16LE=function writeInt16LE(e,t,r){e=+e;t=t|0;if(!r)checkInt(this,e,t,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[t]=e&255;this[t+1]=e>>>8}else{objectWriteUInt16(this,e,t,true)}return t+2};Buffer.prototype.writeInt16BE=function writeInt16BE(e,t,r){e=+e;t=t|0;if(!r)checkInt(this,e,t,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[t]=e>>>8;this[t+1]=e&255}else{objectWriteUInt16(this,e,t,false)}return t+2};Buffer.prototype.writeInt32LE=function writeInt32LE(e,t,r){e=+e;t=t|0;if(!r)checkInt(this,e,t,4,2147483647,-2147483648);if(Buffer.TYPED_ARRAY_SUPPORT){this[t]=e&255;this[t+1]=e>>>8;this[t+2]=e>>>16;this[t+3]=e>>>24}else{objectWriteUInt32(this,e,t,true)}return t+4};Buffer.prototype.writeInt32BE=function writeInt32BE(e,t,r){e=+e;t=t|0;if(!r)checkInt(this,e,t,4,2147483647,-2147483648);if(e<0)e=4294967295+e+1;if(Buffer.TYPED_ARRAY_SUPPORT){this[t]=e>>>24;this[t+1]=e>>>16;this[t+2]=e>>>8;this[t+3]=e&255}else{objectWriteUInt32(this,e,t,false)}return t+4};function checkIEEE754(e,t,r,n,i,a){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function writeFloat(e,t,r,n,a){if(!a){checkIEEE754(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38)}i.write(e,t,r,n,23,4);return r+4}Buffer.prototype.writeFloatLE=function writeFloatLE(e,t,r){return writeFloat(this,e,t,true,r)};Buffer.prototype.writeFloatBE=function writeFloatBE(e,t,r){return writeFloat(this,e,t,false,r)};function writeDouble(e,t,r,n,a){if(!a){checkIEEE754(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308)}i.write(e,t,r,n,52,8);return r+8}Buffer.prototype.writeDoubleLE=function writeDoubleLE(e,t,r){return writeDouble(this,e,t,true,r)};Buffer.prototype.writeDoubleBE=function writeDoubleBE(e,t,r){return writeDouble(this,e,t,false,r)};Buffer.prototype.copy=function copy(e,t,r,n){if(!r)r=0;if(!n&&n!==0)n=this.length;if(t>=e.length)t=e.length;if(!t)t=0;if(n>0&&n<r)n=r;if(n===r)return 0;if(e.length===0||this.length===0)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(n<0)throw new RangeError("sourceEnd out of bounds");if(n>this.length)n=this.length;if(e.length-t<n-r){n=e.length-t+r}var i=n-r;var a;if(this===e&&r<t&&t<n){for(a=i-1;a>=0;--a){e[a+t]=this[a+r]}}else if(i<1e3||!Buffer.TYPED_ARRAY_SUPPORT){for(a=0;a<i;++a){e[a+t]=this[a+r]}}else{Uint8Array.prototype.set.call(e,this.subarray(r,r+i),t)}return i};Buffer.prototype.fill=function fill(e,t,r,n){if(typeof e==="string"){if(typeof t==="string"){n=t;t=0;r=this.length}else if(typeof r==="string"){n=r;r=this.length}if(e.length===1){var i=e.charCodeAt(0);if(i<256){e=i}}if(n!==undefined&&typeof n!=="string"){throw new TypeError("encoding must be a string")}if(typeof n==="string"&&!Buffer.isEncoding(n)){throw new TypeError("Unknown encoding: "+n)}}else if(typeof e==="number"){e=e&255}if(t<0||this.length<t||this.length<r){throw new RangeError("Out of range index")}if(r<=t){return this}t=t>>>0;r=r===undefined?this.length:r>>>0;if(!e)e=0;var a;if(typeof e==="number"){for(a=t;a<r;++a){this[a]=e}}else{var o=Buffer.isBuffer(e)?e:utf8ToBytes(new Buffer(e,n).toString());var s=o.length;for(a=0;a<r-t;++a){this[a+t]=o[a%s]}}return this};var s=/[^+\/0-9A-Za-z-_]/g;function base64clean(e){e=stringtrim(e).replace(s,"");if(e.length<2)return"";while(e.length%4!==0){e=e+"="}return e}function stringtrim(e){if(e.trim)return e.trim();return e.replace(/^\s+|\s+$/g,"")}function toHex(e){if(e<16)return"0"+e.toString(16);return e.toString(16)}function utf8ToBytes(e,t){t=t||Infinity;var r;var n=e.length;var i=null;var a=[];for(var o=0;o<n;++o){r=e.charCodeAt(o);if(r>55295&&r<57344){if(!i){if(r>56319){if((t-=3)>-1)a.push(239,191,189);continue}else if(o+1===n){if((t-=3)>-1)a.push(239,191,189);continue}i=r;continue}if(r<56320){if((t-=3)>-1)a.push(239,191,189);i=r;continue}r=(i-55296<<10|r-56320)+65536}else if(i){if((t-=3)>-1)a.push(239,191,189)}i=null;if(r<128){if((t-=1)<0)break;a.push(r)}else if(r<2048){if((t-=2)<0)break;a.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;a.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else{throw new Error("Invalid code point")}}return a}function asciiToBytes(e){var t=[];for(var r=0;r<e.length;++r){t.push(e.charCodeAt(r)&255)}return t}function utf16leToBytes(e,t){var r,n,i;var a=[];for(var o=0;o<e.length;++o){if((t-=2)<0)break;r=e.charCodeAt(o);n=r>>8;i=r%256;a.push(i);a.push(n)}return a}function base64ToBytes(e){return n.toByteArray(base64clean(e))}function blitBuffer(e,t,r,n){for(var i=0;i<n;++i){if(i+r>=t.length||i>=e.length)break;t[i+r]=e[i]}return i}function isnan(e){return e!==e}}).call(this,r(7))},function(e,t,r){(function(e){(function(e,t){"use strict";function assert(e,t){if(!e)throw new Error(t||"Assertion failed")}function inherits(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype;e.prototype=new r;e.prototype.constructor=e}function BN(e,t,r){if(BN.isBN(e)){return e}this.negative=0;this.words=null;this.length=0;this.red=null;if(e!==null){if(t==="le"||t==="be"){r=t;t=10}this._init(e||0,t||10,r||"be")}}if(typeof e==="object"){e.exports=BN}else{t.BN=BN}BN.BN=BN;BN.wordSize=26;var n;try{n=r(130).Buffer}catch(e){}BN.isBN=function isBN(e){if(e instanceof BN){return true}return e!==null&&typeof e==="object"&&e.constructor.wordSize===BN.wordSize&&Array.isArray(e.words)};BN.max=function max(e,t){if(e.cmp(t)>0)return e;return t};BN.min=function min(e,t){if(e.cmp(t)<0)return e;return t};BN.prototype._init=function init(e,t,r){if(typeof e==="number"){return this._initNumber(e,t,r)}if(typeof e==="object"){return this._initArray(e,t,r)}if(t==="hex"){t=16}assert(t===(t|0)&&t>=2&&t<=36);e=e.toString().replace(/\s+/g,"");var n=0;if(e[0]==="-"){n++}if(t===16){this._parseHex(e,n)}else{this._parseBase(e,t,n)}if(e[0]==="-"){this.negative=1}this.strip();if(r!=="le")return;this._initArray(this.toArray(),t,r)};BN.prototype._initNumber=function _initNumber(e,t,r){if(e<0){this.negative=1;e=-e}if(e<67108864){this.words=[e&67108863];this.length=1}else if(e<4503599627370496){this.words=[e&67108863,e/67108864&67108863];this.length=2}else{assert(e<9007199254740992);this.words=[e&67108863,e/67108864&67108863,1];this.length=3}if(r!=="le")return;this._initArray(this.toArray(),t,r)};BN.prototype._initArray=function _initArray(e,t,r){assert(typeof e.length==="number");if(e.length<=0){this.words=[0];this.length=1;return 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 i,a;var o=0;if(r==="be"){for(n=e.length-1,i=0;n>=0;n-=3){a=e[n]|e[n-1]<<8|e[n-2]<<16;this.words[i]|=a<<o&67108863;this.words[i+1]=a>>>26-o&67108863;o+=24;if(o>=26){o-=26;i++}}}else if(r==="le"){for(n=0,i=0;n<e.length;n+=3){a=e[n]|e[n+1]<<8|e[n+2]<<16;this.words[i]|=a<<o&67108863;this.words[i+1]=a>>>26-o&67108863;o+=24;if(o>=26){o-=26;i++}}}return this.strip()};function parseHex(e,t,r){var n=0;var i=Math.min(e.length,r);for(var a=t;a<i;a++){var o=e.charCodeAt(a)-48;n<<=4;if(o>=49&&o<=54){n|=o-49+10}else if(o>=17&&o<=22){n|=o-17+10}else{n|=o&15}}return n}BN.prototype._parseHex=function _parseHex(e,t){this.length=Math.ceil((e.length-t)/6);this.words=new Array(this.length);for(var r=0;r<this.length;r++){this.words[r]=0}var n,i;var a=0;for(r=e.length-6,n=0;r>=t;r-=6){i=parseHex(e,r,r+6);this.words[n]|=i<<a&67108863;this.words[n+1]|=i>>>26-a&4194303;a+=24;if(a>=26){a-=26;n++}}if(r+6!==t){i=parseHex(e,t,r+6);this.words[n]|=i<<a&67108863;this.words[n+1]|=i>>>26-a&4194303}this.strip()};function parseBase(e,t,r,n){var i=0;var a=Math.min(e.length,r);for(var o=t;o<a;o++){var s=e.charCodeAt(o)-48;i*=n;if(s>=49){i+=s-49+10}else if(s>=17){i+=s-17+10}else{i+=s}}return i}BN.prototype._parseBase=function _parseBase(e,t,r){this.words=[0];this.length=1;for(var n=0,i=1;i<=67108863;i*=t){n++}n--;i=i/t|0;var a=e.length-r;var o=a%n;var s=Math.min(a,a-o)+r;var f=0;for(var c=r;c<s;c+=n){f=parseBase(e,c,c+n,t);this.imuln(i);if(this.words[0]+f<67108864){this.words[0]+=f}else{this._iaddn(f)}}if(o!==0){var u=1;f=parseBase(e,c,e.length,t);for(c=0;c<o;c++){u*=t}this.imuln(u);if(this.words[0]+f<67108864){this.words[0]+=f}else{this._iaddn(f)}}};BN.prototype.copy=function copy(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};BN.prototype.clone=function clone(){var e=new BN(null);this.copy(e);return e};BN.prototype._expand=function _expand(e){while(this.length<e){this.words[this.length++]=0}return this};BN.prototype.strip=function strip(){while(this.length>1&&this.words[this.length-1]===0){this.length--}return this._normSign()};BN.prototype._normSign=function _normSign(){if(this.length===1&&this.words[0]===0){this.negative=0}return this};BN.prototype.inspect=function inspect(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var i=["","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"];var a=[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];var o=[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];BN.prototype.toString=function toString(e,t){e=e||10;t=t|0||1;var r;if(e===16||e==="hex"){r="";var n=0;var s=0;for(var f=0;f<this.length;f++){var c=this.words[f];var u=((c<<n|s)&16777215).toString(16);s=c>>>24-n&16777215;if(s!==0||f!==this.length-1){r=i[6-u.length]+u+r}else{r=u+r}n+=2;if(n>=26){n-=26;f--}}if(s!==0){r=s.toString(16)+r}while(r.length%t!==0){r="0"+r}if(this.negative!==0){r="-"+r}return r}if(e===(e|0)&&e>=2&&e<=36){var d=a[e];var h=o[e];r="";var l=this.clone();l.negative=0;while(!l.isZero()){var p=l.modn(h).toString(e);l=l.idivn(h);if(!l.isZero()){r=i[d-p.length]+p+r}else{r=p+r}}if(this.isZero()){r="0"+r}while(r.length%t!==0){r="0"+r}if(this.negative!==0){r="-"+r}return r}assert(false,"Base should be between 2 and 36")};BN.prototype.toNumber=function toNumber(){var e=this.words[0];if(this.length===2){e+=this.words[1]*67108864}else if(this.length===3&&this.words[2]===1){e+=4503599627370496+this.words[1]*67108864}else if(this.length>2){assert(false,"Number can only safely store up to 53 bits")}return this.negative!==0?-e:e};BN.prototype.toJSON=function toJSON(){return this.toString(16)};BN.prototype.toBuffer=function toBuffer(e,t){assert(typeof n!=="undefined");return this.toArrayLike(n,e,t)};BN.prototype.toArray=function toArray(e,t){return this.toArrayLike(Array,e,t)};BN.prototype.toArrayLike=function toArrayLike(e,t,r){var n=this.byteLength();var i=r||Math.max(1,n);assert(n<=i,"byte array longer than desired length");assert(i>0,"Requested array length <= 0");this.strip();var a=t==="le";var o=new e(i);var s,f;var c=this.clone();if(!a){for(f=0;f<i-n;f++){o[f]=0}for(f=0;!c.isZero();f++){s=c.andln(255);c.iushrn(8);o[i-f-1]=s}}else{for(f=0;!c.isZero();f++){s=c.andln(255);c.iushrn(8);o[f]=s}for(;f<i;f++){o[f]=0}}return o};if(Math.clz32){BN.prototype._countBits=function _countBits(e){return 32-Math.clz32(e)}}else{BN.prototype._countBits=function _countBits(e){var t=e;var r=0;if(t>=4096){r+=13;t>>>=13}if(t>=64){r+=7;t>>>=7}if(t>=8){r+=4;t>>>=4}if(t>=2){r+=2;t>>>=2}return r+t}}BN.prototype._zeroBits=function _zeroBits(e){if(e===0)return 26;var t=e;var r=0;if((t&8191)===0){r+=13;t>>>=13}if((t&127)===0){r+=7;t>>>=7}if((t&15)===0){r+=4;t>>>=4}if((t&3)===0){r+=2;t>>>=2}if((t&1)===0){r++}return r};BN.prototype.bitLength=function bitLength(){var e=this.words[this.length-1];var t=this._countBits(e);return(this.length-1)*26+t};function toBitArray(e){var t=new Array(e.bitLength());for(var r=0;r<t.length;r++){var n=r/26|0;var i=r%26;t[r]=(e.words[n]&1<<i)>>>i}return t}BN.prototype.zeroBits=function zeroBits(){if(this.isZero())return 0;var e=0;for(var t=0;t<this.length;t++){var r=this._zeroBits(this.words[t]);e+=r;if(r!==26)break}return e};BN.prototype.byteLength=function byteLength(){return Math.ceil(this.bitLength()/8)};BN.prototype.toTwos=function toTwos(e){if(this.negative!==0){return this.abs().inotn(e).iaddn(1)}return this.clone()};BN.prototype.fromTwos=function fromTwos(e){if(this.testn(e-1)){return this.notn(e).iaddn(1).ineg()}return this.clone()};BN.prototype.isNeg=function isNeg(){return this.negative!==0};BN.prototype.neg=function neg(){return this.clone().ineg()};BN.prototype.ineg=function ineg(){if(!this.isZero()){this.negative^=1}return this};BN.prototype.iuor=function iuor(e){while(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()};BN.prototype.ior=function ior(e){assert((this.negative|e.negative)===0);return this.iuor(e)};BN.prototype.or=function or(e){if(this.length>e.length)return this.clone().ior(e);return e.clone().ior(this)};BN.prototype.uor=function uor(e){if(this.length>e.length)return this.clone().iuor(e);return e.clone().iuor(this)};BN.prototype.iuand=function iuand(e){var t;if(this.length>e.length){t=e}else{t=this}for(var r=0;r<t.length;r++){this.words[r]=this.words[r]&e.words[r]}this.length=t.length;return this.strip()};BN.prototype.iand=function iand(e){assert((this.negative|e.negative)===0);return this.iuand(e)};BN.prototype.and=function and(e){if(this.length>e.length)return this.clone().iand(e);return e.clone().iand(this)};BN.prototype.uand=function uand(e){if(this.length>e.length)return this.clone().iuand(e);return e.clone().iuand(this)};BN.prototype.iuxor=function iuxor(e){var t;var r;if(this.length>e.length){t=this;r=e}else{t=e;r=this}for(var n=0;n<r.length;n++){this.words[n]=t.words[n]^r.words[n]}if(this!==t){for(;n<t.length;n++){this.words[n]=t.words[n]}}this.length=t.length;return this.strip()};BN.prototype.ixor=function ixor(e){assert((this.negative|e.negative)===0);return this.iuxor(e)};BN.prototype.xor=function xor(e){if(this.length>e.length)return this.clone().ixor(e);return e.clone().ixor(this)};BN.prototype.uxor=function uxor(e){if(this.length>e.length)return this.clone().iuxor(e);return e.clone().iuxor(this)};BN.prototype.inotn=function inotn(e){assert(typeof e==="number"&&e>=0);var t=Math.ceil(e/26)|0;var r=e%26;this._expand(t);if(r>0){t--}for(var n=0;n<t;n++){this.words[n]=~this.words[n]&67108863}if(r>0){this.words[n]=~this.words[n]&67108863>>26-r}return this.strip()};BN.prototype.notn=function notn(e){return this.clone().inotn(e)};BN.prototype.setn=function setn(e,t){assert(typeof e==="number"&&e>=0);var r=e/26|0;var n=e%26;this._expand(r+1);if(t){this.words[r]=this.words[r]|1<<n}else{this.words[r]=this.words[r]&~(1<<n)}return this.strip()};BN.prototype.iadd=function iadd(e){var t;if(this.negative!==0&&e.negative===0){this.negative=0;t=this.isub(e);this.negative^=1;return this._normSign()}else if(this.negative===0&&e.negative!==0){e.negative=0;t=this.isub(e);e.negative=1;return t._normSign()}var r,n;if(this.length>e.length){r=this;n=e}else{r=e;n=this}var i=0;for(var a=0;a<n.length;a++){t=(r.words[a]|0)+(n.words[a]|0)+i;this.words[a]=t&67108863;i=t>>>26}for(;i!==0&&a<r.length;a++){t=(r.words[a]|0)+i;this.words[a]=t&67108863;i=t>>>26}this.length=r.length;if(i!==0){this.words[this.length]=i;this.length++}else if(r!==this){for(;a<r.length;a++){this.words[a]=r.words[a]}}return this};BN.prototype.add=function add(e){var t;if(e.negative!==0&&this.negative===0){e.negative=0;t=this.sub(e);e.negative^=1;return t}else if(e.negative===0&&this.negative!==0){this.negative=0;t=e.sub(this);this.negative=1;return t}if(this.length>e.length)return this.clone().iadd(e);return e.clone().iadd(this)};BN.prototype.isub=function isub(e){if(e.negative!==0){e.negative=0;var t=this.iadd(e);e.negative=1;return t._normSign()}else if(this.negative!==0){this.negative=0;this.iadd(e);this.negative=1;return this._normSign()}var r=this.cmp(e);if(r===0){this.negative=0;this.length=1;this.words[0]=0;return this}var n,i;if(r>0){n=this;i=e}else{n=e;i=this}var a=0;for(var o=0;o<i.length;o++){t=(n.words[o]|0)-(i.words[o]|0)+a;a=t>>26;this.words[o]=t&67108863}for(;a!==0&&o<n.length;o++){t=(n.words[o]|0)+a;a=t>>26;this.words[o]=t&67108863}if(a===0&&o<n.length&&n!==this){for(;o<n.length;o++){this.words[o]=n.words[o]}}this.length=Math.max(this.length,o);if(n!==this){this.negative=1}return this.strip()};BN.prototype.sub=function sub(e){return this.clone().isub(e)};function smallMulTo(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n;n=n-1|0;var i=e.words[0]|0;var a=t.words[0]|0;var o=i*a;var s=o&67108863;var f=o/67108864|0;r.words[0]=s;for(var c=1;c<n;c++){var u=f>>>26;var d=f&67108863;var h=Math.min(c,t.length-1);for(var l=Math.max(0,c-e.length+1);l<=h;l++){var p=c-l|0;i=e.words[p]|0;a=t.words[l]|0;o=i*a+d;u+=o/67108864|0;d=o&67108863}r.words[c]=d|0;f=u|0}if(f!==0){r.words[c]=f|0}else{r.length--}return r.strip()}var s=function comb10MulTo(e,t,r){var n=e.words;var i=t.words;var a=r.words;var o=0;var s;var f;var c;var u=n[0]|0;var d=u&8191;var h=u>>>13;var l=n[1]|0;var p=l&8191;var v=l>>>13;var y=n[2]|0;var b=y&8191;var m=y>>>13;var g=n[3]|0;var w=g&8191;var C=g>>>13;var S=n[4]|0;var A=S&8191;var E=S>>>13;var B=n[5]|0;var _=B&8191;var P=B>>>13;var F=n[6]|0;var k=F&8191;var D=F>>>13;var I=n[7]|0;var x=I&8191;var M=I>>>13;var K=n[8]|0;var R=K&8191;var T=K>>>13;var N=n[9]|0;var U=N&8191;var O=N>>>13;var G=i[0]|0;var j=G&8191;var L=G>>>13;var H=i[1]|0;var q=H&8191;var z=H>>>13;var W=i[2]|0;var V=W&8191;var X=W>>>13;var Y=i[3]|0;var J=Y&8191;var Z=Y>>>13;var Q=i[4]|0;var $=Q&8191;var ee=Q>>>13;var te=i[5]|0;var re=te&8191;var ne=te>>>13;var ie=i[6]|0;var ae=ie&8191;var oe=ie>>>13;var se=i[7]|0;var fe=se&8191;var ce=se>>>13;var ue=i[8]|0;var de=ue&8191;var he=ue>>>13;var le=i[9]|0;var pe=le&8191;var ve=le>>>13;r.negative=e.negative^t.negative;r.length=19;s=Math.imul(d,j);f=Math.imul(d,L);f=f+Math.imul(h,j)|0;c=Math.imul(h,L);var ye=(o+s|0)+((f&8191)<<13)|0;o=(c+(f>>>13)|0)+(ye>>>26)|0;ye&=67108863;s=Math.imul(p,j);f=Math.imul(p,L);f=f+Math.imul(v,j)|0;c=Math.imul(v,L);s=s+Math.imul(d,q)|0;f=f+Math.imul(d,z)|0;f=f+Math.imul(h,q)|0;c=c+Math.imul(h,z)|0;var be=(o+s|0)+((f&8191)<<13)|0;o=(c+(f>>>13)|0)+(be>>>26)|0;be&=67108863;s=Math.imul(b,j);f=Math.imul(b,L);f=f+Math.imul(m,j)|0;c=Math.imul(m,L);s=s+Math.imul(p,q)|0;f=f+Math.imul(p,z)|0;f=f+Math.imul(v,q)|0;c=c+Math.imul(v,z)|0;s=s+Math.imul(d,V)|0;f=f+Math.imul(d,X)|0;f=f+Math.imul(h,V)|0;c=c+Math.imul(h,X)|0;var me=(o+s|0)+((f&8191)<<13)|0;o=(c+(f>>>13)|0)+(me>>>26)|0;me&=67108863;s=Math.imul(w,j);f=Math.imul(w,L);f=f+Math.imul(C,j)|0;c=Math.imul(C,L);s=s+Math.imul(b,q)|0;f=f+Math.imul(b,z)|0;f=f+Math.imul(m,q)|0;c=c+Math.imul(m,z)|0;s=s+Math.imul(p,V)|0;f=f+Math.imul(p,X)|0;f=f+Math.imul(v,V)|0;c=c+Math.imul(v,X)|0;s=s+Math.imul(d,J)|0;f=f+Math.imul(d,Z)|0;f=f+Math.imul(h,J)|0;c=c+Math.imul(h,Z)|0;var ge=(o+s|0)+((f&8191)<<13)|0;o=(c+(f>>>13)|0)+(ge>>>26)|0;ge&=67108863;s=Math.imul(A,j);f=Math.imul(A,L);f=f+Math.imul(E,j)|0;c=Math.imul(E,L);s=s+Math.imul(w,q)|0;f=f+Math.imul(w,z)|0;f=f+Math.imul(C,q)|0;c=c+Math.imul(C,z)|0;s=s+Math.imul(b,V)|0;f=f+Math.imul(b,X)|0;f=f+Math.imul(m,V)|0;c=c+Math.imul(m,X)|0;s=s+Math.imul(p,J)|0;f=f+Math.imul(p,Z)|0;f=f+Math.imul(v,J)|0;c=c+Math.imul(v,Z)|0;s=s+Math.imul(d,$)|0;f=f+Math.imul(d,ee)|0;f=f+Math.imul(h,$)|0;c=c+Math.imul(h,ee)|0;var we=(o+s|0)+((f&8191)<<13)|0;o=(c+(f>>>13)|0)+(we>>>26)|0;we&=67108863;s=Math.imul(_,j);f=Math.imul(_,L);f=f+Math.imul(P,j)|0;c=Math.imul(P,L);s=s+Math.imul(A,q)|0;f=f+Math.imul(A,z)|0;f=f+Math.imul(E,q)|0;c=c+Math.imul(E,z)|0;s=s+Math.imul(w,V)|0;f=f+Math.imul(w,X)|0;f=f+Math.imul(C,V)|0;c=c+Math.imul(C,X)|0;s=s+Math.imul(b,J)|0;f=f+Math.imul(b,Z)|0;f=f+Math.imul(m,J)|0;c=c+Math.imul(m,Z)|0;s=s+Math.imul(p,$)|0;f=f+Math.imul(p,ee)|0;f=f+Math.imul(v,$)|0;c=c+Math.imul(v,ee)|0;s=s+Math.imul(d,re)|0;f=f+Math.imul(d,ne)|0;f=f+Math.imul(h,re)|0;c=c+Math.imul(h,ne)|0;var Ce=(o+s|0)+((f&8191)<<13)|0;o=(c+(f>>>13)|0)+(Ce>>>26)|0;Ce&=67108863;s=Math.imul(k,j);f=Math.imul(k,L);f=f+Math.imul(D,j)|0;c=Math.imul(D,L);s=s+Math.imul(_,q)|0;f=f+Math.imul(_,z)|0;f=f+Math.imul(P,q)|0;c=c+Math.imul(P,z)|0;s=s+Math.imul(A,V)|0;f=f+Math.imul(A,X)|0;f=f+Math.imul(E,V)|0;c=c+Math.imul(E,X)|0;s=s+Math.imul(w,J)|0;f=f+Math.imul(w,Z)|0;f=f+Math.imul(C,J)|0;c=c+Math.imul(C,Z)|0;s=s+Math.imul(b,$)|0;f=f+Math.imul(b,ee)|0;f=f+Math.imul(m,$)|0;c=c+Math.imul(m,ee)|0;s=s+Math.imul(p,re)|0;f=f+Math.imul(p,ne)|0;f=f+Math.imul(v,re)|0;c=c+Math.imul(v,ne)|0;s=s+Math.imul(d,ae)|0;f=f+Math.imul(d,oe)|0;f=f+Math.imul(h,ae)|0;c=c+Math.imul(h,oe)|0;var Se=(o+s|0)+((f&8191)<<13)|0;o=(c+(f>>>13)|0)+(Se>>>26)|0;Se&=67108863;s=Math.imul(x,j);f=Math.imul(x,L);f=f+Math.imul(M,j)|0;c=Math.imul(M,L);s=s+Math.imul(k,q)|0;f=f+Math.imul(k,z)|0;f=f+Math.imul(D,q)|0;c=c+Math.imul(D,z)|0;s=s+Math.imul(_,V)|0;f=f+Math.imul(_,X)|0;f=f+Math.imul(P,V)|0;c=c+Math.imul(P,X)|0;s=s+Math.imul(A,J)|0;f=f+Math.imul(A,Z)|0;f=f+Math.imul(E,J)|0;c=c+Math.imul(E,Z)|0;s=s+Math.imul(w,$)|0;f=f+Math.imul(w,ee)|0;f=f+Math.imul(C,$)|0;c=c+Math.imul(C,ee)|0;s=s+Math.imul(b,re)|0;f=f+Math.imul(b,ne)|0;f=f+Math.imul(m,re)|0;c=c+Math.imul(m,ne)|0;s=s+Math.imul(p,ae)|0;f=f+Math.imul(p,oe)|0;f=f+Math.imul(v,ae)|0;c=c+Math.imul(v,oe)|0;s=s+Math.imul(d,fe)|0;f=f+Math.imul(d,ce)|0;f=f+Math.imul(h,fe)|0;c=c+Math.imul(h,ce)|0;var Ae=(o+s|0)+((f&8191)<<13)|0;o=(c+(f>>>13)|0)+(Ae>>>26)|0;Ae&=67108863;s=Math.imul(R,j);f=Math.imul(R,L);f=f+Math.imul(T,j)|0;c=Math.imul(T,L);s=s+Math.imul(x,q)|0;f=f+Math.imul(x,z)|0;f=f+Math.imul(M,q)|0;c=c+Math.imul(M,z)|0;s=s+Math.imul(k,V)|0;f=f+Math.imul(k,X)|0;f=f+Math.imul(D,V)|0;c=c+Math.imul(D,X)|0;s=s+Math.imul(_,J)|0;f=f+Math.imul(_,Z)|0;f=f+Math.imul(P,J)|0;c=c+Math.imul(P,Z)|0;s=s+Math.imul(A,$)|0;f=f+Math.imul(A,ee)|0;f=f+Math.imul(E,$)|0;c=c+Math.imul(E,ee)|0;s=s+Math.imul(w,re)|0;f=f+Math.imul(w,ne)|0;f=f+Math.imul(C,re)|0;c=c+Math.imul(C,ne)|0;s=s+Math.imul(b,ae)|0;f=f+Math.imul(b,oe)|0;f=f+Math.imul(m,ae)|0;c=c+Math.imul(m,oe)|0;s=s+Math.imul(p,fe)|0;f=f+Math.imul(p,ce)|0;f=f+Math.imul(v,fe)|0;c=c+Math.imul(v,ce)|0;s=s+Math.imul(d,de)|0;f=f+Math.imul(d,he)|0;f=f+Math.imul(h,de)|0;c=c+Math.imul(h,he)|0;var Ee=(o+s|0)+((f&8191)<<13)|0;o=(c+(f>>>13)|0)+(Ee>>>26)|0;Ee&=67108863;s=Math.imul(U,j);f=Math.imul(U,L);f=f+Math.imul(O,j)|0;c=Math.imul(O,L);s=s+Math.imul(R,q)|0;f=f+Math.imul(R,z)|0;f=f+Math.imul(T,q)|0;c=c+Math.imul(T,z)|0;s=s+Math.imul(x,V)|0;f=f+Math.imul(x,X)|0;f=f+Math.imul(M,V)|0;c=c+Math.imul(M,X)|0;s=s+Math.imul(k,J)|0;f=f+Math.imul(k,Z)|0;f=f+Math.imul(D,J)|0;c=c+Math.imul(D,Z)|0;s=s+Math.imul(_,$)|0;f=f+Math.imul(_,ee)|0;f=f+Math.imul(P,$)|0;c=c+Math.imul(P,ee)|0;s=s+Math.imul(A,re)|0;f=f+Math.imul(A,ne)|0;f=f+Math.imul(E,re)|0;c=c+Math.imul(E,ne)|0;s=s+Math.imul(w,ae)|0;f=f+Math.imul(w,oe)|0;f=f+Math.imul(C,ae)|0;c=c+Math.imul(C,oe)|0;s=s+Math.imul(b,fe)|0;f=f+Math.imul(b,ce)|0;f=f+Math.imul(m,fe)|0;c=c+Math.imul(m,ce)|0;s=s+Math.imul(p,de)|0;f=f+Math.imul(p,he)|0;f=f+Math.imul(v,de)|0;c=c+Math.imul(v,he)|0;s=s+Math.imul(d,pe)|0;f=f+Math.imul(d,ve)|0;f=f+Math.imul(h,pe)|0;c=c+Math.imul(h,ve)|0;var Be=(o+s|0)+((f&8191)<<13)|0;o=(c+(f>>>13)|0)+(Be>>>26)|0;Be&=67108863;s=Math.imul(U,q);f=Math.imul(U,z);f=f+Math.imul(O,q)|0;c=Math.imul(O,z);s=s+Math.imul(R,V)|0;f=f+Math.imul(R,X)|0;f=f+Math.imul(T,V)|0;c=c+Math.imul(T,X)|0;s=s+Math.imul(x,J)|0;f=f+Math.imul(x,Z)|0;f=f+Math.imul(M,J)|0;c=c+Math.imul(M,Z)|0;s=s+Math.imul(k,$)|0;f=f+Math.imul(k,ee)|0;f=f+Math.imul(D,$)|0;c=c+Math.imul(D,ee)|0;s=s+Math.imul(_,re)|0;f=f+Math.imul(_,ne)|0;f=f+Math.imul(P,re)|0;c=c+Math.imul(P,ne)|0;s=s+Math.imul(A,ae)|0;f=f+Math.imul(A,oe)|0;f=f+Math.imul(E,ae)|0;c=c+Math.imul(E,oe)|0;s=s+Math.imul(w,fe)|0;f=f+Math.imul(w,ce)|0;f=f+Math.imul(C,fe)|0;c=c+Math.imul(C,ce)|0;s=s+Math.imul(b,de)|0;f=f+Math.imul(b,he)|0;f=f+Math.imul(m,de)|0;c=c+Math.imul(m,he)|0;s=s+Math.imul(p,pe)|0;f=f+Math.imul(p,ve)|0;f=f+Math.imul(v,pe)|0;c=c+Math.imul(v,ve)|0;var _e=(o+s|0)+((f&8191)<<13)|0;o=(c+(f>>>13)|0)+(_e>>>26)|0;_e&=67108863;s=Math.imul(U,V);f=Math.imul(U,X);f=f+Math.imul(O,V)|0;c=Math.imul(O,X);s=s+Math.imul(R,J)|0;f=f+Math.imul(R,Z)|0;f=f+Math.imul(T,J)|0;c=c+Math.imul(T,Z)|0;s=s+Math.imul(x,$)|0;f=f+Math.imul(x,ee)|0;f=f+Math.imul(M,$)|0;c=c+Math.imul(M,ee)|0;s=s+Math.imul(k,re)|0;f=f+Math.imul(k,ne)|0;f=f+Math.imul(D,re)|0;c=c+Math.imul(D,ne)|0;s=s+Math.imul(_,ae)|0;f=f+Math.imul(_,oe)|0;f=f+Math.imul(P,ae)|0;c=c+Math.imul(P,oe)|0;s=s+Math.imul(A,fe)|0;f=f+Math.imul(A,ce)|0;f=f+Math.imul(E,fe)|0;c=c+Math.imul(E,ce)|0;s=s+Math.imul(w,de)|0;f=f+Math.imul(w,he)|0;f=f+Math.imul(C,de)|0;c=c+Math.imul(C,he)|0;s=s+Math.imul(b,pe)|0;f=f+Math.imul(b,ve)|0;f=f+Math.imul(m,pe)|0;c=c+Math.imul(m,ve)|0;var Pe=(o+s|0)+((f&8191)<<13)|0;o=(c+(f>>>13)|0)+(Pe>>>26)|0;Pe&=67108863;s=Math.imul(U,J);f=Math.imul(U,Z);f=f+Math.imul(O,J)|0;c=Math.imul(O,Z);s=s+Math.imul(R,$)|0;f=f+Math.imul(R,ee)|0;f=f+Math.imul(T,$)|0;c=c+Math.imul(T,ee)|0;s=s+Math.imul(x,re)|0;f=f+Math.imul(x,ne)|0;f=f+Math.imul(M,re)|0;c=c+Math.imul(M,ne)|0;s=s+Math.imul(k,ae)|0;f=f+Math.imul(k,oe)|0;f=f+Math.imul(D,ae)|0;c=c+Math.imul(D,oe)|0;s=s+Math.imul(_,fe)|0;f=f+Math.imul(_,ce)|0;f=f+Math.imul(P,fe)|0;c=c+Math.imul(P,ce)|0;s=s+Math.imul(A,de)|0;f=f+Math.imul(A,he)|0;f=f+Math.imul(E,de)|0;c=c+Math.imul(E,he)|0;s=s+Math.imul(w,pe)|0;f=f+Math.imul(w,ve)|0;f=f+Math.imul(C,pe)|0;c=c+Math.imul(C,ve)|0;var Fe=(o+s|0)+((f&8191)<<13)|0;o=(c+(f>>>13)|0)+(Fe>>>26)|0;Fe&=67108863;s=Math.imul(U,$);f=Math.imul(U,ee);f=f+Math.imul(O,$)|0;c=Math.imul(O,ee);s=s+Math.imul(R,re)|0;f=f+Math.imul(R,ne)|0;f=f+Math.imul(T,re)|0;c=c+Math.imul(T,ne)|0;s=s+Math.imul(x,ae)|0;f=f+Math.imul(x,oe)|0;f=f+Math.imul(M,ae)|0;c=c+Math.imul(M,oe)|0;s=s+Math.imul(k,fe)|0;f=f+Math.imul(k,ce)|0;f=f+Math.imul(D,fe)|0;c=c+Math.imul(D,ce)|0;s=s+Math.imul(_,de)|0;f=f+Math.imul(_,he)|0;f=f+Math.imul(P,de)|0;c=c+Math.imul(P,he)|0;s=s+Math.imul(A,pe)|0;f=f+Math.imul(A,ve)|0;f=f+Math.imul(E,pe)|0;c=c+Math.imul(E,ve)|0;var ke=(o+s|0)+((f&8191)<<13)|0;o=(c+(f>>>13)|0)+(ke>>>26)|0;ke&=67108863;s=Math.imul(U,re);f=Math.imul(U,ne);f=f+Math.imul(O,re)|0;c=Math.imul(O,ne);s=s+Math.imul(R,ae)|0;f=f+Math.imul(R,oe)|0;f=f+Math.imul(T,ae)|0;c=c+Math.imul(T,oe)|0;s=s+Math.imul(x,fe)|0;f=f+Math.imul(x,ce)|0;f=f+Math.imul(M,fe)|0;c=c+Math.imul(M,ce)|0;s=s+Math.imul(k,de)|0;f=f+Math.imul(k,he)|0;f=f+Math.imul(D,de)|0;c=c+Math.imul(D,he)|0;s=s+Math.imul(_,pe)|0;f=f+Math.imul(_,ve)|0;f=f+Math.imul(P,pe)|0;c=c+Math.imul(P,ve)|0;var De=(o+s|0)+((f&8191)<<13)|0;o=(c+(f>>>13)|0)+(De>>>26)|0;De&=67108863;s=Math.imul(U,ae);f=Math.imul(U,oe);f=f+Math.imul(O,ae)|0;c=Math.imul(O,oe);s=s+Math.imul(R,fe)|0;f=f+Math.imul(R,ce)|0;f=f+Math.imul(T,fe)|0;c=c+Math.imul(T,ce)|0;s=s+Math.imul(x,de)|0;f=f+Math.imul(x,he)|0;f=f+Math.imul(M,de)|0;c=c+Math.imul(M,he)|0;s=s+Math.imul(k,pe)|0;f=f+Math.imul(k,ve)|0;f=f+Math.imul(D,pe)|0;c=c+Math.imul(D,ve)|0;var Ie=(o+s|0)+((f&8191)<<13)|0;o=(c+(f>>>13)|0)+(Ie>>>26)|0;Ie&=67108863;s=Math.imul(U,fe);f=Math.imul(U,ce);f=f+Math.imul(O,fe)|0;c=Math.imul(O,ce);s=s+Math.imul(R,de)|0;f=f+Math.imul(R,he)|0;f=f+Math.imul(T,de)|0;c=c+Math.imul(T,he)|0;s=s+Math.imul(x,pe)|0;f=f+Math.imul(x,ve)|0;f=f+Math.imul(M,pe)|0;c=c+Math.imul(M,ve)|0;var xe=(o+s|0)+((f&8191)<<13)|0;o=(c+(f>>>13)|0)+(xe>>>26)|0;xe&=67108863;s=Math.imul(U,de);f=Math.imul(U,he);f=f+Math.imul(O,de)|0;c=Math.imul(O,he);s=s+Math.imul(R,pe)|0;f=f+Math.imul(R,ve)|0;f=f+Math.imul(T,pe)|0;c=c+Math.imul(T,ve)|0;var Me=(o+s|0)+((f&8191)<<13)|0;o=(c+(f>>>13)|0)+(Me>>>26)|0;Me&=67108863;s=Math.imul(U,pe);f=Math.imul(U,ve);f=f+Math.imul(O,pe)|0;c=Math.imul(O,ve);var Ke=(o