encryptlongx
Version:
基于jsencrypt扩展的可支持长文本加解密的库
128 lines • 368 kB
JSON
{
"errors": [
"./lib/jsbn/rsa.ts\n[tsl] ERROR in /home/corax/source/jsencrypt/lib/jsbn/rsa.ts(11,10)\n TS6133: 'linebrk' is declared but its value is never read.",
"./lib/jsbn/rsa.ts\n[tsl] ERROR in /home/corax/source/jsencrypt/lib/jsbn/rsa.ts(21,10)\n TS6133: 'byte2Hex' is declared but its value is never read."
],
"warnings": [],
"version": "3.10.0",
"hash": "aec46fc65c33ce497959",
"time": 1411,
"publicPath": "",
"assetsByChunkName": {
"main": "bundle.js"
},
"assets": [
{
"name": "bundle.js",
"size": 541848,
"chunks": [
0
],
"chunkNames": [
"main"
],
"emitted": true,
"isOverSizeLimit": true
}
],
"filteredAssets": 0,
"entrypoints": {
"main": {
"chunks": [
0
],
"assets": [
"bundle.js"
],
"isOverSizeLimit": true
}
},
"chunks": [
{
"id": 0,
"rendered": true,
"initial": true,
"entry": true,
"extraAsync": false,
"size": 158532,
"names": [
"main"
],
"files": [
"bundle.js"
],
"hash": "b6a3b215b0fe567a1af4",
"parents": [],
"modules": [
{
"id": 0,
"identifier": "/home/corax/source/jsencrypt/node_modules/ts-loader/index.js??ref--0-0!/home/corax/source/jsencrypt/lib/jsbn/jsbn.ts",
"name": "./lib/jsbn/jsbn.ts",
"index": 5,
"index2": 3,
"size": 46027,
"cacheable": true,
"built": true,
"optional": false,
"prefetched": false,
"chunks": [
0
],
"assets": [],
"issuer": "/home/corax/source/jsencrypt/src/jsencrypt.js",
"issuerId": 4,
"issuerName": "./src/jsencrypt.js",
"profile": {
"factory": 48,
"building": 944,
"dependencies": 1
},
"failed": false,
"errors": 0,
"warnings": 0,
"reasons": [
{
"moduleId": 4,
"moduleIdentifier": "/home/corax/source/jsencrypt/src/jsencrypt.js",
"module": "./src/jsencrypt.js",
"moduleName": "./src/jsencrypt.js",
"type": "harmony import",
"userRequest": "../lib/jsbn/jsbn",
"loc": "5:0-45"
},
{
"moduleId": 7,
"moduleIdentifier": "/home/corax/source/jsencrypt/node_modules/ts-loader/index.js??ref--0-0!/home/corax/source/jsencrypt/lib/jsbn/rsa.ts",
"module": "./lib/jsbn/rsa.ts",
"moduleName": "./lib/jsbn/rsa.ts",
"type": "harmony import",
"userRequest": "./jsbn",
"loc": "4:0-49"
},
{
"moduleId": 12,
"moduleIdentifier": "/home/corax/source/jsencrypt/lib/jsrsasign/asn1-1.0.js",
"module": "./lib/jsrsasign/asn1-1.0.js",
"moduleName": "./lib/jsrsasign/asn1-1.0.js",
"type": "harmony import",
"userRequest": "../jsbn/jsbn",
"loc": "4:0-40"
}
],
"usedExports": [
"BigInteger",
"parseBigInt"
],
"providedExports": [
"BigInteger",
"Classic",
"Montgomery",
"nbi",
"parseBigInt",
"intAt",
"nbv",
"nbits"
],
"optimizationBailout": [],
"depth": 2,
"source": "// Copyright (c) 2005 Tom Wu\n// All Rights Reserved.\n// See \"LICENSE\" for details.\n// Basic JavaScript BN library - subset useful for RSA encryption.\nimport { cbit, int2char, lbit, op_and, op_andnot, op_or, op_xor } from \"./util\";\n// Bits per digit\nvar dbits;\n// JavaScript engine analysis\nvar canary = 0xdeadbeefcafe;\nvar j_lm = ((canary & 0xffffff) == 0xefcafe);\n//#region\nvar lowprimes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997];\nvar lplim = (1 << 26) / lowprimes[lowprimes.length - 1];\n//#endregion\n// (public) Constructor\nvar BigInteger = /** @class */ (function () {\n function BigInteger(a, b, c) {\n if (a != null)\n if (\"number\" == typeof a)\n this.fromNumber(a, b, c);\n else if (b == null && \"string\" != typeof a)\n this.fromString(a, 256);\n else\n this.fromString(a, b);\n }\n //#region PUBLIC\n // BigInteger.prototype.toString = bnToString;\n // (public) return string representation in given radix\n BigInteger.prototype.toString = function (b) {\n if (this.s < 0) {\n return \"-\" + this.negate().toString(b);\n }\n var k;\n if (b == 16)\n k = 4;\n else if (b == 8)\n k = 3;\n else if (b == 2)\n k = 1;\n else if (b == 32)\n k = 5;\n else if (b == 4)\n k = 2;\n else\n return this.toRadix(b);\n var km = (1 << k) - 1, d, m = false, r = \"\", i = this.t;\n var p = this.DB - (i * this.DB) % k;\n if (i-- > 0) {\n if (p < this.DB && (d = this[i] >> p) > 0) {\n m = true;\n r = int2char(d);\n }\n while (i >= 0) {\n if (p < k) {\n d = (this[i] & ((1 << p) - 1)) << (k - p);\n d |= this[--i] >> (p += this.DB - k);\n }\n else {\n d = (this[i] >> (p -= k)) & km;\n if (p <= 0) {\n p += this.DB;\n --i;\n }\n }\n if (d > 0)\n m = true;\n if (m)\n r += int2char(d);\n }\n }\n return m ? r : \"0\";\n };\n // BigInteger.prototype.negate = bnNegate;\n // (public) -this\n BigInteger.prototype.negate = function () { var r = nbi(); BigInteger.ZERO.subTo(this, r); return r; };\n // BigInteger.prototype.abs = bnAbs;\n // (public) |this|\n BigInteger.prototype.abs = function () { return (this.s < 0) ? this.negate() : this; };\n // BigInteger.prototype.compareTo = bnCompareTo;\n // (public) return + if this > a, - if this < a, 0 if equal\n BigInteger.prototype.compareTo = function (a) {\n var r = this.s - a.s;\n if (r != 0)\n return r;\n var i = this.t;\n r = i - a.t;\n if (r != 0)\n return (this.s < 0) ? -r : r;\n while (--i >= 0)\n if ((r = this[i] - a[i]) != 0)\n return r;\n return 0;\n };\n // BigInteger.prototype.bitLength = bnBitLength;\n // (public) return the number of bits in \"this\"\n BigInteger.prototype.bitLength = function () {\n if (this.t <= 0)\n return 0;\n return this.DB * (this.t - 1) + nbits(this[this.t - 1] ^ (this.s & this.DM));\n };\n // BigInteger.prototype.mod = bnMod;\n // (public) this mod a\n BigInteger.prototype.mod = function (a) {\n var r = nbi();\n this.abs().divRemTo(a, null, r);\n if (this.s < 0 && r.compareTo(BigInteger.ZERO) > 0)\n a.subTo(r, r);\n return r;\n };\n // BigInteger.prototype.modPowInt = bnModPowInt;\n // (public) this^e % m, 0 <= e < 2^32\n BigInteger.prototype.modPowInt = function (e, m) {\n var z;\n if (e < 256 || m.isEven())\n z = new Classic(m);\n else\n z = new Montgomery(m);\n return this.exp(e, z);\n };\n // BigInteger.prototype.clone = bnClone;\n // (public)\n BigInteger.prototype.clone = function () { var r = nbi(); this.copyTo(r); return r; };\n // BigInteger.prototype.intValue = bnIntValue;\n // (public) return value as integer\n BigInteger.prototype.intValue = function () {\n if (this.s < 0) {\n if (this.t == 1)\n return this[0] - this.DV;\n else if (this.t == 0)\n return -1;\n }\n else if (this.t == 1)\n return this[0];\n else if (this.t == 0)\n return 0;\n // assumes 16 < DB < 32\n return ((this[1] & ((1 << (32 - this.DB)) - 1)) << this.DB) | this[0];\n };\n // BigInteger.prototype.byteValue = bnByteValue;\n // (public) return value as byte\n BigInteger.prototype.byteValue = function () { return (this.t == 0) ? this.s : (this[0] << 24) >> 24; };\n // BigInteger.prototype.shortValue = bnShortValue;\n // (public) return value as short (assumes DB>=16)\n BigInteger.prototype.shortValue = function () { return (this.t == 0) ? this.s : (this[0] << 16) >> 16; };\n // BigInteger.prototype.signum = bnSigNum;\n // (public) 0 if this == 0, 1 if this > 0\n BigInteger.prototype.signum = function () {\n if (this.s < 0)\n return -1;\n else if (this.t <= 0 || (this.t == 1 && this[0] <= 0))\n return 0;\n else\n return 1;\n };\n // BigInteger.prototype.toByteArray = bnToByteArray;\n // (public) convert to bigendian byte array\n BigInteger.prototype.toByteArray = function () {\n var i = this.t, r = new Array();\n r[0] = this.s;\n var p = this.DB - (i * this.DB) % 8, d, k = 0;\n if (i-- > 0) {\n if (p < this.DB && (d = this[i] >> p) != (this.s & this.DM) >> p)\n r[k++] = d | (this.s << (this.DB - p));\n while (i >= 0) {\n if (p < 8) {\n d = (this[i] & ((1 << p) - 1)) << (8 - p);\n d |= this[--i] >> (p += this.DB - 8);\n }\n else {\n d = (this[i] >> (p -= 8)) & 0xff;\n if (p <= 0) {\n p += this.DB;\n --i;\n }\n }\n if ((d & 0x80) != 0)\n d |= -256;\n if (k == 0 && (this.s & 0x80) != (d & 0x80))\n ++k;\n if (k > 0 || d != this.s)\n r[k++] = d;\n }\n }\n return r;\n };\n // BigInteger.prototype.equals = bnEquals;\n BigInteger.prototype.equals = function (a) { return (this.compareTo(a) == 0); };\n // BigInteger.prototype.min = bnMin;\n BigInteger.prototype.min = function (a) { return (this.compareTo(a) < 0) ? this : a; };\n // BigInteger.prototype.max = bnMax;\n BigInteger.prototype.max = function (a) { return (this.compareTo(a) > 0) ? this : a; };\n // BigInteger.prototype.and = bnAnd;\n BigInteger.prototype.and = function (a) { var r = nbi(); this.bitwiseTo(a, op_and, r); return r; };\n // BigInteger.prototype.or = bnOr;\n BigInteger.prototype.or = function (a) { var r = nbi(); this.bitwiseTo(a, op_or, r); return r; };\n // BigInteger.prototype.xor = bnXor;\n BigInteger.prototype.xor = function (a) { var r = nbi(); this.bitwiseTo(a, op_xor, r); return r; };\n // BigInteger.prototype.andNot = bnAndNot;\n BigInteger.prototype.andNot = function (a) { var r = nbi(); this.bitwiseTo(a, op_andnot, r); return r; };\n // BigInteger.prototype.not = bnNot;\n // (public) ~this\n BigInteger.prototype.not = function () {\n var r = nbi();\n for (var i = 0; i < this.t; ++i)\n r[i] = this.DM & ~this[i];\n r.t = this.t;\n r.s = ~this.s;\n return r;\n };\n // BigInteger.prototype.shiftLeft = bnShiftLeft;\n // (public) this << n\n BigInteger.prototype.shiftLeft = function (n) {\n var r = nbi();\n if (n < 0)\n this.rShiftTo(-n, r);\n else\n this.lShiftTo(n, r);\n return r;\n };\n // BigInteger.prototype.shiftRight = bnShiftRight;\n // (public) this >> n\n BigInteger.prototype.shiftRight = function (n) {\n var r = nbi();\n if (n < 0)\n this.lShiftTo(-n, r);\n else\n this.rShiftTo(n, r);\n return r;\n };\n // BigInteger.prototype.getLowestSetBit = bnGetLowestSetBit;\n // (public) returns index of lowest 1-bit (or -1 if none)\n BigInteger.prototype.getLowestSetBit = function () {\n for (var i = 0; i < this.t; ++i)\n if (this[i] != 0)\n return i * this.DB + lbit(this[i]);\n if (this.s < 0)\n return this.t * this.DB;\n return -1;\n };\n // BigInteger.prototype.bitCount = bnBitCount;\n // (public) return number of set bits\n BigInteger.prototype.bitCount = function () {\n var r = 0, x = this.s & this.DM;\n for (var i = 0; i < this.t; ++i)\n r += cbit(this[i] ^ x);\n return r;\n };\n // BigInteger.prototype.testBit = bnTestBit;\n // (public) true iff nth bit is set\n BigInteger.prototype.testBit = function (n) {\n var j = Math.floor(n / this.DB);\n if (j >= this.t)\n return (this.s != 0);\n return ((this[j] & (1 << (n % this.DB))) != 0);\n };\n // BigInteger.prototype.setBit = bnSetBit;\n // (public) this | (1<<n)\n BigInteger.prototype.setBit = function (n) { return this.changeBit(n, op_or); };\n // BigInteger.prototype.clearBit = bnClearBit;\n // (public) this & ~(1<<n)\n BigInteger.prototype.clearBit = function (n) { return this.changeBit(n, op_andnot); };\n // BigInteger.prototype.flipBit = bnFlipBit;\n // (public) this ^ (1<<n)\n BigInteger.prototype.flipBit = function (n) { return this.changeBit(n, op_xor); };\n // BigInteger.prototype.add = bnAdd;\n // (public) this + a\n BigInteger.prototype.add = function (a) { var r = nbi(); this.addTo(a, r); return r; };\n // BigInteger.prototype.subtract = bnSubtract;\n // (public) this - a\n BigInteger.prototype.subtract = function (a) { var r = nbi(); this.subTo(a, r); return r; };\n // BigInteger.prototype.multiply = bnMultiply;\n // (public) this * a\n BigInteger.prototype.multiply = function (a) { var r = nbi(); this.multiplyTo(a, r); return r; };\n // BigInteger.prototype.divide = bnDivide;\n // (public) this / a\n BigInteger.prototype.divide = function (a) { var r = nbi(); this.divRemTo(a, r, null); return r; };\n // BigInteger.prototype.remainder = bnRemainder;\n // (public) this % a\n BigInteger.prototype.remainder = function (a) { var r = nbi(); this.divRemTo(a, null, r); return r; };\n // BigInteger.prototype.divideAndRemainder = bnDivideAndRemainder;\n // (public) [this/a,this%a]\n BigInteger.prototype.divideAndRemainder = function (a) {\n var q = nbi(), r = nbi();\n this.divRemTo(a, q, r);\n return new Array(q, r);\n };\n // BigInteger.prototype.modPow = bnModPow;\n // (public) this^e % m (HAC 14.85)\n BigInteger.prototype.modPow = function (e, m) {\n var i = e.bitLength(), k, r = nbv(1), z;\n if (i <= 0)\n return r;\n else if (i < 18)\n k = 1;\n else if (i < 48)\n k = 3;\n else if (i < 144)\n k = 4;\n else if (i < 768)\n k = 5;\n else\n k = 6;\n if (i < 8)\n z = new Classic(m);\n else if (m.isEven())\n z = new Barrett(m);\n else\n z = new Montgomery(m);\n // precomputation\n var g = new Array(), n = 3, k1 = k - 1, km = (1 << k) - 1;\n g[1] = z.convert(this);\n if (k > 1) {\n var g2 = nbi();\n z.sqrTo(g[1], g2);\n while (n <= km) {\n g[n] = nbi();\n z.mulTo(g2, g[n - 2], g[n]);\n n += 2;\n }\n }\n var j = e.t - 1, w, is1 = true, r2 = nbi(), t;\n i = nbits(e[j]) - 1;\n while (j >= 0) {\n if (i >= k1)\n w = (e[j] >> (i - k1)) & km;\n else {\n w = (e[j] & ((1 << (i + 1)) - 1)) << (k1 - i);\n if (j > 0)\n w |= e[j - 1] >> (this.DB + i - k1);\n }\n n = k;\n while ((w & 1) == 0) {\n w >>= 1;\n --n;\n }\n if ((i -= n) < 0) {\n i += this.DB;\n --j;\n }\n if (is1) {\n g[w].copyTo(r);\n is1 = false;\n }\n else {\n while (n > 1) {\n z.sqrTo(r, r2);\n z.sqrTo(r2, r);\n n -= 2;\n }\n if (n > 0)\n z.sqrTo(r, r2);\n else {\n t = r;\n r = r2;\n r2 = t;\n }\n z.mulTo(r2, g[w], r);\n }\n while (j >= 0 && (e[j] & (1 << i)) == 0) {\n z.sqrTo(r, r2);\n t = r;\n r = r2;\n r2 = t;\n if (--i < 0) {\n i = this.DB - 1;\n --j;\n }\n }\n }\n return z.revert(r);\n };\n // BigInteger.prototype.modInverse = bnModInverse;\n // (public) 1/this % m (HAC 14.61)\n BigInteger.prototype.modInverse = function (m) {\n var ac = m.isEven();\n if ((this.isEven() && ac) || m.signum() == 0)\n return BigInteger.ZERO;\n var u = m.clone(), v = this.clone();\n var a = nbv(1), b = nbv(0), c = nbv(0), d = nbv(1);\n while (u.signum() != 0) {\n while (u.isEven()) {\n u.rShiftTo(1, u);\n if (ac) {\n if (!a.isEven() || !b.isEven()) {\n a.addTo(this, a);\n b.subTo(m, b);\n }\n a.rShiftTo(1, a);\n }\n else if (!b.isEven())\n b.subTo(m, b);\n b.rShiftTo(1, b);\n }\n while (v.isEven()) {\n v.rShiftTo(1, v);\n if (ac) {\n if (!c.isEven() || !d.isEven()) {\n c.addTo(this, c);\n d.subTo(m, d);\n }\n c.rShiftTo(1, c);\n }\n else if (!d.isEven())\n d.subTo(m, d);\n d.rShiftTo(1, d);\n }\n if (u.compareTo(v) >= 0) {\n u.subTo(v, u);\n if (ac)\n a.subTo(c, a);\n b.subTo(d, b);\n }\n else {\n v.subTo(u, v);\n if (ac)\n c.subTo(a, c);\n d.subTo(b, d);\n }\n }\n if (v.compareTo(BigInteger.ONE) != 0)\n return BigInteger.ZERO;\n if (d.compareTo(m) >= 0)\n return d.subtract(m);\n if (d.signum() < 0)\n d.addTo(m, d);\n else\n return d;\n if (d.signum() < 0)\n return d.add(m);\n else\n return d;\n };\n // BigInteger.prototype.pow = bnPow;\n // (public) this^e\n BigInteger.prototype.pow = function (e) { return this.exp(e, new NullExp()); };\n // BigInteger.prototype.gcd = bnGCD;\n // (public) gcd(this,a) (HAC 14.54)\n BigInteger.prototype.gcd = function (a) {\n var x = (this.s < 0) ? this.negate() : this.clone();\n var y = (a.s < 0) ? a.negate() : a.clone();\n if (x.compareTo(y) < 0) {\n var t = x;\n x = y;\n y = t;\n }\n var i = x.getLowestSetBit(), g = y.getLowestSetBit();\n if (g < 0)\n return x;\n if (i < g)\n g = i;\n if (g > 0) {\n x.rShiftTo(g, x);\n y.rShiftTo(g, y);\n }\n while (x.signum() > 0) {\n if ((i = x.getLowestSetBit()) > 0)\n x.rShiftTo(i, x);\n if ((i = y.getLowestSetBit()) > 0)\n y.rShiftTo(i, y);\n if (x.compareTo(y) >= 0) {\n x.subTo(y, x);\n x.rShiftTo(1, x);\n }\n else {\n y.subTo(x, y);\n y.rShiftTo(1, y);\n }\n }\n if (g > 0)\n y.lShiftTo(g, y);\n return y;\n };\n // BigInteger.prototype.isProbablePrime = bnIsProbablePrime;\n // (public) test primality with certainty >= 1-.5^t\n BigInteger.prototype.isProbablePrime = function (t) {\n var i, x = this.abs();\n if (x.t == 1 && x[0] <= lowprimes[lowprimes.length - 1]) {\n for (i = 0; i < lowprimes.length; ++i)\n if (x[0] == lowprimes[i])\n return true;\n return false;\n }\n if (x.isEven())\n return false;\n i = 1;\n while (i < lowprimes.length) {\n var m = lowprimes[i], j = i + 1;\n while (j < lowprimes.length && m < lplim)\n m *= lowprimes[j++];\n m = x.modInt(m);\n while (i < j)\n if (m % lowprimes[i++] == 0)\n return false;\n }\n return x.millerRabin(t);\n };\n //#endregion PUBLIC\n //#region PROTECTED\n // BigInteger.prototype.copyTo = bnpCopyTo;\n // (protected) copy this to r\n BigInteger.prototype.copyTo = function (r) {\n for (var i = this.t - 1; i >= 0; --i)\n r[i] = this[i];\n r.t = this.t;\n r.s = this.s;\n };\n // BigInteger.prototype.fromInt = bnpFromInt;\n // (protected) set from integer value x, -DV <= x < DV\n BigInteger.prototype.fromInt = function (x) {\n this.t = 1;\n this.s = (x < 0) ? -1 : 0;\n if (x > 0)\n this[0] = x;\n else if (x < -1)\n this[0] = x + this.DV;\n else\n this.t = 0;\n };\n // BigInteger.prototype.fromString = bnpFromString;\n // (protected) set from string and radix\n BigInteger.prototype.fromString = function (s, b) {\n var k;\n if (b == 16)\n k = 4;\n else if (b == 8)\n k = 3;\n else if (b == 256)\n k = 8; // byte array\n else if (b == 2)\n k = 1;\n else if (b == 32)\n k = 5;\n else if (b == 4)\n k = 2;\n else {\n this.fromRadix(s, b);\n return;\n }\n this.t = 0;\n this.s = 0;\n var i = s.length, mi = false, sh = 0;\n while (--i >= 0) {\n var x = (k == 8) ? s[i] & 0xff : intAt(s, i);\n if (x < 0) {\n if (s.charAt(i) == \"-\")\n mi = true;\n continue;\n }\n mi = false;\n if (sh == 0)\n this[this.t++] = x;\n else if (sh + k > this.DB) {\n this[this.t - 1] |= (x & ((1 << (this.DB - sh)) - 1)) << sh;\n this[this.t++] = (x >> (this.DB - sh));\n }\n else\n this[this.t - 1] |= x << sh;\n sh += k;\n if (sh >= this.DB)\n sh -= this.DB;\n }\n if (k == 8 && (s[0] & 0x80) != 0) {\n this.s = -1;\n if (sh > 0)\n this[this.t - 1] |= ((1 << (this.DB - sh)) - 1) << sh;\n }\n this.clamp();\n if (mi)\n BigInteger.ZERO.subTo(this, this);\n };\n // BigInteger.prototype.clamp = bnpClamp;\n // (protected) clamp off excess high words\n BigInteger.prototype.clamp = function () {\n var c = this.s & this.DM;\n while (this.t > 0 && this[this.t - 1] == c)\n --this.t;\n };\n // BigInteger.prototype.dlShiftTo = bnpDLShiftTo;\n // (protected) r = this << n*DB\n BigInteger.prototype.dlShiftTo = function (n, r) {\n var i;\n for (i = this.t - 1; i >= 0; --i)\n r[i + n] = this[i];\n for (i = n - 1; i >= 0; --i)\n r[i] = 0;\n r.t = this.t + n;\n r.s = this.s;\n };\n // BigInteger.prototype.drShiftTo = bnpDRShiftTo;\n // (protected) r = this >> n*DB\n BigInteger.prototype.drShiftTo = function (n, r) {\n for (var i = n; i < this.t; ++i)\n r[i - n] = this[i];\n r.t = Math.max(this.t - n, 0);\n r.s = this.s;\n };\n // BigInteger.prototype.lShiftTo = bnpLShiftTo;\n // (protected) r = this << n\n BigInteger.prototype.lShiftTo = function (n, r) {\n var bs = n % this.DB;\n var cbs = this.DB - bs;\n var bm = (1 << cbs) - 1;\n var ds = Math.floor(n / this.DB), c = (this.s << bs) & this.DM, i;\n for (i = this.t - 1; i >= 0; --i) {\n r[i + ds + 1] = (this[i] >> cbs) | c;\n c = (this[i] & bm) << bs;\n }\n for (i = ds - 1; i >= 0; --i)\n r[i] = 0;\n r[ds] = c;\n r.t = this.t + ds + 1;\n r.s = this.s;\n r.clamp();\n };\n // BigInteger.prototype.rShiftTo = bnpRShiftTo;\n // (protected) r = this >> n\n BigInteger.prototype.rShiftTo = function (n, r) {\n r.s = this.s;\n var ds = Math.floor(n / this.DB);\n if (ds >= this.t) {\n r.t = 0;\n return;\n }\n var bs = n % this.DB;\n var cbs = this.DB - bs;\n var bm = (1 << bs) - 1;\n r[0] = this[ds] >> bs;\n for (var i = ds + 1; i < this.t; ++i) {\n r[i - ds - 1] |= (this[i] & bm) << cbs;\n r[i - ds] = this[i] >> bs;\n }\n if (bs > 0)\n r[this.t - ds - 1] |= (this.s & bm) << cbs;\n r.t = this.t - ds;\n r.clamp();\n };\n // BigInteger.prototype.subTo = bnpSubTo;\n // (protected) r = this - a\n BigInteger.prototype.subTo = function (a, r) {\n var i = 0, c = 0, m = Math.min(a.t, this.t);\n while (i < m) {\n c += this[i] - a[i];\n r[i++] = c & this.DM;\n c >>= this.DB;\n }\n if (a.t < this.t) {\n c -= a.s;\n while (i < this.t) {\n c += this[i];\n r[i++] = c & this.DM;\n c >>= this.DB;\n }\n c += this.s;\n }\n else {\n c += this.s;\n while (i < a.t) {\n c -= a[i];\n r[i++] = c & this.DM;\n c >>= this.DB;\n }\n c -= a.s;\n }\n r.s = (c < 0) ? -1 : 0;\n if (c < -1)\n r[i++] = this.DV + c;\n else if (c > 0)\n r[i++] = c;\n r.t = i;\n r.clamp();\n };\n // BigInteger.prototype.multiplyTo = bnpMultiplyTo;\n // (protected) r = this * a, r != this,a (HAC 14.12)\n // \"this\" should be the larger one if appropriate.\n BigInteger.prototype.multiplyTo = function (a, r) {\n var x = this.abs(), y = a.abs();\n var i = x.t;\n r.t = i + y.t;\n while (--i >= 0)\n r[i] = 0;\n for (i = 0; i < y.t; ++i)\n r[i + x.t] = x.am(0, y[i], r, i, 0, x.t);\n r.s = 0;\n r.clamp();\n if (this.s != a.s)\n BigInteger.ZERO.subTo(r, r);\n };\n // BigInteger.prototype.squareTo = bnpSquareTo;\n // (protected) r = this^2, r != this (HAC 14.16)\n BigInteger.prototype.squareTo = function (r) {\n var x = this.abs();\n var i = r.t = 2 * x.t;\n while (--i >= 0)\n r[i] = 0;\n for (i = 0; i < x.t - 1; ++i) {\n var c = x.am(i, x[i], r, 2 * i, 0, 1);\n if ((r[i + x.t] += x.am(i + 1, 2 * x[i], r, 2 * i + 1, c, x.t - i - 1)) >= x.DV) {\n r[i + x.t] -= x.DV;\n r[i + x.t + 1] = 1;\n }\n }\n if (r.t > 0)\n r[r.t - 1] += x.am(i, x[i], r, 2 * i, 0, 1);\n r.s = 0;\n r.clamp();\n };\n // BigInteger.prototype.divRemTo = bnpDivRemTo;\n // (protected) divide this by m, quotient and remainder to q, r (HAC 14.20)\n // r != q, this != m. q or r may be null.\n BigInteger.prototype.divRemTo = function (m, q, r) {\n var pm = m.abs();\n if (pm.t <= 0)\n return;\n var pt = this.abs();\n if (pt.t < pm.t) {\n if (q != null)\n q.fromInt(0);\n if (r != null)\n this.copyTo(r);\n return;\n }\n if (r == null)\n r = nbi();\n var y = nbi(), ts = this.s, ms = m.s;\n var nsh = this.DB - nbits(pm[pm.t - 1]); // normalize modulus\n if (nsh > 0) {\n pm.lShiftTo(nsh, y);\n pt.lShiftTo(nsh, r);\n }\n else {\n pm.copyTo(y);\n pt.copyTo(r);\n }\n var ys = y.t;\n var y0 = y[ys - 1];\n if (y0 == 0)\n return;\n var yt = y0 * (1 << this.F1) + ((ys > 1) ? y[ys - 2] >> this.F2 : 0);\n var d1 = this.FV / yt, d2 = (1 << this.F1) / yt, e = 1 << this.F2;\n var i = r.t, j = i - ys, t = (q == null) ? nbi() : q;\n y.dlShiftTo(j, t);\n if (r.compareTo(t) >= 0) {\n r[r.t++] = 1;\n r.subTo(t, r);\n }\n BigInteger.ONE.dlShiftTo(ys, t);\n t.subTo(y, y); // \"negative\" y so we can replace sub with am later\n while (y.t < ys)\n y[y.t++] = 0;\n while (--j >= 0) {\n // Estimate quotient digit\n var qd = (r[--i] == y0) ? this.DM : Math.floor(r[i] * d1 + (r[i - 1] + e) * d2);\n if ((r[i] += y.am(0, qd, r, j, 0, ys)) < qd) {\n y.dlShiftTo(j, t);\n r.subTo(t, r);\n while (r[i] < --qd)\n r.subTo(t, r);\n }\n }\n if (q != null) {\n r.drShiftTo(ys, q);\n if (ts != ms)\n BigInteger.ZERO.subTo(q, q);\n }\n r.t = ys;\n r.clamp();\n if (nsh > 0)\n r.rShiftTo(nsh, r); // Denormalize remainder\n if (ts < 0)\n BigInteger.ZERO.subTo(r, r);\n };\n // BigInteger.prototype.invDigit = bnpInvDigit;\n // (protected) return \"-1/this % 2^DB\"; useful for Mont. reduction\n // justification:\n // xy == 1 (mod m)\n // xy = 1+km\n // xy(2-xy) = (1+km)(1-km)\n // x[y(2-xy)] = 1-k^2m^2\n // x[y(2-xy)] == 1 (mod m^2)\n // if y is 1/x mod m, then y(2-xy) is 1/x mod m^2\n // should reduce x and y(2-xy) by m^2 at each step to keep size bounded.\n // JS multiply \"overflows\" differently from C/C++, so care is needed here.\n BigInteger.prototype.invDigit = function () {\n if (this.t < 1)\n return 0;\n var x = this[0];\n if ((x & 1) == 0)\n return 0;\n var y = x & 3; // y == 1/x mod 2^2\n y = (y * (2 - (x & 0xf) * y)) & 0xf; // y == 1/x mod 2^4\n y = (y * (2 - (x & 0xff) * y)) & 0xff; // y == 1/x mod 2^8\n y = (y * (2 - (((x & 0xffff) * y) & 0xffff))) & 0xffff; // y == 1/x mod 2^16\n // last step - calculate inverse mod DV directly;\n // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints\n y = (y * (2 - x * y % this.DV)) % this.DV; // y == 1/x mod 2^dbits\n // we really want the negative inverse, and -DV < y < DV\n return (y > 0) ? this.DV - y : -y;\n };\n // BigInteger.prototype.isEven = bnpIsEven;\n // (protected) true iff this is even\n BigInteger.prototype.isEven = function () { return ((this.t > 0) ? (this[0] & 1) : this.s) == 0; };\n // BigInteger.prototype.exp = bnpExp;\n // (protected) this^e, e < 2^32, doing sqr and mul with \"r\" (HAC 14.79)\n BigInteger.prototype.exp = function (e, z) {\n if (e > 0xffffffff || e < 1)\n return BigInteger.ONE;\n var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e) - 1;\n g.copyTo(r);\n while (--i >= 0) {\n z.sqrTo(r, r2);\n if ((e & (1 << i)) > 0)\n z.mulTo(r2, g, r);\n else {\n var t = r;\n r = r2;\n r2 = t;\n }\n }\n return z.revert(r);\n };\n // BigInteger.prototype.chunkSize = bnpChunkSize;\n // (protected) return x s.t. r^x < DV\n BigInteger.prototype.chunkSize = function (r) { return Math.floor(Math.LN2 * this.DB / Math.log(r)); };\n // BigInteger.prototype.toRadix = bnpToRadix;\n // (protected) convert to radix string\n BigInteger.prototype.toRadix = function (b) {\n if (b == null)\n b = 10;\n if (this.signum() == 0 || b < 2 || b > 36)\n return \"0\";\n var cs = this.chunkSize(b);\n var a = Math.pow(b, cs);\n var d = nbv(a), y = nbi(), z = nbi(), r = \"\";\n this.divRemTo(d, y, z);\n while (y.signum() > 0) {\n r = (a + z.intValue()).toString(b).substr(1) + r;\n y.divRemTo(d, y, z);\n }\n return z.intValue().toString(b) + r;\n };\n // BigInteger.prototype.fromRadix = bnpFromRadix;\n // (protected) convert from radix string\n BigInteger.prototype.fromRadix = function (s, b) {\n this.fromInt(0);\n if (b == null)\n b = 10;\n var cs = this.chunkSize(b);\n var d = Math.pow(b, cs), mi = false, j = 0, w = 0;\n for (var i = 0; i < s.length; ++i) {\n var x = intAt(s, i);\n if (x < 0) {\n if (s.charAt(i) == \"-\" && this.signum() == 0)\n mi = true;\n continue;\n }\n w = b * w + x;\n if (++j >= cs) {\n this.dMultiply(d);\n this.dAddOffset(w, 0);\n j = 0;\n w = 0;\n }\n }\n if (j > 0) {\n this.dMultiply(Math.pow(b, j));\n this.dAddOffset(w, 0);\n }\n if (mi)\n BigInteger.ZERO.subTo(this, this);\n };\n // BigInteger.prototype.fromNumber = bnpFromNumber;\n // (protected) alternate constructor\n BigInteger.prototype.fromNumber = function (a, b, c) {\n if (\"number\" == typeof b) {\n // new BigInteger(int,int,RNG)\n if (a < 2)\n this.fromInt(1);\n else {\n this.fromNumber(a, c);\n if (!this.testBit(a - 1))\n this.bitwiseTo(BigInteger.ONE.shiftLeft(a - 1), op_or, this);\n if (this.isEven())\n this.dAddOffset(1, 0); // force odd\n while (!this.isProbablePrime(b)) {\n this.dAddOffset(2, 0);\n if (this.bitLength() > a)\n this.subTo(BigInteger.ONE.shiftLeft(a - 1), this);\n }\n }\n }\n else {\n // new BigInteger(int,RNG)\n var x = new Array(), t = a & 7;\n x.length = (a >> 3) + 1;\n b.nextBytes(x);\n if (t > 0)\n x[0] &= ((1 << t) - 1);\n else\n x[0] = 0;\n this.fromString(x, 256);\n }\n };\n // BigInteger.prototype.bitwiseTo = bnpBitwiseTo;\n // (protected) r = this op a (bitwise)\n BigInteger.prototype.bitwiseTo = function (a, op, r) {\n var i, f, m = Math.min(a.t, this.t);\n for (i = 0; i < m; ++i)\n r[i] = op(this[i], a[i]);\n if (a.t < this.t) {\n f = a.s & this.DM;\n for (i = m; i < this.t; ++i)\n r[i] = op(this[i], f);\n r.t = this.t;\n }\n else {\n f = this.s & this.DM;\n for (i = m; i < a.t; ++i)\n r[i] = op(f, a[i]);\n r.t = a.t;\n }\n r.s = op(this.s, a.s);\n r.clamp();\n };\n // BigInteger.prototype.changeBit = bnpChangeBit;\n // (protected) this op (1<<n)\n BigInteger.prototype.changeBit = function (n, op) {\n var r = BigInteger.ONE.shiftLeft(n);\n this.bitwiseTo(r, op, r);\n return r;\n };\n // BigInteger.prototype.addTo = bnpAddTo;\n // (protected) r = this + a\n BigInteger.prototype.addTo = function (a, r) {\n var i = 0, c = 0, m = Math.min(a.t, this.t);\n while (i < m) {\n c += this[i] + a[i];\n r[i++] = c & this.DM;\n c >>= this.DB;\n }\n if (a.t < this.t) {\n c += a.s;\n while (i < this.t) {\n c += this[i];\n r[i++] = c & this.DM;\n c >>= this.DB;\n }\n c += this.s;\n }\n else {\n c += this.s;\n while (i < a.t) {\n c += a[i];\n r[i++] = c & this.DM;\n c >>= this.DB;\n }\n c += a.s;\n }\n r.s = (c < 0) ? -1 : 0;\n if (c > 0)\n r[i++] = c;\n else if (c < -1)\n r[i++] = this.DV + c;\n r.t = i;\n r.clamp();\n };\n // BigInteger.prototype.dMultiply = bnpDMultiply;\n // (protected) this *= n, this >= 0, 1 < n < DV\n BigInteger.prototype.dMultiply = function (n) {\n this[this.t] = this.am(0, n - 1, this, 0, 0, this.t);\n ++this.t;\n this.clamp();\n };\n // BigInteger.prototype.dAddOffset = bnpDAddOffset;\n // (protected) this += n << w words, this >= 0\n BigInteger.prototype.dAddOffset = function (n, w) {\n if (n == 0)\n return;\n while (this.t <= w)\n this[this.t++] = 0;\n this[w] += n;\n while (this[w] >= this.DV) {\n this[w] -= this.DV;\n if (++w >= this.t)\n this[this.t++] = 0;\n ++this[w];\n }\n };\n // BigInteger.prototype.multiplyLowerTo = bnpMultiplyLowerTo;\n // (protected) r = lower n words of \"this * a\", a.t <= n\n // \"this\" should be the larger one if appropriate.\n BigInteger.prototype.multiplyLowerTo = function (a, n, r) {\n var i = Math.min(this.t + a.t, n);\n r.s = 0; // assumes a,this >= 0\n r.t = i;\n while (i > 0)\n r[--i] = 0;\n var j;\n for (j = r.t - this.t; i < j; ++i)\n r[i + this.t] = this.am(0, a[i], r, i, 0, this.t);\n for (j = Math.min(a.t, n); i < j; ++i)\n this.am(0, a[i], r, i, 0, n - i);\n r.clamp();\n };\n // BigInteger.prototype.multiplyUpperTo = bnpMultiplyUpperTo;\n // (protected) r = \"this * a\" without lower n words, n > 0\n // \"this\" should be the larger one if appropriate.\n BigInteger.prototype.multiplyUpperTo = function (a, n, r) {\n --n;\n var i = r.t = this.t + a.t - n;\n r.s = 0; // assumes a,this >= 0\n while (--i >= 0)\n r[i] = 0;\n for (i = Math.max(n - this.t, 0); i < a.t; ++i)\n r[this.t + i - n] = this.am(n - i, a[i], r, 0, 0, this.t + i - n);\n r.clamp();\n r.drShiftTo(1, r);\n };\n // BigInteger.prototype.modInt = bnpModInt;\n // (protected) this % n, n < 2^26\n BigInteger.prototype.modInt = function (n) {\n if (n <= 0)\n return 0;\n var d = this.DV % n, r = (this.s < 0) ? n - 1 : 0;\n if (this.t > 0)\n if (d == 0)\n r = this[0] % n;\n else\n for (var i = this.t - 1; i >= 0; --i)\n r = (d * r + this[i]) % n;\n return r;\n };\n // BigInteger.prototype.millerRabin = bnpMillerRabin;\n // (protected) true if probably prime (HAC 4.24, Miller-Rabin)\n BigInteger.prototype.millerRabin = function (t) {\n var n1 = this.subtract(BigInteger.ONE);\n var k = n1.getLowestSetBit();\n if (k <= 0)\n return false;\n var r = n1.shiftRight(k);\n t = (t + 1) >> 1;\n if (t > lowprimes.length)\n t = lowprimes.length;\n var a = nbi();\n for (var i = 0; i < t; ++i) {\n //Pick bases at random, instead of starting at 2\n a.fromInt(lowprimes[Math.floor(Math.random() * lowprimes.length)]);\n var y = a.modPow(r, this);\n if (y.compareTo(BigInteger.ONE) != 0 && y.compareTo(n1) != 0) {\n var j = 1;\n while (j++ < k && y.compareTo(n1) != 0) {\n y = y.modPowInt(2, this);\n if (y.compareTo(BigInteger.ONE) == 0)\n return false;\n }\n if (y.compareTo(n1) != 0)\n return false;\n }\n }\n return true;\n };\n //BigInteger.prototype.square = bnSquare;\n // (public) this^2\n BigInteger.prototype.square = function () { var r = nbi(); this.squareTo(r); return r; };\n return BigInteger;\n}());\nexport { BigInteger };\n//#region REDUCERS\n//#region NullExp\nvar NullExp = /** @class */ (function () {\n function NullExp() {\n }\n // NullExp.prototype.convert = nNop;\n NullExp.prototype.convert = function (x) { return x; };\n // NullExp.prototype.revert = nNop;\n NullExp.prototype.revert = function (x) { return x; };\n // NullExp.prototype.mulTo = nMulTo;\n NullExp.prototype.mulTo = function (x, y, r) { x.multiplyTo(y, r); };\n // NullExp.prototype.sqrTo = nSqrTo;\n NullExp.prototype.nSqrTo = function (x, r) { x.squareTo(r); };\n return NullExp;\n}());\n// Modular reduction using \"classic\" algorithm\nvar Classic = /** @class */ (function () {\n function Classic(m) {\n this.m = m;\n }\n // Classic.prototype.convert = cConvert;\n Classic.prototype.convert = function (x) {\n if (x.s < 0 || x.compareTo(this.m) >= 0)\n return x.mod(this.m);\n else\n return x;\n };\n // Classic.prototype.revert = cRevert;\n Classic.prototype.revert = function (x) {\n return x;\n };\n // Classic.prototype.reduce = cReduce;\n Classic.prototype.reduce = function (x) {\n x.divRemTo(this.m, null, x);\n };\n // Classic.prototype.mulTo = cMulTo;\n Classic.prototype.mulTo = function (x, y, r) {\n x.multiplyTo(y, r);\n this.reduce(r);\n };\n // Classic.prototype.sqrTo = cSqrTo;\n Classic.prototype.sqrTo = function (x, r) {\n x.squareTo(r);\n this.reduce(r);\n };\n return Classic;\n}());\nexport { Classic };\n//#endregion\n//#region Montgomery\n// Montgomery reduction\nvar Montgomery = /** @class */ (function () {\n function Montgomery(m) {\n this.m = m;\n this.mp = m.invDigit();\n this.mpl = this.mp & 0x7fff;\n this.mph = this.mp >> 15;\n this.um = (1 << (m.DB - 15)) - 1;\n this.mt2 = 2 * m.t;\n }\n // Montgomery.prototype.convert = montConvert;\n // xR mod m\n Montgomery.prototype.convert = function (x) {\n var r = nbi();\n x.abs().dlShiftTo(this.m.t, r);\n r.divRemTo(this.m, null, r);\n if (x.s < 0 && r.compareTo(BigInteger.ZERO) > 0)\n this.m.subTo(r, r);\n return r;\n };\n // Montgomery.prototype.revert = montRevert;\n // x/R mod m\n Montgomery.prototype.revert = function (x) {\n var r = nbi();\n x.copyTo(r);\n this.reduce(r);\n return r;\n };\n // Montgomery.prototype.reduce = montReduce;\n // x = x/R mod m (HAC 14.32)\n Montgomery.prototype.reduce = function (x) {\n while (x.t <= this.mt2)\n x[x.t++] = 0;\n for (var i = 0; i < this.m.t; ++i) {\n // faster way of calculating u0 = x[i]*mp mod DV\n var j = x[i] & 0x7fff;\n var u0 = (j * this.mpl + (((j * this.mph + (x[i] >> 15) * this.mpl) & this.um) << 15)) & x.DM;\n // use am to combine the multiply-shift-add into one call\n j = i + this.m.t;\n x[j] += this.m.am(0, u0, x, i, 0, this.m.t);\n // propagate carry\n while (x[j] >= x.DV) {\n x[j] -= x.DV;\n x[++j]++;\n }\n }\n x.clamp();\n x.drShiftTo(this.m.t, x);\n if (x.compareTo(this.m) >= 0)\n x.subTo(this.m, x);\n };\n // Montgomery.prototype.mulTo = montMulTo;\n // r = \"xy/R mod m\"; x,y != r\n Montgomery.prototype.mulTo = function (x, y, r) { x.multiplyTo(y, r); this.reduce(r); };\n // Montgomery.prototype.sqrTo = montSqrTo;\n // r = \"x^2/R mod m\"; x != r\n Montgomery.prototype.sqrTo = function (x, r) { x.squareTo(r); this.reduce(r); };\n return Montgomery;\n}());\nexport { Montgomery };\n//#endregion Montgomery\n//#region Barrett\n// Barrett modular reduction\nvar Barrett = /** @class */ (function () {\n function Barrett(m) {\n this.m = m;\n // setup Barrett\n this.r2 = nbi();\n this.q3 = nbi();\n BigInteger.ONE.dlShiftTo(2 * m.t, this.r2);\n this.mu = this.r2.divide(m);\n }\n // Barrett.prototype.convert = barrettConvert;\n Barrett.prototype.convert = function (x) {\n if (x.s < 0 || x.t > 2 * this.m.t)\n return x.mod(this.m);\n else if (x.compareTo(this.m) < 0)\n return x;\n else {\n var r = nbi();\n x.copyTo(r);\n this.reduce(r);\n return r;\n }\n };\n // Barrett.prototype.revert = barrettRevert;\n Barrett.prototype.revert = function (x) { return x; };\n // Barrett.prototype.reduce = barrettReduce;\n // x = x mod m (HAC 14.42)\n Barrett.prototype.reduce = function (x) {\n x.drShiftTo(this.m.t - 1, this.r2);\n if (x.t > this.m.t + 1) {\n x.t = this.m.t + 1;\n x.clamp();\n }\n this.mu.multiplyUpperTo(this.r2, this.m.t + 1, this.q3);\n this.m.multiplyLowerTo(this.q3, this.m.t + 1, this.r2);\n while (x.compareTo(this.r2) < 0)\n x.dAddOffset(1, this.m.t + 1);\n x.subTo(this.r2, x);\n while (x.compareTo(this.m) >= 0)\n x.subTo(this.m, x);\n };\n // Barrett.prototype.mulTo = barrettMulTo;\n // r = x*y mod m; x,y != r\n Barrett.prototype.mulTo = function (x, y, r) { x.multiplyTo(y, r); this.reduce(r); };\n // Barrett.prototype.sqrTo = barrettSqrTo;\n // r = x^2 mod m; x != r\n Barrett.prototype.sqrTo = function (x, r) { x.squareTo(r); this.reduce(r); };\n return Barrett;\n}());\n//#endregion\n//#endregion REDUCERS\n// return new, unset BigInteger\nexport function nbi() { return new BigInteger(null); }\nexport function parseBigInt(str, r) {\n return new BigInteger(str, r);\n}\n// am: Compute w_j += (x*this_i), propagate carries,\n// c is initial carry, returns final carry.\n// c < 3*dvalue, x < 2*dvalue, this_i < dvalue\n// We need to select the fastest one that works in this environment.\n// am1: use a single mult and divide to get the high bits,\n// max digit bits should be 26 because\n// max internal value = 2*dvalue^2-2*dvalue (< 2^53)\nfunction am1(i, x, w, j, c, n) {\n while (--n >= 0) {\n var v = x * this[i++] + w[j] + c;\n c = Math.floor(v / 0x4000000);\n w[j++] = v & 0x3ffffff;\n }\n return c;\n}\n// am2 avoids a big mult-and-extract completely.\n// Max digit bits should be <= 30 because we do bitwise ops\n// on values up to 2*hdvalue^2-hdvalue-1 (< 2^31)\nfunction am2(i, x, w, j, c, n) {\n var xl = x & 0x7fff, xh = x >> 15;\n while (--n >= 0) {\n var l = this[i] & 0x7fff;\n var h = this[i++] >> 15;\n var m = xh * l + h * xl;\n l = xl * l + ((m & 0x7fff) << 15) + w[j] + (c & 0x3fffffff);\n c = (l >>> 30) + (m >>> 15) + xh * h + (c >>> 30);\n w[j++] = l & 0x3fffffff;\n }\n return c;\n}\n// Alternately, set max digit bits to 28 since some\n// browsers slow down when dealing with 32-bit numbers.\nfunction am3(i, x, w, j, c, n) {\n var xl = x & 0x3fff, xh = x >> 14;\n while (--n >= 0) {\n var l = this[i] & 0x3fff;\n var h = this[i++] >> 14;\n var m = xh * l + h * xl;\n l = xl * l + ((m & 0x3fff) << 14) + w[j] + c;\n c = (l >> 28) + (m >> 14) + xh * h;\n w[j++] = l & 0xfffffff;\n }\n return c;\n}\nif (j_lm && (navigator.appName == \"Microsoft Internet Explorer\")) {\n BigInteger.prototype.am = am2;\n dbits = 30;\n}\nelse if (j_lm && (navigator.appName != \"Netscape\")) {\n BigInteger.prototype.am = am1;\n dbits = 26;\n}\nelse {\n BigInteger.prototype.am = am3;\n dbits = 28;\n}\nBigInteger.prototype.DB = dbits;\nBigInteger.prototype.DM = ((1 << dbits) - 1);\nBigInteger.prototype.DV = (1 << dbits);\nvar BI_FP = 52;\nBigInteger.prototype.FV = Math.pow(2, BI_FP);\nBigInteger.prototype.F1 = BI_FP - dbits;\nBigInteger.prototype.F2 = 2 * dbits - BI_FP;\n// Digit conversions\nva