@vostokplatform/crypto-gost-js
Version:
Pure Javascript implementation of WebCrypto API interfaces and Public Key Infrastructure for GOST algorithms (Russian Cryptographic Standards)
8 lines • 440 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 i=t[r]={i:r,l:false,exports:{}};e[r].call(i.exports,i,i.exports,__webpack_require__);i.l=true;return i.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 i in e)__webpack_require__.d(r,i,function(t){return e[t]}.bind(null,i));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=174)}([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 i=r(2);var n=i.Buffer;function copyProps(e,t){for(var r in e){t[r]=e[r]}}if(n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow){e.exports=i}else{copyProps(i,t);t.Buffer=SafeBuffer}function SafeBuffer(e,t,r){return n(e,t,r)}copyProps(n,SafeBuffer);SafeBuffer.from=function(e,t,r){if(typeof e==="number"){throw new TypeError("Argument must not be a number")}return n(e,t,r)};SafeBuffer.alloc=function(e,t,r){if(typeof e!=="number"){throw new TypeError("Argument must be a number")}var i=n(e);if(t!==undefined){if(typeof r==="string"){i.fill(t,r)}else{i.fill(t)}}else{i.fill(0)}return i};SafeBuffer.allocUnsafe=function(e){if(typeof e!=="number"){throw new TypeError("Argument must be a number")}return n(e)};SafeBuffer.allocUnsafeSlow=function(e){if(typeof e!=="number"){throw new TypeError("Argument must be a number")}return i.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 i=r(169);var n=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,i){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,i)}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,i){assertSize(t);if(t<=0){return createBuffer(e,t)}if(r!==undefined){return typeof i==="string"?createBuffer(e,t).fill(r,i):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 i=byteLength(t,r)|0;e=createBuffer(e,i);var n=e.write(t,r);if(n!==i){e=e.slice(0,n)}return e}function fromArrayLike(e,t){var r=t.length<0?0:checked(t.length)|0;e=createBuffer(e,r);for(var i=0;i<r;i+=1){e[i]=t[i]&255}return e}function fromArrayBuffer(e,t,r,i){t.byteLength;if(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")}if(r===undefined&&i===undefined){t=new Uint8Array(t)}else if(i===undefined){t=new Uint8Array(t,r)}else{t=new Uint8Array(t,r,i)}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 i=t.length;for(var n=0,a=Math.min(r,i);n<a;++n){if(e[n]!==t[n]){r=e[n];i=t[n];break}}if(r<i)return-1;if(i<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 i=Buffer.allocUnsafe(t);var n=0;for(r=0;r<e.length;++r){var f=e[r];if(!Buffer.isBuffer(f)){throw new TypeError('"list" argument must be an Array of Buffers')}f.copy(i,n);n+=f.length}return i};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 i=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(i)return utf8ToBytes(e).length;t=(""+t).toLowerCase();i=true}}}Buffer.byteLength=byteLength;function slowToString(e,t,r){var i=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(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase();i=true}}}Buffer.prototype._isBuffer=true;function swap(e,t,r){var i=e[t];e[t]=e[r];e[r]=i}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,i,n){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(i===undefined){i=0}if(n===undefined){n=this.length}if(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}t>>>=0;r>>>=0;i>>>=0;n>>>=0;if(this===e)return 0;var a=n-i;var f=r-t;var s=Math.min(a,f);var o=this.slice(i,n);var c=e.slice(t,r);for(var u=0;u<s;++u){if(o[u]!==c[u]){a=o[u];f=c[u];break}}if(a<f)return-1;if(f<a)return 1;return 0};function bidirectionalIndexOf(e,t,r,i,n){if(e.length===0)return-1;if(typeof r==="string"){i=r;r=0}else if(r>2147483647){r=2147483647}else if(r<-2147483648){r=-2147483648}r=+r;if(isNaN(r)){r=n?0:e.length-1}if(r<0)r=e.length+r;if(r>=e.length){if(n)return-1;else r=e.length-1}else if(r<0){if(n)r=0;else return-1}if(typeof t==="string"){t=Buffer.from(t,i)}if(Buffer.isBuffer(t)){if(t.length===0){return-1}return arrayIndexOf(e,t,r,i,n)}else if(typeof t==="number"){t=t&255;if(Buffer.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf==="function"){if(n){return Uint8Array.prototype.indexOf.call(e,t,r)}else{return Uint8Array.prototype.lastIndexOf.call(e,t,r)}}return arrayIndexOf(e,[t],r,i,n)}throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(e,t,r,i,n){var a=1;var f=e.length;var s=t.length;if(i!==undefined){i=String(i).toLowerCase();if(i==="ucs2"||i==="ucs-2"||i==="utf16le"||i==="utf-16le"){if(e.length<2||t.length<2){return-1}a=2;f/=2;s/=2;r/=2}}function read(e,t){if(a===1){return e[t]}else{return e.readUInt16BE(t*a)}}var o;if(n){var c=-1;for(o=r;o<f;o++){if(read(e,o)===read(t,c===-1?0:o-c)){if(c===-1)c=o;if(o-c+1===s)return c*a}else{if(c!==-1)o-=o-c;c=-1}}}else{if(r+s>f)r=f-s;for(o=r;o>=0;o--){var u=true;for(var h=0;h<s;h++){if(read(e,o+h)!==read(t,h)){u=false;break}}if(u)return o}}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,i){r=Number(r)||0;var n=e.length-r;if(!i){i=n}else{i=Number(i);if(i>n){i=n}}var a=t.length;if(a%2!==0)throw new TypeError("Invalid hex string");if(i>a/2){i=a/2}for(var f=0;f<i;++f){var s=parseInt(t.substr(f*2,2),16);if(isNaN(s))return f;e[r+f]=s}return f}function utf8Write(e,t,r,i){return blitBuffer(utf8ToBytes(t,e.length-r),e,r,i)}function asciiWrite(e,t,r,i){return blitBuffer(asciiToBytes(t),e,r,i)}function latin1Write(e,t,r,i){return asciiWrite(e,t,r,i)}function base64Write(e,t,r,i){return blitBuffer(base64ToBytes(t),e,r,i)}function ucs2Write(e,t,r,i){return blitBuffer(utf16leToBytes(t,e.length-r),e,r,i)}Buffer.prototype.write=function write(e,t,r,i){if(t===undefined){i="utf8";r=this.length;t=0}else if(r===undefined&&typeof t==="string"){i=t;r=this.length;t=0}else if(isFinite(t)){t=t|0;if(isFinite(r)){r=r|0;if(i===undefined)i="utf8"}else{i=r;r=undefined}}else{throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported")}var n=this.length-t;if(r===undefined||r>n)r=n;if(e.length>0&&(r<0||t<0)||t>this.length){throw new RangeError("Attempt to write outside buffer bounds")}if(!i)i="utf8";var a=false;for(;;){switch(i){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: "+i);i=(""+i).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 i.fromByteArray(e)}else{return i.fromByteArray(e.slice(t,r))}}function utf8Slice(e,t,r){r=Math.min(e.length,r);var i=[];var n=t;while(n<r){var a=e[n];var f=null;var s=a>239?4:a>223?3:a>191?2:1;if(n+s<=r){var o,c,u,h;switch(s){case 1:if(a<128){f=a}break;case 2:o=e[n+1];if((o&192)===128){h=(a&31)<<6|o&63;if(h>127){f=h}}break;case 3:o=e[n+1];c=e[n+2];if((o&192)===128&&(c&192)===128){h=(a&15)<<12|(o&63)<<6|c&63;if(h>2047&&(h<55296||h>57343)){f=h}}break;case 4:o=e[n+1];c=e[n+2];u=e[n+3];if((o&192)===128&&(c&192)===128&&(u&192)===128){h=(a&15)<<18|(o&63)<<12|(c&63)<<6|u&63;if(h>65535&&h<1114112){f=h}}}}if(f===null){f=65533;s=1}else if(f>65535){f-=65536;i.push(f>>>10&1023|55296);f=56320|f&1023}i.push(f);n+=s}return decodeCodePointsArray(i)}var f=4096;function decodeCodePointsArray(e){var t=e.length;if(t<=f){return String.fromCharCode.apply(String,e)}var r="";var i=0;while(i<t){r+=String.fromCharCode.apply(String,e.slice(i,i+=f))}return r}function asciiSlice(e,t,r){var i="";r=Math.min(e.length,r);for(var n=t;n<r;++n){i+=String.fromCharCode(e[n]&127)}return i}function latin1Slice(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 hexSlice(e,t,r){var i=e.length;if(!t||t<0)t=0;if(!r||r<0||r>i)r=i;var n="";for(var a=t;a<r;++a){n+=toHex(e[a])}return n}function utf16leSlice(e,t,r){var i=e.slice(t,r);var n="";for(var a=0;a<i.length;a+=2){n+=String.fromCharCode(i[a]+i[a+1]*256)}return n}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 i;if(Buffer.TYPED_ARRAY_SUPPORT){i=this.subarray(e,t);i.__proto__=Buffer.prototype}else{var n=t-e;i=new Buffer(n,undefined);for(var a=0;a<n;++a){i[a]=this[a+e]}}return i};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 i=this[e];var n=1;var a=0;while(++a<t&&(n*=256)){i+=this[e+a]*n}return i};Buffer.prototype.readUIntBE=function readUIntBE(e,t,r){e=e|0;t=t|0;if(!r){checkOffset(e,t,this.length)}var i=this[e+--t];var n=1;while(t>0&&(n*=256)){i+=this[e+--t]*n}return i};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 i=this[e];var n=1;var a=0;while(++a<t&&(n*=256)){i+=this[e+a]*n}n*=128;if(i>=n)i-=Math.pow(2,8*t);return i};Buffer.prototype.readIntBE=function readIntBE(e,t,r){e=e|0;t=t|0;if(!r)checkOffset(e,t,this.length);var i=t;var n=1;var a=this[e+--i];while(i>0&&(n*=256)){a+=this[e+--i]*n}n*=128;if(a>=n)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 n.read(this,e,true,23,4)};Buffer.prototype.readFloatBE=function readFloatBE(e,t){if(!t)checkOffset(e,4,this.length);return n.read(this,e,false,23,4)};Buffer.prototype.readDoubleLE=function readDoubleLE(e,t){if(!t)checkOffset(e,8,this.length);return n.read(this,e,true,52,8)};Buffer.prototype.readDoubleBE=function readDoubleBE(e,t){if(!t)checkOffset(e,8,this.length);return n.read(this,e,false,52,8)};function checkInt(e,t,r,i,n,a){if(!Buffer.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||t<a)throw new RangeError('"value" argument is out of bounds');if(r+i>e.length)throw new RangeError("Index out of range")}Buffer.prototype.writeUIntLE=function writeUIntLE(e,t,r,i){e=+e;t=t|0;r=r|0;if(!i){var n=Math.pow(2,8*r)-1;checkInt(this,e,t,r,n,0)}var a=1;var f=0;this[t]=e&255;while(++f<r&&(a*=256)){this[t+f]=e/a&255}return t+r};Buffer.prototype.writeUIntBE=function writeUIntBE(e,t,r,i){e=+e;t=t|0;r=r|0;if(!i){var n=Math.pow(2,8*r)-1;checkInt(this,e,t,r,n,0)}var a=r-1;var f=1;this[t+a]=e&255;while(--a>=0&&(f*=256)){this[t+a]=e/f&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,i){if(t<0)t=65535+t+1;for(var n=0,a=Math.min(e.length-r,2);n<a;++n){e[r+n]=(t&255<<8*(i?n:1-n))>>>(i?n:1-n)*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,i){if(t<0)t=4294967295+t+1;for(var n=0,a=Math.min(e.length-r,4);n<a;++n){e[r+n]=t>>>(i?n:3-n)*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,i){e=+e;t=t|0;if(!i){var n=Math.pow(2,8*r-1);checkInt(this,e,t,r,n-1,-n)}var a=0;var f=1;var s=0;this[t]=e&255;while(++a<r&&(f*=256)){if(e<0&&s===0&&this[t+a-1]!==0){s=1}this[t+a]=(e/f>>0)-s&255}return t+r};Buffer.prototype.writeIntBE=function writeIntBE(e,t,r,i){e=+e;t=t|0;if(!i){var n=Math.pow(2,8*r-1);checkInt(this,e,t,r,n-1,-n)}var a=r-1;var f=1;var s=0;this[t+a]=e&255;while(--a>=0&&(f*=256)){if(e<0&&s===0&&this[t+a+1]!==0){s=1}this[t+a]=(e/f>>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,i,n,a){if(r+i>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function writeFloat(e,t,r,i,a){if(!a){checkIEEE754(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38)}n.write(e,t,r,i,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,i,a){if(!a){checkIEEE754(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308)}n.write(e,t,r,i,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,i){if(!r)r=0;if(!i&&i!==0)i=this.length;if(t>=e.length)t=e.length;if(!t)t=0;if(i>0&&i<r)i=r;if(i===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(i<0)throw new RangeError("sourceEnd out of bounds");if(i>this.length)i=this.length;if(e.length-t<i-r){i=e.length-t+r}var n=i-r;var a;if(this===e&&r<t&&t<i){for(a=n-1;a>=0;--a){e[a+t]=this[a+r]}}else if(n<1e3||!Buffer.TYPED_ARRAY_SUPPORT){for(a=0;a<n;++a){e[a+t]=this[a+r]}}else{Uint8Array.prototype.set.call(e,this.subarray(r,r+n),t)}return n};Buffer.prototype.fill=function fill(e,t,r,i){if(typeof e==="string"){if(typeof t==="string"){i=t;t=0;r=this.length}else if(typeof r==="string"){i=r;r=this.length}if(e.length===1){var n=e.charCodeAt(0);if(n<256){e=n}}if(i!==undefined&&typeof i!=="string"){throw new TypeError("encoding must be a string")}if(typeof i==="string"&&!Buffer.isEncoding(i)){throw new TypeError("Unknown encoding: "+i)}}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 f=Buffer.isBuffer(e)?e:utf8ToBytes(new Buffer(e,i).toString());var s=f.length;for(a=0;a<r-t;++a){this[a+t]=f[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 i=e.length;var n=null;var a=[];for(var f=0;f<i;++f){r=e.charCodeAt(f);if(r>55295&&r<57344){if(!n){if(r>56319){if((t-=3)>-1)a.push(239,191,189);continue}else if(f+1===i){if((t-=3)>-1)a.push(239,191,189);continue}n=r;continue}if(r<56320){if((t-=3)>-1)a.push(239,191,189);n=r;continue}r=(n-55296<<10|r-56320)+65536}else if(n){if((t-=3)>-1)a.push(239,191,189)}n=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,i,n;var a=[];for(var f=0;f<e.length;++f){if((t-=2)<0)break;r=e.charCodeAt(f);i=r>>8;n=r%256;a.push(n);a.push(i)}return a}function base64ToBytes(e){return i.toByteArray(base64clean(e))}function blitBuffer(e,t,r,i){for(var n=0;n<i;++n){if(n+r>=t.length||n>=e.length)break;t[n+r]=e[n]}return n}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 i;try{i=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 i=0;if(e[0]==="-"){i++}if(t===16){this._parseHex(e,i)}else{this._parseBase(e,t,i)}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 i=0;i<this.length;i++){this.words[i]=0}var n,a;var f=0;if(r==="be"){for(i=e.length-1,n=0;i>=0;i-=3){a=e[i]|e[i-1]<<8|e[i-2]<<16;this.words[n]|=a<<f&67108863;this.words[n+1]=a>>>26-f&67108863;f+=24;if(f>=26){f-=26;n++}}}else if(r==="le"){for(i=0,n=0;i<e.length;i+=3){a=e[i]|e[i+1]<<8|e[i+2]<<16;this.words[n]|=a<<f&67108863;this.words[n+1]=a>>>26-f&67108863;f+=24;if(f>=26){f-=26;n++}}}return this.strip()};function parseHex(e,t,r){var i=0;var n=Math.min(e.length,r);for(var a=t;a<n;a++){var f=e.charCodeAt(a)-48;i<<=4;if(f>=49&&f<=54){i|=f-49+10}else if(f>=17&&f<=22){i|=f-17+10}else{i|=f&15}}return i}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 i,n;var a=0;for(r=e.length-6,i=0;r>=t;r-=6){n=parseHex(e,r,r+6);this.words[i]|=n<<a&67108863;this.words[i+1]|=n>>>26-a&4194303;a+=24;if(a>=26){a-=26;i++}}if(r+6!==t){n=parseHex(e,t,r+6);this.words[i]|=n<<a&67108863;this.words[i+1]|=n>>>26-a&4194303}this.strip()};function parseBase(e,t,r,i){var n=0;var a=Math.min(e.length,r);for(var f=t;f<a;f++){var s=e.charCodeAt(f)-48;n*=i;if(s>=49){n+=s-49+10}else if(s>=17){n+=s-17+10}else{n+=s}}return n}BN.prototype._parseBase=function _parseBase(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;var a=e.length-r;var f=a%i;var s=Math.min(a,a-f)+r;var o=0;for(var c=r;c<s;c+=i){o=parseBase(e,c,c+i,t);this.imuln(n);if(this.words[0]+o<67108864){this.words[0]+=o}else{this._iaddn(o)}}if(f!==0){var u=1;o=parseBase(e,c,e.length,t);for(c=0;c<f;c++){u*=t}this.imuln(u);if(this.words[0]+o<67108864){this.words[0]+=o}else{this._iaddn(o)}}};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 n=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"];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 f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];BN.prototype.toString=function toString(e,t){e=e||10;t=t|0||1;var r;if(e===16||e==="hex"){r="";var i=0;var s=0;for(var o=0;o<this.length;o++){var c=this.words[o];var u=((c<<i|s)&16777215).toString(16);s=c>>>24-i&16777215;if(s!==0||o!==this.length-1){r=n[6-u.length]+u+r}else{r=u+r}i+=2;if(i>=26){i-=26;o--}}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 h=a[e];var d=f[e];r="";var l=this.clone();l.negative=0;while(!l.isZero()){var p=l.modn(d).toString(e);l=l.idivn(d);if(!l.isZero()){r=n[h-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 i!=="undefined");return this.toArrayLike(i,e,t)};BN.prototype.toArray=function toArray(e,t){return this.toArrayLike(Array,e,t)};BN.prototype.toArrayLike=function toArrayLike(e,t,r){var i=this.byteLength();var n=r||Math.max(1,i);assert(i<=n,"byte array longer than desired length");assert(n>0,"Requested array length <= 0");this.strip();var a=t==="le";var f=new e(n);var s,o;var c=this.clone();if(!a){for(o=0;o<n-i;o++){f[o]=0}for(o=0;!c.isZero();o++){s=c.andln(255);c.iushrn(8);f[n-o-1]=s}}else{for(o=0;!c.isZero();o++){s=c.andln(255);c.iushrn(8);f[o]=s}for(;o<n;o++){f[o]=0}}return f};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 i=r/26|0;var n=r%26;t[r]=(e.words[i]&1<<n)>>>n}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 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]}}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 i=0;i<t;i++){this.words[i]=~this.words[i]&67108863}if(r>0){this.words[i]=~this.words[i]&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 i=e%26;this._expand(r+1);if(t){this.words[r]=this.words[r]|1<<i}else{this.words[r]=this.words[r]&~(1<<i)}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,i;if(this.length>e.length){r=this;i=e}else{r=e;i=this}var n=0;for(var a=0;a<i.length;a++){t=(r.words[a]|0)+(i.words[a]|0)+n;this.words[a]=t&67108863;n=t>>>26}for(;n!==0&&a<r.length;a++){t=(r.words[a]|0)+n;this.words[a]=t&67108863;n=t>>>26}this.length=r.length;if(n!==0){this.words[this.length]=n;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 i,n;if(r>0){i=this;n=e}else{i=e;n=this}var a=0;for(var f=0;f<n.length;f++){t=(i.words[f]|0)-(n.words[f]|0)+a;a=t>>26;this.words[f]=t&67108863}for(;a!==0&&f<i.length;f++){t=(i.words[f]|0)+a;a=t>>26;this.words[f]=t&67108863}if(a===0&&f<i.length&&i!==this){for(;f<i.length;f++){this.words[f]=i.words[f]}}this.length=Math.max(this.length,f);if(i!==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 i=e.length+t.length|0;r.length=i;i=i-1|0;var n=e.words[0]|0;var a=t.words[0]|0;var f=n*a;var s=f&67108863;var o=f/67108864|0;r.words[0]=s;for(var c=1;c<i;c++){var u=o>>>26;var h=o&67108863;var d=Math.min(c,t.length-1);for(var l=Math.max(0,c-e.length+1);l<=d;l++){var p=c-l|0;n=e.words[p]|0;a=t.words[l]|0;f=n*a+h;u+=f/67108864|0;h=f&67108863}r.words[c]=h|0;o=u|0}if(o!==0){r.words[c]=o|0}else{r.length--}return r.strip()}var s=function comb10MulTo(e,t,r){var i=e.words;var n=t.words;var a=r.words;var f=0;var s;var o;var c;var u=i[0]|0;var h=u&8191;var d=u>>>13;var l=i[1]|0;var p=l&8191;var v=l>>>13;var b=i[2]|0;var y=b&8191;var m=b>>>13;var g=i[3]|0;var w=g&8191;var E=g>>>13;var _=i[4]|0;var B=_&8191;var A=_>>>13;var S=i[5]|0;var F=S&8191;var C=S>>>13;var M=i[6]|0;var k=M&8191;var D=M>>>13;var x=i[7]|0;var I=x&8191;var P=x>>>13;var T=i[8]|0;var R=T&8191;var N=T>>>13;var U=i[9]|0;var L=U&8191;var O=U>>>13;var j=n[0]|0;var K=j&8191;var H=j>>>13;var q=n[1]|0;var z=q&8191;var W=q>>>13;var G=n[2]|0;var X=G&8191;var Y=G>>>13;var V=n[3]|0;var J=V&8191;var Z=V>>>13;var Q=n[4]|0;var $=Q&8191;var ee=Q>>>13;var te=n[5]|0;var re=te&8191;var ie=te>>>13;var ne=n[6]|0;var ae=ne&8191;var fe=ne>>>13;var se=n[7]|0;var oe=se&8191;var ce=se>>>13;var ue=n[8]|0;var he=ue&8191;var de=ue>>>13;var le=n[9]|0;var pe=le&8191;var ve=le>>>13;r.negative=e.negative^t.negative;r.length=19;s=Math.imul(h,K);o=Math.imul(h,H);o=o+Math.imul(d,K)|0;c=Math.imul(d,H);var be=(f+s|0)+((o&8191)<<13)|0;f=(c+(o>>>13)|0)+(be>>>26)|0;be&=67108863;s=Math.imul(p,K);o=Math.imul(p,H);o=o+Math.imul(v,K)|0;c=Math.imul(v,H);s=s+Math.imul(h,z)|0;o=o+Math.imul(h,W)|0;o=o+Math.imul(d,z)|0;c=c+Math.imul(d,W)|0;var ye=(f+s|0)+((o&8191)<<13)|0;f=(c+(o>>>13)|0)+(ye>>>26)|0;ye&=67108863;s=Math.imul(y,K);o=Math.imul(y,H);o=o+Math.imul(m,K)|0;c=Math.imul(m,H);s=s+Math.imul(p,z)|0;o=o+Math.imul(p,W)|0;o=o+Math.imul(v,z)|0;c=c+Math.imul(v,W)|0;s=s+Math.imul(h,X)|0;o=o+Math.imul(h,Y)|0;o=o+Math.imul(d,X)|0;c=c+Math.imul(d,Y)|0;var me=(f+s|0)+((o&8191)<<13)|0;f=(c+(o>>>13)|0)+(me>>>26)|0;me&=67108863;s=Math.imul(w,K);o=Math.imul(w,H);o=o+Math.imul(E,K)|0;c=Math.imul(E,H);s=s+Math.imul(y,z)|0;o=o+Math.imul(y,W)|0;o=o+Math.imul(m,z)|0;c=c+Math.imul(m,W)|0;s=s+Math.imul(p,X)|0;o=o+Math.imul(p,Y)|0;o=o+Math.imul(v,X)|0;c=c+Math.imul(v,Y)|0;s=s+Math.imul(h,J)|0;o=o+Math.imul(h,Z)|0;o=o+Math.imul(d,J)|0;c=c+Math.imul(d,Z)|0;var ge=(f+s|0)+((o&8191)<<13)|0;f=(c+(o>>>13)|0)+(ge>>>26)|0;ge&=67108863;s=Math.imul(B,K);o=Math.imul(B,H);o=o+Math.imul(A,K)|0;c=Math.imul(A,H);s=s+Math.imul(w,z)|0;o=o+Math.imul(w,W)|0;o=o+Math.imul(E,z)|0;c=c+Math.imul(E,W)|0;s=s+Math.imul(y,X)|0;o=o+Math.imul(y,Y)|0;o=o+Math.imul(m,X)|0;c=c+Math.imul(m,Y)|0;s=s+Math.imul(p,J)|0;o=o+Math.imul(p,Z)|0;o=o+Math.imul(v,J)|0;c=c+Math.imul(v,Z)|0;s=s+Math.imul(h,$)|0;o=o+Math.imul(h,ee)|0;o=o+Math.imul(d,$)|0;c=c+Math.imul(d,ee)|0;var we=(f+s|0)+((o&8191)<<13)|0;f=(c+(o>>>13)|0)+(we>>>26)|0;we&=67108863;s=Math.imul(F,K);o=Math.imul(F,H);o=o+Math.imul(C,K)|0;c=Math.imul(C,H);s=s+Math.imul(B,z)|0;o=o+Math.imul(B,W)|0;o=o+Math.imul(A,z)|0;c=c+Math.imul(A,W)|0;s=s+Math.imul(w,X)|0;o=o+Math.imul(w,Y)|0;o=o+Math.imul(E,X)|0;c=c+Math.imul(E,Y)|0;s=s+Math.imul(y,J)|0;o=o+Math.imul(y,Z)|0;o=o+Math.imul(m,J)|0;c=c+Math.imul(m,Z)|0;s=s+Math.imul(p,$)|0;o=o+Math.imul(p,ee)|0;o=o+Math.imul(v,$)|0;c=c+Math.imul(v,ee)|0;s=s+Math.imul(h,re)|0;o=o+Math.imul(h,ie)|0;o=o+Math.imul(d,re)|0;c=c+Math.imul(d,ie)|0;var Ee=(f+s|0)+((o&8191)<<13)|0;f=(c+(o>>>13)|0)+(Ee>>>26)|0;Ee&=67108863;s=Math.imul(k,K);o=Math.imul(k,H);o=o+Math.imul(D,K)|0;c=Math.imul(D,H);s=s+Math.imul(F,z)|0;o=o+Math.imul(F,W)|0;o=o+Math.imul(C,z)|0;c=c+Math.imul(C,W)|0;s=s+Math.imul(B,X)|0;o=o+Math.imul(B,Y)|0;o=o+Math.imul(A,X)|0;c=c+Math.imul(A,Y)|0;s=s+Math.imul(w,J)|0;o=o+Math.imul(w,Z)|0;o=o+Math.imul(E,J)|0;c=c+Math.imul(E,Z)|0;s=s+Math.imul(y,$)|0;o=o+Math.imul(y,ee)|0;o=o+Math.imul(m,$)|0;c=c+Math.imul(m,ee)|0;s=s+Math.imul(p,re)|0;o=o+Math.imul(p,ie)|0;o=o+Math.imul(v,re)|0;c=c+Math.imul(v,ie)|0;s=s+Math.imul(h,ae)|0;o=o+Math.imul(h,fe)|0;o=o+Math.imul(d,ae)|0;c=c+Math.imul(d,fe)|0;var _e=(f+s|0)+((o&8191)<<13)|0;f=(c+(o>>>13)|0)+(_e>>>26)|0;_e&=67108863;s=Math.imul(I,K);o=Math.imul(I,H);o=o+Math.imul(P,K)|0;c=Math.imul(P,H);s=s+Math.imul(k,z)|0;o=o+Math.imul(k,W)|0;o=o+Math.imul(D,z)|0;c=c+Math.imul(D,W)|0;s=s+Math.imul(F,X)|0;o=o+Math.imul(F,Y)|0;o=o+Math.imul(C,X)|0;c=c+Math.imul(C,Y)|0;s=s+Math.imul(B,J)|0;o=o+Math.imul(B,Z)|0;o=o+Math.imul(A,J)|0;c=c+Math.imul(A,Z)|0;s=s+Math.imul(w,$)|0;o=o+Math.imul(w,ee)|0;o=o+Math.imul(E,$)|0;c=c+Math.imul(E,ee)|0;s=s+Math.imul(y,re)|0;o=o+Math.imul(y,ie)|0;o=o+Math.imul(m,re)|0;c=c+Math.imul(m,ie)|0;s=s+Math.imul(p,ae)|0;o=o+Math.imul(p,fe)|0;o=o+Math.imul(v,ae)|0;c=c+Math.imul(v,fe)|0;s=s+Math.imul(h,oe)|0;o=o+Math.imul(h,ce)|0;o=o+Math.imul(d,oe)|0;c=c+Math.imul(d,ce)|0;var Be=(f+s|0)+((o&8191)<<13)|0;f=(c+(o>>>13)|0)+(Be>>>26)|0;Be&=67108863;s=Math.imul(R,K);o=Math.imul(R,H);o=o+Math.imul(N,K)|0;c=Math.imul(N,H);s=s+Math.imul(I,z)|0;o=o+Math.imul(I,W)|0;o=o+Math.imul(P,z)|0;c=c+Math.imul(P,W)|0;s=s+Math.imul(k,X)|0;o=o+Math.imul(k,Y)|0;o=o+Math.imul(D,X)|0;c=c+Math.imul(D,Y)|0;s=s+Math.imul(F,J)|0;o=o+Math.imul(F,Z)|0;o=o+Math.imul(C,J)|0;c=c+Math.imul(C,Z)|0;s=s+Math.imul(B,$)|0;o=o+Math.imul(B,ee)|0;o=o+Math.imul(A,$)|0;c=c+Math.imul(A,ee)|0;s=s+Math.imul(w,re)|0;o=o+Math.imul(w,ie)|0;o=o+Math.imul(E,re)|0;c=c+Math.imul(E,ie)|0;s=s+Math.imul(y,ae)|0;o=o+Math.imul(y,fe)|0;o=o+Math.imul(m,ae)|0;c=c+Math.imul(m,fe)|0;s=s+Math.imul(p,oe)|0;o=o+Math.imul(p,ce)|0;o=o+Math.imul(v,oe)|0;c=c+Math.imul(v,ce)|0;s=s+Math.imul(h,he)|0;o=o+Math.imul(h,de)|0;o=o+Math.imul(d,he)|0;c=c+Math.imul(d,de)|0;var Ae=(f+s|0)+((o&8191)<<13)|0;f=(c+(o>>>13)|0)+(Ae>>>26)|0;Ae&=67108863;s=Math.imul(L,K);o=Math.imul(L,H);o=o+Math.imul(O,K)|0;c=Math.imul(O,H);s=s+Math.imul(R,z)|0;o=o+Math.imul(R,W)|0;o=o+Math.imul(N,z)|0;c=c+Math.imul(N,W)|0;s=s+Math.imul(I,X)|0;o=o+Math.imul(I,Y)|0;o=o+Math.imul(P,X)|0;c=c+Math.imul(P,Y)|0;s=s+Math.imul(k,J)|0;o=o+Math.imul(k,Z)|0;o=o+Math.imul(D,J)|0;c=c+Math.imul(D,Z)|0;s=s+Math.imul(F,$)|0;o=o+Math.imul(F,ee)|0;o=o+Math.imul(C,$)|0;c=c+Math.imul(C,ee)|0;s=s+Math.imul(B,re)|0;o=o+Math.imul(B,ie)|0;o=o+Math.imul(A,re)|0;c=c+Math.imul(A,ie)|0;s=s+Math.imul(w,ae)|0;o=o+Math.imul(w,fe)|0;o=o+Math.imul(E,ae)|0;c=c+Math.imul(E,fe)|0;s=s+Math.imul(y,oe)|0;o=o+Math.imul(y,ce)|0;o=o+Math.imul(m,oe)|0;c=c+Math.imul(m,ce)|0;s=s+Math.imul(p,he)|0;o=o+Math.imul(p,de)|0;o=o+Math.imul(v,he)|0;c=c+Math.imul(v,de)|0;s=s+Math.imul(h,pe)|0;o=o+Math.imul(h,ve)|0;o=o+Math.imul(d,pe)|0;c=c+Math.imul(d,ve)|0;var Se=(f+s|0)+((o&8191)<<13)|0;f=(c+(o>>>13)|0)+(Se>>>26)|0;Se&=67108863;s=Math.imul(L,z);o=Math.imul(L,W);o=o+Math.imul(O,z)|0;c=Math.imul(O,W);s=s+Math.imul(R,X)|0;o=o+Math.imul(R,Y)|0;o=o+Math.imul(N,X)|0;c=c+Math.imul(N,Y)|0;s=s+Math.imul(I,J)|0;o=o+Math.imul(I,Z)|0;o=o+Math.imul(P,J)|0;c=c+Math.imul(P,Z)|0;s=s+Math.imul(k,$)|0;o=o+Math.imul(k,ee)|0;o=o+Math.imul(D,$)|0;c=c+Math.imul(D,ee)|0;s=s+Math.imul(F,re)|0;o=o+Math.imul(F,ie)|0;o=o+Math.imul(C,re)|0;c=c+Math.imul(C,ie)|0;s=s+Math.imul(B,ae)|0;o=o+Math.imul(B,fe)|0;o=o+Math.imul(A,ae)|0;c=c+Math.imul(A,fe)|0;s=s+Math.imul(w,oe)|0;o=o+Math.imul(w,ce)|0;o=o+Math.imul(E,oe)|0;c=c+Math.imul(E,ce)|0;s=s+Math.imul(y,he)|0;o=o+Math.imul(y,de)|0;o=o+Math.imul(m,he)|0;c=c+Math.imul(m,de)|0;s=s+Math.imul(p,pe)|0;o=o+Math.imul(p,ve)|0;o=o+Math.imul(v,pe)|0;c=c+Math.imul(v,ve)|0;var Fe=(f+s|0)+((o&8191)<<13)|0;f=(c+(o>>>13)|0)+(Fe>>>26)|0;Fe&=67108863;s=Math.imul(L,X);o=Math.imul(L,Y);o=o+Math.imul(O,X)|0;c=Math.imul(O,Y);s=s+Math.imul(R,J)|0;o=o+Math.imul(R,Z)|0;o=o+Math.imul(N,J)|0;c=c+Math.imul(N,Z)|0;s=s+Math.imul(I,$)|0;o=o+Math.imul(I,ee)|0;o=o+Math.imul(P,$)|0;c=c+Math.imul(P,ee)|0;s=s+Math.imul(k,re)|0;o=o+Math.imul(k,ie)|0;o=o+Math.imul(D,re)|0;c=c+Math.imul(D,ie)|0;s=s+Math.imul(F,ae)|0;o=o+Math.imul(F,fe)|0;o=o+Math.imul(C,ae)|0;c=c+Math.imul(C,fe)|0;s=s+Math.imul(B,oe)|0;o=o+Math.imul(B,ce)|0;o=o+Math.imul(A,oe)|0;c=c+Math.imul(A,ce)|0;s=s+Math.imul(w,he)|0;o=o+Math.imul(w,de)|0;o=o+Math.imul(E,he)|0;c=c+Math.imul(E,de)|0;s=s+Math.imul(y,pe)|0;o=o+Math.imul(y,ve)|0;o=o+Math.imul(m,pe)|0;c=c+Math.imul(m,ve)|0;var Ce=(f+s|0)+((o&8191)<<13)|0;f=(c+(o>>>13)|0)+(Ce>>>26)|0;Ce&=67108863;s=Math.imul(L,J);o=Math.imul(L,Z);o=o+Math.imul(O,J)|0;c=Math.imul(O,Z);s=s+Math.imul(R,$)|0;o=o+Math.imul(R,ee)|0;o=o+Math.imul(N,$)|0;c=c+Math.imul(N,ee)|0;s=s+Math.imul(I,re)|0;o=o+Math.imul(I,ie)|0;o=o+Math.imul(P,re)|0;c=c+Math.imul(P,ie)|0;s=s+Math.imul(k,ae)|0;o=o+Math.imul(k,fe)|0;o=o+Math.imul(D,ae)|0;c=c+Math.imul(D,fe)|0;s=s+Math.imul(F,oe)|0;o=o+Math.imul(F,ce)|0;o=o+Math.imul(C,oe)|0;c=c+Math.imul(C,ce)|0;s=s+Math.imul(B,he)|0;o=o+Math.imul(B,de)|0;o=o+Math.imul(A,he)|0;c=c+Math.imul(A,de)|0;s=s+Math.imul(w,pe)|0;o=o+Math.imul(w,ve)|0;o=o+Math.imul(E,pe)|0;c=c+Math.imul(E,ve)|0;var Me=(f+s|0)+((o&8191)<<13)|0;f=(c+(o>>>13)|0)+(Me>>>26)|0;Me&=67108863;s=Math.imul(L,$);o=Math.imul(L,ee);o=o+Math.imul(O,$)|0;c=Math.imul(O,ee);s=s+Math.imul(R,re)|0;o=o+Math.imul(R,ie)|0;o=o+Math.imul(N,re)|0;c=c+Math.imul(N,ie)|0;s=s+Math.imul(I,ae)|0;o=o+Math.imul(I,fe)|0;o=o+Math.imul(P,ae)|0;c=c+Math.imul(P,fe)|0;s=s+Math.imul(k,oe)|0;o=o+Math.imul(k,ce)|0;o=o+Math.imul(D,oe)|0;c=c+Math.imul(D,ce)|0;s=s+Math.imul(F,he)|0;o=o+Math.imul(F,de)|0;o=o+Math.imul(C,he)|0;c=c+Math.imul(C,de)|0;s=s+Math.imul(B,pe)|0;o=o+Math.imul(B,ve)|0;o=o+Math.imul(A,pe)|0;c=c+Math.imul(A,ve)|0;var ke=(f+s|0)+((o&8191)<<13)|0;f=(c+(o>>>13)|0)+(ke>>>26)|0;ke&=67108863;s=Math.imul(L,re);o=Math.imul(L,ie);o=o+Math.imul(O,re)|0;c=Math.imul(O,ie);s=s+Math.imul(R,ae)|0;o=o+Math.imul(R,fe)|0;o=o+Math.imul(N,ae)|0;c=c+Math.imul(N,fe)|0;s=s+Math.imul(I,oe)|0;o=o+Math.imul(I,ce)|0;o=o+Math.imul(P,oe)|0;c=c+Math.imul(P,ce)|0;s=s+Math.imul(k,he)|0;o=o+Math.imul(k,de)|0;o=o+Math.imul(D,he)|0;c=c+Math.imul(D,de)|0;s=s+Math.imul(F,pe)|0;o=o+Math.imul(F,ve)|0;o=o+Math.imul(C,pe)|0;c=c+Math.imul(C,ve)|0;var De=(f+s|0)+((o&8191)<<13)|0;f=(c+(o>>>13)|0)+(De>>>26)|0;De&=67108863;s=Math.imul(L,ae);o=Math.imul(L,fe);o=o+Math.imul(O,ae)|0;c=Math.imul(O,fe);s=s+Math.imul(R,oe)|0;o=o+Math.imul(R,ce)|0;o=o+Math.imul(N,oe)|0;c=c+Math.imul(N,ce)|0;s=s+Math.imul(I,he)|0;o=o+Math.imul(I,de)|0;o=o+Math.imul(P,he)|0;c=c+Math.imul(P,de)|0;s=s+Math.imul(k,pe)|0;o=o+Math.imul(k,ve)|0;o=o+Math.imul(D,pe)|0;c=c+Math.imul(D,ve)|0;var xe=(f+s|0)+((o&8191)<<13)|0;f=(c+(o>>>13)|0)+(xe>>>26)|0;xe&=67108863;s=Math.imul(L,oe);o=Math.imul(L,ce);o=o+Math.imul(O,oe)|0;c=Math.imul(O,ce);s=s+Math.imul(R,he)|0;o=o+Math.imul(R,de)|0;o=o+Math.imul(N,he)|0;c=c+Math.imul(N,de)|0;s=s+Math.imul(I,pe)|0;o=o+Math.imul(I,ve)|0;o=o+Math.imul(P,pe)|0;c=c+Math.imul(P,ve)|0;var Ie=(f+s|0)+((o&8191)<<13)|0;f=(c+(o>>>13)|0)+(Ie>>>26)|0;Ie&=67108863;s=Math.imul(L,he);o=Math.imul(L,de);o=o+Math.imul(O,he)|0;c=Math.imul(O,de);s=s+Math.imul(R,pe)|0;o=o+Math.imul(R,ve)|0;o=o+Math.imul(N,pe)|0;c=c+Math.imul(N,ve)|0;var Pe=(f+s|0)+((o&8191)<<13)|0;f=(c+(o>>>13)|0)+(Pe>>>26)|0;Pe&=67108863;s=Math.imul(L,pe);o=Math.imul(L,ve);o=o+Math.imul(O,pe)|0;c=Math.imul(O,ve);var Te=(f