diff options
-rw-r--r-- | bip39-standalone.html | 10609 | ||||
-rw-r--r-- | changelog.md | 12 | ||||
-rw-r--r-- | src/index.html | 2 |
3 files changed, 1688 insertions, 8935 deletions
diff --git a/bip39-standalone.html b/bip39-standalone.html index a017cc0..8361e05 100644 --- a/bip39-standalone.html +++ b/bip39-standalone.html | |||
@@ -6877,7 +6877,7 @@ button.close { | |||
6877 | <div class="container"> | 6877 | <div class="container"> |
6878 | 6878 | ||
6879 | <h1 class="text-center">Mnemonic Code Converter</h1> | 6879 | <h1 class="text-center">Mnemonic Code Converter</h1> |
6880 | <p class="version">v0.3.4</p> | 6880 | <p class="version">v0.3.5</p> |
6881 | <hr> | 6881 | <hr> |
6882 | <div class="row"> | 6882 | <div class="row"> |
6883 | <div class="col-md-12"> | 6883 | <div class="col-md-12"> |
@@ -6910,7 +6910,12 @@ button.close { | |||
6910 | <option value="21">21</option> | 6910 | <option value="21">21</option> |
6911 | <option value="24">24</option> | 6911 | <option value="24">24</option> |
6912 | </select> | 6912 | </select> |
6913 | <span>words</span> | 6913 | <span>words</span>. |
6914 | <p class="warning help-block hidden"> | ||
6915 | <span class="text-danger"> | ||
6916 | Mnemonics with less than 12 words have low entropy and may be guessed by an attacker. | ||
6917 | </span> | ||
6918 | </p> | ||
6914 | </div> | 6919 | </div> |
6915 | </div> | 6920 | </div> |
6916 | </div> | 6921 | </div> |
@@ -6970,6 +6975,11 @@ button.close { | |||
6970 | <option value="21">21 <span>Words</span></option> | 6975 | <option value="21">21 <span>Words</span></option> |
6971 | <option value="24">24 <span>Words</span></option> | 6976 | <option value="24">24 <span>Words</span></option> |
6972 | </select> | 6977 | </select> |
6978 | <p class="weak-entropy-override-warning hidden"> | ||
6979 | <span class="text-danger"> | ||
6980 | The mnemonic will appear more secure than it really is. | ||
6981 | </span> | ||
6982 | </p> | ||
6973 | </div> | 6983 | </div> |
6974 | </div> | 6984 | </div> |
6975 | <div class="col-sm-3"> | 6985 | <div class="col-sm-3"> |
@@ -7475,7 +7485,7 @@ button.close { | |||
7475 | <span>Encrypt private keys using BIP38 and this password:</span> | 7485 | <span>Encrypt private keys using BIP38 and this password:</span> |
7476 | </label> | 7486 | </label> |
7477 | <input class="bip38-password"> | 7487 | <input class="bip38-password"> |
7478 | <span>Enabling BIP38 means each key will take take several minutes to generate.</span> | 7488 | <span>Enabling BIP38 means each key will take several minutes to generate.</span> |
7479 | </div> | 7489 | </div> |
7480 | </div> | 7490 | </div> |
7481 | <ul class="addresses-type nav nav-tabs" role="tablist"> | 7491 | <ul class="addresses-type nav nav-tabs" role="tablist"> |
@@ -33218,19 +33228,13 @@ function hasOwnProperty(obj, prop) { | |||
33218 | 33228 | ||
33219 | }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | 33229 | }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) |
33220 | },{"./support/isBuffer":32,"_process":13,"inherits":31}],34:[function(require,module,exports){ | 33230 | },{"./support/isBuffer":32,"_process":13,"inherits":31}],34:[function(require,module,exports){ |
33221 | bitcoin = { | 33231 | let bitcoin = require('bitcoinjs-lib'); |
33222 | base58: require('bs58'), | ||
33223 | bitcoin: require('bitcoinjs-lib'), | ||
33224 | ecurve: require('ecurve'), | ||
33225 | BigInteger: require('bigi'), | ||
33226 | Buffer: require('buffer'), | ||
33227 | elliptic: require('elliptic'), | ||
33228 | bs58check: require('bs58check'), | ||
33229 | } | ||
33230 | 33232 | ||
33231 | module.exports = bitcoin; | 33233 | module.exports = { |
33234 | bitcoin | ||
33235 | } | ||
33232 | 33236 | ||
33233 | },{"bigi":39,"bitcoinjs-lib":52,"bs58":83,"bs58check":85,"buffer":5,"ecurve":94,"elliptic":97}],35:[function(require,module,exports){ | 33237 | },{"bitcoinjs-lib":52}],35:[function(require,module,exports){ |
33234 | // base-x encoding | 33238 | // base-x encoding |
33235 | // Forked from https://github.com/cryptocoinjs/bs58 | 33239 | // Forked from https://github.com/cryptocoinjs/bs58 |
33236 | // Originally written by Mike Hearn for BitcoinJ | 33240 | // Originally written by Mike Hearn for BitcoinJ |
@@ -33274,7 +33278,7 @@ module.exports = function base (ALPHABET) { | |||
33274 | var string = '' | 33278 | var string = '' |
33275 | 33279 | ||
33276 | // deal with leading zeros | 33280 | // deal with leading zeros |
33277 | for (var k = 0; source[k] === 0 && k < source.length - 1; ++k) string += ALPHABET[0] | 33281 | for (var k = 0; source[k] === 0 && k < source.length - 1; ++k) string += LEADER |
33278 | // convert digits to a string | 33282 | // convert digits to a string |
33279 | for (var q = digits.length - 1; q >= 0; --q) string += ALPHABET[digits[q]] | 33283 | for (var q = digits.length - 1; q >= 0; --q) string += ALPHABET[digits[q]] |
33280 | 33284 | ||
@@ -33282,6 +33286,7 @@ module.exports = function base (ALPHABET) { | |||
33282 | } | 33286 | } |
33283 | 33287 | ||
33284 | function decodeUnsafe (string) { | 33288 | function decodeUnsafe (string) { |
33289 | if (typeof string !== 'string') throw new TypeError('Expected String') | ||
33285 | if (string.length === 0) return Buffer.allocUnsafe(0) | 33290 | if (string.length === 0) return Buffer.allocUnsafe(0) |
33286 | 33291 | ||
33287 | var bytes = [0] | 33292 | var bytes = [0] |
@@ -33323,21 +33328,21 @@ module.exports = function base (ALPHABET) { | |||
33323 | } | 33328 | } |
33324 | } | 33329 | } |
33325 | 33330 | ||
33326 | },{"safe-buffer":128}],36:[function(require,module,exports){ | 33331 | },{"safe-buffer":101}],36:[function(require,module,exports){ |
33327 | 'use strict' | 33332 | 'use strict' |
33328 | let ALPHABET = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l' | 33333 | var ALPHABET = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l' |
33329 | 33334 | ||
33330 | // pre-compute lookup table | 33335 | // pre-compute lookup table |
33331 | let ALPHABET_MAP = {} | 33336 | var ALPHABET_MAP = {} |
33332 | for (let z = 0; z < ALPHABET.length; z++) { | 33337 | for (var z = 0; z < ALPHABET.length; z++) { |
33333 | let x = ALPHABET.charAt(z) | 33338 | var x = ALPHABET.charAt(z) |
33334 | 33339 | ||
33335 | if (ALPHABET_MAP[x] !== undefined) throw new TypeError(x + ' is ambiguous') | 33340 | if (ALPHABET_MAP[x] !== undefined) throw new TypeError(x + ' is ambiguous') |
33336 | ALPHABET_MAP[x] = z | 33341 | ALPHABET_MAP[x] = z |
33337 | } | 33342 | } |
33338 | 33343 | ||
33339 | function polymodStep (pre) { | 33344 | function polymodStep (pre) { |
33340 | let b = pre >> 25 | 33345 | var b = pre >> 25 |
33341 | return ((pre & 0x1FFFFFF) << 5) ^ | 33346 | return ((pre & 0x1FFFFFF) << 5) ^ |
33342 | (-((b >> 0) & 1) & 0x3b6a57b2) ^ | 33347 | (-((b >> 0) & 1) & 0x3b6a57b2) ^ |
33343 | (-((b >> 1) & 1) & 0x26508e6d) ^ | 33348 | (-((b >> 1) & 1) & 0x26508e6d) ^ |
@@ -33347,73 +33352,76 @@ function polymodStep (pre) { | |||
33347 | } | 33352 | } |
33348 | 33353 | ||
33349 | function prefixChk (prefix) { | 33354 | function prefixChk (prefix) { |
33350 | let chk = 1 | 33355 | var chk = 1 |
33351 | for (let i = 0; i < prefix.length; ++i) { | 33356 | for (var i = 0; i < prefix.length; ++i) { |
33352 | let c = prefix.charCodeAt(i) | 33357 | var c = prefix.charCodeAt(i) |
33353 | if (c < 33 || c > 126) throw new Error('Invalid prefix (' + prefix + ')') | 33358 | if (c < 33 || c > 126) throw new Error('Invalid prefix (' + prefix + ')') |
33354 | 33359 | ||
33355 | chk = polymodStep(chk) ^ (c >> 5) | 33360 | chk = polymodStep(chk) ^ (c >> 5) |
33356 | } | 33361 | } |
33357 | chk = polymodStep(chk) | 33362 | chk = polymodStep(chk) |
33358 | 33363 | ||
33359 | for (let i = 0; i < prefix.length; ++i) { | 33364 | for (i = 0; i < prefix.length; ++i) { |
33360 | let v = prefix.charCodeAt(i) | 33365 | var v = prefix.charCodeAt(i) |
33361 | chk = polymodStep(chk) ^ (v & 0x1f) | 33366 | chk = polymodStep(chk) ^ (v & 0x1f) |
33362 | } | 33367 | } |
33363 | return chk | 33368 | return chk |
33364 | } | 33369 | } |
33365 | 33370 | ||
33366 | function encode (prefix, words) { | 33371 | function encode (prefix, words, LIMIT) { |
33367 | // too long? | 33372 | LIMIT = LIMIT || 90 |
33368 | if ((prefix.length + 7 + words.length) > 90) throw new TypeError('Exceeds Bech32 maximum length') | 33373 | if ((prefix.length + 7 + words.length) > LIMIT) throw new TypeError('Exceeds length limit') |
33374 | |||
33369 | prefix = prefix.toLowerCase() | 33375 | prefix = prefix.toLowerCase() |
33370 | 33376 | ||
33371 | // determine chk mod | 33377 | // determine chk mod |
33372 | let chk = prefixChk(prefix) | 33378 | var chk = prefixChk(prefix) |
33373 | let result = prefix + '1' | 33379 | var result = prefix + '1' |
33374 | for (let i = 0; i < words.length; ++i) { | 33380 | for (var i = 0; i < words.length; ++i) { |
33375 | let x = words[i] | 33381 | var x = words[i] |
33376 | if ((x >> 5) !== 0) throw new Error('Non 5-bit word') | 33382 | if ((x >> 5) !== 0) throw new Error('Non 5-bit word') |
33377 | 33383 | ||
33378 | chk = polymodStep(chk) ^ x | 33384 | chk = polymodStep(chk) ^ x |
33379 | result += ALPHABET.charAt(x) | 33385 | result += ALPHABET.charAt(x) |
33380 | } | 33386 | } |
33381 | 33387 | ||
33382 | for (let i = 0; i < 6; ++i) { | 33388 | for (i = 0; i < 6; ++i) { |
33383 | chk = polymodStep(chk) | 33389 | chk = polymodStep(chk) |
33384 | } | 33390 | } |
33385 | chk ^= 1 | 33391 | chk ^= 1 |
33386 | 33392 | ||
33387 | for (let i = 0; i < 6; ++i) { | 33393 | for (i = 0; i < 6; ++i) { |
33388 | let v = (chk >> ((5 - i) * 5)) & 0x1f | 33394 | var v = (chk >> ((5 - i) * 5)) & 0x1f |
33389 | result += ALPHABET.charAt(v) | 33395 | result += ALPHABET.charAt(v) |
33390 | } | 33396 | } |
33391 | 33397 | ||
33392 | return result | 33398 | return result |
33393 | } | 33399 | } |
33394 | 33400 | ||
33395 | function decode (str) { | 33401 | function decode (str, LIMIT) { |
33402 | LIMIT = LIMIT || 90 | ||
33396 | if (str.length < 8) throw new TypeError(str + ' too short') | 33403 | if (str.length < 8) throw new TypeError(str + ' too short') |
33397 | if (str.length > 90) throw new TypeError(str + ' too long') | 33404 | if (str.length > LIMIT) throw new TypeError('Exceeds length limit') |
33398 | 33405 | ||
33399 | // don't allow mixed case | 33406 | // don't allow mixed case |
33400 | let lowered = str.toLowerCase() | 33407 | var lowered = str.toLowerCase() |
33401 | let uppered = str.toUpperCase() | 33408 | var uppered = str.toUpperCase() |
33402 | if (str !== lowered && str !== uppered) throw new Error('Mixed-case string ' + str) | 33409 | if (str !== lowered && str !== uppered) throw new Error('Mixed-case string ' + str) |
33403 | str = lowered | 33410 | str = lowered |
33404 | 33411 | ||
33405 | let split = str.lastIndexOf('1') | 33412 | var split = str.lastIndexOf('1') |
33413 | if (split === -1) throw new Error('No separator character for ' + str) | ||
33406 | if (split === 0) throw new Error('Missing prefix for ' + str) | 33414 | if (split === 0) throw new Error('Missing prefix for ' + str) |
33407 | 33415 | ||
33408 | let prefix = str.slice(0, split) | 33416 | var prefix = str.slice(0, split) |
33409 | let wordChars = str.slice(split + 1) | 33417 | var wordChars = str.slice(split + 1) |
33410 | if (wordChars.length < 6) throw new Error('Data too short') | 33418 | if (wordChars.length < 6) throw new Error('Data too short') |
33411 | 33419 | ||
33412 | let chk = prefixChk(prefix) | 33420 | var chk = prefixChk(prefix) |
33413 | let words = [] | 33421 | var words = [] |
33414 | for (let i = 0; i < wordChars.length; ++i) { | 33422 | for (var i = 0; i < wordChars.length; ++i) { |
33415 | let c = wordChars.charAt(i) | 33423 | var c = wordChars.charAt(i) |
33416 | let v = ALPHABET_MAP[c] | 33424 | var v = ALPHABET_MAP[c] |
33417 | if (v === undefined) throw new Error('Unknown character ' + c) | 33425 | if (v === undefined) throw new Error('Unknown character ' + c) |
33418 | chk = polymodStep(chk) ^ v | 33426 | chk = polymodStep(chk) ^ v |
33419 | 33427 | ||
@@ -33423,16 +33431,16 @@ function decode (str) { | |||
33423 | } | 33431 | } |
33424 | 33432 | ||
33425 | if (chk !== 1) throw new Error('Invalid checksum for ' + str) | 33433 | if (chk !== 1) throw new Error('Invalid checksum for ' + str) |
33426 | return { prefix, words } | 33434 | return { prefix: prefix, words: words } |
33427 | } | 33435 | } |
33428 | 33436 | ||
33429 | function convert (data, inBits, outBits, pad) { | 33437 | function convert (data, inBits, outBits, pad) { |
33430 | let value = 0 | 33438 | var value = 0 |
33431 | let bits = 0 | 33439 | var bits = 0 |
33432 | let maxV = (1 << outBits) - 1 | 33440 | var maxV = (1 << outBits) - 1 |
33433 | 33441 | ||
33434 | let result = [] | 33442 | var result = [] |
33435 | for (let i = 0; i < data.length; ++i) { | 33443 | for (var i = 0; i < data.length; ++i) { |
33436 | value = (value << inBits) | data[i] | 33444 | value = (value << inBits) | data[i] |
33437 | bits += inBits | 33445 | bits += inBits |
33438 | 33446 | ||
@@ -33462,7 +33470,12 @@ function fromWords (words) { | |||
33462 | return convert(words, 5, 8, false) | 33470 | return convert(words, 5, 8, false) |
33463 | } | 33471 | } |
33464 | 33472 | ||
33465 | module.exports = { decode, encode, toWords, fromWords } | 33473 | module.exports = { |
33474 | decode: decode, | ||
33475 | encode: encode, | ||
33476 | toWords: toWords, | ||
33477 | fromWords: fromWords | ||
33478 | } | ||
33466 | 33479 | ||
33467 | },{}],37:[function(require,module,exports){ | 33480 | },{}],37:[function(require,module,exports){ |
33468 | // (public) Constructor | 33481 | // (public) Constructor |
@@ -35081,11 +35094,11 @@ module.exports = BigInteger | |||
35081 | module.exports={ | 35094 | module.exports={ |
35082 | "_args": [ | 35095 | "_args": [ |
35083 | [ | 35096 | [ |
35084 | "bigi", | 35097 | "bigi@^1.4.0", |
35085 | "/home/ian/git/bitcoin/bitcoinjs-lib-browser" | 35098 | "/home/ian/git/bitcoin/bitcoinjs-lib-browser/node_modules/bitcoinjs-lib" |
35086 | ] | 35099 | ] |
35087 | ], | 35100 | ], |
35088 | "_from": "bigi@latest", | 35101 | "_from": "bigi@>=1.4.0 <2.0.0", |
35089 | "_id": "bigi@1.4.2", | 35102 | "_id": "bigi@1.4.2", |
35090 | "_inCache": true, | 35103 | "_inCache": true, |
35091 | "_installable": true, | 35104 | "_installable": true, |
@@ -35103,22 +35116,21 @@ module.exports={ | |||
35103 | "_phantomChildren": {}, | 35116 | "_phantomChildren": {}, |
35104 | "_requested": { | 35117 | "_requested": { |
35105 | "name": "bigi", | 35118 | "name": "bigi", |
35106 | "raw": "bigi", | 35119 | "raw": "bigi@^1.4.0", |
35107 | "rawSpec": "", | 35120 | "rawSpec": "^1.4.0", |
35108 | "scope": null, | 35121 | "scope": null, |
35109 | "spec": "latest", | 35122 | "spec": ">=1.4.0 <2.0.0", |
35110 | "type": "tag" | 35123 | "type": "range" |
35111 | }, | 35124 | }, |
35112 | "_requiredBy": [ | 35125 | "_requiredBy": [ |
35113 | "#USER", | ||
35114 | "/bitcoinjs-lib", | 35126 | "/bitcoinjs-lib", |
35115 | "/ecurve" | 35127 | "/ecurve" |
35116 | ], | 35128 | ], |
35117 | "_resolved": "https://registry.npmjs.org/bigi/-/bigi-1.4.2.tgz", | 35129 | "_resolved": "https://registry.npmjs.org/bigi/-/bigi-1.4.2.tgz", |
35118 | "_shasum": "9c665a95f88b8b08fc05cfd731f561859d725825", | 35130 | "_shasum": "9c665a95f88b8b08fc05cfd731f561859d725825", |
35119 | "_shrinkwrap": null, | 35131 | "_shrinkwrap": null, |
35120 | "_spec": "bigi", | 35132 | "_spec": "bigi@^1.4.0", |
35121 | "_where": "/home/ian/git/bitcoin/bitcoinjs-lib-browser", | 35133 | "_where": "/home/ian/git/bitcoin/bitcoinjs-lib-browser/node_modules/bitcoinjs-lib", |
35122 | "bugs": { | 35134 | "bugs": { |
35123 | "url": "https://github.com/cryptocoinjs/bigi/issues" | 35135 | "url": "https://github.com/cryptocoinjs/bigi/issues" |
35124 | }, | 35136 | }, |
@@ -35319,7 +35331,7 @@ module.exports = { | |||
35319 | encode: encode | 35331 | encode: encode |
35320 | } | 35332 | } |
35321 | 35333 | ||
35322 | },{"safe-buffer":128}],42:[function(require,module,exports){ | 35334 | },{"safe-buffer":101}],42:[function(require,module,exports){ |
35323 | module.exports={ | 35335 | module.exports={ |
35324 | "OP_FALSE": 0, | 35336 | "OP_FALSE": 0, |
35325 | "OP_0": 0, | 35337 | "OP_0": 0, |
@@ -35328,8 +35340,8 @@ module.exports={ | |||
35328 | "OP_PUSHDATA4": 78, | 35340 | "OP_PUSHDATA4": 78, |
35329 | "OP_1NEGATE": 79, | 35341 | "OP_1NEGATE": 79, |
35330 | "OP_RESERVED": 80, | 35342 | "OP_RESERVED": 80, |
35331 | "OP_1": 81, | ||
35332 | "OP_TRUE": 81, | 35343 | "OP_TRUE": 81, |
35344 | "OP_1": 81, | ||
35333 | "OP_2": 82, | 35345 | "OP_2": 82, |
35334 | "OP_3": 83, | 35346 | "OP_3": 83, |
35335 | "OP_4": 84, | 35347 | "OP_4": 84, |
@@ -35434,10 +35446,13 @@ module.exports={ | |||
35434 | "OP_CHECKMULTISIGVERIFY": 175, | 35446 | "OP_CHECKMULTISIGVERIFY": 175, |
35435 | 35447 | ||
35436 | "OP_NOP1": 176, | 35448 | "OP_NOP1": 176, |
35449 | |||
35437 | "OP_NOP2": 177, | 35450 | "OP_NOP2": 177, |
35438 | "OP_CHECKLOCKTIMEVERIFY": 177, | 35451 | "OP_CHECKLOCKTIMEVERIFY": 177, |
35439 | 35452 | ||
35440 | "OP_NOP3": 178, | 35453 | "OP_NOP3": 178, |
35454 | "OP_CHECKSEQUENCEVERIFY": 178, | ||
35455 | |||
35441 | "OP_NOP4": 179, | 35456 | "OP_NOP4": 179, |
35442 | "OP_NOP5": 180, | 35457 | "OP_NOP5": 180, |
35443 | "OP_NOP6": 181, | 35458 | "OP_NOP6": 181, |
@@ -35561,7 +35576,7 @@ module.exports = { | |||
35561 | toOutputScript: toOutputScript | 35576 | toOutputScript: toOutputScript |
35562 | } | 35577 | } |
35563 | 35578 | ||
35564 | },{"./networks":53,"./script":54,"./templates":56,"./types":80,"bech32":36,"bs58check":85,"safe-buffer":128,"typeforce":139}],45:[function(require,module,exports){ | 35579 | },{"./networks":53,"./script":54,"./templates":56,"./types":80,"bech32":36,"bs58check":83,"safe-buffer":101,"typeforce":112}],45:[function(require,module,exports){ |
35565 | var Buffer = require('safe-buffer').Buffer | 35580 | var Buffer = require('safe-buffer').Buffer |
35566 | var bcrypto = require('./crypto') | 35581 | var bcrypto = require('./crypto') |
35567 | var fastMerkleRoot = require('merkle-lib/fastRoot') | 35582 | var fastMerkleRoot = require('merkle-lib/fastRoot') |
@@ -35740,7 +35755,7 @@ Block.prototype.checkProofOfWork = function () { | |||
35740 | 35755 | ||
35741 | module.exports = Block | 35756 | module.exports = Block |
35742 | 35757 | ||
35743 | },{"./crypto":47,"./transaction":78,"./types":80,"merkle-lib/fastRoot":122,"safe-buffer":128,"typeforce":139,"varuint-bitcoin":141}],46:[function(require,module,exports){ | 35758 | },{"./crypto":47,"./transaction":78,"./types":80,"merkle-lib/fastRoot":97,"safe-buffer":101,"typeforce":112,"varuint-bitcoin":114}],46:[function(require,module,exports){ |
35744 | var pushdata = require('pushdata-bitcoin') | 35759 | var pushdata = require('pushdata-bitcoin') |
35745 | var varuint = require('varuint-bitcoin') | 35760 | var varuint = require('varuint-bitcoin') |
35746 | 35761 | ||
@@ -35798,7 +35813,7 @@ module.exports = { | |||
35798 | writeVarInt: writeVarInt | 35813 | writeVarInt: writeVarInt |
35799 | } | 35814 | } |
35800 | 35815 | ||
35801 | },{"pushdata-bitcoin":125,"varuint-bitcoin":141}],47:[function(require,module,exports){ | 35816 | },{"pushdata-bitcoin":98,"varuint-bitcoin":114}],47:[function(require,module,exports){ |
35802 | var createHash = require('create-hash') | 35817 | var createHash = require('create-hash') |
35803 | 35818 | ||
35804 | function ripemd160 (buffer) { | 35819 | function ripemd160 (buffer) { |
@@ -35829,7 +35844,7 @@ module.exports = { | |||
35829 | sha256: sha256 | 35844 | sha256: sha256 |
35830 | } | 35845 | } |
35831 | 35846 | ||
35832 | },{"create-hash":87}],48:[function(require,module,exports){ | 35847 | },{"create-hash":85}],48:[function(require,module,exports){ |
35833 | var Buffer = require('safe-buffer').Buffer | 35848 | var Buffer = require('safe-buffer').Buffer |
35834 | var createHmac = require('create-hmac') | 35849 | var createHmac = require('create-hmac') |
35835 | var typeforce = require('typeforce') | 35850 | var typeforce = require('typeforce') |
@@ -35992,7 +36007,7 @@ module.exports = { | |||
35992 | __curve: secp256k1 | 36007 | __curve: secp256k1 |
35993 | } | 36008 | } |
35994 | 36009 | ||
35995 | },{"./ecsignature":50,"./types":80,"bigi":39,"create-hmac":90,"ecurve":94,"safe-buffer":128,"typeforce":139}],49:[function(require,module,exports){ | 36010 | },{"./ecsignature":50,"./types":80,"bigi":39,"create-hmac":88,"ecurve":92,"safe-buffer":101,"typeforce":112}],49:[function(require,module,exports){ |
35996 | var baddress = require('./address') | 36011 | var baddress = require('./address') |
35997 | var bcrypto = require('./crypto') | 36012 | var bcrypto = require('./crypto') |
35998 | var ecdsa = require('./ecdsa') | 36013 | var ecdsa = require('./ecdsa') |
@@ -36125,7 +36140,7 @@ ECPair.prototype.verify = function (hash, signature) { | |||
36125 | 36140 | ||
36126 | module.exports = ECPair | 36141 | module.exports = ECPair |
36127 | 36142 | ||
36128 | },{"./address":44,"./crypto":47,"./ecdsa":48,"./networks":53,"./types":80,"bigi":39,"ecurve":94,"randombytes":126,"typeforce":139,"wif":142}],50:[function(require,module,exports){ | 36143 | },{"./address":44,"./crypto":47,"./ecdsa":48,"./networks":53,"./types":80,"bigi":39,"ecurve":92,"randombytes":99,"typeforce":112,"wif":115}],50:[function(require,module,exports){ |
36129 | (function (Buffer){ | 36144 | (function (Buffer){ |
36130 | var bip66 = require('bip66') | 36145 | var bip66 = require('bip66') |
36131 | var typeforce = require('typeforce') | 36146 | var typeforce = require('typeforce') |
@@ -36226,7 +36241,7 @@ ECSignature.prototype.toScriptSignature = function (hashType) { | |||
36226 | module.exports = ECSignature | 36241 | module.exports = ECSignature |
36227 | 36242 | ||
36228 | }).call(this,require("buffer").Buffer) | 36243 | }).call(this,require("buffer").Buffer) |
36229 | },{"./types":80,"bigi":39,"bip66":41,"buffer":5,"typeforce":139}],51:[function(require,module,exports){ | 36244 | },{"./types":80,"bigi":39,"bip66":41,"buffer":5,"typeforce":112}],51:[function(require,module,exports){ |
36230 | var Buffer = require('safe-buffer').Buffer | 36245 | var Buffer = require('safe-buffer').Buffer |
36231 | var base58check = require('bs58check') | 36246 | var base58check = require('bs58check') |
36232 | var bcrypto = require('./crypto') | 36247 | var bcrypto = require('./crypto') |
@@ -36544,7 +36559,7 @@ HDNode.prototype.derivePath = function (path) { | |||
36544 | 36559 | ||
36545 | module.exports = HDNode | 36560 | module.exports = HDNode |
36546 | 36561 | ||
36547 | },{"./crypto":47,"./ecpair":49,"./networks":53,"./types":80,"bigi":39,"bs58check":85,"create-hmac":90,"ecurve":94,"safe-buffer":128,"typeforce":139}],52:[function(require,module,exports){ | 36562 | },{"./crypto":47,"./ecpair":49,"./networks":53,"./types":80,"bigi":39,"bs58check":83,"create-hmac":88,"ecurve":92,"safe-buffer":101,"typeforce":112}],52:[function(require,module,exports){ |
36548 | var script = require('./script') | 36563 | var script = require('./script') |
36549 | 36564 | ||
36550 | var templates = require('./templates') | 36565 | var templates = require('./templates') |
@@ -36824,7 +36839,7 @@ module.exports = { | |||
36824 | isDefinedHashType: isDefinedHashType | 36839 | isDefinedHashType: isDefinedHashType |
36825 | } | 36840 | } |
36826 | 36841 | ||
36827 | },{"./script_number":55,"./types":80,"bip66":41,"bitcoin-ops":42,"bitcoin-ops/map":43,"pushdata-bitcoin":125,"safe-buffer":128,"typeforce":139}],55:[function(require,module,exports){ | 36842 | },{"./script_number":55,"./types":80,"bip66":41,"bitcoin-ops":42,"bitcoin-ops/map":43,"pushdata-bitcoin":98,"safe-buffer":101,"typeforce":112}],55:[function(require,module,exports){ |
36828 | var Buffer = require('safe-buffer').Buffer | 36843 | var Buffer = require('safe-buffer').Buffer |
36829 | 36844 | ||
36830 | function decode (buffer, maxLength, minimal) { | 36845 | function decode (buffer, maxLength, minimal) { |
@@ -36894,7 +36909,7 @@ module.exports = { | |||
36894 | encode: encode | 36909 | encode: encode |
36895 | } | 36910 | } |
36896 | 36911 | ||
36897 | },{"safe-buffer":128}],56:[function(require,module,exports){ | 36912 | },{"safe-buffer":101}],56:[function(require,module,exports){ |
36898 | var decompile = require('../script').decompile | 36913 | var decompile = require('../script').decompile |
36899 | var multisig = require('./multisig') | 36914 | var multisig = require('./multisig') |
36900 | var nullData = require('./nulldata') | 36915 | var nullData = require('./nulldata') |
@@ -37032,6 +37047,7 @@ function encode (signatures, scriptPubKey) { | |||
37032 | } | 37047 | } |
37033 | 37048 | ||
37034 | function decodeStack (stack, allowIncomplete) { | 37049 | function decodeStack (stack, allowIncomplete) { |
37050 | typeforce(typeforce.Array, stack) | ||
37035 | typeforce(check, stack, allowIncomplete) | 37051 | typeforce(check, stack, allowIncomplete) |
37036 | return stack.slice(1) | 37052 | return stack.slice(1) |
37037 | } | 37053 | } |
@@ -37049,7 +37065,7 @@ module.exports = { | |||
37049 | encodeStack: encodeStack | 37065 | encodeStack: encodeStack |
37050 | } | 37066 | } |
37051 | 37067 | ||
37052 | },{"../../script":54,"./output":59,"bitcoin-ops":42,"safe-buffer":128,"typeforce":139}],59:[function(require,module,exports){ | 37068 | },{"../../script":54,"./output":59,"bitcoin-ops":42,"safe-buffer":101,"typeforce":112}],59:[function(require,module,exports){ |
37053 | // m [pubKeys ...] n OP_CHECKMULTISIG | 37069 | // m [pubKeys ...] n OP_CHECKMULTISIG |
37054 | 37070 | ||
37055 | var bscript = require('../../script') | 37071 | var bscript = require('../../script') |
@@ -37115,7 +37131,7 @@ module.exports = { | |||
37115 | encode: encode | 37131 | encode: encode |
37116 | } | 37132 | } |
37117 | 37133 | ||
37118 | },{"../../script":54,"../../types":80,"bitcoin-ops":42,"typeforce":139}],60:[function(require,module,exports){ | 37134 | },{"../../script":54,"../../types":80,"bitcoin-ops":42,"typeforce":112}],60:[function(require,module,exports){ |
37119 | // OP_RETURN {data} | 37135 | // OP_RETURN {data} |
37120 | 37136 | ||
37121 | var bscript = require('../script') | 37137 | var bscript = require('../script') |
@@ -37151,7 +37167,7 @@ module.exports = { | |||
37151 | } | 37167 | } |
37152 | } | 37168 | } |
37153 | 37169 | ||
37154 | },{"../script":54,"../types":80,"bitcoin-ops":42,"typeforce":139}],61:[function(require,module,exports){ | 37170 | },{"../script":54,"../types":80,"bitcoin-ops":42,"typeforce":112}],61:[function(require,module,exports){ |
37155 | arguments[4][57][0].apply(exports,arguments) | 37171 | arguments[4][57][0].apply(exports,arguments) |
37156 | },{"./input":62,"./output":63,"dup":57}],62:[function(require,module,exports){ | 37172 | },{"./input":62,"./output":63,"dup":57}],62:[function(require,module,exports){ |
37157 | // {signature} | 37173 | // {signature} |
@@ -37177,6 +37193,7 @@ function encode (signature) { | |||
37177 | } | 37193 | } |
37178 | 37194 | ||
37179 | function decodeStack (stack) { | 37195 | function decodeStack (stack) { |
37196 | typeforce(typeforce.Array, stack) | ||
37180 | typeforce(check, stack) | 37197 | typeforce(check, stack) |
37181 | return stack[0] | 37198 | return stack[0] |
37182 | } | 37199 | } |
@@ -37194,7 +37211,7 @@ module.exports = { | |||
37194 | encodeStack: encodeStack | 37211 | encodeStack: encodeStack |
37195 | } | 37212 | } |
37196 | 37213 | ||
37197 | },{"../../script":54,"typeforce":139}],63:[function(require,module,exports){ | 37214 | },{"../../script":54,"typeforce":112}],63:[function(require,module,exports){ |
37198 | // {pubKey} OP_CHECKSIG | 37215 | // {pubKey} OP_CHECKSIG |
37199 | 37216 | ||
37200 | var bscript = require('../../script') | 37217 | var bscript = require('../../script') |
@@ -37229,7 +37246,7 @@ module.exports = { | |||
37229 | encode: encode | 37246 | encode: encode |
37230 | } | 37247 | } |
37231 | 37248 | ||
37232 | },{"../../script":54,"bitcoin-ops":42,"typeforce":139}],64:[function(require,module,exports){ | 37249 | },{"../../script":54,"bitcoin-ops":42,"typeforce":112}],64:[function(require,module,exports){ |
37233 | arguments[4][57][0].apply(exports,arguments) | 37250 | arguments[4][57][0].apply(exports,arguments) |
37234 | },{"./input":65,"./output":66,"dup":57}],65:[function(require,module,exports){ | 37251 | },{"./input":65,"./output":66,"dup":57}],65:[function(require,module,exports){ |
37235 | // {signature} {pubKey} | 37252 | // {signature} {pubKey} |
@@ -37263,6 +37280,7 @@ function encode (signature, pubKey) { | |||
37263 | } | 37280 | } |
37264 | 37281 | ||
37265 | function decodeStack (stack) { | 37282 | function decodeStack (stack) { |
37283 | typeforce(typeforce.Array, stack) | ||
37266 | typeforce(check, stack) | 37284 | typeforce(check, stack) |
37267 | 37285 | ||
37268 | return { | 37286 | return { |
@@ -37284,7 +37302,7 @@ module.exports = { | |||
37284 | encodeStack: encodeStack | 37302 | encodeStack: encodeStack |
37285 | } | 37303 | } |
37286 | 37304 | ||
37287 | },{"../../script":54,"typeforce":139}],66:[function(require,module,exports){ | 37305 | },{"../../script":54,"typeforce":112}],66:[function(require,module,exports){ |
37288 | // OP_DUP OP_HASH160 {pubKeyHash} OP_EQUALVERIFY OP_CHECKSIG | 37306 | // OP_DUP OP_HASH160 {pubKeyHash} OP_EQUALVERIFY OP_CHECKSIG |
37289 | 37307 | ||
37290 | var bscript = require('../../script') | 37308 | var bscript = require('../../script') |
@@ -37328,7 +37346,7 @@ module.exports = { | |||
37328 | encode: encode | 37346 | encode: encode |
37329 | } | 37347 | } |
37330 | 37348 | ||
37331 | },{"../../script":54,"../../types":80,"bitcoin-ops":42,"typeforce":139}],67:[function(require,module,exports){ | 37349 | },{"../../script":54,"../../types":80,"bitcoin-ops":42,"typeforce":112}],67:[function(require,module,exports){ |
37332 | arguments[4][57][0].apply(exports,arguments) | 37350 | arguments[4][57][0].apply(exports,arguments) |
37333 | },{"./input":68,"./output":69,"dup":57}],68:[function(require,module,exports){ | 37351 | },{"./input":68,"./output":69,"dup":57}],68:[function(require,module,exports){ |
37334 | // <scriptSig> {serialized scriptPubKey script} | 37352 | // <scriptSig> {serialized scriptPubKey script} |
@@ -37392,6 +37410,7 @@ function encode (redeemScriptSig, redeemScript) { | |||
37392 | } | 37410 | } |
37393 | 37411 | ||
37394 | function decodeStack (stack) { | 37412 | function decodeStack (stack) { |
37413 | typeforce(typeforce.Array, stack) | ||
37395 | typeforce(check, stack) | 37414 | typeforce(check, stack) |
37396 | 37415 | ||
37397 | return { | 37416 | return { |
@@ -37416,7 +37435,7 @@ module.exports = { | |||
37416 | encodeStack: encodeStack | 37435 | encodeStack: encodeStack |
37417 | } | 37436 | } |
37418 | 37437 | ||
37419 | },{"../../script":54,"../multisig/":57,"../pubkey/":61,"../pubkeyhash/":64,"../witnesspubkeyhash/output":74,"../witnessscripthash/output":77,"safe-buffer":128,"typeforce":139}],69:[function(require,module,exports){ | 37438 | },{"../../script":54,"../multisig/":57,"../pubkey/":61,"../pubkeyhash/":64,"../witnesspubkeyhash/output":74,"../witnessscripthash/output":77,"safe-buffer":101,"typeforce":112}],69:[function(require,module,exports){ |
37420 | // OP_HASH160 {scriptHash} OP_EQUAL | 37439 | // OP_HASH160 {scriptHash} OP_EQUAL |
37421 | 37440 | ||
37422 | var bscript = require('../../script') | 37441 | var bscript = require('../../script') |
@@ -37452,7 +37471,7 @@ module.exports = { | |||
37452 | encode: encode | 37471 | encode: encode |
37453 | } | 37472 | } |
37454 | 37473 | ||
37455 | },{"../../script":54,"../../types":80,"bitcoin-ops":42,"typeforce":139}],70:[function(require,module,exports){ | 37474 | },{"../../script":54,"../../types":80,"bitcoin-ops":42,"typeforce":112}],70:[function(require,module,exports){ |
37456 | module.exports = { | 37475 | module.exports = { |
37457 | output: require('./output') | 37476 | output: require('./output') |
37458 | } | 37477 | } |
@@ -37501,7 +37520,7 @@ module.exports = { | |||
37501 | encode: encode | 37520 | encode: encode |
37502 | } | 37521 | } |
37503 | 37522 | ||
37504 | },{"../../script":54,"../../types":80,"bitcoin-ops":42,"safe-buffer":128,"typeforce":139}],72:[function(require,module,exports){ | 37523 | },{"../../script":54,"../../types":80,"bitcoin-ops":42,"safe-buffer":101,"typeforce":112}],72:[function(require,module,exports){ |
37505 | arguments[4][57][0].apply(exports,arguments) | 37524 | arguments[4][57][0].apply(exports,arguments) |
37506 | },{"./input":73,"./output":74,"dup":57}],73:[function(require,module,exports){ | 37525 | },{"./input":73,"./output":74,"dup":57}],73:[function(require,module,exports){ |
37507 | // {signature} {pubKey} | 37526 | // {signature} {pubKey} |
@@ -37535,6 +37554,7 @@ function encodeStack (signature, pubKey) { | |||
37535 | } | 37554 | } |
37536 | 37555 | ||
37537 | function decodeStack (stack) { | 37556 | function decodeStack (stack) { |
37557 | typeforce(typeforce.Array, stack) | ||
37538 | typeforce(check, stack) | 37558 | typeforce(check, stack) |
37539 | 37559 | ||
37540 | return { | 37560 | return { |
@@ -37549,7 +37569,7 @@ module.exports = { | |||
37549 | encodeStack: encodeStack | 37569 | encodeStack: encodeStack |
37550 | } | 37570 | } |
37551 | 37571 | ||
37552 | },{"../../script":54,"typeforce":139}],74:[function(require,module,exports){ | 37572 | },{"../../script":54,"typeforce":112}],74:[function(require,module,exports){ |
37553 | // OP_0 {pubKeyHash} | 37573 | // OP_0 {pubKeyHash} |
37554 | 37574 | ||
37555 | var bscript = require('../../script') | 37575 | var bscript = require('../../script') |
@@ -37584,7 +37604,7 @@ module.exports = { | |||
37584 | encode: encode | 37604 | encode: encode |
37585 | } | 37605 | } |
37586 | 37606 | ||
37587 | },{"../../script":54,"../../types":80,"bitcoin-ops":42,"typeforce":139}],75:[function(require,module,exports){ | 37607 | },{"../../script":54,"../../types":80,"bitcoin-ops":42,"typeforce":112}],75:[function(require,module,exports){ |
37588 | arguments[4][57][0].apply(exports,arguments) | 37608 | arguments[4][57][0].apply(exports,arguments) |
37589 | },{"./input":76,"./output":77,"dup":57}],76:[function(require,module,exports){ | 37609 | },{"./input":76,"./output":77,"dup":57}],76:[function(require,module,exports){ |
37590 | (function (Buffer){ | 37610 | (function (Buffer){ |
@@ -37638,11 +37658,12 @@ function encodeStack (witnessData, witnessScript) { | |||
37638 | return [].concat(witnessData, witnessScript) | 37658 | return [].concat(witnessData, witnessScript) |
37639 | } | 37659 | } |
37640 | 37660 | ||
37641 | function decodeStack (chunks) { | 37661 | function decodeStack (stack) { |
37642 | typeforce(check, chunks) | 37662 | typeforce(typeforce.Array, stack) |
37663 | typeforce(check, stack) | ||
37643 | return { | 37664 | return { |
37644 | witnessData: chunks.slice(0, -1), | 37665 | witnessData: stack.slice(0, -1), |
37645 | witnessScript: chunks[chunks.length - 1] | 37666 | witnessScript: stack[stack.length - 1] |
37646 | } | 37667 | } |
37647 | } | 37668 | } |
37648 | 37669 | ||
@@ -37653,7 +37674,7 @@ module.exports = { | |||
37653 | } | 37674 | } |
37654 | 37675 | ||
37655 | }).call(this,{"isBuffer":require("../../../../../../../../.nvm/versions/node/v6.0.0/lib/node_modules/browserify/node_modules/is-buffer/index.js")}) | 37676 | }).call(this,{"isBuffer":require("../../../../../../../../.nvm/versions/node/v6.0.0/lib/node_modules/browserify/node_modules/is-buffer/index.js")}) |
37656 | },{"../../../../../../../../.nvm/versions/node/v6.0.0/lib/node_modules/browserify/node_modules/is-buffer/index.js":10,"../../script":54,"../../types":80,"../multisig/":57,"../pubkey/":61,"../pubkeyhash/":64,"typeforce":139}],77:[function(require,module,exports){ | 37677 | },{"../../../../../../../../.nvm/versions/node/v6.0.0/lib/node_modules/browserify/node_modules/is-buffer/index.js":10,"../../script":54,"../../types":80,"../multisig/":57,"../pubkey/":61,"../pubkeyhash/":64,"typeforce":112}],77:[function(require,module,exports){ |
37657 | // OP_0 {scriptHash} | 37678 | // OP_0 {scriptHash} |
37658 | 37679 | ||
37659 | var bscript = require('../../script') | 37680 | var bscript = require('../../script') |
@@ -37688,7 +37709,7 @@ module.exports = { | |||
37688 | encode: encode | 37709 | encode: encode |
37689 | } | 37710 | } |
37690 | 37711 | ||
37691 | },{"../../script":54,"../../types":80,"bitcoin-ops":42,"typeforce":139}],78:[function(require,module,exports){ | 37712 | },{"../../script":54,"../../types":80,"bitcoin-ops":42,"typeforce":112}],78:[function(require,module,exports){ |
37692 | var Buffer = require('safe-buffer').Buffer | 37713 | var Buffer = require('safe-buffer').Buffer |
37693 | var bcrypto = require('./crypto') | 37714 | var bcrypto = require('./crypto') |
37694 | var bscript = require('./script') | 37715 | var bscript = require('./script') |
@@ -38182,7 +38203,7 @@ Transaction.prototype.setWitness = function (index, witness) { | |||
38182 | 38203 | ||
38183 | module.exports = Transaction | 38204 | module.exports = Transaction |
38184 | 38205 | ||
38185 | },{"./bufferutils":46,"./crypto":47,"./script":54,"./types":80,"bitcoin-ops":42,"safe-buffer":128,"typeforce":139,"varuint-bitcoin":141}],79:[function(require,module,exports){ | 38206 | },{"./bufferutils":46,"./crypto":47,"./script":54,"./types":80,"bitcoin-ops":42,"safe-buffer":101,"typeforce":112,"varuint-bitcoin":114}],79:[function(require,module,exports){ |
38186 | var Buffer = require('safe-buffer').Buffer | 38207 | var Buffer = require('safe-buffer').Buffer |
38187 | var baddress = require('./address') | 38208 | var baddress = require('./address') |
38188 | var bcrypto = require('./crypto') | 38209 | var bcrypto = require('./crypto') |
@@ -38654,7 +38675,7 @@ function TransactionBuilder (network, maximumFeeRate) { | |||
38654 | this.network = network || networks.bitcoin | 38675 | this.network = network || networks.bitcoin |
38655 | 38676 | ||
38656 | // WARNING: This is __NOT__ to be relied on, its just another potential safety mechanism (safety in-depth) | 38677 | // WARNING: This is __NOT__ to be relied on, its just another potential safety mechanism (safety in-depth) |
38657 | this.maximumFeeRate = maximumFeeRate || 1000 | 38678 | this.maximumFeeRate = maximumFeeRate || 2500 |
38658 | 38679 | ||
38659 | this.inputs = [] | 38680 | this.inputs = [] |
38660 | this.tx = new Transaction() | 38681 | this.tx = new Transaction() |
@@ -38961,7 +38982,7 @@ TransactionBuilder.prototype.__overMaximumFees = function (bytes) { | |||
38961 | 38982 | ||
38962 | module.exports = TransactionBuilder | 38983 | module.exports = TransactionBuilder |
38963 | 38984 | ||
38964 | },{"./address":44,"./crypto":47,"./ecpair":49,"./ecsignature":50,"./networks":53,"./script":54,"./templates":56,"./transaction":78,"./types":80,"bitcoin-ops":42,"safe-buffer":128,"typeforce":139}],80:[function(require,module,exports){ | 38985 | },{"./address":44,"./crypto":47,"./ecpair":49,"./ecsignature":50,"./networks":53,"./script":54,"./templates":56,"./transaction":78,"./types":80,"bitcoin-ops":42,"safe-buffer":101,"typeforce":112}],80:[function(require,module,exports){ |
38965 | var typeforce = require('typeforce') | 38986 | var typeforce = require('typeforce') |
38966 | 38987 | ||
38967 | var UINT31_MAX = Math.pow(2, 31) - 1 | 38988 | var UINT31_MAX = Math.pow(2, 31) - 1 |
@@ -39016,3513 +39037,17 @@ for (var typeName in typeforce) { | |||
39016 | 39037 | ||
39017 | module.exports = types | 39038 | module.exports = types |
39018 | 39039 | ||
39019 | },{"typeforce":139}],81:[function(require,module,exports){ | 39040 | },{"typeforce":112}],81:[function(require,module,exports){ |
39020 | (function (module, exports) { | ||
39021 | 'use strict'; | ||
39022 | |||
39023 | // Utils | ||
39024 | function assert (val, msg) { | ||
39025 | if (!val) throw new Error(msg || 'Assertion failed'); | ||
39026 | } | ||
39027 | |||
39028 | // Could use `inherits` module, but don't want to move from single file | ||
39029 | // architecture yet. | ||
39030 | function inherits (ctor, superCtor) { | ||
39031 | ctor.super_ = superCtor; | ||
39032 | var TempCtor = function () {}; | ||
39033 | TempCtor.prototype = superCtor.prototype; | ||
39034 | ctor.prototype = new TempCtor(); | ||
39035 | ctor.prototype.constructor = ctor; | ||
39036 | } | ||
39037 | |||
39038 | // BN | ||
39039 | |||
39040 | function BN (number, base, endian) { | ||
39041 | if (BN.isBN(number)) { | ||
39042 | return number; | ||
39043 | } | ||
39044 | |||
39045 | this.negative = 0; | ||
39046 | this.words = null; | ||
39047 | this.length = 0; | ||
39048 | |||
39049 | // Reduction context | ||
39050 | this.red = null; | ||
39051 | |||
39052 | if (number !== null) { | ||
39053 | if (base === 'le' || base === 'be') { | ||
39054 | endian = base; | ||
39055 | base = 10; | ||
39056 | } | ||
39057 | |||
39058 | this._init(number || 0, base || 10, endian || 'be'); | ||
39059 | } | ||
39060 | } | ||
39061 | if (typeof module === 'object') { | ||
39062 | module.exports = BN; | ||
39063 | } else { | ||
39064 | exports.BN = BN; | ||
39065 | } | ||
39066 | |||
39067 | BN.BN = BN; | ||
39068 | BN.wordSize = 26; | ||
39069 | |||
39070 | var Buffer; | ||
39071 | try { | ||
39072 | Buffer = require('buf' + 'fer').Buffer; | ||
39073 | } catch (e) { | ||
39074 | } | ||
39075 | |||
39076 | BN.isBN = function isBN (num) { | ||
39077 | if (num instanceof BN) { | ||
39078 | return true; | ||
39079 | } | ||
39080 | |||
39081 | return num !== null && typeof num === 'object' && | ||
39082 | num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); | ||
39083 | }; | ||
39084 | |||
39085 | BN.max = function max (left, right) { | ||
39086 | if (left.cmp(right) > 0) return left; | ||
39087 | return right; | ||
39088 | }; | ||
39089 | |||
39090 | BN.min = function min (left, right) { | ||
39091 | if (left.cmp(right) < 0) return left; | ||
39092 | return right; | ||
39093 | }; | ||
39094 | |||
39095 | BN.prototype._init = function init (number, base, endian) { | ||
39096 | if (typeof number === 'number') { | ||
39097 | return this._initNumber(number, base, endian); | ||
39098 | } | ||
39099 | |||
39100 | if (typeof number === 'object') { | ||
39101 | return this._initArray(number, base, endian); | ||
39102 | } | ||
39103 | |||
39104 | if (base === 'hex') { | ||
39105 | base = 16; | ||
39106 | } | ||
39107 | assert(base === (base | 0) && base >= 2 && base <= 36); | ||
39108 | |||
39109 | number = number.toString().replace(/\s+/g, ''); | ||
39110 | var start = 0; | ||
39111 | if (number[0] === '-') { | ||
39112 | start++; | ||
39113 | } | ||
39114 | |||
39115 | if (base === 16) { | ||
39116 | this._parseHex(number, start); | ||
39117 | } else { | ||
39118 | this._parseBase(number, base, start); | ||
39119 | } | ||
39120 | |||
39121 | if (number[0] === '-') { | ||
39122 | this.negative = 1; | ||
39123 | } | ||
39124 | |||
39125 | this.strip(); | ||
39126 | |||
39127 | if (endian !== 'le') return; | ||
39128 | |||
39129 | this._initArray(this.toArray(), base, endian); | ||
39130 | }; | ||
39131 | |||
39132 | BN.prototype._initNumber = function _initNumber (number, base, endian) { | ||
39133 | if (number < 0) { | ||
39134 | this.negative = 1; | ||
39135 | number = -number; | ||
39136 | } | ||
39137 | if (number < 0x4000000) { | ||
39138 | this.words = [ number & 0x3ffffff ]; | ||
39139 | this.length = 1; | ||
39140 | } else if (number < 0x10000000000000) { | ||
39141 | this.words = [ | ||
39142 | number & 0x3ffffff, | ||
39143 | (number / 0x4000000) & 0x3ffffff | ||
39144 | ]; | ||
39145 | this.length = 2; | ||
39146 | } else { | ||
39147 | assert(number < 0x20000000000000); // 2 ^ 53 (unsafe) | ||
39148 | this.words = [ | ||
39149 | number & 0x3ffffff, | ||
39150 | (number / 0x4000000) & 0x3ffffff, | ||
39151 | 1 | ||
39152 | ]; | ||
39153 | this.length = 3; | ||
39154 | } | ||
39155 | |||
39156 | if (endian !== 'le') return; | ||
39157 | |||
39158 | // Reverse the bytes | ||
39159 | this._initArray(this.toArray(), base, endian); | ||
39160 | }; | ||
39161 | |||
39162 | BN.prototype._initArray = function _initArray (number, base, endian) { | ||
39163 | // Perhaps a Uint8Array | ||
39164 | assert(typeof number.length === 'number'); | ||
39165 | if (number.length <= 0) { | ||
39166 | this.words = [ 0 ]; | ||
39167 | this.length = 1; | ||
39168 | return this; | ||
39169 | } | ||
39170 | |||
39171 | this.length = Math.ceil(number.length / 3); | ||
39172 | this.words = new Array(this.length); | ||
39173 | for (var i = 0; i < this.length; i++) { | ||
39174 | this.words[i] = 0; | ||
39175 | } | ||
39176 | |||
39177 | var j, w; | ||
39178 | var off = 0; | ||
39179 | if (endian === 'be') { | ||
39180 | for (i = number.length - 1, j = 0; i >= 0; i -= 3) { | ||
39181 | w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16); | ||
39182 | this.words[j] |= (w << off) & 0x3ffffff; | ||
39183 | this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; | ||
39184 | off += 24; | ||
39185 | if (off >= 26) { | ||
39186 | off -= 26; | ||
39187 | j++; | ||
39188 | } | ||
39189 | } | ||
39190 | } else if (endian === 'le') { | ||
39191 | for (i = 0, j = 0; i < number.length; i += 3) { | ||
39192 | w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16); | ||
39193 | this.words[j] |= (w << off) & 0x3ffffff; | ||
39194 | this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; | ||
39195 | off += 24; | ||
39196 | if (off >= 26) { | ||
39197 | off -= 26; | ||
39198 | j++; | ||
39199 | } | ||
39200 | } | ||
39201 | } | ||
39202 | return this.strip(); | ||
39203 | }; | ||
39204 | |||
39205 | function parseHex (str, start, end) { | ||
39206 | var r = 0; | ||
39207 | var len = Math.min(str.length, end); | ||
39208 | for (var i = start; i < len; i++) { | ||
39209 | var c = str.charCodeAt(i) - 48; | ||
39210 | |||
39211 | r <<= 4; | ||
39212 | |||
39213 | // 'a' - 'f' | ||
39214 | if (c >= 49 && c <= 54) { | ||
39215 | r |= c - 49 + 0xa; | ||
39216 | |||
39217 | // 'A' - 'F' | ||
39218 | } else if (c >= 17 && c <= 22) { | ||
39219 | r |= c - 17 + 0xa; | ||
39220 | |||
39221 | // '0' - '9' | ||
39222 | } else { | ||
39223 | r |= c & 0xf; | ||
39224 | } | ||
39225 | } | ||
39226 | return r; | ||
39227 | } | ||
39228 | |||
39229 | BN.prototype._parseHex = function _parseHex (number, start) { | ||
39230 | // Create possibly bigger array to ensure that it fits the number | ||
39231 | this.length = Math.ceil((number.length - start) / 6); | ||
39232 | this.words = new Array(this.length); | ||
39233 | for (var i = 0; i < this.length; i++) { | ||
39234 | this.words[i] = 0; | ||
39235 | } | ||
39236 | |||
39237 | var j, w; | ||
39238 | // Scan 24-bit chunks and add them to the number | ||
39239 | var off = 0; | ||
39240 | for (i = number.length - 6, j = 0; i >= start; i -= 6) { | ||
39241 | w = parseHex(number, i, i + 6); | ||
39242 | this.words[j] |= (w << off) & 0x3ffffff; | ||
39243 | // NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb | ||
39244 | this.words[j + 1] |= w >>> (26 - off) & 0x3fffff; | ||
39245 | off += 24; | ||
39246 | if (off >= 26) { | ||
39247 | off -= 26; | ||
39248 | j++; | ||
39249 | } | ||
39250 | } | ||
39251 | if (i + 6 !== start) { | ||
39252 | w = parseHex(number, start, i + 6); | ||
39253 | this.words[j] |= (w << off) & 0x3ffffff; | ||
39254 | this.words[j + 1] |= w >>> (26 - off) & 0x3fffff; | ||
39255 | } | ||
39256 | this.strip(); | ||
39257 | }; | ||
39258 | |||
39259 | function parseBase (str, start, end, mul) { | ||
39260 | var r = 0; | ||
39261 | var len = Math.min(str.length, end); | ||
39262 | for (var i = start; i < len; i++) { | ||
39263 | var c = str.charCodeAt(i) - 48; | ||
39264 | |||
39265 | r *= mul; | ||
39266 | |||
39267 | // 'a' | ||
39268 | if (c >= 49) { | ||
39269 | r += c - 49 + 0xa; | ||
39270 | |||
39271 | // 'A' | ||
39272 | } else if (c >= 17) { | ||
39273 | r += c - 17 + 0xa; | ||
39274 | |||
39275 | // '0' - '9' | ||
39276 | } else { | ||
39277 | r += c; | ||
39278 | } | ||
39279 | } | ||
39280 | return r; | ||
39281 | } | ||
39282 | |||
39283 | BN.prototype._parseBase = function _parseBase (number, base, start) { | ||
39284 | // Initialize as zero | ||
39285 | this.words = [ 0 ]; | ||
39286 | this.length = 1; | ||
39287 | |||
39288 | // Find length of limb in base | ||
39289 | for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) { | ||
39290 | limbLen++; | ||
39291 | } | ||
39292 | limbLen--; | ||
39293 | limbPow = (limbPow / base) | 0; | ||
39294 | |||
39295 | var total = number.length - start; | ||
39296 | var mod = total % limbLen; | ||
39297 | var end = Math.min(total, total - mod) + start; | ||
39298 | |||
39299 | var word = 0; | ||
39300 | for (var i = start; i < end; i += limbLen) { | ||
39301 | word = parseBase(number, i, i + limbLen, base); | ||
39302 | |||
39303 | this.imuln(limbPow); | ||
39304 | if (this.words[0] + word < 0x4000000) { | ||
39305 | this.words[0] += word; | ||
39306 | } else { | ||
39307 | this._iaddn(word); | ||
39308 | } | ||
39309 | } | ||
39310 | |||
39311 | if (mod !== 0) { | ||
39312 | var pow = 1; | ||
39313 | word = parseBase(number, i, number.length, base); | ||
39314 | |||
39315 | for (i = 0; i < mod; i++) { | ||
39316 | pow *= base; | ||
39317 | } | ||
39318 | |||
39319 | this.imuln(pow); | ||
39320 | if (this.words[0] + word < 0x4000000) { | ||
39321 | this.words[0] += word; | ||
39322 | } else { | ||
39323 | this._iaddn(word); | ||
39324 | } | ||
39325 | } | ||
39326 | }; | ||
39327 | |||
39328 | BN.prototype.copy = function copy (dest) { | ||
39329 | dest.words = new Array(this.length); | ||
39330 | for (var i = 0; i < this.length; i++) { | ||
39331 | dest.words[i] = this.words[i]; | ||
39332 | } | ||
39333 | dest.length = this.length; | ||
39334 | dest.negative = this.negative; | ||
39335 | dest.red = this.red; | ||
39336 | }; | ||
39337 | |||
39338 | BN.prototype.clone = function clone () { | ||
39339 | var r = new BN(null); | ||
39340 | this.copy(r); | ||
39341 | return r; | ||
39342 | }; | ||
39343 | |||
39344 | BN.prototype._expand = function _expand (size) { | ||
39345 | while (this.length < size) { | ||
39346 | this.words[this.length++] = 0; | ||
39347 | } | ||
39348 | return this; | ||
39349 | }; | ||
39350 | |||
39351 | // Remove leading `0` from `this` | ||
39352 | BN.prototype.strip = function strip () { | ||
39353 | while (this.length > 1 && this.words[this.length - 1] === 0) { | ||
39354 | this.length--; | ||
39355 | } | ||
39356 | return this._normSign(); | ||
39357 | }; | ||
39358 | |||
39359 | BN.prototype._normSign = function _normSign () { | ||
39360 | // -0 = 0 | ||
39361 | if (this.length === 1 && this.words[0] === 0) { | ||
39362 | this.negative = 0; | ||
39363 | } | ||
39364 | return this; | ||
39365 | }; | ||
39366 | |||
39367 | BN.prototype.inspect = function inspect () { | ||
39368 | return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>'; | ||
39369 | }; | ||
39370 | |||
39371 | /* | ||
39372 | |||
39373 | var zeros = []; | ||
39374 | var groupSizes = []; | ||
39375 | var groupBases = []; | ||
39376 | |||
39377 | var s = ''; | ||
39378 | var i = -1; | ||
39379 | while (++i < BN.wordSize) { | ||
39380 | zeros[i] = s; | ||
39381 | s += '0'; | ||
39382 | } | ||
39383 | groupSizes[0] = 0; | ||
39384 | groupSizes[1] = 0; | ||
39385 | groupBases[0] = 0; | ||
39386 | groupBases[1] = 0; | ||
39387 | var base = 2 - 1; | ||
39388 | while (++base < 36 + 1) { | ||
39389 | var groupSize = 0; | ||
39390 | var groupBase = 1; | ||
39391 | while (groupBase < (1 << BN.wordSize) / base) { | ||
39392 | groupBase *= base; | ||
39393 | groupSize += 1; | ||
39394 | } | ||
39395 | groupSizes[base] = groupSize; | ||
39396 | groupBases[base] = groupBase; | ||
39397 | } | ||
39398 | |||
39399 | */ | ||
39400 | |||
39401 | var zeros = [ | ||
39402 | '', | ||
39403 | '0', | ||
39404 | '00', | ||
39405 | '000', | ||
39406 | '0000', | ||
39407 | '00000', | ||
39408 | '000000', | ||
39409 | '0000000', | ||
39410 | '00000000', | ||
39411 | '000000000', | ||
39412 | '0000000000', | ||
39413 | '00000000000', | ||
39414 | '000000000000', | ||
39415 | '0000000000000', | ||
39416 | '00000000000000', | ||
39417 | '000000000000000', | ||
39418 | '0000000000000000', | ||
39419 | '00000000000000000', | ||
39420 | '000000000000000000', | ||
39421 | '0000000000000000000', | ||
39422 | '00000000000000000000', | ||
39423 | '000000000000000000000', | ||
39424 | '0000000000000000000000', | ||
39425 | '00000000000000000000000', | ||
39426 | '000000000000000000000000', | ||
39427 | '0000000000000000000000000' | ||
39428 | ]; | ||
39429 | |||
39430 | var groupSizes = [ | ||
39431 | 0, 0, | ||
39432 | 25, 16, 12, 11, 10, 9, 8, | ||
39433 | 8, 7, 7, 7, 7, 6, 6, | ||
39434 | 6, 6, 6, 6, 6, 5, 5, | ||
39435 | 5, 5, 5, 5, 5, 5, 5, | ||
39436 | 5, 5, 5, 5, 5, 5, 5 | ||
39437 | ]; | ||
39438 | |||
39439 | var groupBases = [ | ||
39440 | 0, 0, | ||
39441 | 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, | ||
39442 | 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625, | ||
39443 | 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632, | ||
39444 | 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, | ||
39445 | 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176 | ||
39446 | ]; | ||
39447 | |||
39448 | BN.prototype.toString = function toString (base, padding) { | ||
39449 | base = base || 10; | ||
39450 | padding = padding | 0 || 1; | ||
39451 | |||
39452 | var out; | ||
39453 | if (base === 16 || base === 'hex') { | ||
39454 | out = ''; | ||
39455 | var off = 0; | ||
39456 | var carry = 0; | ||
39457 | for (var i = 0; i < this.length; i++) { | ||
39458 | var w = this.words[i]; | ||
39459 | var word = (((w << off) | carry) & 0xffffff).toString(16); | ||
39460 | carry = (w >>> (24 - off)) & 0xffffff; | ||
39461 | if (carry !== 0 || i !== this.length - 1) { | ||
39462 | out = zeros[6 - word.length] + word + out; | ||
39463 | } else { | ||
39464 | out = word + out; | ||
39465 | } | ||
39466 | off += 2; | ||
39467 | if (off >= 26) { | ||
39468 | off -= 26; | ||
39469 | i--; | ||
39470 | } | ||
39471 | } | ||
39472 | if (carry !== 0) { | ||
39473 | out = carry.toString(16) + out; | ||
39474 | } | ||
39475 | while (out.length % padding !== 0) { | ||
39476 | out = '0' + out; | ||
39477 | } | ||
39478 | if (this.negative !== 0) { | ||
39479 | out = '-' + out; | ||
39480 | } | ||
39481 | return out; | ||
39482 | } | ||
39483 | |||
39484 | if (base === (base | 0) && base >= 2 && base <= 36) { | ||
39485 | // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base)); | ||
39486 | var groupSize = groupSizes[base]; | ||
39487 | // var groupBase = Math.pow(base, groupSize); | ||
39488 | var groupBase = groupBases[base]; | ||
39489 | out = ''; | ||
39490 | var c = this.clone(); | ||
39491 | c.negative = 0; | ||
39492 | while (!c.isZero()) { | ||
39493 | var r = c.modn(groupBase).toString(base); | ||
39494 | c = c.idivn(groupBase); | ||
39495 | |||
39496 | if (!c.isZero()) { | ||
39497 | out = zeros[groupSize - r.length] + r + out; | ||
39498 | } else { | ||
39499 | out = r + out; | ||
39500 | } | ||
39501 | } | ||
39502 | if (this.isZero()) { | ||
39503 | out = '0' + out; | ||
39504 | } | ||
39505 | while (out.length % padding !== 0) { | ||
39506 | out = '0' + out; | ||
39507 | } | ||
39508 | if (this.negative !== 0) { | ||
39509 | out = '-' + out; | ||
39510 | } | ||
39511 | return out; | ||
39512 | } | ||
39513 | |||
39514 | assert(false, 'Base should be between 2 and 36'); | ||
39515 | }; | ||
39516 | |||
39517 | BN.prototype.toNumber = function toNumber () { | ||
39518 | var ret = this.words[0]; | ||
39519 | if (this.length === 2) { | ||
39520 | ret += this.words[1] * 0x4000000; | ||
39521 | } else if (this.length === 3 && this.words[2] === 0x01) { | ||
39522 | // NOTE: at this stage it is known that the top bit is set | ||
39523 | ret += 0x10000000000000 + (this.words[1] * 0x4000000); | ||
39524 | } else if (this.length > 2) { | ||
39525 | assert(false, 'Number can only safely store up to 53 bits'); | ||
39526 | } | ||
39527 | return (this.negative !== 0) ? -ret : ret; | ||
39528 | }; | ||
39529 | |||
39530 | BN.prototype.toJSON = function toJSON () { | ||
39531 | return this.toString(16); | ||
39532 | }; | ||
39533 | |||
39534 | BN.prototype.toBuffer = function toBuffer (endian, length) { | ||
39535 | assert(typeof Buffer !== 'undefined'); | ||
39536 | return this.toArrayLike(Buffer, endian, length); | ||
39537 | }; | ||
39538 | |||
39539 | BN.prototype.toArray = function toArray (endian, length) { | ||
39540 | return this.toArrayLike(Array, endian, length); | ||
39541 | }; | ||
39542 | |||
39543 | BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) { | ||
39544 | var byteLength = this.byteLength(); | ||
39545 | var reqLength = length || Math.max(1, byteLength); | ||
39546 | assert(byteLength <= reqLength, 'byte array longer than desired length'); | ||
39547 | assert(reqLength > 0, 'Requested array length <= 0'); | ||
39548 | |||
39549 | this.strip(); | ||
39550 | var littleEndian = endian === 'le'; | ||
39551 | var res = new ArrayType(reqLength); | ||
39552 | |||
39553 | var b, i; | ||
39554 | var q = this.clone(); | ||
39555 | if (!littleEndian) { | ||
39556 | // Assume big-endian | ||
39557 | for (i = 0; i < reqLength - byteLength; i++) { | ||
39558 | res[i] = 0; | ||
39559 | } | ||
39560 | |||
39561 | for (i = 0; !q.isZero(); i++) { | ||
39562 | b = q.andln(0xff); | ||
39563 | q.iushrn(8); | ||
39564 | |||
39565 | res[reqLength - i - 1] = b; | ||
39566 | } | ||
39567 | } else { | ||
39568 | for (i = 0; !q.isZero(); i++) { | ||
39569 | b = q.andln(0xff); | ||
39570 | q.iushrn(8); | ||
39571 | |||
39572 | res[i] = b; | ||
39573 | } | ||
39574 | |||
39575 | for (; i < reqLength; i++) { | ||
39576 | res[i] = 0; | ||
39577 | } | ||
39578 | } | ||
39579 | |||
39580 | return res; | ||
39581 | }; | ||
39582 | |||
39583 | if (Math.clz32) { | ||
39584 | BN.prototype._countBits = function _countBits (w) { | ||
39585 | return 32 - Math.clz32(w); | ||
39586 | }; | ||
39587 | } else { | ||
39588 | BN.prototype._countBits = function _countBits (w) { | ||
39589 | var t = w; | ||
39590 | var r = 0; | ||
39591 | if (t >= 0x1000) { | ||
39592 | r += 13; | ||
39593 | t >>>= 13; | ||
39594 | } | ||
39595 | if (t >= 0x40) { | ||
39596 | r += 7; | ||
39597 | t >>>= 7; | ||
39598 | } | ||
39599 | if (t >= 0x8) { | ||
39600 | r += 4; | ||
39601 | t >>>= 4; | ||
39602 | } | ||
39603 | if (t >= 0x02) { | ||
39604 | r += 2; | ||
39605 | t >>>= 2; | ||
39606 | } | ||
39607 | return r + t; | ||
39608 | }; | ||
39609 | } | ||
39610 | |||
39611 | BN.prototype._zeroBits = function _zeroBits (w) { | ||
39612 | // Short-cut | ||
39613 | if (w === 0) return 26; | ||
39614 | |||
39615 | var t = w; | ||
39616 | var r = 0; | ||
39617 | if ((t & 0x1fff) === 0) { | ||
39618 | r += 13; | ||
39619 | t >>>= 13; | ||
39620 | } | ||
39621 | if ((t & 0x7f) === 0) { | ||
39622 | r += 7; | ||
39623 | t >>>= 7; | ||
39624 | } | ||
39625 | if ((t & 0xf) === 0) { | ||
39626 | r += 4; | ||
39627 | t >>>= 4; | ||
39628 | } | ||
39629 | if ((t & 0x3) === 0) { | ||
39630 | r += 2; | ||
39631 | t >>>= 2; | ||
39632 | } | ||
39633 | if ((t & 0x1) === 0) { | ||
39634 | r++; | ||
39635 | } | ||
39636 | return r; | ||
39637 | }; | ||
39638 | |||
39639 | // Return number of used bits in a BN | ||
39640 | BN.prototype.bitLength = function bitLength () { | ||
39641 | var w = this.words[this.length - 1]; | ||
39642 | var hi = this._countBits(w); | ||
39643 | return (this.length - 1) * 26 + hi; | ||
39644 | }; | ||
39645 | |||
39646 | function toBitArray (num) { | ||
39647 | var w = new Array(num.bitLength()); | ||
39648 | |||
39649 | for (var bit = 0; bit < w.length; bit++) { | ||
39650 | var off = (bit / 26) | 0; | ||
39651 | var wbit = bit % 26; | ||
39652 | |||
39653 | w[bit] = (num.words[off] & (1 << wbit)) >>> wbit; | ||
39654 | } | ||
39655 | |||
39656 | return w; | ||
39657 | } | ||
39658 | |||
39659 | // Number of trailing zero bits | ||
39660 | BN.prototype.zeroBits = function zeroBits () { | ||
39661 | if (this.isZero()) return 0; | ||
39662 | |||
39663 | var r = 0; | ||
39664 | for (var i = 0; i < this.length; i++) { | ||
39665 | var b = this._zeroBits(this.words[i]); | ||
39666 | r += b; | ||
39667 | if (b !== 26) break; | ||
39668 | } | ||
39669 | return r; | ||
39670 | }; | ||
39671 | |||
39672 | BN.prototype.byteLength = function byteLength () { | ||
39673 | return Math.ceil(this.bitLength() / 8); | ||
39674 | }; | ||
39675 | |||
39676 | BN.prototype.toTwos = function toTwos (width) { | ||
39677 | if (this.negative !== 0) { | ||
39678 | return this.abs().inotn(width).iaddn(1); | ||
39679 | } | ||
39680 | return this.clone(); | ||
39681 | }; | ||
39682 | |||
39683 | BN.prototype.fromTwos = function fromTwos (width) { | ||
39684 | if (this.testn(width - 1)) { | ||
39685 | return this.notn(width).iaddn(1).ineg(); | ||
39686 | } | ||
39687 | return this.clone(); | ||
39688 | }; | ||
39689 | |||
39690 | BN.prototype.isNeg = function isNeg () { | ||
39691 | return this.negative !== 0; | ||
39692 | }; | ||
39693 | |||
39694 | // Return negative clone of `this` | ||
39695 | BN.prototype.neg = function neg () { | ||
39696 | return this.clone().ineg(); | ||
39697 | }; | ||
39698 | |||
39699 | BN.prototype.ineg = function ineg () { | ||
39700 | if (!this.isZero()) { | ||
39701 | this.negative ^= 1; | ||
39702 | } | ||
39703 | |||
39704 | return this; | ||
39705 | }; | ||
39706 | |||
39707 | // Or `num` with `this` in-place | ||
39708 | BN.prototype.iuor = function iuor (num) { | ||
39709 | while (this.length < num.length) { | ||
39710 | this.words[this.length++] = 0; | ||
39711 | } | ||
39712 | |||
39713 | for (var i = 0; i < num.length; i++) { | ||
39714 | this.words[i] = this.words[i] | num.words[i]; | ||
39715 | } | ||
39716 | |||
39717 | return this.strip(); | ||
39718 | }; | ||
39719 | |||
39720 | BN.prototype.ior = function ior (num) { | ||
39721 | assert((this.negative | num.negative) === 0); | ||
39722 | return this.iuor(num); | ||
39723 | }; | ||
39724 | |||
39725 | // Or `num` with `this` | ||
39726 | BN.prototype.or = function or (num) { | ||
39727 | if (this.length > num.length) return this.clone().ior(num); | ||
39728 | return num.clone().ior(this); | ||
39729 | }; | ||
39730 | |||
39731 | BN.prototype.uor = function uor (num) { | ||
39732 | if (this.length > num.length) return this.clone().iuor(num); | ||
39733 | return num.clone().iuor(this); | ||
39734 | }; | ||
39735 | |||
39736 | // And `num` with `this` in-place | ||
39737 | BN.prototype.iuand = function iuand (num) { | ||
39738 | // b = min-length(num, this) | ||
39739 | var b; | ||
39740 | if (this.length > num.length) { | ||
39741 | b = num; | ||
39742 | } else { | ||
39743 | b = this; | ||
39744 | } | ||
39745 | |||
39746 | for (var i = 0; i < b.length; i++) { | ||
39747 | this.words[i] = this.words[i] & num.words[i]; | ||
39748 | } | ||
39749 | |||
39750 | this.length = b.length; | ||
39751 | |||
39752 | return this.strip(); | ||
39753 | }; | ||
39754 | |||
39755 | BN.prototype.iand = function iand (num) { | ||
39756 | assert((this.negative | num.negative) === 0); | ||
39757 | return this.iuand(num); | ||
39758 | }; | ||
39759 | |||
39760 | // And `num` with `this` | ||
39761 | BN.prototype.and = function and (num) { | ||
39762 | if (this.length > num.length) return this.clone().iand(num); | ||
39763 | return num.clone().iand(this); | ||
39764 | }; | ||
39765 | |||
39766 | BN.prototype.uand = function uand (num) { | ||
39767 | if (this.length > num.length) return this.clone().iuand(num); | ||
39768 | return num.clone().iuand(this); | ||
39769 | }; | ||
39770 | |||
39771 | // Xor `num` with `this` in-place | ||
39772 | BN.prototype.iuxor = function iuxor (num) { | ||
39773 | // a.length > b.length | ||
39774 | var a; | ||
39775 | var b; | ||
39776 | if (this.length > num.length) { | ||
39777 | a = this; | ||
39778 | b = num; | ||
39779 | } else { | ||
39780 | a = num; | ||
39781 | b = this; | ||
39782 | } | ||
39783 | |||
39784 | for (var i = 0; i < b.length; i++) { | ||
39785 | this.words[i] = a.words[i] ^ b.words[i]; | ||
39786 | } | ||
39787 | |||
39788 | if (this !== a) { | ||
39789 | for (; i < a.length; i++) { | ||
39790 | this.words[i] = a.words[i]; | ||
39791 | } | ||
39792 | } | ||
39793 | |||
39794 | this.length = a.length; | ||
39795 | |||
39796 | return this.strip(); | ||
39797 | }; | ||
39798 | |||
39799 | BN.prototype.ixor = function ixor (num) { | ||
39800 | assert((this.negative | num.negative) === 0); | ||
39801 | return this.iuxor(num); | ||
39802 | }; | ||
39803 | |||
39804 | // Xor `num` with `this` | ||
39805 | BN.prototype.xor = function xor (num) { | ||
39806 | if (this.length > num.length) return this.clone().ixor(num); | ||
39807 | return num.clone().ixor(this); | ||
39808 | }; | ||
39809 | |||
39810 | BN.prototype.uxor = function uxor (num) { | ||
39811 | if (this.length > num.length) return this.clone().iuxor(num); | ||
39812 | return num.clone().iuxor(this); | ||
39813 | }; | ||
39814 | |||
39815 | // Not ``this`` with ``width`` bitwidth | ||
39816 | BN.prototype.inotn = function inotn (width) { | ||
39817 | assert(typeof width === 'number' && width >= 0); | ||
39818 | |||
39819 | var bytesNeeded = Math.ceil(width / 26) | 0; | ||
39820 | var bitsLeft = width % 26; | ||
39821 | |||
39822 | // Extend the buffer with leading zeroes | ||
39823 | this._expand(bytesNeeded); | ||
39824 | |||
39825 | if (bitsLeft > 0) { | ||
39826 | bytesNeeded--; | ||
39827 | } | ||
39828 | |||
39829 | // Handle complete words | ||
39830 | for (var i = 0; i < bytesNeeded; i++) { | ||
39831 | this.words[i] = ~this.words[i] & 0x3ffffff; | ||
39832 | } | ||
39833 | |||
39834 | // Handle the residue | ||
39835 | if (bitsLeft > 0) { | ||
39836 | this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft)); | ||
39837 | } | ||
39838 | |||
39839 | // And remove leading zeroes | ||
39840 | return this.strip(); | ||
39841 | }; | ||
39842 | |||
39843 | BN.prototype.notn = function notn (width) { | ||
39844 | return this.clone().inotn(width); | ||
39845 | }; | ||
39846 | |||
39847 | // Set `bit` of `this` | ||
39848 | BN.prototype.setn = function setn (bit, val) { | ||
39849 | assert(typeof bit === 'number' && bit >= 0); | ||
39850 | |||
39851 | var off = (bit / 26) | 0; | ||
39852 | var wbit = bit % 26; | ||
39853 | |||
39854 | this._expand(off + 1); | ||
39855 | |||
39856 | if (val) { | ||
39857 | this.words[off] = this.words[off] | (1 << wbit); | ||
39858 | } else { | ||
39859 | this.words[off] = this.words[off] & ~(1 << wbit); | ||
39860 | } | ||
39861 | |||
39862 | return this.strip(); | ||
39863 | }; | ||
39864 | |||
39865 | // Add `num` to `this` in-place | ||
39866 | BN.prototype.iadd = function iadd (num) { | ||
39867 | var r; | ||
39868 | |||
39869 | // negative + positive | ||
39870 | if (this.negative !== 0 && num.negative === 0) { | ||
39871 | this.negative = 0; | ||
39872 | r = this.isub(num); | ||
39873 | this.negative ^= 1; | ||
39874 | return this._normSign(); | ||
39875 | |||
39876 | // positive + negative | ||
39877 | } else if (this.negative === 0 && num.negative !== 0) { | ||
39878 | num.negative = 0; | ||
39879 | r = this.isub(num); | ||
39880 | num.negative = 1; | ||
39881 | return r._normSign(); | ||
39882 | } | ||
39883 | |||
39884 | // a.length > b.length | ||
39885 | var a, b; | ||
39886 | if (this.length > num.length) { | ||
39887 | a = this; | ||
39888 | b = num; | ||
39889 | } else { | ||
39890 | a = num; | ||
39891 | b = this; | ||
39892 | } | ||
39893 | |||
39894 | var carry = 0; | ||
39895 | for (var i = 0; i < b.length; i++) { | ||
39896 | r = (a.words[i] | 0) + (b.words[i] | 0) + carry; | ||
39897 | this.words[i] = r & 0x3ffffff; | ||
39898 | carry = r >>> 26; | ||
39899 | } | ||
39900 | for (; carry !== 0 && i < a.length; i++) { | ||
39901 | r = (a.words[i] | 0) + carry; | ||
39902 | this.words[i] = r & 0x3ffffff; | ||
39903 | carry = r >>> 26; | ||
39904 | } | ||
39905 | |||
39906 | this.length = a.length; | ||
39907 | if (carry !== 0) { | ||
39908 | this.words[this.length] = carry; | ||
39909 | this.length++; | ||
39910 | // Copy the rest of the words | ||
39911 | } else if (a !== this) { | ||
39912 | for (; i < a.length; i++) { | ||
39913 | this.words[i] = a.words[i]; | ||
39914 | } | ||
39915 | } | ||
39916 | |||
39917 | return this; | ||
39918 | }; | ||
39919 | |||
39920 | // Add `num` to `this` | ||
39921 | BN.prototype.add = function add (num) { | ||
39922 | var res; | ||
39923 | if (num.negative !== 0 && this.negative === 0) { | ||
39924 | num.negative = 0; | ||
39925 | res = this.sub(num); | ||
39926 | num.negative ^= 1; | ||
39927 | return res; | ||
39928 | } else if (num.negative === 0 && this.negative !== 0) { | ||
39929 | this.negative = 0; | ||
39930 | res = num.sub(this); | ||
39931 | this.negative = 1; | ||
39932 | return res; | ||
39933 | } | ||
39934 | |||
39935 | if (this.length > num.length) return this.clone().iadd(num); | ||
39936 | |||
39937 | return num.clone().iadd(this); | ||
39938 | }; | ||
39939 | |||
39940 | // Subtract `num` from `this` in-place | ||
39941 | BN.prototype.isub = function isub (num) { | ||
39942 | // this - (-num) = this + num | ||
39943 | if (num.negative !== 0) { | ||
39944 | num.negative = 0; | ||
39945 | var r = this.iadd(num); | ||
39946 | num.negative = 1; | ||
39947 | return r._normSign(); | ||
39948 | |||
39949 | // -this - num = -(this + num) | ||
39950 | } else if (this.negative !== 0) { | ||
39951 | this.negative = 0; | ||
39952 | this.iadd(num); | ||
39953 | this.negative = 1; | ||
39954 | return this._normSign(); | ||
39955 | } | ||
39956 | |||
39957 | // At this point both numbers are positive | ||
39958 | var cmp = this.cmp(num); | ||
39959 | |||
39960 | // Optimization - zeroify | ||
39961 | if (cmp === 0) { | ||
39962 | this.negative = 0; | ||
39963 | this.length = 1; | ||
39964 | this.words[0] = 0; | ||
39965 | return this; | ||
39966 | } | ||
39967 | |||
39968 | // a > b | ||
39969 | var a, b; | ||
39970 | if (cmp > 0) { | ||
39971 | a = this; | ||
39972 | b = num; | ||
39973 | } else { | ||
39974 | a = num; | ||
39975 | b = this; | ||
39976 | } | ||
39977 | |||
39978 | var carry = 0; | ||
39979 | for (var i = 0; i < b.length; i++) { | ||
39980 | r = (a.words[i] | 0) - (b.words[i] | 0) + carry; | ||
39981 | carry = r >> 26; | ||
39982 | this.words[i] = r & 0x3ffffff; | ||
39983 | } | ||
39984 | for (; carry !== 0 && i < a.length; i++) { | ||
39985 | r = (a.words[i] | 0) + carry; | ||
39986 | carry = r >> 26; | ||
39987 | this.words[i] = r & 0x3ffffff; | ||
39988 | } | ||
39989 | |||
39990 | // Copy rest of the words | ||
39991 | if (carry === 0 && i < a.length && a !== this) { | ||
39992 | for (; i < a.length; i++) { | ||
39993 | this.words[i] = a.words[i]; | ||
39994 | } | ||
39995 | } | ||
39996 | |||
39997 | this.length = Math.max(this.length, i); | ||
39998 | |||
39999 | if (a !== this) { | ||
40000 | this.negative = 1; | ||
40001 | } | ||
40002 | |||
40003 | return this.strip(); | ||
40004 | }; | ||
40005 | |||
40006 | // Subtract `num` from `this` | ||
40007 | BN.prototype.sub = function sub (num) { | ||
40008 | return this.clone().isub(num); | ||
40009 | }; | ||
40010 | |||
40011 | function smallMulTo (self, num, out) { | ||
40012 | out.negative = num.negative ^ self.negative; | ||
40013 | var len = (self.length + num.length) | 0; | ||
40014 | out.length = len; | ||
40015 | len = (len - 1) | 0; | ||
40016 | |||
40017 | // Peel one iteration (compiler can't do it, because of code complexity) | ||
40018 | var a = self.words[0] | 0; | ||
40019 | var b = num.words[0] | 0; | ||
40020 | var r = a * b; | ||
40021 | |||
40022 | var lo = r & 0x3ffffff; | ||
40023 | var carry = (r / 0x4000000) | 0; | ||
40024 | out.words[0] = lo; | ||
40025 | |||
40026 | for (var k = 1; k < len; k++) { | ||
40027 | // Sum all words with the same `i + j = k` and accumulate `ncarry`, | ||
40028 | // note that ncarry could be >= 0x3ffffff | ||
40029 | var ncarry = carry >>> 26; | ||
40030 | var rword = carry & 0x3ffffff; | ||
40031 | var maxJ = Math.min(k, num.length - 1); | ||
40032 | for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { | ||
40033 | var i = (k - j) | 0; | ||
40034 | a = self.words[i] | 0; | ||
40035 | b = num.words[j] | 0; | ||
40036 | r = a * b + rword; | ||
40037 | ncarry += (r / 0x4000000) | 0; | ||
40038 | rword = r & 0x3ffffff; | ||
40039 | } | ||
40040 | out.words[k] = rword | 0; | ||
40041 | carry = ncarry | 0; | ||
40042 | } | ||
40043 | if (carry !== 0) { | ||
40044 | out.words[k] = carry | 0; | ||
40045 | } else { | ||
40046 | out.length--; | ||
40047 | } | ||
40048 | |||
40049 | return out.strip(); | ||
40050 | } | ||
40051 | |||
40052 | // TODO(indutny): it may be reasonable to omit it for users who don't need | ||
40053 | // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit | ||
40054 | // multiplication (like elliptic secp256k1). | ||
40055 | var comb10MulTo = function comb10MulTo (self, num, out) { | ||
40056 | var a = self.words; | ||
40057 | var b = num.words; | ||
40058 | var o = out.words; | ||
40059 | var c = 0; | ||
40060 | var lo; | ||
40061 | var mid; | ||
40062 | var hi; | ||
40063 | var a0 = a[0] | 0; | ||
40064 | var al0 = a0 & 0x1fff; | ||
40065 | var ah0 = a0 >>> 13; | ||
40066 | var a1 = a[1] | 0; | ||
40067 | var al1 = a1 & 0x1fff; | ||
40068 | var ah1 = a1 >>> 13; | ||
40069 | var a2 = a[2] | 0; | ||
40070 | var al2 = a2 & 0x1fff; | ||
40071 | var ah2 = a2 >>> 13; | ||
40072 | var a3 = a[3] | 0; | ||
40073 | var al3 = a3 & 0x1fff; | ||
40074 | var ah3 = a3 >>> 13; | ||
40075 | var a4 = a[4] | 0; | ||
40076 | var al4 = a4 & 0x1fff; | ||
40077 | var ah4 = a4 >>> 13; | ||
40078 | var a5 = a[5] | 0; | ||
40079 | var al5 = a5 & 0x1fff; | ||
40080 | var ah5 = a5 >>> 13; | ||
40081 | var a6 = a[6] | 0; | ||
40082 | var al6 = a6 & 0x1fff; | ||
40083 | var ah6 = a6 >>> 13; | ||
40084 | var a7 = a[7] | 0; | ||
40085 | var al7 = a7 & 0x1fff; | ||
40086 | var ah7 = a7 >>> 13; | ||
40087 | var a8 = a[8] | 0; | ||
40088 | var al8 = a8 & 0x1fff; | ||
40089 | var ah8 = a8 >>> 13; | ||
40090 | var a9 = a[9] | 0; | ||
40091 | var al9 = a9 & 0x1fff; | ||
40092 | var ah9 = a9 >>> 13; | ||
40093 | var b0 = b[0] | 0; | ||
40094 | var bl0 = b0 & 0x1fff; | ||
40095 | var bh0 = b0 >>> 13; | ||
40096 | var b1 = b[1] | 0; | ||
40097 | var bl1 = b1 & 0x1fff; | ||
40098 | var bh1 = b1 >>> 13; | ||
40099 | var b2 = b[2] | 0; | ||
40100 | var bl2 = b2 & 0x1fff; | ||
40101 | var bh2 = b2 >>> 13; | ||
40102 | var b3 = b[3] | 0; | ||
40103 | var bl3 = b3 & 0x1fff; | ||
40104 | var bh3 = b3 >>> 13; | ||
40105 | var b4 = b[4] | 0; | ||
40106 | var bl4 = b4 & 0x1fff; | ||
40107 | var bh4 = b4 >>> 13; | ||
40108 | var b5 = b[5] | 0; | ||
40109 | var bl5 = b5 & 0x1fff; | ||
40110 | var bh5 = b5 >>> 13; | ||
40111 | var b6 = b[6] | 0; | ||
40112 | var bl6 = b6 & 0x1fff; | ||
40113 | var bh6 = b6 >>> 13; | ||
40114 | var b7 = b[7] | 0; | ||
40115 | var bl7 = b7 & 0x1fff; | ||
40116 | var bh7 = b7 >>> 13; | ||
40117 | var b8 = b[8] | 0; | ||
40118 | var bl8 = b8 & 0x1fff; | ||
40119 | var bh8 = b8 >>> 13; | ||
40120 | var b9 = b[9] | 0; | ||
40121 | var bl9 = b9 & 0x1fff; | ||
40122 | var bh9 = b9 >>> 13; | ||
40123 | |||
40124 | out.negative = self.negative ^ num.negative; | ||
40125 | out.length = 19; | ||
40126 | /* k = 0 */ | ||
40127 | lo = Math.imul(al0, bl0); | ||
40128 | mid = Math.imul(al0, bh0); | ||
40129 | mid = (mid + Math.imul(ah0, bl0)) | 0; | ||
40130 | hi = Math.imul(ah0, bh0); | ||
40131 | var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; | ||
40132 | c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0; | ||
40133 | w0 &= 0x3ffffff; | ||
40134 | /* k = 1 */ | ||
40135 | lo = Math.imul(al1, bl0); | ||
40136 | mid = Math.imul(al1, bh0); | ||
40137 | mid = (mid + Math.imul(ah1, bl0)) | 0; | ||
40138 | hi = Math.imul(ah1, bh0); | ||
40139 | lo = (lo + Math.imul(al0, bl1)) | 0; | ||
40140 | mid = (mid + Math.imul(al0, bh1)) | 0; | ||
40141 | mid = (mid + Math.imul(ah0, bl1)) | 0; | ||
40142 | hi = (hi + Math.imul(ah0, bh1)) | 0; | ||
40143 | var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; | ||
40144 | c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0; | ||
40145 | w1 &= 0x3ffffff; | ||
40146 | /* k = 2 */ | ||
40147 | lo = Math.imul(al2, bl0); | ||
40148 | mid = Math.imul(al2, bh0); | ||
40149 | mid = (mid + Math.imul(ah2, bl0)) | 0; | ||
40150 | hi = Math.imul(ah2, bh0); | ||
40151 | lo = (lo + Math.imul(al1, bl1)) | 0; | ||
40152 | mid = (mid + Math.imul(al1, bh1)) | 0; | ||
40153 | mid = (mid + Math.imul(ah1, bl1)) | 0; | ||
40154 | hi = (hi + Math.imul(ah1, bh1)) | 0; | ||
40155 | lo = (lo + Math.imul(al0, bl2)) | 0; | ||
40156 | mid = (mid + Math.imul(al0, bh2)) | 0; | ||
40157 | mid = (mid + Math.imul(ah0, bl2)) | 0; | ||
40158 | hi = (hi + Math.imul(ah0, bh2)) | 0; | ||
40159 | var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; | ||
40160 | c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0; | ||
40161 | w2 &= 0x3ffffff; | ||
40162 | /* k = 3 */ | ||
40163 | lo = Math.imul(al3, bl0); | ||
40164 | mid = Math.imul(al3, bh0); | ||
40165 | mid = (mid + Math.imul(ah3, bl0)) | 0; | ||
40166 | hi = Math.imul(ah3, bh0); | ||
40167 | lo = (lo + Math.imul(al2, bl1)) | 0; | ||
40168 | mid = (mid + Math.imul(al2, bh1)) | 0; | ||
40169 | mid = (mid + Math.imul(ah2, bl1)) | 0; | ||
40170 | hi = (hi + Math.imul(ah2, bh1)) | 0; | ||
40171 | lo = (lo + Math.imul(al1, bl2)) | 0; | ||
40172 | mid = (mid + Math.imul(al1, bh2)) | 0; | ||
40173 | mid = (mid + Math.imul(ah1, bl2)) | 0; | ||
40174 | hi = (hi + Math.imul(ah1, bh2)) | 0; | ||
40175 | lo = (lo + Math.imul(al0, bl3)) | 0; | ||
40176 | mid = (mid + Math.imul(al0, bh3)) | 0; | ||
40177 | mid = (mid + Math.imul(ah0, bl3)) | 0; | ||
40178 | hi = (hi + Math.imul(ah0, bh3)) | 0; | ||
40179 | var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; | ||
40180 | c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0; | ||
40181 | w3 &= 0x3ffffff; | ||
40182 | /* k = 4 */ | ||
40183 | lo = Math.imul(al4, bl0); | ||
40184 | mid = Math.imul(al4, bh0); | ||
40185 | mid = (mid + Math.imul(ah4, bl0)) | 0; | ||
40186 | hi = Math.imul(ah4, bh0); | ||
40187 | lo = (lo + Math.imul(al3, bl1)) | 0; | ||
40188 | mid = (mid + Math.imul(al3, bh1)) | 0; | ||
40189 | mid = (mid + Math.imul(ah3, bl1)) | 0; | ||
40190 | hi = (hi + Math.imul(ah3, bh1)) | 0; | ||
40191 | lo = (lo + Math.imul(al2, bl2)) | 0; | ||
40192 | mid = (mid + Math.imul(al2, bh2)) | 0; | ||
40193 | mid = (mid + Math.imul(ah2, bl2)) | 0; | ||
40194 | hi = (hi + Math.imul(ah2, bh2)) | 0; | ||
40195 | lo = (lo + Math.imul(al1, bl3)) | 0; | ||
40196 | mid = (mid + Math.imul(al1, bh3)) | 0; | ||
40197 | mid = (mid + Math.imul(ah1, bl3)) | 0; | ||
40198 | hi = (hi + Math.imul(ah1, bh3)) | 0; | ||
40199 | lo = (lo + Math.imul(al0, bl4)) | 0; | ||
40200 | mid = (mid + Math.imul(al0, bh4)) | 0; | ||
40201 | mid = (mid + Math.imul(ah0, bl4)) | 0; | ||
40202 | hi = (hi + Math.imul(ah0, bh4)) | 0; | ||
40203 | var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; | ||
40204 | c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0; | ||
40205 | w4 &= 0x3ffffff; | ||
40206 | /* k = 5 */ | ||
40207 | lo = Math.imul(al5, bl0); | ||
40208 | mid = Math.imul(al5, bh0); | ||
40209 | mid = (mid + Math.imul(ah5, bl0)) | 0; | ||
40210 | hi = Math.imul(ah5, bh0); | ||
40211 | lo = (lo + Math.imul(al4, bl1)) | 0; | ||
40212 | mid = (mid + Math.imul(al4, bh1)) | 0; | ||
40213 | mid = (mid + Math.imul(ah4, bl1)) | 0; | ||
40214 | hi = (hi + Math.imul(ah4, bh1)) | 0; | ||
40215 | lo = (lo + Math.imul(al3, bl2)) | 0; | ||
40216 | mid = (mid + Math.imul(al3, bh2)) | 0; | ||
40217 | mid = (mid + Math.imul(ah3, bl2)) | 0; | ||
40218 | hi = (hi + Math.imul(ah3, bh2)) | 0; | ||
40219 | lo = (lo + Math.imul(al2, bl3)) | 0; | ||
40220 | mid = (mid + Math.imul(al2, bh3)) | 0; | ||
40221 | mid = (mid + Math.imul(ah2, bl3)) | 0; | ||
40222 | hi = (hi + Math.imul(ah2, bh3)) | 0; | ||
40223 | lo = (lo + Math.imul(al1, bl4)) | 0; | ||
40224 | mid = (mid + Math.imul(al1, bh4)) | 0; | ||
40225 | mid = (mid + Math.imul(ah1, bl4)) | 0; | ||
40226 | hi = (hi + Math.imul(ah1, bh4)) | 0; | ||
40227 | lo = (lo + Math.imul(al0, bl5)) | 0; | ||
40228 | mid = (mid + Math.imul(al0, bh5)) | 0; | ||
40229 | mid = (mid + Math.imul(ah0, bl5)) | 0; | ||
40230 | hi = (hi + Math.imul(ah0, bh5)) | 0; | ||
40231 | var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; | ||
40232 | c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0; | ||
40233 | w5 &= 0x3ffffff; | ||
40234 | /* k = 6 */ | ||
40235 | lo = Math.imul(al6, bl0); | ||
40236 | mid = Math.imul(al6, bh0); | ||
40237 | mid = (mid + Math.imul(ah6, bl0)) | 0; | ||
40238 | hi = Math.imul(ah6, bh0); | ||
40239 | lo = (lo + Math.imul(al5, bl1)) | 0; | ||
40240 | mid = (mid + Math.imul(al5, bh1)) | 0; | ||
40241 | mid = (mid + Math.imul(ah5, bl1)) | 0; | ||
40242 | hi = (hi + Math.imul(ah5, bh1)) | 0; | ||
40243 | lo = (lo + Math.imul(al4, bl2)) | 0; | ||
40244 | mid = (mid + Math.imul(al4, bh2)) | 0; | ||
40245 | mid = (mid + Math.imul(ah4, bl2)) | 0; | ||
40246 | hi = (hi + Math.imul(ah4, bh2)) | 0; | ||
40247 | lo = (lo + Math.imul(al3, bl3)) | 0; | ||
40248 | mid = (mid + Math.imul(al3, bh3)) | 0; | ||
40249 | mid = (mid + Math.imul(ah3, bl3)) | 0; | ||
40250 | hi = (hi + Math.imul(ah3, bh3)) | 0; | ||
40251 | lo = (lo + Math.imul(al2, bl4)) | 0; | ||
40252 | mid = (mid + Math.imul(al2, bh4)) | 0; | ||
40253 | mid = (mid + Math.imul(ah2, bl4)) | 0; | ||
40254 | hi = (hi + Math.imul(ah2, bh4)) | 0; | ||
40255 | lo = (lo + Math.imul(al1, bl5)) | 0; | ||
40256 | mid = (mid + Math.imul(al1, bh5)) | 0; | ||
40257 | mid = (mid + Math.imul(ah1, bl5)) | 0; | ||
40258 | hi = (hi + Math.imul(ah1, bh5)) | 0; | ||
40259 | lo = (lo + Math.imul(al0, bl6)) | 0; | ||
40260 | mid = (mid + Math.imul(al0, bh6)) | 0; | ||
40261 | mid = (mid + Math.imul(ah0, bl6)) | 0; | ||
40262 | hi = (hi + Math.imul(ah0, bh6)) | 0; | ||
40263 | var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; | ||
40264 | c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0; | ||
40265 | w6 &= 0x3ffffff; | ||
40266 | /* k = 7 */ | ||
40267 | lo = Math.imul(al7, bl0); | ||
40268 | mid = Math.imul(al7, bh0); | ||
40269 | mid = (mid + Math.imul(ah7, bl0)) | 0; | ||
40270 | hi = Math.imul(ah7, bh0); | ||
40271 | lo = (lo + Math.imul(al6, bl1)) | 0; | ||
40272 | mid = (mid + Math.imul(al6, bh1)) | 0; | ||
40273 | mid = (mid + Math.imul(ah6, bl1)) | 0; | ||
40274 | hi = (hi + Math.imul(ah6, bh1)) | 0; | ||
40275 | lo = (lo + Math.imul(al5, bl2)) | 0; | ||
40276 | mid = (mid + Math.imul(al5, bh2)) | 0; | ||
40277 | mid = (mid + Math.imul(ah5, bl2)) | 0; | ||
40278 | hi = (hi + Math.imul(ah5, bh2)) | 0; | ||
40279 | lo = (lo + Math.imul(al4, bl3)) | 0; | ||
40280 | mid = (mid + Math.imul(al4, bh3)) | 0; | ||
40281 | mid = (mid + Math.imul(ah4, bl3)) | 0; | ||
40282 | hi = (hi + Math.imul(ah4, bh3)) | 0; | ||
40283 | lo = (lo + Math.imul(al3, bl4)) | 0; | ||
40284 | mid = (mid + Math.imul(al3, bh4)) | 0; | ||
40285 | mid = (mid + Math.imul(ah3, bl4)) | 0; | ||
40286 | hi = (hi + Math.imul(ah3, bh4)) | 0; | ||
40287 | lo = (lo + Math.imul(al2, bl5)) | 0; | ||
40288 | mid = (mid + Math.imul(al2, bh5)) | 0; | ||
40289 | mid = (mid + Math.imul(ah2, bl5)) | 0; | ||
40290 | hi = (hi + Math.imul(ah2, bh5)) | 0; | ||
40291 | lo = (lo + Math.imul(al1, bl6)) | 0; | ||
40292 | mid = (mid + Math.imul(al1, bh6)) | 0; | ||
40293 | mid = (mid + Math.imul(ah1, bl6)) | 0; | ||
40294 | hi = (hi + Math.imul(ah1, bh6)) | 0; | ||
40295 | lo = (lo + Math.imul(al0, bl7)) | 0; | ||
40296 | mid = (mid + Math.imul(al0, bh7)) | 0; | ||
40297 | mid = (mid + Math.imul(ah0, bl7)) | 0; | ||
40298 | hi = (hi + Math.imul(ah0, bh7)) | 0; | ||
40299 | var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; | ||
40300 | c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0; | ||
40301 | w7 &= 0x3ffffff; | ||
40302 | /* k = 8 */ | ||
40303 | lo = Math.imul(al8, bl0); | ||
40304 | mid = Math.imul(al8, bh0); | ||
40305 | mid = (mid + Math.imul(ah8, bl0)) | 0; | ||
40306 | hi = Math.imul(ah8, bh0); | ||
40307 | lo = (lo + Math.imul(al7, bl1)) | 0; | ||
40308 | mid = (mid + Math.imul(al7, bh1)) | 0; | ||
40309 | mid = (mid + Math.imul(ah7, bl1)) | 0; | ||
40310 | hi = (hi + Math.imul(ah7, bh1)) | 0; | ||
40311 | lo = (lo + Math.imul(al6, bl2)) | 0; | ||
40312 | mid = (mid + Math.imul(al6, bh2)) | 0; | ||
40313 | mid = (mid + Math.imul(ah6, bl2)) | 0; | ||
40314 | hi = (hi + Math.imul(ah6, bh2)) | 0; | ||
40315 | lo = (lo + Math.imul(al5, bl3)) | 0; | ||
40316 | mid = (mid + Math.imul(al5, bh3)) | 0; | ||
40317 | mid = (mid + Math.imul(ah5, bl3)) | 0; | ||
40318 | hi = (hi + Math.imul(ah5, bh3)) | 0; | ||
40319 | lo = (lo + Math.imul(al4, bl4)) | 0; | ||
40320 | mid = (mid + Math.imul(al4, bh4)) | 0; | ||
40321 | mid = (mid + Math.imul(ah4, bl4)) | 0; | ||
40322 | hi = (hi + Math.imul(ah4, bh4)) | 0; | ||
40323 | lo = (lo + Math.imul(al3, bl5)) | 0; | ||
40324 | mid = (mid + Math.imul(al3, bh5)) | 0; | ||
40325 | mid = (mid + Math.imul(ah3, bl5)) | 0; | ||
40326 | hi = (hi + Math.imul(ah3, bh5)) | 0; | ||
40327 | lo = (lo + Math.imul(al2, bl6)) | 0; | ||
40328 | mid = (mid + Math.imul(al2, bh6)) | 0; | ||
40329 | mid = (mid + Math.imul(ah2, bl6)) | 0; | ||
40330 | hi = (hi + Math.imul(ah2, bh6)) | 0; | ||
40331 | lo = (lo + Math.imul(al1, bl7)) | 0; | ||
40332 | mid = (mid + Math.imul(al1, bh7)) | 0; | ||
40333 | mid = (mid + Math.imul(ah1, bl7)) | 0; | ||
40334 | hi = (hi + Math.imul(ah1, bh7)) | 0; | ||
40335 | lo = (lo + Math.imul(al0, bl8)) | 0; | ||
40336 | mid = (mid + Math.imul(al0, bh8)) | 0; | ||
40337 | mid = (mid + Math.imul(ah0, bl8)) | 0; | ||
40338 | hi = (hi + Math.imul(ah0, bh8)) | 0; | ||
40339 | var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; | ||
40340 | c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0; | ||
40341 | w8 &= 0x3ffffff; | ||
40342 | /* k = 9 */ | ||
40343 | lo = Math.imul(al9, bl0); | ||
40344 | mid = Math.imul(al9, bh0); | ||
40345 | mid = (mid + Math.imul(ah9, bl0)) | 0; | ||
40346 | hi = Math.imul(ah9, bh0); | ||
40347 | lo = (lo + Math.imul(al8, bl1)) | 0; | ||
40348 | mid = (mid + Math.imul(al8, bh1)) | 0; | ||
40349 | mid = (mid + Math.imul(ah8, bl1)) | 0; | ||
40350 | hi = (hi + Math.imul(ah8, bh1)) | 0; | ||
40351 | lo = (lo + Math.imul(al7, bl2)) | 0; | ||
40352 | mid = (mid + Math.imul(al7, bh2)) | 0; | ||
40353 | mid = (mid + Math.imul(ah7, bl2)) | 0; | ||
40354 | hi = (hi + Math.imul(ah7, bh2)) | 0; | ||
40355 | lo = (lo + Math.imul(al6, bl3)) | 0; | ||
40356 | mid = (mid + Math.imul(al6, bh3)) | 0; | ||
40357 | mid = (mid + Math.imul(ah6, bl3)) | 0; | ||
40358 | hi = (hi + Math.imul(ah6, bh3)) | 0; | ||
40359 | lo = (lo + Math.imul(al5, bl4)) | 0; | ||
40360 | mid = (mid + Math.imul(al5, bh4)) | 0; | ||
40361 | mid = (mid + Math.imul(ah5, bl4)) | 0; | ||
40362 | hi = (hi + Math.imul(ah5, bh4)) | 0; | ||
40363 | lo = (lo + Math.imul(al4, bl5)) | 0; | ||
40364 | mid = (mid + Math.imul(al4, bh5)) | 0; | ||
40365 | mid = (mid + Math.imul(ah4, bl5)) | 0; | ||
40366 | hi = (hi + Math.imul(ah4, bh5)) | 0; | ||
40367 | lo = (lo + Math.imul(al3, bl6)) | 0; | ||
40368 | mid = (mid + Math.imul(al3, bh6)) | 0; | ||
40369 | mid = (mid + Math.imul(ah3, bl6)) | 0; | ||
40370 | hi = (hi + Math.imul(ah3, bh6)) | 0; | ||
40371 | lo = (lo + Math.imul(al2, bl7)) | 0; | ||
40372 | mid = (mid + Math.imul(al2, bh7)) | 0; | ||
40373 | mid = (mid + Math.imul(ah2, bl7)) | 0; | ||
40374 | hi = (hi + Math.imul(ah2, bh7)) | 0; | ||
40375 | lo = (lo + Math.imul(al1, bl8)) | 0; | ||
40376 | mid = (mid + Math.imul(al1, bh8)) | 0; | ||
40377 | mid = (mid + Math.imul(ah1, bl8)) | 0; | ||
40378 | hi = (hi + Math.imul(ah1, bh8)) | 0; | ||
40379 | lo = (lo + Math.imul(al0, bl9)) | 0; | ||
40380 | mid = (mid + Math.imul(al0, bh9)) | 0; | ||
40381 | mid = (mid + Math.imul(ah0, bl9)) | 0; | ||
40382 | hi = (hi + Math.imul(ah0, bh9)) | 0; | ||
40383 | var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; | ||
40384 | c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0; | ||
40385 | w9 &= 0x3ffffff; | ||
40386 | /* k = 10 */ | ||
40387 | lo = Math.imul(al9, bl1); | ||
40388 | mid = Math.imul(al9, bh1); | ||
40389 | mid = (mid + Math.imul(ah9, bl1)) | 0; | ||
40390 | hi = Math.imul(ah9, bh1); | ||
40391 | lo = (lo + Math.imul(al8, bl2)) | 0; | ||
40392 | mid = (mid + Math.imul(al8, bh2)) | 0; | ||
40393 | mid = (mid + Math.imul(ah8, bl2)) | 0; | ||
40394 | hi = (hi + Math.imul(ah8, bh2)) | 0; | ||
40395 | lo = (lo + Math.imul(al7, bl3)) | 0; | ||
40396 | mid = (mid + Math.imul(al7, bh3)) | 0; | ||
40397 | mid = (mid + Math.imul(ah7, bl3)) | 0; | ||
40398 | hi = (hi + Math.imul(ah7, bh3)) | 0; | ||
40399 | lo = (lo + Math.imul(al6, bl4)) | 0; | ||
40400 | mid = (mid + Math.imul(al6, bh4)) | 0; | ||
40401 | mid = (mid + Math.imul(ah6, bl4)) | 0; | ||
40402 | hi = (hi + Math.imul(ah6, bh4)) | 0; | ||
40403 | lo = (lo + Math.imul(al5, bl5)) | 0; | ||
40404 | mid = (mid + Math.imul(al5, bh5)) | 0; | ||
40405 | mid = (mid + Math.imul(ah5, bl5)) | 0; | ||
40406 | hi = (hi + Math.imul(ah5, bh5)) | 0; | ||
40407 | lo = (lo + Math.imul(al4, bl6)) | 0; | ||
40408 | mid = (mid + Math.imul(al4, bh6)) | 0; | ||
40409 | mid = (mid + Math.imul(ah4, bl6)) | 0; | ||
40410 | hi = (hi + Math.imul(ah4, bh6)) | 0; | ||
40411 | lo = (lo + Math.imul(al3, bl7)) | 0; | ||
40412 | mid = (mid + Math.imul(al3, bh7)) | 0; | ||
40413 | mid = (mid + Math.imul(ah3, bl7)) | 0; | ||
40414 | hi = (hi + Math.imul(ah3, bh7)) | 0; | ||
40415 | lo = (lo + Math.imul(al2, bl8)) | 0; | ||
40416 | mid = (mid + Math.imul(al2, bh8)) | 0; | ||
40417 | mid = (mid + Math.imul(ah2, bl8)) | 0; | ||
40418 | hi = (hi + Math.imul(ah2, bh8)) | 0; | ||
40419 | lo = (lo + Math.imul(al1, bl9)) | 0; | ||
40420 | mid = (mid + Math.imul(al1, bh9)) | 0; | ||
40421 | mid = (mid + Math.imul(ah1, bl9)) | 0; | ||
40422 | hi = (hi + Math.imul(ah1, bh9)) | 0; | ||
40423 | var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; | ||
40424 | c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0; | ||
40425 | w10 &= 0x3ffffff; | ||
40426 | /* k = 11 */ | ||
40427 | lo = Math.imul(al9, bl2); | ||
40428 | mid = Math.imul(al9, bh2); | ||
40429 | mid = (mid + Math.imul(ah9, bl2)) | 0; | ||
40430 | hi = Math.imul(ah9, bh2); | ||
40431 | lo = (lo + Math.imul(al8, bl3)) | 0; | ||
40432 | mid = (mid + Math.imul(al8, bh3)) | 0; | ||
40433 | mid = (mid + Math.imul(ah8, bl3)) | 0; | ||
40434 | hi = (hi + Math.imul(ah8, bh3)) | 0; | ||
40435 | lo = (lo + Math.imul(al7, bl4)) | 0; | ||
40436 | mid = (mid + Math.imul(al7, bh4)) | 0; | ||
40437 | mid = (mid + Math.imul(ah7, bl4)) | 0; | ||
40438 | hi = (hi + Math.imul(ah7, bh4)) | 0; | ||
40439 | lo = (lo + Math.imul(al6, bl5)) | 0; | ||
40440 | mid = (mid + Math.imul(al6, bh5)) | 0; | ||
40441 | mid = (mid + Math.imul(ah6, bl5)) | 0; | ||
40442 | hi = (hi + Math.imul(ah6, bh5)) | 0; | ||
40443 | lo = (lo + Math.imul(al5, bl6)) | 0; | ||
40444 | mid = (mid + Math.imul(al5, bh6)) | 0; | ||
40445 | mid = (mid + Math.imul(ah5, bl6)) | 0; | ||
40446 | hi = (hi + Math.imul(ah5, bh6)) | 0; | ||
40447 | lo = (lo + Math.imul(al4, bl7)) | 0; | ||
40448 | mid = (mid + Math.imul(al4, bh7)) | 0; | ||
40449 | mid = (mid + Math.imul(ah4, bl7)) | 0; | ||
40450 | hi = (hi + Math.imul(ah4, bh7)) | 0; | ||
40451 | lo = (lo + Math.imul(al3, bl8)) | 0; | ||
40452 | mid = (mid + Math.imul(al3, bh8)) | 0; | ||
40453 | mid = (mid + Math.imul(ah3, bl8)) | 0; | ||
40454 | hi = (hi + Math.imul(ah3, bh8)) | 0; | ||
40455 | lo = (lo + Math.imul(al2, bl9)) | 0; | ||
40456 | mid = (mid + Math.imul(al2, bh9)) | 0; | ||
40457 | mid = (mid + Math.imul(ah2, bl9)) | 0; | ||
40458 | hi = (hi + Math.imul(ah2, bh9)) | 0; | ||
40459 | var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; | ||
40460 | c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0; | ||
40461 | w11 &= 0x3ffffff; | ||
40462 | /* k = 12 */ | ||
40463 | lo = Math.imul(al9, bl3); | ||
40464 | mid = Math.imul(al9, bh3); | ||
40465 | mid = (mid + Math.imul(ah9, bl3)) | 0; | ||
40466 | hi = Math.imul(ah9, bh3); | ||
40467 | lo = (lo + Math.imul(al8, bl4)) | 0; | ||
40468 | mid = (mid + Math.imul(al8, bh4)) | 0; | ||
40469 | mid = (mid + Math.imul(ah8, bl4)) | 0; | ||
40470 | hi = (hi + Math.imul(ah8, bh4)) | 0; | ||
40471 | lo = (lo + Math.imul(al7, bl5)) | 0; | ||
40472 | mid = (mid + Math.imul(al7, bh5)) | 0; | ||
40473 | mid = (mid + Math.imul(ah7, bl5)) | 0; | ||
40474 | hi = (hi + Math.imul(ah7, bh5)) | 0; | ||
40475 | lo = (lo + Math.imul(al6, bl6)) | 0; | ||
40476 | mid = (mid + Math.imul(al6, bh6)) | 0; | ||
40477 | mid = (mid + Math.imul(ah6, bl6)) | 0; | ||
40478 | hi = (hi + Math.imul(ah6, bh6)) | 0; | ||
40479 | lo = (lo + Math.imul(al5, bl7)) | 0; | ||
40480 | mid = (mid + Math.imul(al5, bh7)) | 0; | ||
40481 | mid = (mid + Math.imul(ah5, bl7)) | 0; | ||
40482 | hi = (hi + Math.imul(ah5, bh7)) | 0; | ||
40483 | lo = (lo + Math.imul(al4, bl8)) | 0; | ||
40484 | mid = (mid + Math.imul(al4, bh8)) | 0; | ||
40485 | mid = (mid + Math.imul(ah4, bl8)) | 0; | ||
40486 | hi = (hi + Math.imul(ah4, bh8)) | 0; | ||
40487 | lo = (lo + Math.imul(al3, bl9)) | 0; | ||
40488 | mid = (mid + Math.imul(al3, bh9)) | 0; | ||
40489 | mid = (mid + Math.imul(ah3, bl9)) | 0; | ||
40490 | hi = (hi + Math.imul(ah3, bh9)) | 0; | ||
40491 | var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; | ||
40492 | c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0; | ||
40493 | w12 &= 0x3ffffff; | ||
40494 | /* k = 13 */ | ||
40495 | lo = Math.imul(al9, bl4); | ||
40496 | mid = Math.imul(al9, bh4); | ||
40497 | mid = (mid + Math.imul(ah9, bl4)) | 0; | ||
40498 | hi = Math.imul(ah9, bh4); | ||
40499 | lo = (lo + Math.imul(al8, bl5)) | 0; | ||
40500 | mid = (mid + Math.imul(al8, bh5)) | 0; | ||
40501 | mid = (mid + Math.imul(ah8, bl5)) | 0; | ||
40502 | hi = (hi + Math.imul(ah8, bh5)) | 0; | ||
40503 | lo = (lo + Math.imul(al7, bl6)) | 0; | ||
40504 | mid = (mid + Math.imul(al7, bh6)) | 0; | ||
40505 | mid = (mid + Math.imul(ah7, bl6)) | 0; | ||
40506 | hi = (hi + Math.imul(ah7, bh6)) | 0; | ||
40507 | lo = (lo + Math.imul(al6, bl7)) | 0; | ||
40508 | mid = (mid + Math.imul(al6, bh7)) | 0; | ||
40509 | mid = (mid + Math.imul(ah6, bl7)) | 0; | ||
40510 | hi = (hi + Math.imul(ah6, bh7)) | 0; | ||
40511 | lo = (lo + Math.imul(al5, bl8)) | 0; | ||
40512 | mid = (mid + Math.imul(al5, bh8)) | 0; | ||
40513 | mid = (mid + Math.imul(ah5, bl8)) | 0; | ||
40514 | hi = (hi + Math.imul(ah5, bh8)) | 0; | ||
40515 | lo = (lo + Math.imul(al4, bl9)) | 0; | ||
40516 | mid = (mid + Math.imul(al4, bh9)) | 0; | ||
40517 | mid = (mid + Math.imul(ah4, bl9)) | 0; | ||
40518 | hi = (hi + Math.imul(ah4, bh9)) | 0; | ||
40519 | var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; | ||
40520 | c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0; | ||
40521 | w13 &= 0x3ffffff; | ||
40522 | /* k = 14 */ | ||
40523 | lo = Math.imul(al9, bl5); | ||
40524 | mid = Math.imul(al9, bh5); | ||
40525 | mid = (mid + Math.imul(ah9, bl5)) | 0; | ||
40526 | hi = Math.imul(ah9, bh5); | ||
40527 | lo = (lo + Math.imul(al8, bl6)) | 0; | ||
40528 | mid = (mid + Math.imul(al8, bh6)) | 0; | ||
40529 | mid = (mid + Math.imul(ah8, bl6)) | 0; | ||
40530 | hi = (hi + Math.imul(ah8, bh6)) | 0; | ||
40531 | lo = (lo + Math.imul(al7, bl7)) | 0; | ||
40532 | mid = (mid + Math.imul(al7, bh7)) | 0; | ||
40533 | mid = (mid + Math.imul(ah7, bl7)) | 0; | ||
40534 | hi = (hi + Math.imul(ah7, bh7)) | 0; | ||
40535 | lo = (lo + Math.imul(al6, bl8)) | 0; | ||
40536 | mid = (mid + Math.imul(al6, bh8)) | 0; | ||
40537 | mid = (mid + Math.imul(ah6, bl8)) | 0; | ||
40538 | hi = (hi + Math.imul(ah6, bh8)) | 0; | ||
40539 | lo = (lo + Math.imul(al5, bl9)) | 0; | ||
40540 | mid = (mid + Math.imul(al5, bh9)) | 0; | ||
40541 | mid = (mid + Math.imul(ah5, bl9)) | 0; | ||
40542 | hi = (hi + Math.imul(ah5, bh9)) | 0; | ||
40543 | var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; | ||
40544 | c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0; | ||
40545 | w14 &= 0x3ffffff; | ||
40546 | /* k = 15 */ | ||
40547 | lo = Math.imul(al9, bl6); | ||
40548 | mid = Math.imul(al9, bh6); | ||
40549 | mid = (mid + Math.imul(ah9, bl6)) | 0; | ||
40550 | hi = Math.imul(ah9, bh6); | ||
40551 | lo = (lo + Math.imul(al8, bl7)) | 0; | ||
40552 | mid = (mid + Math.imul(al8, bh7)) | 0; | ||
40553 | mid = (mid + Math.imul(ah8, bl7)) | 0; | ||
40554 | hi = (hi + Math.imul(ah8, bh7)) | 0; | ||
40555 | lo = (lo + Math.imul(al7, bl8)) | 0; | ||
40556 | mid = (mid + Math.imul(al7, bh8)) | 0; | ||
40557 | mid = (mid + Math.imul(ah7, bl8)) | 0; | ||
40558 | hi = (hi + Math.imul(ah7, bh8)) | 0; | ||
40559 | lo = (lo + Math.imul(al6, bl9)) | 0; | ||
40560 | mid = (mid + Math.imul(al6, bh9)) | 0; | ||
40561 | mid = (mid + Math.imul(ah6, bl9)) | 0; | ||
40562 | hi = (hi + Math.imul(ah6, bh9)) | 0; | ||
40563 | var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; | ||
40564 | c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0; | ||
40565 | w15 &= 0x3ffffff; | ||
40566 | /* k = 16 */ | ||
40567 | lo = Math.imul(al9, bl7); | ||
40568 | mid = Math.imul(al9, bh7); | ||
40569 | mid = (mid + Math.imul(ah9, bl7)) | 0; | ||
40570 | hi = Math.imul(ah9, bh7); | ||
40571 | lo = (lo + Math.imul(al8, bl8)) | 0; | ||
40572 | mid = (mid + Math.imul(al8, bh8)) | 0; | ||
40573 | mid = (mid + Math.imul(ah8, bl8)) | 0; | ||
40574 | hi = (hi + Math.imul(ah8, bh8)) | 0; | ||
40575 | lo = (lo + Math.imul(al7, bl9)) | 0; | ||
40576 | mid = (mid + Math.imul(al7, bh9)) | 0; | ||
40577 | mid = (mid + Math.imul(ah7, bl9)) | 0; | ||
40578 | hi = (hi + Math.imul(ah7, bh9)) | 0; | ||
40579 | var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; | ||
40580 | c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0; | ||
40581 | w16 &= 0x3ffffff; | ||
40582 | /* k = 17 */ | ||
40583 | lo = Math.imul(al9, bl8); | ||
40584 | mid = Math.imul(al9, bh8); | ||
40585 | mid = (mid + Math.imul(ah9, bl8)) | 0; | ||
40586 | hi = Math.imul(ah9, bh8); | ||
40587 | lo = (lo + Math.imul(al8, bl9)) | 0; | ||
40588 | mid = (mid + Math.imul(al8, bh9)) | 0; | ||
40589 | mid = (mid + Math.imul(ah8, bl9)) | 0; | ||
40590 | hi = (hi + Math.imul(ah8, bh9)) | 0; | ||
40591 | var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; | ||
40592 | c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0; | ||
40593 | w17 &= 0x3ffffff; | ||
40594 | /* k = 18 */ | ||
40595 | lo = Math.imul(al9, bl9); | ||
40596 | mid = Math.imul(al9, bh9); | ||
40597 | mid = (mid + Math.imul(ah9, bl9)) | 0; | ||
40598 | hi = Math.imul(ah9, bh9); | ||
40599 | var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; | ||
40600 | c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0; | ||
40601 | w18 &= 0x3ffffff; | ||
40602 | o[0] = w0; | ||
40603 | o[1] = w1; | ||
40604 | o[2] = w2; | ||
40605 | o[3] = w3; | ||
40606 | o[4] = w4; | ||
40607 | o[5] = w5; | ||
40608 | o[6] = w6; | ||
40609 | o[7] = w7; | ||
40610 | o[8] = w8; | ||
40611 | o[9] = w9; | ||
40612 | o[10] = w10; | ||
40613 | o[11] = w11; | ||
40614 | o[12] = w12; | ||
40615 | o[13] = w13; | ||
40616 | o[14] = w14; | ||
40617 | o[15] = w15; | ||
40618 | o[16] = w16; | ||
40619 | o[17] = w17; | ||
40620 | o[18] = w18; | ||
40621 | if (c !== 0) { | ||
40622 | o[19] = c; | ||
40623 | out.length++; | ||
40624 | } | ||
40625 | return out; | ||
40626 | }; | ||
40627 | |||
40628 | // Polyfill comb | ||
40629 | if (!Math.imul) { | ||
40630 | comb10MulTo = smallMulTo; | ||
40631 | } | ||
40632 | |||
40633 | function bigMulTo (self, num, out) { | ||
40634 | out.negative = num.negative ^ self.negative; | ||
40635 | out.length = self.length + num.length; | ||
40636 | |||
40637 | var carry = 0; | ||
40638 | var hncarry = 0; | ||
40639 | for (var k = 0; k < out.length - 1; k++) { | ||
40640 | // Sum all words with the same `i + j = k` and accumulate `ncarry`, | ||
40641 | // note that ncarry could be >= 0x3ffffff | ||
40642 | var ncarry = hncarry; | ||
40643 | hncarry = 0; | ||
40644 | var rword = carry & 0x3ffffff; | ||
40645 | var maxJ = Math.min(k, num.length - 1); | ||
40646 | for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { | ||
40647 | var i = k - j; | ||
40648 | var a = self.words[i] | 0; | ||
40649 | var b = num.words[j] | 0; | ||
40650 | var r = a * b; | ||
40651 | |||
40652 | var lo = r & 0x3ffffff; | ||
40653 | ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0; | ||
40654 | lo = (lo + rword) | 0; | ||
40655 | rword = lo & 0x3ffffff; | ||
40656 | ncarry = (ncarry + (lo >>> 26)) | 0; | ||
40657 | |||
40658 | hncarry += ncarry >>> 26; | ||
40659 | ncarry &= 0x3ffffff; | ||
40660 | } | ||
40661 | out.words[k] = rword; | ||
40662 | carry = ncarry; | ||
40663 | ncarry = hncarry; | ||
40664 | } | ||
40665 | if (carry !== 0) { | ||
40666 | out.words[k] = carry; | ||
40667 | } else { | ||
40668 | out.length--; | ||
40669 | } | ||
40670 | |||
40671 | return out.strip(); | ||
40672 | } | ||
40673 | |||
40674 | function jumboMulTo (self, num, out) { | ||
40675 | var fftm = new FFTM(); | ||
40676 | return fftm.mulp(self, num, out); | ||
40677 | } | ||
40678 | |||
40679 | BN.prototype.mulTo = function mulTo (num, out) { | ||
40680 | var res; | ||
40681 | var len = this.length + num.length; | ||
40682 | if (this.length === 10 && num.length === 10) { | ||
40683 | res = comb10MulTo(this, num, out); | ||
40684 | } else if (len < 63) { | ||
40685 | res = smallMulTo(this, num, out); | ||
40686 | } else if (len < 1024) { | ||
40687 | res = bigMulTo(this, num, out); | ||
40688 | } else { | ||
40689 | res = jumboMulTo(this, num, out); | ||
40690 | } | ||
40691 | |||
40692 | return res; | ||
40693 | }; | ||
40694 | |||
40695 | // Cooley-Tukey algorithm for FFT | ||
40696 | // slightly revisited to rely on looping instead of recursion | ||
40697 | |||
40698 | function FFTM (x, y) { | ||
40699 | this.x = x; | ||
40700 | this.y = y; | ||
40701 | } | ||
40702 | |||
40703 | FFTM.prototype.makeRBT = function makeRBT (N) { | ||
40704 | var t = new Array(N); | ||
40705 | var l = BN.prototype._countBits(N) - 1; | ||
40706 | for (var i = 0; i < N; i++) { | ||
40707 | t[i] = this.revBin(i, l, N); | ||
40708 | } | ||
40709 | |||
40710 | return t; | ||
40711 | }; | ||
40712 | |||
40713 | // Returns binary-reversed representation of `x` | ||
40714 | FFTM.prototype.revBin = function revBin (x, l, N) { | ||
40715 | if (x === 0 || x === N - 1) return x; | ||
40716 | |||
40717 | var rb = 0; | ||
40718 | for (var i = 0; i < l; i++) { | ||
40719 | rb |= (x & 1) << (l - i - 1); | ||
40720 | x >>= 1; | ||
40721 | } | ||
40722 | |||
40723 | return rb; | ||
40724 | }; | ||
40725 | |||
40726 | // Performs "tweedling" phase, therefore 'emulating' | ||
40727 | // behaviour of the recursive algorithm | ||
40728 | FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) { | ||
40729 | for (var i = 0; i < N; i++) { | ||
40730 | rtws[i] = rws[rbt[i]]; | ||
40731 | itws[i] = iws[rbt[i]]; | ||
40732 | } | ||
40733 | }; | ||
40734 | |||
40735 | FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) { | ||
40736 | this.permute(rbt, rws, iws, rtws, itws, N); | ||
40737 | |||
40738 | for (var s = 1; s < N; s <<= 1) { | ||
40739 | var l = s << 1; | ||
40740 | |||
40741 | var rtwdf = Math.cos(2 * Math.PI / l); | ||
40742 | var itwdf = Math.sin(2 * Math.PI / l); | ||
40743 | |||
40744 | for (var p = 0; p < N; p += l) { | ||
40745 | var rtwdf_ = rtwdf; | ||
40746 | var itwdf_ = itwdf; | ||
40747 | |||
40748 | for (var j = 0; j < s; j++) { | ||
40749 | var re = rtws[p + j]; | ||
40750 | var ie = itws[p + j]; | ||
40751 | |||
40752 | var ro = rtws[p + j + s]; | ||
40753 | var io = itws[p + j + s]; | ||
40754 | |||
40755 | var rx = rtwdf_ * ro - itwdf_ * io; | ||
40756 | |||
40757 | io = rtwdf_ * io + itwdf_ * ro; | ||
40758 | ro = rx; | ||
40759 | |||
40760 | rtws[p + j] = re + ro; | ||
40761 | itws[p + j] = ie + io; | ||
40762 | |||
40763 | rtws[p + j + s] = re - ro; | ||
40764 | itws[p + j + s] = ie - io; | ||
40765 | |||
40766 | /* jshint maxdepth : false */ | ||
40767 | if (j !== l) { | ||
40768 | rx = rtwdf * rtwdf_ - itwdf * itwdf_; | ||
40769 | |||
40770 | itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_; | ||
40771 | rtwdf_ = rx; | ||
40772 | } | ||
40773 | } | ||
40774 | } | ||
40775 | } | ||
40776 | }; | ||
40777 | |||
40778 | FFTM.prototype.guessLen13b = function guessLen13b (n, m) { | ||
40779 | var N = Math.max(m, n) | 1; | ||
40780 | var odd = N & 1; | ||
40781 | var i = 0; | ||
40782 | for (N = N / 2 | 0; N; N = N >>> 1) { | ||
40783 | i++; | ||
40784 | } | ||
40785 | |||
40786 | return 1 << i + 1 + odd; | ||
40787 | }; | ||
40788 | |||
40789 | FFTM.prototype.conjugate = function conjugate (rws, iws, N) { | ||
40790 | if (N <= 1) return; | ||
40791 | |||
40792 | for (var i = 0; i < N / 2; i++) { | ||
40793 | var t = rws[i]; | ||
40794 | |||
40795 | rws[i] = rws[N - i - 1]; | ||
40796 | rws[N - i - 1] = t; | ||
40797 | |||
40798 | t = iws[i]; | ||
40799 | |||
40800 | iws[i] = -iws[N - i - 1]; | ||
40801 | iws[N - i - 1] = -t; | ||
40802 | } | ||
40803 | }; | ||
40804 | |||
40805 | FFTM.prototype.normalize13b = function normalize13b (ws, N) { | ||
40806 | var carry = 0; | ||
40807 | for (var i = 0; i < N / 2; i++) { | ||
40808 | var w = Math.round(ws[2 * i + 1] / N) * 0x2000 + | ||
40809 | Math.round(ws[2 * i] / N) + | ||
40810 | carry; | ||
40811 | |||
40812 | ws[i] = w & 0x3ffffff; | ||
40813 | |||
40814 | if (w < 0x4000000) { | ||
40815 | carry = 0; | ||
40816 | } else { | ||
40817 | carry = w / 0x4000000 | 0; | ||
40818 | } | ||
40819 | } | ||
40820 | |||
40821 | return ws; | ||
40822 | }; | ||
40823 | |||
40824 | FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) { | ||
40825 | var carry = 0; | ||
40826 | for (var i = 0; i < len; i++) { | ||
40827 | carry = carry + (ws[i] | 0); | ||
40828 | |||
40829 | rws[2 * i] = carry & 0x1fff; carry = carry >>> 13; | ||
40830 | rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13; | ||
40831 | } | ||
40832 | |||
40833 | // Pad with zeroes | ||
40834 | for (i = 2 * len; i < N; ++i) { | ||
40835 | rws[i] = 0; | ||
40836 | } | ||
40837 | |||
40838 | assert(carry === 0); | ||
40839 | assert((carry & ~0x1fff) === 0); | ||
40840 | }; | ||
40841 | |||
40842 | FFTM.prototype.stub = function stub (N) { | ||
40843 | var ph = new Array(N); | ||
40844 | for (var i = 0; i < N; i++) { | ||
40845 | ph[i] = 0; | ||
40846 | } | ||
40847 | |||
40848 | return ph; | ||
40849 | }; | ||
40850 | |||
40851 | FFTM.prototype.mulp = function mulp (x, y, out) { | ||
40852 | var N = 2 * this.guessLen13b(x.length, y.length); | ||
40853 | |||
40854 | var rbt = this.makeRBT(N); | ||
40855 | |||
40856 | var _ = this.stub(N); | ||
40857 | |||
40858 | var rws = new Array(N); | ||
40859 | var rwst = new Array(N); | ||
40860 | var iwst = new Array(N); | ||
40861 | |||
40862 | var nrws = new Array(N); | ||
40863 | var nrwst = new Array(N); | ||
40864 | var niwst = new Array(N); | ||
40865 | |||
40866 | var rmws = out.words; | ||
40867 | rmws.length = N; | ||
40868 | |||
40869 | this.convert13b(x.words, x.length, rws, N); | ||
40870 | this.convert13b(y.words, y.length, nrws, N); | ||
40871 | |||
40872 | this.transform(rws, _, rwst, iwst, N, rbt); | ||
40873 | this.transform(nrws, _, nrwst, niwst, N, rbt); | ||
40874 | |||
40875 | for (var i = 0; i < N; i++) { | ||
40876 | var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i]; | ||
40877 | iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i]; | ||
40878 | rwst[i] = rx; | ||
40879 | } | ||
40880 | |||
40881 | this.conjugate(rwst, iwst, N); | ||
40882 | this.transform(rwst, iwst, rmws, _, N, rbt); | ||
40883 | this.conjugate(rmws, _, N); | ||
40884 | this.normalize13b(rmws, N); | ||
40885 | |||
40886 | out.negative = x.negative ^ y.negative; | ||
40887 | out.length = x.length + y.length; | ||
40888 | return out.strip(); | ||
40889 | }; | ||
40890 | |||
40891 | // Multiply `this` by `num` | ||
40892 | BN.prototype.mul = function mul (num) { | ||
40893 | var out = new BN(null); | ||
40894 | out.words = new Array(this.length + num.length); | ||
40895 | return this.mulTo(num, out); | ||
40896 | }; | ||
40897 | |||
40898 | // Multiply employing FFT | ||
40899 | BN.prototype.mulf = function mulf (num) { | ||
40900 | var out = new BN(null); | ||
40901 | out.words = new Array(this.length + num.length); | ||
40902 | return jumboMulTo(this, num, out); | ||
40903 | }; | ||
40904 | |||
40905 | // In-place Multiplication | ||
40906 | BN.prototype.imul = function imul (num) { | ||
40907 | return this.clone().mulTo(num, this); | ||
40908 | }; | ||
40909 | |||
40910 | BN.prototype.imuln = function imuln (num) { | ||
40911 | assert(typeof num === 'number'); | ||
40912 | assert(num < 0x4000000); | ||
40913 | |||
40914 | // Carry | ||
40915 | var carry = 0; | ||
40916 | for (var i = 0; i < this.length; i++) { | ||
40917 | var w = (this.words[i] | 0) * num; | ||
40918 | var lo = (w & 0x3ffffff) + (carry & 0x3ffffff); | ||
40919 | carry >>= 26; | ||
40920 | carry += (w / 0x4000000) | 0; | ||
40921 | // NOTE: lo is 27bit maximum | ||
40922 | carry += lo >>> 26; | ||
40923 | this.words[i] = lo & 0x3ffffff; | ||
40924 | } | ||
40925 | |||
40926 | if (carry !== 0) { | ||
40927 | this.words[i] = carry; | ||
40928 | this.length++; | ||
40929 | } | ||
40930 | |||
40931 | return this; | ||
40932 | }; | ||
40933 | |||
40934 | BN.prototype.muln = function muln (num) { | ||
40935 | return this.clone().imuln(num); | ||
40936 | }; | ||
40937 | |||
40938 | // `this` * `this` | ||
40939 | BN.prototype.sqr = function sqr () { | ||
40940 | return this.mul(this); | ||
40941 | }; | ||
40942 | |||
40943 | // `this` * `this` in-place | ||
40944 | BN.prototype.isqr = function isqr () { | ||
40945 | return this.imul(this.clone()); | ||
40946 | }; | ||
40947 | |||
40948 | // Math.pow(`this`, `num`) | ||
40949 | BN.prototype.pow = function pow (num) { | ||
40950 | var w = toBitArray(num); | ||
40951 | if (w.length === 0) return new BN(1); | ||
40952 | |||
40953 | // Skip leading zeroes | ||
40954 | var res = this; | ||
40955 | for (var i = 0; i < w.length; i++, res = res.sqr()) { | ||
40956 | if (w[i] !== 0) break; | ||
40957 | } | ||
40958 | |||
40959 | if (++i < w.length) { | ||
40960 | for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) { | ||
40961 | if (w[i] === 0) continue; | ||
40962 | |||
40963 | res = res.mul(q); | ||
40964 | } | ||
40965 | } | ||
40966 | |||
40967 | return res; | ||
40968 | }; | ||
40969 | |||
40970 | // Shift-left in-place | ||
40971 | BN.prototype.iushln = function iushln (bits) { | ||
40972 | assert(typeof bits === 'number' && bits >= 0); | ||
40973 | var r = bits % 26; | ||
40974 | var s = (bits - r) / 26; | ||
40975 | var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r); | ||
40976 | var i; | ||
40977 | |||
40978 | if (r !== 0) { | ||
40979 | var carry = 0; | ||
40980 | |||
40981 | for (i = 0; i < this.length; i++) { | ||
40982 | var newCarry = this.words[i] & carryMask; | ||
40983 | var c = ((this.words[i] | 0) - newCarry) << r; | ||
40984 | this.words[i] = c | carry; | ||
40985 | carry = newCarry >>> (26 - r); | ||
40986 | } | ||
40987 | |||
40988 | if (carry) { | ||
40989 | this.words[i] = carry; | ||
40990 | this.length++; | ||
40991 | } | ||
40992 | } | ||
40993 | |||
40994 | if (s !== 0) { | ||
40995 | for (i = this.length - 1; i >= 0; i--) { | ||
40996 | this.words[i + s] = this.words[i]; | ||
40997 | } | ||
40998 | |||
40999 | for (i = 0; i < s; i++) { | ||
41000 | this.words[i] = 0; | ||
41001 | } | ||
41002 | |||
41003 | this.length += s; | ||
41004 | } | ||
41005 | |||
41006 | return this.strip(); | ||
41007 | }; | ||
41008 | |||
41009 | BN.prototype.ishln = function ishln (bits) { | ||
41010 | // TODO(indutny): implement me | ||
41011 | assert(this.negative === 0); | ||
41012 | return this.iushln(bits); | ||
41013 | }; | ||
41014 | |||
41015 | // Shift-right in-place | ||
41016 | // NOTE: `hint` is a lowest bit before trailing zeroes | ||
41017 | // NOTE: if `extended` is present - it will be filled with destroyed bits | ||
41018 | BN.prototype.iushrn = function iushrn (bits, hint, extended) { | ||
41019 | assert(typeof bits === 'number' && bits >= 0); | ||
41020 | var h; | ||
41021 | if (hint) { | ||
41022 | h = (hint - (hint % 26)) / 26; | ||
41023 | } else { | ||
41024 | h = 0; | ||
41025 | } | ||
41026 | |||
41027 | var r = bits % 26; | ||
41028 | var s = Math.min((bits - r) / 26, this.length); | ||
41029 | var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); | ||
41030 | var maskedWords = extended; | ||
41031 | |||
41032 | h -= s; | ||
41033 | h = Math.max(0, h); | ||
41034 | |||
41035 | // Extended mode, copy masked part | ||
41036 | if (maskedWords) { | ||
41037 | for (var i = 0; i < s; i++) { | ||
41038 | maskedWords.words[i] = this.words[i]; | ||
41039 | } | ||
41040 | maskedWords.length = s; | ||
41041 | } | ||
41042 | |||
41043 | if (s === 0) { | ||
41044 | // No-op, we should not move anything at all | ||
41045 | } else if (this.length > s) { | ||
41046 | this.length -= s; | ||
41047 | for (i = 0; i < this.length; i++) { | ||
41048 | this.words[i] = this.words[i + s]; | ||
41049 | } | ||
41050 | } else { | ||
41051 | this.words[0] = 0; | ||
41052 | this.length = 1; | ||
41053 | } | ||
41054 | |||
41055 | var carry = 0; | ||
41056 | for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) { | ||
41057 | var word = this.words[i] | 0; | ||
41058 | this.words[i] = (carry << (26 - r)) | (word >>> r); | ||
41059 | carry = word & mask; | ||
41060 | } | ||
41061 | |||
41062 | // Push carried bits as a mask | ||
41063 | if (maskedWords && carry !== 0) { | ||
41064 | maskedWords.words[maskedWords.length++] = carry; | ||
41065 | } | ||
41066 | |||
41067 | if (this.length === 0) { | ||
41068 | this.words[0] = 0; | ||
41069 | this.length = 1; | ||
41070 | } | ||
41071 | |||
41072 | return this.strip(); | ||
41073 | }; | ||
41074 | |||
41075 | BN.prototype.ishrn = function ishrn (bits, hint, extended) { | ||
41076 | // TODO(indutny): implement me | ||
41077 | assert(this.negative === 0); | ||
41078 | return this.iushrn(bits, hint, extended); | ||
41079 | }; | ||
41080 | |||
41081 | // Shift-left | ||
41082 | BN.prototype.shln = function shln (bits) { | ||
41083 | return this.clone().ishln(bits); | ||
41084 | }; | ||
41085 | |||
41086 | BN.prototype.ushln = function ushln (bits) { | ||
41087 | return this.clone().iushln(bits); | ||
41088 | }; | ||
41089 | |||
41090 | // Shift-right | ||
41091 | BN.prototype.shrn = function shrn (bits) { | ||
41092 | return this.clone().ishrn(bits); | ||
41093 | }; | ||
41094 | |||
41095 | BN.prototype.ushrn = function ushrn (bits) { | ||
41096 | return this.clone().iushrn(bits); | ||
41097 | }; | ||
41098 | |||
41099 | // Test if n bit is set | ||
41100 | BN.prototype.testn = function testn (bit) { | ||
41101 | assert(typeof bit === 'number' && bit >= 0); | ||
41102 | var r = bit % 26; | ||
41103 | var s = (bit - r) / 26; | ||
41104 | var q = 1 << r; | ||
41105 | |||
41106 | // Fast case: bit is much higher than all existing words | ||
41107 | if (this.length <= s) return false; | ||
41108 | |||
41109 | // Check bit and return | ||
41110 | var w = this.words[s]; | ||
41111 | |||
41112 | return !!(w & q); | ||
41113 | }; | ||
41114 | |||
41115 | // Return only lowers bits of number (in-place) | ||
41116 | BN.prototype.imaskn = function imaskn (bits) { | ||
41117 | assert(typeof bits === 'number' && bits >= 0); | ||
41118 | var r = bits % 26; | ||
41119 | var s = (bits - r) / 26; | ||
41120 | |||
41121 | assert(this.negative === 0, 'imaskn works only with positive numbers'); | ||
41122 | |||
41123 | if (this.length <= s) { | ||
41124 | return this; | ||
41125 | } | ||
41126 | |||
41127 | if (r !== 0) { | ||
41128 | s++; | ||
41129 | } | ||
41130 | this.length = Math.min(s, this.length); | ||
41131 | |||
41132 | if (r !== 0) { | ||
41133 | var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); | ||
41134 | this.words[this.length - 1] &= mask; | ||
41135 | } | ||
41136 | |||
41137 | return this.strip(); | ||
41138 | }; | ||
41139 | |||
41140 | // Return only lowers bits of number | ||
41141 | BN.prototype.maskn = function maskn (bits) { | ||
41142 | return this.clone().imaskn(bits); | ||
41143 | }; | ||
41144 | |||
41145 | // Add plain number `num` to `this` | ||
41146 | BN.prototype.iaddn = function iaddn (num) { | ||
41147 | assert(typeof num === 'number'); | ||
41148 | assert(num < 0x4000000); | ||
41149 | if (num < 0) return this.isubn(-num); | ||
41150 | |||
41151 | // Possible sign change | ||
41152 | if (this.negative !== 0) { | ||
41153 | if (this.length === 1 && (this.words[0] | 0) < num) { | ||
41154 | this.words[0] = num - (this.words[0] | 0); | ||
41155 | this.negative = 0; | ||
41156 | return this; | ||
41157 | } | ||
41158 | |||
41159 | this.negative = 0; | ||
41160 | this.isubn(num); | ||
41161 | this.negative = 1; | ||
41162 | return this; | ||
41163 | } | ||
41164 | |||
41165 | // Add without checks | ||
41166 | return this._iaddn(num); | ||
41167 | }; | ||
41168 | |||
41169 | BN.prototype._iaddn = function _iaddn (num) { | ||
41170 | this.words[0] += num; | ||
41171 | |||
41172 | // Carry | ||
41173 | for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) { | ||
41174 | this.words[i] -= 0x4000000; | ||
41175 | if (i === this.length - 1) { | ||
41176 | this.words[i + 1] = 1; | ||
41177 | } else { | ||
41178 | this.words[i + 1]++; | ||
41179 | } | ||
41180 | } | ||
41181 | this.length = Math.max(this.length, i + 1); | ||
41182 | |||
41183 | return this; | ||
41184 | }; | ||
41185 | |||
41186 | // Subtract plain number `num` from `this` | ||
41187 | BN.prototype.isubn = function isubn (num) { | ||
41188 | assert(typeof num === 'number'); | ||
41189 | assert(num < 0x4000000); | ||
41190 | if (num < 0) return this.iaddn(-num); | ||
41191 | |||
41192 | if (this.negative !== 0) { | ||
41193 | this.negative = 0; | ||
41194 | this.iaddn(num); | ||
41195 | this.negative = 1; | ||
41196 | return this; | ||
41197 | } | ||
41198 | |||
41199 | this.words[0] -= num; | ||
41200 | |||
41201 | if (this.length === 1 && this.words[0] < 0) { | ||
41202 | this.words[0] = -this.words[0]; | ||
41203 | this.negative = 1; | ||
41204 | } else { | ||
41205 | // Carry | ||
41206 | for (var i = 0; i < this.length && this.words[i] < 0; i++) { | ||
41207 | this.words[i] += 0x4000000; | ||
41208 | this.words[i + 1] -= 1; | ||
41209 | } | ||
41210 | } | ||
41211 | |||
41212 | return this.strip(); | ||
41213 | }; | ||
41214 | |||
41215 | BN.prototype.addn = function addn (num) { | ||
41216 | return this.clone().iaddn(num); | ||
41217 | }; | ||
41218 | |||
41219 | BN.prototype.subn = function subn (num) { | ||
41220 | return this.clone().isubn(num); | ||
41221 | }; | ||
41222 | |||
41223 | BN.prototype.iabs = function iabs () { | ||
41224 | this.negative = 0; | ||
41225 | |||
41226 | return this; | ||
41227 | }; | ||
41228 | |||
41229 | BN.prototype.abs = function abs () { | ||
41230 | return this.clone().iabs(); | ||
41231 | }; | ||
41232 | |||
41233 | BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) { | ||
41234 | var len = num.length + shift; | ||
41235 | var i; | ||
41236 | |||
41237 | this._expand(len); | ||
41238 | |||
41239 | var w; | ||
41240 | var carry = 0; | ||
41241 | for (i = 0; i < num.length; i++) { | ||
41242 | w = (this.words[i + shift] | 0) + carry; | ||
41243 | var right = (num.words[i] | 0) * mul; | ||
41244 | w -= right & 0x3ffffff; | ||
41245 | carry = (w >> 26) - ((right / 0x4000000) | 0); | ||
41246 | this.words[i + shift] = w & 0x3ffffff; | ||
41247 | } | ||
41248 | for (; i < this.length - shift; i++) { | ||
41249 | w = (this.words[i + shift] | 0) + carry; | ||
41250 | carry = w >> 26; | ||
41251 | this.words[i + shift] = w & 0x3ffffff; | ||
41252 | } | ||
41253 | |||
41254 | if (carry === 0) return this.strip(); | ||
41255 | |||
41256 | // Subtraction overflow | ||
41257 | assert(carry === -1); | ||
41258 | carry = 0; | ||
41259 | for (i = 0; i < this.length; i++) { | ||
41260 | w = -(this.words[i] | 0) + carry; | ||
41261 | carry = w >> 26; | ||
41262 | this.words[i] = w & 0x3ffffff; | ||
41263 | } | ||
41264 | this.negative = 1; | ||
41265 | |||
41266 | return this.strip(); | ||
41267 | }; | ||
41268 | |||
41269 | BN.prototype._wordDiv = function _wordDiv (num, mode) { | ||
41270 | var shift = this.length - num.length; | ||
41271 | |||
41272 | var a = this.clone(); | ||
41273 | var b = num; | ||
41274 | |||
41275 | // Normalize | ||
41276 | var bhi = b.words[b.length - 1] | 0; | ||
41277 | var bhiBits = this._countBits(bhi); | ||
41278 | shift = 26 - bhiBits; | ||
41279 | if (shift !== 0) { | ||
41280 | b = b.ushln(shift); | ||
41281 | a.iushln(shift); | ||
41282 | bhi = b.words[b.length - 1] | 0; | ||
41283 | } | ||
41284 | |||
41285 | // Initialize quotient | ||
41286 | var m = a.length - b.length; | ||
41287 | var q; | ||
41288 | |||
41289 | if (mode !== 'mod') { | ||
41290 | q = new BN(null); | ||
41291 | q.length = m + 1; | ||
41292 | q.words = new Array(q.length); | ||
41293 | for (var i = 0; i < q.length; i++) { | ||
41294 | q.words[i] = 0; | ||
41295 | } | ||
41296 | } | ||
41297 | |||
41298 | var diff = a.clone()._ishlnsubmul(b, 1, m); | ||
41299 | if (diff.negative === 0) { | ||
41300 | a = diff; | ||
41301 | if (q) { | ||
41302 | q.words[m] = 1; | ||
41303 | } | ||
41304 | } | ||
41305 | |||
41306 | for (var j = m - 1; j >= 0; j--) { | ||
41307 | var qj = (a.words[b.length + j] | 0) * 0x4000000 + | ||
41308 | (a.words[b.length + j - 1] | 0); | ||
41309 | |||
41310 | // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max | ||
41311 | // (0x7ffffff) | ||
41312 | qj = Math.min((qj / bhi) | 0, 0x3ffffff); | ||
41313 | |||
41314 | a._ishlnsubmul(b, qj, j); | ||
41315 | while (a.negative !== 0) { | ||
41316 | qj--; | ||
41317 | a.negative = 0; | ||
41318 | a._ishlnsubmul(b, 1, j); | ||
41319 | if (!a.isZero()) { | ||
41320 | a.negative ^= 1; | ||
41321 | } | ||
41322 | } | ||
41323 | if (q) { | ||
41324 | q.words[j] = qj; | ||
41325 | } | ||
41326 | } | ||
41327 | if (q) { | ||
41328 | q.strip(); | ||
41329 | } | ||
41330 | a.strip(); | ||
41331 | |||
41332 | // Denormalize | ||
41333 | if (mode !== 'div' && shift !== 0) { | ||
41334 | a.iushrn(shift); | ||
41335 | } | ||
41336 | |||
41337 | return { | ||
41338 | div: q || null, | ||
41339 | mod: a | ||
41340 | }; | ||
41341 | }; | ||
41342 | |||
41343 | // NOTE: 1) `mode` can be set to `mod` to request mod only, | ||
41344 | // to `div` to request div only, or be absent to | ||
41345 | // request both div & mod | ||
41346 | // 2) `positive` is true if unsigned mod is requested | ||
41347 | BN.prototype.divmod = function divmod (num, mode, positive) { | ||
41348 | assert(!num.isZero()); | ||
41349 | |||
41350 | if (this.isZero()) { | ||
41351 | return { | ||
41352 | div: new BN(0), | ||
41353 | mod: new BN(0) | ||
41354 | }; | ||
41355 | } | ||
41356 | |||
41357 | var div, mod, res; | ||
41358 | if (this.negative !== 0 && num.negative === 0) { | ||
41359 | res = this.neg().divmod(num, mode); | ||
41360 | |||
41361 | if (mode !== 'mod') { | ||
41362 | div = res.div.neg(); | ||
41363 | } | ||
41364 | |||
41365 | if (mode !== 'div') { | ||
41366 | mod = res.mod.neg(); | ||
41367 | if (positive && mod.negative !== 0) { | ||
41368 | mod.iadd(num); | ||
41369 | } | ||
41370 | } | ||
41371 | |||
41372 | return { | ||
41373 | div: div, | ||
41374 | mod: mod | ||
41375 | }; | ||
41376 | } | ||
41377 | |||
41378 | if (this.negative === 0 && num.negative !== 0) { | ||
41379 | res = this.divmod(num.neg(), mode); | ||
41380 | |||
41381 | if (mode !== 'mod') { | ||
41382 | div = res.div.neg(); | ||
41383 | } | ||
41384 | |||
41385 | return { | ||
41386 | div: div, | ||
41387 | mod: res.mod | ||
41388 | }; | ||
41389 | } | ||
41390 | |||
41391 | if ((this.negative & num.negative) !== 0) { | ||
41392 | res = this.neg().divmod(num.neg(), mode); | ||
41393 | |||
41394 | if (mode !== 'div') { | ||
41395 | mod = res.mod.neg(); | ||
41396 | if (positive && mod.negative !== 0) { | ||
41397 | mod.isub(num); | ||
41398 | } | ||
41399 | } | ||
41400 | |||
41401 | return { | ||
41402 | div: res.div, | ||
41403 | mod: mod | ||
41404 | }; | ||
41405 | } | ||
41406 | |||
41407 | // Both numbers are positive at this point | ||
41408 | |||
41409 | // Strip both numbers to approximate shift value | ||
41410 | if (num.length > this.length || this.cmp(num) < 0) { | ||
41411 | return { | ||
41412 | div: new BN(0), | ||
41413 | mod: this | ||
41414 | }; | ||
41415 | } | ||
41416 | |||
41417 | // Very short reduction | ||
41418 | if (num.length === 1) { | ||
41419 | if (mode === 'div') { | ||
41420 | return { | ||
41421 | div: this.divn(num.words[0]), | ||
41422 | mod: null | ||
41423 | }; | ||
41424 | } | ||
41425 | |||
41426 | if (mode === 'mod') { | ||
41427 | return { | ||
41428 | div: null, | ||
41429 | mod: new BN(this.modn(num.words[0])) | ||
41430 | }; | ||
41431 | } | ||
41432 | |||
41433 | return { | ||
41434 | div: this.divn(num.words[0]), | ||
41435 | mod: new BN(this.modn(num.words[0])) | ||
41436 | }; | ||
41437 | } | ||
41438 | |||
41439 | return this._wordDiv(num, mode); | ||
41440 | }; | ||
41441 | |||
41442 | // Find `this` / `num` | ||
41443 | BN.prototype.div = function div (num) { | ||
41444 | return this.divmod(num, 'div', false).div; | ||
41445 | }; | ||
41446 | |||
41447 | // Find `this` % `num` | ||
41448 | BN.prototype.mod = function mod (num) { | ||
41449 | return this.divmod(num, 'mod', false).mod; | ||
41450 | }; | ||
41451 | |||
41452 | BN.prototype.umod = function umod (num) { | ||
41453 | return this.divmod(num, 'mod', true).mod; | ||
41454 | }; | ||
41455 | |||
41456 | // Find Round(`this` / `num`) | ||
41457 | BN.prototype.divRound = function divRound (num) { | ||
41458 | var dm = this.divmod(num); | ||
41459 | |||
41460 | // Fast case - exact division | ||
41461 | if (dm.mod.isZero()) return dm.div; | ||
41462 | |||
41463 | var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; | ||
41464 | |||
41465 | var half = num.ushrn(1); | ||
41466 | var r2 = num.andln(1); | ||
41467 | var cmp = mod.cmp(half); | ||
41468 | |||
41469 | // Round down | ||
41470 | if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div; | ||
41471 | |||
41472 | // Round up | ||
41473 | return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); | ||
41474 | }; | ||
41475 | |||
41476 | BN.prototype.modn = function modn (num) { | ||
41477 | assert(num <= 0x3ffffff); | ||
41478 | var p = (1 << 26) % num; | ||
41479 | |||
41480 | var acc = 0; | ||
41481 | for (var i = this.length - 1; i >= 0; i--) { | ||
41482 | acc = (p * acc + (this.words[i] | 0)) % num; | ||
41483 | } | ||
41484 | |||
41485 | return acc; | ||
41486 | }; | ||
41487 | |||
41488 | // In-place division by number | ||
41489 | BN.prototype.idivn = function idivn (num) { | ||
41490 | assert(num <= 0x3ffffff); | ||
41491 | |||
41492 | var carry = 0; | ||
41493 | for (var i = this.length - 1; i >= 0; i--) { | ||
41494 | var w = (this.words[i] | 0) + carry * 0x4000000; | ||
41495 | this.words[i] = (w / num) | 0; | ||
41496 | carry = w % num; | ||
41497 | } | ||
41498 | |||
41499 | return this.strip(); | ||
41500 | }; | ||
41501 | |||
41502 | BN.prototype.divn = function divn (num) { | ||
41503 | return this.clone().idivn(num); | ||
41504 | }; | ||
41505 | |||
41506 | BN.prototype.egcd = function egcd (p) { | ||
41507 | assert(p.negative === 0); | ||
41508 | assert(!p.isZero()); | ||
41509 | |||
41510 | var x = this; | ||
41511 | var y = p.clone(); | ||
41512 | |||
41513 | if (x.negative !== 0) { | ||
41514 | x = x.umod(p); | ||
41515 | } else { | ||
41516 | x = x.clone(); | ||
41517 | } | ||
41518 | |||
41519 | // A * x + B * y = x | ||
41520 | var A = new BN(1); | ||
41521 | var B = new BN(0); | ||
41522 | |||
41523 | // C * x + D * y = y | ||
41524 | var C = new BN(0); | ||
41525 | var D = new BN(1); | ||
41526 | |||
41527 | var g = 0; | ||
41528 | |||
41529 | while (x.isEven() && y.isEven()) { | ||
41530 | x.iushrn(1); | ||
41531 | y.iushrn(1); | ||
41532 | ++g; | ||
41533 | } | ||
41534 | |||
41535 | var yp = y.clone(); | ||
41536 | var xp = x.clone(); | ||
41537 | |||
41538 | while (!x.isZero()) { | ||
41539 | for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1); | ||
41540 | if (i > 0) { | ||
41541 | x.iushrn(i); | ||
41542 | while (i-- > 0) { | ||
41543 | if (A.isOdd() || B.isOdd()) { | ||
41544 | A.iadd(yp); | ||
41545 | B.isub(xp); | ||
41546 | } | ||
41547 | |||
41548 | A.iushrn(1); | ||
41549 | B.iushrn(1); | ||
41550 | } | ||
41551 | } | ||
41552 | |||
41553 | for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); | ||
41554 | if (j > 0) { | ||
41555 | y.iushrn(j); | ||
41556 | while (j-- > 0) { | ||
41557 | if (C.isOdd() || D.isOdd()) { | ||
41558 | C.iadd(yp); | ||
41559 | D.isub(xp); | ||
41560 | } | ||
41561 | |||
41562 | C.iushrn(1); | ||
41563 | D.iushrn(1); | ||
41564 | } | ||
41565 | } | ||
41566 | |||
41567 | if (x.cmp(y) >= 0) { | ||
41568 | x.isub(y); | ||
41569 | A.isub(C); | ||
41570 | B.isub(D); | ||
41571 | } else { | ||
41572 | y.isub(x); | ||
41573 | C.isub(A); | ||
41574 | D.isub(B); | ||
41575 | } | ||
41576 | } | ||
41577 | |||
41578 | return { | ||
41579 | a: C, | ||
41580 | b: D, | ||
41581 | gcd: y.iushln(g) | ||
41582 | }; | ||
41583 | }; | ||
41584 | |||
41585 | // This is reduced incarnation of the binary EEA | ||
41586 | // above, designated to invert members of the | ||
41587 | // _prime_ fields F(p) at a maximal speed | ||
41588 | BN.prototype._invmp = function _invmp (p) { | ||
41589 | assert(p.negative === 0); | ||
41590 | assert(!p.isZero()); | ||
41591 | |||
41592 | var a = this; | ||
41593 | var b = p.clone(); | ||
41594 | |||
41595 | if (a.negative !== 0) { | ||
41596 | a = a.umod(p); | ||
41597 | } else { | ||
41598 | a = a.clone(); | ||
41599 | } | ||
41600 | |||
41601 | var x1 = new BN(1); | ||
41602 | var x2 = new BN(0); | ||
41603 | |||
41604 | var delta = b.clone(); | ||
41605 | |||
41606 | while (a.cmpn(1) > 0 && b.cmpn(1) > 0) { | ||
41607 | for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1); | ||
41608 | if (i > 0) { | ||
41609 | a.iushrn(i); | ||
41610 | while (i-- > 0) { | ||
41611 | if (x1.isOdd()) { | ||
41612 | x1.iadd(delta); | ||
41613 | } | ||
41614 | |||
41615 | x1.iushrn(1); | ||
41616 | } | ||
41617 | } | ||
41618 | |||
41619 | for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); | ||
41620 | if (j > 0) { | ||
41621 | b.iushrn(j); | ||
41622 | while (j-- > 0) { | ||
41623 | if (x2.isOdd()) { | ||
41624 | x2.iadd(delta); | ||
41625 | } | ||
41626 | |||
41627 | x2.iushrn(1); | ||
41628 | } | ||
41629 | } | ||
41630 | |||
41631 | if (a.cmp(b) >= 0) { | ||
41632 | a.isub(b); | ||
41633 | x1.isub(x2); | ||
41634 | } else { | ||
41635 | b.isub(a); | ||
41636 | x2.isub(x1); | ||
41637 | } | ||
41638 | } | ||
41639 | |||
41640 | var res; | ||
41641 | if (a.cmpn(1) === 0) { | ||
41642 | res = x1; | ||
41643 | } else { | ||
41644 | res = x2; | ||
41645 | } | ||
41646 | |||
41647 | if (res.cmpn(0) < 0) { | ||
41648 | res.iadd(p); | ||
41649 | } | ||
41650 | |||
41651 | return res; | ||
41652 | }; | ||
41653 | |||
41654 | BN.prototype.gcd = function gcd (num) { | ||
41655 | if (this.isZero()) return num.abs(); | ||
41656 | if (num.isZero()) return this.abs(); | ||
41657 | |||
41658 | var a = this.clone(); | ||
41659 | var b = num.clone(); | ||
41660 | a.negative = 0; | ||
41661 | b.negative = 0; | ||
41662 | |||
41663 | // Remove common factor of two | ||
41664 | for (var shift = 0; a.isEven() && b.isEven(); shift++) { | ||
41665 | a.iushrn(1); | ||
41666 | b.iushrn(1); | ||
41667 | } | ||
41668 | |||
41669 | do { | ||
41670 | while (a.isEven()) { | ||
41671 | a.iushrn(1); | ||
41672 | } | ||
41673 | while (b.isEven()) { | ||
41674 | b.iushrn(1); | ||
41675 | } | ||
41676 | |||
41677 | var r = a.cmp(b); | ||
41678 | if (r < 0) { | ||
41679 | // Swap `a` and `b` to make `a` always bigger than `b` | ||
41680 | var t = a; | ||
41681 | a = b; | ||
41682 | b = t; | ||
41683 | } else if (r === 0 || b.cmpn(1) === 0) { | ||
41684 | break; | ||
41685 | } | ||
41686 | |||
41687 | a.isub(b); | ||
41688 | } while (true); | ||
41689 | |||
41690 | return b.iushln(shift); | ||
41691 | }; | ||
41692 | |||
41693 | // Invert number in the field F(num) | ||
41694 | BN.prototype.invm = function invm (num) { | ||
41695 | return this.egcd(num).a.umod(num); | ||
41696 | }; | ||
41697 | |||
41698 | BN.prototype.isEven = function isEven () { | ||
41699 | return (this.words[0] & 1) === 0; | ||
41700 | }; | ||
41701 | |||
41702 | BN.prototype.isOdd = function isOdd () { | ||
41703 | return (this.words[0] & 1) === 1; | ||
41704 | }; | ||
41705 | |||
41706 | // And first word and num | ||
41707 | BN.prototype.andln = function andln (num) { | ||
41708 | return this.words[0] & num; | ||
41709 | }; | ||
41710 | |||
41711 | // Increment at the bit position in-line | ||
41712 | BN.prototype.bincn = function bincn (bit) { | ||
41713 | assert(typeof bit === 'number'); | ||
41714 | var r = bit % 26; | ||
41715 | var s = (bit - r) / 26; | ||
41716 | var q = 1 << r; | ||
41717 | |||
41718 | // Fast case: bit is much higher than all existing words | ||
41719 | if (this.length <= s) { | ||
41720 | this._expand(s + 1); | ||
41721 | this.words[s] |= q; | ||
41722 | return this; | ||
41723 | } | ||
41724 | |||
41725 | // Add bit and propagate, if needed | ||
41726 | var carry = q; | ||
41727 | for (var i = s; carry !== 0 && i < this.length; i++) { | ||
41728 | var w = this.words[i] | 0; | ||
41729 | w += carry; | ||
41730 | carry = w >>> 26; | ||
41731 | w &= 0x3ffffff; | ||
41732 | this.words[i] = w; | ||
41733 | } | ||
41734 | if (carry !== 0) { | ||
41735 | this.words[i] = carry; | ||
41736 | this.length++; | ||
41737 | } | ||
41738 | return this; | ||
41739 | }; | ||
41740 | |||
41741 | BN.prototype.isZero = function isZero () { | ||
41742 | return this.length === 1 && this.words[0] === 0; | ||
41743 | }; | ||
41744 | |||
41745 | BN.prototype.cmpn = function cmpn (num) { | ||
41746 | var negative = num < 0; | ||
41747 | |||
41748 | if (this.negative !== 0 && !negative) return -1; | ||
41749 | if (this.negative === 0 && negative) return 1; | ||
41750 | |||
41751 | this.strip(); | ||
41752 | |||
41753 | var res; | ||
41754 | if (this.length > 1) { | ||
41755 | res = 1; | ||
41756 | } else { | ||
41757 | if (negative) { | ||
41758 | num = -num; | ||
41759 | } | ||
41760 | |||
41761 | assert(num <= 0x3ffffff, 'Number is too big'); | ||
41762 | |||
41763 | var w = this.words[0] | 0; | ||
41764 | res = w === num ? 0 : w < num ? -1 : 1; | ||
41765 | } | ||
41766 | if (this.negative !== 0) return -res | 0; | ||
41767 | return res; | ||
41768 | }; | ||
41769 | |||
41770 | // Compare two numbers and return: | ||
41771 | // 1 - if `this` > `num` | ||
41772 | // 0 - if `this` == `num` | ||
41773 | // -1 - if `this` < `num` | ||
41774 | BN.prototype.cmp = function cmp (num) { | ||
41775 | if (this.negative !== 0 && num.negative === 0) return -1; | ||
41776 | if (this.negative === 0 && num.negative !== 0) return 1; | ||
41777 | |||
41778 | var res = this.ucmp(num); | ||
41779 | if (this.negative !== 0) return -res | 0; | ||
41780 | return res; | ||
41781 | }; | ||
41782 | |||
41783 | // Unsigned comparison | ||
41784 | BN.prototype.ucmp = function ucmp (num) { | ||
41785 | // At this point both numbers have the same sign | ||
41786 | if (this.length > num.length) return 1; | ||
41787 | if (this.length < num.length) return -1; | ||
41788 | |||
41789 | var res = 0; | ||
41790 | for (var i = this.length - 1; i >= 0; i--) { | ||
41791 | var a = this.words[i] | 0; | ||
41792 | var b = num.words[i] | 0; | ||
41793 | |||
41794 | if (a === b) continue; | ||
41795 | if (a < b) { | ||
41796 | res = -1; | ||
41797 | } else if (a > b) { | ||
41798 | res = 1; | ||
41799 | } | ||
41800 | break; | ||
41801 | } | ||
41802 | return res; | ||
41803 | }; | ||
41804 | |||
41805 | BN.prototype.gtn = function gtn (num) { | ||
41806 | return this.cmpn(num) === 1; | ||
41807 | }; | ||
41808 | |||
41809 | BN.prototype.gt = function gt (num) { | ||
41810 | return this.cmp(num) === 1; | ||
41811 | }; | ||
41812 | |||
41813 | BN.prototype.gten = function gten (num) { | ||
41814 | return this.cmpn(num) >= 0; | ||
41815 | }; | ||
41816 | |||
41817 | BN.prototype.gte = function gte (num) { | ||
41818 | return this.cmp(num) >= 0; | ||
41819 | }; | ||
41820 | |||
41821 | BN.prototype.ltn = function ltn (num) { | ||
41822 | return this.cmpn(num) === -1; | ||
41823 | }; | ||
41824 | |||
41825 | BN.prototype.lt = function lt (num) { | ||
41826 | return this.cmp(num) === -1; | ||
41827 | }; | ||
41828 | |||
41829 | BN.prototype.lten = function lten (num) { | ||
41830 | return this.cmpn(num) <= 0; | ||
41831 | }; | ||
41832 | |||
41833 | BN.prototype.lte = function lte (num) { | ||
41834 | return this.cmp(num) <= 0; | ||
41835 | }; | ||
41836 | |||
41837 | BN.prototype.eqn = function eqn (num) { | ||
41838 | return this.cmpn(num) === 0; | ||
41839 | }; | ||
41840 | |||
41841 | BN.prototype.eq = function eq (num) { | ||
41842 | return this.cmp(num) === 0; | ||
41843 | }; | ||
41844 | |||
41845 | // | ||
41846 | // A reduce context, could be using montgomery or something better, depending | ||
41847 | // on the `m` itself. | ||
41848 | // | ||
41849 | BN.red = function red (num) { | ||
41850 | return new Red(num); | ||
41851 | }; | ||
41852 | |||
41853 | BN.prototype.toRed = function toRed (ctx) { | ||
41854 | assert(!this.red, 'Already a number in reduction context'); | ||
41855 | assert(this.negative === 0, 'red works only with positives'); | ||
41856 | return ctx.convertTo(this)._forceRed(ctx); | ||
41857 | }; | ||
41858 | |||
41859 | BN.prototype.fromRed = function fromRed () { | ||
41860 | assert(this.red, 'fromRed works only with numbers in reduction context'); | ||
41861 | return this.red.convertFrom(this); | ||
41862 | }; | ||
41863 | |||
41864 | BN.prototype._forceRed = function _forceRed (ctx) { | ||
41865 | this.red = ctx; | ||
41866 | return this; | ||
41867 | }; | ||
41868 | |||
41869 | BN.prototype.forceRed = function forceRed (ctx) { | ||
41870 | assert(!this.red, 'Already a number in reduction context'); | ||
41871 | return this._forceRed(ctx); | ||
41872 | }; | ||
41873 | |||
41874 | BN.prototype.redAdd = function redAdd (num) { | ||
41875 | assert(this.red, 'redAdd works only with red numbers'); | ||
41876 | return this.red.add(this, num); | ||
41877 | }; | ||
41878 | |||
41879 | BN.prototype.redIAdd = function redIAdd (num) { | ||
41880 | assert(this.red, 'redIAdd works only with red numbers'); | ||
41881 | return this.red.iadd(this, num); | ||
41882 | }; | ||
41883 | |||
41884 | BN.prototype.redSub = function redSub (num) { | ||
41885 | assert(this.red, 'redSub works only with red numbers'); | ||
41886 | return this.red.sub(this, num); | ||
41887 | }; | ||
41888 | |||
41889 | BN.prototype.redISub = function redISub (num) { | ||
41890 | assert(this.red, 'redISub works only with red numbers'); | ||
41891 | return this.red.isub(this, num); | ||
41892 | }; | ||
41893 | |||
41894 | BN.prototype.redShl = function redShl (num) { | ||
41895 | assert(this.red, 'redShl works only with red numbers'); | ||
41896 | return this.red.shl(this, num); | ||
41897 | }; | ||
41898 | |||
41899 | BN.prototype.redMul = function redMul (num) { | ||
41900 | assert(this.red, 'redMul works only with red numbers'); | ||
41901 | this.red._verify2(this, num); | ||
41902 | return this.red.mul(this, num); | ||
41903 | }; | ||
41904 | |||
41905 | BN.prototype.redIMul = function redIMul (num) { | ||
41906 | assert(this.red, 'redMul works only with red numbers'); | ||
41907 | this.red._verify2(this, num); | ||
41908 | return this.red.imul(this, num); | ||
41909 | }; | ||
41910 | |||
41911 | BN.prototype.redSqr = function redSqr () { | ||
41912 | assert(this.red, 'redSqr works only with red numbers'); | ||
41913 | this.red._verify1(this); | ||
41914 | return this.red.sqr(this); | ||
41915 | }; | ||
41916 | |||
41917 | BN.prototype.redISqr = function redISqr () { | ||
41918 | assert(this.red, 'redISqr works only with red numbers'); | ||
41919 | this.red._verify1(this); | ||
41920 | return this.red.isqr(this); | ||
41921 | }; | ||
41922 | |||
41923 | // Square root over p | ||
41924 | BN.prototype.redSqrt = function redSqrt () { | ||
41925 | assert(this.red, 'redSqrt works only with red numbers'); | ||
41926 | this.red._verify1(this); | ||
41927 | return this.red.sqrt(this); | ||
41928 | }; | ||
41929 | |||
41930 | BN.prototype.redInvm = function redInvm () { | ||
41931 | assert(this.red, 'redInvm works only with red numbers'); | ||
41932 | this.red._verify1(this); | ||
41933 | return this.red.invm(this); | ||
41934 | }; | ||
41935 | |||
41936 | // Return negative clone of `this` % `red modulo` | ||
41937 | BN.prototype.redNeg = function redNeg () { | ||
41938 | assert(this.red, 'redNeg works only with red numbers'); | ||
41939 | this.red._verify1(this); | ||
41940 | return this.red.neg(this); | ||
41941 | }; | ||
41942 | |||
41943 | BN.prototype.redPow = function redPow (num) { | ||
41944 | assert(this.red && !num.red, 'redPow(normalNum)'); | ||
41945 | this.red._verify1(this); | ||
41946 | return this.red.pow(this, num); | ||
41947 | }; | ||
41948 | |||
41949 | // Prime numbers with efficient reduction | ||
41950 | var primes = { | ||
41951 | k256: null, | ||
41952 | p224: null, | ||
41953 | p192: null, | ||
41954 | p25519: null | ||
41955 | }; | ||
41956 | |||
41957 | // Pseudo-Mersenne prime | ||
41958 | function MPrime (name, p) { | ||
41959 | // P = 2 ^ N - K | ||
41960 | this.name = name; | ||
41961 | this.p = new BN(p, 16); | ||
41962 | this.n = this.p.bitLength(); | ||
41963 | this.k = new BN(1).iushln(this.n).isub(this.p); | ||
41964 | |||
41965 | this.tmp = this._tmp(); | ||
41966 | } | ||
41967 | |||
41968 | MPrime.prototype._tmp = function _tmp () { | ||
41969 | var tmp = new BN(null); | ||
41970 | tmp.words = new Array(Math.ceil(this.n / 13)); | ||
41971 | return tmp; | ||
41972 | }; | ||
41973 | |||
41974 | MPrime.prototype.ireduce = function ireduce (num) { | ||
41975 | // Assumes that `num` is less than `P^2` | ||
41976 | // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P) | ||
41977 | var r = num; | ||
41978 | var rlen; | ||
41979 | |||
41980 | do { | ||
41981 | this.split(r, this.tmp); | ||
41982 | r = this.imulK(r); | ||
41983 | r = r.iadd(this.tmp); | ||
41984 | rlen = r.bitLength(); | ||
41985 | } while (rlen > this.n); | ||
41986 | |||
41987 | var cmp = rlen < this.n ? -1 : r.ucmp(this.p); | ||
41988 | if (cmp === 0) { | ||
41989 | r.words[0] = 0; | ||
41990 | r.length = 1; | ||
41991 | } else if (cmp > 0) { | ||
41992 | r.isub(this.p); | ||
41993 | } else { | ||
41994 | r.strip(); | ||
41995 | } | ||
41996 | |||
41997 | return r; | ||
41998 | }; | ||
41999 | |||
42000 | MPrime.prototype.split = function split (input, out) { | ||
42001 | input.iushrn(this.n, 0, out); | ||
42002 | }; | ||
42003 | |||
42004 | MPrime.prototype.imulK = function imulK (num) { | ||
42005 | return num.imul(this.k); | ||
42006 | }; | ||
42007 | |||
42008 | function K256 () { | ||
42009 | MPrime.call( | ||
42010 | this, | ||
42011 | 'k256', | ||
42012 | 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f'); | ||
42013 | } | ||
42014 | inherits(K256, MPrime); | ||
42015 | |||
42016 | K256.prototype.split = function split (input, output) { | ||
42017 | // 256 = 9 * 26 + 22 | ||
42018 | var mask = 0x3fffff; | ||
42019 | |||
42020 | var outLen = Math.min(input.length, 9); | ||
42021 | for (var i = 0; i < outLen; i++) { | ||
42022 | output.words[i] = input.words[i]; | ||
42023 | } | ||
42024 | output.length = outLen; | ||
42025 | |||
42026 | if (input.length <= 9) { | ||
42027 | input.words[0] = 0; | ||
42028 | input.length = 1; | ||
42029 | return; | ||
42030 | } | ||
42031 | |||
42032 | // Shift by 9 limbs | ||
42033 | var prev = input.words[9]; | ||
42034 | output.words[output.length++] = prev & mask; | ||
42035 | |||
42036 | for (i = 10; i < input.length; i++) { | ||
42037 | var next = input.words[i] | 0; | ||
42038 | input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22); | ||
42039 | prev = next; | ||
42040 | } | ||
42041 | prev >>>= 22; | ||
42042 | input.words[i - 10] = prev; | ||
42043 | if (prev === 0 && input.length > 10) { | ||
42044 | input.length -= 10; | ||
42045 | } else { | ||
42046 | input.length -= 9; | ||
42047 | } | ||
42048 | }; | ||
42049 | |||
42050 | K256.prototype.imulK = function imulK (num) { | ||
42051 | // K = 0x1000003d1 = [ 0x40, 0x3d1 ] | ||
42052 | num.words[num.length] = 0; | ||
42053 | num.words[num.length + 1] = 0; | ||
42054 | num.length += 2; | ||
42055 | |||
42056 | // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390 | ||
42057 | var lo = 0; | ||
42058 | for (var i = 0; i < num.length; i++) { | ||
42059 | var w = num.words[i] | 0; | ||
42060 | lo += w * 0x3d1; | ||
42061 | num.words[i] = lo & 0x3ffffff; | ||
42062 | lo = w * 0x40 + ((lo / 0x4000000) | 0); | ||
42063 | } | ||
42064 | |||
42065 | // Fast length reduction | ||
42066 | if (num.words[num.length - 1] === 0) { | ||
42067 | num.length--; | ||
42068 | if (num.words[num.length - 1] === 0) { | ||
42069 | num.length--; | ||
42070 | } | ||
42071 | } | ||
42072 | return num; | ||
42073 | }; | ||
42074 | |||
42075 | function P224 () { | ||
42076 | MPrime.call( | ||
42077 | this, | ||
42078 | 'p224', | ||
42079 | 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001'); | ||
42080 | } | ||
42081 | inherits(P224, MPrime); | ||
42082 | |||
42083 | function P192 () { | ||
42084 | MPrime.call( | ||
42085 | this, | ||
42086 | 'p192', | ||
42087 | 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff'); | ||
42088 | } | ||
42089 | inherits(P192, MPrime); | ||
42090 | |||
42091 | function P25519 () { | ||
42092 | // 2 ^ 255 - 19 | ||
42093 | MPrime.call( | ||
42094 | this, | ||
42095 | '25519', | ||
42096 | '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed'); | ||
42097 | } | ||
42098 | inherits(P25519, MPrime); | ||
42099 | |||
42100 | P25519.prototype.imulK = function imulK (num) { | ||
42101 | // K = 0x13 | ||
42102 | var carry = 0; | ||
42103 | for (var i = 0; i < num.length; i++) { | ||
42104 | var hi = (num.words[i] | 0) * 0x13 + carry; | ||
42105 | var lo = hi & 0x3ffffff; | ||
42106 | hi >>>= 26; | ||
42107 | |||
42108 | num.words[i] = lo; | ||
42109 | carry = hi; | ||
42110 | } | ||
42111 | if (carry !== 0) { | ||
42112 | num.words[num.length++] = carry; | ||
42113 | } | ||
42114 | return num; | ||
42115 | }; | ||
42116 | |||
42117 | // Exported mostly for testing purposes, use plain name instead | ||
42118 | BN._prime = function prime (name) { | ||
42119 | // Cached version of prime | ||
42120 | if (primes[name]) return primes[name]; | ||
42121 | |||
42122 | var prime; | ||
42123 | if (name === 'k256') { | ||
42124 | prime = new K256(); | ||
42125 | } else if (name === 'p224') { | ||
42126 | prime = new P224(); | ||
42127 | } else if (name === 'p192') { | ||
42128 | prime = new P192(); | ||
42129 | } else if (name === 'p25519') { | ||
42130 | prime = new P25519(); | ||
42131 | } else { | ||
42132 | throw new Error('Unknown prime ' + name); | ||
42133 | } | ||
42134 | primes[name] = prime; | ||
42135 | |||
42136 | return prime; | ||
42137 | }; | ||
42138 | |||
42139 | // | ||
42140 | // Base reduction engine | ||
42141 | // | ||
42142 | function Red (m) { | ||
42143 | if (typeof m === 'string') { | ||
42144 | var prime = BN._prime(m); | ||
42145 | this.m = prime.p; | ||
42146 | this.prime = prime; | ||
42147 | } else { | ||
42148 | assert(m.gtn(1), 'modulus must be greater than 1'); | ||
42149 | this.m = m; | ||
42150 | this.prime = null; | ||
42151 | } | ||
42152 | } | ||
42153 | |||
42154 | Red.prototype._verify1 = function _verify1 (a) { | ||
42155 | assert(a.negative === 0, 'red works only with positives'); | ||
42156 | assert(a.red, 'red works only with red numbers'); | ||
42157 | }; | ||
42158 | |||
42159 | Red.prototype._verify2 = function _verify2 (a, b) { | ||
42160 | assert((a.negative | b.negative) === 0, 'red works only with positives'); | ||
42161 | assert(a.red && a.red === b.red, | ||
42162 | 'red works only with red numbers'); | ||
42163 | }; | ||
42164 | |||
42165 | Red.prototype.imod = function imod (a) { | ||
42166 | if (this.prime) return this.prime.ireduce(a)._forceRed(this); | ||
42167 | return a.umod(this.m)._forceRed(this); | ||
42168 | }; | ||
42169 | |||
42170 | Red.prototype.neg = function neg (a) { | ||
42171 | if (a.isZero()) { | ||
42172 | return a.clone(); | ||
42173 | } | ||
42174 | |||
42175 | return this.m.sub(a)._forceRed(this); | ||
42176 | }; | ||
42177 | |||
42178 | Red.prototype.add = function add (a, b) { | ||
42179 | this._verify2(a, b); | ||
42180 | |||
42181 | var res = a.add(b); | ||
42182 | if (res.cmp(this.m) >= 0) { | ||
42183 | res.isub(this.m); | ||
42184 | } | ||
42185 | return res._forceRed(this); | ||
42186 | }; | ||
42187 | |||
42188 | Red.prototype.iadd = function iadd (a, b) { | ||
42189 | this._verify2(a, b); | ||
42190 | |||
42191 | var res = a.iadd(b); | ||
42192 | if (res.cmp(this.m) >= 0) { | ||
42193 | res.isub(this.m); | ||
42194 | } | ||
42195 | return res; | ||
42196 | }; | ||
42197 | |||
42198 | Red.prototype.sub = function sub (a, b) { | ||
42199 | this._verify2(a, b); | ||
42200 | |||
42201 | var res = a.sub(b); | ||
42202 | if (res.cmpn(0) < 0) { | ||
42203 | res.iadd(this.m); | ||
42204 | } | ||
42205 | return res._forceRed(this); | ||
42206 | }; | ||
42207 | |||
42208 | Red.prototype.isub = function isub (a, b) { | ||
42209 | this._verify2(a, b); | ||
42210 | |||
42211 | var res = a.isub(b); | ||
42212 | if (res.cmpn(0) < 0) { | ||
42213 | res.iadd(this.m); | ||
42214 | } | ||
42215 | return res; | ||
42216 | }; | ||
42217 | |||
42218 | Red.prototype.shl = function shl (a, num) { | ||
42219 | this._verify1(a); | ||
42220 | return this.imod(a.ushln(num)); | ||
42221 | }; | ||
42222 | |||
42223 | Red.prototype.imul = function imul (a, b) { | ||
42224 | this._verify2(a, b); | ||
42225 | return this.imod(a.imul(b)); | ||
42226 | }; | ||
42227 | |||
42228 | Red.prototype.mul = function mul (a, b) { | ||
42229 | this._verify2(a, b); | ||
42230 | return this.imod(a.mul(b)); | ||
42231 | }; | ||
42232 | |||
42233 | Red.prototype.isqr = function isqr (a) { | ||
42234 | return this.imul(a, a.clone()); | ||
42235 | }; | ||
42236 | |||
42237 | Red.prototype.sqr = function sqr (a) { | ||
42238 | return this.mul(a, a); | ||
42239 | }; | ||
42240 | |||
42241 | Red.prototype.sqrt = function sqrt (a) { | ||
42242 | if (a.isZero()) return a.clone(); | ||
42243 | |||
42244 | var mod3 = this.m.andln(3); | ||
42245 | assert(mod3 % 2 === 1); | ||
42246 | |||
42247 | // Fast case | ||
42248 | if (mod3 === 3) { | ||
42249 | var pow = this.m.add(new BN(1)).iushrn(2); | ||
42250 | return this.pow(a, pow); | ||
42251 | } | ||
42252 | |||
42253 | // Tonelli-Shanks algorithm (Totally unoptimized and slow) | ||
42254 | // | ||
42255 | // Find Q and S, that Q * 2 ^ S = (P - 1) | ||
42256 | var q = this.m.subn(1); | ||
42257 | var s = 0; | ||
42258 | while (!q.isZero() && q.andln(1) === 0) { | ||
42259 | s++; | ||
42260 | q.iushrn(1); | ||
42261 | } | ||
42262 | assert(!q.isZero()); | ||
42263 | |||
42264 | var one = new BN(1).toRed(this); | ||
42265 | var nOne = one.redNeg(); | ||
42266 | |||
42267 | // Find quadratic non-residue | ||
42268 | // NOTE: Max is such because of generalized Riemann hypothesis. | ||
42269 | var lpow = this.m.subn(1).iushrn(1); | ||
42270 | var z = this.m.bitLength(); | ||
42271 | z = new BN(2 * z * z).toRed(this); | ||
42272 | |||
42273 | while (this.pow(z, lpow).cmp(nOne) !== 0) { | ||
42274 | z.redIAdd(nOne); | ||
42275 | } | ||
42276 | |||
42277 | var c = this.pow(z, q); | ||
42278 | var r = this.pow(a, q.addn(1).iushrn(1)); | ||
42279 | var t = this.pow(a, q); | ||
42280 | var m = s; | ||
42281 | while (t.cmp(one) !== 0) { | ||
42282 | var tmp = t; | ||
42283 | for (var i = 0; tmp.cmp(one) !== 0; i++) { | ||
42284 | tmp = tmp.redSqr(); | ||
42285 | } | ||
42286 | assert(i < m); | ||
42287 | var b = this.pow(c, new BN(1).iushln(m - i - 1)); | ||
42288 | |||
42289 | r = r.redMul(b); | ||
42290 | c = b.redSqr(); | ||
42291 | t = t.redMul(c); | ||
42292 | m = i; | ||
42293 | } | ||
42294 | |||
42295 | return r; | ||
42296 | }; | ||
42297 | |||
42298 | Red.prototype.invm = function invm (a) { | ||
42299 | var inv = a._invmp(this.m); | ||
42300 | if (inv.negative !== 0) { | ||
42301 | inv.negative = 0; | ||
42302 | return this.imod(inv).redNeg(); | ||
42303 | } else { | ||
42304 | return this.imod(inv); | ||
42305 | } | ||
42306 | }; | ||
42307 | |||
42308 | Red.prototype.pow = function pow (a, num) { | ||
42309 | if (num.isZero()) return new BN(1); | ||
42310 | if (num.cmpn(1) === 0) return a.clone(); | ||
42311 | |||
42312 | var windowSize = 4; | ||
42313 | var wnd = new Array(1 << windowSize); | ||
42314 | wnd[0] = new BN(1).toRed(this); | ||
42315 | wnd[1] = a; | ||
42316 | for (var i = 2; i < wnd.length; i++) { | ||
42317 | wnd[i] = this.mul(wnd[i - 1], a); | ||
42318 | } | ||
42319 | |||
42320 | var res = wnd[0]; | ||
42321 | var current = 0; | ||
42322 | var currentLen = 0; | ||
42323 | var start = num.bitLength() % 26; | ||
42324 | if (start === 0) { | ||
42325 | start = 26; | ||
42326 | } | ||
42327 | |||
42328 | for (i = num.length - 1; i >= 0; i--) { | ||
42329 | var word = num.words[i]; | ||
42330 | for (var j = start - 1; j >= 0; j--) { | ||
42331 | var bit = (word >> j) & 1; | ||
42332 | if (res !== wnd[0]) { | ||
42333 | res = this.sqr(res); | ||
42334 | } | ||
42335 | |||
42336 | if (bit === 0 && current === 0) { | ||
42337 | currentLen = 0; | ||
42338 | continue; | ||
42339 | } | ||
42340 | |||
42341 | current <<= 1; | ||
42342 | current |= bit; | ||
42343 | currentLen++; | ||
42344 | if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue; | ||
42345 | |||
42346 | res = this.mul(res, wnd[current]); | ||
42347 | currentLen = 0; | ||
42348 | current = 0; | ||
42349 | } | ||
42350 | start = 26; | ||
42351 | } | ||
42352 | |||
42353 | return res; | ||
42354 | }; | ||
42355 | |||
42356 | Red.prototype.convertTo = function convertTo (num) { | ||
42357 | var r = num.umod(this.m); | ||
42358 | |||
42359 | return r === num ? r.clone() : r; | ||
42360 | }; | ||
42361 | |||
42362 | Red.prototype.convertFrom = function convertFrom (num) { | ||
42363 | var res = num.clone(); | ||
42364 | res.red = null; | ||
42365 | return res; | ||
42366 | }; | ||
42367 | |||
42368 | // | ||
42369 | // Montgomery method engine | ||
42370 | // | ||
42371 | |||
42372 | BN.mont = function mont (num) { | ||
42373 | return new Mont(num); | ||
42374 | }; | ||
42375 | |||
42376 | function Mont (m) { | ||
42377 | Red.call(this, m); | ||
42378 | |||
42379 | this.shift = this.m.bitLength(); | ||
42380 | if (this.shift % 26 !== 0) { | ||
42381 | this.shift += 26 - (this.shift % 26); | ||
42382 | } | ||
42383 | |||
42384 | this.r = new BN(1).iushln(this.shift); | ||
42385 | this.r2 = this.imod(this.r.sqr()); | ||
42386 | this.rinv = this.r._invmp(this.m); | ||
42387 | |||
42388 | this.minv = this.rinv.mul(this.r).isubn(1).div(this.m); | ||
42389 | this.minv = this.minv.umod(this.r); | ||
42390 | this.minv = this.r.sub(this.minv); | ||
42391 | } | ||
42392 | inherits(Mont, Red); | ||
42393 | |||
42394 | Mont.prototype.convertTo = function convertTo (num) { | ||
42395 | return this.imod(num.ushln(this.shift)); | ||
42396 | }; | ||
42397 | |||
42398 | Mont.prototype.convertFrom = function convertFrom (num) { | ||
42399 | var r = this.imod(num.mul(this.rinv)); | ||
42400 | r.red = null; | ||
42401 | return r; | ||
42402 | }; | ||
42403 | |||
42404 | Mont.prototype.imul = function imul (a, b) { | ||
42405 | if (a.isZero() || b.isZero()) { | ||
42406 | a.words[0] = 0; | ||
42407 | a.length = 1; | ||
42408 | return a; | ||
42409 | } | ||
42410 | |||
42411 | var t = a.imul(b); | ||
42412 | var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); | ||
42413 | var u = t.isub(c).iushrn(this.shift); | ||
42414 | var res = u; | ||
42415 | |||
42416 | if (u.cmp(this.m) >= 0) { | ||
42417 | res = u.isub(this.m); | ||
42418 | } else if (u.cmpn(0) < 0) { | ||
42419 | res = u.iadd(this.m); | ||
42420 | } | ||
42421 | |||
42422 | return res._forceRed(this); | ||
42423 | }; | ||
42424 | |||
42425 | Mont.prototype.mul = function mul (a, b) { | ||
42426 | if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this); | ||
42427 | |||
42428 | var t = a.mul(b); | ||
42429 | var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); | ||
42430 | var u = t.isub(c).iushrn(this.shift); | ||
42431 | var res = u; | ||
42432 | if (u.cmp(this.m) >= 0) { | ||
42433 | res = u.isub(this.m); | ||
42434 | } else if (u.cmpn(0) < 0) { | ||
42435 | res = u.iadd(this.m); | ||
42436 | } | ||
42437 | |||
42438 | return res._forceRed(this); | ||
42439 | }; | ||
42440 | |||
42441 | Mont.prototype.invm = function invm (a) { | ||
42442 | // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R | ||
42443 | var res = this.imod(a._invmp(this.m).mul(this.r2)); | ||
42444 | return res._forceRed(this); | ||
42445 | }; | ||
42446 | })(typeof module === 'undefined' || module, this); | ||
42447 | |||
42448 | },{}],82:[function(require,module,exports){ | ||
42449 | var r; | ||
42450 | |||
42451 | module.exports = function rand(len) { | ||
42452 | if (!r) | ||
42453 | r = new Rand(null); | ||
42454 | |||
42455 | return r.generate(len); | ||
42456 | }; | ||
42457 | |||
42458 | function Rand(rand) { | ||
42459 | this.rand = rand; | ||
42460 | } | ||
42461 | module.exports.Rand = Rand; | ||
42462 | |||
42463 | Rand.prototype.generate = function generate(len) { | ||
42464 | return this._rand(len); | ||
42465 | }; | ||
42466 | |||
42467 | // Emulate crypto API using randy | ||
42468 | Rand.prototype._rand = function _rand(n) { | ||
42469 | if (this.rand.getBytes) | ||
42470 | return this.rand.getBytes(n); | ||
42471 | |||
42472 | var res = new Uint8Array(n); | ||
42473 | for (var i = 0; i < res.length; i++) | ||
42474 | res[i] = this.rand.getByte(); | ||
42475 | return res; | ||
42476 | }; | ||
42477 | |||
42478 | if (typeof self === 'object') { | ||
42479 | if (self.crypto && self.crypto.getRandomValues) { | ||
42480 | // Modern browsers | ||
42481 | Rand.prototype._rand = function _rand(n) { | ||
42482 | var arr = new Uint8Array(n); | ||
42483 | self.crypto.getRandomValues(arr); | ||
42484 | return arr; | ||
42485 | }; | ||
42486 | } else if (self.msCrypto && self.msCrypto.getRandomValues) { | ||
42487 | // IE | ||
42488 | Rand.prototype._rand = function _rand(n) { | ||
42489 | var arr = new Uint8Array(n); | ||
42490 | self.msCrypto.getRandomValues(arr); | ||
42491 | return arr; | ||
42492 | }; | ||
42493 | |||
42494 | // Safari's WebWorkers do not have `crypto` | ||
42495 | } else if (typeof window === 'object') { | ||
42496 | // Old junk | ||
42497 | Rand.prototype._rand = function() { | ||
42498 | throw new Error('Not implemented yet'); | ||
42499 | }; | ||
42500 | } | ||
42501 | } else { | ||
42502 | // Node.js or Web worker with no crypto support | ||
42503 | try { | ||
42504 | var crypto = require('crypto'); | ||
42505 | if (typeof crypto.randomBytes !== 'function') | ||
42506 | throw new Error('Not supported'); | ||
42507 | |||
42508 | Rand.prototype._rand = function _rand(n) { | ||
42509 | return crypto.randomBytes(n); | ||
42510 | }; | ||
42511 | } catch (e) { | ||
42512 | } | ||
42513 | } | ||
42514 | |||
42515 | },{"crypto":3}],83:[function(require,module,exports){ | ||
42516 | var basex = require('base-x') | 39041 | var basex = require('base-x') |
42517 | var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' | 39042 | var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' |
42518 | 39043 | ||
42519 | module.exports = basex(ALPHABET) | 39044 | module.exports = basex(ALPHABET) |
42520 | 39045 | ||
42521 | },{"base-x":35}],84:[function(require,module,exports){ | 39046 | },{"base-x":35}],82:[function(require,module,exports){ |
42522 | (function (Buffer){ | ||
42523 | 'use strict' | 39047 | 'use strict' |
42524 | 39048 | ||
42525 | var base58 = require('bs58') | 39049 | var base58 = require('bs58') |
39050 | var Buffer = require('safe-buffer').Buffer | ||
42526 | 39051 | ||
42527 | module.exports = function (checksumFn) { | 39052 | module.exports = function (checksumFn) { |
42528 | // Encode a buffer as a base58-check encoded string | 39053 | // Encode a buffer as a base58-check encoded string |
@@ -42570,8 +39095,7 @@ module.exports = function (checksumFn) { | |||
42570 | } | 39095 | } |
42571 | } | 39096 | } |
42572 | 39097 | ||
42573 | }).call(this,require("buffer").Buffer) | 39098 | },{"bs58":81,"safe-buffer":101}],83:[function(require,module,exports){ |
42574 | },{"bs58":83,"buffer":5}],85:[function(require,module,exports){ | ||
42575 | 'use strict' | 39099 | 'use strict' |
42576 | 39100 | ||
42577 | var createHash = require('create-hash') | 39101 | var createHash = require('create-hash') |
@@ -42585,7 +39109,7 @@ function sha256x2 (buffer) { | |||
42585 | 39109 | ||
42586 | module.exports = bs58checkBase(sha256x2) | 39110 | module.exports = bs58checkBase(sha256x2) |
42587 | 39111 | ||
42588 | },{"./base":84,"create-hash":87}],86:[function(require,module,exports){ | 39112 | },{"./base":82,"create-hash":85}],84:[function(require,module,exports){ |
42589 | var Buffer = require('safe-buffer').Buffer | 39113 | var Buffer = require('safe-buffer').Buffer |
42590 | var Transform = require('stream').Transform | 39114 | var Transform = require('stream').Transform |
42591 | var StringDecoder = require('string_decoder').StringDecoder | 39115 | var StringDecoder = require('string_decoder').StringDecoder |
@@ -42686,7 +39210,7 @@ CipherBase.prototype._toString = function (value, enc, fin) { | |||
42686 | 39210 | ||
42687 | module.exports = CipherBase | 39211 | module.exports = CipherBase |
42688 | 39212 | ||
42689 | },{"inherits":121,"safe-buffer":128,"stream":28,"string_decoder":29}],87:[function(require,module,exports){ | 39213 | },{"inherits":96,"safe-buffer":101,"stream":28,"string_decoder":29}],85:[function(require,module,exports){ |
42690 | (function (Buffer){ | 39214 | (function (Buffer){ |
42691 | 'use strict' | 39215 | 'use strict' |
42692 | var inherits = require('inherits') | 39216 | var inherits = require('inherits') |
@@ -42742,7 +39266,7 @@ module.exports = function createHash (alg) { | |||
42742 | } | 39266 | } |
42743 | 39267 | ||
42744 | }).call(this,require("buffer").Buffer) | 39268 | }).call(this,require("buffer").Buffer) |
42745 | },{"./md5":89,"buffer":5,"cipher-base":86,"inherits":121,"ripemd160":127,"sha.js":130}],88:[function(require,module,exports){ | 39269 | },{"./md5":87,"buffer":5,"cipher-base":84,"inherits":96,"ripemd160":100,"sha.js":103}],86:[function(require,module,exports){ |
42746 | (function (Buffer){ | 39270 | (function (Buffer){ |
42747 | 'use strict' | 39271 | 'use strict' |
42748 | var intSize = 4 | 39272 | var intSize = 4 |
@@ -42776,7 +39300,7 @@ module.exports = function hash (buf, fn) { | |||
42776 | } | 39300 | } |
42777 | 39301 | ||
42778 | }).call(this,require("buffer").Buffer) | 39302 | }).call(this,require("buffer").Buffer) |
42779 | },{"buffer":5}],89:[function(require,module,exports){ | 39303 | },{"buffer":5}],87:[function(require,module,exports){ |
42780 | 'use strict' | 39304 | 'use strict' |
42781 | /* | 39305 | /* |
42782 | * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message | 39306 | * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message |
@@ -42929,7 +39453,7 @@ module.exports = function md5 (buf) { | |||
42929 | return makeHash(buf, core_md5) | 39453 | return makeHash(buf, core_md5) |
42930 | } | 39454 | } |
42931 | 39455 | ||
42932 | },{"./make-hash":88}],90:[function(require,module,exports){ | 39456 | },{"./make-hash":86}],88:[function(require,module,exports){ |
42933 | 'use strict' | 39457 | 'use strict' |
42934 | var inherits = require('inherits') | 39458 | var inherits = require('inherits') |
42935 | var Legacy = require('./legacy') | 39459 | var Legacy = require('./legacy') |
@@ -42993,7 +39517,7 @@ module.exports = function createHmac (alg, key) { | |||
42993 | return new Hmac(alg, key) | 39517 | return new Hmac(alg, key) |
42994 | } | 39518 | } |
42995 | 39519 | ||
42996 | },{"./legacy":91,"cipher-base":86,"create-hash/md5":89,"inherits":121,"ripemd160":127,"safe-buffer":128,"sha.js":130}],91:[function(require,module,exports){ | 39520 | },{"./legacy":89,"cipher-base":84,"create-hash/md5":87,"inherits":96,"ripemd160":100,"safe-buffer":101,"sha.js":103}],89:[function(require,module,exports){ |
42997 | 'use strict' | 39521 | 'use strict' |
42998 | var inherits = require('inherits') | 39522 | var inherits = require('inherits') |
42999 | var Buffer = require('safe-buffer').Buffer | 39523 | var Buffer = require('safe-buffer').Buffer |
@@ -43041,7 +39565,7 @@ Hmac.prototype._final = function () { | |||
43041 | } | 39565 | } |
43042 | module.exports = Hmac | 39566 | module.exports = Hmac |
43043 | 39567 | ||
43044 | },{"cipher-base":86,"inherits":121,"safe-buffer":128}],92:[function(require,module,exports){ | 39568 | },{"cipher-base":84,"inherits":96,"safe-buffer":101}],90:[function(require,module,exports){ |
43045 | var assert = require('assert') | 39569 | var assert = require('assert') |
43046 | var BigInteger = require('bigi') | 39570 | var BigInteger = require('bigi') |
43047 | 39571 | ||
@@ -43120,7 +39644,7 @@ Curve.prototype.validate = function (Q) { | |||
43120 | 39644 | ||
43121 | module.exports = Curve | 39645 | module.exports = Curve |
43122 | 39646 | ||
43123 | },{"./point":96,"assert":1,"bigi":39}],93:[function(require,module,exports){ | 39647 | },{"./point":94,"assert":1,"bigi":39}],91:[function(require,module,exports){ |
43124 | module.exports={ | 39648 | module.exports={ |
43125 | "secp128r1": { | 39649 | "secp128r1": { |
43126 | "p": "fffffffdffffffffffffffffffffffff", | 39650 | "p": "fffffffdffffffffffffffffffffffff", |
@@ -43187,7 +39711,7 @@ module.exports={ | |||
43187 | } | 39711 | } |
43188 | } | 39712 | } |
43189 | 39713 | ||
43190 | },{}],94:[function(require,module,exports){ | 39714 | },{}],92:[function(require,module,exports){ |
43191 | var Point = require('./point') | 39715 | var Point = require('./point') |
43192 | var Curve = require('./curve') | 39716 | var Curve = require('./curve') |
43193 | 39717 | ||
@@ -43199,7 +39723,7 @@ module.exports = { | |||
43199 | getCurveByName: getCurveByName | 39723 | getCurveByName: getCurveByName |
43200 | } | 39724 | } |
43201 | 39725 | ||
43202 | },{"./curve":92,"./names":95,"./point":96}],95:[function(require,module,exports){ | 39726 | },{"./curve":90,"./names":93,"./point":94}],93:[function(require,module,exports){ |
43203 | var BigInteger = require('bigi') | 39727 | var BigInteger = require('bigi') |
43204 | 39728 | ||
43205 | var curves = require('./curves.json') | 39729 | var curves = require('./curves.json') |
@@ -43222,9 +39746,9 @@ function getCurveByName (name) { | |||
43222 | 39746 | ||
43223 | module.exports = getCurveByName | 39747 | module.exports = getCurveByName |
43224 | 39748 | ||
43225 | },{"./curve":92,"./curves.json":93,"bigi":39}],96:[function(require,module,exports){ | 39749 | },{"./curve":90,"./curves.json":91,"bigi":39}],94:[function(require,module,exports){ |
43226 | (function (Buffer){ | ||
43227 | var assert = require('assert') | 39750 | var assert = require('assert') |
39751 | var Buffer = require('safe-buffer').Buffer | ||
43228 | var BigInteger = require('bigi') | 39752 | var BigInteger = require('bigi') |
43229 | 39753 | ||
43230 | var THREE = BigInteger.valueOf(3) | 39754 | var THREE = BigInteger.valueOf(3) |
@@ -43410,7 +39934,7 @@ Point.prototype.multiplyTwo = function (j, x, k) { | |||
43410 | 39934 | ||
43411 | Point.prototype.getEncoded = function (compressed) { | 39935 | Point.prototype.getEncoded = function (compressed) { |
43412 | if (compressed == null) compressed = this.compressed | 39936 | if (compressed == null) compressed = this.compressed |
43413 | if (this.curve.isInfinity(this)) return new Buffer('00', 'hex') // Infinity point encoded is simply '00' | 39937 | if (this.curve.isInfinity(this)) return Buffer.alloc(1, 0) // Infinity point encoded is simply '00' |
43414 | 39938 | ||
43415 | var x = this.affineX | 39939 | var x = this.affineX |
43416 | var y = this.affineY | 39940 | var y = this.affineY |
@@ -43419,12 +39943,12 @@ Point.prototype.getEncoded = function (compressed) { | |||
43419 | 39943 | ||
43420 | // 0x02/0x03 | X | 39944 | // 0x02/0x03 | X |
43421 | if (compressed) { | 39945 | if (compressed) { |
43422 | buffer = new Buffer(1 + byteLength) | 39946 | buffer = Buffer.allocUnsafe(1 + byteLength) |
43423 | buffer.writeUInt8(y.isEven() ? 0x02 : 0x03, 0) | 39947 | buffer.writeUInt8(y.isEven() ? 0x02 : 0x03, 0) |
43424 | 39948 | ||
43425 | // 0x04 | X | Y | 39949 | // 0x04 | X | Y |
43426 | } else { | 39950 | } else { |
43427 | buffer = new Buffer(1 + byteLength + byteLength) | 39951 | buffer = Buffer.allocUnsafe(1 + byteLength + byteLength) |
43428 | buffer.writeUInt8(0x04, 0) | 39952 | buffer.writeUInt8(0x04, 0) |
43429 | 39953 | ||
43430 | y.toBuffer(byteLength).copy(buffer, 1 + byteLength) | 39954 | y.toBuffer(byteLength).copy(buffer, 1 + byteLength) |
@@ -43468,3979 +39992,7 @@ Point.prototype.toString = function () { | |||
43468 | 39992 | ||
43469 | module.exports = Point | 39993 | module.exports = Point |
43470 | 39994 | ||
43471 | }).call(this,require("buffer").Buffer) | 39995 | },{"assert":1,"bigi":39,"safe-buffer":101}],95:[function(require,module,exports){ |
43472 | },{"assert":1,"bigi":39,"buffer":5}],97:[function(require,module,exports){ | ||
43473 | 'use strict'; | ||
43474 | |||
43475 | var elliptic = exports; | ||
43476 | |||
43477 | elliptic.version = require('../package.json').version; | ||
43478 | elliptic.utils = require('./elliptic/utils'); | ||
43479 | elliptic.rand = require('brorand'); | ||
43480 | elliptic.curve = require('./elliptic/curve'); | ||
43481 | elliptic.curves = require('./elliptic/curves'); | ||
43482 | |||
43483 | // Protocols | ||
43484 | elliptic.ec = require('./elliptic/ec'); | ||
43485 | elliptic.eddsa = require('./elliptic/eddsa'); | ||
43486 | |||
43487 | },{"../package.json":112,"./elliptic/curve":100,"./elliptic/curves":103,"./elliptic/ec":104,"./elliptic/eddsa":107,"./elliptic/utils":111,"brorand":82}],98:[function(require,module,exports){ | ||
43488 | 'use strict'; | ||
43489 | |||
43490 | var BN = require('bn.js'); | ||
43491 | var elliptic = require('../../elliptic'); | ||
43492 | var utils = elliptic.utils; | ||
43493 | var getNAF = utils.getNAF; | ||
43494 | var getJSF = utils.getJSF; | ||
43495 | var assert = utils.assert; | ||
43496 | |||
43497 | function BaseCurve(type, conf) { | ||
43498 | this.type = type; | ||
43499 | this.p = new BN(conf.p, 16); | ||
43500 | |||
43501 | // Use Montgomery, when there is no fast reduction for the prime | ||
43502 | this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p); | ||
43503 | |||
43504 | // Useful for many curves | ||
43505 | this.zero = new BN(0).toRed(this.red); | ||
43506 | this.one = new BN(1).toRed(this.red); | ||
43507 | this.two = new BN(2).toRed(this.red); | ||
43508 | |||
43509 | // Curve configuration, optional | ||
43510 | this.n = conf.n && new BN(conf.n, 16); | ||
43511 | this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed); | ||
43512 | |||
43513 | // Temporary arrays | ||
43514 | this._wnafT1 = new Array(4); | ||
43515 | this._wnafT2 = new Array(4); | ||
43516 | this._wnafT3 = new Array(4); | ||
43517 | this._wnafT4 = new Array(4); | ||
43518 | |||
43519 | // Generalized Greg Maxwell's trick | ||
43520 | var adjustCount = this.n && this.p.div(this.n); | ||
43521 | if (!adjustCount || adjustCount.cmpn(100) > 0) { | ||
43522 | this.redN = null; | ||
43523 | } else { | ||
43524 | this._maxwellTrick = true; | ||
43525 | this.redN = this.n.toRed(this.red); | ||
43526 | } | ||
43527 | } | ||
43528 | module.exports = BaseCurve; | ||
43529 | |||
43530 | BaseCurve.prototype.point = function point() { | ||
43531 | throw new Error('Not implemented'); | ||
43532 | }; | ||
43533 | |||
43534 | BaseCurve.prototype.validate = function validate() { | ||
43535 | throw new Error('Not implemented'); | ||
43536 | }; | ||
43537 | |||
43538 | BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) { | ||
43539 | assert(p.precomputed); | ||
43540 | var doubles = p._getDoubles(); | ||
43541 | |||
43542 | var naf = getNAF(k, 1); | ||
43543 | var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1); | ||
43544 | I /= 3; | ||
43545 | |||
43546 | // Translate into more windowed form | ||
43547 | var repr = []; | ||
43548 | for (var j = 0; j < naf.length; j += doubles.step) { | ||
43549 | var nafW = 0; | ||
43550 | for (var k = j + doubles.step - 1; k >= j; k--) | ||
43551 | nafW = (nafW << 1) + naf[k]; | ||
43552 | repr.push(nafW); | ||
43553 | } | ||
43554 | |||
43555 | var a = this.jpoint(null, null, null); | ||
43556 | var b = this.jpoint(null, null, null); | ||
43557 | for (var i = I; i > 0; i--) { | ||
43558 | for (var j = 0; j < repr.length; j++) { | ||
43559 | var nafW = repr[j]; | ||
43560 | if (nafW === i) | ||
43561 | b = b.mixedAdd(doubles.points[j]); | ||
43562 | else if (nafW === -i) | ||
43563 | b = b.mixedAdd(doubles.points[j].neg()); | ||
43564 | } | ||
43565 | a = a.add(b); | ||
43566 | } | ||
43567 | return a.toP(); | ||
43568 | }; | ||
43569 | |||
43570 | BaseCurve.prototype._wnafMul = function _wnafMul(p, k) { | ||
43571 | var w = 4; | ||
43572 | |||
43573 | // Precompute window | ||
43574 | var nafPoints = p._getNAFPoints(w); | ||
43575 | w = nafPoints.wnd; | ||
43576 | var wnd = nafPoints.points; | ||
43577 | |||
43578 | // Get NAF form | ||
43579 | var naf = getNAF(k, w); | ||
43580 | |||
43581 | // Add `this`*(N+1) for every w-NAF index | ||
43582 | var acc = this.jpoint(null, null, null); | ||
43583 | for (var i = naf.length - 1; i >= 0; i--) { | ||
43584 | // Count zeroes | ||
43585 | for (var k = 0; i >= 0 && naf[i] === 0; i--) | ||
43586 | k++; | ||
43587 | if (i >= 0) | ||
43588 | k++; | ||
43589 | acc = acc.dblp(k); | ||
43590 | |||
43591 | if (i < 0) | ||
43592 | break; | ||
43593 | var z = naf[i]; | ||
43594 | assert(z !== 0); | ||
43595 | if (p.type === 'affine') { | ||
43596 | // J +- P | ||
43597 | if (z > 0) | ||
43598 | acc = acc.mixedAdd(wnd[(z - 1) >> 1]); | ||
43599 | else | ||
43600 | acc = acc.mixedAdd(wnd[(-z - 1) >> 1].neg()); | ||
43601 | } else { | ||
43602 | // J +- J | ||
43603 | if (z > 0) | ||
43604 | acc = acc.add(wnd[(z - 1) >> 1]); | ||
43605 | else | ||
43606 | acc = acc.add(wnd[(-z - 1) >> 1].neg()); | ||
43607 | } | ||
43608 | } | ||
43609 | return p.type === 'affine' ? acc.toP() : acc; | ||
43610 | }; | ||
43611 | |||
43612 | BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW, | ||
43613 | points, | ||
43614 | coeffs, | ||
43615 | len, | ||
43616 | jacobianResult) { | ||
43617 | var wndWidth = this._wnafT1; | ||
43618 | var wnd = this._wnafT2; | ||
43619 | var naf = this._wnafT3; | ||
43620 | |||
43621 | // Fill all arrays | ||
43622 | var max = 0; | ||
43623 | for (var i = 0; i < len; i++) { | ||
43624 | var p = points[i]; | ||
43625 | var nafPoints = p._getNAFPoints(defW); | ||
43626 | wndWidth[i] = nafPoints.wnd; | ||
43627 | wnd[i] = nafPoints.points; | ||
43628 | } | ||
43629 | |||
43630 | // Comb small window NAFs | ||
43631 | for (var i = len - 1; i >= 1; i -= 2) { | ||
43632 | var a = i - 1; | ||
43633 | var b = i; | ||
43634 | if (wndWidth[a] !== 1 || wndWidth[b] !== 1) { | ||
43635 | naf[a] = getNAF(coeffs[a], wndWidth[a]); | ||
43636 | naf[b] = getNAF(coeffs[b], wndWidth[b]); | ||
43637 | max = Math.max(naf[a].length, max); | ||
43638 | max = Math.max(naf[b].length, max); | ||
43639 | continue; | ||
43640 | } | ||
43641 | |||
43642 | var comb = [ | ||
43643 | points[a], /* 1 */ | ||
43644 | null, /* 3 */ | ||
43645 | null, /* 5 */ | ||
43646 | points[b] /* 7 */ | ||
43647 | ]; | ||
43648 | |||
43649 | // Try to avoid Projective points, if possible | ||
43650 | if (points[a].y.cmp(points[b].y) === 0) { | ||
43651 | comb[1] = points[a].add(points[b]); | ||
43652 | comb[2] = points[a].toJ().mixedAdd(points[b].neg()); | ||
43653 | } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) { | ||
43654 | comb[1] = points[a].toJ().mixedAdd(points[b]); | ||
43655 | comb[2] = points[a].add(points[b].neg()); | ||
43656 | } else { | ||
43657 | comb[1] = points[a].toJ().mixedAdd(points[b]); | ||
43658 | comb[2] = points[a].toJ().mixedAdd(points[b].neg()); | ||
43659 | } | ||
43660 | |||
43661 | var index = [ | ||
43662 | -3, /* -1 -1 */ | ||
43663 | -1, /* -1 0 */ | ||
43664 | -5, /* -1 1 */ | ||
43665 | -7, /* 0 -1 */ | ||
43666 | 0, /* 0 0 */ | ||
43667 | 7, /* 0 1 */ | ||
43668 | 5, /* 1 -1 */ | ||
43669 | 1, /* 1 0 */ | ||
43670 | 3 /* 1 1 */ | ||
43671 | ]; | ||
43672 | |||
43673 | var jsf = getJSF(coeffs[a], coeffs[b]); | ||
43674 | max = Math.max(jsf[0].length, max); | ||
43675 | naf[a] = new Array(max); | ||
43676 | naf[b] = new Array(max); | ||
43677 | for (var j = 0; j < max; j++) { | ||
43678 | var ja = jsf[0][j] | 0; | ||
43679 | var jb = jsf[1][j] | 0; | ||
43680 | |||
43681 | naf[a][j] = index[(ja + 1) * 3 + (jb + 1)]; | ||
43682 | naf[b][j] = 0; | ||
43683 | wnd[a] = comb; | ||
43684 | } | ||
43685 | } | ||
43686 | |||
43687 | var acc = this.jpoint(null, null, null); | ||
43688 | var tmp = this._wnafT4; | ||
43689 | for (var i = max; i >= 0; i--) { | ||
43690 | var k = 0; | ||
43691 | |||
43692 | while (i >= 0) { | ||
43693 | var zero = true; | ||
43694 | for (var j = 0; j < len; j++) { | ||
43695 | tmp[j] = naf[j][i] | 0; | ||
43696 | if (tmp[j] !== 0) | ||
43697 | zero = false; | ||
43698 | } | ||
43699 | if (!zero) | ||
43700 | break; | ||
43701 | k++; | ||
43702 | i--; | ||
43703 | } | ||
43704 | if (i >= 0) | ||
43705 | k++; | ||
43706 | acc = acc.dblp(k); | ||
43707 | if (i < 0) | ||
43708 | break; | ||
43709 | |||
43710 | for (var j = 0; j < len; j++) { | ||
43711 | var z = tmp[j]; | ||
43712 | var p; | ||
43713 | if (z === 0) | ||
43714 | continue; | ||
43715 | else if (z > 0) | ||
43716 | p = wnd[j][(z - 1) >> 1]; | ||
43717 | else if (z < 0) | ||
43718 | p = wnd[j][(-z - 1) >> 1].neg(); | ||
43719 | |||
43720 | if (p.type === 'affine') | ||
43721 | acc = acc.mixedAdd(p); | ||
43722 | else | ||
43723 | acc = acc.add(p); | ||
43724 | } | ||
43725 | } | ||
43726 | // Zeroify references | ||
43727 | for (var i = 0; i < len; i++) | ||
43728 | wnd[i] = null; | ||
43729 | |||
43730 | if (jacobianResult) | ||
43731 | return acc; | ||
43732 | else | ||
43733 | return acc.toP(); | ||
43734 | }; | ||
43735 | |||
43736 | function BasePoint(curve, type) { | ||
43737 | this.curve = curve; | ||
43738 | this.type = type; | ||
43739 | this.precomputed = null; | ||
43740 | } | ||
43741 | BaseCurve.BasePoint = BasePoint; | ||
43742 | |||
43743 | BasePoint.prototype.eq = function eq(/*other*/) { | ||
43744 | throw new Error('Not implemented'); | ||
43745 | }; | ||
43746 | |||
43747 | BasePoint.prototype.validate = function validate() { | ||
43748 | return this.curve.validate(this); | ||
43749 | }; | ||
43750 | |||
43751 | BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) { | ||
43752 | bytes = utils.toArray(bytes, enc); | ||
43753 | |||
43754 | var len = this.p.byteLength(); | ||
43755 | |||
43756 | // uncompressed, hybrid-odd, hybrid-even | ||
43757 | if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) && | ||
43758 | bytes.length - 1 === 2 * len) { | ||
43759 | if (bytes[0] === 0x06) | ||
43760 | assert(bytes[bytes.length - 1] % 2 === 0); | ||
43761 | else if (bytes[0] === 0x07) | ||
43762 | assert(bytes[bytes.length - 1] % 2 === 1); | ||
43763 | |||
43764 | var res = this.point(bytes.slice(1, 1 + len), | ||
43765 | bytes.slice(1 + len, 1 + 2 * len)); | ||
43766 | |||
43767 | return res; | ||
43768 | } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) && | ||
43769 | bytes.length - 1 === len) { | ||
43770 | return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03); | ||
43771 | } | ||
43772 | throw new Error('Unknown point format'); | ||
43773 | }; | ||
43774 | |||
43775 | BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) { | ||
43776 | return this.encode(enc, true); | ||
43777 | }; | ||
43778 | |||
43779 | BasePoint.prototype._encode = function _encode(compact) { | ||
43780 | var len = this.curve.p.byteLength(); | ||
43781 | var x = this.getX().toArray('be', len); | ||
43782 | |||
43783 | if (compact) | ||
43784 | return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x); | ||
43785 | |||
43786 | return [ 0x04 ].concat(x, this.getY().toArray('be', len)) ; | ||
43787 | }; | ||
43788 | |||
43789 | BasePoint.prototype.encode = function encode(enc, compact) { | ||
43790 | return utils.encode(this._encode(compact), enc); | ||
43791 | }; | ||
43792 | |||
43793 | BasePoint.prototype.precompute = function precompute(power) { | ||
43794 | if (this.precomputed) | ||
43795 | return this; | ||
43796 | |||
43797 | var precomputed = { | ||
43798 | doubles: null, | ||
43799 | naf: null, | ||
43800 | beta: null | ||
43801 | }; | ||
43802 | precomputed.naf = this._getNAFPoints(8); | ||
43803 | precomputed.doubles = this._getDoubles(4, power); | ||
43804 | precomputed.beta = this._getBeta(); | ||
43805 | this.precomputed = precomputed; | ||
43806 | |||
43807 | return this; | ||
43808 | }; | ||
43809 | |||
43810 | BasePoint.prototype._hasDoubles = function _hasDoubles(k) { | ||
43811 | if (!this.precomputed) | ||
43812 | return false; | ||
43813 | |||
43814 | var doubles = this.precomputed.doubles; | ||
43815 | if (!doubles) | ||
43816 | return false; | ||
43817 | |||
43818 | return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step); | ||
43819 | }; | ||
43820 | |||
43821 | BasePoint.prototype._getDoubles = function _getDoubles(step, power) { | ||
43822 | if (this.precomputed && this.precomputed.doubles) | ||
43823 | return this.precomputed.doubles; | ||
43824 | |||
43825 | var doubles = [ this ]; | ||
43826 | var acc = this; | ||
43827 | for (var i = 0; i < power; i += step) { | ||
43828 | for (var j = 0; j < step; j++) | ||
43829 | acc = acc.dbl(); | ||
43830 | doubles.push(acc); | ||
43831 | } | ||
43832 | return { | ||
43833 | step: step, | ||
43834 | points: doubles | ||
43835 | }; | ||
43836 | }; | ||
43837 | |||
43838 | BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) { | ||
43839 | if (this.precomputed && this.precomputed.naf) | ||
43840 | return this.precomputed.naf; | ||
43841 | |||
43842 | var res = [ this ]; | ||
43843 | var max = (1 << wnd) - 1; | ||
43844 | var dbl = max === 1 ? null : this.dbl(); | ||
43845 | for (var i = 1; i < max; i++) | ||
43846 | res[i] = res[i - 1].add(dbl); | ||
43847 | return { | ||
43848 | wnd: wnd, | ||
43849 | points: res | ||
43850 | }; | ||
43851 | }; | ||
43852 | |||
43853 | BasePoint.prototype._getBeta = function _getBeta() { | ||
43854 | return null; | ||
43855 | }; | ||
43856 | |||
43857 | BasePoint.prototype.dblp = function dblp(k) { | ||
43858 | var r = this; | ||
43859 | for (var i = 0; i < k; i++) | ||
43860 | r = r.dbl(); | ||
43861 | return r; | ||
43862 | }; | ||
43863 | |||
43864 | },{"../../elliptic":97,"bn.js":81}],99:[function(require,module,exports){ | ||
43865 | 'use strict'; | ||
43866 | |||
43867 | var curve = require('../curve'); | ||
43868 | var elliptic = require('../../elliptic'); | ||
43869 | var BN = require('bn.js'); | ||
43870 | var inherits = require('inherits'); | ||
43871 | var Base = curve.base; | ||
43872 | |||
43873 | var assert = elliptic.utils.assert; | ||
43874 | |||
43875 | function EdwardsCurve(conf) { | ||
43876 | // NOTE: Important as we are creating point in Base.call() | ||
43877 | this.twisted = (conf.a | 0) !== 1; | ||
43878 | this.mOneA = this.twisted && (conf.a | 0) === -1; | ||
43879 | this.extended = this.mOneA; | ||
43880 | |||
43881 | Base.call(this, 'edwards', conf); | ||
43882 | |||
43883 | this.a = new BN(conf.a, 16).umod(this.red.m); | ||
43884 | this.a = this.a.toRed(this.red); | ||
43885 | this.c = new BN(conf.c, 16).toRed(this.red); | ||
43886 | this.c2 = this.c.redSqr(); | ||
43887 | this.d = new BN(conf.d, 16).toRed(this.red); | ||
43888 | this.dd = this.d.redAdd(this.d); | ||
43889 | |||
43890 | assert(!this.twisted || this.c.fromRed().cmpn(1) === 0); | ||
43891 | this.oneC = (conf.c | 0) === 1; | ||
43892 | } | ||
43893 | inherits(EdwardsCurve, Base); | ||
43894 | module.exports = EdwardsCurve; | ||
43895 | |||
43896 | EdwardsCurve.prototype._mulA = function _mulA(num) { | ||
43897 | if (this.mOneA) | ||
43898 | return num.redNeg(); | ||
43899 | else | ||
43900 | return this.a.redMul(num); | ||
43901 | }; | ||
43902 | |||
43903 | EdwardsCurve.prototype._mulC = function _mulC(num) { | ||
43904 | if (this.oneC) | ||
43905 | return num; | ||
43906 | else | ||
43907 | return this.c.redMul(num); | ||
43908 | }; | ||
43909 | |||
43910 | // Just for compatibility with Short curve | ||
43911 | EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) { | ||
43912 | return this.point(x, y, z, t); | ||
43913 | }; | ||
43914 | |||
43915 | EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) { | ||
43916 | x = new BN(x, 16); | ||
43917 | if (!x.red) | ||
43918 | x = x.toRed(this.red); | ||
43919 | |||
43920 | var x2 = x.redSqr(); | ||
43921 | var rhs = this.c2.redSub(this.a.redMul(x2)); | ||
43922 | var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x2)); | ||
43923 | |||
43924 | var y2 = rhs.redMul(lhs.redInvm()); | ||
43925 | var y = y2.redSqrt(); | ||
43926 | if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) | ||
43927 | throw new Error('invalid point'); | ||
43928 | |||
43929 | var isOdd = y.fromRed().isOdd(); | ||
43930 | if (odd && !isOdd || !odd && isOdd) | ||
43931 | y = y.redNeg(); | ||
43932 | |||
43933 | return this.point(x, y); | ||
43934 | }; | ||
43935 | |||
43936 | EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) { | ||
43937 | y = new BN(y, 16); | ||
43938 | if (!y.red) | ||
43939 | y = y.toRed(this.red); | ||
43940 | |||
43941 | // x^2 = (y^2 - 1) / (d y^2 + 1) | ||
43942 | var y2 = y.redSqr(); | ||
43943 | var lhs = y2.redSub(this.one); | ||
43944 | var rhs = y2.redMul(this.d).redAdd(this.one); | ||
43945 | var x2 = lhs.redMul(rhs.redInvm()); | ||
43946 | |||
43947 | if (x2.cmp(this.zero) === 0) { | ||
43948 | if (odd) | ||
43949 | throw new Error('invalid point'); | ||
43950 | else | ||
43951 | return this.point(this.zero, y); | ||
43952 | } | ||
43953 | |||
43954 | var x = x2.redSqrt(); | ||
43955 | if (x.redSqr().redSub(x2).cmp(this.zero) !== 0) | ||
43956 | throw new Error('invalid point'); | ||
43957 | |||
43958 | if (x.isOdd() !== odd) | ||
43959 | x = x.redNeg(); | ||
43960 | |||
43961 | return this.point(x, y); | ||
43962 | }; | ||
43963 | |||
43964 | EdwardsCurve.prototype.validate = function validate(point) { | ||
43965 | if (point.isInfinity()) | ||
43966 | return true; | ||
43967 | |||
43968 | // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2) | ||
43969 | point.normalize(); | ||
43970 | |||
43971 | var x2 = point.x.redSqr(); | ||
43972 | var y2 = point.y.redSqr(); | ||
43973 | var lhs = x2.redMul(this.a).redAdd(y2); | ||
43974 | var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2))); | ||
43975 | |||
43976 | return lhs.cmp(rhs) === 0; | ||
43977 | }; | ||
43978 | |||
43979 | function Point(curve, x, y, z, t) { | ||
43980 | Base.BasePoint.call(this, curve, 'projective'); | ||
43981 | if (x === null && y === null && z === null) { | ||
43982 | this.x = this.curve.zero; | ||
43983 | this.y = this.curve.one; | ||
43984 | this.z = this.curve.one; | ||
43985 | this.t = this.curve.zero; | ||
43986 | this.zOne = true; | ||
43987 | } else { | ||
43988 | this.x = new BN(x, 16); | ||
43989 | this.y = new BN(y, 16); | ||
43990 | this.z = z ? new BN(z, 16) : this.curve.one; | ||
43991 | this.t = t && new BN(t, 16); | ||
43992 | if (!this.x.red) | ||
43993 | this.x = this.x.toRed(this.curve.red); | ||
43994 | if (!this.y.red) | ||
43995 | this.y = this.y.toRed(this.curve.red); | ||
43996 | if (!this.z.red) | ||
43997 | this.z = this.z.toRed(this.curve.red); | ||
43998 | if (this.t && !this.t.red) | ||
43999 | this.t = this.t.toRed(this.curve.red); | ||
44000 | this.zOne = this.z === this.curve.one; | ||
44001 | |||
44002 | // Use extended coordinates | ||
44003 | if (this.curve.extended && !this.t) { | ||
44004 | this.t = this.x.redMul(this.y); | ||
44005 | if (!this.zOne) | ||
44006 | this.t = this.t.redMul(this.z.redInvm()); | ||
44007 | } | ||
44008 | } | ||
44009 | } | ||
44010 | inherits(Point, Base.BasePoint); | ||
44011 | |||
44012 | EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) { | ||
44013 | return Point.fromJSON(this, obj); | ||
44014 | }; | ||
44015 | |||
44016 | EdwardsCurve.prototype.point = function point(x, y, z, t) { | ||
44017 | return new Point(this, x, y, z, t); | ||
44018 | }; | ||
44019 | |||
44020 | Point.fromJSON = function fromJSON(curve, obj) { | ||
44021 | return new Point(curve, obj[0], obj[1], obj[2]); | ||
44022 | }; | ||
44023 | |||
44024 | Point.prototype.inspect = function inspect() { | ||
44025 | if (this.isInfinity()) | ||
44026 | return '<EC Point Infinity>'; | ||
44027 | return '<EC Point x: ' + this.x.fromRed().toString(16, 2) + | ||
44028 | ' y: ' + this.y.fromRed().toString(16, 2) + | ||
44029 | ' z: ' + this.z.fromRed().toString(16, 2) + '>'; | ||
44030 | }; | ||
44031 | |||
44032 | Point.prototype.isInfinity = function isInfinity() { | ||
44033 | // XXX This code assumes that zero is always zero in red | ||
44034 | return this.x.cmpn(0) === 0 && | ||
44035 | this.y.cmp(this.z) === 0; | ||
44036 | }; | ||
44037 | |||
44038 | Point.prototype._extDbl = function _extDbl() { | ||
44039 | // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html | ||
44040 | // #doubling-dbl-2008-hwcd | ||
44041 | // 4M + 4S | ||
44042 | |||
44043 | // A = X1^2 | ||
44044 | var a = this.x.redSqr(); | ||
44045 | // B = Y1^2 | ||
44046 | var b = this.y.redSqr(); | ||
44047 | // C = 2 * Z1^2 | ||
44048 | var c = this.z.redSqr(); | ||
44049 | c = c.redIAdd(c); | ||
44050 | // D = a * A | ||
44051 | var d = this.curve._mulA(a); | ||
44052 | // E = (X1 + Y1)^2 - A - B | ||
44053 | var e = this.x.redAdd(this.y).redSqr().redISub(a).redISub(b); | ||
44054 | // G = D + B | ||
44055 | var g = d.redAdd(b); | ||
44056 | // F = G - C | ||
44057 | var f = g.redSub(c); | ||
44058 | // H = D - B | ||
44059 | var h = d.redSub(b); | ||
44060 | // X3 = E * F | ||
44061 | var nx = e.redMul(f); | ||
44062 | // Y3 = G * H | ||
44063 | var ny = g.redMul(h); | ||
44064 | // T3 = E * H | ||
44065 | var nt = e.redMul(h); | ||
44066 | // Z3 = F * G | ||
44067 | var nz = f.redMul(g); | ||
44068 | return this.curve.point(nx, ny, nz, nt); | ||
44069 | }; | ||
44070 | |||
44071 | Point.prototype._projDbl = function _projDbl() { | ||
44072 | // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html | ||
44073 | // #doubling-dbl-2008-bbjlp | ||
44074 | // #doubling-dbl-2007-bl | ||
44075 | // and others | ||
44076 | // Generally 3M + 4S or 2M + 4S | ||
44077 | |||
44078 | // B = (X1 + Y1)^2 | ||
44079 | var b = this.x.redAdd(this.y).redSqr(); | ||
44080 | // C = X1^2 | ||
44081 | var c = this.x.redSqr(); | ||
44082 | // D = Y1^2 | ||
44083 | var d = this.y.redSqr(); | ||
44084 | |||
44085 | var nx; | ||
44086 | var ny; | ||
44087 | var nz; | ||
44088 | if (this.curve.twisted) { | ||
44089 | // E = a * C | ||
44090 | var e = this.curve._mulA(c); | ||
44091 | // F = E + D | ||
44092 | var f = e.redAdd(d); | ||
44093 | if (this.zOne) { | ||
44094 | // X3 = (B - C - D) * (F - 2) | ||
44095 | nx = b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two)); | ||
44096 | // Y3 = F * (E - D) | ||
44097 | ny = f.redMul(e.redSub(d)); | ||
44098 | // Z3 = F^2 - 2 * F | ||
44099 | nz = f.redSqr().redSub(f).redSub(f); | ||
44100 | } else { | ||
44101 | // H = Z1^2 | ||
44102 | var h = this.z.redSqr(); | ||
44103 | // J = F - 2 * H | ||
44104 | var j = f.redSub(h).redISub(h); | ||
44105 | // X3 = (B-C-D)*J | ||
44106 | nx = b.redSub(c).redISub(d).redMul(j); | ||
44107 | // Y3 = F * (E - D) | ||
44108 | ny = f.redMul(e.redSub(d)); | ||
44109 | // Z3 = F * J | ||
44110 | nz = f.redMul(j); | ||
44111 | } | ||
44112 | } else { | ||
44113 | // E = C + D | ||
44114 | var e = c.redAdd(d); | ||
44115 | // H = (c * Z1)^2 | ||
44116 | var h = this.curve._mulC(this.c.redMul(this.z)).redSqr(); | ||
44117 | // J = E - 2 * H | ||
44118 | var j = e.redSub(h).redSub(h); | ||
44119 | // X3 = c * (B - E) * J | ||
44120 | nx = this.curve._mulC(b.redISub(e)).redMul(j); | ||
44121 | // Y3 = c * E * (C - D) | ||
44122 | ny = this.curve._mulC(e).redMul(c.redISub(d)); | ||
44123 | // Z3 = E * J | ||
44124 | nz = e.redMul(j); | ||
44125 | } | ||
44126 | return this.curve.point(nx, ny, nz); | ||
44127 | }; | ||
44128 | |||
44129 | Point.prototype.dbl = function dbl() { | ||
44130 | if (this.isInfinity()) | ||
44131 | return this; | ||
44132 | |||
44133 | // Double in extended coordinates | ||
44134 | if (this.curve.extended) | ||
44135 | return this._extDbl(); | ||
44136 | else | ||
44137 | return this._projDbl(); | ||
44138 | }; | ||
44139 | |||
44140 | Point.prototype._extAdd = function _extAdd(p) { | ||
44141 | // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html | ||
44142 | // #addition-add-2008-hwcd-3 | ||
44143 | // 8M | ||
44144 | |||
44145 | // A = (Y1 - X1) * (Y2 - X2) | ||
44146 | var a = this.y.redSub(this.x).redMul(p.y.redSub(p.x)); | ||
44147 | // B = (Y1 + X1) * (Y2 + X2) | ||
44148 | var b = this.y.redAdd(this.x).redMul(p.y.redAdd(p.x)); | ||
44149 | // C = T1 * k * T2 | ||
44150 | var c = this.t.redMul(this.curve.dd).redMul(p.t); | ||
44151 | // D = Z1 * 2 * Z2 | ||
44152 | var d = this.z.redMul(p.z.redAdd(p.z)); | ||
44153 | // E = B - A | ||
44154 | var e = b.redSub(a); | ||
44155 | // F = D - C | ||
44156 | var f = d.redSub(c); | ||
44157 | // G = D + C | ||
44158 | var g = d.redAdd(c); | ||
44159 | // H = B + A | ||
44160 | var h = b.redAdd(a); | ||
44161 | // X3 = E * F | ||
44162 | var nx = e.redMul(f); | ||
44163 | // Y3 = G * H | ||
44164 | var ny = g.redMul(h); | ||
44165 | // T3 = E * H | ||
44166 | var nt = e.redMul(h); | ||
44167 | // Z3 = F * G | ||
44168 | var nz = f.redMul(g); | ||
44169 | return this.curve.point(nx, ny, nz, nt); | ||
44170 | }; | ||
44171 | |||
44172 | Point.prototype._projAdd = function _projAdd(p) { | ||
44173 | // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html | ||
44174 | // #addition-add-2008-bbjlp | ||
44175 | // #addition-add-2007-bl | ||
44176 | // 10M + 1S | ||
44177 | |||
44178 | // A = Z1 * Z2 | ||
44179 | var a = this.z.redMul(p.z); | ||
44180 | // B = A^2 | ||
44181 | var b = a.redSqr(); | ||
44182 | // C = X1 * X2 | ||
44183 | var c = this.x.redMul(p.x); | ||
44184 | // D = Y1 * Y2 | ||
44185 | var d = this.y.redMul(p.y); | ||
44186 | // E = d * C * D | ||
44187 | var e = this.curve.d.redMul(c).redMul(d); | ||
44188 | // F = B - E | ||
44189 | var f = b.redSub(e); | ||
44190 | // G = B + E | ||
44191 | var g = b.redAdd(e); | ||
44192 | // X3 = A * F * ((X1 + Y1) * (X2 + Y2) - C - D) | ||
44193 | var tmp = this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d); | ||
44194 | var nx = a.redMul(f).redMul(tmp); | ||
44195 | var ny; | ||
44196 | var nz; | ||
44197 | if (this.curve.twisted) { | ||
44198 | // Y3 = A * G * (D - a * C) | ||
44199 | ny = a.redMul(g).redMul(d.redSub(this.curve._mulA(c))); | ||
44200 | // Z3 = F * G | ||
44201 | nz = f.redMul(g); | ||
44202 | } else { | ||
44203 | // Y3 = A * G * (D - C) | ||
44204 | ny = a.redMul(g).redMul(d.redSub(c)); | ||
44205 | // Z3 = c * F * G | ||
44206 | nz = this.curve._mulC(f).redMul(g); | ||
44207 | } | ||
44208 | return this.curve.point(nx, ny, nz); | ||
44209 | }; | ||
44210 | |||
44211 | Point.prototype.add = function add(p) { | ||
44212 | if (this.isInfinity()) | ||
44213 | return p; | ||
44214 | if (p.isInfinity()) | ||
44215 | return this; | ||
44216 | |||
44217 | if (this.curve.extended) | ||
44218 | return this._extAdd(p); | ||
44219 | else | ||
44220 | return this._projAdd(p); | ||
44221 | }; | ||
44222 | |||
44223 | Point.prototype.mul = function mul(k) { | ||
44224 | if (this._hasDoubles(k)) | ||
44225 | return this.curve._fixedNafMul(this, k); | ||
44226 | else | ||
44227 | return this.curve._wnafMul(this, k); | ||
44228 | }; | ||
44229 | |||
44230 | Point.prototype.mulAdd = function mulAdd(k1, p, k2) { | ||
44231 | return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false); | ||
44232 | }; | ||
44233 | |||
44234 | Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) { | ||
44235 | return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true); | ||
44236 | }; | ||
44237 | |||
44238 | Point.prototype.normalize = function normalize() { | ||
44239 | if (this.zOne) | ||
44240 | return this; | ||
44241 | |||
44242 | // Normalize coordinates | ||
44243 | var zi = this.z.redInvm(); | ||
44244 | this.x = this.x.redMul(zi); | ||
44245 | this.y = this.y.redMul(zi); | ||
44246 | if (this.t) | ||
44247 | this.t = this.t.redMul(zi); | ||
44248 | this.z = this.curve.one; | ||
44249 | this.zOne = true; | ||
44250 | return this; | ||
44251 | }; | ||
44252 | |||
44253 | Point.prototype.neg = function neg() { | ||
44254 | return this.curve.point(this.x.redNeg(), | ||
44255 | this.y, | ||
44256 | this.z, | ||
44257 | this.t && this.t.redNeg()); | ||
44258 | }; | ||
44259 | |||
44260 | Point.prototype.getX = function getX() { | ||
44261 | this.normalize(); | ||
44262 | return this.x.fromRed(); | ||
44263 | }; | ||
44264 | |||
44265 | Point.prototype.getY = function getY() { | ||
44266 | this.normalize(); | ||
44267 | return this.y.fromRed(); | ||
44268 | }; | ||
44269 | |||
44270 | Point.prototype.eq = function eq(other) { | ||
44271 | return this === other || | ||
44272 | this.getX().cmp(other.getX()) === 0 && | ||
44273 | this.getY().cmp(other.getY()) === 0; | ||
44274 | }; | ||
44275 | |||
44276 | Point.prototype.eqXToP = function eqXToP(x) { | ||
44277 | var rx = x.toRed(this.curve.red).redMul(this.z); | ||
44278 | if (this.x.cmp(rx) === 0) | ||
44279 | return true; | ||
44280 | |||
44281 | var xc = x.clone(); | ||
44282 | var t = this.curve.redN.redMul(this.z); | ||
44283 | for (;;) { | ||
44284 | xc.iadd(this.curve.n); | ||
44285 | if (xc.cmp(this.curve.p) >= 0) | ||
44286 | return false; | ||
44287 | |||
44288 | rx.redIAdd(t); | ||
44289 | if (this.x.cmp(rx) === 0) | ||
44290 | return true; | ||
44291 | } | ||
44292 | return false; | ||
44293 | }; | ||
44294 | |||
44295 | // Compatibility with BaseCurve | ||
44296 | Point.prototype.toP = Point.prototype.normalize; | ||
44297 | Point.prototype.mixedAdd = Point.prototype.add; | ||
44298 | |||
44299 | },{"../../elliptic":97,"../curve":100,"bn.js":81,"inherits":121}],100:[function(require,module,exports){ | ||
44300 | 'use strict'; | ||
44301 | |||
44302 | var curve = exports; | ||
44303 | |||
44304 | curve.base = require('./base'); | ||
44305 | curve.short = require('./short'); | ||
44306 | curve.mont = require('./mont'); | ||
44307 | curve.edwards = require('./edwards'); | ||
44308 | |||
44309 | },{"./base":98,"./edwards":99,"./mont":101,"./short":102}],101:[function(require,module,exports){ | ||
44310 | 'use strict'; | ||
44311 | |||
44312 | var curve = require('../curve'); | ||
44313 | var BN = require('bn.js'); | ||
44314 | var inherits = require('inherits'); | ||
44315 | var Base = curve.base; | ||
44316 | |||
44317 | var elliptic = require('../../elliptic'); | ||
44318 | var utils = elliptic.utils; | ||
44319 | |||
44320 | function MontCurve(conf) { | ||
44321 | Base.call(this, 'mont', conf); | ||
44322 | |||
44323 | this.a = new BN(conf.a, 16).toRed(this.red); | ||
44324 | this.b = new BN(conf.b, 16).toRed(this.red); | ||
44325 | this.i4 = new BN(4).toRed(this.red).redInvm(); | ||
44326 | this.two = new BN(2).toRed(this.red); | ||
44327 | this.a24 = this.i4.redMul(this.a.redAdd(this.two)); | ||
44328 | } | ||
44329 | inherits(MontCurve, Base); | ||
44330 | module.exports = MontCurve; | ||
44331 | |||
44332 | MontCurve.prototype.validate = function validate(point) { | ||
44333 | var x = point.normalize().x; | ||
44334 | var x2 = x.redSqr(); | ||
44335 | var rhs = x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x); | ||
44336 | var y = rhs.redSqrt(); | ||
44337 | |||
44338 | return y.redSqr().cmp(rhs) === 0; | ||
44339 | }; | ||
44340 | |||
44341 | function Point(curve, x, z) { | ||
44342 | Base.BasePoint.call(this, curve, 'projective'); | ||
44343 | if (x === null && z === null) { | ||
44344 | this.x = this.curve.one; | ||
44345 | this.z = this.curve.zero; | ||
44346 | } else { | ||
44347 | this.x = new BN(x, 16); | ||
44348 | this.z = new BN(z, 16); | ||
44349 | if (!this.x.red) | ||
44350 | this.x = this.x.toRed(this.curve.red); | ||
44351 | if (!this.z.red) | ||
44352 | this.z = this.z.toRed(this.curve.red); | ||
44353 | } | ||
44354 | } | ||
44355 | inherits(Point, Base.BasePoint); | ||
44356 | |||
44357 | MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) { | ||
44358 | return this.point(utils.toArray(bytes, enc), 1); | ||
44359 | }; | ||
44360 | |||
44361 | MontCurve.prototype.point = function point(x, z) { | ||
44362 | return new Point(this, x, z); | ||
44363 | }; | ||
44364 | |||
44365 | MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) { | ||
44366 | return Point.fromJSON(this, obj); | ||
44367 | }; | ||
44368 | |||
44369 | Point.prototype.precompute = function precompute() { | ||
44370 | // No-op | ||
44371 | }; | ||
44372 | |||
44373 | Point.prototype._encode = function _encode() { | ||
44374 | return this.getX().toArray('be', this.curve.p.byteLength()); | ||
44375 | }; | ||
44376 | |||
44377 | Point.fromJSON = function fromJSON(curve, obj) { | ||
44378 | return new Point(curve, obj[0], obj[1] || curve.one); | ||
44379 | }; | ||
44380 | |||
44381 | Point.prototype.inspect = function inspect() { | ||
44382 | if (this.isInfinity()) | ||
44383 | return '<EC Point Infinity>'; | ||
44384 | return '<EC Point x: ' + this.x.fromRed().toString(16, 2) + | ||
44385 | ' z: ' + this.z.fromRed().toString(16, 2) + '>'; | ||
44386 | }; | ||
44387 | |||
44388 | Point.prototype.isInfinity = function isInfinity() { | ||
44389 | // XXX This code assumes that zero is always zero in red | ||
44390 | return this.z.cmpn(0) === 0; | ||
44391 | }; | ||
44392 | |||
44393 | Point.prototype.dbl = function dbl() { | ||
44394 | // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3 | ||
44395 | // 2M + 2S + 4A | ||
44396 | |||
44397 | // A = X1 + Z1 | ||
44398 | var a = this.x.redAdd(this.z); | ||
44399 | // AA = A^2 | ||
44400 | var aa = a.redSqr(); | ||
44401 | // B = X1 - Z1 | ||
44402 | var b = this.x.redSub(this.z); | ||
44403 | // BB = B^2 | ||
44404 | var bb = b.redSqr(); | ||
44405 | // C = AA - BB | ||
44406 | var c = aa.redSub(bb); | ||
44407 | // X3 = AA * BB | ||
44408 | var nx = aa.redMul(bb); | ||
44409 | // Z3 = C * (BB + A24 * C) | ||
44410 | var nz = c.redMul(bb.redAdd(this.curve.a24.redMul(c))); | ||
44411 | return this.curve.point(nx, nz); | ||
44412 | }; | ||
44413 | |||
44414 | Point.prototype.add = function add() { | ||
44415 | throw new Error('Not supported on Montgomery curve'); | ||
44416 | }; | ||
44417 | |||
44418 | Point.prototype.diffAdd = function diffAdd(p, diff) { | ||
44419 | // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3 | ||
44420 | // 4M + 2S + 6A | ||
44421 | |||
44422 | // A = X2 + Z2 | ||
44423 | var a = this.x.redAdd(this.z); | ||
44424 | // B = X2 - Z2 | ||
44425 | var b = this.x.redSub(this.z); | ||
44426 | // C = X3 + Z3 | ||
44427 | var c = p.x.redAdd(p.z); | ||
44428 | // D = X3 - Z3 | ||
44429 | var d = p.x.redSub(p.z); | ||
44430 | // DA = D * A | ||
44431 | var da = d.redMul(a); | ||
44432 | // CB = C * B | ||
44433 | var cb = c.redMul(b); | ||
44434 | // X5 = Z1 * (DA + CB)^2 | ||
44435 | var nx = diff.z.redMul(da.redAdd(cb).redSqr()); | ||
44436 | // Z5 = X1 * (DA - CB)^2 | ||
44437 | var nz = diff.x.redMul(da.redISub(cb).redSqr()); | ||
44438 | return this.curve.point(nx, nz); | ||
44439 | }; | ||
44440 | |||
44441 | Point.prototype.mul = function mul(k) { | ||
44442 | var t = k.clone(); | ||
44443 | var a = this; // (N / 2) * Q + Q | ||
44444 | var b = this.curve.point(null, null); // (N / 2) * Q | ||
44445 | var c = this; // Q | ||
44446 | |||
44447 | for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1)) | ||
44448 | bits.push(t.andln(1)); | ||
44449 | |||
44450 | for (var i = bits.length - 1; i >= 0; i--) { | ||
44451 | if (bits[i] === 0) { | ||
44452 | // N * Q + Q = ((N / 2) * Q + Q)) + (N / 2) * Q | ||
44453 | a = a.diffAdd(b, c); | ||
44454 | // N * Q = 2 * ((N / 2) * Q + Q)) | ||
44455 | b = b.dbl(); | ||
44456 | } else { | ||
44457 | // N * Q = ((N / 2) * Q + Q) + ((N / 2) * Q) | ||
44458 | b = a.diffAdd(b, c); | ||
44459 | // N * Q + Q = 2 * ((N / 2) * Q + Q) | ||
44460 | a = a.dbl(); | ||
44461 | } | ||
44462 | } | ||
44463 | return b; | ||
44464 | }; | ||
44465 | |||
44466 | Point.prototype.mulAdd = function mulAdd() { | ||
44467 | throw new Error('Not supported on Montgomery curve'); | ||
44468 | }; | ||
44469 | |||
44470 | Point.prototype.jumlAdd = function jumlAdd() { | ||
44471 | throw new Error('Not supported on Montgomery curve'); | ||
44472 | }; | ||
44473 | |||
44474 | Point.prototype.eq = function eq(other) { | ||
44475 | return this.getX().cmp(other.getX()) === 0; | ||
44476 | }; | ||
44477 | |||
44478 | Point.prototype.normalize = function normalize() { | ||
44479 | this.x = this.x.redMul(this.z.redInvm()); | ||
44480 | this.z = this.curve.one; | ||
44481 | return this; | ||
44482 | }; | ||
44483 | |||
44484 | Point.prototype.getX = function getX() { | ||
44485 | // Normalize coordinates | ||
44486 | this.normalize(); | ||
44487 | |||
44488 | return this.x.fromRed(); | ||
44489 | }; | ||
44490 | |||
44491 | },{"../../elliptic":97,"../curve":100,"bn.js":81,"inherits":121}],102:[function(require,module,exports){ | ||
44492 | 'use strict'; | ||
44493 | |||
44494 | var curve = require('../curve'); | ||
44495 | var elliptic = require('../../elliptic'); | ||
44496 | var BN = require('bn.js'); | ||
44497 | var inherits = require('inherits'); | ||
44498 | var Base = curve.base; | ||
44499 | |||
44500 | var assert = elliptic.utils.assert; | ||
44501 | |||
44502 | function ShortCurve(conf) { | ||
44503 | Base.call(this, 'short', conf); | ||
44504 | |||
44505 | this.a = new BN(conf.a, 16).toRed(this.red); | ||
44506 | this.b = new BN(conf.b, 16).toRed(this.red); | ||
44507 | this.tinv = this.two.redInvm(); | ||
44508 | |||
44509 | this.zeroA = this.a.fromRed().cmpn(0) === 0; | ||
44510 | this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0; | ||
44511 | |||
44512 | // If the curve is endomorphic, precalculate beta and lambda | ||
44513 | this.endo = this._getEndomorphism(conf); | ||
44514 | this._endoWnafT1 = new Array(4); | ||
44515 | this._endoWnafT2 = new Array(4); | ||
44516 | } | ||
44517 | inherits(ShortCurve, Base); | ||
44518 | module.exports = ShortCurve; | ||
44519 | |||
44520 | ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) { | ||
44521 | // No efficient endomorphism | ||
44522 | if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1) | ||
44523 | return; | ||
44524 | |||
44525 | // Compute beta and lambda, that lambda * P = (beta * Px; Py) | ||
44526 | var beta; | ||
44527 | var lambda; | ||
44528 | if (conf.beta) { | ||
44529 | beta = new BN(conf.beta, 16).toRed(this.red); | ||
44530 | } else { | ||
44531 | var betas = this._getEndoRoots(this.p); | ||
44532 | // Choose the smallest beta | ||
44533 | beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1]; | ||
44534 | beta = beta.toRed(this.red); | ||
44535 | } | ||
44536 | if (conf.lambda) { | ||
44537 | lambda = new BN(conf.lambda, 16); | ||
44538 | } else { | ||
44539 | // Choose the lambda that is matching selected beta | ||
44540 | var lambdas = this._getEndoRoots(this.n); | ||
44541 | if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) { | ||
44542 | lambda = lambdas[0]; | ||
44543 | } else { | ||
44544 | lambda = lambdas[1]; | ||
44545 | assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0); | ||
44546 | } | ||
44547 | } | ||
44548 | |||
44549 | // Get basis vectors, used for balanced length-two representation | ||
44550 | var basis; | ||
44551 | if (conf.basis) { | ||
44552 | basis = conf.basis.map(function(vec) { | ||
44553 | return { | ||
44554 | a: new BN(vec.a, 16), | ||
44555 | b: new BN(vec.b, 16) | ||
44556 | }; | ||
44557 | }); | ||
44558 | } else { | ||
44559 | basis = this._getEndoBasis(lambda); | ||
44560 | } | ||
44561 | |||
44562 | return { | ||
44563 | beta: beta, | ||
44564 | lambda: lambda, | ||
44565 | basis: basis | ||
44566 | }; | ||
44567 | }; | ||
44568 | |||
44569 | ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) { | ||
44570 | // Find roots of for x^2 + x + 1 in F | ||
44571 | // Root = (-1 +- Sqrt(-3)) / 2 | ||
44572 | // | ||
44573 | var red = num === this.p ? this.red : BN.mont(num); | ||
44574 | var tinv = new BN(2).toRed(red).redInvm(); | ||
44575 | var ntinv = tinv.redNeg(); | ||
44576 | |||
44577 | var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv); | ||
44578 | |||
44579 | var l1 = ntinv.redAdd(s).fromRed(); | ||
44580 | var l2 = ntinv.redSub(s).fromRed(); | ||
44581 | return [ l1, l2 ]; | ||
44582 | }; | ||
44583 | |||
44584 | ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) { | ||
44585 | // aprxSqrt >= sqrt(this.n) | ||
44586 | var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2)); | ||
44587 | |||
44588 | // 3.74 | ||
44589 | // Run EGCD, until r(L + 1) < aprxSqrt | ||
44590 | var u = lambda; | ||
44591 | var v = this.n.clone(); | ||
44592 | var x1 = new BN(1); | ||
44593 | var y1 = new BN(0); | ||
44594 | var x2 = new BN(0); | ||
44595 | var y2 = new BN(1); | ||
44596 | |||
44597 | // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n) | ||
44598 | var a0; | ||
44599 | var b0; | ||
44600 | // First vector | ||
44601 | var a1; | ||
44602 | var b1; | ||
44603 | // Second vector | ||
44604 | var a2; | ||
44605 | var b2; | ||
44606 | |||
44607 | var prevR; | ||
44608 | var i = 0; | ||
44609 | var r; | ||
44610 | var x; | ||
44611 | while (u.cmpn(0) !== 0) { | ||
44612 | var q = v.div(u); | ||
44613 | r = v.sub(q.mul(u)); | ||
44614 | x = x2.sub(q.mul(x1)); | ||
44615 | var y = y2.sub(q.mul(y1)); | ||
44616 | |||
44617 | if (!a1 && r.cmp(aprxSqrt) < 0) { | ||
44618 | a0 = prevR.neg(); | ||
44619 | b0 = x1; | ||
44620 | a1 = r.neg(); | ||
44621 | b1 = x; | ||
44622 | } else if (a1 && ++i === 2) { | ||
44623 | break; | ||
44624 | } | ||
44625 | prevR = r; | ||
44626 | |||
44627 | v = u; | ||
44628 | u = r; | ||
44629 | x2 = x1; | ||
44630 | x1 = x; | ||
44631 | y2 = y1; | ||
44632 | y1 = y; | ||
44633 | } | ||
44634 | a2 = r.neg(); | ||
44635 | b2 = x; | ||
44636 | |||
44637 | var len1 = a1.sqr().add(b1.sqr()); | ||
44638 | var len2 = a2.sqr().add(b2.sqr()); | ||
44639 | if (len2.cmp(len1) >= 0) { | ||
44640 | a2 = a0; | ||
44641 | b2 = b0; | ||
44642 | } | ||
44643 | |||
44644 | // Normalize signs | ||
44645 | if (a1.negative) { | ||
44646 | a1 = a1.neg(); | ||
44647 | b1 = b1.neg(); | ||
44648 | } | ||
44649 | if (a2.negative) { | ||
44650 | a2 = a2.neg(); | ||
44651 | b2 = b2.neg(); | ||
44652 | } | ||
44653 | |||
44654 | return [ | ||
44655 | { a: a1, b: b1 }, | ||
44656 | { a: a2, b: b2 } | ||
44657 | ]; | ||
44658 | }; | ||
44659 | |||
44660 | ShortCurve.prototype._endoSplit = function _endoSplit(k) { | ||
44661 | var basis = this.endo.basis; | ||
44662 | var v1 = basis[0]; | ||
44663 | var v2 = basis[1]; | ||
44664 | |||
44665 | var c1 = v2.b.mul(k).divRound(this.n); | ||
44666 | var c2 = v1.b.neg().mul(k).divRound(this.n); | ||
44667 | |||
44668 | var p1 = c1.mul(v1.a); | ||
44669 | var p2 = c2.mul(v2.a); | ||
44670 | var q1 = c1.mul(v1.b); | ||
44671 | var q2 = c2.mul(v2.b); | ||
44672 | |||
44673 | // Calculate answer | ||
44674 | var k1 = k.sub(p1).sub(p2); | ||
44675 | var k2 = q1.add(q2).neg(); | ||
44676 | return { k1: k1, k2: k2 }; | ||
44677 | }; | ||
44678 | |||
44679 | ShortCurve.prototype.pointFromX = function pointFromX(x, odd) { | ||
44680 | x = new BN(x, 16); | ||
44681 | if (!x.red) | ||
44682 | x = x.toRed(this.red); | ||
44683 | |||
44684 | var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b); | ||
44685 | var y = y2.redSqrt(); | ||
44686 | if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) | ||
44687 | throw new Error('invalid point'); | ||
44688 | |||
44689 | // XXX Is there any way to tell if the number is odd without converting it | ||
44690 | // to non-red form? | ||
44691 | var isOdd = y.fromRed().isOdd(); | ||
44692 | if (odd && !isOdd || !odd && isOdd) | ||
44693 | y = y.redNeg(); | ||
44694 | |||
44695 | return this.point(x, y); | ||
44696 | }; | ||
44697 | |||
44698 | ShortCurve.prototype.validate = function validate(point) { | ||
44699 | if (point.inf) | ||
44700 | return true; | ||
44701 | |||
44702 | var x = point.x; | ||
44703 | var y = point.y; | ||
44704 | |||
44705 | var ax = this.a.redMul(x); | ||
44706 | var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b); | ||
44707 | return y.redSqr().redISub(rhs).cmpn(0) === 0; | ||
44708 | }; | ||
44709 | |||
44710 | ShortCurve.prototype._endoWnafMulAdd = | ||
44711 | function _endoWnafMulAdd(points, coeffs, jacobianResult) { | ||
44712 | var npoints = this._endoWnafT1; | ||
44713 | var ncoeffs = this._endoWnafT2; | ||
44714 | for (var i = 0; i < points.length; i++) { | ||
44715 | var split = this._endoSplit(coeffs[i]); | ||
44716 | var p = points[i]; | ||
44717 | var beta = p._getBeta(); | ||
44718 | |||
44719 | if (split.k1.negative) { | ||
44720 | split.k1.ineg(); | ||
44721 | p = p.neg(true); | ||
44722 | } | ||
44723 | if (split.k2.negative) { | ||
44724 | split.k2.ineg(); | ||
44725 | beta = beta.neg(true); | ||
44726 | } | ||
44727 | |||
44728 | npoints[i * 2] = p; | ||
44729 | npoints[i * 2 + 1] = beta; | ||
44730 | ncoeffs[i * 2] = split.k1; | ||
44731 | ncoeffs[i * 2 + 1] = split.k2; | ||
44732 | } | ||
44733 | var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult); | ||
44734 | |||
44735 | // Clean-up references to points and coefficients | ||
44736 | for (var j = 0; j < i * 2; j++) { | ||
44737 | npoints[j] = null; | ||
44738 | ncoeffs[j] = null; | ||
44739 | } | ||
44740 | return res; | ||
44741 | }; | ||
44742 | |||
44743 | function Point(curve, x, y, isRed) { | ||
44744 | Base.BasePoint.call(this, curve, 'affine'); | ||
44745 | if (x === null && y === null) { | ||
44746 | this.x = null; | ||
44747 | this.y = null; | ||
44748 | this.inf = true; | ||
44749 | } else { | ||
44750 | this.x = new BN(x, 16); | ||
44751 | this.y = new BN(y, 16); | ||
44752 | // Force redgomery representation when loading from JSON | ||
44753 | if (isRed) { | ||
44754 | this.x.forceRed(this.curve.red); | ||
44755 | this.y.forceRed(this.curve.red); | ||
44756 | } | ||
44757 | if (!this.x.red) | ||
44758 | this.x = this.x.toRed(this.curve.red); | ||
44759 | if (!this.y.red) | ||
44760 | this.y = this.y.toRed(this.curve.red); | ||
44761 | this.inf = false; | ||
44762 | } | ||
44763 | } | ||
44764 | inherits(Point, Base.BasePoint); | ||
44765 | |||
44766 | ShortCurve.prototype.point = function point(x, y, isRed) { | ||
44767 | return new Point(this, x, y, isRed); | ||
44768 | }; | ||
44769 | |||
44770 | ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) { | ||
44771 | return Point.fromJSON(this, obj, red); | ||
44772 | }; | ||
44773 | |||
44774 | Point.prototype._getBeta = function _getBeta() { | ||
44775 | if (!this.curve.endo) | ||
44776 | return; | ||
44777 | |||
44778 | var pre = this.precomputed; | ||
44779 | if (pre && pre.beta) | ||
44780 | return pre.beta; | ||
44781 | |||
44782 | var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); | ||
44783 | if (pre) { | ||
44784 | var curve = this.curve; | ||
44785 | var endoMul = function(p) { | ||
44786 | return curve.point(p.x.redMul(curve.endo.beta), p.y); | ||
44787 | }; | ||
44788 | pre.beta = beta; | ||
44789 | beta.precomputed = { | ||
44790 | beta: null, | ||
44791 | naf: pre.naf && { | ||
44792 | wnd: pre.naf.wnd, | ||
44793 | points: pre.naf.points.map(endoMul) | ||
44794 | }, | ||
44795 | doubles: pre.doubles && { | ||
44796 | step: pre.doubles.step, | ||
44797 | points: pre.doubles.points.map(endoMul) | ||
44798 | } | ||
44799 | }; | ||
44800 | } | ||
44801 | return beta; | ||
44802 | }; | ||
44803 | |||
44804 | Point.prototype.toJSON = function toJSON() { | ||
44805 | if (!this.precomputed) | ||
44806 | return [ this.x, this.y ]; | ||
44807 | |||
44808 | return [ this.x, this.y, this.precomputed && { | ||
44809 | doubles: this.precomputed.doubles && { | ||
44810 | step: this.precomputed.doubles.step, | ||
44811 | points: this.precomputed.doubles.points.slice(1) | ||
44812 | }, | ||
44813 | naf: this.precomputed.naf && { | ||
44814 | wnd: this.precomputed.naf.wnd, | ||
44815 | points: this.precomputed.naf.points.slice(1) | ||
44816 | } | ||
44817 | } ]; | ||
44818 | }; | ||
44819 | |||
44820 | Point.fromJSON = function fromJSON(curve, obj, red) { | ||
44821 | if (typeof obj === 'string') | ||
44822 | obj = JSON.parse(obj); | ||
44823 | var res = curve.point(obj[0], obj[1], red); | ||
44824 | if (!obj[2]) | ||
44825 | return res; | ||
44826 | |||
44827 | function obj2point(obj) { | ||
44828 | return curve.point(obj[0], obj[1], red); | ||
44829 | } | ||
44830 | |||
44831 | var pre = obj[2]; | ||
44832 | res.precomputed = { | ||
44833 | beta: null, | ||
44834 | doubles: pre.doubles && { | ||
44835 | step: pre.doubles.step, | ||
44836 | points: [ res ].concat(pre.doubles.points.map(obj2point)) | ||
44837 | }, | ||
44838 | naf: pre.naf && { | ||
44839 | wnd: pre.naf.wnd, | ||
44840 | points: [ res ].concat(pre.naf.points.map(obj2point)) | ||
44841 | } | ||
44842 | }; | ||
44843 | return res; | ||
44844 | }; | ||
44845 | |||
44846 | Point.prototype.inspect = function inspect() { | ||
44847 | if (this.isInfinity()) | ||
44848 | return '<EC Point Infinity>'; | ||
44849 | return '<EC Point x: ' + this.x.fromRed().toString(16, 2) + | ||
44850 | ' y: ' + this.y.fromRed().toString(16, 2) + '>'; | ||
44851 | }; | ||
44852 | |||
44853 | Point.prototype.isInfinity = function isInfinity() { | ||
44854 | return this.inf; | ||
44855 | }; | ||
44856 | |||
44857 | Point.prototype.add = function add(p) { | ||
44858 | // O + P = P | ||
44859 | if (this.inf) | ||
44860 | return p; | ||
44861 | |||
44862 | // P + O = P | ||
44863 | if (p.inf) | ||
44864 | return this; | ||
44865 | |||
44866 | // P + P = 2P | ||
44867 | if (this.eq(p)) | ||
44868 | return this.dbl(); | ||
44869 | |||
44870 | // P + (-P) = O | ||
44871 | if (this.neg().eq(p)) | ||
44872 | return this.curve.point(null, null); | ||
44873 | |||
44874 | // P + Q = O | ||
44875 | if (this.x.cmp(p.x) === 0) | ||
44876 | return this.curve.point(null, null); | ||
44877 | |||
44878 | var c = this.y.redSub(p.y); | ||
44879 | if (c.cmpn(0) !== 0) | ||
44880 | c = c.redMul(this.x.redSub(p.x).redInvm()); | ||
44881 | var nx = c.redSqr().redISub(this.x).redISub(p.x); | ||
44882 | var ny = c.redMul(this.x.redSub(nx)).redISub(this.y); | ||
44883 | return this.curve.point(nx, ny); | ||
44884 | }; | ||
44885 | |||
44886 | Point.prototype.dbl = function dbl() { | ||
44887 | if (this.inf) | ||
44888 | return this; | ||
44889 | |||
44890 | // 2P = O | ||
44891 | var ys1 = this.y.redAdd(this.y); | ||
44892 | if (ys1.cmpn(0) === 0) | ||
44893 | return this.curve.point(null, null); | ||
44894 | |||
44895 | var a = this.curve.a; | ||
44896 | |||
44897 | var x2 = this.x.redSqr(); | ||
44898 | var dyinv = ys1.redInvm(); | ||
44899 | var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv); | ||
44900 | |||
44901 | var nx = c.redSqr().redISub(this.x.redAdd(this.x)); | ||
44902 | var ny = c.redMul(this.x.redSub(nx)).redISub(this.y); | ||
44903 | return this.curve.point(nx, ny); | ||
44904 | }; | ||
44905 | |||
44906 | Point.prototype.getX = function getX() { | ||
44907 | return this.x.fromRed(); | ||
44908 | }; | ||
44909 | |||
44910 | Point.prototype.getY = function getY() { | ||
44911 | return this.y.fromRed(); | ||
44912 | }; | ||
44913 | |||
44914 | Point.prototype.mul = function mul(k) { | ||
44915 | k = new BN(k, 16); | ||
44916 | |||
44917 | if (this._hasDoubles(k)) | ||
44918 | return this.curve._fixedNafMul(this, k); | ||
44919 | else if (this.curve.endo) | ||
44920 | return this.curve._endoWnafMulAdd([ this ], [ k ]); | ||
44921 | else | ||
44922 | return this.curve._wnafMul(this, k); | ||
44923 | }; | ||
44924 | |||
44925 | Point.prototype.mulAdd = function mulAdd(k1, p2, k2) { | ||
44926 | var points = [ this, p2 ]; | ||
44927 | var coeffs = [ k1, k2 ]; | ||
44928 | if (this.curve.endo) | ||
44929 | return this.curve._endoWnafMulAdd(points, coeffs); | ||
44930 | else | ||
44931 | return this.curve._wnafMulAdd(1, points, coeffs, 2); | ||
44932 | }; | ||
44933 | |||
44934 | Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) { | ||
44935 | var points = [ this, p2 ]; | ||
44936 | var coeffs = [ k1, k2 ]; | ||
44937 | if (this.curve.endo) | ||
44938 | return this.curve._endoWnafMulAdd(points, coeffs, true); | ||
44939 | else | ||
44940 | return this.curve._wnafMulAdd(1, points, coeffs, 2, true); | ||
44941 | }; | ||
44942 | |||
44943 | Point.prototype.eq = function eq(p) { | ||
44944 | return this === p || | ||
44945 | this.inf === p.inf && | ||
44946 | (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0); | ||
44947 | }; | ||
44948 | |||
44949 | Point.prototype.neg = function neg(_precompute) { | ||
44950 | if (this.inf) | ||
44951 | return this; | ||
44952 | |||
44953 | var res = this.curve.point(this.x, this.y.redNeg()); | ||
44954 | if (_precompute && this.precomputed) { | ||
44955 | var pre = this.precomputed; | ||
44956 | var negate = function(p) { | ||
44957 | return p.neg(); | ||
44958 | }; | ||
44959 | res.precomputed = { | ||
44960 | naf: pre.naf && { | ||
44961 | wnd: pre.naf.wnd, | ||
44962 | points: pre.naf.points.map(negate) | ||
44963 | }, | ||
44964 | doubles: pre.doubles && { | ||
44965 | step: pre.doubles.step, | ||
44966 | points: pre.doubles.points.map(negate) | ||
44967 | } | ||
44968 | }; | ||
44969 | } | ||
44970 | return res; | ||
44971 | }; | ||
44972 | |||
44973 | Point.prototype.toJ = function toJ() { | ||
44974 | if (this.inf) | ||
44975 | return this.curve.jpoint(null, null, null); | ||
44976 | |||
44977 | var res = this.curve.jpoint(this.x, this.y, this.curve.one); | ||
44978 | return res; | ||
44979 | }; | ||
44980 | |||
44981 | function JPoint(curve, x, y, z) { | ||
44982 | Base.BasePoint.call(this, curve, 'jacobian'); | ||
44983 | if (x === null && y === null && z === null) { | ||
44984 | this.x = this.curve.one; | ||
44985 | this.y = this.curve.one; | ||
44986 | this.z = new BN(0); | ||
44987 | } else { | ||
44988 | this.x = new BN(x, 16); | ||
44989 | this.y = new BN(y, 16); | ||
44990 | this.z = new BN(z, 16); | ||
44991 | } | ||
44992 | if (!this.x.red) | ||
44993 | this.x = this.x.toRed(this.curve.red); | ||
44994 | if (!this.y.red) | ||
44995 | this.y = this.y.toRed(this.curve.red); | ||
44996 | if (!this.z.red) | ||
44997 | this.z = this.z.toRed(this.curve.red); | ||
44998 | |||
44999 | this.zOne = this.z === this.curve.one; | ||
45000 | } | ||
45001 | inherits(JPoint, Base.BasePoint); | ||
45002 | |||
45003 | ShortCurve.prototype.jpoint = function jpoint(x, y, z) { | ||
45004 | return new JPoint(this, x, y, z); | ||
45005 | }; | ||
45006 | |||
45007 | JPoint.prototype.toP = function toP() { | ||
45008 | if (this.isInfinity()) | ||
45009 | return this.curve.point(null, null); | ||
45010 | |||
45011 | var zinv = this.z.redInvm(); | ||
45012 | var zinv2 = zinv.redSqr(); | ||
45013 | var ax = this.x.redMul(zinv2); | ||
45014 | var ay = this.y.redMul(zinv2).redMul(zinv); | ||
45015 | |||
45016 | return this.curve.point(ax, ay); | ||
45017 | }; | ||
45018 | |||
45019 | JPoint.prototype.neg = function neg() { | ||
45020 | return this.curve.jpoint(this.x, this.y.redNeg(), this.z); | ||
45021 | }; | ||
45022 | |||
45023 | JPoint.prototype.add = function add(p) { | ||
45024 | // O + P = P | ||
45025 | if (this.isInfinity()) | ||
45026 | return p; | ||
45027 | |||
45028 | // P + O = P | ||
45029 | if (p.isInfinity()) | ||
45030 | return this; | ||
45031 | |||
45032 | // 12M + 4S + 7A | ||
45033 | var pz2 = p.z.redSqr(); | ||
45034 | var z2 = this.z.redSqr(); | ||
45035 | var u1 = this.x.redMul(pz2); | ||
45036 | var u2 = p.x.redMul(z2); | ||
45037 | var s1 = this.y.redMul(pz2.redMul(p.z)); | ||
45038 | var s2 = p.y.redMul(z2.redMul(this.z)); | ||
45039 | |||
45040 | var h = u1.redSub(u2); | ||
45041 | var r = s1.redSub(s2); | ||
45042 | if (h.cmpn(0) === 0) { | ||
45043 | if (r.cmpn(0) !== 0) | ||
45044 | return this.curve.jpoint(null, null, null); | ||
45045 | else | ||
45046 | return this.dbl(); | ||
45047 | } | ||
45048 | |||
45049 | var h2 = h.redSqr(); | ||
45050 | var h3 = h2.redMul(h); | ||
45051 | var v = u1.redMul(h2); | ||
45052 | |||
45053 | var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v); | ||
45054 | var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)); | ||
45055 | var nz = this.z.redMul(p.z).redMul(h); | ||
45056 | |||
45057 | return this.curve.jpoint(nx, ny, nz); | ||
45058 | }; | ||
45059 | |||
45060 | JPoint.prototype.mixedAdd = function mixedAdd(p) { | ||
45061 | // O + P = P | ||
45062 | if (this.isInfinity()) | ||
45063 | return p.toJ(); | ||
45064 | |||
45065 | // P + O = P | ||
45066 | if (p.isInfinity()) | ||
45067 | return this; | ||
45068 | |||
45069 | // 8M + 3S + 7A | ||
45070 | var z2 = this.z.redSqr(); | ||
45071 | var u1 = this.x; | ||
45072 | var u2 = p.x.redMul(z2); | ||
45073 | var s1 = this.y; | ||
45074 | var s2 = p.y.redMul(z2).redMul(this.z); | ||
45075 | |||
45076 | var h = u1.redSub(u2); | ||
45077 | var r = s1.redSub(s2); | ||
45078 | if (h.cmpn(0) === 0) { | ||
45079 | if (r.cmpn(0) !== 0) | ||
45080 | return this.curve.jpoint(null, null, null); | ||
45081 | else | ||
45082 | return this.dbl(); | ||
45083 | } | ||
45084 | |||
45085 | var h2 = h.redSqr(); | ||
45086 | var h3 = h2.redMul(h); | ||
45087 | var v = u1.redMul(h2); | ||
45088 | |||
45089 | var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v); | ||
45090 | var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)); | ||
45091 | var nz = this.z.redMul(h); | ||
45092 | |||
45093 | return this.curve.jpoint(nx, ny, nz); | ||
45094 | }; | ||
45095 | |||
45096 | JPoint.prototype.dblp = function dblp(pow) { | ||
45097 | if (pow === 0) | ||
45098 | return this; | ||
45099 | if (this.isInfinity()) | ||
45100 | return this; | ||
45101 | if (!pow) | ||
45102 | return this.dbl(); | ||
45103 | |||
45104 | if (this.curve.zeroA || this.curve.threeA) { | ||
45105 | var r = this; | ||
45106 | for (var i = 0; i < pow; i++) | ||
45107 | r = r.dbl(); | ||
45108 | return r; | ||
45109 | } | ||
45110 | |||
45111 | // 1M + 2S + 1A + N * (4S + 5M + 8A) | ||
45112 | // N = 1 => 6M + 6S + 9A | ||
45113 | var a = this.curve.a; | ||
45114 | var tinv = this.curve.tinv; | ||
45115 | |||
45116 | var jx = this.x; | ||
45117 | var jy = this.y; | ||
45118 | var jz = this.z; | ||
45119 | var jz4 = jz.redSqr().redSqr(); | ||
45120 | |||
45121 | // Reuse results | ||
45122 | var jyd = jy.redAdd(jy); | ||
45123 | for (var i = 0; i < pow; i++) { | ||
45124 | var jx2 = jx.redSqr(); | ||
45125 | var jyd2 = jyd.redSqr(); | ||
45126 | var jyd4 = jyd2.redSqr(); | ||
45127 | var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); | ||
45128 | |||
45129 | var t1 = jx.redMul(jyd2); | ||
45130 | var nx = c.redSqr().redISub(t1.redAdd(t1)); | ||
45131 | var t2 = t1.redISub(nx); | ||
45132 | var dny = c.redMul(t2); | ||
45133 | dny = dny.redIAdd(dny).redISub(jyd4); | ||
45134 | var nz = jyd.redMul(jz); | ||
45135 | if (i + 1 < pow) | ||
45136 | jz4 = jz4.redMul(jyd4); | ||
45137 | |||
45138 | jx = nx; | ||
45139 | jz = nz; | ||
45140 | jyd = dny; | ||
45141 | } | ||
45142 | |||
45143 | return this.curve.jpoint(jx, jyd.redMul(tinv), jz); | ||
45144 | }; | ||
45145 | |||
45146 | JPoint.prototype.dbl = function dbl() { | ||
45147 | if (this.isInfinity()) | ||
45148 | return this; | ||
45149 | |||
45150 | if (this.curve.zeroA) | ||
45151 | return this._zeroDbl(); | ||
45152 | else if (this.curve.threeA) | ||
45153 | return this._threeDbl(); | ||
45154 | else | ||
45155 | return this._dbl(); | ||
45156 | }; | ||
45157 | |||
45158 | JPoint.prototype._zeroDbl = function _zeroDbl() { | ||
45159 | var nx; | ||
45160 | var ny; | ||
45161 | var nz; | ||
45162 | // Z = 1 | ||
45163 | if (this.zOne) { | ||
45164 | // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html | ||
45165 | // #doubling-mdbl-2007-bl | ||
45166 | // 1M + 5S + 14A | ||
45167 | |||
45168 | // XX = X1^2 | ||
45169 | var xx = this.x.redSqr(); | ||
45170 | // YY = Y1^2 | ||
45171 | var yy = this.y.redSqr(); | ||
45172 | // YYYY = YY^2 | ||
45173 | var yyyy = yy.redSqr(); | ||
45174 | // S = 2 * ((X1 + YY)^2 - XX - YYYY) | ||
45175 | var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); | ||
45176 | s = s.redIAdd(s); | ||
45177 | // M = 3 * XX + a; a = 0 | ||
45178 | var m = xx.redAdd(xx).redIAdd(xx); | ||
45179 | // T = M ^ 2 - 2*S | ||
45180 | var t = m.redSqr().redISub(s).redISub(s); | ||
45181 | |||
45182 | // 8 * YYYY | ||
45183 | var yyyy8 = yyyy.redIAdd(yyyy); | ||
45184 | yyyy8 = yyyy8.redIAdd(yyyy8); | ||
45185 | yyyy8 = yyyy8.redIAdd(yyyy8); | ||
45186 | |||
45187 | // X3 = T | ||
45188 | nx = t; | ||
45189 | // Y3 = M * (S - T) - 8 * YYYY | ||
45190 | ny = m.redMul(s.redISub(t)).redISub(yyyy8); | ||
45191 | // Z3 = 2*Y1 | ||
45192 | nz = this.y.redAdd(this.y); | ||
45193 | } else { | ||
45194 | // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html | ||
45195 | // #doubling-dbl-2009-l | ||
45196 | // 2M + 5S + 13A | ||
45197 | |||
45198 | // A = X1^2 | ||
45199 | var a = this.x.redSqr(); | ||
45200 | // B = Y1^2 | ||
45201 | var b = this.y.redSqr(); | ||
45202 | // C = B^2 | ||
45203 | var c = b.redSqr(); | ||
45204 | // D = 2 * ((X1 + B)^2 - A - C) | ||
45205 | var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c); | ||
45206 | d = d.redIAdd(d); | ||
45207 | // E = 3 * A | ||
45208 | var e = a.redAdd(a).redIAdd(a); | ||
45209 | // F = E^2 | ||
45210 | var f = e.redSqr(); | ||
45211 | |||
45212 | // 8 * C | ||
45213 | var c8 = c.redIAdd(c); | ||
45214 | c8 = c8.redIAdd(c8); | ||
45215 | c8 = c8.redIAdd(c8); | ||
45216 | |||
45217 | // X3 = F - 2 * D | ||
45218 | nx = f.redISub(d).redISub(d); | ||
45219 | // Y3 = E * (D - X3) - 8 * C | ||
45220 | ny = e.redMul(d.redISub(nx)).redISub(c8); | ||
45221 | // Z3 = 2 * Y1 * Z1 | ||
45222 | nz = this.y.redMul(this.z); | ||
45223 | nz = nz.redIAdd(nz); | ||
45224 | } | ||
45225 | |||
45226 | return this.curve.jpoint(nx, ny, nz); | ||
45227 | }; | ||
45228 | |||
45229 | JPoint.prototype._threeDbl = function _threeDbl() { | ||
45230 | var nx; | ||
45231 | var ny; | ||
45232 | var nz; | ||
45233 | // Z = 1 | ||
45234 | if (this.zOne) { | ||
45235 | // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html | ||
45236 | // #doubling-mdbl-2007-bl | ||
45237 | // 1M + 5S + 15A | ||
45238 | |||
45239 | // XX = X1^2 | ||
45240 | var xx = this.x.redSqr(); | ||
45241 | // YY = Y1^2 | ||
45242 | var yy = this.y.redSqr(); | ||
45243 | // YYYY = YY^2 | ||
45244 | var yyyy = yy.redSqr(); | ||
45245 | // S = 2 * ((X1 + YY)^2 - XX - YYYY) | ||
45246 | var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); | ||
45247 | s = s.redIAdd(s); | ||
45248 | // M = 3 * XX + a | ||
45249 | var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a); | ||
45250 | // T = M^2 - 2 * S | ||
45251 | var t = m.redSqr().redISub(s).redISub(s); | ||
45252 | // X3 = T | ||
45253 | nx = t; | ||
45254 | // Y3 = M * (S - T) - 8 * YYYY | ||
45255 | var yyyy8 = yyyy.redIAdd(yyyy); | ||
45256 | yyyy8 = yyyy8.redIAdd(yyyy8); | ||
45257 | yyyy8 = yyyy8.redIAdd(yyyy8); | ||
45258 | ny = m.redMul(s.redISub(t)).redISub(yyyy8); | ||
45259 | // Z3 = 2 * Y1 | ||
45260 | nz = this.y.redAdd(this.y); | ||
45261 | } else { | ||
45262 | // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b | ||
45263 | // 3M + 5S | ||
45264 | |||
45265 | // delta = Z1^2 | ||
45266 | var delta = this.z.redSqr(); | ||
45267 | // gamma = Y1^2 | ||
45268 | var gamma = this.y.redSqr(); | ||
45269 | // beta = X1 * gamma | ||
45270 | var beta = this.x.redMul(gamma); | ||
45271 | // alpha = 3 * (X1 - delta) * (X1 + delta) | ||
45272 | var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta)); | ||
45273 | alpha = alpha.redAdd(alpha).redIAdd(alpha); | ||
45274 | // X3 = alpha^2 - 8 * beta | ||
45275 | var beta4 = beta.redIAdd(beta); | ||
45276 | beta4 = beta4.redIAdd(beta4); | ||
45277 | var beta8 = beta4.redAdd(beta4); | ||
45278 | nx = alpha.redSqr().redISub(beta8); | ||
45279 | // Z3 = (Y1 + Z1)^2 - gamma - delta | ||
45280 | nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta); | ||
45281 | // Y3 = alpha * (4 * beta - X3) - 8 * gamma^2 | ||
45282 | var ggamma8 = gamma.redSqr(); | ||
45283 | ggamma8 = ggamma8.redIAdd(ggamma8); | ||
45284 | ggamma8 = ggamma8.redIAdd(ggamma8); | ||
45285 | ggamma8 = ggamma8.redIAdd(ggamma8); | ||
45286 | ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8); | ||
45287 | } | ||
45288 | |||
45289 | return this.curve.jpoint(nx, ny, nz); | ||
45290 | }; | ||
45291 | |||
45292 | JPoint.prototype._dbl = function _dbl() { | ||
45293 | var a = this.curve.a; | ||
45294 | |||
45295 | // 4M + 6S + 10A | ||
45296 | var jx = this.x; | ||
45297 | var jy = this.y; | ||
45298 | var jz = this.z; | ||
45299 | var jz4 = jz.redSqr().redSqr(); | ||
45300 | |||
45301 | var jx2 = jx.redSqr(); | ||
45302 | var jy2 = jy.redSqr(); | ||
45303 | |||
45304 | var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); | ||
45305 | |||
45306 | var jxd4 = jx.redAdd(jx); | ||
45307 | jxd4 = jxd4.redIAdd(jxd4); | ||
45308 | var t1 = jxd4.redMul(jy2); | ||
45309 | var nx = c.redSqr().redISub(t1.redAdd(t1)); | ||
45310 | var t2 = t1.redISub(nx); | ||
45311 | |||
45312 | var jyd8 = jy2.redSqr(); | ||
45313 | jyd8 = jyd8.redIAdd(jyd8); | ||
45314 | jyd8 = jyd8.redIAdd(jyd8); | ||
45315 | jyd8 = jyd8.redIAdd(jyd8); | ||
45316 | var ny = c.redMul(t2).redISub(jyd8); | ||
45317 | var nz = jy.redAdd(jy).redMul(jz); | ||
45318 | |||
45319 | return this.curve.jpoint(nx, ny, nz); | ||
45320 | }; | ||
45321 | |||
45322 | JPoint.prototype.trpl = function trpl() { | ||
45323 | if (!this.curve.zeroA) | ||
45324 | return this.dbl().add(this); | ||
45325 | |||
45326 | // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl | ||
45327 | // 5M + 10S + ... | ||
45328 | |||
45329 | // XX = X1^2 | ||
45330 | var xx = this.x.redSqr(); | ||
45331 | // YY = Y1^2 | ||
45332 | var yy = this.y.redSqr(); | ||
45333 | // ZZ = Z1^2 | ||
45334 | var zz = this.z.redSqr(); | ||
45335 | // YYYY = YY^2 | ||
45336 | var yyyy = yy.redSqr(); | ||
45337 | // M = 3 * XX + a * ZZ2; a = 0 | ||
45338 | var m = xx.redAdd(xx).redIAdd(xx); | ||
45339 | // MM = M^2 | ||
45340 | var mm = m.redSqr(); | ||
45341 | // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM | ||
45342 | var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); | ||
45343 | e = e.redIAdd(e); | ||
45344 | e = e.redAdd(e).redIAdd(e); | ||
45345 | e = e.redISub(mm); | ||
45346 | // EE = E^2 | ||
45347 | var ee = e.redSqr(); | ||
45348 | // T = 16*YYYY | ||
45349 | var t = yyyy.redIAdd(yyyy); | ||
45350 | t = t.redIAdd(t); | ||
45351 | t = t.redIAdd(t); | ||
45352 | t = t.redIAdd(t); | ||
45353 | // U = (M + E)^2 - MM - EE - T | ||
45354 | var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t); | ||
45355 | // X3 = 4 * (X1 * EE - 4 * YY * U) | ||
45356 | var yyu4 = yy.redMul(u); | ||
45357 | yyu4 = yyu4.redIAdd(yyu4); | ||
45358 | yyu4 = yyu4.redIAdd(yyu4); | ||
45359 | var nx = this.x.redMul(ee).redISub(yyu4); | ||
45360 | nx = nx.redIAdd(nx); | ||
45361 | nx = nx.redIAdd(nx); | ||
45362 | // Y3 = 8 * Y1 * (U * (T - U) - E * EE) | ||
45363 | var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee))); | ||
45364 | ny = ny.redIAdd(ny); | ||
45365 | ny = ny.redIAdd(ny); | ||
45366 | ny = ny.redIAdd(ny); | ||
45367 | // Z3 = (Z1 + E)^2 - ZZ - EE | ||
45368 | var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee); | ||
45369 | |||
45370 | return this.curve.jpoint(nx, ny, nz); | ||
45371 | }; | ||
45372 | |||
45373 | JPoint.prototype.mul = function mul(k, kbase) { | ||
45374 | k = new BN(k, kbase); | ||
45375 | |||
45376 | return this.curve._wnafMul(this, k); | ||
45377 | }; | ||
45378 | |||
45379 | JPoint.prototype.eq = function eq(p) { | ||
45380 | if (p.type === 'affine') | ||
45381 | return this.eq(p.toJ()); | ||
45382 | |||
45383 | if (this === p) | ||
45384 | return true; | ||
45385 | |||
45386 | // x1 * z2^2 == x2 * z1^2 | ||
45387 | var z2 = this.z.redSqr(); | ||
45388 | var pz2 = p.z.redSqr(); | ||
45389 | if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0) | ||
45390 | return false; | ||
45391 | |||
45392 | // y1 * z2^3 == y2 * z1^3 | ||
45393 | var z3 = z2.redMul(this.z); | ||
45394 | var pz3 = pz2.redMul(p.z); | ||
45395 | return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0; | ||
45396 | }; | ||
45397 | |||
45398 | JPoint.prototype.eqXToP = function eqXToP(x) { | ||
45399 | var zs = this.z.redSqr(); | ||
45400 | var rx = x.toRed(this.curve.red).redMul(zs); | ||
45401 | if (this.x.cmp(rx) === 0) | ||
45402 | return true; | ||
45403 | |||
45404 | var xc = x.clone(); | ||
45405 | var t = this.curve.redN.redMul(zs); | ||
45406 | for (;;) { | ||
45407 | xc.iadd(this.curve.n); | ||
45408 | if (xc.cmp(this.curve.p) >= 0) | ||
45409 | return false; | ||
45410 | |||
45411 | rx.redIAdd(t); | ||
45412 | if (this.x.cmp(rx) === 0) | ||
45413 | return true; | ||
45414 | } | ||
45415 | return false; | ||
45416 | }; | ||
45417 | |||
45418 | JPoint.prototype.inspect = function inspect() { | ||
45419 | if (this.isInfinity()) | ||
45420 | return '<EC JPoint Infinity>'; | ||
45421 | return '<EC JPoint x: ' + this.x.toString(16, 2) + | ||
45422 | ' y: ' + this.y.toString(16, 2) + | ||
45423 | ' z: ' + this.z.toString(16, 2) + '>'; | ||
45424 | }; | ||
45425 | |||
45426 | JPoint.prototype.isInfinity = function isInfinity() { | ||
45427 | // XXX This code assumes that zero is always zero in red | ||
45428 | return this.z.cmpn(0) === 0; | ||
45429 | }; | ||
45430 | |||
45431 | },{"../../elliptic":97,"../curve":100,"bn.js":81,"inherits":121}],103:[function(require,module,exports){ | ||
45432 | 'use strict'; | ||
45433 | |||
45434 | var curves = exports; | ||
45435 | |||
45436 | var hash = require('hash.js'); | ||
45437 | var elliptic = require('../elliptic'); | ||
45438 | |||
45439 | var assert = elliptic.utils.assert; | ||
45440 | |||
45441 | function PresetCurve(options) { | ||
45442 | if (options.type === 'short') | ||
45443 | this.curve = new elliptic.curve.short(options); | ||
45444 | else if (options.type === 'edwards') | ||
45445 | this.curve = new elliptic.curve.edwards(options); | ||
45446 | else | ||
45447 | this.curve = new elliptic.curve.mont(options); | ||
45448 | this.g = this.curve.g; | ||
45449 | this.n = this.curve.n; | ||
45450 | this.hash = options.hash; | ||
45451 | |||
45452 | assert(this.g.validate(), 'Invalid curve'); | ||
45453 | assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O'); | ||
45454 | } | ||
45455 | curves.PresetCurve = PresetCurve; | ||
45456 | |||
45457 | function defineCurve(name, options) { | ||
45458 | Object.defineProperty(curves, name, { | ||
45459 | configurable: true, | ||
45460 | enumerable: true, | ||
45461 | get: function() { | ||
45462 | var curve = new PresetCurve(options); | ||
45463 | Object.defineProperty(curves, name, { | ||
45464 | configurable: true, | ||
45465 | enumerable: true, | ||
45466 | value: curve | ||
45467 | }); | ||
45468 | return curve; | ||
45469 | } | ||
45470 | }); | ||
45471 | } | ||
45472 | |||
45473 | defineCurve('p192', { | ||
45474 | type: 'short', | ||
45475 | prime: 'p192', | ||
45476 | p: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff', | ||
45477 | a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc', | ||
45478 | b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1', | ||
45479 | n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831', | ||
45480 | hash: hash.sha256, | ||
45481 | gRed: false, | ||
45482 | g: [ | ||
45483 | '188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012', | ||
45484 | '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811' | ||
45485 | ] | ||
45486 | }); | ||
45487 | |||
45488 | defineCurve('p224', { | ||
45489 | type: 'short', | ||
45490 | prime: 'p224', | ||
45491 | p: 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001', | ||
45492 | a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe', | ||
45493 | b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4', | ||
45494 | n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d', | ||
45495 | hash: hash.sha256, | ||
45496 | gRed: false, | ||
45497 | g: [ | ||
45498 | 'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21', | ||
45499 | 'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34' | ||
45500 | ] | ||
45501 | }); | ||
45502 | |||
45503 | defineCurve('p256', { | ||
45504 | type: 'short', | ||
45505 | prime: null, | ||
45506 | p: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff', | ||
45507 | a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc', | ||
45508 | b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b', | ||
45509 | n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551', | ||
45510 | hash: hash.sha256, | ||
45511 | gRed: false, | ||
45512 | g: [ | ||
45513 | '6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296', | ||
45514 | '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5' | ||
45515 | ] | ||
45516 | }); | ||
45517 | |||
45518 | defineCurve('p384', { | ||
45519 | type: 'short', | ||
45520 | prime: null, | ||
45521 | p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + | ||
45522 | 'fffffffe ffffffff 00000000 00000000 ffffffff', | ||
45523 | a: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + | ||
45524 | 'fffffffe ffffffff 00000000 00000000 fffffffc', | ||
45525 | b: 'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f ' + | ||
45526 | '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef', | ||
45527 | n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' + | ||
45528 | 'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973', | ||
45529 | hash: hash.sha384, | ||
45530 | gRed: false, | ||
45531 | g: [ | ||
45532 | 'aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' + | ||
45533 | '5502f25d bf55296c 3a545e38 72760ab7', | ||
45534 | '3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' + | ||
45535 | '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f' | ||
45536 | ] | ||
45537 | }); | ||
45538 | |||
45539 | defineCurve('p521', { | ||
45540 | type: 'short', | ||
45541 | prime: null, | ||
45542 | p: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + | ||
45543 | 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + | ||
45544 | 'ffffffff ffffffff ffffffff ffffffff ffffffff', | ||
45545 | a: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + | ||
45546 | 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + | ||
45547 | 'ffffffff ffffffff ffffffff ffffffff fffffffc', | ||
45548 | b: '00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b ' + | ||
45549 | '99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd ' + | ||
45550 | '3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00', | ||
45551 | n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + | ||
45552 | 'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' + | ||
45553 | 'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409', | ||
45554 | hash: hash.sha512, | ||
45555 | gRed: false, | ||
45556 | g: [ | ||
45557 | '000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' + | ||
45558 | '053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 ' + | ||
45559 | 'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66', | ||
45560 | '00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' + | ||
45561 | '579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' + | ||
45562 | '3fad0761 353c7086 a272c240 88be9476 9fd16650' | ||
45563 | ] | ||
45564 | }); | ||
45565 | |||
45566 | defineCurve('curve25519', { | ||
45567 | type: 'mont', | ||
45568 | prime: 'p25519', | ||
45569 | p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed', | ||
45570 | a: '76d06', | ||
45571 | b: '1', | ||
45572 | n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed', | ||
45573 | hash: hash.sha256, | ||
45574 | gRed: false, | ||
45575 | g: [ | ||
45576 | '9' | ||
45577 | ] | ||
45578 | }); | ||
45579 | |||
45580 | defineCurve('ed25519', { | ||
45581 | type: 'edwards', | ||
45582 | prime: 'p25519', | ||
45583 | p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed', | ||
45584 | a: '-1', | ||
45585 | c: '1', | ||
45586 | // -121665 * (121666^(-1)) (mod P) | ||
45587 | d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3', | ||
45588 | n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed', | ||
45589 | hash: hash.sha256, | ||
45590 | gRed: false, | ||
45591 | g: [ | ||
45592 | '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a', | ||
45593 | |||
45594 | // 4/5 | ||
45595 | '6666666666666666666666666666666666666666666666666666666666666658' | ||
45596 | ] | ||
45597 | }); | ||
45598 | |||
45599 | var pre; | ||
45600 | try { | ||
45601 | pre = require('./precomputed/secp256k1'); | ||
45602 | } catch (e) { | ||
45603 | pre = undefined; | ||
45604 | } | ||
45605 | |||
45606 | defineCurve('secp256k1', { | ||
45607 | type: 'short', | ||
45608 | prime: 'k256', | ||
45609 | p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f', | ||
45610 | a: '0', | ||
45611 | b: '7', | ||
45612 | n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141', | ||
45613 | h: '1', | ||
45614 | hash: hash.sha256, | ||
45615 | |||
45616 | // Precomputed endomorphism | ||
45617 | beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee', | ||
45618 | lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72', | ||
45619 | basis: [ | ||
45620 | { | ||
45621 | a: '3086d221a7d46bcde86c90e49284eb15', | ||
45622 | b: '-e4437ed6010e88286f547fa90abfe4c3' | ||
45623 | }, | ||
45624 | { | ||
45625 | a: '114ca50f7a8e2f3f657c1108d9d44cfd8', | ||
45626 | b: '3086d221a7d46bcde86c90e49284eb15' | ||
45627 | } | ||
45628 | ], | ||
45629 | |||
45630 | gRed: false, | ||
45631 | g: [ | ||
45632 | '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798', | ||
45633 | '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8', | ||
45634 | pre | ||
45635 | ] | ||
45636 | }); | ||
45637 | |||
45638 | },{"../elliptic":97,"./precomputed/secp256k1":110,"hash.js":114}],104:[function(require,module,exports){ | ||
45639 | 'use strict'; | ||
45640 | |||
45641 | var BN = require('bn.js'); | ||
45642 | var HmacDRBG = require('hmac-drbg'); | ||
45643 | var elliptic = require('../../elliptic'); | ||
45644 | var utils = elliptic.utils; | ||
45645 | var assert = utils.assert; | ||
45646 | |||
45647 | var KeyPair = require('./key'); | ||
45648 | var Signature = require('./signature'); | ||
45649 | |||
45650 | function EC(options) { | ||
45651 | if (!(this instanceof EC)) | ||
45652 | return new EC(options); | ||
45653 | |||
45654 | // Shortcut `elliptic.ec(curve-name)` | ||
45655 | if (typeof options === 'string') { | ||
45656 | assert(elliptic.curves.hasOwnProperty(options), 'Unknown curve ' + options); | ||
45657 | |||
45658 | options = elliptic.curves[options]; | ||
45659 | } | ||
45660 | |||
45661 | // Shortcut for `elliptic.ec(elliptic.curves.curveName)` | ||
45662 | if (options instanceof elliptic.curves.PresetCurve) | ||
45663 | options = { curve: options }; | ||
45664 | |||
45665 | this.curve = options.curve.curve; | ||
45666 | this.n = this.curve.n; | ||
45667 | this.nh = this.n.ushrn(1); | ||
45668 | this.g = this.curve.g; | ||
45669 | |||
45670 | // Point on curve | ||
45671 | this.g = options.curve.g; | ||
45672 | this.g.precompute(options.curve.n.bitLength() + 1); | ||
45673 | |||
45674 | // Hash for function for DRBG | ||
45675 | this.hash = options.hash || options.curve.hash; | ||
45676 | } | ||
45677 | module.exports = EC; | ||
45678 | |||
45679 | EC.prototype.keyPair = function keyPair(options) { | ||
45680 | return new KeyPair(this, options); | ||
45681 | }; | ||
45682 | |||
45683 | EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) { | ||
45684 | return KeyPair.fromPrivate(this, priv, enc); | ||
45685 | }; | ||
45686 | |||
45687 | EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) { | ||
45688 | return KeyPair.fromPublic(this, pub, enc); | ||
45689 | }; | ||
45690 | |||
45691 | EC.prototype.genKeyPair = function genKeyPair(options) { | ||
45692 | if (!options) | ||
45693 | options = {}; | ||
45694 | |||
45695 | // Instantiate Hmac_DRBG | ||
45696 | var drbg = new HmacDRBG({ | ||
45697 | hash: this.hash, | ||
45698 | pers: options.pers, | ||
45699 | persEnc: options.persEnc || 'utf8', | ||
45700 | entropy: options.entropy || elliptic.rand(this.hash.hmacStrength), | ||
45701 | entropyEnc: options.entropy && options.entropyEnc || 'utf8', | ||
45702 | nonce: this.n.toArray() | ||
45703 | }); | ||
45704 | |||
45705 | var bytes = this.n.byteLength(); | ||
45706 | var ns2 = this.n.sub(new BN(2)); | ||
45707 | do { | ||
45708 | var priv = new BN(drbg.generate(bytes)); | ||
45709 | if (priv.cmp(ns2) > 0) | ||
45710 | continue; | ||
45711 | |||
45712 | priv.iaddn(1); | ||
45713 | return this.keyFromPrivate(priv); | ||
45714 | } while (true); | ||
45715 | }; | ||
45716 | |||
45717 | EC.prototype._truncateToN = function truncateToN(msg, truncOnly) { | ||
45718 | var delta = msg.byteLength() * 8 - this.n.bitLength(); | ||
45719 | if (delta > 0) | ||
45720 | msg = msg.ushrn(delta); | ||
45721 | if (!truncOnly && msg.cmp(this.n) >= 0) | ||
45722 | return msg.sub(this.n); | ||
45723 | else | ||
45724 | return msg; | ||
45725 | }; | ||
45726 | |||
45727 | EC.prototype.sign = function sign(msg, key, enc, options) { | ||
45728 | if (typeof enc === 'object') { | ||
45729 | options = enc; | ||
45730 | enc = null; | ||
45731 | } | ||
45732 | if (!options) | ||
45733 | options = {}; | ||
45734 | |||
45735 | key = this.keyFromPrivate(key, enc); | ||
45736 | msg = this._truncateToN(new BN(msg, 16)); | ||
45737 | |||
45738 | // Zero-extend key to provide enough entropy | ||
45739 | var bytes = this.n.byteLength(); | ||
45740 | var bkey = key.getPrivate().toArray('be', bytes); | ||
45741 | |||
45742 | // Zero-extend nonce to have the same byte size as N | ||
45743 | var nonce = msg.toArray('be', bytes); | ||
45744 | |||
45745 | // Instantiate Hmac_DRBG | ||
45746 | var drbg = new HmacDRBG({ | ||
45747 | hash: this.hash, | ||
45748 | entropy: bkey, | ||
45749 | nonce: nonce, | ||
45750 | pers: options.pers, | ||
45751 | persEnc: options.persEnc || 'utf8' | ||
45752 | }); | ||
45753 | |||
45754 | // Number of bytes to generate | ||
45755 | var ns1 = this.n.sub(new BN(1)); | ||
45756 | |||
45757 | for (var iter = 0; true; iter++) { | ||
45758 | var k = options.k ? | ||
45759 | options.k(iter) : | ||
45760 | new BN(drbg.generate(this.n.byteLength())); | ||
45761 | k = this._truncateToN(k, true); | ||
45762 | if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0) | ||
45763 | continue; | ||
45764 | |||
45765 | var kp = this.g.mul(k); | ||
45766 | if (kp.isInfinity()) | ||
45767 | continue; | ||
45768 | |||
45769 | var kpX = kp.getX(); | ||
45770 | var r = kpX.umod(this.n); | ||
45771 | if (r.cmpn(0) === 0) | ||
45772 | continue; | ||
45773 | |||
45774 | var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg)); | ||
45775 | s = s.umod(this.n); | ||
45776 | if (s.cmpn(0) === 0) | ||
45777 | continue; | ||
45778 | |||
45779 | var recoveryParam = (kp.getY().isOdd() ? 1 : 0) | | ||
45780 | (kpX.cmp(r) !== 0 ? 2 : 0); | ||
45781 | |||
45782 | // Use complement of `s`, if it is > `n / 2` | ||
45783 | if (options.canonical && s.cmp(this.nh) > 0) { | ||
45784 | s = this.n.sub(s); | ||
45785 | recoveryParam ^= 1; | ||
45786 | } | ||
45787 | |||
45788 | return new Signature({ r: r, s: s, recoveryParam: recoveryParam }); | ||
45789 | } | ||
45790 | }; | ||
45791 | |||
45792 | EC.prototype.verify = function verify(msg, signature, key, enc) { | ||
45793 | msg = this._truncateToN(new BN(msg, 16)); | ||
45794 | key = this.keyFromPublic(key, enc); | ||
45795 | signature = new Signature(signature, 'hex'); | ||
45796 | |||
45797 | // Perform primitive values validation | ||
45798 | var r = signature.r; | ||
45799 | var s = signature.s; | ||
45800 | if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0) | ||
45801 | return false; | ||
45802 | if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0) | ||
45803 | return false; | ||
45804 | |||
45805 | // Validate signature | ||
45806 | var sinv = s.invm(this.n); | ||
45807 | var u1 = sinv.mul(msg).umod(this.n); | ||
45808 | var u2 = sinv.mul(r).umod(this.n); | ||
45809 | |||
45810 | if (!this.curve._maxwellTrick) { | ||
45811 | var p = this.g.mulAdd(u1, key.getPublic(), u2); | ||
45812 | if (p.isInfinity()) | ||
45813 | return false; | ||
45814 | |||
45815 | return p.getX().umod(this.n).cmp(r) === 0; | ||
45816 | } | ||
45817 | |||
45818 | // NOTE: Greg Maxwell's trick, inspired by: | ||
45819 | // https://git.io/vad3K | ||
45820 | |||
45821 | var p = this.g.jmulAdd(u1, key.getPublic(), u2); | ||
45822 | if (p.isInfinity()) | ||
45823 | return false; | ||
45824 | |||
45825 | // Compare `p.x` of Jacobian point with `r`, | ||
45826 | // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the | ||
45827 | // inverse of `p.z^2` | ||
45828 | return p.eqXToP(r); | ||
45829 | }; | ||
45830 | |||
45831 | EC.prototype.recoverPubKey = function(msg, signature, j, enc) { | ||
45832 | assert((3 & j) === j, 'The recovery param is more than two bits'); | ||
45833 | signature = new Signature(signature, enc); | ||
45834 | |||
45835 | var n = this.n; | ||
45836 | var e = new BN(msg); | ||
45837 | var r = signature.r; | ||
45838 | var s = signature.s; | ||
45839 | |||
45840 | // A set LSB signifies that the y-coordinate is odd | ||
45841 | var isYOdd = j & 1; | ||
45842 | var isSecondKey = j >> 1; | ||
45843 | if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey) | ||
45844 | throw new Error('Unable to find sencond key candinate'); | ||
45845 | |||
45846 | // 1.1. Let x = r + jn. | ||
45847 | if (isSecondKey) | ||
45848 | r = this.curve.pointFromX(r.add(this.curve.n), isYOdd); | ||
45849 | else | ||
45850 | r = this.curve.pointFromX(r, isYOdd); | ||
45851 | |||
45852 | var rInv = signature.r.invm(n); | ||
45853 | var s1 = n.sub(e).mul(rInv).umod(n); | ||
45854 | var s2 = s.mul(rInv).umod(n); | ||
45855 | |||
45856 | // 1.6.1 Compute Q = r^-1 (sR - eG) | ||
45857 | // Q = r^-1 (sR + -eG) | ||
45858 | return this.g.mulAdd(s1, r, s2); | ||
45859 | }; | ||
45860 | |||
45861 | EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) { | ||
45862 | signature = new Signature(signature, enc); | ||
45863 | if (signature.recoveryParam !== null) | ||
45864 | return signature.recoveryParam; | ||
45865 | |||
45866 | for (var i = 0; i < 4; i++) { | ||
45867 | var Qprime; | ||
45868 | try { | ||
45869 | Qprime = this.recoverPubKey(e, signature, i); | ||
45870 | } catch (e) { | ||
45871 | continue; | ||
45872 | } | ||
45873 | |||
45874 | if (Qprime.eq(Q)) | ||
45875 | return i; | ||
45876 | } | ||
45877 | throw new Error('Unable to find valid recovery factor'); | ||
45878 | }; | ||
45879 | |||
45880 | },{"../../elliptic":97,"./key":105,"./signature":106,"bn.js":81,"hmac-drbg":120}],105:[function(require,module,exports){ | ||
45881 | 'use strict'; | ||
45882 | |||
45883 | var BN = require('bn.js'); | ||
45884 | var elliptic = require('../../elliptic'); | ||
45885 | var utils = elliptic.utils; | ||
45886 | var assert = utils.assert; | ||
45887 | |||
45888 | function KeyPair(ec, options) { | ||
45889 | this.ec = ec; | ||
45890 | this.priv = null; | ||
45891 | this.pub = null; | ||
45892 | |||
45893 | // KeyPair(ec, { priv: ..., pub: ... }) | ||
45894 | if (options.priv) | ||
45895 | this._importPrivate(options.priv, options.privEnc); | ||
45896 | if (options.pub) | ||
45897 | this._importPublic(options.pub, options.pubEnc); | ||
45898 | } | ||
45899 | module.exports = KeyPair; | ||
45900 | |||
45901 | KeyPair.fromPublic = function fromPublic(ec, pub, enc) { | ||
45902 | if (pub instanceof KeyPair) | ||
45903 | return pub; | ||
45904 | |||
45905 | return new KeyPair(ec, { | ||
45906 | pub: pub, | ||
45907 | pubEnc: enc | ||
45908 | }); | ||
45909 | }; | ||
45910 | |||
45911 | KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) { | ||
45912 | if (priv instanceof KeyPair) | ||
45913 | return priv; | ||
45914 | |||
45915 | return new KeyPair(ec, { | ||
45916 | priv: priv, | ||
45917 | privEnc: enc | ||
45918 | }); | ||
45919 | }; | ||
45920 | |||
45921 | KeyPair.prototype.validate = function validate() { | ||
45922 | var pub = this.getPublic(); | ||
45923 | |||
45924 | if (pub.isInfinity()) | ||
45925 | return { result: false, reason: 'Invalid public key' }; | ||
45926 | if (!pub.validate()) | ||
45927 | return { result: false, reason: 'Public key is not a point' }; | ||
45928 | if (!pub.mul(this.ec.curve.n).isInfinity()) | ||
45929 | return { result: false, reason: 'Public key * N != O' }; | ||
45930 | |||
45931 | return { result: true, reason: null }; | ||
45932 | }; | ||
45933 | |||
45934 | KeyPair.prototype.getPublic = function getPublic(compact, enc) { | ||
45935 | // compact is optional argument | ||
45936 | if (typeof compact === 'string') { | ||
45937 | enc = compact; | ||
45938 | compact = null; | ||
45939 | } | ||
45940 | |||
45941 | if (!this.pub) | ||
45942 | this.pub = this.ec.g.mul(this.priv); | ||
45943 | |||
45944 | if (!enc) | ||
45945 | return this.pub; | ||
45946 | |||
45947 | return this.pub.encode(enc, compact); | ||
45948 | }; | ||
45949 | |||
45950 | KeyPair.prototype.getPrivate = function getPrivate(enc) { | ||
45951 | if (enc === 'hex') | ||
45952 | return this.priv.toString(16, 2); | ||
45953 | else | ||
45954 | return this.priv; | ||
45955 | }; | ||
45956 | |||
45957 | KeyPair.prototype._importPrivate = function _importPrivate(key, enc) { | ||
45958 | this.priv = new BN(key, enc || 16); | ||
45959 | |||
45960 | // Ensure that the priv won't be bigger than n, otherwise we may fail | ||
45961 | // in fixed multiplication method | ||
45962 | this.priv = this.priv.umod(this.ec.curve.n); | ||
45963 | }; | ||
45964 | |||
45965 | KeyPair.prototype._importPublic = function _importPublic(key, enc) { | ||
45966 | if (key.x || key.y) { | ||
45967 | // Montgomery points only have an `x` coordinate. | ||
45968 | // Weierstrass/Edwards points on the other hand have both `x` and | ||
45969 | // `y` coordinates. | ||
45970 | if (this.ec.curve.type === 'mont') { | ||
45971 | assert(key.x, 'Need x coordinate'); | ||
45972 | } else if (this.ec.curve.type === 'short' || | ||
45973 | this.ec.curve.type === 'edwards') { | ||
45974 | assert(key.x && key.y, 'Need both x and y coordinate'); | ||
45975 | } | ||
45976 | this.pub = this.ec.curve.point(key.x, key.y); | ||
45977 | return; | ||
45978 | } | ||
45979 | this.pub = this.ec.curve.decodePoint(key, enc); | ||
45980 | }; | ||
45981 | |||
45982 | // ECDH | ||
45983 | KeyPair.prototype.derive = function derive(pub) { | ||
45984 | return pub.mul(this.priv).getX(); | ||
45985 | }; | ||
45986 | |||
45987 | // ECDSA | ||
45988 | KeyPair.prototype.sign = function sign(msg, enc, options) { | ||
45989 | return this.ec.sign(msg, this, enc, options); | ||
45990 | }; | ||
45991 | |||
45992 | KeyPair.prototype.verify = function verify(msg, signature) { | ||
45993 | return this.ec.verify(msg, signature, this); | ||
45994 | }; | ||
45995 | |||
45996 | KeyPair.prototype.inspect = function inspect() { | ||
45997 | return '<Key priv: ' + (this.priv && this.priv.toString(16, 2)) + | ||
45998 | ' pub: ' + (this.pub && this.pub.inspect()) + ' >'; | ||
45999 | }; | ||
46000 | |||
46001 | },{"../../elliptic":97,"bn.js":81}],106:[function(require,module,exports){ | ||
46002 | 'use strict'; | ||
46003 | |||
46004 | var BN = require('bn.js'); | ||
46005 | |||
46006 | var elliptic = require('../../elliptic'); | ||
46007 | var utils = elliptic.utils; | ||
46008 | var assert = utils.assert; | ||
46009 | |||
46010 | function Signature(options, enc) { | ||
46011 | if (options instanceof Signature) | ||
46012 | return options; | ||
46013 | |||
46014 | if (this._importDER(options, enc)) | ||
46015 | return; | ||
46016 | |||
46017 | assert(options.r && options.s, 'Signature without r or s'); | ||
46018 | this.r = new BN(options.r, 16); | ||
46019 | this.s = new BN(options.s, 16); | ||
46020 | if (options.recoveryParam === undefined) | ||
46021 | this.recoveryParam = null; | ||
46022 | else | ||
46023 | this.recoveryParam = options.recoveryParam; | ||
46024 | } | ||
46025 | module.exports = Signature; | ||
46026 | |||
46027 | function Position() { | ||
46028 | this.place = 0; | ||
46029 | } | ||
46030 | |||
46031 | function getLength(buf, p) { | ||
46032 | var initial = buf[p.place++]; | ||
46033 | if (!(initial & 0x80)) { | ||
46034 | return initial; | ||
46035 | } | ||
46036 | var octetLen = initial & 0xf; | ||
46037 | var val = 0; | ||
46038 | for (var i = 0, off = p.place; i < octetLen; i++, off++) { | ||
46039 | val <<= 8; | ||
46040 | val |= buf[off]; | ||
46041 | } | ||
46042 | p.place = off; | ||
46043 | return val; | ||
46044 | } | ||
46045 | |||
46046 | function rmPadding(buf) { | ||
46047 | var i = 0; | ||
46048 | var len = buf.length - 1; | ||
46049 | while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) { | ||
46050 | i++; | ||
46051 | } | ||
46052 | if (i === 0) { | ||
46053 | return buf; | ||
46054 | } | ||
46055 | return buf.slice(i); | ||
46056 | } | ||
46057 | |||
46058 | Signature.prototype._importDER = function _importDER(data, enc) { | ||
46059 | data = utils.toArray(data, enc); | ||
46060 | var p = new Position(); | ||
46061 | if (data[p.place++] !== 0x30) { | ||
46062 | return false; | ||
46063 | } | ||
46064 | var len = getLength(data, p); | ||
46065 | if ((len + p.place) !== data.length) { | ||
46066 | return false; | ||
46067 | } | ||
46068 | if (data[p.place++] !== 0x02) { | ||
46069 | return false; | ||
46070 | } | ||
46071 | var rlen = getLength(data, p); | ||
46072 | var r = data.slice(p.place, rlen + p.place); | ||
46073 | p.place += rlen; | ||
46074 | if (data[p.place++] !== 0x02) { | ||
46075 | return false; | ||
46076 | } | ||
46077 | var slen = getLength(data, p); | ||
46078 | if (data.length !== slen + p.place) { | ||
46079 | return false; | ||
46080 | } | ||
46081 | var s = data.slice(p.place, slen + p.place); | ||
46082 | if (r[0] === 0 && (r[1] & 0x80)) { | ||
46083 | r = r.slice(1); | ||
46084 | } | ||
46085 | if (s[0] === 0 && (s[1] & 0x80)) { | ||
46086 | s = s.slice(1); | ||
46087 | } | ||
46088 | |||
46089 | this.r = new BN(r); | ||
46090 | this.s = new BN(s); | ||
46091 | this.recoveryParam = null; | ||
46092 | |||
46093 | return true; | ||
46094 | }; | ||
46095 | |||
46096 | function constructLength(arr, len) { | ||
46097 | if (len < 0x80) { | ||
46098 | arr.push(len); | ||
46099 | return; | ||
46100 | } | ||
46101 | var octets = 1 + (Math.log(len) / Math.LN2 >>> 3); | ||
46102 | arr.push(octets | 0x80); | ||
46103 | while (--octets) { | ||
46104 | arr.push((len >>> (octets << 3)) & 0xff); | ||
46105 | } | ||
46106 | arr.push(len); | ||
46107 | } | ||
46108 | |||
46109 | Signature.prototype.toDER = function toDER(enc) { | ||
46110 | var r = this.r.toArray(); | ||
46111 | var s = this.s.toArray(); | ||
46112 | |||
46113 | // Pad values | ||
46114 | if (r[0] & 0x80) | ||
46115 | r = [ 0 ].concat(r); | ||
46116 | // Pad values | ||
46117 | if (s[0] & 0x80) | ||
46118 | s = [ 0 ].concat(s); | ||
46119 | |||
46120 | r = rmPadding(r); | ||
46121 | s = rmPadding(s); | ||
46122 | |||
46123 | while (!s[0] && !(s[1] & 0x80)) { | ||
46124 | s = s.slice(1); | ||
46125 | } | ||
46126 | var arr = [ 0x02 ]; | ||
46127 | constructLength(arr, r.length); | ||
46128 | arr = arr.concat(r); | ||
46129 | arr.push(0x02); | ||
46130 | constructLength(arr, s.length); | ||
46131 | var backHalf = arr.concat(s); | ||
46132 | var res = [ 0x30 ]; | ||
46133 | constructLength(res, backHalf.length); | ||
46134 | res = res.concat(backHalf); | ||
46135 | return utils.encode(res, enc); | ||
46136 | }; | ||
46137 | |||
46138 | },{"../../elliptic":97,"bn.js":81}],107:[function(require,module,exports){ | ||
46139 | 'use strict'; | ||
46140 | |||
46141 | var hash = require('hash.js'); | ||
46142 | var elliptic = require('../../elliptic'); | ||
46143 | var utils = elliptic.utils; | ||
46144 | var assert = utils.assert; | ||
46145 | var parseBytes = utils.parseBytes; | ||
46146 | var KeyPair = require('./key'); | ||
46147 | var Signature = require('./signature'); | ||
46148 | |||
46149 | function EDDSA(curve) { | ||
46150 | assert(curve === 'ed25519', 'only tested with ed25519 so far'); | ||
46151 | |||
46152 | if (!(this instanceof EDDSA)) | ||
46153 | return new EDDSA(curve); | ||
46154 | |||
46155 | var curve = elliptic.curves[curve].curve; | ||
46156 | this.curve = curve; | ||
46157 | this.g = curve.g; | ||
46158 | this.g.precompute(curve.n.bitLength() + 1); | ||
46159 | |||
46160 | this.pointClass = curve.point().constructor; | ||
46161 | this.encodingLength = Math.ceil(curve.n.bitLength() / 8); | ||
46162 | this.hash = hash.sha512; | ||
46163 | } | ||
46164 | |||
46165 | module.exports = EDDSA; | ||
46166 | |||
46167 | /** | ||
46168 | * @param {Array|String} message - message bytes | ||
46169 | * @param {Array|String|KeyPair} secret - secret bytes or a keypair | ||
46170 | * @returns {Signature} - signature | ||
46171 | */ | ||
46172 | EDDSA.prototype.sign = function sign(message, secret) { | ||
46173 | message = parseBytes(message); | ||
46174 | var key = this.keyFromSecret(secret); | ||
46175 | var r = this.hashInt(key.messagePrefix(), message); | ||
46176 | var R = this.g.mul(r); | ||
46177 | var Rencoded = this.encodePoint(R); | ||
46178 | var s_ = this.hashInt(Rencoded, key.pubBytes(), message) | ||
46179 | .mul(key.priv()); | ||
46180 | var S = r.add(s_).umod(this.curve.n); | ||
46181 | return this.makeSignature({ R: R, S: S, Rencoded: Rencoded }); | ||
46182 | }; | ||
46183 | |||
46184 | /** | ||
46185 | * @param {Array} message - message bytes | ||
46186 | * @param {Array|String|Signature} sig - sig bytes | ||
46187 | * @param {Array|String|Point|KeyPair} pub - public key | ||
46188 | * @returns {Boolean} - true if public key matches sig of message | ||
46189 | */ | ||
46190 | EDDSA.prototype.verify = function verify(message, sig, pub) { | ||
46191 | message = parseBytes(message); | ||
46192 | sig = this.makeSignature(sig); | ||
46193 | var key = this.keyFromPublic(pub); | ||
46194 | var h = this.hashInt(sig.Rencoded(), key.pubBytes(), message); | ||
46195 | var SG = this.g.mul(sig.S()); | ||
46196 | var RplusAh = sig.R().add(key.pub().mul(h)); | ||
46197 | return RplusAh.eq(SG); | ||
46198 | }; | ||
46199 | |||
46200 | EDDSA.prototype.hashInt = function hashInt() { | ||
46201 | var hash = this.hash(); | ||
46202 | for (var i = 0; i < arguments.length; i++) | ||
46203 | hash.update(arguments[i]); | ||
46204 | return utils.intFromLE(hash.digest()).umod(this.curve.n); | ||
46205 | }; | ||
46206 | |||
46207 | EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) { | ||
46208 | return KeyPair.fromPublic(this, pub); | ||
46209 | }; | ||
46210 | |||
46211 | EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) { | ||
46212 | return KeyPair.fromSecret(this, secret); | ||
46213 | }; | ||
46214 | |||
46215 | EDDSA.prototype.makeSignature = function makeSignature(sig) { | ||
46216 | if (sig instanceof Signature) | ||
46217 | return sig; | ||
46218 | return new Signature(this, sig); | ||
46219 | }; | ||
46220 | |||
46221 | /** | ||
46222 | * * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.2 | ||
46223 | * | ||
46224 | * EDDSA defines methods for encoding and decoding points and integers. These are | ||
46225 | * helper convenience methods, that pass along to utility functions implied | ||
46226 | * parameters. | ||
46227 | * | ||
46228 | */ | ||
46229 | EDDSA.prototype.encodePoint = function encodePoint(point) { | ||
46230 | var enc = point.getY().toArray('le', this.encodingLength); | ||
46231 | enc[this.encodingLength - 1] |= point.getX().isOdd() ? 0x80 : 0; | ||
46232 | return enc; | ||
46233 | }; | ||
46234 | |||
46235 | EDDSA.prototype.decodePoint = function decodePoint(bytes) { | ||
46236 | bytes = utils.parseBytes(bytes); | ||
46237 | |||
46238 | var lastIx = bytes.length - 1; | ||
46239 | var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80); | ||
46240 | var xIsOdd = (bytes[lastIx] & 0x80) !== 0; | ||
46241 | |||
46242 | var y = utils.intFromLE(normed); | ||
46243 | return this.curve.pointFromY(y, xIsOdd); | ||
46244 | }; | ||
46245 | |||
46246 | EDDSA.prototype.encodeInt = function encodeInt(num) { | ||
46247 | return num.toArray('le', this.encodingLength); | ||
46248 | }; | ||
46249 | |||
46250 | EDDSA.prototype.decodeInt = function decodeInt(bytes) { | ||
46251 | return utils.intFromLE(bytes); | ||
46252 | }; | ||
46253 | |||
46254 | EDDSA.prototype.isPoint = function isPoint(val) { | ||
46255 | return val instanceof this.pointClass; | ||
46256 | }; | ||
46257 | |||
46258 | },{"../../elliptic":97,"./key":108,"./signature":109,"hash.js":114}],108:[function(require,module,exports){ | ||
46259 | 'use strict'; | ||
46260 | |||
46261 | var elliptic = require('../../elliptic'); | ||
46262 | var utils = elliptic.utils; | ||
46263 | var assert = utils.assert; | ||
46264 | var parseBytes = utils.parseBytes; | ||
46265 | var cachedProperty = utils.cachedProperty; | ||
46266 | |||
46267 | /** | ||
46268 | * @param {EDDSA} eddsa - instance | ||
46269 | * @param {Object} params - public/private key parameters | ||
46270 | * | ||
46271 | * @param {Array<Byte>} [params.secret] - secret seed bytes | ||
46272 | * @param {Point} [params.pub] - public key point (aka `A` in eddsa terms) | ||
46273 | * @param {Array<Byte>} [params.pub] - public key point encoded as bytes | ||
46274 | * | ||
46275 | */ | ||
46276 | function KeyPair(eddsa, params) { | ||
46277 | this.eddsa = eddsa; | ||
46278 | this._secret = parseBytes(params.secret); | ||
46279 | if (eddsa.isPoint(params.pub)) | ||
46280 | this._pub = params.pub; | ||
46281 | else | ||
46282 | this._pubBytes = parseBytes(params.pub); | ||
46283 | } | ||
46284 | |||
46285 | KeyPair.fromPublic = function fromPublic(eddsa, pub) { | ||
46286 | if (pub instanceof KeyPair) | ||
46287 | return pub; | ||
46288 | return new KeyPair(eddsa, { pub: pub }); | ||
46289 | }; | ||
46290 | |||
46291 | KeyPair.fromSecret = function fromSecret(eddsa, secret) { | ||
46292 | if (secret instanceof KeyPair) | ||
46293 | return secret; | ||
46294 | return new KeyPair(eddsa, { secret: secret }); | ||
46295 | }; | ||
46296 | |||
46297 | KeyPair.prototype.secret = function secret() { | ||
46298 | return this._secret; | ||
46299 | }; | ||
46300 | |||
46301 | cachedProperty(KeyPair, 'pubBytes', function pubBytes() { | ||
46302 | return this.eddsa.encodePoint(this.pub()); | ||
46303 | }); | ||
46304 | |||
46305 | cachedProperty(KeyPair, 'pub', function pub() { | ||
46306 | if (this._pubBytes) | ||
46307 | return this.eddsa.decodePoint(this._pubBytes); | ||
46308 | return this.eddsa.g.mul(this.priv()); | ||
46309 | }); | ||
46310 | |||
46311 | cachedProperty(KeyPair, 'privBytes', function privBytes() { | ||
46312 | var eddsa = this.eddsa; | ||
46313 | var hash = this.hash(); | ||
46314 | var lastIx = eddsa.encodingLength - 1; | ||
46315 | |||
46316 | var a = hash.slice(0, eddsa.encodingLength); | ||
46317 | a[0] &= 248; | ||
46318 | a[lastIx] &= 127; | ||
46319 | a[lastIx] |= 64; | ||
46320 | |||
46321 | return a; | ||
46322 | }); | ||
46323 | |||
46324 | cachedProperty(KeyPair, 'priv', function priv() { | ||
46325 | return this.eddsa.decodeInt(this.privBytes()); | ||
46326 | }); | ||
46327 | |||
46328 | cachedProperty(KeyPair, 'hash', function hash() { | ||
46329 | return this.eddsa.hash().update(this.secret()).digest(); | ||
46330 | }); | ||
46331 | |||
46332 | cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() { | ||
46333 | return this.hash().slice(this.eddsa.encodingLength); | ||
46334 | }); | ||
46335 | |||
46336 | KeyPair.prototype.sign = function sign(message) { | ||
46337 | assert(this._secret, 'KeyPair can only verify'); | ||
46338 | return this.eddsa.sign(message, this); | ||
46339 | }; | ||
46340 | |||
46341 | KeyPair.prototype.verify = function verify(message, sig) { | ||
46342 | return this.eddsa.verify(message, sig, this); | ||
46343 | }; | ||
46344 | |||
46345 | KeyPair.prototype.getSecret = function getSecret(enc) { | ||
46346 | assert(this._secret, 'KeyPair is public only'); | ||
46347 | return utils.encode(this.secret(), enc); | ||
46348 | }; | ||
46349 | |||
46350 | KeyPair.prototype.getPublic = function getPublic(enc) { | ||
46351 | return utils.encode(this.pubBytes(), enc); | ||
46352 | }; | ||
46353 | |||
46354 | module.exports = KeyPair; | ||
46355 | |||
46356 | },{"../../elliptic":97}],109:[function(require,module,exports){ | ||
46357 | 'use strict'; | ||
46358 | |||
46359 | var BN = require('bn.js'); | ||
46360 | var elliptic = require('../../elliptic'); | ||
46361 | var utils = elliptic.utils; | ||
46362 | var assert = utils.assert; | ||
46363 | var cachedProperty = utils.cachedProperty; | ||
46364 | var parseBytes = utils.parseBytes; | ||
46365 | |||
46366 | /** | ||
46367 | * @param {EDDSA} eddsa - eddsa instance | ||
46368 | * @param {Array<Bytes>|Object} sig - | ||
46369 | * @param {Array<Bytes>|Point} [sig.R] - R point as Point or bytes | ||
46370 | * @param {Array<Bytes>|bn} [sig.S] - S scalar as bn or bytes | ||
46371 | * @param {Array<Bytes>} [sig.Rencoded] - R point encoded | ||
46372 | * @param {Array<Bytes>} [sig.Sencoded] - S scalar encoded | ||
46373 | */ | ||
46374 | function Signature(eddsa, sig) { | ||
46375 | this.eddsa = eddsa; | ||
46376 | |||
46377 | if (typeof sig !== 'object') | ||
46378 | sig = parseBytes(sig); | ||
46379 | |||
46380 | if (Array.isArray(sig)) { | ||
46381 | sig = { | ||
46382 | R: sig.slice(0, eddsa.encodingLength), | ||
46383 | S: sig.slice(eddsa.encodingLength) | ||
46384 | }; | ||
46385 | } | ||
46386 | |||
46387 | assert(sig.R && sig.S, 'Signature without R or S'); | ||
46388 | |||
46389 | if (eddsa.isPoint(sig.R)) | ||
46390 | this._R = sig.R; | ||
46391 | if (sig.S instanceof BN) | ||
46392 | this._S = sig.S; | ||
46393 | |||
46394 | this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded; | ||
46395 | this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded; | ||
46396 | } | ||
46397 | |||
46398 | cachedProperty(Signature, 'S', function S() { | ||
46399 | return this.eddsa.decodeInt(this.Sencoded()); | ||
46400 | }); | ||
46401 | |||
46402 | cachedProperty(Signature, 'R', function R() { | ||
46403 | return this.eddsa.decodePoint(this.Rencoded()); | ||
46404 | }); | ||
46405 | |||
46406 | cachedProperty(Signature, 'Rencoded', function Rencoded() { | ||
46407 | return this.eddsa.encodePoint(this.R()); | ||
46408 | }); | ||
46409 | |||
46410 | cachedProperty(Signature, 'Sencoded', function Sencoded() { | ||
46411 | return this.eddsa.encodeInt(this.S()); | ||
46412 | }); | ||
46413 | |||
46414 | Signature.prototype.toBytes = function toBytes() { | ||
46415 | return this.Rencoded().concat(this.Sencoded()); | ||
46416 | }; | ||
46417 | |||
46418 | Signature.prototype.toHex = function toHex() { | ||
46419 | return utils.encode(this.toBytes(), 'hex').toUpperCase(); | ||
46420 | }; | ||
46421 | |||
46422 | module.exports = Signature; | ||
46423 | |||
46424 | },{"../../elliptic":97,"bn.js":81}],110:[function(require,module,exports){ | ||
46425 | module.exports = { | ||
46426 | doubles: { | ||
46427 | step: 4, | ||
46428 | points: [ | ||
46429 | [ | ||
46430 | 'e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a', | ||
46431 | 'f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821' | ||
46432 | ], | ||
46433 | [ | ||
46434 | '8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508', | ||
46435 | '11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf' | ||
46436 | ], | ||
46437 | [ | ||
46438 | '175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739', | ||
46439 | 'd3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695' | ||
46440 | ], | ||
46441 | [ | ||
46442 | '363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640', | ||
46443 | '4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9' | ||
46444 | ], | ||
46445 | [ | ||
46446 | '8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c', | ||
46447 | '4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36' | ||
46448 | ], | ||
46449 | [ | ||
46450 | '723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda', | ||
46451 | '96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f' | ||
46452 | ], | ||
46453 | [ | ||
46454 | 'eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa', | ||
46455 | '5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999' | ||
46456 | ], | ||
46457 | [ | ||
46458 | '100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0', | ||
46459 | 'cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09' | ||
46460 | ], | ||
46461 | [ | ||
46462 | 'e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d', | ||
46463 | '9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d' | ||
46464 | ], | ||
46465 | [ | ||
46466 | 'feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d', | ||
46467 | 'e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088' | ||
46468 | ], | ||
46469 | [ | ||
46470 | 'da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1', | ||
46471 | '9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d' | ||
46472 | ], | ||
46473 | [ | ||
46474 | '53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0', | ||
46475 | '5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8' | ||
46476 | ], | ||
46477 | [ | ||
46478 | '8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047', | ||
46479 | '10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a' | ||
46480 | ], | ||
46481 | [ | ||
46482 | '385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862', | ||
46483 | '283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453' | ||
46484 | ], | ||
46485 | [ | ||
46486 | '6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7', | ||
46487 | '7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160' | ||
46488 | ], | ||
46489 | [ | ||
46490 | '3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd', | ||
46491 | '56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0' | ||
46492 | ], | ||
46493 | [ | ||
46494 | '85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83', | ||
46495 | '7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6' | ||
46496 | ], | ||
46497 | [ | ||
46498 | '948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a', | ||
46499 | '53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589' | ||
46500 | ], | ||
46501 | [ | ||
46502 | '6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8', | ||
46503 | 'bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17' | ||
46504 | ], | ||
46505 | [ | ||
46506 | 'e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d', | ||
46507 | '4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda' | ||
46508 | ], | ||
46509 | [ | ||
46510 | 'e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725', | ||
46511 | '7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd' | ||
46512 | ], | ||
46513 | [ | ||
46514 | '213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754', | ||
46515 | '4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2' | ||
46516 | ], | ||
46517 | [ | ||
46518 | '4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c', | ||
46519 | '17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6' | ||
46520 | ], | ||
46521 | [ | ||
46522 | 'fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6', | ||
46523 | '6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f' | ||
46524 | ], | ||
46525 | [ | ||
46526 | '76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39', | ||
46527 | 'c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01' | ||
46528 | ], | ||
46529 | [ | ||
46530 | 'c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891', | ||
46531 | '893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3' | ||
46532 | ], | ||
46533 | [ | ||
46534 | 'd895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b', | ||
46535 | 'febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f' | ||
46536 | ], | ||
46537 | [ | ||
46538 | 'b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03', | ||
46539 | '2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7' | ||
46540 | ], | ||
46541 | [ | ||
46542 | 'e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d', | ||
46543 | 'eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78' | ||
46544 | ], | ||
46545 | [ | ||
46546 | 'a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070', | ||
46547 | '7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1' | ||
46548 | ], | ||
46549 | [ | ||
46550 | '90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4', | ||
46551 | 'e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150' | ||
46552 | ], | ||
46553 | [ | ||
46554 | '8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da', | ||
46555 | '662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82' | ||
46556 | ], | ||
46557 | [ | ||
46558 | 'e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11', | ||
46559 | '1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc' | ||
46560 | ], | ||
46561 | [ | ||
46562 | '8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e', | ||
46563 | 'efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b' | ||
46564 | ], | ||
46565 | [ | ||
46566 | 'e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41', | ||
46567 | '2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51' | ||
46568 | ], | ||
46569 | [ | ||
46570 | 'b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef', | ||
46571 | '67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45' | ||
46572 | ], | ||
46573 | [ | ||
46574 | 'd68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8', | ||
46575 | 'db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120' | ||
46576 | ], | ||
46577 | [ | ||
46578 | '324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d', | ||
46579 | '648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84' | ||
46580 | ], | ||
46581 | [ | ||
46582 | '4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96', | ||
46583 | '35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d' | ||
46584 | ], | ||
46585 | [ | ||
46586 | '9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd', | ||
46587 | 'ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d' | ||
46588 | ], | ||
46589 | [ | ||
46590 | '6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5', | ||
46591 | '9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8' | ||
46592 | ], | ||
46593 | [ | ||
46594 | 'a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266', | ||
46595 | '40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8' | ||
46596 | ], | ||
46597 | [ | ||
46598 | '7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71', | ||
46599 | '34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac' | ||
46600 | ], | ||
46601 | [ | ||
46602 | '928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac', | ||
46603 | 'c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f' | ||
46604 | ], | ||
46605 | [ | ||
46606 | '85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751', | ||
46607 | '1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962' | ||
46608 | ], | ||
46609 | [ | ||
46610 | 'ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e', | ||
46611 | '493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907' | ||
46612 | ], | ||
46613 | [ | ||
46614 | '827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241', | ||
46615 | 'c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec' | ||
46616 | ], | ||
46617 | [ | ||
46618 | 'eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3', | ||
46619 | 'be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d' | ||
46620 | ], | ||
46621 | [ | ||
46622 | 'e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f', | ||
46623 | '4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414' | ||
46624 | ], | ||
46625 | [ | ||
46626 | '1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19', | ||
46627 | 'aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd' | ||
46628 | ], | ||
46629 | [ | ||
46630 | '146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be', | ||
46631 | 'b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0' | ||
46632 | ], | ||
46633 | [ | ||
46634 | 'fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9', | ||
46635 | '6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811' | ||
46636 | ], | ||
46637 | [ | ||
46638 | 'da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2', | ||
46639 | '8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1' | ||
46640 | ], | ||
46641 | [ | ||
46642 | 'a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13', | ||
46643 | '7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c' | ||
46644 | ], | ||
46645 | [ | ||
46646 | '174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c', | ||
46647 | 'ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73' | ||
46648 | ], | ||
46649 | [ | ||
46650 | '959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba', | ||
46651 | '2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd' | ||
46652 | ], | ||
46653 | [ | ||
46654 | 'd2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151', | ||
46655 | 'e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405' | ||
46656 | ], | ||
46657 | [ | ||
46658 | '64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073', | ||
46659 | 'd99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589' | ||
46660 | ], | ||
46661 | [ | ||
46662 | '8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458', | ||
46663 | '38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e' | ||
46664 | ], | ||
46665 | [ | ||
46666 | '13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b', | ||
46667 | '69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27' | ||
46668 | ], | ||
46669 | [ | ||
46670 | 'bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366', | ||
46671 | 'd3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1' | ||
46672 | ], | ||
46673 | [ | ||
46674 | '8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa', | ||
46675 | '40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482' | ||
46676 | ], | ||
46677 | [ | ||
46678 | '8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0', | ||
46679 | '620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945' | ||
46680 | ], | ||
46681 | [ | ||
46682 | 'dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787', | ||
46683 | '7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573' | ||
46684 | ], | ||
46685 | [ | ||
46686 | 'f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e', | ||
46687 | 'ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82' | ||
46688 | ] | ||
46689 | ] | ||
46690 | }, | ||
46691 | naf: { | ||
46692 | wnd: 7, | ||
46693 | points: [ | ||
46694 | [ | ||
46695 | 'f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9', | ||
46696 | '388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672' | ||
46697 | ], | ||
46698 | [ | ||
46699 | '2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4', | ||
46700 | 'd8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6' | ||
46701 | ], | ||
46702 | [ | ||
46703 | '5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc', | ||
46704 | '6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da' | ||
46705 | ], | ||
46706 | [ | ||
46707 | 'acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe', | ||
46708 | 'cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37' | ||
46709 | ], | ||
46710 | [ | ||
46711 | '774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb', | ||
46712 | 'd984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b' | ||
46713 | ], | ||
46714 | [ | ||
46715 | 'f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8', | ||
46716 | 'ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81' | ||
46717 | ], | ||
46718 | [ | ||
46719 | 'd7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e', | ||
46720 | '581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58' | ||
46721 | ], | ||
46722 | [ | ||
46723 | 'defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34', | ||
46724 | '4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77' | ||
46725 | ], | ||
46726 | [ | ||
46727 | '2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c', | ||
46728 | '85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a' | ||
46729 | ], | ||
46730 | [ | ||
46731 | '352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5', | ||
46732 | '321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c' | ||
46733 | ], | ||
46734 | [ | ||
46735 | '2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f', | ||
46736 | '2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67' | ||
46737 | ], | ||
46738 | [ | ||
46739 | '9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714', | ||
46740 | '73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402' | ||
46741 | ], | ||
46742 | [ | ||
46743 | 'daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729', | ||
46744 | 'a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55' | ||
46745 | ], | ||
46746 | [ | ||
46747 | 'c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db', | ||
46748 | '2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482' | ||
46749 | ], | ||
46750 | [ | ||
46751 | '6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4', | ||
46752 | 'e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82' | ||
46753 | ], | ||
46754 | [ | ||
46755 | '1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5', | ||
46756 | 'b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396' | ||
46757 | ], | ||
46758 | [ | ||
46759 | '605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479', | ||
46760 | '2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49' | ||
46761 | ], | ||
46762 | [ | ||
46763 | '62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d', | ||
46764 | '80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf' | ||
46765 | ], | ||
46766 | [ | ||
46767 | '80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f', | ||
46768 | '1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a' | ||
46769 | ], | ||
46770 | [ | ||
46771 | '7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb', | ||
46772 | 'd0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7' | ||
46773 | ], | ||
46774 | [ | ||
46775 | 'd528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9', | ||
46776 | 'eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933' | ||
46777 | ], | ||
46778 | [ | ||
46779 | '49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963', | ||
46780 | '758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a' | ||
46781 | ], | ||
46782 | [ | ||
46783 | '77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74', | ||
46784 | '958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6' | ||
46785 | ], | ||
46786 | [ | ||
46787 | 'f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530', | ||
46788 | 'e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37' | ||
46789 | ], | ||
46790 | [ | ||
46791 | '463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b', | ||
46792 | '5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e' | ||
46793 | ], | ||
46794 | [ | ||
46795 | 'f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247', | ||
46796 | 'cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6' | ||
46797 | ], | ||
46798 | [ | ||
46799 | 'caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1', | ||
46800 | 'cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476' | ||
46801 | ], | ||
46802 | [ | ||
46803 | '2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120', | ||
46804 | '4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40' | ||
46805 | ], | ||
46806 | [ | ||
46807 | '7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435', | ||
46808 | '91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61' | ||
46809 | ], | ||
46810 | [ | ||
46811 | '754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18', | ||
46812 | '673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683' | ||
46813 | ], | ||
46814 | [ | ||
46815 | 'e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8', | ||
46816 | '59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5' | ||
46817 | ], | ||
46818 | [ | ||
46819 | '186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb', | ||
46820 | '3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b' | ||
46821 | ], | ||
46822 | [ | ||
46823 | 'df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f', | ||
46824 | '55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417' | ||
46825 | ], | ||
46826 | [ | ||
46827 | '5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143', | ||
46828 | 'efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868' | ||
46829 | ], | ||
46830 | [ | ||
46831 | '290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba', | ||
46832 | 'e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a' | ||
46833 | ], | ||
46834 | [ | ||
46835 | 'af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45', | ||
46836 | 'f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6' | ||
46837 | ], | ||
46838 | [ | ||
46839 | '766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a', | ||
46840 | '744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996' | ||
46841 | ], | ||
46842 | [ | ||
46843 | '59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e', | ||
46844 | 'c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e' | ||
46845 | ], | ||
46846 | [ | ||
46847 | 'f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8', | ||
46848 | 'e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d' | ||
46849 | ], | ||
46850 | [ | ||
46851 | '7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c', | ||
46852 | '30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2' | ||
46853 | ], | ||
46854 | [ | ||
46855 | '948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519', | ||
46856 | 'e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e' | ||
46857 | ], | ||
46858 | [ | ||
46859 | '7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab', | ||
46860 | '100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437' | ||
46861 | ], | ||
46862 | [ | ||
46863 | '3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca', | ||
46864 | 'ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311' | ||
46865 | ], | ||
46866 | [ | ||
46867 | 'd3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf', | ||
46868 | '8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4' | ||
46869 | ], | ||
46870 | [ | ||
46871 | '1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610', | ||
46872 | '68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575' | ||
46873 | ], | ||
46874 | [ | ||
46875 | '733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4', | ||
46876 | 'f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d' | ||
46877 | ], | ||
46878 | [ | ||
46879 | '15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c', | ||
46880 | 'd56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d' | ||
46881 | ], | ||
46882 | [ | ||
46883 | 'a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940', | ||
46884 | 'edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629' | ||
46885 | ], | ||
46886 | [ | ||
46887 | 'e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980', | ||
46888 | 'a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06' | ||
46889 | ], | ||
46890 | [ | ||
46891 | '311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3', | ||
46892 | '66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374' | ||
46893 | ], | ||
46894 | [ | ||
46895 | '34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf', | ||
46896 | '9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee' | ||
46897 | ], | ||
46898 | [ | ||
46899 | 'f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63', | ||
46900 | '4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1' | ||
46901 | ], | ||
46902 | [ | ||
46903 | 'd7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448', | ||
46904 | 'fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b' | ||
46905 | ], | ||
46906 | [ | ||
46907 | '32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf', | ||
46908 | '5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661' | ||
46909 | ], | ||
46910 | [ | ||
46911 | '7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5', | ||
46912 | '8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6' | ||
46913 | ], | ||
46914 | [ | ||
46915 | 'ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6', | ||
46916 | '8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e' | ||
46917 | ], | ||
46918 | [ | ||
46919 | '16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5', | ||
46920 | '5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d' | ||
46921 | ], | ||
46922 | [ | ||
46923 | 'eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99', | ||
46924 | 'f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc' | ||
46925 | ], | ||
46926 | [ | ||
46927 | '78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51', | ||
46928 | 'f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4' | ||
46929 | ], | ||
46930 | [ | ||
46931 | '494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5', | ||
46932 | '42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c' | ||
46933 | ], | ||
46934 | [ | ||
46935 | 'a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5', | ||
46936 | '204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b' | ||
46937 | ], | ||
46938 | [ | ||
46939 | 'c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997', | ||
46940 | '4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913' | ||
46941 | ], | ||
46942 | [ | ||
46943 | '841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881', | ||
46944 | '73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154' | ||
46945 | ], | ||
46946 | [ | ||
46947 | '5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5', | ||
46948 | '39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865' | ||
46949 | ], | ||
46950 | [ | ||
46951 | '36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66', | ||
46952 | 'd2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc' | ||
46953 | ], | ||
46954 | [ | ||
46955 | '336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726', | ||
46956 | 'ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224' | ||
46957 | ], | ||
46958 | [ | ||
46959 | '8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede', | ||
46960 | '6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e' | ||
46961 | ], | ||
46962 | [ | ||
46963 | '1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94', | ||
46964 | '60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6' | ||
46965 | ], | ||
46966 | [ | ||
46967 | '85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31', | ||
46968 | '3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511' | ||
46969 | ], | ||
46970 | [ | ||
46971 | '29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51', | ||
46972 | 'b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b' | ||
46973 | ], | ||
46974 | [ | ||
46975 | 'a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252', | ||
46976 | 'ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2' | ||
46977 | ], | ||
46978 | [ | ||
46979 | '4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5', | ||
46980 | 'cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c' | ||
46981 | ], | ||
46982 | [ | ||
46983 | 'd24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b', | ||
46984 | '6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3' | ||
46985 | ], | ||
46986 | [ | ||
46987 | 'ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4', | ||
46988 | '322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d' | ||
46989 | ], | ||
46990 | [ | ||
46991 | 'af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f', | ||
46992 | '6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700' | ||
46993 | ], | ||
46994 | [ | ||
46995 | 'e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889', | ||
46996 | '2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4' | ||
46997 | ], | ||
46998 | [ | ||
46999 | '591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246', | ||
47000 | 'b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196' | ||
47001 | ], | ||
47002 | [ | ||
47003 | '11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984', | ||
47004 | '998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4' | ||
47005 | ], | ||
47006 | [ | ||
47007 | '3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a', | ||
47008 | 'b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257' | ||
47009 | ], | ||
47010 | [ | ||
47011 | 'cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030', | ||
47012 | 'bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13' | ||
47013 | ], | ||
47014 | [ | ||
47015 | 'c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197', | ||
47016 | '6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096' | ||
47017 | ], | ||
47018 | [ | ||
47019 | 'c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593', | ||
47020 | 'c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38' | ||
47021 | ], | ||
47022 | [ | ||
47023 | 'a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef', | ||
47024 | '21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f' | ||
47025 | ], | ||
47026 | [ | ||
47027 | '347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38', | ||
47028 | '60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448' | ||
47029 | ], | ||
47030 | [ | ||
47031 | 'da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a', | ||
47032 | '49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a' | ||
47033 | ], | ||
47034 | [ | ||
47035 | 'c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111', | ||
47036 | '5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4' | ||
47037 | ], | ||
47038 | [ | ||
47039 | '4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502', | ||
47040 | '7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437' | ||
47041 | ], | ||
47042 | [ | ||
47043 | '3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea', | ||
47044 | 'be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7' | ||
47045 | ], | ||
47046 | [ | ||
47047 | 'cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26', | ||
47048 | '8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d' | ||
47049 | ], | ||
47050 | [ | ||
47051 | 'b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986', | ||
47052 | '39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a' | ||
47053 | ], | ||
47054 | [ | ||
47055 | 'd4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e', | ||
47056 | '62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54' | ||
47057 | ], | ||
47058 | [ | ||
47059 | '48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4', | ||
47060 | '25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77' | ||
47061 | ], | ||
47062 | [ | ||
47063 | 'dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda', | ||
47064 | 'ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517' | ||
47065 | ], | ||
47066 | [ | ||
47067 | '6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859', | ||
47068 | 'cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10' | ||
47069 | ], | ||
47070 | [ | ||
47071 | 'e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f', | ||
47072 | 'f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125' | ||
47073 | ], | ||
47074 | [ | ||
47075 | 'eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c', | ||
47076 | '6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e' | ||
47077 | ], | ||
47078 | [ | ||
47079 | '13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942', | ||
47080 | 'fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1' | ||
47081 | ], | ||
47082 | [ | ||
47083 | 'ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a', | ||
47084 | '1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2' | ||
47085 | ], | ||
47086 | [ | ||
47087 | 'b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80', | ||
47088 | '5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423' | ||
47089 | ], | ||
47090 | [ | ||
47091 | 'ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d', | ||
47092 | '438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8' | ||
47093 | ], | ||
47094 | [ | ||
47095 | '8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1', | ||
47096 | 'cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758' | ||
47097 | ], | ||
47098 | [ | ||
47099 | '52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63', | ||
47100 | 'c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375' | ||
47101 | ], | ||
47102 | [ | ||
47103 | 'e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352', | ||
47104 | '6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d' | ||
47105 | ], | ||
47106 | [ | ||
47107 | '7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193', | ||
47108 | 'ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec' | ||
47109 | ], | ||
47110 | [ | ||
47111 | '5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00', | ||
47112 | '9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0' | ||
47113 | ], | ||
47114 | [ | ||
47115 | '32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58', | ||
47116 | 'ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c' | ||
47117 | ], | ||
47118 | [ | ||
47119 | 'e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7', | ||
47120 | 'd3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4' | ||
47121 | ], | ||
47122 | [ | ||
47123 | '8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8', | ||
47124 | 'c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f' | ||
47125 | ], | ||
47126 | [ | ||
47127 | '4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e', | ||
47128 | '67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649' | ||
47129 | ], | ||
47130 | [ | ||
47131 | '3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d', | ||
47132 | 'cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826' | ||
47133 | ], | ||
47134 | [ | ||
47135 | '674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b', | ||
47136 | '299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5' | ||
47137 | ], | ||
47138 | [ | ||
47139 | 'd32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f', | ||
47140 | 'f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87' | ||
47141 | ], | ||
47142 | [ | ||
47143 | '30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6', | ||
47144 | '462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b' | ||
47145 | ], | ||
47146 | [ | ||
47147 | 'be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297', | ||
47148 | '62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc' | ||
47149 | ], | ||
47150 | [ | ||
47151 | '93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a', | ||
47152 | '7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c' | ||
47153 | ], | ||
47154 | [ | ||
47155 | 'b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c', | ||
47156 | 'ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f' | ||
47157 | ], | ||
47158 | [ | ||
47159 | 'd5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52', | ||
47160 | '4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a' | ||
47161 | ], | ||
47162 | [ | ||
47163 | 'd3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb', | ||
47164 | 'bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46' | ||
47165 | ], | ||
47166 | [ | ||
47167 | '463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065', | ||
47168 | 'bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f' | ||
47169 | ], | ||
47170 | [ | ||
47171 | '7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917', | ||
47172 | '603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03' | ||
47173 | ], | ||
47174 | [ | ||
47175 | '74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9', | ||
47176 | 'cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08' | ||
47177 | ], | ||
47178 | [ | ||
47179 | '30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3', | ||
47180 | '553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8' | ||
47181 | ], | ||
47182 | [ | ||
47183 | '9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57', | ||
47184 | '712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373' | ||
47185 | ], | ||
47186 | [ | ||
47187 | '176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66', | ||
47188 | 'ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3' | ||
47189 | ], | ||
47190 | [ | ||
47191 | '75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8', | ||
47192 | '9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8' | ||
47193 | ], | ||
47194 | [ | ||
47195 | '809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721', | ||
47196 | '9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1' | ||
47197 | ], | ||
47198 | [ | ||
47199 | '1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180', | ||
47200 | '4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9' | ||
47201 | ] | ||
47202 | ] | ||
47203 | } | ||
47204 | }; | ||
47205 | |||
47206 | },{}],111:[function(require,module,exports){ | ||
47207 | 'use strict'; | ||
47208 | |||
47209 | var utils = exports; | ||
47210 | var BN = require('bn.js'); | ||
47211 | var minAssert = require('minimalistic-assert'); | ||
47212 | var minUtils = require('minimalistic-crypto-utils'); | ||
47213 | |||
47214 | utils.assert = minAssert; | ||
47215 | utils.toArray = minUtils.toArray; | ||
47216 | utils.zero2 = minUtils.zero2; | ||
47217 | utils.toHex = minUtils.toHex; | ||
47218 | utils.encode = minUtils.encode; | ||
47219 | |||
47220 | // Represent num in a w-NAF form | ||
47221 | function getNAF(num, w) { | ||
47222 | var naf = []; | ||
47223 | var ws = 1 << (w + 1); | ||
47224 | var k = num.clone(); | ||
47225 | while (k.cmpn(1) >= 0) { | ||
47226 | var z; | ||
47227 | if (k.isOdd()) { | ||
47228 | var mod = k.andln(ws - 1); | ||
47229 | if (mod > (ws >> 1) - 1) | ||
47230 | z = (ws >> 1) - mod; | ||
47231 | else | ||
47232 | z = mod; | ||
47233 | k.isubn(z); | ||
47234 | } else { | ||
47235 | z = 0; | ||
47236 | } | ||
47237 | naf.push(z); | ||
47238 | |||
47239 | // Optimization, shift by word if possible | ||
47240 | var shift = (k.cmpn(0) !== 0 && k.andln(ws - 1) === 0) ? (w + 1) : 1; | ||
47241 | for (var i = 1; i < shift; i++) | ||
47242 | naf.push(0); | ||
47243 | k.iushrn(shift); | ||
47244 | } | ||
47245 | |||
47246 | return naf; | ||
47247 | } | ||
47248 | utils.getNAF = getNAF; | ||
47249 | |||
47250 | // Represent k1, k2 in a Joint Sparse Form | ||
47251 | function getJSF(k1, k2) { | ||
47252 | var jsf = [ | ||
47253 | [], | ||
47254 | [] | ||
47255 | ]; | ||
47256 | |||
47257 | k1 = k1.clone(); | ||
47258 | k2 = k2.clone(); | ||
47259 | var d1 = 0; | ||
47260 | var d2 = 0; | ||
47261 | while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) { | ||
47262 | |||
47263 | // First phase | ||
47264 | var m14 = (k1.andln(3) + d1) & 3; | ||
47265 | var m24 = (k2.andln(3) + d2) & 3; | ||
47266 | if (m14 === 3) | ||
47267 | m14 = -1; | ||
47268 | if (m24 === 3) | ||
47269 | m24 = -1; | ||
47270 | var u1; | ||
47271 | if ((m14 & 1) === 0) { | ||
47272 | u1 = 0; | ||
47273 | } else { | ||
47274 | var m8 = (k1.andln(7) + d1) & 7; | ||
47275 | if ((m8 === 3 || m8 === 5) && m24 === 2) | ||
47276 | u1 = -m14; | ||
47277 | else | ||
47278 | u1 = m14; | ||
47279 | } | ||
47280 | jsf[0].push(u1); | ||
47281 | |||
47282 | var u2; | ||
47283 | if ((m24 & 1) === 0) { | ||
47284 | u2 = 0; | ||
47285 | } else { | ||
47286 | var m8 = (k2.andln(7) + d2) & 7; | ||
47287 | if ((m8 === 3 || m8 === 5) && m14 === 2) | ||
47288 | u2 = -m24; | ||
47289 | else | ||
47290 | u2 = m24; | ||
47291 | } | ||
47292 | jsf[1].push(u2); | ||
47293 | |||
47294 | // Second phase | ||
47295 | if (2 * d1 === u1 + 1) | ||
47296 | d1 = 1 - d1; | ||
47297 | if (2 * d2 === u2 + 1) | ||
47298 | d2 = 1 - d2; | ||
47299 | k1.iushrn(1); | ||
47300 | k2.iushrn(1); | ||
47301 | } | ||
47302 | |||
47303 | return jsf; | ||
47304 | } | ||
47305 | utils.getJSF = getJSF; | ||
47306 | |||
47307 | function cachedProperty(obj, name, computer) { | ||
47308 | var key = '_' + name; | ||
47309 | obj.prototype[name] = function cachedProperty() { | ||
47310 | return this[key] !== undefined ? this[key] : | ||
47311 | this[key] = computer.call(this); | ||
47312 | }; | ||
47313 | } | ||
47314 | utils.cachedProperty = cachedProperty; | ||
47315 | |||
47316 | function parseBytes(bytes) { | ||
47317 | return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') : | ||
47318 | bytes; | ||
47319 | } | ||
47320 | utils.parseBytes = parseBytes; | ||
47321 | |||
47322 | function intFromLE(bytes) { | ||
47323 | return new BN(bytes, 'hex', 'le'); | ||
47324 | } | ||
47325 | utils.intFromLE = intFromLE; | ||
47326 | |||
47327 | |||
47328 | },{"bn.js":81,"minimalistic-assert":123,"minimalistic-crypto-utils":124}],112:[function(require,module,exports){ | ||
47329 | module.exports={ | ||
47330 | "_args": [ | ||
47331 | [ | ||
47332 | "elliptic", | ||
47333 | "/home/ian/git/bitcoin/bitcoinjs-lib-browser" | ||
47334 | ] | ||
47335 | ], | ||
47336 | "_from": "elliptic@latest", | ||
47337 | "_id": "elliptic@6.4.0", | ||
47338 | "_inCache": true, | ||
47339 | "_installable": true, | ||
47340 | "_location": "/elliptic", | ||
47341 | "_nodeVersion": "7.0.0", | ||
47342 | "_npmOperationalInternal": { | ||
47343 | "host": "packages-18-east.internal.npmjs.com", | ||
47344 | "tmp": "tmp/elliptic-6.4.0.tgz_1487798866428_0.30510620190761983" | ||
47345 | }, | ||
47346 | "_npmUser": { | ||
47347 | "email": "fedor@indutny.com", | ||
47348 | "name": "indutny" | ||
47349 | }, | ||
47350 | "_npmVersion": "3.10.8", | ||
47351 | "_phantomChildren": {}, | ||
47352 | "_requested": { | ||
47353 | "name": "elliptic", | ||
47354 | "raw": "elliptic", | ||
47355 | "rawSpec": "", | ||
47356 | "scope": null, | ||
47357 | "spec": "latest", | ||
47358 | "type": "tag" | ||
47359 | }, | ||
47360 | "_requiredBy": [ | ||
47361 | "#USER" | ||
47362 | ], | ||
47363 | "_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz", | ||
47364 | "_shasum": "cac9af8762c85836187003c8dfe193e5e2eae5df", | ||
47365 | "_shrinkwrap": null, | ||
47366 | "_spec": "elliptic", | ||
47367 | "_where": "/home/ian/git/bitcoin/bitcoinjs-lib-browser", | ||
47368 | "author": { | ||
47369 | "email": "fedor@indutny.com", | ||
47370 | "name": "Fedor Indutny" | ||
47371 | }, | ||
47372 | "bugs": { | ||
47373 | "url": "https://github.com/indutny/elliptic/issues" | ||
47374 | }, | ||
47375 | "dependencies": { | ||
47376 | "bn.js": "^4.4.0", | ||
47377 | "brorand": "^1.0.1", | ||
47378 | "hash.js": "^1.0.0", | ||
47379 | "hmac-drbg": "^1.0.0", | ||
47380 | "inherits": "^2.0.1", | ||
47381 | "minimalistic-assert": "^1.0.0", | ||
47382 | "minimalistic-crypto-utils": "^1.0.0" | ||
47383 | }, | ||
47384 | "description": "EC cryptography", | ||
47385 | "devDependencies": { | ||
47386 | "brfs": "^1.4.3", | ||
47387 | "coveralls": "^2.11.3", | ||
47388 | "grunt": "^0.4.5", | ||
47389 | "grunt-browserify": "^5.0.0", | ||
47390 | "grunt-cli": "^1.2.0", | ||
47391 | "grunt-contrib-connect": "^1.0.0", | ||
47392 | "grunt-contrib-copy": "^1.0.0", | ||
47393 | "grunt-contrib-uglify": "^1.0.1", | ||
47394 | "grunt-mocha-istanbul": "^3.0.1", | ||
47395 | "grunt-saucelabs": "^8.6.2", | ||
47396 | "istanbul": "^0.4.2", | ||
47397 | "jscs": "^2.9.0", | ||
47398 | "jshint": "^2.6.0", | ||
47399 | "mocha": "^2.1.0" | ||
47400 | }, | ||
47401 | "directories": {}, | ||
47402 | "dist": { | ||
47403 | "shasum": "cac9af8762c85836187003c8dfe193e5e2eae5df", | ||
47404 | "tarball": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz" | ||
47405 | }, | ||
47406 | "files": [ | ||
47407 | "lib" | ||
47408 | ], | ||
47409 | "gitHead": "6b0d2b76caae91471649c8e21f0b1d3ba0f96090", | ||
47410 | "homepage": "https://github.com/indutny/elliptic", | ||
47411 | "keywords": [ | ||
47412 | "EC", | ||
47413 | "Elliptic", | ||
47414 | "curve", | ||
47415 | "Cryptography" | ||
47416 | ], | ||
47417 | "license": "MIT", | ||
47418 | "main": "lib/elliptic.js", | ||
47419 | "maintainers": [ | ||
47420 | { | ||
47421 | "email": "fedor@indutny.com", | ||
47422 | "name": "indutny" | ||
47423 | } | ||
47424 | ], | ||
47425 | "name": "elliptic", | ||
47426 | "optionalDependencies": {}, | ||
47427 | "readme": "ERROR: No README data found!", | ||
47428 | "repository": { | ||
47429 | "type": "git", | ||
47430 | "url": "git+ssh://git@github.com/indutny/elliptic.git" | ||
47431 | }, | ||
47432 | "scripts": { | ||
47433 | "jscs": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js", | ||
47434 | "jshint": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js", | ||
47435 | "lint": "npm run jscs && npm run jshint", | ||
47436 | "test": "npm run lint && npm run unit", | ||
47437 | "unit": "istanbul test _mocha --reporter=spec test/index.js", | ||
47438 | "version": "grunt dist && git add dist/" | ||
47439 | }, | ||
47440 | "version": "6.4.0" | ||
47441 | } | ||
47442 | |||
47443 | },{}],113:[function(require,module,exports){ | ||
47444 | (function (Buffer){ | 39996 | (function (Buffer){ |
47445 | 'use strict' | 39997 | 'use strict' |
47446 | var Transform = require('stream').Transform | 39998 | var Transform = require('stream').Transform |
@@ -47527,1255 +40079,9 @@ HashBase.prototype._digest = function () { | |||
47527 | module.exports = HashBase | 40079 | module.exports = HashBase |
47528 | 40080 | ||
47529 | }).call(this,require("buffer").Buffer) | 40081 | }).call(this,require("buffer").Buffer) |
47530 | },{"buffer":5,"inherits":121,"stream":28}],114:[function(require,module,exports){ | 40082 | },{"buffer":5,"inherits":96,"stream":28}],96:[function(require,module,exports){ |
47531 | var hash = exports; | ||
47532 | |||
47533 | hash.utils = require('./hash/utils'); | ||
47534 | hash.common = require('./hash/common'); | ||
47535 | hash.sha = require('./hash/sha'); | ||
47536 | hash.ripemd = require('./hash/ripemd'); | ||
47537 | hash.hmac = require('./hash/hmac'); | ||
47538 | |||
47539 | // Proxy hash functions to the main object | ||
47540 | hash.sha1 = hash.sha.sha1; | ||
47541 | hash.sha256 = hash.sha.sha256; | ||
47542 | hash.sha224 = hash.sha.sha224; | ||
47543 | hash.sha384 = hash.sha.sha384; | ||
47544 | hash.sha512 = hash.sha.sha512; | ||
47545 | hash.ripemd160 = hash.ripemd.ripemd160; | ||
47546 | |||
47547 | },{"./hash/common":115,"./hash/hmac":116,"./hash/ripemd":117,"./hash/sha":118,"./hash/utils":119}],115:[function(require,module,exports){ | ||
47548 | var hash = require('../hash'); | ||
47549 | var utils = hash.utils; | ||
47550 | var assert = utils.assert; | ||
47551 | |||
47552 | function BlockHash() { | ||
47553 | this.pending = null; | ||
47554 | this.pendingTotal = 0; | ||
47555 | this.blockSize = this.constructor.blockSize; | ||
47556 | this.outSize = this.constructor.outSize; | ||
47557 | this.hmacStrength = this.constructor.hmacStrength; | ||
47558 | this.padLength = this.constructor.padLength / 8; | ||
47559 | this.endian = 'big'; | ||
47560 | |||
47561 | this._delta8 = this.blockSize / 8; | ||
47562 | this._delta32 = this.blockSize / 32; | ||
47563 | } | ||
47564 | exports.BlockHash = BlockHash; | ||
47565 | |||
47566 | BlockHash.prototype.update = function update(msg, enc) { | ||
47567 | // Convert message to array, pad it, and join into 32bit blocks | ||
47568 | msg = utils.toArray(msg, enc); | ||
47569 | if (!this.pending) | ||
47570 | this.pending = msg; | ||
47571 | else | ||
47572 | this.pending = this.pending.concat(msg); | ||
47573 | this.pendingTotal += msg.length; | ||
47574 | |||
47575 | // Enough data, try updating | ||
47576 | if (this.pending.length >= this._delta8) { | ||
47577 | msg = this.pending; | ||
47578 | |||
47579 | // Process pending data in blocks | ||
47580 | var r = msg.length % this._delta8; | ||
47581 | this.pending = msg.slice(msg.length - r, msg.length); | ||
47582 | if (this.pending.length === 0) | ||
47583 | this.pending = null; | ||
47584 | |||
47585 | msg = utils.join32(msg, 0, msg.length - r, this.endian); | ||
47586 | for (var i = 0; i < msg.length; i += this._delta32) | ||
47587 | this._update(msg, i, i + this._delta32); | ||
47588 | } | ||
47589 | |||
47590 | return this; | ||
47591 | }; | ||
47592 | |||
47593 | BlockHash.prototype.digest = function digest(enc) { | ||
47594 | this.update(this._pad()); | ||
47595 | assert(this.pending === null); | ||
47596 | |||
47597 | return this._digest(enc); | ||
47598 | }; | ||
47599 | |||
47600 | BlockHash.prototype._pad = function pad() { | ||
47601 | var len = this.pendingTotal; | ||
47602 | var bytes = this._delta8; | ||
47603 | var k = bytes - ((len + this.padLength) % bytes); | ||
47604 | var res = new Array(k + this.padLength); | ||
47605 | res[0] = 0x80; | ||
47606 | for (var i = 1; i < k; i++) | ||
47607 | res[i] = 0; | ||
47608 | |||
47609 | // Append length | ||
47610 | len <<= 3; | ||
47611 | if (this.endian === 'big') { | ||
47612 | for (var t = 8; t < this.padLength; t++) | ||
47613 | res[i++] = 0; | ||
47614 | |||
47615 | res[i++] = 0; | ||
47616 | res[i++] = 0; | ||
47617 | res[i++] = 0; | ||
47618 | res[i++] = 0; | ||
47619 | res[i++] = (len >>> 24) & 0xff; | ||
47620 | res[i++] = (len >>> 16) & 0xff; | ||
47621 | res[i++] = (len >>> 8) & 0xff; | ||
47622 | res[i++] = len & 0xff; | ||
47623 | } else { | ||
47624 | res[i++] = len & 0xff; | ||
47625 | res[i++] = (len >>> 8) & 0xff; | ||
47626 | res[i++] = (len >>> 16) & 0xff; | ||
47627 | res[i++] = (len >>> 24) & 0xff; | ||
47628 | res[i++] = 0; | ||
47629 | res[i++] = 0; | ||
47630 | res[i++] = 0; | ||
47631 | res[i++] = 0; | ||
47632 | |||
47633 | for (var t = 8; t < this.padLength; t++) | ||
47634 | res[i++] = 0; | ||
47635 | } | ||
47636 | |||
47637 | return res; | ||
47638 | }; | ||
47639 | |||
47640 | },{"../hash":114}],116:[function(require,module,exports){ | ||
47641 | var hmac = exports; | ||
47642 | |||
47643 | var hash = require('../hash'); | ||
47644 | var utils = hash.utils; | ||
47645 | var assert = utils.assert; | ||
47646 | |||
47647 | function Hmac(hash, key, enc) { | ||
47648 | if (!(this instanceof Hmac)) | ||
47649 | return new Hmac(hash, key, enc); | ||
47650 | this.Hash = hash; | ||
47651 | this.blockSize = hash.blockSize / 8; | ||
47652 | this.outSize = hash.outSize / 8; | ||
47653 | this.inner = null; | ||
47654 | this.outer = null; | ||
47655 | |||
47656 | this._init(utils.toArray(key, enc)); | ||
47657 | } | ||
47658 | module.exports = Hmac; | ||
47659 | |||
47660 | Hmac.prototype._init = function init(key) { | ||
47661 | // Shorten key, if needed | ||
47662 | if (key.length > this.blockSize) | ||
47663 | key = new this.Hash().update(key).digest(); | ||
47664 | assert(key.length <= this.blockSize); | ||
47665 | |||
47666 | // Add padding to key | ||
47667 | for (var i = key.length; i < this.blockSize; i++) | ||
47668 | key.push(0); | ||
47669 | |||
47670 | for (var i = 0; i < key.length; i++) | ||
47671 | key[i] ^= 0x36; | ||
47672 | this.inner = new this.Hash().update(key); | ||
47673 | |||
47674 | // 0x36 ^ 0x5c = 0x6a | ||
47675 | for (var i = 0; i < key.length; i++) | ||
47676 | key[i] ^= 0x6a; | ||
47677 | this.outer = new this.Hash().update(key); | ||
47678 | }; | ||
47679 | |||
47680 | Hmac.prototype.update = function update(msg, enc) { | ||
47681 | this.inner.update(msg, enc); | ||
47682 | return this; | ||
47683 | }; | ||
47684 | |||
47685 | Hmac.prototype.digest = function digest(enc) { | ||
47686 | this.outer.update(this.inner.digest()); | ||
47687 | return this.outer.digest(enc); | ||
47688 | }; | ||
47689 | |||
47690 | },{"../hash":114}],117:[function(require,module,exports){ | ||
47691 | var hash = require('../hash'); | ||
47692 | var utils = hash.utils; | ||
47693 | |||
47694 | var rotl32 = utils.rotl32; | ||
47695 | var sum32 = utils.sum32; | ||
47696 | var sum32_3 = utils.sum32_3; | ||
47697 | var sum32_4 = utils.sum32_4; | ||
47698 | var BlockHash = hash.common.BlockHash; | ||
47699 | |||
47700 | function RIPEMD160() { | ||
47701 | if (!(this instanceof RIPEMD160)) | ||
47702 | return new RIPEMD160(); | ||
47703 | |||
47704 | BlockHash.call(this); | ||
47705 | |||
47706 | this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ]; | ||
47707 | this.endian = 'little'; | ||
47708 | } | ||
47709 | utils.inherits(RIPEMD160, BlockHash); | ||
47710 | exports.ripemd160 = RIPEMD160; | ||
47711 | |||
47712 | RIPEMD160.blockSize = 512; | ||
47713 | RIPEMD160.outSize = 160; | ||
47714 | RIPEMD160.hmacStrength = 192; | ||
47715 | RIPEMD160.padLength = 64; | ||
47716 | |||
47717 | RIPEMD160.prototype._update = function update(msg, start) { | ||
47718 | var A = this.h[0]; | ||
47719 | var B = this.h[1]; | ||
47720 | var C = this.h[2]; | ||
47721 | var D = this.h[3]; | ||
47722 | var E = this.h[4]; | ||
47723 | var Ah = A; | ||
47724 | var Bh = B; | ||
47725 | var Ch = C; | ||
47726 | var Dh = D; | ||
47727 | var Eh = E; | ||
47728 | for (var j = 0; j < 80; j++) { | ||
47729 | var T = sum32( | ||
47730 | rotl32( | ||
47731 | sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)), | ||
47732 | s[j]), | ||
47733 | E); | ||
47734 | A = E; | ||
47735 | E = D; | ||
47736 | D = rotl32(C, 10); | ||
47737 | C = B; | ||
47738 | B = T; | ||
47739 | T = sum32( | ||
47740 | rotl32( | ||
47741 | sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)), | ||
47742 | sh[j]), | ||
47743 | Eh); | ||
47744 | Ah = Eh; | ||
47745 | Eh = Dh; | ||
47746 | Dh = rotl32(Ch, 10); | ||
47747 | Ch = Bh; | ||
47748 | Bh = T; | ||
47749 | } | ||
47750 | T = sum32_3(this.h[1], C, Dh); | ||
47751 | this.h[1] = sum32_3(this.h[2], D, Eh); | ||
47752 | this.h[2] = sum32_3(this.h[3], E, Ah); | ||
47753 | this.h[3] = sum32_3(this.h[4], A, Bh); | ||
47754 | this.h[4] = sum32_3(this.h[0], B, Ch); | ||
47755 | this.h[0] = T; | ||
47756 | }; | ||
47757 | |||
47758 | RIPEMD160.prototype._digest = function digest(enc) { | ||
47759 | if (enc === 'hex') | ||
47760 | return utils.toHex32(this.h, 'little'); | ||
47761 | else | ||
47762 | return utils.split32(this.h, 'little'); | ||
47763 | }; | ||
47764 | |||
47765 | function f(j, x, y, z) { | ||
47766 | if (j <= 15) | ||
47767 | return x ^ y ^ z; | ||
47768 | else if (j <= 31) | ||
47769 | return (x & y) | ((~x) & z); | ||
47770 | else if (j <= 47) | ||
47771 | return (x | (~y)) ^ z; | ||
47772 | else if (j <= 63) | ||
47773 | return (x & z) | (y & (~z)); | ||
47774 | else | ||
47775 | return x ^ (y | (~z)); | ||
47776 | } | ||
47777 | |||
47778 | function K(j) { | ||
47779 | if (j <= 15) | ||
47780 | return 0x00000000; | ||
47781 | else if (j <= 31) | ||
47782 | return 0x5a827999; | ||
47783 | else if (j <= 47) | ||
47784 | return 0x6ed9eba1; | ||
47785 | else if (j <= 63) | ||
47786 | return 0x8f1bbcdc; | ||
47787 | else | ||
47788 | return 0xa953fd4e; | ||
47789 | } | ||
47790 | |||
47791 | function Kh(j) { | ||
47792 | if (j <= 15) | ||
47793 | return 0x50a28be6; | ||
47794 | else if (j <= 31) | ||
47795 | return 0x5c4dd124; | ||
47796 | else if (j <= 47) | ||
47797 | return 0x6d703ef3; | ||
47798 | else if (j <= 63) | ||
47799 | return 0x7a6d76e9; | ||
47800 | else | ||
47801 | return 0x00000000; | ||
47802 | } | ||
47803 | |||
47804 | var r = [ | ||
47805 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, | ||
47806 | 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, | ||
47807 | 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, | ||
47808 | 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, | ||
47809 | 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13 | ||
47810 | ]; | ||
47811 | |||
47812 | var rh = [ | ||
47813 | 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, | ||
47814 | 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, | ||
47815 | 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, | ||
47816 | 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, | ||
47817 | 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11 | ||
47818 | ]; | ||
47819 | |||
47820 | var s = [ | ||
47821 | 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, | ||
47822 | 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, | ||
47823 | 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, | ||
47824 | 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, | ||
47825 | 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 | ||
47826 | ]; | ||
47827 | |||
47828 | var sh = [ | ||
47829 | 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, | ||
47830 | 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, | ||
47831 | 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, | ||
47832 | 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, | ||
47833 | 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 | ||
47834 | ]; | ||
47835 | |||
47836 | },{"../hash":114}],118:[function(require,module,exports){ | ||
47837 | var hash = require('../hash'); | ||
47838 | var utils = hash.utils; | ||
47839 | var assert = utils.assert; | ||
47840 | |||
47841 | var rotr32 = utils.rotr32; | ||
47842 | var rotl32 = utils.rotl32; | ||
47843 | var sum32 = utils.sum32; | ||
47844 | var sum32_4 = utils.sum32_4; | ||
47845 | var sum32_5 = utils.sum32_5; | ||
47846 | var rotr64_hi = utils.rotr64_hi; | ||
47847 | var rotr64_lo = utils.rotr64_lo; | ||
47848 | var shr64_hi = utils.shr64_hi; | ||
47849 | var shr64_lo = utils.shr64_lo; | ||
47850 | var sum64 = utils.sum64; | ||
47851 | var sum64_hi = utils.sum64_hi; | ||
47852 | var sum64_lo = utils.sum64_lo; | ||
47853 | var sum64_4_hi = utils.sum64_4_hi; | ||
47854 | var sum64_4_lo = utils.sum64_4_lo; | ||
47855 | var sum64_5_hi = utils.sum64_5_hi; | ||
47856 | var sum64_5_lo = utils.sum64_5_lo; | ||
47857 | var BlockHash = hash.common.BlockHash; | ||
47858 | |||
47859 | var sha256_K = [ | ||
47860 | 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, | ||
47861 | 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, | ||
47862 | 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, | ||
47863 | 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, | ||
47864 | 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, | ||
47865 | 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, | ||
47866 | 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, | ||
47867 | 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, | ||
47868 | 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, | ||
47869 | 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, | ||
47870 | 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, | ||
47871 | 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, | ||
47872 | 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, | ||
47873 | 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, | ||
47874 | 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, | ||
47875 | 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 | ||
47876 | ]; | ||
47877 | |||
47878 | var sha512_K = [ | ||
47879 | 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, | ||
47880 | 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc, | ||
47881 | 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019, | ||
47882 | 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118, | ||
47883 | 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe, | ||
47884 | 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2, | ||
47885 | 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1, | ||
47886 | 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694, | ||
47887 | 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3, | ||
47888 | 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65, | ||
47889 | 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483, | ||
47890 | 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5, | ||
47891 | 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210, | ||
47892 | 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4, | ||
47893 | 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725, | ||
47894 | 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70, | ||
47895 | 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926, | ||
47896 | 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df, | ||
47897 | 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8, | ||
47898 | 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b, | ||
47899 | 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001, | ||
47900 | 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30, | ||
47901 | 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910, | ||
47902 | 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8, | ||
47903 | 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53, | ||
47904 | 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8, | ||
47905 | 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb, | ||
47906 | 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3, | ||
47907 | 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60, | ||
47908 | 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec, | ||
47909 | 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9, | ||
47910 | 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b, | ||
47911 | 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207, | ||
47912 | 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178, | ||
47913 | 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6, | ||
47914 | 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b, | ||
47915 | 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493, | ||
47916 | 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c, | ||
47917 | 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, | ||
47918 | 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817 | ||
47919 | ]; | ||
47920 | |||
47921 | var sha1_K = [ | ||
47922 | 0x5A827999, 0x6ED9EBA1, | ||
47923 | 0x8F1BBCDC, 0xCA62C1D6 | ||
47924 | ]; | ||
47925 | |||
47926 | function SHA256() { | ||
47927 | if (!(this instanceof SHA256)) | ||
47928 | return new SHA256(); | ||
47929 | |||
47930 | BlockHash.call(this); | ||
47931 | this.h = [ 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, | ||
47932 | 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 ]; | ||
47933 | this.k = sha256_K; | ||
47934 | this.W = new Array(64); | ||
47935 | } | ||
47936 | utils.inherits(SHA256, BlockHash); | ||
47937 | exports.sha256 = SHA256; | ||
47938 | |||
47939 | SHA256.blockSize = 512; | ||
47940 | SHA256.outSize = 256; | ||
47941 | SHA256.hmacStrength = 192; | ||
47942 | SHA256.padLength = 64; | ||
47943 | |||
47944 | SHA256.prototype._update = function _update(msg, start) { | ||
47945 | var W = this.W; | ||
47946 | |||
47947 | for (var i = 0; i < 16; i++) | ||
47948 | W[i] = msg[start + i]; | ||
47949 | for (; i < W.length; i++) | ||
47950 | W[i] = sum32_4(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]); | ||
47951 | |||
47952 | var a = this.h[0]; | ||
47953 | var b = this.h[1]; | ||
47954 | var c = this.h[2]; | ||
47955 | var d = this.h[3]; | ||
47956 | var e = this.h[4]; | ||
47957 | var f = this.h[5]; | ||
47958 | var g = this.h[6]; | ||
47959 | var h = this.h[7]; | ||
47960 | |||
47961 | assert(this.k.length === W.length); | ||
47962 | for (var i = 0; i < W.length; i++) { | ||
47963 | var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]); | ||
47964 | var T2 = sum32(s0_256(a), maj32(a, b, c)); | ||
47965 | h = g; | ||
47966 | g = f; | ||
47967 | f = e; | ||
47968 | e = sum32(d, T1); | ||
47969 | d = c; | ||
47970 | c = b; | ||
47971 | b = a; | ||
47972 | a = sum32(T1, T2); | ||
47973 | } | ||
47974 | |||
47975 | this.h[0] = sum32(this.h[0], a); | ||
47976 | this.h[1] = sum32(this.h[1], b); | ||
47977 | this.h[2] = sum32(this.h[2], c); | ||
47978 | this.h[3] = sum32(this.h[3], d); | ||
47979 | this.h[4] = sum32(this.h[4], e); | ||
47980 | this.h[5] = sum32(this.h[5], f); | ||
47981 | this.h[6] = sum32(this.h[6], g); | ||
47982 | this.h[7] = sum32(this.h[7], h); | ||
47983 | }; | ||
47984 | |||
47985 | SHA256.prototype._digest = function digest(enc) { | ||
47986 | if (enc === 'hex') | ||
47987 | return utils.toHex32(this.h, 'big'); | ||
47988 | else | ||
47989 | return utils.split32(this.h, 'big'); | ||
47990 | }; | ||
47991 | |||
47992 | function SHA224() { | ||
47993 | if (!(this instanceof SHA224)) | ||
47994 | return new SHA224(); | ||
47995 | |||
47996 | SHA256.call(this); | ||
47997 | this.h = [ 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, | ||
47998 | 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 ]; | ||
47999 | } | ||
48000 | utils.inherits(SHA224, SHA256); | ||
48001 | exports.sha224 = SHA224; | ||
48002 | |||
48003 | SHA224.blockSize = 512; | ||
48004 | SHA224.outSize = 224; | ||
48005 | SHA224.hmacStrength = 192; | ||
48006 | SHA224.padLength = 64; | ||
48007 | |||
48008 | SHA224.prototype._digest = function digest(enc) { | ||
48009 | // Just truncate output | ||
48010 | if (enc === 'hex') | ||
48011 | return utils.toHex32(this.h.slice(0, 7), 'big'); | ||
48012 | else | ||
48013 | return utils.split32(this.h.slice(0, 7), 'big'); | ||
48014 | }; | ||
48015 | |||
48016 | function SHA512() { | ||
48017 | if (!(this instanceof SHA512)) | ||
48018 | return new SHA512(); | ||
48019 | |||
48020 | BlockHash.call(this); | ||
48021 | this.h = [ 0x6a09e667, 0xf3bcc908, | ||
48022 | 0xbb67ae85, 0x84caa73b, | ||
48023 | 0x3c6ef372, 0xfe94f82b, | ||
48024 | 0xa54ff53a, 0x5f1d36f1, | ||
48025 | 0x510e527f, 0xade682d1, | ||
48026 | 0x9b05688c, 0x2b3e6c1f, | ||
48027 | 0x1f83d9ab, 0xfb41bd6b, | ||
48028 | 0x5be0cd19, 0x137e2179 ]; | ||
48029 | this.k = sha512_K; | ||
48030 | this.W = new Array(160); | ||
48031 | } | ||
48032 | utils.inherits(SHA512, BlockHash); | ||
48033 | exports.sha512 = SHA512; | ||
48034 | |||
48035 | SHA512.blockSize = 1024; | ||
48036 | SHA512.outSize = 512; | ||
48037 | SHA512.hmacStrength = 192; | ||
48038 | SHA512.padLength = 128; | ||
48039 | |||
48040 | SHA512.prototype._prepareBlock = function _prepareBlock(msg, start) { | ||
48041 | var W = this.W; | ||
48042 | |||
48043 | // 32 x 32bit words | ||
48044 | for (var i = 0; i < 32; i++) | ||
48045 | W[i] = msg[start + i]; | ||
48046 | for (; i < W.length; i += 2) { | ||
48047 | var c0_hi = g1_512_hi(W[i - 4], W[i - 3]); // i - 2 | ||
48048 | var c0_lo = g1_512_lo(W[i - 4], W[i - 3]); | ||
48049 | var c1_hi = W[i - 14]; // i - 7 | ||
48050 | var c1_lo = W[i - 13]; | ||
48051 | var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); // i - 15 | ||
48052 | var c2_lo = g0_512_lo(W[i - 30], W[i - 29]); | ||
48053 | var c3_hi = W[i - 32]; // i - 16 | ||
48054 | var c3_lo = W[i - 31]; | ||
48055 | |||
48056 | W[i] = sum64_4_hi(c0_hi, c0_lo, | ||
48057 | c1_hi, c1_lo, | ||
48058 | c2_hi, c2_lo, | ||
48059 | c3_hi, c3_lo); | ||
48060 | W[i + 1] = sum64_4_lo(c0_hi, c0_lo, | ||
48061 | c1_hi, c1_lo, | ||
48062 | c2_hi, c2_lo, | ||
48063 | c3_hi, c3_lo); | ||
48064 | } | ||
48065 | }; | ||
48066 | |||
48067 | SHA512.prototype._update = function _update(msg, start) { | ||
48068 | this._prepareBlock(msg, start); | ||
48069 | |||
48070 | var W = this.W; | ||
48071 | |||
48072 | var ah = this.h[0]; | ||
48073 | var al = this.h[1]; | ||
48074 | var bh = this.h[2]; | ||
48075 | var bl = this.h[3]; | ||
48076 | var ch = this.h[4]; | ||
48077 | var cl = this.h[5]; | ||
48078 | var dh = this.h[6]; | ||
48079 | var dl = this.h[7]; | ||
48080 | var eh = this.h[8]; | ||
48081 | var el = this.h[9]; | ||
48082 | var fh = this.h[10]; | ||
48083 | var fl = this.h[11]; | ||
48084 | var gh = this.h[12]; | ||
48085 | var gl = this.h[13]; | ||
48086 | var hh = this.h[14]; | ||
48087 | var hl = this.h[15]; | ||
48088 | |||
48089 | assert(this.k.length === W.length); | ||
48090 | for (var i = 0; i < W.length; i += 2) { | ||
48091 | var c0_hi = hh; | ||
48092 | var c0_lo = hl; | ||
48093 | var c1_hi = s1_512_hi(eh, el); | ||
48094 | var c1_lo = s1_512_lo(eh, el); | ||
48095 | var c2_hi = ch64_hi(eh, el, fh, fl, gh, gl); | ||
48096 | var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl); | ||
48097 | var c3_hi = this.k[i]; | ||
48098 | var c3_lo = this.k[i + 1]; | ||
48099 | var c4_hi = W[i]; | ||
48100 | var c4_lo = W[i + 1]; | ||
48101 | |||
48102 | var T1_hi = sum64_5_hi(c0_hi, c0_lo, | ||
48103 | c1_hi, c1_lo, | ||
48104 | c2_hi, c2_lo, | ||
48105 | c3_hi, c3_lo, | ||
48106 | c4_hi, c4_lo); | ||
48107 | var T1_lo = sum64_5_lo(c0_hi, c0_lo, | ||
48108 | c1_hi, c1_lo, | ||
48109 | c2_hi, c2_lo, | ||
48110 | c3_hi, c3_lo, | ||
48111 | c4_hi, c4_lo); | ||
48112 | |||
48113 | var c0_hi = s0_512_hi(ah, al); | ||
48114 | var c0_lo = s0_512_lo(ah, al); | ||
48115 | var c1_hi = maj64_hi(ah, al, bh, bl, ch, cl); | ||
48116 | var c1_lo = maj64_lo(ah, al, bh, bl, ch, cl); | ||
48117 | |||
48118 | var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo); | ||
48119 | var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo); | ||
48120 | |||
48121 | hh = gh; | ||
48122 | hl = gl; | ||
48123 | |||
48124 | gh = fh; | ||
48125 | gl = fl; | ||
48126 | |||
48127 | fh = eh; | ||
48128 | fl = el; | ||
48129 | |||
48130 | eh = sum64_hi(dh, dl, T1_hi, T1_lo); | ||
48131 | el = sum64_lo(dl, dl, T1_hi, T1_lo); | ||
48132 | |||
48133 | dh = ch; | ||
48134 | dl = cl; | ||
48135 | |||
48136 | ch = bh; | ||
48137 | cl = bl; | ||
48138 | |||
48139 | bh = ah; | ||
48140 | bl = al; | ||
48141 | |||
48142 | ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo); | ||
48143 | al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo); | ||
48144 | } | ||
48145 | |||
48146 | sum64(this.h, 0, ah, al); | ||
48147 | sum64(this.h, 2, bh, bl); | ||
48148 | sum64(this.h, 4, ch, cl); | ||
48149 | sum64(this.h, 6, dh, dl); | ||
48150 | sum64(this.h, 8, eh, el); | ||
48151 | sum64(this.h, 10, fh, fl); | ||
48152 | sum64(this.h, 12, gh, gl); | ||
48153 | sum64(this.h, 14, hh, hl); | ||
48154 | }; | ||
48155 | |||
48156 | SHA512.prototype._digest = function digest(enc) { | ||
48157 | if (enc === 'hex') | ||
48158 | return utils.toHex32(this.h, 'big'); | ||
48159 | else | ||
48160 | return utils.split32(this.h, 'big'); | ||
48161 | }; | ||
48162 | |||
48163 | function SHA384() { | ||
48164 | if (!(this instanceof SHA384)) | ||
48165 | return new SHA384(); | ||
48166 | |||
48167 | SHA512.call(this); | ||
48168 | this.h = [ 0xcbbb9d5d, 0xc1059ed8, | ||
48169 | 0x629a292a, 0x367cd507, | ||
48170 | 0x9159015a, 0x3070dd17, | ||
48171 | 0x152fecd8, 0xf70e5939, | ||
48172 | 0x67332667, 0xffc00b31, | ||
48173 | 0x8eb44a87, 0x68581511, | ||
48174 | 0xdb0c2e0d, 0x64f98fa7, | ||
48175 | 0x47b5481d, 0xbefa4fa4 ]; | ||
48176 | } | ||
48177 | utils.inherits(SHA384, SHA512); | ||
48178 | exports.sha384 = SHA384; | ||
48179 | |||
48180 | SHA384.blockSize = 1024; | ||
48181 | SHA384.outSize = 384; | ||
48182 | SHA384.hmacStrength = 192; | ||
48183 | SHA384.padLength = 128; | ||
48184 | |||
48185 | SHA384.prototype._digest = function digest(enc) { | ||
48186 | if (enc === 'hex') | ||
48187 | return utils.toHex32(this.h.slice(0, 12), 'big'); | ||
48188 | else | ||
48189 | return utils.split32(this.h.slice(0, 12), 'big'); | ||
48190 | }; | ||
48191 | |||
48192 | function SHA1() { | ||
48193 | if (!(this instanceof SHA1)) | ||
48194 | return new SHA1(); | ||
48195 | |||
48196 | BlockHash.call(this); | ||
48197 | this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, | ||
48198 | 0x10325476, 0xc3d2e1f0 ]; | ||
48199 | this.W = new Array(80); | ||
48200 | } | ||
48201 | |||
48202 | utils.inherits(SHA1, BlockHash); | ||
48203 | exports.sha1 = SHA1; | ||
48204 | |||
48205 | SHA1.blockSize = 512; | ||
48206 | SHA1.outSize = 160; | ||
48207 | SHA1.hmacStrength = 80; | ||
48208 | SHA1.padLength = 64; | ||
48209 | |||
48210 | SHA1.prototype._update = function _update(msg, start) { | ||
48211 | var W = this.W; | ||
48212 | |||
48213 | for (var i = 0; i < 16; i++) | ||
48214 | W[i] = msg[start + i]; | ||
48215 | |||
48216 | for(; i < W.length; i++) | ||
48217 | W[i] = rotl32(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1); | ||
48218 | |||
48219 | var a = this.h[0]; | ||
48220 | var b = this.h[1]; | ||
48221 | var c = this.h[2]; | ||
48222 | var d = this.h[3]; | ||
48223 | var e = this.h[4]; | ||
48224 | |||
48225 | for (var i = 0; i < W.length; i++) { | ||
48226 | var s = ~~(i / 20); | ||
48227 | var t = sum32_5(rotl32(a, 5), ft_1(s, b, c, d), e, W[i], sha1_K[s]); | ||
48228 | e = d; | ||
48229 | d = c; | ||
48230 | c = rotl32(b, 30); | ||
48231 | b = a; | ||
48232 | a = t; | ||
48233 | } | ||
48234 | |||
48235 | this.h[0] = sum32(this.h[0], a); | ||
48236 | this.h[1] = sum32(this.h[1], b); | ||
48237 | this.h[2] = sum32(this.h[2], c); | ||
48238 | this.h[3] = sum32(this.h[3], d); | ||
48239 | this.h[4] = sum32(this.h[4], e); | ||
48240 | }; | ||
48241 | |||
48242 | SHA1.prototype._digest = function digest(enc) { | ||
48243 | if (enc === 'hex') | ||
48244 | return utils.toHex32(this.h, 'big'); | ||
48245 | else | ||
48246 | return utils.split32(this.h, 'big'); | ||
48247 | }; | ||
48248 | |||
48249 | function ch32(x, y, z) { | ||
48250 | return (x & y) ^ ((~x) & z); | ||
48251 | } | ||
48252 | |||
48253 | function maj32(x, y, z) { | ||
48254 | return (x & y) ^ (x & z) ^ (y & z); | ||
48255 | } | ||
48256 | |||
48257 | function p32(x, y, z) { | ||
48258 | return x ^ y ^ z; | ||
48259 | } | ||
48260 | |||
48261 | function s0_256(x) { | ||
48262 | return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22); | ||
48263 | } | ||
48264 | |||
48265 | function s1_256(x) { | ||
48266 | return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25); | ||
48267 | } | ||
48268 | |||
48269 | function g0_256(x) { | ||
48270 | return rotr32(x, 7) ^ rotr32(x, 18) ^ (x >>> 3); | ||
48271 | } | ||
48272 | |||
48273 | function g1_256(x) { | ||
48274 | return rotr32(x, 17) ^ rotr32(x, 19) ^ (x >>> 10); | ||
48275 | } | ||
48276 | |||
48277 | function ft_1(s, x, y, z) { | ||
48278 | if (s === 0) | ||
48279 | return ch32(x, y, z); | ||
48280 | if (s === 1 || s === 3) | ||
48281 | return p32(x, y, z); | ||
48282 | if (s === 2) | ||
48283 | return maj32(x, y, z); | ||
48284 | } | ||
48285 | |||
48286 | function ch64_hi(xh, xl, yh, yl, zh, zl) { | ||
48287 | var r = (xh & yh) ^ ((~xh) & zh); | ||
48288 | if (r < 0) | ||
48289 | r += 0x100000000; | ||
48290 | return r; | ||
48291 | } | ||
48292 | |||
48293 | function ch64_lo(xh, xl, yh, yl, zh, zl) { | ||
48294 | var r = (xl & yl) ^ ((~xl) & zl); | ||
48295 | if (r < 0) | ||
48296 | r += 0x100000000; | ||
48297 | return r; | ||
48298 | } | ||
48299 | |||
48300 | function maj64_hi(xh, xl, yh, yl, zh, zl) { | ||
48301 | var r = (xh & yh) ^ (xh & zh) ^ (yh & zh); | ||
48302 | if (r < 0) | ||
48303 | r += 0x100000000; | ||
48304 | return r; | ||
48305 | } | ||
48306 | |||
48307 | function maj64_lo(xh, xl, yh, yl, zh, zl) { | ||
48308 | var r = (xl & yl) ^ (xl & zl) ^ (yl & zl); | ||
48309 | if (r < 0) | ||
48310 | r += 0x100000000; | ||
48311 | return r; | ||
48312 | } | ||
48313 | |||
48314 | function s0_512_hi(xh, xl) { | ||
48315 | var c0_hi = rotr64_hi(xh, xl, 28); | ||
48316 | var c1_hi = rotr64_hi(xl, xh, 2); // 34 | ||
48317 | var c2_hi = rotr64_hi(xl, xh, 7); // 39 | ||
48318 | |||
48319 | var r = c0_hi ^ c1_hi ^ c2_hi; | ||
48320 | if (r < 0) | ||
48321 | r += 0x100000000; | ||
48322 | return r; | ||
48323 | } | ||
48324 | |||
48325 | function s0_512_lo(xh, xl) { | ||
48326 | var c0_lo = rotr64_lo(xh, xl, 28); | ||
48327 | var c1_lo = rotr64_lo(xl, xh, 2); // 34 | ||
48328 | var c2_lo = rotr64_lo(xl, xh, 7); // 39 | ||
48329 | |||
48330 | var r = c0_lo ^ c1_lo ^ c2_lo; | ||
48331 | if (r < 0) | ||
48332 | r += 0x100000000; | ||
48333 | return r; | ||
48334 | } | ||
48335 | |||
48336 | function s1_512_hi(xh, xl) { | ||
48337 | var c0_hi = rotr64_hi(xh, xl, 14); | ||
48338 | var c1_hi = rotr64_hi(xh, xl, 18); | ||
48339 | var c2_hi = rotr64_hi(xl, xh, 9); // 41 | ||
48340 | |||
48341 | var r = c0_hi ^ c1_hi ^ c2_hi; | ||
48342 | if (r < 0) | ||
48343 | r += 0x100000000; | ||
48344 | return r; | ||
48345 | } | ||
48346 | |||
48347 | function s1_512_lo(xh, xl) { | ||
48348 | var c0_lo = rotr64_lo(xh, xl, 14); | ||
48349 | var c1_lo = rotr64_lo(xh, xl, 18); | ||
48350 | var c2_lo = rotr64_lo(xl, xh, 9); // 41 | ||
48351 | |||
48352 | var r = c0_lo ^ c1_lo ^ c2_lo; | ||
48353 | if (r < 0) | ||
48354 | r += 0x100000000; | ||
48355 | return r; | ||
48356 | } | ||
48357 | |||
48358 | function g0_512_hi(xh, xl) { | ||
48359 | var c0_hi = rotr64_hi(xh, xl, 1); | ||
48360 | var c1_hi = rotr64_hi(xh, xl, 8); | ||
48361 | var c2_hi = shr64_hi(xh, xl, 7); | ||
48362 | |||
48363 | var r = c0_hi ^ c1_hi ^ c2_hi; | ||
48364 | if (r < 0) | ||
48365 | r += 0x100000000; | ||
48366 | return r; | ||
48367 | } | ||
48368 | |||
48369 | function g0_512_lo(xh, xl) { | ||
48370 | var c0_lo = rotr64_lo(xh, xl, 1); | ||
48371 | var c1_lo = rotr64_lo(xh, xl, 8); | ||
48372 | var c2_lo = shr64_lo(xh, xl, 7); | ||
48373 | |||
48374 | var r = c0_lo ^ c1_lo ^ c2_lo; | ||
48375 | if (r < 0) | ||
48376 | r += 0x100000000; | ||
48377 | return r; | ||
48378 | } | ||
48379 | |||
48380 | function g1_512_hi(xh, xl) { | ||
48381 | var c0_hi = rotr64_hi(xh, xl, 19); | ||
48382 | var c1_hi = rotr64_hi(xl, xh, 29); // 61 | ||
48383 | var c2_hi = shr64_hi(xh, xl, 6); | ||
48384 | |||
48385 | var r = c0_hi ^ c1_hi ^ c2_hi; | ||
48386 | if (r < 0) | ||
48387 | r += 0x100000000; | ||
48388 | return r; | ||
48389 | } | ||
48390 | |||
48391 | function g1_512_lo(xh, xl) { | ||
48392 | var c0_lo = rotr64_lo(xh, xl, 19); | ||
48393 | var c1_lo = rotr64_lo(xl, xh, 29); // 61 | ||
48394 | var c2_lo = shr64_lo(xh, xl, 6); | ||
48395 | |||
48396 | var r = c0_lo ^ c1_lo ^ c2_lo; | ||
48397 | if (r < 0) | ||
48398 | r += 0x100000000; | ||
48399 | return r; | ||
48400 | } | ||
48401 | |||
48402 | },{"../hash":114}],119:[function(require,module,exports){ | ||
48403 | var utils = exports; | ||
48404 | var inherits = require('inherits'); | ||
48405 | |||
48406 | function toArray(msg, enc) { | ||
48407 | if (Array.isArray(msg)) | ||
48408 | return msg.slice(); | ||
48409 | if (!msg) | ||
48410 | return []; | ||
48411 | var res = []; | ||
48412 | if (typeof msg === 'string') { | ||
48413 | if (!enc) { | ||
48414 | for (var i = 0; i < msg.length; i++) { | ||
48415 | var c = msg.charCodeAt(i); | ||
48416 | var hi = c >> 8; | ||
48417 | var lo = c & 0xff; | ||
48418 | if (hi) | ||
48419 | res.push(hi, lo); | ||
48420 | else | ||
48421 | res.push(lo); | ||
48422 | } | ||
48423 | } else if (enc === 'hex') { | ||
48424 | msg = msg.replace(/[^a-z0-9]+/ig, ''); | ||
48425 | if (msg.length % 2 !== 0) | ||
48426 | msg = '0' + msg; | ||
48427 | for (var i = 0; i < msg.length; i += 2) | ||
48428 | res.push(parseInt(msg[i] + msg[i + 1], 16)); | ||
48429 | } | ||
48430 | } else { | ||
48431 | for (var i = 0; i < msg.length; i++) | ||
48432 | res[i] = msg[i] | 0; | ||
48433 | } | ||
48434 | return res; | ||
48435 | } | ||
48436 | utils.toArray = toArray; | ||
48437 | |||
48438 | function toHex(msg) { | ||
48439 | var res = ''; | ||
48440 | for (var i = 0; i < msg.length; i++) | ||
48441 | res += zero2(msg[i].toString(16)); | ||
48442 | return res; | ||
48443 | } | ||
48444 | utils.toHex = toHex; | ||
48445 | |||
48446 | function htonl(w) { | ||
48447 | var res = (w >>> 24) | | ||
48448 | ((w >>> 8) & 0xff00) | | ||
48449 | ((w << 8) & 0xff0000) | | ||
48450 | ((w & 0xff) << 24); | ||
48451 | return res >>> 0; | ||
48452 | } | ||
48453 | utils.htonl = htonl; | ||
48454 | |||
48455 | function toHex32(msg, endian) { | ||
48456 | var res = ''; | ||
48457 | for (var i = 0; i < msg.length; i++) { | ||
48458 | var w = msg[i]; | ||
48459 | if (endian === 'little') | ||
48460 | w = htonl(w); | ||
48461 | res += zero8(w.toString(16)); | ||
48462 | } | ||
48463 | return res; | ||
48464 | } | ||
48465 | utils.toHex32 = toHex32; | ||
48466 | |||
48467 | function zero2(word) { | ||
48468 | if (word.length === 1) | ||
48469 | return '0' + word; | ||
48470 | else | ||
48471 | return word; | ||
48472 | } | ||
48473 | utils.zero2 = zero2; | ||
48474 | |||
48475 | function zero8(word) { | ||
48476 | if (word.length === 7) | ||
48477 | return '0' + word; | ||
48478 | else if (word.length === 6) | ||
48479 | return '00' + word; | ||
48480 | else if (word.length === 5) | ||
48481 | return '000' + word; | ||
48482 | else if (word.length === 4) | ||
48483 | return '0000' + word; | ||
48484 | else if (word.length === 3) | ||
48485 | return '00000' + word; | ||
48486 | else if (word.length === 2) | ||
48487 | return '000000' + word; | ||
48488 | else if (word.length === 1) | ||
48489 | return '0000000' + word; | ||
48490 | else | ||
48491 | return word; | ||
48492 | } | ||
48493 | utils.zero8 = zero8; | ||
48494 | |||
48495 | function join32(msg, start, end, endian) { | ||
48496 | var len = end - start; | ||
48497 | assert(len % 4 === 0); | ||
48498 | var res = new Array(len / 4); | ||
48499 | for (var i = 0, k = start; i < res.length; i++, k += 4) { | ||
48500 | var w; | ||
48501 | if (endian === 'big') | ||
48502 | w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3]; | ||
48503 | else | ||
48504 | w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k]; | ||
48505 | res[i] = w >>> 0; | ||
48506 | } | ||
48507 | return res; | ||
48508 | } | ||
48509 | utils.join32 = join32; | ||
48510 | |||
48511 | function split32(msg, endian) { | ||
48512 | var res = new Array(msg.length * 4); | ||
48513 | for (var i = 0, k = 0; i < msg.length; i++, k += 4) { | ||
48514 | var m = msg[i]; | ||
48515 | if (endian === 'big') { | ||
48516 | res[k] = m >>> 24; | ||
48517 | res[k + 1] = (m >>> 16) & 0xff; | ||
48518 | res[k + 2] = (m >>> 8) & 0xff; | ||
48519 | res[k + 3] = m & 0xff; | ||
48520 | } else { | ||
48521 | res[k + 3] = m >>> 24; | ||
48522 | res[k + 2] = (m >>> 16) & 0xff; | ||
48523 | res[k + 1] = (m >>> 8) & 0xff; | ||
48524 | res[k] = m & 0xff; | ||
48525 | } | ||
48526 | } | ||
48527 | return res; | ||
48528 | } | ||
48529 | utils.split32 = split32; | ||
48530 | |||
48531 | function rotr32(w, b) { | ||
48532 | return (w >>> b) | (w << (32 - b)); | ||
48533 | } | ||
48534 | utils.rotr32 = rotr32; | ||
48535 | |||
48536 | function rotl32(w, b) { | ||
48537 | return (w << b) | (w >>> (32 - b)); | ||
48538 | } | ||
48539 | utils.rotl32 = rotl32; | ||
48540 | |||
48541 | function sum32(a, b) { | ||
48542 | return (a + b) >>> 0; | ||
48543 | } | ||
48544 | utils.sum32 = sum32; | ||
48545 | |||
48546 | function sum32_3(a, b, c) { | ||
48547 | return (a + b + c) >>> 0; | ||
48548 | } | ||
48549 | utils.sum32_3 = sum32_3; | ||
48550 | |||
48551 | function sum32_4(a, b, c, d) { | ||
48552 | return (a + b + c + d) >>> 0; | ||
48553 | } | ||
48554 | utils.sum32_4 = sum32_4; | ||
48555 | |||
48556 | function sum32_5(a, b, c, d, e) { | ||
48557 | return (a + b + c + d + e) >>> 0; | ||
48558 | } | ||
48559 | utils.sum32_5 = sum32_5; | ||
48560 | |||
48561 | function assert(cond, msg) { | ||
48562 | if (!cond) | ||
48563 | throw new Error(msg || 'Assertion failed'); | ||
48564 | } | ||
48565 | utils.assert = assert; | ||
48566 | |||
48567 | utils.inherits = inherits; | ||
48568 | |||
48569 | function sum64(buf, pos, ah, al) { | ||
48570 | var bh = buf[pos]; | ||
48571 | var bl = buf[pos + 1]; | ||
48572 | |||
48573 | var lo = (al + bl) >>> 0; | ||
48574 | var hi = (lo < al ? 1 : 0) + ah + bh; | ||
48575 | buf[pos] = hi >>> 0; | ||
48576 | buf[pos + 1] = lo; | ||
48577 | } | ||
48578 | exports.sum64 = sum64; | ||
48579 | |||
48580 | function sum64_hi(ah, al, bh, bl) { | ||
48581 | var lo = (al + bl) >>> 0; | ||
48582 | var hi = (lo < al ? 1 : 0) + ah + bh; | ||
48583 | return hi >>> 0; | ||
48584 | }; | ||
48585 | exports.sum64_hi = sum64_hi; | ||
48586 | |||
48587 | function sum64_lo(ah, al, bh, bl) { | ||
48588 | var lo = al + bl; | ||
48589 | return lo >>> 0; | ||
48590 | }; | ||
48591 | exports.sum64_lo = sum64_lo; | ||
48592 | |||
48593 | function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) { | ||
48594 | var carry = 0; | ||
48595 | var lo = al; | ||
48596 | lo = (lo + bl) >>> 0; | ||
48597 | carry += lo < al ? 1 : 0; | ||
48598 | lo = (lo + cl) >>> 0; | ||
48599 | carry += lo < cl ? 1 : 0; | ||
48600 | lo = (lo + dl) >>> 0; | ||
48601 | carry += lo < dl ? 1 : 0; | ||
48602 | |||
48603 | var hi = ah + bh + ch + dh + carry; | ||
48604 | return hi >>> 0; | ||
48605 | }; | ||
48606 | exports.sum64_4_hi = sum64_4_hi; | ||
48607 | |||
48608 | function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) { | ||
48609 | var lo = al + bl + cl + dl; | ||
48610 | return lo >>> 0; | ||
48611 | }; | ||
48612 | exports.sum64_4_lo = sum64_4_lo; | ||
48613 | |||
48614 | function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) { | ||
48615 | var carry = 0; | ||
48616 | var lo = al; | ||
48617 | lo = (lo + bl) >>> 0; | ||
48618 | carry += lo < al ? 1 : 0; | ||
48619 | lo = (lo + cl) >>> 0; | ||
48620 | carry += lo < cl ? 1 : 0; | ||
48621 | lo = (lo + dl) >>> 0; | ||
48622 | carry += lo < dl ? 1 : 0; | ||
48623 | lo = (lo + el) >>> 0; | ||
48624 | carry += lo < el ? 1 : 0; | ||
48625 | |||
48626 | var hi = ah + bh + ch + dh + eh + carry; | ||
48627 | return hi >>> 0; | ||
48628 | }; | ||
48629 | exports.sum64_5_hi = sum64_5_hi; | ||
48630 | |||
48631 | function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) { | ||
48632 | var lo = al + bl + cl + dl + el; | ||
48633 | |||
48634 | return lo >>> 0; | ||
48635 | }; | ||
48636 | exports.sum64_5_lo = sum64_5_lo; | ||
48637 | |||
48638 | function rotr64_hi(ah, al, num) { | ||
48639 | var r = (al << (32 - num)) | (ah >>> num); | ||
48640 | return r >>> 0; | ||
48641 | }; | ||
48642 | exports.rotr64_hi = rotr64_hi; | ||
48643 | |||
48644 | function rotr64_lo(ah, al, num) { | ||
48645 | var r = (ah << (32 - num)) | (al >>> num); | ||
48646 | return r >>> 0; | ||
48647 | }; | ||
48648 | exports.rotr64_lo = rotr64_lo; | ||
48649 | |||
48650 | function shr64_hi(ah, al, num) { | ||
48651 | return ah >>> num; | ||
48652 | }; | ||
48653 | exports.shr64_hi = shr64_hi; | ||
48654 | |||
48655 | function shr64_lo(ah, al, num) { | ||
48656 | var r = (ah << (32 - num)) | (al >>> num); | ||
48657 | return r >>> 0; | ||
48658 | }; | ||
48659 | exports.shr64_lo = shr64_lo; | ||
48660 | |||
48661 | },{"inherits":121}],120:[function(require,module,exports){ | ||
48662 | 'use strict'; | ||
48663 | |||
48664 | var hash = require('hash.js'); | ||
48665 | var utils = require('minimalistic-crypto-utils'); | ||
48666 | var assert = require('minimalistic-assert'); | ||
48667 | |||
48668 | function HmacDRBG(options) { | ||
48669 | if (!(this instanceof HmacDRBG)) | ||
48670 | return new HmacDRBG(options); | ||
48671 | this.hash = options.hash; | ||
48672 | this.predResist = !!options.predResist; | ||
48673 | |||
48674 | this.outLen = this.hash.outSize; | ||
48675 | this.minEntropy = options.minEntropy || this.hash.hmacStrength; | ||
48676 | |||
48677 | this._reseed = null; | ||
48678 | this.reseedInterval = null; | ||
48679 | this.K = null; | ||
48680 | this.V = null; | ||
48681 | |||
48682 | var entropy = utils.toArray(options.entropy, options.entropyEnc || 'hex'); | ||
48683 | var nonce = utils.toArray(options.nonce, options.nonceEnc || 'hex'); | ||
48684 | var pers = utils.toArray(options.pers, options.persEnc || 'hex'); | ||
48685 | assert(entropy.length >= (this.minEntropy / 8), | ||
48686 | 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits'); | ||
48687 | this._init(entropy, nonce, pers); | ||
48688 | } | ||
48689 | module.exports = HmacDRBG; | ||
48690 | |||
48691 | HmacDRBG.prototype._init = function init(entropy, nonce, pers) { | ||
48692 | var seed = entropy.concat(nonce).concat(pers); | ||
48693 | |||
48694 | this.K = new Array(this.outLen / 8); | ||
48695 | this.V = new Array(this.outLen / 8); | ||
48696 | for (var i = 0; i < this.V.length; i++) { | ||
48697 | this.K[i] = 0x00; | ||
48698 | this.V[i] = 0x01; | ||
48699 | } | ||
48700 | |||
48701 | this._update(seed); | ||
48702 | this._reseed = 1; | ||
48703 | this.reseedInterval = 0x1000000000000; // 2^48 | ||
48704 | }; | ||
48705 | |||
48706 | HmacDRBG.prototype._hmac = function hmac() { | ||
48707 | return new hash.hmac(this.hash, this.K); | ||
48708 | }; | ||
48709 | |||
48710 | HmacDRBG.prototype._update = function update(seed) { | ||
48711 | var kmac = this._hmac() | ||
48712 | .update(this.V) | ||
48713 | .update([ 0x00 ]); | ||
48714 | if (seed) | ||
48715 | kmac = kmac.update(seed); | ||
48716 | this.K = kmac.digest(); | ||
48717 | this.V = this._hmac().update(this.V).digest(); | ||
48718 | if (!seed) | ||
48719 | return; | ||
48720 | |||
48721 | this.K = this._hmac() | ||
48722 | .update(this.V) | ||
48723 | .update([ 0x01 ]) | ||
48724 | .update(seed) | ||
48725 | .digest(); | ||
48726 | this.V = this._hmac().update(this.V).digest(); | ||
48727 | }; | ||
48728 | |||
48729 | HmacDRBG.prototype.reseed = function reseed(entropy, entropyEnc, add, addEnc) { | ||
48730 | // Optional entropy enc | ||
48731 | if (typeof entropyEnc !== 'string') { | ||
48732 | addEnc = add; | ||
48733 | add = entropyEnc; | ||
48734 | entropyEnc = null; | ||
48735 | } | ||
48736 | |||
48737 | entropy = utils.toArray(entropy, entropyEnc); | ||
48738 | add = utils.toArray(add, addEnc); | ||
48739 | |||
48740 | assert(entropy.length >= (this.minEntropy / 8), | ||
48741 | 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits'); | ||
48742 | |||
48743 | this._update(entropy.concat(add || [])); | ||
48744 | this._reseed = 1; | ||
48745 | }; | ||
48746 | |||
48747 | HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) { | ||
48748 | if (this._reseed > this.reseedInterval) | ||
48749 | throw new Error('Reseed is required'); | ||
48750 | |||
48751 | // Optional encoding | ||
48752 | if (typeof enc !== 'string') { | ||
48753 | addEnc = add; | ||
48754 | add = enc; | ||
48755 | enc = null; | ||
48756 | } | ||
48757 | |||
48758 | // Optional additional data | ||
48759 | if (add) { | ||
48760 | add = utils.toArray(add, addEnc || 'hex'); | ||
48761 | this._update(add); | ||
48762 | } | ||
48763 | |||
48764 | var temp = []; | ||
48765 | while (temp.length < len) { | ||
48766 | this.V = this._hmac().update(this.V).digest(); | ||
48767 | temp = temp.concat(this.V); | ||
48768 | } | ||
48769 | |||
48770 | var res = temp.slice(0, len); | ||
48771 | this._update(add); | ||
48772 | this._reseed++; | ||
48773 | return utils.encode(res, enc); | ||
48774 | }; | ||
48775 | |||
48776 | },{"hash.js":114,"minimalistic-assert":123,"minimalistic-crypto-utils":124}],121:[function(require,module,exports){ | ||
48777 | arguments[4][9][0].apply(exports,arguments) | 40083 | arguments[4][9][0].apply(exports,arguments) |
48778 | },{"dup":9}],122:[function(require,module,exports){ | 40084 | },{"dup":9}],97:[function(require,module,exports){ |
48779 | (function (Buffer){ | 40085 | (function (Buffer){ |
48780 | // constant-space merkle root calculation algorithm | 40086 | // constant-space merkle root calculation algorithm |
48781 | module.exports = function fastRoot (values, digestFn) { | 40087 | module.exports = function fastRoot (values, digestFn) { |
@@ -48803,80 +40109,7 @@ module.exports = function fastRoot (values, digestFn) { | |||
48803 | } | 40109 | } |
48804 | 40110 | ||
48805 | }).call(this,require("buffer").Buffer) | 40111 | }).call(this,require("buffer").Buffer) |
48806 | },{"buffer":5}],123:[function(require,module,exports){ | 40112 | },{"buffer":5}],98:[function(require,module,exports){ |
48807 | module.exports = assert; | ||
48808 | |||
48809 | function assert(val, msg) { | ||
48810 | if (!val) | ||
48811 | throw new Error(msg || 'Assertion failed'); | ||
48812 | } | ||
48813 | |||
48814 | assert.equal = function assertEqual(l, r, msg) { | ||
48815 | if (l != r) | ||
48816 | throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r)); | ||
48817 | }; | ||
48818 | |||
48819 | },{}],124:[function(require,module,exports){ | ||
48820 | 'use strict'; | ||
48821 | |||
48822 | var utils = exports; | ||
48823 | |||
48824 | function toArray(msg, enc) { | ||
48825 | if (Array.isArray(msg)) | ||
48826 | return msg.slice(); | ||
48827 | if (!msg) | ||
48828 | return []; | ||
48829 | var res = []; | ||
48830 | if (typeof msg !== 'string') { | ||
48831 | for (var i = 0; i < msg.length; i++) | ||
48832 | res[i] = msg[i] | 0; | ||
48833 | return res; | ||
48834 | } | ||
48835 | if (enc === 'hex') { | ||
48836 | msg = msg.replace(/[^a-z0-9]+/ig, ''); | ||
48837 | if (msg.length % 2 !== 0) | ||
48838 | msg = '0' + msg; | ||
48839 | for (var i = 0; i < msg.length; i += 2) | ||
48840 | res.push(parseInt(msg[i] + msg[i + 1], 16)); | ||
48841 | } else { | ||
48842 | for (var i = 0; i < msg.length; i++) { | ||
48843 | var c = msg.charCodeAt(i); | ||
48844 | var hi = c >> 8; | ||
48845 | var lo = c & 0xff; | ||
48846 | if (hi) | ||
48847 | res.push(hi, lo); | ||
48848 | else | ||
48849 | res.push(lo); | ||
48850 | } | ||
48851 | } | ||
48852 | return res; | ||
48853 | } | ||
48854 | utils.toArray = toArray; | ||
48855 | |||
48856 | function zero2(word) { | ||
48857 | if (word.length === 1) | ||
48858 | return '0' + word; | ||
48859 | else | ||
48860 | return word; | ||
48861 | } | ||
48862 | utils.zero2 = zero2; | ||
48863 | |||
48864 | function toHex(msg) { | ||
48865 | var res = ''; | ||
48866 | for (var i = 0; i < msg.length; i++) | ||
48867 | res += zero2(msg[i].toString(16)); | ||
48868 | return res; | ||
48869 | } | ||
48870 | utils.toHex = toHex; | ||
48871 | |||
48872 | utils.encode = function encode(arr, enc) { | ||
48873 | if (enc === 'hex') | ||
48874 | return toHex(arr); | ||
48875 | else | ||
48876 | return arr; | ||
48877 | }; | ||
48878 | |||
48879 | },{}],125:[function(require,module,exports){ | ||
48880 | var OPS = require('bitcoin-ops') | 40113 | var OPS = require('bitcoin-ops') |
48881 | 40114 | ||
48882 | function encodingLength (i) { | 40115 | function encodingLength (i) { |
@@ -48955,12 +40188,12 @@ module.exports = { | |||
48955 | decode: decode | 40188 | decode: decode |
48956 | } | 40189 | } |
48957 | 40190 | ||
48958 | },{"bitcoin-ops":42}],126:[function(require,module,exports){ | 40191 | },{"bitcoin-ops":42}],99:[function(require,module,exports){ |
48959 | (function (process,global){ | 40192 | (function (process,global){ |
48960 | 'use strict' | 40193 | 'use strict' |
48961 | 40194 | ||
48962 | function oldBrowser () { | 40195 | function oldBrowser () { |
48963 | throw new Error('secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11') | 40196 | throw new Error('Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11') |
48964 | } | 40197 | } |
48965 | 40198 | ||
48966 | var Buffer = require('safe-buffer').Buffer | 40199 | var Buffer = require('safe-buffer').Buffer |
@@ -48997,7 +40230,7 @@ function randomBytes (size, cb) { | |||
48997 | } | 40230 | } |
48998 | 40231 | ||
48999 | }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | 40232 | }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) |
49000 | },{"_process":13,"safe-buffer":128}],127:[function(require,module,exports){ | 40233 | },{"_process":13,"safe-buffer":101}],100:[function(require,module,exports){ |
49001 | (function (Buffer){ | 40234 | (function (Buffer){ |
49002 | 'use strict' | 40235 | 'use strict' |
49003 | var inherits = require('inherits') | 40236 | var inherits = require('inherits') |
@@ -49292,7 +40525,7 @@ function fn5 (a, b, c, d, e, m, k, s) { | |||
49292 | module.exports = RIPEMD160 | 40525 | module.exports = RIPEMD160 |
49293 | 40526 | ||
49294 | }).call(this,require("buffer").Buffer) | 40527 | }).call(this,require("buffer").Buffer) |
49295 | },{"buffer":5,"hash-base":113,"inherits":121}],128:[function(require,module,exports){ | 40528 | },{"buffer":5,"hash-base":95,"inherits":96}],101:[function(require,module,exports){ |
49296 | /* eslint-disable node/no-deprecated-api */ | 40529 | /* eslint-disable node/no-deprecated-api */ |
49297 | var buffer = require('buffer') | 40530 | var buffer = require('buffer') |
49298 | var Buffer = buffer.Buffer | 40531 | var Buffer = buffer.Buffer |
@@ -49356,7 +40589,7 @@ SafeBuffer.allocUnsafeSlow = function (size) { | |||
49356 | return buffer.SlowBuffer(size) | 40589 | return buffer.SlowBuffer(size) |
49357 | } | 40590 | } |
49358 | 40591 | ||
49359 | },{"buffer":5}],129:[function(require,module,exports){ | 40592 | },{"buffer":5}],102:[function(require,module,exports){ |
49360 | var Buffer = require('safe-buffer').Buffer | 40593 | var Buffer = require('safe-buffer').Buffer |
49361 | 40594 | ||
49362 | // prototype class for hash functions | 40595 | // prototype class for hash functions |
@@ -49420,7 +40653,7 @@ Hash.prototype.digest = function (enc) { | |||
49420 | 40653 | ||
49421 | // uint64 | 40654 | // uint64 |
49422 | } else { | 40655 | } else { |
49423 | var lowBits = bits & 0xffffffff | 40656 | var lowBits = (bits & 0xffffffff) >>> 0 |
49424 | var highBits = (bits - lowBits) / 0x100000000 | 40657 | var highBits = (bits - lowBits) / 0x100000000 |
49425 | 40658 | ||
49426 | this._block.writeUInt32BE(highBits, this._blockSize - 8) | 40659 | this._block.writeUInt32BE(highBits, this._blockSize - 8) |
@@ -49439,7 +40672,7 @@ Hash.prototype._update = function () { | |||
49439 | 40672 | ||
49440 | module.exports = Hash | 40673 | module.exports = Hash |
49441 | 40674 | ||
49442 | },{"safe-buffer":128}],130:[function(require,module,exports){ | 40675 | },{"safe-buffer":101}],103:[function(require,module,exports){ |
49443 | var exports = module.exports = function SHA (algorithm) { | 40676 | var exports = module.exports = function SHA (algorithm) { |
49444 | algorithm = algorithm.toLowerCase() | 40677 | algorithm = algorithm.toLowerCase() |
49445 | 40678 | ||
@@ -49456,7 +40689,7 @@ exports.sha256 = require('./sha256') | |||
49456 | exports.sha384 = require('./sha384') | 40689 | exports.sha384 = require('./sha384') |
49457 | exports.sha512 = require('./sha512') | 40690 | exports.sha512 = require('./sha512') |
49458 | 40691 | ||
49459 | },{"./sha":131,"./sha1":132,"./sha224":133,"./sha256":134,"./sha384":135,"./sha512":136}],131:[function(require,module,exports){ | 40692 | },{"./sha":104,"./sha1":105,"./sha224":106,"./sha256":107,"./sha384":108,"./sha512":109}],104:[function(require,module,exports){ |
49460 | /* | 40693 | /* |
49461 | * A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined | 40694 | * A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined |
49462 | * in FIPS PUB 180-1 | 40695 | * in FIPS PUB 180-1 |
@@ -49552,7 +40785,7 @@ Sha.prototype._hash = function () { | |||
49552 | 40785 | ||
49553 | module.exports = Sha | 40786 | module.exports = Sha |
49554 | 40787 | ||
49555 | },{"./hash":129,"inherits":121,"safe-buffer":128}],132:[function(require,module,exports){ | 40788 | },{"./hash":102,"inherits":96,"safe-buffer":101}],105:[function(require,module,exports){ |
49556 | /* | 40789 | /* |
49557 | * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined | 40790 | * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined |
49558 | * in FIPS PUB 180-1 | 40791 | * in FIPS PUB 180-1 |
@@ -49653,7 +40886,7 @@ Sha1.prototype._hash = function () { | |||
49653 | 40886 | ||
49654 | module.exports = Sha1 | 40887 | module.exports = Sha1 |
49655 | 40888 | ||
49656 | },{"./hash":129,"inherits":121,"safe-buffer":128}],133:[function(require,module,exports){ | 40889 | },{"./hash":102,"inherits":96,"safe-buffer":101}],106:[function(require,module,exports){ |
49657 | /** | 40890 | /** |
49658 | * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined | 40891 | * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined |
49659 | * in FIPS 180-2 | 40892 | * in FIPS 180-2 |
@@ -49708,7 +40941,7 @@ Sha224.prototype._hash = function () { | |||
49708 | 40941 | ||
49709 | module.exports = Sha224 | 40942 | module.exports = Sha224 |
49710 | 40943 | ||
49711 | },{"./hash":129,"./sha256":134,"inherits":121,"safe-buffer":128}],134:[function(require,module,exports){ | 40944 | },{"./hash":102,"./sha256":107,"inherits":96,"safe-buffer":101}],107:[function(require,module,exports){ |
49712 | /** | 40945 | /** |
49713 | * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined | 40946 | * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined |
49714 | * in FIPS 180-2 | 40947 | * in FIPS 180-2 |
@@ -49845,7 +41078,7 @@ Sha256.prototype._hash = function () { | |||
49845 | 41078 | ||
49846 | module.exports = Sha256 | 41079 | module.exports = Sha256 |
49847 | 41080 | ||
49848 | },{"./hash":129,"inherits":121,"safe-buffer":128}],135:[function(require,module,exports){ | 41081 | },{"./hash":102,"inherits":96,"safe-buffer":101}],108:[function(require,module,exports){ |
49849 | var inherits = require('inherits') | 41082 | var inherits = require('inherits') |
49850 | var SHA512 = require('./sha512') | 41083 | var SHA512 = require('./sha512') |
49851 | var Hash = require('./hash') | 41084 | var Hash = require('./hash') |
@@ -49904,7 +41137,7 @@ Sha384.prototype._hash = function () { | |||
49904 | 41137 | ||
49905 | module.exports = Sha384 | 41138 | module.exports = Sha384 |
49906 | 41139 | ||
49907 | },{"./hash":129,"./sha512":136,"inherits":121,"safe-buffer":128}],136:[function(require,module,exports){ | 41140 | },{"./hash":102,"./sha512":109,"inherits":96,"safe-buffer":101}],109:[function(require,module,exports){ |
49908 | var inherits = require('inherits') | 41141 | var inherits = require('inherits') |
49909 | var Hash = require('./hash') | 41142 | var Hash = require('./hash') |
49910 | var Buffer = require('safe-buffer').Buffer | 41143 | var Buffer = require('safe-buffer').Buffer |
@@ -50166,7 +41399,7 @@ Sha512.prototype._hash = function () { | |||
50166 | 41399 | ||
50167 | module.exports = Sha512 | 41400 | module.exports = Sha512 |
50168 | 41401 | ||
50169 | },{"./hash":129,"inherits":121,"safe-buffer":128}],137:[function(require,module,exports){ | 41402 | },{"./hash":102,"inherits":96,"safe-buffer":101}],110:[function(require,module,exports){ |
50170 | var native = require('./native') | 41403 | var native = require('./native') |
50171 | 41404 | ||
50172 | function getTypeName (fn) { | 41405 | function getTypeName (fn) { |
@@ -50272,7 +41505,7 @@ module.exports = { | |||
50272 | getValueTypeName: getValueTypeName | 41505 | getValueTypeName: getValueTypeName |
50273 | } | 41506 | } |
50274 | 41507 | ||
50275 | },{"./native":140}],138:[function(require,module,exports){ | 41508 | },{"./native":113}],111:[function(require,module,exports){ |
50276 | (function (Buffer){ | 41509 | (function (Buffer){ |
50277 | var NATIVE = require('./native') | 41510 | var NATIVE = require('./native') |
50278 | var ERRORS = require('./errors') | 41511 | var ERRORS = require('./errors') |
@@ -50348,7 +41581,7 @@ for (var typeName in types) { | |||
50348 | module.exports = types | 41581 | module.exports = types |
50349 | 41582 | ||
50350 | }).call(this,{"isBuffer":require("../../../../../.nvm/versions/node/v6.0.0/lib/node_modules/browserify/node_modules/is-buffer/index.js")}) | 41583 | }).call(this,{"isBuffer":require("../../../../../.nvm/versions/node/v6.0.0/lib/node_modules/browserify/node_modules/is-buffer/index.js")}) |
50351 | },{"../../../../../.nvm/versions/node/v6.0.0/lib/node_modules/browserify/node_modules/is-buffer/index.js":10,"./errors":137,"./native":140}],139:[function(require,module,exports){ | 41584 | },{"../../../../../.nvm/versions/node/v6.0.0/lib/node_modules/browserify/node_modules/is-buffer/index.js":10,"./errors":110,"./native":113}],112:[function(require,module,exports){ |
50352 | var ERRORS = require('./errors') | 41585 | var ERRORS = require('./errors') |
50353 | var NATIVE = require('./native') | 41586 | var NATIVE = require('./native') |
50354 | 41587 | ||
@@ -50588,7 +41821,7 @@ typeforce.TfPropertyTypeError = TfPropertyTypeError | |||
50588 | 41821 | ||
50589 | module.exports = typeforce | 41822 | module.exports = typeforce |
50590 | 41823 | ||
50591 | },{"./errors":137,"./extra":138,"./native":140}],140:[function(require,module,exports){ | 41824 | },{"./errors":110,"./extra":111,"./native":113}],113:[function(require,module,exports){ |
50592 | var types = { | 41825 | var types = { |
50593 | Array: function (value) { return value !== null && value !== undefined && value.constructor === Array }, | 41826 | Array: function (value) { return value !== null && value !== undefined && value.constructor === Array }, |
50594 | Boolean: function (value) { return typeof value === 'boolean' }, | 41827 | Boolean: function (value) { return typeof value === 'boolean' }, |
@@ -50611,9 +41844,9 @@ for (var typeName in types) { | |||
50611 | 41844 | ||
50612 | module.exports = types | 41845 | module.exports = types |
50613 | 41846 | ||
50614 | },{}],141:[function(require,module,exports){ | 41847 | },{}],114:[function(require,module,exports){ |
50615 | (function (Buffer){ | ||
50616 | 'use strict' | 41848 | 'use strict' |
41849 | var Buffer = require('safe-buffer').Buffer | ||
50617 | 41850 | ||
50618 | // Number.MAX_SAFE_INTEGER | 41851 | // Number.MAX_SAFE_INTEGER |
50619 | var MAX_SAFE_INTEGER = 9007199254740991 | 41852 | var MAX_SAFE_INTEGER = 9007199254740991 |
@@ -50625,7 +41858,7 @@ function checkUInt53 (n) { | |||
50625 | function encode (number, buffer, offset) { | 41858 | function encode (number, buffer, offset) { |
50626 | checkUInt53(number) | 41859 | checkUInt53(number) |
50627 | 41860 | ||
50628 | if (!buffer) buffer = new Buffer(encodingLength(number)) | 41861 | if (!buffer) buffer = Buffer.allocUnsafe(encodingLength(number)) |
50629 | if (!Buffer.isBuffer(buffer)) throw new TypeError('buffer must be a Buffer instance') | 41862 | if (!Buffer.isBuffer(buffer)) throw new TypeError('buffer must be a Buffer instance') |
50630 | if (!offset) offset = 0 | 41863 | if (!offset) offset = 0 |
50631 | 41864 | ||
@@ -50703,8 +41936,7 @@ function encodingLength (number) { | |||
50703 | 41936 | ||
50704 | module.exports = { encode: encode, decode: decode, encodingLength: encodingLength } | 41937 | module.exports = { encode: encode, decode: decode, encodingLength: encodingLength } |
50705 | 41938 | ||
50706 | }).call(this,require("buffer").Buffer) | 41939 | },{"safe-buffer":101}],115:[function(require,module,exports){ |
50707 | },{"buffer":5}],142:[function(require,module,exports){ | ||
50708 | (function (Buffer){ | 41940 | (function (Buffer){ |
50709 | var bs58check = require('bs58check') | 41941 | var bs58check = require('bs58check') |
50710 | 41942 | ||
@@ -50771,7 +42003,7 @@ module.exports = { | |||
50771 | } | 42003 | } |
50772 | 42004 | ||
50773 | }).call(this,require("buffer").Buffer) | 42005 | }).call(this,require("buffer").Buffer) |
50774 | },{"bs58check":85,"buffer":5}]},{},[34])(34) | 42006 | },{"bs58check":83,"buffer":5}]},{},[34])(34) |
50775 | });</script> | 42007 | });</script> |
50776 | <script>bitcoinjs.bitcoin.networks.shadow = { | 42008 | <script>bitcoinjs.bitcoin.networks.shadow = { |
50777 | messagePrefix: 'unused', | 42009 | messagePrefix: 'unused', |
@@ -50938,6 +42170,17 @@ bitcoinjs.bitcoin.networks.denarius = { | |||
50938 | wif: 0x9e | 42170 | wif: 0x9e |
50939 | }; | 42171 | }; |
50940 | 42172 | ||
42173 | bitcoinjs.bitcoin.networks.neblio = { | ||
42174 | messagePrefix: '\x18Neblio Signed Message:\n', | ||
42175 | bip32: { | ||
42176 | public: 0x0488b21e, | ||
42177 | private: 0x0488ade4 | ||
42178 | }, | ||
42179 | pubKeyHash: 0x35, | ||
42180 | scriptHash: 0x70, | ||
42181 | wif: 0xb5 | ||
42182 | }; | ||
42183 | |||
50941 | bitcoinjs.bitcoin.networks.viacoin = { | 42184 | bitcoinjs.bitcoin.networks.viacoin = { |
50942 | messagePrefix: '\x18Viacoin Signed Message:\n', | 42185 | messagePrefix: '\x18Viacoin Signed Message:\n', |
50943 | bip32: { | 42186 | bip32: { |
@@ -51125,6 +42368,833 @@ bitcoinjs.bitcoin.networks.blackcoin = { | |||
51125 | scriptHash: 0x55, | 42368 | scriptHash: 0x55, |
51126 | wif: 0x99 | 42369 | wif: 0x99 |
51127 | }; | 42370 | }; |
42371 | |||
42372 | bitcoinjs.bitcoin.networks.beetlecoin = { | ||
42373 | messagePrefix: '\x19Beetlecoin Signed Message:\n', | ||
42374 | bip32: { | ||
42375 | public: 0x0488b21e, | ||
42376 | private: 0x0488ade4 | ||
42377 | }, | ||
42378 | pubKeyHash: 0x1A, | ||
42379 | scriptHash: 0x55, | ||
42380 | wif: 0x99, | ||
42381 | }; | ||
42382 | |||
42383 | |||
42384 | bitcoinjs.bitcoin.networks.adcoin = { | ||
42385 | messagePrefix: '\x18AdCoin Signed Message:\n', | ||
42386 | bip32: { | ||
42387 | public: 0x0488B21E, | ||
42388 | private: 0x0488ADE4, | ||
42389 | }, | ||
42390 | pubKeyHash: 0x17, | ||
42391 | scriptHash: 0x05, | ||
42392 | wif: 0xb0, | ||
42393 | }; | ||
42394 | |||
42395 | bitcoinjs.bitcoin.networks.asiacoin = { | ||
42396 | messagePrefix: '\x18AsiaCoin Signed Message:\n', | ||
42397 | bip32: { | ||
42398 | public: 0x0488b21e, | ||
42399 | private: 0x0488ade4, | ||
42400 | }, | ||
42401 | pubKeyHash: 0x17, | ||
42402 | scriptHash: 0x08, | ||
42403 | wif: 0x97, | ||
42404 | }; | ||
42405 | |||
42406 | bitcoinjs.bitcoin.networks.auroracoin = { | ||
42407 | messagePrefix: '\x18AuroraCoin Signed Message:\n', | ||
42408 | bip32: { | ||
42409 | public: 0x0488b21e, | ||
42410 | private: 0x0488ade4, | ||
42411 | }, | ||
42412 | pubKeyHash: 0x17, | ||
42413 | scriptHash: 0x05, | ||
42414 | wif: 0x97, | ||
42415 | }; | ||
42416 | |||
42417 | bitcoinjs.bitcoin.networks.bata = { | ||
42418 | messagePrefix: '\x18Bata Signed Message:\n', | ||
42419 | bip32: { | ||
42420 | public: 0xA40C86FA, | ||
42421 | private: 0xA40B91BD, | ||
42422 | }, | ||
42423 | pubKeyHash: 0x19, | ||
42424 | scriptHash: 0x05, | ||
42425 | wif: 0xa4, | ||
42426 | }; | ||
42427 | |||
42428 | bitcoinjs.bitcoin.networks.belacoin = { | ||
42429 | messagePrefix: '\x18BelaCoin Signed Message:\n', | ||
42430 | bip32: { | ||
42431 | public: 0x0488b21e, | ||
42432 | private: 0x0488ade4, | ||
42433 | }, | ||
42434 | pubKeyHash: 0x19, | ||
42435 | scriptHash: 0x05, | ||
42436 | wif: 0x99, | ||
42437 | }; | ||
42438 | |||
42439 | bitcoinjs.bitcoin.networks.atom = { | ||
42440 | messagePrefix: '\x18Bitcoin Signed Message:\n', | ||
42441 | bip32: { | ||
42442 | public: 0x0488B21E, | ||
42443 | private: 0x0488ADE4, | ||
42444 | }, | ||
42445 | pubKeyHash: 0x17, | ||
42446 | scriptHash: 0x0a, | ||
42447 | wif: 0x80, | ||
42448 | }; | ||
42449 | |||
42450 | bitcoinjs.bitcoin.networks.bitcoinplus = { | ||
42451 | messagePrefix: '\x18BitcoinPlus Signed Message:\n', | ||
42452 | bip32: { | ||
42453 | public: 0x0488b21e, | ||
42454 | private: 0x0488ade4, | ||
42455 | }, | ||
42456 | pubKeyHash: 0x19, | ||
42457 | scriptHash: 0x08, | ||
42458 | wif: 0x99, | ||
42459 | }; | ||
42460 | |||
42461 | bitcoinjs.bitcoin.networks.bitcore = { | ||
42462 | messagePrefix: '\x18BitCore Signed Message:\n', | ||
42463 | bip32: { | ||
42464 | public: 0x0488B21E, | ||
42465 | private: 0x0488ADE4, | ||
42466 | }, | ||
42467 | pubKeyHash: 0x00, | ||
42468 | scriptHash: 0x05, | ||
42469 | wif: 0x80, | ||
42470 | }; | ||
42471 | |||
42472 | bitcoinjs.bitcoin.networks.bitsend = { | ||
42473 | messagePrefix: '\x18Bitsend Signed Message:\n', | ||
42474 | bip32: { | ||
42475 | public: 0x0488B21E, | ||
42476 | private: 0x0488ADE4, | ||
42477 | }, | ||
42478 | pubKeyHash: 0x66, | ||
42479 | scriptHash: 0x05, | ||
42480 | wif: 0xcc, | ||
42481 | }; | ||
42482 | |||
42483 | bitcoinjs.bitcoin.networks.britcoin = { | ||
42484 | messagePrefix: '\x18BritCoin Signed Message:\n', | ||
42485 | bip32: { | ||
42486 | public: 0x0488b21e, | ||
42487 | private: 0x0488ade4, | ||
42488 | }, | ||
42489 | pubKeyHash: 0x19, | ||
42490 | scriptHash: 0x55, | ||
42491 | wif: 0x99, | ||
42492 | }; | ||
42493 | |||
42494 | bitcoinjs.bitcoin.networks.canadaecoin = { | ||
42495 | messagePrefix: '\x18Canada eCoin Signed Message:\n', | ||
42496 | bip32: { | ||
42497 | public: 0x0488b21e, | ||
42498 | private: 0x0488ade4, | ||
42499 | }, | ||
42500 | pubKeyHash: 0x1c, | ||
42501 | scriptHash: 0x05, | ||
42502 | wif: 0x9c, | ||
42503 | }; | ||
42504 | |||
42505 | bitcoinjs.bitcoin.networks.cannacoin = { | ||
42506 | messagePrefix: '\x18Cannacoin Signed Message:\n', | ||
42507 | bip32: { | ||
42508 | public: 0x0488b21e, | ||
42509 | private: 0x0488ade4, | ||
42510 | }, | ||
42511 | pubKeyHash: 0x1c, | ||
42512 | scriptHash: 0x05, | ||
42513 | wif: 0x9c, | ||
42514 | }; | ||
42515 | |||
42516 | bitcoinjs.bitcoin.networks.clubcoin = { | ||
42517 | messagePrefix: '\x18ClubCoin Signed Message:\n', | ||
42518 | bip32: { | ||
42519 | public: 0x0488B21E, | ||
42520 | private: 0x0488ADE4, | ||
42521 | }, | ||
42522 | pubKeyHash: 0x1c, | ||
42523 | scriptHash: 0x55, | ||
42524 | wif: 0x99, | ||
42525 | }; | ||
42526 | |||
42527 | bitcoinjs.bitcoin.networks.compcoin = { | ||
42528 | messagePrefix: '\x18CompCoin Signed Message:\n', | ||
42529 | bip32: { | ||
42530 | public: 0x0488b21e, | ||
42531 | private: 0x0488ade4, | ||
42532 | }, | ||
42533 | pubKeyHash: 0x1c, | ||
42534 | scriptHash: 0x55, | ||
42535 | wif: 0x9c, | ||
42536 | }; | ||
42537 | |||
42538 | bitcoinjs.bitcoin.networks.crave = { | ||
42539 | messagePrefix: '\x18DarkNet Signed Message:\n', | ||
42540 | bip32: { | ||
42541 | public: 0x0488B21E, | ||
42542 | private: 0x0488ADE4, | ||
42543 | }, | ||
42544 | pubKeyHash: 0x46, | ||
42545 | scriptHash: 0x55, | ||
42546 | wif: 0x99, | ||
42547 | }; | ||
42548 | |||
42549 | bitcoinjs.bitcoin.networks.defcoin = { | ||
42550 | messagePrefix: '\x18defcoin Signed Message:\n', | ||
42551 | bip32: { | ||
42552 | public: 0x0488b21e, | ||
42553 | private: 0x0488ade4, | ||
42554 | }, | ||
42555 | pubKeyHash: 0x1e, | ||
42556 | scriptHash: 0x05, | ||
42557 | wif: 0x9e, | ||
42558 | }; | ||
42559 | |||
42560 | bitcoinjs.bitcoin.networks.diamond = { | ||
42561 | messagePrefix: '\x18Diamond Signed Message:\n', | ||
42562 | bip32: { | ||
42563 | public: 0x0488B21E, | ||
42564 | private: 0x0488ADE4, | ||
42565 | }, | ||
42566 | pubKeyHash: 0x5a, | ||
42567 | scriptHash: 0x08, | ||
42568 | wif: 0xda, | ||
42569 | }; | ||
42570 | |||
42571 | bitcoinjs.bitcoin.networks.digibyte = { | ||
42572 | messagePrefix: '\x18DigiByte Signed Message:\n', | ||
42573 | bip32: { | ||
42574 | public: 0x0488B21E, | ||
42575 | private: 0x0488ADE4, | ||
42576 | }, | ||
42577 | pubKeyHash: 0x1e, | ||
42578 | scriptHash: 0x05, | ||
42579 | wif: 0x80, | ||
42580 | }; | ||
42581 | |||
42582 | bitcoinjs.bitcoin.networks.digitalcoin = { | ||
42583 | messagePrefix: '\x18Digitalcoin Signed Message:\n', | ||
42584 | bip32: { | ||
42585 | public: 0x9e0488B2, | ||
42586 | private: 0x0488ADE4, | ||
42587 | }, | ||
42588 | pubKeyHash: 0x1e, | ||
42589 | scriptHash: 0x05, | ||
42590 | wif: 0x9e, | ||
42591 | }; | ||
42592 | |||
42593 | bitcoinjs.bitcoin.networks.ecoin = { | ||
42594 | messagePrefix: '\x18eCoin Signed Message:\n', | ||
42595 | bip32: { | ||
42596 | public: 0x0488b21e, | ||
42597 | private: 0x0488ade4, | ||
42598 | }, | ||
42599 | pubKeyHash: 0x5c, | ||
42600 | scriptHash: 0x14, | ||
42601 | wif: 0xdc, | ||
42602 | }; | ||
42603 | |||
42604 | bitcoinjs.bitcoin.networks.edrcoin = { | ||
42605 | messagePrefix: '\x18EDRcoin Signed Message:\n', | ||
42606 | bip32: { | ||
42607 | public: 0x0488b21e, | ||
42608 | private: 0x0488ade4, | ||
42609 | }, | ||
42610 | pubKeyHash: 0x5d, | ||
42611 | scriptHash: 0x1c, | ||
42612 | wif: 0xdd, | ||
42613 | }; | ||
42614 | |||
42615 | bitcoinjs.bitcoin.networks.egulden = { | ||
42616 | messagePrefix: '\x18Egulden Signed Message:\n', | ||
42617 | bip32: { | ||
42618 | public: 0x0488B21E, | ||
42619 | private: 0x0488ADE4, | ||
42620 | }, | ||
42621 | pubKeyHash: 0x30, | ||
42622 | scriptHash: 0x05, | ||
42623 | wif: 0xb0, | ||
42624 | }; | ||
42625 | |||
42626 | bitcoinjs.bitcoin.networks.einsteinium = { | ||
42627 | messagePrefix: '\x18Einsteinium Signed Message:\n', | ||
42628 | bip32: { | ||
42629 | public: 0x0488b21e, | ||
42630 | private: 0x0488ade4, | ||
42631 | }, | ||
42632 | pubKeyHash: 0x21, | ||
42633 | scriptHash: 0x05, | ||
42634 | wif: 0xa1, | ||
42635 | }; | ||
42636 | |||
42637 | bitcoinjs.bitcoin.networks.europecoin = { | ||
42638 | messagePrefix: '\x18Bitcoin Signed Message:\n', | ||
42639 | bip32: { | ||
42640 | public: 0x0488B21E, | ||
42641 | private: 0x0488ADE4, | ||
42642 | }, | ||
42643 | pubKeyHash: 0x21, | ||
42644 | scriptHash: 0x05, | ||
42645 | wif: 0xa8, | ||
42646 | }; | ||
42647 | |||
42648 | bitcoinjs.bitcoin.networks.exclusivecoin = { | ||
42649 | messagePrefix: '\x18ExclusiveCoin Signed Message:\n', | ||
42650 | bip32: { | ||
42651 | public: 0x0488B21E, | ||
42652 | private: 0x0488ADE4, | ||
42653 | }, | ||
42654 | pubKeyHash: 0x21, | ||
42655 | scriptHash: 0x89, | ||
42656 | wif: 0xa1, | ||
42657 | }; | ||
42658 | |||
42659 | bitcoinjs.bitcoin.networks.feathercoin = { | ||
42660 | messagePrefix: '\x18Feathercoin Signed Message:\n', | ||
42661 | bip32: { | ||
42662 | public: 0x0488BC26, | ||
42663 | private: 0x0488DAEE, | ||
42664 | }, | ||
42665 | pubKeyHash: 0x0e, | ||
42666 | scriptHash: 0x05, | ||
42667 | wif: 0x8e, | ||
42668 | }; | ||
42669 | |||
42670 | bitcoinjs.bitcoin.networks.firstcoin = { | ||
42671 | messagePrefix: '\x18FirstCoin Signed Message:\n', | ||
42672 | bip32: { | ||
42673 | public: 0x0488b21e, | ||
42674 | private: 0x0488ade4, | ||
42675 | }, | ||
42676 | pubKeyHash: 0x23, | ||
42677 | scriptHash: 0x05, | ||
42678 | wif: 0xa3, | ||
42679 | }; | ||
42680 | |||
42681 | bitcoinjs.bitcoin.networks.flashcoin = { | ||
42682 | messagePrefix: '\x18Flashcoin Signed Message:\n', | ||
42683 | bip32: { | ||
42684 | public: 0x0488b21e, | ||
42685 | private: 0x0488ade4, | ||
42686 | }, | ||
42687 | pubKeyHash: 0x44, | ||
42688 | scriptHash: 0x82, | ||
42689 | wif: 0xc4, | ||
42690 | }; | ||
42691 | |||
42692 | bitcoinjs.bitcoin.networks.gcr = { | ||
42693 | messagePrefix: '\x18GCR Signed Message:\n', | ||
42694 | bip32: { | ||
42695 | public: 0x0488B21E, | ||
42696 | private: 0x0488ADE4, | ||
42697 | }, | ||
42698 | pubKeyHash: 0x26, | ||
42699 | scriptHash: 0x61, | ||
42700 | wif: 0x9a, | ||
42701 | }; | ||
42702 | |||
42703 | bitcoinjs.bitcoin.networks.gobyte = { | ||
42704 | messagePrefix: '\x18DarkCoin Signed Message:\n', | ||
42705 | bip32: { | ||
42706 | public: 0x0488B21E, | ||
42707 | private: 0x0488ADE4, | ||
42708 | }, | ||
42709 | pubKeyHash: 0x26, | ||
42710 | scriptHash: 0x0a, | ||
42711 | wif: 0xc6, | ||
42712 | }; | ||
42713 | |||
42714 | bitcoinjs.bitcoin.networks.gridcoin = { | ||
42715 | messagePrefix: '\x18Gridcoin Signed Message:\n', | ||
42716 | bip32: { | ||
42717 | public: 0x0488b21e, | ||
42718 | private: 0x0488ade4, | ||
42719 | }, | ||
42720 | pubKeyHash: 0x3e, | ||
42721 | scriptHash: 0x55, | ||
42722 | wif: 0xbe, | ||
42723 | }; | ||
42724 | |||
42725 | bitcoinjs.bitcoin.networks.gulden = { | ||
42726 | messagePrefix: '\x18Guldencoin Signed Message:\n', | ||
42727 | bip32: { | ||
42728 | public: 0x0488B21E, | ||
42729 | private: 0x0488ADE4, | ||
42730 | }, | ||
42731 | pubKeyHash: 0x26, | ||
42732 | scriptHash: 0x62, | ||
42733 | wif: 0x62, | ||
42734 | }; | ||
42735 | |||
42736 | bitcoinjs.bitcoin.networks.helleniccoin = { | ||
42737 | messagePrefix: '\x18helleniccoin Signed Message:\n', | ||
42738 | bip32: { | ||
42739 | public: 0x0488b21e, | ||
42740 | private: 0x0488ade4, | ||
42741 | }, | ||
42742 | pubKeyHash: 0x30, | ||
42743 | scriptHash: 0x05, | ||
42744 | wif: 0xb0, | ||
42745 | }; | ||
42746 | |||
42747 | bitcoinjs.bitcoin.networks.hempcoin = { | ||
42748 | messagePrefix: '\x18Hempcoin Signed Message:\n', | ||
42749 | bip32: { | ||
42750 | public: 0x0488b21e, | ||
42751 | private: 0x0488ade4, | ||
42752 | }, | ||
42753 | pubKeyHash: 0x28, | ||
42754 | scriptHash: 0x08, | ||
42755 | wif: 0xa8, | ||
42756 | }; | ||
42757 | |||
42758 | bitcoinjs.bitcoin.networks.insane = { | ||
42759 | messagePrefix: '\x18INSaNe Signed Message:\n', | ||
42760 | bip32: { | ||
42761 | public: 0x0488B21E, | ||
42762 | private: 0x0488ADE4, | ||
42763 | }, | ||
42764 | pubKeyHash: 0x66, | ||
42765 | scriptHash: 0x39, | ||
42766 | wif: 0x37, | ||
42767 | }; | ||
42768 | |||
42769 | bitcoinjs.bitcoin.networks.iop = { | ||
42770 | messagePrefix: '\x18IoP Signed Message:\n', | ||
42771 | bip32: { | ||
42772 | public: 0x2780915F, | ||
42773 | private: 0xAE3416F6, | ||
42774 | }, | ||
42775 | pubKeyHash: 0x75, | ||
42776 | scriptHash: 0xae, | ||
42777 | wif: 0x31, | ||
42778 | }; | ||
42779 | |||
42780 | bitcoinjs.bitcoin.networks.ixcoin = { | ||
42781 | messagePrefix: '\x18Ixcoin Signed Message:\n', | ||
42782 | bip32: { | ||
42783 | public: 0x0488B21E, | ||
42784 | private: 0x0488ADE4, | ||
42785 | }, | ||
42786 | pubKeyHash: 0x8a, | ||
42787 | scriptHash: 0x05, | ||
42788 | wif: 0x80, | ||
42789 | }; | ||
42790 | |||
42791 | bitcoinjs.bitcoin.networks.landcoin = { | ||
42792 | messagePrefix: '\x18Landcoin Signed Message:\n', | ||
42793 | bip32: { | ||
42794 | public: 0x0488B21E, | ||
42795 | private: 0x0488ADE4, | ||
42796 | }, | ||
42797 | pubKeyHash: 0x30, | ||
42798 | scriptHash: 0x7a, | ||
42799 | wif: 0xb0, | ||
42800 | }; | ||
42801 | |||
42802 | bitcoinjs.bitcoin.networks.lbry = { | ||
42803 | messagePrefix: '\x18LBRYcrd Signed Message:\n', | ||
42804 | bip32: { | ||
42805 | public: 0x0488B21E, | ||
42806 | private: 0x0488ADE4, | ||
42807 | }, | ||
42808 | pubKeyHash: 0x55, | ||
42809 | scriptHash: 0x7a, | ||
42810 | wif: 0x1c, | ||
42811 | }; | ||
42812 | |||
42813 | bitcoinjs.bitcoin.networks.linx = { | ||
42814 | messagePrefix: '\x18LinX Signed Message:\n', | ||
42815 | bip32: { | ||
42816 | public: 0x0488b21e, | ||
42817 | private: 0x0488ade4, | ||
42818 | }, | ||
42819 | pubKeyHash: 0x4b, | ||
42820 | scriptHash: 0x05, | ||
42821 | wif: 0xcb, | ||
42822 | }; | ||
42823 | |||
42824 | bitcoinjs.bitcoin.networks.litecoincash = { | ||
42825 | messagePrefix: '\x18Litecoin Signed Message:\n', | ||
42826 | bip32: { | ||
42827 | public: 0x0488B21E, | ||
42828 | private: 0x0488ADE4, | ||
42829 | }, | ||
42830 | pubKeyHash: 0x1c, | ||
42831 | scriptHash: 0x05, | ||
42832 | wif: 0xb0, | ||
42833 | }; | ||
42834 | |||
42835 | bitcoinjs.bitcoin.networks.lynx = { | ||
42836 | messagePrefix: '\x18Lynx Signed Message:\n', | ||
42837 | bip32: { | ||
42838 | public: 0x0488B21E, | ||
42839 | private: 0x0488ADE4, | ||
42840 | }, | ||
42841 | pubKeyHash: 0x2d, | ||
42842 | scriptHash: 0x32, | ||
42843 | wif: 0xad, | ||
42844 | }; | ||
42845 | |||
42846 | bitcoinjs.bitcoin.networks.minexcoin = { | ||
42847 | messagePrefix: '\x18Bitcoin Signed Message:\n', | ||
42848 | bip32: { | ||
42849 | public: 0x0488B21E, | ||
42850 | private: 0x0488ADE4, | ||
42851 | }, | ||
42852 | pubKeyHash: 0x4b, | ||
42853 | scriptHash: 0x05, | ||
42854 | wif: 0x80, | ||
42855 | }; | ||
42856 | |||
42857 | bitcoinjs.bitcoin.networks.navcoin = { | ||
42858 | messagePrefix: '\x18Navcoin Signed Message:\n', | ||
42859 | bip32: { | ||
42860 | public: 0x0488B21E, | ||
42861 | private: 0x0488ADE4, | ||
42862 | }, | ||
42863 | pubKeyHash: 0x35, | ||
42864 | scriptHash: 0x55, | ||
42865 | wif: 0x96, | ||
42866 | }; | ||
42867 | |||
42868 | bitcoinjs.bitcoin.networks.neoscoin = { | ||
42869 | messagePrefix: '\x18NeosCoin Signed Message:\n', | ||
42870 | bip32: { | ||
42871 | public: 0x0488B21E, | ||
42872 | private: 0x0488ADE4, | ||
42873 | }, | ||
42874 | pubKeyHash: 0x35, | ||
42875 | scriptHash: 0x05, | ||
42876 | wif: 0xb1, | ||
42877 | }; | ||
42878 | |||
42879 | bitcoinjs.bitcoin.networks.neurocoin = { | ||
42880 | messagePrefix: '\x18PPCoin Signed Message:\n', | ||
42881 | bip32: { | ||
42882 | public: 0x0488B21E, | ||
42883 | private: 0x0488ADE4, | ||
42884 | }, | ||
42885 | pubKeyHash: 0x35, | ||
42886 | scriptHash: 0x75, | ||
42887 | wif: 0xb5, | ||
42888 | }; | ||
42889 | |||
42890 | bitcoinjs.bitcoin.networks.newyorkc = { | ||
42891 | messagePrefix: '\x18newyorkc Signed Message:\n', | ||
42892 | bip32: { | ||
42893 | public: 0x0488b21e, | ||
42894 | private: 0x0488ade4, | ||
42895 | }, | ||
42896 | pubKeyHash: 0x3c, | ||
42897 | scriptHash: 0x16, | ||
42898 | wif: 0xbc, | ||
42899 | }; | ||
42900 | |||
42901 | bitcoinjs.bitcoin.networks.novacoin = { | ||
42902 | messagePrefix: '\x18NovaCoin Signed Message:\n', | ||
42903 | bip32: { | ||
42904 | public: 0x0488b21e, | ||
42905 | private: 0x0488ade4, | ||
42906 | }, | ||
42907 | pubKeyHash: 0x08, | ||
42908 | scriptHash: 0x14, | ||
42909 | wif: 0x88, | ||
42910 | }; | ||
42911 | |||
42912 | bitcoinjs.bitcoin.networks.nushares = { | ||
42913 | messagePrefix: '\x18Nu Signed Message:\n', | ||
42914 | bip32: { | ||
42915 | public: 0x0488b21e, | ||
42916 | private: 0x0488ade4, | ||
42917 | }, | ||
42918 | pubKeyHash: 0x3f, | ||
42919 | scriptHash: 0x40, | ||
42920 | wif: 0x95, | ||
42921 | }; | ||
42922 | |||
42923 | bitcoinjs.bitcoin.networks.okcash = { | ||
42924 | messagePrefix: '\x18OKCash Signed Message:\n', | ||
42925 | bip32: { | ||
42926 | public: 0x03CC23D7, | ||
42927 | private: 0x03CC1C73, | ||
42928 | }, | ||
42929 | pubKeyHash: 0x37, | ||
42930 | scriptHash: 0x1c, | ||
42931 | wif: 0x03, | ||
42932 | }; | ||
42933 | |||
42934 | bitcoinjs.bitcoin.networks.omnicore = { | ||
42935 | messagePrefix: '\x18Bitcoin Signed Message:\n', | ||
42936 | bip32: { | ||
42937 | public: 0x0488B21E, | ||
42938 | private: 0x0488ADE4, | ||
42939 | }, | ||
42940 | pubKeyHash: 0x00, | ||
42941 | scriptHash: 0x05, | ||
42942 | wif: 0x80, | ||
42943 | }; | ||
42944 | |||
42945 | bitcoinjs.bitcoin.networks.pesobit = { | ||
42946 | messagePrefix: '\x18Pesobit Signed Message:\n', | ||
42947 | bip32: { | ||
42948 | public: 0x0488b21e, | ||
42949 | private: 0x0488ade4, | ||
42950 | }, | ||
42951 | pubKeyHash: 0x37, | ||
42952 | scriptHash: 0x55, | ||
42953 | wif: 0xb7, | ||
42954 | }; | ||
42955 | |||
42956 | bitcoinjs.bitcoin.networks.pinkcoin = { | ||
42957 | messagePrefix: '\x18Pinkcoin Signed Message:\n', | ||
42958 | bip32: { | ||
42959 | public: 0x0488b21e, | ||
42960 | private: 0x0488ade4, | ||
42961 | }, | ||
42962 | pubKeyHash: 0x03, | ||
42963 | scriptHash: 0x1c, | ||
42964 | wif: 0x83, | ||
42965 | }; | ||
42966 | |||
42967 | bitcoinjs.bitcoin.networks.poswcoin = { | ||
42968 | messagePrefix: '\x18Poswcoin Signed Message:\n', | ||
42969 | bip32: { | ||
42970 | public: 0x0488b21e, | ||
42971 | private: 0x0488ade4, | ||
42972 | }, | ||
42973 | pubKeyHash: 0x37, | ||
42974 | scriptHash: 0x55, | ||
42975 | wif: 0xb7, | ||
42976 | }; | ||
42977 | |||
42978 | bitcoinjs.bitcoin.networks.potcoin = { | ||
42979 | messagePrefix: '\x18Potcoin Signed Message:\n', | ||
42980 | bip32: { | ||
42981 | public: 0x0488b21e, | ||
42982 | private: 0x0488ade4, | ||
42983 | }, | ||
42984 | pubKeyHash: 0x37, | ||
42985 | scriptHash: 0x05, | ||
42986 | wif: 0xb7, | ||
42987 | }; | ||
42988 | |||
42989 | bitcoinjs.bitcoin.networks.putincoin = { | ||
42990 | messagePrefix: '\x18PutinCoin Signed Message:\n', | ||
42991 | bip32: { | ||
42992 | public: 0x0488b21e, | ||
42993 | private: 0x0488ade4, | ||
42994 | }, | ||
42995 | pubKeyHash: 0x37, | ||
42996 | scriptHash: 0x14, | ||
42997 | wif: 0xb7, | ||
42998 | }; | ||
42999 | |||
43000 | bitcoinjs.bitcoin.networks.reddcoin = { | ||
43001 | messagePrefix: '\x18Reddcoin Signed Message:\n', | ||
43002 | bip32: { | ||
43003 | public: 0x0488B21E, | ||
43004 | private: 0x0488ADE4, | ||
43005 | }, | ||
43006 | pubKeyHash: 0x3d, | ||
43007 | scriptHash: 0x05, | ||
43008 | wif: 0xbd, | ||
43009 | }; | ||
43010 | |||
43011 | bitcoinjs.bitcoin.networks.revolutionvr = { | ||
43012 | messagePrefix: '\x18Voxels Signed Message:\n', | ||
43013 | bip32: { | ||
43014 | public: 0x0488B21E, | ||
43015 | private: 0x0488ADE4, | ||
43016 | }, | ||
43017 | pubKeyHash: 0x46, | ||
43018 | scriptHash: 0x05, | ||
43019 | wif: 0xc6, | ||
43020 | }; | ||
43021 | |||
43022 | bitcoinjs.bitcoin.networks.rubycoin = { | ||
43023 | messagePrefix: '\x18Rubycoin Signed Message:\n', | ||
43024 | bip32: { | ||
43025 | public: 0x0488B21E, | ||
43026 | private: 0x0488ADE4, | ||
43027 | }, | ||
43028 | pubKeyHash: 0x3c, | ||
43029 | scriptHash: 0x55, | ||
43030 | wif: 0xbc, | ||
43031 | }; | ||
43032 | |||
43033 | bitcoinjs.bitcoin.networks.smileycoin = { | ||
43034 | messagePrefix: '\x18Smileycoin Signed Message:\n', | ||
43035 | bip32: { | ||
43036 | public: 0x1E562D9A, | ||
43037 | private: 0x1E5631BC, | ||
43038 | }, | ||
43039 | pubKeyHash: 0x19, | ||
43040 | scriptHash: 0x05, | ||
43041 | wif: 0x05, | ||
43042 | }; | ||
43043 | |||
43044 | bitcoinjs.bitcoin.networks.solarcoin = { | ||
43045 | messagePrefix: '\x18SolarCoin Signed Message:\n', | ||
43046 | bip32: { | ||
43047 | public: 0x0488b21e, | ||
43048 | private: 0x0488ade4, | ||
43049 | }, | ||
43050 | pubKeyHash: 0x12, | ||
43051 | scriptHash: 0x05, | ||
43052 | wif: 0x92, | ||
43053 | }; | ||
43054 | |||
43055 | bitcoinjs.bitcoin.networks.stratis = { | ||
43056 | messagePrefix: '\x18Stratis Signed Message:\n', | ||
43057 | bip32: { | ||
43058 | public: 0x0488B21E, | ||
43059 | private: 0x0488ADE4, | ||
43060 | }, | ||
43061 | pubKeyHash: 0x3f, | ||
43062 | scriptHash: 0x7d, | ||
43063 | wif: 0xbf, | ||
43064 | }; | ||
43065 | |||
43066 | bitcoinjs.bitcoin.networks.syscoin = { | ||
43067 | messagePrefix: '\x18Syscoin Signed Message:\n', | ||
43068 | bip32: { | ||
43069 | public: 0x0488B21E, | ||
43070 | private: 0x0488ADE4, | ||
43071 | }, | ||
43072 | pubKeyHash: 0x3f, | ||
43073 | scriptHash: 0x05, | ||
43074 | wif: 0xbf, | ||
43075 | }; | ||
43076 | |||
43077 | |||
43078 | bitcoinjs.bitcoin.networks.toa = { | ||
43079 | messagePrefix: '\x18TOA Signed Message:\n', | ||
43080 | bip32: { | ||
43081 | public: 0x0488b21e, | ||
43082 | private: 0x0488ade4, | ||
43083 | }, | ||
43084 | pubKeyHash: 0x41, | ||
43085 | scriptHash: 0x17, | ||
43086 | wif: 0xc1, | ||
43087 | }; | ||
43088 | |||
43089 | bitcoinjs.bitcoin.networks.ultimatesecurecash = { | ||
43090 | messagePrefix: '\x18UltimateSecureCash Signed Message:\n', | ||
43091 | bip32: { | ||
43092 | public: 0xEE80286A, | ||
43093 | private: 0xEE8031E8, | ||
43094 | }, | ||
43095 | pubKeyHash: 0x44, | ||
43096 | scriptHash: 0x7d, | ||
43097 | wif: 0xbf, | ||
43098 | }; | ||
43099 | |||
43100 | bitcoinjs.bitcoin.networks.unobtanium = { | ||
43101 | messagePrefix: '\x18Unobtanium Signed Message:\n', | ||
43102 | bip32: { | ||
43103 | public: 0x0488B21E, | ||
43104 | private: 0x0488ADE4, | ||
43105 | }, | ||
43106 | pubKeyHash: 0x82, | ||
43107 | scriptHash: 0x1e, | ||
43108 | wif: 0xe0, | ||
43109 | }; | ||
43110 | |||
43111 | bitcoinjs.bitcoin.networks.vcash = { | ||
43112 | messagePrefix: '\x18Vcash Signed Message:\n', | ||
43113 | bip32: { | ||
43114 | public: 0x0488b21e, | ||
43115 | private: 0x0488ade4, | ||
43116 | }, | ||
43117 | pubKeyHash: 0x47, | ||
43118 | scriptHash: 0x08, | ||
43119 | wif: 0xc7, | ||
43120 | }; | ||
43121 | |||
43122 | bitcoinjs.bitcoin.networks.verge = { | ||
43123 | messagePrefix: '\x18VERGE Signed Message:\n', | ||
43124 | bip32: { | ||
43125 | public: 0x0488b21e, | ||
43126 | private: 0x0488ade4, | ||
43127 | }, | ||
43128 | pubKeyHash: 0x1e, | ||
43129 | scriptHash: 0x21, | ||
43130 | wif: 0x9e, | ||
43131 | }; | ||
43132 | |||
43133 | bitcoinjs.bitcoin.networks.vertcoin = { | ||
43134 | messagePrefix: '\x18Vertcoin Signed Message:\n', | ||
43135 | bip32: { | ||
43136 | public: 0x0488b21e, | ||
43137 | private: 0x0488ade4, | ||
43138 | }, | ||
43139 | pubKeyHash: 0x47, | ||
43140 | scriptHash: 0x05, | ||
43141 | wif: 0xc7, | ||
43142 | }; | ||
43143 | |||
43144 | bitcoinjs.bitcoin.networks.vivo = { | ||
43145 | messagePrefix: '\x18DarkCoin Signed Message:\n', | ||
43146 | bip32: { | ||
43147 | public: 0x0488B21E, | ||
43148 | private: 0x0488ADE4, | ||
43149 | }, | ||
43150 | pubKeyHash: 0x46, | ||
43151 | scriptHash: 0x0a, | ||
43152 | wif: 0xc6, | ||
43153 | }; | ||
43154 | |||
43155 | bitcoinjs.bitcoin.networks.vpncoin = { | ||
43156 | messagePrefix: '\x18VpnCoin Signed Message:\n', | ||
43157 | bip32: { | ||
43158 | public: 0x0488b21e, | ||
43159 | private: 0x0488ade4, | ||
43160 | }, | ||
43161 | pubKeyHash: 0x47, | ||
43162 | scriptHash: 0x05, | ||
43163 | wif: 0xc7, | ||
43164 | }; | ||
43165 | |||
43166 | bitcoinjs.bitcoin.networks.whitecoin = { | ||
43167 | messagePrefix: '\x18Whitecoin Signed Message:\n', | ||
43168 | bip32: { | ||
43169 | public: 0x04887F1E, | ||
43170 | private: 0x048894ED, | ||
43171 | }, | ||
43172 | pubKeyHash: 0x49, | ||
43173 | scriptHash: 0x57, | ||
43174 | wif: 0xc9, | ||
43175 | }; | ||
43176 | |||
43177 | bitcoinjs.bitcoin.networks.wincoin = { | ||
43178 | messagePrefix: '\x18WinCoin Signed Message:\n', | ||
43179 | bip32: { | ||
43180 | public: 0x0488b21e, | ||
43181 | private: 0x0488ade4, | ||
43182 | }, | ||
43183 | pubKeyHash: 0x49, | ||
43184 | scriptHash: 0x1c, | ||
43185 | wif: 0xc9, | ||
43186 | }; | ||
43187 | |||
43188 | bitcoinjs.bitcoin.networks.zcoin = { | ||
43189 | messagePrefix: '\x18Zcoin Signed Message:\n', | ||
43190 | bip32: { | ||
43191 | public: 0x0488B21E, | ||
43192 | private: 0x0488ADE4, | ||
43193 | }, | ||
43194 | pubKeyHash: 0x52, | ||
43195 | scriptHash: 0x07, | ||
43196 | wif: 0xd2, | ||
43197 | }; | ||
51128 | </script> | 43198 | </script> |
51129 | <script>(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.bitcoinjsBip38 = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | 43199 | <script>(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.bitcoinjsBip38 = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ |
51130 | var asn1 = exports; | 43200 | var asn1 = exports; |
@@ -79060,6 +71130,19 @@ bitcoinjs.bitcoin.networks.bitcoin.p2wpkh = { | |||
79060 | wif: 0x80 | 71130 | wif: 0x80 |
79061 | }; | 71131 | }; |
79062 | 71132 | ||
71133 | bitcoinjs.bitcoin.networks.testnet.p2wpkh = { | ||
71134 | baseNetwork: "testnet", | ||
71135 | messagePrefix: '\x18Bitcoin Signed Message:\n', | ||
71136 | bech32: 'tb', | ||
71137 | bip32: { | ||
71138 | public: 0x045f1cf6, | ||
71139 | private: 0x045f18bc | ||
71140 | }, | ||
71141 | pubKeyHash: 0x6f, | ||
71142 | scriptHash: 0xc4, | ||
71143 | wif: 0xef | ||
71144 | }; | ||
71145 | |||
79063 | // p2wpkh in p2sh | 71146 | // p2wpkh in p2sh |
79064 | 71147 | ||
79065 | bitcoinjs.bitcoin.networks.bitcoin.p2wpkhInP2sh = { | 71148 | bitcoinjs.bitcoin.networks.bitcoin.p2wpkhInP2sh = { |
@@ -79100,6 +71183,32 @@ bitcoinjs.bitcoin.networks.litecoin.p2wpkhInP2sh = { | |||
79100 | wif: 0xb0 | 71183 | wif: 0xb0 |
79101 | }; | 71184 | }; |
79102 | 71185 | ||
71186 | bitcoinjs.bitcoin.networks.fujicoin.p2wpkh = { | ||
71187 | baseNetwork: "fujicoin", | ||
71188 | messagePrefix: '\x19FujiCoin Signed Message:\n', | ||
71189 | bech32: 'fc', | ||
71190 | bip32: { | ||
71191 | public: 0x04b24746, | ||
71192 | private: 0x04b2430c | ||
71193 | }, | ||
71194 | pubKeyHash: 0x24, | ||
71195 | scriptHash: 0x10, | ||
71196 | wif: 0xa4 | ||
71197 | }; | ||
71198 | |||
71199 | bitcoinjs.bitcoin.networks.fujicoin.p2wpkhInP2sh = { | ||
71200 | baseNetwork: "fujicoin", | ||
71201 | messagePrefix: '\x19FujiCoin Signed Message:\n', | ||
71202 | bech32: 'fc', | ||
71203 | bip32: { | ||
71204 | public: 0x049d7cb2, | ||
71205 | private: 0x049d7878 | ||
71206 | }, | ||
71207 | pubKeyHash: 0x24, | ||
71208 | scriptHash: 0x10, | ||
71209 | wif: 0xa4 | ||
71210 | }; | ||
71211 | |||
79103 | })(); | 71212 | })(); |
79104 | </script> | 71213 | </script> |
79105 | <script>(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ethUtil = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | 71214 | <script>(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ethUtil = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ |
@@ -104699,6 +96808,7 @@ window.Entropy = new (function() { | |||
104699 | DOM.entropyWordIndexes = DOM.entropyContainer.find(".word-indexes"); | 96808 | DOM.entropyWordIndexes = DOM.entropyContainer.find(".word-indexes"); |
104700 | DOM.entropyChecksum = DOM.entropyContainer.find(".checksum"); | 96809 | DOM.entropyChecksum = DOM.entropyContainer.find(".checksum"); |
104701 | DOM.entropyMnemonicLength = DOM.entropyContainer.find(".mnemonic-length"); | 96810 | DOM.entropyMnemonicLength = DOM.entropyContainer.find(".mnemonic-length"); |
96811 | DOM.entropyWeakEntropyOverrideWarning = DOM.entropyContainer.find(".weak-entropy-override-warning"); | ||
104702 | DOM.entropyFilterWarning = DOM.entropyContainer.find(".filter-warning"); | 96812 | DOM.entropyFilterWarning = DOM.entropyContainer.find(".filter-warning"); |
104703 | DOM.phrase = $(".phrase"); | 96813 | DOM.phrase = $(".phrase"); |
104704 | DOM.passphrase = $(".passphrase"); | 96814 | DOM.passphrase = $(".passphrase"); |
@@ -104747,6 +96857,7 @@ window.Entropy = new (function() { | |||
104747 | DOM.bip141path = $("#bip141-path"); | 96857 | DOM.bip141path = $("#bip141-path"); |
104748 | DOM.bip141semantics = $(".bip141-semantics"); | 96858 | DOM.bip141semantics = $(".bip141-semantics"); |
104749 | DOM.generatedStrength = $(".generate-container .strength"); | 96859 | DOM.generatedStrength = $(".generate-container .strength"); |
96860 | DOM.generatedStrengthWarning = $(".generate-container .warning"); | ||
104750 | DOM.hardenedAddresses = $(".hardened-addresses"); | 96861 | DOM.hardenedAddresses = $(".hardened-addresses"); |
104751 | DOM.useBitpayAddressesContainer = $(".use-bitpay-addresses-container"); | 96862 | DOM.useBitpayAddressesContainer = $(".use-bitpay-addresses-container"); |
104752 | DOM.useBitpayAddresses = $(".use-bitpay-addresses"); | 96863 | DOM.useBitpayAddresses = $(".use-bitpay-addresses"); |
@@ -104773,6 +96884,7 @@ window.Entropy = new (function() { | |||
104773 | 96884 | ||
104774 | function init() { | 96885 | function init() { |
104775 | // Events | 96886 | // Events |
96887 | DOM.generatedStrength.on("change", generatedStrengthChanged); | ||
104776 | DOM.network.on("change", networkChanged); | 96888 | DOM.network.on("change", networkChanged); |
104777 | DOM.bip32Client.on("change", bip32ClientChanged); | 96889 | DOM.bip32Client.on("change", bip32ClientChanged); |
104778 | DOM.useEntropy.on("change", setEntropyVisibility); | 96890 | DOM.useEntropy.on("change", setEntropyVisibility); |
@@ -104814,6 +96926,16 @@ window.Entropy = new (function() { | |||
104814 | 96926 | ||
104815 | // Event handlers | 96927 | // Event handlers |
104816 | 96928 | ||
96929 | function generatedStrengthChanged() { | ||
96930 | var strength = parseInt(DOM.generatedStrength.val()); | ||
96931 | if (strength < 12) { | ||
96932 | DOM.generatedStrengthWarning.removeClass("hidden"); | ||
96933 | } | ||
96934 | else { | ||
96935 | DOM.generatedStrengthWarning.addClass("hidden"); | ||
96936 | } | ||
96937 | } | ||
96938 | |||
104817 | function networkChanged(e) { | 96939 | function networkChanged(e) { |
104818 | clearDerivedKeys(); | 96940 | clearDerivedKeys(); |
104819 | clearAddressesList(); | 96941 | clearAddressesList(); |
@@ -105837,6 +97959,17 @@ window.Entropy = new (function() { | |||
105837 | mnemonicLength = parseInt(mnemonicLength); | 97959 | mnemonicLength = parseInt(mnemonicLength); |
105838 | var numberOfBits = 32 * mnemonicLength / 3; | 97960 | var numberOfBits = 32 * mnemonicLength / 3; |
105839 | bits = bits.substring(0, numberOfBits); | 97961 | bits = bits.substring(0, numberOfBits); |
97962 | // show warning for weak entropy override | ||
97963 | if (mnemonicLength / 3 * 32 > entropy.binaryStr.length) { | ||
97964 | DOM.entropyWeakEntropyOverrideWarning.removeClass("hidden"); | ||
97965 | } | ||
97966 | else { | ||
97967 | DOM.entropyWeakEntropyOverrideWarning.addClass("hidden"); | ||
97968 | } | ||
97969 | } | ||
97970 | else { | ||
97971 | // hide warning for weak entropy override | ||
97972 | DOM.entropyWeakEntropyOverrideWarning.addClass("hidden"); | ||
105840 | } | 97973 | } |
105841 | // Discard trailing entropy | 97974 | // Discard trailing entropy |
105842 | var bitsToUse = Math.floor(bits.length / 32) * 32; | 97975 | var bitsToUse = Math.floor(bits.length / 32) * 32; |
@@ -106174,6 +98307,30 @@ window.Entropy = new (function() { | |||
106174 | 98307 | ||
106175 | var networks = [ | 98308 | var networks = [ |
106176 | { | 98309 | { |
98310 | name: "AC - Asiacoin", | ||
98311 | segwitAvailable: false, | ||
98312 | onSelect: function() { | ||
98313 | network = bitcoinjs.bitcoin.networks.asiacoin; | ||
98314 | setHdCoin(51); | ||
98315 | }, | ||
98316 | }, | ||
98317 | { | ||
98318 | name: "ACC - Adcoin", | ||
98319 | segwitAvailable: true, | ||
98320 | onSelect: function() { | ||
98321 | network = bitcoinjs.bitcoin.networks.adcoin; | ||
98322 | setHdCoin(161); | ||
98323 | }, | ||
98324 | }, | ||
98325 | { | ||
98326 | name: "AUR - Auroracoin", | ||
98327 | segwitAvailable: false, | ||
98328 | onSelect: function() { | ||
98329 | network = bitcoinjs.bitcoin.networks.auroracoin; | ||
98330 | setHdCoin(85); | ||
98331 | }, | ||
98332 | }, | ||
98333 | { | ||
106177 | name: "AXE - Axe", | 98334 | name: "AXE - Axe", |
106178 | segwitAvailable: false, | 98335 | segwitAvailable: false, |
106179 | onSelect: function() { | 98336 | onSelect: function() { |
@@ -106182,6 +98339,14 @@ window.Entropy = new (function() { | |||
106182 | }, | 98339 | }, |
106183 | }, | 98340 | }, |
106184 | { | 98341 | { |
98342 | name: "BCA - Bitcoin Atom", | ||
98343 | segwitAvailable: true, | ||
98344 | onSelect: function() { | ||
98345 | network = bitcoinjs.bitcoin.networks.atom; | ||
98346 | setHdCoin(185); | ||
98347 | }, | ||
98348 | }, | ||
98349 | { | ||
106185 | name: "BCH - Bitcoin Cash", | 98350 | name: "BCH - Bitcoin Cash", |
106186 | segwitAvailable: false, | 98351 | segwitAvailable: false, |
106187 | onSelect: function() { | 98352 | onSelect: function() { |
@@ -106191,6 +98356,22 @@ window.Entropy = new (function() { | |||
106191 | }, | 98356 | }, |
106192 | }, | 98357 | }, |
106193 | { | 98358 | { |
98359 | name: "BEET - Beetlecoin", | ||
98360 | segwitAvailable: false, | ||
98361 | onSelect: function() { | ||
98362 | network = bitcoinjs.bitcoin.networks.beetlecoin; | ||
98363 | setHdCoin(800); | ||
98364 | }, | ||
98365 | }, | ||
98366 | { | ||
98367 | name: "BELA - Belacoin", | ||
98368 | segwitAvailable: false, | ||
98369 | onSelect: function() { | ||
98370 | network = bitcoinjs.bitcoin.networks.belacoin; | ||
98371 | setHdCoin(73); | ||
98372 | }, | ||
98373 | }, | ||
98374 | { | ||
106194 | name: "BLK - BlackCoin", | 98375 | name: "BLK - BlackCoin", |
106195 | segwitAvailable: false, | 98376 | segwitAvailable: false, |
106196 | onSelect: function() { | 98377 | onSelect: function() { |
@@ -106199,6 +98380,30 @@ window.Entropy = new (function() { | |||
106199 | }, | 98380 | }, |
106200 | }, | 98381 | }, |
106201 | { | 98382 | { |
98383 | name: "BRIT - Britcoin", | ||
98384 | segwitAvailable: false, | ||
98385 | onSelect: function() { | ||
98386 | network = bitcoinjs.bitcoin.networks.britcoin; | ||
98387 | setHdCoin(70); | ||
98388 | }, | ||
98389 | }, | ||
98390 | { | ||
98391 | name: "BSD - Bitsend", | ||
98392 | segwitAvailable: true, | ||
98393 | onSelect: function() { | ||
98394 | network = bitcoinjs.bitcoin.networks.bitsend; | ||
98395 | setHdCoin(91); | ||
98396 | }, | ||
98397 | }, | ||
98398 | { | ||
98399 | name: "BTA - Bata", | ||
98400 | segwitAvailable: false, | ||
98401 | onSelect: function() { | ||
98402 | network = bitcoinjs.bitcoin.networks.bata; | ||
98403 | setHdCoin(89); | ||
98404 | }, | ||
98405 | }, | ||
98406 | { | ||
106202 | name: "BTC - Bitcoin", | 98407 | name: "BTC - Bitcoin", |
106203 | segwitAvailable: true, | 98408 | segwitAvailable: true, |
106204 | onSelect: function() { | 98409 | onSelect: function() { |
@@ -106219,7 +98424,31 @@ window.Entropy = new (function() { | |||
106219 | segwitAvailable: true, | 98424 | segwitAvailable: true, |
106220 | onSelect: function() { | 98425 | onSelect: function() { |
106221 | network = bitcoinjs.bitcoin.networks.bgold; | 98426 | network = bitcoinjs.bitcoin.networks.bgold; |
106222 | setHdCoin(0); | 98427 | setHdCoin(156); |
98428 | }, | ||
98429 | }, | ||
98430 | { | ||
98431 | name: "BTX - Bitcore", | ||
98432 | segwitAvailable: true, | ||
98433 | onSelect: function() { | ||
98434 | network = bitcoinjs.bitcoin.networks.bitcore; | ||
98435 | setHdCoin(160); | ||
98436 | }, | ||
98437 | }, | ||
98438 | { | ||
98439 | name: "CCN - Cannacoin", | ||
98440 | segwitAvailable: false, | ||
98441 | onSelect: function() { | ||
98442 | network = bitcoinjs.bitcoin.networks.cannacoin; | ||
98443 | setHdCoin(19); | ||
98444 | }, | ||
98445 | }, | ||
98446 | { | ||
98447 | name: "CDN - Canadaecoin", | ||
98448 | segwitAvailable: false, | ||
98449 | onSelect: function() { | ||
98450 | network = bitcoinjs.bitcoin.networks.canadaecoin; | ||
98451 | setHdCoin(34); | ||
106223 | }, | 98452 | }, |
106224 | }, | 98453 | }, |
106225 | { | 98454 | { |
@@ -106231,6 +98460,30 @@ window.Entropy = new (function() { | |||
106231 | }, | 98460 | }, |
106232 | }, | 98461 | }, |
106233 | { | 98462 | { |
98463 | name: "CLUB - Clubcoin", | ||
98464 | segwitAvailable: false, | ||
98465 | onSelect: function() { | ||
98466 | network = bitcoinjs.bitcoin.networks.clubcoin; | ||
98467 | setHdCoin(79); | ||
98468 | }, | ||
98469 | }, | ||
98470 | { | ||
98471 | name: "CMP - Compcoin", | ||
98472 | segwitAvailable: false, | ||
98473 | onSelect: function() { | ||
98474 | network = bitcoinjs.bitcoin.networks.compcoin; | ||
98475 | setHdCoin(71); | ||
98476 | }, | ||
98477 | }, | ||
98478 | { | ||
98479 | name: "CRAVE - Crave", | ||
98480 | segwitAvailable: false, | ||
98481 | onSelect: function() { | ||
98482 | network = bitcoinjs.bitcoin.networks.crave; | ||
98483 | setHdCoin(186); | ||
98484 | }, | ||
98485 | }, | ||
98486 | { | ||
106234 | name: "CRW - Crown", | 98487 | name: "CRW - Crown", |
106235 | segwitAvailable: false, | 98488 | segwitAvailable: false, |
106236 | onSelect: function() { | 98489 | onSelect: function() { |
@@ -106255,6 +98508,38 @@ window.Entropy = new (function() { | |||
106255 | }, | 98508 | }, |
106256 | }, | 98509 | }, |
106257 | { | 98510 | { |
98511 | name: "DFC - Defcoin", | ||
98512 | segwitAvailable: false, | ||
98513 | onSelect: function() { | ||
98514 | network = bitcoinjs.bitcoin.networks.defcoin; | ||
98515 | setHdCoin(1337); | ||
98516 | }, | ||
98517 | }, | ||
98518 | { | ||
98519 | name: "DGB - Digibyte", | ||
98520 | segwitAvailable: true, | ||
98521 | onSelect: function() { | ||
98522 | network = bitcoinjs.bitcoin.networks.digibyte; | ||
98523 | setHdCoin(20); | ||
98524 | }, | ||
98525 | }, | ||
98526 | { | ||
98527 | name: "DGC - Digitalcoin", | ||
98528 | segwitAvailable: false, | ||
98529 | onSelect: function() { | ||
98530 | network = bitcoinjs.bitcoin.networks.digitalcoin; | ||
98531 | setHdCoin(18); | ||
98532 | }, | ||
98533 | }, | ||
98534 | { | ||
98535 | name: "DMD - Diamond", | ||
98536 | segwitAvailable: false, | ||
98537 | onSelect: function() { | ||
98538 | network = bitcoinjs.bitcoin.networks.diamond; | ||
98539 | setHdCoin(152); | ||
98540 | }, | ||
98541 | }, | ||
98542 | { | ||
106258 | name: "DNR - Denarius", | 98543 | name: "DNR - Denarius", |
106259 | segwitAvailable: false, | 98544 | segwitAvailable: false, |
106260 | onSelect: function() { | 98545 | onSelect: function() { |
@@ -106271,6 +98556,46 @@ window.Entropy = new (function() { | |||
106271 | }, | 98556 | }, |
106272 | }, | 98557 | }, |
106273 | { | 98558 | { |
98559 | name: "ECN - Ecoin", | ||
98560 | segwitAvailable: false, | ||
98561 | onSelect: function() { | ||
98562 | network = bitcoinjs.bitcoin.networks.ecoin; | ||
98563 | setHdCoin(115); | ||
98564 | }, | ||
98565 | }, | ||
98566 | { | ||
98567 | name: "EDRC - Edrcoin", | ||
98568 | segwitAvailable: false, | ||
98569 | onSelect: function() { | ||
98570 | network = bitcoinjs.bitcoin.networks.edrcoin; | ||
98571 | setHdCoin(56); | ||
98572 | }, | ||
98573 | }, | ||
98574 | { | ||
98575 | name: "EFL - Egulden", | ||
98576 | segwitAvailable: true, | ||
98577 | onSelect: function() { | ||
98578 | network = bitcoinjs.bitcoin.networks.egulden; | ||
98579 | setHdCoin(78); | ||
98580 | }, | ||
98581 | }, | ||
98582 | { | ||
98583 | name: "EMC2 - Einsteinium", | ||
98584 | segwitAvailable: false, | ||
98585 | onSelect: function() { | ||
98586 | network = bitcoinjs.bitcoin.networks.einsteinium; | ||
98587 | setHdCoin(41); | ||
98588 | }, | ||
98589 | }, | ||
98590 | { | ||
98591 | name: "ERC - Europecoin", | ||
98592 | segwitAvailable: false, | ||
98593 | onSelect: function() { | ||
98594 | network = bitcoinjs.bitcoin.networks.europecoin; | ||
98595 | setHdCoin(151); | ||
98596 | }, | ||
98597 | }, | ||
98598 | { | ||
106274 | name: "ETH - Ethereum", | 98599 | name: "ETH - Ethereum", |
106275 | segwitAvailable: false, | 98600 | segwitAvailable: false, |
106276 | onSelect: function() { | 98601 | onSelect: function() { |
@@ -106279,14 +98604,46 @@ window.Entropy = new (function() { | |||
106279 | }, | 98604 | }, |
106280 | }, | 98605 | }, |
106281 | { | 98606 | { |
106282 | name: "FJC - Fujicoin", | 98607 | name: "EXCL - Exclusivecoin", |
106283 | segwitAvailable: false, | 98608 | segwitAvailable: false, |
106284 | onSelect: function() { | 98609 | onSelect: function() { |
98610 | network = bitcoinjs.bitcoin.networks.exclusivecoin; | ||
98611 | setHdCoin(190); | ||
98612 | }, | ||
98613 | }, | ||
98614 | { | ||
98615 | name: "FJC - Fujicoin", | ||
98616 | segwitAvailable: true, | ||
98617 | onSelect: function() { | ||
106285 | network = bitcoinjs.bitcoin.networks.fujicoin; | 98618 | network = bitcoinjs.bitcoin.networks.fujicoin; |
106286 | setHdCoin(75); | 98619 | setHdCoin(75); |
106287 | }, | 98620 | }, |
106288 | }, | 98621 | }, |
106289 | { | 98622 | { |
98623 | name: "FLASH - Flashcoin", | ||
98624 | segwitAvailable: false, | ||
98625 | onSelect: function() { | ||
98626 | network = bitcoinjs.bitcoin.networks.flashcoin; | ||
98627 | setHdCoin(120); | ||
98628 | }, | ||
98629 | }, | ||
98630 | { | ||
98631 | name: "FRST - Firstcoin", | ||
98632 | segwitAvailable: false, | ||
98633 | onSelect: function() { | ||
98634 | network = bitcoinjs.bitcoin.networks.firstcoin; | ||
98635 | setHdCoin(167); | ||
98636 | }, | ||
98637 | }, | ||
98638 | { | ||
98639 | name: "FTC - Feathercoin", | ||
98640 | segwitAvailable: true, | ||
98641 | onSelect: function() { | ||
98642 | network = bitcoinjs.bitcoin.networks.feathercoin; | ||
98643 | setHdCoin(8); | ||
98644 | }, | ||
98645 | }, | ||
98646 | { | ||
106290 | name: "GAME - GameCredits", | 98647 | name: "GAME - GameCredits", |
106291 | segwitAvailable: false, | 98648 | segwitAvailable: false, |
106292 | onSelect: function() { | 98649 | onSelect: function() { |
@@ -106295,6 +98652,62 @@ window.Entropy = new (function() { | |||
106295 | }, | 98652 | }, |
106296 | }, | 98653 | }, |
106297 | { | 98654 | { |
98655 | name: "GBX - Gobyte", | ||
98656 | segwitAvailable: false, | ||
98657 | onSelect: function() { | ||
98658 | network = bitcoinjs.bitcoin.networks.gobyte; | ||
98659 | setHdCoin(176); | ||
98660 | }, | ||
98661 | }, | ||
98662 | { | ||
98663 | name: "GCR - GCRCoin", | ||
98664 | segwitAvailable: false, | ||
98665 | onSelect: function() { | ||
98666 | network = bitcoinjs.bitcoin.networks.gcr; | ||
98667 | setHdCoin(79); | ||
98668 | }, | ||
98669 | }, | ||
98670 | { | ||
98671 | name: "GRC - Gridcoin", | ||
98672 | segwitAvailable: false, | ||
98673 | onSelect: function() { | ||
98674 | network = bitcoinjs.bitcoin.networks.gridcoin; | ||
98675 | setHdCoin(84); | ||
98676 | }, | ||
98677 | }, | ||
98678 | { | ||
98679 | name: "HNC - Helleniccoin", | ||
98680 | segwitAvailable: false, | ||
98681 | onSelect: function() { | ||
98682 | network = bitcoinjs.bitcoin.networks.helleniccoin; | ||
98683 | setHdCoin(168); | ||
98684 | }, | ||
98685 | }, | ||
98686 | { | ||
98687 | name: "INSN - Insane", | ||
98688 | segwitAvailable: false, | ||
98689 | onSelect: function() { | ||
98690 | network = bitcoinjs.bitcoin.networks.insane; | ||
98691 | setHdCoin(68); | ||
98692 | }, | ||
98693 | }, | ||
98694 | { | ||
98695 | name: "IOP - Iop", | ||
98696 | segwitAvailable: true, | ||
98697 | onSelect: function() { | ||
98698 | network = bitcoinjs.bitcoin.networks.iop; | ||
98699 | setHdCoin(66); | ||
98700 | }, | ||
98701 | }, | ||
98702 | { | ||
98703 | name: "IXC - Ixcoin", | ||
98704 | segwitAvailable: false, | ||
98705 | onSelect: function() { | ||
98706 | network = bitcoinjs.bitcoin.networks.ixcoin; | ||
98707 | setHdCoin(86); | ||
98708 | }, | ||
98709 | }, | ||
98710 | { | ||
106298 | name: "JBS - Jumbucks", | 98711 | name: "JBS - Jumbucks", |
106299 | segwitAvailable: false, | 98712 | segwitAvailable: false, |
106300 | onSelect: function() { | 98713 | onSelect: function() { |
@@ -106311,6 +98724,38 @@ window.Entropy = new (function() { | |||
106311 | }, | 98724 | }, |
106312 | }, | 98725 | }, |
106313 | { | 98726 | { |
98727 | name: "LBC - Library Credits", | ||
98728 | segwitAvailable: false, | ||
98729 | onSelect: function() { | ||
98730 | network = bitcoinjs.bitcoin.networks.lbry; | ||
98731 | setHdCoin(140); | ||
98732 | }, | ||
98733 | }, | ||
98734 | { | ||
98735 | name: "LCC - Litecoincash", | ||
98736 | segwitAvailable: true, | ||
98737 | onSelect: function() { | ||
98738 | network = bitcoinjs.bitcoin.networks.litecoincash; | ||
98739 | setHdCoin(192); | ||
98740 | }, | ||
98741 | }, | ||
98742 | { | ||
98743 | name: "LDCN - Landcoin", | ||
98744 | segwitAvailable: false, | ||
98745 | onSelect: function() { | ||
98746 | network = bitcoinjs.bitcoin.networks.landcoin; | ||
98747 | setHdCoin(63); | ||
98748 | }, | ||
98749 | }, | ||
98750 | { | ||
98751 | name: "LINX - Linx", | ||
98752 | segwitAvailable: false, | ||
98753 | onSelect: function() { | ||
98754 | network = bitcoinjs.bitcoin.networks.linx; | ||
98755 | setHdCoin(114); | ||
98756 | }, | ||
98757 | }, | ||
98758 | { | ||
106314 | name: "LTC - Litecoin", | 98759 | name: "LTC - Litecoin", |
106315 | segwitAvailable: true, | 98760 | segwitAvailable: true, |
106316 | onSelect: function() { | 98761 | onSelect: function() { |
@@ -106320,6 +98765,14 @@ window.Entropy = new (function() { | |||
106320 | }, | 98765 | }, |
106321 | }, | 98766 | }, |
106322 | { | 98767 | { |
98768 | name: "LYNX - Lynx", | ||
98769 | segwitAvailable: false, | ||
98770 | onSelect: function() { | ||
98771 | network = bitcoinjs.bitcoin.networks.lynx; | ||
98772 | setHdCoin(191); | ||
98773 | }, | ||
98774 | }, | ||
98775 | { | ||
106323 | name: "MAZA - Maza", | 98776 | name: "MAZA - Maza", |
106324 | segwitAvailable: false, | 98777 | segwitAvailable: false, |
106325 | onSelect: function() { | 98778 | onSelect: function() { |
@@ -106328,6 +98781,14 @@ window.Entropy = new (function() { | |||
106328 | }, | 98781 | }, |
106329 | }, | 98782 | }, |
106330 | { | 98783 | { |
98784 | name: "MNX - Minexcoin", | ||
98785 | segwitAvailable: true, | ||
98786 | onSelect: function() { | ||
98787 | network = bitcoinjs.bitcoin.networks.minexcoin; | ||
98788 | setHdCoin(182); | ||
98789 | }, | ||
98790 | }, | ||
98791 | { | ||
106331 | name: "MONA - Monacoin", | 98792 | name: "MONA - Monacoin", |
106332 | segwitAvailable: true, | 98793 | segwitAvailable: true, |
106333 | onSelect: function() { | 98794 | onSelect: function() { |
@@ -106336,6 +98797,38 @@ window.Entropy = new (function() { | |||
106336 | }, | 98797 | }, |
106337 | }, | 98798 | }, |
106338 | { | 98799 | { |
98800 | name: "NAV - Navcoin", | ||
98801 | segwitAvailable: true, | ||
98802 | onSelect: function() { | ||
98803 | network = bitcoinjs.bitcoin.networks.navcoin; | ||
98804 | setHdCoin(130); | ||
98805 | }, | ||
98806 | }, | ||
98807 | { | ||
98808 | name: "NEBL - Neblio", | ||
98809 | segwitAvailable: false, | ||
98810 | onSelect: function() { | ||
98811 | network = bitcoinjs.bitcoin.networks.neblio; | ||
98812 | setHdCoin(146); | ||
98813 | }, | ||
98814 | }, | ||
98815 | { | ||
98816 | name: "NEOS - Neoscoin", | ||
98817 | segwitAvailable: false, | ||
98818 | onSelect: function() { | ||
98819 | network = bitcoinjs.bitcoin.networks.neoscoin; | ||
98820 | setHdCoin(25); | ||
98821 | }, | ||
98822 | }, | ||
98823 | { | ||
98824 | name: "NLG - Gulden", | ||
98825 | segwitAvailable: false, | ||
98826 | onSelect: function() { | ||
98827 | network = bitcoinjs.bitcoin.networks.gulden; | ||
98828 | setHdCoin(87); | ||
98829 | }, | ||
98830 | }, | ||
98831 | { | ||
106339 | name: "NMC - Namecoin", | 98832 | name: "NMC - Namecoin", |
106340 | segwitAvailable: false, | 98833 | segwitAvailable: false, |
106341 | onSelect: function() { | 98834 | onSelect: function() { |
@@ -106344,6 +98837,54 @@ window.Entropy = new (function() { | |||
106344 | }, | 98837 | }, |
106345 | }, | 98838 | }, |
106346 | { | 98839 | { |
98840 | name: "NRO - Neurocoin", | ||
98841 | segwitAvailable: false, | ||
98842 | onSelect: function() { | ||
98843 | network = bitcoinjs.bitcoin.networks.neurocoin; | ||
98844 | setHdCoin(110); | ||
98845 | }, | ||
98846 | }, | ||
98847 | { | ||
98848 | name: "NSR - Nushares", | ||
98849 | segwitAvailable: false, | ||
98850 | onSelect: function() { | ||
98851 | network = bitcoinjs.bitcoin.networks.nushares; | ||
98852 | setHdCoin(11); | ||
98853 | }, | ||
98854 | }, | ||
98855 | { | ||
98856 | name: "NYC - Newyorkc", | ||
98857 | segwitAvailable: false, | ||
98858 | onSelect: function() { | ||
98859 | network = bitcoinjs.bitcoin.networks.newyorkc; | ||
98860 | setHdCoin(179); | ||
98861 | }, | ||
98862 | }, | ||
98863 | { | ||
98864 | name: "NVC - Novacoin", | ||
98865 | segwitAvailable: false, | ||
98866 | onSelect: function() { | ||
98867 | network = bitcoinjs.bitcoin.networks.novacoin; | ||
98868 | setHdCoin(50); | ||
98869 | }, | ||
98870 | }, | ||
98871 | { | ||
98872 | name: "OK - Okcash", | ||
98873 | segwitAvailable: false, | ||
98874 | onSelect: function() { | ||
98875 | network = bitcoinjs.bitcoin.networks.okcash; | ||
98876 | setHdCoin(69); | ||
98877 | }, | ||
98878 | }, | ||
98879 | { | ||
98880 | name: "OMNI - Omnicore", | ||
98881 | segwitAvailable: true, | ||
98882 | onSelect: function() { | ||
98883 | network = bitcoinjs.bitcoin.networks.omnicore; | ||
98884 | setHdCoin(200); | ||
98885 | }, | ||
98886 | }, | ||
98887 | { | ||
106347 | name: "ONX - Onixcoin", | 98888 | name: "ONX - Onixcoin", |
106348 | segwitAvailable: false, | 98889 | segwitAvailable: false, |
106349 | onSelect: function() { | 98890 | onSelect: function() { |
@@ -106352,6 +98893,14 @@ window.Entropy = new (function() { | |||
106352 | }, | 98893 | }, |
106353 | }, | 98894 | }, |
106354 | { | 98895 | { |
98896 | name: "PINK - Pinkcoin", | ||
98897 | segwitAvailable: false, | ||
98898 | onSelect: function() { | ||
98899 | network = bitcoinjs.bitcoin.networks.pinkcoin; | ||
98900 | setHdCoin(117); | ||
98901 | }, | ||
98902 | }, | ||
98903 | { | ||
106355 | name: "PIVX - PIVX", | 98904 | name: "PIVX - PIVX", |
106356 | segwitAvailable: false, | 98905 | segwitAvailable: false, |
106357 | onSelect: function() { | 98906 | onSelect: function() { |
@@ -106368,6 +98917,22 @@ window.Entropy = new (function() { | |||
106368 | }, | 98917 | }, |
106369 | }, | 98918 | }, |
106370 | { | 98919 | { |
98920 | name: "POSW - POSWcoin", | ||
98921 | segwitAvailable: false, | ||
98922 | onSelect: function() { | ||
98923 | network = bitcoinjs.bitcoin.networks.poswcoin; | ||
98924 | setHdCoin(47); | ||
98925 | }, | ||
98926 | }, | ||
98927 | { | ||
98928 | name: "POT - Potcoin", | ||
98929 | segwitAvailable: false, | ||
98930 | onSelect: function() { | ||
98931 | network = bitcoinjs.bitcoin.networks.potcoin; | ||
98932 | setHdCoin(81); | ||
98933 | }, | ||
98934 | }, | ||
98935 | { | ||
106371 | name: "PPC - Peercoin", | 98936 | name: "PPC - Peercoin", |
106372 | segwitAvailable: false, | 98937 | segwitAvailable: false, |
106373 | onSelect: function() { | 98938 | onSelect: function() { |
@@ -106376,6 +98941,46 @@ window.Entropy = new (function() { | |||
106376 | }, | 98941 | }, |
106377 | }, | 98942 | }, |
106378 | { | 98943 | { |
98944 | name: "PSB - Pesobit", | ||
98945 | segwitAvailable: false, | ||
98946 | onSelect: function() { | ||
98947 | network = bitcoinjs.bitcoin.networks.pesobit; | ||
98948 | setHdCoin(62); | ||
98949 | }, | ||
98950 | }, | ||
98951 | { | ||
98952 | name: "PUT - Putincoin", | ||
98953 | segwitAvailable: false, | ||
98954 | onSelect: function() { | ||
98955 | network = bitcoinjs.bitcoin.networks.putincoin; | ||
98956 | setHdCoin(122); | ||
98957 | }, | ||
98958 | }, | ||
98959 | { | ||
98960 | name: "RBY - Rubycoin", | ||
98961 | segwitAvailable: false, | ||
98962 | onSelect: function() { | ||
98963 | network = bitcoinjs.bitcoin.networks.rubycoin; | ||
98964 | setHdCoin(16); | ||
98965 | }, | ||
98966 | }, | ||
98967 | { | ||
98968 | name: "RDD - Reddcoin", | ||
98969 | segwitAvailable: false, | ||
98970 | onSelect: function() { | ||
98971 | network = bitcoinjs.bitcoin.networks.reddoin; | ||
98972 | setHdCoin(4); | ||
98973 | }, | ||
98974 | }, | ||
98975 | { | ||
98976 | name: "RVR - RevolutionVR", | ||
98977 | segwitAvailable: false, | ||
98978 | onSelect: function() { | ||
98979 | network = bitcoinjs.bitcoin.networks.revolutionvr; | ||
98980 | setHdCoin(129); | ||
98981 | }, | ||
98982 | }, | ||
98983 | { | ||
106379 | name: "SDC - ShadowCash", | 98984 | name: "SDC - ShadowCash", |
106380 | segwitAvailable: false, | 98985 | segwitAvailable: false, |
106381 | onSelect: function() { | 98986 | onSelect: function() { |
@@ -106408,6 +99013,62 @@ window.Entropy = new (function() { | |||
106408 | }, | 99013 | }, |
106409 | }, | 99014 | }, |
106410 | { | 99015 | { |
99016 | name: "SLR - Solarcoin", | ||
99017 | segwitAvailable: false, | ||
99018 | onSelect: function() { | ||
99019 | network = bitcoinjs.bitcoin.networks.solarcoin; | ||
99020 | setHdCoin(58); | ||
99021 | }, | ||
99022 | }, | ||
99023 | { | ||
99024 | name: "SMLY - Smileycoin", | ||
99025 | segwitAvailable: false, | ||
99026 | onSelect: function() { | ||
99027 | network = bitcoinjs.bitcoin.networks.smileycoin; | ||
99028 | setHdCoin(59); | ||
99029 | }, | ||
99030 | }, | ||
99031 | { | ||
99032 | name: "STRAT - Stratis", | ||
99033 | segwitAvailable: false, | ||
99034 | onSelect: function() { | ||
99035 | network = bitcoinjs.bitcoin.networks.stratis; | ||
99036 | setHdCoin(105); | ||
99037 | }, | ||
99038 | }, | ||
99039 | { | ||
99040 | name: "SYS - Syscoin", | ||
99041 | segwitAvailable: true, | ||
99042 | onSelect: function() { | ||
99043 | network = bitcoinjs.bitcoin.networks.syscoin; | ||
99044 | setHdCoin(57); | ||
99045 | }, | ||
99046 | }, | ||
99047 | { | ||
99048 | name: "THC - Hempcoin", | ||
99049 | segwitAvailable: false, | ||
99050 | onSelect: function() { | ||
99051 | network = bitcoinjs.bitcoin.networks.hempcoin; | ||
99052 | setHdCoin(113); | ||
99053 | }, | ||
99054 | }, | ||
99055 | { | ||
99056 | name: "TOA - Toa", | ||
99057 | segwitAvailable: false, | ||
99058 | onSelect: function() { | ||
99059 | network = bitcoinjs.bitcoin.networks.toa; | ||
99060 | setHdCoin(159); | ||
99061 | }, | ||
99062 | }, | ||
99063 | { | ||
99064 | name: "USC - Ultimatesecurecash", | ||
99065 | segwitAvailable: false, | ||
99066 | onSelect: function() { | ||
99067 | network = bitcoinjs.bitcoin.networks.ultimatesecurecash; | ||
99068 | setHdCoin(112); | ||
99069 | }, | ||
99070 | }, | ||
99071 | { | ||
106411 | name: "USNBT - NuBits", | 99072 | name: "USNBT - NuBits", |
106412 | segwitAvailable: false, | 99073 | segwitAvailable: false, |
106413 | onSelect: function() { | 99074 | onSelect: function() { |
@@ -106416,6 +99077,22 @@ window.Entropy = new (function() { | |||
106416 | }, | 99077 | }, |
106417 | }, | 99078 | }, |
106418 | { | 99079 | { |
99080 | name: "UNO - Unobtanium", | ||
99081 | segwitAvailable: false, | ||
99082 | onSelect: function() { | ||
99083 | network = bitcoinjs.bitcoin.networks.unobtanium; | ||
99084 | setHdCoin(92); | ||
99085 | }, | ||
99086 | }, | ||
99087 | { | ||
99088 | name: "VASH - Vpncoin", | ||
99089 | segwitAvailable: false, | ||
99090 | onSelect: function() { | ||
99091 | network = bitcoinjs.bitcoin.networks.vpncoin; | ||
99092 | setHdCoin(33); | ||
99093 | }, | ||
99094 | }, | ||
99095 | { | ||
106419 | name: "VIA - Viacoin", | 99096 | name: "VIA - Viacoin", |
106420 | segwitAvailable: false, | 99097 | segwitAvailable: false, |
106421 | onSelect: function() { | 99098 | onSelect: function() { |
@@ -106432,6 +99109,38 @@ window.Entropy = new (function() { | |||
106432 | }, | 99109 | }, |
106433 | }, | 99110 | }, |
106434 | { | 99111 | { |
99112 | name: "VIVO - Vivo", | ||
99113 | segwitAvailable: false, | ||
99114 | onSelect: function() { | ||
99115 | network = bitcoinjs.bitcoin.networks.vivo; | ||
99116 | setHdCoin(166); | ||
99117 | }, | ||
99118 | }, | ||
99119 | { | ||
99120 | name: "VTC - Vertcoin", | ||
99121 | segwitAvailable: false, | ||
99122 | onSelect: function() { | ||
99123 | network = bitcoinjs.bitcoin.networks.vertcoin; | ||
99124 | setHdCoin(28); | ||
99125 | }, | ||
99126 | }, | ||
99127 | { | ||
99128 | name: "WC - Wincoin", | ||
99129 | segwitAvailable: false, | ||
99130 | onSelect: function() { | ||
99131 | network = bitcoinjs.bitcoin.networks.wincoin; | ||
99132 | setHdCoin(181); | ||
99133 | }, | ||
99134 | }, | ||
99135 | { | ||
99136 | name: "XBC - Bitcoinplus", | ||
99137 | segwitAvailable: false, | ||
99138 | onSelect: function() { | ||
99139 | network = bitcoinjs.bitcoin.networks.bitcoinplus; | ||
99140 | setHdCoin(65); | ||
99141 | }, | ||
99142 | }, | ||
99143 | { | ||
106435 | name: "XMY - Myriadcoin", | 99144 | name: "XMY - Myriadcoin", |
106436 | segwitAvailable: false, | 99145 | segwitAvailable: false, |
106437 | onSelect: function() { | 99146 | onSelect: function() { |
@@ -106447,6 +99156,38 @@ window.Entropy = new (function() { | |||
106447 | setHdCoin(144); | 99156 | setHdCoin(144); |
106448 | }, | 99157 | }, |
106449 | }, | 99158 | }, |
99159 | { | ||
99160 | name: "XVC - Vcash", | ||
99161 | segwitAvailable: false, | ||
99162 | onSelect: function() { | ||
99163 | network = bitcoinjs.bitcoin.networks.vcash; | ||
99164 | setHdCoin(127); | ||
99165 | }, | ||
99166 | }, | ||
99167 | { | ||
99168 | name: "XVG - Verge", | ||
99169 | segwitAvailable: false, | ||
99170 | onSelect: function() { | ||
99171 | network = bitcoinjs.bitcoin.networks.verge; | ||
99172 | setHdCoin(77); | ||
99173 | }, | ||
99174 | }, | ||
99175 | { | ||
99176 | name: "XWC - Whitecoin", | ||
99177 | segwitAvailable: false, | ||
99178 | onSelect: function() { | ||
99179 | network = bitcoinjs.bitcoin.networks.whitecoin; | ||
99180 | setHdCoin(155); | ||
99181 | }, | ||
99182 | }, | ||
99183 | { | ||
99184 | name: "XZC - Zcoin", | ||
99185 | segwitAvailable: true, | ||
99186 | onSelect: function() { | ||
99187 | network = bitcoinjs.bitcoin.networks.zcoin; | ||
99188 | setHdCoin(136); | ||
99189 | }, | ||
99190 | }, | ||
106450 | ] | 99191 | ] |
106451 | 99192 | ||
106452 | var clients = [ | 99193 | var clients = [ |
diff --git a/changelog.md b/changelog.md index 392df56..1e41709 100644 --- a/changelog.md +++ b/changelog.md | |||
@@ -1,3 +1,15 @@ | |||
1 | # 0.3.5 | ||
2 | |||
3 | * Fix typo | ||
4 | * Add Neblio network | ||
5 | * Update bitcoinjs-lib from 3.3.0 to 3.3.2 | ||
6 | * Add Beetle Coin | ||
7 | * Add segwit for bitcoin testnet and Fujicoin | ||
8 | * Set coin number for Bitcoin God to 156 | ||
9 | * Add coins supported by coinomi | ||
10 | * Warn when generating low entropy mnemonics | ||
11 | * Warn when overriding weak entropy with a strong mnemonic length | ||
12 | |||
1 | # 0.3.4 | 13 | # 0.3.4 |
2 | 14 | ||
3 | * Add BlackCoin | 15 | * Add BlackCoin |
diff --git a/src/index.html b/src/index.html index 4056610..ad38117 100644 --- a/src/index.html +++ b/src/index.html | |||
@@ -15,7 +15,7 @@ | |||
15 | <div class="container"> | 15 | <div class="container"> |
16 | 16 | ||
17 | <h1 class="text-center">Mnemonic Code Converter</h1> | 17 | <h1 class="text-center">Mnemonic Code Converter</h1> |
18 | <p class="version">v0.3.4</p> | 18 | <p class="version">v0.3.5</p> |
19 | <hr> | 19 | <hr> |
20 | <div class="row"> | 20 | <div class="row"> |
21 | <div class="col-md-12"> | 21 | <div class="col-md-12"> |