diff options
Diffstat (limited to 'src/js/node/crypto.js')
-rw-r--r-- | src/js/node/crypto.js | 12183 |
1 files changed, 75 insertions, 12108 deletions
diff --git a/src/js/node/crypto.js b/src/js/node/crypto.js index 0e4840d38..351f6adff 100644 --- a/src/js/node/crypto.js +++ b/src/js/node/crypto.js @@ -1,18 +1,14 @@ // Hardcoded module "node:crypto" -var __create = Object.create; var __defProp = Object.defineProperty; -var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; -var __getProtoOf = Object.getPrototypeOf, - __hasOwnProp = Object.prototype.hasOwnProperty; -import { StringDecoder } from "node:string_decoder"; -import * as BufferModule from "node:buffer"; -import * as StreamModule from "node:stream"; +const StreamModule = require("node:stream"); +const BufferModule = require("node:buffer"); +const StringDecoder = require("node:string_decoder").StringDecoder; const MAX_STRING_LENGTH = 536870888; var Buffer = globalThis.Buffer; const EMPTY_BUFFER = Buffer.alloc(0); -const { isAnyArrayBuffer, isArrayBufferView } = require("util/types"); +const { isAnyArrayBuffer, isArrayBufferView } = require("node:util/types"); function getArrayBufferOrView(buffer, name, encoding) { if (isAnyArrayBuffer(buffer)) return buffer; @@ -34,38 +30,13 @@ function getArrayBufferOrView(buffer, name, encoding) { const crypto = globalThis.crypto; const globalCrypto = crypto; -var __esm = (fn, res) => - function () { - return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])((fn = 0))), res; - }; var __commonJS = (cb, mod) => function () { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __export = (target, all) => { - for (var name in all) __defProp(target, name, { get: all[name], enumerable: !0 }); - }, - __copyProps = (to, from, except, desc) => { - if ((from && typeof from == "object") || typeof from == "function") - for (let key of __getOwnPropNames(from)) - !__hasOwnProp.call(to, key) && - key !== except && - __defProp(to, key, { - get: () => from[key], - enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable, - }); - return to; - }, - __reExport = (target, mod, secondTarget) => ( - __copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default") - ), - __toESM = (mod, isNodeMode, target) => ( - (target = mod != null ? __create(__getProtoOf(mod)) : {}), - __copyProps( - isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target, - mod, - ) - ); + for (var name in all) __defProp(target, name, { get: all[name], enumerable: !0 }); +}; // node_modules/safe-buffer/index.js var require_safe_buffer = __commonJS({ @@ -138,28 +109,18 @@ Use Chrome, Firefox or Internet Explorer 11`); // node_modules/inherits/inherits_browser.js var require_inherits_browser = __commonJS({ "node_modules/inherits/inherits_browser.js"(exports, module) { - typeof Object.create == "function" - ? (module.exports = function (ctor, superCtor) { - superCtor && - ((ctor.super_ = superCtor), - (ctor.prototype = Object.create(superCtor.prototype, { - constructor: { - value: ctor, - enumerable: !1, - writable: !0, - configurable: !0, - }, - }))); - }) - : (module.exports = function (ctor, superCtor) { - if (superCtor) { - ctor.super_ = superCtor; - var TempCtor = function () {}; - (TempCtor.prototype = superCtor.prototype), - (ctor.prototype = new TempCtor()), - (ctor.prototype.constructor = ctor); - } - }); + module.exports = function (ctor, superCtor) { + superCtor && + ((ctor.super_ = superCtor), + (ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: !1, + writable: !0, + configurable: !0, + }, + }))); + }; }, }); @@ -496,6 +457,7 @@ var require_hash = __commonJS({ (this._blockSize = blockSize), (this._len = 0); } + Hash.prototype = {}; Hash.prototype.update = function (data, enc) { typeof data == "string" && ((enc = enc || "utf8"), (data = Buffer2.from(data, enc))); for ( @@ -1149,7 +1111,7 @@ var require_cipher_base = __commonJS({ // node_modules/create-hash/browser.js var require_browser2 = __commonJS({ "node_modules/create-hash/browser.js"(exports, module) { - ("use strict"); + "use strict"; // does not become a node stream unless you create it into one const LazyHash = function Hash(algorithm, options) { this._options = options; @@ -1329,6 +1291,7 @@ var require_legacy = __commonJS({ (ipad[i] = key[i] ^ 54), (opad[i] = key[i] ^ 92); this._hash = [ipad]; } + Hmac.prototype = {}; inherits(Hmac, Base); Hmac.prototype._update = function (data) { this._hash.push(data); @@ -1355,14 +1318,14 @@ var require_md52 = __commonJS({ var require_browser3 = __commonJS({ "node_modules/create-hmac/browser.js"(exports, module) { "use strict"; - var inherits = require_inherits_browser(), - Legacy = require_legacy(), - Base = require_cipher_base(), - Buffer2 = require_safe_buffer().Buffer, - md5 = require_md52(), - RIPEMD160 = require_ripemd160(), - sha = require_sha2(), - ZEROS = Buffer2.alloc(128); + var inherits = require_inherits_browser(); + var Legacy = require_legacy(); + var Base = require_cipher_base(); + var Buffer2 = require_safe_buffer().Buffer; + var md5 = require_md52(); + var RIPEMD160 = require_ripemd160(); + var sha = require_sha2(); + var ZEROS = Buffer2.alloc(128); function Hmac(alg, key) { Base.call(this, "digest"), typeof key == "string" && (key = Buffer2.from(key)); var blocksize = alg === "sha512" || alg === "sha384" ? 128 : 64; @@ -1653,6 +1616,7 @@ var require_sync_browser = __commonJS({ (this.hash = hash), (this.size = sizes[alg]); } + Hmac.prototype = {}; Hmac.prototype.run = function (data, ipad) { data.copy(ipad, this.blocksize); var h = this.hash(ipad); @@ -1958,6 +1922,7 @@ var require_cipher = __commonJS({ (this.buffer = new Array(this.blockSize)), (this.bufferOff = 0); } + Cipher.prototype = {}; module.exports = Cipher; Cipher.prototype._init = function () {}; Cipher.prototype.update = function (data) { @@ -2778,6 +2743,7 @@ var require_aes = __commonJS({ function AES(key) { (this._key = asUInt32Array(key)), this._reset(); } + AES.prototype = {}; AES.blockSize = 4 * 4; AES.keySize = 256 / 8; AES.prototype.blockSize = AES.blockSize; @@ -2882,6 +2848,7 @@ var require_ghash = __commonJS({ function GHASH(key) { (this.h = key), (this.state = Buffer2.alloc(16, 0)), (this.cache = Buffer2.allocUnsafe(0)); } + GHASH.prototype = {}; GHASH.prototype.ghash = function (block) { for (var i = -1; ++i < block.length; ) this.state[i] ^= block[i]; this._multiply(); @@ -3102,6 +3069,7 @@ var require_encrypter = __commonJS({ function Splitter() { this.cache = Buffer2.allocUnsafe(0); } + Splitter.prototype = {}; Splitter.prototype.add = function (data) { this.cache = Buffer2.concat([this.cache, data]); }; @@ -3191,6 +3159,7 @@ var require_decrypter = __commonJS({ function Splitter() { this.cache = Buffer2.allocUnsafe(0); } + Splitter.prototype = {}; Splitter.prototype.add = function (data) { this.cache = Buffer2.concat([this.cache, data]); }; @@ -3367,6 +3336,7 @@ var require_bn = __commonJS({ ((base === "le" || base === "be") && ((endian = base), (base = 10)), this._init(number || 0, base || 10, endian || "be")); } + BN.prototype = {}; typeof module2 == "object" ? (module2.exports = BN) : (exports2.BN = BN), (BN.BN = BN), (BN.wordSize = 26); var Buffer2 = Buffer; (BN.isBN = function (num) { @@ -4432,6 +4402,7 @@ var require_bn = __commonJS({ function FFTM(x, y) { (this.x = x), (this.y = y); } + FFTM.prototype = {}; (FFTM.prototype.makeRBT = function (N) { for (var t = new Array(N), l = BN.prototype._countBits(N) - 1, i = 0; i < N; i++) t[i] = this.revBin(i, l, N); return t; @@ -5072,6 +5043,7 @@ var require_bn = __commonJS({ (this.k = new BN(1).iushln(this.n).isub(this.p)), (this.tmp = this._tmp()); } + MPrime.prototype = {}; (MPrime.prototype._tmp = function () { var tmp = new BN(null); return (tmp.words = new Array(Math.ceil(this.n / 13))), tmp; @@ -5165,6 +5137,7 @@ var require_bn = __commonJS({ (this.m = prime.p), (this.prime = prime); } else assert(m.gtn(1), "modulus must be greater than 1"), (this.m = m), (this.prime = null); } + Red.prototype = {}; (Red.prototype._verify1 = function (a) { assert(a.negative === 0, "red works only with positives"), assert(a.red, "red works only with red numbers"); }), @@ -5328,1998 +5301,7 @@ var require_bn = __commonJS({ })(typeof module > "u" || module, exports); }, }); - -// node_modules/miller-rabin/node_modules/bn.js/lib/bn.js -var require_bn2 = __commonJS({ - "node_modules/miller-rabin/node_modules/bn.js/lib/bn.js"(exports, module) { - (function (module2, exports2) { - "use strict"; - function assert(val, msg) { - if (!val) throw new Error(msg || "Assertion failed"); - } - function inherits(ctor, superCtor) { - ctor.super_ = superCtor; - var TempCtor = function () {}; - (TempCtor.prototype = superCtor.prototype), - (ctor.prototype = new TempCtor()), - (ctor.prototype.constructor = ctor); - } - function BN(number, base, endian) { - if (BN.isBN(number)) return number; - (this.negative = 0), - (this.words = null), - (this.length = 0), - (this.red = null), - number !== null && - ((base === "le" || base === "be") && ((endian = base), (base = 10)), - this._init(number || 0, base || 10, endian || "be")); - } - typeof module2 == "object" ? (module2.exports = BN) : (exports2.BN = BN), (BN.BN = BN), (BN.wordSize = 26); - var Buffer2 = Buffer; - (BN.isBN = function (num) { - return num instanceof BN - ? !0 - : num !== null && - typeof num == "object" && - num.constructor.wordSize === BN.wordSize && - Array.isArray(num.words); - }), - (BN.max = function (left, right) { - return left.cmp(right) > 0 ? left : right; - }), - (BN.min = function (left, right) { - return left.cmp(right) < 0 ? left : right; - }), - (BN.prototype._init = function (number, base, endian) { - if (typeof number == "number") return this._initNumber(number, base, endian); - if (typeof number == "object") return this._initArray(number, base, endian); - base === "hex" && (base = 16), - assert(base === (base | 0) && base >= 2 && base <= 36), - (number = number.toString().replace(/\s+/g, "")); - var start = 0; - number[0] === "-" && (start++, (this.negative = 1)), - start < number.length && - (base === 16 - ? this._parseHex(number, start, endian) - : (this._parseBase(number, base, start), - endian === "le" && this._initArray(this.toArray(), base, endian))); - }), - (BN.prototype._initNumber = function (number, base, endian) { - number < 0 && ((this.negative = 1), (number = -number)), - number < 67108864 - ? ((this.words = [number & 67108863]), (this.length = 1)) - : number < 4503599627370496 - ? ((this.words = [number & 67108863, (number / 67108864) & 67108863]), (this.length = 2)) - : (assert(number < 9007199254740992), - (this.words = [number & 67108863, (number / 67108864) & 67108863, 1]), - (this.length = 3)), - endian === "le" && this._initArray(this.toArray(), base, endian); - }), - (BN.prototype._initArray = function (number, base, endian) { - if ((assert(typeof number.length == "number"), number.length <= 0)) - return (this.words = [0]), (this.length = 1), this; - (this.length = Math.ceil(number.length / 3)), (this.words = new Array(this.length)); - for (var i = 0; i < this.length; i++) this.words[i] = 0; - var j, - w, - off = 0; - if (endian === "be") - for (i = number.length - 1, j = 0; i >= 0; i -= 3) - (w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16)), - (this.words[j] |= (w << off) & 67108863), - (this.words[j + 1] = (w >>> (26 - off)) & 67108863), - (off += 24), - off >= 26 && ((off -= 26), j++); - else if (endian === "le") - for (i = 0, j = 0; i < number.length; i += 3) - (w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16)), - (this.words[j] |= (w << off) & 67108863), - (this.words[j + 1] = (w >>> (26 - off)) & 67108863), - (off += 24), - off >= 26 && ((off -= 26), j++); - return this.strip(); - }); - function parseHex4Bits(string, index) { - var c = string.charCodeAt(index); - return c >= 65 && c <= 70 ? c - 55 : c >= 97 && c <= 102 ? c - 87 : (c - 48) & 15; - } - function parseHexByte(string, lowerBound, index) { - var r = parseHex4Bits(string, index); - return index - 1 >= lowerBound && (r |= parseHex4Bits(string, index - 1) << 4), r; - } - BN.prototype._parseHex = function (number, start, endian) { - (this.length = Math.ceil((number.length - start) / 6)), (this.words = new Array(this.length)); - for (var i = 0; i < this.length; i++) this.words[i] = 0; - var off = 0, - j = 0, - w; - if (endian === "be") - for (i = number.length - 1; i >= start; i -= 2) - (w = parseHexByte(number, start, i) << off), - (this.words[j] |= w & 67108863), - off >= 18 ? ((off -= 18), (j += 1), (this.words[j] |= w >>> 26)) : (off += 8); - else { - var parseLength = number.length - start; - for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) - (w = parseHexByte(number, start, i) << off), - (this.words[j] |= w & 67108863), - off >= 18 ? ((off -= 18), (j += 1), (this.words[j] |= w >>> 26)) : (off += 8); - } - this.strip(); - }; - function parseBase(str, start, end, mul) { - for (var r = 0, len = Math.min(str.length, end), i = start; i < len; i++) { - var c = str.charCodeAt(i) - 48; - (r *= mul), c >= 49 ? (r += c - 49 + 10) : c >= 17 ? (r += c - 17 + 10) : (r += c); - } - return r; - } - (BN.prototype._parseBase = function (number, base, start) { - (this.words = [0]), (this.length = 1); - for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *= base) limbLen++; - limbLen--, (limbPow = (limbPow / base) | 0); - for ( - var total = number.length - start, - mod = total % limbLen, - end = Math.min(total, total - mod) + start, - word = 0, - i = start; - i < end; - i += limbLen - ) - (word = parseBase(number, i, i + limbLen, base)), - this.imuln(limbPow), - this.words[0] + word < 67108864 ? (this.words[0] += word) : this._iaddn(word); - if (mod !== 0) { - var pow = 1; - for (word = parseBase(number, i, number.length, base), i = 0; i < mod; i++) pow *= base; - this.imuln(pow), this.words[0] + word < 67108864 ? (this.words[0] += word) : this._iaddn(word); - } - this.strip(); - }), - (BN.prototype.copy = function (dest) { - dest.words = new Array(this.length); - for (var i = 0; i < this.length; i++) dest.words[i] = this.words[i]; - (dest.length = this.length), (dest.negative = this.negative), (dest.red = this.red); - }), - (BN.prototype.clone = function () { - var r = new BN(null); - return this.copy(r), r; - }), - (BN.prototype._expand = function (size) { - for (; this.length < size; ) this.words[this.length++] = 0; - return this; - }), - (BN.prototype.strip = function () { - for (; this.length > 1 && this.words[this.length - 1] === 0; ) this.length--; - return this._normSign(); - }), - (BN.prototype._normSign = function () { - return this.length === 1 && this.words[0] === 0 && (this.negative = 0), this; - }), - (BN.prototype.inspect = function () { - return (this.red ? "<BN-R: " : "<BN: ") + this.toString(16) + ">"; - }); - var zeros = [ - "", - "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", - ], - groupSizes = [ - 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, - ], - groupBases = [ - 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 (base, padding) { - (base = base || 10), (padding = padding | 0 || 1); - var out; - if (base === 16 || base === "hex") { - out = ""; - for (var off = 0, carry = 0, i = 0; i < this.length; i++) { - var w = this.words[i], - word = (((w << off) | carry) & 16777215).toString(16); - (carry = (w >>> (24 - off)) & 16777215), - carry !== 0 || i !== this.length - 1 ? (out = zeros[6 - word.length] + word + out) : (out = word + out), - (off += 2), - off >= 26 && ((off -= 26), i--); - } - for (carry !== 0 && (out = carry.toString(16) + out); out.length % padding !== 0; ) out = "0" + out; - return this.negative !== 0 && (out = "-" + out), out; - } - if (base === (base | 0) && base >= 2 && base <= 36) { - var groupSize = groupSizes[base], - groupBase = groupBases[base]; - out = ""; - var c = this.clone(); - for (c.negative = 0; !c.isZero(); ) { - var r = c.modn(groupBase).toString(base); - (c = c.idivn(groupBase)), c.isZero() ? (out = r + out) : (out = zeros[groupSize - r.length] + r + out); - } - for (this.isZero() && (out = "0" + out); out.length % padding !== 0; ) out = "0" + out; - return this.negative !== 0 && (out = "-" + out), out; - } - assert(!1, "Base should be between 2 and 36"); - }), - (BN.prototype.toNumber = function () { - var ret = this.words[0]; - return ( - this.length === 2 - ? (ret += this.words[1] * 67108864) - : this.length === 3 && this.words[2] === 1 - ? (ret += 4503599627370496 + this.words[1] * 67108864) - : this.length > 2 && assert(!1, "Number can only safely store up to 53 bits"), - this.negative !== 0 ? -ret : ret - ); - }), - (BN.prototype.toJSON = function () { - return this.toString(16); - }), - (BN.prototype.toBuffer = function (endian, length) { - return assert(typeof Buffer2 < "u"), this.toArrayLike(Buffer2, endian, length); - }), - (BN.prototype.toArray = function (endian, length) { - return this.toArrayLike(Array, endian, length); - }), - (BN.prototype.toArrayLike = function (ArrayType, endian, length) { - var byteLength = this.byteLength(), - reqLength = length || Math.max(1, byteLength); - assert(byteLength <= reqLength, "byte array longer than desired length"), - assert(reqLength > 0, "Requested array length <= 0"), - this.strip(); - var littleEndian = endian === "le", - res = new ArrayType(reqLength), - b, - i, - q = this.clone(); - if (littleEndian) { - for (i = 0; !q.isZero(); i++) (b = q.andln(255)), q.iushrn(8), (res[i] = b); - for (; i < reqLength; i++) res[i] = 0; - } else { - for (i = 0; i < reqLength - byteLength; i++) res[i] = 0; - for (i = 0; !q.isZero(); i++) (b = q.andln(255)), q.iushrn(8), (res[reqLength - i - 1] = b); - } - return res; - }), - Math.clz32 - ? (BN.prototype._countBits = function (w) { - return 32 - Math.clz32(w); - }) - : (BN.prototype._countBits = function (w) { - var t = w, - r = 0; - return ( - t >= 4096 && ((r += 13), (t >>>= 13)), - t >= 64 && ((r += 7), (t >>>= 7)), - t >= 8 && ((r += 4), (t >>>= 4)), - t >= 2 && ((r += 2), (t >>>= 2)), - r + t - ); - }), - (BN.prototype._zeroBits = function (w) { - if (w === 0) return 26; - var t = w, - r = 0; - return ( - (t & 8191) === 0 && ((r += 13), (t >>>= 13)), - (t & 127) === 0 && ((r += 7), (t >>>= 7)), - (t & 15) === 0 && ((r += 4), (t >>>= 4)), - (t & 3) === 0 && ((r += 2), (t >>>= 2)), - (t & 1) === 0 && r++, - r - ); - }), - (BN.prototype.bitLength = function () { - var w = this.words[this.length - 1], - hi = this._countBits(w); - return (this.length - 1) * 26 + hi; - }); - function toBitArray(num) { - for (var w = new Array(num.bitLength()), bit = 0; bit < w.length; bit++) { - var off = (bit / 26) | 0, - wbit = bit % 26; - w[bit] = (num.words[off] & (1 << wbit)) >>> wbit; - } - return w; - } - (BN.prototype.zeroBits = function () { - if (this.isZero()) return 0; - for (var r = 0, i = 0; i < this.length; i++) { - var b = this._zeroBits(this.words[i]); - if (((r += b), b !== 26)) break; - } - return r; - }), - (BN.prototype.byteLength = function () { - return Math.ceil(this.bitLength() / 8); - }), - (BN.prototype.toTwos = function (width) { - return this.negative !== 0 ? this.abs().inotn(width).iaddn(1) : this.clone(); - }), - (BN.prototype.fromTwos = function (width) { - return this.testn(width - 1) ? this.notn(width).iaddn(1).ineg() : this.clone(); - }), - (BN.prototype.isNeg = function () { - return this.negative !== 0; - }), - (BN.prototype.neg = function () { - return this.clone().ineg(); - }), - (BN.prototype.ineg = function () { - return this.isZero() || (this.negative ^= 1), this; - }), - (BN.prototype.iuor = function (num) { - for (; this.length < num.length; ) this.words[this.length++] = 0; - for (var i = 0; i < num.length; i++) this.words[i] = this.words[i] | num.words[i]; - return this.strip(); - }), - (BN.prototype.ior = function (num) { - return assert((this.negative | num.negative) === 0), this.iuor(num); - }), - (BN.prototype.or = function (num) { - return this.length > num.length ? this.clone().ior(num) : num.clone().ior(this); - }), - (BN.prototype.uor = function (num) { - return this.length > num.length ? this.clone().iuor(num) : num.clone().iuor(this); - }), - (BN.prototype.iuand = function (num) { - var b; - this.length > num.length ? (b = num) : (b = this); - for (var i = 0; i < b.length; i++) this.words[i] = this.words[i] & num.words[i]; - return (this.length = b.length), this.strip(); - }), - (BN.prototype.iand = function (num) { - return assert((this.negative | num.negative) === 0), this.iuand(num); - }), - (BN.prototype.and = function (num) { - return this.length > num.length ? this.clone().iand(num) : num.clone().iand(this); - }), - (BN.prototype.uand = function (num) { - return this.length > num.length ? this.clone().iuand(num) : num.clone().iuand(this); - }), - (BN.prototype.iuxor = function (num) { - var a, b; - this.length > num.length ? ((a = this), (b = num)) : ((a = num), (b = this)); - for (var i = 0; i < b.length; i++) this.words[i] = a.words[i] ^ b.words[i]; - if (this !== a) for (; i < a.length; i++) this.words[i] = a.words[i]; - return (this.length = a.length), this.strip(); - }), - (BN.prototype.ixor = function (num) { - return assert((this.negative | num.negative) === 0), this.iuxor(num); - }), - (BN.prototype.xor = function (num) { - return this.length > num.length ? this.clone().ixor(num) : num.clone().ixor(this); - }), - (BN.prototype.uxor = function (num) { - return this.length > num.length ? this.clone().iuxor(num) : num.clone().iuxor(this); - }), - (BN.prototype.inotn = function (width) { - assert(typeof width == "number" && width >= 0); - var bytesNeeded = Math.ceil(width / 26) | 0, - bitsLeft = width % 26; - this._expand(bytesNeeded), bitsLeft > 0 && bytesNeeded--; - for (var i = 0; i < bytesNeeded; i++) this.words[i] = ~this.words[i] & 67108863; - return bitsLeft > 0 && (this.words[i] = ~this.words[i] & (67108863 >> (26 - bitsLeft))), this.strip(); - }), - (BN.prototype.notn = function (width) { - return this.clone().inotn(width); - }), - (BN.prototype.setn = function (bit, val) { - assert(typeof bit == "number" && bit >= 0); - var off = (bit / 26) | 0, - wbit = bit % 26; - return ( - this._expand(off + 1), - val - ? (this.words[off] = this.words[off] | (1 << wbit)) - : (this.words[off] = this.words[off] & ~(1 << wbit)), - this.strip() - ); - }), - (BN.prototype.iadd = function (num) { - var r; - if (this.negative !== 0 && num.negative === 0) - return (this.negative = 0), (r = this.isub(num)), (this.negative ^= 1), this._normSign(); - if (this.negative === 0 && num.negative !== 0) - return (num.negative = 0), (r = this.isub(num)), (num.negative = 1), r._normSign(); - var a, b; - this.length > num.length ? ((a = this), (b = num)) : ((a = num), (b = this)); - for (var carry = 0, i = 0; i < b.length; i++) - (r = (a.words[i] | 0) + (b.words[i] | 0) + carry), (this.words[i] = r & 67108863), (carry = r >>> 26); - for (; carry !== 0 && i < a.length; i++) - (r = (a.words[i] | 0) + carry), (this.words[i] = r & 67108863), (carry = r >>> 26); - if (((this.length = a.length), carry !== 0)) (this.words[this.length] = carry), this.length++; - else if (a !== this) for (; i < a.length; i++) this.words[i] = a.words[i]; - return this; - }), - (BN.prototype.add = function (num) { - var res; - return num.negative !== 0 && this.negative === 0 - ? ((num.negative = 0), (res = this.sub(num)), (num.negative ^= 1), res) - : num.negative === 0 && this.negative !== 0 - ? ((this.negative = 0), (res = num.sub(this)), (this.negative = 1), res) - : this.length > num.length - ? this.clone().iadd(num) - : num.clone().iadd(this); - }), - (BN.prototype.isub = function (num) { - if (num.negative !== 0) { - num.negative = 0; - var r = this.iadd(num); - return (num.negative = 1), r._normSign(); - } else if (this.negative !== 0) - return (this.negative = 0), this.iadd(num), (this.negative = 1), this._normSign(); - var cmp = this.cmp(num); - if (cmp === 0) return (this.negative = 0), (this.length = 1), (this.words[0] = 0), this; - var a, b; - cmp > 0 ? ((a = this), (b = num)) : ((a = num), (b = this)); - for (var carry = 0, i = 0; i < b.length; i++) - (r = (a.words[i] | 0) - (b.words[i] | 0) + carry), (carry = r >> 26), (this.words[i] = r & 67108863); - for (; carry !== 0 && i < a.length; i++) - (r = (a.words[i] | 0) + carry), (carry = r >> 26), (this.words[i] = r & 67108863); - if (carry === 0 && i < a.length && a !== this) for (; i < a.length; i++) this.words[i] = a.words[i]; - return (this.length = Math.max(this.length, i)), a !== this && (this.negative = 1), this.strip(); - }), - (BN.prototype.sub = function (num) { - return this.clone().isub(num); - }); - function smallMulTo(self2, num, out) { - out.negative = num.negative ^ self2.negative; - var len = (self2.length + num.length) | 0; - (out.length = len), (len = (len - 1) | 0); - var a = self2.words[0] | 0, - b = num.words[0] | 0, - r = a * b, - lo = r & 67108863, - carry = (r / 67108864) | 0; - out.words[0] = lo; - for (var k = 1; k < len; k++) { - for ( - var ncarry = carry >>> 26, - rword = carry & 67108863, - maxJ = Math.min(k, num.length - 1), - j = Math.max(0, k - self2.length + 1); - j <= maxJ; - j++ - ) { - var i = (k - j) | 0; - (a = self2.words[i] | 0), - (b = num.words[j] | 0), - (r = a * b + rword), - (ncarry += (r / 67108864) | 0), - (rword = r & 67108863); - } - (out.words[k] = rword | 0), (carry = ncarry | 0); - } - return carry !== 0 ? (out.words[k] = carry | 0) : out.length--, out.strip(); - } - var comb10MulTo = function (self2, num, out) { - var a = self2.words, - b = num.words, - o = out.words, - c = 0, - lo, - mid, - hi, - a0 = a[0] | 0, - al0 = a0 & 8191, - ah0 = a0 >>> 13, - a1 = a[1] | 0, - al1 = a1 & 8191, - ah1 = a1 >>> 13, - a2 = a[2] | 0, - al2 = a2 & 8191, - ah2 = a2 >>> 13, - a3 = a[3] | 0, - al3 = a3 & 8191, - ah3 = a3 >>> 13, - a4 = a[4] | 0, - al4 = a4 & 8191, - ah4 = a4 >>> 13, - a5 = a[5] | 0, - al5 = a5 & 8191, - ah5 = a5 >>> 13, - a6 = a[6] | 0, - al6 = a6 & 8191, - ah6 = a6 >>> 13, - a7 = a[7] | 0, - al7 = a7 & 8191, - ah7 = a7 >>> 13, - a8 = a[8] | 0, - al8 = a8 & 8191, - ah8 = a8 >>> 13, - a9 = a[9] | 0, - al9 = a9 & 8191, - ah9 = a9 >>> 13, - b0 = b[0] | 0, - bl0 = b0 & 8191, - bh0 = b0 >>> 13, - b1 = b[1] | 0, - bl1 = b1 & 8191, - bh1 = b1 >>> 13, - b2 = b[2] | 0, - bl2 = b2 & 8191, - bh2 = b2 >>> 13, - b3 = b[3] | 0, - bl3 = b3 & 8191, - bh3 = b3 >>> 13, - b4 = b[4] | 0, - bl4 = b4 & 8191, - bh4 = b4 >>> 13, - b5 = b[5] | 0, - bl5 = b5 & 8191, - bh5 = b5 >>> 13, - b6 = b[6] | 0, - bl6 = b6 & 8191, - bh6 = b6 >>> 13, - b7 = b[7] | 0, - bl7 = b7 & 8191, - bh7 = b7 >>> 13, - b8 = b[8] | 0, - bl8 = b8 & 8191, - bh8 = b8 >>> 13, - b9 = b[9] | 0, - bl9 = b9 & 8191, - bh9 = b9 >>> 13; - (out.negative = self2.negative ^ num.negative), - (out.length = 19), - (lo = Math.imul(al0, bl0)), - (mid = Math.imul(al0, bh0)), - (mid = (mid + Math.imul(ah0, bl0)) | 0), - (hi = Math.imul(ah0, bh0)); - var w0 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0), - (w0 &= 67108863), - (lo = Math.imul(al1, bl0)), - (mid = Math.imul(al1, bh0)), - (mid = (mid + Math.imul(ah1, bl0)) | 0), - (hi = Math.imul(ah1, bh0)), - (lo = (lo + Math.imul(al0, bl1)) | 0), - (mid = (mid + Math.imul(al0, bh1)) | 0), - (mid = (mid + Math.imul(ah0, bl1)) | 0), - (hi = (hi + Math.imul(ah0, bh1)) | 0); - var w1 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0), - (w1 &= 67108863), - (lo = Math.imul(al2, bl0)), - (mid = Math.imul(al2, bh0)), - (mid = (mid + Math.imul(ah2, bl0)) | 0), - (hi = Math.imul(ah2, bh0)), - (lo = (lo + Math.imul(al1, bl1)) | 0), - (mid = (mid + Math.imul(al1, bh1)) | 0), - (mid = (mid + Math.imul(ah1, bl1)) | 0), - (hi = (hi + Math.imul(ah1, bh1)) | 0), - (lo = (lo + Math.imul(al0, bl2)) | 0), - (mid = (mid + Math.imul(al0, bh2)) | 0), - (mid = (mid + Math.imul(ah0, bl2)) | 0), - (hi = (hi + Math.imul(ah0, bh2)) | 0); - var w2 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0), - (w2 &= 67108863), - (lo = Math.imul(al3, bl0)), - (mid = Math.imul(al3, bh0)), - (mid = (mid + Math.imul(ah3, bl0)) | 0), - (hi = Math.imul(ah3, bh0)), - (lo = (lo + Math.imul(al2, bl1)) | 0), - (mid = (mid + Math.imul(al2, bh1)) | 0), - (mid = (mid + Math.imul(ah2, bl1)) | 0), - (hi = (hi + Math.imul(ah2, bh1)) | 0), - (lo = (lo + Math.imul(al1, bl2)) | 0), - (mid = (mid + Math.imul(al1, bh2)) | 0), - (mid = (mid + Math.imul(ah1, bl2)) | 0), - (hi = (hi + Math.imul(ah1, bh2)) | 0), - (lo = (lo + Math.imul(al0, bl3)) | 0), - (mid = (mid + Math.imul(al0, bh3)) | 0), - (mid = (mid + Math.imul(ah0, bl3)) | 0), - (hi = (hi + Math.imul(ah0, bh3)) | 0); - var w3 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0), - (w3 &= 67108863), - (lo = Math.imul(al4, bl0)), - (mid = Math.imul(al4, bh0)), - (mid = (mid + Math.imul(ah4, bl0)) | 0), - (hi = Math.imul(ah4, bh0)), - (lo = (lo + Math.imul(al3, bl1)) | 0), - (mid = (mid + Math.imul(al3, bh1)) | 0), - (mid = (mid + Math.imul(ah3, bl1)) | 0), - (hi = (hi + Math.imul(ah3, bh1)) | 0), - (lo = (lo + Math.imul(al2, bl2)) | 0), - (mid = (mid + Math.imul(al2, bh2)) | 0), - (mid = (mid + Math.imul(ah2, bl2)) | 0), - (hi = (hi + Math.imul(ah2, bh2)) | 0), - (lo = (lo + Math.imul(al1, bl3)) | 0), - (mid = (mid + Math.imul(al1, bh3)) | 0), - (mid = (mid + Math.imul(ah1, bl3)) | 0), - (hi = (hi + Math.imul(ah1, bh3)) | 0), - (lo = (lo + Math.imul(al0, bl4)) | 0), - (mid = (mid + Math.imul(al0, bh4)) | 0), - (mid = (mid + Math.imul(ah0, bl4)) | 0), - (hi = (hi + Math.imul(ah0, bh4)) | 0); - var w4 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0), - (w4 &= 67108863), - (lo = Math.imul(al5, bl0)), - (mid = Math.imul(al5, bh0)), - (mid = (mid + Math.imul(ah5, bl0)) | 0), - (hi = Math.imul(ah5, bh0)), - (lo = (lo + Math.imul(al4, bl1)) | 0), - (mid = (mid + Math.imul(al4, bh1)) | 0), - (mid = (mid + Math.imul(ah4, bl1)) | 0), - (hi = (hi + Math.imul(ah4, bh1)) | 0), - (lo = (lo + Math.imul(al3, bl2)) | 0), - (mid = (mid + Math.imul(al3, bh2)) | 0), - (mid = (mid + Math.imul(ah3, bl2)) | 0), - (hi = (hi + Math.imul(ah3, bh2)) | 0), - (lo = (lo + Math.imul(al2, bl3)) | 0), - (mid = (mid + Math.imul(al2, bh3)) | 0), - (mid = (mid + Math.imul(ah2, bl3)) | 0), - (hi = (hi + Math.imul(ah2, bh3)) | 0), - (lo = (lo + Math.imul(al1, bl4)) | 0), - (mid = (mid + Math.imul(al1, bh4)) | 0), - (mid = (mid + Math.imul(ah1, bl4)) | 0), - (hi = (hi + Math.imul(ah1, bh4)) | 0), - (lo = (lo + Math.imul(al0, bl5)) | 0), - (mid = (mid + Math.imul(al0, bh5)) | 0), - (mid = (mid + Math.imul(ah0, bl5)) | 0), - (hi = (hi + Math.imul(ah0, bh5)) | 0); - var w5 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0), - (w5 &= 67108863), - (lo = Math.imul(al6, bl0)), - (mid = Math.imul(al6, bh0)), - (mid = (mid + Math.imul(ah6, bl0)) | 0), - (hi = Math.imul(ah6, bh0)), - (lo = (lo + Math.imul(al5, bl1)) | 0), - (mid = (mid + Math.imul(al5, bh1)) | 0), - (mid = (mid + Math.imul(ah5, bl1)) | 0), - (hi = (hi + Math.imul(ah5, bh1)) | 0), - (lo = (lo + Math.imul(al4, bl2)) | 0), - (mid = (mid + Math.imul(al4, bh2)) | 0), - (mid = (mid + Math.imul(ah4, bl2)) | 0), - (hi = (hi + Math.imul(ah4, bh2)) | 0), - (lo = (lo + Math.imul(al3, bl3)) | 0), - (mid = (mid + Math.imul(al3, bh3)) | 0), - (mid = (mid + Math.imul(ah3, bl3)) | 0), - (hi = (hi + Math.imul(ah3, bh3)) | 0), - (lo = (lo + Math.imul(al2, bl4)) | 0), - (mid = (mid + Math.imul(al2, bh4)) | 0), - (mid = (mid + Math.imul(ah2, bl4)) | 0), - (hi = (hi + Math.imul(ah2, bh4)) | 0), - (lo = (lo + Math.imul(al1, bl5)) | 0), - (mid = (mid + Math.imul(al1, bh5)) | 0), - (mid = (mid + Math.imul(ah1, bl5)) | 0), - (hi = (hi + Math.imul(ah1, bh5)) | 0), - (lo = (lo + Math.imul(al0, bl6)) | 0), - (mid = (mid + Math.imul(al0, bh6)) | 0), - (mid = (mid + Math.imul(ah0, bl6)) | 0), - (hi = (hi + Math.imul(ah0, bh6)) | 0); - var w6 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0), - (w6 &= 67108863), - (lo = Math.imul(al7, bl0)), - (mid = Math.imul(al7, bh0)), - (mid = (mid + Math.imul(ah7, bl0)) | 0), - (hi = Math.imul(ah7, bh0)), - (lo = (lo + Math.imul(al6, bl1)) | 0), - (mid = (mid + Math.imul(al6, bh1)) | 0), - (mid = (mid + Math.imul(ah6, bl1)) | 0), - (hi = (hi + Math.imul(ah6, bh1)) | 0), - (lo = (lo + Math.imul(al5, bl2)) | 0), - (mid = (mid + Math.imul(al5, bh2)) | 0), - (mid = (mid + Math.imul(ah5, bl2)) | 0), - (hi = (hi + Math.imul(ah5, bh2)) | 0), - (lo = (lo + Math.imul(al4, bl3)) | 0), - (mid = (mid + Math.imul(al4, bh3)) | 0), - (mid = (mid + Math.imul(ah4, bl3)) | 0), - (hi = (hi + Math.imul(ah4, bh3)) | 0), - (lo = (lo + Math.imul(al3, bl4)) | 0), - (mid = (mid + Math.imul(al3, bh4)) | 0), - (mid = (mid + Math.imul(ah3, bl4)) | 0), - (hi = (hi + Math.imul(ah3, bh4)) | 0), - (lo = (lo + Math.imul(al2, bl5)) | 0), - (mid = (mid + Math.imul(al2, bh5)) | 0), - (mid = (mid + Math.imul(ah2, bl5)) | 0), - (hi = (hi + Math.imul(ah2, bh5)) | 0), - (lo = (lo + Math.imul(al1, bl6)) | 0), - (mid = (mid + Math.imul(al1, bh6)) | 0), - (mid = (mid + Math.imul(ah1, bl6)) | 0), - (hi = (hi + Math.imul(ah1, bh6)) | 0), - (lo = (lo + Math.imul(al0, bl7)) | 0), - (mid = (mid + Math.imul(al0, bh7)) | 0), - (mid = (mid + Math.imul(ah0, bl7)) | 0), - (hi = (hi + Math.imul(ah0, bh7)) | 0); - var w7 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0), - (w7 &= 67108863), - (lo = Math.imul(al8, bl0)), - (mid = Math.imul(al8, bh0)), - (mid = (mid + Math.imul(ah8, bl0)) | 0), - (hi = Math.imul(ah8, bh0)), - (lo = (lo + Math.imul(al7, bl1)) | 0), - (mid = (mid + Math.imul(al7, bh1)) | 0), - (mid = (mid + Math.imul(ah7, bl1)) | 0), - (hi = (hi + Math.imul(ah7, bh1)) | 0), - (lo = (lo + Math.imul(al6, bl2)) | 0), - (mid = (mid + Math.imul(al6, bh2)) | 0), - (mid = (mid + Math.imul(ah6, bl2)) | 0), - (hi = (hi + Math.imul(ah6, bh2)) | 0), - (lo = (lo + Math.imul(al5, bl3)) | 0), - (mid = (mid + Math.imul(al5, bh3)) | 0), - (mid = (mid + Math.imul(ah5, bl3)) | 0), - (hi = (hi + Math.imul(ah5, bh3)) | 0), - (lo = (lo + Math.imul(al4, bl4)) | 0), - (mid = (mid + Math.imul(al4, bh4)) | 0), - (mid = (mid + Math.imul(ah4, bl4)) | 0), - (hi = (hi + Math.imul(ah4, bh4)) | 0), - (lo = (lo + Math.imul(al3, bl5)) | 0), - (mid = (mid + Math.imul(al3, bh5)) | 0), - (mid = (mid + Math.imul(ah3, bl5)) | 0), - (hi = (hi + Math.imul(ah3, bh5)) | 0), - (lo = (lo + Math.imul(al2, bl6)) | 0), - (mid = (mid + Math.imul(al2, bh6)) | 0), - (mid = (mid + Math.imul(ah2, bl6)) | 0), - (hi = (hi + Math.imul(ah2, bh6)) | 0), - (lo = (lo + Math.imul(al1, bl7)) | 0), - (mid = (mid + Math.imul(al1, bh7)) | 0), - (mid = (mid + Math.imul(ah1, bl7)) | 0), - (hi = (hi + Math.imul(ah1, bh7)) | 0), - (lo = (lo + Math.imul(al0, bl8)) | 0), - (mid = (mid + Math.imul(al0, bh8)) | 0), - (mid = (mid + Math.imul(ah0, bl8)) | 0), - (hi = (hi + Math.imul(ah0, bh8)) | 0); - var w8 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0), - (w8 &= 67108863), - (lo = Math.imul(al9, bl0)), - (mid = Math.imul(al9, bh0)), - (mid = (mid + Math.imul(ah9, bl0)) | 0), - (hi = Math.imul(ah9, bh0)), - (lo = (lo + Math.imul(al8, bl1)) | 0), - (mid = (mid + Math.imul(al8, bh1)) | 0), - (mid = (mid + Math.imul(ah8, bl1)) | 0), - (hi = (hi + Math.imul(ah8, bh1)) | 0), - (lo = (lo + Math.imul(al7, bl2)) | 0), - (mid = (mid + Math.imul(al7, bh2)) | 0), - (mid = (mid + Math.imul(ah7, bl2)) | 0), - (hi = (hi + Math.imul(ah7, bh2)) | 0), - (lo = (lo + Math.imul(al6, bl3)) | 0), - (mid = (mid + Math.imul(al6, bh3)) | 0), - (mid = (mid + Math.imul(ah6, bl3)) | 0), - (hi = (hi + Math.imul(ah6, bh3)) | 0), - (lo = (lo + Math.imul(al5, bl4)) | 0), - (mid = (mid + Math.imul(al5, bh4)) | 0), - (mid = (mid + Math.imul(ah5, bl4)) | 0), - (hi = (hi + Math.imul(ah5, bh4)) | 0), - (lo = (lo + Math.imul(al4, bl5)) | 0), - (mid = (mid + Math.imul(al4, bh5)) | 0), - (mid = (mid + Math.imul(ah4, bl5)) | 0), - (hi = (hi + Math.imul(ah4, bh5)) | 0), - (lo = (lo + Math.imul(al3, bl6)) | 0), - (mid = (mid + Math.imul(al3, bh6)) | 0), - (mid = (mid + Math.imul(ah3, bl6)) | 0), - (hi = (hi + Math.imul(ah3, bh6)) | 0), - (lo = (lo + Math.imul(al2, bl7)) | 0), - (mid = (mid + Math.imul(al2, bh7)) | 0), - (mid = (mid + Math.imul(ah2, bl7)) | 0), - (hi = (hi + Math.imul(ah2, bh7)) | 0), - (lo = (lo + Math.imul(al1, bl8)) | 0), - (mid = (mid + Math.imul(al1, bh8)) | 0), - (mid = (mid + Math.imul(ah1, bl8)) | 0), - (hi = (hi + Math.imul(ah1, bh8)) | 0), - (lo = (lo + Math.imul(al0, bl9)) | 0), - (mid = (mid + Math.imul(al0, bh9)) | 0), - (mid = (mid + Math.imul(ah0, bl9)) | 0), - (hi = (hi + Math.imul(ah0, bh9)) | 0); - var w9 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0), - (w9 &= 67108863), - (lo = Math.imul(al9, bl1)), - (mid = Math.imul(al9, bh1)), - (mid = (mid + Math.imul(ah9, bl1)) | 0), - (hi = Math.imul(ah9, bh1)), - (lo = (lo + Math.imul(al8, bl2)) | 0), - (mid = (mid + Math.imul(al8, bh2)) | 0), - (mid = (mid + Math.imul(ah8, bl2)) | 0), - (hi = (hi + Math.imul(ah8, bh2)) | 0), - (lo = (lo + Math.imul(al7, bl3)) | 0), - (mid = (mid + Math.imul(al7, bh3)) | 0), - (mid = (mid + Math.imul(ah7, bl3)) | 0), - (hi = (hi + Math.imul(ah7, bh3)) | 0), - (lo = (lo + Math.imul(al6, bl4)) | 0), - (mid = (mid + Math.imul(al6, bh4)) | 0), - (mid = (mid + Math.imul(ah6, bl4)) | 0), - (hi = (hi + Math.imul(ah6, bh4)) | 0), - (lo = (lo + Math.imul(al5, bl5)) | 0), - (mid = (mid + Math.imul(al5, bh5)) | 0), - (mid = (mid + Math.imul(ah5, bl5)) | 0), - (hi = (hi + Math.imul(ah5, bh5)) | 0), - (lo = (lo + Math.imul(al4, bl6)) | 0), - (mid = (mid + Math.imul(al4, bh6)) | 0), - (mid = (mid + Math.imul(ah4, bl6)) | 0), - (hi = (hi + Math.imul(ah4, bh6)) | 0), - (lo = (lo + Math.imul(al3, bl7)) | 0), - (mid = (mid + Math.imul(al3, bh7)) | 0), - (mid = (mid + Math.imul(ah3, bl7)) | 0), - (hi = (hi + Math.imul(ah3, bh7)) | 0), - (lo = (lo + Math.imul(al2, bl8)) | 0), - (mid = (mid + Math.imul(al2, bh8)) | 0), - (mid = (mid + Math.imul(ah2, bl8)) | 0), - (hi = (hi + Math.imul(ah2, bh8)) | 0), - (lo = (lo + Math.imul(al1, bl9)) | 0), - (mid = (mid + Math.imul(al1, bh9)) | 0), - (mid = (mid + Math.imul(ah1, bl9)) | 0), - (hi = (hi + Math.imul(ah1, bh9)) | 0); - var w10 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0), - (w10 &= 67108863), - (lo = Math.imul(al9, bl2)), - (mid = Math.imul(al9, bh2)), - (mid = (mid + Math.imul(ah9, bl2)) | 0), - (hi = Math.imul(ah9, bh2)), - (lo = (lo + Math.imul(al8, bl3)) | 0), - (mid = (mid + Math.imul(al8, bh3)) | 0), - (mid = (mid + Math.imul(ah8, bl3)) | 0), - (hi = (hi + Math.imul(ah8, bh3)) | 0), - (lo = (lo + Math.imul(al7, bl4)) | 0), - (mid = (mid + Math.imul(al7, bh4)) | 0), - (mid = (mid + Math.imul(ah7, bl4)) | 0), - (hi = (hi + Math.imul(ah7, bh4)) | 0), - (lo = (lo + Math.imul(al6, bl5)) | 0), - (mid = (mid + Math.imul(al6, bh5)) | 0), - (mid = (mid + Math.imul(ah6, bl5)) | 0), - (hi = (hi + Math.imul(ah6, bh5)) | 0), - (lo = (lo + Math.imul(al5, bl6)) | 0), - (mid = (mid + Math.imul(al5, bh6)) | 0), - (mid = (mid + Math.imul(ah5, bl6)) | 0), - (hi = (hi + Math.imul(ah5, bh6)) | 0), - (lo = (lo + Math.imul(al4, bl7)) | 0), - (mid = (mid + Math.imul(al4, bh7)) | 0), - (mid = (mid + Math.imul(ah4, bl7)) | 0), - (hi = (hi + Math.imul(ah4, bh7)) | 0), - (lo = (lo + Math.imul(al3, bl8)) | 0), - (mid = (mid + Math.imul(al3, bh8)) | 0), - (mid = (mid + Math.imul(ah3, bl8)) | 0), - (hi = (hi + Math.imul(ah3, bh8)) | 0), - (lo = (lo + Math.imul(al2, bl9)) | 0), - (mid = (mid + Math.imul(al2, bh9)) | 0), - (mid = (mid + Math.imul(ah2, bl9)) | 0), - (hi = (hi + Math.imul(ah2, bh9)) | 0); - var w11 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0), - (w11 &= 67108863), - (lo = Math.imul(al9, bl3)), - (mid = Math.imul(al9, bh3)), - (mid = (mid + Math.imul(ah9, bl3)) | 0), - (hi = Math.imul(ah9, bh3)), - (lo = (lo + Math.imul(al8, bl4)) | 0), - (mid = (mid + Math.imul(al8, bh4)) | 0), - (mid = (mid + Math.imul(ah8, bl4)) | 0), - (hi = (hi + Math.imul(ah8, bh4)) | 0), - (lo = (lo + Math.imul(al7, bl5)) | 0), - (mid = (mid + Math.imul(al7, bh5)) | 0), - (mid = (mid + Math.imul(ah7, bl5)) | 0), - (hi = (hi + Math.imul(ah7, bh5)) | 0), - (lo = (lo + Math.imul(al6, bl6)) | 0), - (mid = (mid + Math.imul(al6, bh6)) | 0), - (mid = (mid + Math.imul(ah6, bl6)) | 0), - (hi = (hi + Math.imul(ah6, bh6)) | 0), - (lo = (lo + Math.imul(al5, bl7)) | 0), - (mid = (mid + Math.imul(al5, bh7)) | 0), - (mid = (mid + Math.imul(ah5, bl7)) | 0), - (hi = (hi + Math.imul(ah5, bh7)) | 0), - (lo = (lo + Math.imul(al4, bl8)) | 0), - (mid = (mid + Math.imul(al4, bh8)) | 0), - (mid = (mid + Math.imul(ah4, bl8)) | 0), - (hi = (hi + Math.imul(ah4, bh8)) | 0), - (lo = (lo + Math.imul(al3, bl9)) | 0), - (mid = (mid + Math.imul(al3, bh9)) | 0), - (mid = (mid + Math.imul(ah3, bl9)) | 0), - (hi = (hi + Math.imul(ah3, bh9)) | 0); - var w12 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0), - (w12 &= 67108863), - (lo = Math.imul(al9, bl4)), - (mid = Math.imul(al9, bh4)), - (mid = (mid + Math.imul(ah9, bl4)) | 0), - (hi = Math.imul(ah9, bh4)), - (lo = (lo + Math.imul(al8, bl5)) | 0), - (mid = (mid + Math.imul(al8, bh5)) | 0), - (mid = (mid + Math.imul(ah8, bl5)) | 0), - (hi = (hi + Math.imul(ah8, bh5)) | 0), - (lo = (lo + Math.imul(al7, bl6)) | 0), - (mid = (mid + Math.imul(al7, bh6)) | 0), - (mid = (mid + Math.imul(ah7, bl6)) | 0), - (hi = (hi + Math.imul(ah7, bh6)) | 0), - (lo = (lo + Math.imul(al6, bl7)) | 0), - (mid = (mid + Math.imul(al6, bh7)) | 0), - (mid = (mid + Math.imul(ah6, bl7)) | 0), - (hi = (hi + Math.imul(ah6, bh7)) | 0), - (lo = (lo + Math.imul(al5, bl8)) | 0), - (mid = (mid + Math.imul(al5, bh8)) | 0), - (mid = (mid + Math.imul(ah5, bl8)) | 0), - (hi = (hi + Math.imul(ah5, bh8)) | 0), - (lo = (lo + Math.imul(al4, bl9)) | 0), - (mid = (mid + Math.imul(al4, bh9)) | 0), - (mid = (mid + Math.imul(ah4, bl9)) | 0), - (hi = (hi + Math.imul(ah4, bh9)) | 0); - var w13 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0), - (w13 &= 67108863), - (lo = Math.imul(al9, bl5)), - (mid = Math.imul(al9, bh5)), - (mid = (mid + Math.imul(ah9, bl5)) | 0), - (hi = Math.imul(ah9, bh5)), - (lo = (lo + Math.imul(al8, bl6)) | 0), - (mid = (mid + Math.imul(al8, bh6)) | 0), - (mid = (mid + Math.imul(ah8, bl6)) | 0), - (hi = (hi + Math.imul(ah8, bh6)) | 0), - (lo = (lo + Math.imul(al7, bl7)) | 0), - (mid = (mid + Math.imul(al7, bh7)) | 0), - (mid = (mid + Math.imul(ah7, bl7)) | 0), - (hi = (hi + Math.imul(ah7, bh7)) | 0), - (lo = (lo + Math.imul(al6, bl8)) | 0), - (mid = (mid + Math.imul(al6, bh8)) | 0), - (mid = (mid + Math.imul(ah6, bl8)) | 0), - (hi = (hi + Math.imul(ah6, bh8)) | 0), - (lo = (lo + Math.imul(al5, bl9)) | 0), - (mid = (mid + Math.imul(al5, bh9)) | 0), - (mid = (mid + Math.imul(ah5, bl9)) | 0), - (hi = (hi + Math.imul(ah5, bh9)) | 0); - var w14 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0), - (w14 &= 67108863), - (lo = Math.imul(al9, bl6)), - (mid = Math.imul(al9, bh6)), - (mid = (mid + Math.imul(ah9, bl6)) | 0), - (hi = Math.imul(ah9, bh6)), - (lo = (lo + Math.imul(al8, bl7)) | 0), - (mid = (mid + Math.imul(al8, bh7)) | 0), - (mid = (mid + Math.imul(ah8, bl7)) | 0), - (hi = (hi + Math.imul(ah8, bh7)) | 0), - (lo = (lo + Math.imul(al7, bl8)) | 0), - (mid = (mid + Math.imul(al7, bh8)) | 0), - (mid = (mid + Math.imul(ah7, bl8)) | 0), - (hi = (hi + Math.imul(ah7, bh8)) | 0), - (lo = (lo + Math.imul(al6, bl9)) | 0), - (mid = (mid + Math.imul(al6, bh9)) | 0), - (mid = (mid + Math.imul(ah6, bl9)) | 0), - (hi = (hi + Math.imul(ah6, bh9)) | 0); - var w15 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0), - (w15 &= 67108863), - (lo = Math.imul(al9, bl7)), - (mid = Math.imul(al9, bh7)), - (mid = (mid + Math.imul(ah9, bl7)) | 0), - (hi = Math.imul(ah9, bh7)), - (lo = (lo + Math.imul(al8, bl8)) | 0), - (mid = (mid + Math.imul(al8, bh8)) | 0), - (mid = (mid + Math.imul(ah8, bl8)) | 0), - (hi = (hi + Math.imul(ah8, bh8)) | 0), - (lo = (lo + Math.imul(al7, bl9)) | 0), - (mid = (mid + Math.imul(al7, bh9)) | 0), - (mid = (mid + Math.imul(ah7, bl9)) | 0), - (hi = (hi + Math.imul(ah7, bh9)) | 0); - var w16 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0), - (w16 &= 67108863), - (lo = Math.imul(al9, bl8)), - (mid = Math.imul(al9, bh8)), - (mid = (mid + Math.imul(ah9, bl8)) | 0), - (hi = Math.imul(ah9, bh8)), - (lo = (lo + Math.imul(al8, bl9)) | 0), - (mid = (mid + Math.imul(al8, bh9)) | 0), - (mid = (mid + Math.imul(ah8, bl9)) | 0), - (hi = (hi + Math.imul(ah8, bh9)) | 0); - var w17 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0), - (w17 &= 67108863), - (lo = Math.imul(al9, bl9)), - (mid = Math.imul(al9, bh9)), - (mid = (mid + Math.imul(ah9, bl9)) | 0), - (hi = Math.imul(ah9, bh9)); - var w18 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - return ( - (c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0), - (w18 &= 67108863), - (o[0] = w0), - (o[1] = w1), - (o[2] = w2), - (o[3] = w3), - (o[4] = w4), - (o[5] = w5), - (o[6] = w6), - (o[7] = w7), - (o[8] = w8), - (o[9] = w9), - (o[10] = w10), - (o[11] = w11), - (o[12] = w12), - (o[13] = w13), - (o[14] = w14), - (o[15] = w15), - (o[16] = w16), - (o[17] = w17), - (o[18] = w18), - c !== 0 && ((o[19] = c), out.length++), - out - ); - }; - Math.imul || (comb10MulTo = smallMulTo); - function bigMulTo(self2, num, out) { - (out.negative = num.negative ^ self2.negative), (out.length = self2.length + num.length); - for (var carry = 0, hncarry = 0, k = 0; k < out.length - 1; k++) { - var ncarry = hncarry; - hncarry = 0; - for ( - var rword = carry & 67108863, maxJ = Math.min(k, num.length - 1), j = Math.max(0, k - self2.length + 1); - j <= maxJ; - j++ - ) { - var i = k - j, - a = self2.words[i] | 0, - b = num.words[j] | 0, - r = a * b, - lo = r & 67108863; - (ncarry = (ncarry + ((r / 67108864) | 0)) | 0), - (lo = (lo + rword) | 0), - (rword = lo & 67108863), - (ncarry = (ncarry + (lo >>> 26)) | 0), - (hncarry += ncarry >>> 26), - (ncarry &= 67108863); - } - (out.words[k] = rword), (carry = ncarry), (ncarry = hncarry); - } - return carry !== 0 ? (out.words[k] = carry) : out.length--, out.strip(); - } - function jumboMulTo(self2, num, out) { - var fftm = new FFTM(); - return fftm.mulp(self2, num, out); - } - BN.prototype.mulTo = function (num, out) { - var res, - len = this.length + num.length; - return ( - this.length === 10 && num.length === 10 - ? (res = comb10MulTo(this, num, out)) - : len < 63 - ? (res = smallMulTo(this, num, out)) - : len < 1024 - ? (res = bigMulTo(this, num, out)) - : (res = jumboMulTo(this, num, out)), - res - ); - }; - function FFTM(x, y) { - (this.x = x), (this.y = y); - } - (FFTM.prototype.makeRBT = function (N) { - for (var t = new Array(N), l = BN.prototype._countBits(N) - 1, i = 0; i < N; i++) t[i] = this.revBin(i, l, N); - return t; - }), - (FFTM.prototype.revBin = function (x, l, N) { - if (x === 0 || x === N - 1) return x; - for (var rb = 0, i = 0; i < l; i++) (rb |= (x & 1) << (l - i - 1)), (x >>= 1); - return rb; - }), - (FFTM.prototype.permute = function (rbt, rws, iws, rtws, itws, N) { - for (var i = 0; i < N; i++) (rtws[i] = rws[rbt[i]]), (itws[i] = iws[rbt[i]]); - }), - (FFTM.prototype.transform = function (rws, iws, rtws, itws, N, rbt) { - this.permute(rbt, rws, iws, rtws, itws, N); - for (var s = 1; s < N; s <<= 1) - for ( - var l = s << 1, rtwdf = Math.cos((2 * Math.PI) / l), itwdf = Math.sin((2 * Math.PI) / l), p = 0; - p < N; - p += l - ) - for (var rtwdf_ = rtwdf, itwdf_ = itwdf, j = 0; j < s; j++) { - var re = rtws[p + j], - ie = itws[p + j], - ro = rtws[p + j + s], - io = itws[p + j + s], - rx = rtwdf_ * ro - itwdf_ * io; - (io = rtwdf_ * io + itwdf_ * ro), - (ro = rx), - (rtws[p + j] = re + ro), - (itws[p + j] = ie + io), - (rtws[p + j + s] = re - ro), - (itws[p + j + s] = ie - io), - j !== l && - ((rx = rtwdf * rtwdf_ - itwdf * itwdf_), (itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_), (rtwdf_ = rx)); - } - }), - (FFTM.prototype.guessLen13b = function (n, m) { - var N = Math.max(m, n) | 1, - odd = N & 1, - i = 0; - for (N = (N / 2) | 0; N; N = N >>> 1) i++; - return 1 << (i + 1 + odd); - }), - (FFTM.prototype.conjugate = function (rws, iws, N) { - if (!(N <= 1)) - for (var i = 0; i < N / 2; i++) { - var t = rws[i]; - (rws[i] = rws[N - i - 1]), - (rws[N - i - 1] = t), - (t = iws[i]), - (iws[i] = -iws[N - i - 1]), - (iws[N - i - 1] = -t); - } - }), - (FFTM.prototype.normalize13b = function (ws, N) { - for (var carry = 0, i = 0; i < N / 2; i++) { - var w = Math.round(ws[2 * i + 1] / N) * 8192 + Math.round(ws[2 * i] / N) + carry; - (ws[i] = w & 67108863), w < 67108864 ? (carry = 0) : (carry = (w / 67108864) | 0); - } - return ws; - }), - (FFTM.prototype.convert13b = function (ws, len, rws, N) { - for (var carry = 0, i = 0; i < len; i++) - (carry = carry + (ws[i] | 0)), - (rws[2 * i] = carry & 8191), - (carry = carry >>> 13), - (rws[2 * i + 1] = carry & 8191), - (carry = carry >>> 13); - for (i = 2 * len; i < N; ++i) rws[i] = 0; - assert(carry === 0), assert((carry & -8192) === 0); - }), - (FFTM.prototype.stub = function (N) { - for (var ph = new Array(N), i = 0; i < N; i++) ph[i] = 0; - return ph; - }), - (FFTM.prototype.mulp = function (x, y, out) { - var N = 2 * this.guessLen13b(x.length, y.length), - rbt = this.makeRBT(N), - _ = this.stub(N), - rws = new Array(N), - rwst = new Array(N), - iwst = new Array(N), - nrws = new Array(N), - nrwst = new Array(N), - niwst = new Array(N), - rmws = out.words; - (rmws.length = N), - this.convert13b(x.words, x.length, rws, N), - this.convert13b(y.words, y.length, nrws, N), - this.transform(rws, _, rwst, iwst, N, rbt), - this.transform(nrws, _, nrwst, niwst, N, rbt); - for (var i = 0; i < N; i++) { - var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i]; - (iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i]), (rwst[i] = rx); - } - return ( - this.conjugate(rwst, iwst, N), - this.transform(rwst, iwst, rmws, _, N, rbt), - this.conjugate(rmws, _, N), - this.normalize13b(rmws, N), - (out.negative = x.negative ^ y.negative), - (out.length = x.length + y.length), - out.strip() - ); - }), - (BN.prototype.mul = function (num) { - var out = new BN(null); - return (out.words = new Array(this.length + num.length)), this.mulTo(num, out); - }), - (BN.prototype.mulf = function (num) { - var out = new BN(null); - return (out.words = new Array(this.length + num.length)), jumboMulTo(this, num, out); - }), - (BN.prototype.imul = function (num) { - return this.clone().mulTo(num, this); - }), - (BN.prototype.imuln = function (num) { - assert(typeof num == "number"), assert(num < 67108864); - for (var carry = 0, i = 0; i < this.length; i++) { - var w = (this.words[i] | 0) * num, - lo = (w & 67108863) + (carry & 67108863); - (carry >>= 26), (carry += (w / 67108864) | 0), (carry += lo >>> 26), (this.words[i] = lo & 67108863); - } - return carry !== 0 && ((this.words[i] = carry), this.length++), this; - }), - (BN.prototype.muln = function (num) { - return this.clone().imuln(num); - }), - (BN.prototype.sqr = function () { - return this.mul(this); - }), - (BN.prototype.isqr = function () { - return this.imul(this.clone()); - }), - (BN.prototype.pow = function (num) { - var w = toBitArray(num); - if (w.length === 0) return new BN(1); - for (var res = this, i = 0; i < w.length && w[i] === 0; i++, res = res.sqr()); - if (++i < w.length) for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) w[i] !== 0 && (res = res.mul(q)); - return res; - }), - (BN.prototype.iushln = function (bits) { - assert(typeof bits == "number" && bits >= 0); - var r = bits % 26, - s = (bits - r) / 26, - carryMask = (67108863 >>> (26 - r)) << (26 - r), - i; - if (r !== 0) { - var carry = 0; - for (i = 0; i < this.length; i++) { - var newCarry = this.words[i] & carryMask, - c = ((this.words[i] | 0) - newCarry) << r; - (this.words[i] = c | carry), (carry = newCarry >>> (26 - r)); - } - carry && ((this.words[i] = carry), this.length++); - } - if (s !== 0) { - for (i = this.length - 1; i >= 0; i--) this.words[i + s] = this.words[i]; - for (i = 0; i < s; i++) this.words[i] = 0; - this.length += s; - } - return this.strip(); - }), - (BN.prototype.ishln = function (bits) { - return assert(this.negative === 0), this.iushln(bits); - }), - (BN.prototype.iushrn = function (bits, hint, extended) { - assert(typeof bits == "number" && bits >= 0); - var h; - hint ? (h = (hint - (hint % 26)) / 26) : (h = 0); - var r = bits % 26, - s = Math.min((bits - r) / 26, this.length), - mask = 67108863 ^ ((67108863 >>> r) << r), - maskedWords = extended; - if (((h -= s), (h = Math.max(0, h)), maskedWords)) { - for (var i = 0; i < s; i++) maskedWords.words[i] = this.words[i]; - maskedWords.length = s; - } - if (s !== 0) - if (this.length > s) for (this.length -= s, i = 0; i < this.length; i++) this.words[i] = this.words[i + s]; - else (this.words[0] = 0), (this.length = 1); - var carry = 0; - for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) { - var word = this.words[i] | 0; - (this.words[i] = (carry << (26 - r)) | (word >>> r)), (carry = word & mask); - } - return ( - maskedWords && carry !== 0 && (maskedWords.words[maskedWords.length++] = carry), - this.length === 0 && ((this.words[0] = 0), (this.length = 1)), - this.strip() - ); - }), - (BN.prototype.ishrn = function (bits, hint, extended) { - return assert(this.negative === 0), this.iushrn(bits, hint, extended); - }), - (BN.prototype.shln = function (bits) { - return this.clone().ishln(bits); - }), - (BN.prototype.ushln = function (bits) { - return this.clone().iushln(bits); - }), - (BN.prototype.shrn = function (bits) { - return this.clone().ishrn(bits); - }), - (BN.prototype.ushrn = function (bits) { - return this.clone().iushrn(bits); - }), - (BN.prototype.testn = function (bit) { - assert(typeof bit == "number" && bit >= 0); - var r = bit % 26, - s = (bit - r) / 26, - q = 1 << r; - if (this.length <= s) return !1; - var w = this.words[s]; - return !!(w & q); - }), - (BN.prototype.imaskn = function (bits) { - assert(typeof bits == "number" && bits >= 0); - var r = bits % 26, - s = (bits - r) / 26; - if ((assert(this.negative === 0, "imaskn works only with positive numbers"), this.length <= s)) return this; - if ((r !== 0 && s++, (this.length = Math.min(s, this.length)), r !== 0)) { - var mask = 67108863 ^ ((67108863 >>> r) << r); - this.words[this.length - 1] &= mask; - } - return this.strip(); - }), - (BN.prototype.maskn = function (bits) { - return this.clone().imaskn(bits); - }), - (BN.prototype.iaddn = function (num) { - return ( - assert(typeof num == "number"), - assert(num < 67108864), - num < 0 - ? this.isubn(-num) - : this.negative !== 0 - ? this.length === 1 && (this.words[0] | 0) < num - ? ((this.words[0] = num - (this.words[0] | 0)), (this.negative = 0), this) - : ((this.negative = 0), this.isubn(num), (this.negative = 1), this) - : this._iaddn(num) - ); - }), - (BN.prototype._iaddn = function (num) { - this.words[0] += num; - for (var i = 0; i < this.length && this.words[i] >= 67108864; i++) - (this.words[i] -= 67108864), i === this.length - 1 ? (this.words[i + 1] = 1) : this.words[i + 1]++; - return (this.length = Math.max(this.length, i + 1)), this; - }), - (BN.prototype.isubn = function (num) { - if ((assert(typeof num == "number"), assert(num < 67108864), num < 0)) return this.iaddn(-num); - if (this.negative !== 0) return (this.negative = 0), this.iaddn(num), (this.negative = 1), this; - if (((this.words[0] -= num), this.length === 1 && this.words[0] < 0)) - (this.words[0] = -this.words[0]), (this.negative = 1); - else - for (var i = 0; i < this.length && this.words[i] < 0; i++) - (this.words[i] += 67108864), (this.words[i + 1] -= 1); - return this.strip(); - }), - (BN.prototype.addn = function (num) { - return this.clone().iaddn(num); - }), - (BN.prototype.subn = function (num) { - return this.clone().isubn(num); - }), - (BN.prototype.iabs = function () { - return (this.negative = 0), this; - }), - (BN.prototype.abs = function () { - return this.clone().iabs(); - }), - (BN.prototype._ishlnsubmul = function (num, mul, shift) { - var len = num.length + shift, - i; - this._expand(len); - var w, - carry = 0; - for (i = 0; i < num.length; i++) { - w = (this.words[i + shift] | 0) + carry; - var right = (num.words[i] | 0) * mul; - (w -= right & 67108863), - (carry = (w >> 26) - ((right / 67108864) | 0)), - (this.words[i + shift] = w & 67108863); - } - for (; i < this.length - shift; i++) - (w = (this.words[i + shift] | 0) + carry), (carry = w >> 26), (this.words[i + shift] = w & 67108863); - if (carry === 0) return this.strip(); - for (assert(carry === -1), carry = 0, i = 0; i < this.length; i++) - (w = -(this.words[i] | 0) + carry), (carry = w >> 26), (this.words[i] = w & 67108863); - return (this.negative = 1), this.strip(); - }), - (BN.prototype._wordDiv = function (num, mode) { - var shift = this.length - num.length, - a = this.clone(), - b = num, - bhi = b.words[b.length - 1] | 0, - bhiBits = this._countBits(bhi); - (shift = 26 - bhiBits), - shift !== 0 && ((b = b.ushln(shift)), a.iushln(shift), (bhi = b.words[b.length - 1] | 0)); - var m = a.length - b.length, - q; - if (mode !== "mod") { - (q = new BN(null)), (q.length = m + 1), (q.words = new Array(q.length)); - for (var i = 0; i < q.length; i++) q.words[i] = 0; - } - var diff = a.clone()._ishlnsubmul(b, 1, m); - diff.negative === 0 && ((a = diff), q && (q.words[m] = 1)); - for (var j = m - 1; j >= 0; j--) { - var qj = (a.words[b.length + j] | 0) * 67108864 + (a.words[b.length + j - 1] | 0); - for (qj = Math.min((qj / bhi) | 0, 67108863), a._ishlnsubmul(b, qj, j); a.negative !== 0; ) - qj--, (a.negative = 0), a._ishlnsubmul(b, 1, j), a.isZero() || (a.negative ^= 1); - q && (q.words[j] = qj); - } - return ( - q && q.strip(), - a.strip(), - mode !== "div" && shift !== 0 && a.iushrn(shift), - { - div: q || null, - mod: a, - } - ); - }), - (BN.prototype.divmod = function (num, mode, positive) { - if ((assert(!num.isZero()), this.isZero())) - return { - div: new BN(0), - mod: new BN(0), - }; - var div, mod, res; - return this.negative !== 0 && num.negative === 0 - ? ((res = this.neg().divmod(num, mode)), - mode !== "mod" && (div = res.div.neg()), - mode !== "div" && ((mod = res.mod.neg()), positive && mod.negative !== 0 && mod.iadd(num)), - { - div, - mod, - }) - : this.negative === 0 && num.negative !== 0 - ? ((res = this.divmod(num.neg(), mode)), - mode !== "mod" && (div = res.div.neg()), - { - div, - mod: res.mod, - }) - : (this.negative & num.negative) !== 0 - ? ((res = this.neg().divmod(num.neg(), mode)), - mode !== "div" && ((mod = res.mod.neg()), positive && mod.negative !== 0 && mod.isub(num)), - { - div: res.div, - mod, - }) - : num.length > this.length || this.cmp(num) < 0 - ? { - div: new BN(0), - mod: this, - } - : num.length === 1 - ? mode === "div" - ? { - div: this.divn(num.words[0]), - mod: null, - } - : mode === "mod" - ? { - div: null, - mod: new BN(this.modn(num.words[0])), - } - : { - div: this.divn(num.words[0]), - mod: new BN(this.modn(num.words[0])), - } - : this._wordDiv(num, mode); - }), - (BN.prototype.div = function (num) { - return this.divmod(num, "div", !1).div; - }), - (BN.prototype.mod = function (num) { - return this.divmod(num, "mod", !1).mod; - }), - (BN.prototype.umod = function (num) { - return this.divmod(num, "mod", !0).mod; - }), - (BN.prototype.divRound = function (num) { - var dm = this.divmod(num); - if (dm.mod.isZero()) return dm.div; - var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod, - half = num.ushrn(1), - r2 = num.andln(1), - cmp = mod.cmp(half); - return cmp < 0 || (r2 === 1 && cmp === 0) - ? dm.div - : dm.div.negative !== 0 - ? dm.div.isubn(1) - : dm.div.iaddn(1); - }), - (BN.prototype.modn = function (num) { - assert(num <= 67108863); - for (var p = (1 << 26) % num, acc = 0, i = this.length - 1; i >= 0; i--) - acc = (p * acc + (this.words[i] | 0)) % num; - return acc; - }), - (BN.prototype.idivn = function (num) { - assert(num <= 67108863); - for (var carry = 0, i = this.length - 1; i >= 0; i--) { - var w = (this.words[i] | 0) + carry * 67108864; - (this.words[i] = (w / num) | 0), (carry = w % num); - } - return this.strip(); - }), - (BN.prototype.divn = function (num) { - return this.clone().idivn(num); - }), - (BN.prototype.egcd = function (p) { - assert(p.negative === 0), assert(!p.isZero()); - var x = this, - y = p.clone(); - x.negative !== 0 ? (x = x.umod(p)) : (x = x.clone()); - for (var A = new BN(1), B = new BN(0), C = new BN(0), D = new BN(1), g = 0; x.isEven() && y.isEven(); ) - x.iushrn(1), y.iushrn(1), ++g; - for (var yp = y.clone(), xp = x.clone(); !x.isZero(); ) { - for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1); - if (i > 0) - for (x.iushrn(i); i-- > 0; ) - (A.isOdd() || B.isOdd()) && (A.iadd(yp), B.isub(xp)), A.iushrn(1), B.iushrn(1); - for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); - if (j > 0) - for (y.iushrn(j); j-- > 0; ) - (C.isOdd() || D.isOdd()) && (C.iadd(yp), D.isub(xp)), C.iushrn(1), D.iushrn(1); - x.cmp(y) >= 0 ? (x.isub(y), A.isub(C), B.isub(D)) : (y.isub(x), C.isub(A), D.isub(B)); - } - return { - a: C, - b: D, - gcd: y.iushln(g), - }; - }), - (BN.prototype._invmp = function (p) { - assert(p.negative === 0), assert(!p.isZero()); - var a = this, - b = p.clone(); - a.negative !== 0 ? (a = a.umod(p)) : (a = a.clone()); - for (var x1 = new BN(1), x2 = new BN(0), delta = b.clone(); a.cmpn(1) > 0 && b.cmpn(1) > 0; ) { - for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1); - if (i > 0) for (a.iushrn(i); i-- > 0; ) x1.isOdd() && x1.iadd(delta), x1.iushrn(1); - for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); - if (j > 0) for (b.iushrn(j); j-- > 0; ) x2.isOdd() && x2.iadd(delta), x2.iushrn(1); - a.cmp(b) >= 0 ? (a.isub(b), x1.isub(x2)) : (b.isub(a), x2.isub(x1)); - } - var res; - return a.cmpn(1) === 0 ? (res = x1) : (res = x2), res.cmpn(0) < 0 && res.iadd(p), res; - }), - (BN.prototype.gcd = function (num) { - if (this.isZero()) return num.abs(); - if (num.isZero()) return this.abs(); - var a = this.clone(), - b = num.clone(); - (a.negative = 0), (b.negative = 0); - for (var shift = 0; a.isEven() && b.isEven(); shift++) a.iushrn(1), b.iushrn(1); - do { - for (; a.isEven(); ) a.iushrn(1); - for (; b.isEven(); ) b.iushrn(1); - var r = a.cmp(b); - if (r < 0) { - var t = a; - (a = b), (b = t); - } else if (r === 0 || b.cmpn(1) === 0) break; - a.isub(b); - } while (!0); - return b.iushln(shift); - }), - (BN.prototype.invm = function (num) { - return this.egcd(num).a.umod(num); - }), - (BN.prototype.isEven = function () { - return (this.words[0] & 1) === 0; - }), - (BN.prototype.isOdd = function () { - return (this.words[0] & 1) === 1; - }), - (BN.prototype.andln = function (num) { - return this.words[0] & num; - }), - (BN.prototype.bincn = function (bit) { - assert(typeof bit == "number"); - var r = bit % 26, - s = (bit - r) / 26, - q = 1 << r; - if (this.length <= s) return this._expand(s + 1), (this.words[s] |= q), this; - for (var carry = q, i = s; carry !== 0 && i < this.length; i++) { - var w = this.words[i] | 0; - (w += carry), (carry = w >>> 26), (w &= 67108863), (this.words[i] = w); - } - return carry !== 0 && ((this.words[i] = carry), this.length++), this; - }), - (BN.prototype.isZero = function () { - return this.length === 1 && this.words[0] === 0; - }), - (BN.prototype.cmpn = function (num) { - var negative = num < 0; - if (this.negative !== 0 && !negative) return -1; - if (this.negative === 0 && negative) return 1; - this.strip(); - var res; - if (this.length > 1) res = 1; - else { - negative && (num = -num), assert(num <= 67108863, "Number is too big"); - var w = this.words[0] | 0; - res = w === num ? 0 : w < num ? -1 : 1; - } - return this.negative !== 0 ? -res | 0 : res; - }), - (BN.prototype.cmp = function (num) { - if (this.negative !== 0 && num.negative === 0) return -1; - if (this.negative === 0 && num.negative !== 0) return 1; - var res = this.ucmp(num); - return this.negative !== 0 ? -res | 0 : res; - }), - (BN.prototype.ucmp = function (num) { - if (this.length > num.length) return 1; - if (this.length < num.length) return -1; - for (var res = 0, i = this.length - 1; i >= 0; i--) { - var a = this.words[i] | 0, - b = num.words[i] | 0; - if (a !== b) { - a < b ? (res = -1) : a > b && (res = 1); - break; - } - } - return res; - }), - (BN.prototype.gtn = function (num) { - return this.cmpn(num) === 1; - }), - (BN.prototype.gt = function (num) { - return this.cmp(num) === 1; - }), - (BN.prototype.gten = function (num) { - return this.cmpn(num) >= 0; - }), - (BN.prototype.gte = function (num) { - return this.cmp(num) >= 0; - }), - (BN.prototype.ltn = function (num) { - return this.cmpn(num) === -1; - }), - (BN.prototype.lt = function (num) { - return this.cmp(num) === -1; - }), - (BN.prototype.lten = function (num) { - return this.cmpn(num) <= 0; - }), - (BN.prototype.lte = function (num) { - return this.cmp(num) <= 0; - }), - (BN.prototype.eqn = function (num) { - return this.cmpn(num) === 0; - }), - (BN.prototype.eq = function (num) { - return this.cmp(num) === 0; - }), - (BN.red = function (num) { - return new Red(num); - }), - (BN.prototype.toRed = function (ctx) { - return ( - assert(!this.red, "Already a number in reduction context"), - assert(this.negative === 0, "red works only with positives"), - ctx.convertTo(this)._forceRed(ctx) - ); - }), - (BN.prototype.fromRed = function () { - return assert(this.red, "fromRed works only with numbers in reduction context"), this.red.convertFrom(this); - }), - (BN.prototype._forceRed = function (ctx) { - return (this.red = ctx), this; - }), - (BN.prototype.forceRed = function (ctx) { - return assert(!this.red, "Already a number in reduction context"), this._forceRed(ctx); - }), - (BN.prototype.redAdd = function (num) { - return assert(this.red, "redAdd works only with red numbers"), this.red.add(this, num); - }), - (BN.prototype.redIAdd = function (num) { - return assert(this.red, "redIAdd works only with red numbers"), this.red.iadd(this, num); - }), - (BN.prototype.redSub = function (num) { - return assert(this.red, "redSub works only with red numbers"), this.red.sub(this, num); - }), - (BN.prototype.redISub = function (num) { - return assert(this.red, "redISub works only with red numbers"), this.red.isub(this, num); - }), - (BN.prototype.redShl = function (num) { - return assert(this.red, "redShl works only with red numbers"), this.red.shl(this, num); - }), - (BN.prototype.redMul = function (num) { - return ( - assert(this.red, "redMul works only with red numbers"), - this.red._verify2(this, num), - this.red.mul(this, num) - ); - }), - (BN.prototype.redIMul = function (num) { - return ( - assert(this.red, "redMul works only with red numbers"), - this.red._verify2(this, num), - this.red.imul(this, num) - ); - }), - (BN.prototype.redSqr = function () { - return assert(this.red, "redSqr works only with red numbers"), this.red._verify1(this), this.red.sqr(this); - }), - (BN.prototype.redISqr = function () { - return assert(this.red, "redISqr works only with red numbers"), this.red._verify1(this), this.red.isqr(this); - }), - (BN.prototype.redSqrt = function () { - return assert(this.red, "redSqrt works only with red numbers"), this.red._verify1(this), this.red.sqrt(this); - }), - (BN.prototype.redInvm = function () { - return assert(this.red, "redInvm works only with red numbers"), this.red._verify1(this), this.red.invm(this); - }), - (BN.prototype.redNeg = function () { - return assert(this.red, "redNeg works only with red numbers"), this.red._verify1(this), this.red.neg(this); - }), - (BN.prototype.redPow = function (num) { - return assert(this.red && !num.red, "redPow(normalNum)"), this.red._verify1(this), this.red.pow(this, num); - }); - var primes = { - k256: null, - p224: null, - p192: null, - p25519: null, - }; - function MPrime(name, p) { - (this.name = name), - (this.p = new BN(p, 16)), - (this.n = this.p.bitLength()), - (this.k = new BN(1).iushln(this.n).isub(this.p)), - (this.tmp = this._tmp()); - } - (MPrime.prototype._tmp = function () { - var tmp = new BN(null); - return (tmp.words = new Array(Math.ceil(this.n / 13))), tmp; - }), - (MPrime.prototype.ireduce = function (num) { - var r = num, - rlen; - do this.split(r, this.tmp), (r = this.imulK(r)), (r = r.iadd(this.tmp)), (rlen = r.bitLength()); - while (rlen > this.n); - var cmp = rlen < this.n ? -1 : r.ucmp(this.p); - return ( - cmp === 0 - ? ((r.words[0] = 0), (r.length = 1)) - : cmp > 0 - ? r.isub(this.p) - : r.strip !== void 0 - ? r.strip() - : r._strip(), - r - ); - }), - (MPrime.prototype.split = function (input, out) { - input.iushrn(this.n, 0, out); - }), - (MPrime.prototype.imulK = function (num) { - return num.imul(this.k); - }); - function K256() { - MPrime.call(this, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); - } - inherits(K256, MPrime), - (K256.prototype.split = function (input, output) { - for (var mask = 4194303, outLen = Math.min(input.length, 9), i = 0; i < outLen; i++) - output.words[i] = input.words[i]; - if (((output.length = outLen), input.length <= 9)) { - (input.words[0] = 0), (input.length = 1); - return; - } - var prev = input.words[9]; - for (output.words[output.length++] = prev & mask, i = 10; i < input.length; i++) { - var next = input.words[i] | 0; - (input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22)), (prev = next); - } - (prev >>>= 22), - (input.words[i - 10] = prev), - prev === 0 && input.length > 10 ? (input.length -= 10) : (input.length -= 9); - }), - (K256.prototype.imulK = function (num) { - (num.words[num.length] = 0), (num.words[num.length + 1] = 0), (num.length += 2); - for (var lo = 0, i = 0; i < num.length; i++) { - var w = num.words[i] | 0; - (lo += w * 977), (num.words[i] = lo & 67108863), (lo = w * 64 + ((lo / 67108864) | 0)); - } - return ( - num.words[num.length - 1] === 0 && (num.length--, num.words[num.length - 1] === 0 && num.length--), num - ); - }); - function P224() { - MPrime.call(this, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); - } - inherits(P224, MPrime); - function P192() { - MPrime.call(this, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); - } - inherits(P192, MPrime); - function P25519() { - MPrime.call(this, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); - } - inherits(P25519, MPrime), - (P25519.prototype.imulK = function (num) { - for (var carry = 0, i = 0; i < num.length; i++) { - var hi = (num.words[i] | 0) * 19 + carry, - lo = hi & 67108863; - (hi >>>= 26), (num.words[i] = lo), (carry = hi); - } - return carry !== 0 && (num.words[num.length++] = carry), num; - }), - (BN._prime = function (name) { - if (primes[name]) return primes[name]; - var prime2; - if (name === "k256") prime2 = new K256(); - else if (name === "p224") prime2 = new P224(); - else if (name === "p192") prime2 = new P192(); - else if (name === "p25519") prime2 = new P25519(); - else throw new Error("Unknown prime " + name); - return (primes[name] = prime2), prime2; - }); - function Red(m) { - if (typeof m == "string") { - var prime = BN._prime(m); - (this.m = prime.p), (this.prime = prime); - } else assert(m.gtn(1), "modulus must be greater than 1"), (this.m = m), (this.prime = null); - } - (Red.prototype._verify1 = function (a) { - assert(a.negative === 0, "red works only with positives"), assert(a.red, "red works only with red numbers"); - }), - (Red.prototype._verify2 = function (a, b) { - assert((a.negative | b.negative) === 0, "red works only with positives"), - assert(a.red && a.red === b.red, "red works only with red numbers"); - }), - (Red.prototype.imod = function (a) { - return this.prime ? this.prime.ireduce(a)._forceRed(this) : a.umod(this.m)._forceRed(this); - }), - (Red.prototype.neg = function (a) { - return a.isZero() ? a.clone() : this.m.sub(a)._forceRed(this); - }), - (Red.prototype.add = function (a, b) { - this._verify2(a, b); - var res = a.add(b); - return res.cmp(this.m) >= 0 && res.isub(this.m), res._forceRed(this); - }), - (Red.prototype.iadd = function (a, b) { - this._verify2(a, b); - var res = a.iadd(b); - return res.cmp(this.m) >= 0 && res.isub(this.m), res; - }), - (Red.prototype.sub = function (a, b) { - this._verify2(a, b); - var res = a.sub(b); - return res.cmpn(0) < 0 && res.iadd(this.m), res._forceRed(this); - }), - (Red.prototype.isub = function (a, b) { - this._verify2(a, b); - var res = a.isub(b); - return res.cmpn(0) < 0 && res.iadd(this.m), res; - }), - (Red.prototype.shl = function (a, num) { - return this._verify1(a), this.imod(a.ushln(num)); - }), - (Red.prototype.imul = function (a, b) { - return this._verify2(a, b), this.imod(a.imul(b)); - }), - (Red.prototype.mul = function (a, b) { - return this._verify2(a, b), this.imod(a.mul(b)); - }), - (Red.prototype.isqr = function (a) { - return this.imul(a, a.clone()); - }), - (Red.prototype.sqr = function (a) { - return this.mul(a, a); - }), - (Red.prototype.sqrt = function (a) { - if (a.isZero()) return a.clone(); - var mod3 = this.m.andln(3); - if ((assert(mod3 % 2 === 1), mod3 === 3)) { - var pow = this.m.add(new BN(1)).iushrn(2); - return this.pow(a, pow); - } - for (var q = this.m.subn(1), s = 0; !q.isZero() && q.andln(1) === 0; ) s++, q.iushrn(1); - assert(!q.isZero()); - var one = new BN(1).toRed(this), - nOne = one.redNeg(), - lpow = this.m.subn(1).iushrn(1), - z = this.m.bitLength(); - for (z = new BN(2 * z * z).toRed(this); this.pow(z, lpow).cmp(nOne) !== 0; ) z.redIAdd(nOne); - for ( - var c = this.pow(z, q), r = this.pow(a, q.addn(1).iushrn(1)), t = this.pow(a, q), m = s; - t.cmp(one) !== 0; - - ) { - for (var tmp = t, i = 0; tmp.cmp(one) !== 0; i++) tmp = tmp.redSqr(); - assert(i < m); - var b = this.pow(c, new BN(1).iushln(m - i - 1)); - (r = r.redMul(b)), (c = b.redSqr()), (t = t.redMul(c)), (m = i); - } - return r; - }), - (Red.prototype.invm = function (a) { - var inv = a._invmp(this.m); - return inv.negative !== 0 ? ((inv.negative = 0), this.imod(inv).redNeg()) : this.imod(inv); - }), - (Red.prototype.pow = function (a, num) { - if (num.isZero()) return new BN(1).toRed(this); - if (num.cmpn(1) === 0) return a.clone(); - var windowSize = 4, - wnd = new Array(1 << windowSize); - (wnd[0] = new BN(1).toRed(this)), (wnd[1] = a); - for (var i = 2; i < wnd.length; i++) wnd[i] = this.mul(wnd[i - 1], a); - var res = wnd[0], - current = 0, - currentLen = 0, - start = num.bitLength() % 26; - for (start === 0 && (start = 26), i = num.length - 1; i >= 0; i--) { - for (var word = num.words[i], j = start - 1; j >= 0; j--) { - var bit = (word >> j) & 1; - if ((res !== wnd[0] && (res = this.sqr(res)), bit === 0 && current === 0)) { - currentLen = 0; - continue; - } - (current <<= 1), - (current |= bit), - currentLen++, - !(currentLen !== windowSize && (i !== 0 || j !== 0)) && - ((res = this.mul(res, wnd[current])), (currentLen = 0), (current = 0)); - } - start = 26; - } - return res; - }), - (Red.prototype.convertTo = function (num) { - var r = num.umod(this.m); - return r === num ? r.clone() : r; - }), - (Red.prototype.convertFrom = function (num) { - var res = num.clone(); - return (res.red = null), res; - }), - (BN.mont = function (num) { - return new Mont(num); - }); - function Mont(m) { - Red.call(this, m), - (this.shift = this.m.bitLength()), - this.shift % 26 !== 0 && (this.shift += 26 - (this.shift % 26)), - (this.r = new BN(1).iushln(this.shift)), - (this.r2 = this.imod(this.r.sqr())), - (this.rinv = this.r._invmp(this.m)), - (this.minv = this.rinv.mul(this.r).isubn(1).div(this.m)), - (this.minv = this.minv.umod(this.r)), - (this.minv = this.r.sub(this.minv)); - } - inherits(Mont, Red), - (Mont.prototype.convertTo = function (num) { - return this.imod(num.ushln(this.shift)); - }), - (Mont.prototype.convertFrom = function (num) { - var r = this.imod(num.mul(this.rinv)); - return (r.red = null), r; - }), - (Mont.prototype.imul = function (a, b) { - if (a.isZero() || b.isZero()) return (a.words[0] = 0), (a.length = 1), a; - var t = a.imul(b), - c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), - u = t.isub(c).iushrn(this.shift), - res = u; - return ( - u.cmp(this.m) >= 0 ? (res = u.isub(this.m)) : u.cmpn(0) < 0 && (res = u.iadd(this.m)), res._forceRed(this) - ); - }), - (Mont.prototype.mul = function (a, b) { - if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this); - var t = a.mul(b), - c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), - u = t.isub(c).iushrn(this.shift), - res = u; - return ( - u.cmp(this.m) >= 0 ? (res = u.isub(this.m)) : u.cmpn(0) < 0 && (res = u.iadd(this.m)), res._forceRed(this) - ); - }), - (Mont.prototype.invm = function (a) { - var res = this.imod(a._invmp(this.m).mul(this.r2)); - return res._forceRed(this); - }); - })(typeof module > "u" || module, exports); - }, -}); - -// (disabled):node_modules/crypto-browserify/index.js -var require_crypto_browserify = __commonJS({ - "(disabled):node_modules/crypto-browserify/index.js"() {}, -}); +var require_bn2 = require_bn; // node_modules/brorand/index.js var require_brorand = __commonJS({ @@ -7331,6 +5313,7 @@ var require_brorand = __commonJS({ function Rand(rand) { this.rand = rand; } + Rand.prototype = {}; module.exports.Rand = Rand; Rand.prototype.generate = function (len) { return this._rand(len); @@ -7355,6 +5338,7 @@ var require_mr = __commonJS({ MillerRabin.create = function (rand) { return new MillerRabin(rand); }; + MillerRabin.prototype = {}; MillerRabin.prototype._randbelow = function (n) { var len = n.bitLength(), min_bytes = Math.ceil(len / 8); @@ -7585,6 +5569,7 @@ var require_dh = __commonJS({ (this._primeCode = void 0), malleable ? ((this.setPublicKey = setPublicKey), (this.setPrivateKey = setPrivateKey)) : (this._primeCode = 8); } + DH.prototype = {}; Object.defineProperty(DH.prototype, "verifyError", { enumerable: !0, get: function () { @@ -7673,2035 +5658,7 @@ var require_browser7 = __commonJS({ }); // node_modules/bn.js/lib/bn.js -var require_bn3 = __commonJS({ - "node_modules/bn.js/lib/bn.js"(exports, module) { - (function (module2, exports2) { - "use strict"; - function assert(val, msg) { - if (!val) throw new Error(msg || "Assertion failed"); - } - function inherits(ctor, superCtor) { - ctor.super_ = superCtor; - var TempCtor = function () {}; - (TempCtor.prototype = superCtor.prototype), - (ctor.prototype = new TempCtor()), - (ctor.prototype.constructor = ctor); - } - function BN(number, base, endian) { - if (BN.isBN(number)) return number; - (this.negative = 0), - (this.words = null), - (this.length = 0), - (this.red = null), - number !== null && - ((base === "le" || base === "be") && ((endian = base), (base = 10)), - this._init(number || 0, base || 10, endian || "be")); - } - typeof module2 == "object" ? (module2.exports = BN) : (exports2.BN = BN), (BN.BN = BN), (BN.wordSize = 26); - var Buffer2 = Buffer; - (BN.isBN = function (num) { - return num instanceof BN - ? !0 - : num !== null && - typeof num == "object" && - num.constructor.wordSize === BN.wordSize && - Array.isArray(num.words); - }), - (BN.max = function (left, right) { - return left.cmp(right) > 0 ? left : right; - }), - (BN.min = function (left, right) { - return left.cmp(right) < 0 ? left : right; - }), - (BN.prototype._init = function (number, base, endian) { - if (typeof number == "number") return this._initNumber(number, base, endian); - if (typeof number == "object") return this._initArray(number, base, endian); - base === "hex" && (base = 16), - assert(base === (base | 0) && base >= 2 && base <= 36), - (number = number.toString().replace(/\s+/g, "")); - var start = 0; - number[0] === "-" && (start++, (this.negative = 1)), - start < number.length && - (base === 16 - ? this._parseHex(number, start, endian) - : (this._parseBase(number, base, start), - endian === "le" && this._initArray(this.toArray(), base, endian))); - }), - (BN.prototype._initNumber = function (number, base, endian) { - number < 0 && ((this.negative = 1), (number = -number)), - number < 67108864 - ? ((this.words = [number & 67108863]), (this.length = 1)) - : number < 4503599627370496 - ? ((this.words = [number & 67108863, (number / 67108864) & 67108863]), (this.length = 2)) - : (assert(number < 9007199254740992), - (this.words = [number & 67108863, (number / 67108864) & 67108863, 1]), - (this.length = 3)), - endian === "le" && this._initArray(this.toArray(), base, endian); - }), - (BN.prototype._initArray = function (number, base, endian) { - if ((assert(typeof number.length == "number"), number.length <= 0)) - return (this.words = [0]), (this.length = 1), this; - (this.length = Math.ceil(number.length / 3)), (this.words = new Array(this.length)); - for (var i = 0; i < this.length; i++) this.words[i] = 0; - var j, - w, - off = 0; - if (endian === "be") - for (i = number.length - 1, j = 0; i >= 0; i -= 3) - (w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16)), - (this.words[j] |= (w << off) & 67108863), - (this.words[j + 1] = (w >>> (26 - off)) & 67108863), - (off += 24), - off >= 26 && ((off -= 26), j++); - else if (endian === "le") - for (i = 0, j = 0; i < number.length; i += 3) - (w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16)), - (this.words[j] |= (w << off) & 67108863), - (this.words[j + 1] = (w >>> (26 - off)) & 67108863), - (off += 24), - off >= 26 && ((off -= 26), j++); - return this._strip(); - }); - function parseHex4Bits(string, index) { - var c = string.charCodeAt(index); - if (c >= 48 && c <= 57) return c - 48; - if (c >= 65 && c <= 70) return c - 55; - if (c >= 97 && c <= 102) return c - 87; - assert(!1, "Invalid character in " + string); - } - function parseHexByte(string, lowerBound, index) { - var r = parseHex4Bits(string, index); - return index - 1 >= lowerBound && (r |= parseHex4Bits(string, index - 1) << 4), r; - } - BN.prototype._parseHex = function (number, start, endian) { - (this.length = Math.ceil((number.length - start) / 6)), (this.words = new Array(this.length)); - for (var i = 0; i < this.length; i++) this.words[i] = 0; - var off = 0, - j = 0, - w; - if (endian === "be") - for (i = number.length - 1; i >= start; i -= 2) - (w = parseHexByte(number, start, i) << off), - (this.words[j] |= w & 67108863), - off >= 18 ? ((off -= 18), (j += 1), (this.words[j] |= w >>> 26)) : (off += 8); - else { - var parseLength = number.length - start; - for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) - (w = parseHexByte(number, start, i) << off), - (this.words[j] |= w & 67108863), - off >= 18 ? ((off -= 18), (j += 1), (this.words[j] |= w >>> 26)) : (off += 8); - } - this._strip(); - }; - function parseBase(str, start, end, mul) { - for (var r = 0, b = 0, len = Math.min(str.length, end), i = start; i < len; i++) { - var c = str.charCodeAt(i) - 48; - (r *= mul), - c >= 49 ? (b = c - 49 + 10) : c >= 17 ? (b = c - 17 + 10) : (b = c), - assert(c >= 0 && b < mul, "Invalid character"), - (r += b); - } - return r; - } - (BN.prototype._parseBase = function (number, base, start) { - (this.words = [0]), (this.length = 1); - for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *= base) limbLen++; - limbLen--, (limbPow = (limbPow / base) | 0); - for ( - var total = number.length - start, - mod = total % limbLen, - end = Math.min(total, total - mod) + start, - word = 0, - i = start; - i < end; - i += limbLen - ) - (word = parseBase(number, i, i + limbLen, base)), - this.imuln(limbPow), - this.words[0] + word < 67108864 ? (this.words[0] += word) : this._iaddn(word); - if (mod !== 0) { - var pow = 1; - for (word = parseBase(number, i, number.length, base), i = 0; i < mod; i++) pow *= base; - this.imuln(pow), this.words[0] + word < 67108864 ? (this.words[0] += word) : this._iaddn(word); - } - this._strip(); - }), - (BN.prototype.copy = function (dest) { - dest.words = new Array(this.length); - for (var i = 0; i < this.length; i++) dest.words[i] = this.words[i]; - (dest.length = this.length), (dest.negative = this.negative), (dest.red = this.red); - }); - function move(dest, src) { - (dest.words = src.words), (dest.length = src.length), (dest.negative = src.negative), (dest.red = src.red); - } - if ( - ((BN.prototype._move = function (dest) { - move(dest, this); - }), - (BN.prototype.clone = function () { - var r = new BN(null); - return this.copy(r), r; - }), - (BN.prototype._expand = function (size) { - for (; this.length < size; ) this.words[this.length++] = 0; - return this; - }), - (BN.prototype._strip = function () { - for (; this.length > 1 && this.words[this.length - 1] === 0; ) this.length--; - return this._normSign(); - }), - (BN.prototype._normSign = function () { - return this.length === 1 && this.words[0] === 0 && (this.negative = 0), this; - }), - typeof Symbol < "u" && typeof Symbol.for == "function") - ) - try { - BN.prototype[Symbol.for("nodejs.util.inspect.custom")] = inspect; - } catch { - BN.prototype.inspect = inspect; - } - else BN.prototype.inspect = inspect; - function inspect() { - return (this.red ? "<BN-R: " : "<BN: ") + this.toString(16) + ">"; - } - var zeros = [ - "", - "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", - ], - groupSizes = [ - 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, - ], - groupBases = [ - 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 (base, padding) { - (base = base || 10), (padding = padding | 0 || 1); - var out; - if (base === 16 || base === "hex") { - out = ""; - for (var off = 0, carry = 0, i = 0; i < this.length; i++) { - var w = this.words[i], - word = (((w << off) | carry) & 16777215).toString(16); - (carry = (w >>> (24 - off)) & 16777215), - (off += 2), - off >= 26 && ((off -= 26), i--), - carry !== 0 || i !== this.length - 1 ? (out = zeros[6 - word.length] + word + out) : (out = word + out); - } - for (carry !== 0 && (out = carry.toString(16) + out); out.length % padding !== 0; ) out = "0" + out; - return this.negative !== 0 && (out = "-" + out), out; - } - if (base === (base | 0) && base >= 2 && base <= 36) { - var groupSize = groupSizes[base], - groupBase = groupBases[base]; - out = ""; - var c = this.clone(); - for (c.negative = 0; !c.isZero(); ) { - var r = c.modrn(groupBase).toString(base); - (c = c.idivn(groupBase)), c.isZero() ? (out = r + out) : (out = zeros[groupSize - r.length] + r + out); - } - for (this.isZero() && (out = "0" + out); out.length % padding !== 0; ) out = "0" + out; - return this.negative !== 0 && (out = "-" + out), out; - } - assert(!1, "Base should be between 2 and 36"); - }), - (BN.prototype.toNumber = function () { - var ret = this.words[0]; - return ( - this.length === 2 - ? (ret += this.words[1] * 67108864) - : this.length === 3 && this.words[2] === 1 - ? (ret += 4503599627370496 + this.words[1] * 67108864) - : this.length > 2 && assert(!1, "Number can only safely store up to 53 bits"), - this.negative !== 0 ? -ret : ret - ); - }), - (BN.prototype.toJSON = function () { - return this.toString(16, 2); - }), - Buffer2 && - (BN.prototype.toBuffer = function (endian, length) { - return this.toArrayLike(Buffer2, endian, length); - }), - (BN.prototype.toArray = function (endian, length) { - return this.toArrayLike(Array, endian, length); - }); - var allocate = function (ArrayType, size) { - return ArrayType.allocUnsafe ? ArrayType.allocUnsafe(size) : new ArrayType(size); - }; - (BN.prototype.toArrayLike = function (ArrayType, endian, length) { - this._strip(); - var byteLength = this.byteLength(), - reqLength = length || Math.max(1, byteLength); - assert(byteLength <= reqLength, "byte array longer than desired length"), - assert(reqLength > 0, "Requested array length <= 0"); - var res = allocate(ArrayType, reqLength), - postfix = endian === "le" ? "LE" : "BE"; - return this["_toArrayLike" + postfix](res, byteLength), res; - }), - (BN.prototype._toArrayLikeLE = function (res, byteLength) { - for (var position = 0, carry = 0, i = 0, shift = 0; i < this.length; i++) { - var word = (this.words[i] << shift) | carry; - (res[position++] = word & 255), - position < res.length && (res[position++] = (word >> 8) & 255), - position < res.length && (res[position++] = (word >> 16) & 255), - shift === 6 - ? (position < res.length && (res[position++] = (word >> 24) & 255), (carry = 0), (shift = 0)) - : ((carry = word >>> 24), (shift += 2)); - } - if (position < res.length) for (res[position++] = carry; position < res.length; ) res[position++] = 0; - }), - (BN.prototype._toArrayLikeBE = function (res, byteLength) { - for (var position = res.length - 1, carry = 0, i = 0, shift = 0; i < this.length; i++) { - var word = (this.words[i] << shift) | carry; - (res[position--] = word & 255), - position >= 0 && (res[position--] = (word >> 8) & 255), - position >= 0 && (res[position--] = (word >> 16) & 255), - shift === 6 - ? (position >= 0 && (res[position--] = (word >> 24) & 255), (carry = 0), (shift = 0)) - : ((carry = word >>> 24), (shift += 2)); - } - if (position >= 0) for (res[position--] = carry; position >= 0; ) res[position--] = 0; - }), - Math.clz32 - ? (BN.prototype._countBits = function (w) { - return 32 - Math.clz32(w); - }) - : (BN.prototype._countBits = function (w) { - var t = w, - r = 0; - return ( - t >= 4096 && ((r += 13), (t >>>= 13)), - t >= 64 && ((r += 7), (t >>>= 7)), - t >= 8 && ((r += 4), (t >>>= 4)), - t >= 2 && ((r += 2), (t >>>= 2)), - r + t - ); - }), - (BN.prototype._zeroBits = function (w) { - if (w === 0) return 26; - var t = w, - r = 0; - return ( - (t & 8191) === 0 && ((r += 13), (t >>>= 13)), - (t & 127) === 0 && ((r += 7), (t >>>= 7)), - (t & 15) === 0 && ((r += 4), (t >>>= 4)), - (t & 3) === 0 && ((r += 2), (t >>>= 2)), - (t & 1) === 0 && r++, - r - ); - }), - (BN.prototype.bitLength = function () { - var w = this.words[this.length - 1], - hi = this._countBits(w); - return (this.length - 1) * 26 + hi; - }); - function toBitArray(num) { - for (var w = new Array(num.bitLength()), bit = 0; bit < w.length; bit++) { - var off = (bit / 26) | 0, - wbit = bit % 26; - w[bit] = (num.words[off] >>> wbit) & 1; - } - return w; - } - (BN.prototype.zeroBits = function () { - if (this.isZero()) return 0; - for (var r = 0, i = 0; i < this.length; i++) { - var b = this._zeroBits(this.words[i]); - if (((r += b), b !== 26)) break; - } - return r; - }), - (BN.prototype.byteLength = function () { - return Math.ceil(this.bitLength() / 8); - }), - (BN.prototype.toTwos = function (width) { - return this.negative !== 0 ? this.abs().inotn(width).iaddn(1) : this.clone(); - }), - (BN.prototype.fromTwos = function (width) { - return this.testn(width - 1) ? this.notn(width).iaddn(1).ineg() : this.clone(); - }), - (BN.prototype.isNeg = function () { - return this.negative !== 0; - }), - (BN.prototype.neg = function () { - return this.clone().ineg(); - }), - (BN.prototype.ineg = function () { - return this.isZero() || (this.negative ^= 1), this; - }), - (BN.prototype.iuor = function (num) { - for (; this.length < num.length; ) this.words[this.length++] = 0; - for (var i = 0; i < num.length; i++) this.words[i] = this.words[i] | num.words[i]; - return this._strip(); - }), - (BN.prototype.ior = function (num) { - return assert((this.negative | num.negative) === 0), this.iuor(num); - }), - (BN.prototype.or = function (num) { - return this.length > num.length ? this.clone().ior(num) : num.clone().ior(this); - }), - (BN.prototype.uor = function (num) { - return this.length > num.length ? this.clone().iuor(num) : num.clone().iuor(this); - }), - (BN.prototype.iuand = function (num) { - var b; - this.length > num.length ? (b = num) : (b = this); - for (var i = 0; i < b.length; i++) this.words[i] = this.words[i] & num.words[i]; - return (this.length = b.length), this._strip(); - }), - (BN.prototype.iand = function (num) { - return assert((this.negative | num.negative) === 0), this.iuand(num); - }), - (BN.prototype.and = function (num) { - return this.length > num.length ? this.clone().iand(num) : num.clone().iand(this); - }), - (BN.prototype.uand = function (num) { - return this.length > num.length ? this.clone().iuand(num) : num.clone().iuand(this); - }), - (BN.prototype.iuxor = function (num) { - var a, b; - this.length > num.length ? ((a = this), (b = num)) : ((a = num), (b = this)); - for (var i = 0; i < b.length; i++) this.words[i] = a.words[i] ^ b.words[i]; - if (this !== a) for (; i < a.length; i++) this.words[i] = a.words[i]; - return (this.length = a.length), this._strip(); - }), - (BN.prototype.ixor = function (num) { - return assert((this.negative | num.negative) === 0), this.iuxor(num); - }), - (BN.prototype.xor = function (num) { - return this.length > num.length ? this.clone().ixor(num) : num.clone().ixor(this); - }), - (BN.prototype.uxor = function (num) { - return this.length > num.length ? this.clone().iuxor(num) : num.clone().iuxor(this); - }), - (BN.prototype.inotn = function (width) { - assert(typeof width == "number" && width >= 0); - var bytesNeeded = Math.ceil(width / 26) | 0, - bitsLeft = width % 26; - this._expand(bytesNeeded), bitsLeft > 0 && bytesNeeded--; - for (var i = 0; i < bytesNeeded; i++) this.words[i] = ~this.words[i] & 67108863; - return bitsLeft > 0 && (this.words[i] = ~this.words[i] & (67108863 >> (26 - bitsLeft))), this._strip(); - }), - (BN.prototype.notn = function (width) { - return this.clone().inotn(width); - }), - (BN.prototype.setn = function (bit, val) { - assert(typeof bit == "number" && bit >= 0); - var off = (bit / 26) | 0, - wbit = bit % 26; - return ( - this._expand(off + 1), - val - ? (this.words[off] = this.words[off] | (1 << wbit)) - : (this.words[off] = this.words[off] & ~(1 << wbit)), - this._strip() - ); - }), - (BN.prototype.iadd = function (num) { - var r; - if (this.negative !== 0 && num.negative === 0) - return (this.negative = 0), (r = this.isub(num)), (this.negative ^= 1), this._normSign(); - if (this.negative === 0 && num.negative !== 0) - return (num.negative = 0), (r = this.isub(num)), (num.negative = 1), r._normSign(); - var a, b; - this.length > num.length ? ((a = this), (b = num)) : ((a = num), (b = this)); - for (var carry = 0, i = 0; i < b.length; i++) - (r = (a.words[i] | 0) + (b.words[i] | 0) + carry), (this.words[i] = r & 67108863), (carry = r >>> 26); - for (; carry !== 0 && i < a.length; i++) - (r = (a.words[i] | 0) + carry), (this.words[i] = r & 67108863), (carry = r >>> 26); - if (((this.length = a.length), carry !== 0)) (this.words[this.length] = carry), this.length++; - else if (a !== this) for (; i < a.length; i++) this.words[i] = a.words[i]; - return this; - }), - (BN.prototype.add = function (num) { - var res; - return num.negative !== 0 && this.negative === 0 - ? ((num.negative = 0), (res = this.sub(num)), (num.negative ^= 1), res) - : num.negative === 0 && this.negative !== 0 - ? ((this.negative = 0), (res = num.sub(this)), (this.negative = 1), res) - : this.length > num.length - ? this.clone().iadd(num) - : num.clone().iadd(this); - }), - (BN.prototype.isub = function (num) { - if (num.negative !== 0) { - num.negative = 0; - var r = this.iadd(num); - return (num.negative = 1), r._normSign(); - } else if (this.negative !== 0) - return (this.negative = 0), this.iadd(num), (this.negative = 1), this._normSign(); - var cmp = this.cmp(num); - if (cmp === 0) return (this.negative = 0), (this.length = 1), (this.words[0] = 0), this; - var a, b; - cmp > 0 ? ((a = this), (b = num)) : ((a = num), (b = this)); - for (var carry = 0, i = 0; i < b.length; i++) - (r = (a.words[i] | 0) - (b.words[i] | 0) + carry), (carry = r >> 26), (this.words[i] = r & 67108863); - for (; carry !== 0 && i < a.length; i++) - (r = (a.words[i] | 0) + carry), (carry = r >> 26), (this.words[i] = r & 67108863); - if (carry === 0 && i < a.length && a !== this) for (; i < a.length; i++) this.words[i] = a.words[i]; - return (this.length = Math.max(this.length, i)), a !== this && (this.negative = 1), this._strip(); - }), - (BN.prototype.sub = function (num) { - return this.clone().isub(num); - }); - function smallMulTo(self2, num, out) { - out.negative = num.negative ^ self2.negative; - var len = (self2.length + num.length) | 0; - (out.length = len), (len = (len - 1) | 0); - var a = self2.words[0] | 0, - b = num.words[0] | 0, - r = a * b, - lo = r & 67108863, - carry = (r / 67108864) | 0; - out.words[0] = lo; - for (var k = 1; k < len; k++) { - for ( - var ncarry = carry >>> 26, - rword = carry & 67108863, - maxJ = Math.min(k, num.length - 1), - j = Math.max(0, k - self2.length + 1); - j <= maxJ; - j++ - ) { - var i = (k - j) | 0; - (a = self2.words[i] | 0), - (b = num.words[j] | 0), - (r = a * b + rword), - (ncarry += (r / 67108864) | 0), - (rword = r & 67108863); - } - (out.words[k] = rword | 0), (carry = ncarry | 0); - } - return carry !== 0 ? (out.words[k] = carry | 0) : out.length--, out._strip(); - } - var comb10MulTo = function (self2, num, out) { - var a = self2.words, - b = num.words, - o = out.words, - c = 0, - lo, - mid, - hi, - a0 = a[0] | 0, - al0 = a0 & 8191, - ah0 = a0 >>> 13, - a1 = a[1] | 0, - al1 = a1 & 8191, - ah1 = a1 >>> 13, - a2 = a[2] | 0, - al2 = a2 & 8191, - ah2 = a2 >>> 13, - a3 = a[3] | 0, - al3 = a3 & 8191, - ah3 = a3 >>> 13, - a4 = a[4] | 0, - al4 = a4 & 8191, - ah4 = a4 >>> 13, - a5 = a[5] | 0, - al5 = a5 & 8191, - ah5 = a5 >>> 13, - a6 = a[6] | 0, - al6 = a6 & 8191, - ah6 = a6 >>> 13, - a7 = a[7] | 0, - al7 = a7 & 8191, - ah7 = a7 >>> 13, - a8 = a[8] | 0, - al8 = a8 & 8191, - ah8 = a8 >>> 13, - a9 = a[9] | 0, - al9 = a9 & 8191, - ah9 = a9 >>> 13, - b0 = b[0] | 0, - bl0 = b0 & 8191, - bh0 = b0 >>> 13, - b1 = b[1] | 0, - bl1 = b1 & 8191, - bh1 = b1 >>> 13, - b2 = b[2] | 0, - bl2 = b2 & 8191, - bh2 = b2 >>> 13, - b3 = b[3] | 0, - bl3 = b3 & 8191, - bh3 = b3 >>> 13, - b4 = b[4] | 0, - bl4 = b4 & 8191, - bh4 = b4 >>> 13, - b5 = b[5] | 0, - bl5 = b5 & 8191, - bh5 = b5 >>> 13, - b6 = b[6] | 0, - bl6 = b6 & 8191, - bh6 = b6 >>> 13, - b7 = b[7] | 0, - bl7 = b7 & 8191, - bh7 = b7 >>> 13, - b8 = b[8] | 0, - bl8 = b8 & 8191, - bh8 = b8 >>> 13, - b9 = b[9] | 0, - bl9 = b9 & 8191, - bh9 = b9 >>> 13; - (out.negative = self2.negative ^ num.negative), - (out.length = 19), - (lo = Math.imul(al0, bl0)), - (mid = Math.imul(al0, bh0)), - (mid = (mid + Math.imul(ah0, bl0)) | 0), - (hi = Math.imul(ah0, bh0)); - var w0 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0), - (w0 &= 67108863), - (lo = Math.imul(al1, bl0)), - (mid = Math.imul(al1, bh0)), - (mid = (mid + Math.imul(ah1, bl0)) | 0), - (hi = Math.imul(ah1, bh0)), - (lo = (lo + Math.imul(al0, bl1)) | 0), - (mid = (mid + Math.imul(al0, bh1)) | 0), - (mid = (mid + Math.imul(ah0, bl1)) | 0), - (hi = (hi + Math.imul(ah0, bh1)) | 0); - var w1 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0), - (w1 &= 67108863), - (lo = Math.imul(al2, bl0)), - (mid = Math.imul(al2, bh0)), - (mid = (mid + Math.imul(ah2, bl0)) | 0), - (hi = Math.imul(ah2, bh0)), - (lo = (lo + Math.imul(al1, bl1)) | 0), - (mid = (mid + Math.imul(al1, bh1)) | 0), - (mid = (mid + Math.imul(ah1, bl1)) | 0), - (hi = (hi + Math.imul(ah1, bh1)) | 0), - (lo = (lo + Math.imul(al0, bl2)) | 0), - (mid = (mid + Math.imul(al0, bh2)) | 0), - (mid = (mid + Math.imul(ah0, bl2)) | 0), - (hi = (hi + Math.imul(ah0, bh2)) | 0); - var w2 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0), - (w2 &= 67108863), - (lo = Math.imul(al3, bl0)), - (mid = Math.imul(al3, bh0)), - (mid = (mid + Math.imul(ah3, bl0)) | 0), - (hi = Math.imul(ah3, bh0)), - (lo = (lo + Math.imul(al2, bl1)) | 0), - (mid = (mid + Math.imul(al2, bh1)) | 0), - (mid = (mid + Math.imul(ah2, bl1)) | 0), - (hi = (hi + Math.imul(ah2, bh1)) | 0), - (lo = (lo + Math.imul(al1, bl2)) | 0), - (mid = (mid + Math.imul(al1, bh2)) | 0), - (mid = (mid + Math.imul(ah1, bl2)) | 0), - (hi = (hi + Math.imul(ah1, bh2)) | 0), - (lo = (lo + Math.imul(al0, bl3)) | 0), - (mid = (mid + Math.imul(al0, bh3)) | 0), - (mid = (mid + Math.imul(ah0, bl3)) | 0), - (hi = (hi + Math.imul(ah0, bh3)) | 0); - var w3 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0), - (w3 &= 67108863), - (lo = Math.imul(al4, bl0)), - (mid = Math.imul(al4, bh0)), - (mid = (mid + Math.imul(ah4, bl0)) | 0), - (hi = Math.imul(ah4, bh0)), - (lo = (lo + Math.imul(al3, bl1)) | 0), - (mid = (mid + Math.imul(al3, bh1)) | 0), - (mid = (mid + Math.imul(ah3, bl1)) | 0), - (hi = (hi + Math.imul(ah3, bh1)) | 0), - (lo = (lo + Math.imul(al2, bl2)) | 0), - (mid = (mid + Math.imul(al2, bh2)) | 0), - (mid = (mid + Math.imul(ah2, bl2)) | 0), - (hi = (hi + Math.imul(ah2, bh2)) | 0), - (lo = (lo + Math.imul(al1, bl3)) | 0), - (mid = (mid + Math.imul(al1, bh3)) | 0), - (mid = (mid + Math.imul(ah1, bl3)) | 0), - (hi = (hi + Math.imul(ah1, bh3)) | 0), - (lo = (lo + Math.imul(al0, bl4)) | 0), - (mid = (mid + Math.imul(al0, bh4)) | 0), - (mid = (mid + Math.imul(ah0, bl4)) | 0), - (hi = (hi + Math.imul(ah0, bh4)) | 0); - var w4 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0), - (w4 &= 67108863), - (lo = Math.imul(al5, bl0)), - (mid = Math.imul(al5, bh0)), - (mid = (mid + Math.imul(ah5, bl0)) | 0), - (hi = Math.imul(ah5, bh0)), - (lo = (lo + Math.imul(al4, bl1)) | 0), - (mid = (mid + Math.imul(al4, bh1)) | 0), - (mid = (mid + Math.imul(ah4, bl1)) | 0), - (hi = (hi + Math.imul(ah4, bh1)) | 0), - (lo = (lo + Math.imul(al3, bl2)) | 0), - (mid = (mid + Math.imul(al3, bh2)) | 0), - (mid = (mid + Math.imul(ah3, bl2)) | 0), - (hi = (hi + Math.imul(ah3, bh2)) | 0), - (lo = (lo + Math.imul(al2, bl3)) | 0), - (mid = (mid + Math.imul(al2, bh3)) | 0), - (mid = (mid + Math.imul(ah2, bl3)) | 0), - (hi = (hi + Math.imul(ah2, bh3)) | 0), - (lo = (lo + Math.imul(al1, bl4)) | 0), - (mid = (mid + Math.imul(al1, bh4)) | 0), - (mid = (mid + Math.imul(ah1, bl4)) | 0), - (hi = (hi + Math.imul(ah1, bh4)) | 0), - (lo = (lo + Math.imul(al0, bl5)) | 0), - (mid = (mid + Math.imul(al0, bh5)) | 0), - (mid = (mid + Math.imul(ah0, bl5)) | 0), - (hi = (hi + Math.imul(ah0, bh5)) | 0); - var w5 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0), - (w5 &= 67108863), - (lo = Math.imul(al6, bl0)), - (mid = Math.imul(al6, bh0)), - (mid = (mid + Math.imul(ah6, bl0)) | 0), - (hi = Math.imul(ah6, bh0)), - (lo = (lo + Math.imul(al5, bl1)) | 0), - (mid = (mid + Math.imul(al5, bh1)) | 0), - (mid = (mid + Math.imul(ah5, bl1)) | 0), - (hi = (hi + Math.imul(ah5, bh1)) | 0), - (lo = (lo + Math.imul(al4, bl2)) | 0), - (mid = (mid + Math.imul(al4, bh2)) | 0), - (mid = (mid + Math.imul(ah4, bl2)) | 0), - (hi = (hi + Math.imul(ah4, bh2)) | 0), - (lo = (lo + Math.imul(al3, bl3)) | 0), - (mid = (mid + Math.imul(al3, bh3)) | 0), - (mid = (mid + Math.imul(ah3, bl3)) | 0), - (hi = (hi + Math.imul(ah3, bh3)) | 0), - (lo = (lo + Math.imul(al2, bl4)) | 0), - (mid = (mid + Math.imul(al2, bh4)) | 0), - (mid = (mid + Math.imul(ah2, bl4)) | 0), - (hi = (hi + Math.imul(ah2, bh4)) | 0), - (lo = (lo + Math.imul(al1, bl5)) | 0), - (mid = (mid + Math.imul(al1, bh5)) | 0), - (mid = (mid + Math.imul(ah1, bl5)) | 0), - (hi = (hi + Math.imul(ah1, bh5)) | 0), - (lo = (lo + Math.imul(al0, bl6)) | 0), - (mid = (mid + Math.imul(al0, bh6)) | 0), - (mid = (mid + Math.imul(ah0, bl6)) | 0), - (hi = (hi + Math.imul(ah0, bh6)) | 0); - var w6 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0), - (w6 &= 67108863), - (lo = Math.imul(al7, bl0)), - (mid = Math.imul(al7, bh0)), - (mid = (mid + Math.imul(ah7, bl0)) | 0), - (hi = Math.imul(ah7, bh0)), - (lo = (lo + Math.imul(al6, bl1)) | 0), - (mid = (mid + Math.imul(al6, bh1)) | 0), - (mid = (mid + Math.imul(ah6, bl1)) | 0), - (hi = (hi + Math.imul(ah6, bh1)) | 0), - (lo = (lo + Math.imul(al5, bl2)) | 0), - (mid = (mid + Math.imul(al5, bh2)) | 0), - (mid = (mid + Math.imul(ah5, bl2)) | 0), - (hi = (hi + Math.imul(ah5, bh2)) | 0), - (lo = (lo + Math.imul(al4, bl3)) | 0), - (mid = (mid + Math.imul(al4, bh3)) | 0), - (mid = (mid + Math.imul(ah4, bl3)) | 0), - (hi = (hi + Math.imul(ah4, bh3)) | 0), - (lo = (lo + Math.imul(al3, bl4)) | 0), - (mid = (mid + Math.imul(al3, bh4)) | 0), - (mid = (mid + Math.imul(ah3, bl4)) | 0), - (hi = (hi + Math.imul(ah3, bh4)) | 0), - (lo = (lo + Math.imul(al2, bl5)) | 0), - (mid = (mid + Math.imul(al2, bh5)) | 0), - (mid = (mid + Math.imul(ah2, bl5)) | 0), - (hi = (hi + Math.imul(ah2, bh5)) | 0), - (lo = (lo + Math.imul(al1, bl6)) | 0), - (mid = (mid + Math.imul(al1, bh6)) | 0), - (mid = (mid + Math.imul(ah1, bl6)) | 0), - (hi = (hi + Math.imul(ah1, bh6)) | 0), - (lo = (lo + Math.imul(al0, bl7)) | 0), - (mid = (mid + Math.imul(al0, bh7)) | 0), - (mid = (mid + Math.imul(ah0, bl7)) | 0), - (hi = (hi + Math.imul(ah0, bh7)) | 0); - var w7 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0), - (w7 &= 67108863), - (lo = Math.imul(al8, bl0)), - (mid = Math.imul(al8, bh0)), - (mid = (mid + Math.imul(ah8, bl0)) | 0), - (hi = Math.imul(ah8, bh0)), - (lo = (lo + Math.imul(al7, bl1)) | 0), - (mid = (mid + Math.imul(al7, bh1)) | 0), - (mid = (mid + Math.imul(ah7, bl1)) | 0), - (hi = (hi + Math.imul(ah7, bh1)) | 0), - (lo = (lo + Math.imul(al6, bl2)) | 0), - (mid = (mid + Math.imul(al6, bh2)) | 0), - (mid = (mid + Math.imul(ah6, bl2)) | 0), - (hi = (hi + Math.imul(ah6, bh2)) | 0), - (lo = (lo + Math.imul(al5, bl3)) | 0), - (mid = (mid + Math.imul(al5, bh3)) | 0), - (mid = (mid + Math.imul(ah5, bl3)) | 0), - (hi = (hi + Math.imul(ah5, bh3)) | 0), - (lo = (lo + Math.imul(al4, bl4)) | 0), - (mid = (mid + Math.imul(al4, bh4)) | 0), - (mid = (mid + Math.imul(ah4, bl4)) | 0), - (hi = (hi + Math.imul(ah4, bh4)) | 0), - (lo = (lo + Math.imul(al3, bl5)) | 0), - (mid = (mid + Math.imul(al3, bh5)) | 0), - (mid = (mid + Math.imul(ah3, bl5)) | 0), - (hi = (hi + Math.imul(ah3, bh5)) | 0), - (lo = (lo + Math.imul(al2, bl6)) | 0), - (mid = (mid + Math.imul(al2, bh6)) | 0), - (mid = (mid + Math.imul(ah2, bl6)) | 0), - (hi = (hi + Math.imul(ah2, bh6)) | 0), - (lo = (lo + Math.imul(al1, bl7)) | 0), - (mid = (mid + Math.imul(al1, bh7)) | 0), - (mid = (mid + Math.imul(ah1, bl7)) | 0), - (hi = (hi + Math.imul(ah1, bh7)) | 0), - (lo = (lo + Math.imul(al0, bl8)) | 0), - (mid = (mid + Math.imul(al0, bh8)) | 0), - (mid = (mid + Math.imul(ah0, bl8)) | 0), - (hi = (hi + Math.imul(ah0, bh8)) | 0); - var w8 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0), - (w8 &= 67108863), - (lo = Math.imul(al9, bl0)), - (mid = Math.imul(al9, bh0)), - (mid = (mid + Math.imul(ah9, bl0)) | 0), - (hi = Math.imul(ah9, bh0)), - (lo = (lo + Math.imul(al8, bl1)) | 0), - (mid = (mid + Math.imul(al8, bh1)) | 0), - (mid = (mid + Math.imul(ah8, bl1)) | 0), - (hi = (hi + Math.imul(ah8, bh1)) | 0), - (lo = (lo + Math.imul(al7, bl2)) | 0), - (mid = (mid + Math.imul(al7, bh2)) | 0), - (mid = (mid + Math.imul(ah7, bl2)) | 0), - (hi = (hi + Math.imul(ah7, bh2)) | 0), - (lo = (lo + Math.imul(al6, bl3)) | 0), - (mid = (mid + Math.imul(al6, bh3)) | 0), - (mid = (mid + Math.imul(ah6, bl3)) | 0), - (hi = (hi + Math.imul(ah6, bh3)) | 0), - (lo = (lo + Math.imul(al5, bl4)) | 0), - (mid = (mid + Math.imul(al5, bh4)) | 0), - (mid = (mid + Math.imul(ah5, bl4)) | 0), - (hi = (hi + Math.imul(ah5, bh4)) | 0), - (lo = (lo + Math.imul(al4, bl5)) | 0), - (mid = (mid + Math.imul(al4, bh5)) | 0), - (mid = (mid + Math.imul(ah4, bl5)) | 0), - (hi = (hi + Math.imul(ah4, bh5)) | 0), - (lo = (lo + Math.imul(al3, bl6)) | 0), - (mid = (mid + Math.imul(al3, bh6)) | 0), - (mid = (mid + Math.imul(ah3, bl6)) | 0), - (hi = (hi + Math.imul(ah3, bh6)) | 0), - (lo = (lo + Math.imul(al2, bl7)) | 0), - (mid = (mid + Math.imul(al2, bh7)) | 0), - (mid = (mid + Math.imul(ah2, bl7)) | 0), - (hi = (hi + Math.imul(ah2, bh7)) | 0), - (lo = (lo + Math.imul(al1, bl8)) | 0), - (mid = (mid + Math.imul(al1, bh8)) | 0), - (mid = (mid + Math.imul(ah1, bl8)) | 0), - (hi = (hi + Math.imul(ah1, bh8)) | 0), - (lo = (lo + Math.imul(al0, bl9)) | 0), - (mid = (mid + Math.imul(al0, bh9)) | 0), - (mid = (mid + Math.imul(ah0, bl9)) | 0), - (hi = (hi + Math.imul(ah0, bh9)) | 0); - var w9 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0), - (w9 &= 67108863), - (lo = Math.imul(al9, bl1)), - (mid = Math.imul(al9, bh1)), - (mid = (mid + Math.imul(ah9, bl1)) | 0), - (hi = Math.imul(ah9, bh1)), - (lo = (lo + Math.imul(al8, bl2)) | 0), - (mid = (mid + Math.imul(al8, bh2)) | 0), - (mid = (mid + Math.imul(ah8, bl2)) | 0), - (hi = (hi + Math.imul(ah8, bh2)) | 0), - (lo = (lo + Math.imul(al7, bl3)) | 0), - (mid = (mid + Math.imul(al7, bh3)) | 0), - (mid = (mid + Math.imul(ah7, bl3)) | 0), - (hi = (hi + Math.imul(ah7, bh3)) | 0), - (lo = (lo + Math.imul(al6, bl4)) | 0), - (mid = (mid + Math.imul(al6, bh4)) | 0), - (mid = (mid + Math.imul(ah6, bl4)) | 0), - (hi = (hi + Math.imul(ah6, bh4)) | 0), - (lo = (lo + Math.imul(al5, bl5)) | 0), - (mid = (mid + Math.imul(al5, bh5)) | 0), - (mid = (mid + Math.imul(ah5, bl5)) | 0), - (hi = (hi + Math.imul(ah5, bh5)) | 0), - (lo = (lo + Math.imul(al4, bl6)) | 0), - (mid = (mid + Math.imul(al4, bh6)) | 0), - (mid = (mid + Math.imul(ah4, bl6)) | 0), - (hi = (hi + Math.imul(ah4, bh6)) | 0), - (lo = (lo + Math.imul(al3, bl7)) | 0), - (mid = (mid + Math.imul(al3, bh7)) | 0), - (mid = (mid + Math.imul(ah3, bl7)) | 0), - (hi = (hi + Math.imul(ah3, bh7)) | 0), - (lo = (lo + Math.imul(al2, bl8)) | 0), - (mid = (mid + Math.imul(al2, bh8)) | 0), - (mid = (mid + Math.imul(ah2, bl8)) | 0), - (hi = (hi + Math.imul(ah2, bh8)) | 0), - (lo = (lo + Math.imul(al1, bl9)) | 0), - (mid = (mid + Math.imul(al1, bh9)) | 0), - (mid = (mid + Math.imul(ah1, bl9)) | 0), - (hi = (hi + Math.imul(ah1, bh9)) | 0); - var w10 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0), - (w10 &= 67108863), - (lo = Math.imul(al9, bl2)), - (mid = Math.imul(al9, bh2)), - (mid = (mid + Math.imul(ah9, bl2)) | 0), - (hi = Math.imul(ah9, bh2)), - (lo = (lo + Math.imul(al8, bl3)) | 0), - (mid = (mid + Math.imul(al8, bh3)) | 0), - (mid = (mid + Math.imul(ah8, bl3)) | 0), - (hi = (hi + Math.imul(ah8, bh3)) | 0), - (lo = (lo + Math.imul(al7, bl4)) | 0), - (mid = (mid + Math.imul(al7, bh4)) | 0), - (mid = (mid + Math.imul(ah7, bl4)) | 0), - (hi = (hi + Math.imul(ah7, bh4)) | 0), - (lo = (lo + Math.imul(al6, bl5)) | 0), - (mid = (mid + Math.imul(al6, bh5)) | 0), - (mid = (mid + Math.imul(ah6, bl5)) | 0), - (hi = (hi + Math.imul(ah6, bh5)) | 0), - (lo = (lo + Math.imul(al5, bl6)) | 0), - (mid = (mid + Math.imul(al5, bh6)) | 0), - (mid = (mid + Math.imul(ah5, bl6)) | 0), - (hi = (hi + Math.imul(ah5, bh6)) | 0), - (lo = (lo + Math.imul(al4, bl7)) | 0), - (mid = (mid + Math.imul(al4, bh7)) | 0), - (mid = (mid + Math.imul(ah4, bl7)) | 0), - (hi = (hi + Math.imul(ah4, bh7)) | 0), - (lo = (lo + Math.imul(al3, bl8)) | 0), - (mid = (mid + Math.imul(al3, bh8)) | 0), - (mid = (mid + Math.imul(ah3, bl8)) | 0), - (hi = (hi + Math.imul(ah3, bh8)) | 0), - (lo = (lo + Math.imul(al2, bl9)) | 0), - (mid = (mid + Math.imul(al2, bh9)) | 0), - (mid = (mid + Math.imul(ah2, bl9)) | 0), - (hi = (hi + Math.imul(ah2, bh9)) | 0); - var w11 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0), - (w11 &= 67108863), - (lo = Math.imul(al9, bl3)), - (mid = Math.imul(al9, bh3)), - (mid = (mid + Math.imul(ah9, bl3)) | 0), - (hi = Math.imul(ah9, bh3)), - (lo = (lo + Math.imul(al8, bl4)) | 0), - (mid = (mid + Math.imul(al8, bh4)) | 0), - (mid = (mid + Math.imul(ah8, bl4)) | 0), - (hi = (hi + Math.imul(ah8, bh4)) | 0), - (lo = (lo + Math.imul(al7, bl5)) | 0), - (mid = (mid + Math.imul(al7, bh5)) | 0), - (mid = (mid + Math.imul(ah7, bl5)) | 0), - (hi = (hi + Math.imul(ah7, bh5)) | 0), - (lo = (lo + Math.imul(al6, bl6)) | 0), - (mid = (mid + Math.imul(al6, bh6)) | 0), - (mid = (mid + Math.imul(ah6, bl6)) | 0), - (hi = (hi + Math.imul(ah6, bh6)) | 0), - (lo = (lo + Math.imul(al5, bl7)) | 0), - (mid = (mid + Math.imul(al5, bh7)) | 0), - (mid = (mid + Math.imul(ah5, bl7)) | 0), - (hi = (hi + Math.imul(ah5, bh7)) | 0), - (lo = (lo + Math.imul(al4, bl8)) | 0), - (mid = (mid + Math.imul(al4, bh8)) | 0), - (mid = (mid + Math.imul(ah4, bl8)) | 0), - (hi = (hi + Math.imul(ah4, bh8)) | 0), - (lo = (lo + Math.imul(al3, bl9)) | 0), - (mid = (mid + Math.imul(al3, bh9)) | 0), - (mid = (mid + Math.imul(ah3, bl9)) | 0), - (hi = (hi + Math.imul(ah3, bh9)) | 0); - var w12 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0), - (w12 &= 67108863), - (lo = Math.imul(al9, bl4)), - (mid = Math.imul(al9, bh4)), - (mid = (mid + Math.imul(ah9, bl4)) | 0), - (hi = Math.imul(ah9, bh4)), - (lo = (lo + Math.imul(al8, bl5)) | 0), - (mid = (mid + Math.imul(al8, bh5)) | 0), - (mid = (mid + Math.imul(ah8, bl5)) | 0), - (hi = (hi + Math.imul(ah8, bh5)) | 0), - (lo = (lo + Math.imul(al7, bl6)) | 0), - (mid = (mid + Math.imul(al7, bh6)) | 0), - (mid = (mid + Math.imul(ah7, bl6)) | 0), - (hi = (hi + Math.imul(ah7, bh6)) | 0), - (lo = (lo + Math.imul(al6, bl7)) | 0), - (mid = (mid + Math.imul(al6, bh7)) | 0), - (mid = (mid + Math.imul(ah6, bl7)) | 0), - (hi = (hi + Math.imul(ah6, bh7)) | 0), - (lo = (lo + Math.imul(al5, bl8)) | 0), - (mid = (mid + Math.imul(al5, bh8)) | 0), - (mid = (mid + Math.imul(ah5, bl8)) | 0), - (hi = (hi + Math.imul(ah5, bh8)) | 0), - (lo = (lo + Math.imul(al4, bl9)) | 0), - (mid = (mid + Math.imul(al4, bh9)) | 0), - (mid = (mid + Math.imul(ah4, bl9)) | 0), - (hi = (hi + Math.imul(ah4, bh9)) | 0); - var w13 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0), - (w13 &= 67108863), - (lo = Math.imul(al9, bl5)), - (mid = Math.imul(al9, bh5)), - (mid = (mid + Math.imul(ah9, bl5)) | 0), - (hi = Math.imul(ah9, bh5)), - (lo = (lo + Math.imul(al8, bl6)) | 0), - (mid = (mid + Math.imul(al8, bh6)) | 0), - (mid = (mid + Math.imul(ah8, bl6)) | 0), - (hi = (hi + Math.imul(ah8, bh6)) | 0), - (lo = (lo + Math.imul(al7, bl7)) | 0), - (mid = (mid + Math.imul(al7, bh7)) | 0), - (mid = (mid + Math.imul(ah7, bl7)) | 0), - (hi = (hi + Math.imul(ah7, bh7)) | 0), - (lo = (lo + Math.imul(al6, bl8)) | 0), - (mid = (mid + Math.imul(al6, bh8)) | 0), - (mid = (mid + Math.imul(ah6, bl8)) | 0), - (hi = (hi + Math.imul(ah6, bh8)) | 0), - (lo = (lo + Math.imul(al5, bl9)) | 0), - (mid = (mid + Math.imul(al5, bh9)) | 0), - (mid = (mid + Math.imul(ah5, bl9)) | 0), - (hi = (hi + Math.imul(ah5, bh9)) | 0); - var w14 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0), - (w14 &= 67108863), - (lo = Math.imul(al9, bl6)), - (mid = Math.imul(al9, bh6)), - (mid = (mid + Math.imul(ah9, bl6)) | 0), - (hi = Math.imul(ah9, bh6)), - (lo = (lo + Math.imul(al8, bl7)) | 0), - (mid = (mid + Math.imul(al8, bh7)) | 0), - (mid = (mid + Math.imul(ah8, bl7)) | 0), - (hi = (hi + Math.imul(ah8, bh7)) | 0), - (lo = (lo + Math.imul(al7, bl8)) | 0), - (mid = (mid + Math.imul(al7, bh8)) | 0), - (mid = (mid + Math.imul(ah7, bl8)) | 0), - (hi = (hi + Math.imul(ah7, bh8)) | 0), - (lo = (lo + Math.imul(al6, bl9)) | 0), - (mid = (mid + Math.imul(al6, bh9)) | 0), - (mid = (mid + Math.imul(ah6, bl9)) | 0), - (hi = (hi + Math.imul(ah6, bh9)) | 0); - var w15 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0), - (w15 &= 67108863), - (lo = Math.imul(al9, bl7)), - (mid = Math.imul(al9, bh7)), - (mid = (mid + Math.imul(ah9, bl7)) | 0), - (hi = Math.imul(ah9, bh7)), - (lo = (lo + Math.imul(al8, bl8)) | 0), - (mid = (mid + Math.imul(al8, bh8)) | 0), - (mid = (mid + Math.imul(ah8, bl8)) | 0), - (hi = (hi + Math.imul(ah8, bh8)) | 0), - (lo = (lo + Math.imul(al7, bl9)) | 0), - (mid = (mid + Math.imul(al7, bh9)) | 0), - (mid = (mid + Math.imul(ah7, bl9)) | 0), - (hi = (hi + Math.imul(ah7, bh9)) | 0); - var w16 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0), - (w16 &= 67108863), - (lo = Math.imul(al9, bl8)), - (mid = Math.imul(al9, bh8)), - (mid = (mid + Math.imul(ah9, bl8)) | 0), - (hi = Math.imul(ah9, bh8)), - (lo = (lo + Math.imul(al8, bl9)) | 0), - (mid = (mid + Math.imul(al8, bh9)) | 0), - (mid = (mid + Math.imul(ah8, bl9)) | 0), - (hi = (hi + Math.imul(ah8, bh9)) | 0); - var w17 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0), - (w17 &= 67108863), - (lo = Math.imul(al9, bl9)), - (mid = Math.imul(al9, bh9)), - (mid = (mid + Math.imul(ah9, bl9)) | 0), - (hi = Math.imul(ah9, bh9)); - var w18 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - return ( - (c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0), - (w18 &= 67108863), - (o[0] = w0), - (o[1] = w1), - (o[2] = w2), - (o[3] = w3), - (o[4] = w4), - (o[5] = w5), - (o[6] = w6), - (o[7] = w7), - (o[8] = w8), - (o[9] = w9), - (o[10] = w10), - (o[11] = w11), - (o[12] = w12), - (o[13] = w13), - (o[14] = w14), - (o[15] = w15), - (o[16] = w16), - (o[17] = w17), - (o[18] = w18), - c !== 0 && ((o[19] = c), out.length++), - out - ); - }; - Math.imul || (comb10MulTo = smallMulTo); - function bigMulTo(self2, num, out) { - (out.negative = num.negative ^ self2.negative), (out.length = self2.length + num.length); - for (var carry = 0, hncarry = 0, k = 0; k < out.length - 1; k++) { - var ncarry = hncarry; - hncarry = 0; - for ( - var rword = carry & 67108863, maxJ = Math.min(k, num.length - 1), j = Math.max(0, k - self2.length + 1); - j <= maxJ; - j++ - ) { - var i = k - j, - a = self2.words[i] | 0, - b = num.words[j] | 0, - r = a * b, - lo = r & 67108863; - (ncarry = (ncarry + ((r / 67108864) | 0)) | 0), - (lo = (lo + rword) | 0), - (rword = lo & 67108863), - (ncarry = (ncarry + (lo >>> 26)) | 0), - (hncarry += ncarry >>> 26), - (ncarry &= 67108863); - } - (out.words[k] = rword), (carry = ncarry), (ncarry = hncarry); - } - return carry !== 0 ? (out.words[k] = carry) : out.length--, out._strip(); - } - function jumboMulTo(self2, num, out) { - return bigMulTo(self2, num, out); - } - BN.prototype.mulTo = function (num, out) { - var res, - len = this.length + num.length; - return ( - this.length === 10 && num.length === 10 - ? (res = comb10MulTo(this, num, out)) - : len < 63 - ? (res = smallMulTo(this, num, out)) - : len < 1024 - ? (res = bigMulTo(this, num, out)) - : (res = jumboMulTo(this, num, out)), - res - ); - }; - function FFTM(x, y) { - (this.x = x), (this.y = y); - } - (FFTM.prototype.makeRBT = function (N) { - for (var t = new Array(N), l = BN.prototype._countBits(N) - 1, i = 0; i < N; i++) t[i] = this.revBin(i, l, N); - return t; - }), - (FFTM.prototype.revBin = function (x, l, N) { - if (x === 0 || x === N - 1) return x; - for (var rb = 0, i = 0; i < l; i++) (rb |= (x & 1) << (l - i - 1)), (x >>= 1); - return rb; - }), - (FFTM.prototype.permute = function (rbt, rws, iws, rtws, itws, N) { - for (var i = 0; i < N; i++) (rtws[i] = rws[rbt[i]]), (itws[i] = iws[rbt[i]]); - }), - (FFTM.prototype.transform = function (rws, iws, rtws, itws, N, rbt) { - this.permute(rbt, rws, iws, rtws, itws, N); - for (var s = 1; s < N; s <<= 1) - for ( - var l = s << 1, rtwdf = Math.cos((2 * Math.PI) / l), itwdf = Math.sin((2 * Math.PI) / l), p = 0; - p < N; - p += l - ) - for (var rtwdf_ = rtwdf, itwdf_ = itwdf, j = 0; j < s; j++) { - var re = rtws[p + j], - ie = itws[p + j], - ro = rtws[p + j + s], - io = itws[p + j + s], - rx = rtwdf_ * ro - itwdf_ * io; - (io = rtwdf_ * io + itwdf_ * ro), - (ro = rx), - (rtws[p + j] = re + ro), - (itws[p + j] = ie + io), - (rtws[p + j + s] = re - ro), - (itws[p + j + s] = ie - io), - j !== l && - ((rx = rtwdf * rtwdf_ - itwdf * itwdf_), (itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_), (rtwdf_ = rx)); - } - }), - (FFTM.prototype.guessLen13b = function (n, m) { - var N = Math.max(m, n) | 1, - odd = N & 1, - i = 0; - for (N = (N / 2) | 0; N; N = N >>> 1) i++; - return 1 << (i + 1 + odd); - }), - (FFTM.prototype.conjugate = function (rws, iws, N) { - if (!(N <= 1)) - for (var i = 0; i < N / 2; i++) { - var t = rws[i]; - (rws[i] = rws[N - i - 1]), - (rws[N - i - 1] = t), - (t = iws[i]), - (iws[i] = -iws[N - i - 1]), - (iws[N - i - 1] = -t); - } - }), - (FFTM.prototype.normalize13b = function (ws, N) { - for (var carry = 0, i = 0; i < N / 2; i++) { - var w = Math.round(ws[2 * i + 1] / N) * 8192 + Math.round(ws[2 * i] / N) + carry; - (ws[i] = w & 67108863), w < 67108864 ? (carry = 0) : (carry = (w / 67108864) | 0); - } - return ws; - }), - (FFTM.prototype.convert13b = function (ws, len, rws, N) { - for (var carry = 0, i = 0; i < len; i++) - (carry = carry + (ws[i] | 0)), - (rws[2 * i] = carry & 8191), - (carry = carry >>> 13), - (rws[2 * i + 1] = carry & 8191), - (carry = carry >>> 13); - for (i = 2 * len; i < N; ++i) rws[i] = 0; - assert(carry === 0), assert((carry & -8192) === 0); - }), - (FFTM.prototype.stub = function (N) { - for (var ph = new Array(N), i = 0; i < N; i++) ph[i] = 0; - return ph; - }), - (FFTM.prototype.mulp = function (x, y, out) { - var N = 2 * this.guessLen13b(x.length, y.length), - rbt = this.makeRBT(N), - _ = this.stub(N), - rws = new Array(N), - rwst = new Array(N), - iwst = new Array(N), - nrws = new Array(N), - nrwst = new Array(N), - niwst = new Array(N), - rmws = out.words; - (rmws.length = N), - this.convert13b(x.words, x.length, rws, N), - this.convert13b(y.words, y.length, nrws, N), - this.transform(rws, _, rwst, iwst, N, rbt), - this.transform(nrws, _, nrwst, niwst, N, rbt); - for (var i = 0; i < N; i++) { - var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i]; - (iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i]), (rwst[i] = rx); - } - return ( - this.conjugate(rwst, iwst, N), - this.transform(rwst, iwst, rmws, _, N, rbt), - this.conjugate(rmws, _, N), - this.normalize13b(rmws, N), - (out.negative = x.negative ^ y.negative), - (out.length = x.length + y.length), - out._strip() - ); - }), - (BN.prototype.mul = function (num) { - var out = new BN(null); - return (out.words = new Array(this.length + num.length)), this.mulTo(num, out); - }), - (BN.prototype.mulf = function (num) { - var out = new BN(null); - return (out.words = new Array(this.length + num.length)), jumboMulTo(this, num, out); - }), - (BN.prototype.imul = function (num) { - return this.clone().mulTo(num, this); - }), - (BN.prototype.imuln = function (num) { - var isNegNum = num < 0; - isNegNum && (num = -num), assert(typeof num == "number"), assert(num < 67108864); - for (var carry = 0, i = 0; i < this.length; i++) { - var w = (this.words[i] | 0) * num, - lo = (w & 67108863) + (carry & 67108863); - (carry >>= 26), (carry += (w / 67108864) | 0), (carry += lo >>> 26), (this.words[i] = lo & 67108863); - } - return carry !== 0 && ((this.words[i] = carry), this.length++), isNegNum ? this.ineg() : this; - }), - (BN.prototype.muln = function (num) { - return this.clone().imuln(num); - }), - (BN.prototype.sqr = function () { - return this.mul(this); - }), - (BN.prototype.isqr = function () { - return this.imul(this.clone()); - }), - (BN.prototype.pow = function (num) { - var w = toBitArray(num); - if (w.length === 0) return new BN(1); - for (var res = this, i = 0; i < w.length && w[i] === 0; i++, res = res.sqr()); - if (++i < w.length) for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) w[i] !== 0 && (res = res.mul(q)); - return res; - }), - (BN.prototype.iushln = function (bits) { - assert(typeof bits == "number" && bits >= 0); - var r = bits % 26, - s = (bits - r) / 26, - carryMask = (67108863 >>> (26 - r)) << (26 - r), - i; - if (r !== 0) { - var carry = 0; - for (i = 0; i < this.length; i++) { - var newCarry = this.words[i] & carryMask, - c = ((this.words[i] | 0) - newCarry) << r; - (this.words[i] = c | carry), (carry = newCarry >>> (26 - r)); - } - carry && ((this.words[i] = carry), this.length++); - } - if (s !== 0) { - for (i = this.length - 1; i >= 0; i--) this.words[i + s] = this.words[i]; - for (i = 0; i < s; i++) this.words[i] = 0; - this.length += s; - } - return this._strip(); - }), - (BN.prototype.ishln = function (bits) { - return assert(this.negative === 0), this.iushln(bits); - }), - (BN.prototype.iushrn = function (bits, hint, extended) { - assert(typeof bits == "number" && bits >= 0); - var h; - hint ? (h = (hint - (hint % 26)) / 26) : (h = 0); - var r = bits % 26, - s = Math.min((bits - r) / 26, this.length), - mask = 67108863 ^ ((67108863 >>> r) << r), - maskedWords = extended; - if (((h -= s), (h = Math.max(0, h)), maskedWords)) { - for (var i = 0; i < s; i++) maskedWords.words[i] = this.words[i]; - maskedWords.length = s; - } - if (s !== 0) - if (this.length > s) for (this.length -= s, i = 0; i < this.length; i++) this.words[i] = this.words[i + s]; - else (this.words[0] = 0), (this.length = 1); - var carry = 0; - for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) { - var word = this.words[i] | 0; - (this.words[i] = (carry << (26 - r)) | (word >>> r)), (carry = word & mask); - } - return ( - maskedWords && carry !== 0 && (maskedWords.words[maskedWords.length++] = carry), - this.length === 0 && ((this.words[0] = 0), (this.length = 1)), - this._strip() - ); - }), - (BN.prototype.ishrn = function (bits, hint, extended) { - return assert(this.negative === 0), this.iushrn(bits, hint, extended); - }), - (BN.prototype.shln = function (bits) { - return this.clone().ishln(bits); - }), - (BN.prototype.ushln = function (bits) { - return this.clone().iushln(bits); - }), - (BN.prototype.shrn = function (bits) { - return this.clone().ishrn(bits); - }), - (BN.prototype.ushrn = function (bits) { - return this.clone().iushrn(bits); - }), - (BN.prototype.testn = function (bit) { - assert(typeof bit == "number" && bit >= 0); - var r = bit % 26, - s = (bit - r) / 26, - q = 1 << r; - if (this.length <= s) return !1; - var w = this.words[s]; - return !!(w & q); - }), - (BN.prototype.imaskn = function (bits) { - assert(typeof bits == "number" && bits >= 0); - var r = bits % 26, - s = (bits - r) / 26; - if ((assert(this.negative === 0, "imaskn works only with positive numbers"), this.length <= s)) return this; - if ((r !== 0 && s++, (this.length = Math.min(s, this.length)), r !== 0)) { - var mask = 67108863 ^ ((67108863 >>> r) << r); - this.words[this.length - 1] &= mask; - } - return this._strip(); - }), - (BN.prototype.maskn = function (bits) { - return this.clone().imaskn(bits); - }), - (BN.prototype.iaddn = function (num) { - return ( - assert(typeof num == "number"), - assert(num < 67108864), - num < 0 - ? this.isubn(-num) - : this.negative !== 0 - ? this.length === 1 && (this.words[0] | 0) <= num - ? ((this.words[0] = num - (this.words[0] | 0)), (this.negative = 0), this) - : ((this.negative = 0), this.isubn(num), (this.negative = 1), this) - : this._iaddn(num) - ); - }), - (BN.prototype._iaddn = function (num) { - this.words[0] += num; - for (var i = 0; i < this.length && this.words[i] >= 67108864; i++) - (this.words[i] -= 67108864), i === this.length - 1 ? (this.words[i + 1] = 1) : this.words[i + 1]++; - return (this.length = Math.max(this.length, i + 1)), this; - }), - (BN.prototype.isubn = function (num) { - if ((assert(typeof num == "number"), assert(num < 67108864), num < 0)) return this.iaddn(-num); - if (this.negative !== 0) return (this.negative = 0), this.iaddn(num), (this.negative = 1), this; - if (((this.words[0] -= num), this.length === 1 && this.words[0] < 0)) - (this.words[0] = -this.words[0]), (this.negative = 1); - else - for (var i = 0; i < this.length && this.words[i] < 0; i++) - (this.words[i] += 67108864), (this.words[i + 1] -= 1); - return this._strip(); - }), - (BN.prototype.addn = function (num) { - return this.clone().iaddn(num); - }), - (BN.prototype.subn = function (num) { - return this.clone().isubn(num); - }), - (BN.prototype.iabs = function () { - return (this.negative = 0), this; - }), - (BN.prototype.abs = function () { - return this.clone().iabs(); - }), - (BN.prototype._ishlnsubmul = function (num, mul, shift) { - var len = num.length + shift, - i; - this._expand(len); - var w, - carry = 0; - for (i = 0; i < num.length; i++) { - w = (this.words[i + shift] | 0) + carry; - var right = (num.words[i] | 0) * mul; - (w -= right & 67108863), - (carry = (w >> 26) - ((right / 67108864) | 0)), - (this.words[i + shift] = w & 67108863); - } - for (; i < this.length - shift; i++) - (w = (this.words[i + shift] | 0) + carry), (carry = w >> 26), (this.words[i + shift] = w & 67108863); - if (carry === 0) return this._strip(); - for (assert(carry === -1), carry = 0, i = 0; i < this.length; i++) - (w = -(this.words[i] | 0) + carry), (carry = w >> 26), (this.words[i] = w & 67108863); - return (this.negative = 1), this._strip(); - }), - (BN.prototype._wordDiv = function (num, mode) { - var shift = this.length - num.length, - a = this.clone(), - b = num, - bhi = b.words[b.length - 1] | 0, - bhiBits = this._countBits(bhi); - (shift = 26 - bhiBits), - shift !== 0 && ((b = b.ushln(shift)), a.iushln(shift), (bhi = b.words[b.length - 1] | 0)); - var m = a.length - b.length, - q; - if (mode !== "mod") { - (q = new BN(null)), (q.length = m + 1), (q.words = new Array(q.length)); - for (var i = 0; i < q.length; i++) q.words[i] = 0; - } - var diff = a.clone()._ishlnsubmul(b, 1, m); - diff.negative === 0 && ((a = diff), q && (q.words[m] = 1)); - for (var j = m - 1; j >= 0; j--) { - var qj = (a.words[b.length + j] | 0) * 67108864 + (a.words[b.length + j - 1] | 0); - for (qj = Math.min((qj / bhi) | 0, 67108863), a._ishlnsubmul(b, qj, j); a.negative !== 0; ) - qj--, (a.negative = 0), a._ishlnsubmul(b, 1, j), a.isZero() || (a.negative ^= 1); - q && (q.words[j] = qj); - } - return ( - q && q._strip(), - a._strip(), - mode !== "div" && shift !== 0 && a.iushrn(shift), - { - div: q || null, - mod: a, - } - ); - }), - (BN.prototype.divmod = function (num, mode, positive) { - if ((assert(!num.isZero()), this.isZero())) - return { - div: new BN(0), - mod: new BN(0), - }; - var div, mod, res; - return this.negative !== 0 && num.negative === 0 - ? ((res = this.neg().divmod(num, mode)), - mode !== "mod" && (div = res.div.neg()), - mode !== "div" && ((mod = res.mod.neg()), positive && mod.negative !== 0 && mod.iadd(num)), - { - div, - mod, - }) - : this.negative === 0 && num.negative !== 0 - ? ((res = this.divmod(num.neg(), mode)), - mode !== "mod" && (div = res.div.neg()), - { - div, - mod: res.mod, - }) - : (this.negative & num.negative) !== 0 - ? ((res = this.neg().divmod(num.neg(), mode)), - mode !== "div" && ((mod = res.mod.neg()), positive && mod.negative !== 0 && mod.isub(num)), - { - div: res.div, - mod, - }) - : num.length > this.length || this.cmp(num) < 0 - ? { - div: new BN(0), - mod: this, - } - : num.length === 1 - ? mode === "div" - ? { - div: this.divn(num.words[0]), - mod: null, - } - : mode === "mod" - ? { - div: null, - mod: new BN(this.modrn(num.words[0])), - } - : { - div: this.divn(num.words[0]), - mod: new BN(this.modrn(num.words[0])), - } - : this._wordDiv(num, mode); - }), - (BN.prototype.div = function (num) { - return this.divmod(num, "div", !1).div; - }), - (BN.prototype.mod = function (num) { - return this.divmod(num, "mod", !1).mod; - }), - (BN.prototype.umod = function (num) { - return this.divmod(num, "mod", !0).mod; - }), - (BN.prototype.divRound = function (num) { - var dm = this.divmod(num); - if (dm.mod.isZero()) return dm.div; - var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod, - half = num.ushrn(1), - r2 = num.andln(1), - cmp = mod.cmp(half); - return cmp < 0 || (r2 === 1 && cmp === 0) - ? dm.div - : dm.div.negative !== 0 - ? dm.div.isubn(1) - : dm.div.iaddn(1); - }), - (BN.prototype.modrn = function (num) { - var isNegNum = num < 0; - isNegNum && (num = -num), assert(num <= 67108863); - for (var p = (1 << 26) % num, acc = 0, i = this.length - 1; i >= 0; i--) - acc = (p * acc + (this.words[i] | 0)) % num; - return isNegNum ? -acc : acc; - }), - (BN.prototype.modn = function (num) { - return this.modrn(num); - }), - (BN.prototype.idivn = function (num) { - var isNegNum = num < 0; - isNegNum && (num = -num), assert(num <= 67108863); - for (var carry = 0, i = this.length - 1; i >= 0; i--) { - var w = (this.words[i] | 0) + carry * 67108864; - (this.words[i] = (w / num) | 0), (carry = w % num); - } - return this._strip(), isNegNum ? this.ineg() : this; - }), - (BN.prototype.divn = function (num) { - return this.clone().idivn(num); - }), - (BN.prototype.egcd = function (p) { - assert(p.negative === 0), assert(!p.isZero()); - var x = this, - y = p.clone(); - x.negative !== 0 ? (x = x.umod(p)) : (x = x.clone()); - for (var A = new BN(1), B = new BN(0), C = new BN(0), D = new BN(1), g = 0; x.isEven() && y.isEven(); ) - x.iushrn(1), y.iushrn(1), ++g; - for (var yp = y.clone(), xp = x.clone(); !x.isZero(); ) { - for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1); - if (i > 0) - for (x.iushrn(i); i-- > 0; ) - (A.isOdd() || B.isOdd()) && (A.iadd(yp), B.isub(xp)), A.iushrn(1), B.iushrn(1); - for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); - if (j > 0) - for (y.iushrn(j); j-- > 0; ) - (C.isOdd() || D.isOdd()) && (C.iadd(yp), D.isub(xp)), C.iushrn(1), D.iushrn(1); - x.cmp(y) >= 0 ? (x.isub(y), A.isub(C), B.isub(D)) : (y.isub(x), C.isub(A), D.isub(B)); - } - return { - a: C, - b: D, - gcd: y.iushln(g), - }; - }), - (BN.prototype._invmp = function (p) { - assert(p.negative === 0), assert(!p.isZero()); - var a = this, - b = p.clone(); - a.negative !== 0 ? (a = a.umod(p)) : (a = a.clone()); - for (var x1 = new BN(1), x2 = new BN(0), delta = b.clone(); a.cmpn(1) > 0 && b.cmpn(1) > 0; ) { - for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1); - if (i > 0) for (a.iushrn(i); i-- > 0; ) x1.isOdd() && x1.iadd(delta), x1.iushrn(1); - for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); - if (j > 0) for (b.iushrn(j); j-- > 0; ) x2.isOdd() && x2.iadd(delta), x2.iushrn(1); - a.cmp(b) >= 0 ? (a.isub(b), x1.isub(x2)) : (b.isub(a), x2.isub(x1)); - } - var res; - return a.cmpn(1) === 0 ? (res = x1) : (res = x2), res.cmpn(0) < 0 && res.iadd(p), res; - }), - (BN.prototype.gcd = function (num) { - if (this.isZero()) return num.abs(); - if (num.isZero()) return this.abs(); - var a = this.clone(), - b = num.clone(); - (a.negative = 0), (b.negative = 0); - for (var shift = 0; a.isEven() && b.isEven(); shift++) a.iushrn(1), b.iushrn(1); - do { - for (; a.isEven(); ) a.iushrn(1); - for (; b.isEven(); ) b.iushrn(1); - var r = a.cmp(b); - if (r < 0) { - var t = a; - (a = b), (b = t); - } else if (r === 0 || b.cmpn(1) === 0) break; - a.isub(b); - } while (!0); - return b.iushln(shift); - }), - (BN.prototype.invm = function (num) { - return this.egcd(num).a.umod(num); - }), - (BN.prototype.isEven = function () { - return (this.words[0] & 1) === 0; - }), - (BN.prototype.isOdd = function () { - return (this.words[0] & 1) === 1; - }), - (BN.prototype.andln = function (num) { - return this.words[0] & num; - }), - (BN.prototype.bincn = function (bit) { - assert(typeof bit == "number"); - var r = bit % 26, - s = (bit - r) / 26, - q = 1 << r; - if (this.length <= s) return this._expand(s + 1), (this.words[s] |= q), this; - for (var carry = q, i = s; carry !== 0 && i < this.length; i++) { - var w = this.words[i] | 0; - (w += carry), (carry = w >>> 26), (w &= 67108863), (this.words[i] = w); - } - return carry !== 0 && ((this.words[i] = carry), this.length++), this; - }), - (BN.prototype.isZero = function () { - return this.length === 1 && this.words[0] === 0; - }), - (BN.prototype.cmpn = function (num) { - var negative = num < 0; - if (this.negative !== 0 && !negative) return -1; - if (this.negative === 0 && negative) return 1; - this._strip(); - var res; - if (this.length > 1) res = 1; - else { - negative && (num = -num), assert(num <= 67108863, "Number is too big"); - var w = this.words[0] | 0; - res = w === num ? 0 : w < num ? -1 : 1; - } - return this.negative !== 0 ? -res | 0 : res; - }), - (BN.prototype.cmp = function (num) { - if (this.negative !== 0 && num.negative === 0) return -1; - if (this.negative === 0 && num.negative !== 0) return 1; - var res = this.ucmp(num); - return this.negative !== 0 ? -res | 0 : res; - }), - (BN.prototype.ucmp = function (num) { - if (this.length > num.length) return 1; - if (this.length < num.length) return -1; - for (var res = 0, i = this.length - 1; i >= 0; i--) { - var a = this.words[i] | 0, - b = num.words[i] | 0; - if (a !== b) { - a < b ? (res = -1) : a > b && (res = 1); - break; - } - } - return res; - }), - (BN.prototype.gtn = function (num) { - return this.cmpn(num) === 1; - }), - (BN.prototype.gt = function (num) { - return this.cmp(num) === 1; - }), - (BN.prototype.gten = function (num) { - return this.cmpn(num) >= 0; - }), - (BN.prototype.gte = function (num) { - return this.cmp(num) >= 0; - }), - (BN.prototype.ltn = function (num) { - return this.cmpn(num) === -1; - }), - (BN.prototype.lt = function (num) { - return this.cmp(num) === -1; - }), - (BN.prototype.lten = function (num) { - return this.cmpn(num) <= 0; - }), - (BN.prototype.lte = function (num) { - return this.cmp(num) <= 0; - }), - (BN.prototype.eqn = function (num) { - return this.cmpn(num) === 0; - }), - (BN.prototype.eq = function (num) { - return this.cmp(num) === 0; - }), - (BN.red = function (num) { - return new Red(num); - }), - (BN.prototype.toRed = function (ctx) { - return ( - assert(!this.red, "Already a number in reduction context"), - assert(this.negative === 0, "red works only with positives"), - ctx.convertTo(this)._forceRed(ctx) - ); - }), - (BN.prototype.fromRed = function () { - return assert(this.red, "fromRed works only with numbers in reduction context"), this.red.convertFrom(this); - }), - (BN.prototype._forceRed = function (ctx) { - return (this.red = ctx), this; - }), - (BN.prototype.forceRed = function (ctx) { - return assert(!this.red, "Already a number in reduction context"), this._forceRed(ctx); - }), - (BN.prototype.redAdd = function (num) { - return assert(this.red, "redAdd works only with red numbers"), this.red.add(this, num); - }), - (BN.prototype.redIAdd = function (num) { - return assert(this.red, "redIAdd works only with red numbers"), this.red.iadd(this, num); - }), - (BN.prototype.redSub = function (num) { - return assert(this.red, "redSub works only with red numbers"), this.red.sub(this, num); - }), - (BN.prototype.redISub = function (num) { - return assert(this.red, "redISub works only with red numbers"), this.red.isub(this, num); - }), - (BN.prototype.redShl = function (num) { - return assert(this.red, "redShl works only with red numbers"), this.red.shl(this, num); - }), - (BN.prototype.redMul = function (num) { - return ( - assert(this.red, "redMul works only with red numbers"), - this.red._verify2(this, num), - this.red.mul(this, num) - ); - }), - (BN.prototype.redIMul = function (num) { - return ( - assert(this.red, "redMul works only with red numbers"), - this.red._verify2(this, num), - this.red.imul(this, num) - ); - }), - (BN.prototype.redSqr = function () { - return assert(this.red, "redSqr works only with red numbers"), this.red._verify1(this), this.red.sqr(this); - }), - (BN.prototype.redISqr = function () { - return assert(this.red, "redISqr works only with red numbers"), this.red._verify1(this), this.red.isqr(this); - }), - (BN.prototype.redSqrt = function () { - return assert(this.red, "redSqrt works only with red numbers"), this.red._verify1(this), this.red.sqrt(this); - }), - (BN.prototype.redInvm = function () { - return assert(this.red, "redInvm works only with red numbers"), this.red._verify1(this), this.red.invm(this); - }), - (BN.prototype.redNeg = function () { - return assert(this.red, "redNeg works only with red numbers"), this.red._verify1(this), this.red.neg(this); - }), - (BN.prototype.redPow = function (num) { - return assert(this.red && !num.red, "redPow(normalNum)"), this.red._verify1(this), this.red.pow(this, num); - }); - var primes = { - k256: null, - p224: null, - p192: null, - p25519: null, - }; - function MPrime(name, p) { - (this.name = name), - (this.p = new BN(p, 16)), - (this.n = this.p.bitLength()), - (this.k = new BN(1).iushln(this.n).isub(this.p)), - (this.tmp = this._tmp()); - } - (MPrime.prototype._tmp = function () { - var tmp = new BN(null); - return (tmp.words = new Array(Math.ceil(this.n / 13))), tmp; - }), - (MPrime.prototype.ireduce = function (num) { - var r = num, - rlen; - do this.split(r, this.tmp), (r = this.imulK(r)), (r = r.iadd(this.tmp)), (rlen = r.bitLength()); - while (rlen > this.n); - var cmp = rlen < this.n ? -1 : r.ucmp(this.p); - return ( - cmp === 0 - ? ((r.words[0] = 0), (r.length = 1)) - : cmp > 0 - ? r.isub(this.p) - : r.strip !== void 0 - ? r.strip() - : r._strip(), - r - ); - }), - (MPrime.prototype.split = function (input, out) { - input.iushrn(this.n, 0, out); - }), - (MPrime.prototype.imulK = function (num) { - return num.imul(this.k); - }); - function K256() { - MPrime.call(this, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); - } - inherits(K256, MPrime), - (K256.prototype.split = function (input, output) { - for (var mask = 4194303, outLen = Math.min(input.length, 9), i = 0; i < outLen; i++) - output.words[i] = input.words[i]; - if (((output.length = outLen), input.length <= 9)) { - (input.words[0] = 0), (input.length = 1); - return; - } - var prev = input.words[9]; - for (output.words[output.length++] = prev & mask, i = 10; i < input.length; i++) { - var next = input.words[i] | 0; - (input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22)), (prev = next); - } - (prev >>>= 22), - (input.words[i - 10] = prev), - prev === 0 && input.length > 10 ? (input.length -= 10) : (input.length -= 9); - }), - (K256.prototype.imulK = function (num) { - (num.words[num.length] = 0), (num.words[num.length + 1] = 0), (num.length += 2); - for (var lo = 0, i = 0; i < num.length; i++) { - var w = num.words[i] | 0; - (lo += w * 977), (num.words[i] = lo & 67108863), (lo = w * 64 + ((lo / 67108864) | 0)); - } - return ( - num.words[num.length - 1] === 0 && (num.length--, num.words[num.length - 1] === 0 && num.length--), num - ); - }); - function P224() { - MPrime.call(this, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); - } - inherits(P224, MPrime); - function P192() { - MPrime.call(this, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); - } - inherits(P192, MPrime); - function P25519() { - MPrime.call(this, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); - } - inherits(P25519, MPrime), - (P25519.prototype.imulK = function (num) { - for (var carry = 0, i = 0; i < num.length; i++) { - var hi = (num.words[i] | 0) * 19 + carry, - lo = hi & 67108863; - (hi >>>= 26), (num.words[i] = lo), (carry = hi); - } - return carry !== 0 && (num.words[num.length++] = carry), num; - }), - (BN._prime = function (name) { - if (primes[name]) return primes[name]; - var prime2; - if (name === "k256") prime2 = new K256(); - else if (name === "p224") prime2 = new P224(); - else if (name === "p192") prime2 = new P192(); - else if (name === "p25519") prime2 = new P25519(); - else throw new Error("Unknown prime " + name); - return (primes[name] = prime2), prime2; - }); - function Red(m) { - if (typeof m == "string") { - var prime = BN._prime(m); - (this.m = prime.p), (this.prime = prime); - } else assert(m.gtn(1), "modulus must be greater than 1"), (this.m = m), (this.prime = null); - } - (Red.prototype._verify1 = function (a) { - assert(a.negative === 0, "red works only with positives"), assert(a.red, "red works only with red numbers"); - }), - (Red.prototype._verify2 = function (a, b) { - assert((a.negative | b.negative) === 0, "red works only with positives"), - assert(a.red && a.red === b.red, "red works only with red numbers"); - }), - (Red.prototype.imod = function (a) { - return this.prime ? this.prime.ireduce(a)._forceRed(this) : (move(a, a.umod(this.m)._forceRed(this)), a); - }), - (Red.prototype.neg = function (a) { - return a.isZero() ? a.clone() : this.m.sub(a)._forceRed(this); - }), - (Red.prototype.add = function (a, b) { - this._verify2(a, b); - var res = a.add(b); - return res.cmp(this.m) >= 0 && res.isub(this.m), res._forceRed(this); - }), - (Red.prototype.iadd = function (a, b) { - this._verify2(a, b); - var res = a.iadd(b); - return res.cmp(this.m) >= 0 && res.isub(this.m), res; - }), - (Red.prototype.sub = function (a, b) { - this._verify2(a, b); - var res = a.sub(b); - return res.cmpn(0) < 0 && res.iadd(this.m), res._forceRed(this); - }), - (Red.prototype.isub = function (a, b) { - this._verify2(a, b); - var res = a.isub(b); - return res.cmpn(0) < 0 && res.iadd(this.m), res; - }), - (Red.prototype.shl = function (a, num) { - return this._verify1(a), this.imod(a.ushln(num)); - }), - (Red.prototype.imul = function (a, b) { - return this._verify2(a, b), this.imod(a.imul(b)); - }), - (Red.prototype.mul = function (a, b) { - return this._verify2(a, b), this.imod(a.mul(b)); - }), - (Red.prototype.isqr = function (a) { - return this.imul(a, a.clone()); - }), - (Red.prototype.sqr = function (a) { - return this.mul(a, a); - }), - (Red.prototype.sqrt = function (a) { - if (a.isZero()) return a.clone(); - var mod3 = this.m.andln(3); - if ((assert(mod3 % 2 === 1), mod3 === 3)) { - var pow = this.m.add(new BN(1)).iushrn(2); - return this.pow(a, pow); - } - for (var q = this.m.subn(1), s = 0; !q.isZero() && q.andln(1) === 0; ) s++, q.iushrn(1); - assert(!q.isZero()); - var one = new BN(1).toRed(this), - nOne = one.redNeg(), - lpow = this.m.subn(1).iushrn(1), - z = this.m.bitLength(); - for (z = new BN(2 * z * z).toRed(this); this.pow(z, lpow).cmp(nOne) !== 0; ) z.redIAdd(nOne); - for ( - var c = this.pow(z, q), r = this.pow(a, q.addn(1).iushrn(1)), t = this.pow(a, q), m = s; - t.cmp(one) !== 0; - - ) { - for (var tmp = t, i = 0; tmp.cmp(one) !== 0; i++) tmp = tmp.redSqr(); - assert(i < m); - var b = this.pow(c, new BN(1).iushln(m - i - 1)); - (r = r.redMul(b)), (c = b.redSqr()), (t = t.redMul(c)), (m = i); - } - return r; - }), - (Red.prototype.invm = function (a) { - var inv = a._invmp(this.m); - return inv.negative !== 0 ? ((inv.negative = 0), this.imod(inv).redNeg()) : this.imod(inv); - }), - (Red.prototype.pow = function (a, num) { - if (num.isZero()) return new BN(1).toRed(this); - if (num.cmpn(1) === 0) return a.clone(); - var windowSize = 4, - wnd = new Array(1 << windowSize); - (wnd[0] = new BN(1).toRed(this)), (wnd[1] = a); - for (var i = 2; i < wnd.length; i++) wnd[i] = this.mul(wnd[i - 1], a); - var res = wnd[0], - current = 0, - currentLen = 0, - start = num.bitLength() % 26; - for (start === 0 && (start = 26), i = num.length - 1; i >= 0; i--) { - for (var word = num.words[i], j = start - 1; j >= 0; j--) { - var bit = (word >> j) & 1; - if ((res !== wnd[0] && (res = this.sqr(res)), bit === 0 && current === 0)) { - currentLen = 0; - continue; - } - (current <<= 1), - (current |= bit), - currentLen++, - !(currentLen !== windowSize && (i !== 0 || j !== 0)) && - ((res = this.mul(res, wnd[current])), (currentLen = 0), (current = 0)); - } - start = 26; - } - return res; - }), - (Red.prototype.convertTo = function (num) { - var r = num.umod(this.m); - return r === num ? r.clone() : r; - }), - (Red.prototype.convertFrom = function (num) { - var res = num.clone(); - return (res.red = null), res; - }), - (BN.mont = function (num) { - return new Mont(num); - }); - function Mont(m) { - Red.call(this, m), - (this.shift = this.m.bitLength()), - this.shift % 26 !== 0 && (this.shift += 26 - (this.shift % 26)), - (this.r = new BN(1).iushln(this.shift)), - (this.r2 = this.imod(this.r.sqr())), - (this.rinv = this.r._invmp(this.m)), - (this.minv = this.rinv.mul(this.r).isubn(1).div(this.m)), - (this.minv = this.minv.umod(this.r)), - (this.minv = this.r.sub(this.minv)); - } - inherits(Mont, Red), - (Mont.prototype.convertTo = function (num) { - return this.imod(num.ushln(this.shift)); - }), - (Mont.prototype.convertFrom = function (num) { - var r = this.imod(num.mul(this.rinv)); - return (r.red = null), r; - }), - (Mont.prototype.imul = function (a, b) { - if (a.isZero() || b.isZero()) return (a.words[0] = 0), (a.length = 1), a; - var t = a.imul(b), - c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), - u = t.isub(c).iushrn(this.shift), - res = u; - return ( - u.cmp(this.m) >= 0 ? (res = u.isub(this.m)) : u.cmpn(0) < 0 && (res = u.iadd(this.m)), res._forceRed(this) - ); - }), - (Mont.prototype.mul = function (a, b) { - if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this); - var t = a.mul(b), - c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), - u = t.isub(c).iushrn(this.shift), - res = u; - return ( - u.cmp(this.m) >= 0 ? (res = u.isub(this.m)) : u.cmpn(0) < 0 && (res = u.iadd(this.m)), res._forceRed(this) - ); - }), - (Mont.prototype.invm = function (a) { - var res = this.imod(a._invmp(this.m).mul(this.r2)); - return res._forceRed(this); - }); - })(typeof module > "u" || module, exports); - }, -}); +var require_bn3 = require_bn; // node_modules/browserify-rsa/index.js var require_browserify_rsa = __commonJS({ @@ -9795,1991 +5752,7 @@ var require_package = __commonJS({ }); // node_modules/elliptic/node_modules/bn.js/lib/bn.js -var require_bn4 = __commonJS({ - "node_modules/elliptic/node_modules/bn.js/lib/bn.js"(exports, module) { - (function (module2, exports2) { - "use strict"; - function assert(val, msg) { - if (!val) throw new Error(msg || "Assertion failed"); - } - function inherits(ctor, superCtor) { - ctor.super_ = superCtor; - var TempCtor = function () {}; - (TempCtor.prototype = superCtor.prototype), - (ctor.prototype = new TempCtor()), - (ctor.prototype.constructor = ctor); - } - function BN(number, base, endian) { - if (BN.isBN(number)) return number; - (this.negative = 0), - (this.words = null), - (this.length = 0), - (this.red = null), - number !== null && - ((base === "le" || base === "be") && ((endian = base), (base = 10)), - this._init(number || 0, base || 10, endian || "be")); - } - typeof module2 == "object" ? (module2.exports = BN) : (exports2.BN = BN), (BN.BN = BN), (BN.wordSize = 26); - var Buffer2 = Buffer; - (BN.isBN = function (num) { - return num instanceof BN - ? !0 - : num !== null && - typeof num == "object" && - num.constructor.wordSize === BN.wordSize && - Array.isArray(num.words); - }), - (BN.max = function (left, right) { - return left.cmp(right) > 0 ? left : right; - }), - (BN.min = function (left, right) { - return left.cmp(right) < 0 ? left : right; - }), - (BN.prototype._init = function (number, base, endian) { - if (typeof number == "number") return this._initNumber(number, base, endian); - if (typeof number == "object") return this._initArray(number, base, endian); - base === "hex" && (base = 16), - assert(base === (base | 0) && base >= 2 && base <= 36), - (number = number.toString().replace(/\s+/g, "")); - var start = 0; - number[0] === "-" && (start++, (this.negative = 1)), - start < number.length && - (base === 16 - ? this._parseHex(number, start, endian) - : (this._parseBase(number, base, start), - endian === "le" && this._initArray(this.toArray(), base, endian))); - }), - (BN.prototype._initNumber = function (number, base, endian) { - number < 0 && ((this.negative = 1), (number = -number)), - number < 67108864 - ? ((this.words = [number & 67108863]), (this.length = 1)) - : number < 4503599627370496 - ? ((this.words = [number & 67108863, (number / 67108864) & 67108863]), (this.length = 2)) - : (assert(number < 9007199254740992), - (this.words = [number & 67108863, (number / 67108864) & 67108863, 1]), - (this.length = 3)), - endian === "le" && this._initArray(this.toArray(), base, endian); - }), - (BN.prototype._initArray = function (number, base, endian) { - if ((assert(typeof number.length == "number"), number.length <= 0)) - return (this.words = [0]), (this.length = 1), this; - (this.length = Math.ceil(number.length / 3)), (this.words = new Array(this.length)); - for (var i = 0; i < this.length; i++) this.words[i] = 0; - var j, - w, - off = 0; - if (endian === "be") - for (i = number.length - 1, j = 0; i >= 0; i -= 3) - (w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16)), - (this.words[j] |= (w << off) & 67108863), - (this.words[j + 1] = (w >>> (26 - off)) & 67108863), - (off += 24), - off >= 26 && ((off -= 26), j++); - else if (endian === "le") - for (i = 0, j = 0; i < number.length; i += 3) - (w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16)), - (this.words[j] |= (w << off) & 67108863), - (this.words[j + 1] = (w >>> (26 - off)) & 67108863), - (off += 24), - off >= 26 && ((off -= 26), j++); - return this.strip(); - }); - function parseHex4Bits(string, index) { - var c = string.charCodeAt(index); - return c >= 65 && c <= 70 ? c - 55 : c >= 97 && c <= 102 ? c - 87 : (c - 48) & 15; - } - function parseHexByte(string, lowerBound, index) { - var r = parseHex4Bits(string, index); - return index - 1 >= lowerBound && (r |= parseHex4Bits(string, index - 1) << 4), r; - } - BN.prototype._parseHex = function (number, start, endian) { - (this.length = Math.ceil((number.length - start) / 6)), (this.words = new Array(this.length)); - for (var i = 0; i < this.length; i++) this.words[i] = 0; - var off = 0, - j = 0, - w; - if (endian === "be") - for (i = number.length - 1; i >= start; i -= 2) - (w = parseHexByte(number, start, i) << off), - (this.words[j] |= w & 67108863), - off >= 18 ? ((off -= 18), (j += 1), (this.words[j] |= w >>> 26)) : (off += 8); - else { - var parseLength = number.length - start; - for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) - (w = parseHexByte(number, start, i) << off), - (this.words[j] |= w & 67108863), - off >= 18 ? ((off -= 18), (j += 1), (this.words[j] |= w >>> 26)) : (off += 8); - } - this.strip(); - }; - function parseBase(str, start, end, mul) { - for (var r = 0, len = Math.min(str.length, end), i = start; i < len; i++) { - var c = str.charCodeAt(i) - 48; - (r *= mul), c >= 49 ? (r += c - 49 + 10) : c >= 17 ? (r += c - 17 + 10) : (r += c); - } - return r; - } - (BN.prototype._parseBase = function (number, base, start) { - (this.words = [0]), (this.length = 1); - for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *= base) limbLen++; - limbLen--, (limbPow = (limbPow / base) | 0); - for ( - var total = number.length - start, - mod = total % limbLen, - end = Math.min(total, total - mod) + start, - word = 0, - i = start; - i < end; - i += limbLen - ) - (word = parseBase(number, i, i + limbLen, base)), - this.imuln(limbPow), - this.words[0] + word < 67108864 ? (this.words[0] += word) : this._iaddn(word); - if (mod !== 0) { - var pow = 1; - for (word = parseBase(number, i, number.length, base), i = 0; i < mod; i++) pow *= base; - this.imuln(pow), this.words[0] + word < 67108864 ? (this.words[0] += word) : this._iaddn(word); - } - this.strip(); - }), - (BN.prototype.copy = function (dest) { - dest.words = new Array(this.length); - for (var i = 0; i < this.length; i++) dest.words[i] = this.words[i]; - (dest.length = this.length), (dest.negative = this.negative), (dest.red = this.red); - }), - (BN.prototype.clone = function () { - var r = new BN(null); - return this.copy(r), r; - }), - (BN.prototype._expand = function (size) { - for (; this.length < size; ) this.words[this.length++] = 0; - return this; - }), - (BN.prototype.strip = function () { - for (; this.length > 1 && this.words[this.length - 1] === 0; ) this.length--; - return this._normSign(); - }), - (BN.prototype._normSign = function () { - return this.length === 1 && this.words[0] === 0 && (this.negative = 0), this; - }), - (BN.prototype.inspect = function () { - return (this.red ? "<BN-R: " : "<BN: ") + this.toString(16) + ">"; - }); - var zeros = [ - "", - "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", - ], - groupSizes = [ - 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, - ], - groupBases = [ - 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 (base, padding) { - (base = base || 10), (padding = padding | 0 || 1); - var out; - if (base === 16 || base === "hex") { - out = ""; - for (var off = 0, carry = 0, i = 0; i < this.length; i++) { - var w = this.words[i], - word = (((w << off) | carry) & 16777215).toString(16); - (carry = (w >>> (24 - off)) & 16777215), - carry !== 0 || i !== this.length - 1 ? (out = zeros[6 - word.length] + word + out) : (out = word + out), - (off += 2), - off >= 26 && ((off -= 26), i--); - } - for (carry !== 0 && (out = carry.toString(16) + out); out.length % padding !== 0; ) out = "0" + out; - return this.negative !== 0 && (out = "-" + out), out; - } - if (base === (base | 0) && base >= 2 && base <= 36) { - var groupSize = groupSizes[base], - groupBase = groupBases[base]; - out = ""; - var c = this.clone(); - for (c.negative = 0; !c.isZero(); ) { - var r = c.modn(groupBase).toString(base); - (c = c.idivn(groupBase)), c.isZero() ? (out = r + out) : (out = zeros[groupSize - r.length] + r + out); - } - for (this.isZero() && (out = "0" + out); out.length % padding !== 0; ) out = "0" + out; - return this.negative !== 0 && (out = "-" + out), out; - } - assert(!1, "Base should be between 2 and 36"); - }), - (BN.prototype.toNumber = function () { - var ret = this.words[0]; - return ( - this.length === 2 - ? (ret += this.words[1] * 67108864) - : this.length === 3 && this.words[2] === 1 - ? (ret += 4503599627370496 + this.words[1] * 67108864) - : this.length > 2 && assert(!1, "Number can only safely store up to 53 bits"), - this.negative !== 0 ? -ret : ret - ); - }), - (BN.prototype.toJSON = function () { - return this.toString(16); - }), - (BN.prototype.toBuffer = function (endian, length) { - return assert(typeof Buffer2 < "u"), this.toArrayLike(Buffer2, endian, length); - }), - (BN.prototype.toArray = function (endian, length) { - return this.toArrayLike(Array, endian, length); - }), - (BN.prototype.toArrayLike = function (ArrayType, endian, length) { - var byteLength = this.byteLength(), - reqLength = length || Math.max(1, byteLength); - assert(byteLength <= reqLength, "byte array longer than desired length"), - assert(reqLength > 0, "Requested array length <= 0"), - this.strip(); - var littleEndian = endian === "le", - res = new ArrayType(reqLength), - b, - i, - q = this.clone(); - if (littleEndian) { - for (i = 0; !q.isZero(); i++) (b = q.andln(255)), q.iushrn(8), (res[i] = b); - for (; i < reqLength; i++) res[i] = 0; - } else { - for (i = 0; i < reqLength - byteLength; i++) res[i] = 0; - for (i = 0; !q.isZero(); i++) (b = q.andln(255)), q.iushrn(8), (res[reqLength - i - 1] = b); - } - return res; - }), - Math.clz32 - ? (BN.prototype._countBits = function (w) { - return 32 - Math.clz32(w); - }) - : (BN.prototype._countBits = function (w) { - var t = w, - r = 0; - return ( - t >= 4096 && ((r += 13), (t >>>= 13)), - t >= 64 && ((r += 7), (t >>>= 7)), - t >= 8 && ((r += 4), (t >>>= 4)), - t >= 2 && ((r += 2), (t >>>= 2)), - r + t - ); - }), - (BN.prototype._zeroBits = function (w) { - if (w === 0) return 26; - var t = w, - r = 0; - return ( - (t & 8191) === 0 && ((r += 13), (t >>>= 13)), - (t & 127) === 0 && ((r += 7), (t >>>= 7)), - (t & 15) === 0 && ((r += 4), (t >>>= 4)), - (t & 3) === 0 && ((r += 2), (t >>>= 2)), - (t & 1) === 0 && r++, - r - ); - }), - (BN.prototype.bitLength = function () { - var w = this.words[this.length - 1], - hi = this._countBits(w); - return (this.length - 1) * 26 + hi; - }); - function toBitArray(num) { - for (var w = new Array(num.bitLength()), bit = 0; bit < w.length; bit++) { - var off = (bit / 26) | 0, - wbit = bit % 26; - w[bit] = (num.words[off] & (1 << wbit)) >>> wbit; - } - return w; - } - (BN.prototype.zeroBits = function () { - if (this.isZero()) return 0; - for (var r = 0, i = 0; i < this.length; i++) { - var b = this._zeroBits(this.words[i]); - if (((r += b), b !== 26)) break; - } - return r; - }), - (BN.prototype.byteLength = function () { - return Math.ceil(this.bitLength() / 8); - }), - (BN.prototype.toTwos = function (width) { - return this.negative !== 0 ? this.abs().inotn(width).iaddn(1) : this.clone(); - }), - (BN.prototype.fromTwos = function (width) { - return this.testn(width - 1) ? this.notn(width).iaddn(1).ineg() : this.clone(); - }), - (BN.prototype.isNeg = function () { - return this.negative !== 0; - }), - (BN.prototype.neg = function () { - return this.clone().ineg(); - }), - (BN.prototype.ineg = function () { - return this.isZero() || (this.negative ^= 1), this; - }), - (BN.prototype.iuor = function (num) { - for (; this.length < num.length; ) this.words[this.length++] = 0; - for (var i = 0; i < num.length; i++) this.words[i] = this.words[i] | num.words[i]; - return this.strip(); - }), - (BN.prototype.ior = function (num) { - return assert((this.negative | num.negative) === 0), this.iuor(num); - }), - (BN.prototype.or = function (num) { - return this.length > num.length ? this.clone().ior(num) : num.clone().ior(this); - }), - (BN.prototype.uor = function (num) { - return this.length > num.length ? this.clone().iuor(num) : num.clone().iuor(this); - }), - (BN.prototype.iuand = function (num) { - var b; - this.length > num.length ? (b = num) : (b = this); - for (var i = 0; i < b.length; i++) this.words[i] = this.words[i] & num.words[i]; - return (this.length = b.length), this.strip(); - }), - (BN.prototype.iand = function (num) { - return assert((this.negative | num.negative) === 0), this.iuand(num); - }), - (BN.prototype.and = function (num) { - return this.length > num.length ? this.clone().iand(num) : num.clone().iand(this); - }), - (BN.prototype.uand = function (num) { - return this.length > num.length ? this.clone().iuand(num) : num.clone().iuand(this); - }), - (BN.prototype.iuxor = function (num) { - var a, b; - this.length > num.length ? ((a = this), (b = num)) : ((a = num), (b = this)); - for (var i = 0; i < b.length; i++) this.words[i] = a.words[i] ^ b.words[i]; - if (this !== a) for (; i < a.length; i++) this.words[i] = a.words[i]; - return (this.length = a.length), this.strip(); - }), - (BN.prototype.ixor = function (num) { - return assert((this.negative | num.negative) === 0), this.iuxor(num); - }), - (BN.prototype.xor = function (num) { - return this.length > num.length ? this.clone().ixor(num) : num.clone().ixor(this); - }), - (BN.prototype.uxor = function (num) { - return this.length > num.length ? this.clone().iuxor(num) : num.clone().iuxor(this); - }), - (BN.prototype.inotn = function (width) { - assert(typeof width == "number" && width >= 0); - var bytesNeeded = Math.ceil(width / 26) | 0, - bitsLeft = width % 26; - this._expand(bytesNeeded), bitsLeft > 0 && bytesNeeded--; - for (var i = 0; i < bytesNeeded; i++) this.words[i] = ~this.words[i] & 67108863; - return bitsLeft > 0 && (this.words[i] = ~this.words[i] & (67108863 >> (26 - bitsLeft))), this.strip(); - }), - (BN.prototype.notn = function (width) { - return this.clone().inotn(width); - }), - (BN.prototype.setn = function (bit, val) { - assert(typeof bit == "number" && bit >= 0); - var off = (bit / 26) | 0, - wbit = bit % 26; - return ( - this._expand(off + 1), - val - ? (this.words[off] = this.words[off] | (1 << wbit)) - : (this.words[off] = this.words[off] & ~(1 << wbit)), - this.strip() - ); - }), - (BN.prototype.iadd = function (num) { - var r; - if (this.negative !== 0 && num.negative === 0) - return (this.negative = 0), (r = this.isub(num)), (this.negative ^= 1), this._normSign(); - if (this.negative === 0 && num.negative !== 0) - return (num.negative = 0), (r = this.isub(num)), (num.negative = 1), r._normSign(); - var a, b; - this.length > num.length ? ((a = this), (b = num)) : ((a = num), (b = this)); - for (var carry = 0, i = 0; i < b.length; i++) - (r = (a.words[i] | 0) + (b.words[i] | 0) + carry), (this.words[i] = r & 67108863), (carry = r >>> 26); - for (; carry !== 0 && i < a.length; i++) - (r = (a.words[i] | 0) + carry), (this.words[i] = r & 67108863), (carry = r >>> 26); - if (((this.length = a.length), carry !== 0)) (this.words[this.length] = carry), this.length++; - else if (a !== this) for (; i < a.length; i++) this.words[i] = a.words[i]; - return this; - }), - (BN.prototype.add = function (num) { - var res; - return num.negative !== 0 && this.negative === 0 - ? ((num.negative = 0), (res = this.sub(num)), (num.negative ^= 1), res) - : num.negative === 0 && this.negative !== 0 - ? ((this.negative = 0), (res = num.sub(this)), (this.negative = 1), res) - : this.length > num.length - ? this.clone().iadd(num) - : num.clone().iadd(this); - }), - (BN.prototype.isub = function (num) { - if (num.negative !== 0) { - num.negative = 0; - var r = this.iadd(num); - return (num.negative = 1), r._normSign(); - } else if (this.negative !== 0) - return (this.negative = 0), this.iadd(num), (this.negative = 1), this._normSign(); - var cmp = this.cmp(num); - if (cmp === 0) return (this.negative = 0), (this.length = 1), (this.words[0] = 0), this; - var a, b; - cmp > 0 ? ((a = this), (b = num)) : ((a = num), (b = this)); - for (var carry = 0, i = 0; i < b.length; i++) - (r = (a.words[i] | 0) - (b.words[i] | 0) + carry), (carry = r >> 26), (this.words[i] = r & 67108863); - for (; carry !== 0 && i < a.length; i++) - (r = (a.words[i] | 0) + carry), (carry = r >> 26), (this.words[i] = r & 67108863); - if (carry === 0 && i < a.length && a !== this) for (; i < a.length; i++) this.words[i] = a.words[i]; - return (this.length = Math.max(this.length, i)), a !== this && (this.negative = 1), this.strip(); - }), - (BN.prototype.sub = function (num) { - return this.clone().isub(num); - }); - function smallMulTo(self2, num, out) { - out.negative = num.negative ^ self2.negative; - var len = (self2.length + num.length) | 0; - (out.length = len), (len = (len - 1) | 0); - var a = self2.words[0] | 0, - b = num.words[0] | 0, - r = a * b, - lo = r & 67108863, - carry = (r / 67108864) | 0; - out.words[0] = lo; - for (var k = 1; k < len; k++) { - for ( - var ncarry = carry >>> 26, - rword = carry & 67108863, - maxJ = Math.min(k, num.length - 1), - j = Math.max(0, k - self2.length + 1); - j <= maxJ; - j++ - ) { - var i = (k - j) | 0; - (a = self2.words[i] | 0), - (b = num.words[j] | 0), - (r = a * b + rword), - (ncarry += (r / 67108864) | 0), - (rword = r & 67108863); - } - (out.words[k] = rword | 0), (carry = ncarry | 0); - } - return carry !== 0 ? (out.words[k] = carry | 0) : out.length--, out.strip(); - } - var comb10MulTo = function (self2, num, out) { - var a = self2.words, - b = num.words, - o = out.words, - c = 0, - lo, - mid, - hi, - a0 = a[0] | 0, - al0 = a0 & 8191, - ah0 = a0 >>> 13, - a1 = a[1] | 0, - al1 = a1 & 8191, - ah1 = a1 >>> 13, - a2 = a[2] | 0, - al2 = a2 & 8191, - ah2 = a2 >>> 13, - a3 = a[3] | 0, - al3 = a3 & 8191, - ah3 = a3 >>> 13, - a4 = a[4] | 0, - al4 = a4 & 8191, - ah4 = a4 >>> 13, - a5 = a[5] | 0, - al5 = a5 & 8191, - ah5 = a5 >>> 13, - a6 = a[6] | 0, - al6 = a6 & 8191, - ah6 = a6 >>> 13, - a7 = a[7] | 0, - al7 = a7 & 8191, - ah7 = a7 >>> 13, - a8 = a[8] | 0, - al8 = a8 & 8191, - ah8 = a8 >>> 13, - a9 = a[9] | 0, - al9 = a9 & 8191, - ah9 = a9 >>> 13, - b0 = b[0] | 0, - bl0 = b0 & 8191, - bh0 = b0 >>> 13, - b1 = b[1] | 0, - bl1 = b1 & 8191, - bh1 = b1 >>> 13, - b2 = b[2] | 0, - bl2 = b2 & 8191, - bh2 = b2 >>> 13, - b3 = b[3] | 0, - bl3 = b3 & 8191, - bh3 = b3 >>> 13, - b4 = b[4] | 0, - bl4 = b4 & 8191, - bh4 = b4 >>> 13, - b5 = b[5] | 0, - bl5 = b5 & 8191, - bh5 = b5 >>> 13, - b6 = b[6] | 0, - bl6 = b6 & 8191, - bh6 = b6 >>> 13, - b7 = b[7] | 0, - bl7 = b7 & 8191, - bh7 = b7 >>> 13, - b8 = b[8] | 0, - bl8 = b8 & 8191, - bh8 = b8 >>> 13, - b9 = b[9] | 0, - bl9 = b9 & 8191, - bh9 = b9 >>> 13; - (out.negative = self2.negative ^ num.negative), - (out.length = 19), - (lo = Math.imul(al0, bl0)), - (mid = Math.imul(al0, bh0)), - (mid = (mid + Math.imul(ah0, bl0)) | 0), - (hi = Math.imul(ah0, bh0)); - var w0 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0), - (w0 &= 67108863), - (lo = Math.imul(al1, bl0)), - (mid = Math.imul(al1, bh0)), - (mid = (mid + Math.imul(ah1, bl0)) | 0), - (hi = Math.imul(ah1, bh0)), - (lo = (lo + Math.imul(al0, bl1)) | 0), - (mid = (mid + Math.imul(al0, bh1)) | 0), - (mid = (mid + Math.imul(ah0, bl1)) | 0), - (hi = (hi + Math.imul(ah0, bh1)) | 0); - var w1 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0), - (w1 &= 67108863), - (lo = Math.imul(al2, bl0)), - (mid = Math.imul(al2, bh0)), - (mid = (mid + Math.imul(ah2, bl0)) | 0), - (hi = Math.imul(ah2, bh0)), - (lo = (lo + Math.imul(al1, bl1)) | 0), - (mid = (mid + Math.imul(al1, bh1)) | 0), - (mid = (mid + Math.imul(ah1, bl1)) | 0), - (hi = (hi + Math.imul(ah1, bh1)) | 0), - (lo = (lo + Math.imul(al0, bl2)) | 0), - (mid = (mid + Math.imul(al0, bh2)) | 0), - (mid = (mid + Math.imul(ah0, bl2)) | 0), - (hi = (hi + Math.imul(ah0, bh2)) | 0); - var w2 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0), - (w2 &= 67108863), - (lo = Math.imul(al3, bl0)), - (mid = Math.imul(al3, bh0)), - (mid = (mid + Math.imul(ah3, bl0)) | 0), - (hi = Math.imul(ah3, bh0)), - (lo = (lo + Math.imul(al2, bl1)) | 0), - (mid = (mid + Math.imul(al2, bh1)) | 0), - (mid = (mid + Math.imul(ah2, bl1)) | 0), - (hi = (hi + Math.imul(ah2, bh1)) | 0), - (lo = (lo + Math.imul(al1, bl2)) | 0), - (mid = (mid + Math.imul(al1, bh2)) | 0), - (mid = (mid + Math.imul(ah1, bl2)) | 0), - (hi = (hi + Math.imul(ah1, bh2)) | 0), - (lo = (lo + Math.imul(al0, bl3)) | 0), - (mid = (mid + Math.imul(al0, bh3)) | 0), - (mid = (mid + Math.imul(ah0, bl3)) | 0), - (hi = (hi + Math.imul(ah0, bh3)) | 0); - var w3 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0), - (w3 &= 67108863), - (lo = Math.imul(al4, bl0)), - (mid = Math.imul(al4, bh0)), - (mid = (mid + Math.imul(ah4, bl0)) | 0), - (hi = Math.imul(ah4, bh0)), - (lo = (lo + Math.imul(al3, bl1)) | 0), - (mid = (mid + Math.imul(al3, bh1)) | 0), - (mid = (mid + Math.imul(ah3, bl1)) | 0), - (hi = (hi + Math.imul(ah3, bh1)) | 0), - (lo = (lo + Math.imul(al2, bl2)) | 0), - (mid = (mid + Math.imul(al2, bh2)) | 0), - (mid = (mid + Math.imul(ah2, bl2)) | 0), - (hi = (hi + Math.imul(ah2, bh2)) | 0), - (lo = (lo + Math.imul(al1, bl3)) | 0), - (mid = (mid + Math.imul(al1, bh3)) | 0), - (mid = (mid + Math.imul(ah1, bl3)) | 0), - (hi = (hi + Math.imul(ah1, bh3)) | 0), - (lo = (lo + Math.imul(al0, bl4)) | 0), - (mid = (mid + Math.imul(al0, bh4)) | 0), - (mid = (mid + Math.imul(ah0, bl4)) | 0), - (hi = (hi + Math.imul(ah0, bh4)) | 0); - var w4 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0), - (w4 &= 67108863), - (lo = Math.imul(al5, bl0)), - (mid = Math.imul(al5, bh0)), - (mid = (mid + Math.imul(ah5, bl0)) | 0), - (hi = Math.imul(ah5, bh0)), - (lo = (lo + Math.imul(al4, bl1)) | 0), - (mid = (mid + Math.imul(al4, bh1)) | 0), - (mid = (mid + Math.imul(ah4, bl1)) | 0), - (hi = (hi + Math.imul(ah4, bh1)) | 0), - (lo = (lo + Math.imul(al3, bl2)) | 0), - (mid = (mid + Math.imul(al3, bh2)) | 0), - (mid = (mid + Math.imul(ah3, bl2)) | 0), - (hi = (hi + Math.imul(ah3, bh2)) | 0), - (lo = (lo + Math.imul(al2, bl3)) | 0), - (mid = (mid + Math.imul(al2, bh3)) | 0), - (mid = (mid + Math.imul(ah2, bl3)) | 0), - (hi = (hi + Math.imul(ah2, bh3)) | 0), - (lo = (lo + Math.imul(al1, bl4)) | 0), - (mid = (mid + Math.imul(al1, bh4)) | 0), - (mid = (mid + Math.imul(ah1, bl4)) | 0), - (hi = (hi + Math.imul(ah1, bh4)) | 0), - (lo = (lo + Math.imul(al0, bl5)) | 0), - (mid = (mid + Math.imul(al0, bh5)) | 0), - (mid = (mid + Math.imul(ah0, bl5)) | 0), - (hi = (hi + Math.imul(ah0, bh5)) | 0); - var w5 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0), - (w5 &= 67108863), - (lo = Math.imul(al6, bl0)), - (mid = Math.imul(al6, bh0)), - (mid = (mid + Math.imul(ah6, bl0)) | 0), - (hi = Math.imul(ah6, bh0)), - (lo = (lo + Math.imul(al5, bl1)) | 0), - (mid = (mid + Math.imul(al5, bh1)) | 0), - (mid = (mid + Math.imul(ah5, bl1)) | 0), - (hi = (hi + Math.imul(ah5, bh1)) | 0), - (lo = (lo + Math.imul(al4, bl2)) | 0), - (mid = (mid + Math.imul(al4, bh2)) | 0), - (mid = (mid + Math.imul(ah4, bl2)) | 0), - (hi = (hi + Math.imul(ah4, bh2)) | 0), - (lo = (lo + Math.imul(al3, bl3)) | 0), - (mid = (mid + Math.imul(al3, bh3)) | 0), - (mid = (mid + Math.imul(ah3, bl3)) | 0), - (hi = (hi + Math.imul(ah3, bh3)) | 0), - (lo = (lo + Math.imul(al2, bl4)) | 0), - (mid = (mid + Math.imul(al2, bh4)) | 0), - (mid = (mid + Math.imul(ah2, bl4)) | 0), - (hi = (hi + Math.imul(ah2, bh4)) | 0), - (lo = (lo + Math.imul(al1, bl5)) | 0), - (mid = (mid + Math.imul(al1, bh5)) | 0), - (mid = (mid + Math.imul(ah1, bl5)) | 0), - (hi = (hi + Math.imul(ah1, bh5)) | 0), - (lo = (lo + Math.imul(al0, bl6)) | 0), - (mid = (mid + Math.imul(al0, bh6)) | 0), - (mid = (mid + Math.imul(ah0, bl6)) | 0), - (hi = (hi + Math.imul(ah0, bh6)) | 0); - var w6 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0), - (w6 &= 67108863), - (lo = Math.imul(al7, bl0)), - (mid = Math.imul(al7, bh0)), - (mid = (mid + Math.imul(ah7, bl0)) | 0), - (hi = Math.imul(ah7, bh0)), - (lo = (lo + Math.imul(al6, bl1)) | 0), - (mid = (mid + Math.imul(al6, bh1)) | 0), - (mid = (mid + Math.imul(ah6, bl1)) | 0), - (hi = (hi + Math.imul(ah6, bh1)) | 0), - (lo = (lo + Math.imul(al5, bl2)) | 0), - (mid = (mid + Math.imul(al5, bh2)) | 0), - (mid = (mid + Math.imul(ah5, bl2)) | 0), - (hi = (hi + Math.imul(ah5, bh2)) | 0), - (lo = (lo + Math.imul(al4, bl3)) | 0), - (mid = (mid + Math.imul(al4, bh3)) | 0), - (mid = (mid + Math.imul(ah4, bl3)) | 0), - (hi = (hi + Math.imul(ah4, bh3)) | 0), - (lo = (lo + Math.imul(al3, bl4)) | 0), - (mid = (mid + Math.imul(al3, bh4)) | 0), - (mid = (mid + Math.imul(ah3, bl4)) | 0), - (hi = (hi + Math.imul(ah3, bh4)) | 0), - (lo = (lo + Math.imul(al2, bl5)) | 0), - (mid = (mid + Math.imul(al2, bh5)) | 0), - (mid = (mid + Math.imul(ah2, bl5)) | 0), - (hi = (hi + Math.imul(ah2, bh5)) | 0), - (lo = (lo + Math.imul(al1, bl6)) | 0), - (mid = (mid + Math.imul(al1, bh6)) | 0), - (mid = (mid + Math.imul(ah1, bl6)) | 0), - (hi = (hi + Math.imul(ah1, bh6)) | 0), - (lo = (lo + Math.imul(al0, bl7)) | 0), - (mid = (mid + Math.imul(al0, bh7)) | 0), - (mid = (mid + Math.imul(ah0, bl7)) | 0), - (hi = (hi + Math.imul(ah0, bh7)) | 0); - var w7 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0), - (w7 &= 67108863), - (lo = Math.imul(al8, bl0)), - (mid = Math.imul(al8, bh0)), - (mid = (mid + Math.imul(ah8, bl0)) | 0), - (hi = Math.imul(ah8, bh0)), - (lo = (lo + Math.imul(al7, bl1)) | 0), - (mid = (mid + Math.imul(al7, bh1)) | 0), - (mid = (mid + Math.imul(ah7, bl1)) | 0), - (hi = (hi + Math.imul(ah7, bh1)) | 0), - (lo = (lo + Math.imul(al6, bl2)) | 0), - (mid = (mid + Math.imul(al6, bh2)) | 0), - (mid = (mid + Math.imul(ah6, bl2)) | 0), - (hi = (hi + Math.imul(ah6, bh2)) | 0), - (lo = (lo + Math.imul(al5, bl3)) | 0), - (mid = (mid + Math.imul(al5, bh3)) | 0), - (mid = (mid + Math.imul(ah5, bl3)) | 0), - (hi = (hi + Math.imul(ah5, bh3)) | 0), - (lo = (lo + Math.imul(al4, bl4)) | 0), - (mid = (mid + Math.imul(al4, bh4)) | 0), - (mid = (mid + Math.imul(ah4, bl4)) | 0), - (hi = (hi + Math.imul(ah4, bh4)) | 0), - (lo = (lo + Math.imul(al3, bl5)) | 0), - (mid = (mid + Math.imul(al3, bh5)) | 0), - (mid = (mid + Math.imul(ah3, bl5)) | 0), - (hi = (hi + Math.imul(ah3, bh5)) | 0), - (lo = (lo + Math.imul(al2, bl6)) | 0), - (mid = (mid + Math.imul(al2, bh6)) | 0), - (mid = (mid + Math.imul(ah2, bl6)) | 0), - (hi = (hi + Math.imul(ah2, bh6)) | 0), - (lo = (lo + Math.imul(al1, bl7)) | 0), - (mid = (mid + Math.imul(al1, bh7)) | 0), - (mid = (mid + Math.imul(ah1, bl7)) | 0), - (hi = (hi + Math.imul(ah1, bh7)) | 0), - (lo = (lo + Math.imul(al0, bl8)) | 0), - (mid = (mid + Math.imul(al0, bh8)) | 0), - (mid = (mid + Math.imul(ah0, bl8)) | 0), - (hi = (hi + Math.imul(ah0, bh8)) | 0); - var w8 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0), - (w8 &= 67108863), - (lo = Math.imul(al9, bl0)), - (mid = Math.imul(al9, bh0)), - (mid = (mid + Math.imul(ah9, bl0)) | 0), - (hi = Math.imul(ah9, bh0)), - (lo = (lo + Math.imul(al8, bl1)) | 0), - (mid = (mid + Math.imul(al8, bh1)) | 0), - (mid = (mid + Math.imul(ah8, bl1)) | 0), - (hi = (hi + Math.imul(ah8, bh1)) | 0), - (lo = (lo + Math.imul(al7, bl2)) | 0), - (mid = (mid + Math.imul(al7, bh2)) | 0), - (mid = (mid + Math.imul(ah7, bl2)) | 0), - (hi = (hi + Math.imul(ah7, bh2)) | 0), - (lo = (lo + Math.imul(al6, bl3)) | 0), - (mid = (mid + Math.imul(al6, bh3)) | 0), - (mid = (mid + Math.imul(ah6, bl3)) | 0), - (hi = (hi + Math.imul(ah6, bh3)) | 0), - (lo = (lo + Math.imul(al5, bl4)) | 0), - (mid = (mid + Math.imul(al5, bh4)) | 0), - (mid = (mid + Math.imul(ah5, bl4)) | 0), - (hi = (hi + Math.imul(ah5, bh4)) | 0), - (lo = (lo + Math.imul(al4, bl5)) | 0), - (mid = (mid + Math.imul(al4, bh5)) | 0), - (mid = (mid + Math.imul(ah4, bl5)) | 0), - (hi = (hi + Math.imul(ah4, bh5)) | 0), - (lo = (lo + Math.imul(al3, bl6)) | 0), - (mid = (mid + Math.imul(al3, bh6)) | 0), - (mid = (mid + Math.imul(ah3, bl6)) | 0), - (hi = (hi + Math.imul(ah3, bh6)) | 0), - (lo = (lo + Math.imul(al2, bl7)) | 0), - (mid = (mid + Math.imul(al2, bh7)) | 0), - (mid = (mid + Math.imul(ah2, bl7)) | 0), - (hi = (hi + Math.imul(ah2, bh7)) | 0), - (lo = (lo + Math.imul(al1, bl8)) | 0), - (mid = (mid + Math.imul(al1, bh8)) | 0), - (mid = (mid + Math.imul(ah1, bl8)) | 0), - (hi = (hi + Math.imul(ah1, bh8)) | 0), - (lo = (lo + Math.imul(al0, bl9)) | 0), - (mid = (mid + Math.imul(al0, bh9)) | 0), - (mid = (mid + Math.imul(ah0, bl9)) | 0), - (hi = (hi + Math.imul(ah0, bh9)) | 0); - var w9 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0), - (w9 &= 67108863), - (lo = Math.imul(al9, bl1)), - (mid = Math.imul(al9, bh1)), - (mid = (mid + Math.imul(ah9, bl1)) | 0), - (hi = Math.imul(ah9, bh1)), - (lo = (lo + Math.imul(al8, bl2)) | 0), - (mid = (mid + Math.imul(al8, bh2)) | 0), - (mid = (mid + Math.imul(ah8, bl2)) | 0), - (hi = (hi + Math.imul(ah8, bh2)) | 0), - (lo = (lo + Math.imul(al7, bl3)) | 0), - (mid = (mid + Math.imul(al7, bh3)) | 0), - (mid = (mid + Math.imul(ah7, bl3)) | 0), - (hi = (hi + Math.imul(ah7, bh3)) | 0), - (lo = (lo + Math.imul(al6, bl4)) | 0), - (mid = (mid + Math.imul(al6, bh4)) | 0), - (mid = (mid + Math.imul(ah6, bl4)) | 0), - (hi = (hi + Math.imul(ah6, bh4)) | 0), - (lo = (lo + Math.imul(al5, bl5)) | 0), - (mid = (mid + Math.imul(al5, bh5)) | 0), - (mid = (mid + Math.imul(ah5, bl5)) | 0), - (hi = (hi + Math.imul(ah5, bh5)) | 0), - (lo = (lo + Math.imul(al4, bl6)) | 0), - (mid = (mid + Math.imul(al4, bh6)) | 0), - (mid = (mid + Math.imul(ah4, bl6)) | 0), - (hi = (hi + Math.imul(ah4, bh6)) | 0), - (lo = (lo + Math.imul(al3, bl7)) | 0), - (mid = (mid + Math.imul(al3, bh7)) | 0), - (mid = (mid + Math.imul(ah3, bl7)) | 0), - (hi = (hi + Math.imul(ah3, bh7)) | 0), - (lo = (lo + Math.imul(al2, bl8)) | 0), - (mid = (mid + Math.imul(al2, bh8)) | 0), - (mid = (mid + Math.imul(ah2, bl8)) | 0), - (hi = (hi + Math.imul(ah2, bh8)) | 0), - (lo = (lo + Math.imul(al1, bl9)) | 0), - (mid = (mid + Math.imul(al1, bh9)) | 0), - (mid = (mid + Math.imul(ah1, bl9)) | 0), - (hi = (hi + Math.imul(ah1, bh9)) | 0); - var w10 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0), - (w10 &= 67108863), - (lo = Math.imul(al9, bl2)), - (mid = Math.imul(al9, bh2)), - (mid = (mid + Math.imul(ah9, bl2)) | 0), - (hi = Math.imul(ah9, bh2)), - (lo = (lo + Math.imul(al8, bl3)) | 0), - (mid = (mid + Math.imul(al8, bh3)) | 0), - (mid = (mid + Math.imul(ah8, bl3)) | 0), - (hi = (hi + Math.imul(ah8, bh3)) | 0), - (lo = (lo + Math.imul(al7, bl4)) | 0), - (mid = (mid + Math.imul(al7, bh4)) | 0), - (mid = (mid + Math.imul(ah7, bl4)) | 0), - (hi = (hi + Math.imul(ah7, bh4)) | 0), - (lo = (lo + Math.imul(al6, bl5)) | 0), - (mid = (mid + Math.imul(al6, bh5)) | 0), - (mid = (mid + Math.imul(ah6, bl5)) | 0), - (hi = (hi + Math.imul(ah6, bh5)) | 0), - (lo = (lo + Math.imul(al5, bl6)) | 0), - (mid = (mid + Math.imul(al5, bh6)) | 0), - (mid = (mid + Math.imul(ah5, bl6)) | 0), - (hi = (hi + Math.imul(ah5, bh6)) | 0), - (lo = (lo + Math.imul(al4, bl7)) | 0), - (mid = (mid + Math.imul(al4, bh7)) | 0), - (mid = (mid + Math.imul(ah4, bl7)) | 0), - (hi = (hi + Math.imul(ah4, bh7)) | 0), - (lo = (lo + Math.imul(al3, bl8)) | 0), - (mid = (mid + Math.imul(al3, bh8)) | 0), - (mid = (mid + Math.imul(ah3, bl8)) | 0), - (hi = (hi + Math.imul(ah3, bh8)) | 0), - (lo = (lo + Math.imul(al2, bl9)) | 0), - (mid = (mid + Math.imul(al2, bh9)) | 0), - (mid = (mid + Math.imul(ah2, bl9)) | 0), - (hi = (hi + Math.imul(ah2, bh9)) | 0); - var w11 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0), - (w11 &= 67108863), - (lo = Math.imul(al9, bl3)), - (mid = Math.imul(al9, bh3)), - (mid = (mid + Math.imul(ah9, bl3)) | 0), - (hi = Math.imul(ah9, bh3)), - (lo = (lo + Math.imul(al8, bl4)) | 0), - (mid = (mid + Math.imul(al8, bh4)) | 0), - (mid = (mid + Math.imul(ah8, bl4)) | 0), - (hi = (hi + Math.imul(ah8, bh4)) | 0), - (lo = (lo + Math.imul(al7, bl5)) | 0), - (mid = (mid + Math.imul(al7, bh5)) | 0), - (mid = (mid + Math.imul(ah7, bl5)) | 0), - (hi = (hi + Math.imul(ah7, bh5)) | 0), - (lo = (lo + Math.imul(al6, bl6)) | 0), - (mid = (mid + Math.imul(al6, bh6)) | 0), - (mid = (mid + Math.imul(ah6, bl6)) | 0), - (hi = (hi + Math.imul(ah6, bh6)) | 0), - (lo = (lo + Math.imul(al5, bl7)) | 0), - (mid = (mid + Math.imul(al5, bh7)) | 0), - (mid = (mid + Math.imul(ah5, bl7)) | 0), - (hi = (hi + Math.imul(ah5, bh7)) | 0), - (lo = (lo + Math.imul(al4, bl8)) | 0), - (mid = (mid + Math.imul(al4, bh8)) | 0), - (mid = (mid + Math.imul(ah4, bl8)) | 0), - (hi = (hi + Math.imul(ah4, bh8)) | 0), - (lo = (lo + Math.imul(al3, bl9)) | 0), - (mid = (mid + Math.imul(al3, bh9)) | 0), - (mid = (mid + Math.imul(ah3, bl9)) | 0), - (hi = (hi + Math.imul(ah3, bh9)) | 0); - var w12 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0), - (w12 &= 67108863), - (lo = Math.imul(al9, bl4)), - (mid = Math.imul(al9, bh4)), - (mid = (mid + Math.imul(ah9, bl4)) | 0), - (hi = Math.imul(ah9, bh4)), - (lo = (lo + Math.imul(al8, bl5)) | 0), - (mid = (mid + Math.imul(al8, bh5)) | 0), - (mid = (mid + Math.imul(ah8, bl5)) | 0), - (hi = (hi + Math.imul(ah8, bh5)) | 0), - (lo = (lo + Math.imul(al7, bl6)) | 0), - (mid = (mid + Math.imul(al7, bh6)) | 0), - (mid = (mid + Math.imul(ah7, bl6)) | 0), - (hi = (hi + Math.imul(ah7, bh6)) | 0), - (lo = (lo + Math.imul(al6, bl7)) | 0), - (mid = (mid + Math.imul(al6, bh7)) | 0), - (mid = (mid + Math.imul(ah6, bl7)) | 0), - (hi = (hi + Math.imul(ah6, bh7)) | 0), - (lo = (lo + Math.imul(al5, bl8)) | 0), - (mid = (mid + Math.imul(al5, bh8)) | 0), - (mid = (mid + Math.imul(ah5, bl8)) | 0), - (hi = (hi + Math.imul(ah5, bh8)) | 0), - (lo = (lo + Math.imul(al4, bl9)) | 0), - (mid = (mid + Math.imul(al4, bh9)) | 0), - (mid = (mid + Math.imul(ah4, bl9)) | 0), - (hi = (hi + Math.imul(ah4, bh9)) | 0); - var w13 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0), - (w13 &= 67108863), - (lo = Math.imul(al9, bl5)), - (mid = Math.imul(al9, bh5)), - (mid = (mid + Math.imul(ah9, bl5)) | 0), - (hi = Math.imul(ah9, bh5)), - (lo = (lo + Math.imul(al8, bl6)) | 0), - (mid = (mid + Math.imul(al8, bh6)) | 0), - (mid = (mid + Math.imul(ah8, bl6)) | 0), - (hi = (hi + Math.imul(ah8, bh6)) | 0), - (lo = (lo + Math.imul(al7, bl7)) | 0), - (mid = (mid + Math.imul(al7, bh7)) | 0), - (mid = (mid + Math.imul(ah7, bl7)) | 0), - (hi = (hi + Math.imul(ah7, bh7)) | 0), - (lo = (lo + Math.imul(al6, bl8)) | 0), - (mid = (mid + Math.imul(al6, bh8)) | 0), - (mid = (mid + Math.imul(ah6, bl8)) | 0), - (hi = (hi + Math.imul(ah6, bh8)) | 0), - (lo = (lo + Math.imul(al5, bl9)) | 0), - (mid = (mid + Math.imul(al5, bh9)) | 0), - (mid = (mid + Math.imul(ah5, bl9)) | 0), - (hi = (hi + Math.imul(ah5, bh9)) | 0); - var w14 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0), - (w14 &= 67108863), - (lo = Math.imul(al9, bl6)), - (mid = Math.imul(al9, bh6)), - (mid = (mid + Math.imul(ah9, bl6)) | 0), - (hi = Math.imul(ah9, bh6)), - (lo = (lo + Math.imul(al8, bl7)) | 0), - (mid = (mid + Math.imul(al8, bh7)) | 0), - (mid = (mid + Math.imul(ah8, bl7)) | 0), - (hi = (hi + Math.imul(ah8, bh7)) | 0), - (lo = (lo + Math.imul(al7, bl8)) | 0), - (mid = (mid + Math.imul(al7, bh8)) | 0), - (mid = (mid + Math.imul(ah7, bl8)) | 0), - (hi = (hi + Math.imul(ah7, bh8)) | 0), - (lo = (lo + Math.imul(al6, bl9)) | 0), - (mid = (mid + Math.imul(al6, bh9)) | 0), - (mid = (mid + Math.imul(ah6, bl9)) | 0), - (hi = (hi + Math.imul(ah6, bh9)) | 0); - var w15 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0), - (w15 &= 67108863), - (lo = Math.imul(al9, bl7)), - (mid = Math.imul(al9, bh7)), - (mid = (mid + Math.imul(ah9, bl7)) | 0), - (hi = Math.imul(ah9, bh7)), - (lo = (lo + Math.imul(al8, bl8)) | 0), - (mid = (mid + Math.imul(al8, bh8)) | 0), - (mid = (mid + Math.imul(ah8, bl8)) | 0), - (hi = (hi + Math.imul(ah8, bh8)) | 0), - (lo = (lo + Math.imul(al7, bl9)) | 0), - (mid = (mid + Math.imul(al7, bh9)) | 0), - (mid = (mid + Math.imul(ah7, bl9)) | 0), - (hi = (hi + Math.imul(ah7, bh9)) | 0); - var w16 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0), - (w16 &= 67108863), - (lo = Math.imul(al9, bl8)), - (mid = Math.imul(al9, bh8)), - (mid = (mid + Math.imul(ah9, bl8)) | 0), - (hi = Math.imul(ah9, bh8)), - (lo = (lo + Math.imul(al8, bl9)) | 0), - (mid = (mid + Math.imul(al8, bh9)) | 0), - (mid = (mid + Math.imul(ah8, bl9)) | 0), - (hi = (hi + Math.imul(ah8, bh9)) | 0); - var w17 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0), - (w17 &= 67108863), - (lo = Math.imul(al9, bl9)), - (mid = Math.imul(al9, bh9)), - (mid = (mid + Math.imul(ah9, bl9)) | 0), - (hi = Math.imul(ah9, bh9)); - var w18 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - return ( - (c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0), - (w18 &= 67108863), - (o[0] = w0), - (o[1] = w1), - (o[2] = w2), - (o[3] = w3), - (o[4] = w4), - (o[5] = w5), - (o[6] = w6), - (o[7] = w7), - (o[8] = w8), - (o[9] = w9), - (o[10] = w10), - (o[11] = w11), - (o[12] = w12), - (o[13] = w13), - (o[14] = w14), - (o[15] = w15), - (o[16] = w16), - (o[17] = w17), - (o[18] = w18), - c !== 0 && ((o[19] = c), out.length++), - out - ); - }; - Math.imul || (comb10MulTo = smallMulTo); - function bigMulTo(self2, num, out) { - (out.negative = num.negative ^ self2.negative), (out.length = self2.length + num.length); - for (var carry = 0, hncarry = 0, k = 0; k < out.length - 1; k++) { - var ncarry = hncarry; - hncarry = 0; - for ( - var rword = carry & 67108863, maxJ = Math.min(k, num.length - 1), j = Math.max(0, k - self2.length + 1); - j <= maxJ; - j++ - ) { - var i = k - j, - a = self2.words[i] | 0, - b = num.words[j] | 0, - r = a * b, - lo = r & 67108863; - (ncarry = (ncarry + ((r / 67108864) | 0)) | 0), - (lo = (lo + rword) | 0), - (rword = lo & 67108863), - (ncarry = (ncarry + (lo >>> 26)) | 0), - (hncarry += ncarry >>> 26), - (ncarry &= 67108863); - } - (out.words[k] = rword), (carry = ncarry), (ncarry = hncarry); - } - return carry !== 0 ? (out.words[k] = carry) : out.length--, out.strip(); - } - function jumboMulTo(self2, num, out) { - var fftm = new FFTM(); - return fftm.mulp(self2, num, out); - } - BN.prototype.mulTo = function (num, out) { - var res, - len = this.length + num.length; - return ( - this.length === 10 && num.length === 10 - ? (res = comb10MulTo(this, num, out)) - : len < 63 - ? (res = smallMulTo(this, num, out)) - : len < 1024 - ? (res = bigMulTo(this, num, out)) - : (res = jumboMulTo(this, num, out)), - res - ); - }; - function FFTM(x, y) { - (this.x = x), (this.y = y); - } - (FFTM.prototype.makeRBT = function (N) { - for (var t = new Array(N), l = BN.prototype._countBits(N) - 1, i = 0; i < N; i++) t[i] = this.revBin(i, l, N); - return t; - }), - (FFTM.prototype.revBin = function (x, l, N) { - if (x === 0 || x === N - 1) return x; - for (var rb = 0, i = 0; i < l; i++) (rb |= (x & 1) << (l - i - 1)), (x >>= 1); - return rb; - }), - (FFTM.prototype.permute = function (rbt, rws, iws, rtws, itws, N) { - for (var i = 0; i < N; i++) (rtws[i] = rws[rbt[i]]), (itws[i] = iws[rbt[i]]); - }), - (FFTM.prototype.transform = function (rws, iws, rtws, itws, N, rbt) { - this.permute(rbt, rws, iws, rtws, itws, N); - for (var s = 1; s < N; s <<= 1) - for ( - var l = s << 1, rtwdf = Math.cos((2 * Math.PI) / l), itwdf = Math.sin((2 * Math.PI) / l), p = 0; - p < N; - p += l - ) - for (var rtwdf_ = rtwdf, itwdf_ = itwdf, j = 0; j < s; j++) { - var re = rtws[p + j], - ie = itws[p + j], - ro = rtws[p + j + s], - io = itws[p + j + s], - rx = rtwdf_ * ro - itwdf_ * io; - (io = rtwdf_ * io + itwdf_ * ro), - (ro = rx), - (rtws[p + j] = re + ro), - (itws[p + j] = ie + io), - (rtws[p + j + s] = re - ro), - (itws[p + j + s] = ie - io), - j !== l && - ((rx = rtwdf * rtwdf_ - itwdf * itwdf_), (itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_), (rtwdf_ = rx)); - } - }), - (FFTM.prototype.guessLen13b = function (n, m) { - var N = Math.max(m, n) | 1, - odd = N & 1, - i = 0; - for (N = (N / 2) | 0; N; N = N >>> 1) i++; - return 1 << (i + 1 + odd); - }), - (FFTM.prototype.conjugate = function (rws, iws, N) { - if (!(N <= 1)) - for (var i = 0; i < N / 2; i++) { - var t = rws[i]; - (rws[i] = rws[N - i - 1]), - (rws[N - i - 1] = t), - (t = iws[i]), - (iws[i] = -iws[N - i - 1]), - (iws[N - i - 1] = -t); - } - }), - (FFTM.prototype.normalize13b = function (ws, N) { - for (var carry = 0, i = 0; i < N / 2; i++) { - var w = Math.round(ws[2 * i + 1] / N) * 8192 + Math.round(ws[2 * i] / N) + carry; - (ws[i] = w & 67108863), w < 67108864 ? (carry = 0) : (carry = (w / 67108864) | 0); - } - return ws; - }), - (FFTM.prototype.convert13b = function (ws, len, rws, N) { - for (var carry = 0, i = 0; i < len; i++) - (carry = carry + (ws[i] | 0)), - (rws[2 * i] = carry & 8191), - (carry = carry >>> 13), - (rws[2 * i + 1] = carry & 8191), - (carry = carry >>> 13); - for (i = 2 * len; i < N; ++i) rws[i] = 0; - assert(carry === 0), assert((carry & -8192) === 0); - }), - (FFTM.prototype.stub = function (N) { - for (var ph = new Array(N), i = 0; i < N; i++) ph[i] = 0; - return ph; - }), - (FFTM.prototype.mulp = function (x, y, out) { - var N = 2 * this.guessLen13b(x.length, y.length), - rbt = this.makeRBT(N), - _ = this.stub(N), - rws = new Array(N), - rwst = new Array(N), - iwst = new Array(N), - nrws = new Array(N), - nrwst = new Array(N), - niwst = new Array(N), - rmws = out.words; - (rmws.length = N), - this.convert13b(x.words, x.length, rws, N), - this.convert13b(y.words, y.length, nrws, N), - this.transform(rws, _, rwst, iwst, N, rbt), - this.transform(nrws, _, nrwst, niwst, N, rbt); - for (var i = 0; i < N; i++) { - var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i]; - (iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i]), (rwst[i] = rx); - } - return ( - this.conjugate(rwst, iwst, N), - this.transform(rwst, iwst, rmws, _, N, rbt), - this.conjugate(rmws, _, N), - this.normalize13b(rmws, N), - (out.negative = x.negative ^ y.negative), - (out.length = x.length + y.length), - out.strip() - ); - }), - (BN.prototype.mul = function (num) { - var out = new BN(null); - return (out.words = new Array(this.length + num.length)), this.mulTo(num, out); - }), - (BN.prototype.mulf = function (num) { - var out = new BN(null); - return (out.words = new Array(this.length + num.length)), jumboMulTo(this, num, out); - }), - (BN.prototype.imul = function (num) { - return this.clone().mulTo(num, this); - }), - (BN.prototype.imuln = function (num) { - assert(typeof num == "number"), assert(num < 67108864); - for (var carry = 0, i = 0; i < this.length; i++) { - var w = (this.words[i] | 0) * num, - lo = (w & 67108863) + (carry & 67108863); - (carry >>= 26), (carry += (w / 67108864) | 0), (carry += lo >>> 26), (this.words[i] = lo & 67108863); - } - return carry !== 0 && ((this.words[i] = carry), this.length++), this; - }), - (BN.prototype.muln = function (num) { - return this.clone().imuln(num); - }), - (BN.prototype.sqr = function () { - return this.mul(this); - }), - (BN.prototype.isqr = function () { - return this.imul(this.clone()); - }), - (BN.prototype.pow = function (num) { - var w = toBitArray(num); - if (w.length === 0) return new BN(1); - for (var res = this, i = 0; i < w.length && w[i] === 0; i++, res = res.sqr()); - if (++i < w.length) for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) w[i] !== 0 && (res = res.mul(q)); - return res; - }), - (BN.prototype.iushln = function (bits) { - assert(typeof bits == "number" && bits >= 0); - var r = bits % 26, - s = (bits - r) / 26, - carryMask = (67108863 >>> (26 - r)) << (26 - r), - i; - if (r !== 0) { - var carry = 0; - for (i = 0; i < this.length; i++) { - var newCarry = this.words[i] & carryMask, - c = ((this.words[i] | 0) - newCarry) << r; - (this.words[i] = c | carry), (carry = newCarry >>> (26 - r)); - } - carry && ((this.words[i] = carry), this.length++); - } - if (s !== 0) { - for (i = this.length - 1; i >= 0; i--) this.words[i + s] = this.words[i]; - for (i = 0; i < s; i++) this.words[i] = 0; - this.length += s; - } - return this.strip(); - }), - (BN.prototype.ishln = function (bits) { - return assert(this.negative === 0), this.iushln(bits); - }), - (BN.prototype.iushrn = function (bits, hint, extended) { - assert(typeof bits == "number" && bits >= 0); - var h; - hint ? (h = (hint - (hint % 26)) / 26) : (h = 0); - var r = bits % 26, - s = Math.min((bits - r) / 26, this.length), - mask = 67108863 ^ ((67108863 >>> r) << r), - maskedWords = extended; - if (((h -= s), (h = Math.max(0, h)), maskedWords)) { - for (var i = 0; i < s; i++) maskedWords.words[i] = this.words[i]; - maskedWords.length = s; - } - if (s !== 0) - if (this.length > s) for (this.length -= s, i = 0; i < this.length; i++) this.words[i] = this.words[i + s]; - else (this.words[0] = 0), (this.length = 1); - var carry = 0; - for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) { - var word = this.words[i] | 0; - (this.words[i] = (carry << (26 - r)) | (word >>> r)), (carry = word & mask); - } - return ( - maskedWords && carry !== 0 && (maskedWords.words[maskedWords.length++] = carry), - this.length === 0 && ((this.words[0] = 0), (this.length = 1)), - this.strip() - ); - }), - (BN.prototype.ishrn = function (bits, hint, extended) { - return assert(this.negative === 0), this.iushrn(bits, hint, extended); - }), - (BN.prototype.shln = function (bits) { - return this.clone().ishln(bits); - }), - (BN.prototype.ushln = function (bits) { - return this.clone().iushln(bits); - }), - (BN.prototype.shrn = function (bits) { - return this.clone().ishrn(bits); - }), - (BN.prototype.ushrn = function (bits) { - return this.clone().iushrn(bits); - }), - (BN.prototype.testn = function (bit) { - assert(typeof bit == "number" && bit >= 0); - var r = bit % 26, - s = (bit - r) / 26, - q = 1 << r; - if (this.length <= s) return !1; - var w = this.words[s]; - return !!(w & q); - }), - (BN.prototype.imaskn = function (bits) { - assert(typeof bits == "number" && bits >= 0); - var r = bits % 26, - s = (bits - r) / 26; - if ((assert(this.negative === 0, "imaskn works only with positive numbers"), this.length <= s)) return this; - if ((r !== 0 && s++, (this.length = Math.min(s, this.length)), r !== 0)) { - var mask = 67108863 ^ ((67108863 >>> r) << r); - this.words[this.length - 1] &= mask; - } - return this.strip(); - }), - (BN.prototype.maskn = function (bits) { - return this.clone().imaskn(bits); - }), - (BN.prototype.iaddn = function (num) { - return ( - assert(typeof num == "number"), - assert(num < 67108864), - num < 0 - ? this.isubn(-num) - : this.negative !== 0 - ? this.length === 1 && (this.words[0] | 0) < num - ? ((this.words[0] = num - (this.words[0] | 0)), (this.negative = 0), this) - : ((this.negative = 0), this.isubn(num), (this.negative = 1), this) - : this._iaddn(num) - ); - }), - (BN.prototype._iaddn = function (num) { - this.words[0] += num; - for (var i = 0; i < this.length && this.words[i] >= 67108864; i++) - (this.words[i] -= 67108864), i === this.length - 1 ? (this.words[i + 1] = 1) : this.words[i + 1]++; - return (this.length = Math.max(this.length, i + 1)), this; - }), - (BN.prototype.isubn = function (num) { - if ((assert(typeof num == "number"), assert(num < 67108864), num < 0)) return this.iaddn(-num); - if (this.negative !== 0) return (this.negative = 0), this.iaddn(num), (this.negative = 1), this; - if (((this.words[0] -= num), this.length === 1 && this.words[0] < 0)) - (this.words[0] = -this.words[0]), (this.negative = 1); - else - for (var i = 0; i < this.length && this.words[i] < 0; i++) - (this.words[i] += 67108864), (this.words[i + 1] -= 1); - return this.strip(); - }), - (BN.prototype.addn = function (num) { - return this.clone().iaddn(num); - }), - (BN.prototype.subn = function (num) { - return this.clone().isubn(num); - }), - (BN.prototype.iabs = function () { - return (this.negative = 0), this; - }), - (BN.prototype.abs = function () { - return this.clone().iabs(); - }), - (BN.prototype._ishlnsubmul = function (num, mul, shift) { - var len = num.length + shift, - i; - this._expand(len); - var w, - carry = 0; - for (i = 0; i < num.length; i++) { - w = (this.words[i + shift] | 0) + carry; - var right = (num.words[i] | 0) * mul; - (w -= right & 67108863), - (carry = (w >> 26) - ((right / 67108864) | 0)), - (this.words[i + shift] = w & 67108863); - } - for (; i < this.length - shift; i++) - (w = (this.words[i + shift] | 0) + carry), (carry = w >> 26), (this.words[i + shift] = w & 67108863); - if (carry === 0) return this.strip(); - for (assert(carry === -1), carry = 0, i = 0; i < this.length; i++) - (w = -(this.words[i] | 0) + carry), (carry = w >> 26), (this.words[i] = w & 67108863); - return (this.negative = 1), this.strip(); - }), - (BN.prototype._wordDiv = function (num, mode) { - var shift = this.length - num.length, - a = this.clone(), - b = num, - bhi = b.words[b.length - 1] | 0, - bhiBits = this._countBits(bhi); - (shift = 26 - bhiBits), - shift !== 0 && ((b = b.ushln(shift)), a.iushln(shift), (bhi = b.words[b.length - 1] | 0)); - var m = a.length - b.length, - q; - if (mode !== "mod") { - (q = new BN(null)), (q.length = m + 1), (q.words = new Array(q.length)); - for (var i = 0; i < q.length; i++) q.words[i] = 0; - } - var diff = a.clone()._ishlnsubmul(b, 1, m); - diff.negative === 0 && ((a = diff), q && (q.words[m] = 1)); - for (var j = m - 1; j >= 0; j--) { - var qj = (a.words[b.length + j] | 0) * 67108864 + (a.words[b.length + j - 1] | 0); - for (qj = Math.min((qj / bhi) | 0, 67108863), a._ishlnsubmul(b, qj, j); a.negative !== 0; ) - qj--, (a.negative = 0), a._ishlnsubmul(b, 1, j), a.isZero() || (a.negative ^= 1); - q && (q.words[j] = qj); - } - return ( - q && q.strip(), - a.strip(), - mode !== "div" && shift !== 0 && a.iushrn(shift), - { - div: q || null, - mod: a, - } - ); - }), - (BN.prototype.divmod = function (num, mode, positive) { - if ((assert(!num.isZero()), this.isZero())) - return { - div: new BN(0), - mod: new BN(0), - }; - var div, mod, res; - return this.negative !== 0 && num.negative === 0 - ? ((res = this.neg().divmod(num, mode)), - mode !== "mod" && (div = res.div.neg()), - mode !== "div" && ((mod = res.mod.neg()), positive && mod.negative !== 0 && mod.iadd(num)), - { - div, - mod, - }) - : this.negative === 0 && num.negative !== 0 - ? ((res = this.divmod(num.neg(), mode)), - mode !== "mod" && (div = res.div.neg()), - { - div, - mod: res.mod, - }) - : (this.negative & num.negative) !== 0 - ? ((res = this.neg().divmod(num.neg(), mode)), - mode !== "div" && ((mod = res.mod.neg()), positive && mod.negative !== 0 && mod.isub(num)), - { - div: res.div, - mod, - }) - : num.length > this.length || this.cmp(num) < 0 - ? { - div: new BN(0), - mod: this, - } - : num.length === 1 - ? mode === "div" - ? { - div: this.divn(num.words[0]), - mod: null, - } - : mode === "mod" - ? { - div: null, - mod: new BN(this.modn(num.words[0])), - } - : { - div: this.divn(num.words[0]), - mod: new BN(this.modn(num.words[0])), - } - : this._wordDiv(num, mode); - }), - (BN.prototype.div = function (num) { - return this.divmod(num, "div", !1).div; - }), - (BN.prototype.mod = function (num) { - return this.divmod(num, "mod", !1).mod; - }), - (BN.prototype.umod = function (num) { - return this.divmod(num, "mod", !0).mod; - }), - (BN.prototype.divRound = function (num) { - var dm = this.divmod(num); - if (dm.mod.isZero()) return dm.div; - var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod, - half = num.ushrn(1), - r2 = num.andln(1), - cmp = mod.cmp(half); - return cmp < 0 || (r2 === 1 && cmp === 0) - ? dm.div - : dm.div.negative !== 0 - ? dm.div.isubn(1) - : dm.div.iaddn(1); - }), - (BN.prototype.modn = function (num) { - assert(num <= 67108863); - for (var p = (1 << 26) % num, acc = 0, i = this.length - 1; i >= 0; i--) - acc = (p * acc + (this.words[i] | 0)) % num; - return acc; - }), - (BN.prototype.idivn = function (num) { - assert(num <= 67108863); - for (var carry = 0, i = this.length - 1; i >= 0; i--) { - var w = (this.words[i] | 0) + carry * 67108864; - (this.words[i] = (w / num) | 0), (carry = w % num); - } - return this.strip(); - }), - (BN.prototype.divn = function (num) { - return this.clone().idivn(num); - }), - (BN.prototype.egcd = function (p) { - assert(p.negative === 0), assert(!p.isZero()); - var x = this, - y = p.clone(); - x.negative !== 0 ? (x = x.umod(p)) : (x = x.clone()); - for (var A = new BN(1), B = new BN(0), C = new BN(0), D = new BN(1), g = 0; x.isEven() && y.isEven(); ) - x.iushrn(1), y.iushrn(1), ++g; - for (var yp = y.clone(), xp = x.clone(); !x.isZero(); ) { - for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1); - if (i > 0) - for (x.iushrn(i); i-- > 0; ) - (A.isOdd() || B.isOdd()) && (A.iadd(yp), B.isub(xp)), A.iushrn(1), B.iushrn(1); - for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); - if (j > 0) - for (y.iushrn(j); j-- > 0; ) - (C.isOdd() || D.isOdd()) && (C.iadd(yp), D.isub(xp)), C.iushrn(1), D.iushrn(1); - x.cmp(y) >= 0 ? (x.isub(y), A.isub(C), B.isub(D)) : (y.isub(x), C.isub(A), D.isub(B)); - } - return { - a: C, - b: D, - gcd: y.iushln(g), - }; - }), - (BN.prototype._invmp = function (p) { - assert(p.negative === 0), assert(!p.isZero()); - var a = this, - b = p.clone(); - a.negative !== 0 ? (a = a.umod(p)) : (a = a.clone()); - for (var x1 = new BN(1), x2 = new BN(0), delta = b.clone(); a.cmpn(1) > 0 && b.cmpn(1) > 0; ) { - for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1); - if (i > 0) for (a.iushrn(i); i-- > 0; ) x1.isOdd() && x1.iadd(delta), x1.iushrn(1); - for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); - if (j > 0) for (b.iushrn(j); j-- > 0; ) x2.isOdd() && x2.iadd(delta), x2.iushrn(1); - a.cmp(b) >= 0 ? (a.isub(b), x1.isub(x2)) : (b.isub(a), x2.isub(x1)); - } - var res; - return a.cmpn(1) === 0 ? (res = x1) : (res = x2), res.cmpn(0) < 0 && res.iadd(p), res; - }), - (BN.prototype.gcd = function (num) { - if (this.isZero()) return num.abs(); - if (num.isZero()) return this.abs(); - var a = this.clone(), - b = num.clone(); - (a.negative = 0), (b.negative = 0); - for (var shift = 0; a.isEven() && b.isEven(); shift++) a.iushrn(1), b.iushrn(1); - do { - for (; a.isEven(); ) a.iushrn(1); - for (; b.isEven(); ) b.iushrn(1); - var r = a.cmp(b); - if (r < 0) { - var t = a; - (a = b), (b = t); - } else if (r === 0 || b.cmpn(1) === 0) break; - a.isub(b); - } while (!0); - return b.iushln(shift); - }), - (BN.prototype.invm = function (num) { - return this.egcd(num).a.umod(num); - }), - (BN.prototype.isEven = function () { - return (this.words[0] & 1) === 0; - }), - (BN.prototype.isOdd = function () { - return (this.words[0] & 1) === 1; - }), - (BN.prototype.andln = function (num) { - return this.words[0] & num; - }), - (BN.prototype.bincn = function (bit) { - assert(typeof bit == "number"); - var r = bit % 26, - s = (bit - r) / 26, - q = 1 << r; - if (this.length <= s) return this._expand(s + 1), (this.words[s] |= q), this; - for (var carry = q, i = s; carry !== 0 && i < this.length; i++) { - var w = this.words[i] | 0; - (w += carry), (carry = w >>> 26), (w &= 67108863), (this.words[i] = w); - } - return carry !== 0 && ((this.words[i] = carry), this.length++), this; - }), - (BN.prototype.isZero = function () { - return this.length === 1 && this.words[0] === 0; - }), - (BN.prototype.cmpn = function (num) { - var negative = num < 0; - if (this.negative !== 0 && !negative) return -1; - if (this.negative === 0 && negative) return 1; - this.strip(); - var res; - if (this.length > 1) res = 1; - else { - negative && (num = -num), assert(num <= 67108863, "Number is too big"); - var w = this.words[0] | 0; - res = w === num ? 0 : w < num ? -1 : 1; - } - return this.negative !== 0 ? -res | 0 : res; - }), - (BN.prototype.cmp = function (num) { - if (this.negative !== 0 && num.negative === 0) return -1; - if (this.negative === 0 && num.negative !== 0) return 1; - var res = this.ucmp(num); - return this.negative !== 0 ? -res | 0 : res; - }), - (BN.prototype.ucmp = function (num) { - if (this.length > num.length) return 1; - if (this.length < num.length) return -1; - for (var res = 0, i = this.length - 1; i >= 0; i--) { - var a = this.words[i] | 0, - b = num.words[i] | 0; - if (a !== b) { - a < b ? (res = -1) : a > b && (res = 1); - break; - } - } - return res; - }), - (BN.prototype.gtn = function (num) { - return this.cmpn(num) === 1; - }), - (BN.prototype.gt = function (num) { - return this.cmp(num) === 1; - }), - (BN.prototype.gten = function (num) { - return this.cmpn(num) >= 0; - }), - (BN.prototype.gte = function (num) { - return this.cmp(num) >= 0; - }), - (BN.prototype.ltn = function (num) { - return this.cmpn(num) === -1; - }), - (BN.prototype.lt = function (num) { - return this.cmp(num) === -1; - }), - (BN.prototype.lten = function (num) { - return this.cmpn(num) <= 0; - }), - (BN.prototype.lte = function (num) { - return this.cmp(num) <= 0; - }), - (BN.prototype.eqn = function (num) { - return this.cmpn(num) === 0; - }), - (BN.prototype.eq = function (num) { - return this.cmp(num) === 0; - }), - (BN.red = function (num) { - return new Red(num); - }), - (BN.prototype.toRed = function (ctx) { - return ( - assert(!this.red, "Already a number in reduction context"), - assert(this.negative === 0, "red works only with positives"), - ctx.convertTo(this)._forceRed(ctx) - ); - }), - (BN.prototype.fromRed = function () { - return assert(this.red, "fromRed works only with numbers in reduction context"), this.red.convertFrom(this); - }), - (BN.prototype._forceRed = function (ctx) { - return (this.red = ctx), this; - }), - (BN.prototype.forceRed = function (ctx) { - return assert(!this.red, "Already a number in reduction context"), this._forceRed(ctx); - }), - (BN.prototype.redAdd = function (num) { - return assert(this.red, "redAdd works only with red numbers"), this.red.add(this, num); - }), - (BN.prototype.redIAdd = function (num) { - return assert(this.red, "redIAdd works only with red numbers"), this.red.iadd(this, num); - }), - (BN.prototype.redSub = function (num) { - return assert(this.red, "redSub works only with red numbers"), this.red.sub(this, num); - }), - (BN.prototype.redISub = function (num) { - return assert(this.red, "redISub works only with red numbers"), this.red.isub(this, num); - }), - (BN.prototype.redShl = function (num) { - return assert(this.red, "redShl works only with red numbers"), this.red.shl(this, num); - }), - (BN.prototype.redMul = function (num) { - return ( - assert(this.red, "redMul works only with red numbers"), - this.red._verify2(this, num), - this.red.mul(this, num) - ); - }), - (BN.prototype.redIMul = function (num) { - return ( - assert(this.red, "redMul works only with red numbers"), - this.red._verify2(this, num), - this.red.imul(this, num) - ); - }), - (BN.prototype.redSqr = function () { - return assert(this.red, "redSqr works only with red numbers"), this.red._verify1(this), this.red.sqr(this); - }), - (BN.prototype.redISqr = function () { - return assert(this.red, "redISqr works only with red numbers"), this.red._verify1(this), this.red.isqr(this); - }), - (BN.prototype.redSqrt = function () { - return assert(this.red, "redSqrt works only with red numbers"), this.red._verify1(this), this.red.sqrt(this); - }), - (BN.prototype.redInvm = function () { - return assert(this.red, "redInvm works only with red numbers"), this.red._verify1(this), this.red.invm(this); - }), - (BN.prototype.redNeg = function () { - return assert(this.red, "redNeg works only with red numbers"), this.red._verify1(this), this.red.neg(this); - }), - (BN.prototype.redPow = function (num) { - return assert(this.red && !num.red, "redPow(normalNum)"), this.red._verify1(this), this.red.pow(this, num); - }); - var primes = { - k256: null, - p224: null, - p192: null, - p25519: null, - }; - function MPrime(name, p) { - (this.name = name), - (this.p = new BN(p, 16)), - (this.n = this.p.bitLength()), - (this.k = new BN(1).iushln(this.n).isub(this.p)), - (this.tmp = this._tmp()); - } - (MPrime.prototype._tmp = function () { - var tmp = new BN(null); - return (tmp.words = new Array(Math.ceil(this.n / 13))), tmp; - }), - (MPrime.prototype.ireduce = function (num) { - var r = num, - rlen; - do this.split(r, this.tmp), (r = this.imulK(r)), (r = r.iadd(this.tmp)), (rlen = r.bitLength()); - while (rlen > this.n); - var cmp = rlen < this.n ? -1 : r.ucmp(this.p); - return ( - cmp === 0 - ? ((r.words[0] = 0), (r.length = 1)) - : cmp > 0 - ? r.isub(this.p) - : r.strip !== void 0 - ? r.strip() - : r._strip(), - r - ); - }), - (MPrime.prototype.split = function (input, out) { - input.iushrn(this.n, 0, out); - }), - (MPrime.prototype.imulK = function (num) { - return num.imul(this.k); - }); - function K256() { - MPrime.call(this, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); - } - inherits(K256, MPrime), - (K256.prototype.split = function (input, output) { - for (var mask = 4194303, outLen = Math.min(input.length, 9), i = 0; i < outLen; i++) - output.words[i] = input.words[i]; - if (((output.length = outLen), input.length <= 9)) { - (input.words[0] = 0), (input.length = 1); - return; - } - var prev = input.words[9]; - for (output.words[output.length++] = prev & mask, i = 10; i < input.length; i++) { - var next = input.words[i] | 0; - (input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22)), (prev = next); - } - (prev >>>= 22), - (input.words[i - 10] = prev), - prev === 0 && input.length > 10 ? (input.length -= 10) : (input.length -= 9); - }), - (K256.prototype.imulK = function (num) { - (num.words[num.length] = 0), (num.words[num.length + 1] = 0), (num.length += 2); - for (var lo = 0, i = 0; i < num.length; i++) { - var w = num.words[i] | 0; - (lo += w * 977), (num.words[i] = lo & 67108863), (lo = w * 64 + ((lo / 67108864) | 0)); - } - return ( - num.words[num.length - 1] === 0 && (num.length--, num.words[num.length - 1] === 0 && num.length--), num - ); - }); - function P224() { - MPrime.call(this, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); - } - inherits(P224, MPrime); - function P192() { - MPrime.call(this, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); - } - inherits(P192, MPrime); - function P25519() { - MPrime.call(this, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); - } - inherits(P25519, MPrime), - (P25519.prototype.imulK = function (num) { - for (var carry = 0, i = 0; i < num.length; i++) { - var hi = (num.words[i] | 0) * 19 + carry, - lo = hi & 67108863; - (hi >>>= 26), (num.words[i] = lo), (carry = hi); - } - return carry !== 0 && (num.words[num.length++] = carry), num; - }), - (BN._prime = function (name) { - if (primes[name]) return primes[name]; - var prime2; - if (name === "k256") prime2 = new K256(); - else if (name === "p224") prime2 = new P224(); - else if (name === "p192") prime2 = new P192(); - else if (name === "p25519") prime2 = new P25519(); - else throw new Error("Unknown prime " + name); - return (primes[name] = prime2), prime2; - }); - function Red(m) { - if (typeof m == "string") { - var prime = BN._prime(m); - (this.m = prime.p), (this.prime = prime); - } else assert(m.gtn(1), "modulus must be greater than 1"), (this.m = m), (this.prime = null); - } - (Red.prototype._verify1 = function (a) { - assert(a.negative === 0, "red works only with positives"), assert(a.red, "red works only with red numbers"); - }), - (Red.prototype._verify2 = function (a, b) { - assert((a.negative | b.negative) === 0, "red works only with positives"), - assert(a.red && a.red === b.red, "red works only with red numbers"); - }), - (Red.prototype.imod = function (a) { - return this.prime ? this.prime.ireduce(a)._forceRed(this) : a.umod(this.m)._forceRed(this); - }), - (Red.prototype.neg = function (a) { - return a.isZero() ? a.clone() : this.m.sub(a)._forceRed(this); - }), - (Red.prototype.add = function (a, b) { - this._verify2(a, b); - var res = a.add(b); - return res.cmp(this.m) >= 0 && res.isub(this.m), res._forceRed(this); - }), - (Red.prototype.iadd = function (a, b) { - this._verify2(a, b); - var res = a.iadd(b); - return res.cmp(this.m) >= 0 && res.isub(this.m), res; - }), - (Red.prototype.sub = function (a, b) { - this._verify2(a, b); - var res = a.sub(b); - return res.cmpn(0) < 0 && res.iadd(this.m), res._forceRed(this); - }), - (Red.prototype.isub = function (a, b) { - this._verify2(a, b); - var res = a.isub(b); - return res.cmpn(0) < 0 && res.iadd(this.m), res; - }), - (Red.prototype.shl = function (a, num) { - return this._verify1(a), this.imod(a.ushln(num)); - }), - (Red.prototype.imul = function (a, b) { - return this._verify2(a, b), this.imod(a.imul(b)); - }), - (Red.prototype.mul = function (a, b) { - return this._verify2(a, b), this.imod(a.mul(b)); - }), - (Red.prototype.isqr = function (a) { - return this.imul(a, a.clone()); - }), - (Red.prototype.sqr = function (a) { - return this.mul(a, a); - }), - (Red.prototype.sqrt = function (a) { - if (a.isZero()) return a.clone(); - var mod3 = this.m.andln(3); - if ((assert(mod3 % 2 === 1), mod3 === 3)) { - var pow = this.m.add(new BN(1)).iushrn(2); - return this.pow(a, pow); - } - for (var q = this.m.subn(1), s = 0; !q.isZero() && q.andln(1) === 0; ) s++, q.iushrn(1); - assert(!q.isZero()); - var one = new BN(1).toRed(this), - nOne = one.redNeg(), - lpow = this.m.subn(1).iushrn(1), - z = this.m.bitLength(); - for (z = new BN(2 * z * z).toRed(this); this.pow(z, lpow).cmp(nOne) !== 0; ) z.redIAdd(nOne); - for ( - var c = this.pow(z, q), r = this.pow(a, q.addn(1).iushrn(1)), t = this.pow(a, q), m = s; - t.cmp(one) !== 0; - - ) { - for (var tmp = t, i = 0; tmp.cmp(one) !== 0; i++) tmp = tmp.redSqr(); - assert(i < m); - var b = this.pow(c, new BN(1).iushln(m - i - 1)); - (r = r.redMul(b)), (c = b.redSqr()), (t = t.redMul(c)), (m = i); - } - return r; - }), - (Red.prototype.invm = function (a) { - var inv = a._invmp(this.m); - return inv.negative !== 0 ? ((inv.negative = 0), this.imod(inv).redNeg()) : this.imod(inv); - }), - (Red.prototype.pow = function (a, num) { - if (num.isZero()) return new BN(1).toRed(this); - if (num.cmpn(1) === 0) return a.clone(); - var windowSize = 4, - wnd = new Array(1 << windowSize); - (wnd[0] = new BN(1).toRed(this)), (wnd[1] = a); - for (var i = 2; i < wnd.length; i++) wnd[i] = this.mul(wnd[i - 1], a); - var res = wnd[0], - current = 0, - currentLen = 0, - start = num.bitLength() % 26; - for (start === 0 && (start = 26), i = num.length - 1; i >= 0; i--) { - for (var word = num.words[i], j = start - 1; j >= 0; j--) { - var bit = (word >> j) & 1; - if ((res !== wnd[0] && (res = this.sqr(res)), bit === 0 && current === 0)) { - currentLen = 0; - continue; - } - (current <<= 1), - (current |= bit), - currentLen++, - !(currentLen !== windowSize && (i !== 0 || j !== 0)) && - ((res = this.mul(res, wnd[current])), (currentLen = 0), (current = 0)); - } - start = 26; - } - return res; - }), - (Red.prototype.convertTo = function (num) { - var r = num.umod(this.m); - return r === num ? r.clone() : r; - }), - (Red.prototype.convertFrom = function (num) { - var res = num.clone(); - return (res.red = null), res; - }), - (BN.mont = function (num) { - return new Mont(num); - }); - function Mont(m) { - Red.call(this, m), - (this.shift = this.m.bitLength()), - this.shift % 26 !== 0 && (this.shift += 26 - (this.shift % 26)), - (this.r = new BN(1).iushln(this.shift)), - (this.r2 = this.imod(this.r.sqr())), - (this.rinv = this.r._invmp(this.m)), - (this.minv = this.rinv.mul(this.r).isubn(1).div(this.m)), - (this.minv = this.minv.umod(this.r)), - (this.minv = this.r.sub(this.minv)); - } - inherits(Mont, Red), - (Mont.prototype.convertTo = function (num) { - return this.imod(num.ushln(this.shift)); - }), - (Mont.prototype.convertFrom = function (num) { - var r = this.imod(num.mul(this.rinv)); - return (r.red = null), r; - }), - (Mont.prototype.imul = function (a, b) { - if (a.isZero() || b.isZero()) return (a.words[0] = 0), (a.length = 1), a; - var t = a.imul(b), - c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), - u = t.isub(c).iushrn(this.shift), - res = u; - return ( - u.cmp(this.m) >= 0 ? (res = u.isub(this.m)) : u.cmpn(0) < 0 && (res = u.iadd(this.m)), res._forceRed(this) - ); - }), - (Mont.prototype.mul = function (a, b) { - if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this); - var t = a.mul(b), - c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), - u = t.isub(c).iushrn(this.shift), - res = u; - return ( - u.cmp(this.m) >= 0 ? (res = u.isub(this.m)) : u.cmpn(0) < 0 && (res = u.iadd(this.m)), res._forceRed(this) - ); - }), - (Mont.prototype.invm = function (a) { - var res = this.imod(a._invmp(this.m).mul(this.r2)); - return res._forceRed(this); - }); - })(typeof module > "u" || module, exports); - }, -}); +var require_bn4 = require_bn; // node_modules/minimalistic-crypto-utils/lib/utils.js var require_utils2 = __commonJS({ @@ -11920,6 +5893,7 @@ var require_base = __commonJS({ : ((this._maxwellTrick = !0), (this.redN = this.n.toRed(this.red))); } module.exports = BaseCurve; + BaseCurve.prototype = {}; BaseCurve.prototype.point = function () { throw new Error("Not implemented"); }; @@ -12038,6 +6012,7 @@ var require_base = __commonJS({ function BasePoint(curve, type) { (this.curve = curve), (this.type = type), (this.precomputed = null); } + BasePoint.prototype = {}; BaseCurve.BasePoint = BasePoint; BasePoint.prototype.eq = function () { throw new Error("Not implemented"); @@ -13307,6 +7282,7 @@ var require_common = __commonJS({ (this._delta8 = this.blockSize / 8), (this._delta32 = this.blockSize / 32); } + BlockHash.prototype = {}; exports.BlockHash = BlockHash; BlockHash.prototype.update = function (msg, enc) { if ( @@ -13920,6 +7896,7 @@ var require_hmac = __commonJS({ (this.outer = null), this._init(utils.toArray(key, enc)); } + Hmac.prototype = {}; module.exports = Hmac; Hmac.prototype._init = function (key) { key.length > this.blockSize && (key = new this.Hash().update(key).digest()), assert(key.length <= this.blockSize); @@ -14936,6 +8913,7 @@ var require_hmac_drbg = __commonJS({ assert(entropy.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"), this._init(entropy, nonce, pers); } + HmacDRBG.prototype = {}; module.exports = HmacDRBG; HmacDRBG.prototype._init = function (entropy, nonce, pers) { var seed = entropy.concat(nonce).concat(pers); @@ -14989,6 +8967,7 @@ var require_key = __commonJS({ options.priv && this._importPrivate(options.priv, options.privEnc), options.pub && this._importPublic(options.pub, options.pubEnc); } + KeyPair.prototype = {}; module.exports = KeyPair; KeyPair.fromPublic = function (ec, pub, enc) { return pub instanceof KeyPair @@ -15072,6 +9051,7 @@ var require_signature = __commonJS({ (this.s = new BN(options.s, 16)), options.recoveryParam === void 0 ? (this.recoveryParam = null) : (this.recoveryParam = options.recoveryParam)); } + Signature.prototype = {}; module.exports = Signature; function Position() { this.place = 0; @@ -15162,6 +9142,7 @@ var require_ec = __commonJS({ this.g.precompute(options.curve.n.bitLength() + 1), (this.hash = options.hash || options.curve.hash); } + EC.prototype = {}; module.exports = EC; EC.prototype.keyPair = function (options) { return new KeyPair(this, options); @@ -15298,6 +9279,7 @@ var require_key2 = __commonJS({ (this._secret = parseBytes(params.secret)), eddsa.isPoint(params.pub) ? (this._pub = params.pub) : (this._pubBytes = parseBytes(params.pub)); } + KeyPair.prototype = {}; KeyPair.fromPublic = function (eddsa, pub) { return pub instanceof KeyPair ? pub : new KeyPair(eddsa, { pub }); }; @@ -15368,6 +9350,7 @@ var require_signature2 = __commonJS({ (this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded), (this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded); } + Signature.prototype = {}; cachedProperty(Signature, "S", function () { return this.eddsa.decodeInt(this.Sencoded()); }); @@ -15412,6 +9395,7 @@ var require_eddsa = __commonJS({ (this.encodingLength = Math.ceil(curve.n.bitLength() / 8)), (this.hash = hash.sha512); } + EDDSA.prototype = {}; module.exports = EDDSA; EDDSA.prototype.sign = function (message, secret) { message = parseBytes(message); @@ -15484,1992 +9468,7 @@ var require_elliptic = __commonJS({ }); // node_modules/asn1.js/node_modules/bn.js/lib/bn.js -var require_bn5 = __commonJS({ - "node_modules/asn1.js/node_modules/bn.js/lib/bn.js"(exports, module) { - (function (module2, exports2) { - "use strict"; - function assert(val, msg) { - if (!val) throw new Error(msg || "Assertion failed"); - } - function inherits(ctor, superCtor) { - ctor.super_ = superCtor; - var TempCtor = function () {}; - (TempCtor.prototype = superCtor.prototype), - (ctor.prototype = new TempCtor()), - (ctor.prototype.constructor = ctor); - } - function BN(number, base, endian) { - if (BN.isBN(number)) return number; - (this.negative = 0), - (this.words = null), - (this.length = 0), - (this.red = null), - number !== null && - ((base === "le" || base === "be") && ((endian = base), (base = 10)), - this._init(number || 0, base || 10, endian || "be")); - } - typeof module2 == "object" ? (module2.exports = BN) : (exports2.BN = BN), (BN.BN = BN), (BN.wordSize = 26); - var Buffer2 = Buffer; - - (BN.isBN = function (num) { - return num instanceof BN - ? !0 - : num !== null && - typeof num == "object" && - num.constructor.wordSize === BN.wordSize && - Array.isArray(num.words); - }), - (BN.max = function (left, right) { - return left.cmp(right) > 0 ? left : right; - }), - (BN.min = function (left, right) { - return left.cmp(right) < 0 ? left : right; - }), - (BN.prototype._init = function (number, base, endian) { - if (typeof number == "number") return this._initNumber(number, base, endian); - if (typeof number == "object") return this._initArray(number, base, endian); - base === "hex" && (base = 16), - assert(base === (base | 0) && base >= 2 && base <= 36), - (number = number.toString().replace(/\s+/g, "")); - var start = 0; - number[0] === "-" && (start++, (this.negative = 1)), - start < number.length && - (base === 16 - ? this._parseHex(number, start, endian) - : (this._parseBase(number, base, start), - endian === "le" && this._initArray(this.toArray(), base, endian))); - }), - (BN.prototype._initNumber = function (number, base, endian) { - number < 0 && ((this.negative = 1), (number = -number)), - number < 67108864 - ? ((this.words = [number & 67108863]), (this.length = 1)) - : number < 4503599627370496 - ? ((this.words = [number & 67108863, (number / 67108864) & 67108863]), (this.length = 2)) - : (assert(number < 9007199254740992), - (this.words = [number & 67108863, (number / 67108864) & 67108863, 1]), - (this.length = 3)), - endian === "le" && this._initArray(this.toArray(), base, endian); - }), - (BN.prototype._initArray = function (number, base, endian) { - if ((assert(typeof number.length == "number"), number.length <= 0)) - return (this.words = [0]), (this.length = 1), this; - (this.length = Math.ceil(number.length / 3)), (this.words = new Array(this.length)); - for (var i = 0; i < this.length; i++) this.words[i] = 0; - var j, - w, - off = 0; - if (endian === "be") - for (i = number.length - 1, j = 0; i >= 0; i -= 3) - (w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16)), - (this.words[j] |= (w << off) & 67108863), - (this.words[j + 1] = (w >>> (26 - off)) & 67108863), - (off += 24), - off >= 26 && ((off -= 26), j++); - else if (endian === "le") - for (i = 0, j = 0; i < number.length; i += 3) - (w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16)), - (this.words[j] |= (w << off) & 67108863), - (this.words[j + 1] = (w >>> (26 - off)) & 67108863), - (off += 24), - off >= 26 && ((off -= 26), j++); - return this.strip(); - }); - function parseHex4Bits(string, index) { - var c = string.charCodeAt(index); - return c >= 65 && c <= 70 ? c - 55 : c >= 97 && c <= 102 ? c - 87 : (c - 48) & 15; - } - function parseHexByte(string, lowerBound, index) { - var r = parseHex4Bits(string, index); - return index - 1 >= lowerBound && (r |= parseHex4Bits(string, index - 1) << 4), r; - } - BN.prototype._parseHex = function (number, start, endian) { - (this.length = Math.ceil((number.length - start) / 6)), (this.words = new Array(this.length)); - for (var i = 0; i < this.length; i++) this.words[i] = 0; - var off = 0, - j = 0, - w; - if (endian === "be") - for (i = number.length - 1; i >= start; i -= 2) - (w = parseHexByte(number, start, i) << off), - (this.words[j] |= w & 67108863), - off >= 18 ? ((off -= 18), (j += 1), (this.words[j] |= w >>> 26)) : (off += 8); - else { - var parseLength = number.length - start; - for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) - (w = parseHexByte(number, start, i) << off), - (this.words[j] |= w & 67108863), - off >= 18 ? ((off -= 18), (j += 1), (this.words[j] |= w >>> 26)) : (off += 8); - } - this.strip(); - }; - function parseBase(str, start, end, mul) { - for (var r = 0, len = Math.min(str.length, end), i = start; i < len; i++) { - var c = str.charCodeAt(i) - 48; - (r *= mul), c >= 49 ? (r += c - 49 + 10) : c >= 17 ? (r += c - 17 + 10) : (r += c); - } - return r; - } - (BN.prototype._parseBase = function (number, base, start) { - (this.words = [0]), (this.length = 1); - for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *= base) limbLen++; - limbLen--, (limbPow = (limbPow / base) | 0); - for ( - var total = number.length - start, - mod = total % limbLen, - end = Math.min(total, total - mod) + start, - word = 0, - i = start; - i < end; - i += limbLen - ) - (word = parseBase(number, i, i + limbLen, base)), - this.imuln(limbPow), - this.words[0] + word < 67108864 ? (this.words[0] += word) : this._iaddn(word); - if (mod !== 0) { - var pow = 1; - for (word = parseBase(number, i, number.length, base), i = 0; i < mod; i++) pow *= base; - this.imuln(pow), this.words[0] + word < 67108864 ? (this.words[0] += word) : this._iaddn(word); - } - this.strip(); - }), - (BN.prototype.copy = function (dest) { - dest.words = new Array(this.length); - for (var i = 0; i < this.length; i++) dest.words[i] = this.words[i]; - (dest.length = this.length), (dest.negative = this.negative), (dest.red = this.red); - }), - (BN.prototype.clone = function () { - var r = new BN(null); - return this.copy(r), r; - }), - (BN.prototype._expand = function (size) { - for (; this.length < size; ) this.words[this.length++] = 0; - return this; - }), - (BN.prototype.strip = function () { - for (; this.length > 1 && this.words[this.length - 1] === 0; ) this.length--; - return this._normSign(); - }), - (BN.prototype._normSign = function () { - return this.length === 1 && this.words[0] === 0 && (this.negative = 0), this; - }), - (BN.prototype.inspect = function () { - return (this.red ? "<BN-R: " : "<BN: ") + this.toString(16) + ">"; - }); - var zeros = [ - "", - "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", - ], - groupSizes = [ - 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, - ], - groupBases = [ - 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 (base, padding) { - (base = base || 10), (padding = padding | 0 || 1); - var out; - if (base === 16 || base === "hex") { - out = ""; - for (var off = 0, carry = 0, i = 0; i < this.length; i++) { - var w = this.words[i], - word = (((w << off) | carry) & 16777215).toString(16); - (carry = (w >>> (24 - off)) & 16777215), - carry !== 0 || i !== this.length - 1 ? (out = zeros[6 - word.length] + word + out) : (out = word + out), - (off += 2), - off >= 26 && ((off -= 26), i--); - } - for (carry !== 0 && (out = carry.toString(16) + out); out.length % padding !== 0; ) out = "0" + out; - return this.negative !== 0 && (out = "-" + out), out; - } - if (base === (base | 0) && base >= 2 && base <= 36) { - var groupSize = groupSizes[base], - groupBase = groupBases[base]; - out = ""; - var c = this.clone(); - for (c.negative = 0; !c.isZero(); ) { - var r = c.modn(groupBase).toString(base); - (c = c.idivn(groupBase)), c.isZero() ? (out = r + out) : (out = zeros[groupSize - r.length] + r + out); - } - for (this.isZero() && (out = "0" + out); out.length % padding !== 0; ) out = "0" + out; - return this.negative !== 0 && (out = "-" + out), out; - } - assert(!1, "Base should be between 2 and 36"); - }), - (BN.prototype.toNumber = function () { - var ret = this.words[0]; - return ( - this.length === 2 - ? (ret += this.words[1] * 67108864) - : this.length === 3 && this.words[2] === 1 - ? (ret += 4503599627370496 + this.words[1] * 67108864) - : this.length > 2 && assert(!1, "Number can only safely store up to 53 bits"), - this.negative !== 0 ? -ret : ret - ); - }), - (BN.prototype.toJSON = function () { - return this.toString(16); - }), - (BN.prototype.toBuffer = function (endian, length) { - return assert(typeof Buffer2 < "u"), this.toArrayLike(Buffer2, endian, length); - }), - (BN.prototype.toArray = function (endian, length) { - return this.toArrayLike(Array, endian, length); - }), - (BN.prototype.toArrayLike = function (ArrayType, endian, length) { - var byteLength = this.byteLength(), - reqLength = length || Math.max(1, byteLength); - assert(byteLength <= reqLength, "byte array longer than desired length"), - assert(reqLength > 0, "Requested array length <= 0"), - this.strip(); - var littleEndian = endian === "le", - res = new ArrayType(reqLength), - b, - i, - q = this.clone(); - if (littleEndian) { - for (i = 0; !q.isZero(); i++) (b = q.andln(255)), q.iushrn(8), (res[i] = b); - for (; i < reqLength; i++) res[i] = 0; - } else { - for (i = 0; i < reqLength - byteLength; i++) res[i] = 0; - for (i = 0; !q.isZero(); i++) (b = q.andln(255)), q.iushrn(8), (res[reqLength - i - 1] = b); - } - return res; - }), - Math.clz32 - ? (BN.prototype._countBits = function (w) { - return 32 - Math.clz32(w); - }) - : (BN.prototype._countBits = function (w) { - var t = w, - r = 0; - return ( - t >= 4096 && ((r += 13), (t >>>= 13)), - t >= 64 && ((r += 7), (t >>>= 7)), - t >= 8 && ((r += 4), (t >>>= 4)), - t >= 2 && ((r += 2), (t >>>= 2)), - r + t - ); - }), - (BN.prototype._zeroBits = function (w) { - if (w === 0) return 26; - var t = w, - r = 0; - return ( - (t & 8191) === 0 && ((r += 13), (t >>>= 13)), - (t & 127) === 0 && ((r += 7), (t >>>= 7)), - (t & 15) === 0 && ((r += 4), (t >>>= 4)), - (t & 3) === 0 && ((r += 2), (t >>>= 2)), - (t & 1) === 0 && r++, - r - ); - }), - (BN.prototype.bitLength = function () { - var w = this.words[this.length - 1], - hi = this._countBits(w); - return (this.length - 1) * 26 + hi; - }); - function toBitArray(num) { - for (var w = new Array(num.bitLength()), bit = 0; bit < w.length; bit++) { - var off = (bit / 26) | 0, - wbit = bit % 26; - w[bit] = (num.words[off] & (1 << wbit)) >>> wbit; - } - return w; - } - (BN.prototype.zeroBits = function () { - if (this.isZero()) return 0; - for (var r = 0, i = 0; i < this.length; i++) { - var b = this._zeroBits(this.words[i]); - if (((r += b), b !== 26)) break; - } - return r; - }), - (BN.prototype.byteLength = function () { - return Math.ceil(this.bitLength() / 8); - }), - (BN.prototype.toTwos = function (width) { - return this.negative !== 0 ? this.abs().inotn(width).iaddn(1) : this.clone(); - }), - (BN.prototype.fromTwos = function (width) { - return this.testn(width - 1) ? this.notn(width).iaddn(1).ineg() : this.clone(); - }), - (BN.prototype.isNeg = function () { - return this.negative !== 0; - }), - (BN.prototype.neg = function () { - return this.clone().ineg(); - }), - (BN.prototype.ineg = function () { - return this.isZero() || (this.negative ^= 1), this; - }), - (BN.prototype.iuor = function (num) { - for (; this.length < num.length; ) this.words[this.length++] = 0; - for (var i = 0; i < num.length; i++) this.words[i] = this.words[i] | num.words[i]; - return this.strip(); - }), - (BN.prototype.ior = function (num) { - return assert((this.negative | num.negative) === 0), this.iuor(num); - }), - (BN.prototype.or = function (num) { - return this.length > num.length ? this.clone().ior(num) : num.clone().ior(this); - }), - (BN.prototype.uor = function (num) { - return this.length > num.length ? this.clone().iuor(num) : num.clone().iuor(this); - }), - (BN.prototype.iuand = function (num) { - var b; - this.length > num.length ? (b = num) : (b = this); - for (var i = 0; i < b.length; i++) this.words[i] = this.words[i] & num.words[i]; - return (this.length = b.length), this.strip(); - }), - (BN.prototype.iand = function (num) { - return assert((this.negative | num.negative) === 0), this.iuand(num); - }), - (BN.prototype.and = function (num) { - return this.length > num.length ? this.clone().iand(num) : num.clone().iand(this); - }), - (BN.prototype.uand = function (num) { - return this.length > num.length ? this.clone().iuand(num) : num.clone().iuand(this); - }), - (BN.prototype.iuxor = function (num) { - var a, b; - this.length > num.length ? ((a = this), (b = num)) : ((a = num), (b = this)); - for (var i = 0; i < b.length; i++) this.words[i] = a.words[i] ^ b.words[i]; - if (this !== a) for (; i < a.length; i++) this.words[i] = a.words[i]; - return (this.length = a.length), this.strip(); - }), - (BN.prototype.ixor = function (num) { - return assert((this.negative | num.negative) === 0), this.iuxor(num); - }), - (BN.prototype.xor = function (num) { - return this.length > num.length ? this.clone().ixor(num) : num.clone().ixor(this); - }), - (BN.prototype.uxor = function (num) { - return this.length > num.length ? this.clone().iuxor(num) : num.clone().iuxor(this); - }), - (BN.prototype.inotn = function (width) { - assert(typeof width == "number" && width >= 0); - var bytesNeeded = Math.ceil(width / 26) | 0, - bitsLeft = width % 26; - this._expand(bytesNeeded), bitsLeft > 0 && bytesNeeded--; - for (var i = 0; i < bytesNeeded; i++) this.words[i] = ~this.words[i] & 67108863; - return bitsLeft > 0 && (this.words[i] = ~this.words[i] & (67108863 >> (26 - bitsLeft))), this.strip(); - }), - (BN.prototype.notn = function (width) { - return this.clone().inotn(width); - }), - (BN.prototype.setn = function (bit, val) { - assert(typeof bit == "number" && bit >= 0); - var off = (bit / 26) | 0, - wbit = bit % 26; - return ( - this._expand(off + 1), - val - ? (this.words[off] = this.words[off] | (1 << wbit)) - : (this.words[off] = this.words[off] & ~(1 << wbit)), - this.strip() - ); - }), - (BN.prototype.iadd = function (num) { - var r; - if (this.negative !== 0 && num.negative === 0) - return (this.negative = 0), (r = this.isub(num)), (this.negative ^= 1), this._normSign(); - if (this.negative === 0 && num.negative !== 0) - return (num.negative = 0), (r = this.isub(num)), (num.negative = 1), r._normSign(); - var a, b; - this.length > num.length ? ((a = this), (b = num)) : ((a = num), (b = this)); - for (var carry = 0, i = 0; i < b.length; i++) - (r = (a.words[i] | 0) + (b.words[i] | 0) + carry), (this.words[i] = r & 67108863), (carry = r >>> 26); - for (; carry !== 0 && i < a.length; i++) - (r = (a.words[i] | 0) + carry), (this.words[i] = r & 67108863), (carry = r >>> 26); - if (((this.length = a.length), carry !== 0)) (this.words[this.length] = carry), this.length++; - else if (a !== this) for (; i < a.length; i++) this.words[i] = a.words[i]; - return this; - }), - (BN.prototype.add = function (num) { - var res; - return num.negative !== 0 && this.negative === 0 - ? ((num.negative = 0), (res = this.sub(num)), (num.negative ^= 1), res) - : num.negative === 0 && this.negative !== 0 - ? ((this.negative = 0), (res = num.sub(this)), (this.negative = 1), res) - : this.length > num.length - ? this.clone().iadd(num) - : num.clone().iadd(this); - }), - (BN.prototype.isub = function (num) { - if (num.negative !== 0) { - num.negative = 0; - var r = this.iadd(num); - return (num.negative = 1), r._normSign(); - } else if (this.negative !== 0) - return (this.negative = 0), this.iadd(num), (this.negative = 1), this._normSign(); - var cmp = this.cmp(num); - if (cmp === 0) return (this.negative = 0), (this.length = 1), (this.words[0] = 0), this; - var a, b; - cmp > 0 ? ((a = this), (b = num)) : ((a = num), (b = this)); - for (var carry = 0, i = 0; i < b.length; i++) - (r = (a.words[i] | 0) - (b.words[i] | 0) + carry), (carry = r >> 26), (this.words[i] = r & 67108863); - for (; carry !== 0 && i < a.length; i++) - (r = (a.words[i] | 0) + carry), (carry = r >> 26), (this.words[i] = r & 67108863); - if (carry === 0 && i < a.length && a !== this) for (; i < a.length; i++) this.words[i] = a.words[i]; - return (this.length = Math.max(this.length, i)), a !== this && (this.negative = 1), this.strip(); - }), - (BN.prototype.sub = function (num) { - return this.clone().isub(num); - }); - function smallMulTo(self2, num, out) { - out.negative = num.negative ^ self2.negative; - var len = (self2.length + num.length) | 0; - (out.length = len), (len = (len - 1) | 0); - var a = self2.words[0] | 0, - b = num.words[0] | 0, - r = a * b, - lo = r & 67108863, - carry = (r / 67108864) | 0; - out.words[0] = lo; - for (var k = 1; k < len; k++) { - for ( - var ncarry = carry >>> 26, - rword = carry & 67108863, - maxJ = Math.min(k, num.length - 1), - j = Math.max(0, k - self2.length + 1); - j <= maxJ; - j++ - ) { - var i = (k - j) | 0; - (a = self2.words[i] | 0), - (b = num.words[j] | 0), - (r = a * b + rword), - (ncarry += (r / 67108864) | 0), - (rword = r & 67108863); - } - (out.words[k] = rword | 0), (carry = ncarry | 0); - } - return carry !== 0 ? (out.words[k] = carry | 0) : out.length--, out.strip(); - } - var comb10MulTo = function (self2, num, out) { - var a = self2.words, - b = num.words, - o = out.words, - c = 0, - lo, - mid, - hi, - a0 = a[0] | 0, - al0 = a0 & 8191, - ah0 = a0 >>> 13, - a1 = a[1] | 0, - al1 = a1 & 8191, - ah1 = a1 >>> 13, - a2 = a[2] | 0, - al2 = a2 & 8191, - ah2 = a2 >>> 13, - a3 = a[3] | 0, - al3 = a3 & 8191, - ah3 = a3 >>> 13, - a4 = a[4] | 0, - al4 = a4 & 8191, - ah4 = a4 >>> 13, - a5 = a[5] | 0, - al5 = a5 & 8191, - ah5 = a5 >>> 13, - a6 = a[6] | 0, - al6 = a6 & 8191, - ah6 = a6 >>> 13, - a7 = a[7] | 0, - al7 = a7 & 8191, - ah7 = a7 >>> 13, - a8 = a[8] | 0, - al8 = a8 & 8191, - ah8 = a8 >>> 13, - a9 = a[9] | 0, - al9 = a9 & 8191, - ah9 = a9 >>> 13, - b0 = b[0] | 0, - bl0 = b0 & 8191, - bh0 = b0 >>> 13, - b1 = b[1] | 0, - bl1 = b1 & 8191, - bh1 = b1 >>> 13, - b2 = b[2] | 0, - bl2 = b2 & 8191, - bh2 = b2 >>> 13, - b3 = b[3] | 0, - bl3 = b3 & 8191, - bh3 = b3 >>> 13, - b4 = b[4] | 0, - bl4 = b4 & 8191, - bh4 = b4 >>> 13, - b5 = b[5] | 0, - bl5 = b5 & 8191, - bh5 = b5 >>> 13, - b6 = b[6] | 0, - bl6 = b6 & 8191, - bh6 = b6 >>> 13, - b7 = b[7] | 0, - bl7 = b7 & 8191, - bh7 = b7 >>> 13, - b8 = b[8] | 0, - bl8 = b8 & 8191, - bh8 = b8 >>> 13, - b9 = b[9] | 0, - bl9 = b9 & 8191, - bh9 = b9 >>> 13; - (out.negative = self2.negative ^ num.negative), - (out.length = 19), - (lo = Math.imul(al0, bl0)), - (mid = Math.imul(al0, bh0)), - (mid = (mid + Math.imul(ah0, bl0)) | 0), - (hi = Math.imul(ah0, bh0)); - var w0 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0), - (w0 &= 67108863), - (lo = Math.imul(al1, bl0)), - (mid = Math.imul(al1, bh0)), - (mid = (mid + Math.imul(ah1, bl0)) | 0), - (hi = Math.imul(ah1, bh0)), - (lo = (lo + Math.imul(al0, bl1)) | 0), - (mid = (mid + Math.imul(al0, bh1)) | 0), - (mid = (mid + Math.imul(ah0, bl1)) | 0), - (hi = (hi + Math.imul(ah0, bh1)) | 0); - var w1 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0), - (w1 &= 67108863), - (lo = Math.imul(al2, bl0)), - (mid = Math.imul(al2, bh0)), - (mid = (mid + Math.imul(ah2, bl0)) | 0), - (hi = Math.imul(ah2, bh0)), - (lo = (lo + Math.imul(al1, bl1)) | 0), - (mid = (mid + Math.imul(al1, bh1)) | 0), - (mid = (mid + Math.imul(ah1, bl1)) | 0), - (hi = (hi + Math.imul(ah1, bh1)) | 0), - (lo = (lo + Math.imul(al0, bl2)) | 0), - (mid = (mid + Math.imul(al0, bh2)) | 0), - (mid = (mid + Math.imul(ah0, bl2)) | 0), - (hi = (hi + Math.imul(ah0, bh2)) | 0); - var w2 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0), - (w2 &= 67108863), - (lo = Math.imul(al3, bl0)), - (mid = Math.imul(al3, bh0)), - (mid = (mid + Math.imul(ah3, bl0)) | 0), - (hi = Math.imul(ah3, bh0)), - (lo = (lo + Math.imul(al2, bl1)) | 0), - (mid = (mid + Math.imul(al2, bh1)) | 0), - (mid = (mid + Math.imul(ah2, bl1)) | 0), - (hi = (hi + Math.imul(ah2, bh1)) | 0), - (lo = (lo + Math.imul(al1, bl2)) | 0), - (mid = (mid + Math.imul(al1, bh2)) | 0), - (mid = (mid + Math.imul(ah1, bl2)) | 0), - (hi = (hi + Math.imul(ah1, bh2)) | 0), - (lo = (lo + Math.imul(al0, bl3)) | 0), - (mid = (mid + Math.imul(al0, bh3)) | 0), - (mid = (mid + Math.imul(ah0, bl3)) | 0), - (hi = (hi + Math.imul(ah0, bh3)) | 0); - var w3 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0), - (w3 &= 67108863), - (lo = Math.imul(al4, bl0)), - (mid = Math.imul(al4, bh0)), - (mid = (mid + Math.imul(ah4, bl0)) | 0), - (hi = Math.imul(ah4, bh0)), - (lo = (lo + Math.imul(al3, bl1)) | 0), - (mid = (mid + Math.imul(al3, bh1)) | 0), - (mid = (mid + Math.imul(ah3, bl1)) | 0), - (hi = (hi + Math.imul(ah3, bh1)) | 0), - (lo = (lo + Math.imul(al2, bl2)) | 0), - (mid = (mid + Math.imul(al2, bh2)) | 0), - (mid = (mid + Math.imul(ah2, bl2)) | 0), - (hi = (hi + Math.imul(ah2, bh2)) | 0), - (lo = (lo + Math.imul(al1, bl3)) | 0), - (mid = (mid + Math.imul(al1, bh3)) | 0), - (mid = (mid + Math.imul(ah1, bl3)) | 0), - (hi = (hi + Math.imul(ah1, bh3)) | 0), - (lo = (lo + Math.imul(al0, bl4)) | 0), - (mid = (mid + Math.imul(al0, bh4)) | 0), - (mid = (mid + Math.imul(ah0, bl4)) | 0), - (hi = (hi + Math.imul(ah0, bh4)) | 0); - var w4 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0), - (w4 &= 67108863), - (lo = Math.imul(al5, bl0)), - (mid = Math.imul(al5, bh0)), - (mid = (mid + Math.imul(ah5, bl0)) | 0), - (hi = Math.imul(ah5, bh0)), - (lo = (lo + Math.imul(al4, bl1)) | 0), - (mid = (mid + Math.imul(al4, bh1)) | 0), - (mid = (mid + Math.imul(ah4, bl1)) | 0), - (hi = (hi + Math.imul(ah4, bh1)) | 0), - (lo = (lo + Math.imul(al3, bl2)) | 0), - (mid = (mid + Math.imul(al3, bh2)) | 0), - (mid = (mid + Math.imul(ah3, bl2)) | 0), - (hi = (hi + Math.imul(ah3, bh2)) | 0), - (lo = (lo + Math.imul(al2, bl3)) | 0), - (mid = (mid + Math.imul(al2, bh3)) | 0), - (mid = (mid + Math.imul(ah2, bl3)) | 0), - (hi = (hi + Math.imul(ah2, bh3)) | 0), - (lo = (lo + Math.imul(al1, bl4)) | 0), - (mid = (mid + Math.imul(al1, bh4)) | 0), - (mid = (mid + Math.imul(ah1, bl4)) | 0), - (hi = (hi + Math.imul(ah1, bh4)) | 0), - (lo = (lo + Math.imul(al0, bl5)) | 0), - (mid = (mid + Math.imul(al0, bh5)) | 0), - (mid = (mid + Math.imul(ah0, bl5)) | 0), - (hi = (hi + Math.imul(ah0, bh5)) | 0); - var w5 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0), - (w5 &= 67108863), - (lo = Math.imul(al6, bl0)), - (mid = Math.imul(al6, bh0)), - (mid = (mid + Math.imul(ah6, bl0)) | 0), - (hi = Math.imul(ah6, bh0)), - (lo = (lo + Math.imul(al5, bl1)) | 0), - (mid = (mid + Math.imul(al5, bh1)) | 0), - (mid = (mid + Math.imul(ah5, bl1)) | 0), - (hi = (hi + Math.imul(ah5, bh1)) | 0), - (lo = (lo + Math.imul(al4, bl2)) | 0), - (mid = (mid + Math.imul(al4, bh2)) | 0), - (mid = (mid + Math.imul(ah4, bl2)) | 0), - (hi = (hi + Math.imul(ah4, bh2)) | 0), - (lo = (lo + Math.imul(al3, bl3)) | 0), - (mid = (mid + Math.imul(al3, bh3)) | 0), - (mid = (mid + Math.imul(ah3, bl3)) | 0), - (hi = (hi + Math.imul(ah3, bh3)) | 0), - (lo = (lo + Math.imul(al2, bl4)) | 0), - (mid = (mid + Math.imul(al2, bh4)) | 0), - (mid = (mid + Math.imul(ah2, bl4)) | 0), - (hi = (hi + Math.imul(ah2, bh4)) | 0), - (lo = (lo + Math.imul(al1, bl5)) | 0), - (mid = (mid + Math.imul(al1, bh5)) | 0), - (mid = (mid + Math.imul(ah1, bl5)) | 0), - (hi = (hi + Math.imul(ah1, bh5)) | 0), - (lo = (lo + Math.imul(al0, bl6)) | 0), - (mid = (mid + Math.imul(al0, bh6)) | 0), - (mid = (mid + Math.imul(ah0, bl6)) | 0), - (hi = (hi + Math.imul(ah0, bh6)) | 0); - var w6 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0), - (w6 &= 67108863), - (lo = Math.imul(al7, bl0)), - (mid = Math.imul(al7, bh0)), - (mid = (mid + Math.imul(ah7, bl0)) | 0), - (hi = Math.imul(ah7, bh0)), - (lo = (lo + Math.imul(al6, bl1)) | 0), - (mid = (mid + Math.imul(al6, bh1)) | 0), - (mid = (mid + Math.imul(ah6, bl1)) | 0), - (hi = (hi + Math.imul(ah6, bh1)) | 0), - (lo = (lo + Math.imul(al5, bl2)) | 0), - (mid = (mid + Math.imul(al5, bh2)) | 0), - (mid = (mid + Math.imul(ah5, bl2)) | 0), - (hi = (hi + Math.imul(ah5, bh2)) | 0), - (lo = (lo + Math.imul(al4, bl3)) | 0), - (mid = (mid + Math.imul(al4, bh3)) | 0), - (mid = (mid + Math.imul(ah4, bl3)) | 0), - (hi = (hi + Math.imul(ah4, bh3)) | 0), - (lo = (lo + Math.imul(al3, bl4)) | 0), - (mid = (mid + Math.imul(al3, bh4)) | 0), - (mid = (mid + Math.imul(ah3, bl4)) | 0), - (hi = (hi + Math.imul(ah3, bh4)) | 0), - (lo = (lo + Math.imul(al2, bl5)) | 0), - (mid = (mid + Math.imul(al2, bh5)) | 0), - (mid = (mid + Math.imul(ah2, bl5)) | 0), - (hi = (hi + Math.imul(ah2, bh5)) | 0), - (lo = (lo + Math.imul(al1, bl6)) | 0), - (mid = (mid + Math.imul(al1, bh6)) | 0), - (mid = (mid + Math.imul(ah1, bl6)) | 0), - (hi = (hi + Math.imul(ah1, bh6)) | 0), - (lo = (lo + Math.imul(al0, bl7)) | 0), - (mid = (mid + Math.imul(al0, bh7)) | 0), - (mid = (mid + Math.imul(ah0, bl7)) | 0), - (hi = (hi + Math.imul(ah0, bh7)) | 0); - var w7 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0), - (w7 &= 67108863), - (lo = Math.imul(al8, bl0)), - (mid = Math.imul(al8, bh0)), - (mid = (mid + Math.imul(ah8, bl0)) | 0), - (hi = Math.imul(ah8, bh0)), - (lo = (lo + Math.imul(al7, bl1)) | 0), - (mid = (mid + Math.imul(al7, bh1)) | 0), - (mid = (mid + Math.imul(ah7, bl1)) | 0), - (hi = (hi + Math.imul(ah7, bh1)) | 0), - (lo = (lo + Math.imul(al6, bl2)) | 0), - (mid = (mid + Math.imul(al6, bh2)) | 0), - (mid = (mid + Math.imul(ah6, bl2)) | 0), - (hi = (hi + Math.imul(ah6, bh2)) | 0), - (lo = (lo + Math.imul(al5, bl3)) | 0), - (mid = (mid + Math.imul(al5, bh3)) | 0), - (mid = (mid + Math.imul(ah5, bl3)) | 0), - (hi = (hi + Math.imul(ah5, bh3)) | 0), - (lo = (lo + Math.imul(al4, bl4)) | 0), - (mid = (mid + Math.imul(al4, bh4)) | 0), - (mid = (mid + Math.imul(ah4, bl4)) | 0), - (hi = (hi + Math.imul(ah4, bh4)) | 0), - (lo = (lo + Math.imul(al3, bl5)) | 0), - (mid = (mid + Math.imul(al3, bh5)) | 0), - (mid = (mid + Math.imul(ah3, bl5)) | 0), - (hi = (hi + Math.imul(ah3, bh5)) | 0), - (lo = (lo + Math.imul(al2, bl6)) | 0), - (mid = (mid + Math.imul(al2, bh6)) | 0), - (mid = (mid + Math.imul(ah2, bl6)) | 0), - (hi = (hi + Math.imul(ah2, bh6)) | 0), - (lo = (lo + Math.imul(al1, bl7)) | 0), - (mid = (mid + Math.imul(al1, bh7)) | 0), - (mid = (mid + Math.imul(ah1, bl7)) | 0), - (hi = (hi + Math.imul(ah1, bh7)) | 0), - (lo = (lo + Math.imul(al0, bl8)) | 0), - (mid = (mid + Math.imul(al0, bh8)) | 0), - (mid = (mid + Math.imul(ah0, bl8)) | 0), - (hi = (hi + Math.imul(ah0, bh8)) | 0); - var w8 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0), - (w8 &= 67108863), - (lo = Math.imul(al9, bl0)), - (mid = Math.imul(al9, bh0)), - (mid = (mid + Math.imul(ah9, bl0)) | 0), - (hi = Math.imul(ah9, bh0)), - (lo = (lo + Math.imul(al8, bl1)) | 0), - (mid = (mid + Math.imul(al8, bh1)) | 0), - (mid = (mid + Math.imul(ah8, bl1)) | 0), - (hi = (hi + Math.imul(ah8, bh1)) | 0), - (lo = (lo + Math.imul(al7, bl2)) | 0), - (mid = (mid + Math.imul(al7, bh2)) | 0), - (mid = (mid + Math.imul(ah7, bl2)) | 0), - (hi = (hi + Math.imul(ah7, bh2)) | 0), - (lo = (lo + Math.imul(al6, bl3)) | 0), - (mid = (mid + Math.imul(al6, bh3)) | 0), - (mid = (mid + Math.imul(ah6, bl3)) | 0), - (hi = (hi + Math.imul(ah6, bh3)) | 0), - (lo = (lo + Math.imul(al5, bl4)) | 0), - (mid = (mid + Math.imul(al5, bh4)) | 0), - (mid = (mid + Math.imul(ah5, bl4)) | 0), - (hi = (hi + Math.imul(ah5, bh4)) | 0), - (lo = (lo + Math.imul(al4, bl5)) | 0), - (mid = (mid + Math.imul(al4, bh5)) | 0), - (mid = (mid + Math.imul(ah4, bl5)) | 0), - (hi = (hi + Math.imul(ah4, bh5)) | 0), - (lo = (lo + Math.imul(al3, bl6)) | 0), - (mid = (mid + Math.imul(al3, bh6)) | 0), - (mid = (mid + Math.imul(ah3, bl6)) | 0), - (hi = (hi + Math.imul(ah3, bh6)) | 0), - (lo = (lo + Math.imul(al2, bl7)) | 0), - (mid = (mid + Math.imul(al2, bh7)) | 0), - (mid = (mid + Math.imul(ah2, bl7)) | 0), - (hi = (hi + Math.imul(ah2, bh7)) | 0), - (lo = (lo + Math.imul(al1, bl8)) | 0), - (mid = (mid + Math.imul(al1, bh8)) | 0), - (mid = (mid + Math.imul(ah1, bl8)) | 0), - (hi = (hi + Math.imul(ah1, bh8)) | 0), - (lo = (lo + Math.imul(al0, bl9)) | 0), - (mid = (mid + Math.imul(al0, bh9)) | 0), - (mid = (mid + Math.imul(ah0, bl9)) | 0), - (hi = (hi + Math.imul(ah0, bh9)) | 0); - var w9 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0), - (w9 &= 67108863), - (lo = Math.imul(al9, bl1)), - (mid = Math.imul(al9, bh1)), - (mid = (mid + Math.imul(ah9, bl1)) | 0), - (hi = Math.imul(ah9, bh1)), - (lo = (lo + Math.imul(al8, bl2)) | 0), - (mid = (mid + Math.imul(al8, bh2)) | 0), - (mid = (mid + Math.imul(ah8, bl2)) | 0), - (hi = (hi + Math.imul(ah8, bh2)) | 0), - (lo = (lo + Math.imul(al7, bl3)) | 0), - (mid = (mid + Math.imul(al7, bh3)) | 0), - (mid = (mid + Math.imul(ah7, bl3)) | 0), - (hi = (hi + Math.imul(ah7, bh3)) | 0), - (lo = (lo + Math.imul(al6, bl4)) | 0), - (mid = (mid + Math.imul(al6, bh4)) | 0), - (mid = (mid + Math.imul(ah6, bl4)) | 0), - (hi = (hi + Math.imul(ah6, bh4)) | 0), - (lo = (lo + Math.imul(al5, bl5)) | 0), - (mid = (mid + Math.imul(al5, bh5)) | 0), - (mid = (mid + Math.imul(ah5, bl5)) | 0), - (hi = (hi + Math.imul(ah5, bh5)) | 0), - (lo = (lo + Math.imul(al4, bl6)) | 0), - (mid = (mid + Math.imul(al4, bh6)) | 0), - (mid = (mid + Math.imul(ah4, bl6)) | 0), - (hi = (hi + Math.imul(ah4, bh6)) | 0), - (lo = (lo + Math.imul(al3, bl7)) | 0), - (mid = (mid + Math.imul(al3, bh7)) | 0), - (mid = (mid + Math.imul(ah3, bl7)) | 0), - (hi = (hi + Math.imul(ah3, bh7)) | 0), - (lo = (lo + Math.imul(al2, bl8)) | 0), - (mid = (mid + Math.imul(al2, bh8)) | 0), - (mid = (mid + Math.imul(ah2, bl8)) | 0), - (hi = (hi + Math.imul(ah2, bh8)) | 0), - (lo = (lo + Math.imul(al1, bl9)) | 0), - (mid = (mid + Math.imul(al1, bh9)) | 0), - (mid = (mid + Math.imul(ah1, bl9)) | 0), - (hi = (hi + Math.imul(ah1, bh9)) | 0); - var w10 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0), - (w10 &= 67108863), - (lo = Math.imul(al9, bl2)), - (mid = Math.imul(al9, bh2)), - (mid = (mid + Math.imul(ah9, bl2)) | 0), - (hi = Math.imul(ah9, bh2)), - (lo = (lo + Math.imul(al8, bl3)) | 0), - (mid = (mid + Math.imul(al8, bh3)) | 0), - (mid = (mid + Math.imul(ah8, bl3)) | 0), - (hi = (hi + Math.imul(ah8, bh3)) | 0), - (lo = (lo + Math.imul(al7, bl4)) | 0), - (mid = (mid + Math.imul(al7, bh4)) | 0), - (mid = (mid + Math.imul(ah7, bl4)) | 0), - (hi = (hi + Math.imul(ah7, bh4)) | 0), - (lo = (lo + Math.imul(al6, bl5)) | 0), - (mid = (mid + Math.imul(al6, bh5)) | 0), - (mid = (mid + Math.imul(ah6, bl5)) | 0), - (hi = (hi + Math.imul(ah6, bh5)) | 0), - (lo = (lo + Math.imul(al5, bl6)) | 0), - (mid = (mid + Math.imul(al5, bh6)) | 0), - (mid = (mid + Math.imul(ah5, bl6)) | 0), - (hi = (hi + Math.imul(ah5, bh6)) | 0), - (lo = (lo + Math.imul(al4, bl7)) | 0), - (mid = (mid + Math.imul(al4, bh7)) | 0), - (mid = (mid + Math.imul(ah4, bl7)) | 0), - (hi = (hi + Math.imul(ah4, bh7)) | 0), - (lo = (lo + Math.imul(al3, bl8)) | 0), - (mid = (mid + Math.imul(al3, bh8)) | 0), - (mid = (mid + Math.imul(ah3, bl8)) | 0), - (hi = (hi + Math.imul(ah3, bh8)) | 0), - (lo = (lo + Math.imul(al2, bl9)) | 0), - (mid = (mid + Math.imul(al2, bh9)) | 0), - (mid = (mid + Math.imul(ah2, bl9)) | 0), - (hi = (hi + Math.imul(ah2, bh9)) | 0); - var w11 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0), - (w11 &= 67108863), - (lo = Math.imul(al9, bl3)), - (mid = Math.imul(al9, bh3)), - (mid = (mid + Math.imul(ah9, bl3)) | 0), - (hi = Math.imul(ah9, bh3)), - (lo = (lo + Math.imul(al8, bl4)) | 0), - (mid = (mid + Math.imul(al8, bh4)) | 0), - (mid = (mid + Math.imul(ah8, bl4)) | 0), - (hi = (hi + Math.imul(ah8, bh4)) | 0), - (lo = (lo + Math.imul(al7, bl5)) | 0), - (mid = (mid + Math.imul(al7, bh5)) | 0), - (mid = (mid + Math.imul(ah7, bl5)) | 0), - (hi = (hi + Math.imul(ah7, bh5)) | 0), - (lo = (lo + Math.imul(al6, bl6)) | 0), - (mid = (mid + Math.imul(al6, bh6)) | 0), - (mid = (mid + Math.imul(ah6, bl6)) | 0), - (hi = (hi + Math.imul(ah6, bh6)) | 0), - (lo = (lo + Math.imul(al5, bl7)) | 0), - (mid = (mid + Math.imul(al5, bh7)) | 0), - (mid = (mid + Math.imul(ah5, bl7)) | 0), - (hi = (hi + Math.imul(ah5, bh7)) | 0), - (lo = (lo + Math.imul(al4, bl8)) | 0), - (mid = (mid + Math.imul(al4, bh8)) | 0), - (mid = (mid + Math.imul(ah4, bl8)) | 0), - (hi = (hi + Math.imul(ah4, bh8)) | 0), - (lo = (lo + Math.imul(al3, bl9)) | 0), - (mid = (mid + Math.imul(al3, bh9)) | 0), - (mid = (mid + Math.imul(ah3, bl9)) | 0), - (hi = (hi + Math.imul(ah3, bh9)) | 0); - var w12 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0), - (w12 &= 67108863), - (lo = Math.imul(al9, bl4)), - (mid = Math.imul(al9, bh4)), - (mid = (mid + Math.imul(ah9, bl4)) | 0), - (hi = Math.imul(ah9, bh4)), - (lo = (lo + Math.imul(al8, bl5)) | 0), - (mid = (mid + Math.imul(al8, bh5)) | 0), - (mid = (mid + Math.imul(ah8, bl5)) | 0), - (hi = (hi + Math.imul(ah8, bh5)) | 0), - (lo = (lo + Math.imul(al7, bl6)) | 0), - (mid = (mid + Math.imul(al7, bh6)) | 0), - (mid = (mid + Math.imul(ah7, bl6)) | 0), - (hi = (hi + Math.imul(ah7, bh6)) | 0), - (lo = (lo + Math.imul(al6, bl7)) | 0), - (mid = (mid + Math.imul(al6, bh7)) | 0), - (mid = (mid + Math.imul(ah6, bl7)) | 0), - (hi = (hi + Math.imul(ah6, bh7)) | 0), - (lo = (lo + Math.imul(al5, bl8)) | 0), - (mid = (mid + Math.imul(al5, bh8)) | 0), - (mid = (mid + Math.imul(ah5, bl8)) | 0), - (hi = (hi + Math.imul(ah5, bh8)) | 0), - (lo = (lo + Math.imul(al4, bl9)) | 0), - (mid = (mid + Math.imul(al4, bh9)) | 0), - (mid = (mid + Math.imul(ah4, bl9)) | 0), - (hi = (hi + Math.imul(ah4, bh9)) | 0); - var w13 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0), - (w13 &= 67108863), - (lo = Math.imul(al9, bl5)), - (mid = Math.imul(al9, bh5)), - (mid = (mid + Math.imul(ah9, bl5)) | 0), - (hi = Math.imul(ah9, bh5)), - (lo = (lo + Math.imul(al8, bl6)) | 0), - (mid = (mid + Math.imul(al8, bh6)) | 0), - (mid = (mid + Math.imul(ah8, bl6)) | 0), - (hi = (hi + Math.imul(ah8, bh6)) | 0), - (lo = (lo + Math.imul(al7, bl7)) | 0), - (mid = (mid + Math.imul(al7, bh7)) | 0), - (mid = (mid + Math.imul(ah7, bl7)) | 0), - (hi = (hi + Math.imul(ah7, bh7)) | 0), - (lo = (lo + Math.imul(al6, bl8)) | 0), - (mid = (mid + Math.imul(al6, bh8)) | 0), - (mid = (mid + Math.imul(ah6, bl8)) | 0), - (hi = (hi + Math.imul(ah6, bh8)) | 0), - (lo = (lo + Math.imul(al5, bl9)) | 0), - (mid = (mid + Math.imul(al5, bh9)) | 0), - (mid = (mid + Math.imul(ah5, bl9)) | 0), - (hi = (hi + Math.imul(ah5, bh9)) | 0); - var w14 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0), - (w14 &= 67108863), - (lo = Math.imul(al9, bl6)), - (mid = Math.imul(al9, bh6)), - (mid = (mid + Math.imul(ah9, bl6)) | 0), - (hi = Math.imul(ah9, bh6)), - (lo = (lo + Math.imul(al8, bl7)) | 0), - (mid = (mid + Math.imul(al8, bh7)) | 0), - (mid = (mid + Math.imul(ah8, bl7)) | 0), - (hi = (hi + Math.imul(ah8, bh7)) | 0), - (lo = (lo + Math.imul(al7, bl8)) | 0), - (mid = (mid + Math.imul(al7, bh8)) | 0), - (mid = (mid + Math.imul(ah7, bl8)) | 0), - (hi = (hi + Math.imul(ah7, bh8)) | 0), - (lo = (lo + Math.imul(al6, bl9)) | 0), - (mid = (mid + Math.imul(al6, bh9)) | 0), - (mid = (mid + Math.imul(ah6, bl9)) | 0), - (hi = (hi + Math.imul(ah6, bh9)) | 0); - var w15 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0), - (w15 &= 67108863), - (lo = Math.imul(al9, bl7)), - (mid = Math.imul(al9, bh7)), - (mid = (mid + Math.imul(ah9, bl7)) | 0), - (hi = Math.imul(ah9, bh7)), - (lo = (lo + Math.imul(al8, bl8)) | 0), - (mid = (mid + Math.imul(al8, bh8)) | 0), - (mid = (mid + Math.imul(ah8, bl8)) | 0), - (hi = (hi + Math.imul(ah8, bh8)) | 0), - (lo = (lo + Math.imul(al7, bl9)) | 0), - (mid = (mid + Math.imul(al7, bh9)) | 0), - (mid = (mid + Math.imul(ah7, bl9)) | 0), - (hi = (hi + Math.imul(ah7, bh9)) | 0); - var w16 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0), - (w16 &= 67108863), - (lo = Math.imul(al9, bl8)), - (mid = Math.imul(al9, bh8)), - (mid = (mid + Math.imul(ah9, bl8)) | 0), - (hi = Math.imul(ah9, bh8)), - (lo = (lo + Math.imul(al8, bl9)) | 0), - (mid = (mid + Math.imul(al8, bh9)) | 0), - (mid = (mid + Math.imul(ah8, bl9)) | 0), - (hi = (hi + Math.imul(ah8, bh9)) | 0); - var w17 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0), - (w17 &= 67108863), - (lo = Math.imul(al9, bl9)), - (mid = Math.imul(al9, bh9)), - (mid = (mid + Math.imul(ah9, bl9)) | 0), - (hi = Math.imul(ah9, bh9)); - var w18 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - return ( - (c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0), - (w18 &= 67108863), - (o[0] = w0), - (o[1] = w1), - (o[2] = w2), - (o[3] = w3), - (o[4] = w4), - (o[5] = w5), - (o[6] = w6), - (o[7] = w7), - (o[8] = w8), - (o[9] = w9), - (o[10] = w10), - (o[11] = w11), - (o[12] = w12), - (o[13] = w13), - (o[14] = w14), - (o[15] = w15), - (o[16] = w16), - (o[17] = w17), - (o[18] = w18), - c !== 0 && ((o[19] = c), out.length++), - out - ); - }; - Math.imul || (comb10MulTo = smallMulTo); - function bigMulTo(self2, num, out) { - (out.negative = num.negative ^ self2.negative), (out.length = self2.length + num.length); - for (var carry = 0, hncarry = 0, k = 0; k < out.length - 1; k++) { - var ncarry = hncarry; - hncarry = 0; - for ( - var rword = carry & 67108863, maxJ = Math.min(k, num.length - 1), j = Math.max(0, k - self2.length + 1); - j <= maxJ; - j++ - ) { - var i = k - j, - a = self2.words[i] | 0, - b = num.words[j] | 0, - r = a * b, - lo = r & 67108863; - (ncarry = (ncarry + ((r / 67108864) | 0)) | 0), - (lo = (lo + rword) | 0), - (rword = lo & 67108863), - (ncarry = (ncarry + (lo >>> 26)) | 0), - (hncarry += ncarry >>> 26), - (ncarry &= 67108863); - } - (out.words[k] = rword), (carry = ncarry), (ncarry = hncarry); - } - return carry !== 0 ? (out.words[k] = carry) : out.length--, out.strip(); - } - function jumboMulTo(self2, num, out) { - var fftm = new FFTM(); - return fftm.mulp(self2, num, out); - } - BN.prototype.mulTo = function (num, out) { - var res, - len = this.length + num.length; - return ( - this.length === 10 && num.length === 10 - ? (res = comb10MulTo(this, num, out)) - : len < 63 - ? (res = smallMulTo(this, num, out)) - : len < 1024 - ? (res = bigMulTo(this, num, out)) - : (res = jumboMulTo(this, num, out)), - res - ); - }; - function FFTM(x, y) { - (this.x = x), (this.y = y); - } - (FFTM.prototype.makeRBT = function (N) { - for (var t = new Array(N), l = BN.prototype._countBits(N) - 1, i = 0; i < N; i++) t[i] = this.revBin(i, l, N); - return t; - }), - (FFTM.prototype.revBin = function (x, l, N) { - if (x === 0 || x === N - 1) return x; - for (var rb = 0, i = 0; i < l; i++) (rb |= (x & 1) << (l - i - 1)), (x >>= 1); - return rb; - }), - (FFTM.prototype.permute = function (rbt, rws, iws, rtws, itws, N) { - for (var i = 0; i < N; i++) (rtws[i] = rws[rbt[i]]), (itws[i] = iws[rbt[i]]); - }), - (FFTM.prototype.transform = function (rws, iws, rtws, itws, N, rbt) { - this.permute(rbt, rws, iws, rtws, itws, N); - for (var s = 1; s < N; s <<= 1) - for ( - var l = s << 1, rtwdf = Math.cos((2 * Math.PI) / l), itwdf = Math.sin((2 * Math.PI) / l), p = 0; - p < N; - p += l - ) - for (var rtwdf_ = rtwdf, itwdf_ = itwdf, j = 0; j < s; j++) { - var re = rtws[p + j], - ie = itws[p + j], - ro = rtws[p + j + s], - io = itws[p + j + s], - rx = rtwdf_ * ro - itwdf_ * io; - (io = rtwdf_ * io + itwdf_ * ro), - (ro = rx), - (rtws[p + j] = re + ro), - (itws[p + j] = ie + io), - (rtws[p + j + s] = re - ro), - (itws[p + j + s] = ie - io), - j !== l && - ((rx = rtwdf * rtwdf_ - itwdf * itwdf_), (itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_), (rtwdf_ = rx)); - } - }), - (FFTM.prototype.guessLen13b = function (n, m) { - var N = Math.max(m, n) | 1, - odd = N & 1, - i = 0; - for (N = (N / 2) | 0; N; N = N >>> 1) i++; - return 1 << (i + 1 + odd); - }), - (FFTM.prototype.conjugate = function (rws, iws, N) { - if (!(N <= 1)) - for (var i = 0; i < N / 2; i++) { - var t = rws[i]; - (rws[i] = rws[N - i - 1]), - (rws[N - i - 1] = t), - (t = iws[i]), - (iws[i] = -iws[N - i - 1]), - (iws[N - i - 1] = -t); - } - }), - (FFTM.prototype.normalize13b = function (ws, N) { - for (var carry = 0, i = 0; i < N / 2; i++) { - var w = Math.round(ws[2 * i + 1] / N) * 8192 + Math.round(ws[2 * i] / N) + carry; - (ws[i] = w & 67108863), w < 67108864 ? (carry = 0) : (carry = (w / 67108864) | 0); - } - return ws; - }), - (FFTM.prototype.convert13b = function (ws, len, rws, N) { - for (var carry = 0, i = 0; i < len; i++) - (carry = carry + (ws[i] | 0)), - (rws[2 * i] = carry & 8191), - (carry = carry >>> 13), - (rws[2 * i + 1] = carry & 8191), - (carry = carry >>> 13); - for (i = 2 * len; i < N; ++i) rws[i] = 0; - assert(carry === 0), assert((carry & -8192) === 0); - }), - (FFTM.prototype.stub = function (N) { - for (var ph = new Array(N), i = 0; i < N; i++) ph[i] = 0; - return ph; - }), - (FFTM.prototype.mulp = function (x, y, out) { - var N = 2 * this.guessLen13b(x.length, y.length), - rbt = this.makeRBT(N), - _ = this.stub(N), - rws = new Array(N), - rwst = new Array(N), - iwst = new Array(N), - nrws = new Array(N), - nrwst = new Array(N), - niwst = new Array(N), - rmws = out.words; - (rmws.length = N), - this.convert13b(x.words, x.length, rws, N), - this.convert13b(y.words, y.length, nrws, N), - this.transform(rws, _, rwst, iwst, N, rbt), - this.transform(nrws, _, nrwst, niwst, N, rbt); - for (var i = 0; i < N; i++) { - var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i]; - (iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i]), (rwst[i] = rx); - } - return ( - this.conjugate(rwst, iwst, N), - this.transform(rwst, iwst, rmws, _, N, rbt), - this.conjugate(rmws, _, N), - this.normalize13b(rmws, N), - (out.negative = x.negative ^ y.negative), - (out.length = x.length + y.length), - out.strip() - ); - }), - (BN.prototype.mul = function (num) { - var out = new BN(null); - return (out.words = new Array(this.length + num.length)), this.mulTo(num, out); - }), - (BN.prototype.mulf = function (num) { - var out = new BN(null); - return (out.words = new Array(this.length + num.length)), jumboMulTo(this, num, out); - }), - (BN.prototype.imul = function (num) { - return this.clone().mulTo(num, this); - }), - (BN.prototype.imuln = function (num) { - assert(typeof num == "number"), assert(num < 67108864); - for (var carry = 0, i = 0; i < this.length; i++) { - var w = (this.words[i] | 0) * num, - lo = (w & 67108863) + (carry & 67108863); - (carry >>= 26), (carry += (w / 67108864) | 0), (carry += lo >>> 26), (this.words[i] = lo & 67108863); - } - return carry !== 0 && ((this.words[i] = carry), this.length++), this; - }), - (BN.prototype.muln = function (num) { - return this.clone().imuln(num); - }), - (BN.prototype.sqr = function () { - return this.mul(this); - }), - (BN.prototype.isqr = function () { - return this.imul(this.clone()); - }), - (BN.prototype.pow = function (num) { - var w = toBitArray(num); - if (w.length === 0) return new BN(1); - for (var res = this, i = 0; i < w.length && w[i] === 0; i++, res = res.sqr()); - if (++i < w.length) for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) w[i] !== 0 && (res = res.mul(q)); - return res; - }), - (BN.prototype.iushln = function (bits) { - assert(typeof bits == "number" && bits >= 0); - var r = bits % 26, - s = (bits - r) / 26, - carryMask = (67108863 >>> (26 - r)) << (26 - r), - i; - if (r !== 0) { - var carry = 0; - for (i = 0; i < this.length; i++) { - var newCarry = this.words[i] & carryMask, - c = ((this.words[i] | 0) - newCarry) << r; - (this.words[i] = c | carry), (carry = newCarry >>> (26 - r)); - } - carry && ((this.words[i] = carry), this.length++); - } - if (s !== 0) { - for (i = this.length - 1; i >= 0; i--) this.words[i + s] = this.words[i]; - for (i = 0; i < s; i++) this.words[i] = 0; - this.length += s; - } - return this.strip(); - }), - (BN.prototype.ishln = function (bits) { - return assert(this.negative === 0), this.iushln(bits); - }), - (BN.prototype.iushrn = function (bits, hint, extended) { - assert(typeof bits == "number" && bits >= 0); - var h; - hint ? (h = (hint - (hint % 26)) / 26) : (h = 0); - var r = bits % 26, - s = Math.min((bits - r) / 26, this.length), - mask = 67108863 ^ ((67108863 >>> r) << r), - maskedWords = extended; - if (((h -= s), (h = Math.max(0, h)), maskedWords)) { - for (var i = 0; i < s; i++) maskedWords.words[i] = this.words[i]; - maskedWords.length = s; - } - if (s !== 0) - if (this.length > s) for (this.length -= s, i = 0; i < this.length; i++) this.words[i] = this.words[i + s]; - else (this.words[0] = 0), (this.length = 1); - var carry = 0; - for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) { - var word = this.words[i] | 0; - (this.words[i] = (carry << (26 - r)) | (word >>> r)), (carry = word & mask); - } - return ( - maskedWords && carry !== 0 && (maskedWords.words[maskedWords.length++] = carry), - this.length === 0 && ((this.words[0] = 0), (this.length = 1)), - this.strip() - ); - }), - (BN.prototype.ishrn = function (bits, hint, extended) { - return assert(this.negative === 0), this.iushrn(bits, hint, extended); - }), - (BN.prototype.shln = function (bits) { - return this.clone().ishln(bits); - }), - (BN.prototype.ushln = function (bits) { - return this.clone().iushln(bits); - }), - (BN.prototype.shrn = function (bits) { - return this.clone().ishrn(bits); - }), - (BN.prototype.ushrn = function (bits) { - return this.clone().iushrn(bits); - }), - (BN.prototype.testn = function (bit) { - assert(typeof bit == "number" && bit >= 0); - var r = bit % 26, - s = (bit - r) / 26, - q = 1 << r; - if (this.length <= s) return !1; - var w = this.words[s]; - return !!(w & q); - }), - (BN.prototype.imaskn = function (bits) { - assert(typeof bits == "number" && bits >= 0); - var r = bits % 26, - s = (bits - r) / 26; - if ((assert(this.negative === 0, "imaskn works only with positive numbers"), this.length <= s)) return this; - if ((r !== 0 && s++, (this.length = Math.min(s, this.length)), r !== 0)) { - var mask = 67108863 ^ ((67108863 >>> r) << r); - this.words[this.length - 1] &= mask; - } - return this.strip(); - }), - (BN.prototype.maskn = function (bits) { - return this.clone().imaskn(bits); - }), - (BN.prototype.iaddn = function (num) { - return ( - assert(typeof num == "number"), - assert(num < 67108864), - num < 0 - ? this.isubn(-num) - : this.negative !== 0 - ? this.length === 1 && (this.words[0] | 0) < num - ? ((this.words[0] = num - (this.words[0] | 0)), (this.negative = 0), this) - : ((this.negative = 0), this.isubn(num), (this.negative = 1), this) - : this._iaddn(num) - ); - }), - (BN.prototype._iaddn = function (num) { - this.words[0] += num; - for (var i = 0; i < this.length && this.words[i] >= 67108864; i++) - (this.words[i] -= 67108864), i === this.length - 1 ? (this.words[i + 1] = 1) : this.words[i + 1]++; - return (this.length = Math.max(this.length, i + 1)), this; - }), - (BN.prototype.isubn = function (num) { - if ((assert(typeof num == "number"), assert(num < 67108864), num < 0)) return this.iaddn(-num); - if (this.negative !== 0) return (this.negative = 0), this.iaddn(num), (this.negative = 1), this; - if (((this.words[0] -= num), this.length === 1 && this.words[0] < 0)) - (this.words[0] = -this.words[0]), (this.negative = 1); - else - for (var i = 0; i < this.length && this.words[i] < 0; i++) - (this.words[i] += 67108864), (this.words[i + 1] -= 1); - return this.strip(); - }), - (BN.prototype.addn = function (num) { - return this.clone().iaddn(num); - }), - (BN.prototype.subn = function (num) { - return this.clone().isubn(num); - }), - (BN.prototype.iabs = function () { - return (this.negative = 0), this; - }), - (BN.prototype.abs = function () { - return this.clone().iabs(); - }), - (BN.prototype._ishlnsubmul = function (num, mul, shift) { - var len = num.length + shift, - i; - this._expand(len); - var w, - carry = 0; - for (i = 0; i < num.length; i++) { - w = (this.words[i + shift] | 0) + carry; - var right = (num.words[i] | 0) * mul; - (w -= right & 67108863), - (carry = (w >> 26) - ((right / 67108864) | 0)), - (this.words[i + shift] = w & 67108863); - } - for (; i < this.length - shift; i++) - (w = (this.words[i + shift] | 0) + carry), (carry = w >> 26), (this.words[i + shift] = w & 67108863); - if (carry === 0) return this.strip(); - for (assert(carry === -1), carry = 0, i = 0; i < this.length; i++) - (w = -(this.words[i] | 0) + carry), (carry = w >> 26), (this.words[i] = w & 67108863); - return (this.negative = 1), this.strip(); - }), - (BN.prototype._wordDiv = function (num, mode) { - var shift = this.length - num.length, - a = this.clone(), - b = num, - bhi = b.words[b.length - 1] | 0, - bhiBits = this._countBits(bhi); - (shift = 26 - bhiBits), - shift !== 0 && ((b = b.ushln(shift)), a.iushln(shift), (bhi = b.words[b.length - 1] | 0)); - var m = a.length - b.length, - q; - if (mode !== "mod") { - (q = new BN(null)), (q.length = m + 1), (q.words = new Array(q.length)); - for (var i = 0; i < q.length; i++) q.words[i] = 0; - } - var diff = a.clone()._ishlnsubmul(b, 1, m); - diff.negative === 0 && ((a = diff), q && (q.words[m] = 1)); - for (var j = m - 1; j >= 0; j--) { - var qj = (a.words[b.length + j] | 0) * 67108864 + (a.words[b.length + j - 1] | 0); - for (qj = Math.min((qj / bhi) | 0, 67108863), a._ishlnsubmul(b, qj, j); a.negative !== 0; ) - qj--, (a.negative = 0), a._ishlnsubmul(b, 1, j), a.isZero() || (a.negative ^= 1); - q && (q.words[j] = qj); - } - return ( - q && q.strip(), - a.strip(), - mode !== "div" && shift !== 0 && a.iushrn(shift), - { - div: q || null, - mod: a, - } - ); - }), - (BN.prototype.divmod = function (num, mode, positive) { - if ((assert(!num.isZero()), this.isZero())) - return { - div: new BN(0), - mod: new BN(0), - }; - var div, mod, res; - return this.negative !== 0 && num.negative === 0 - ? ((res = this.neg().divmod(num, mode)), - mode !== "mod" && (div = res.div.neg()), - mode !== "div" && ((mod = res.mod.neg()), positive && mod.negative !== 0 && mod.iadd(num)), - { - div, - mod, - }) - : this.negative === 0 && num.negative !== 0 - ? ((res = this.divmod(num.neg(), mode)), - mode !== "mod" && (div = res.div.neg()), - { - div, - mod: res.mod, - }) - : (this.negative & num.negative) !== 0 - ? ((res = this.neg().divmod(num.neg(), mode)), - mode !== "div" && ((mod = res.mod.neg()), positive && mod.negative !== 0 && mod.isub(num)), - { - div: res.div, - mod, - }) - : num.length > this.length || this.cmp(num) < 0 - ? { - div: new BN(0), - mod: this, - } - : num.length === 1 - ? mode === "div" - ? { - div: this.divn(num.words[0]), - mod: null, - } - : mode === "mod" - ? { - div: null, - mod: new BN(this.modn(num.words[0])), - } - : { - div: this.divn(num.words[0]), - mod: new BN(this.modn(num.words[0])), - } - : this._wordDiv(num, mode); - }), - (BN.prototype.div = function (num) { - return this.divmod(num, "div", !1).div; - }), - (BN.prototype.mod = function (num) { - return this.divmod(num, "mod", !1).mod; - }), - (BN.prototype.umod = function (num) { - return this.divmod(num, "mod", !0).mod; - }), - (BN.prototype.divRound = function (num) { - var dm = this.divmod(num); - if (dm.mod.isZero()) return dm.div; - var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod, - half = num.ushrn(1), - r2 = num.andln(1), - cmp = mod.cmp(half); - return cmp < 0 || (r2 === 1 && cmp === 0) - ? dm.div - : dm.div.negative !== 0 - ? dm.div.isubn(1) - : dm.div.iaddn(1); - }), - (BN.prototype.modn = function (num) { - assert(num <= 67108863); - for (var p = (1 << 26) % num, acc = 0, i = this.length - 1; i >= 0; i--) - acc = (p * acc + (this.words[i] | 0)) % num; - return acc; - }), - (BN.prototype.idivn = function (num) { - assert(num <= 67108863); - for (var carry = 0, i = this.length - 1; i >= 0; i--) { - var w = (this.words[i] | 0) + carry * 67108864; - (this.words[i] = (w / num) | 0), (carry = w % num); - } - return this.strip(); - }), - (BN.prototype.divn = function (num) { - return this.clone().idivn(num); - }), - (BN.prototype.egcd = function (p) { - assert(p.negative === 0), assert(!p.isZero()); - var x = this, - y = p.clone(); - x.negative !== 0 ? (x = x.umod(p)) : (x = x.clone()); - for (var A = new BN(1), B = new BN(0), C = new BN(0), D = new BN(1), g = 0; x.isEven() && y.isEven(); ) - x.iushrn(1), y.iushrn(1), ++g; - for (var yp = y.clone(), xp = x.clone(); !x.isZero(); ) { - for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1); - if (i > 0) - for (x.iushrn(i); i-- > 0; ) - (A.isOdd() || B.isOdd()) && (A.iadd(yp), B.isub(xp)), A.iushrn(1), B.iushrn(1); - for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); - if (j > 0) - for (y.iushrn(j); j-- > 0; ) - (C.isOdd() || D.isOdd()) && (C.iadd(yp), D.isub(xp)), C.iushrn(1), D.iushrn(1); - x.cmp(y) >= 0 ? (x.isub(y), A.isub(C), B.isub(D)) : (y.isub(x), C.isub(A), D.isub(B)); - } - return { - a: C, - b: D, - gcd: y.iushln(g), - }; - }), - (BN.prototype._invmp = function (p) { - assert(p.negative === 0), assert(!p.isZero()); - var a = this, - b = p.clone(); - a.negative !== 0 ? (a = a.umod(p)) : (a = a.clone()); - for (var x1 = new BN(1), x2 = new BN(0), delta = b.clone(); a.cmpn(1) > 0 && b.cmpn(1) > 0; ) { - for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1); - if (i > 0) for (a.iushrn(i); i-- > 0; ) x1.isOdd() && x1.iadd(delta), x1.iushrn(1); - for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); - if (j > 0) for (b.iushrn(j); j-- > 0; ) x2.isOdd() && x2.iadd(delta), x2.iushrn(1); - a.cmp(b) >= 0 ? (a.isub(b), x1.isub(x2)) : (b.isub(a), x2.isub(x1)); - } - var res; - return a.cmpn(1) === 0 ? (res = x1) : (res = x2), res.cmpn(0) < 0 && res.iadd(p), res; - }), - (BN.prototype.gcd = function (num) { - if (this.isZero()) return num.abs(); - if (num.isZero()) return this.abs(); - var a = this.clone(), - b = num.clone(); - (a.negative = 0), (b.negative = 0); - for (var shift = 0; a.isEven() && b.isEven(); shift++) a.iushrn(1), b.iushrn(1); - do { - for (; a.isEven(); ) a.iushrn(1); - for (; b.isEven(); ) b.iushrn(1); - var r = a.cmp(b); - if (r < 0) { - var t = a; - (a = b), (b = t); - } else if (r === 0 || b.cmpn(1) === 0) break; - a.isub(b); - } while (!0); - return b.iushln(shift); - }), - (BN.prototype.invm = function (num) { - return this.egcd(num).a.umod(num); - }), - (BN.prototype.isEven = function () { - return (this.words[0] & 1) === 0; - }), - (BN.prototype.isOdd = function () { - return (this.words[0] & 1) === 1; - }), - (BN.prototype.andln = function (num) { - return this.words[0] & num; - }), - (BN.prototype.bincn = function (bit) { - assert(typeof bit == "number"); - var r = bit % 26, - s = (bit - r) / 26, - q = 1 << r; - if (this.length <= s) return this._expand(s + 1), (this.words[s] |= q), this; - for (var carry = q, i = s; carry !== 0 && i < this.length; i++) { - var w = this.words[i] | 0; - (w += carry), (carry = w >>> 26), (w &= 67108863), (this.words[i] = w); - } - return carry !== 0 && ((this.words[i] = carry), this.length++), this; - }), - (BN.prototype.isZero = function () { - return this.length === 1 && this.words[0] === 0; - }), - (BN.prototype.cmpn = function (num) { - var negative = num < 0; - if (this.negative !== 0 && !negative) return -1; - if (this.negative === 0 && negative) return 1; - this.strip(); - var res; - if (this.length > 1) res = 1; - else { - negative && (num = -num), assert(num <= 67108863, "Number is too big"); - var w = this.words[0] | 0; - res = w === num ? 0 : w < num ? -1 : 1; - } - return this.negative !== 0 ? -res | 0 : res; - }), - (BN.prototype.cmp = function (num) { - if (this.negative !== 0 && num.negative === 0) return -1; - if (this.negative === 0 && num.negative !== 0) return 1; - var res = this.ucmp(num); - return this.negative !== 0 ? -res | 0 : res; - }), - (BN.prototype.ucmp = function (num) { - if (this.length > num.length) return 1; - if (this.length < num.length) return -1; - for (var res = 0, i = this.length - 1; i >= 0; i--) { - var a = this.words[i] | 0, - b = num.words[i] | 0; - if (a !== b) { - a < b ? (res = -1) : a > b && (res = 1); - break; - } - } - return res; - }), - (BN.prototype.gtn = function (num) { - return this.cmpn(num) === 1; - }), - (BN.prototype.gt = function (num) { - return this.cmp(num) === 1; - }), - (BN.prototype.gten = function (num) { - return this.cmpn(num) >= 0; - }), - (BN.prototype.gte = function (num) { - return this.cmp(num) >= 0; - }), - (BN.prototype.ltn = function (num) { - return this.cmpn(num) === -1; - }), - (BN.prototype.lt = function (num) { - return this.cmp(num) === -1; - }), - (BN.prototype.lten = function (num) { - return this.cmpn(num) <= 0; - }), - (BN.prototype.lte = function (num) { - return this.cmp(num) <= 0; - }), - (BN.prototype.eqn = function (num) { - return this.cmpn(num) === 0; - }), - (BN.prototype.eq = function (num) { - return this.cmp(num) === 0; - }), - (BN.red = function (num) { - return new Red(num); - }), - (BN.prototype.toRed = function (ctx) { - return ( - assert(!this.red, "Already a number in reduction context"), - assert(this.negative === 0, "red works only with positives"), - ctx.convertTo(this)._forceRed(ctx) - ); - }), - (BN.prototype.fromRed = function () { - return assert(this.red, "fromRed works only with numbers in reduction context"), this.red.convertFrom(this); - }), - (BN.prototype._forceRed = function (ctx) { - return (this.red = ctx), this; - }), - (BN.prototype.forceRed = function (ctx) { - return assert(!this.red, "Already a number in reduction context"), this._forceRed(ctx); - }), - (BN.prototype.redAdd = function (num) { - return assert(this.red, "redAdd works only with red numbers"), this.red.add(this, num); - }), - (BN.prototype.redIAdd = function (num) { - return assert(this.red, "redIAdd works only with red numbers"), this.red.iadd(this, num); - }), - (BN.prototype.redSub = function (num) { - return assert(this.red, "redSub works only with red numbers"), this.red.sub(this, num); - }), - (BN.prototype.redISub = function (num) { - return assert(this.red, "redISub works only with red numbers"), this.red.isub(this, num); - }), - (BN.prototype.redShl = function (num) { - return assert(this.red, "redShl works only with red numbers"), this.red.shl(this, num); - }), - (BN.prototype.redMul = function (num) { - return ( - assert(this.red, "redMul works only with red numbers"), - this.red._verify2(this, num), - this.red.mul(this, num) - ); - }), - (BN.prototype.redIMul = function (num) { - return ( - assert(this.red, "redMul works only with red numbers"), - this.red._verify2(this, num), - this.red.imul(this, num) - ); - }), - (BN.prototype.redSqr = function () { - return assert(this.red, "redSqr works only with red numbers"), this.red._verify1(this), this.red.sqr(this); - }), - (BN.prototype.redISqr = function () { - return assert(this.red, "redISqr works only with red numbers"), this.red._verify1(this), this.red.isqr(this); - }), - (BN.prototype.redSqrt = function () { - return assert(this.red, "redSqrt works only with red numbers"), this.red._verify1(this), this.red.sqrt(this); - }), - (BN.prototype.redInvm = function () { - return assert(this.red, "redInvm works only with red numbers"), this.red._verify1(this), this.red.invm(this); - }), - (BN.prototype.redNeg = function () { - return assert(this.red, "redNeg works only with red numbers"), this.red._verify1(this), this.red.neg(this); - }), - (BN.prototype.redPow = function (num) { - return assert(this.red && !num.red, "redPow(normalNum)"), this.red._verify1(this), this.red.pow(this, num); - }); - var primes = { - k256: null, - p224: null, - p192: null, - p25519: null, - }; - function MPrime(name, p) { - (this.name = name), - (this.p = new BN(p, 16)), - (this.n = this.p.bitLength()), - (this.k = new BN(1).iushln(this.n).isub(this.p)), - (this.tmp = this._tmp()); - } - (MPrime.prototype._tmp = function () { - var tmp = new BN(null); - return (tmp.words = new Array(Math.ceil(this.n / 13))), tmp; - }), - (MPrime.prototype.ireduce = function (num) { - var r = num, - rlen; - do this.split(r, this.tmp), (r = this.imulK(r)), (r = r.iadd(this.tmp)), (rlen = r.bitLength()); - while (rlen > this.n); - var cmp = rlen < this.n ? -1 : r.ucmp(this.p); - return ( - cmp === 0 - ? ((r.words[0] = 0), (r.length = 1)) - : cmp > 0 - ? r.isub(this.p) - : r.strip !== void 0 - ? r.strip() - : r._strip(), - r - ); - }), - (MPrime.prototype.split = function (input, out) { - input.iushrn(this.n, 0, out); - }), - (MPrime.prototype.imulK = function (num) { - return num.imul(this.k); - }); - function K256() { - MPrime.call(this, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); - } - inherits(K256, MPrime), - (K256.prototype.split = function (input, output) { - for (var mask = 4194303, outLen = Math.min(input.length, 9), i = 0; i < outLen; i++) - output.words[i] = input.words[i]; - if (((output.length = outLen), input.length <= 9)) { - (input.words[0] = 0), (input.length = 1); - return; - } - var prev = input.words[9]; - for (output.words[output.length++] = prev & mask, i = 10; i < input.length; i++) { - var next = input.words[i] | 0; - (input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22)), (prev = next); - } - (prev >>>= 22), - (input.words[i - 10] = prev), - prev === 0 && input.length > 10 ? (input.length -= 10) : (input.length -= 9); - }), - (K256.prototype.imulK = function (num) { - (num.words[num.length] = 0), (num.words[num.length + 1] = 0), (num.length += 2); - for (var lo = 0, i = 0; i < num.length; i++) { - var w = num.words[i] | 0; - (lo += w * 977), (num.words[i] = lo & 67108863), (lo = w * 64 + ((lo / 67108864) | 0)); - } - return ( - num.words[num.length - 1] === 0 && (num.length--, num.words[num.length - 1] === 0 && num.length--), num - ); - }); - function P224() { - MPrime.call(this, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); - } - inherits(P224, MPrime); - function P192() { - MPrime.call(this, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); - } - inherits(P192, MPrime); - function P25519() { - MPrime.call(this, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); - } - inherits(P25519, MPrime), - (P25519.prototype.imulK = function (num) { - for (var carry = 0, i = 0; i < num.length; i++) { - var hi = (num.words[i] | 0) * 19 + carry, - lo = hi & 67108863; - (hi >>>= 26), (num.words[i] = lo), (carry = hi); - } - return carry !== 0 && (num.words[num.length++] = carry), num; - }), - (BN._prime = function (name) { - if (primes[name]) return primes[name]; - var prime2; - if (name === "k256") prime2 = new K256(); - else if (name === "p224") prime2 = new P224(); - else if (name === "p192") prime2 = new P192(); - else if (name === "p25519") prime2 = new P25519(); - else throw new Error("Unknown prime " + name); - return (primes[name] = prime2), prime2; - }); - function Red(m) { - if (typeof m == "string") { - var prime = BN._prime(m); - (this.m = prime.p), (this.prime = prime); - } else assert(m.gtn(1), "modulus must be greater than 1"), (this.m = m), (this.prime = null); - } - (Red.prototype._verify1 = function (a) { - assert(a.negative === 0, "red works only with positives"), assert(a.red, "red works only with red numbers"); - }), - (Red.prototype._verify2 = function (a, b) { - assert((a.negative | b.negative) === 0, "red works only with positives"), - assert(a.red && a.red === b.red, "red works only with red numbers"); - }), - (Red.prototype.imod = function (a) { - return this.prime ? this.prime.ireduce(a)._forceRed(this) : a.umod(this.m)._forceRed(this); - }), - (Red.prototype.neg = function (a) { - return a.isZero() ? a.clone() : this.m.sub(a)._forceRed(this); - }), - (Red.prototype.add = function (a, b) { - this._verify2(a, b); - var res = a.add(b); - return res.cmp(this.m) >= 0 && res.isub(this.m), res._forceRed(this); - }), - (Red.prototype.iadd = function (a, b) { - this._verify2(a, b); - var res = a.iadd(b); - return res.cmp(this.m) >= 0 && res.isub(this.m), res; - }), - (Red.prototype.sub = function (a, b) { - this._verify2(a, b); - var res = a.sub(b); - return res.cmpn(0) < 0 && res.iadd(this.m), res._forceRed(this); - }), - (Red.prototype.isub = function (a, b) { - this._verify2(a, b); - var res = a.isub(b); - return res.cmpn(0) < 0 && res.iadd(this.m), res; - }), - (Red.prototype.shl = function (a, num) { - return this._verify1(a), this.imod(a.ushln(num)); - }), - (Red.prototype.imul = function (a, b) { - return this._verify2(a, b), this.imod(a.imul(b)); - }), - (Red.prototype.mul = function (a, b) { - return this._verify2(a, b), this.imod(a.mul(b)); - }), - (Red.prototype.isqr = function (a) { - return this.imul(a, a.clone()); - }), - (Red.prototype.sqr = function (a) { - return this.mul(a, a); - }), - (Red.prototype.sqrt = function (a) { - if (a.isZero()) return a.clone(); - var mod3 = this.m.andln(3); - if ((assert(mod3 % 2 === 1), mod3 === 3)) { - var pow = this.m.add(new BN(1)).iushrn(2); - return this.pow(a, pow); - } - for (var q = this.m.subn(1), s = 0; !q.isZero() && q.andln(1) === 0; ) s++, q.iushrn(1); - assert(!q.isZero()); - var one = new BN(1).toRed(this), - nOne = one.redNeg(), - lpow = this.m.subn(1).iushrn(1), - z = this.m.bitLength(); - for (z = new BN(2 * z * z).toRed(this); this.pow(z, lpow).cmp(nOne) !== 0; ) z.redIAdd(nOne); - for ( - var c = this.pow(z, q), r = this.pow(a, q.addn(1).iushrn(1)), t = this.pow(a, q), m = s; - t.cmp(one) !== 0; - - ) { - for (var tmp = t, i = 0; tmp.cmp(one) !== 0; i++) tmp = tmp.redSqr(); - assert(i < m); - var b = this.pow(c, new BN(1).iushln(m - i - 1)); - (r = r.redMul(b)), (c = b.redSqr()), (t = t.redMul(c)), (m = i); - } - return r; - }), - (Red.prototype.invm = function (a) { - var inv = a._invmp(this.m); - return inv.negative !== 0 ? ((inv.negative = 0), this.imod(inv).redNeg()) : this.imod(inv); - }), - (Red.prototype.pow = function (a, num) { - if (num.isZero()) return new BN(1).toRed(this); - if (num.cmpn(1) === 0) return a.clone(); - var windowSize = 4, - wnd = new Array(1 << windowSize); - (wnd[0] = new BN(1).toRed(this)), (wnd[1] = a); - for (var i = 2; i < wnd.length; i++) wnd[i] = this.mul(wnd[i - 1], a); - var res = wnd[0], - current = 0, - currentLen = 0, - start = num.bitLength() % 26; - for (start === 0 && (start = 26), i = num.length - 1; i >= 0; i--) { - for (var word = num.words[i], j = start - 1; j >= 0; j--) { - var bit = (word >> j) & 1; - if ((res !== wnd[0] && (res = this.sqr(res)), bit === 0 && current === 0)) { - currentLen = 0; - continue; - } - (current <<= 1), - (current |= bit), - currentLen++, - !(currentLen !== windowSize && (i !== 0 || j !== 0)) && - ((res = this.mul(res, wnd[current])), (currentLen = 0), (current = 0)); - } - start = 26; - } - return res; - }), - (Red.prototype.convertTo = function (num) { - var r = num.umod(this.m); - return r === num ? r.clone() : r; - }), - (Red.prototype.convertFrom = function (num) { - var res = num.clone(); - return (res.red = null), res; - }), - (BN.mont = function (num) { - return new Mont(num); - }); - function Mont(m) { - Red.call(this, m), - (this.shift = this.m.bitLength()), - this.shift % 26 !== 0 && (this.shift += 26 - (this.shift % 26)), - (this.r = new BN(1).iushln(this.shift)), - (this.r2 = this.imod(this.r.sqr())), - (this.rinv = this.r._invmp(this.m)), - (this.minv = this.rinv.mul(this.r).isubn(1).div(this.m)), - (this.minv = this.minv.umod(this.r)), - (this.minv = this.r.sub(this.minv)); - } - inherits(Mont, Red), - (Mont.prototype.convertTo = function (num) { - return this.imod(num.ushln(this.shift)); - }), - (Mont.prototype.convertFrom = function (num) { - var r = this.imod(num.mul(this.rinv)); - return (r.red = null), r; - }), - (Mont.prototype.imul = function (a, b) { - if (a.isZero() || b.isZero()) return (a.words[0] = 0), (a.length = 1), a; - var t = a.imul(b), - c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), - u = t.isub(c).iushrn(this.shift), - res = u; - return ( - u.cmp(this.m) >= 0 ? (res = u.isub(this.m)) : u.cmpn(0) < 0 && (res = u.iadd(this.m)), res._forceRed(this) - ); - }), - (Mont.prototype.mul = function (a, b) { - if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this); - var t = a.mul(b), - c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), - u = t.isub(c).iushrn(this.shift), - res = u; - return ( - u.cmp(this.m) >= 0 ? (res = u.isub(this.m)) : u.cmpn(0) < 0 && (res = u.iadd(this.m)), res._forceRed(this) - ); - }), - (Mont.prototype.invm = function (a) { - var res = this.imod(a._invmp(this.m).mul(this.r2)); - return res._forceRed(this); - }); - })(typeof module > "u" || module, exports); - }, -}); +var require_bn5 = require_bn; // node_modules/safer-buffer/safer.js var require_safer = __commonJS({ @@ -17538,6 +9537,7 @@ var require_reporter = __commonJS({ errors: [], }; } + Reporter.prototype = {}; exports.Reporter = Reporter; Reporter.prototype.isError = function (obj) { return obj instanceof ReporterError; @@ -17710,6 +9710,7 @@ var require_buffer = __commonJS({ else if (Buffer2.isBuffer(value)) (this.value = value), (this.length = value.length); else return reporter.error("Unsupported type: " + typeof value); } + EncoderBuffer.prototype = {}; exports.EncoderBuffer = EncoderBuffer; EncoderBuffer.isEncoderBuffer = function (data) { return data instanceof EncoderBuffer @@ -17821,6 +9822,7 @@ var require_node = __commonJS({ (state.contains = null), state.parent || ((state.children = []), this._wrap()); } + Node.prototype = {}; module.exports = Node; var stateProps = [ "enc", @@ -18255,6 +10257,7 @@ var require_der2 = __commonJS({ (this.tree = new DERNode()), this.tree._init(entity.body); } + DEREncoder.prototype = {}; module.exports = DEREncoder; DEREncoder.prototype.encode = function (data, reporter) { return this.tree._encode(data, reporter).join(); @@ -18470,6 +10473,7 @@ var require_der3 = __commonJS({ (this.tree = new DERNode()), this.tree._init(entity.body); } + DERDecoder.prototype = {}; module.exports = DERDecoder; DERDecoder.prototype.decode = function (data, options) { return ( @@ -18721,6 +10725,7 @@ var require_api = __commonJS({ function Entity(name, body) { (this.name = name), (this.body = body), (this.decoders = {}), (this.encoders = {}); } + Entity.prototype = {}; Entity.prototype._createNamed = function (Base) { let name = this.name; function Generated(entity) { @@ -19346,12 +11351,12 @@ var require_verify = __commonJS({ // node_modules/browserify-sign/browser/index.js var require_browser8 = __commonJS({ "node_modules/browserify-sign/browser/index.js"(exports, module) { - var Buffer2 = require_safe_buffer().Buffer, - createHash = require_browser2(), - inherits = require_inherits_browser(), - sign = require_sign(), - verify = require_verify(), - algorithms = require_algorithms(); + var Buffer2 = require_safe_buffer().Buffer; + var createHash = require_browser2(); + var inherits = require_inherits_browser(); + var sign = require_sign(); + var verify = require_verify(); + var algorithms = require_algorithms(); Object.keys(algorithms).forEach(function (key) { (algorithms[key].id = Buffer2.from(algorithms[key].id, "hex")), (algorithms[key.toLowerCase()] = algorithms[key]); }); @@ -19411,1991 +11416,7 @@ var require_browser8 = __commonJS({ }); // node_modules/create-ecdh/node_modules/bn.js/lib/bn.js -var require_bn6 = __commonJS({ - "node_modules/create-ecdh/node_modules/bn.js/lib/bn.js"(exports, module) { - (function (module2, exports2) { - "use strict"; - function assert(val, msg) { - if (!val) throw new Error(msg || "Assertion failed"); - } - function inherits(ctor, superCtor) { - ctor.super_ = superCtor; - var TempCtor = function () {}; - (TempCtor.prototype = superCtor.prototype), - (ctor.prototype = new TempCtor()), - (ctor.prototype.constructor = ctor); - } - function BN(number, base, endian) { - if (BN.isBN(number)) return number; - (this.negative = 0), - (this.words = null), - (this.length = 0), - (this.red = null), - number !== null && - ((base === "le" || base === "be") && ((endian = base), (base = 10)), - this._init(number || 0, base || 10, endian || "be")); - } - typeof module2 == "object" ? (module2.exports = BN) : (exports2.BN = BN), (BN.BN = BN), (BN.wordSize = 26); - var Buffer2 = Buffer; - (BN.isBN = function (num) { - return num instanceof BN - ? !0 - : num !== null && - typeof num == "object" && - num.constructor.wordSize === BN.wordSize && - Array.isArray(num.words); - }), - (BN.max = function (left, right) { - return left.cmp(right) > 0 ? left : right; - }), - (BN.min = function (left, right) { - return left.cmp(right) < 0 ? left : right; - }), - (BN.prototype._init = function (number, base, endian) { - if (typeof number == "number") return this._initNumber(number, base, endian); - if (typeof number == "object") return this._initArray(number, base, endian); - base === "hex" && (base = 16), - assert(base === (base | 0) && base >= 2 && base <= 36), - (number = number.toString().replace(/\s+/g, "")); - var start = 0; - number[0] === "-" && (start++, (this.negative = 1)), - start < number.length && - (base === 16 - ? this._parseHex(number, start, endian) - : (this._parseBase(number, base, start), - endian === "le" && this._initArray(this.toArray(), base, endian))); - }), - (BN.prototype._initNumber = function (number, base, endian) { - number < 0 && ((this.negative = 1), (number = -number)), - number < 67108864 - ? ((this.words = [number & 67108863]), (this.length = 1)) - : number < 4503599627370496 - ? ((this.words = [number & 67108863, (number / 67108864) & 67108863]), (this.length = 2)) - : (assert(number < 9007199254740992), - (this.words = [number & 67108863, (number / 67108864) & 67108863, 1]), - (this.length = 3)), - endian === "le" && this._initArray(this.toArray(), base, endian); - }), - (BN.prototype._initArray = function (number, base, endian) { - if ((assert(typeof number.length == "number"), number.length <= 0)) - return (this.words = [0]), (this.length = 1), this; - (this.length = Math.ceil(number.length / 3)), (this.words = new Array(this.length)); - for (var i = 0; i < this.length; i++) this.words[i] = 0; - var j, - w, - off = 0; - if (endian === "be") - for (i = number.length - 1, j = 0; i >= 0; i -= 3) - (w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16)), - (this.words[j] |= (w << off) & 67108863), - (this.words[j + 1] = (w >>> (26 - off)) & 67108863), - (off += 24), - off >= 26 && ((off -= 26), j++); - else if (endian === "le") - for (i = 0, j = 0; i < number.length; i += 3) - (w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16)), - (this.words[j] |= (w << off) & 67108863), - (this.words[j + 1] = (w >>> (26 - off)) & 67108863), - (off += 24), - off >= 26 && ((off -= 26), j++); - return this.strip(); - }); - function parseHex4Bits(string, index) { - var c = string.charCodeAt(index); - return c >= 65 && c <= 70 ? c - 55 : c >= 97 && c <= 102 ? c - 87 : (c - 48) & 15; - } - function parseHexByte(string, lowerBound, index) { - var r = parseHex4Bits(string, index); - return index - 1 >= lowerBound && (r |= parseHex4Bits(string, index - 1) << 4), r; - } - BN.prototype._parseHex = function (number, start, endian) { - (this.length = Math.ceil((number.length - start) / 6)), (this.words = new Array(this.length)); - for (var i = 0; i < this.length; i++) this.words[i] = 0; - var off = 0, - j = 0, - w; - if (endian === "be") - for (i = number.length - 1; i >= start; i -= 2) - (w = parseHexByte(number, start, i) << off), - (this.words[j] |= w & 67108863), - off >= 18 ? ((off -= 18), (j += 1), (this.words[j] |= w >>> 26)) : (off += 8); - else { - var parseLength = number.length - start; - for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) - (w = parseHexByte(number, start, i) << off), - (this.words[j] |= w & 67108863), - off >= 18 ? ((off -= 18), (j += 1), (this.words[j] |= w >>> 26)) : (off += 8); - } - this.strip(); - }; - function parseBase(str, start, end, mul) { - for (var r = 0, len = Math.min(str.length, end), i = start; i < len; i++) { - var c = str.charCodeAt(i) - 48; - (r *= mul), c >= 49 ? (r += c - 49 + 10) : c >= 17 ? (r += c - 17 + 10) : (r += c); - } - return r; - } - (BN.prototype._parseBase = function (number, base, start) { - (this.words = [0]), (this.length = 1); - for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *= base) limbLen++; - limbLen--, (limbPow = (limbPow / base) | 0); - for ( - var total = number.length - start, - mod = total % limbLen, - end = Math.min(total, total - mod) + start, - word = 0, - i = start; - i < end; - i += limbLen - ) - (word = parseBase(number, i, i + limbLen, base)), - this.imuln(limbPow), - this.words[0] + word < 67108864 ? (this.words[0] += word) : this._iaddn(word); - if (mod !== 0) { - var pow = 1; - for (word = parseBase(number, i, number.length, base), i = 0; i < mod; i++) pow *= base; - this.imuln(pow), this.words[0] + word < 67108864 ? (this.words[0] += word) : this._iaddn(word); - } - this.strip(); - }), - (BN.prototype.copy = function (dest) { - dest.words = new Array(this.length); - for (var i = 0; i < this.length; i++) dest.words[i] = this.words[i]; - (dest.length = this.length), (dest.negative = this.negative), (dest.red = this.red); - }), - (BN.prototype.clone = function () { - var r = new BN(null); - return this.copy(r), r; - }), - (BN.prototype._expand = function (size) { - for (; this.length < size; ) this.words[this.length++] = 0; - return this; - }), - (BN.prototype.strip = function () { - for (; this.length > 1 && this.words[this.length - 1] === 0; ) this.length--; - return this._normSign(); - }), - (BN.prototype._normSign = function () { - return this.length === 1 && this.words[0] === 0 && (this.negative = 0), this; - }), - (BN.prototype.inspect = function () { - return (this.red ? "<BN-R: " : "<BN: ") + this.toString(16) + ">"; - }); - var zeros = [ - "", - "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", - ], - groupSizes = [ - 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, - ], - groupBases = [ - 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 (base, padding) { - (base = base || 10), (padding = padding | 0 || 1); - var out; - if (base === 16 || base === "hex") { - out = ""; - for (var off = 0, carry = 0, i = 0; i < this.length; i++) { - var w = this.words[i], - word = (((w << off) | carry) & 16777215).toString(16); - (carry = (w >>> (24 - off)) & 16777215), - carry !== 0 || i !== this.length - 1 ? (out = zeros[6 - word.length] + word + out) : (out = word + out), - (off += 2), - off >= 26 && ((off -= 26), i--); - } - for (carry !== 0 && (out = carry.toString(16) + out); out.length % padding !== 0; ) out = "0" + out; - return this.negative !== 0 && (out = "-" + out), out; - } - if (base === (base | 0) && base >= 2 && base <= 36) { - var groupSize = groupSizes[base], - groupBase = groupBases[base]; - out = ""; - var c = this.clone(); - for (c.negative = 0; !c.isZero(); ) { - var r = c.modn(groupBase).toString(base); - (c = c.idivn(groupBase)), c.isZero() ? (out = r + out) : (out = zeros[groupSize - r.length] + r + out); - } - for (this.isZero() && (out = "0" + out); out.length % padding !== 0; ) out = "0" + out; - return this.negative !== 0 && (out = "-" + out), out; - } - assert(!1, "Base should be between 2 and 36"); - }), - (BN.prototype.toNumber = function () { - var ret = this.words[0]; - return ( - this.length === 2 - ? (ret += this.words[1] * 67108864) - : this.length === 3 && this.words[2] === 1 - ? (ret += 4503599627370496 + this.words[1] * 67108864) - : this.length > 2 && assert(!1, "Number can only safely store up to 53 bits"), - this.negative !== 0 ? -ret : ret - ); - }), - (BN.prototype.toJSON = function () { - return this.toString(16); - }), - (BN.prototype.toBuffer = function (endian, length) { - return assert(typeof Buffer2 < "u"), this.toArrayLike(Buffer2, endian, length); - }), - (BN.prototype.toArray = function (endian, length) { - return this.toArrayLike(Array, endian, length); - }), - (BN.prototype.toArrayLike = function (ArrayType, endian, length) { - var byteLength = this.byteLength(), - reqLength = length || Math.max(1, byteLength); - assert(byteLength <= reqLength, "byte array longer than desired length"), - assert(reqLength > 0, "Requested array length <= 0"), - this.strip(); - var littleEndian = endian === "le", - res = new ArrayType(reqLength), - b, - i, - q = this.clone(); - if (littleEndian) { - for (i = 0; !q.isZero(); i++) (b = q.andln(255)), q.iushrn(8), (res[i] = b); - for (; i < reqLength; i++) res[i] = 0; - } else { - for (i = 0; i < reqLength - byteLength; i++) res[i] = 0; - for (i = 0; !q.isZero(); i++) (b = q.andln(255)), q.iushrn(8), (res[reqLength - i - 1] = b); - } - return res; - }), - Math.clz32 - ? (BN.prototype._countBits = function (w) { - return 32 - Math.clz32(w); - }) - : (BN.prototype._countBits = function (w) { - var t = w, - r = 0; - return ( - t >= 4096 && ((r += 13), (t >>>= 13)), - t >= 64 && ((r += 7), (t >>>= 7)), - t >= 8 && ((r += 4), (t >>>= 4)), - t >= 2 && ((r += 2), (t >>>= 2)), - r + t - ); - }), - (BN.prototype._zeroBits = function (w) { - if (w === 0) return 26; - var t = w, - r = 0; - return ( - (t & 8191) === 0 && ((r += 13), (t >>>= 13)), - (t & 127) === 0 && ((r += 7), (t >>>= 7)), - (t & 15) === 0 && ((r += 4), (t >>>= 4)), - (t & 3) === 0 && ((r += 2), (t >>>= 2)), - (t & 1) === 0 && r++, - r - ); - }), - (BN.prototype.bitLength = function () { - var w = this.words[this.length - 1], - hi = this._countBits(w); - return (this.length - 1) * 26 + hi; - }); - function toBitArray(num) { - for (var w = new Array(num.bitLength()), bit = 0; bit < w.length; bit++) { - var off = (bit / 26) | 0, - wbit = bit % 26; - w[bit] = (num.words[off] & (1 << wbit)) >>> wbit; - } - return w; - } - (BN.prototype.zeroBits = function () { - if (this.isZero()) return 0; - for (var r = 0, i = 0; i < this.length; i++) { - var b = this._zeroBits(this.words[i]); - if (((r += b), b !== 26)) break; - } - return r; - }), - (BN.prototype.byteLength = function () { - return Math.ceil(this.bitLength() / 8); - }), - (BN.prototype.toTwos = function (width) { - return this.negative !== 0 ? this.abs().inotn(width).iaddn(1) : this.clone(); - }), - (BN.prototype.fromTwos = function (width) { - return this.testn(width - 1) ? this.notn(width).iaddn(1).ineg() : this.clone(); - }), - (BN.prototype.isNeg = function () { - return this.negative !== 0; - }), - (BN.prototype.neg = function () { - return this.clone().ineg(); - }), - (BN.prototype.ineg = function () { - return this.isZero() || (this.negative ^= 1), this; - }), - (BN.prototype.iuor = function (num) { - for (; this.length < num.length; ) this.words[this.length++] = 0; - for (var i = 0; i < num.length; i++) this.words[i] = this.words[i] | num.words[i]; - return this.strip(); - }), - (BN.prototype.ior = function (num) { - return assert((this.negative | num.negative) === 0), this.iuor(num); - }), - (BN.prototype.or = function (num) { - return this.length > num.length ? this.clone().ior(num) : num.clone().ior(this); - }), - (BN.prototype.uor = function (num) { - return this.length > num.length ? this.clone().iuor(num) : num.clone().iuor(this); - }), - (BN.prototype.iuand = function (num) { - var b; - this.length > num.length ? (b = num) : (b = this); - for (var i = 0; i < b.length; i++) this.words[i] = this.words[i] & num.words[i]; - return (this.length = b.length), this.strip(); - }), - (BN.prototype.iand = function (num) { - return assert((this.negative | num.negative) === 0), this.iuand(num); - }), - (BN.prototype.and = function (num) { - return this.length > num.length ? this.clone().iand(num) : num.clone().iand(this); - }), - (BN.prototype.uand = function (num) { - return this.length > num.length ? this.clone().iuand(num) : num.clone().iuand(this); - }), - (BN.prototype.iuxor = function (num) { - var a, b; - this.length > num.length ? ((a = this), (b = num)) : ((a = num), (b = this)); - for (var i = 0; i < b.length; i++) this.words[i] = a.words[i] ^ b.words[i]; - if (this !== a) for (; i < a.length; i++) this.words[i] = a.words[i]; - return (this.length = a.length), this.strip(); - }), - (BN.prototype.ixor = function (num) { - return assert((this.negative | num.negative) === 0), this.iuxor(num); - }), - (BN.prototype.xor = function (num) { - return this.length > num.length ? this.clone().ixor(num) : num.clone().ixor(this); - }), - (BN.prototype.uxor = function (num) { - return this.length > num.length ? this.clone().iuxor(num) : num.clone().iuxor(this); - }), - (BN.prototype.inotn = function (width) { - assert(typeof width == "number" && width >= 0); - var bytesNeeded = Math.ceil(width / 26) | 0, - bitsLeft = width % 26; - this._expand(bytesNeeded), bitsLeft > 0 && bytesNeeded--; - for (var i = 0; i < bytesNeeded; i++) this.words[i] = ~this.words[i] & 67108863; - return bitsLeft > 0 && (this.words[i] = ~this.words[i] & (67108863 >> (26 - bitsLeft))), this.strip(); - }), - (BN.prototype.notn = function (width) { - return this.clone().inotn(width); - }), - (BN.prototype.setn = function (bit, val) { - assert(typeof bit == "number" && bit >= 0); - var off = (bit / 26) | 0, - wbit = bit % 26; - return ( - this._expand(off + 1), - val - ? (this.words[off] = this.words[off] | (1 << wbit)) - : (this.words[off] = this.words[off] & ~(1 << wbit)), - this.strip() - ); - }), - (BN.prototype.iadd = function (num) { - var r; - if (this.negative !== 0 && num.negative === 0) - return (this.negative = 0), (r = this.isub(num)), (this.negative ^= 1), this._normSign(); - if (this.negative === 0 && num.negative !== 0) - return (num.negative = 0), (r = this.isub(num)), (num.negative = 1), r._normSign(); - var a, b; - this.length > num.length ? ((a = this), (b = num)) : ((a = num), (b = this)); - for (var carry = 0, i = 0; i < b.length; i++) - (r = (a.words[i] | 0) + (b.words[i] | 0) + carry), (this.words[i] = r & 67108863), (carry = r >>> 26); - for (; carry !== 0 && i < a.length; i++) - (r = (a.words[i] | 0) + carry), (this.words[i] = r & 67108863), (carry = r >>> 26); - if (((this.length = a.length), carry !== 0)) (this.words[this.length] = carry), this.length++; - else if (a !== this) for (; i < a.length; i++) this.words[i] = a.words[i]; - return this; - }), - (BN.prototype.add = function (num) { - var res; - return num.negative !== 0 && this.negative === 0 - ? ((num.negative = 0), (res = this.sub(num)), (num.negative ^= 1), res) - : num.negative === 0 && this.negative !== 0 - ? ((this.negative = 0), (res = num.sub(this)), (this.negative = 1), res) - : this.length > num.length - ? this.clone().iadd(num) - : num.clone().iadd(this); - }), - (BN.prototype.isub = function (num) { - if (num.negative !== 0) { - num.negative = 0; - var r = this.iadd(num); - return (num.negative = 1), r._normSign(); - } else if (this.negative !== 0) - return (this.negative = 0), this.iadd(num), (this.negative = 1), this._normSign(); - var cmp = this.cmp(num); - if (cmp === 0) return (this.negative = 0), (this.length = 1), (this.words[0] = 0), this; - var a, b; - cmp > 0 ? ((a = this), (b = num)) : ((a = num), (b = this)); - for (var carry = 0, i = 0; i < b.length; i++) - (r = (a.words[i] | 0) - (b.words[i] | 0) + carry), (carry = r >> 26), (this.words[i] = r & 67108863); - for (; carry !== 0 && i < a.length; i++) - (r = (a.words[i] | 0) + carry), (carry = r >> 26), (this.words[i] = r & 67108863); - if (carry === 0 && i < a.length && a !== this) for (; i < a.length; i++) this.words[i] = a.words[i]; - return (this.length = Math.max(this.length, i)), a !== this && (this.negative = 1), this.strip(); - }), - (BN.prototype.sub = function (num) { - return this.clone().isub(num); - }); - function smallMulTo(self2, num, out) { - out.negative = num.negative ^ self2.negative; - var len = (self2.length + num.length) | 0; - (out.length = len), (len = (len - 1) | 0); - var a = self2.words[0] | 0, - b = num.words[0] | 0, - r = a * b, - lo = r & 67108863, - carry = (r / 67108864) | 0; - out.words[0] = lo; - for (var k = 1; k < len; k++) { - for ( - var ncarry = carry >>> 26, - rword = carry & 67108863, - maxJ = Math.min(k, num.length - 1), - j = Math.max(0, k - self2.length + 1); - j <= maxJ; - j++ - ) { - var i = (k - j) | 0; - (a = self2.words[i] | 0), - (b = num.words[j] | 0), - (r = a * b + rword), - (ncarry += (r / 67108864) | 0), - (rword = r & 67108863); - } - (out.words[k] = rword | 0), (carry = ncarry | 0); - } - return carry !== 0 ? (out.words[k] = carry | 0) : out.length--, out.strip(); - } - var comb10MulTo = function (self2, num, out) { - var a = self2.words, - b = num.words, - o = out.words, - c = 0, - lo, - mid, - hi, - a0 = a[0] | 0, - al0 = a0 & 8191, - ah0 = a0 >>> 13, - a1 = a[1] | 0, - al1 = a1 & 8191, - ah1 = a1 >>> 13, - a2 = a[2] | 0, - al2 = a2 & 8191, - ah2 = a2 >>> 13, - a3 = a[3] | 0, - al3 = a3 & 8191, - ah3 = a3 >>> 13, - a4 = a[4] | 0, - al4 = a4 & 8191, - ah4 = a4 >>> 13, - a5 = a[5] | 0, - al5 = a5 & 8191, - ah5 = a5 >>> 13, - a6 = a[6] | 0, - al6 = a6 & 8191, - ah6 = a6 >>> 13, - a7 = a[7] | 0, - al7 = a7 & 8191, - ah7 = a7 >>> 13, - a8 = a[8] | 0, - al8 = a8 & 8191, - ah8 = a8 >>> 13, - a9 = a[9] | 0, - al9 = a9 & 8191, - ah9 = a9 >>> 13, - b0 = b[0] | 0, - bl0 = b0 & 8191, - bh0 = b0 >>> 13, - b1 = b[1] | 0, - bl1 = b1 & 8191, - bh1 = b1 >>> 13, - b2 = b[2] | 0, - bl2 = b2 & 8191, - bh2 = b2 >>> 13, - b3 = b[3] | 0, - bl3 = b3 & 8191, - bh3 = b3 >>> 13, - b4 = b[4] | 0, - bl4 = b4 & 8191, - bh4 = b4 >>> 13, - b5 = b[5] | 0, - bl5 = b5 & 8191, - bh5 = b5 >>> 13, - b6 = b[6] | 0, - bl6 = b6 & 8191, - bh6 = b6 >>> 13, - b7 = b[7] | 0, - bl7 = b7 & 8191, - bh7 = b7 >>> 13, - b8 = b[8] | 0, - bl8 = b8 & 8191, - bh8 = b8 >>> 13, - b9 = b[9] | 0, - bl9 = b9 & 8191, - bh9 = b9 >>> 13; - (out.negative = self2.negative ^ num.negative), - (out.length = 19), - (lo = Math.imul(al0, bl0)), - (mid = Math.imul(al0, bh0)), - (mid = (mid + Math.imul(ah0, bl0)) | 0), - (hi = Math.imul(ah0, bh0)); - var w0 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0), - (w0 &= 67108863), - (lo = Math.imul(al1, bl0)), - (mid = Math.imul(al1, bh0)), - (mid = (mid + Math.imul(ah1, bl0)) | 0), - (hi = Math.imul(ah1, bh0)), - (lo = (lo + Math.imul(al0, bl1)) | 0), - (mid = (mid + Math.imul(al0, bh1)) | 0), - (mid = (mid + Math.imul(ah0, bl1)) | 0), - (hi = (hi + Math.imul(ah0, bh1)) | 0); - var w1 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0), - (w1 &= 67108863), - (lo = Math.imul(al2, bl0)), - (mid = Math.imul(al2, bh0)), - (mid = (mid + Math.imul(ah2, bl0)) | 0), - (hi = Math.imul(ah2, bh0)), - (lo = (lo + Math.imul(al1, bl1)) | 0), - (mid = (mid + Math.imul(al1, bh1)) | 0), - (mid = (mid + Math.imul(ah1, bl1)) | 0), - (hi = (hi + Math.imul(ah1, bh1)) | 0), - (lo = (lo + Math.imul(al0, bl2)) | 0), - (mid = (mid + Math.imul(al0, bh2)) | 0), - (mid = (mid + Math.imul(ah0, bl2)) | 0), - (hi = (hi + Math.imul(ah0, bh2)) | 0); - var w2 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0), - (w2 &= 67108863), - (lo = Math.imul(al3, bl0)), - (mid = Math.imul(al3, bh0)), - (mid = (mid + Math.imul(ah3, bl0)) | 0), - (hi = Math.imul(ah3, bh0)), - (lo = (lo + Math.imul(al2, bl1)) | 0), - (mid = (mid + Math.imul(al2, bh1)) | 0), - (mid = (mid + Math.imul(ah2, bl1)) | 0), - (hi = (hi + Math.imul(ah2, bh1)) | 0), - (lo = (lo + Math.imul(al1, bl2)) | 0), - (mid = (mid + Math.imul(al1, bh2)) | 0), - (mid = (mid + Math.imul(ah1, bl2)) | 0), - (hi = (hi + Math.imul(ah1, bh2)) | 0), - (lo = (lo + Math.imul(al0, bl3)) | 0), - (mid = (mid + Math.imul(al0, bh3)) | 0), - (mid = (mid + Math.imul(ah0, bl3)) | 0), - (hi = (hi + Math.imul(ah0, bh3)) | 0); - var w3 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0), - (w3 &= 67108863), - (lo = Math.imul(al4, bl0)), - (mid = Math.imul(al4, bh0)), - (mid = (mid + Math.imul(ah4, bl0)) | 0), - (hi = Math.imul(ah4, bh0)), - (lo = (lo + Math.imul(al3, bl1)) | 0), - (mid = (mid + Math.imul(al3, bh1)) | 0), - (mid = (mid + Math.imul(ah3, bl1)) | 0), - (hi = (hi + Math.imul(ah3, bh1)) | 0), - (lo = (lo + Math.imul(al2, bl2)) | 0), - (mid = (mid + Math.imul(al2, bh2)) | 0), - (mid = (mid + Math.imul(ah2, bl2)) | 0), - (hi = (hi + Math.imul(ah2, bh2)) | 0), - (lo = (lo + Math.imul(al1, bl3)) | 0), - (mid = (mid + Math.imul(al1, bh3)) | 0), - (mid = (mid + Math.imul(ah1, bl3)) | 0), - (hi = (hi + Math.imul(ah1, bh3)) | 0), - (lo = (lo + Math.imul(al0, bl4)) | 0), - (mid = (mid + Math.imul(al0, bh4)) | 0), - (mid = (mid + Math.imul(ah0, bl4)) | 0), - (hi = (hi + Math.imul(ah0, bh4)) | 0); - var w4 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0), - (w4 &= 67108863), - (lo = Math.imul(al5, bl0)), - (mid = Math.imul(al5, bh0)), - (mid = (mid + Math.imul(ah5, bl0)) | 0), - (hi = Math.imul(ah5, bh0)), - (lo = (lo + Math.imul(al4, bl1)) | 0), - (mid = (mid + Math.imul(al4, bh1)) | 0), - (mid = (mid + Math.imul(ah4, bl1)) | 0), - (hi = (hi + Math.imul(ah4, bh1)) | 0), - (lo = (lo + Math.imul(al3, bl2)) | 0), - (mid = (mid + Math.imul(al3, bh2)) | 0), - (mid = (mid + Math.imul(ah3, bl2)) | 0), - (hi = (hi + Math.imul(ah3, bh2)) | 0), - (lo = (lo + Math.imul(al2, bl3)) | 0), - (mid = (mid + Math.imul(al2, bh3)) | 0), - (mid = (mid + Math.imul(ah2, bl3)) | 0), - (hi = (hi + Math.imul(ah2, bh3)) | 0), - (lo = (lo + Math.imul(al1, bl4)) | 0), - (mid = (mid + Math.imul(al1, bh4)) | 0), - (mid = (mid + Math.imul(ah1, bl4)) | 0), - (hi = (hi + Math.imul(ah1, bh4)) | 0), - (lo = (lo + Math.imul(al0, bl5)) | 0), - (mid = (mid + Math.imul(al0, bh5)) | 0), - (mid = (mid + Math.imul(ah0, bl5)) | 0), - (hi = (hi + Math.imul(ah0, bh5)) | 0); - var w5 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0), - (w5 &= 67108863), - (lo = Math.imul(al6, bl0)), - (mid = Math.imul(al6, bh0)), - (mid = (mid + Math.imul(ah6, bl0)) | 0), - (hi = Math.imul(ah6, bh0)), - (lo = (lo + Math.imul(al5, bl1)) | 0), - (mid = (mid + Math.imul(al5, bh1)) | 0), - (mid = (mid + Math.imul(ah5, bl1)) | 0), - (hi = (hi + Math.imul(ah5, bh1)) | 0), - (lo = (lo + Math.imul(al4, bl2)) | 0), - (mid = (mid + Math.imul(al4, bh2)) | 0), - (mid = (mid + Math.imul(ah4, bl2)) | 0), - (hi = (hi + Math.imul(ah4, bh2)) | 0), - (lo = (lo + Math.imul(al3, bl3)) | 0), - (mid = (mid + Math.imul(al3, bh3)) | 0), - (mid = (mid + Math.imul(ah3, bl3)) | 0), - (hi = (hi + Math.imul(ah3, bh3)) | 0), - (lo = (lo + Math.imul(al2, bl4)) | 0), - (mid = (mid + Math.imul(al2, bh4)) | 0), - (mid = (mid + Math.imul(ah2, bl4)) | 0), - (hi = (hi + Math.imul(ah2, bh4)) | 0), - (lo = (lo + Math.imul(al1, bl5)) | 0), - (mid = (mid + Math.imul(al1, bh5)) | 0), - (mid = (mid + Math.imul(ah1, bl5)) | 0), - (hi = (hi + Math.imul(ah1, bh5)) | 0), - (lo = (lo + Math.imul(al0, bl6)) | 0), - (mid = (mid + Math.imul(al0, bh6)) | 0), - (mid = (mid + Math.imul(ah0, bl6)) | 0), - (hi = (hi + Math.imul(ah0, bh6)) | 0); - var w6 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0), - (w6 &= 67108863), - (lo = Math.imul(al7, bl0)), - (mid = Math.imul(al7, bh0)), - (mid = (mid + Math.imul(ah7, bl0)) | 0), - (hi = Math.imul(ah7, bh0)), - (lo = (lo + Math.imul(al6, bl1)) | 0), - (mid = (mid + Math.imul(al6, bh1)) | 0), - (mid = (mid + Math.imul(ah6, bl1)) | 0), - (hi = (hi + Math.imul(ah6, bh1)) | 0), - (lo = (lo + Math.imul(al5, bl2)) | 0), - (mid = (mid + Math.imul(al5, bh2)) | 0), - (mid = (mid + Math.imul(ah5, bl2)) | 0), - (hi = (hi + Math.imul(ah5, bh2)) | 0), - (lo = (lo + Math.imul(al4, bl3)) | 0), - (mid = (mid + Math.imul(al4, bh3)) | 0), - (mid = (mid + Math.imul(ah4, bl3)) | 0), - (hi = (hi + Math.imul(ah4, bh3)) | 0), - (lo = (lo + Math.imul(al3, bl4)) | 0), - (mid = (mid + Math.imul(al3, bh4)) | 0), - (mid = (mid + Math.imul(ah3, bl4)) | 0), - (hi = (hi + Math.imul(ah3, bh4)) | 0), - (lo = (lo + Math.imul(al2, bl5)) | 0), - (mid = (mid + Math.imul(al2, bh5)) | 0), - (mid = (mid + Math.imul(ah2, bl5)) | 0), - (hi = (hi + Math.imul(ah2, bh5)) | 0), - (lo = (lo + Math.imul(al1, bl6)) | 0), - (mid = (mid + Math.imul(al1, bh6)) | 0), - (mid = (mid + Math.imul(ah1, bl6)) | 0), - (hi = (hi + Math.imul(ah1, bh6)) | 0), - (lo = (lo + Math.imul(al0, bl7)) | 0), - (mid = (mid + Math.imul(al0, bh7)) | 0), - (mid = (mid + Math.imul(ah0, bl7)) | 0), - (hi = (hi + Math.imul(ah0, bh7)) | 0); - var w7 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0), - (w7 &= 67108863), - (lo = Math.imul(al8, bl0)), - (mid = Math.imul(al8, bh0)), - (mid = (mid + Math.imul(ah8, bl0)) | 0), - (hi = Math.imul(ah8, bh0)), - (lo = (lo + Math.imul(al7, bl1)) | 0), - (mid = (mid + Math.imul(al7, bh1)) | 0), - (mid = (mid + Math.imul(ah7, bl1)) | 0), - (hi = (hi + Math.imul(ah7, bh1)) | 0), - (lo = (lo + Math.imul(al6, bl2)) | 0), - (mid = (mid + Math.imul(al6, bh2)) | 0), - (mid = (mid + Math.imul(ah6, bl2)) | 0), - (hi = (hi + Math.imul(ah6, bh2)) | 0), - (lo = (lo + Math.imul(al5, bl3)) | 0), - (mid = (mid + Math.imul(al5, bh3)) | 0), - (mid = (mid + Math.imul(ah5, bl3)) | 0), - (hi = (hi + Math.imul(ah5, bh3)) | 0), - (lo = (lo + Math.imul(al4, bl4)) | 0), - (mid = (mid + Math.imul(al4, bh4)) | 0), - (mid = (mid + Math.imul(ah4, bl4)) | 0), - (hi = (hi + Math.imul(ah4, bh4)) | 0), - (lo = (lo + Math.imul(al3, bl5)) | 0), - (mid = (mid + Math.imul(al3, bh5)) | 0), - (mid = (mid + Math.imul(ah3, bl5)) | 0), - (hi = (hi + Math.imul(ah3, bh5)) | 0), - (lo = (lo + Math.imul(al2, bl6)) | 0), - (mid = (mid + Math.imul(al2, bh6)) | 0), - (mid = (mid + Math.imul(ah2, bl6)) | 0), - (hi = (hi + Math.imul(ah2, bh6)) | 0), - (lo = (lo + Math.imul(al1, bl7)) | 0), - (mid = (mid + Math.imul(al1, bh7)) | 0), - (mid = (mid + Math.imul(ah1, bl7)) | 0), - (hi = (hi + Math.imul(ah1, bh7)) | 0), - (lo = (lo + Math.imul(al0, bl8)) | 0), - (mid = (mid + Math.imul(al0, bh8)) | 0), - (mid = (mid + Math.imul(ah0, bl8)) | 0), - (hi = (hi + Math.imul(ah0, bh8)) | 0); - var w8 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0), - (w8 &= 67108863), - (lo = Math.imul(al9, bl0)), - (mid = Math.imul(al9, bh0)), - (mid = (mid + Math.imul(ah9, bl0)) | 0), - (hi = Math.imul(ah9, bh0)), - (lo = (lo + Math.imul(al8, bl1)) | 0), - (mid = (mid + Math.imul(al8, bh1)) | 0), - (mid = (mid + Math.imul(ah8, bl1)) | 0), - (hi = (hi + Math.imul(ah8, bh1)) | 0), - (lo = (lo + Math.imul(al7, bl2)) | 0), - (mid = (mid + Math.imul(al7, bh2)) | 0), - (mid = (mid + Math.imul(ah7, bl2)) | 0), - (hi = (hi + Math.imul(ah7, bh2)) | 0), - (lo = (lo + Math.imul(al6, bl3)) | 0), - (mid = (mid + Math.imul(al6, bh3)) | 0), - (mid = (mid + Math.imul(ah6, bl3)) | 0), - (hi = (hi + Math.imul(ah6, bh3)) | 0), - (lo = (lo + Math.imul(al5, bl4)) | 0), - (mid = (mid + Math.imul(al5, bh4)) | 0), - (mid = (mid + Math.imul(ah5, bl4)) | 0), - (hi = (hi + Math.imul(ah5, bh4)) | 0), - (lo = (lo + Math.imul(al4, bl5)) | 0), - (mid = (mid + Math.imul(al4, bh5)) | 0), - (mid = (mid + Math.imul(ah4, bl5)) | 0), - (hi = (hi + Math.imul(ah4, bh5)) | 0), - (lo = (lo + Math.imul(al3, bl6)) | 0), - (mid = (mid + Math.imul(al3, bh6)) | 0), - (mid = (mid + Math.imul(ah3, bl6)) | 0), - (hi = (hi + Math.imul(ah3, bh6)) | 0), - (lo = (lo + Math.imul(al2, bl7)) | 0), - (mid = (mid + Math.imul(al2, bh7)) | 0), - (mid = (mid + Math.imul(ah2, bl7)) | 0), - (hi = (hi + Math.imul(ah2, bh7)) | 0), - (lo = (lo + Math.imul(al1, bl8)) | 0), - (mid = (mid + Math.imul(al1, bh8)) | 0), - (mid = (mid + Math.imul(ah1, bl8)) | 0), - (hi = (hi + Math.imul(ah1, bh8)) | 0), - (lo = (lo + Math.imul(al0, bl9)) | 0), - (mid = (mid + Math.imul(al0, bh9)) | 0), - (mid = (mid + Math.imul(ah0, bl9)) | 0), - (hi = (hi + Math.imul(ah0, bh9)) | 0); - var w9 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0), - (w9 &= 67108863), - (lo = Math.imul(al9, bl1)), - (mid = Math.imul(al9, bh1)), - (mid = (mid + Math.imul(ah9, bl1)) | 0), - (hi = Math.imul(ah9, bh1)), - (lo = (lo + Math.imul(al8, bl2)) | 0), - (mid = (mid + Math.imul(al8, bh2)) | 0), - (mid = (mid + Math.imul(ah8, bl2)) | 0), - (hi = (hi + Math.imul(ah8, bh2)) | 0), - (lo = (lo + Math.imul(al7, bl3)) | 0), - (mid = (mid + Math.imul(al7, bh3)) | 0), - (mid = (mid + Math.imul(ah7, bl3)) | 0), - (hi = (hi + Math.imul(ah7, bh3)) | 0), - (lo = (lo + Math.imul(al6, bl4)) | 0), - (mid = (mid + Math.imul(al6, bh4)) | 0), - (mid = (mid + Math.imul(ah6, bl4)) | 0), - (hi = (hi + Math.imul(ah6, bh4)) | 0), - (lo = (lo + Math.imul(al5, bl5)) | 0), - (mid = (mid + Math.imul(al5, bh5)) | 0), - (mid = (mid + Math.imul(ah5, bl5)) | 0), - (hi = (hi + Math.imul(ah5, bh5)) | 0), - (lo = (lo + Math.imul(al4, bl6)) | 0), - (mid = (mid + Math.imul(al4, bh6)) | 0), - (mid = (mid + Math.imul(ah4, bl6)) | 0), - (hi = (hi + Math.imul(ah4, bh6)) | 0), - (lo = (lo + Math.imul(al3, bl7)) | 0), - (mid = (mid + Math.imul(al3, bh7)) | 0), - (mid = (mid + Math.imul(ah3, bl7)) | 0), - (hi = (hi + Math.imul(ah3, bh7)) | 0), - (lo = (lo + Math.imul(al2, bl8)) | 0), - (mid = (mid + Math.imul(al2, bh8)) | 0), - (mid = (mid + Math.imul(ah2, bl8)) | 0), - (hi = (hi + Math.imul(ah2, bh8)) | 0), - (lo = (lo + Math.imul(al1, bl9)) | 0), - (mid = (mid + Math.imul(al1, bh9)) | 0), - (mid = (mid + Math.imul(ah1, bl9)) | 0), - (hi = (hi + Math.imul(ah1, bh9)) | 0); - var w10 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0), - (w10 &= 67108863), - (lo = Math.imul(al9, bl2)), - (mid = Math.imul(al9, bh2)), - (mid = (mid + Math.imul(ah9, bl2)) | 0), - (hi = Math.imul(ah9, bh2)), - (lo = (lo + Math.imul(al8, bl3)) | 0), - (mid = (mid + Math.imul(al8, bh3)) | 0), - (mid = (mid + Math.imul(ah8, bl3)) | 0), - (hi = (hi + Math.imul(ah8, bh3)) | 0), - (lo = (lo + Math.imul(al7, bl4)) | 0), - (mid = (mid + Math.imul(al7, bh4)) | 0), - (mid = (mid + Math.imul(ah7, bl4)) | 0), - (hi = (hi + Math.imul(ah7, bh4)) | 0), - (lo = (lo + Math.imul(al6, bl5)) | 0), - (mid = (mid + Math.imul(al6, bh5)) | 0), - (mid = (mid + Math.imul(ah6, bl5)) | 0), - (hi = (hi + Math.imul(ah6, bh5)) | 0), - (lo = (lo + Math.imul(al5, bl6)) | 0), - (mid = (mid + Math.imul(al5, bh6)) | 0), - (mid = (mid + Math.imul(ah5, bl6)) | 0), - (hi = (hi + Math.imul(ah5, bh6)) | 0), - (lo = (lo + Math.imul(al4, bl7)) | 0), - (mid = (mid + Math.imul(al4, bh7)) | 0), - (mid = (mid + Math.imul(ah4, bl7)) | 0), - (hi = (hi + Math.imul(ah4, bh7)) | 0), - (lo = (lo + Math.imul(al3, bl8)) | 0), - (mid = (mid + Math.imul(al3, bh8)) | 0), - (mid = (mid + Math.imul(ah3, bl8)) | 0), - (hi = (hi + Math.imul(ah3, bh8)) | 0), - (lo = (lo + Math.imul(al2, bl9)) | 0), - (mid = (mid + Math.imul(al2, bh9)) | 0), - (mid = (mid + Math.imul(ah2, bl9)) | 0), - (hi = (hi + Math.imul(ah2, bh9)) | 0); - var w11 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0), - (w11 &= 67108863), - (lo = Math.imul(al9, bl3)), - (mid = Math.imul(al9, bh3)), - (mid = (mid + Math.imul(ah9, bl3)) | 0), - (hi = Math.imul(ah9, bh3)), - (lo = (lo + Math.imul(al8, bl4)) | 0), - (mid = (mid + Math.imul(al8, bh4)) | 0), - (mid = (mid + Math.imul(ah8, bl4)) | 0), - (hi = (hi + Math.imul(ah8, bh4)) | 0), - (lo = (lo + Math.imul(al7, bl5)) | 0), - (mid = (mid + Math.imul(al7, bh5)) | 0), - (mid = (mid + Math.imul(ah7, bl5)) | 0), - (hi = (hi + Math.imul(ah7, bh5)) | 0), - (lo = (lo + Math.imul(al6, bl6)) | 0), - (mid = (mid + Math.imul(al6, bh6)) | 0), - (mid = (mid + Math.imul(ah6, bl6)) | 0), - (hi = (hi + Math.imul(ah6, bh6)) | 0), - (lo = (lo + Math.imul(al5, bl7)) | 0), - (mid = (mid + Math.imul(al5, bh7)) | 0), - (mid = (mid + Math.imul(ah5, bl7)) | 0), - (hi = (hi + Math.imul(ah5, bh7)) | 0), - (lo = (lo + Math.imul(al4, bl8)) | 0), - (mid = (mid + Math.imul(al4, bh8)) | 0), - (mid = (mid + Math.imul(ah4, bl8)) | 0), - (hi = (hi + Math.imul(ah4, bh8)) | 0), - (lo = (lo + Math.imul(al3, bl9)) | 0), - (mid = (mid + Math.imul(al3, bh9)) | 0), - (mid = (mid + Math.imul(ah3, bl9)) | 0), - (hi = (hi + Math.imul(ah3, bh9)) | 0); - var w12 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0), - (w12 &= 67108863), - (lo = Math.imul(al9, bl4)), - (mid = Math.imul(al9, bh4)), - (mid = (mid + Math.imul(ah9, bl4)) | 0), - (hi = Math.imul(ah9, bh4)), - (lo = (lo + Math.imul(al8, bl5)) | 0), - (mid = (mid + Math.imul(al8, bh5)) | 0), - (mid = (mid + Math.imul(ah8, bl5)) | 0), - (hi = (hi + Math.imul(ah8, bh5)) | 0), - (lo = (lo + Math.imul(al7, bl6)) | 0), - (mid = (mid + Math.imul(al7, bh6)) | 0), - (mid = (mid + Math.imul(ah7, bl6)) | 0), - (hi = (hi + Math.imul(ah7, bh6)) | 0), - (lo = (lo + Math.imul(al6, bl7)) | 0), - (mid = (mid + Math.imul(al6, bh7)) | 0), - (mid = (mid + Math.imul(ah6, bl7)) | 0), - (hi = (hi + Math.imul(ah6, bh7)) | 0), - (lo = (lo + Math.imul(al5, bl8)) | 0), - (mid = (mid + Math.imul(al5, bh8)) | 0), - (mid = (mid + Math.imul(ah5, bl8)) | 0), - (hi = (hi + Math.imul(ah5, bh8)) | 0), - (lo = (lo + Math.imul(al4, bl9)) | 0), - (mid = (mid + Math.imul(al4, bh9)) | 0), - (mid = (mid + Math.imul(ah4, bl9)) | 0), - (hi = (hi + Math.imul(ah4, bh9)) | 0); - var w13 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0), - (w13 &= 67108863), - (lo = Math.imul(al9, bl5)), - (mid = Math.imul(al9, bh5)), - (mid = (mid + Math.imul(ah9, bl5)) | 0), - (hi = Math.imul(ah9, bh5)), - (lo = (lo + Math.imul(al8, bl6)) | 0), - (mid = (mid + Math.imul(al8, bh6)) | 0), - (mid = (mid + Math.imul(ah8, bl6)) | 0), - (hi = (hi + Math.imul(ah8, bh6)) | 0), - (lo = (lo + Math.imul(al7, bl7)) | 0), - (mid = (mid + Math.imul(al7, bh7)) | 0), - (mid = (mid + Math.imul(ah7, bl7)) | 0), - (hi = (hi + Math.imul(ah7, bh7)) | 0), - (lo = (lo + Math.imul(al6, bl8)) | 0), - (mid = (mid + Math.imul(al6, bh8)) | 0), - (mid = (mid + Math.imul(ah6, bl8)) | 0), - (hi = (hi + Math.imul(ah6, bh8)) | 0), - (lo = (lo + Math.imul(al5, bl9)) | 0), - (mid = (mid + Math.imul(al5, bh9)) | 0), - (mid = (mid + Math.imul(ah5, bl9)) | 0), - (hi = (hi + Math.imul(ah5, bh9)) | 0); - var w14 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0), - (w14 &= 67108863), - (lo = Math.imul(al9, bl6)), - (mid = Math.imul(al9, bh6)), - (mid = (mid + Math.imul(ah9, bl6)) | 0), - (hi = Math.imul(ah9, bh6)), - (lo = (lo + Math.imul(al8, bl7)) | 0), - (mid = (mid + Math.imul(al8, bh7)) | 0), - (mid = (mid + Math.imul(ah8, bl7)) | 0), - (hi = (hi + Math.imul(ah8, bh7)) | 0), - (lo = (lo + Math.imul(al7, bl8)) | 0), - (mid = (mid + Math.imul(al7, bh8)) | 0), - (mid = (mid + Math.imul(ah7, bl8)) | 0), - (hi = (hi + Math.imul(ah7, bh8)) | 0), - (lo = (lo + Math.imul(al6, bl9)) | 0), - (mid = (mid + Math.imul(al6, bh9)) | 0), - (mid = (mid + Math.imul(ah6, bl9)) | 0), - (hi = (hi + Math.imul(ah6, bh9)) | 0); - var w15 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0), - (w15 &= 67108863), - (lo = Math.imul(al9, bl7)), - (mid = Math.imul(al9, bh7)), - (mid = (mid + Math.imul(ah9, bl7)) | 0), - (hi = Math.imul(ah9, bh7)), - (lo = (lo + Math.imul(al8, bl8)) | 0), - (mid = (mid + Math.imul(al8, bh8)) | 0), - (mid = (mid + Math.imul(ah8, bl8)) | 0), - (hi = (hi + Math.imul(ah8, bh8)) | 0), - (lo = (lo + Math.imul(al7, bl9)) | 0), - (mid = (mid + Math.imul(al7, bh9)) | 0), - (mid = (mid + Math.imul(ah7, bl9)) | 0), - (hi = (hi + Math.imul(ah7, bh9)) | 0); - var w16 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0), - (w16 &= 67108863), - (lo = Math.imul(al9, bl8)), - (mid = Math.imul(al9, bh8)), - (mid = (mid + Math.imul(ah9, bl8)) | 0), - (hi = Math.imul(ah9, bh8)), - (lo = (lo + Math.imul(al8, bl9)) | 0), - (mid = (mid + Math.imul(al8, bh9)) | 0), - (mid = (mid + Math.imul(ah8, bl9)) | 0), - (hi = (hi + Math.imul(ah8, bh9)) | 0); - var w17 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0), - (w17 &= 67108863), - (lo = Math.imul(al9, bl9)), - (mid = Math.imul(al9, bh9)), - (mid = (mid + Math.imul(ah9, bl9)) | 0), - (hi = Math.imul(ah9, bh9)); - var w18 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - return ( - (c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0), - (w18 &= 67108863), - (o[0] = w0), - (o[1] = w1), - (o[2] = w2), - (o[3] = w3), - (o[4] = w4), - (o[5] = w5), - (o[6] = w6), - (o[7] = w7), - (o[8] = w8), - (o[9] = w9), - (o[10] = w10), - (o[11] = w11), - (o[12] = w12), - (o[13] = w13), - (o[14] = w14), - (o[15] = w15), - (o[16] = w16), - (o[17] = w17), - (o[18] = w18), - c !== 0 && ((o[19] = c), out.length++), - out - ); - }; - Math.imul || (comb10MulTo = smallMulTo); - function bigMulTo(self2, num, out) { - (out.negative = num.negative ^ self2.negative), (out.length = self2.length + num.length); - for (var carry = 0, hncarry = 0, k = 0; k < out.length - 1; k++) { - var ncarry = hncarry; - hncarry = 0; - for ( - var rword = carry & 67108863, maxJ = Math.min(k, num.length - 1), j = Math.max(0, k - self2.length + 1); - j <= maxJ; - j++ - ) { - var i = k - j, - a = self2.words[i] | 0, - b = num.words[j] | 0, - r = a * b, - lo = r & 67108863; - (ncarry = (ncarry + ((r / 67108864) | 0)) | 0), - (lo = (lo + rword) | 0), - (rword = lo & 67108863), - (ncarry = (ncarry + (lo >>> 26)) | 0), - (hncarry += ncarry >>> 26), - (ncarry &= 67108863); - } - (out.words[k] = rword), (carry = ncarry), (ncarry = hncarry); - } - return carry !== 0 ? (out.words[k] = carry) : out.length--, out.strip(); - } - function jumboMulTo(self2, num, out) { - var fftm = new FFTM(); - return fftm.mulp(self2, num, out); - } - BN.prototype.mulTo = function (num, out) { - var res, - len = this.length + num.length; - return ( - this.length === 10 && num.length === 10 - ? (res = comb10MulTo(this, num, out)) - : len < 63 - ? (res = smallMulTo(this, num, out)) - : len < 1024 - ? (res = bigMulTo(this, num, out)) - : (res = jumboMulTo(this, num, out)), - res - ); - }; - function FFTM(x, y) { - (this.x = x), (this.y = y); - } - (FFTM.prototype.makeRBT = function (N) { - for (var t = new Array(N), l = BN.prototype._countBits(N) - 1, i = 0; i < N; i++) t[i] = this.revBin(i, l, N); - return t; - }), - (FFTM.prototype.revBin = function (x, l, N) { - if (x === 0 || x === N - 1) return x; - for (var rb = 0, i = 0; i < l; i++) (rb |= (x & 1) << (l - i - 1)), (x >>= 1); - return rb; - }), - (FFTM.prototype.permute = function (rbt, rws, iws, rtws, itws, N) { - for (var i = 0; i < N; i++) (rtws[i] = rws[rbt[i]]), (itws[i] = iws[rbt[i]]); - }), - (FFTM.prototype.transform = function (rws, iws, rtws, itws, N, rbt) { - this.permute(rbt, rws, iws, rtws, itws, N); - for (var s = 1; s < N; s <<= 1) - for ( - var l = s << 1, rtwdf = Math.cos((2 * Math.PI) / l), itwdf = Math.sin((2 * Math.PI) / l), p = 0; - p < N; - p += l - ) - for (var rtwdf_ = rtwdf, itwdf_ = itwdf, j = 0; j < s; j++) { - var re = rtws[p + j], - ie = itws[p + j], - ro = rtws[p + j + s], - io = itws[p + j + s], - rx = rtwdf_ * ro - itwdf_ * io; - (io = rtwdf_ * io + itwdf_ * ro), - (ro = rx), - (rtws[p + j] = re + ro), - (itws[p + j] = ie + io), - (rtws[p + j + s] = re - ro), - (itws[p + j + s] = ie - io), - j !== l && - ((rx = rtwdf * rtwdf_ - itwdf * itwdf_), (itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_), (rtwdf_ = rx)); - } - }), - (FFTM.prototype.guessLen13b = function (n, m) { - var N = Math.max(m, n) | 1, - odd = N & 1, - i = 0; - for (N = (N / 2) | 0; N; N = N >>> 1) i++; - return 1 << (i + 1 + odd); - }), - (FFTM.prototype.conjugate = function (rws, iws, N) { - if (!(N <= 1)) - for (var i = 0; i < N / 2; i++) { - var t = rws[i]; - (rws[i] = rws[N - i - 1]), - (rws[N - i - 1] = t), - (t = iws[i]), - (iws[i] = -iws[N - i - 1]), - (iws[N - i - 1] = -t); - } - }), - (FFTM.prototype.normalize13b = function (ws, N) { - for (var carry = 0, i = 0; i < N / 2; i++) { - var w = Math.round(ws[2 * i + 1] / N) * 8192 + Math.round(ws[2 * i] / N) + carry; - (ws[i] = w & 67108863), w < 67108864 ? (carry = 0) : (carry = (w / 67108864) | 0); - } - return ws; - }), - (FFTM.prototype.convert13b = function (ws, len, rws, N) { - for (var carry = 0, i = 0; i < len; i++) - (carry = carry + (ws[i] | 0)), - (rws[2 * i] = carry & 8191), - (carry = carry >>> 13), - (rws[2 * i + 1] = carry & 8191), - (carry = carry >>> 13); - for (i = 2 * len; i < N; ++i) rws[i] = 0; - assert(carry === 0), assert((carry & -8192) === 0); - }), - (FFTM.prototype.stub = function (N) { - for (var ph = new Array(N), i = 0; i < N; i++) ph[i] = 0; - return ph; - }), - (FFTM.prototype.mulp = function (x, y, out) { - var N = 2 * this.guessLen13b(x.length, y.length), - rbt = this.makeRBT(N), - _ = this.stub(N), - rws = new Array(N), - rwst = new Array(N), - iwst = new Array(N), - nrws = new Array(N), - nrwst = new Array(N), - niwst = new Array(N), - rmws = out.words; - (rmws.length = N), - this.convert13b(x.words, x.length, rws, N), - this.convert13b(y.words, y.length, nrws, N), - this.transform(rws, _, rwst, iwst, N, rbt), - this.transform(nrws, _, nrwst, niwst, N, rbt); - for (var i = 0; i < N; i++) { - var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i]; - (iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i]), (rwst[i] = rx); - } - return ( - this.conjugate(rwst, iwst, N), - this.transform(rwst, iwst, rmws, _, N, rbt), - this.conjugate(rmws, _, N), - this.normalize13b(rmws, N), - (out.negative = x.negative ^ y.negative), - (out.length = x.length + y.length), - out.strip() - ); - }), - (BN.prototype.mul = function (num) { - var out = new BN(null); - return (out.words = new Array(this.length + num.length)), this.mulTo(num, out); - }), - (BN.prototype.mulf = function (num) { - var out = new BN(null); - return (out.words = new Array(this.length + num.length)), jumboMulTo(this, num, out); - }), - (BN.prototype.imul = function (num) { - return this.clone().mulTo(num, this); - }), - (BN.prototype.imuln = function (num) { - assert(typeof num == "number"), assert(num < 67108864); - for (var carry = 0, i = 0; i < this.length; i++) { - var w = (this.words[i] | 0) * num, - lo = (w & 67108863) + (carry & 67108863); - (carry >>= 26), (carry += (w / 67108864) | 0), (carry += lo >>> 26), (this.words[i] = lo & 67108863); - } - return carry !== 0 && ((this.words[i] = carry), this.length++), this; - }), - (BN.prototype.muln = function (num) { - return this.clone().imuln(num); - }), - (BN.prototype.sqr = function () { - return this.mul(this); - }), - (BN.prototype.isqr = function () { - return this.imul(this.clone()); - }), - (BN.prototype.pow = function (num) { - var w = toBitArray(num); - if (w.length === 0) return new BN(1); - for (var res = this, i = 0; i < w.length && w[i] === 0; i++, res = res.sqr()); - if (++i < w.length) for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) w[i] !== 0 && (res = res.mul(q)); - return res; - }), - (BN.prototype.iushln = function (bits) { - assert(typeof bits == "number" && bits >= 0); - var r = bits % 26, - s = (bits - r) / 26, - carryMask = (67108863 >>> (26 - r)) << (26 - r), - i; - if (r !== 0) { - var carry = 0; - for (i = 0; i < this.length; i++) { - var newCarry = this.words[i] & carryMask, - c = ((this.words[i] | 0) - newCarry) << r; - (this.words[i] = c | carry), (carry = newCarry >>> (26 - r)); - } - carry && ((this.words[i] = carry), this.length++); - } - if (s !== 0) { - for (i = this.length - 1; i >= 0; i--) this.words[i + s] = this.words[i]; - for (i = 0; i < s; i++) this.words[i] = 0; - this.length += s; - } - return this.strip(); - }), - (BN.prototype.ishln = function (bits) { - return assert(this.negative === 0), this.iushln(bits); - }), - (BN.prototype.iushrn = function (bits, hint, extended) { - assert(typeof bits == "number" && bits >= 0); - var h; - hint ? (h = (hint - (hint % 26)) / 26) : (h = 0); - var r = bits % 26, - s = Math.min((bits - r) / 26, this.length), - mask = 67108863 ^ ((67108863 >>> r) << r), - maskedWords = extended; - if (((h -= s), (h = Math.max(0, h)), maskedWords)) { - for (var i = 0; i < s; i++) maskedWords.words[i] = this.words[i]; - maskedWords.length = s; - } - if (s !== 0) - if (this.length > s) for (this.length -= s, i = 0; i < this.length; i++) this.words[i] = this.words[i + s]; - else (this.words[0] = 0), (this.length = 1); - var carry = 0; - for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) { - var word = this.words[i] | 0; - (this.words[i] = (carry << (26 - r)) | (word >>> r)), (carry = word & mask); - } - return ( - maskedWords && carry !== 0 && (maskedWords.words[maskedWords.length++] = carry), - this.length === 0 && ((this.words[0] = 0), (this.length = 1)), - this.strip() - ); - }), - (BN.prototype.ishrn = function (bits, hint, extended) { - return assert(this.negative === 0), this.iushrn(bits, hint, extended); - }), - (BN.prototype.shln = function (bits) { - return this.clone().ishln(bits); - }), - (BN.prototype.ushln = function (bits) { - return this.clone().iushln(bits); - }), - (BN.prototype.shrn = function (bits) { - return this.clone().ishrn(bits); - }), - (BN.prototype.ushrn = function (bits) { - return this.clone().iushrn(bits); - }), - (BN.prototype.testn = function (bit) { - assert(typeof bit == "number" && bit >= 0); - var r = bit % 26, - s = (bit - r) / 26, - q = 1 << r; - if (this.length <= s) return !1; - var w = this.words[s]; - return !!(w & q); - }), - (BN.prototype.imaskn = function (bits) { - assert(typeof bits == "number" && bits >= 0); - var r = bits % 26, - s = (bits - r) / 26; - if ((assert(this.negative === 0, "imaskn works only with positive numbers"), this.length <= s)) return this; - if ((r !== 0 && s++, (this.length = Math.min(s, this.length)), r !== 0)) { - var mask = 67108863 ^ ((67108863 >>> r) << r); - this.words[this.length - 1] &= mask; - } - return this.strip(); - }), - (BN.prototype.maskn = function (bits) { - return this.clone().imaskn(bits); - }), - (BN.prototype.iaddn = function (num) { - return ( - assert(typeof num == "number"), - assert(num < 67108864), - num < 0 - ? this.isubn(-num) - : this.negative !== 0 - ? this.length === 1 && (this.words[0] | 0) < num - ? ((this.words[0] = num - (this.words[0] | 0)), (this.negative = 0), this) - : ((this.negative = 0), this.isubn(num), (this.negative = 1), this) - : this._iaddn(num) - ); - }), - (BN.prototype._iaddn = function (num) { - this.words[0] += num; - for (var i = 0; i < this.length && this.words[i] >= 67108864; i++) - (this.words[i] -= 67108864), i === this.length - 1 ? (this.words[i + 1] = 1) : this.words[i + 1]++; - return (this.length = Math.max(this.length, i + 1)), this; - }), - (BN.prototype.isubn = function (num) { - if ((assert(typeof num == "number"), assert(num < 67108864), num < 0)) return this.iaddn(-num); - if (this.negative !== 0) return (this.negative = 0), this.iaddn(num), (this.negative = 1), this; - if (((this.words[0] -= num), this.length === 1 && this.words[0] < 0)) - (this.words[0] = -this.words[0]), (this.negative = 1); - else - for (var i = 0; i < this.length && this.words[i] < 0; i++) - (this.words[i] += 67108864), (this.words[i + 1] -= 1); - return this.strip(); - }), - (BN.prototype.addn = function (num) { - return this.clone().iaddn(num); - }), - (BN.prototype.subn = function (num) { - return this.clone().isubn(num); - }), - (BN.prototype.iabs = function () { - return (this.negative = 0), this; - }), - (BN.prototype.abs = function () { - return this.clone().iabs(); - }), - (BN.prototype._ishlnsubmul = function (num, mul, shift) { - var len = num.length + shift, - i; - this._expand(len); - var w, - carry = 0; - for (i = 0; i < num.length; i++) { - w = (this.words[i + shift] | 0) + carry; - var right = (num.words[i] | 0) * mul; - (w -= right & 67108863), - (carry = (w >> 26) - ((right / 67108864) | 0)), - (this.words[i + shift] = w & 67108863); - } - for (; i < this.length - shift; i++) - (w = (this.words[i + shift] | 0) + carry), (carry = w >> 26), (this.words[i + shift] = w & 67108863); - if (carry === 0) return this.strip(); - for (assert(carry === -1), carry = 0, i = 0; i < this.length; i++) - (w = -(this.words[i] | 0) + carry), (carry = w >> 26), (this.words[i] = w & 67108863); - return (this.negative = 1), this.strip(); - }), - (BN.prototype._wordDiv = function (num, mode) { - var shift = this.length - num.length, - a = this.clone(), - b = num, - bhi = b.words[b.length - 1] | 0, - bhiBits = this._countBits(bhi); - (shift = 26 - bhiBits), - shift !== 0 && ((b = b.ushln(shift)), a.iushln(shift), (bhi = b.words[b.length - 1] | 0)); - var m = a.length - b.length, - q; - if (mode !== "mod") { - (q = new BN(null)), (q.length = m + 1), (q.words = new Array(q.length)); - for (var i = 0; i < q.length; i++) q.words[i] = 0; - } - var diff = a.clone()._ishlnsubmul(b, 1, m); - diff.negative === 0 && ((a = diff), q && (q.words[m] = 1)); - for (var j = m - 1; j >= 0; j--) { - var qj = (a.words[b.length + j] | 0) * 67108864 + (a.words[b.length + j - 1] | 0); - for (qj = Math.min((qj / bhi) | 0, 67108863), a._ishlnsubmul(b, qj, j); a.negative !== 0; ) - qj--, (a.negative = 0), a._ishlnsubmul(b, 1, j), a.isZero() || (a.negative ^= 1); - q && (q.words[j] = qj); - } - return ( - q && q.strip(), - a.strip(), - mode !== "div" && shift !== 0 && a.iushrn(shift), - { - div: q || null, - mod: a, - } - ); - }), - (BN.prototype.divmod = function (num, mode, positive) { - if ((assert(!num.isZero()), this.isZero())) - return { - div: new BN(0), - mod: new BN(0), - }; - var div, mod, res; - return this.negative !== 0 && num.negative === 0 - ? ((res = this.neg().divmod(num, mode)), - mode !== "mod" && (div = res.div.neg()), - mode !== "div" && ((mod = res.mod.neg()), positive && mod.negative !== 0 && mod.iadd(num)), - { - div, - mod, - }) - : this.negative === 0 && num.negative !== 0 - ? ((res = this.divmod(num.neg(), mode)), - mode !== "mod" && (div = res.div.neg()), - { - div, - mod: res.mod, - }) - : (this.negative & num.negative) !== 0 - ? ((res = this.neg().divmod(num.neg(), mode)), - mode !== "div" && ((mod = res.mod.neg()), positive && mod.negative !== 0 && mod.isub(num)), - { - div: res.div, - mod, - }) - : num.length > this.length || this.cmp(num) < 0 - ? { - div: new BN(0), - mod: this, - } - : num.length === 1 - ? mode === "div" - ? { - div: this.divn(num.words[0]), - mod: null, - } - : mode === "mod" - ? { - div: null, - mod: new BN(this.modn(num.words[0])), - } - : { - div: this.divn(num.words[0]), - mod: new BN(this.modn(num.words[0])), - } - : this._wordDiv(num, mode); - }), - (BN.prototype.div = function (num) { - return this.divmod(num, "div", !1).div; - }), - (BN.prototype.mod = function (num) { - return this.divmod(num, "mod", !1).mod; - }), - (BN.prototype.umod = function (num) { - return this.divmod(num, "mod", !0).mod; - }), - (BN.prototype.divRound = function (num) { - var dm = this.divmod(num); - if (dm.mod.isZero()) return dm.div; - var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod, - half = num.ushrn(1), - r2 = num.andln(1), - cmp = mod.cmp(half); - return cmp < 0 || (r2 === 1 && cmp === 0) - ? dm.div - : dm.div.negative !== 0 - ? dm.div.isubn(1) - : dm.div.iaddn(1); - }), - (BN.prototype.modn = function (num) { - assert(num <= 67108863); - for (var p = (1 << 26) % num, acc = 0, i = this.length - 1; i >= 0; i--) - acc = (p * acc + (this.words[i] | 0)) % num; - return acc; - }), - (BN.prototype.idivn = function (num) { - assert(num <= 67108863); - for (var carry = 0, i = this.length - 1; i >= 0; i--) { - var w = (this.words[i] | 0) + carry * 67108864; - (this.words[i] = (w / num) | 0), (carry = w % num); - } - return this.strip(); - }), - (BN.prototype.divn = function (num) { - return this.clone().idivn(num); - }), - (BN.prototype.egcd = function (p) { - assert(p.negative === 0), assert(!p.isZero()); - var x = this, - y = p.clone(); - x.negative !== 0 ? (x = x.umod(p)) : (x = x.clone()); - for (var A = new BN(1), B = new BN(0), C = new BN(0), D = new BN(1), g = 0; x.isEven() && y.isEven(); ) - x.iushrn(1), y.iushrn(1), ++g; - for (var yp = y.clone(), xp = x.clone(); !x.isZero(); ) { - for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1); - if (i > 0) - for (x.iushrn(i); i-- > 0; ) - (A.isOdd() || B.isOdd()) && (A.iadd(yp), B.isub(xp)), A.iushrn(1), B.iushrn(1); - for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); - if (j > 0) - for (y.iushrn(j); j-- > 0; ) - (C.isOdd() || D.isOdd()) && (C.iadd(yp), D.isub(xp)), C.iushrn(1), D.iushrn(1); - x.cmp(y) >= 0 ? (x.isub(y), A.isub(C), B.isub(D)) : (y.isub(x), C.isub(A), D.isub(B)); - } - return { - a: C, - b: D, - gcd: y.iushln(g), - }; - }), - (BN.prototype._invmp = function (p) { - assert(p.negative === 0), assert(!p.isZero()); - var a = this, - b = p.clone(); - a.negative !== 0 ? (a = a.umod(p)) : (a = a.clone()); - for (var x1 = new BN(1), x2 = new BN(0), delta = b.clone(); a.cmpn(1) > 0 && b.cmpn(1) > 0; ) { - for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1); - if (i > 0) for (a.iushrn(i); i-- > 0; ) x1.isOdd() && x1.iadd(delta), x1.iushrn(1); - for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); - if (j > 0) for (b.iushrn(j); j-- > 0; ) x2.isOdd() && x2.iadd(delta), x2.iushrn(1); - a.cmp(b) >= 0 ? (a.isub(b), x1.isub(x2)) : (b.isub(a), x2.isub(x1)); - } - var res; - return a.cmpn(1) === 0 ? (res = x1) : (res = x2), res.cmpn(0) < 0 && res.iadd(p), res; - }), - (BN.prototype.gcd = function (num) { - if (this.isZero()) return num.abs(); - if (num.isZero()) return this.abs(); - var a = this.clone(), - b = num.clone(); - (a.negative = 0), (b.negative = 0); - for (var shift = 0; a.isEven() && b.isEven(); shift++) a.iushrn(1), b.iushrn(1); - do { - for (; a.isEven(); ) a.iushrn(1); - for (; b.isEven(); ) b.iushrn(1); - var r = a.cmp(b); - if (r < 0) { - var t = a; - (a = b), (b = t); - } else if (r === 0 || b.cmpn(1) === 0) break; - a.isub(b); - } while (!0); - return b.iushln(shift); - }), - (BN.prototype.invm = function (num) { - return this.egcd(num).a.umod(num); - }), - (BN.prototype.isEven = function () { - return (this.words[0] & 1) === 0; - }), - (BN.prototype.isOdd = function () { - return (this.words[0] & 1) === 1; - }), - (BN.prototype.andln = function (num) { - return this.words[0] & num; - }), - (BN.prototype.bincn = function (bit) { - assert(typeof bit == "number"); - var r = bit % 26, - s = (bit - r) / 26, - q = 1 << r; - if (this.length <= s) return this._expand(s + 1), (this.words[s] |= q), this; - for (var carry = q, i = s; carry !== 0 && i < this.length; i++) { - var w = this.words[i] | 0; - (w += carry), (carry = w >>> 26), (w &= 67108863), (this.words[i] = w); - } - return carry !== 0 && ((this.words[i] = carry), this.length++), this; - }), - (BN.prototype.isZero = function () { - return this.length === 1 && this.words[0] === 0; - }), - (BN.prototype.cmpn = function (num) { - var negative = num < 0; - if (this.negative !== 0 && !negative) return -1; - if (this.negative === 0 && negative) return 1; - this.strip(); - var res; - if (this.length > 1) res = 1; - else { - negative && (num = -num), assert(num <= 67108863, "Number is too big"); - var w = this.words[0] | 0; - res = w === num ? 0 : w < num ? -1 : 1; - } - return this.negative !== 0 ? -res | 0 : res; - }), - (BN.prototype.cmp = function (num) { - if (this.negative !== 0 && num.negative === 0) return -1; - if (this.negative === 0 && num.negative !== 0) return 1; - var res = this.ucmp(num); - return this.negative !== 0 ? -res | 0 : res; - }), - (BN.prototype.ucmp = function (num) { - if (this.length > num.length) return 1; - if (this.length < num.length) return -1; - for (var res = 0, i = this.length - 1; i >= 0; i--) { - var a = this.words[i] | 0, - b = num.words[i] | 0; - if (a !== b) { - a < b ? (res = -1) : a > b && (res = 1); - break; - } - } - return res; - }), - (BN.prototype.gtn = function (num) { - return this.cmpn(num) === 1; - }), - (BN.prototype.gt = function (num) { - return this.cmp(num) === 1; - }), - (BN.prototype.gten = function (num) { - return this.cmpn(num) >= 0; - }), - (BN.prototype.gte = function (num) { - return this.cmp(num) >= 0; - }), - (BN.prototype.ltn = function (num) { - return this.cmpn(num) === -1; - }), - (BN.prototype.lt = function (num) { - return this.cmp(num) === -1; - }), - (BN.prototype.lten = function (num) { - return this.cmpn(num) <= 0; - }), - (BN.prototype.lte = function (num) { - return this.cmp(num) <= 0; - }), - (BN.prototype.eqn = function (num) { - return this.cmpn(num) === 0; - }), - (BN.prototype.eq = function (num) { - return this.cmp(num) === 0; - }), - (BN.red = function (num) { - return new Red(num); - }), - (BN.prototype.toRed = function (ctx) { - return ( - assert(!this.red, "Already a number in reduction context"), - assert(this.negative === 0, "red works only with positives"), - ctx.convertTo(this)._forceRed(ctx) - ); - }), - (BN.prototype.fromRed = function () { - return assert(this.red, "fromRed works only with numbers in reduction context"), this.red.convertFrom(this); - }), - (BN.prototype._forceRed = function (ctx) { - return (this.red = ctx), this; - }), - (BN.prototype.forceRed = function (ctx) { - return assert(!this.red, "Already a number in reduction context"), this._forceRed(ctx); - }), - (BN.prototype.redAdd = function (num) { - return assert(this.red, "redAdd works only with red numbers"), this.red.add(this, num); - }), - (BN.prototype.redIAdd = function (num) { - return assert(this.red, "redIAdd works only with red numbers"), this.red.iadd(this, num); - }), - (BN.prototype.redSub = function (num) { - return assert(this.red, "redSub works only with red numbers"), this.red.sub(this, num); - }), - (BN.prototype.redISub = function (num) { - return assert(this.red, "redISub works only with red numbers"), this.red.isub(this, num); - }), - (BN.prototype.redShl = function (num) { - return assert(this.red, "redShl works only with red numbers"), this.red.shl(this, num); - }), - (BN.prototype.redMul = function (num) { - return ( - assert(this.red, "redMul works only with red numbers"), - this.red._verify2(this, num), - this.red.mul(this, num) - ); - }), - (BN.prototype.redIMul = function (num) { - return ( - assert(this.red, "redMul works only with red numbers"), - this.red._verify2(this, num), - this.red.imul(this, num) - ); - }), - (BN.prototype.redSqr = function () { - return assert(this.red, "redSqr works only with red numbers"), this.red._verify1(this), this.red.sqr(this); - }), - (BN.prototype.redISqr = function () { - return assert(this.red, "redISqr works only with red numbers"), this.red._verify1(this), this.red.isqr(this); - }), - (BN.prototype.redSqrt = function () { - return assert(this.red, "redSqrt works only with red numbers"), this.red._verify1(this), this.red.sqrt(this); - }), - (BN.prototype.redInvm = function () { - return assert(this.red, "redInvm works only with red numbers"), this.red._verify1(this), this.red.invm(this); - }), - (BN.prototype.redNeg = function () { - return assert(this.red, "redNeg works only with red numbers"), this.red._verify1(this), this.red.neg(this); - }), - (BN.prototype.redPow = function (num) { - return assert(this.red && !num.red, "redPow(normalNum)"), this.red._verify1(this), this.red.pow(this, num); - }); - var primes = { - k256: null, - p224: null, - p192: null, - p25519: null, - }; - function MPrime(name, p) { - (this.name = name), - (this.p = new BN(p, 16)), - (this.n = this.p.bitLength()), - (this.k = new BN(1).iushln(this.n).isub(this.p)), - (this.tmp = this._tmp()); - } - (MPrime.prototype._tmp = function () { - var tmp = new BN(null); - return (tmp.words = new Array(Math.ceil(this.n / 13))), tmp; - }), - (MPrime.prototype.ireduce = function (num) { - var r = num, - rlen; - do this.split(r, this.tmp), (r = this.imulK(r)), (r = r.iadd(this.tmp)), (rlen = r.bitLength()); - while (rlen > this.n); - var cmp = rlen < this.n ? -1 : r.ucmp(this.p); - return ( - cmp === 0 - ? ((r.words[0] = 0), (r.length = 1)) - : cmp > 0 - ? r.isub(this.p) - : r.strip !== void 0 - ? r.strip() - : r._strip(), - r - ); - }), - (MPrime.prototype.split = function (input, out) { - input.iushrn(this.n, 0, out); - }), - (MPrime.prototype.imulK = function (num) { - return num.imul(this.k); - }); - function K256() { - MPrime.call(this, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); - } - inherits(K256, MPrime), - (K256.prototype.split = function (input, output) { - for (var mask = 4194303, outLen = Math.min(input.length, 9), i = 0; i < outLen; i++) - output.words[i] = input.words[i]; - if (((output.length = outLen), input.length <= 9)) { - (input.words[0] = 0), (input.length = 1); - return; - } - var prev = input.words[9]; - for (output.words[output.length++] = prev & mask, i = 10; i < input.length; i++) { - var next = input.words[i] | 0; - (input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22)), (prev = next); - } - (prev >>>= 22), - (input.words[i - 10] = prev), - prev === 0 && input.length > 10 ? (input.length -= 10) : (input.length -= 9); - }), - (K256.prototype.imulK = function (num) { - (num.words[num.length] = 0), (num.words[num.length + 1] = 0), (num.length += 2); - for (var lo = 0, i = 0; i < num.length; i++) { - var w = num.words[i] | 0; - (lo += w * 977), (num.words[i] = lo & 67108863), (lo = w * 64 + ((lo / 67108864) | 0)); - } - return ( - num.words[num.length - 1] === 0 && (num.length--, num.words[num.length - 1] === 0 && num.length--), num - ); - }); - function P224() { - MPrime.call(this, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); - } - inherits(P224, MPrime); - function P192() { - MPrime.call(this, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); - } - inherits(P192, MPrime); - function P25519() { - MPrime.call(this, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); - } - inherits(P25519, MPrime), - (P25519.prototype.imulK = function (num) { - for (var carry = 0, i = 0; i < num.length; i++) { - var hi = (num.words[i] | 0) * 19 + carry, - lo = hi & 67108863; - (hi >>>= 26), (num.words[i] = lo), (carry = hi); - } - return carry !== 0 && (num.words[num.length++] = carry), num; - }), - (BN._prime = function (name) { - if (primes[name]) return primes[name]; - var prime2; - if (name === "k256") prime2 = new K256(); - else if (name === "p224") prime2 = new P224(); - else if (name === "p192") prime2 = new P192(); - else if (name === "p25519") prime2 = new P25519(); - else throw new Error("Unknown prime " + name); - return (primes[name] = prime2), prime2; - }); - function Red(m) { - if (typeof m == "string") { - var prime = BN._prime(m); - (this.m = prime.p), (this.prime = prime); - } else assert(m.gtn(1), "modulus must be greater than 1"), (this.m = m), (this.prime = null); - } - (Red.prototype._verify1 = function (a) { - assert(a.negative === 0, "red works only with positives"), assert(a.red, "red works only with red numbers"); - }), - (Red.prototype._verify2 = function (a, b) { - assert((a.negative | b.negative) === 0, "red works only with positives"), - assert(a.red && a.red === b.red, "red works only with red numbers"); - }), - (Red.prototype.imod = function (a) { - return this.prime ? this.prime.ireduce(a)._forceRed(this) : a.umod(this.m)._forceRed(this); - }), - (Red.prototype.neg = function (a) { - return a.isZero() ? a.clone() : this.m.sub(a)._forceRed(this); - }), - (Red.prototype.add = function (a, b) { - this._verify2(a, b); - var res = a.add(b); - return res.cmp(this.m) >= 0 && res.isub(this.m), res._forceRed(this); - }), - (Red.prototype.iadd = function (a, b) { - this._verify2(a, b); - var res = a.iadd(b); - return res.cmp(this.m) >= 0 && res.isub(this.m), res; - }), - (Red.prototype.sub = function (a, b) { - this._verify2(a, b); - var res = a.sub(b); - return res.cmpn(0) < 0 && res.iadd(this.m), res._forceRed(this); - }), - (Red.prototype.isub = function (a, b) { - this._verify2(a, b); - var res = a.isub(b); - return res.cmpn(0) < 0 && res.iadd(this.m), res; - }), - (Red.prototype.shl = function (a, num) { - return this._verify1(a), this.imod(a.ushln(num)); - }), - (Red.prototype.imul = function (a, b) { - return this._verify2(a, b), this.imod(a.imul(b)); - }), - (Red.prototype.mul = function (a, b) { - return this._verify2(a, b), this.imod(a.mul(b)); - }), - (Red.prototype.isqr = function (a) { - return this.imul(a, a.clone()); - }), - (Red.prototype.sqr = function (a) { - return this.mul(a, a); - }), - (Red.prototype.sqrt = function (a) { - if (a.isZero()) return a.clone(); - var mod3 = this.m.andln(3); - if ((assert(mod3 % 2 === 1), mod3 === 3)) { - var pow = this.m.add(new BN(1)).iushrn(2); - return this.pow(a, pow); - } - for (var q = this.m.subn(1), s = 0; !q.isZero() && q.andln(1) === 0; ) s++, q.iushrn(1); - assert(!q.isZero()); - var one = new BN(1).toRed(this), - nOne = one.redNeg(), - lpow = this.m.subn(1).iushrn(1), - z = this.m.bitLength(); - for (z = new BN(2 * z * z).toRed(this); this.pow(z, lpow).cmp(nOne) !== 0; ) z.redIAdd(nOne); - for ( - var c = this.pow(z, q), r = this.pow(a, q.addn(1).iushrn(1)), t = this.pow(a, q), m = s; - t.cmp(one) !== 0; - - ) { - for (var tmp = t, i = 0; tmp.cmp(one) !== 0; i++) tmp = tmp.redSqr(); - assert(i < m); - var b = this.pow(c, new BN(1).iushln(m - i - 1)); - (r = r.redMul(b)), (c = b.redSqr()), (t = t.redMul(c)), (m = i); - } - return r; - }), - (Red.prototype.invm = function (a) { - var inv = a._invmp(this.m); - return inv.negative !== 0 ? ((inv.negative = 0), this.imod(inv).redNeg()) : this.imod(inv); - }), - (Red.prototype.pow = function (a, num) { - if (num.isZero()) return new BN(1).toRed(this); - if (num.cmpn(1) === 0) return a.clone(); - var windowSize = 4, - wnd = new Array(1 << windowSize); - (wnd[0] = new BN(1).toRed(this)), (wnd[1] = a); - for (var i = 2; i < wnd.length; i++) wnd[i] = this.mul(wnd[i - 1], a); - var res = wnd[0], - current = 0, - currentLen = 0, - start = num.bitLength() % 26; - for (start === 0 && (start = 26), i = num.length - 1; i >= 0; i--) { - for (var word = num.words[i], j = start - 1; j >= 0; j--) { - var bit = (word >> j) & 1; - if ((res !== wnd[0] && (res = this.sqr(res)), bit === 0 && current === 0)) { - currentLen = 0; - continue; - } - (current <<= 1), - (current |= bit), - currentLen++, - !(currentLen !== windowSize && (i !== 0 || j !== 0)) && - ((res = this.mul(res, wnd[current])), (currentLen = 0), (current = 0)); - } - start = 26; - } - return res; - }), - (Red.prototype.convertTo = function (num) { - var r = num.umod(this.m); - return r === num ? r.clone() : r; - }), - (Red.prototype.convertFrom = function (num) { - var res = num.clone(); - return (res.red = null), res; - }), - (BN.mont = function (num) { - return new Mont(num); - }); - function Mont(m) { - Red.call(this, m), - (this.shift = this.m.bitLength()), - this.shift % 26 !== 0 && (this.shift += 26 - (this.shift % 26)), - (this.r = new BN(1).iushln(this.shift)), - (this.r2 = this.imod(this.r.sqr())), - (this.rinv = this.r._invmp(this.m)), - (this.minv = this.rinv.mul(this.r).isubn(1).div(this.m)), - (this.minv = this.minv.umod(this.r)), - (this.minv = this.r.sub(this.minv)); - } - inherits(Mont, Red), - (Mont.prototype.convertTo = function (num) { - return this.imod(num.ushln(this.shift)); - }), - (Mont.prototype.convertFrom = function (num) { - var r = this.imod(num.mul(this.rinv)); - return (r.red = null), r; - }), - (Mont.prototype.imul = function (a, b) { - if (a.isZero() || b.isZero()) return (a.words[0] = 0), (a.length = 1), a; - var t = a.imul(b), - c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), - u = t.isub(c).iushrn(this.shift), - res = u; - return ( - u.cmp(this.m) >= 0 ? (res = u.isub(this.m)) : u.cmpn(0) < 0 && (res = u.iadd(this.m)), res._forceRed(this) - ); - }), - (Mont.prototype.mul = function (a, b) { - if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this); - var t = a.mul(b), - c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), - u = t.isub(c).iushrn(this.shift), - res = u; - return ( - u.cmp(this.m) >= 0 ? (res = u.isub(this.m)) : u.cmpn(0) < 0 && (res = u.iadd(this.m)), res._forceRed(this) - ); - }), - (Mont.prototype.invm = function (a) { - var res = this.imod(a._invmp(this.m).mul(this.r2)); - return res._forceRed(this); - }); - })(typeof module > "u" || module, exports); - }, -}); +var require_bn6 = require_bn; // node_modules/create-ecdh/browser.js var require_browser9 = __commonJS({ @@ -21449,6 +11470,7 @@ var require_browser9 = __commonJS({ (this.curve = new elliptic.ec(this.curveType.name)), (this.keys = void 0); } + ECDH.prototype = {}; ECDH.prototype.generateKeys = function (enc, format) { return (this.keys = this.curve.genKeyPair()), this.getPublicKey(enc, format); }; @@ -21517,1991 +11539,7 @@ var require_xor = __commonJS({ }); // node_modules/public-encrypt/node_modules/bn.js/lib/bn.js -var require_bn7 = __commonJS({ - "node_modules/public-encrypt/node_modules/bn.js/lib/bn.js"(exports, module) { - (function (module2, exports2) { - "use strict"; - function assert(val, msg) { - if (!val) throw new Error(msg || "Assertion failed"); - } - function inherits(ctor, superCtor) { - ctor.super_ = superCtor; - var TempCtor = function () {}; - (TempCtor.prototype = superCtor.prototype), - (ctor.prototype = new TempCtor()), - (ctor.prototype.constructor = ctor); - } - function BN(number, base, endian) { - if (BN.isBN(number)) return number; - (this.negative = 0), - (this.words = null), - (this.length = 0), - (this.red = null), - number !== null && - ((base === "le" || base === "be") && ((endian = base), (base = 10)), - this._init(number || 0, base || 10, endian || "be")); - } - typeof module2 == "object" ? (module2.exports = BN) : (exports2.BN = BN), (BN.BN = BN), (BN.wordSize = 26); - var Buffer2 = globalThis.Buffer; - (BN.isBN = function (num) { - return num instanceof BN - ? !0 - : num !== null && - typeof num == "object" && - num.constructor.wordSize === BN.wordSize && - Array.isArray(num.words); - }), - (BN.max = function (left, right) { - return left.cmp(right) > 0 ? left : right; - }), - (BN.min = function (left, right) { - return left.cmp(right) < 0 ? left : right; - }), - (BN.prototype._init = function (number, base, endian) { - if (typeof number == "number") return this._initNumber(number, base, endian); - if (typeof number == "object") return this._initArray(number, base, endian); - base === "hex" && (base = 16), - assert(base === (base | 0) && base >= 2 && base <= 36), - (number = number.toString().replace(/\s+/g, "")); - var start = 0; - number[0] === "-" && (start++, (this.negative = 1)), - start < number.length && - (base === 16 - ? this._parseHex(number, start, endian) - : (this._parseBase(number, base, start), - endian === "le" && this._initArray(this.toArray(), base, endian))); - }), - (BN.prototype._initNumber = function (number, base, endian) { - number < 0 && ((this.negative = 1), (number = -number)), - number < 67108864 - ? ((this.words = [number & 67108863]), (this.length = 1)) - : number < 4503599627370496 - ? ((this.words = [number & 67108863, (number / 67108864) & 67108863]), (this.length = 2)) - : (assert(number < 9007199254740992), - (this.words = [number & 67108863, (number / 67108864) & 67108863, 1]), - (this.length = 3)), - endian === "le" && this._initArray(this.toArray(), base, endian); - }), - (BN.prototype._initArray = function (number, base, endian) { - if ((assert(typeof number.length == "number"), number.length <= 0)) - return (this.words = [0]), (this.length = 1), this; - (this.length = Math.ceil(number.length / 3)), (this.words = new Array(this.length)); - for (var i = 0; i < this.length; i++) this.words[i] = 0; - var j, - w, - off = 0; - if (endian === "be") - for (i = number.length - 1, j = 0; i >= 0; i -= 3) - (w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16)), - (this.words[j] |= (w << off) & 67108863), - (this.words[j + 1] = (w >>> (26 - off)) & 67108863), - (off += 24), - off >= 26 && ((off -= 26), j++); - else if (endian === "le") - for (i = 0, j = 0; i < number.length; i += 3) - (w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16)), - (this.words[j] |= (w << off) & 67108863), - (this.words[j + 1] = (w >>> (26 - off)) & 67108863), - (off += 24), - off >= 26 && ((off -= 26), j++); - return this.strip(); - }); - function parseHex4Bits(string, index) { - var c = string.charCodeAt(index); - return c >= 65 && c <= 70 ? c - 55 : c >= 97 && c <= 102 ? c - 87 : (c - 48) & 15; - } - function parseHexByte(string, lowerBound, index) { - var r = parseHex4Bits(string, index); - return index - 1 >= lowerBound && (r |= parseHex4Bits(string, index - 1) << 4), r; - } - BN.prototype._parseHex = function (number, start, endian) { - (this.length = Math.ceil((number.length - start) / 6)), (this.words = new Array(this.length)); - for (var i = 0; i < this.length; i++) this.words[i] = 0; - var off = 0, - j = 0, - w; - if (endian === "be") - for (i = number.length - 1; i >= start; i -= 2) - (w = parseHexByte(number, start, i) << off), - (this.words[j] |= w & 67108863), - off >= 18 ? ((off -= 18), (j += 1), (this.words[j] |= w >>> 26)) : (off += 8); - else { - var parseLength = number.length - start; - for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) - (w = parseHexByte(number, start, i) << off), - (this.words[j] |= w & 67108863), - off >= 18 ? ((off -= 18), (j += 1), (this.words[j] |= w >>> 26)) : (off += 8); - } - this.strip(); - }; - function parseBase(str, start, end, mul) { - for (var r = 0, len = Math.min(str.length, end), i = start; i < len; i++) { - var c = str.charCodeAt(i) - 48; - (r *= mul), c >= 49 ? (r += c - 49 + 10) : c >= 17 ? (r += c - 17 + 10) : (r += c); - } - return r; - } - (BN.prototype._parseBase = function (number, base, start) { - (this.words = [0]), (this.length = 1); - for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *= base) limbLen++; - limbLen--, (limbPow = (limbPow / base) | 0); - for ( - var total = number.length - start, - mod = total % limbLen, - end = Math.min(total, total - mod) + start, - word = 0, - i = start; - i < end; - i += limbLen - ) - (word = parseBase(number, i, i + limbLen, base)), - this.imuln(limbPow), - this.words[0] + word < 67108864 ? (this.words[0] += word) : this._iaddn(word); - if (mod !== 0) { - var pow = 1; - for (word = parseBase(number, i, number.length, base), i = 0; i < mod; i++) pow *= base; - this.imuln(pow), this.words[0] + word < 67108864 ? (this.words[0] += word) : this._iaddn(word); - } - this.strip(); - }), - (BN.prototype.copy = function (dest) { - dest.words = new Array(this.length); - for (var i = 0; i < this.length; i++) dest.words[i] = this.words[i]; - (dest.length = this.length), (dest.negative = this.negative), (dest.red = this.red); - }), - (BN.prototype.clone = function () { - var r = new BN(null); - return this.copy(r), r; - }), - (BN.prototype._expand = function (size) { - for (; this.length < size; ) this.words[this.length++] = 0; - return this; - }), - (BN.prototype.strip = function () { - for (; this.length > 1 && this.words[this.length - 1] === 0; ) this.length--; - return this._normSign(); - }), - (BN.prototype._normSign = function () { - return this.length === 1 && this.words[0] === 0 && (this.negative = 0), this; - }), - (BN.prototype.inspect = function () { - return (this.red ? "<BN-R: " : "<BN: ") + this.toString(16) + ">"; - }); - var zeros = [ - "", - "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", - ], - groupSizes = [ - 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, - ], - groupBases = [ - 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 (base, padding) { - (base = base || 10), (padding = padding | 0 || 1); - var out; - if (base === 16 || base === "hex") { - out = ""; - for (var off = 0, carry = 0, i = 0; i < this.length; i++) { - var w = this.words[i], - word = (((w << off) | carry) & 16777215).toString(16); - (carry = (w >>> (24 - off)) & 16777215), - carry !== 0 || i !== this.length - 1 ? (out = zeros[6 - word.length] + word + out) : (out = word + out), - (off += 2), - off >= 26 && ((off -= 26), i--); - } - for (carry !== 0 && (out = carry.toString(16) + out); out.length % padding !== 0; ) out = "0" + out; - return this.negative !== 0 && (out = "-" + out), out; - } - if (base === (base | 0) && base >= 2 && base <= 36) { - var groupSize = groupSizes[base], - groupBase = groupBases[base]; - out = ""; - var c = this.clone(); - for (c.negative = 0; !c.isZero(); ) { - var r = c.modn(groupBase).toString(base); - (c = c.idivn(groupBase)), c.isZero() ? (out = r + out) : (out = zeros[groupSize - r.length] + r + out); - } - for (this.isZero() && (out = "0" + out); out.length % padding !== 0; ) out = "0" + out; - return this.negative !== 0 && (out = "-" + out), out; - } - assert(!1, "Base should be between 2 and 36"); - }), - (BN.prototype.toNumber = function () { - var ret = this.words[0]; - return ( - this.length === 2 - ? (ret += this.words[1] * 67108864) - : this.length === 3 && this.words[2] === 1 - ? (ret += 4503599627370496 + this.words[1] * 67108864) - : this.length > 2 && assert(!1, "Number can only safely store up to 53 bits"), - this.negative !== 0 ? -ret : ret - ); - }), - (BN.prototype.toJSON = function () { - return this.toString(16); - }), - (BN.prototype.toBuffer = function (endian, length) { - return assert(typeof Buffer2 < "u"), this.toArrayLike(Buffer2, endian, length); - }), - (BN.prototype.toArray = function (endian, length) { - return this.toArrayLike(Array, endian, length); - }), - (BN.prototype.toArrayLike = function (ArrayType, endian, length) { - var byteLength = this.byteLength(), - reqLength = length || Math.max(1, byteLength); - assert(byteLength <= reqLength, "byte array longer than desired length"), - assert(reqLength > 0, "Requested array length <= 0"), - this.strip(); - var littleEndian = endian === "le", - res = new ArrayType(reqLength), - b, - i, - q = this.clone(); - if (littleEndian) { - for (i = 0; !q.isZero(); i++) (b = q.andln(255)), q.iushrn(8), (res[i] = b); - for (; i < reqLength; i++) res[i] = 0; - } else { - for (i = 0; i < reqLength - byteLength; i++) res[i] = 0; - for (i = 0; !q.isZero(); i++) (b = q.andln(255)), q.iushrn(8), (res[reqLength - i - 1] = b); - } - return res; - }), - Math.clz32 - ? (BN.prototype._countBits = function (w) { - return 32 - Math.clz32(w); - }) - : (BN.prototype._countBits = function (w) { - var t = w, - r = 0; - return ( - t >= 4096 && ((r += 13), (t >>>= 13)), - t >= 64 && ((r += 7), (t >>>= 7)), - t >= 8 && ((r += 4), (t >>>= 4)), - t >= 2 && ((r += 2), (t >>>= 2)), - r + t - ); - }), - (BN.prototype._zeroBits = function (w) { - if (w === 0) return 26; - var t = w, - r = 0; - return ( - (t & 8191) === 0 && ((r += 13), (t >>>= 13)), - (t & 127) === 0 && ((r += 7), (t >>>= 7)), - (t & 15) === 0 && ((r += 4), (t >>>= 4)), - (t & 3) === 0 && ((r += 2), (t >>>= 2)), - (t & 1) === 0 && r++, - r - ); - }), - (BN.prototype.bitLength = function () { - var w = this.words[this.length - 1], - hi = this._countBits(w); - return (this.length - 1) * 26 + hi; - }); - function toBitArray(num) { - for (var w = new Array(num.bitLength()), bit = 0; bit < w.length; bit++) { - var off = (bit / 26) | 0, - wbit = bit % 26; - w[bit] = (num.words[off] & (1 << wbit)) >>> wbit; - } - return w; - } - (BN.prototype.zeroBits = function () { - if (this.isZero()) return 0; - for (var r = 0, i = 0; i < this.length; i++) { - var b = this._zeroBits(this.words[i]); - if (((r += b), b !== 26)) break; - } - return r; - }), - (BN.prototype.byteLength = function () { - return Math.ceil(this.bitLength() / 8); - }), - (BN.prototype.toTwos = function (width) { - return this.negative !== 0 ? this.abs().inotn(width).iaddn(1) : this.clone(); - }), - (BN.prototype.fromTwos = function (width) { - return this.testn(width - 1) ? this.notn(width).iaddn(1).ineg() : this.clone(); - }), - (BN.prototype.isNeg = function () { - return this.negative !== 0; - }), - (BN.prototype.neg = function () { - return this.clone().ineg(); - }), - (BN.prototype.ineg = function () { - return this.isZero() || (this.negative ^= 1), this; - }), - (BN.prototype.iuor = function (num) { - for (; this.length < num.length; ) this.words[this.length++] = 0; - for (var i = 0; i < num.length; i++) this.words[i] = this.words[i] | num.words[i]; - return this.strip(); - }), - (BN.prototype.ior = function (num) { - return assert((this.negative | num.negative) === 0), this.iuor(num); - }), - (BN.prototype.or = function (num) { - return this.length > num.length ? this.clone().ior(num) : num.clone().ior(this); - }), - (BN.prototype.uor = function (num) { - return this.length > num.length ? this.clone().iuor(num) : num.clone().iuor(this); - }), - (BN.prototype.iuand = function (num) { - var b; - this.length > num.length ? (b = num) : (b = this); - for (var i = 0; i < b.length; i++) this.words[i] = this.words[i] & num.words[i]; - return (this.length = b.length), this.strip(); - }), - (BN.prototype.iand = function (num) { - return assert((this.negative | num.negative) === 0), this.iuand(num); - }), - (BN.prototype.and = function (num) { - return this.length > num.length ? this.clone().iand(num) : num.clone().iand(this); - }), - (BN.prototype.uand = function (num) { - return this.length > num.length ? this.clone().iuand(num) : num.clone().iuand(this); - }), - (BN.prototype.iuxor = function (num) { - var a, b; - this.length > num.length ? ((a = this), (b = num)) : ((a = num), (b = this)); - for (var i = 0; i < b.length; i++) this.words[i] = a.words[i] ^ b.words[i]; - if (this !== a) for (; i < a.length; i++) this.words[i] = a.words[i]; - return (this.length = a.length), this.strip(); - }), - (BN.prototype.ixor = function (num) { - return assert((this.negative | num.negative) === 0), this.iuxor(num); - }), - (BN.prototype.xor = function (num) { - return this.length > num.length ? this.clone().ixor(num) : num.clone().ixor(this); - }), - (BN.prototype.uxor = function (num) { - return this.length > num.length ? this.clone().iuxor(num) : num.clone().iuxor(this); - }), - (BN.prototype.inotn = function (width) { - assert(typeof width == "number" && width >= 0); - var bytesNeeded = Math.ceil(width / 26) | 0, - bitsLeft = width % 26; - this._expand(bytesNeeded), bitsLeft > 0 && bytesNeeded--; - for (var i = 0; i < bytesNeeded; i++) this.words[i] = ~this.words[i] & 67108863; - return bitsLeft > 0 && (this.words[i] = ~this.words[i] & (67108863 >> (26 - bitsLeft))), this.strip(); - }), - (BN.prototype.notn = function (width) { - return this.clone().inotn(width); - }), - (BN.prototype.setn = function (bit, val) { - assert(typeof bit == "number" && bit >= 0); - var off = (bit / 26) | 0, - wbit = bit % 26; - return ( - this._expand(off + 1), - val - ? (this.words[off] = this.words[off] | (1 << wbit)) - : (this.words[off] = this.words[off] & ~(1 << wbit)), - this.strip() - ); - }), - (BN.prototype.iadd = function (num) { - var r; - if (this.negative !== 0 && num.negative === 0) - return (this.negative = 0), (r = this.isub(num)), (this.negative ^= 1), this._normSign(); - if (this.negative === 0 && num.negative !== 0) - return (num.negative = 0), (r = this.isub(num)), (num.negative = 1), r._normSign(); - var a, b; - this.length > num.length ? ((a = this), (b = num)) : ((a = num), (b = this)); - for (var carry = 0, i = 0; i < b.length; i++) - (r = (a.words[i] | 0) + (b.words[i] | 0) + carry), (this.words[i] = r & 67108863), (carry = r >>> 26); - for (; carry !== 0 && i < a.length; i++) - (r = (a.words[i] | 0) + carry), (this.words[i] = r & 67108863), (carry = r >>> 26); - if (((this.length = a.length), carry !== 0)) (this.words[this.length] = carry), this.length++; - else if (a !== this) for (; i < a.length; i++) this.words[i] = a.words[i]; - return this; - }), - (BN.prototype.add = function (num) { - var res; - return num.negative !== 0 && this.negative === 0 - ? ((num.negative = 0), (res = this.sub(num)), (num.negative ^= 1), res) - : num.negative === 0 && this.negative !== 0 - ? ((this.negative = 0), (res = num.sub(this)), (this.negative = 1), res) - : this.length > num.length - ? this.clone().iadd(num) - : num.clone().iadd(this); - }), - (BN.prototype.isub = function (num) { - if (num.negative !== 0) { - num.negative = 0; - var r = this.iadd(num); - return (num.negative = 1), r._normSign(); - } else if (this.negative !== 0) - return (this.negative = 0), this.iadd(num), (this.negative = 1), this._normSign(); - var cmp = this.cmp(num); - if (cmp === 0) return (this.negative = 0), (this.length = 1), (this.words[0] = 0), this; - var a, b; - cmp > 0 ? ((a = this), (b = num)) : ((a = num), (b = this)); - for (var carry = 0, i = 0; i < b.length; i++) - (r = (a.words[i] | 0) - (b.words[i] | 0) + carry), (carry = r >> 26), (this.words[i] = r & 67108863); - for (; carry !== 0 && i < a.length; i++) - (r = (a.words[i] | 0) + carry), (carry = r >> 26), (this.words[i] = r & 67108863); - if (carry === 0 && i < a.length && a !== this) for (; i < a.length; i++) this.words[i] = a.words[i]; - return (this.length = Math.max(this.length, i)), a !== this && (this.negative = 1), this.strip(); - }), - (BN.prototype.sub = function (num) { - return this.clone().isub(num); - }); - function smallMulTo(self2, num, out) { - out.negative = num.negative ^ self2.negative; - var len = (self2.length + num.length) | 0; - (out.length = len), (len = (len - 1) | 0); - var a = self2.words[0] | 0, - b = num.words[0] | 0, - r = a * b, - lo = r & 67108863, - carry = (r / 67108864) | 0; - out.words[0] = lo; - for (var k = 1; k < len; k++) { - for ( - var ncarry = carry >>> 26, - rword = carry & 67108863, - maxJ = Math.min(k, num.length - 1), - j = Math.max(0, k - self2.length + 1); - j <= maxJ; - j++ - ) { - var i = (k - j) | 0; - (a = self2.words[i] | 0), - (b = num.words[j] | 0), - (r = a * b + rword), - (ncarry += (r / 67108864) | 0), - (rword = r & 67108863); - } - (out.words[k] = rword | 0), (carry = ncarry | 0); - } - return carry !== 0 ? (out.words[k] = carry | 0) : out.length--, out.strip(); - } - var comb10MulTo = function (self2, num, out) { - var a = self2.words, - b = num.words, - o = out.words, - c = 0, - lo, - mid, - hi, - a0 = a[0] | 0, - al0 = a0 & 8191, - ah0 = a0 >>> 13, - a1 = a[1] | 0, - al1 = a1 & 8191, - ah1 = a1 >>> 13, - a2 = a[2] | 0, - al2 = a2 & 8191, - ah2 = a2 >>> 13, - a3 = a[3] | 0, - al3 = a3 & 8191, - ah3 = a3 >>> 13, - a4 = a[4] | 0, - al4 = a4 & 8191, - ah4 = a4 >>> 13, - a5 = a[5] | 0, - al5 = a5 & 8191, - ah5 = a5 >>> 13, - a6 = a[6] | 0, - al6 = a6 & 8191, - ah6 = a6 >>> 13, - a7 = a[7] | 0, - al7 = a7 & 8191, - ah7 = a7 >>> 13, - a8 = a[8] | 0, - al8 = a8 & 8191, - ah8 = a8 >>> 13, - a9 = a[9] | 0, - al9 = a9 & 8191, - ah9 = a9 >>> 13, - b0 = b[0] | 0, - bl0 = b0 & 8191, - bh0 = b0 >>> 13, - b1 = b[1] | 0, - bl1 = b1 & 8191, - bh1 = b1 >>> 13, - b2 = b[2] | 0, - bl2 = b2 & 8191, - bh2 = b2 >>> 13, - b3 = b[3] | 0, - bl3 = b3 & 8191, - bh3 = b3 >>> 13, - b4 = b[4] | 0, - bl4 = b4 & 8191, - bh4 = b4 >>> 13, - b5 = b[5] | 0, - bl5 = b5 & 8191, - bh5 = b5 >>> 13, - b6 = b[6] | 0, - bl6 = b6 & 8191, - bh6 = b6 >>> 13, - b7 = b[7] | 0, - bl7 = b7 & 8191, - bh7 = b7 >>> 13, - b8 = b[8] | 0, - bl8 = b8 & 8191, - bh8 = b8 >>> 13, - b9 = b[9] | 0, - bl9 = b9 & 8191, - bh9 = b9 >>> 13; - (out.negative = self2.negative ^ num.negative), - (out.length = 19), - (lo = Math.imul(al0, bl0)), - (mid = Math.imul(al0, bh0)), - (mid = (mid + Math.imul(ah0, bl0)) | 0), - (hi = Math.imul(ah0, bh0)); - var w0 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0), - (w0 &= 67108863), - (lo = Math.imul(al1, bl0)), - (mid = Math.imul(al1, bh0)), - (mid = (mid + Math.imul(ah1, bl0)) | 0), - (hi = Math.imul(ah1, bh0)), - (lo = (lo + Math.imul(al0, bl1)) | 0), - (mid = (mid + Math.imul(al0, bh1)) | 0), - (mid = (mid + Math.imul(ah0, bl1)) | 0), - (hi = (hi + Math.imul(ah0, bh1)) | 0); - var w1 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0), - (w1 &= 67108863), - (lo = Math.imul(al2, bl0)), - (mid = Math.imul(al2, bh0)), - (mid = (mid + Math.imul(ah2, bl0)) | 0), - (hi = Math.imul(ah2, bh0)), - (lo = (lo + Math.imul(al1, bl1)) | 0), - (mid = (mid + Math.imul(al1, bh1)) | 0), - (mid = (mid + Math.imul(ah1, bl1)) | 0), - (hi = (hi + Math.imul(ah1, bh1)) | 0), - (lo = (lo + Math.imul(al0, bl2)) | 0), - (mid = (mid + Math.imul(al0, bh2)) | 0), - (mid = (mid + Math.imul(ah0, bl2)) | 0), - (hi = (hi + Math.imul(ah0, bh2)) | 0); - var w2 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0), - (w2 &= 67108863), - (lo = Math.imul(al3, bl0)), - (mid = Math.imul(al3, bh0)), - (mid = (mid + Math.imul(ah3, bl0)) | 0), - (hi = Math.imul(ah3, bh0)), - (lo = (lo + Math.imul(al2, bl1)) | 0), - (mid = (mid + Math.imul(al2, bh1)) | 0), - (mid = (mid + Math.imul(ah2, bl1)) | 0), - (hi = (hi + Math.imul(ah2, bh1)) | 0), - (lo = (lo + Math.imul(al1, bl2)) | 0), - (mid = (mid + Math.imul(al1, bh2)) | 0), - (mid = (mid + Math.imul(ah1, bl2)) | 0), - (hi = (hi + Math.imul(ah1, bh2)) | 0), - (lo = (lo + Math.imul(al0, bl3)) | 0), - (mid = (mid + Math.imul(al0, bh3)) | 0), - (mid = (mid + Math.imul(ah0, bl3)) | 0), - (hi = (hi + Math.imul(ah0, bh3)) | 0); - var w3 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0), - (w3 &= 67108863), - (lo = Math.imul(al4, bl0)), - (mid = Math.imul(al4, bh0)), - (mid = (mid + Math.imul(ah4, bl0)) | 0), - (hi = Math.imul(ah4, bh0)), - (lo = (lo + Math.imul(al3, bl1)) | 0), - (mid = (mid + Math.imul(al3, bh1)) | 0), - (mid = (mid + Math.imul(ah3, bl1)) | 0), - (hi = (hi + Math.imul(ah3, bh1)) | 0), - (lo = (lo + Math.imul(al2, bl2)) | 0), - (mid = (mid + Math.imul(al2, bh2)) | 0), - (mid = (mid + Math.imul(ah2, bl2)) | 0), - (hi = (hi + Math.imul(ah2, bh2)) | 0), - (lo = (lo + Math.imul(al1, bl3)) | 0), - (mid = (mid + Math.imul(al1, bh3)) | 0), - (mid = (mid + Math.imul(ah1, bl3)) | 0), - (hi = (hi + Math.imul(ah1, bh3)) | 0), - (lo = (lo + Math.imul(al0, bl4)) | 0), - (mid = (mid + Math.imul(al0, bh4)) | 0), - (mid = (mid + Math.imul(ah0, bl4)) | 0), - (hi = (hi + Math.imul(ah0, bh4)) | 0); - var w4 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0), - (w4 &= 67108863), - (lo = Math.imul(al5, bl0)), - (mid = Math.imul(al5, bh0)), - (mid = (mid + Math.imul(ah5, bl0)) | 0), - (hi = Math.imul(ah5, bh0)), - (lo = (lo + Math.imul(al4, bl1)) | 0), - (mid = (mid + Math.imul(al4, bh1)) | 0), - (mid = (mid + Math.imul(ah4, bl1)) | 0), - (hi = (hi + Math.imul(ah4, bh1)) | 0), - (lo = (lo + Math.imul(al3, bl2)) | 0), - (mid = (mid + Math.imul(al3, bh2)) | 0), - (mid = (mid + Math.imul(ah3, bl2)) | 0), - (hi = (hi + Math.imul(ah3, bh2)) | 0), - (lo = (lo + Math.imul(al2, bl3)) | 0), - (mid = (mid + Math.imul(al2, bh3)) | 0), - (mid = (mid + Math.imul(ah2, bl3)) | 0), - (hi = (hi + Math.imul(ah2, bh3)) | 0), - (lo = (lo + Math.imul(al1, bl4)) | 0), - (mid = (mid + Math.imul(al1, bh4)) | 0), - (mid = (mid + Math.imul(ah1, bl4)) | 0), - (hi = (hi + Math.imul(ah1, bh4)) | 0), - (lo = (lo + Math.imul(al0, bl5)) | 0), - (mid = (mid + Math.imul(al0, bh5)) | 0), - (mid = (mid + Math.imul(ah0, bl5)) | 0), - (hi = (hi + Math.imul(ah0, bh5)) | 0); - var w5 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0), - (w5 &= 67108863), - (lo = Math.imul(al6, bl0)), - (mid = Math.imul(al6, bh0)), - (mid = (mid + Math.imul(ah6, bl0)) | 0), - (hi = Math.imul(ah6, bh0)), - (lo = (lo + Math.imul(al5, bl1)) | 0), - (mid = (mid + Math.imul(al5, bh1)) | 0), - (mid = (mid + Math.imul(ah5, bl1)) | 0), - (hi = (hi + Math.imul(ah5, bh1)) | 0), - (lo = (lo + Math.imul(al4, bl2)) | 0), - (mid = (mid + Math.imul(al4, bh2)) | 0), - (mid = (mid + Math.imul(ah4, bl2)) | 0), - (hi = (hi + Math.imul(ah4, bh2)) | 0), - (lo = (lo + Math.imul(al3, bl3)) | 0), - (mid = (mid + Math.imul(al3, bh3)) | 0), - (mid = (mid + Math.imul(ah3, bl3)) | 0), - (hi = (hi + Math.imul(ah3, bh3)) | 0), - (lo = (lo + Math.imul(al2, bl4)) | 0), - (mid = (mid + Math.imul(al2, bh4)) | 0), - (mid = (mid + Math.imul(ah2, bl4)) | 0), - (hi = (hi + Math.imul(ah2, bh4)) | 0), - (lo = (lo + Math.imul(al1, bl5)) | 0), - (mid = (mid + Math.imul(al1, bh5)) | 0), - (mid = (mid + Math.imul(ah1, bl5)) | 0), - (hi = (hi + Math.imul(ah1, bh5)) | 0), - (lo = (lo + Math.imul(al0, bl6)) | 0), - (mid = (mid + Math.imul(al0, bh6)) | 0), - (mid = (mid + Math.imul(ah0, bl6)) | 0), - (hi = (hi + Math.imul(ah0, bh6)) | 0); - var w6 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0), - (w6 &= 67108863), - (lo = Math.imul(al7, bl0)), - (mid = Math.imul(al7, bh0)), - (mid = (mid + Math.imul(ah7, bl0)) | 0), - (hi = Math.imul(ah7, bh0)), - (lo = (lo + Math.imul(al6, bl1)) | 0), - (mid = (mid + Math.imul(al6, bh1)) | 0), - (mid = (mid + Math.imul(ah6, bl1)) | 0), - (hi = (hi + Math.imul(ah6, bh1)) | 0), - (lo = (lo + Math.imul(al5, bl2)) | 0), - (mid = (mid + Math.imul(al5, bh2)) | 0), - (mid = (mid + Math.imul(ah5, bl2)) | 0), - (hi = (hi + Math.imul(ah5, bh2)) | 0), - (lo = (lo + Math.imul(al4, bl3)) | 0), - (mid = (mid + Math.imul(al4, bh3)) | 0), - (mid = (mid + Math.imul(ah4, bl3)) | 0), - (hi = (hi + Math.imul(ah4, bh3)) | 0), - (lo = (lo + Math.imul(al3, bl4)) | 0), - (mid = (mid + Math.imul(al3, bh4)) | 0), - (mid = (mid + Math.imul(ah3, bl4)) | 0), - (hi = (hi + Math.imul(ah3, bh4)) | 0), - (lo = (lo + Math.imul(al2, bl5)) | 0), - (mid = (mid + Math.imul(al2, bh5)) | 0), - (mid = (mid + Math.imul(ah2, bl5)) | 0), - (hi = (hi + Math.imul(ah2, bh5)) | 0), - (lo = (lo + Math.imul(al1, bl6)) | 0), - (mid = (mid + Math.imul(al1, bh6)) | 0), - (mid = (mid + Math.imul(ah1, bl6)) | 0), - (hi = (hi + Math.imul(ah1, bh6)) | 0), - (lo = (lo + Math.imul(al0, bl7)) | 0), - (mid = (mid + Math.imul(al0, bh7)) | 0), - (mid = (mid + Math.imul(ah0, bl7)) | 0), - (hi = (hi + Math.imul(ah0, bh7)) | 0); - var w7 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0), - (w7 &= 67108863), - (lo = Math.imul(al8, bl0)), - (mid = Math.imul(al8, bh0)), - (mid = (mid + Math.imul(ah8, bl0)) | 0), - (hi = Math.imul(ah8, bh0)), - (lo = (lo + Math.imul(al7, bl1)) | 0), - (mid = (mid + Math.imul(al7, bh1)) | 0), - (mid = (mid + Math.imul(ah7, bl1)) | 0), - (hi = (hi + Math.imul(ah7, bh1)) | 0), - (lo = (lo + Math.imul(al6, bl2)) | 0), - (mid = (mid + Math.imul(al6, bh2)) | 0), - (mid = (mid + Math.imul(ah6, bl2)) | 0), - (hi = (hi + Math.imul(ah6, bh2)) | 0), - (lo = (lo + Math.imul(al5, bl3)) | 0), - (mid = (mid + Math.imul(al5, bh3)) | 0), - (mid = (mid + Math.imul(ah5, bl3)) | 0), - (hi = (hi + Math.imul(ah5, bh3)) | 0), - (lo = (lo + Math.imul(al4, bl4)) | 0), - (mid = (mid + Math.imul(al4, bh4)) | 0), - (mid = (mid + Math.imul(ah4, bl4)) | 0), - (hi = (hi + Math.imul(ah4, bh4)) | 0), - (lo = (lo + Math.imul(al3, bl5)) | 0), - (mid = (mid + Math.imul(al3, bh5)) | 0), - (mid = (mid + Math.imul(ah3, bl5)) | 0), - (hi = (hi + Math.imul(ah3, bh5)) | 0), - (lo = (lo + Math.imul(al2, bl6)) | 0), - (mid = (mid + Math.imul(al2, bh6)) | 0), - (mid = (mid + Math.imul(ah2, bl6)) | 0), - (hi = (hi + Math.imul(ah2, bh6)) | 0), - (lo = (lo + Math.imul(al1, bl7)) | 0), - (mid = (mid + Math.imul(al1, bh7)) | 0), - (mid = (mid + Math.imul(ah1, bl7)) | 0), - (hi = (hi + Math.imul(ah1, bh7)) | 0), - (lo = (lo + Math.imul(al0, bl8)) | 0), - (mid = (mid + Math.imul(al0, bh8)) | 0), - (mid = (mid + Math.imul(ah0, bl8)) | 0), - (hi = (hi + Math.imul(ah0, bh8)) | 0); - var w8 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0), - (w8 &= 67108863), - (lo = Math.imul(al9, bl0)), - (mid = Math.imul(al9, bh0)), - (mid = (mid + Math.imul(ah9, bl0)) | 0), - (hi = Math.imul(ah9, bh0)), - (lo = (lo + Math.imul(al8, bl1)) | 0), - (mid = (mid + Math.imul(al8, bh1)) | 0), - (mid = (mid + Math.imul(ah8, bl1)) | 0), - (hi = (hi + Math.imul(ah8, bh1)) | 0), - (lo = (lo + Math.imul(al7, bl2)) | 0), - (mid = (mid + Math.imul(al7, bh2)) | 0), - (mid = (mid + Math.imul(ah7, bl2)) | 0), - (hi = (hi + Math.imul(ah7, bh2)) | 0), - (lo = (lo + Math.imul(al6, bl3)) | 0), - (mid = (mid + Math.imul(al6, bh3)) | 0), - (mid = (mid + Math.imul(ah6, bl3)) | 0), - (hi = (hi + Math.imul(ah6, bh3)) | 0), - (lo = (lo + Math.imul(al5, bl4)) | 0), - (mid = (mid + Math.imul(al5, bh4)) | 0), - (mid = (mid + Math.imul(ah5, bl4)) | 0), - (hi = (hi + Math.imul(ah5, bh4)) | 0), - (lo = (lo + Math.imul(al4, bl5)) | 0), - (mid = (mid + Math.imul(al4, bh5)) | 0), - (mid = (mid + Math.imul(ah4, bl5)) | 0), - (hi = (hi + Math.imul(ah4, bh5)) | 0), - (lo = (lo + Math.imul(al3, bl6)) | 0), - (mid = (mid + Math.imul(al3, bh6)) | 0), - (mid = (mid + Math.imul(ah3, bl6)) | 0), - (hi = (hi + Math.imul(ah3, bh6)) | 0), - (lo = (lo + Math.imul(al2, bl7)) | 0), - (mid = (mid + Math.imul(al2, bh7)) | 0), - (mid = (mid + Math.imul(ah2, bl7)) | 0), - (hi = (hi + Math.imul(ah2, bh7)) | 0), - (lo = (lo + Math.imul(al1, bl8)) | 0), - (mid = (mid + Math.imul(al1, bh8)) | 0), - (mid = (mid + Math.imul(ah1, bl8)) | 0), - (hi = (hi + Math.imul(ah1, bh8)) | 0), - (lo = (lo + Math.imul(al0, bl9)) | 0), - (mid = (mid + Math.imul(al0, bh9)) | 0), - (mid = (mid + Math.imul(ah0, bl9)) | 0), - (hi = (hi + Math.imul(ah0, bh9)) | 0); - var w9 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0), - (w9 &= 67108863), - (lo = Math.imul(al9, bl1)), - (mid = Math.imul(al9, bh1)), - (mid = (mid + Math.imul(ah9, bl1)) | 0), - (hi = Math.imul(ah9, bh1)), - (lo = (lo + Math.imul(al8, bl2)) | 0), - (mid = (mid + Math.imul(al8, bh2)) | 0), - (mid = (mid + Math.imul(ah8, bl2)) | 0), - (hi = (hi + Math.imul(ah8, bh2)) | 0), - (lo = (lo + Math.imul(al7, bl3)) | 0), - (mid = (mid + Math.imul(al7, bh3)) | 0), - (mid = (mid + Math.imul(ah7, bl3)) | 0), - (hi = (hi + Math.imul(ah7, bh3)) | 0), - (lo = (lo + Math.imul(al6, bl4)) | 0), - (mid = (mid + Math.imul(al6, bh4)) | 0), - (mid = (mid + Math.imul(ah6, bl4)) | 0), - (hi = (hi + Math.imul(ah6, bh4)) | 0), - (lo = (lo + Math.imul(al5, bl5)) | 0), - (mid = (mid + Math.imul(al5, bh5)) | 0), - (mid = (mid + Math.imul(ah5, bl5)) | 0), - (hi = (hi + Math.imul(ah5, bh5)) | 0), - (lo = (lo + Math.imul(al4, bl6)) | 0), - (mid = (mid + Math.imul(al4, bh6)) | 0), - (mid = (mid + Math.imul(ah4, bl6)) | 0), - (hi = (hi + Math.imul(ah4, bh6)) | 0), - (lo = (lo + Math.imul(al3, bl7)) | 0), - (mid = (mid + Math.imul(al3, bh7)) | 0), - (mid = (mid + Math.imul(ah3, bl7)) | 0), - (hi = (hi + Math.imul(ah3, bh7)) | 0), - (lo = (lo + Math.imul(al2, bl8)) | 0), - (mid = (mid + Math.imul(al2, bh8)) | 0), - (mid = (mid + Math.imul(ah2, bl8)) | 0), - (hi = (hi + Math.imul(ah2, bh8)) | 0), - (lo = (lo + Math.imul(al1, bl9)) | 0), - (mid = (mid + Math.imul(al1, bh9)) | 0), - (mid = (mid + Math.imul(ah1, bl9)) | 0), - (hi = (hi + Math.imul(ah1, bh9)) | 0); - var w10 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0), - (w10 &= 67108863), - (lo = Math.imul(al9, bl2)), - (mid = Math.imul(al9, bh2)), - (mid = (mid + Math.imul(ah9, bl2)) | 0), - (hi = Math.imul(ah9, bh2)), - (lo = (lo + Math.imul(al8, bl3)) | 0), - (mid = (mid + Math.imul(al8, bh3)) | 0), - (mid = (mid + Math.imul(ah8, bl3)) | 0), - (hi = (hi + Math.imul(ah8, bh3)) | 0), - (lo = (lo + Math.imul(al7, bl4)) | 0), - (mid = (mid + Math.imul(al7, bh4)) | 0), - (mid = (mid + Math.imul(ah7, bl4)) | 0), - (hi = (hi + Math.imul(ah7, bh4)) | 0), - (lo = (lo + Math.imul(al6, bl5)) | 0), - (mid = (mid + Math.imul(al6, bh5)) | 0), - (mid = (mid + Math.imul(ah6, bl5)) | 0), - (hi = (hi + Math.imul(ah6, bh5)) | 0), - (lo = (lo + Math.imul(al5, bl6)) | 0), - (mid = (mid + Math.imul(al5, bh6)) | 0), - (mid = (mid + Math.imul(ah5, bl6)) | 0), - (hi = (hi + Math.imul(ah5, bh6)) | 0), - (lo = (lo + Math.imul(al4, bl7)) | 0), - (mid = (mid + Math.imul(al4, bh7)) | 0), - (mid = (mid + Math.imul(ah4, bl7)) | 0), - (hi = (hi + Math.imul(ah4, bh7)) | 0), - (lo = (lo + Math.imul(al3, bl8)) | 0), - (mid = (mid + Math.imul(al3, bh8)) | 0), - (mid = (mid + Math.imul(ah3, bl8)) | 0), - (hi = (hi + Math.imul(ah3, bh8)) | 0), - (lo = (lo + Math.imul(al2, bl9)) | 0), - (mid = (mid + Math.imul(al2, bh9)) | 0), - (mid = (mid + Math.imul(ah2, bl9)) | 0), - (hi = (hi + Math.imul(ah2, bh9)) | 0); - var w11 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0), - (w11 &= 67108863), - (lo = Math.imul(al9, bl3)), - (mid = Math.imul(al9, bh3)), - (mid = (mid + Math.imul(ah9, bl3)) | 0), - (hi = Math.imul(ah9, bh3)), - (lo = (lo + Math.imul(al8, bl4)) | 0), - (mid = (mid + Math.imul(al8, bh4)) | 0), - (mid = (mid + Math.imul(ah8, bl4)) | 0), - (hi = (hi + Math.imul(ah8, bh4)) | 0), - (lo = (lo + Math.imul(al7, bl5)) | 0), - (mid = (mid + Math.imul(al7, bh5)) | 0), - (mid = (mid + Math.imul(ah7, bl5)) | 0), - (hi = (hi + Math.imul(ah7, bh5)) | 0), - (lo = (lo + Math.imul(al6, bl6)) | 0), - (mid = (mid + Math.imul(al6, bh6)) | 0), - (mid = (mid + Math.imul(ah6, bl6)) | 0), - (hi = (hi + Math.imul(ah6, bh6)) | 0), - (lo = (lo + Math.imul(al5, bl7)) | 0), - (mid = (mid + Math.imul(al5, bh7)) | 0), - (mid = (mid + Math.imul(ah5, bl7)) | 0), - (hi = (hi + Math.imul(ah5, bh7)) | 0), - (lo = (lo + Math.imul(al4, bl8)) | 0), - (mid = (mid + Math.imul(al4, bh8)) | 0), - (mid = (mid + Math.imul(ah4, bl8)) | 0), - (hi = (hi + Math.imul(ah4, bh8)) | 0), - (lo = (lo + Math.imul(al3, bl9)) | 0), - (mid = (mid + Math.imul(al3, bh9)) | 0), - (mid = (mid + Math.imul(ah3, bl9)) | 0), - (hi = (hi + Math.imul(ah3, bh9)) | 0); - var w12 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0), - (w12 &= 67108863), - (lo = Math.imul(al9, bl4)), - (mid = Math.imul(al9, bh4)), - (mid = (mid + Math.imul(ah9, bl4)) | 0), - (hi = Math.imul(ah9, bh4)), - (lo = (lo + Math.imul(al8, bl5)) | 0), - (mid = (mid + Math.imul(al8, bh5)) | 0), - (mid = (mid + Math.imul(ah8, bl5)) | 0), - (hi = (hi + Math.imul(ah8, bh5)) | 0), - (lo = (lo + Math.imul(al7, bl6)) | 0), - (mid = (mid + Math.imul(al7, bh6)) | 0), - (mid = (mid + Math.imul(ah7, bl6)) | 0), - (hi = (hi + Math.imul(ah7, bh6)) | 0), - (lo = (lo + Math.imul(al6, bl7)) | 0), - (mid = (mid + Math.imul(al6, bh7)) | 0), - (mid = (mid + Math.imul(ah6, bl7)) | 0), - (hi = (hi + Math.imul(ah6, bh7)) | 0), - (lo = (lo + Math.imul(al5, bl8)) | 0), - (mid = (mid + Math.imul(al5, bh8)) | 0), - (mid = (mid + Math.imul(ah5, bl8)) | 0), - (hi = (hi + Math.imul(ah5, bh8)) | 0), - (lo = (lo + Math.imul(al4, bl9)) | 0), - (mid = (mid + Math.imul(al4, bh9)) | 0), - (mid = (mid + Math.imul(ah4, bl9)) | 0), - (hi = (hi + Math.imul(ah4, bh9)) | 0); - var w13 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0), - (w13 &= 67108863), - (lo = Math.imul(al9, bl5)), - (mid = Math.imul(al9, bh5)), - (mid = (mid + Math.imul(ah9, bl5)) | 0), - (hi = Math.imul(ah9, bh5)), - (lo = (lo + Math.imul(al8, bl6)) | 0), - (mid = (mid + Math.imul(al8, bh6)) | 0), - (mid = (mid + Math.imul(ah8, bl6)) | 0), - (hi = (hi + Math.imul(ah8, bh6)) | 0), - (lo = (lo + Math.imul(al7, bl7)) | 0), - (mid = (mid + Math.imul(al7, bh7)) | 0), - (mid = (mid + Math.imul(ah7, bl7)) | 0), - (hi = (hi + Math.imul(ah7, bh7)) | 0), - (lo = (lo + Math.imul(al6, bl8)) | 0), - (mid = (mid + Math.imul(al6, bh8)) | 0), - (mid = (mid + Math.imul(ah6, bl8)) | 0), - (hi = (hi + Math.imul(ah6, bh8)) | 0), - (lo = (lo + Math.imul(al5, bl9)) | 0), - (mid = (mid + Math.imul(al5, bh9)) | 0), - (mid = (mid + Math.imul(ah5, bl9)) | 0), - (hi = (hi + Math.imul(ah5, bh9)) | 0); - var w14 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0), - (w14 &= 67108863), - (lo = Math.imul(al9, bl6)), - (mid = Math.imul(al9, bh6)), - (mid = (mid + Math.imul(ah9, bl6)) | 0), - (hi = Math.imul(ah9, bh6)), - (lo = (lo + Math.imul(al8, bl7)) | 0), - (mid = (mid + Math.imul(al8, bh7)) | 0), - (mid = (mid + Math.imul(ah8, bl7)) | 0), - (hi = (hi + Math.imul(ah8, bh7)) | 0), - (lo = (lo + Math.imul(al7, bl8)) | 0), - (mid = (mid + Math.imul(al7, bh8)) | 0), - (mid = (mid + Math.imul(ah7, bl8)) | 0), - (hi = (hi + Math.imul(ah7, bh8)) | 0), - (lo = (lo + Math.imul(al6, bl9)) | 0), - (mid = (mid + Math.imul(al6, bh9)) | 0), - (mid = (mid + Math.imul(ah6, bl9)) | 0), - (hi = (hi + Math.imul(ah6, bh9)) | 0); - var w15 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0), - (w15 &= 67108863), - (lo = Math.imul(al9, bl7)), - (mid = Math.imul(al9, bh7)), - (mid = (mid + Math.imul(ah9, bl7)) | 0), - (hi = Math.imul(ah9, bh7)), - (lo = (lo + Math.imul(al8, bl8)) | 0), - (mid = (mid + Math.imul(al8, bh8)) | 0), - (mid = (mid + Math.imul(ah8, bl8)) | 0), - (hi = (hi + Math.imul(ah8, bh8)) | 0), - (lo = (lo + Math.imul(al7, bl9)) | 0), - (mid = (mid + Math.imul(al7, bh9)) | 0), - (mid = (mid + Math.imul(ah7, bl9)) | 0), - (hi = (hi + Math.imul(ah7, bh9)) | 0); - var w16 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0), - (w16 &= 67108863), - (lo = Math.imul(al9, bl8)), - (mid = Math.imul(al9, bh8)), - (mid = (mid + Math.imul(ah9, bl8)) | 0), - (hi = Math.imul(ah9, bh8)), - (lo = (lo + Math.imul(al8, bl9)) | 0), - (mid = (mid + Math.imul(al8, bh9)) | 0), - (mid = (mid + Math.imul(ah8, bl9)) | 0), - (hi = (hi + Math.imul(ah8, bh9)) | 0); - var w17 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - (c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0), - (w17 &= 67108863), - (lo = Math.imul(al9, bl9)), - (mid = Math.imul(al9, bh9)), - (mid = (mid + Math.imul(ah9, bl9)) | 0), - (hi = Math.imul(ah9, bh9)); - var w18 = (((c + lo) | 0) + ((mid & 8191) << 13)) | 0; - return ( - (c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0), - (w18 &= 67108863), - (o[0] = w0), - (o[1] = w1), - (o[2] = w2), - (o[3] = w3), - (o[4] = w4), - (o[5] = w5), - (o[6] = w6), - (o[7] = w7), - (o[8] = w8), - (o[9] = w9), - (o[10] = w10), - (o[11] = w11), - (o[12] = w12), - (o[13] = w13), - (o[14] = w14), - (o[15] = w15), - (o[16] = w16), - (o[17] = w17), - (o[18] = w18), - c !== 0 && ((o[19] = c), out.length++), - out - ); - }; - Math.imul || (comb10MulTo = smallMulTo); - function bigMulTo(self2, num, out) { - (out.negative = num.negative ^ self2.negative), (out.length = self2.length + num.length); - for (var carry = 0, hncarry = 0, k = 0; k < out.length - 1; k++) { - var ncarry = hncarry; - hncarry = 0; - for ( - var rword = carry & 67108863, maxJ = Math.min(k, num.length - 1), j = Math.max(0, k - self2.length + 1); - j <= maxJ; - j++ - ) { - var i = k - j, - a = self2.words[i] | 0, - b = num.words[j] | 0, - r = a * b, - lo = r & 67108863; - (ncarry = (ncarry + ((r / 67108864) | 0)) | 0), - (lo = (lo + rword) | 0), - (rword = lo & 67108863), - (ncarry = (ncarry + (lo >>> 26)) | 0), - (hncarry += ncarry >>> 26), - (ncarry &= 67108863); - } - (out.words[k] = rword), (carry = ncarry), (ncarry = hncarry); - } - return carry !== 0 ? (out.words[k] = carry) : out.length--, out.strip(); - } - function jumboMulTo(self2, num, out) { - var fftm = new FFTM(); - return fftm.mulp(self2, num, out); - } - BN.prototype.mulTo = function (num, out) { - var res, - len = this.length + num.length; - return ( - this.length === 10 && num.length === 10 - ? (res = comb10MulTo(this, num, out)) - : len < 63 - ? (res = smallMulTo(this, num, out)) - : len < 1024 - ? (res = bigMulTo(this, num, out)) - : (res = jumboMulTo(this, num, out)), - res - ); - }; - function FFTM(x, y) { - (this.x = x), (this.y = y); - } - (FFTM.prototype.makeRBT = function (N) { - for (var t = new Array(N), l = BN.prototype._countBits(N) - 1, i = 0; i < N; i++) t[i] = this.revBin(i, l, N); - return t; - }), - (FFTM.prototype.revBin = function (x, l, N) { - if (x === 0 || x === N - 1) return x; - for (var rb = 0, i = 0; i < l; i++) (rb |= (x & 1) << (l - i - 1)), (x >>= 1); - return rb; - }), - (FFTM.prototype.permute = function (rbt, rws, iws, rtws, itws, N) { - for (var i = 0; i < N; i++) (rtws[i] = rws[rbt[i]]), (itws[i] = iws[rbt[i]]); - }), - (FFTM.prototype.transform = function (rws, iws, rtws, itws, N, rbt) { - this.permute(rbt, rws, iws, rtws, itws, N); - for (var s = 1; s < N; s <<= 1) - for ( - var l = s << 1, rtwdf = Math.cos((2 * Math.PI) / l), itwdf = Math.sin((2 * Math.PI) / l), p = 0; - p < N; - p += l - ) - for (var rtwdf_ = rtwdf, itwdf_ = itwdf, j = 0; j < s; j++) { - var re = rtws[p + j], - ie = itws[p + j], - ro = rtws[p + j + s], - io = itws[p + j + s], - rx = rtwdf_ * ro - itwdf_ * io; - (io = rtwdf_ * io + itwdf_ * ro), - (ro = rx), - (rtws[p + j] = re + ro), - (itws[p + j] = ie + io), - (rtws[p + j + s] = re - ro), - (itws[p + j + s] = ie - io), - j !== l && - ((rx = rtwdf * rtwdf_ - itwdf * itwdf_), (itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_), (rtwdf_ = rx)); - } - }), - (FFTM.prototype.guessLen13b = function (n, m) { - var N = Math.max(m, n) | 1, - odd = N & 1, - i = 0; - for (N = (N / 2) | 0; N; N = N >>> 1) i++; - return 1 << (i + 1 + odd); - }), - (FFTM.prototype.conjugate = function (rws, iws, N) { - if (!(N <= 1)) - for (var i = 0; i < N / 2; i++) { - var t = rws[i]; - (rws[i] = rws[N - i - 1]), - (rws[N - i - 1] = t), - (t = iws[i]), - (iws[i] = -iws[N - i - 1]), - (iws[N - i - 1] = -t); - } - }), - (FFTM.prototype.normalize13b = function (ws, N) { - for (var carry = 0, i = 0; i < N / 2; i++) { - var w = Math.round(ws[2 * i + 1] / N) * 8192 + Math.round(ws[2 * i] / N) + carry; - (ws[i] = w & 67108863), w < 67108864 ? (carry = 0) : (carry = (w / 67108864) | 0); - } - return ws; - }), - (FFTM.prototype.convert13b = function (ws, len, rws, N) { - for (var carry = 0, i = 0; i < len; i++) - (carry = carry + (ws[i] | 0)), - (rws[2 * i] = carry & 8191), - (carry = carry >>> 13), - (rws[2 * i + 1] = carry & 8191), - (carry = carry >>> 13); - for (i = 2 * len; i < N; ++i) rws[i] = 0; - assert(carry === 0), assert((carry & -8192) === 0); - }), - (FFTM.prototype.stub = function (N) { - for (var ph = new Array(N), i = 0; i < N; i++) ph[i] = 0; - return ph; - }), - (FFTM.prototype.mulp = function (x, y, out) { - var N = 2 * this.guessLen13b(x.length, y.length), - rbt = this.makeRBT(N), - _ = this.stub(N), - rws = new Array(N), - rwst = new Array(N), - iwst = new Array(N), - nrws = new Array(N), - nrwst = new Array(N), - niwst = new Array(N), - rmws = out.words; - (rmws.length = N), - this.convert13b(x.words, x.length, rws, N), - this.convert13b(y.words, y.length, nrws, N), - this.transform(rws, _, rwst, iwst, N, rbt), - this.transform(nrws, _, nrwst, niwst, N, rbt); - for (var i = 0; i < N; i++) { - var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i]; - (iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i]), (rwst[i] = rx); - } - return ( - this.conjugate(rwst, iwst, N), - this.transform(rwst, iwst, rmws, _, N, rbt), - this.conjugate(rmws, _, N), - this.normalize13b(rmws, N), - (out.negative = x.negative ^ y.negative), - (out.length = x.length + y.length), - out.strip() - ); - }), - (BN.prototype.mul = function (num) { - var out = new BN(null); - return (out.words = new Array(this.length + num.length)), this.mulTo(num, out); - }), - (BN.prototype.mulf = function (num) { - var out = new BN(null); - return (out.words = new Array(this.length + num.length)), jumboMulTo(this, num, out); - }), - (BN.prototype.imul = function (num) { - return this.clone().mulTo(num, this); - }), - (BN.prototype.imuln = function (num) { - assert(typeof num == "number"), assert(num < 67108864); - for (var carry = 0, i = 0; i < this.length; i++) { - var w = (this.words[i] | 0) * num, - lo = (w & 67108863) + (carry & 67108863); - (carry >>= 26), (carry += (w / 67108864) | 0), (carry += lo >>> 26), (this.words[i] = lo & 67108863); - } - return carry !== 0 && ((this.words[i] = carry), this.length++), this; - }), - (BN.prototype.muln = function (num) { - return this.clone().imuln(num); - }), - (BN.prototype.sqr = function () { - return this.mul(this); - }), - (BN.prototype.isqr = function () { - return this.imul(this.clone()); - }), - (BN.prototype.pow = function (num) { - var w = toBitArray(num); - if (w.length === 0) return new BN(1); - for (var res = this, i = 0; i < w.length && w[i] === 0; i++, res = res.sqr()); - if (++i < w.length) for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) w[i] !== 0 && (res = res.mul(q)); - return res; - }), - (BN.prototype.iushln = function (bits) { - assert(typeof bits == "number" && bits >= 0); - var r = bits % 26, - s = (bits - r) / 26, - carryMask = (67108863 >>> (26 - r)) << (26 - r), - i; - if (r !== 0) { - var carry = 0; - for (i = 0; i < this.length; i++) { - var newCarry = this.words[i] & carryMask, - c = ((this.words[i] | 0) - newCarry) << r; - (this.words[i] = c | carry), (carry = newCarry >>> (26 - r)); - } - carry && ((this.words[i] = carry), this.length++); - } - if (s !== 0) { - for (i = this.length - 1; i >= 0; i--) this.words[i + s] = this.words[i]; - for (i = 0; i < s; i++) this.words[i] = 0; - this.length += s; - } - return this.strip(); - }), - (BN.prototype.ishln = function (bits) { - return assert(this.negative === 0), this.iushln(bits); - }), - (BN.prototype.iushrn = function (bits, hint, extended) { - assert(typeof bits == "number" && bits >= 0); - var h; - hint ? (h = (hint - (hint % 26)) / 26) : (h = 0); - var r = bits % 26, - s = Math.min((bits - r) / 26, this.length), - mask = 67108863 ^ ((67108863 >>> r) << r), - maskedWords = extended; - if (((h -= s), (h = Math.max(0, h)), maskedWords)) { - for (var i = 0; i < s; i++) maskedWords.words[i] = this.words[i]; - maskedWords.length = s; - } - if (s !== 0) - if (this.length > s) for (this.length -= s, i = 0; i < this.length; i++) this.words[i] = this.words[i + s]; - else (this.words[0] = 0), (this.length = 1); - var carry = 0; - for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) { - var word = this.words[i] | 0; - (this.words[i] = (carry << (26 - r)) | (word >>> r)), (carry = word & mask); - } - return ( - maskedWords && carry !== 0 && (maskedWords.words[maskedWords.length++] = carry), - this.length === 0 && ((this.words[0] = 0), (this.length = 1)), - this.strip() - ); - }), - (BN.prototype.ishrn = function (bits, hint, extended) { - return assert(this.negative === 0), this.iushrn(bits, hint, extended); - }), - (BN.prototype.shln = function (bits) { - return this.clone().ishln(bits); - }), - (BN.prototype.ushln = function (bits) { - return this.clone().iushln(bits); - }), - (BN.prototype.shrn = function (bits) { - return this.clone().ishrn(bits); - }), - (BN.prototype.ushrn = function (bits) { - return this.clone().iushrn(bits); - }), - (BN.prototype.testn = function (bit) { - assert(typeof bit == "number" && bit >= 0); - var r = bit % 26, - s = (bit - r) / 26, - q = 1 << r; - if (this.length <= s) return !1; - var w = this.words[s]; - return !!(w & q); - }), - (BN.prototype.imaskn = function (bits) { - assert(typeof bits == "number" && bits >= 0); - var r = bits % 26, - s = (bits - r) / 26; - if ((assert(this.negative === 0, "imaskn works only with positive numbers"), this.length <= s)) return this; - if ((r !== 0 && s++, (this.length = Math.min(s, this.length)), r !== 0)) { - var mask = 67108863 ^ ((67108863 >>> r) << r); - this.words[this.length - 1] &= mask; - } - return this.strip(); - }), - (BN.prototype.maskn = function (bits) { - return this.clone().imaskn(bits); - }), - (BN.prototype.iaddn = function (num) { - return ( - assert(typeof num == "number"), - assert(num < 67108864), - num < 0 - ? this.isubn(-num) - : this.negative !== 0 - ? this.length === 1 && (this.words[0] | 0) < num - ? ((this.words[0] = num - (this.words[0] | 0)), (this.negative = 0), this) - : ((this.negative = 0), this.isubn(num), (this.negative = 1), this) - : this._iaddn(num) - ); - }), - (BN.prototype._iaddn = function (num) { - this.words[0] += num; - for (var i = 0; i < this.length && this.words[i] >= 67108864; i++) - (this.words[i] -= 67108864), i === this.length - 1 ? (this.words[i + 1] = 1) : this.words[i + 1]++; - return (this.length = Math.max(this.length, i + 1)), this; - }), - (BN.prototype.isubn = function (num) { - if ((assert(typeof num == "number"), assert(num < 67108864), num < 0)) return this.iaddn(-num); - if (this.negative !== 0) return (this.negative = 0), this.iaddn(num), (this.negative = 1), this; - if (((this.words[0] -= num), this.length === 1 && this.words[0] < 0)) - (this.words[0] = -this.words[0]), (this.negative = 1); - else - for (var i = 0; i < this.length && this.words[i] < 0; i++) - (this.words[i] += 67108864), (this.words[i + 1] -= 1); - return this.strip(); - }), - (BN.prototype.addn = function (num) { - return this.clone().iaddn(num); - }), - (BN.prototype.subn = function (num) { - return this.clone().isubn(num); - }), - (BN.prototype.iabs = function () { - return (this.negative = 0), this; - }), - (BN.prototype.abs = function () { - return this.clone().iabs(); - }), - (BN.prototype._ishlnsubmul = function (num, mul, shift) { - var len = num.length + shift, - i; - this._expand(len); - var w, - carry = 0; - for (i = 0; i < num.length; i++) { - w = (this.words[i + shift] | 0) + carry; - var right = (num.words[i] | 0) * mul; - (w -= right & 67108863), - (carry = (w >> 26) - ((right / 67108864) | 0)), - (this.words[i + shift] = w & 67108863); - } - for (; i < this.length - shift; i++) - (w = (this.words[i + shift] | 0) + carry), (carry = w >> 26), (this.words[i + shift] = w & 67108863); - if (carry === 0) return this.strip(); - for (assert(carry === -1), carry = 0, i = 0; i < this.length; i++) - (w = -(this.words[i] | 0) + carry), (carry = w >> 26), (this.words[i] = w & 67108863); - return (this.negative = 1), this.strip(); - }), - (BN.prototype._wordDiv = function (num, mode) { - var shift = this.length - num.length, - a = this.clone(), - b = num, - bhi = b.words[b.length - 1] | 0, - bhiBits = this._countBits(bhi); - (shift = 26 - bhiBits), - shift !== 0 && ((b = b.ushln(shift)), a.iushln(shift), (bhi = b.words[b.length - 1] | 0)); - var m = a.length - b.length, - q; - if (mode !== "mod") { - (q = new BN(null)), (q.length = m + 1), (q.words = new Array(q.length)); - for (var i = 0; i < q.length; i++) q.words[i] = 0; - } - var diff = a.clone()._ishlnsubmul(b, 1, m); - diff.negative === 0 && ((a = diff), q && (q.words[m] = 1)); - for (var j = m - 1; j >= 0; j--) { - var qj = (a.words[b.length + j] | 0) * 67108864 + (a.words[b.length + j - 1] | 0); - for (qj = Math.min((qj / bhi) | 0, 67108863), a._ishlnsubmul(b, qj, j); a.negative !== 0; ) - qj--, (a.negative = 0), a._ishlnsubmul(b, 1, j), a.isZero() || (a.negative ^= 1); - q && (q.words[j] = qj); - } - return ( - q && q.strip(), - a.strip(), - mode !== "div" && shift !== 0 && a.iushrn(shift), - { - div: q || null, - mod: a, - } - ); - }), - (BN.prototype.divmod = function (num, mode, positive) { - if ((assert(!num.isZero()), this.isZero())) - return { - div: new BN(0), - mod: new BN(0), - }; - var div, mod, res; - return this.negative !== 0 && num.negative === 0 - ? ((res = this.neg().divmod(num, mode)), - mode !== "mod" && (div = res.div.neg()), - mode !== "div" && ((mod = res.mod.neg()), positive && mod.negative !== 0 && mod.iadd(num)), - { - div, - mod, - }) - : this.negative === 0 && num.negative !== 0 - ? ((res = this.divmod(num.neg(), mode)), - mode !== "mod" && (div = res.div.neg()), - { - div, - mod: res.mod, - }) - : (this.negative & num.negative) !== 0 - ? ((res = this.neg().divmod(num.neg(), mode)), - mode !== "div" && ((mod = res.mod.neg()), positive && mod.negative !== 0 && mod.isub(num)), - { - div: res.div, - mod, - }) - : num.length > this.length || this.cmp(num) < 0 - ? { - div: new BN(0), - mod: this, - } - : num.length === 1 - ? mode === "div" - ? { - div: this.divn(num.words[0]), - mod: null, - } - : mode === "mod" - ? { - div: null, - mod: new BN(this.modn(num.words[0])), - } - : { - div: this.divn(num.words[0]), - mod: new BN(this.modn(num.words[0])), - } - : this._wordDiv(num, mode); - }), - (BN.prototype.div = function (num) { - return this.divmod(num, "div", !1).div; - }), - (BN.prototype.mod = function (num) { - return this.divmod(num, "mod", !1).mod; - }), - (BN.prototype.umod = function (num) { - return this.divmod(num, "mod", !0).mod; - }), - (BN.prototype.divRound = function (num) { - var dm = this.divmod(num); - if (dm.mod.isZero()) return dm.div; - var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod, - half = num.ushrn(1), - r2 = num.andln(1), - cmp = mod.cmp(half); - return cmp < 0 || (r2 === 1 && cmp === 0) - ? dm.div - : dm.div.negative !== 0 - ? dm.div.isubn(1) - : dm.div.iaddn(1); - }), - (BN.prototype.modn = function (num) { - assert(num <= 67108863); - for (var p = (1 << 26) % num, acc = 0, i = this.length - 1; i >= 0; i--) - acc = (p * acc + (this.words[i] | 0)) % num; - return acc; - }), - (BN.prototype.idivn = function (num) { - assert(num <= 67108863); - for (var carry = 0, i = this.length - 1; i >= 0; i--) { - var w = (this.words[i] | 0) + carry * 67108864; - (this.words[i] = (w / num) | 0), (carry = w % num); - } - return this.strip(); - }), - (BN.prototype.divn = function (num) { - return this.clone().idivn(num); - }), - (BN.prototype.egcd = function (p) { - assert(p.negative === 0), assert(!p.isZero()); - var x = this, - y = p.clone(); - x.negative !== 0 ? (x = x.umod(p)) : (x = x.clone()); - for (var A = new BN(1), B = new BN(0), C = new BN(0), D = new BN(1), g = 0; x.isEven() && y.isEven(); ) - x.iushrn(1), y.iushrn(1), ++g; - for (var yp = y.clone(), xp = x.clone(); !x.isZero(); ) { - for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1); - if (i > 0) - for (x.iushrn(i); i-- > 0; ) - (A.isOdd() || B.isOdd()) && (A.iadd(yp), B.isub(xp)), A.iushrn(1), B.iushrn(1); - for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); - if (j > 0) - for (y.iushrn(j); j-- > 0; ) - (C.isOdd() || D.isOdd()) && (C.iadd(yp), D.isub(xp)), C.iushrn(1), D.iushrn(1); - x.cmp(y) >= 0 ? (x.isub(y), A.isub(C), B.isub(D)) : (y.isub(x), C.isub(A), D.isub(B)); - } - return { - a: C, - b: D, - gcd: y.iushln(g), - }; - }), - (BN.prototype._invmp = function (p) { - assert(p.negative === 0), assert(!p.isZero()); - var a = this, - b = p.clone(); - a.negative !== 0 ? (a = a.umod(p)) : (a = a.clone()); - for (var x1 = new BN(1), x2 = new BN(0), delta = b.clone(); a.cmpn(1) > 0 && b.cmpn(1) > 0; ) { - for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1); - if (i > 0) for (a.iushrn(i); i-- > 0; ) x1.isOdd() && x1.iadd(delta), x1.iushrn(1); - for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); - if (j > 0) for (b.iushrn(j); j-- > 0; ) x2.isOdd() && x2.iadd(delta), x2.iushrn(1); - a.cmp(b) >= 0 ? (a.isub(b), x1.isub(x2)) : (b.isub(a), x2.isub(x1)); - } - var res; - return a.cmpn(1) === 0 ? (res = x1) : (res = x2), res.cmpn(0) < 0 && res.iadd(p), res; - }), - (BN.prototype.gcd = function (num) { - if (this.isZero()) return num.abs(); - if (num.isZero()) return this.abs(); - var a = this.clone(), - b = num.clone(); - (a.negative = 0), (b.negative = 0); - for (var shift = 0; a.isEven() && b.isEven(); shift++) a.iushrn(1), b.iushrn(1); - do { - for (; a.isEven(); ) a.iushrn(1); - for (; b.isEven(); ) b.iushrn(1); - var r = a.cmp(b); - if (r < 0) { - var t = a; - (a = b), (b = t); - } else if (r === 0 || b.cmpn(1) === 0) break; - a.isub(b); - } while (!0); - return b.iushln(shift); - }), - (BN.prototype.invm = function (num) { - return this.egcd(num).a.umod(num); - }), - (BN.prototype.isEven = function () { - return (this.words[0] & 1) === 0; - }), - (BN.prototype.isOdd = function () { - return (this.words[0] & 1) === 1; - }), - (BN.prototype.andln = function (num) { - return this.words[0] & num; - }), - (BN.prototype.bincn = function (bit) { - assert(typeof bit == "number"); - var r = bit % 26, - s = (bit - r) / 26, - q = 1 << r; - if (this.length <= s) return this._expand(s + 1), (this.words[s] |= q), this; - for (var carry = q, i = s; carry !== 0 && i < this.length; i++) { - var w = this.words[i] | 0; - (w += carry), (carry = w >>> 26), (w &= 67108863), (this.words[i] = w); - } - return carry !== 0 && ((this.words[i] = carry), this.length++), this; - }), - (BN.prototype.isZero = function () { - return this.length === 1 && this.words[0] === 0; - }), - (BN.prototype.cmpn = function (num) { - var negative = num < 0; - if (this.negative !== 0 && !negative) return -1; - if (this.negative === 0 && negative) return 1; - this.strip(); - var res; - if (this.length > 1) res = 1; - else { - negative && (num = -num), assert(num <= 67108863, "Number is too big"); - var w = this.words[0] | 0; - res = w === num ? 0 : w < num ? -1 : 1; - } - return this.negative !== 0 ? -res | 0 : res; - }), - (BN.prototype.cmp = function (num) { - if (this.negative !== 0 && num.negative === 0) return -1; - if (this.negative === 0 && num.negative !== 0) return 1; - var res = this.ucmp(num); - return this.negative !== 0 ? -res | 0 : res; - }), - (BN.prototype.ucmp = function (num) { - if (this.length > num.length) return 1; - if (this.length < num.length) return -1; - for (var res = 0, i = this.length - 1; i >= 0; i--) { - var a = this.words[i] | 0, - b = num.words[i] | 0; - if (a !== b) { - a < b ? (res = -1) : a > b && (res = 1); - break; - } - } - return res; - }), - (BN.prototype.gtn = function (num) { - return this.cmpn(num) === 1; - }), - (BN.prototype.gt = function (num) { - return this.cmp(num) === 1; - }), - (BN.prototype.gten = function (num) { - return this.cmpn(num) >= 0; - }), - (BN.prototype.gte = function (num) { - return this.cmp(num) >= 0; - }), - (BN.prototype.ltn = function (num) { - return this.cmpn(num) === -1; - }), - (BN.prototype.lt = function (num) { - return this.cmp(num) === -1; - }), - (BN.prototype.lten = function (num) { - return this.cmpn(num) <= 0; - }), - (BN.prototype.lte = function (num) { - return this.cmp(num) <= 0; - }), - (BN.prototype.eqn = function (num) { - return this.cmpn(num) === 0; - }), - (BN.prototype.eq = function (num) { - return this.cmp(num) === 0; - }), - (BN.red = function (num) { - return new Red(num); - }), - (BN.prototype.toRed = function (ctx) { - return ( - assert(!this.red, "Already a number in reduction context"), - assert(this.negative === 0, "red works only with positives"), - ctx.convertTo(this)._forceRed(ctx) - ); - }), - (BN.prototype.fromRed = function () { - return assert(this.red, "fromRed works only with numbers in reduction context"), this.red.convertFrom(this); - }), - (BN.prototype._forceRed = function (ctx) { - return (this.red = ctx), this; - }), - (BN.prototype.forceRed = function (ctx) { - return assert(!this.red, "Already a number in reduction context"), this._forceRed(ctx); - }), - (BN.prototype.redAdd = function (num) { - return assert(this.red, "redAdd works only with red numbers"), this.red.add(this, num); - }), - (BN.prototype.redIAdd = function (num) { - return assert(this.red, "redIAdd works only with red numbers"), this.red.iadd(this, num); - }), - (BN.prototype.redSub = function (num) { - return assert(this.red, "redSub works only with red numbers"), this.red.sub(this, num); - }), - (BN.prototype.redISub = function (num) { - return assert(this.red, "redISub works only with red numbers"), this.red.isub(this, num); - }), - (BN.prototype.redShl = function (num) { - return assert(this.red, "redShl works only with red numbers"), this.red.shl(this, num); - }), - (BN.prototype.redMul = function (num) { - return ( - assert(this.red, "redMul works only with red numbers"), - this.red._verify2(this, num), - this.red.mul(this, num) - ); - }), - (BN.prototype.redIMul = function (num) { - return ( - assert(this.red, "redMul works only with red numbers"), - this.red._verify2(this, num), - this.red.imul(this, num) - ); - }), - (BN.prototype.redSqr = function () { - return assert(this.red, "redSqr works only with red numbers"), this.red._verify1(this), this.red.sqr(this); - }), - (BN.prototype.redISqr = function () { - return assert(this.red, "redISqr works only with red numbers"), this.red._verify1(this), this.red.isqr(this); - }), - (BN.prototype.redSqrt = function () { - return assert(this.red, "redSqrt works only with red numbers"), this.red._verify1(this), this.red.sqrt(this); - }), - (BN.prototype.redInvm = function () { - return assert(this.red, "redInvm works only with red numbers"), this.red._verify1(this), this.red.invm(this); - }), - (BN.prototype.redNeg = function () { - return assert(this.red, "redNeg works only with red numbers"), this.red._verify1(this), this.red.neg(this); - }), - (BN.prototype.redPow = function (num) { - return assert(this.red && !num.red, "redPow(normalNum)"), this.red._verify1(this), this.red.pow(this, num); - }); - var primes = { - k256: null, - p224: null, - p192: null, - p25519: null, - }; - function MPrime(name, p) { - (this.name = name), - (this.p = new BN(p, 16)), - (this.n = this.p.bitLength()), - (this.k = new BN(1).iushln(this.n).isub(this.p)), - (this.tmp = this._tmp()); - } - (MPrime.prototype._tmp = function () { - var tmp = new BN(null); - return (tmp.words = new Array(Math.ceil(this.n / 13))), tmp; - }), - (MPrime.prototype.ireduce = function (num) { - var r = num, - rlen; - do this.split(r, this.tmp), (r = this.imulK(r)), (r = r.iadd(this.tmp)), (rlen = r.bitLength()); - while (rlen > this.n); - var cmp = rlen < this.n ? -1 : r.ucmp(this.p); - return ( - cmp === 0 - ? ((r.words[0] = 0), (r.length = 1)) - : cmp > 0 - ? r.isub(this.p) - : r.strip !== void 0 - ? r.strip() - : r._strip(), - r - ); - }), - (MPrime.prototype.split = function (input, out) { - input.iushrn(this.n, 0, out); - }), - (MPrime.prototype.imulK = function (num) { - return num.imul(this.k); - }); - function K256() { - MPrime.call(this, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); - } - inherits(K256, MPrime), - (K256.prototype.split = function (input, output) { - for (var mask = 4194303, outLen = Math.min(input.length, 9), i = 0; i < outLen; i++) - output.words[i] = input.words[i]; - if (((output.length = outLen), input.length <= 9)) { - (input.words[0] = 0), (input.length = 1); - return; - } - var prev = input.words[9]; - for (output.words[output.length++] = prev & mask, i = 10; i < input.length; i++) { - var next = input.words[i] | 0; - (input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22)), (prev = next); - } - (prev >>>= 22), - (input.words[i - 10] = prev), - prev === 0 && input.length > 10 ? (input.length -= 10) : (input.length -= 9); - }), - (K256.prototype.imulK = function (num) { - (num.words[num.length] = 0), (num.words[num.length + 1] = 0), (num.length += 2); - for (var lo = 0, i = 0; i < num.length; i++) { - var w = num.words[i] | 0; - (lo += w * 977), (num.words[i] = lo & 67108863), (lo = w * 64 + ((lo / 67108864) | 0)); - } - return ( - num.words[num.length - 1] === 0 && (num.length--, num.words[num.length - 1] === 0 && num.length--), num - ); - }); - function P224() { - MPrime.call(this, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); - } - inherits(P224, MPrime); - function P192() { - MPrime.call(this, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); - } - inherits(P192, MPrime); - function P25519() { - MPrime.call(this, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); - } - inherits(P25519, MPrime), - (P25519.prototype.imulK = function (num) { - for (var carry = 0, i = 0; i < num.length; i++) { - var hi = (num.words[i] | 0) * 19 + carry, - lo = hi & 67108863; - (hi >>>= 26), (num.words[i] = lo), (carry = hi); - } - return carry !== 0 && (num.words[num.length++] = carry), num; - }), - (BN._prime = function (name) { - if (primes[name]) return primes[name]; - var prime2; - if (name === "k256") prime2 = new K256(); - else if (name === "p224") prime2 = new P224(); - else if (name === "p192") prime2 = new P192(); - else if (name === "p25519") prime2 = new P25519(); - else throw new Error("Unknown prime " + name); - return (primes[name] = prime2), prime2; - }); - function Red(m) { - if (typeof m == "string") { - var prime = BN._prime(m); - (this.m = prime.p), (this.prime = prime); - } else assert(m.gtn(1), "modulus must be greater than 1"), (this.m = m), (this.prime = null); - } - (Red.prototype._verify1 = function (a) { - assert(a.negative === 0, "red works only with positives"), assert(a.red, "red works only with red numbers"); - }), - (Red.prototype._verify2 = function (a, b) { - assert((a.negative | b.negative) === 0, "red works only with positives"), - assert(a.red && a.red === b.red, "red works only with red numbers"); - }), - (Red.prototype.imod = function (a) { - return this.prime ? this.prime.ireduce(a)._forceRed(this) : a.umod(this.m)._forceRed(this); - }), - (Red.prototype.neg = function (a) { - return a.isZero() ? a.clone() : this.m.sub(a)._forceRed(this); - }), - (Red.prototype.add = function (a, b) { - this._verify2(a, b); - var res = a.add(b); - return res.cmp(this.m) >= 0 && res.isub(this.m), res._forceRed(this); - }), - (Red.prototype.iadd = function (a, b) { - this._verify2(a, b); - var res = a.iadd(b); - return res.cmp(this.m) >= 0 && res.isub(this.m), res; - }), - (Red.prototype.sub = function (a, b) { - this._verify2(a, b); - var res = a.sub(b); - return res.cmpn(0) < 0 && res.iadd(this.m), res._forceRed(this); - }), - (Red.prototype.isub = function (a, b) { - this._verify2(a, b); - var res = a.isub(b); - return res.cmpn(0) < 0 && res.iadd(this.m), res; - }), - (Red.prototype.shl = function (a, num) { - return this._verify1(a), this.imod(a.ushln(num)); - }), - (Red.prototype.imul = function (a, b) { - return this._verify2(a, b), this.imod(a.imul(b)); - }), - (Red.prototype.mul = function (a, b) { - return this._verify2(a, b), this.imod(a.mul(b)); - }), - (Red.prototype.isqr = function (a) { - return this.imul(a, a.clone()); - }), - (Red.prototype.sqr = function (a) { - return this.mul(a, a); - }), - (Red.prototype.sqrt = function (a) { - if (a.isZero()) return a.clone(); - var mod3 = this.m.andln(3); - if ((assert(mod3 % 2 === 1), mod3 === 3)) { - var pow = this.m.add(new BN(1)).iushrn(2); - return this.pow(a, pow); - } - for (var q = this.m.subn(1), s = 0; !q.isZero() && q.andln(1) === 0; ) s++, q.iushrn(1); - assert(!q.isZero()); - var one = new BN(1).toRed(this), - nOne = one.redNeg(), - lpow = this.m.subn(1).iushrn(1), - z = this.m.bitLength(); - for (z = new BN(2 * z * z).toRed(this); this.pow(z, lpow).cmp(nOne) !== 0; ) z.redIAdd(nOne); - for ( - var c = this.pow(z, q), r = this.pow(a, q.addn(1).iushrn(1)), t = this.pow(a, q), m = s; - t.cmp(one) !== 0; - - ) { - for (var tmp = t, i = 0; tmp.cmp(one) !== 0; i++) tmp = tmp.redSqr(); - assert(i < m); - var b = this.pow(c, new BN(1).iushln(m - i - 1)); - (r = r.redMul(b)), (c = b.redSqr()), (t = t.redMul(c)), (m = i); - } - return r; - }), - (Red.prototype.invm = function (a) { - var inv = a._invmp(this.m); - return inv.negative !== 0 ? ((inv.negative = 0), this.imod(inv).redNeg()) : this.imod(inv); - }), - (Red.prototype.pow = function (a, num) { - if (num.isZero()) return new BN(1).toRed(this); - if (num.cmpn(1) === 0) return a.clone(); - var windowSize = 4, - wnd = new Array(1 << windowSize); - (wnd[0] = new BN(1).toRed(this)), (wnd[1] = a); - for (var i = 2; i < wnd.length; i++) wnd[i] = this.mul(wnd[i - 1], a); - var res = wnd[0], - current = 0, - currentLen = 0, - start = num.bitLength() % 26; - for (start === 0 && (start = 26), i = num.length - 1; i >= 0; i--) { - for (var word = num.words[i], j = start - 1; j >= 0; j--) { - var bit = (word >> j) & 1; - if ((res !== wnd[0] && (res = this.sqr(res)), bit === 0 && current === 0)) { - currentLen = 0; - continue; - } - (current <<= 1), - (current |= bit), - currentLen++, - !(currentLen !== windowSize && (i !== 0 || j !== 0)) && - ((res = this.mul(res, wnd[current])), (currentLen = 0), (current = 0)); - } - start = 26; - } - return res; - }), - (Red.prototype.convertTo = function (num) { - var r = num.umod(this.m); - return r === num ? r.clone() : r; - }), - (Red.prototype.convertFrom = function (num) { - var res = num.clone(); - return (res.red = null), res; - }), - (BN.mont = function (num) { - return new Mont(num); - }); - function Mont(m) { - Red.call(this, m), - (this.shift = this.m.bitLength()), - this.shift % 26 !== 0 && (this.shift += 26 - (this.shift % 26)), - (this.r = new BN(1).iushln(this.shift)), - (this.r2 = this.imod(this.r.sqr())), - (this.rinv = this.r._invmp(this.m)), - (this.minv = this.rinv.mul(this.r).isubn(1).div(this.m)), - (this.minv = this.minv.umod(this.r)), - (this.minv = this.r.sub(this.minv)); - } - inherits(Mont, Red), - (Mont.prototype.convertTo = function (num) { - return this.imod(num.ushln(this.shift)); - }), - (Mont.prototype.convertFrom = function (num) { - var r = this.imod(num.mul(this.rinv)); - return (r.red = null), r; - }), - (Mont.prototype.imul = function (a, b) { - if (a.isZero() || b.isZero()) return (a.words[0] = 0), (a.length = 1), a; - var t = a.imul(b), - c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), - u = t.isub(c).iushrn(this.shift), - res = u; - return ( - u.cmp(this.m) >= 0 ? (res = u.isub(this.m)) : u.cmpn(0) < 0 && (res = u.iadd(this.m)), res._forceRed(this) - ); - }), - (Mont.prototype.mul = function (a, b) { - if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this); - var t = a.mul(b), - c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), - u = t.isub(c).iushrn(this.shift), - res = u; - return ( - u.cmp(this.m) >= 0 ? (res = u.isub(this.m)) : u.cmpn(0) < 0 && (res = u.iadd(this.m)), res._forceRed(this) - ); - }), - (Mont.prototype.invm = function (a) { - var res = this.imod(a._invmp(this.m).mul(this.r2)); - return res._forceRed(this); - }); - })(typeof module > "u" || module, exports); - }, -}); +var require_bn7 = require_bn; const { CryptoHasher } = globalThis.Bun; @@ -23768,31 +11806,13 @@ var require_crypto_browserify2 = __commonJS({ `), ); }; - exports.constants = { - DH_CHECK_P_NOT_SAFE_PRIME: 2, - DH_CHECK_P_NOT_PRIME: 1, - DH_UNABLE_TO_CHECK_GENERATOR: 4, - DH_NOT_SUITABLE_GENERATOR: 8, - NPN_ENABLED: 1, - ALPN_ENABLED: 1, - RSA_PKCS1_PADDING: 1, - RSA_SSLV23_PADDING: 2, - RSA_NO_PADDING: 3, - RSA_PKCS1_OAEP_PADDING: 4, - RSA_X931_PADDING: 5, - RSA_PKCS1_PSS_PADDING: 6, - POINT_CONVERSION_COMPRESSED: 2, - POINT_CONVERSION_UNCOMPRESSED: 4, - POINT_CONVERSION_HYBRID: 6, - }; + exports.constants = $processBindingConstants.crypto; }, }); // crypto.js -var crypto_exports = { - ...require_crypto_browserify2(), - [Symbol.for("CommonJS")]: 0, -}; +var crypto_exports = require_crypto_browserify2(); + var DEFAULT_ENCODING = "buffer", getRandomValues = array => crypto.getRandomValues(array), randomUUID = () => crypto.randomUUID(), @@ -23882,58 +11902,5 @@ __export(crypto_exports, { subtle: () => webcrypto.subtle, }); -export const { - randomBytes, - rng, - pseudoRandomBytes, - prng, - Hash, - createHash, - createHmac, - Hmac, - getHashes, - pbkdf2, - pbkdf2Sync, - Cipher, - createCipher, - Cipheriv, - createCipheriv, - Decipher, - createDecipher, - Decipheriv, - createDecipheriv, - getCiphers, - listCiphers, - DiffieHellmanGroup, - createDiffieHellmanGroup, - getDiffieHellman, - createDiffieHellman, - DiffieHellman, - createSign, - Sign, - createVerify, - Verify, - createECDH, - publicEncrypt, - privateEncrypt, - publicDecrypt, - privateDecrypt, - randomFill, - randomFillSync, - createCredentials, - constants, -} = crypto_exports; - -export { - DEFAULT_ENCODING, - getRandomValues, - getCurves, - randomUUID, - randomInt, - scrypt, - scryptSync, - timingSafeEqual, - webcrypto, -}; export default crypto_exports; /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */ |