aboutsummaryrefslogtreecommitdiff
path: root/src/js
diff options
context:
space:
mode:
Diffstat (limited to 'src/js')
-rw-r--r--src/js/bchaddrjs-0.2.1.js53
-rw-r--r--src/js/bitcoinjs-3.3.2.js6
-rw-r--r--src/js/bitcoinjs-bip38-2.0.2.js20
-rw-r--r--src/js/bitcoinjs-extensions.js308
-rw-r--r--src/js/casinocoin-util.js9
-rw-r--r--src/js/eos-util.js7414
-rw-r--r--src/js/groestlcoinjs-3.3.2.js17951
-rw-r--r--src/js/groestlcoinjs-bip38-2.0.2.js28732
-rw-r--r--src/js/index.js428
-rw-r--r--src/js/jsbip39.js51
-rw-r--r--src/js/levenshtein.js223
-rw-r--r--src/js/nebulas-account.js27697
-rw-r--r--src/js/ripple-util.js4
-rw-r--r--src/js/segwit-parameters.js145
-rw-r--r--src/js/sjcl-bip39.js70
-rw-r--r--src/js/stellar-util.js42516
16 files changed, 125378 insertions, 249 deletions
diff --git a/src/js/bchaddrjs-0.2.1.js b/src/js/bchaddrjs-0.2.1.js
index 8356f10..28f67e9 100644
--- a/src/js/bchaddrjs-0.2.1.js
+++ b/src/js/bchaddrjs-0.2.1.js
@@ -3356,7 +3356,7 @@ var validate = validation.validate;
3356 3356
3357/** 3357/**
3358 * Encodes a hash from a given type into a Bitcoin Cash address with the given prefix. 3358 * Encodes a hash from a given type into a Bitcoin Cash address with the given prefix.
3359 * 3359 *
3360 * @static 3360 * @static
3361 * @param {string} prefix Network prefix. E.g.: 'bitcoincash'. 3361 * @param {string} prefix Network prefix. E.g.: 'bitcoincash'.
3362 * @param {string} type Type of address to generate. Either 'P2PKH' or 'P2SH'. 3362 * @param {string} type Type of address to generate. Either 'P2PKH' or 'P2SH'.
@@ -3378,7 +3378,7 @@ function encode(prefix, type, hash) {
3378 3378
3379/** 3379/**
3380 * Decodes the given address into its constituting prefix, type and hash. See [#encode()]{@link encode}. 3380 * Decodes the given address into its constituting prefix, type and hash. See [#encode()]{@link encode}.
3381 * 3381 *
3382 * @static 3382 * @static
3383 * @param {string} address Address to decode. E.g.: 'bitcoincash:qpm2qsznhks23z7629mms6s4cwef74vcwvy22gdx6a'. 3383 * @param {string} address Address to decode. E.g.: 'bitcoincash:qpm2qsznhks23z7629mms6s4cwef74vcwvy22gdx6a'.
3384 * @returns {object} 3384 * @returns {object}
@@ -3416,14 +3416,14 @@ var ValidationError = validation.ValidationError;
3416 * 3416 *
3417 * @private 3417 * @private
3418 */ 3418 */
3419var VALID_PREFIXES = ['bitcoincash', 'bchtest', 'bchreg']; 3419var VALID_PREFIXES = ['bitcoincash', 'bchtest', 'bchreg', 'simpleledger', 'slptest'];
3420 3420
3421/** 3421/**
3422 * Checks whether a string is a valid prefix; ie., it has a single letter case 3422 * Checks whether a string is a valid prefix; ie., it has a single letter case
3423 * and is one of 'bitcoincash', 'bchtest', or 'bchreg'. 3423 * and is one of 'bitcoincash', 'bchtest', or 'bchreg', 'simpleledger' or 'slptest'.
3424 * 3424 *
3425 * @private 3425 * @private
3426 * @param {string} prefix 3426 * @param {string} prefix
3427 * @returns {boolean} 3427 * @returns {boolean}
3428 */ 3428 */
3429function isValidPrefix(prefix) { 3429function isValidPrefix(prefix) {
@@ -3435,7 +3435,7 @@ function isValidPrefix(prefix) {
3435 * of the address' checksum. 3435 * of the address' checksum.
3436 * 3436 *
3437 * @private 3437 * @private
3438 * @param {string} prefix Network prefix. E.g.: 'bitcoincash'. 3438 * @param {string} prefix Network prefix. E.g.: 'bitcoincash'.
3439 * @returns {Uint8Array} 3439 * @returns {Uint8Array}
3440 */ 3440 */
3441function prefixToUint5Array(prefix) { 3441function prefixToUint5Array(prefix) {
@@ -3594,8 +3594,8 @@ function fromUint5Array(data) {
3594 * Returns the concatenation a and b. 3594 * Returns the concatenation a and b.
3595 * 3595 *
3596 * @private 3596 * @private
3597 * @param {Uint8Array} a 3597 * @param {Uint8Array} a
3598 * @param {Uint8Array} b 3598 * @param {Uint8Array} b
3599 * @returns {Uint8Array} 3599 * @returns {Uint8Array}
3600 * @throws {ValidationError} 3600 * @throws {ValidationError}
3601 */ 3601 */
@@ -3633,7 +3633,7 @@ function polymod(data) {
3633/** 3633/**
3634 * Verify that the payload has not been corrupted by checking that the 3634 * Verify that the payload has not been corrupted by checking that the
3635 * checksum is valid. 3635 * checksum is valid.
3636 * 3636 *
3637 * @private 3637 * @private
3638 * @param {string} prefix Network prefix. E.g.: 'bitcoincash'. 3638 * @param {string} prefix Network prefix. E.g.: 'bitcoincash'.
3639 * @param {Uint8Array} payload Array of 5-bit integers containing the address' payload. 3639 * @param {Uint8Array} payload Array of 5-bit integers containing the address' payload.
@@ -9012,6 +9012,21 @@ function toCashAddress (address) {
9012} 9012}
9013 9013
9014/** 9014/**
9015 * Translates the given address into SLP format.
9016 * @static
9017 * @param {string} address - A valid SLP address in any format.
9018 * @return {string}
9019 * @throws {InvalidAddressError}
9020 */
9021function toSlpAddress (address) {
9022 var decoded = decodeAddress(address)
9023 return encodeAsSlpaddr(decoded)
9024}
9025
9026
9027
9028
9029/**
9015 * Version byte table for base58 formats. 9030 * Version byte table for base58 formats.
9016 * @private 9031 * @private
9017 */ 9032 */
@@ -9125,7 +9140,7 @@ function decodeCashAddress (address) {
9125 } catch (error) { 9140 } catch (error) {
9126 } 9141 }
9127 } else { 9142 } else {
9128 var prefixes = ['bitcoincash', 'bchtest', 'regtest'] 9143 var prefixes = ['bitcoincash', 'bchtest', 'regtest', 'simpleledger', 'slptest']
9129 for (var i = 0; i < prefixes.length; ++i) { 9144 for (var i = 0; i < prefixes.length; ++i) {
9130 try { 9145 try {
9131 var prefix = prefixes[i] 9146 var prefix = prefixes[i]
@@ -9151,6 +9166,7 @@ function decodeCashAddressWithPrefix (address) {
9151 var type = decoded.type === 'P2PKH' ? Type.P2PKH : Type.P2SH 9166 var type = decoded.type === 'P2PKH' ? Type.P2PKH : Type.P2SH
9152 switch (decoded.prefix) { 9167 switch (decoded.prefix) {
9153 case 'bitcoincash': 9168 case 'bitcoincash':
9169 case 'simpleledger':
9154 return { 9170 return {
9155 hash: hash, 9171 hash: hash,
9156 format: Format.Cashaddr, 9172 format: Format.Cashaddr,
@@ -9158,6 +9174,7 @@ function decodeCashAddressWithPrefix (address) {
9158 type: type 9174 type: type
9159 } 9175 }
9160 case 'bchtest': 9176 case 'bchtest':
9177 case 'slptest':
9161 case 'regtest': 9178 case 'regtest':
9162 return { 9179 return {
9163 hash: hash, 9180 hash: hash,
@@ -9212,6 +9229,19 @@ function encodeAsCashaddr (decoded) {
9212 return cashaddr.encode(prefix, type, hash) 9229 return cashaddr.encode(prefix, type, hash)
9213} 9230}
9214 9231
9232 /**
9233 * Encodes the given decoded address into slp addr format.
9234 * @private
9235 * @param {object} decoded
9236 * @returns {string}
9237 */
9238 function encodeAsSlpaddr (decoded) {
9239 var prefix = decoded.network === Network.Mainnet ? 'simpleledger' : 'slptest'
9240 var type = decoded.type === Type.P2PKH ? 'P2PKH' : 'P2SH'
9241 var hash = Uint8Array.from(decoded.hash)
9242 return cashaddr.encode(prefix, type, hash)
9243 }
9244
9215/** 9245/**
9216 * Returns a boolean indicating whether the address is in legacy format. 9246 * Returns a boolean indicating whether the address is in legacy format.
9217 * @static 9247 * @static
@@ -9313,6 +9343,7 @@ module.exports = {
9313 toLegacyAddress: toLegacyAddress, 9343 toLegacyAddress: toLegacyAddress,
9314 toBitpayAddress: toBitpayAddress, 9344 toBitpayAddress: toBitpayAddress,
9315 toCashAddress: toCashAddress, 9345 toCashAddress: toCashAddress,
9346 toSlpAddress: toSlpAddress,
9316 isLegacyAddress: isLegacyAddress, 9347 isLegacyAddress: isLegacyAddress,
9317 isBitpayAddress: isBitpayAddress, 9348 isBitpayAddress: isBitpayAddress,
9318 isCashAddress: isCashAddress, 9349 isCashAddress: isCashAddress,
@@ -9325,4 +9356,4 @@ module.exports = {
9325 9356
9326}).call(this,require("buffer").Buffer) 9357}).call(this,require("buffer").Buffer)
9327},{"bs58check":7,"buffer":8,"cashaddrjs":10}]},{},[52])(52) 9358},{"bs58check":7,"buffer":8,"cashaddrjs":10}]},{},[52])(52)
9328}); \ No newline at end of file 9359});
diff --git a/src/js/bitcoinjs-3.3.2.js b/src/js/bitcoinjs-3.3.2.js
index 2390168..76f57e7 100644
--- a/src/js/bitcoinjs-3.3.2.js
+++ b/src/js/bitcoinjs-3.3.2.js
@@ -8596,13 +8596,13 @@ module.exports={
8596 "OP_CHECKMULTISIGVERIFY": 175, 8596 "OP_CHECKMULTISIGVERIFY": 175,
8597 8597
8598 "OP_NOP1": 176, 8598 "OP_NOP1": 176,
8599 8599
8600 "OP_NOP2": 177, 8600 "OP_NOP2": 177,
8601 "OP_CHECKLOCKTIMEVERIFY": 177, 8601 "OP_CHECKLOCKTIMEVERIFY": 177,
8602 8602
8603 "OP_NOP3": 178, 8603 "OP_NOP3": 178,
8604 "OP_CHECKSEQUENCEVERIFY": 178, 8604 "OP_CHECKSEQUENCEVERIFY": 178,
8605 8605
8606 "OP_NOP4": 179, 8606 "OP_NOP4": 179,
8607 "OP_NOP5": 180, 8607 "OP_NOP5": 180,
8608 "OP_NOP6": 181, 8608 "OP_NOP6": 181,
@@ -15165,4 +15165,4 @@ module.exports = {
15165 15165
15166}).call(this,require("buffer").Buffer) 15166}).call(this,require("buffer").Buffer)
15167},{"bs58check":83,"buffer":5}]},{},[34])(34) 15167},{"bs58check":83,"buffer":5}]},{},[34])(34)
15168}); \ No newline at end of file 15168});
diff --git a/src/js/bitcoinjs-bip38-2.0.2.js b/src/js/bitcoinjs-bip38-2.0.2.js
index ea38715..57c1168 100644
--- a/src/js/bitcoinjs-bip38-2.0.2.js
+++ b/src/js/bitcoinjs-bip38-2.0.2.js
@@ -18123,7 +18123,7 @@ module.exports = function privateDecrypt(private_key, enc, reverse) {
18123 } else { 18123 } else {
18124 padding = 4; 18124 padding = 4;
18125 } 18125 }
18126 18126
18127 var key = parseKeys(private_key); 18127 var key = parseKeys(private_key);
18128 var k = key.modulus.byteLength(); 18128 var k = key.modulus.byteLength();
18129 if (enc.length > k || new bn(enc).cmp(key.modulus) >= 0) { 18129 if (enc.length > k || new bn(enc).cmp(key.modulus) >= 0) {
@@ -22690,13 +22690,13 @@ Script.prototype.runInContext = function (context) {
22690 if (!(context instanceof Context)) { 22690 if (!(context instanceof Context)) {
22691 throw new TypeError("needs a 'context' argument."); 22691 throw new TypeError("needs a 'context' argument.");
22692 } 22692 }
22693 22693
22694 var iframe = document.createElement('iframe'); 22694 var iframe = document.createElement('iframe');
22695 if (!iframe.style) iframe.style = {}; 22695 if (!iframe.style) iframe.style = {};
22696 iframe.style.display = 'none'; 22696 iframe.style.display = 'none';
22697 22697
22698 document.body.appendChild(iframe); 22698 document.body.appendChild(iframe);
22699 22699
22700 var win = iframe.contentWindow; 22700 var win = iframe.contentWindow;
22701 var wEval = win.eval, wExecScript = win.execScript; 22701 var wEval = win.eval, wExecScript = win.execScript;
22702 22702
@@ -22705,7 +22705,7 @@ Script.prototype.runInContext = function (context) {
22705 wExecScript.call(win, 'null'); 22705 wExecScript.call(win, 'null');
22706 wEval = win.eval; 22706 wEval = win.eval;
22707 } 22707 }
22708 22708
22709 forEach(Object_keys(context), function (key) { 22709 forEach(Object_keys(context), function (key) {
22710 win[key] = context[key]; 22710 win[key] = context[key];
22711 }); 22711 });
@@ -22714,11 +22714,11 @@ Script.prototype.runInContext = function (context) {
22714 win[key] = context[key]; 22714 win[key] = context[key];
22715 } 22715 }
22716 }); 22716 });
22717 22717
22718 var winKeys = Object_keys(win); 22718 var winKeys = Object_keys(win);
22719 22719
22720 var res = wEval.call(win, this.code); 22720 var res = wEval.call(win, this.code);
22721 22721
22722 forEach(Object_keys(win), function (key) { 22722 forEach(Object_keys(win), function (key) {
22723 // Avoid copying circular objects like `top` and `window` by only 22723 // Avoid copying circular objects like `top` and `window` by only
22724 // updating existing context properties or new properties in the `win` 22724 // updating existing context properties or new properties in the `win`
@@ -22733,9 +22733,9 @@ Script.prototype.runInContext = function (context) {
22733 defineProp(context, key, win[key]); 22733 defineProp(context, key, win[key]);
22734 } 22734 }
22735 }); 22735 });
22736 22736
22737 document.body.removeChild(iframe); 22737 document.body.removeChild(iframe);
22738 22738
22739 return res; 22739 return res;
22740}; 22740};
22741 22741
@@ -27914,4 +27914,4 @@ Sha512.prototype._hash = function () {
27914module.exports = Sha512 27914module.exports = Sha512
27915 27915
27916},{"./hash":195,"inherits":189,"safe-buffer":193}]},{},[150])(150) 27916},{"./hash":195,"inherits":189,"safe-buffer":193}]},{},[150])(150)
27917}); \ No newline at end of file 27917});
diff --git a/src/js/bitcoinjs-extensions.js b/src/js/bitcoinjs-extensions.js
index 271dbce..a9db485 100644
--- a/src/js/bitcoinjs-extensions.js
+++ b/src/js/bitcoinjs-extensions.js
@@ -27,7 +27,7 @@ bitcoinjs.bitcoin.networks.clam = {
27 private: 0xa8c17826 27 private: 0xa8c17826
28 }, 28 },
29 pubKeyHash: 0x89, 29 pubKeyHash: 0x89,
30 scriptHash: 0x00, // TODO set this correctly 30 scriptHash: 0x0D,
31 wif: 0x85 31 wif: 0x85
32}; 32};
33 33
@@ -39,7 +39,27 @@ bitcoinjs.bitcoin.networks.crown = {
39 }, 39 },
40 pubKeyHash: 0x00, 40 pubKeyHash: 0x00,
41 scriptHash: 0x05, 41 scriptHash: 0x05,
42 wif: 0x80 42 wif: 0x80,
43 toNewAddress: function(oldAddress)
44 {
45 var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
46 var b58 = basex(ALPHABET);
47
48 var addrBytes = b58.decode(oldAddress);
49
50 var hash160 = new Uint16Array(23);
51 hash160[0]= 0x01; //C
52 hash160[1]= 0x75; //R
53 hash160[2]= 0x07; //W
54 addrBytes.copy(hash160, 3, 1, 21);
55
56 var checksum = bitcoinjs.bitcoin.crypto.hash256(hash160).subarray(0, 4);
57 var binaryAddr = new Uint16Array(27);
58 binaryAddr.set(hash160,0);
59 checksum.copy(binaryAddr, 23, 0, 4);
60 var newAddress = b58.encode(binaryAddr);
61 return newAddress;
62 }
43}; 63};
44 64
45bitcoinjs.bitcoin.networks.dash = { 65bitcoinjs.bitcoin.networks.dash = {
@@ -93,7 +113,7 @@ bitcoinjs.bitcoin.networks.namecoin = {
93 private: 0x0488ade4 113 private: 0x0488ade4
94 }, 114 },
95 pubKeyHash: 0x34, 115 pubKeyHash: 0x34,
96 scriptHash: 0x00, // TODO set this correctly 116 scriptHash: 0x0D,
97 wif: 0x80 117 wif: 0x80
98}; 118};
99 119
@@ -104,7 +124,7 @@ bitcoinjs.bitcoin.networks.peercoin = {
104 private: 0x0488ade4 124 private: 0x0488ade4
105 }, 125 },
106 pubKeyHash: 0x37, 126 pubKeyHash: 0x37,
107 scriptHash: 0x00, // TODO set this correctly 127 scriptHash: 0x75,
108 wif: 0xb7 128 wif: 0xb7
109}; 129};
110 130
@@ -152,6 +172,17 @@ bitcoinjs.bitcoin.networks.dogecoin = {
152 wif: 0x9e 172 wif: 0x9e
153}; 173};
154 174
175bitcoinjs.bitcoin.networks.dogecointestnet = {
176 messagePrefix: '\x19Dogecoin Signed Message:\n',
177 bip32: {
178 public: 0x043587cf,
179 private: 0x04358394
180 },
181 pubKeyHash: 0x71,
182 scriptHash: 0xc4,
183 wif: 0xf1
184};
185
155bitcoinjs.bitcoin.networks.denarius = { 186bitcoinjs.bitcoin.networks.denarius = {
156 messagePrefix: '\x19Denarius Signed Message:\n', 187 messagePrefix: '\x19Denarius Signed Message:\n',
157 bip32: { 188 bip32: {
@@ -236,20 +267,42 @@ bitcoinjs.bitcoin.networks.myriadcoin = {
236 private: 0x0488ade4 267 private: 0x0488ade4
237 }, 268 },
238 pubKeyHash: 0x32, 269 pubKeyHash: 0x32,
239 scriptHash: 0x00, // TODO set this correctly 270 scriptHash: 0x09,
240 wif: 0xb2 271 wif: 0xb2
241}; 272};
242 273
274bitcoinjs.bitcoin.networks.bolivarcoin = {
275 messagePrefix: 'Bolivarcoin Signed Message:\n',
276 bip32: {
277 public: 0x0488b21e,
278 private: 0x0488ade4
279 },
280 pubKeyHash: 0x55,
281 scriptHash: 0x05,
282 wif: 0xD5
283};
243 284
244bitcoinjs.bitcoin.networks.onixcoin = { 285bitcoinjs.bitcoin.networks.onixcoin = {
245 messagePrefix: 'unused', 286 messagePrefix: 'ONIX Signed Message:\n',
246 bip32: { 287 bip32: {
247 public: 0x049d7cb2, 288 public: 0x0488b21e,
248 private: 0x049d7878 289 private: 0x0488ade4
249 }, 290 },
250 pubKeyHash: 0x4B, 291 pubKeyHash: 0x4B,
251 scriptHash: 0x05, 292 scriptHash: 0x05,
252 wif: 0x80 293 wif: 0xCB
294};
295
296
297bitcoinjs.bitcoin.networks.lkrcoin = {
298 messagePrefix: '\x18LKRcoin Signed Message:\n',
299 bip32: {
300 public: 0x0488b21e,
301 private: 0x0488ade4,
302 },
303 pubKeyHash: 0x30,
304 scriptHash: 0x55,
305 wif: 0xB0
253}; 306};
254 307
255bitcoinjs.bitcoin.networks.pivx = { 308bitcoinjs.bitcoin.networks.pivx = {
@@ -274,6 +327,28 @@ bitcoinjs.bitcoin.networks.pivxtestnet = {
274 wif: 0xef 327 wif: 0xef
275}; 328};
276 329
330bitcoinjs.bitcoin.networks.fix = {
331 messagePrefix: 'unused',
332 bip32: {
333 public: 0x022d2533,
334 private: 0x0221312b
335 },
336 pubKeyHash: 0x23,
337 scriptHash: 0x5F,
338 wif: 0x3C
339};
340
341bitcoinjs.bitcoin.networks.fixtestnet = {
342 messagePrefix: 'unused',
343 bip32: {
344 public: 0x3a8061a0,
345 private: 0x3a805837
346 },
347 pubKeyHash: 0x4c,
348 scriptHash: 0x89,
349 wif: 0xED
350};
351
277bitcoinjs.bitcoin.networks.fujicoin = { 352bitcoinjs.bitcoin.networks.fujicoin = {
278 messagePrefix: '\x19FujiCoin Signed Message:\n', 353 messagePrefix: '\x19FujiCoin Signed Message:\n',
279 bip32: { 354 bip32: {
@@ -573,7 +648,7 @@ bitcoinjs.bitcoin.networks.diamond = {
573}; 648};
574 649
575bitcoinjs.bitcoin.networks.digibyte = { 650bitcoinjs.bitcoin.networks.digibyte = {
576 messagePrefix: '\x18DigiByte Signed Message:\n', 651 messagePrefix: '\x19DigiByte Signed Message:\n',
577 bip32: { 652 bip32: {
578 public: 0x0488B21E, 653 public: 0x0488B21E,
579 private: 0x0488ADE4, 654 private: 0x0488ADE4,
@@ -726,6 +801,28 @@ bitcoinjs.bitcoin.networks.gridcoin = {
726 wif: 0xbe, 801 wif: 0xbe,
727}; 802};
728 803
804bitcoinjs.bitcoin.networks.groestlcoin = {
805 messagePrefix: '\x19GroestlCoin Signed Message:\n',
806 bip32: {
807 public: 0x0488b21e,
808 private: 0x0488ade4
809 },
810 pubKeyHash: 36,
811 scriptHash: 5,
812 wif: 128,
813}
814
815bitcoinjs.bitcoin.networks.groestlcointestnet = {
816 messagePrefix: '\x19GroestlCoin Signed Message:\n',
817 bip32: {
818 public: 0x043587cf,
819 private: 0x04358394
820 },
821 pubKeyHash: 0x6f,
822 scriptHash: 0xc4,
823 wif: 0xef,
824}
825
729bitcoinjs.bitcoin.networks.gulden = { 826bitcoinjs.bitcoin.networks.gulden = {
730 messagePrefix: '\x18Guldencoin Signed Message:\n', 827 messagePrefix: '\x18Guldencoin Signed Message:\n',
731 bip32: { 828 bip32: {
@@ -836,6 +933,17 @@ bitcoinjs.bitcoin.networks.linx = {
836 wif: 0xcb, 933 wif: 0xcb,
837}; 934};
838 935
936
937bitcoinjs.bitcoin.networks.litecointestnet = {
938 messagePrefix: '\x18Litecoin Signed Message:\n',
939 bip32: {
940 public: 0x043587cf,
941 private: 0x04358394,
942 },
943 pubKeyHash: 0x6f,
944 scriptHash: 0xc4,
945 wif: 0xef,
946};
839bitcoinjs.bitcoin.networks.litecoincash = { 947bitcoinjs.bitcoin.networks.litecoincash = {
840 messagePrefix: '\x18Litecoin Signed Message:\n', 948 messagePrefix: '\x18Litecoin Signed Message:\n',
841 bip32: { 949 bip32: {
@@ -902,6 +1010,17 @@ bitcoinjs.bitcoin.networks.neoscoin = {
902 wif: 0xb1, 1010 wif: 0xb1,
903}; 1011};
904 1012
1013bitcoinjs.bitcoin.networks.nix = {
1014 messagePrefix: '\x18Nix Signed Message:\n',
1015 bip32: {
1016 public: 0x0488b21e,
1017 private: 0x0488ade4,
1018 },
1019 pubKeyHash: 0x26,
1020 scriptHash: 0x35,
1021 wif: 0x80,
1022};
1023
905bitcoinjs.bitcoin.networks.neurocoin = { 1024bitcoinjs.bitcoin.networks.neurocoin = {
906 messagePrefix: '\x18PPCoin Signed Message:\n', 1025 messagePrefix: '\x18PPCoin Signed Message:\n',
907 bip32: { 1026 bip32: {
@@ -1067,6 +1186,17 @@ bitcoinjs.bitcoin.networks.rubycoin = {
1067 wif: 0xbc, 1186 wif: 0xbc,
1068}; 1187};
1069 1188
1189bitcoinjs.bitcoin.networks.safecoin = {
1190 messagePrefix: '\x18Safecoin Signed Message:\n',
1191 bip32: {
1192 public: 0x0488b21e,
1193 private: 0x0488ade4,
1194 },
1195 pubKeyHash: 0x3d,
1196 scriptHash: 0x56,
1197 wif: 0xbd,
1198};
1199
1070bitcoinjs.bitcoin.networks.salus = { 1200bitcoinjs.bitcoin.networks.salus = {
1071messagePrefix: '\x18Salus Signed Message:\n', 1201messagePrefix: '\x18Salus Signed Message:\n',
1072bip32: { 1202bip32: {
@@ -1167,6 +1297,28 @@ bitcoinjs.bitcoin.networks.toa = {
1167 wif: 0xc1, 1297 wif: 0xc1,
1168}; 1298};
1169 1299
1300bitcoinjs.bitcoin.networks.twins = {
1301 messagePrefix: 'unused',
1302 bip32: {
1303 public: 0x022d2533,
1304 private: 0x0221312b
1305 },
1306 pubKeyHash: 0x49,
1307 scriptHash: 0x53,
1308 wif: 0x42
1309};
1310
1311bitcoinjs.bitcoin.networks.twinstestnet = {
1312 messagePrefix: 'unused',
1313 bip32: {
1314 public: 0x3a8061a0,
1315 private: 0x3a805837
1316 },
1317 pubKeyHash: 0x4c,
1318 scriptHash: 0x89,
1319 wif: 0xED
1320};
1321
1170bitcoinjs.bitcoin.networks.ultimatesecurecash = { 1322bitcoinjs.bitcoin.networks.ultimatesecurecash = {
1171 messagePrefix: '\x18UltimateSecureCash Signed Message:\n', 1323 messagePrefix: '\x18UltimateSecureCash Signed Message:\n',
1172 bip32: { 1324 bip32: {
@@ -1332,6 +1484,17 @@ bitcoinjs.bitcoin.networks.hush = {
1332 wif: 0x80, 1484 wif: 0x80,
1333}; 1485};
1334 1486
1487bitcoinjs.bitcoin.networks.hush3 = {
1488 messagePrefix: '\x18Hush Signed Message:\n',
1489 bip32: {
1490 public: 0x0488B21E,
1491 private: 0x0488ADE4,
1492 },
1493 pubKeyHash: 0x3C,
1494 scriptHash: 0x55,
1495 wif: 0xBC,
1496};
1497
1335bitcoinjs.bitcoin.networks.zclassic = { 1498bitcoinjs.bitcoin.networks.zclassic = {
1336 messagePrefix: '\x18Zcash Signed Message:\n', 1499 messagePrefix: '\x18Zcash Signed Message:\n',
1337 bip32: { 1500 bip32: {
@@ -1429,4 +1592,127 @@ bitcoinjs.bitcoin.networks.phore = {
1429 pubKeyHash: 0x37, 1592 pubKeyHash: 0x37,
1430 scriptHash: 0x0D, 1593 scriptHash: 0x0D,
1431 wif: 0xD4, 1594 wif: 0xD4,
1432}; \ No newline at end of file 1595};
1596
1597bitcoinjs.bitcoin.networks.blocknode = {
1598 messagePrefix: '\x18Blocknode Signed Message:\n',
1599 bip32: {
1600 public: 0x0488b21e,
1601 private: 0x0488ade4
1602 },
1603 pubKeyHash: 0x19,
1604 scriptHash: 0x3F,
1605 wif: 0x4b,
1606};
1607
1608bitcoinjs.bitcoin.networks.blocknode_testnet = {
1609 messagePrefix: '\x18Blocknode Testnet Signed Message:\n',
1610 bip32: {
1611 public: 0x043587cf,
1612 private: 0x04358394
1613 },
1614 pubKeyHash: 0x55,
1615 scriptHash: 0x7d,
1616 wif: 0x89,
1617};
1618
1619bitcoinjs.bitcoin.networks.litecoinz = {
1620 messagePrefix: '\x18LitecoinZ Signed Message:\n',
1621 bip32: {
1622 public: 0x0488B21E,
1623 private: 0x0488ADE3,
1624 },
1625 pubKeyHash: 0x0AB3,
1626 scriptHash: 0x0AB8,
1627 wif: 0x80,
1628};
1629
1630bitcoinjs.bitcoin.networks.blockstamp = {
1631 messagePrefix: '\x18BlockStamp Signed Message:\n',
1632 bip32: {
1633 public: 0x0488B21E,
1634 private: 0x0488ADE4,
1635 },
1636 pubKeyHash: 0x00,
1637 scriptHash: 0x05,
1638 wif: 0x80,
1639};
1640
1641bitcoinjs.bitcoin.networks.deeponion = {
1642 messagePrefix: 'x18DeepOnion Signed Message:\n',
1643 bip32: {
1644 public: 0x0488B21E,
1645 private: 0x0488ADE4,
1646 },
1647 pubKeyHash: 0x1F,
1648 scriptHash: 0x4E,
1649 wif: 0x9F,
1650};
1651
1652
1653bitcoinjs.bitcoin.networks.cpuchain = {
1654 messagePrefix: 'x18CPUchain Signed Message:\n',
1655 bip32: {
1656 public: 0x0488B21E,
1657 private: 0x0488ADE4,
1658 },
1659 pubKeyHash: 0x1C,
1660 scriptHash: 0x1E,
1661 wif: 0x80,
1662};
1663
1664bitcoinjs.bitcoin.networks.wagerr = {
1665 messagePrefix: 'unused',
1666 bip32: {
1667 public: 0x022d2533,
1668 private: 0x0221312b
1669 },
1670 pubKeyHash: 0x49,
1671 scriptHash: 0x3f,
1672 wif: 0xc7
1673};
1674
1675bitcoinjs.bitcoin.networks.bitcoinsv = {
1676 messagePrefix: 'unused',
1677 bip32: {
1678 public: 0x0488b21e,
1679 private: 0x0488ade4
1680 },
1681 pubKeyHash: 0x00,
1682 scriptHash: 0x05,
1683 wif: 0x80
1684};
1685
1686bitcoinjs.bitcoin.networks.monkeyproject = {
1687 messagePrefix: 'Monkey Signed Message:\n',
1688 bip32: {
1689 public: 0x0488b21e,
1690 private: 0x0488dde4
1691 },
1692 pubKeyHash: 0x33,
1693 scriptHash: 0x1c,
1694 wif: 0x37
1695};
1696
1697bitcoinjs.bitcoin.networks.rapids = {
1698 messagePrefix: 'DarkNet Signed Message:\n',
1699 bip32: {
1700 public: 0x0488b21e,
1701 private: 0x0488ade4
1702 },
1703 pubKeyHash: 0x3d,
1704 scriptHash: 0x06,
1705 wif: 0x2e
1706};
1707
1708bitcoinjs.bitcoin.networks.aryacoin = {
1709 messagePrefix: '\x18Aryacoin Signed Message:\n',
1710 bech32: 'arya',
1711 bip32: {
1712 public: 0x0488B21E,
1713 private: 0x0488ADE4,
1714 },
1715 pubKeyHash: 0x17,
1716 scriptHash: 0x6f,
1717 wif: 0x97
1718};
diff --git a/src/js/casinocoin-util.js b/src/js/casinocoin-util.js
new file mode 100644
index 0000000..ac40c5a
--- /dev/null
+++ b/src/js/casinocoin-util.js
@@ -0,0 +1,9 @@
1function convertCasinoCoinAdrr(address) {
2 return window.basex('cpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2brdeCg65jkm8oFqi1tuvAxyz').encode(
3 window.basex('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz').decode(address)
4 )
5 }
6
7function convertCasinoCoinPriv(priv) {
8 return window.basex('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz').decode(priv).toString("hex").slice(2,66)
9}
diff --git a/src/js/eos-util.js b/src/js/eos-util.js
new file mode 100644
index 0000000..2be3004
--- /dev/null
+++ b/src/js/eos-util.js
@@ -0,0 +1,7414 @@
1(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.eosUtil = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
2const createHash = require("create-hash");
3const base58 = require("bs58");
4const { Buffer } = require("buffer");
5
6function bufferToPublic(pubBuf) {
7 const EOS_PUBLIC_PREFIX = "EOS";
8 let checksum = new createHash("rmd160").update(pubBuf).digest("hex").slice(0, 8);
9 pubBuf = Buffer.concat([pubBuf, Buffer.from(checksum, "hex")]);
10 return EOS_PUBLIC_PREFIX.concat(base58.encode(pubBuf));
11}
12
13function bufferToPrivate(privBuf) {
14 const EOS_PRIVATE_PREFIX = "80";
15 privBuf = Buffer.concat([Buffer.from(EOS_PRIVATE_PREFIX, "hex"), privBuf]);
16 let tmp = new createHash("sha256").update(privBuf).digest();
17 let checksum = new createHash("sha256").update(tmp).digest("hex").slice(0, 8);
18 privBuf = Buffer.concat([privBuf, Buffer.from(checksum, "hex")]);
19 return base58.encode(privBuf);
20}
21
22module.exports = {
23 bufferToPublic: bufferToPublic,
24 bufferToPrivate: bufferToPrivate,
25};
26
27},{"bs58":5,"buffer":6,"create-hash":9}],2:[function(require,module,exports){
28// base-x encoding / decoding
29// Copyright (c) 2018 base-x contributors
30// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
31// Distributed under the MIT software license, see the accompanying
32// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
33
34const Buffer = require('safe-buffer').Buffer
35
36module.exports = function base (ALPHABET) {
37 if (ALPHABET.length >= 255) throw new TypeError('Alphabet too long')
38
39 const BASE_MAP = new Uint8Array(256)
40 BASE_MAP.fill(255)
41
42 for (let i = 0; i < ALPHABET.length; i++) {
43 const x = ALPHABET.charAt(i)
44 const xc = x.charCodeAt(0)
45
46 if (BASE_MAP[xc] !== 255) throw new TypeError(x + ' is ambiguous')
47 BASE_MAP[xc] = i
48 }
49
50 const BASE = ALPHABET.length
51 const LEADER = ALPHABET.charAt(0)
52 const FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up
53 const iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up
54
55 function encode (source) {
56 if (!Buffer.isBuffer(source)) throw new TypeError('Expected Buffer')
57 if (source.length === 0) return ''
58
59 // Skip & count leading zeroes.
60 let zeroes = 0
61 let length = 0
62 let pbegin = 0
63 const pend = source.length
64
65 while (pbegin !== pend && source[pbegin] === 0) {
66 pbegin++
67 zeroes++
68 }
69
70 // Allocate enough space in big-endian base58 representation.
71 const size = ((pend - pbegin) * iFACTOR + 1) >>> 0
72 const b58 = new Uint8Array(size)
73
74 // Process the bytes.
75 while (pbegin !== pend) {
76 let carry = source[pbegin]
77
78 // Apply "b58 = b58 * 256 + ch".
79 let i = 0
80 for (let it = size - 1; (carry !== 0 || i < length) && (it !== -1); it--, i++) {
81 carry += (256 * b58[it]) >>> 0
82 b58[it] = (carry % BASE) >>> 0
83 carry = (carry / BASE) >>> 0
84 }
85
86 if (carry !== 0) throw new Error('Non-zero carry')
87 length = i
88 pbegin++
89 }
90
91 // Skip leading zeroes in base58 result.
92 let it = size - length
93 while (it !== size && b58[it] === 0) {
94 it++
95 }
96
97 // Translate the result into a string.
98 let str = LEADER.repeat(zeroes)
99 for (; it < size; ++it) str += ALPHABET.charAt(b58[it])
100
101 return str
102 }
103
104 function decodeUnsafe (source) {
105 if (typeof source !== 'string') throw new TypeError('Expected String')
106 if (source.length === 0) return Buffer.alloc(0)
107
108 let psz = 0
109
110 // Skip leading spaces.
111 if (source[psz] === ' ') return
112
113 // Skip and count leading '1's.
114 let zeroes = 0
115 let length = 0
116 while (source[psz] === LEADER) {
117 zeroes++
118 psz++
119 }
120
121 // Allocate enough space in big-endian base256 representation.
122 const size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up.
123 const b256 = new Uint8Array(size)
124
125 // Process the characters.
126 while (source[psz]) {
127 // Decode character
128 let carry = BASE_MAP[source.charCodeAt(psz)]
129
130 // Invalid character
131 if (carry === 255) return
132
133 let i = 0
134 for (let it = size - 1; (carry !== 0 || i < length) && (it !== -1); it--, i++) {
135 carry += (BASE * b256[it]) >>> 0
136 b256[it] = (carry % 256) >>> 0
137 carry = (carry / 256) >>> 0
138 }
139
140 if (carry !== 0) throw new Error('Non-zero carry')
141 length = i
142 psz++
143 }
144
145 // Skip trailing spaces.
146 if (source[psz] === ' ') return
147
148 // Skip leading zeroes in b256.
149 let it = size - length
150 while (it !== size && b256[it] === 0) {
151 it++
152 }
153
154 const vch = Buffer.allocUnsafe(zeroes + (size - it))
155 vch.fill(0x00, 0, zeroes)
156
157 let j = zeroes
158 while (it !== size) {
159 vch[j++] = b256[it++]
160 }
161
162 return vch
163 }
164
165 function decode (string) {
166 const buffer = decodeUnsafe(string)
167 if (buffer) return buffer
168
169 throw new Error('Non-base' + BASE + ' character')
170 }
171
172 return {
173 encode: encode,
174 decodeUnsafe: decodeUnsafe,
175 decode: decode
176 }
177}
178
179},{"safe-buffer":34}],3:[function(require,module,exports){
180'use strict'
181
182exports.byteLength = byteLength
183exports.toByteArray = toByteArray
184exports.fromByteArray = fromByteArray
185
186var lookup = []
187var revLookup = []
188var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
189
190var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
191for (var i = 0, len = code.length; i < len; ++i) {
192 lookup[i] = code[i]
193 revLookup[code.charCodeAt(i)] = i
194}
195
196// Support decoding URL-safe base64 strings, as Node.js does.
197// See: https://en.wikipedia.org/wiki/Base64#URL_applications
198revLookup['-'.charCodeAt(0)] = 62
199revLookup['_'.charCodeAt(0)] = 63
200
201function getLens (b64) {
202 var len = b64.length
203
204 if (len % 4 > 0) {
205 throw new Error('Invalid string. Length must be a multiple of 4')
206 }
207
208 // Trim off extra bytes after placeholder bytes are found
209 // See: https://github.com/beatgammit/base64-js/issues/42
210 var validLen = b64.indexOf('=')
211 if (validLen === -1) validLen = len
212
213 var placeHoldersLen = validLen === len
214 ? 0
215 : 4 - (validLen % 4)
216
217 return [validLen, placeHoldersLen]
218}
219
220// base64 is 4/3 + up to two characters of the original data
221function byteLength (b64) {
222 var lens = getLens(b64)
223 var validLen = lens[0]
224 var placeHoldersLen = lens[1]
225 return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
226}
227
228function _byteLength (b64, validLen, placeHoldersLen) {
229 return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
230}
231
232function toByteArray (b64) {
233 var tmp
234 var lens = getLens(b64)
235 var validLen = lens[0]
236 var placeHoldersLen = lens[1]
237
238 var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
239
240 var curByte = 0
241
242 // if there are placeholders, only get up to the last complete 4 chars
243 var len = placeHoldersLen > 0
244 ? validLen - 4
245 : validLen
246
247 for (var i = 0; i < len; i += 4) {
248 tmp =
249 (revLookup[b64.charCodeAt(i)] << 18) |
250 (revLookup[b64.charCodeAt(i + 1)] << 12) |
251 (revLookup[b64.charCodeAt(i + 2)] << 6) |
252 revLookup[b64.charCodeAt(i + 3)]
253 arr[curByte++] = (tmp >> 16) & 0xFF
254 arr[curByte++] = (tmp >> 8) & 0xFF
255 arr[curByte++] = tmp & 0xFF
256 }
257
258 if (placeHoldersLen === 2) {
259 tmp =
260 (revLookup[b64.charCodeAt(i)] << 2) |
261 (revLookup[b64.charCodeAt(i + 1)] >> 4)
262 arr[curByte++] = tmp & 0xFF
263 }
264
265 if (placeHoldersLen === 1) {
266 tmp =
267 (revLookup[b64.charCodeAt(i)] << 10) |
268 (revLookup[b64.charCodeAt(i + 1)] << 4) |
269 (revLookup[b64.charCodeAt(i + 2)] >> 2)
270 arr[curByte++] = (tmp >> 8) & 0xFF
271 arr[curByte++] = tmp & 0xFF
272 }
273
274 return arr
275}
276
277function tripletToBase64 (num) {
278 return lookup[num >> 18 & 0x3F] +
279 lookup[num >> 12 & 0x3F] +
280 lookup[num >> 6 & 0x3F] +
281 lookup[num & 0x3F]
282}
283
284function encodeChunk (uint8, start, end) {
285 var tmp
286 var output = []
287 for (var i = start; i < end; i += 3) {
288 tmp =
289 ((uint8[i] << 16) & 0xFF0000) +
290 ((uint8[i + 1] << 8) & 0xFF00) +
291 (uint8[i + 2] & 0xFF)
292 output.push(tripletToBase64(tmp))
293 }
294 return output.join('')
295}
296
297function fromByteArray (uint8) {
298 var tmp
299 var len = uint8.length
300 var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
301 var parts = []
302 var maxChunkLength = 16383 // must be multiple of 3
303
304 // go through the array every three bytes, we'll deal with trailing stuff later
305 for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
306 parts.push(encodeChunk(
307 uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
308 ))
309 }
310
311 // pad the end with zeros, but make sure to not forget the extra bytes
312 if (extraBytes === 1) {
313 tmp = uint8[len - 1]
314 parts.push(
315 lookup[tmp >> 2] +
316 lookup[(tmp << 4) & 0x3F] +
317 '=='
318 )
319 } else if (extraBytes === 2) {
320 tmp = (uint8[len - 2] << 8) + uint8[len - 1]
321 parts.push(
322 lookup[tmp >> 10] +
323 lookup[(tmp >> 4) & 0x3F] +
324 lookup[(tmp << 2) & 0x3F] +
325 '='
326 )
327 }
328
329 return parts.join('')
330}
331
332},{}],4:[function(require,module,exports){
333
334},{}],5:[function(require,module,exports){
335var basex = require('base-x')
336var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
337
338module.exports = basex(ALPHABET)
339
340},{"base-x":2}],6:[function(require,module,exports){
341(function (Buffer){
342/*!
343 * The buffer module from node.js, for the browser.
344 *
345 * @author Feross Aboukhadijeh <https://feross.org>
346 * @license MIT
347 */
348/* eslint-disable no-proto */
349
350'use strict'
351
352var base64 = require('base64-js')
353var ieee754 = require('ieee754')
354
355exports.Buffer = Buffer
356exports.SlowBuffer = SlowBuffer
357exports.INSPECT_MAX_BYTES = 50
358
359var K_MAX_LENGTH = 0x7fffffff
360exports.kMaxLength = K_MAX_LENGTH
361
362/**
363 * If `Buffer.TYPED_ARRAY_SUPPORT`:
364 * === true Use Uint8Array implementation (fastest)
365 * === false Print warning and recommend using `buffer` v4.x which has an Object
366 * implementation (most compatible, even IE6)
367 *
368 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
369 * Opera 11.6+, iOS 4.2+.
370 *
371 * We report that the browser does not support typed arrays if the are not subclassable
372 * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
373 * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
374 * for __proto__ and has a buggy typed array implementation.
375 */
376Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
377
378if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
379 typeof console.error === 'function') {
380 console.error(
381 'This browser lacks typed array (Uint8Array) support which is required by ' +
382 '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
383 )
384}
385
386function typedArraySupport () {
387 // Can typed array instances can be augmented?
388 try {
389 var arr = new Uint8Array(1)
390 arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } }
391 return arr.foo() === 42
392 } catch (e) {
393 return false
394 }
395}
396
397Object.defineProperty(Buffer.prototype, 'parent', {
398 enumerable: true,
399 get: function () {
400 if (!Buffer.isBuffer(this)) return undefined
401 return this.buffer
402 }
403})
404
405Object.defineProperty(Buffer.prototype, 'offset', {
406 enumerable: true,
407 get: function () {
408 if (!Buffer.isBuffer(this)) return undefined
409 return this.byteOffset
410 }
411})
412
413function createBuffer (length) {
414 if (length > K_MAX_LENGTH) {
415 throw new RangeError('The value "' + length + '" is invalid for option "size"')
416 }
417 // Return an augmented `Uint8Array` instance
418 var buf = new Uint8Array(length)
419 buf.__proto__ = Buffer.prototype
420 return buf
421}
422
423/**
424 * The Buffer constructor returns instances of `Uint8Array` that have their
425 * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
426 * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
427 * and the `Uint8Array` methods. Square bracket notation works as expected -- it
428 * returns a single octet.
429 *
430 * The `Uint8Array` prototype remains unmodified.
431 */
432
433function Buffer (arg, encodingOrOffset, length) {
434 // Common case.
435 if (typeof arg === 'number') {
436 if (typeof encodingOrOffset === 'string') {
437 throw new TypeError(
438 'The "string" argument must be of type string. Received type number'
439 )
440 }
441 return allocUnsafe(arg)
442 }
443 return from(arg, encodingOrOffset, length)
444}
445
446// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
447if (typeof Symbol !== 'undefined' && Symbol.species != null &&
448 Buffer[Symbol.species] === Buffer) {
449 Object.defineProperty(Buffer, Symbol.species, {
450 value: null,
451 configurable: true,
452 enumerable: false,
453 writable: false
454 })
455}
456
457Buffer.poolSize = 8192 // not used by this implementation
458
459function from (value, encodingOrOffset, length) {
460 if (typeof value === 'string') {
461 return fromString(value, encodingOrOffset)
462 }
463
464 if (ArrayBuffer.isView(value)) {
465 return fromArrayLike(value)
466 }
467
468 if (value == null) {
469 throw TypeError(
470 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
471 'or Array-like Object. Received type ' + (typeof value)
472 )
473 }
474
475 if (isInstance(value, ArrayBuffer) ||
476 (value && isInstance(value.buffer, ArrayBuffer))) {
477 return fromArrayBuffer(value, encodingOrOffset, length)
478 }
479
480 if (typeof value === 'number') {
481 throw new TypeError(
482 'The "value" argument must not be of type number. Received type number'
483 )
484 }
485
486 var valueOf = value.valueOf && value.valueOf()
487 if (valueOf != null && valueOf !== value) {
488 return Buffer.from(valueOf, encodingOrOffset, length)
489 }
490
491 var b = fromObject(value)
492 if (b) return b
493
494 if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
495 typeof value[Symbol.toPrimitive] === 'function') {
496 return Buffer.from(
497 value[Symbol.toPrimitive]('string'), encodingOrOffset, length
498 )
499 }
500
501 throw new TypeError(
502 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
503 'or Array-like Object. Received type ' + (typeof value)
504 )
505}
506
507/**
508 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
509 * if value is a number.
510 * Buffer.from(str[, encoding])
511 * Buffer.from(array)
512 * Buffer.from(buffer)
513 * Buffer.from(arrayBuffer[, byteOffset[, length]])
514 **/
515Buffer.from = function (value, encodingOrOffset, length) {
516 return from(value, encodingOrOffset, length)
517}
518
519// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
520// https://github.com/feross/buffer/pull/148
521Buffer.prototype.__proto__ = Uint8Array.prototype
522Buffer.__proto__ = Uint8Array
523
524function assertSize (size) {
525 if (typeof size !== 'number') {
526 throw new TypeError('"size" argument must be of type number')
527 } else if (size < 0) {
528 throw new RangeError('The value "' + size + '" is invalid for option "size"')
529 }
530}
531
532function alloc (size, fill, encoding) {
533 assertSize(size)
534 if (size <= 0) {
535 return createBuffer(size)
536 }
537 if (fill !== undefined) {
538 // Only pay attention to encoding if it's a string. This
539 // prevents accidentally sending in a number that would
540 // be interpretted as a start offset.
541 return typeof encoding === 'string'
542 ? createBuffer(size).fill(fill, encoding)
543 : createBuffer(size).fill(fill)
544 }
545 return createBuffer(size)
546}
547
548/**
549 * Creates a new filled Buffer instance.
550 * alloc(size[, fill[, encoding]])
551 **/
552Buffer.alloc = function (size, fill, encoding) {
553 return alloc(size, fill, encoding)
554}
555
556function allocUnsafe (size) {
557 assertSize(size)
558 return createBuffer(size < 0 ? 0 : checked(size) | 0)
559}
560
561/**
562 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
563 * */
564Buffer.allocUnsafe = function (size) {
565 return allocUnsafe(size)
566}
567/**
568 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
569 */
570Buffer.allocUnsafeSlow = function (size) {
571 return allocUnsafe(size)
572}
573
574function fromString (string, encoding) {
575 if (typeof encoding !== 'string' || encoding === '') {
576 encoding = 'utf8'
577 }
578
579 if (!Buffer.isEncoding(encoding)) {
580 throw new TypeError('Unknown encoding: ' + encoding)
581 }
582
583 var length = byteLength(string, encoding) | 0
584 var buf = createBuffer(length)
585
586 var actual = buf.write(string, encoding)
587
588 if (actual !== length) {
589 // Writing a hex string, for example, that contains invalid characters will
590 // cause everything after the first invalid character to be ignored. (e.g.
591 // 'abxxcd' will be treated as 'ab')
592 buf = buf.slice(0, actual)
593 }
594
595 return buf
596}
597
598function fromArrayLike (array) {
599 var length = array.length < 0 ? 0 : checked(array.length) | 0
600 var buf = createBuffer(length)
601 for (var i = 0; i < length; i += 1) {
602 buf[i] = array[i] & 255
603 }
604 return buf
605}
606
607function fromArrayBuffer (array, byteOffset, length) {
608 if (byteOffset < 0 || array.byteLength < byteOffset) {
609 throw new RangeError('"offset" is outside of buffer bounds')
610 }
611
612 if (array.byteLength < byteOffset + (length || 0)) {
613 throw new RangeError('"length" is outside of buffer bounds')
614 }
615
616 var buf
617 if (byteOffset === undefined && length === undefined) {
618 buf = new Uint8Array(array)
619 } else if (length === undefined) {
620 buf = new Uint8Array(array, byteOffset)
621 } else {
622 buf = new Uint8Array(array, byteOffset, length)
623 }
624
625 // Return an augmented `Uint8Array` instance
626 buf.__proto__ = Buffer.prototype
627 return buf
628}
629
630function fromObject (obj) {
631 if (Buffer.isBuffer(obj)) {
632 var len = checked(obj.length) | 0
633 var buf = createBuffer(len)
634
635 if (buf.length === 0) {
636 return buf
637 }
638
639 obj.copy(buf, 0, 0, len)
640 return buf
641 }
642
643 if (obj.length !== undefined) {
644 if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
645 return createBuffer(0)
646 }
647 return fromArrayLike(obj)
648 }
649
650 if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
651 return fromArrayLike(obj.data)
652 }
653}
654
655function checked (length) {
656 // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
657 // length is NaN (which is otherwise coerced to zero.)
658 if (length >= K_MAX_LENGTH) {
659 throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
660 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
661 }
662 return length | 0
663}
664
665function SlowBuffer (length) {
666 if (+length != length) { // eslint-disable-line eqeqeq
667 length = 0
668 }
669 return Buffer.alloc(+length)
670}
671
672Buffer.isBuffer = function isBuffer (b) {
673 return b != null && b._isBuffer === true &&
674 b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
675}
676
677Buffer.compare = function compare (a, b) {
678 if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)
679 if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)
680 if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
681 throw new TypeError(
682 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
683 )
684 }
685
686 if (a === b) return 0
687
688 var x = a.length
689 var y = b.length
690
691 for (var i = 0, len = Math.min(x, y); i < len; ++i) {
692 if (a[i] !== b[i]) {
693 x = a[i]
694 y = b[i]
695 break
696 }
697 }
698
699 if (x < y) return -1
700 if (y < x) return 1
701 return 0
702}
703
704Buffer.isEncoding = function isEncoding (encoding) {
705 switch (String(encoding).toLowerCase()) {
706 case 'hex':
707 case 'utf8':
708 case 'utf-8':
709 case 'ascii':
710 case 'latin1':
711 case 'binary':
712 case 'base64':
713 case 'ucs2':
714 case 'ucs-2':
715 case 'utf16le':
716 case 'utf-16le':
717 return true
718 default:
719 return false
720 }
721}
722
723Buffer.concat = function concat (list, length) {
724 if (!Array.isArray(list)) {
725 throw new TypeError('"list" argument must be an Array of Buffers')
726 }
727
728 if (list.length === 0) {
729 return Buffer.alloc(0)
730 }
731
732 var i
733 if (length === undefined) {
734 length = 0
735 for (i = 0; i < list.length; ++i) {
736 length += list[i].length
737 }
738 }
739
740 var buffer = Buffer.allocUnsafe(length)
741 var pos = 0
742 for (i = 0; i < list.length; ++i) {
743 var buf = list[i]
744 if (isInstance(buf, Uint8Array)) {
745 buf = Buffer.from(buf)
746 }
747 if (!Buffer.isBuffer(buf)) {
748 throw new TypeError('"list" argument must be an Array of Buffers')
749 }
750 buf.copy(buffer, pos)
751 pos += buf.length
752 }
753 return buffer
754}
755
756function byteLength (string, encoding) {
757 if (Buffer.isBuffer(string)) {
758 return string.length
759 }
760 if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
761 return string.byteLength
762 }
763 if (typeof string !== 'string') {
764 throw new TypeError(
765 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
766 'Received type ' + typeof string
767 )
768 }
769
770 var len = string.length
771 var mustMatch = (arguments.length > 2 && arguments[2] === true)
772 if (!mustMatch && len === 0) return 0
773
774 // Use a for loop to avoid recursion
775 var loweredCase = false
776 for (;;) {
777 switch (encoding) {
778 case 'ascii':
779 case 'latin1':
780 case 'binary':
781 return len
782 case 'utf8':
783 case 'utf-8':
784 return utf8ToBytes(string).length
785 case 'ucs2':
786 case 'ucs-2':
787 case 'utf16le':
788 case 'utf-16le':
789 return len * 2
790 case 'hex':
791 return len >>> 1
792 case 'base64':
793 return base64ToBytes(string).length
794 default:
795 if (loweredCase) {
796 return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
797 }
798 encoding = ('' + encoding).toLowerCase()
799 loweredCase = true
800 }
801 }
802}
803Buffer.byteLength = byteLength
804
805function slowToString (encoding, start, end) {
806 var loweredCase = false
807
808 // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
809 // property of a typed array.
810
811 // This behaves neither like String nor Uint8Array in that we set start/end
812 // to their upper/lower bounds if the value passed is out of range.
813 // undefined is handled specially as per ECMA-262 6th Edition,
814 // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
815 if (start === undefined || start < 0) {
816 start = 0
817 }
818 // Return early if start > this.length. Done here to prevent potential uint32
819 // coercion fail below.
820 if (start > this.length) {
821 return ''
822 }
823
824 if (end === undefined || end > this.length) {
825 end = this.length
826 }
827
828 if (end <= 0) {
829 return ''
830 }
831
832 // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
833 end >>>= 0
834 start >>>= 0
835
836 if (end <= start) {
837 return ''
838 }
839
840 if (!encoding) encoding = 'utf8'
841
842 while (true) {
843 switch (encoding) {
844 case 'hex':
845 return hexSlice(this, start, end)
846
847 case 'utf8':
848 case 'utf-8':
849 return utf8Slice(this, start, end)
850
851 case 'ascii':
852 return asciiSlice(this, start, end)
853
854 case 'latin1':
855 case 'binary':
856 return latin1Slice(this, start, end)
857
858 case 'base64':
859 return base64Slice(this, start, end)
860
861 case 'ucs2':
862 case 'ucs-2':
863 case 'utf16le':
864 case 'utf-16le':
865 return utf16leSlice(this, start, end)
866
867 default:
868 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
869 encoding = (encoding + '').toLowerCase()
870 loweredCase = true
871 }
872 }
873}
874
875// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
876// to detect a Buffer instance. It's not possible to use `instanceof Buffer`
877// reliably in a browserify context because there could be multiple different
878// copies of the 'buffer' package in use. This method works even for Buffer
879// instances that were created from another copy of the `buffer` package.
880// See: https://github.com/feross/buffer/issues/154
881Buffer.prototype._isBuffer = true
882
883function swap (b, n, m) {
884 var i = b[n]
885 b[n] = b[m]
886 b[m] = i
887}
888
889Buffer.prototype.swap16 = function swap16 () {
890 var len = this.length
891 if (len % 2 !== 0) {
892 throw new RangeError('Buffer size must be a multiple of 16-bits')
893 }
894 for (var i = 0; i < len; i += 2) {
895 swap(this, i, i + 1)
896 }
897 return this
898}
899
900Buffer.prototype.swap32 = function swap32 () {
901 var len = this.length
902 if (len % 4 !== 0) {
903 throw new RangeError('Buffer size must be a multiple of 32-bits')
904 }
905 for (var i = 0; i < len; i += 4) {
906 swap(this, i, i + 3)
907 swap(this, i + 1, i + 2)
908 }
909 return this
910}
911
912Buffer.prototype.swap64 = function swap64 () {
913 var len = this.length
914 if (len % 8 !== 0) {
915 throw new RangeError('Buffer size must be a multiple of 64-bits')
916 }
917 for (var i = 0; i < len; i += 8) {
918 swap(this, i, i + 7)
919 swap(this, i + 1, i + 6)
920 swap(this, i + 2, i + 5)
921 swap(this, i + 3, i + 4)
922 }
923 return this
924}
925
926Buffer.prototype.toString = function toString () {
927 var length = this.length
928 if (length === 0) return ''
929 if (arguments.length === 0) return utf8Slice(this, 0, length)
930 return slowToString.apply(this, arguments)
931}
932
933Buffer.prototype.toLocaleString = Buffer.prototype.toString
934
935Buffer.prototype.equals = function equals (b) {
936 if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
937 if (this === b) return true
938 return Buffer.compare(this, b) === 0
939}
940
941Buffer.prototype.inspect = function inspect () {
942 var str = ''
943 var max = exports.INSPECT_MAX_BYTES
944 str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()
945 if (this.length > max) str += ' ... '
946 return '<Buffer ' + str + '>'
947}
948
949Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
950 if (isInstance(target, Uint8Array)) {
951 target = Buffer.from(target, target.offset, target.byteLength)
952 }
953 if (!Buffer.isBuffer(target)) {
954 throw new TypeError(
955 'The "target" argument must be one of type Buffer or Uint8Array. ' +
956 'Received type ' + (typeof target)
957 )
958 }
959
960 if (start === undefined) {
961 start = 0
962 }
963 if (end === undefined) {
964 end = target ? target.length : 0
965 }
966 if (thisStart === undefined) {
967 thisStart = 0
968 }
969 if (thisEnd === undefined) {
970 thisEnd = this.length
971 }
972
973 if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
974 throw new RangeError('out of range index')
975 }
976
977 if (thisStart >= thisEnd && start >= end) {
978 return 0
979 }
980 if (thisStart >= thisEnd) {
981 return -1
982 }
983 if (start >= end) {
984 return 1
985 }
986
987 start >>>= 0
988 end >>>= 0
989 thisStart >>>= 0
990 thisEnd >>>= 0
991
992 if (this === target) return 0
993
994 var x = thisEnd - thisStart
995 var y = end - start
996 var len = Math.min(x, y)
997
998 var thisCopy = this.slice(thisStart, thisEnd)
999 var targetCopy = target.slice(start, end)
1000
1001 for (var i = 0; i < len; ++i) {
1002 if (thisCopy[i] !== targetCopy[i]) {
1003 x = thisCopy[i]
1004 y = targetCopy[i]
1005 break
1006 }
1007 }
1008
1009 if (x < y) return -1
1010 if (y < x) return 1
1011 return 0
1012}
1013
1014// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
1015// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
1016//
1017// Arguments:
1018// - buffer - a Buffer to search
1019// - val - a string, Buffer, or number
1020// - byteOffset - an index into `buffer`; will be clamped to an int32
1021// - encoding - an optional encoding, relevant is val is a string
1022// - dir - true for indexOf, false for lastIndexOf
1023function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
1024 // Empty buffer means no match
1025 if (buffer.length === 0) return -1
1026
1027 // Normalize byteOffset
1028 if (typeof byteOffset === 'string') {
1029 encoding = byteOffset
1030 byteOffset = 0
1031 } else if (byteOffset > 0x7fffffff) {
1032 byteOffset = 0x7fffffff
1033 } else if (byteOffset < -0x80000000) {
1034 byteOffset = -0x80000000
1035 }
1036 byteOffset = +byteOffset // Coerce to Number.
1037 if (numberIsNaN(byteOffset)) {
1038 // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
1039 byteOffset = dir ? 0 : (buffer.length - 1)
1040 }
1041
1042 // Normalize byteOffset: negative offsets start from the end of the buffer
1043 if (byteOffset < 0) byteOffset = buffer.length + byteOffset
1044 if (byteOffset >= buffer.length) {
1045 if (dir) return -1
1046 else byteOffset = buffer.length - 1
1047 } else if (byteOffset < 0) {
1048 if (dir) byteOffset = 0
1049 else return -1
1050 }
1051
1052 // Normalize val
1053 if (typeof val === 'string') {
1054 val = Buffer.from(val, encoding)
1055 }
1056
1057 // Finally, search either indexOf (if dir is true) or lastIndexOf
1058 if (Buffer.isBuffer(val)) {
1059 // Special case: looking for empty string/buffer always fails
1060 if (val.length === 0) {
1061 return -1
1062 }
1063 return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
1064 } else if (typeof val === 'number') {
1065 val = val & 0xFF // Search for a byte value [0-255]
1066 if (typeof Uint8Array.prototype.indexOf === 'function') {
1067 if (dir) {
1068 return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
1069 } else {
1070 return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
1071 }
1072 }
1073 return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
1074 }
1075
1076 throw new TypeError('val must be string, number or Buffer')
1077}
1078
1079function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
1080 var indexSize = 1
1081 var arrLength = arr.length
1082 var valLength = val.length
1083
1084 if (encoding !== undefined) {
1085 encoding = String(encoding).toLowerCase()
1086 if (encoding === 'ucs2' || encoding === 'ucs-2' ||
1087 encoding === 'utf16le' || encoding === 'utf-16le') {
1088 if (arr.length < 2 || val.length < 2) {
1089 return -1
1090 }
1091 indexSize = 2
1092 arrLength /= 2
1093 valLength /= 2
1094 byteOffset /= 2
1095 }
1096 }
1097
1098 function read (buf, i) {
1099 if (indexSize === 1) {
1100 return buf[i]
1101 } else {
1102 return buf.readUInt16BE(i * indexSize)
1103 }
1104 }
1105
1106 var i
1107 if (dir) {
1108 var foundIndex = -1
1109 for (i = byteOffset; i < arrLength; i++) {
1110 if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
1111 if (foundIndex === -1) foundIndex = i
1112 if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
1113 } else {
1114 if (foundIndex !== -1) i -= i - foundIndex
1115 foundIndex = -1
1116 }
1117 }
1118 } else {
1119 if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
1120 for (i = byteOffset; i >= 0; i--) {
1121 var found = true
1122 for (var j = 0; j < valLength; j++) {
1123 if (read(arr, i + j) !== read(val, j)) {
1124 found = false
1125 break
1126 }
1127 }
1128 if (found) return i
1129 }
1130 }
1131
1132 return -1
1133}
1134
1135Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
1136 return this.indexOf(val, byteOffset, encoding) !== -1
1137}
1138
1139Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
1140 return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
1141}
1142
1143Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
1144 return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
1145}
1146
1147function hexWrite (buf, string, offset, length) {
1148 offset = Number(offset) || 0
1149 var remaining = buf.length - offset
1150 if (!length) {
1151 length = remaining
1152 } else {
1153 length = Number(length)
1154 if (length > remaining) {
1155 length = remaining
1156 }
1157 }
1158
1159 var strLen = string.length
1160
1161 if (length > strLen / 2) {
1162 length = strLen / 2
1163 }
1164 for (var i = 0; i < length; ++i) {
1165 var parsed = parseInt(string.substr(i * 2, 2), 16)
1166 if (numberIsNaN(parsed)) return i
1167 buf[offset + i] = parsed
1168 }
1169 return i
1170}
1171
1172function utf8Write (buf, string, offset, length) {
1173 return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
1174}
1175
1176function asciiWrite (buf, string, offset, length) {
1177 return blitBuffer(asciiToBytes(string), buf, offset, length)
1178}
1179
1180function latin1Write (buf, string, offset, length) {
1181 return asciiWrite(buf, string, offset, length)
1182}
1183
1184function base64Write (buf, string, offset, length) {
1185 return blitBuffer(base64ToBytes(string), buf, offset, length)
1186}
1187
1188function ucs2Write (buf, string, offset, length) {
1189 return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
1190}
1191
1192Buffer.prototype.write = function write (string, offset, length, encoding) {
1193 // Buffer#write(string)
1194 if (offset === undefined) {
1195 encoding = 'utf8'
1196 length = this.length
1197 offset = 0
1198 // Buffer#write(string, encoding)
1199 } else if (length === undefined && typeof offset === 'string') {
1200 encoding = offset
1201 length = this.length
1202 offset = 0
1203 // Buffer#write(string, offset[, length][, encoding])
1204 } else if (isFinite(offset)) {
1205 offset = offset >>> 0
1206 if (isFinite(length)) {
1207 length = length >>> 0
1208 if (encoding === undefined) encoding = 'utf8'
1209 } else {
1210 encoding = length
1211 length = undefined
1212 }
1213 } else {
1214 throw new Error(
1215 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
1216 )
1217 }
1218
1219 var remaining = this.length - offset
1220 if (length === undefined || length > remaining) length = remaining
1221
1222 if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
1223 throw new RangeError('Attempt to write outside buffer bounds')
1224 }
1225
1226 if (!encoding) encoding = 'utf8'
1227
1228 var loweredCase = false
1229 for (;;) {
1230 switch (encoding) {
1231 case 'hex':
1232 return hexWrite(this, string, offset, length)
1233
1234 case 'utf8':
1235 case 'utf-8':
1236 return utf8Write(this, string, offset, length)
1237
1238 case 'ascii':
1239 return asciiWrite(this, string, offset, length)
1240
1241 case 'latin1':
1242 case 'binary':
1243 return latin1Write(this, string, offset, length)
1244
1245 case 'base64':
1246 // Warning: maxLength not taken into account in base64Write
1247 return base64Write(this, string, offset, length)
1248
1249 case 'ucs2':
1250 case 'ucs-2':
1251 case 'utf16le':
1252 case 'utf-16le':
1253 return ucs2Write(this, string, offset, length)
1254
1255 default:
1256 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
1257 encoding = ('' + encoding).toLowerCase()
1258 loweredCase = true
1259 }
1260 }
1261}
1262
1263Buffer.prototype.toJSON = function toJSON () {
1264 return {
1265 type: 'Buffer',
1266 data: Array.prototype.slice.call(this._arr || this, 0)
1267 }
1268}
1269
1270function base64Slice (buf, start, end) {
1271 if (start === 0 && end === buf.length) {
1272 return base64.fromByteArray(buf)
1273 } else {
1274 return base64.fromByteArray(buf.slice(start, end))
1275 }
1276}
1277
1278function utf8Slice (buf, start, end) {
1279 end = Math.min(buf.length, end)
1280 var res = []
1281
1282 var i = start
1283 while (i < end) {
1284 var firstByte = buf[i]
1285 var codePoint = null
1286 var bytesPerSequence = (firstByte > 0xEF) ? 4
1287 : (firstByte > 0xDF) ? 3
1288 : (firstByte > 0xBF) ? 2
1289 : 1
1290
1291 if (i + bytesPerSequence <= end) {
1292 var secondByte, thirdByte, fourthByte, tempCodePoint
1293
1294 switch (bytesPerSequence) {
1295 case 1:
1296 if (firstByte < 0x80) {
1297 codePoint = firstByte
1298 }
1299 break
1300 case 2:
1301 secondByte = buf[i + 1]
1302 if ((secondByte & 0xC0) === 0x80) {
1303 tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
1304 if (tempCodePoint > 0x7F) {
1305 codePoint = tempCodePoint
1306 }
1307 }
1308 break
1309 case 3:
1310 secondByte = buf[i + 1]
1311 thirdByte = buf[i + 2]
1312 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
1313 tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
1314 if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
1315 codePoint = tempCodePoint
1316 }
1317 }
1318 break
1319 case 4:
1320 secondByte = buf[i + 1]
1321 thirdByte = buf[i + 2]
1322 fourthByte = buf[i + 3]
1323 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
1324 tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
1325 if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
1326 codePoint = tempCodePoint
1327 }
1328 }
1329 }
1330 }
1331
1332 if (codePoint === null) {
1333 // we did not generate a valid codePoint so insert a
1334 // replacement char (U+FFFD) and advance only 1 byte
1335 codePoint = 0xFFFD
1336 bytesPerSequence = 1
1337 } else if (codePoint > 0xFFFF) {
1338 // encode to utf16 (surrogate pair dance)
1339 codePoint -= 0x10000
1340 res.push(codePoint >>> 10 & 0x3FF | 0xD800)
1341 codePoint = 0xDC00 | codePoint & 0x3FF
1342 }
1343
1344 res.push(codePoint)
1345 i += bytesPerSequence
1346 }
1347
1348 return decodeCodePointsArray(res)
1349}
1350
1351// Based on http://stackoverflow.com/a/22747272/680742, the browser with
1352// the lowest limit is Chrome, with 0x10000 args.
1353// We go 1 magnitude less, for safety
1354var MAX_ARGUMENTS_LENGTH = 0x1000
1355
1356function decodeCodePointsArray (codePoints) {
1357 var len = codePoints.length
1358 if (len <= MAX_ARGUMENTS_LENGTH) {
1359 return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
1360 }
1361
1362 // Decode in chunks to avoid "call stack size exceeded".
1363 var res = ''
1364 var i = 0
1365 while (i < len) {
1366 res += String.fromCharCode.apply(
1367 String,
1368 codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
1369 )
1370 }
1371 return res
1372}
1373
1374function asciiSlice (buf, start, end) {
1375 var ret = ''
1376 end = Math.min(buf.length, end)
1377
1378 for (var i = start; i < end; ++i) {
1379 ret += String.fromCharCode(buf[i] & 0x7F)
1380 }
1381 return ret
1382}
1383
1384function latin1Slice (buf, start, end) {
1385 var ret = ''
1386 end = Math.min(buf.length, end)
1387
1388 for (var i = start; i < end; ++i) {
1389 ret += String.fromCharCode(buf[i])
1390 }
1391 return ret
1392}
1393
1394function hexSlice (buf, start, end) {
1395 var len = buf.length
1396
1397 if (!start || start < 0) start = 0
1398 if (!end || end < 0 || end > len) end = len
1399
1400 var out = ''
1401 for (var i = start; i < end; ++i) {
1402 out += toHex(buf[i])
1403 }
1404 return out
1405}
1406
1407function utf16leSlice (buf, start, end) {
1408 var bytes = buf.slice(start, end)
1409 var res = ''
1410 for (var i = 0; i < bytes.length; i += 2) {
1411 res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
1412 }
1413 return res
1414}
1415
1416Buffer.prototype.slice = function slice (start, end) {
1417 var len = this.length
1418 start = ~~start
1419 end = end === undefined ? len : ~~end
1420
1421 if (start < 0) {
1422 start += len
1423 if (start < 0) start = 0
1424 } else if (start > len) {
1425 start = len
1426 }
1427
1428 if (end < 0) {
1429 end += len
1430 if (end < 0) end = 0
1431 } else if (end > len) {
1432 end = len
1433 }
1434
1435 if (end < start) end = start
1436
1437 var newBuf = this.subarray(start, end)
1438 // Return an augmented `Uint8Array` instance
1439 newBuf.__proto__ = Buffer.prototype
1440 return newBuf
1441}
1442
1443/*
1444 * Need to make sure that buffer isn't trying to write out of bounds.
1445 */
1446function checkOffset (offset, ext, length) {
1447 if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
1448 if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
1449}
1450
1451Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
1452 offset = offset >>> 0
1453 byteLength = byteLength >>> 0
1454 if (!noAssert) checkOffset(offset, byteLength, this.length)
1455
1456 var val = this[offset]
1457 var mul = 1
1458 var i = 0
1459 while (++i < byteLength && (mul *= 0x100)) {
1460 val += this[offset + i] * mul
1461 }
1462
1463 return val
1464}
1465
1466Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
1467 offset = offset >>> 0
1468 byteLength = byteLength >>> 0
1469 if (!noAssert) {
1470 checkOffset(offset, byteLength, this.length)
1471 }
1472
1473 var val = this[offset + --byteLength]
1474 var mul = 1
1475 while (byteLength > 0 && (mul *= 0x100)) {
1476 val += this[offset + --byteLength] * mul
1477 }
1478
1479 return val
1480}
1481
1482Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
1483 offset = offset >>> 0
1484 if (!noAssert) checkOffset(offset, 1, this.length)
1485 return this[offset]
1486}
1487
1488Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
1489 offset = offset >>> 0
1490 if (!noAssert) checkOffset(offset, 2, this.length)
1491 return this[offset] | (this[offset + 1] << 8)
1492}
1493
1494Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
1495 offset = offset >>> 0
1496 if (!noAssert) checkOffset(offset, 2, this.length)
1497 return (this[offset] << 8) | this[offset + 1]
1498}
1499
1500Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
1501 offset = offset >>> 0
1502 if (!noAssert) checkOffset(offset, 4, this.length)
1503
1504 return ((this[offset]) |
1505 (this[offset + 1] << 8) |
1506 (this[offset + 2] << 16)) +
1507 (this[offset + 3] * 0x1000000)
1508}
1509
1510Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
1511 offset = offset >>> 0
1512 if (!noAssert) checkOffset(offset, 4, this.length)
1513
1514 return (this[offset] * 0x1000000) +
1515 ((this[offset + 1] << 16) |
1516 (this[offset + 2] << 8) |
1517 this[offset + 3])
1518}
1519
1520Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
1521 offset = offset >>> 0
1522 byteLength = byteLength >>> 0
1523 if (!noAssert) checkOffset(offset, byteLength, this.length)
1524
1525 var val = this[offset]
1526 var mul = 1
1527 var i = 0
1528 while (++i < byteLength && (mul *= 0x100)) {
1529 val += this[offset + i] * mul
1530 }
1531 mul *= 0x80
1532
1533 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
1534
1535 return val
1536}
1537
1538Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
1539 offset = offset >>> 0
1540 byteLength = byteLength >>> 0
1541 if (!noAssert) checkOffset(offset, byteLength, this.length)
1542
1543 var i = byteLength
1544 var mul = 1
1545 var val = this[offset + --i]
1546 while (i > 0 && (mul *= 0x100)) {
1547 val += this[offset + --i] * mul
1548 }
1549 mul *= 0x80
1550
1551 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
1552
1553 return val
1554}
1555
1556Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
1557 offset = offset >>> 0
1558 if (!noAssert) checkOffset(offset, 1, this.length)
1559 if (!(this[offset] & 0x80)) return (this[offset])
1560 return ((0xff - this[offset] + 1) * -1)
1561}
1562
1563Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
1564 offset = offset >>> 0
1565 if (!noAssert) checkOffset(offset, 2, this.length)
1566 var val = this[offset] | (this[offset + 1] << 8)
1567 return (val & 0x8000) ? val | 0xFFFF0000 : val
1568}
1569
1570Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
1571 offset = offset >>> 0
1572 if (!noAssert) checkOffset(offset, 2, this.length)
1573 var val = this[offset + 1] | (this[offset] << 8)
1574 return (val & 0x8000) ? val | 0xFFFF0000 : val
1575}
1576
1577Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
1578 offset = offset >>> 0
1579 if (!noAssert) checkOffset(offset, 4, this.length)
1580
1581 return (this[offset]) |
1582 (this[offset + 1] << 8) |
1583 (this[offset + 2] << 16) |
1584 (this[offset + 3] << 24)
1585}
1586
1587Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
1588 offset = offset >>> 0
1589 if (!noAssert) checkOffset(offset, 4, this.length)
1590
1591 return (this[offset] << 24) |
1592 (this[offset + 1] << 16) |
1593 (this[offset + 2] << 8) |
1594 (this[offset + 3])
1595}
1596
1597Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
1598 offset = offset >>> 0
1599 if (!noAssert) checkOffset(offset, 4, this.length)
1600 return ieee754.read(this, offset, true, 23, 4)
1601}
1602
1603Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
1604 offset = offset >>> 0
1605 if (!noAssert) checkOffset(offset, 4, this.length)
1606 return ieee754.read(this, offset, false, 23, 4)
1607}
1608
1609Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
1610 offset = offset >>> 0
1611 if (!noAssert) checkOffset(offset, 8, this.length)
1612 return ieee754.read(this, offset, true, 52, 8)
1613}
1614
1615Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
1616 offset = offset >>> 0
1617 if (!noAssert) checkOffset(offset, 8, this.length)
1618 return ieee754.read(this, offset, false, 52, 8)
1619}
1620
1621function checkInt (buf, value, offset, ext, max, min) {
1622 if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
1623 if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
1624 if (offset + ext > buf.length) throw new RangeError('Index out of range')
1625}
1626
1627Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
1628 value = +value
1629 offset = offset >>> 0
1630 byteLength = byteLength >>> 0
1631 if (!noAssert) {
1632 var maxBytes = Math.pow(2, 8 * byteLength) - 1
1633 checkInt(this, value, offset, byteLength, maxBytes, 0)
1634 }
1635
1636 var mul = 1
1637 var i = 0
1638 this[offset] = value & 0xFF
1639 while (++i < byteLength && (mul *= 0x100)) {
1640 this[offset + i] = (value / mul) & 0xFF
1641 }
1642
1643 return offset + byteLength
1644}
1645
1646Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
1647 value = +value
1648 offset = offset >>> 0
1649 byteLength = byteLength >>> 0
1650 if (!noAssert) {
1651 var maxBytes = Math.pow(2, 8 * byteLength) - 1
1652 checkInt(this, value, offset, byteLength, maxBytes, 0)
1653 }
1654
1655 var i = byteLength - 1
1656 var mul = 1
1657 this[offset + i] = value & 0xFF
1658 while (--i >= 0 && (mul *= 0x100)) {
1659 this[offset + i] = (value / mul) & 0xFF
1660 }
1661
1662 return offset + byteLength
1663}
1664
1665Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
1666 value = +value
1667 offset = offset >>> 0
1668 if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
1669 this[offset] = (value & 0xff)
1670 return offset + 1
1671}
1672
1673Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
1674 value = +value
1675 offset = offset >>> 0
1676 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
1677 this[offset] = (value & 0xff)
1678 this[offset + 1] = (value >>> 8)
1679 return offset + 2
1680}
1681
1682Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
1683 value = +value
1684 offset = offset >>> 0
1685 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
1686 this[offset] = (value >>> 8)
1687 this[offset + 1] = (value & 0xff)
1688 return offset + 2
1689}
1690
1691Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
1692 value = +value
1693 offset = offset >>> 0
1694 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
1695 this[offset + 3] = (value >>> 24)
1696 this[offset + 2] = (value >>> 16)
1697 this[offset + 1] = (value >>> 8)
1698 this[offset] = (value & 0xff)
1699 return offset + 4
1700}
1701
1702Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
1703 value = +value
1704 offset = offset >>> 0
1705 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
1706 this[offset] = (value >>> 24)
1707 this[offset + 1] = (value >>> 16)
1708 this[offset + 2] = (value >>> 8)
1709 this[offset + 3] = (value & 0xff)
1710 return offset + 4
1711}
1712
1713Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
1714 value = +value
1715 offset = offset >>> 0
1716 if (!noAssert) {
1717 var limit = Math.pow(2, (8 * byteLength) - 1)
1718
1719 checkInt(this, value, offset, byteLength, limit - 1, -limit)
1720 }
1721
1722 var i = 0
1723 var mul = 1
1724 var sub = 0
1725 this[offset] = value & 0xFF
1726 while (++i < byteLength && (mul *= 0x100)) {
1727 if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
1728 sub = 1
1729 }
1730 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
1731 }
1732
1733 return offset + byteLength
1734}
1735
1736Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
1737 value = +value
1738 offset = offset >>> 0
1739 if (!noAssert) {
1740 var limit = Math.pow(2, (8 * byteLength) - 1)
1741
1742 checkInt(this, value, offset, byteLength, limit - 1, -limit)
1743 }
1744
1745 var i = byteLength - 1
1746 var mul = 1
1747 var sub = 0
1748 this[offset + i] = value & 0xFF
1749 while (--i >= 0 && (mul *= 0x100)) {
1750 if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
1751 sub = 1
1752 }
1753 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
1754 }
1755
1756 return offset + byteLength
1757}
1758
1759Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
1760 value = +value
1761 offset = offset >>> 0
1762 if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
1763 if (value < 0) value = 0xff + value + 1
1764 this[offset] = (value & 0xff)
1765 return offset + 1
1766}
1767
1768Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
1769 value = +value
1770 offset = offset >>> 0
1771 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
1772 this[offset] = (value & 0xff)
1773 this[offset + 1] = (value >>> 8)
1774 return offset + 2
1775}
1776
1777Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
1778 value = +value
1779 offset = offset >>> 0
1780 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
1781 this[offset] = (value >>> 8)
1782 this[offset + 1] = (value & 0xff)
1783 return offset + 2
1784}
1785
1786Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
1787 value = +value
1788 offset = offset >>> 0
1789 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
1790 this[offset] = (value & 0xff)
1791 this[offset + 1] = (value >>> 8)
1792 this[offset + 2] = (value >>> 16)
1793 this[offset + 3] = (value >>> 24)
1794 return offset + 4
1795}
1796
1797Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
1798 value = +value
1799 offset = offset >>> 0
1800 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
1801 if (value < 0) value = 0xffffffff + value + 1
1802 this[offset] = (value >>> 24)
1803 this[offset + 1] = (value >>> 16)
1804 this[offset + 2] = (value >>> 8)
1805 this[offset + 3] = (value & 0xff)
1806 return offset + 4
1807}
1808
1809function checkIEEE754 (buf, value, offset, ext, max, min) {
1810 if (offset + ext > buf.length) throw new RangeError('Index out of range')
1811 if (offset < 0) throw new RangeError('Index out of range')
1812}
1813
1814function writeFloat (buf, value, offset, littleEndian, noAssert) {
1815 value = +value
1816 offset = offset >>> 0
1817 if (!noAssert) {
1818 checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
1819 }
1820 ieee754.write(buf, value, offset, littleEndian, 23, 4)
1821 return offset + 4
1822}
1823
1824Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
1825 return writeFloat(this, value, offset, true, noAssert)
1826}
1827
1828Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
1829 return writeFloat(this, value, offset, false, noAssert)
1830}
1831
1832function writeDouble (buf, value, offset, littleEndian, noAssert) {
1833 value = +value
1834 offset = offset >>> 0
1835 if (!noAssert) {
1836 checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
1837 }
1838 ieee754.write(buf, value, offset, littleEndian, 52, 8)
1839 return offset + 8
1840}
1841
1842Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
1843 return writeDouble(this, value, offset, true, noAssert)
1844}
1845
1846Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
1847 return writeDouble(this, value, offset, false, noAssert)
1848}
1849
1850// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
1851Buffer.prototype.copy = function copy (target, targetStart, start, end) {
1852 if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
1853 if (!start) start = 0
1854 if (!end && end !== 0) end = this.length
1855 if (targetStart >= target.length) targetStart = target.length
1856 if (!targetStart) targetStart = 0
1857 if (end > 0 && end < start) end = start
1858
1859 // Copy 0 bytes; we're done
1860 if (end === start) return 0
1861 if (target.length === 0 || this.length === 0) return 0
1862
1863 // Fatal error conditions
1864 if (targetStart < 0) {
1865 throw new RangeError('targetStart out of bounds')
1866 }
1867 if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
1868 if (end < 0) throw new RangeError('sourceEnd out of bounds')
1869
1870 // Are we oob?
1871 if (end > this.length) end = this.length
1872 if (target.length - targetStart < end - start) {
1873 end = target.length - targetStart + start
1874 }
1875
1876 var len = end - start
1877
1878 if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
1879 // Use built-in when available, missing from IE11
1880 this.copyWithin(targetStart, start, end)
1881 } else if (this === target && start < targetStart && targetStart < end) {
1882 // descending copy from end
1883 for (var i = len - 1; i >= 0; --i) {
1884 target[i + targetStart] = this[i + start]
1885 }
1886 } else {
1887 Uint8Array.prototype.set.call(
1888 target,
1889 this.subarray(start, end),
1890 targetStart
1891 )
1892 }
1893
1894 return len
1895}
1896
1897// Usage:
1898// buffer.fill(number[, offset[, end]])
1899// buffer.fill(buffer[, offset[, end]])
1900// buffer.fill(string[, offset[, end]][, encoding])
1901Buffer.prototype.fill = function fill (val, start, end, encoding) {
1902 // Handle string cases:
1903 if (typeof val === 'string') {
1904 if (typeof start === 'string') {
1905 encoding = start
1906 start = 0
1907 end = this.length
1908 } else if (typeof end === 'string') {
1909 encoding = end
1910 end = this.length
1911 }
1912 if (encoding !== undefined && typeof encoding !== 'string') {
1913 throw new TypeError('encoding must be a string')
1914 }
1915 if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
1916 throw new TypeError('Unknown encoding: ' + encoding)
1917 }
1918 if (val.length === 1) {
1919 var code = val.charCodeAt(0)
1920 if ((encoding === 'utf8' && code < 128) ||
1921 encoding === 'latin1') {
1922 // Fast path: If `val` fits into a single byte, use that numeric value.
1923 val = code
1924 }
1925 }
1926 } else if (typeof val === 'number') {
1927 val = val & 255
1928 }
1929
1930 // Invalid ranges are not set to a default, so can range check early.
1931 if (start < 0 || this.length < start || this.length < end) {
1932 throw new RangeError('Out of range index')
1933 }
1934
1935 if (end <= start) {
1936 return this
1937 }
1938
1939 start = start >>> 0
1940 end = end === undefined ? this.length : end >>> 0
1941
1942 if (!val) val = 0
1943
1944 var i
1945 if (typeof val === 'number') {
1946 for (i = start; i < end; ++i) {
1947 this[i] = val
1948 }
1949 } else {
1950 var bytes = Buffer.isBuffer(val)
1951 ? val
1952 : Buffer.from(val, encoding)
1953 var len = bytes.length
1954 if (len === 0) {
1955 throw new TypeError('The value "' + val +
1956 '" is invalid for argument "value"')
1957 }
1958 for (i = 0; i < end - start; ++i) {
1959 this[i + start] = bytes[i % len]
1960 }
1961 }
1962
1963 return this
1964}
1965
1966// HELPER FUNCTIONS
1967// ================
1968
1969var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
1970
1971function base64clean (str) {
1972 // Node takes equal signs as end of the Base64 encoding
1973 str = str.split('=')[0]
1974 // Node strips out invalid characters like \n and \t from the string, base64-js does not
1975 str = str.trim().replace(INVALID_BASE64_RE, '')
1976 // Node converts strings with length < 2 to ''
1977 if (str.length < 2) return ''
1978 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
1979 while (str.length % 4 !== 0) {
1980 str = str + '='
1981 }
1982 return str
1983}
1984
1985function toHex (n) {
1986 if (n < 16) return '0' + n.toString(16)
1987 return n.toString(16)
1988}
1989
1990function utf8ToBytes (string, units) {
1991 units = units || Infinity
1992 var codePoint
1993 var length = string.length
1994 var leadSurrogate = null
1995 var bytes = []
1996
1997 for (var i = 0; i < length; ++i) {
1998 codePoint = string.charCodeAt(i)
1999
2000 // is surrogate component
2001 if (codePoint > 0xD7FF && codePoint < 0xE000) {
2002 // last char was a lead
2003 if (!leadSurrogate) {
2004 // no lead yet
2005 if (codePoint > 0xDBFF) {
2006 // unexpected trail
2007 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
2008 continue
2009 } else if (i + 1 === length) {
2010 // unpaired lead
2011 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
2012 continue
2013 }
2014
2015 // valid lead
2016 leadSurrogate = codePoint
2017
2018 continue
2019 }
2020
2021 // 2 leads in a row
2022 if (codePoint < 0xDC00) {
2023 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
2024 leadSurrogate = codePoint
2025 continue
2026 }
2027
2028 // valid surrogate pair
2029 codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
2030 } else if (leadSurrogate) {
2031 // valid bmp char, but last char was a lead
2032 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
2033 }
2034
2035 leadSurrogate = null
2036
2037 // encode utf8
2038 if (codePoint < 0x80) {
2039 if ((units -= 1) < 0) break
2040 bytes.push(codePoint)
2041 } else if (codePoint < 0x800) {
2042 if ((units -= 2) < 0) break
2043 bytes.push(
2044 codePoint >> 0x6 | 0xC0,
2045 codePoint & 0x3F | 0x80
2046 )
2047 } else if (codePoint < 0x10000) {
2048 if ((units -= 3) < 0) break
2049 bytes.push(
2050 codePoint >> 0xC | 0xE0,
2051 codePoint >> 0x6 & 0x3F | 0x80,
2052 codePoint & 0x3F | 0x80
2053 )
2054 } else if (codePoint < 0x110000) {
2055 if ((units -= 4) < 0) break
2056 bytes.push(
2057 codePoint >> 0x12 | 0xF0,
2058 codePoint >> 0xC & 0x3F | 0x80,
2059 codePoint >> 0x6 & 0x3F | 0x80,
2060 codePoint & 0x3F | 0x80
2061 )
2062 } else {
2063 throw new Error('Invalid code point')
2064 }
2065 }
2066
2067 return bytes
2068}
2069
2070function asciiToBytes (str) {
2071 var byteArray = []
2072 for (var i = 0; i < str.length; ++i) {
2073 // Node's code seems to be doing this and not & 0x7F..
2074 byteArray.push(str.charCodeAt(i) & 0xFF)
2075 }
2076 return byteArray
2077}
2078
2079function utf16leToBytes (str, units) {
2080 var c, hi, lo
2081 var byteArray = []
2082 for (var i = 0; i < str.length; ++i) {
2083 if ((units -= 2) < 0) break
2084
2085 c = str.charCodeAt(i)
2086 hi = c >> 8
2087 lo = c % 256
2088 byteArray.push(lo)
2089 byteArray.push(hi)
2090 }
2091
2092 return byteArray
2093}
2094
2095function base64ToBytes (str) {
2096 return base64.toByteArray(base64clean(str))
2097}
2098
2099function blitBuffer (src, dst, offset, length) {
2100 for (var i = 0; i < length; ++i) {
2101 if ((i + offset >= dst.length) || (i >= src.length)) break
2102 dst[i + offset] = src[i]
2103 }
2104 return i
2105}
2106
2107// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
2108// the `instanceof` check but they should be treated as of that type.
2109// See: https://github.com/feross/buffer/issues/166
2110function isInstance (obj, type) {
2111 return obj instanceof type ||
2112 (obj != null && obj.constructor != null && obj.constructor.name != null &&
2113 obj.constructor.name === type.name)
2114}
2115function numberIsNaN (obj) {
2116 // For IE11 support
2117 return obj !== obj // eslint-disable-line no-self-compare
2118}
2119
2120}).call(this,require("buffer").Buffer)
2121},{"base64-js":3,"buffer":6,"ieee754":12}],7:[function(require,module,exports){
2122var Buffer = require('safe-buffer').Buffer
2123var Transform = require('stream').Transform
2124var StringDecoder = require('string_decoder').StringDecoder
2125var inherits = require('inherits')
2126
2127function CipherBase (hashMode) {
2128 Transform.call(this)
2129 this.hashMode = typeof hashMode === 'string'
2130 if (this.hashMode) {
2131 this[hashMode] = this._finalOrDigest
2132 } else {
2133 this.final = this._finalOrDigest
2134 }
2135 if (this._final) {
2136 this.__final = this._final
2137 this._final = null
2138 }
2139 this._decoder = null
2140 this._encoding = null
2141}
2142inherits(CipherBase, Transform)
2143
2144CipherBase.prototype.update = function (data, inputEnc, outputEnc) {
2145 if (typeof data === 'string') {
2146 data = Buffer.from(data, inputEnc)
2147 }
2148
2149 var outData = this._update(data)
2150 if (this.hashMode) return this
2151
2152 if (outputEnc) {
2153 outData = this._toString(outData, outputEnc)
2154 }
2155
2156 return outData
2157}
2158
2159CipherBase.prototype.setAutoPadding = function () {}
2160CipherBase.prototype.getAuthTag = function () {
2161 throw new Error('trying to get auth tag in unsupported state')
2162}
2163
2164CipherBase.prototype.setAuthTag = function () {
2165 throw new Error('trying to set auth tag in unsupported state')
2166}
2167
2168CipherBase.prototype.setAAD = function () {
2169 throw new Error('trying to set aad in unsupported state')
2170}
2171
2172CipherBase.prototype._transform = function (data, _, next) {
2173 var err
2174 try {
2175 if (this.hashMode) {
2176 this._update(data)
2177 } else {
2178 this.push(this._update(data))
2179 }
2180 } catch (e) {
2181 err = e
2182 } finally {
2183 next(err)
2184 }
2185}
2186CipherBase.prototype._flush = function (done) {
2187 var err
2188 try {
2189 this.push(this.__final())
2190 } catch (e) {
2191 err = e
2192 }
2193
2194 done(err)
2195}
2196CipherBase.prototype._finalOrDigest = function (outputEnc) {
2197 var outData = this.__final() || Buffer.alloc(0)
2198 if (outputEnc) {
2199 outData = this._toString(outData, outputEnc, true)
2200 }
2201 return outData
2202}
2203
2204CipherBase.prototype._toString = function (value, enc, fin) {
2205 if (!this._decoder) {
2206 this._decoder = new StringDecoder(enc)
2207 this._encoding = enc
2208 }
2209
2210 if (this._encoding !== enc) throw new Error('can\'t switch encodings')
2211
2212 var out = this._decoder.write(value)
2213 if (fin) {
2214 out += this._decoder.end()
2215 }
2216
2217 return out
2218}
2219
2220module.exports = CipherBase
2221
2222},{"inherits":13,"safe-buffer":34,"stream":43,"string_decoder":44}],8:[function(require,module,exports){
2223(function (Buffer){
2224// Copyright Joyent, Inc. and other Node contributors.
2225//
2226// Permission is hereby granted, free of charge, to any person obtaining a
2227// copy of this software and associated documentation files (the
2228// "Software"), to deal in the Software without restriction, including
2229// without limitation the rights to use, copy, modify, merge, publish,
2230// distribute, sublicense, and/or sell copies of the Software, and to permit
2231// persons to whom the Software is furnished to do so, subject to the
2232// following conditions:
2233//
2234// The above copyright notice and this permission notice shall be included
2235// in all copies or substantial portions of the Software.
2236//
2237// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
2238// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2239// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
2240// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
2241// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
2242// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
2243// USE OR OTHER DEALINGS IN THE SOFTWARE.
2244
2245// NOTE: These type checking functions intentionally don't use `instanceof`
2246// because it is fragile and can be easily faked with `Object.create()`.
2247
2248function isArray(arg) {
2249 if (Array.isArray) {
2250 return Array.isArray(arg);
2251 }
2252 return objectToString(arg) === '[object Array]';
2253}
2254exports.isArray = isArray;
2255
2256function isBoolean(arg) {
2257 return typeof arg === 'boolean';
2258}
2259exports.isBoolean = isBoolean;
2260
2261function isNull(arg) {
2262 return arg === null;
2263}
2264exports.isNull = isNull;
2265
2266function isNullOrUndefined(arg) {
2267 return arg == null;
2268}
2269exports.isNullOrUndefined = isNullOrUndefined;
2270
2271function isNumber(arg) {
2272 return typeof arg === 'number';
2273}
2274exports.isNumber = isNumber;
2275
2276function isString(arg) {
2277 return typeof arg === 'string';
2278}
2279exports.isString = isString;
2280
2281function isSymbol(arg) {
2282 return typeof arg === 'symbol';
2283}
2284exports.isSymbol = isSymbol;
2285
2286function isUndefined(arg) {
2287 return arg === void 0;
2288}
2289exports.isUndefined = isUndefined;
2290
2291function isRegExp(re) {
2292 return objectToString(re) === '[object RegExp]';
2293}
2294exports.isRegExp = isRegExp;
2295
2296function isObject(arg) {
2297 return typeof arg === 'object' && arg !== null;
2298}
2299exports.isObject = isObject;
2300
2301function isDate(d) {
2302 return objectToString(d) === '[object Date]';
2303}
2304exports.isDate = isDate;
2305
2306function isError(e) {
2307 return (objectToString(e) === '[object Error]' || e instanceof Error);
2308}
2309exports.isError = isError;
2310
2311function isFunction(arg) {
2312 return typeof arg === 'function';
2313}
2314exports.isFunction = isFunction;
2315
2316function isPrimitive(arg) {
2317 return arg === null ||
2318 typeof arg === 'boolean' ||
2319 typeof arg === 'number' ||
2320 typeof arg === 'string' ||
2321 typeof arg === 'symbol' || // ES6 symbol
2322 typeof arg === 'undefined';
2323}
2324exports.isPrimitive = isPrimitive;
2325
2326exports.isBuffer = Buffer.isBuffer;
2327
2328function objectToString(o) {
2329 return Object.prototype.toString.call(o);
2330}
2331
2332}).call(this,{"isBuffer":require("../../is-buffer/index.js")})
2333},{"../../is-buffer/index.js":14}],9:[function(require,module,exports){
2334'use strict'
2335var inherits = require('inherits')
2336var MD5 = require('md5.js')
2337var RIPEMD160 = require('ripemd160')
2338var sha = require('sha.js')
2339var Base = require('cipher-base')
2340
2341function Hash (hash) {
2342 Base.call(this, 'digest')
2343
2344 this._hash = hash
2345}
2346
2347inherits(Hash, Base)
2348
2349Hash.prototype._update = function (data) {
2350 this._hash.update(data)
2351}
2352
2353Hash.prototype._final = function () {
2354 return this._hash.digest()
2355}
2356
2357module.exports = function createHash (alg) {
2358 alg = alg.toLowerCase()
2359 if (alg === 'md5') return new MD5()
2360 if (alg === 'rmd160' || alg === 'ripemd160') return new RIPEMD160()
2361
2362 return new Hash(sha(alg))
2363}
2364
2365},{"cipher-base":7,"inherits":13,"md5.js":16,"ripemd160":33,"sha.js":36}],10:[function(require,module,exports){
2366// Copyright Joyent, Inc. and other Node contributors.
2367//
2368// Permission is hereby granted, free of charge, to any person obtaining a
2369// copy of this software and associated documentation files (the
2370// "Software"), to deal in the Software without restriction, including
2371// without limitation the rights to use, copy, modify, merge, publish,
2372// distribute, sublicense, and/or sell copies of the Software, and to permit
2373// persons to whom the Software is furnished to do so, subject to the
2374// following conditions:
2375//
2376// The above copyright notice and this permission notice shall be included
2377// in all copies or substantial portions of the Software.
2378//
2379// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
2380// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2381// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
2382// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
2383// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
2384// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
2385// USE OR OTHER DEALINGS IN THE SOFTWARE.
2386
2387var objectCreate = Object.create || objectCreatePolyfill
2388var objectKeys = Object.keys || objectKeysPolyfill
2389var bind = Function.prototype.bind || functionBindPolyfill
2390
2391function EventEmitter() {
2392 if (!this._events || !Object.prototype.hasOwnProperty.call(this, '_events')) {
2393 this._events = objectCreate(null);
2394 this._eventsCount = 0;
2395 }
2396
2397 this._maxListeners = this._maxListeners || undefined;
2398}
2399module.exports = EventEmitter;
2400
2401// Backwards-compat with node 0.10.x
2402EventEmitter.EventEmitter = EventEmitter;
2403
2404EventEmitter.prototype._events = undefined;
2405EventEmitter.prototype._maxListeners = undefined;
2406
2407// By default EventEmitters will print a warning if more than 10 listeners are
2408// added to it. This is a useful default which helps finding memory leaks.
2409var defaultMaxListeners = 10;
2410
2411var hasDefineProperty;
2412try {
2413 var o = {};
2414 if (Object.defineProperty) Object.defineProperty(o, 'x', { value: 0 });
2415 hasDefineProperty = o.x === 0;
2416} catch (err) { hasDefineProperty = false }
2417if (hasDefineProperty) {
2418 Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
2419 enumerable: true,
2420 get: function() {
2421 return defaultMaxListeners;
2422 },
2423 set: function(arg) {
2424 // check whether the input is a positive number (whose value is zero or
2425 // greater and not a NaN).
2426 if (typeof arg !== 'number' || arg < 0 || arg !== arg)
2427 throw new TypeError('"defaultMaxListeners" must be a positive number');
2428 defaultMaxListeners = arg;
2429 }
2430 });
2431} else {
2432 EventEmitter.defaultMaxListeners = defaultMaxListeners;
2433}
2434
2435// Obviously not all Emitters should be limited to 10. This function allows
2436// that to be increased. Set to zero for unlimited.
2437EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
2438 if (typeof n !== 'number' || n < 0 || isNaN(n))
2439 throw new TypeError('"n" argument must be a positive number');
2440 this._maxListeners = n;
2441 return this;
2442};
2443
2444function $getMaxListeners(that) {
2445 if (that._maxListeners === undefined)
2446 return EventEmitter.defaultMaxListeners;
2447 return that._maxListeners;
2448}
2449
2450EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
2451 return $getMaxListeners(this);
2452};
2453
2454// These standalone emit* functions are used to optimize calling of event
2455// handlers for fast cases because emit() itself often has a variable number of
2456// arguments and can be deoptimized because of that. These functions always have
2457// the same number of arguments and thus do not get deoptimized, so the code
2458// inside them can execute faster.
2459function emitNone(handler, isFn, self) {
2460 if (isFn)
2461 handler.call(self);
2462 else {
2463 var len = handler.length;
2464 var listeners = arrayClone(handler, len);
2465 for (var i = 0; i < len; ++i)
2466 listeners[i].call(self);
2467 }
2468}
2469function emitOne(handler, isFn, self, arg1) {
2470 if (isFn)
2471 handler.call(self, arg1);
2472 else {
2473 var len = handler.length;
2474 var listeners = arrayClone(handler, len);
2475 for (var i = 0; i < len; ++i)
2476 listeners[i].call(self, arg1);
2477 }
2478}
2479function emitTwo(handler, isFn, self, arg1, arg2) {
2480 if (isFn)
2481 handler.call(self, arg1, arg2);
2482 else {
2483 var len = handler.length;
2484 var listeners = arrayClone(handler, len);
2485 for (var i = 0; i < len; ++i)
2486 listeners[i].call(self, arg1, arg2);
2487 }
2488}
2489function emitThree(handler, isFn, self, arg1, arg2, arg3) {
2490 if (isFn)
2491 handler.call(self, arg1, arg2, arg3);
2492 else {
2493 var len = handler.length;
2494 var listeners = arrayClone(handler, len);
2495 for (var i = 0; i < len; ++i)
2496 listeners[i].call(self, arg1, arg2, arg3);
2497 }
2498}
2499
2500function emitMany(handler, isFn, self, args) {
2501 if (isFn)
2502 handler.apply(self, args);
2503 else {
2504 var len = handler.length;
2505 var listeners = arrayClone(handler, len);
2506 for (var i = 0; i < len; ++i)
2507 listeners[i].apply(self, args);
2508 }
2509}
2510
2511EventEmitter.prototype.emit = function emit(type) {
2512 var er, handler, len, args, i, events;
2513 var doError = (type === 'error');
2514
2515 events = this._events;
2516 if (events)
2517 doError = (doError && events.error == null);
2518 else if (!doError)
2519 return false;
2520
2521 // If there is no 'error' event listener then throw.
2522 if (doError) {
2523 if (arguments.length > 1)
2524 er = arguments[1];
2525 if (er instanceof Error) {
2526 throw er; // Unhandled 'error' event
2527 } else {
2528 // At least give some kind of context to the user
2529 var err = new Error('Unhandled "error" event. (' + er + ')');
2530 err.context = er;
2531 throw err;
2532 }
2533 return false;
2534 }
2535
2536 handler = events[type];
2537
2538 if (!handler)
2539 return false;
2540
2541 var isFn = typeof handler === 'function';
2542 len = arguments.length;
2543 switch (len) {
2544 // fast cases
2545 case 1:
2546 emitNone(handler, isFn, this);
2547 break;
2548 case 2:
2549 emitOne(handler, isFn, this, arguments[1]);
2550 break;
2551 case 3:
2552 emitTwo(handler, isFn, this, arguments[1], arguments[2]);
2553 break;
2554 case 4:
2555 emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
2556 break;
2557 // slower
2558 default:
2559 args = new Array(len - 1);
2560 for (i = 1; i < len; i++)
2561 args[i - 1] = arguments[i];
2562 emitMany(handler, isFn, this, args);
2563 }
2564
2565 return true;
2566};
2567
2568function _addListener(target, type, listener, prepend) {
2569 var m;
2570 var events;
2571 var existing;
2572
2573 if (typeof listener !== 'function')
2574 throw new TypeError('"listener" argument must be a function');
2575
2576 events = target._events;
2577 if (!events) {
2578 events = target._events = objectCreate(null);
2579 target._eventsCount = 0;
2580 } else {
2581 // To avoid recursion in the case that type === "newListener"! Before
2582 // adding it to the listeners, first emit "newListener".
2583 if (events.newListener) {
2584 target.emit('newListener', type,
2585 listener.listener ? listener.listener : listener);
2586
2587 // Re-assign `events` because a newListener handler could have caused the
2588 // this._events to be assigned to a new object
2589 events = target._events;
2590 }
2591 existing = events[type];
2592 }
2593
2594 if (!existing) {
2595 // Optimize the case of one listener. Don't need the extra array object.
2596 existing = events[type] = listener;
2597 ++target._eventsCount;
2598 } else {
2599 if (typeof existing === 'function') {
2600 // Adding the second element, need to change to array.
2601 existing = events[type] =
2602 prepend ? [listener, existing] : [existing, listener];
2603 } else {
2604 // If we've already got an array, just append.
2605 if (prepend) {
2606 existing.unshift(listener);
2607 } else {
2608 existing.push(listener);
2609 }
2610 }
2611
2612 // Check for listener leak
2613 if (!existing.warned) {
2614 m = $getMaxListeners(target);
2615 if (m && m > 0 && existing.length > m) {
2616 existing.warned = true;
2617 var w = new Error('Possible EventEmitter memory leak detected. ' +
2618 existing.length + ' "' + String(type) + '" listeners ' +
2619 'added. Use emitter.setMaxListeners() to ' +
2620 'increase limit.');
2621 w.name = 'MaxListenersExceededWarning';
2622 w.emitter = target;
2623 w.type = type;
2624 w.count = existing.length;
2625 if (typeof console === 'object' && console.warn) {
2626 console.warn('%s: %s', w.name, w.message);
2627 }
2628 }
2629 }
2630 }
2631
2632 return target;
2633}
2634
2635EventEmitter.prototype.addListener = function addListener(type, listener) {
2636 return _addListener(this, type, listener, false);
2637};
2638
2639EventEmitter.prototype.on = EventEmitter.prototype.addListener;
2640
2641EventEmitter.prototype.prependListener =
2642 function prependListener(type, listener) {
2643 return _addListener(this, type, listener, true);
2644 };
2645
2646function onceWrapper() {
2647 if (!this.fired) {
2648 this.target.removeListener(this.type, this.wrapFn);
2649 this.fired = true;
2650 switch (arguments.length) {
2651 case 0:
2652 return this.listener.call(this.target);
2653 case 1:
2654 return this.listener.call(this.target, arguments[0]);
2655 case 2:
2656 return this.listener.call(this.target, arguments[0], arguments[1]);
2657 case 3:
2658 return this.listener.call(this.target, arguments[0], arguments[1],
2659 arguments[2]);
2660 default:
2661 var args = new Array(arguments.length);
2662 for (var i = 0; i < args.length; ++i)
2663 args[i] = arguments[i];
2664 this.listener.apply(this.target, args);
2665 }
2666 }
2667}
2668
2669function _onceWrap(target, type, listener) {
2670 var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
2671 var wrapped = bind.call(onceWrapper, state);
2672 wrapped.listener = listener;
2673 state.wrapFn = wrapped;
2674 return wrapped;
2675}
2676
2677EventEmitter.prototype.once = function once(type, listener) {
2678 if (typeof listener !== 'function')
2679 throw new TypeError('"listener" argument must be a function');
2680 this.on(type, _onceWrap(this, type, listener));
2681 return this;
2682};
2683
2684EventEmitter.prototype.prependOnceListener =
2685 function prependOnceListener(type, listener) {
2686 if (typeof listener !== 'function')
2687 throw new TypeError('"listener" argument must be a function');
2688 this.prependListener(type, _onceWrap(this, type, listener));
2689 return this;
2690 };
2691
2692// Emits a 'removeListener' event if and only if the listener was removed.
2693EventEmitter.prototype.removeListener =
2694 function removeListener(type, listener) {
2695 var list, events, position, i, originalListener;
2696
2697 if (typeof listener !== 'function')
2698 throw new TypeError('"listener" argument must be a function');
2699
2700 events = this._events;
2701 if (!events)
2702 return this;
2703
2704 list = events[type];
2705 if (!list)
2706 return this;
2707
2708 if (list === listener || list.listener === listener) {
2709 if (--this._eventsCount === 0)
2710 this._events = objectCreate(null);
2711 else {
2712 delete events[type];
2713 if (events.removeListener)
2714 this.emit('removeListener', type, list.listener || listener);
2715 }
2716 } else if (typeof list !== 'function') {
2717 position = -1;
2718
2719 for (i = list.length - 1; i >= 0; i--) {
2720 if (list[i] === listener || list[i].listener === listener) {
2721 originalListener = list[i].listener;
2722 position = i;
2723 break;
2724 }
2725 }
2726
2727 if (position < 0)
2728 return this;
2729
2730 if (position === 0)
2731 list.shift();
2732 else
2733 spliceOne(list, position);
2734
2735 if (list.length === 1)
2736 events[type] = list[0];
2737
2738 if (events.removeListener)
2739 this.emit('removeListener', type, originalListener || listener);
2740 }
2741
2742 return this;
2743 };
2744
2745EventEmitter.prototype.removeAllListeners =
2746 function removeAllListeners(type) {
2747 var listeners, events, i;
2748
2749 events = this._events;
2750 if (!events)
2751 return this;
2752
2753 // not listening for removeListener, no need to emit
2754 if (!events.removeListener) {
2755 if (arguments.length === 0) {
2756 this._events = objectCreate(null);
2757 this._eventsCount = 0;
2758 } else if (events[type]) {
2759 if (--this._eventsCount === 0)
2760 this._events = objectCreate(null);
2761 else
2762 delete events[type];
2763 }
2764 return this;
2765 }
2766
2767 // emit removeListener for all listeners on all events
2768 if (arguments.length === 0) {
2769 var keys = objectKeys(events);
2770 var key;
2771 for (i = 0; i < keys.length; ++i) {
2772 key = keys[i];
2773 if (key === 'removeListener') continue;
2774 this.removeAllListeners(key);
2775 }
2776 this.removeAllListeners('removeListener');
2777 this._events = objectCreate(null);
2778 this._eventsCount = 0;
2779 return this;
2780 }
2781
2782 listeners = events[type];
2783
2784 if (typeof listeners === 'function') {
2785 this.removeListener(type, listeners);
2786 } else if (listeners) {
2787 // LIFO order
2788 for (i = listeners.length - 1; i >= 0; i--) {
2789 this.removeListener(type, listeners[i]);
2790 }
2791 }
2792
2793 return this;
2794 };
2795
2796function _listeners(target, type, unwrap) {
2797 var events = target._events;
2798
2799 if (!events)
2800 return [];
2801
2802 var evlistener = events[type];
2803 if (!evlistener)
2804 return [];
2805
2806 if (typeof evlistener === 'function')
2807 return unwrap ? [evlistener.listener || evlistener] : [evlistener];
2808
2809 return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
2810}
2811
2812EventEmitter.prototype.listeners = function listeners(type) {
2813 return _listeners(this, type, true);
2814};
2815
2816EventEmitter.prototype.rawListeners = function rawListeners(type) {
2817 return _listeners(this, type, false);
2818};
2819
2820EventEmitter.listenerCount = function(emitter, type) {
2821 if (typeof emitter.listenerCount === 'function') {
2822 return emitter.listenerCount(type);
2823 } else {
2824 return listenerCount.call(emitter, type);
2825 }
2826};
2827
2828EventEmitter.prototype.listenerCount = listenerCount;
2829function listenerCount(type) {
2830 var events = this._events;
2831
2832 if (events) {
2833 var evlistener = events[type];
2834
2835 if (typeof evlistener === 'function') {
2836 return 1;
2837 } else if (evlistener) {
2838 return evlistener.length;
2839 }
2840 }
2841
2842 return 0;
2843}
2844
2845EventEmitter.prototype.eventNames = function eventNames() {
2846 return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
2847};
2848
2849// About 1.5x faster than the two-arg version of Array#splice().
2850function spliceOne(list, index) {
2851 for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1)
2852 list[i] = list[k];
2853 list.pop();
2854}
2855
2856function arrayClone(arr, n) {
2857 var copy = new Array(n);
2858 for (var i = 0; i < n; ++i)
2859 copy[i] = arr[i];
2860 return copy;
2861}
2862
2863function unwrapListeners(arr) {
2864 var ret = new Array(arr.length);
2865 for (var i = 0; i < ret.length; ++i) {
2866 ret[i] = arr[i].listener || arr[i];
2867 }
2868 return ret;
2869}
2870
2871function objectCreatePolyfill(proto) {
2872 var F = function() {};
2873 F.prototype = proto;
2874 return new F;
2875}
2876function objectKeysPolyfill(obj) {
2877 var keys = [];
2878 for (var k in obj) if (Object.prototype.hasOwnProperty.call(obj, k)) {
2879 keys.push(k);
2880 }
2881 return k;
2882}
2883function functionBindPolyfill(context) {
2884 var fn = this;
2885 return function () {
2886 return fn.apply(context, arguments);
2887 };
2888}
2889
2890},{}],11:[function(require,module,exports){
2891'use strict'
2892var Buffer = require('safe-buffer').Buffer
2893var Transform = require('stream').Transform
2894var inherits = require('inherits')
2895
2896function throwIfNotStringOrBuffer (val, prefix) {
2897 if (!Buffer.isBuffer(val) && typeof val !== 'string') {
2898 throw new TypeError(prefix + ' must be a string or a buffer')
2899 }
2900}
2901
2902function HashBase (blockSize) {
2903 Transform.call(this)
2904
2905 this._block = Buffer.allocUnsafe(blockSize)
2906 this._blockSize = blockSize
2907 this._blockOffset = 0
2908 this._length = [0, 0, 0, 0]
2909
2910 this._finalized = false
2911}
2912
2913inherits(HashBase, Transform)
2914
2915HashBase.prototype._transform = function (chunk, encoding, callback) {
2916 var error = null
2917 try {
2918 this.update(chunk, encoding)
2919 } catch (err) {
2920 error = err
2921 }
2922
2923 callback(error)
2924}
2925
2926HashBase.prototype._flush = function (callback) {
2927 var error = null
2928 try {
2929 this.push(this.digest())
2930 } catch (err) {
2931 error = err
2932 }
2933
2934 callback(error)
2935}
2936
2937HashBase.prototype.update = function (data, encoding) {
2938 throwIfNotStringOrBuffer(data, 'Data')
2939 if (this._finalized) throw new Error('Digest already called')
2940 if (!Buffer.isBuffer(data)) data = Buffer.from(data, encoding)
2941
2942 // consume data
2943 var block = this._block
2944 var offset = 0
2945 while (this._blockOffset + data.length - offset >= this._blockSize) {
2946 for (var i = this._blockOffset; i < this._blockSize;) block[i++] = data[offset++]
2947 this._update()
2948 this._blockOffset = 0
2949 }
2950 while (offset < data.length) block[this._blockOffset++] = data[offset++]
2951
2952 // update length
2953 for (var j = 0, carry = data.length * 8; carry > 0; ++j) {
2954 this._length[j] += carry
2955 carry = (this._length[j] / 0x0100000000) | 0
2956 if (carry > 0) this._length[j] -= 0x0100000000 * carry
2957 }
2958
2959 return this
2960}
2961
2962HashBase.prototype._update = function () {
2963 throw new Error('_update is not implemented')
2964}
2965
2966HashBase.prototype.digest = function (encoding) {
2967 if (this._finalized) throw new Error('Digest already called')
2968 this._finalized = true
2969
2970 var digest = this._digest()
2971 if (encoding !== undefined) digest = digest.toString(encoding)
2972
2973 // reset state
2974 this._block.fill(0)
2975 this._blockOffset = 0
2976 for (var i = 0; i < 4; ++i) this._length[i] = 0
2977
2978 return digest
2979}
2980
2981HashBase.prototype._digest = function () {
2982 throw new Error('_digest is not implemented')
2983}
2984
2985module.exports = HashBase
2986
2987},{"inherits":13,"safe-buffer":34,"stream":43}],12:[function(require,module,exports){
2988exports.read = function (buffer, offset, isLE, mLen, nBytes) {
2989 var e, m
2990 var eLen = (nBytes * 8) - mLen - 1
2991 var eMax = (1 << eLen) - 1
2992 var eBias = eMax >> 1
2993 var nBits = -7
2994 var i = isLE ? (nBytes - 1) : 0
2995 var d = isLE ? -1 : 1
2996 var s = buffer[offset + i]
2997
2998 i += d
2999
3000 e = s & ((1 << (-nBits)) - 1)
3001 s >>= (-nBits)
3002 nBits += eLen
3003 for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
3004
3005 m = e & ((1 << (-nBits)) - 1)
3006 e >>= (-nBits)
3007 nBits += mLen
3008 for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
3009
3010 if (e === 0) {
3011 e = 1 - eBias
3012 } else if (e === eMax) {
3013 return m ? NaN : ((s ? -1 : 1) * Infinity)
3014 } else {
3015 m = m + Math.pow(2, mLen)
3016 e = e - eBias
3017 }
3018 return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
3019}
3020
3021exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
3022 var e, m, c
3023 var eLen = (nBytes * 8) - mLen - 1
3024 var eMax = (1 << eLen) - 1
3025 var eBias = eMax >> 1
3026 var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
3027 var i = isLE ? 0 : (nBytes - 1)
3028 var d = isLE ? 1 : -1
3029 var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
3030
3031 value = Math.abs(value)
3032
3033 if (isNaN(value) || value === Infinity) {
3034 m = isNaN(value) ? 1 : 0
3035 e = eMax
3036 } else {
3037 e = Math.floor(Math.log(value) / Math.LN2)
3038 if (value * (c = Math.pow(2, -e)) < 1) {
3039 e--
3040 c *= 2
3041 }
3042 if (e + eBias >= 1) {
3043 value += rt / c
3044 } else {
3045 value += rt * Math.pow(2, 1 - eBias)
3046 }
3047 if (value * c >= 2) {
3048 e++
3049 c /= 2
3050 }
3051
3052 if (e + eBias >= eMax) {
3053 m = 0
3054 e = eMax
3055 } else if (e + eBias >= 1) {
3056 m = ((value * c) - 1) * Math.pow(2, mLen)
3057 e = e + eBias
3058 } else {
3059 m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
3060 e = 0
3061 }
3062 }
3063
3064 for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
3065
3066 e = (e << mLen) | m
3067 eLen += mLen
3068 for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
3069
3070 buffer[offset + i - d] |= s * 128
3071}
3072
3073},{}],13:[function(require,module,exports){
3074if (typeof Object.create === 'function') {
3075 // implementation from standard node.js 'util' module
3076 module.exports = function inherits(ctor, superCtor) {
3077 ctor.super_ = superCtor
3078 ctor.prototype = Object.create(superCtor.prototype, {
3079 constructor: {
3080 value: ctor,
3081 enumerable: false,
3082 writable: true,
3083 configurable: true
3084 }
3085 });
3086 };
3087} else {
3088 // old school shim for old browsers
3089 module.exports = function inherits(ctor, superCtor) {
3090 ctor.super_ = superCtor
3091 var TempCtor = function () {}
3092 TempCtor.prototype = superCtor.prototype
3093 ctor.prototype = new TempCtor()
3094 ctor.prototype.constructor = ctor
3095 }
3096}
3097
3098},{}],14:[function(require,module,exports){
3099/*!
3100 * Determine if an object is a Buffer
3101 *
3102 * @author Feross Aboukhadijeh <https://feross.org>
3103 * @license MIT
3104 */
3105
3106// The _isBuffer check is for Safari 5-7 support, because it's missing
3107// Object.prototype.constructor. Remove this eventually
3108module.exports = function (obj) {
3109 return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
3110}
3111
3112function isBuffer (obj) {
3113 return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
3114}
3115
3116// For Node v0.10 support. Remove this eventually.
3117function isSlowBuffer (obj) {
3118 return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
3119}
3120
3121},{}],15:[function(require,module,exports){
3122var toString = {}.toString;
3123
3124module.exports = Array.isArray || function (arr) {
3125 return toString.call(arr) == '[object Array]';
3126};
3127
3128},{}],16:[function(require,module,exports){
3129'use strict'
3130var inherits = require('inherits')
3131var HashBase = require('hash-base')
3132var Buffer = require('safe-buffer').Buffer
3133
3134var ARRAY16 = new Array(16)
3135
3136function MD5 () {
3137 HashBase.call(this, 64)
3138
3139 // state
3140 this._a = 0x67452301
3141 this._b = 0xefcdab89
3142 this._c = 0x98badcfe
3143 this._d = 0x10325476
3144}
3145
3146inherits(MD5, HashBase)
3147
3148MD5.prototype._update = function () {
3149 var M = ARRAY16
3150 for (var i = 0; i < 16; ++i) M[i] = this._block.readInt32LE(i * 4)
3151
3152 var a = this._a
3153 var b = this._b
3154 var c = this._c
3155 var d = this._d
3156
3157 a = fnF(a, b, c, d, M[0], 0xd76aa478, 7)
3158 d = fnF(d, a, b, c, M[1], 0xe8c7b756, 12)
3159 c = fnF(c, d, a, b, M[2], 0x242070db, 17)
3160 b = fnF(b, c, d, a, M[3], 0xc1bdceee, 22)
3161 a = fnF(a, b, c, d, M[4], 0xf57c0faf, 7)
3162 d = fnF(d, a, b, c, M[5], 0x4787c62a, 12)
3163 c = fnF(c, d, a, b, M[6], 0xa8304613, 17)
3164 b = fnF(b, c, d, a, M[7], 0xfd469501, 22)
3165 a = fnF(a, b, c, d, M[8], 0x698098d8, 7)
3166 d = fnF(d, a, b, c, M[9], 0x8b44f7af, 12)
3167 c = fnF(c, d, a, b, M[10], 0xffff5bb1, 17)
3168 b = fnF(b, c, d, a, M[11], 0x895cd7be, 22)
3169 a = fnF(a, b, c, d, M[12], 0x6b901122, 7)
3170 d = fnF(d, a, b, c, M[13], 0xfd987193, 12)
3171 c = fnF(c, d, a, b, M[14], 0xa679438e, 17)
3172 b = fnF(b, c, d, a, M[15], 0x49b40821, 22)
3173
3174 a = fnG(a, b, c, d, M[1], 0xf61e2562, 5)
3175 d = fnG(d, a, b, c, M[6], 0xc040b340, 9)
3176 c = fnG(c, d, a, b, M[11], 0x265e5a51, 14)
3177 b = fnG(b, c, d, a, M[0], 0xe9b6c7aa, 20)
3178 a = fnG(a, b, c, d, M[5], 0xd62f105d, 5)
3179 d = fnG(d, a, b, c, M[10], 0x02441453, 9)
3180 c = fnG(c, d, a, b, M[15], 0xd8a1e681, 14)
3181 b = fnG(b, c, d, a, M[4], 0xe7d3fbc8, 20)
3182 a = fnG(a, b, c, d, M[9], 0x21e1cde6, 5)
3183 d = fnG(d, a, b, c, M[14], 0xc33707d6, 9)
3184 c = fnG(c, d, a, b, M[3], 0xf4d50d87, 14)
3185 b = fnG(b, c, d, a, M[8], 0x455a14ed, 20)
3186 a = fnG(a, b, c, d, M[13], 0xa9e3e905, 5)
3187 d = fnG(d, a, b, c, M[2], 0xfcefa3f8, 9)
3188 c = fnG(c, d, a, b, M[7], 0x676f02d9, 14)
3189 b = fnG(b, c, d, a, M[12], 0x8d2a4c8a, 20)
3190
3191 a = fnH(a, b, c, d, M[5], 0xfffa3942, 4)
3192 d = fnH(d, a, b, c, M[8], 0x8771f681, 11)
3193 c = fnH(c, d, a, b, M[11], 0x6d9d6122, 16)
3194 b = fnH(b, c, d, a, M[14], 0xfde5380c, 23)
3195 a = fnH(a, b, c, d, M[1], 0xa4beea44, 4)
3196 d = fnH(d, a, b, c, M[4], 0x4bdecfa9, 11)
3197 c = fnH(c, d, a, b, M[7], 0xf6bb4b60, 16)
3198 b = fnH(b, c, d, a, M[10], 0xbebfbc70, 23)
3199 a = fnH(a, b, c, d, M[13], 0x289b7ec6, 4)
3200 d = fnH(d, a, b, c, M[0], 0xeaa127fa, 11)
3201 c = fnH(c, d, a, b, M[3], 0xd4ef3085, 16)
3202 b = fnH(b, c, d, a, M[6], 0x04881d05, 23)
3203 a = fnH(a, b, c, d, M[9], 0xd9d4d039, 4)
3204 d = fnH(d, a, b, c, M[12], 0xe6db99e5, 11)
3205 c = fnH(c, d, a, b, M[15], 0x1fa27cf8, 16)
3206 b = fnH(b, c, d, a, M[2], 0xc4ac5665, 23)
3207
3208 a = fnI(a, b, c, d, M[0], 0xf4292244, 6)
3209 d = fnI(d, a, b, c, M[7], 0x432aff97, 10)
3210 c = fnI(c, d, a, b, M[14], 0xab9423a7, 15)
3211 b = fnI(b, c, d, a, M[5], 0xfc93a039, 21)
3212 a = fnI(a, b, c, d, M[12], 0x655b59c3, 6)
3213 d = fnI(d, a, b, c, M[3], 0x8f0ccc92, 10)
3214 c = fnI(c, d, a, b, M[10], 0xffeff47d, 15)
3215 b = fnI(b, c, d, a, M[1], 0x85845dd1, 21)
3216 a = fnI(a, b, c, d, M[8], 0x6fa87e4f, 6)
3217 d = fnI(d, a, b, c, M[15], 0xfe2ce6e0, 10)
3218 c = fnI(c, d, a, b, M[6], 0xa3014314, 15)
3219 b = fnI(b, c, d, a, M[13], 0x4e0811a1, 21)
3220 a = fnI(a, b, c, d, M[4], 0xf7537e82, 6)
3221 d = fnI(d, a, b, c, M[11], 0xbd3af235, 10)
3222 c = fnI(c, d, a, b, M[2], 0x2ad7d2bb, 15)
3223 b = fnI(b, c, d, a, M[9], 0xeb86d391, 21)
3224
3225 this._a = (this._a + a) | 0
3226 this._b = (this._b + b) | 0
3227 this._c = (this._c + c) | 0
3228 this._d = (this._d + d) | 0
3229}
3230
3231MD5.prototype._digest = function () {
3232 // create padding and handle blocks
3233 this._block[this._blockOffset++] = 0x80
3234 if (this._blockOffset > 56) {
3235 this._block.fill(0, this._blockOffset, 64)
3236 this._update()
3237 this._blockOffset = 0
3238 }
3239
3240 this._block.fill(0, this._blockOffset, 56)
3241 this._block.writeUInt32LE(this._length[0], 56)
3242 this._block.writeUInt32LE(this._length[1], 60)
3243 this._update()
3244
3245 // produce result
3246 var buffer = Buffer.allocUnsafe(16)
3247 buffer.writeInt32LE(this._a, 0)
3248 buffer.writeInt32LE(this._b, 4)
3249 buffer.writeInt32LE(this._c, 8)
3250 buffer.writeInt32LE(this._d, 12)
3251 return buffer
3252}
3253
3254function rotl (x, n) {
3255 return (x << n) | (x >>> (32 - n))
3256}
3257
3258function fnF (a, b, c, d, m, k, s) {
3259 return (rotl((a + ((b & c) | ((~b) & d)) + m + k) | 0, s) + b) | 0
3260}
3261
3262function fnG (a, b, c, d, m, k, s) {
3263 return (rotl((a + ((b & d) | (c & (~d))) + m + k) | 0, s) + b) | 0
3264}
3265
3266function fnH (a, b, c, d, m, k, s) {
3267 return (rotl((a + (b ^ c ^ d) + m + k) | 0, s) + b) | 0
3268}
3269
3270function fnI (a, b, c, d, m, k, s) {
3271 return (rotl((a + ((c ^ (b | (~d)))) + m + k) | 0, s) + b) | 0
3272}
3273
3274module.exports = MD5
3275
3276},{"hash-base":11,"inherits":13,"safe-buffer":34}],17:[function(require,module,exports){
3277(function (process){
3278'use strict';
3279
3280if (!process.version ||
3281 process.version.indexOf('v0.') === 0 ||
3282 process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
3283 module.exports = { nextTick: nextTick };
3284} else {
3285 module.exports = process
3286}
3287
3288function nextTick(fn, arg1, arg2, arg3) {
3289 if (typeof fn !== 'function') {
3290 throw new TypeError('"callback" argument must be a function');
3291 }
3292 var len = arguments.length;
3293 var args, i;
3294 switch (len) {
3295 case 0:
3296 case 1:
3297 return process.nextTick(fn);
3298 case 2:
3299 return process.nextTick(function afterTickOne() {
3300 fn.call(null, arg1);
3301 });
3302 case 3:
3303 return process.nextTick(function afterTickTwo() {
3304 fn.call(null, arg1, arg2);
3305 });
3306 case 4:
3307 return process.nextTick(function afterTickThree() {
3308 fn.call(null, arg1, arg2, arg3);
3309 });
3310 default:
3311 args = new Array(len - 1);
3312 i = 0;
3313 while (i < args.length) {
3314 args[i++] = arguments[i];
3315 }
3316 return process.nextTick(function afterTick() {
3317 fn.apply(null, args);
3318 });
3319 }
3320}
3321
3322
3323}).call(this,require('_process'))
3324},{"_process":18}],18:[function(require,module,exports){
3325// shim for using process in browser
3326var process = module.exports = {};
3327
3328// cached from whatever global is present so that test runners that stub it
3329// don't break things. But we need to wrap it in a try catch in case it is
3330// wrapped in strict mode code which doesn't define any globals. It's inside a
3331// function because try/catches deoptimize in certain engines.
3332
3333var cachedSetTimeout;
3334var cachedClearTimeout;
3335
3336function defaultSetTimout() {
3337 throw new Error('setTimeout has not been defined');
3338}
3339function defaultClearTimeout () {
3340 throw new Error('clearTimeout has not been defined');
3341}
3342(function () {
3343 try {
3344 if (typeof setTimeout === 'function') {
3345 cachedSetTimeout = setTimeout;
3346 } else {
3347 cachedSetTimeout = defaultSetTimout;
3348 }
3349 } catch (e) {
3350 cachedSetTimeout = defaultSetTimout;
3351 }
3352 try {
3353 if (typeof clearTimeout === 'function') {
3354 cachedClearTimeout = clearTimeout;
3355 } else {
3356 cachedClearTimeout = defaultClearTimeout;
3357 }
3358 } catch (e) {
3359 cachedClearTimeout = defaultClearTimeout;
3360 }
3361} ())
3362function runTimeout(fun) {
3363 if (cachedSetTimeout === setTimeout) {
3364 //normal enviroments in sane situations
3365 return setTimeout(fun, 0);
3366 }
3367 // if setTimeout wasn't available but was latter defined
3368 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
3369 cachedSetTimeout = setTimeout;
3370 return setTimeout(fun, 0);
3371 }
3372 try {
3373 // when when somebody has screwed with setTimeout but no I.E. maddness
3374 return cachedSetTimeout(fun, 0);
3375 } catch(e){
3376 try {
3377 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
3378 return cachedSetTimeout.call(null, fun, 0);
3379 } catch(e){
3380 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
3381 return cachedSetTimeout.call(this, fun, 0);
3382 }
3383 }
3384
3385
3386}
3387function runClearTimeout(marker) {
3388 if (cachedClearTimeout === clearTimeout) {
3389 //normal enviroments in sane situations
3390 return clearTimeout(marker);
3391 }
3392 // if clearTimeout wasn't available but was latter defined
3393 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
3394 cachedClearTimeout = clearTimeout;
3395 return clearTimeout(marker);
3396 }
3397 try {
3398 // when when somebody has screwed with setTimeout but no I.E. maddness
3399 return cachedClearTimeout(marker);
3400 } catch (e){
3401 try {
3402 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
3403 return cachedClearTimeout.call(null, marker);
3404 } catch (e){
3405 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
3406 // Some versions of I.E. have different rules for clearTimeout vs setTimeout
3407 return cachedClearTimeout.call(this, marker);
3408 }
3409 }
3410
3411
3412
3413}
3414var queue = [];
3415var draining = false;
3416var currentQueue;
3417var queueIndex = -1;
3418
3419function cleanUpNextTick() {
3420 if (!draining || !currentQueue) {
3421 return;
3422 }
3423 draining = false;
3424 if (currentQueue.length) {
3425 queue = currentQueue.concat(queue);
3426 } else {
3427 queueIndex = -1;
3428 }
3429 if (queue.length) {
3430 drainQueue();
3431 }
3432}
3433
3434function drainQueue() {
3435 if (draining) {
3436 return;
3437 }
3438 var timeout = runTimeout(cleanUpNextTick);
3439 draining = true;
3440
3441 var len = queue.length;
3442 while(len) {
3443 currentQueue = queue;
3444 queue = [];
3445 while (++queueIndex < len) {
3446 if (currentQueue) {
3447 currentQueue[queueIndex].run();
3448 }
3449 }
3450 queueIndex = -1;
3451 len = queue.length;
3452 }
3453 currentQueue = null;
3454 draining = false;
3455 runClearTimeout(timeout);
3456}
3457
3458process.nextTick = function (fun) {
3459 var args = new Array(arguments.length - 1);
3460 if (arguments.length > 1) {
3461 for (var i = 1; i < arguments.length; i++) {
3462 args[i - 1] = arguments[i];
3463 }
3464 }
3465 queue.push(new Item(fun, args));
3466 if (queue.length === 1 && !draining) {
3467 runTimeout(drainQueue);
3468 }
3469};
3470
3471// v8 likes predictible objects
3472function Item(fun, array) {
3473 this.fun = fun;
3474 this.array = array;
3475}
3476Item.prototype.run = function () {
3477 this.fun.apply(null, this.array);
3478};
3479process.title = 'browser';
3480process.browser = true;
3481process.env = {};
3482process.argv = [];
3483process.version = ''; // empty string to avoid regexp issues
3484process.versions = {};
3485
3486function noop() {}
3487
3488process.on = noop;
3489process.addListener = noop;
3490process.once = noop;
3491process.off = noop;
3492process.removeListener = noop;
3493process.removeAllListeners = noop;
3494process.emit = noop;
3495process.prependListener = noop;
3496process.prependOnceListener = noop;
3497
3498process.listeners = function (name) { return [] }
3499
3500process.binding = function (name) {
3501 throw new Error('process.binding is not supported');
3502};
3503
3504process.cwd = function () { return '/' };
3505process.chdir = function (dir) {
3506 throw new Error('process.chdir is not supported');
3507};
3508process.umask = function() { return 0; };
3509
3510},{}],19:[function(require,module,exports){
3511module.exports = require('./lib/_stream_duplex.js');
3512
3513},{"./lib/_stream_duplex.js":20}],20:[function(require,module,exports){
3514// Copyright Joyent, Inc. and other Node contributors.
3515//
3516// Permission is hereby granted, free of charge, to any person obtaining a
3517// copy of this software and associated documentation files (the
3518// "Software"), to deal in the Software without restriction, including
3519// without limitation the rights to use, copy, modify, merge, publish,
3520// distribute, sublicense, and/or sell copies of the Software, and to permit
3521// persons to whom the Software is furnished to do so, subject to the
3522// following conditions:
3523//
3524// The above copyright notice and this permission notice shall be included
3525// in all copies or substantial portions of the Software.
3526//
3527// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
3528// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
3529// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
3530// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
3531// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
3532// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
3533// USE OR OTHER DEALINGS IN THE SOFTWARE.
3534
3535// a duplex stream is just a stream that is both readable and writable.
3536// Since JS doesn't have multiple prototypal inheritance, this class
3537// prototypally inherits from Readable, and then parasitically from
3538// Writable.
3539
3540'use strict';
3541
3542/*<replacement>*/
3543
3544var pna = require('process-nextick-args');
3545/*</replacement>*/
3546
3547/*<replacement>*/
3548var objectKeys = Object.keys || function (obj) {
3549 var keys = [];
3550 for (var key in obj) {
3551 keys.push(key);
3552 }return keys;
3553};
3554/*</replacement>*/
3555
3556module.exports = Duplex;
3557
3558/*<replacement>*/
3559var util = require('core-util-is');
3560util.inherits = require('inherits');
3561/*</replacement>*/
3562
3563var Readable = require('./_stream_readable');
3564var Writable = require('./_stream_writable');
3565
3566util.inherits(Duplex, Readable);
3567
3568{
3569 // avoid scope creep, the keys array can then be collected
3570 var keys = objectKeys(Writable.prototype);
3571 for (var v = 0; v < keys.length; v++) {
3572 var method = keys[v];
3573 if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
3574 }
3575}
3576
3577function Duplex(options) {
3578 if (!(this instanceof Duplex)) return new Duplex(options);
3579
3580 Readable.call(this, options);
3581 Writable.call(this, options);
3582
3583 if (options && options.readable === false) this.readable = false;
3584
3585 if (options && options.writable === false) this.writable = false;
3586
3587 this.allowHalfOpen = true;
3588 if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
3589
3590 this.once('end', onend);
3591}
3592
3593Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
3594 // making it explicit this property is not enumerable
3595 // because otherwise some prototype manipulation in
3596 // userland will fail
3597 enumerable: false,
3598 get: function () {
3599 return this._writableState.highWaterMark;
3600 }
3601});
3602
3603// the no-half-open enforcer
3604function onend() {
3605 // if we allow half-open state, or if the writable side ended,
3606 // then we're ok.
3607 if (this.allowHalfOpen || this._writableState.ended) return;
3608
3609 // no more data can be written.
3610 // But allow more writes to happen in this tick.
3611 pna.nextTick(onEndNT, this);
3612}
3613
3614function onEndNT(self) {
3615 self.end();
3616}
3617
3618Object.defineProperty(Duplex.prototype, 'destroyed', {
3619 get: function () {
3620 if (this._readableState === undefined || this._writableState === undefined) {
3621 return false;
3622 }
3623 return this._readableState.destroyed && this._writableState.destroyed;
3624 },
3625 set: function (value) {
3626 // we ignore the value if the stream
3627 // has not been initialized yet
3628 if (this._readableState === undefined || this._writableState === undefined) {
3629 return;
3630 }
3631
3632 // backward compatibility, the user is explicitly
3633 // managing destroyed
3634 this._readableState.destroyed = value;
3635 this._writableState.destroyed = value;
3636 }
3637});
3638
3639Duplex.prototype._destroy = function (err, cb) {
3640 this.push(null);
3641 this.end();
3642
3643 pna.nextTick(cb, err);
3644};
3645},{"./_stream_readable":22,"./_stream_writable":24,"core-util-is":8,"inherits":13,"process-nextick-args":17}],21:[function(require,module,exports){
3646// Copyright Joyent, Inc. and other Node contributors.
3647//
3648// Permission is hereby granted, free of charge, to any person obtaining a
3649// copy of this software and associated documentation files (the
3650// "Software"), to deal in the Software without restriction, including
3651// without limitation the rights to use, copy, modify, merge, publish,
3652// distribute, sublicense, and/or sell copies of the Software, and to permit
3653// persons to whom the Software is furnished to do so, subject to the
3654// following conditions:
3655//
3656// The above copyright notice and this permission notice shall be included
3657// in all copies or substantial portions of the Software.
3658//
3659// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
3660// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
3661// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
3662// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
3663// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
3664// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
3665// USE OR OTHER DEALINGS IN THE SOFTWARE.
3666
3667// a passthrough stream.
3668// basically just the most minimal sort of Transform stream.
3669// Every written chunk gets output as-is.
3670
3671'use strict';
3672
3673module.exports = PassThrough;
3674
3675var Transform = require('./_stream_transform');
3676
3677/*<replacement>*/
3678var util = require('core-util-is');
3679util.inherits = require('inherits');
3680/*</replacement>*/
3681
3682util.inherits(PassThrough, Transform);
3683
3684function PassThrough(options) {
3685 if (!(this instanceof PassThrough)) return new PassThrough(options);
3686
3687 Transform.call(this, options);
3688}
3689
3690PassThrough.prototype._transform = function (chunk, encoding, cb) {
3691 cb(null, chunk);
3692};
3693},{"./_stream_transform":23,"core-util-is":8,"inherits":13}],22:[function(require,module,exports){
3694(function (process,global){
3695// Copyright Joyent, Inc. and other Node contributors.
3696//
3697// Permission is hereby granted, free of charge, to any person obtaining a
3698// copy of this software and associated documentation files (the
3699// "Software"), to deal in the Software without restriction, including
3700// without limitation the rights to use, copy, modify, merge, publish,
3701// distribute, sublicense, and/or sell copies of the Software, and to permit
3702// persons to whom the Software is furnished to do so, subject to the
3703// following conditions:
3704//
3705// The above copyright notice and this permission notice shall be included
3706// in all copies or substantial portions of the Software.
3707//
3708// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
3709// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
3710// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
3711// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
3712// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
3713// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
3714// USE OR OTHER DEALINGS IN THE SOFTWARE.
3715
3716'use strict';
3717
3718/*<replacement>*/
3719
3720var pna = require('process-nextick-args');
3721/*</replacement>*/
3722
3723module.exports = Readable;
3724
3725/*<replacement>*/
3726var isArray = require('isarray');
3727/*</replacement>*/
3728
3729/*<replacement>*/
3730var Duplex;
3731/*</replacement>*/
3732
3733Readable.ReadableState = ReadableState;
3734
3735/*<replacement>*/
3736var EE = require('events').EventEmitter;
3737
3738var EElistenerCount = function (emitter, type) {
3739 return emitter.listeners(type).length;
3740};
3741/*</replacement>*/
3742
3743/*<replacement>*/
3744var Stream = require('./internal/streams/stream');
3745/*</replacement>*/
3746
3747/*<replacement>*/
3748
3749var Buffer = require('safe-buffer').Buffer;
3750var OurUint8Array = global.Uint8Array || function () {};
3751function _uint8ArrayToBuffer(chunk) {
3752 return Buffer.from(chunk);
3753}
3754function _isUint8Array(obj) {
3755 return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
3756}
3757
3758/*</replacement>*/
3759
3760/*<replacement>*/
3761var util = require('core-util-is');
3762util.inherits = require('inherits');
3763/*</replacement>*/
3764
3765/*<replacement>*/
3766var debugUtil = require('util');
3767var debug = void 0;
3768if (debugUtil && debugUtil.debuglog) {
3769 debug = debugUtil.debuglog('stream');
3770} else {
3771 debug = function () {};
3772}
3773/*</replacement>*/
3774
3775var BufferList = require('./internal/streams/BufferList');
3776var destroyImpl = require('./internal/streams/destroy');
3777var StringDecoder;
3778
3779util.inherits(Readable, Stream);
3780
3781var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
3782
3783function prependListener(emitter, event, fn) {
3784 // Sadly this is not cacheable as some libraries bundle their own
3785 // event emitter implementation with them.
3786 if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);
3787
3788 // This is a hack to make sure that our error handler is attached before any
3789 // userland ones. NEVER DO THIS. This is here only because this code needs
3790 // to continue to work with older versions of Node.js that do not include
3791 // the prependListener() method. The goal is to eventually remove this hack.
3792 if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
3793}
3794
3795function ReadableState(options, stream) {
3796 Duplex = Duplex || require('./_stream_duplex');
3797
3798 options = options || {};
3799
3800 // Duplex streams are both readable and writable, but share
3801 // the same options object.
3802 // However, some cases require setting options to different
3803 // values for the readable and the writable sides of the duplex stream.
3804 // These options can be provided separately as readableXXX and writableXXX.
3805 var isDuplex = stream instanceof Duplex;
3806
3807 // object stream flag. Used to make read(n) ignore n and to
3808 // make all the buffer merging and length checks go away
3809 this.objectMode = !!options.objectMode;
3810
3811 if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
3812
3813 // the point at which it stops calling _read() to fill the buffer
3814 // Note: 0 is a valid value, means "don't call _read preemptively ever"
3815 var hwm = options.highWaterMark;
3816 var readableHwm = options.readableHighWaterMark;
3817 var defaultHwm = this.objectMode ? 16 : 16 * 1024;
3818
3819 if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;
3820
3821 // cast to ints.
3822 this.highWaterMark = Math.floor(this.highWaterMark);
3823
3824 // A linked list is used to store data chunks instead of an array because the
3825 // linked list can remove elements from the beginning faster than
3826 // array.shift()
3827 this.buffer = new BufferList();
3828 this.length = 0;
3829 this.pipes = null;
3830 this.pipesCount = 0;
3831 this.flowing = null;
3832 this.ended = false;
3833 this.endEmitted = false;
3834 this.reading = false;
3835
3836 // a flag to be able to tell if the event 'readable'/'data' is emitted
3837 // immediately, or on a later tick. We set this to true at first, because
3838 // any actions that shouldn't happen until "later" should generally also
3839 // not happen before the first read call.
3840 this.sync = true;
3841
3842 // whenever we return null, then we set a flag to say
3843 // that we're awaiting a 'readable' event emission.
3844 this.needReadable = false;
3845 this.emittedReadable = false;
3846 this.readableListening = false;
3847 this.resumeScheduled = false;
3848
3849 // has it been destroyed
3850 this.destroyed = false;
3851
3852 // Crypto is kind of old and crusty. Historically, its default string
3853 // encoding is 'binary' so we have to make this configurable.
3854 // Everything else in the universe uses 'utf8', though.
3855 this.defaultEncoding = options.defaultEncoding || 'utf8';
3856
3857 // the number of writers that are awaiting a drain event in .pipe()s
3858 this.awaitDrain = 0;
3859
3860 // if true, a maybeReadMore has been scheduled
3861 this.readingMore = false;
3862
3863 this.decoder = null;
3864 this.encoding = null;
3865 if (options.encoding) {
3866 if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
3867 this.decoder = new StringDecoder(options.encoding);
3868 this.encoding = options.encoding;
3869 }
3870}
3871
3872function Readable(options) {
3873 Duplex = Duplex || require('./_stream_duplex');
3874
3875 if (!(this instanceof Readable)) return new Readable(options);
3876
3877 this._readableState = new ReadableState(options, this);
3878
3879 // legacy
3880 this.readable = true;
3881
3882 if (options) {
3883 if (typeof options.read === 'function') this._read = options.read;
3884
3885 if (typeof options.destroy === 'function') this._destroy = options.destroy;
3886 }
3887
3888 Stream.call(this);
3889}
3890
3891Object.defineProperty(Readable.prototype, 'destroyed', {
3892 get: function () {
3893 if (this._readableState === undefined) {
3894 return false;
3895 }
3896 return this._readableState.destroyed;
3897 },
3898 set: function (value) {
3899 // we ignore the value if the stream
3900 // has not been initialized yet
3901 if (!this._readableState) {
3902 return;
3903 }
3904
3905 // backward compatibility, the user is explicitly
3906 // managing destroyed
3907 this._readableState.destroyed = value;
3908 }
3909});
3910
3911Readable.prototype.destroy = destroyImpl.destroy;
3912Readable.prototype._undestroy = destroyImpl.undestroy;
3913Readable.prototype._destroy = function (err, cb) {
3914 this.push(null);
3915 cb(err);
3916};
3917
3918// Manually shove something into the read() buffer.
3919// This returns true if the highWaterMark has not been hit yet,
3920// similar to how Writable.write() returns true if you should
3921// write() some more.
3922Readable.prototype.push = function (chunk, encoding) {
3923 var state = this._readableState;
3924 var skipChunkCheck;
3925
3926 if (!state.objectMode) {
3927 if (typeof chunk === 'string') {
3928 encoding = encoding || state.defaultEncoding;
3929 if (encoding !== state.encoding) {
3930 chunk = Buffer.from(chunk, encoding);
3931 encoding = '';
3932 }
3933 skipChunkCheck = true;
3934 }
3935 } else {
3936 skipChunkCheck = true;
3937 }
3938
3939 return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
3940};
3941
3942// Unshift should *always* be something directly out of read()
3943Readable.prototype.unshift = function (chunk) {
3944 return readableAddChunk(this, chunk, null, true, false);
3945};
3946
3947function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
3948 var state = stream._readableState;
3949 if (chunk === null) {
3950 state.reading = false;
3951 onEofChunk(stream, state);
3952 } else {
3953 var er;
3954 if (!skipChunkCheck) er = chunkInvalid(state, chunk);
3955 if (er) {
3956 stream.emit('error', er);
3957 } else if (state.objectMode || chunk && chunk.length > 0) {
3958 if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
3959 chunk = _uint8ArrayToBuffer(chunk);
3960 }
3961
3962 if (addToFront) {
3963 if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
3964 } else if (state.ended) {
3965 stream.emit('error', new Error('stream.push() after EOF'));
3966 } else {
3967 state.reading = false;
3968 if (state.decoder && !encoding) {
3969 chunk = state.decoder.write(chunk);
3970 if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
3971 } else {
3972 addChunk(stream, state, chunk, false);
3973 }
3974 }
3975 } else if (!addToFront) {
3976 state.reading = false;
3977 }
3978 }
3979
3980 return needMoreData(state);
3981}
3982
3983function addChunk(stream, state, chunk, addToFront) {
3984 if (state.flowing && state.length === 0 && !state.sync) {
3985 stream.emit('data', chunk);
3986 stream.read(0);
3987 } else {
3988 // update the buffer info.
3989 state.length += state.objectMode ? 1 : chunk.length;
3990 if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
3991
3992 if (state.needReadable) emitReadable(stream);
3993 }
3994 maybeReadMore(stream, state);
3995}
3996
3997function chunkInvalid(state, chunk) {
3998 var er;
3999 if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
4000 er = new TypeError('Invalid non-string/buffer chunk');
4001 }
4002 return er;
4003}
4004
4005// if it's past the high water mark, we can push in some more.
4006// Also, if we have no data yet, we can stand some
4007// more bytes. This is to work around cases where hwm=0,
4008// such as the repl. Also, if the push() triggered a
4009// readable event, and the user called read(largeNumber) such that
4010// needReadable was set, then we ought to push more, so that another
4011// 'readable' event will be triggered.
4012function needMoreData(state) {
4013 return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
4014}
4015
4016Readable.prototype.isPaused = function () {
4017 return this._readableState.flowing === false;
4018};
4019
4020// backwards compatibility.
4021Readable.prototype.setEncoding = function (enc) {
4022 if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
4023 this._readableState.decoder = new StringDecoder(enc);
4024 this._readableState.encoding = enc;
4025 return this;
4026};
4027
4028// Don't raise the hwm > 8MB
4029var MAX_HWM = 0x800000;
4030function computeNewHighWaterMark(n) {
4031 if (n >= MAX_HWM) {
4032 n = MAX_HWM;
4033 } else {
4034 // Get the next highest power of 2 to prevent increasing hwm excessively in
4035 // tiny amounts
4036 n--;
4037 n |= n >>> 1;
4038 n |= n >>> 2;
4039 n |= n >>> 4;
4040 n |= n >>> 8;
4041 n |= n >>> 16;
4042 n++;
4043 }
4044 return n;
4045}
4046
4047// This function is designed to be inlinable, so please take care when making
4048// changes to the function body.
4049function howMuchToRead(n, state) {
4050 if (n <= 0 || state.length === 0 && state.ended) return 0;
4051 if (state.objectMode) return 1;
4052 if (n !== n) {
4053 // Only flow one buffer at a time
4054 if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
4055 }
4056 // If we're asking for more than the current hwm, then raise the hwm.
4057 if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
4058 if (n <= state.length) return n;
4059 // Don't have enough
4060 if (!state.ended) {
4061 state.needReadable = true;
4062 return 0;
4063 }
4064 return state.length;
4065}
4066
4067// you can override either this method, or the async _read(n) below.
4068Readable.prototype.read = function (n) {
4069 debug('read', n);
4070 n = parseInt(n, 10);
4071 var state = this._readableState;
4072 var nOrig = n;
4073
4074 if (n !== 0) state.emittedReadable = false;
4075
4076 // if we're doing read(0) to trigger a readable event, but we
4077 // already have a bunch of data in the buffer, then just trigger
4078 // the 'readable' event and move on.
4079 if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
4080 debug('read: emitReadable', state.length, state.ended);
4081 if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
4082 return null;
4083 }
4084
4085 n = howMuchToRead(n, state);
4086
4087 // if we've ended, and we're now clear, then finish it up.
4088 if (n === 0 && state.ended) {
4089 if (state.length === 0) endReadable(this);
4090 return null;
4091 }
4092
4093 // All the actual chunk generation logic needs to be
4094 // *below* the call to _read. The reason is that in certain
4095 // synthetic stream cases, such as passthrough streams, _read
4096 // may be a completely synchronous operation which may change
4097 // the state of the read buffer, providing enough data when
4098 // before there was *not* enough.
4099 //
4100 // So, the steps are:
4101 // 1. Figure out what the state of things will be after we do
4102 // a read from the buffer.
4103 //
4104 // 2. If that resulting state will trigger a _read, then call _read.
4105 // Note that this may be asynchronous, or synchronous. Yes, it is
4106 // deeply ugly to write APIs this way, but that still doesn't mean
4107 // that the Readable class should behave improperly, as streams are
4108 // designed to be sync/async agnostic.
4109 // Take note if the _read call is sync or async (ie, if the read call
4110 // has returned yet), so that we know whether or not it's safe to emit
4111 // 'readable' etc.
4112 //
4113 // 3. Actually pull the requested chunks out of the buffer and return.
4114
4115 // if we need a readable event, then we need to do some reading.
4116 var doRead = state.needReadable;
4117 debug('need readable', doRead);
4118
4119 // if we currently have less than the highWaterMark, then also read some
4120 if (state.length === 0 || state.length - n < state.highWaterMark) {
4121 doRead = true;
4122 debug('length less than watermark', doRead);
4123 }
4124
4125 // however, if we've ended, then there's no point, and if we're already
4126 // reading, then it's unnecessary.
4127 if (state.ended || state.reading) {
4128 doRead = false;
4129 debug('reading or ended', doRead);
4130 } else if (doRead) {
4131 debug('do read');
4132 state.reading = true;
4133 state.sync = true;
4134 // if the length is currently zero, then we *need* a readable event.
4135 if (state.length === 0) state.needReadable = true;
4136 // call internal read method
4137 this._read(state.highWaterMark);
4138 state.sync = false;
4139 // If _read pushed data synchronously, then `reading` will be false,
4140 // and we need to re-evaluate how much data we can return to the user.
4141 if (!state.reading) n = howMuchToRead(nOrig, state);
4142 }
4143
4144 var ret;
4145 if (n > 0) ret = fromList(n, state);else ret = null;
4146
4147 if (ret === null) {
4148 state.needReadable = true;
4149 n = 0;
4150 } else {
4151 state.length -= n;
4152 }
4153
4154 if (state.length === 0) {
4155 // If we have nothing in the buffer, then we want to know
4156 // as soon as we *do* get something into the buffer.
4157 if (!state.ended) state.needReadable = true;
4158
4159 // If we tried to read() past the EOF, then emit end on the next tick.
4160 if (nOrig !== n && state.ended) endReadable(this);
4161 }
4162
4163 if (ret !== null) this.emit('data', ret);
4164
4165 return ret;
4166};
4167
4168function onEofChunk(stream, state) {
4169 if (state.ended) return;
4170 if (state.decoder) {
4171 var chunk = state.decoder.end();
4172 if (chunk && chunk.length) {
4173 state.buffer.push(chunk);
4174 state.length += state.objectMode ? 1 : chunk.length;
4175 }
4176 }
4177 state.ended = true;
4178
4179 // emit 'readable' now to make sure it gets picked up.
4180 emitReadable(stream);
4181}
4182
4183// Don't emit readable right away in sync mode, because this can trigger
4184// another read() call => stack overflow. This way, it might trigger
4185// a nextTick recursion warning, but that's not so bad.
4186function emitReadable(stream) {
4187 var state = stream._readableState;
4188 state.needReadable = false;
4189 if (!state.emittedReadable) {
4190 debug('emitReadable', state.flowing);
4191 state.emittedReadable = true;
4192 if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);
4193 }
4194}
4195
4196function emitReadable_(stream) {
4197 debug('emit readable');
4198 stream.emit('readable');
4199 flow(stream);
4200}
4201
4202// at this point, the user has presumably seen the 'readable' event,
4203// and called read() to consume some data. that may have triggered
4204// in turn another _read(n) call, in which case reading = true if
4205// it's in progress.
4206// However, if we're not ended, or reading, and the length < hwm,
4207// then go ahead and try to read some more preemptively.
4208function maybeReadMore(stream, state) {
4209 if (!state.readingMore) {
4210 state.readingMore = true;
4211 pna.nextTick(maybeReadMore_, stream, state);
4212 }
4213}
4214
4215function maybeReadMore_(stream, state) {
4216 var len = state.length;
4217 while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
4218 debug('maybeReadMore read 0');
4219 stream.read(0);
4220 if (len === state.length)
4221 // didn't get any data, stop spinning.
4222 break;else len = state.length;
4223 }
4224 state.readingMore = false;
4225}
4226
4227// abstract method. to be overridden in specific implementation classes.
4228// call cb(er, data) where data is <= n in length.
4229// for virtual (non-string, non-buffer) streams, "length" is somewhat
4230// arbitrary, and perhaps not very meaningful.
4231Readable.prototype._read = function (n) {
4232 this.emit('error', new Error('_read() is not implemented'));
4233};
4234
4235Readable.prototype.pipe = function (dest, pipeOpts) {
4236 var src = this;
4237 var state = this._readableState;
4238
4239 switch (state.pipesCount) {
4240 case 0:
4241 state.pipes = dest;
4242 break;
4243 case 1:
4244 state.pipes = [state.pipes, dest];
4245 break;
4246 default:
4247 state.pipes.push(dest);
4248 break;
4249 }
4250 state.pipesCount += 1;
4251 debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
4252
4253 var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
4254
4255 var endFn = doEnd ? onend : unpipe;
4256 if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);
4257
4258 dest.on('unpipe', onunpipe);
4259 function onunpipe(readable, unpipeInfo) {
4260 debug('onunpipe');
4261 if (readable === src) {
4262 if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
4263 unpipeInfo.hasUnpiped = true;
4264 cleanup();
4265 }
4266 }
4267 }
4268
4269 function onend() {
4270 debug('onend');
4271 dest.end();
4272 }
4273
4274 // when the dest drains, it reduces the awaitDrain counter
4275 // on the source. This would be more elegant with a .once()
4276 // handler in flow(), but adding and removing repeatedly is
4277 // too slow.
4278 var ondrain = pipeOnDrain(src);
4279 dest.on('drain', ondrain);
4280
4281 var cleanedUp = false;
4282 function cleanup() {
4283 debug('cleanup');
4284 // cleanup event handlers once the pipe is broken
4285 dest.removeListener('close', onclose);
4286 dest.removeListener('finish', onfinish);
4287 dest.removeListener('drain', ondrain);
4288 dest.removeListener('error', onerror);
4289 dest.removeListener('unpipe', onunpipe);
4290 src.removeListener('end', onend);
4291 src.removeListener('end', unpipe);
4292 src.removeListener('data', ondata);
4293
4294 cleanedUp = true;
4295
4296 // if the reader is waiting for a drain event from this
4297 // specific writer, then it would cause it to never start
4298 // flowing again.
4299 // So, if this is awaiting a drain, then we just call it now.
4300 // If we don't know, then assume that we are waiting for one.
4301 if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
4302 }
4303
4304 // If the user pushes more data while we're writing to dest then we'll end up
4305 // in ondata again. However, we only want to increase awaitDrain once because
4306 // dest will only emit one 'drain' event for the multiple writes.
4307 // => Introduce a guard on increasing awaitDrain.
4308 var increasedAwaitDrain = false;
4309 src.on('data', ondata);
4310 function ondata(chunk) {
4311 debug('ondata');
4312 increasedAwaitDrain = false;
4313 var ret = dest.write(chunk);
4314 if (false === ret && !increasedAwaitDrain) {
4315 // If the user unpiped during `dest.write()`, it is possible
4316 // to get stuck in a permanently paused state if that write
4317 // also returned false.
4318 // => Check whether `dest` is still a piping destination.
4319 if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
4320 debug('false write response, pause', src._readableState.awaitDrain);
4321 src._readableState.awaitDrain++;
4322 increasedAwaitDrain = true;
4323 }
4324 src.pause();
4325 }
4326 }
4327
4328 // if the dest has an error, then stop piping into it.
4329 // however, don't suppress the throwing behavior for this.
4330 function onerror(er) {
4331 debug('onerror', er);
4332 unpipe();
4333 dest.removeListener('error', onerror);
4334 if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
4335 }
4336
4337 // Make sure our error handler is attached before userland ones.
4338 prependListener(dest, 'error', onerror);
4339
4340 // Both close and finish should trigger unpipe, but only once.
4341 function onclose() {
4342 dest.removeListener('finish', onfinish);
4343 unpipe();
4344 }
4345 dest.once('close', onclose);
4346 function onfinish() {
4347 debug('onfinish');
4348 dest.removeListener('close', onclose);
4349 unpipe();
4350 }
4351 dest.once('finish', onfinish);
4352
4353 function unpipe() {
4354 debug('unpipe');
4355 src.unpipe(dest);
4356 }
4357
4358 // tell the dest that it's being piped to
4359 dest.emit('pipe', src);
4360
4361 // start the flow if it hasn't been started already.
4362 if (!state.flowing) {
4363 debug('pipe resume');
4364 src.resume();
4365 }
4366
4367 return dest;
4368};
4369
4370function pipeOnDrain(src) {
4371 return function () {
4372 var state = src._readableState;
4373 debug('pipeOnDrain', state.awaitDrain);
4374 if (state.awaitDrain) state.awaitDrain--;
4375 if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
4376 state.flowing = true;
4377 flow(src);
4378 }
4379 };
4380}
4381
4382Readable.prototype.unpipe = function (dest) {
4383 var state = this._readableState;
4384 var unpipeInfo = { hasUnpiped: false };
4385
4386 // if we're not piping anywhere, then do nothing.
4387 if (state.pipesCount === 0) return this;
4388
4389 // just one destination. most common case.
4390 if (state.pipesCount === 1) {
4391 // passed in one, but it's not the right one.
4392 if (dest && dest !== state.pipes) return this;
4393
4394 if (!dest) dest = state.pipes;
4395
4396 // got a match.
4397 state.pipes = null;
4398 state.pipesCount = 0;
4399 state.flowing = false;
4400 if (dest) dest.emit('unpipe', this, unpipeInfo);
4401 return this;
4402 }
4403
4404 // slow case. multiple pipe destinations.
4405
4406 if (!dest) {
4407 // remove all.
4408 var dests = state.pipes;
4409 var len = state.pipesCount;
4410 state.pipes = null;
4411 state.pipesCount = 0;
4412 state.flowing = false;
4413
4414 for (var i = 0; i < len; i++) {
4415 dests[i].emit('unpipe', this, unpipeInfo);
4416 }return this;
4417 }
4418
4419 // try to find the right one.
4420 var index = indexOf(state.pipes, dest);
4421 if (index === -1) return this;
4422
4423 state.pipes.splice(index, 1);
4424 state.pipesCount -= 1;
4425 if (state.pipesCount === 1) state.pipes = state.pipes[0];
4426
4427 dest.emit('unpipe', this, unpipeInfo);
4428
4429 return this;
4430};
4431
4432// set up data events if they are asked for
4433// Ensure readable listeners eventually get something
4434Readable.prototype.on = function (ev, fn) {
4435 var res = Stream.prototype.on.call(this, ev, fn);
4436
4437 if (ev === 'data') {
4438 // Start flowing on next tick if stream isn't explicitly paused
4439 if (this._readableState.flowing !== false) this.resume();
4440 } else if (ev === 'readable') {
4441 var state = this._readableState;
4442 if (!state.endEmitted && !state.readableListening) {
4443 state.readableListening = state.needReadable = true;
4444 state.emittedReadable = false;
4445 if (!state.reading) {
4446 pna.nextTick(nReadingNextTick, this);
4447 } else if (state.length) {
4448 emitReadable(this);
4449 }
4450 }
4451 }
4452
4453 return res;
4454};
4455Readable.prototype.addListener = Readable.prototype.on;
4456
4457function nReadingNextTick(self) {
4458 debug('readable nexttick read 0');
4459 self.read(0);
4460}
4461
4462// pause() and resume() are remnants of the legacy readable stream API
4463// If the user uses them, then switch into old mode.
4464Readable.prototype.resume = function () {
4465 var state = this._readableState;
4466 if (!state.flowing) {
4467 debug('resume');
4468 state.flowing = true;
4469 resume(this, state);
4470 }
4471 return this;
4472};
4473
4474function resume(stream, state) {
4475 if (!state.resumeScheduled) {
4476 state.resumeScheduled = true;
4477 pna.nextTick(resume_, stream, state);
4478 }
4479}
4480
4481function resume_(stream, state) {
4482 if (!state.reading) {
4483 debug('resume read 0');
4484 stream.read(0);
4485 }
4486
4487 state.resumeScheduled = false;
4488 state.awaitDrain = 0;
4489 stream.emit('resume');
4490 flow(stream);
4491 if (state.flowing && !state.reading) stream.read(0);
4492}
4493
4494Readable.prototype.pause = function () {
4495 debug('call pause flowing=%j', this._readableState.flowing);
4496 if (false !== this._readableState.flowing) {
4497 debug('pause');
4498 this._readableState.flowing = false;
4499 this.emit('pause');
4500 }
4501 return this;
4502};
4503
4504function flow(stream) {
4505 var state = stream._readableState;
4506 debug('flow', state.flowing);
4507 while (state.flowing && stream.read() !== null) {}
4508}
4509
4510// wrap an old-style stream as the async data source.
4511// This is *not* part of the readable stream interface.
4512// It is an ugly unfortunate mess of history.
4513Readable.prototype.wrap = function (stream) {
4514 var _this = this;
4515
4516 var state = this._readableState;
4517 var paused = false;
4518
4519 stream.on('end', function () {
4520 debug('wrapped end');
4521 if (state.decoder && !state.ended) {
4522 var chunk = state.decoder.end();
4523 if (chunk && chunk.length) _this.push(chunk);
4524 }
4525
4526 _this.push(null);
4527 });
4528
4529 stream.on('data', function (chunk) {
4530 debug('wrapped data');
4531 if (state.decoder) chunk = state.decoder.write(chunk);
4532
4533 // don't skip over falsy values in objectMode
4534 if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
4535
4536 var ret = _this.push(chunk);
4537 if (!ret) {
4538 paused = true;
4539 stream.pause();
4540 }
4541 });
4542
4543 // proxy all the other methods.
4544 // important when wrapping filters and duplexes.
4545 for (var i in stream) {
4546 if (this[i] === undefined && typeof stream[i] === 'function') {
4547 this[i] = function (method) {
4548 return function () {
4549 return stream[method].apply(stream, arguments);
4550 };
4551 }(i);
4552 }
4553 }
4554
4555 // proxy certain important events.
4556 for (var n = 0; n < kProxyEvents.length; n++) {
4557 stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
4558 }
4559
4560 // when we try to consume some more bytes, simply unpause the
4561 // underlying stream.
4562 this._read = function (n) {
4563 debug('wrapped _read', n);
4564 if (paused) {
4565 paused = false;
4566 stream.resume();
4567 }
4568 };
4569
4570 return this;
4571};
4572
4573Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
4574 // making it explicit this property is not enumerable
4575 // because otherwise some prototype manipulation in
4576 // userland will fail
4577 enumerable: false,
4578 get: function () {
4579 return this._readableState.highWaterMark;
4580 }
4581});
4582
4583// exposed for testing purposes only.
4584Readable._fromList = fromList;
4585
4586// Pluck off n bytes from an array of buffers.
4587// Length is the combined lengths of all the buffers in the list.
4588// This function is designed to be inlinable, so please take care when making
4589// changes to the function body.
4590function fromList(n, state) {
4591 // nothing buffered
4592 if (state.length === 0) return null;
4593
4594 var ret;
4595 if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
4596 // read it all, truncate the list
4597 if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);
4598 state.buffer.clear();
4599 } else {
4600 // read part of list
4601 ret = fromListPartial(n, state.buffer, state.decoder);
4602 }
4603
4604 return ret;
4605}
4606
4607// Extracts only enough buffered data to satisfy the amount requested.
4608// This function is designed to be inlinable, so please take care when making
4609// changes to the function body.
4610function fromListPartial(n, list, hasStrings) {
4611 var ret;
4612 if (n < list.head.data.length) {
4613 // slice is the same for buffers and strings
4614 ret = list.head.data.slice(0, n);
4615 list.head.data = list.head.data.slice(n);
4616 } else if (n === list.head.data.length) {
4617 // first chunk is a perfect match
4618 ret = list.shift();
4619 } else {
4620 // result spans more than one buffer
4621 ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
4622 }
4623 return ret;
4624}
4625
4626// Copies a specified amount of characters from the list of buffered data
4627// chunks.
4628// This function is designed to be inlinable, so please take care when making
4629// changes to the function body.
4630function copyFromBufferString(n, list) {
4631 var p = list.head;
4632 var c = 1;
4633 var ret = p.data;
4634 n -= ret.length;
4635 while (p = p.next) {
4636 var str = p.data;
4637 var nb = n > str.length ? str.length : n;
4638 if (nb === str.length) ret += str;else ret += str.slice(0, n);
4639 n -= nb;
4640 if (n === 0) {
4641 if (nb === str.length) {
4642 ++c;
4643 if (p.next) list.head = p.next;else list.head = list.tail = null;
4644 } else {
4645 list.head = p;
4646 p.data = str.slice(nb);
4647 }
4648 break;
4649 }
4650 ++c;
4651 }
4652 list.length -= c;
4653 return ret;
4654}
4655
4656// Copies a specified amount of bytes from the list of buffered data chunks.
4657// This function is designed to be inlinable, so please take care when making
4658// changes to the function body.
4659function copyFromBuffer(n, list) {
4660 var ret = Buffer.allocUnsafe(n);
4661 var p = list.head;
4662 var c = 1;
4663 p.data.copy(ret);
4664 n -= p.data.length;
4665 while (p = p.next) {
4666 var buf = p.data;
4667 var nb = n > buf.length ? buf.length : n;
4668 buf.copy(ret, ret.length - n, 0, nb);
4669 n -= nb;
4670 if (n === 0) {
4671 if (nb === buf.length) {
4672 ++c;
4673 if (p.next) list.head = p.next;else list.head = list.tail = null;
4674 } else {
4675 list.head = p;
4676 p.data = buf.slice(nb);
4677 }
4678 break;
4679 }
4680 ++c;
4681 }
4682 list.length -= c;
4683 return ret;
4684}
4685
4686function endReadable(stream) {
4687 var state = stream._readableState;
4688
4689 // If we get here before consuming all the bytes, then that is a
4690 // bug in node. Should never happen.
4691 if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
4692
4693 if (!state.endEmitted) {
4694 state.ended = true;
4695 pna.nextTick(endReadableNT, state, stream);
4696 }
4697}
4698
4699function endReadableNT(state, stream) {
4700 // Check that we didn't get one last unshift.
4701 if (!state.endEmitted && state.length === 0) {
4702 state.endEmitted = true;
4703 stream.readable = false;
4704 stream.emit('end');
4705 }
4706}
4707
4708function indexOf(xs, x) {
4709 for (var i = 0, l = xs.length; i < l; i++) {
4710 if (xs[i] === x) return i;
4711 }
4712 return -1;
4713}
4714}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
4715},{"./_stream_duplex":20,"./internal/streams/BufferList":25,"./internal/streams/destroy":26,"./internal/streams/stream":27,"_process":18,"core-util-is":8,"events":10,"inherits":13,"isarray":15,"process-nextick-args":17,"safe-buffer":34,"string_decoder/":28,"util":4}],23:[function(require,module,exports){
4716// Copyright Joyent, Inc. and other Node contributors.
4717//
4718// Permission is hereby granted, free of charge, to any person obtaining a
4719// copy of this software and associated documentation files (the
4720// "Software"), to deal in the Software without restriction, including
4721// without limitation the rights to use, copy, modify, merge, publish,
4722// distribute, sublicense, and/or sell copies of the Software, and to permit
4723// persons to whom the Software is furnished to do so, subject to the
4724// following conditions:
4725//
4726// The above copyright notice and this permission notice shall be included
4727// in all copies or substantial portions of the Software.
4728//
4729// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
4730// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
4731// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
4732// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
4733// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
4734// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
4735// USE OR OTHER DEALINGS IN THE SOFTWARE.
4736
4737// a transform stream is a readable/writable stream where you do
4738// something with the data. Sometimes it's called a "filter",
4739// but that's not a great name for it, since that implies a thing where
4740// some bits pass through, and others are simply ignored. (That would
4741// be a valid example of a transform, of course.)
4742//
4743// While the output is causally related to the input, it's not a
4744// necessarily symmetric or synchronous transformation. For example,
4745// a zlib stream might take multiple plain-text writes(), and then
4746// emit a single compressed chunk some time in the future.
4747//
4748// Here's how this works:
4749//
4750// The Transform stream has all the aspects of the readable and writable
4751// stream classes. When you write(chunk), that calls _write(chunk,cb)
4752// internally, and returns false if there's a lot of pending writes
4753// buffered up. When you call read(), that calls _read(n) until
4754// there's enough pending readable data buffered up.
4755//
4756// In a transform stream, the written data is placed in a buffer. When
4757// _read(n) is called, it transforms the queued up data, calling the
4758// buffered _write cb's as it consumes chunks. If consuming a single
4759// written chunk would result in multiple output chunks, then the first
4760// outputted bit calls the readcb, and subsequent chunks just go into
4761// the read buffer, and will cause it to emit 'readable' if necessary.
4762//
4763// This way, back-pressure is actually determined by the reading side,
4764// since _read has to be called to start processing a new chunk. However,
4765// a pathological inflate type of transform can cause excessive buffering
4766// here. For example, imagine a stream where every byte of input is
4767// interpreted as an integer from 0-255, and then results in that many
4768// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
4769// 1kb of data being output. In this case, you could write a very small
4770// amount of input, and end up with a very large amount of output. In
4771// such a pathological inflating mechanism, there'd be no way to tell
4772// the system to stop doing the transform. A single 4MB write could
4773// cause the system to run out of memory.
4774//
4775// However, even in such a pathological case, only a single written chunk
4776// would be consumed, and then the rest would wait (un-transformed) until
4777// the results of the previous transformed chunk were consumed.
4778
4779'use strict';
4780
4781module.exports = Transform;
4782
4783var Duplex = require('./_stream_duplex');
4784
4785/*<replacement>*/
4786var util = require('core-util-is');
4787util.inherits = require('inherits');
4788/*</replacement>*/
4789
4790util.inherits(Transform, Duplex);
4791
4792function afterTransform(er, data) {
4793 var ts = this._transformState;
4794 ts.transforming = false;
4795
4796 var cb = ts.writecb;
4797
4798 if (!cb) {
4799 return this.emit('error', new Error('write callback called multiple times'));
4800 }
4801
4802 ts.writechunk = null;
4803 ts.writecb = null;
4804
4805 if (data != null) // single equals check for both `null` and `undefined`
4806 this.push(data);
4807
4808 cb(er);
4809
4810 var rs = this._readableState;
4811 rs.reading = false;
4812 if (rs.needReadable || rs.length < rs.highWaterMark) {
4813 this._read(rs.highWaterMark);
4814 }
4815}
4816
4817function Transform(options) {
4818 if (!(this instanceof Transform)) return new Transform(options);
4819
4820 Duplex.call(this, options);
4821
4822 this._transformState = {
4823 afterTransform: afterTransform.bind(this),
4824 needTransform: false,
4825 transforming: false,
4826 writecb: null,
4827 writechunk: null,
4828 writeencoding: null
4829 };
4830
4831 // start out asking for a readable event once data is transformed.
4832 this._readableState.needReadable = true;
4833
4834 // we have implemented the _read method, and done the other things
4835 // that Readable wants before the first _read call, so unset the
4836 // sync guard flag.
4837 this._readableState.sync = false;
4838
4839 if (options) {
4840 if (typeof options.transform === 'function') this._transform = options.transform;
4841
4842 if (typeof options.flush === 'function') this._flush = options.flush;
4843 }
4844
4845 // When the writable side finishes, then flush out anything remaining.
4846 this.on('prefinish', prefinish);
4847}
4848
4849function prefinish() {
4850 var _this = this;
4851
4852 if (typeof this._flush === 'function') {
4853 this._flush(function (er, data) {
4854 done(_this, er, data);
4855 });
4856 } else {
4857 done(this, null, null);
4858 }
4859}
4860
4861Transform.prototype.push = function (chunk, encoding) {
4862 this._transformState.needTransform = false;
4863 return Duplex.prototype.push.call(this, chunk, encoding);
4864};
4865
4866// This is the part where you do stuff!
4867// override this function in implementation classes.
4868// 'chunk' is an input chunk.
4869//
4870// Call `push(newChunk)` to pass along transformed output
4871// to the readable side. You may call 'push' zero or more times.
4872//
4873// Call `cb(err)` when you are done with this chunk. If you pass
4874// an error, then that'll put the hurt on the whole operation. If you
4875// never call cb(), then you'll never get another chunk.
4876Transform.prototype._transform = function (chunk, encoding, cb) {
4877 throw new Error('_transform() is not implemented');
4878};
4879
4880Transform.prototype._write = function (chunk, encoding, cb) {
4881 var ts = this._transformState;
4882 ts.writecb = cb;
4883 ts.writechunk = chunk;
4884 ts.writeencoding = encoding;
4885 if (!ts.transforming) {
4886 var rs = this._readableState;
4887 if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
4888 }
4889};
4890
4891// Doesn't matter what the args are here.
4892// _transform does all the work.
4893// That we got here means that the readable side wants more data.
4894Transform.prototype._read = function (n) {
4895 var ts = this._transformState;
4896
4897 if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
4898 ts.transforming = true;
4899 this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
4900 } else {
4901 // mark that we need a transform, so that any data that comes in
4902 // will get processed, now that we've asked for it.
4903 ts.needTransform = true;
4904 }
4905};
4906
4907Transform.prototype._destroy = function (err, cb) {
4908 var _this2 = this;
4909
4910 Duplex.prototype._destroy.call(this, err, function (err2) {
4911 cb(err2);
4912 _this2.emit('close');
4913 });
4914};
4915
4916function done(stream, er, data) {
4917 if (er) return stream.emit('error', er);
4918
4919 if (data != null) // single equals check for both `null` and `undefined`
4920 stream.push(data);
4921
4922 // if there's nothing in the write buffer, then that means
4923 // that nothing more will ever be provided
4924 if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
4925
4926 if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
4927
4928 return stream.push(null);
4929}
4930},{"./_stream_duplex":20,"core-util-is":8,"inherits":13}],24:[function(require,module,exports){
4931(function (process,global,setImmediate){
4932// Copyright Joyent, Inc. and other Node contributors.
4933//
4934// Permission is hereby granted, free of charge, to any person obtaining a
4935// copy of this software and associated documentation files (the
4936// "Software"), to deal in the Software without restriction, including
4937// without limitation the rights to use, copy, modify, merge, publish,
4938// distribute, sublicense, and/or sell copies of the Software, and to permit
4939// persons to whom the Software is furnished to do so, subject to the
4940// following conditions:
4941//
4942// The above copyright notice and this permission notice shall be included
4943// in all copies or substantial portions of the Software.
4944//
4945// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
4946// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
4947// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
4948// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
4949// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
4950// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
4951// USE OR OTHER DEALINGS IN THE SOFTWARE.
4952
4953// A bit simpler than readable streams.
4954// Implement an async ._write(chunk, encoding, cb), and it'll handle all
4955// the drain event emission and buffering.
4956
4957'use strict';
4958
4959/*<replacement>*/
4960
4961var pna = require('process-nextick-args');
4962/*</replacement>*/
4963
4964module.exports = Writable;
4965
4966/* <replacement> */
4967function WriteReq(chunk, encoding, cb) {
4968 this.chunk = chunk;
4969 this.encoding = encoding;
4970 this.callback = cb;
4971 this.next = null;
4972}
4973
4974// It seems a linked list but it is not
4975// there will be only 2 of these for each stream
4976function CorkedRequest(state) {
4977 var _this = this;
4978
4979 this.next = null;
4980 this.entry = null;
4981 this.finish = function () {
4982 onCorkedFinish(_this, state);
4983 };
4984}
4985/* </replacement> */
4986
4987/*<replacement>*/
4988var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
4989/*</replacement>*/
4990
4991/*<replacement>*/
4992var Duplex;
4993/*</replacement>*/
4994
4995Writable.WritableState = WritableState;
4996
4997/*<replacement>*/
4998var util = require('core-util-is');
4999util.inherits = require('inherits');
5000/*</replacement>*/
5001
5002/*<replacement>*/
5003var internalUtil = {
5004 deprecate: require('util-deprecate')
5005};
5006/*</replacement>*/
5007
5008/*<replacement>*/
5009var Stream = require('./internal/streams/stream');
5010/*</replacement>*/
5011
5012/*<replacement>*/
5013
5014var Buffer = require('safe-buffer').Buffer;
5015var OurUint8Array = global.Uint8Array || function () {};
5016function _uint8ArrayToBuffer(chunk) {
5017 return Buffer.from(chunk);
5018}
5019function _isUint8Array(obj) {
5020 return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
5021}
5022
5023/*</replacement>*/
5024
5025var destroyImpl = require('./internal/streams/destroy');
5026
5027util.inherits(Writable, Stream);
5028
5029function nop() {}
5030
5031function WritableState(options, stream) {
5032 Duplex = Duplex || require('./_stream_duplex');
5033
5034 options = options || {};
5035
5036 // Duplex streams are both readable and writable, but share
5037 // the same options object.
5038 // However, some cases require setting options to different
5039 // values for the readable and the writable sides of the duplex stream.
5040 // These options can be provided separately as readableXXX and writableXXX.
5041 var isDuplex = stream instanceof Duplex;
5042
5043 // object stream flag to indicate whether or not this stream
5044 // contains buffers or objects.
5045 this.objectMode = !!options.objectMode;
5046
5047 if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
5048
5049 // the point at which write() starts returning false
5050 // Note: 0 is a valid value, means that we always return false if
5051 // the entire buffer is not flushed immediately on write()
5052 var hwm = options.highWaterMark;
5053 var writableHwm = options.writableHighWaterMark;
5054 var defaultHwm = this.objectMode ? 16 : 16 * 1024;
5055
5056 if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;
5057
5058 // cast to ints.
5059 this.highWaterMark = Math.floor(this.highWaterMark);
5060
5061 // if _final has been called
5062 this.finalCalled = false;
5063
5064 // drain event flag.
5065 this.needDrain = false;
5066 // at the start of calling end()
5067 this.ending = false;
5068 // when end() has been called, and returned
5069 this.ended = false;
5070 // when 'finish' is emitted
5071 this.finished = false;
5072
5073 // has it been destroyed
5074 this.destroyed = false;
5075
5076 // should we decode strings into buffers before passing to _write?
5077 // this is here so that some node-core streams can optimize string
5078 // handling at a lower level.
5079 var noDecode = options.decodeStrings === false;
5080 this.decodeStrings = !noDecode;
5081
5082 // Crypto is kind of old and crusty. Historically, its default string
5083 // encoding is 'binary' so we have to make this configurable.
5084 // Everything else in the universe uses 'utf8', though.
5085 this.defaultEncoding = options.defaultEncoding || 'utf8';
5086
5087 // not an actual buffer we keep track of, but a measurement
5088 // of how much we're waiting to get pushed to some underlying
5089 // socket or file.
5090 this.length = 0;
5091
5092 // a flag to see when we're in the middle of a write.
5093 this.writing = false;
5094
5095 // when true all writes will be buffered until .uncork() call
5096 this.corked = 0;
5097
5098 // a flag to be able to tell if the onwrite cb is called immediately,
5099 // or on a later tick. We set this to true at first, because any
5100 // actions that shouldn't happen until "later" should generally also
5101 // not happen before the first write call.
5102 this.sync = true;
5103
5104 // a flag to know if we're processing previously buffered items, which
5105 // may call the _write() callback in the same tick, so that we don't
5106 // end up in an overlapped onwrite situation.
5107 this.bufferProcessing = false;
5108
5109 // the callback that's passed to _write(chunk,cb)
5110 this.onwrite = function (er) {
5111 onwrite(stream, er);
5112 };
5113
5114 // the callback that the user supplies to write(chunk,encoding,cb)
5115 this.writecb = null;
5116
5117 // the amount that is being written when _write is called.
5118 this.writelen = 0;
5119
5120 this.bufferedRequest = null;
5121 this.lastBufferedRequest = null;
5122
5123 // number of pending user-supplied write callbacks
5124 // this must be 0 before 'finish' can be emitted
5125 this.pendingcb = 0;
5126
5127 // emit prefinish if the only thing we're waiting for is _write cbs
5128 // This is relevant for synchronous Transform streams
5129 this.prefinished = false;
5130
5131 // True if the error was already emitted and should not be thrown again
5132 this.errorEmitted = false;
5133
5134 // count buffered requests
5135 this.bufferedRequestCount = 0;
5136
5137 // allocate the first CorkedRequest, there is always
5138 // one allocated and free to use, and we maintain at most two
5139 this.corkedRequestsFree = new CorkedRequest(this);
5140}
5141
5142WritableState.prototype.getBuffer = function getBuffer() {
5143 var current = this.bufferedRequest;
5144 var out = [];
5145 while (current) {
5146 out.push(current);
5147 current = current.next;
5148 }
5149 return out;
5150};
5151
5152(function () {
5153 try {
5154 Object.defineProperty(WritableState.prototype, 'buffer', {
5155 get: internalUtil.deprecate(function () {
5156 return this.getBuffer();
5157 }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
5158 });
5159 } catch (_) {}
5160})();
5161
5162// Test _writableState for inheritance to account for Duplex streams,
5163// whose prototype chain only points to Readable.
5164var realHasInstance;
5165if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
5166 realHasInstance = Function.prototype[Symbol.hasInstance];
5167 Object.defineProperty(Writable, Symbol.hasInstance, {
5168 value: function (object) {
5169 if (realHasInstance.call(this, object)) return true;
5170 if (this !== Writable) return false;
5171
5172 return object && object._writableState instanceof WritableState;
5173 }
5174 });
5175} else {
5176 realHasInstance = function (object) {
5177 return object instanceof this;
5178 };
5179}
5180
5181function Writable(options) {
5182 Duplex = Duplex || require('./_stream_duplex');
5183
5184 // Writable ctor is applied to Duplexes, too.
5185 // `realHasInstance` is necessary because using plain `instanceof`
5186 // would return false, as no `_writableState` property is attached.
5187
5188 // Trying to use the custom `instanceof` for Writable here will also break the
5189 // Node.js LazyTransform implementation, which has a non-trivial getter for
5190 // `_writableState` that would lead to infinite recursion.
5191 if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
5192 return new Writable(options);
5193 }
5194
5195 this._writableState = new WritableState(options, this);
5196
5197 // legacy.
5198 this.writable = true;
5199
5200 if (options) {
5201 if (typeof options.write === 'function') this._write = options.write;
5202
5203 if (typeof options.writev === 'function') this._writev = options.writev;
5204
5205 if (typeof options.destroy === 'function') this._destroy = options.destroy;
5206
5207 if (typeof options.final === 'function') this._final = options.final;
5208 }
5209
5210 Stream.call(this);
5211}
5212
5213// Otherwise people can pipe Writable streams, which is just wrong.
5214Writable.prototype.pipe = function () {
5215 this.emit('error', new Error('Cannot pipe, not readable'));
5216};
5217
5218function writeAfterEnd(stream, cb) {
5219 var er = new Error('write after end');
5220 // TODO: defer error events consistently everywhere, not just the cb
5221 stream.emit('error', er);
5222 pna.nextTick(cb, er);
5223}
5224
5225// Checks that a user-supplied chunk is valid, especially for the particular
5226// mode the stream is in. Currently this means that `null` is never accepted
5227// and undefined/non-string values are only allowed in object mode.
5228function validChunk(stream, state, chunk, cb) {
5229 var valid = true;
5230 var er = false;
5231
5232 if (chunk === null) {
5233 er = new TypeError('May not write null values to stream');
5234 } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
5235 er = new TypeError('Invalid non-string/buffer chunk');
5236 }
5237 if (er) {
5238 stream.emit('error', er);
5239 pna.nextTick(cb, er);
5240 valid = false;
5241 }
5242 return valid;
5243}
5244
5245Writable.prototype.write = function (chunk, encoding, cb) {
5246 var state = this._writableState;
5247 var ret = false;
5248 var isBuf = !state.objectMode && _isUint8Array(chunk);
5249
5250 if (isBuf && !Buffer.isBuffer(chunk)) {
5251 chunk = _uint8ArrayToBuffer(chunk);
5252 }
5253
5254 if (typeof encoding === 'function') {
5255 cb = encoding;
5256 encoding = null;
5257 }
5258
5259 if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
5260
5261 if (typeof cb !== 'function') cb = nop;
5262
5263 if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
5264 state.pendingcb++;
5265 ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
5266 }
5267
5268 return ret;
5269};
5270
5271Writable.prototype.cork = function () {
5272 var state = this._writableState;
5273
5274 state.corked++;
5275};
5276
5277Writable.prototype.uncork = function () {
5278 var state = this._writableState;
5279
5280 if (state.corked) {
5281 state.corked--;
5282
5283 if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
5284 }
5285};
5286
5287Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
5288 // node::ParseEncoding() requires lower case.
5289 if (typeof encoding === 'string') encoding = encoding.toLowerCase();
5290 if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
5291 this._writableState.defaultEncoding = encoding;
5292 return this;
5293};
5294
5295function decodeChunk(state, chunk, encoding) {
5296 if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
5297 chunk = Buffer.from(chunk, encoding);
5298 }
5299 return chunk;
5300}
5301
5302Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
5303 // making it explicit this property is not enumerable
5304 // because otherwise some prototype manipulation in
5305 // userland will fail
5306 enumerable: false,
5307 get: function () {
5308 return this._writableState.highWaterMark;
5309 }
5310});
5311
5312// if we're already writing something, then just put this
5313// in the queue, and wait our turn. Otherwise, call _write
5314// If we return false, then we need a drain event, so set that flag.
5315function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
5316 if (!isBuf) {
5317 var newChunk = decodeChunk(state, chunk, encoding);
5318 if (chunk !== newChunk) {
5319 isBuf = true;
5320 encoding = 'buffer';
5321 chunk = newChunk;
5322 }
5323 }
5324 var len = state.objectMode ? 1 : chunk.length;
5325
5326 state.length += len;
5327
5328 var ret = state.length < state.highWaterMark;
5329 // we must ensure that previous needDrain will not be reset to false.
5330 if (!ret) state.needDrain = true;
5331
5332 if (state.writing || state.corked) {
5333 var last = state.lastBufferedRequest;
5334 state.lastBufferedRequest = {
5335 chunk: chunk,
5336 encoding: encoding,
5337 isBuf: isBuf,
5338 callback: cb,
5339 next: null
5340 };
5341 if (last) {
5342 last.next = state.lastBufferedRequest;
5343 } else {
5344 state.bufferedRequest = state.lastBufferedRequest;
5345 }
5346 state.bufferedRequestCount += 1;
5347 } else {
5348 doWrite(stream, state, false, len, chunk, encoding, cb);
5349 }
5350
5351 return ret;
5352}
5353
5354function doWrite(stream, state, writev, len, chunk, encoding, cb) {
5355 state.writelen = len;
5356 state.writecb = cb;
5357 state.writing = true;
5358 state.sync = true;
5359 if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
5360 state.sync = false;
5361}
5362
5363function onwriteError(stream, state, sync, er, cb) {
5364 --state.pendingcb;
5365
5366 if (sync) {
5367 // defer the callback if we are being called synchronously
5368 // to avoid piling up things on the stack
5369 pna.nextTick(cb, er);
5370 // this can emit finish, and it will always happen
5371 // after error
5372 pna.nextTick(finishMaybe, stream, state);
5373 stream._writableState.errorEmitted = true;
5374 stream.emit('error', er);
5375 } else {
5376 // the caller expect this to happen before if
5377 // it is async
5378 cb(er);
5379 stream._writableState.errorEmitted = true;
5380 stream.emit('error', er);
5381 // this can emit finish, but finish must
5382 // always follow error
5383 finishMaybe(stream, state);
5384 }
5385}
5386
5387function onwriteStateUpdate(state) {
5388 state.writing = false;
5389 state.writecb = null;
5390 state.length -= state.writelen;
5391 state.writelen = 0;
5392}
5393
5394function onwrite(stream, er) {
5395 var state = stream._writableState;
5396 var sync = state.sync;
5397 var cb = state.writecb;
5398
5399 onwriteStateUpdate(state);
5400
5401 if (er) onwriteError(stream, state, sync, er, cb);else {
5402 // Check if we're actually ready to finish, but don't emit yet
5403 var finished = needFinish(state);
5404
5405 if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
5406 clearBuffer(stream, state);
5407 }
5408
5409 if (sync) {
5410 /*<replacement>*/
5411 asyncWrite(afterWrite, stream, state, finished, cb);
5412 /*</replacement>*/
5413 } else {
5414 afterWrite(stream, state, finished, cb);
5415 }
5416 }
5417}
5418
5419function afterWrite(stream, state, finished, cb) {
5420 if (!finished) onwriteDrain(stream, state);
5421 state.pendingcb--;
5422 cb();
5423 finishMaybe(stream, state);
5424}
5425
5426// Must force callback to be called on nextTick, so that we don't
5427// emit 'drain' before the write() consumer gets the 'false' return
5428// value, and has a chance to attach a 'drain' listener.
5429function onwriteDrain(stream, state) {
5430 if (state.length === 0 && state.needDrain) {
5431 state.needDrain = false;
5432 stream.emit('drain');
5433 }
5434}
5435
5436// if there's something in the buffer waiting, then process it
5437function clearBuffer(stream, state) {
5438 state.bufferProcessing = true;
5439 var entry = state.bufferedRequest;
5440
5441 if (stream._writev && entry && entry.next) {
5442 // Fast case, write everything using _writev()
5443 var l = state.bufferedRequestCount;
5444 var buffer = new Array(l);
5445 var holder = state.corkedRequestsFree;
5446 holder.entry = entry;
5447
5448 var count = 0;
5449 var allBuffers = true;
5450 while (entry) {
5451 buffer[count] = entry;
5452 if (!entry.isBuf) allBuffers = false;
5453 entry = entry.next;
5454 count += 1;
5455 }
5456 buffer.allBuffers = allBuffers;
5457
5458 doWrite(stream, state, true, state.length, buffer, '', holder.finish);
5459
5460 // doWrite is almost always async, defer these to save a bit of time
5461 // as the hot path ends with doWrite
5462 state.pendingcb++;
5463 state.lastBufferedRequest = null;
5464 if (holder.next) {
5465 state.corkedRequestsFree = holder.next;
5466 holder.next = null;
5467 } else {
5468 state.corkedRequestsFree = new CorkedRequest(state);
5469 }
5470 state.bufferedRequestCount = 0;
5471 } else {
5472 // Slow case, write chunks one-by-one
5473 while (entry) {
5474 var chunk = entry.chunk;
5475 var encoding = entry.encoding;
5476 var cb = entry.callback;
5477 var len = state.objectMode ? 1 : chunk.length;
5478
5479 doWrite(stream, state, false, len, chunk, encoding, cb);
5480 entry = entry.next;
5481 state.bufferedRequestCount--;
5482 // if we didn't call the onwrite immediately, then
5483 // it means that we need to wait until it does.
5484 // also, that means that the chunk and cb are currently
5485 // being processed, so move the buffer counter past them.
5486 if (state.writing) {
5487 break;
5488 }
5489 }
5490
5491 if (entry === null) state.lastBufferedRequest = null;
5492 }
5493
5494 state.bufferedRequest = entry;
5495 state.bufferProcessing = false;
5496}
5497
5498Writable.prototype._write = function (chunk, encoding, cb) {
5499 cb(new Error('_write() is not implemented'));
5500};
5501
5502Writable.prototype._writev = null;
5503
5504Writable.prototype.end = function (chunk, encoding, cb) {
5505 var state = this._writableState;
5506
5507 if (typeof chunk === 'function') {
5508 cb = chunk;
5509 chunk = null;
5510 encoding = null;
5511 } else if (typeof encoding === 'function') {
5512 cb = encoding;
5513 encoding = null;
5514 }
5515
5516 if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
5517
5518 // .end() fully uncorks
5519 if (state.corked) {
5520 state.corked = 1;
5521 this.uncork();
5522 }
5523
5524 // ignore unnecessary end() calls.
5525 if (!state.ending && !state.finished) endWritable(this, state, cb);
5526};
5527
5528function needFinish(state) {
5529 return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
5530}
5531function callFinal(stream, state) {
5532 stream._final(function (err) {
5533 state.pendingcb--;
5534 if (err) {
5535 stream.emit('error', err);
5536 }
5537 state.prefinished = true;
5538 stream.emit('prefinish');
5539 finishMaybe(stream, state);
5540 });
5541}
5542function prefinish(stream, state) {
5543 if (!state.prefinished && !state.finalCalled) {
5544 if (typeof stream._final === 'function') {
5545 state.pendingcb++;
5546 state.finalCalled = true;
5547 pna.nextTick(callFinal, stream, state);
5548 } else {
5549 state.prefinished = true;
5550 stream.emit('prefinish');
5551 }
5552 }
5553}
5554
5555function finishMaybe(stream, state) {
5556 var need = needFinish(state);
5557 if (need) {
5558 prefinish(stream, state);
5559 if (state.pendingcb === 0) {
5560 state.finished = true;
5561 stream.emit('finish');
5562 }
5563 }
5564 return need;
5565}
5566
5567function endWritable(stream, state, cb) {
5568 state.ending = true;
5569 finishMaybe(stream, state);
5570 if (cb) {
5571 if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
5572 }
5573 state.ended = true;
5574 stream.writable = false;
5575}
5576
5577function onCorkedFinish(corkReq, state, err) {
5578 var entry = corkReq.entry;
5579 corkReq.entry = null;
5580 while (entry) {
5581 var cb = entry.callback;
5582 state.pendingcb--;
5583 cb(err);
5584 entry = entry.next;
5585 }
5586 if (state.corkedRequestsFree) {
5587 state.corkedRequestsFree.next = corkReq;
5588 } else {
5589 state.corkedRequestsFree = corkReq;
5590 }
5591}
5592
5593Object.defineProperty(Writable.prototype, 'destroyed', {
5594 get: function () {
5595 if (this._writableState === undefined) {
5596 return false;
5597 }
5598 return this._writableState.destroyed;
5599 },
5600 set: function (value) {
5601 // we ignore the value if the stream
5602 // has not been initialized yet
5603 if (!this._writableState) {
5604 return;
5605 }
5606
5607 // backward compatibility, the user is explicitly
5608 // managing destroyed
5609 this._writableState.destroyed = value;
5610 }
5611});
5612
5613Writable.prototype.destroy = destroyImpl.destroy;
5614Writable.prototype._undestroy = destroyImpl.undestroy;
5615Writable.prototype._destroy = function (err, cb) {
5616 this.end();
5617 cb(err);
5618};
5619}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").setImmediate)
5620},{"./_stream_duplex":20,"./internal/streams/destroy":26,"./internal/streams/stream":27,"_process":18,"core-util-is":8,"inherits":13,"process-nextick-args":17,"safe-buffer":34,"timers":45,"util-deprecate":46}],25:[function(require,module,exports){
5621'use strict';
5622
5623function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5624
5625var Buffer = require('safe-buffer').Buffer;
5626var util = require('util');
5627
5628function copyBuffer(src, target, offset) {
5629 src.copy(target, offset);
5630}
5631
5632module.exports = function () {
5633 function BufferList() {
5634 _classCallCheck(this, BufferList);
5635
5636 this.head = null;
5637 this.tail = null;
5638 this.length = 0;
5639 }
5640
5641 BufferList.prototype.push = function push(v) {
5642 var entry = { data: v, next: null };
5643 if (this.length > 0) this.tail.next = entry;else this.head = entry;
5644 this.tail = entry;
5645 ++this.length;
5646 };
5647
5648 BufferList.prototype.unshift = function unshift(v) {
5649 var entry = { data: v, next: this.head };
5650 if (this.length === 0) this.tail = entry;
5651 this.head = entry;
5652 ++this.length;
5653 };
5654
5655 BufferList.prototype.shift = function shift() {
5656 if (this.length === 0) return;
5657 var ret = this.head.data;
5658 if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
5659 --this.length;
5660 return ret;
5661 };
5662
5663 BufferList.prototype.clear = function clear() {
5664 this.head = this.tail = null;
5665 this.length = 0;
5666 };
5667
5668 BufferList.prototype.join = function join(s) {
5669 if (this.length === 0) return '';
5670 var p = this.head;
5671 var ret = '' + p.data;
5672 while (p = p.next) {
5673 ret += s + p.data;
5674 }return ret;
5675 };
5676
5677 BufferList.prototype.concat = function concat(n) {
5678 if (this.length === 0) return Buffer.alloc(0);
5679 if (this.length === 1) return this.head.data;
5680 var ret = Buffer.allocUnsafe(n >>> 0);
5681 var p = this.head;
5682 var i = 0;
5683 while (p) {
5684 copyBuffer(p.data, ret, i);
5685 i += p.data.length;
5686 p = p.next;
5687 }
5688 return ret;
5689 };
5690
5691 return BufferList;
5692}();
5693
5694if (util && util.inspect && util.inspect.custom) {
5695 module.exports.prototype[util.inspect.custom] = function () {
5696 var obj = util.inspect({ length: this.length });
5697 return this.constructor.name + ' ' + obj;
5698 };
5699}
5700},{"safe-buffer":34,"util":4}],26:[function(require,module,exports){
5701'use strict';
5702
5703/*<replacement>*/
5704
5705var pna = require('process-nextick-args');
5706/*</replacement>*/
5707
5708// undocumented cb() API, needed for core, not for public API
5709function destroy(err, cb) {
5710 var _this = this;
5711
5712 var readableDestroyed = this._readableState && this._readableState.destroyed;
5713 var writableDestroyed = this._writableState && this._writableState.destroyed;
5714
5715 if (readableDestroyed || writableDestroyed) {
5716 if (cb) {
5717 cb(err);
5718 } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
5719 pna.nextTick(emitErrorNT, this, err);
5720 }
5721 return this;
5722 }
5723
5724 // we set destroyed to true before firing error callbacks in order
5725 // to make it re-entrance safe in case destroy() is called within callbacks
5726
5727 if (this._readableState) {
5728 this._readableState.destroyed = true;
5729 }
5730
5731 // if this is a duplex stream mark the writable part as destroyed as well
5732 if (this._writableState) {
5733 this._writableState.destroyed = true;
5734 }
5735
5736 this._destroy(err || null, function (err) {
5737 if (!cb && err) {
5738 pna.nextTick(emitErrorNT, _this, err);
5739 if (_this._writableState) {
5740 _this._writableState.errorEmitted = true;
5741 }
5742 } else if (cb) {
5743 cb(err);
5744 }
5745 });
5746
5747 return this;
5748}
5749
5750function undestroy() {
5751 if (this._readableState) {
5752 this._readableState.destroyed = false;
5753 this._readableState.reading = false;
5754 this._readableState.ended = false;
5755 this._readableState.endEmitted = false;
5756 }
5757
5758 if (this._writableState) {
5759 this._writableState.destroyed = false;
5760 this._writableState.ended = false;
5761 this._writableState.ending = false;
5762 this._writableState.finished = false;
5763 this._writableState.errorEmitted = false;
5764 }
5765}
5766
5767function emitErrorNT(self, err) {
5768 self.emit('error', err);
5769}
5770
5771module.exports = {
5772 destroy: destroy,
5773 undestroy: undestroy
5774};
5775},{"process-nextick-args":17}],27:[function(require,module,exports){
5776module.exports = require('events').EventEmitter;
5777
5778},{"events":10}],28:[function(require,module,exports){
5779// Copyright Joyent, Inc. and other Node contributors.
5780//
5781// Permission is hereby granted, free of charge, to any person obtaining a
5782// copy of this software and associated documentation files (the
5783// "Software"), to deal in the Software without restriction, including
5784// without limitation the rights to use, copy, modify, merge, publish,
5785// distribute, sublicense, and/or sell copies of the Software, and to permit
5786// persons to whom the Software is furnished to do so, subject to the
5787// following conditions:
5788//
5789// The above copyright notice and this permission notice shall be included
5790// in all copies or substantial portions of the Software.
5791//
5792// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
5793// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
5794// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
5795// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
5796// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
5797// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
5798// USE OR OTHER DEALINGS IN THE SOFTWARE.
5799
5800'use strict';
5801
5802/*<replacement>*/
5803
5804var Buffer = require('safe-buffer').Buffer;
5805/*</replacement>*/
5806
5807var isEncoding = Buffer.isEncoding || function (encoding) {
5808 encoding = '' + encoding;
5809 switch (encoding && encoding.toLowerCase()) {
5810 case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':
5811 return true;
5812 default:
5813 return false;
5814 }
5815};
5816
5817function _normalizeEncoding(enc) {
5818 if (!enc) return 'utf8';
5819 var retried;
5820 while (true) {
5821 switch (enc) {
5822 case 'utf8':
5823 case 'utf-8':
5824 return 'utf8';
5825 case 'ucs2':
5826 case 'ucs-2':
5827 case 'utf16le':
5828 case 'utf-16le':
5829 return 'utf16le';
5830 case 'latin1':
5831 case 'binary':
5832 return 'latin1';
5833 case 'base64':
5834 case 'ascii':
5835 case 'hex':
5836 return enc;
5837 default:
5838 if (retried) return; // undefined
5839 enc = ('' + enc).toLowerCase();
5840 retried = true;
5841 }
5842 }
5843};
5844
5845// Do not cache `Buffer.isEncoding` when checking encoding names as some
5846// modules monkey-patch it to support additional encodings
5847function normalizeEncoding(enc) {
5848 var nenc = _normalizeEncoding(enc);
5849 if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
5850 return nenc || enc;
5851}
5852
5853// StringDecoder provides an interface for efficiently splitting a series of
5854// buffers into a series of JS strings without breaking apart multi-byte
5855// characters.
5856exports.StringDecoder = StringDecoder;
5857function StringDecoder(encoding) {
5858 this.encoding = normalizeEncoding(encoding);
5859 var nb;
5860 switch (this.encoding) {
5861 case 'utf16le':
5862 this.text = utf16Text;
5863 this.end = utf16End;
5864 nb = 4;
5865 break;
5866 case 'utf8':
5867 this.fillLast = utf8FillLast;
5868 nb = 4;
5869 break;
5870 case 'base64':
5871 this.text = base64Text;
5872 this.end = base64End;
5873 nb = 3;
5874 break;
5875 default:
5876 this.write = simpleWrite;
5877 this.end = simpleEnd;
5878 return;
5879 }
5880 this.lastNeed = 0;
5881 this.lastTotal = 0;
5882 this.lastChar = Buffer.allocUnsafe(nb);
5883}
5884
5885StringDecoder.prototype.write = function (buf) {
5886 if (buf.length === 0) return '';
5887 var r;
5888 var i;
5889 if (this.lastNeed) {
5890 r = this.fillLast(buf);
5891 if (r === undefined) return '';
5892 i = this.lastNeed;
5893 this.lastNeed = 0;
5894 } else {
5895 i = 0;
5896 }
5897 if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
5898 return r || '';
5899};
5900
5901StringDecoder.prototype.end = utf8End;
5902
5903// Returns only complete characters in a Buffer
5904StringDecoder.prototype.text = utf8Text;
5905
5906// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
5907StringDecoder.prototype.fillLast = function (buf) {
5908 if (this.lastNeed <= buf.length) {
5909 buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
5910 return this.lastChar.toString(this.encoding, 0, this.lastTotal);
5911 }
5912 buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
5913 this.lastNeed -= buf.length;
5914};
5915
5916// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
5917// continuation byte. If an invalid byte is detected, -2 is returned.
5918function utf8CheckByte(byte) {
5919 if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
5920 return byte >> 6 === 0x02 ? -1 : -2;
5921}
5922
5923// Checks at most 3 bytes at the end of a Buffer in order to detect an
5924// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
5925// needed to complete the UTF-8 character (if applicable) are returned.
5926function utf8CheckIncomplete(self, buf, i) {
5927 var j = buf.length - 1;
5928 if (j < i) return 0;
5929 var nb = utf8CheckByte(buf[j]);
5930 if (nb >= 0) {
5931 if (nb > 0) self.lastNeed = nb - 1;
5932 return nb;
5933 }
5934 if (--j < i || nb === -2) return 0;
5935 nb = utf8CheckByte(buf[j]);
5936 if (nb >= 0) {
5937 if (nb > 0) self.lastNeed = nb - 2;
5938 return nb;
5939 }
5940 if (--j < i || nb === -2) return 0;
5941 nb = utf8CheckByte(buf[j]);
5942 if (nb >= 0) {
5943 if (nb > 0) {
5944 if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
5945 }
5946 return nb;
5947 }
5948 return 0;
5949}
5950
5951// Validates as many continuation bytes for a multi-byte UTF-8 character as
5952// needed or are available. If we see a non-continuation byte where we expect
5953// one, we "replace" the validated continuation bytes we've seen so far with
5954// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
5955// behavior. The continuation byte check is included three times in the case
5956// where all of the continuation bytes for a character exist in the same buffer.
5957// It is also done this way as a slight performance increase instead of using a
5958// loop.
5959function utf8CheckExtraBytes(self, buf, p) {
5960 if ((buf[0] & 0xC0) !== 0x80) {
5961 self.lastNeed = 0;
5962 return '\ufffd';
5963 }
5964 if (self.lastNeed > 1 && buf.length > 1) {
5965 if ((buf[1] & 0xC0) !== 0x80) {
5966 self.lastNeed = 1;
5967 return '\ufffd';
5968 }
5969 if (self.lastNeed > 2 && buf.length > 2) {
5970 if ((buf[2] & 0xC0) !== 0x80) {
5971 self.lastNeed = 2;
5972 return '\ufffd';
5973 }
5974 }
5975 }
5976}
5977
5978// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
5979function utf8FillLast(buf) {
5980 var p = this.lastTotal - this.lastNeed;
5981 var r = utf8CheckExtraBytes(this, buf, p);
5982 if (r !== undefined) return r;
5983 if (this.lastNeed <= buf.length) {
5984 buf.copy(this.lastChar, p, 0, this.lastNeed);
5985 return this.lastChar.toString(this.encoding, 0, this.lastTotal);
5986 }
5987 buf.copy(this.lastChar, p, 0, buf.length);
5988 this.lastNeed -= buf.length;
5989}
5990
5991// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
5992// partial character, the character's bytes are buffered until the required
5993// number of bytes are available.
5994function utf8Text(buf, i) {
5995 var total = utf8CheckIncomplete(this, buf, i);
5996 if (!this.lastNeed) return buf.toString('utf8', i);
5997 this.lastTotal = total;
5998 var end = buf.length - (total - this.lastNeed);
5999 buf.copy(this.lastChar, 0, end);
6000 return buf.toString('utf8', i, end);
6001}
6002
6003// For UTF-8, a replacement character is added when ending on a partial
6004// character.
6005function utf8End(buf) {
6006 var r = buf && buf.length ? this.write(buf) : '';
6007 if (this.lastNeed) return r + '\ufffd';
6008 return r;
6009}
6010
6011// UTF-16LE typically needs two bytes per character, but even if we have an even
6012// number of bytes available, we need to check if we end on a leading/high
6013// surrogate. In that case, we need to wait for the next two bytes in order to
6014// decode the last character properly.
6015function utf16Text(buf, i) {
6016 if ((buf.length - i) % 2 === 0) {
6017 var r = buf.toString('utf16le', i);
6018 if (r) {
6019 var c = r.charCodeAt(r.length - 1);
6020 if (c >= 0xD800 && c <= 0xDBFF) {
6021 this.lastNeed = 2;
6022 this.lastTotal = 4;
6023 this.lastChar[0] = buf[buf.length - 2];
6024 this.lastChar[1] = buf[buf.length - 1];
6025 return r.slice(0, -1);
6026 }
6027 }
6028 return r;
6029 }
6030 this.lastNeed = 1;
6031 this.lastTotal = 2;
6032 this.lastChar[0] = buf[buf.length - 1];
6033 return buf.toString('utf16le', i, buf.length - 1);
6034}
6035
6036// For UTF-16LE we do not explicitly append special replacement characters if we
6037// end on a partial character, we simply let v8 handle that.
6038function utf16End(buf) {
6039 var r = buf && buf.length ? this.write(buf) : '';
6040 if (this.lastNeed) {
6041 var end = this.lastTotal - this.lastNeed;
6042 return r + this.lastChar.toString('utf16le', 0, end);
6043 }
6044 return r;
6045}
6046
6047function base64Text(buf, i) {
6048 var n = (buf.length - i) % 3;
6049 if (n === 0) return buf.toString('base64', i);
6050 this.lastNeed = 3 - n;
6051 this.lastTotal = 3;
6052 if (n === 1) {
6053 this.lastChar[0] = buf[buf.length - 1];
6054 } else {
6055 this.lastChar[0] = buf[buf.length - 2];
6056 this.lastChar[1] = buf[buf.length - 1];
6057 }
6058 return buf.toString('base64', i, buf.length - n);
6059}
6060
6061function base64End(buf) {
6062 var r = buf && buf.length ? this.write(buf) : '';
6063 if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
6064 return r;
6065}
6066
6067// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
6068function simpleWrite(buf) {
6069 return buf.toString(this.encoding);
6070}
6071
6072function simpleEnd(buf) {
6073 return buf && buf.length ? this.write(buf) : '';
6074}
6075},{"safe-buffer":34}],29:[function(require,module,exports){
6076module.exports = require('./readable').PassThrough
6077
6078},{"./readable":30}],30:[function(require,module,exports){
6079exports = module.exports = require('./lib/_stream_readable.js');
6080exports.Stream = exports;
6081exports.Readable = exports;
6082exports.Writable = require('./lib/_stream_writable.js');
6083exports.Duplex = require('./lib/_stream_duplex.js');
6084exports.Transform = require('./lib/_stream_transform.js');
6085exports.PassThrough = require('./lib/_stream_passthrough.js');
6086
6087},{"./lib/_stream_duplex.js":20,"./lib/_stream_passthrough.js":21,"./lib/_stream_readable.js":22,"./lib/_stream_transform.js":23,"./lib/_stream_writable.js":24}],31:[function(require,module,exports){
6088module.exports = require('./readable').Transform
6089
6090},{"./readable":30}],32:[function(require,module,exports){
6091module.exports = require('./lib/_stream_writable.js');
6092
6093},{"./lib/_stream_writable.js":24}],33:[function(require,module,exports){
6094'use strict'
6095var Buffer = require('buffer').Buffer
6096var inherits = require('inherits')
6097var HashBase = require('hash-base')
6098
6099var ARRAY16 = new Array(16)
6100
6101var zl = [
6102 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
6103 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
6104 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
6105 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
6106 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
6107]
6108
6109var zr = [
6110 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
6111 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
6112 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
6113 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
6114 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
6115]
6116
6117var sl = [
6118 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
6119 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
6120 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
6121 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
6122 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
6123]
6124
6125var sr = [
6126 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
6127 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
6128 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
6129 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
6130 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
6131]
6132
6133var hl = [0x00000000, 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xa953fd4e]
6134var hr = [0x50a28be6, 0x5c4dd124, 0x6d703ef3, 0x7a6d76e9, 0x00000000]
6135
6136function RIPEMD160 () {
6137 HashBase.call(this, 64)
6138
6139 // state
6140 this._a = 0x67452301
6141 this._b = 0xefcdab89
6142 this._c = 0x98badcfe
6143 this._d = 0x10325476
6144 this._e = 0xc3d2e1f0
6145}
6146
6147inherits(RIPEMD160, HashBase)
6148
6149RIPEMD160.prototype._update = function () {
6150 var words = ARRAY16
6151 for (var j = 0; j < 16; ++j) words[j] = this._block.readInt32LE(j * 4)
6152
6153 var al = this._a | 0
6154 var bl = this._b | 0
6155 var cl = this._c | 0
6156 var dl = this._d | 0
6157 var el = this._e | 0
6158
6159 var ar = this._a | 0
6160 var br = this._b | 0
6161 var cr = this._c | 0
6162 var dr = this._d | 0
6163 var er = this._e | 0
6164
6165 // computation
6166 for (var i = 0; i < 80; i += 1) {
6167 var tl
6168 var tr
6169 if (i < 16) {
6170 tl = fn1(al, bl, cl, dl, el, words[zl[i]], hl[0], sl[i])
6171 tr = fn5(ar, br, cr, dr, er, words[zr[i]], hr[0], sr[i])
6172 } else if (i < 32) {
6173 tl = fn2(al, bl, cl, dl, el, words[zl[i]], hl[1], sl[i])
6174 tr = fn4(ar, br, cr, dr, er, words[zr[i]], hr[1], sr[i])
6175 } else if (i < 48) {
6176 tl = fn3(al, bl, cl, dl, el, words[zl[i]], hl[2], sl[i])
6177 tr = fn3(ar, br, cr, dr, er, words[zr[i]], hr[2], sr[i])
6178 } else if (i < 64) {
6179 tl = fn4(al, bl, cl, dl, el, words[zl[i]], hl[3], sl[i])
6180 tr = fn2(ar, br, cr, dr, er, words[zr[i]], hr[3], sr[i])
6181 } else { // if (i<80) {
6182 tl = fn5(al, bl, cl, dl, el, words[zl[i]], hl[4], sl[i])
6183 tr = fn1(ar, br, cr, dr, er, words[zr[i]], hr[4], sr[i])
6184 }
6185
6186 al = el
6187 el = dl
6188 dl = rotl(cl, 10)
6189 cl = bl
6190 bl = tl
6191
6192 ar = er
6193 er = dr
6194 dr = rotl(cr, 10)
6195 cr = br
6196 br = tr
6197 }
6198
6199 // update state
6200 var t = (this._b + cl + dr) | 0
6201 this._b = (this._c + dl + er) | 0
6202 this._c = (this._d + el + ar) | 0
6203 this._d = (this._e + al + br) | 0
6204 this._e = (this._a + bl + cr) | 0
6205 this._a = t
6206}
6207
6208RIPEMD160.prototype._digest = function () {
6209 // create padding and handle blocks
6210 this._block[this._blockOffset++] = 0x80
6211 if (this._blockOffset > 56) {
6212 this._block.fill(0, this._blockOffset, 64)
6213 this._update()
6214 this._blockOffset = 0
6215 }
6216
6217 this._block.fill(0, this._blockOffset, 56)
6218 this._block.writeUInt32LE(this._length[0], 56)
6219 this._block.writeUInt32LE(this._length[1], 60)
6220 this._update()
6221
6222 // produce result
6223 var buffer = Buffer.alloc ? Buffer.alloc(20) : new Buffer(20)
6224 buffer.writeInt32LE(this._a, 0)
6225 buffer.writeInt32LE(this._b, 4)
6226 buffer.writeInt32LE(this._c, 8)
6227 buffer.writeInt32LE(this._d, 12)
6228 buffer.writeInt32LE(this._e, 16)
6229 return buffer
6230}
6231
6232function rotl (x, n) {
6233 return (x << n) | (x >>> (32 - n))
6234}
6235
6236function fn1 (a, b, c, d, e, m, k, s) {
6237 return (rotl((a + (b ^ c ^ d) + m + k) | 0, s) + e) | 0
6238}
6239
6240function fn2 (a, b, c, d, e, m, k, s) {
6241 return (rotl((a + ((b & c) | ((~b) & d)) + m + k) | 0, s) + e) | 0
6242}
6243
6244function fn3 (a, b, c, d, e, m, k, s) {
6245 return (rotl((a + ((b | (~c)) ^ d) + m + k) | 0, s) + e) | 0
6246}
6247
6248function fn4 (a, b, c, d, e, m, k, s) {
6249 return (rotl((a + ((b & d) | (c & (~d))) + m + k) | 0, s) + e) | 0
6250}
6251
6252function fn5 (a, b, c, d, e, m, k, s) {
6253 return (rotl((a + (b ^ (c | (~d))) + m + k) | 0, s) + e) | 0
6254}
6255
6256module.exports = RIPEMD160
6257
6258},{"buffer":6,"hash-base":11,"inherits":13}],34:[function(require,module,exports){
6259/* eslint-disable node/no-deprecated-api */
6260var buffer = require('buffer')
6261var Buffer = buffer.Buffer
6262
6263// alternative to using Object.keys for old browsers
6264function copyProps (src, dst) {
6265 for (var key in src) {
6266 dst[key] = src[key]
6267 }
6268}
6269if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
6270 module.exports = buffer
6271} else {
6272 // Copy properties from require('buffer')
6273 copyProps(buffer, exports)
6274 exports.Buffer = SafeBuffer
6275}
6276
6277function SafeBuffer (arg, encodingOrOffset, length) {
6278 return Buffer(arg, encodingOrOffset, length)
6279}
6280
6281// Copy static methods from Buffer
6282copyProps(Buffer, SafeBuffer)
6283
6284SafeBuffer.from = function (arg, encodingOrOffset, length) {
6285 if (typeof arg === 'number') {
6286 throw new TypeError('Argument must not be a number')
6287 }
6288 return Buffer(arg, encodingOrOffset, length)
6289}
6290
6291SafeBuffer.alloc = function (size, fill, encoding) {
6292 if (typeof size !== 'number') {
6293 throw new TypeError('Argument must be a number')
6294 }
6295 var buf = Buffer(size)
6296 if (fill !== undefined) {
6297 if (typeof encoding === 'string') {
6298 buf.fill(fill, encoding)
6299 } else {
6300 buf.fill(fill)
6301 }
6302 } else {
6303 buf.fill(0)
6304 }
6305 return buf
6306}
6307
6308SafeBuffer.allocUnsafe = function (size) {
6309 if (typeof size !== 'number') {
6310 throw new TypeError('Argument must be a number')
6311 }
6312 return Buffer(size)
6313}
6314
6315SafeBuffer.allocUnsafeSlow = function (size) {
6316 if (typeof size !== 'number') {
6317 throw new TypeError('Argument must be a number')
6318 }
6319 return buffer.SlowBuffer(size)
6320}
6321
6322},{"buffer":6}],35:[function(require,module,exports){
6323var Buffer = require('safe-buffer').Buffer
6324
6325// prototype class for hash functions
6326function Hash (blockSize, finalSize) {
6327 this._block = Buffer.alloc(blockSize)
6328 this._finalSize = finalSize
6329 this._blockSize = blockSize
6330 this._len = 0
6331}
6332
6333Hash.prototype.update = function (data, enc) {
6334 if (typeof data === 'string') {
6335 enc = enc || 'utf8'
6336 data = Buffer.from(data, enc)
6337 }
6338
6339 var block = this._block
6340 var blockSize = this._blockSize
6341 var length = data.length
6342 var accum = this._len
6343
6344 for (var offset = 0; offset < length;) {
6345 var assigned = accum % blockSize
6346 var remainder = Math.min(length - offset, blockSize - assigned)
6347
6348 for (var i = 0; i < remainder; i++) {
6349 block[assigned + i] = data[offset + i]
6350 }
6351
6352 accum += remainder
6353 offset += remainder
6354
6355 if ((accum % blockSize) === 0) {
6356 this._update(block)
6357 }
6358 }
6359
6360 this._len += length
6361 return this
6362}
6363
6364Hash.prototype.digest = function (enc) {
6365 var rem = this._len % this._blockSize
6366
6367 this._block[rem] = 0x80
6368
6369 // zero (rem + 1) trailing bits, where (rem + 1) is the smallest
6370 // non-negative solution to the equation (length + 1 + (rem + 1)) === finalSize mod blockSize
6371 this._block.fill(0, rem + 1)
6372
6373 if (rem >= this._finalSize) {
6374 this._update(this._block)
6375 this._block.fill(0)
6376 }
6377
6378 var bits = this._len * 8
6379
6380 // uint32
6381 if (bits <= 0xffffffff) {
6382 this._block.writeUInt32BE(bits, this._blockSize - 4)
6383
6384 // uint64
6385 } else {
6386 var lowBits = (bits & 0xffffffff) >>> 0
6387 var highBits = (bits - lowBits) / 0x100000000
6388
6389 this._block.writeUInt32BE(highBits, this._blockSize - 8)
6390 this._block.writeUInt32BE(lowBits, this._blockSize - 4)
6391 }
6392
6393 this._update(this._block)
6394 var hash = this._hash()
6395
6396 return enc ? hash.toString(enc) : hash
6397}
6398
6399Hash.prototype._update = function () {
6400 throw new Error('_update must be implemented by subclass')
6401}
6402
6403module.exports = Hash
6404
6405},{"safe-buffer":34}],36:[function(require,module,exports){
6406var exports = module.exports = function SHA (algorithm) {
6407 algorithm = algorithm.toLowerCase()
6408
6409 var Algorithm = exports[algorithm]
6410 if (!Algorithm) throw new Error(algorithm + ' is not supported (we accept pull requests)')
6411
6412 return new Algorithm()
6413}
6414
6415exports.sha = require('./sha')
6416exports.sha1 = require('./sha1')
6417exports.sha224 = require('./sha224')
6418exports.sha256 = require('./sha256')
6419exports.sha384 = require('./sha384')
6420exports.sha512 = require('./sha512')
6421
6422},{"./sha":37,"./sha1":38,"./sha224":39,"./sha256":40,"./sha384":41,"./sha512":42}],37:[function(require,module,exports){
6423/*
6424 * A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined
6425 * in FIPS PUB 180-1
6426 * This source code is derived from sha1.js of the same repository.
6427 * The difference between SHA-0 and SHA-1 is just a bitwise rotate left
6428 * operation was added.
6429 */
6430
6431var inherits = require('inherits')
6432var Hash = require('./hash')
6433var Buffer = require('safe-buffer').Buffer
6434
6435var K = [
6436 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
6437]
6438
6439var W = new Array(80)
6440
6441function Sha () {
6442 this.init()
6443 this._w = W
6444
6445 Hash.call(this, 64, 56)
6446}
6447
6448inherits(Sha, Hash)
6449
6450Sha.prototype.init = function () {
6451 this._a = 0x67452301
6452 this._b = 0xefcdab89
6453 this._c = 0x98badcfe
6454 this._d = 0x10325476
6455 this._e = 0xc3d2e1f0
6456
6457 return this
6458}
6459
6460function rotl5 (num) {
6461 return (num << 5) | (num >>> 27)
6462}
6463
6464function rotl30 (num) {
6465 return (num << 30) | (num >>> 2)
6466}
6467
6468function ft (s, b, c, d) {
6469 if (s === 0) return (b & c) | ((~b) & d)
6470 if (s === 2) return (b & c) | (b & d) | (c & d)
6471 return b ^ c ^ d
6472}
6473
6474Sha.prototype._update = function (M) {
6475 var W = this._w
6476
6477 var a = this._a | 0
6478 var b = this._b | 0
6479 var c = this._c | 0
6480 var d = this._d | 0
6481 var e = this._e | 0
6482
6483 for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
6484 for (; i < 80; ++i) W[i] = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]
6485
6486 for (var j = 0; j < 80; ++j) {
6487 var s = ~~(j / 20)
6488 var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0
6489
6490 e = d
6491 d = c
6492 c = rotl30(b)
6493 b = a
6494 a = t
6495 }
6496
6497 this._a = (a + this._a) | 0
6498 this._b = (b + this._b) | 0
6499 this._c = (c + this._c) | 0
6500 this._d = (d + this._d) | 0
6501 this._e = (e + this._e) | 0
6502}
6503
6504Sha.prototype._hash = function () {
6505 var H = Buffer.allocUnsafe(20)
6506
6507 H.writeInt32BE(this._a | 0, 0)
6508 H.writeInt32BE(this._b | 0, 4)
6509 H.writeInt32BE(this._c | 0, 8)
6510 H.writeInt32BE(this._d | 0, 12)
6511 H.writeInt32BE(this._e | 0, 16)
6512
6513 return H
6514}
6515
6516module.exports = Sha
6517
6518},{"./hash":35,"inherits":13,"safe-buffer":34}],38:[function(require,module,exports){
6519/*
6520 * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
6521 * in FIPS PUB 180-1
6522 * Version 2.1a Copyright Paul Johnston 2000 - 2002.
6523 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
6524 * Distributed under the BSD License
6525 * See http://pajhome.org.uk/crypt/md5 for details.
6526 */
6527
6528var inherits = require('inherits')
6529var Hash = require('./hash')
6530var Buffer = require('safe-buffer').Buffer
6531
6532var K = [
6533 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
6534]
6535
6536var W = new Array(80)
6537
6538function Sha1 () {
6539 this.init()
6540 this._w = W
6541
6542 Hash.call(this, 64, 56)
6543}
6544
6545inherits(Sha1, Hash)
6546
6547Sha1.prototype.init = function () {
6548 this._a = 0x67452301
6549 this._b = 0xefcdab89
6550 this._c = 0x98badcfe
6551 this._d = 0x10325476
6552 this._e = 0xc3d2e1f0
6553
6554 return this
6555}
6556
6557function rotl1 (num) {
6558 return (num << 1) | (num >>> 31)
6559}
6560
6561function rotl5 (num) {
6562 return (num << 5) | (num >>> 27)
6563}
6564
6565function rotl30 (num) {
6566 return (num << 30) | (num >>> 2)
6567}
6568
6569function ft (s, b, c, d) {
6570 if (s === 0) return (b & c) | ((~b) & d)
6571 if (s === 2) return (b & c) | (b & d) | (c & d)
6572 return b ^ c ^ d
6573}
6574
6575Sha1.prototype._update = function (M) {
6576 var W = this._w
6577
6578 var a = this._a | 0
6579 var b = this._b | 0
6580 var c = this._c | 0
6581 var d = this._d | 0
6582 var e = this._e | 0
6583
6584 for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
6585 for (; i < 80; ++i) W[i] = rotl1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16])
6586
6587 for (var j = 0; j < 80; ++j) {
6588 var s = ~~(j / 20)
6589 var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0
6590
6591 e = d
6592 d = c
6593 c = rotl30(b)
6594 b = a
6595 a = t
6596 }
6597
6598 this._a = (a + this._a) | 0
6599 this._b = (b + this._b) | 0
6600 this._c = (c + this._c) | 0
6601 this._d = (d + this._d) | 0
6602 this._e = (e + this._e) | 0
6603}
6604
6605Sha1.prototype._hash = function () {
6606 var H = Buffer.allocUnsafe(20)
6607
6608 H.writeInt32BE(this._a | 0, 0)
6609 H.writeInt32BE(this._b | 0, 4)
6610 H.writeInt32BE(this._c | 0, 8)
6611 H.writeInt32BE(this._d | 0, 12)
6612 H.writeInt32BE(this._e | 0, 16)
6613
6614 return H
6615}
6616
6617module.exports = Sha1
6618
6619},{"./hash":35,"inherits":13,"safe-buffer":34}],39:[function(require,module,exports){
6620/**
6621 * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
6622 * in FIPS 180-2
6623 * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
6624 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
6625 *
6626 */
6627
6628var inherits = require('inherits')
6629var Sha256 = require('./sha256')
6630var Hash = require('./hash')
6631var Buffer = require('safe-buffer').Buffer
6632
6633var W = new Array(64)
6634
6635function Sha224 () {
6636 this.init()
6637
6638 this._w = W // new Array(64)
6639
6640 Hash.call(this, 64, 56)
6641}
6642
6643inherits(Sha224, Sha256)
6644
6645Sha224.prototype.init = function () {
6646 this._a = 0xc1059ed8
6647 this._b = 0x367cd507
6648 this._c = 0x3070dd17
6649 this._d = 0xf70e5939
6650 this._e = 0xffc00b31
6651 this._f = 0x68581511
6652 this._g = 0x64f98fa7
6653 this._h = 0xbefa4fa4
6654
6655 return this
6656}
6657
6658Sha224.prototype._hash = function () {
6659 var H = Buffer.allocUnsafe(28)
6660
6661 H.writeInt32BE(this._a, 0)
6662 H.writeInt32BE(this._b, 4)
6663 H.writeInt32BE(this._c, 8)
6664 H.writeInt32BE(this._d, 12)
6665 H.writeInt32BE(this._e, 16)
6666 H.writeInt32BE(this._f, 20)
6667 H.writeInt32BE(this._g, 24)
6668
6669 return H
6670}
6671
6672module.exports = Sha224
6673
6674},{"./hash":35,"./sha256":40,"inherits":13,"safe-buffer":34}],40:[function(require,module,exports){
6675/**
6676 * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
6677 * in FIPS 180-2
6678 * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
6679 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
6680 *
6681 */
6682
6683var inherits = require('inherits')
6684var Hash = require('./hash')
6685var Buffer = require('safe-buffer').Buffer
6686
6687var K = [
6688 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,
6689 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,
6690 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,
6691 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174,
6692 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC,
6693 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,
6694 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7,
6695 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967,
6696 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,
6697 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85,
6698 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3,
6699 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,
6700 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5,
6701 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3,
6702 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,
6703 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2
6704]
6705
6706var W = new Array(64)
6707
6708function Sha256 () {
6709 this.init()
6710
6711 this._w = W // new Array(64)
6712
6713 Hash.call(this, 64, 56)
6714}
6715
6716inherits(Sha256, Hash)
6717
6718Sha256.prototype.init = function () {
6719 this._a = 0x6a09e667
6720 this._b = 0xbb67ae85
6721 this._c = 0x3c6ef372
6722 this._d = 0xa54ff53a
6723 this._e = 0x510e527f
6724 this._f = 0x9b05688c
6725 this._g = 0x1f83d9ab
6726 this._h = 0x5be0cd19
6727
6728 return this
6729}
6730
6731function ch (x, y, z) {
6732 return z ^ (x & (y ^ z))
6733}
6734
6735function maj (x, y, z) {
6736 return (x & y) | (z & (x | y))
6737}
6738
6739function sigma0 (x) {
6740 return (x >>> 2 | x << 30) ^ (x >>> 13 | x << 19) ^ (x >>> 22 | x << 10)
6741}
6742
6743function sigma1 (x) {
6744 return (x >>> 6 | x << 26) ^ (x >>> 11 | x << 21) ^ (x >>> 25 | x << 7)
6745}
6746
6747function gamma0 (x) {
6748 return (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ (x >>> 3)
6749}
6750
6751function gamma1 (x) {
6752 return (x >>> 17 | x << 15) ^ (x >>> 19 | x << 13) ^ (x >>> 10)
6753}
6754
6755Sha256.prototype._update = function (M) {
6756 var W = this._w
6757
6758 var a = this._a | 0
6759 var b = this._b | 0
6760 var c = this._c | 0
6761 var d = this._d | 0
6762 var e = this._e | 0
6763 var f = this._f | 0
6764 var g = this._g | 0
6765 var h = this._h | 0
6766
6767 for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
6768 for (; i < 64; ++i) W[i] = (gamma1(W[i - 2]) + W[i - 7] + gamma0(W[i - 15]) + W[i - 16]) | 0
6769
6770 for (var j = 0; j < 64; ++j) {
6771 var T1 = (h + sigma1(e) + ch(e, f, g) + K[j] + W[j]) | 0
6772 var T2 = (sigma0(a) + maj(a, b, c)) | 0
6773
6774 h = g
6775 g = f
6776 f = e
6777 e = (d + T1) | 0
6778 d = c
6779 c = b
6780 b = a
6781 a = (T1 + T2) | 0
6782 }
6783
6784 this._a = (a + this._a) | 0
6785 this._b = (b + this._b) | 0
6786 this._c = (c + this._c) | 0
6787 this._d = (d + this._d) | 0
6788 this._e = (e + this._e) | 0
6789 this._f = (f + this._f) | 0
6790 this._g = (g + this._g) | 0
6791 this._h = (h + this._h) | 0
6792}
6793
6794Sha256.prototype._hash = function () {
6795 var H = Buffer.allocUnsafe(32)
6796
6797 H.writeInt32BE(this._a, 0)
6798 H.writeInt32BE(this._b, 4)
6799 H.writeInt32BE(this._c, 8)
6800 H.writeInt32BE(this._d, 12)
6801 H.writeInt32BE(this._e, 16)
6802 H.writeInt32BE(this._f, 20)
6803 H.writeInt32BE(this._g, 24)
6804 H.writeInt32BE(this._h, 28)
6805
6806 return H
6807}
6808
6809module.exports = Sha256
6810
6811},{"./hash":35,"inherits":13,"safe-buffer":34}],41:[function(require,module,exports){
6812var inherits = require('inherits')
6813var SHA512 = require('./sha512')
6814var Hash = require('./hash')
6815var Buffer = require('safe-buffer').Buffer
6816
6817var W = new Array(160)
6818
6819function Sha384 () {
6820 this.init()
6821 this._w = W
6822
6823 Hash.call(this, 128, 112)
6824}
6825
6826inherits(Sha384, SHA512)
6827
6828Sha384.prototype.init = function () {
6829 this._ah = 0xcbbb9d5d
6830 this._bh = 0x629a292a
6831 this._ch = 0x9159015a
6832 this._dh = 0x152fecd8
6833 this._eh = 0x67332667
6834 this._fh = 0x8eb44a87
6835 this._gh = 0xdb0c2e0d
6836 this._hh = 0x47b5481d
6837
6838 this._al = 0xc1059ed8
6839 this._bl = 0x367cd507
6840 this._cl = 0x3070dd17
6841 this._dl = 0xf70e5939
6842 this._el = 0xffc00b31
6843 this._fl = 0x68581511
6844 this._gl = 0x64f98fa7
6845 this._hl = 0xbefa4fa4
6846
6847 return this
6848}
6849
6850Sha384.prototype._hash = function () {
6851 var H = Buffer.allocUnsafe(48)
6852
6853 function writeInt64BE (h, l, offset) {
6854 H.writeInt32BE(h, offset)
6855 H.writeInt32BE(l, offset + 4)
6856 }
6857
6858 writeInt64BE(this._ah, this._al, 0)
6859 writeInt64BE(this._bh, this._bl, 8)
6860 writeInt64BE(this._ch, this._cl, 16)
6861 writeInt64BE(this._dh, this._dl, 24)
6862 writeInt64BE(this._eh, this._el, 32)
6863 writeInt64BE(this._fh, this._fl, 40)
6864
6865 return H
6866}
6867
6868module.exports = Sha384
6869
6870},{"./hash":35,"./sha512":42,"inherits":13,"safe-buffer":34}],42:[function(require,module,exports){
6871var inherits = require('inherits')
6872var Hash = require('./hash')
6873var Buffer = require('safe-buffer').Buffer
6874
6875var K = [
6876 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
6877 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
6878 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
6879 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
6880 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
6881 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
6882 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
6883 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
6884 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
6885 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
6886 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
6887 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
6888 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
6889 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
6890 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
6891 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
6892 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
6893 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
6894 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
6895 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
6896 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
6897 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
6898 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
6899 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
6900 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
6901 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
6902 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
6903 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
6904 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
6905 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
6906 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
6907 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
6908 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
6909 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
6910 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
6911 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
6912 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
6913 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
6914 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
6915 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
6916]
6917
6918var W = new Array(160)
6919
6920function Sha512 () {
6921 this.init()
6922 this._w = W
6923
6924 Hash.call(this, 128, 112)
6925}
6926
6927inherits(Sha512, Hash)
6928
6929Sha512.prototype.init = function () {
6930 this._ah = 0x6a09e667
6931 this._bh = 0xbb67ae85
6932 this._ch = 0x3c6ef372
6933 this._dh = 0xa54ff53a
6934 this._eh = 0x510e527f
6935 this._fh = 0x9b05688c
6936 this._gh = 0x1f83d9ab
6937 this._hh = 0x5be0cd19
6938
6939 this._al = 0xf3bcc908
6940 this._bl = 0x84caa73b
6941 this._cl = 0xfe94f82b
6942 this._dl = 0x5f1d36f1
6943 this._el = 0xade682d1
6944 this._fl = 0x2b3e6c1f
6945 this._gl = 0xfb41bd6b
6946 this._hl = 0x137e2179
6947
6948 return this
6949}
6950
6951function Ch (x, y, z) {
6952 return z ^ (x & (y ^ z))
6953}
6954
6955function maj (x, y, z) {
6956 return (x & y) | (z & (x | y))
6957}
6958
6959function sigma0 (x, xl) {
6960 return (x >>> 28 | xl << 4) ^ (xl >>> 2 | x << 30) ^ (xl >>> 7 | x << 25)
6961}
6962
6963function sigma1 (x, xl) {
6964 return (x >>> 14 | xl << 18) ^ (x >>> 18 | xl << 14) ^ (xl >>> 9 | x << 23)
6965}
6966
6967function Gamma0 (x, xl) {
6968 return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7)
6969}
6970
6971function Gamma0l (x, xl) {
6972 return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7 | xl << 25)
6973}
6974
6975function Gamma1 (x, xl) {
6976 return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6)
6977}
6978
6979function Gamma1l (x, xl) {
6980 return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6 | xl << 26)
6981}
6982
6983function getCarry (a, b) {
6984 return (a >>> 0) < (b >>> 0) ? 1 : 0
6985}
6986
6987Sha512.prototype._update = function (M) {
6988 var W = this._w
6989
6990 var ah = this._ah | 0
6991 var bh = this._bh | 0
6992 var ch = this._ch | 0
6993 var dh = this._dh | 0
6994 var eh = this._eh | 0
6995 var fh = this._fh | 0
6996 var gh = this._gh | 0
6997 var hh = this._hh | 0
6998
6999 var al = this._al | 0
7000 var bl = this._bl | 0
7001 var cl = this._cl | 0
7002 var dl = this._dl | 0
7003 var el = this._el | 0
7004 var fl = this._fl | 0
7005 var gl = this._gl | 0
7006 var hl = this._hl | 0
7007
7008 for (var i = 0; i < 32; i += 2) {
7009 W[i] = M.readInt32BE(i * 4)
7010 W[i + 1] = M.readInt32BE(i * 4 + 4)
7011 }
7012 for (; i < 160; i += 2) {
7013 var xh = W[i - 15 * 2]
7014 var xl = W[i - 15 * 2 + 1]
7015 var gamma0 = Gamma0(xh, xl)
7016 var gamma0l = Gamma0l(xl, xh)
7017
7018 xh = W[i - 2 * 2]
7019 xl = W[i - 2 * 2 + 1]
7020 var gamma1 = Gamma1(xh, xl)
7021 var gamma1l = Gamma1l(xl, xh)
7022
7023 // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
7024 var Wi7h = W[i - 7 * 2]
7025 var Wi7l = W[i - 7 * 2 + 1]
7026
7027 var Wi16h = W[i - 16 * 2]
7028 var Wi16l = W[i - 16 * 2 + 1]
7029
7030 var Wil = (gamma0l + Wi7l) | 0
7031 var Wih = (gamma0 + Wi7h + getCarry(Wil, gamma0l)) | 0
7032 Wil = (Wil + gamma1l) | 0
7033 Wih = (Wih + gamma1 + getCarry(Wil, gamma1l)) | 0
7034 Wil = (Wil + Wi16l) | 0
7035 Wih = (Wih + Wi16h + getCarry(Wil, Wi16l)) | 0
7036
7037 W[i] = Wih
7038 W[i + 1] = Wil
7039 }
7040
7041 for (var j = 0; j < 160; j += 2) {
7042 Wih = W[j]
7043 Wil = W[j + 1]
7044
7045 var majh = maj(ah, bh, ch)
7046 var majl = maj(al, bl, cl)
7047
7048 var sigma0h = sigma0(ah, al)
7049 var sigma0l = sigma0(al, ah)
7050 var sigma1h = sigma1(eh, el)
7051 var sigma1l = sigma1(el, eh)
7052
7053 // t1 = h + sigma1 + ch + K[j] + W[j]
7054 var Kih = K[j]
7055 var Kil = K[j + 1]
7056
7057 var chh = Ch(eh, fh, gh)
7058 var chl = Ch(el, fl, gl)
7059
7060 var t1l = (hl + sigma1l) | 0
7061 var t1h = (hh + sigma1h + getCarry(t1l, hl)) | 0
7062 t1l = (t1l + chl) | 0
7063 t1h = (t1h + chh + getCarry(t1l, chl)) | 0
7064 t1l = (t1l + Kil) | 0
7065 t1h = (t1h + Kih + getCarry(t1l, Kil)) | 0
7066 t1l = (t1l + Wil) | 0
7067 t1h = (t1h + Wih + getCarry(t1l, Wil)) | 0
7068
7069 // t2 = sigma0 + maj
7070 var t2l = (sigma0l + majl) | 0
7071 var t2h = (sigma0h + majh + getCarry(t2l, sigma0l)) | 0
7072
7073 hh = gh
7074 hl = gl
7075 gh = fh
7076 gl = fl
7077 fh = eh
7078 fl = el
7079 el = (dl + t1l) | 0
7080 eh = (dh + t1h + getCarry(el, dl)) | 0
7081 dh = ch
7082 dl = cl
7083 ch = bh
7084 cl = bl
7085 bh = ah
7086 bl = al
7087 al = (t1l + t2l) | 0
7088 ah = (t1h + t2h + getCarry(al, t1l)) | 0
7089 }
7090
7091 this._al = (this._al + al) | 0
7092 this._bl = (this._bl + bl) | 0
7093 this._cl = (this._cl + cl) | 0
7094 this._dl = (this._dl + dl) | 0
7095 this._el = (this._el + el) | 0
7096 this._fl = (this._fl + fl) | 0
7097 this._gl = (this._gl + gl) | 0
7098 this._hl = (this._hl + hl) | 0
7099
7100 this._ah = (this._ah + ah + getCarry(this._al, al)) | 0
7101 this._bh = (this._bh + bh + getCarry(this._bl, bl)) | 0
7102 this._ch = (this._ch + ch + getCarry(this._cl, cl)) | 0
7103 this._dh = (this._dh + dh + getCarry(this._dl, dl)) | 0
7104 this._eh = (this._eh + eh + getCarry(this._el, el)) | 0
7105 this._fh = (this._fh + fh + getCarry(this._fl, fl)) | 0
7106 this._gh = (this._gh + gh + getCarry(this._gl, gl)) | 0
7107 this._hh = (this._hh + hh + getCarry(this._hl, hl)) | 0
7108}
7109
7110Sha512.prototype._hash = function () {
7111 var H = Buffer.allocUnsafe(64)
7112
7113 function writeInt64BE (h, l, offset) {
7114 H.writeInt32BE(h, offset)
7115 H.writeInt32BE(l, offset + 4)
7116 }
7117
7118 writeInt64BE(this._ah, this._al, 0)
7119 writeInt64BE(this._bh, this._bl, 8)
7120 writeInt64BE(this._ch, this._cl, 16)
7121 writeInt64BE(this._dh, this._dl, 24)
7122 writeInt64BE(this._eh, this._el, 32)
7123 writeInt64BE(this._fh, this._fl, 40)
7124 writeInt64BE(this._gh, this._gl, 48)
7125 writeInt64BE(this._hh, this._hl, 56)
7126
7127 return H
7128}
7129
7130module.exports = Sha512
7131
7132},{"./hash":35,"inherits":13,"safe-buffer":34}],43:[function(require,module,exports){
7133// Copyright Joyent, Inc. and other Node contributors.
7134//
7135// Permission is hereby granted, free of charge, to any person obtaining a
7136// copy of this software and associated documentation files (the
7137// "Software"), to deal in the Software without restriction, including
7138// without limitation the rights to use, copy, modify, merge, publish,
7139// distribute, sublicense, and/or sell copies of the Software, and to permit
7140// persons to whom the Software is furnished to do so, subject to the
7141// following conditions:
7142//
7143// The above copyright notice and this permission notice shall be included
7144// in all copies or substantial portions of the Software.
7145//
7146// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
7147// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
7148// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
7149// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
7150// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
7151// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
7152// USE OR OTHER DEALINGS IN THE SOFTWARE.
7153
7154module.exports = Stream;
7155
7156var EE = require('events').EventEmitter;
7157var inherits = require('inherits');
7158
7159inherits(Stream, EE);
7160Stream.Readable = require('readable-stream/readable.js');
7161Stream.Writable = require('readable-stream/writable.js');
7162Stream.Duplex = require('readable-stream/duplex.js');
7163Stream.Transform = require('readable-stream/transform.js');
7164Stream.PassThrough = require('readable-stream/passthrough.js');
7165
7166// Backwards-compat with node 0.4.x
7167Stream.Stream = Stream;
7168
7169
7170
7171// old-style streams. Note that the pipe method (the only relevant
7172// part of this class) is overridden in the Readable class.
7173
7174function Stream() {
7175 EE.call(this);
7176}
7177
7178Stream.prototype.pipe = function(dest, options) {
7179 var source = this;
7180
7181 function ondata(chunk) {
7182 if (dest.writable) {
7183 if (false === dest.write(chunk) && source.pause) {
7184 source.pause();
7185 }
7186 }
7187 }
7188
7189 source.on('data', ondata);
7190
7191 function ondrain() {
7192 if (source.readable && source.resume) {
7193 source.resume();
7194 }
7195 }
7196
7197 dest.on('drain', ondrain);
7198
7199 // If the 'end' option is not supplied, dest.end() will be called when
7200 // source gets the 'end' or 'close' events. Only dest.end() once.
7201 if (!dest._isStdio && (!options || options.end !== false)) {
7202 source.on('end', onend);
7203 source.on('close', onclose);
7204 }
7205
7206 var didOnEnd = false;
7207 function onend() {
7208 if (didOnEnd) return;
7209 didOnEnd = true;
7210
7211 dest.end();
7212 }
7213
7214
7215 function onclose() {
7216 if (didOnEnd) return;
7217 didOnEnd = true;
7218
7219 if (typeof dest.destroy === 'function') dest.destroy();
7220 }
7221
7222 // don't leave dangling pipes when there are errors.
7223 function onerror(er) {
7224 cleanup();
7225 if (EE.listenerCount(this, 'error') === 0) {
7226 throw er; // Unhandled stream error in pipe.
7227 }
7228 }
7229
7230 source.on('error', onerror);
7231 dest.on('error', onerror);
7232
7233 // remove all the event listeners that were added.
7234 function cleanup() {
7235 source.removeListener('data', ondata);
7236 dest.removeListener('drain', ondrain);
7237
7238 source.removeListener('end', onend);
7239 source.removeListener('close', onclose);
7240
7241 source.removeListener('error', onerror);
7242 dest.removeListener('error', onerror);
7243
7244 source.removeListener('end', cleanup);
7245 source.removeListener('close', cleanup);
7246
7247 dest.removeListener('close', cleanup);
7248 }
7249
7250 source.on('end', cleanup);
7251 source.on('close', cleanup);
7252
7253 dest.on('close', cleanup);
7254
7255 dest.emit('pipe', source);
7256
7257 // Allow for unix-like usage: A.pipe(B).pipe(C)
7258 return dest;
7259};
7260
7261},{"events":10,"inherits":13,"readable-stream/duplex.js":19,"readable-stream/passthrough.js":29,"readable-stream/readable.js":30,"readable-stream/transform.js":31,"readable-stream/writable.js":32}],44:[function(require,module,exports){
7262arguments[4][28][0].apply(exports,arguments)
7263},{"dup":28,"safe-buffer":34}],45:[function(require,module,exports){
7264(function (setImmediate,clearImmediate){
7265var nextTick = require('process/browser.js').nextTick;
7266var apply = Function.prototype.apply;
7267var slice = Array.prototype.slice;
7268var immediateIds = {};
7269var nextImmediateId = 0;
7270
7271// DOM APIs, for completeness
7272
7273exports.setTimeout = function() {
7274 return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
7275};
7276exports.setInterval = function() {
7277 return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
7278};
7279exports.clearTimeout =
7280exports.clearInterval = function(timeout) { timeout.close(); };
7281
7282function Timeout(id, clearFn) {
7283 this._id = id;
7284 this._clearFn = clearFn;
7285}
7286Timeout.prototype.unref = Timeout.prototype.ref = function() {};
7287Timeout.prototype.close = function() {
7288 this._clearFn.call(window, this._id);
7289};
7290
7291// Does not start the time, just sets up the members needed.
7292exports.enroll = function(item, msecs) {
7293 clearTimeout(item._idleTimeoutId);
7294 item._idleTimeout = msecs;
7295};
7296
7297exports.unenroll = function(item) {
7298 clearTimeout(item._idleTimeoutId);
7299 item._idleTimeout = -1;
7300};
7301
7302exports._unrefActive = exports.active = function(item) {
7303 clearTimeout(item._idleTimeoutId);
7304
7305 var msecs = item._idleTimeout;
7306 if (msecs >= 0) {
7307 item._idleTimeoutId = setTimeout(function onTimeout() {
7308 if (item._onTimeout)
7309 item._onTimeout();
7310 }, msecs);
7311 }
7312};
7313
7314// That's not how node.js implements it but the exposed api is the same.
7315exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) {
7316 var id = nextImmediateId++;
7317 var args = arguments.length < 2 ? false : slice.call(arguments, 1);
7318
7319 immediateIds[id] = true;
7320
7321 nextTick(function onNextTick() {
7322 if (immediateIds[id]) {
7323 // fn.call() is faster so we optimize for the common use-case
7324 // @see http://jsperf.com/call-apply-segu
7325 if (args) {
7326 fn.apply(null, args);
7327 } else {
7328 fn.call(null);
7329 }
7330 // Prevent ids from leaking
7331 exports.clearImmediate(id);
7332 }
7333 });
7334
7335 return id;
7336};
7337
7338exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) {
7339 delete immediateIds[id];
7340};
7341}).call(this,require("timers").setImmediate,require("timers").clearImmediate)
7342},{"process/browser.js":18,"timers":45}],46:[function(require,module,exports){
7343(function (global){
7344
7345/**
7346 * Module exports.
7347 */
7348
7349module.exports = deprecate;
7350
7351/**
7352 * Mark that a method should not be used.
7353 * Returns a modified function which warns once by default.
7354 *
7355 * If `localStorage.noDeprecation = true` is set, then it is a no-op.
7356 *
7357 * If `localStorage.throwDeprecation = true` is set, then deprecated functions
7358 * will throw an Error when invoked.
7359 *
7360 * If `localStorage.traceDeprecation = true` is set, then deprecated functions
7361 * will invoke `console.trace()` instead of `console.error()`.
7362 *
7363 * @param {Function} fn - the function to deprecate
7364 * @param {String} msg - the string to print to the console when `fn` is invoked
7365 * @returns {Function} a new "deprecated" version of `fn`
7366 * @api public
7367 */
7368
7369function deprecate (fn, msg) {
7370 if (config('noDeprecation')) {
7371 return fn;
7372 }
7373
7374 var warned = false;
7375 function deprecated() {
7376 if (!warned) {
7377 if (config('throwDeprecation')) {
7378 throw new Error(msg);
7379 } else if (config('traceDeprecation')) {
7380 console.trace(msg);
7381 } else {
7382 console.warn(msg);
7383 }
7384 warned = true;
7385 }
7386 return fn.apply(this, arguments);
7387 }
7388
7389 return deprecated;
7390}
7391
7392/**
7393 * Checks `localStorage` for boolean values for the given `name`.
7394 *
7395 * @param {String} name
7396 * @returns {Boolean}
7397 * @api private
7398 */
7399
7400function config (name) {
7401 // accessing global.localStorage can trigger a DOMException in sandboxed iframes
7402 try {
7403 if (!global.localStorage) return false;
7404 } catch (_) {
7405 return false;
7406 }
7407 var val = global.localStorage[name];
7408 if (null == val) return false;
7409 return String(val).toLowerCase() === 'true';
7410}
7411
7412}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
7413},{}]},{},[1])(1)
7414});
diff --git a/src/js/groestlcoinjs-3.3.2.js b/src/js/groestlcoinjs-3.3.2.js
new file mode 100644
index 0000000..632b7d5
--- /dev/null
+++ b/src/js/groestlcoinjs-3.3.2.js
@@ -0,0 +1,17951 @@
1(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.groestlcoinjs = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
2'use strict'
3// base-x encoding / decoding
4// Copyright (c) 2018 base-x contributors
5// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
6// Distributed under the MIT software license, see the accompanying
7// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
8// @ts-ignore
9var _Buffer = require('safe-buffer').Buffer
10function base (ALPHABET) {
11 if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
12 var BASE_MAP = new Uint8Array(256)
13 BASE_MAP.fill(255)
14 for (var i = 0; i < ALPHABET.length; i++) {
15 var x = ALPHABET.charAt(i)
16 var xc = x.charCodeAt(0)
17 if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
18 BASE_MAP[xc] = i
19 }
20 var BASE = ALPHABET.length
21 var LEADER = ALPHABET.charAt(0)
22 var FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up
23 var iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up
24 function encode (source) {
25 if (!_Buffer.isBuffer(source)) { throw new TypeError('Expected Buffer') }
26 if (source.length === 0) { return '' }
27 // Skip & count leading zeroes.
28 var zeroes = 0
29 var length = 0
30 var pbegin = 0
31 var pend = source.length
32 while (pbegin !== pend && source[pbegin] === 0) {
33 pbegin++
34 zeroes++
35 }
36 // Allocate enough space in big-endian base58 representation.
37 var size = ((pend - pbegin) * iFACTOR + 1) >>> 0
38 var b58 = new Uint8Array(size)
39 // Process the bytes.
40 while (pbegin !== pend) {
41 var carry = source[pbegin]
42 // Apply "b58 = b58 * 256 + ch".
43 var i = 0
44 for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
45 carry += (256 * b58[it1]) >>> 0
46 b58[it1] = (carry % BASE) >>> 0
47 carry = (carry / BASE) >>> 0
48 }
49 if (carry !== 0) { throw new Error('Non-zero carry') }
50 length = i
51 pbegin++
52 }
53 // Skip leading zeroes in base58 result.
54 var it2 = size - length
55 while (it2 !== size && b58[it2] === 0) {
56 it2++
57 }
58 // Translate the result into a string.
59 var str = LEADER.repeat(zeroes)
60 for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]) }
61 return str
62 }
63 function decodeUnsafe (source) {
64 if (typeof source !== 'string') { throw new TypeError('Expected String') }
65 if (source.length === 0) { return _Buffer.alloc(0) }
66 var psz = 0
67 // Skip leading spaces.
68 if (source[psz] === ' ') { return }
69 // Skip and count leading '1's.
70 var zeroes = 0
71 var length = 0
72 while (source[psz] === LEADER) {
73 zeroes++
74 psz++
75 }
76 // Allocate enough space in big-endian base256 representation.
77 var size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up.
78 var b256 = new Uint8Array(size)
79 // Process the characters.
80 while (source[psz]) {
81 // Decode character
82 var carry = BASE_MAP[source.charCodeAt(psz)]
83 // Invalid character
84 if (carry === 255) { return }
85 var i = 0
86 for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
87 carry += (BASE * b256[it3]) >>> 0
88 b256[it3] = (carry % 256) >>> 0
89 carry = (carry / 256) >>> 0
90 }
91 if (carry !== 0) { throw new Error('Non-zero carry') }
92 length = i
93 psz++
94 }
95 // Skip trailing spaces.
96 if (source[psz] === ' ') { return }
97 // Skip leading zeroes in b256.
98 var it4 = size - length
99 while (it4 !== size && b256[it4] === 0) {
100 it4++
101 }
102 var vch = _Buffer.allocUnsafe(zeroes + (size - it4))
103 vch.fill(0x00, 0, zeroes)
104 var j = zeroes
105 while (it4 !== size) {
106 vch[j++] = b256[it4++]
107 }
108 return vch
109 }
110 function decode (string) {
111 var buffer = decodeUnsafe(string)
112 if (buffer) { return buffer }
113 throw new Error('Non-base' + BASE + ' character')
114 }
115 return {
116 encode: encode,
117 decodeUnsafe: decodeUnsafe,
118 decode: decode
119 }
120}
121module.exports = base
122
123},{"safe-buffer":38}],2:[function(require,module,exports){
124'use strict'
125var ALPHABET = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l'
126
127// pre-compute lookup table
128var ALPHABET_MAP = {}
129for (var z = 0; z < ALPHABET.length; z++) {
130 var x = ALPHABET.charAt(z)
131
132 if (ALPHABET_MAP[x] !== undefined) throw new TypeError(x + ' is ambiguous')
133 ALPHABET_MAP[x] = z
134}
135
136function polymodStep (pre) {
137 var b = pre >> 25
138 return ((pre & 0x1FFFFFF) << 5) ^
139 (-((b >> 0) & 1) & 0x3b6a57b2) ^
140 (-((b >> 1) & 1) & 0x26508e6d) ^
141 (-((b >> 2) & 1) & 0x1ea119fa) ^
142 (-((b >> 3) & 1) & 0x3d4233dd) ^
143 (-((b >> 4) & 1) & 0x2a1462b3)
144}
145
146function prefixChk (prefix) {
147 var chk = 1
148 for (var i = 0; i < prefix.length; ++i) {
149 var c = prefix.charCodeAt(i)
150 if (c < 33 || c > 126) throw new Error('Invalid prefix (' + prefix + ')')
151
152 chk = polymodStep(chk) ^ (c >> 5)
153 }
154 chk = polymodStep(chk)
155
156 for (i = 0; i < prefix.length; ++i) {
157 var v = prefix.charCodeAt(i)
158 chk = polymodStep(chk) ^ (v & 0x1f)
159 }
160 return chk
161}
162
163function encode (prefix, words, LIMIT) {
164 LIMIT = LIMIT || 90
165 if ((prefix.length + 7 + words.length) > LIMIT) throw new TypeError('Exceeds length limit')
166
167 prefix = prefix.toLowerCase()
168
169 // determine chk mod
170 var chk = prefixChk(prefix)
171 var result = prefix + '1'
172 for (var i = 0; i < words.length; ++i) {
173 var x = words[i]
174 if ((x >> 5) !== 0) throw new Error('Non 5-bit word')
175
176 chk = polymodStep(chk) ^ x
177 result += ALPHABET.charAt(x)
178 }
179
180 for (i = 0; i < 6; ++i) {
181 chk = polymodStep(chk)
182 }
183 chk ^= 1
184
185 for (i = 0; i < 6; ++i) {
186 var v = (chk >> ((5 - i) * 5)) & 0x1f
187 result += ALPHABET.charAt(v)
188 }
189
190 return result
191}
192
193function decode (str, LIMIT) {
194 LIMIT = LIMIT || 90
195 if (str.length < 8) throw new TypeError(str + ' too short')
196 if (str.length > LIMIT) throw new TypeError('Exceeds length limit')
197
198 // don't allow mixed case
199 var lowered = str.toLowerCase()
200 var uppered = str.toUpperCase()
201 if (str !== lowered && str !== uppered) throw new Error('Mixed-case string ' + str)
202 str = lowered
203
204 var split = str.lastIndexOf('1')
205 if (split === -1) throw new Error('No separator character for ' + str)
206 if (split === 0) throw new Error('Missing prefix for ' + str)
207
208 var prefix = str.slice(0, split)
209 var wordChars = str.slice(split + 1)
210 if (wordChars.length < 6) throw new Error('Data too short')
211
212 var chk = prefixChk(prefix)
213 var words = []
214 for (var i = 0; i < wordChars.length; ++i) {
215 var c = wordChars.charAt(i)
216 var v = ALPHABET_MAP[c]
217 if (v === undefined) throw new Error('Unknown character ' + c)
218 chk = polymodStep(chk) ^ v
219
220 // not in the checksum?
221 if (i + 6 >= wordChars.length) continue
222 words.push(v)
223 }
224
225 if (chk !== 1) throw new Error('Invalid checksum for ' + str)
226 return { prefix: prefix, words: words }
227}
228
229function convert (data, inBits, outBits, pad) {
230 var value = 0
231 var bits = 0
232 var maxV = (1 << outBits) - 1
233
234 var result = []
235 for (var i = 0; i < data.length; ++i) {
236 value = (value << inBits) | data[i]
237 bits += inBits
238
239 while (bits >= outBits) {
240 bits -= outBits
241 result.push((value >> bits) & maxV)
242 }
243 }
244
245 if (pad) {
246 if (bits > 0) {
247 result.push((value << (outBits - bits)) & maxV)
248 }
249 } else {
250 if (bits >= inBits) throw new Error('Excess padding')
251 if ((value << (outBits - bits)) & maxV) throw new Error('Non-zero padding')
252 }
253
254 return result
255}
256
257function toWords (bytes) {
258 return convert(bytes, 8, 5, true)
259}
260
261function fromWords (words) {
262 return convert(words, 5, 8, false)
263}
264
265module.exports = {
266 decode: decode,
267 encode: encode,
268 toWords: toWords,
269 fromWords: fromWords
270}
271
272},{}],3:[function(require,module,exports){
273// (public) Constructor
274function BigInteger(a, b, c) {
275 if (!(this instanceof BigInteger))
276 return new BigInteger(a, b, c)
277
278 if (a != null) {
279 if ("number" == typeof a) this.fromNumber(a, b, c)
280 else if (b == null && "string" != typeof a) this.fromString(a, 256)
281 else this.fromString(a, b)
282 }
283}
284
285var proto = BigInteger.prototype
286
287// duck-typed isBigInteger
288proto.__bigi = require('../package.json').version
289BigInteger.isBigInteger = function (obj, check_ver) {
290 return obj && obj.__bigi && (!check_ver || obj.__bigi === proto.__bigi)
291}
292
293// Bits per digit
294var dbits
295
296// am: Compute w_j += (x*this_i), propagate carries,
297// c is initial carry, returns final carry.
298// c < 3*dvalue, x < 2*dvalue, this_i < dvalue
299// We need to select the fastest one that works in this environment.
300
301// am1: use a single mult and divide to get the high bits,
302// max digit bits should be 26 because
303// max internal value = 2*dvalue^2-2*dvalue (< 2^53)
304function am1(i, x, w, j, c, n) {
305 while (--n >= 0) {
306 var v = x * this[i++] + w[j] + c
307 c = Math.floor(v / 0x4000000)
308 w[j++] = v & 0x3ffffff
309 }
310 return c
311}
312// am2 avoids a big mult-and-extract completely.
313// Max digit bits should be <= 30 because we do bitwise ops
314// on values up to 2*hdvalue^2-hdvalue-1 (< 2^31)
315function am2(i, x, w, j, c, n) {
316 var xl = x & 0x7fff,
317 xh = x >> 15
318 while (--n >= 0) {
319 var l = this[i] & 0x7fff
320 var h = this[i++] >> 15
321 var m = xh * l + h * xl
322 l = xl * l + ((m & 0x7fff) << 15) + w[j] + (c & 0x3fffffff)
323 c = (l >>> 30) + (m >>> 15) + xh * h + (c >>> 30)
324 w[j++] = l & 0x3fffffff
325 }
326 return c
327}
328// Alternately, set max digit bits to 28 since some
329// browsers slow down when dealing with 32-bit numbers.
330function am3(i, x, w, j, c, n) {
331 var xl = x & 0x3fff,
332 xh = x >> 14
333 while (--n >= 0) {
334 var l = this[i] & 0x3fff
335 var h = this[i++] >> 14
336 var m = xh * l + h * xl
337 l = xl * l + ((m & 0x3fff) << 14) + w[j] + c
338 c = (l >> 28) + (m >> 14) + xh * h
339 w[j++] = l & 0xfffffff
340 }
341 return c
342}
343
344// wtf?
345BigInteger.prototype.am = am1
346dbits = 26
347
348BigInteger.prototype.DB = dbits
349BigInteger.prototype.DM = ((1 << dbits) - 1)
350var DV = BigInteger.prototype.DV = (1 << dbits)
351
352var BI_FP = 52
353BigInteger.prototype.FV = Math.pow(2, BI_FP)
354BigInteger.prototype.F1 = BI_FP - dbits
355BigInteger.prototype.F2 = 2 * dbits - BI_FP
356
357// Digit conversions
358var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz"
359var BI_RC = new Array()
360var rr, vv
361rr = "0".charCodeAt(0)
362for (vv = 0; vv <= 9; ++vv) BI_RC[rr++] = vv
363rr = "a".charCodeAt(0)
364for (vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv
365rr = "A".charCodeAt(0)
366for (vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv
367
368function int2char(n) {
369 return BI_RM.charAt(n)
370}
371
372function intAt(s, i) {
373 var c = BI_RC[s.charCodeAt(i)]
374 return (c == null) ? -1 : c
375}
376
377// (protected) copy this to r
378function bnpCopyTo(r) {
379 for (var i = this.t - 1; i >= 0; --i) r[i] = this[i]
380 r.t = this.t
381 r.s = this.s
382}
383
384// (protected) set from integer value x, -DV <= x < DV
385function bnpFromInt(x) {
386 this.t = 1
387 this.s = (x < 0) ? -1 : 0
388 if (x > 0) this[0] = x
389 else if (x < -1) this[0] = x + DV
390 else this.t = 0
391}
392
393// return bigint initialized to value
394function nbv(i) {
395 var r = new BigInteger()
396 r.fromInt(i)
397 return r
398}
399
400// (protected) set from string and radix
401function bnpFromString(s, b) {
402 var self = this
403
404 var k
405 if (b == 16) k = 4
406 else if (b == 8) k = 3
407 else if (b == 256) k = 8; // byte array
408 else if (b == 2) k = 1
409 else if (b == 32) k = 5
410 else if (b == 4) k = 2
411 else {
412 self.fromRadix(s, b)
413 return
414 }
415 self.t = 0
416 self.s = 0
417 var i = s.length,
418 mi = false,
419 sh = 0
420 while (--i >= 0) {
421 var x = (k == 8) ? s[i] & 0xff : intAt(s, i)
422 if (x < 0) {
423 if (s.charAt(i) == "-") mi = true
424 continue
425 }
426 mi = false
427 if (sh == 0)
428 self[self.t++] = x
429 else if (sh + k > self.DB) {
430 self[self.t - 1] |= (x & ((1 << (self.DB - sh)) - 1)) << sh
431 self[self.t++] = (x >> (self.DB - sh))
432 } else
433 self[self.t - 1] |= x << sh
434 sh += k
435 if (sh >= self.DB) sh -= self.DB
436 }
437 if (k == 8 && (s[0] & 0x80) != 0) {
438 self.s = -1
439 if (sh > 0) self[self.t - 1] |= ((1 << (self.DB - sh)) - 1) << sh
440 }
441 self.clamp()
442 if (mi) BigInteger.ZERO.subTo(self, self)
443}
444
445// (protected) clamp off excess high words
446function bnpClamp() {
447 var c = this.s & this.DM
448 while (this.t > 0 && this[this.t - 1] == c)--this.t
449}
450
451// (public) return string representation in given radix
452function bnToString(b) {
453 var self = this
454 if (self.s < 0) return "-" + self.negate()
455 .toString(b)
456 var k
457 if (b == 16) k = 4
458 else if (b == 8) k = 3
459 else if (b == 2) k = 1
460 else if (b == 32) k = 5
461 else if (b == 4) k = 2
462 else return self.toRadix(b)
463 var km = (1 << k) - 1,
464 d, m = false,
465 r = "",
466 i = self.t
467 var p = self.DB - (i * self.DB) % k
468 if (i-- > 0) {
469 if (p < self.DB && (d = self[i] >> p) > 0) {
470 m = true
471 r = int2char(d)
472 }
473 while (i >= 0) {
474 if (p < k) {
475 d = (self[i] & ((1 << p) - 1)) << (k - p)
476 d |= self[--i] >> (p += self.DB - k)
477 } else {
478 d = (self[i] >> (p -= k)) & km
479 if (p <= 0) {
480 p += self.DB
481 --i
482 }
483 }
484 if (d > 0) m = true
485 if (m) r += int2char(d)
486 }
487 }
488 return m ? r : "0"
489}
490
491// (public) -this
492function bnNegate() {
493 var r = new BigInteger()
494 BigInteger.ZERO.subTo(this, r)
495 return r
496}
497
498// (public) |this|
499function bnAbs() {
500 return (this.s < 0) ? this.negate() : this
501}
502
503// (public) return + if this > a, - if this < a, 0 if equal
504function bnCompareTo(a) {
505 var r = this.s - a.s
506 if (r != 0) return r
507 var i = this.t
508 r = i - a.t
509 if (r != 0) return (this.s < 0) ? -r : r
510 while (--i >= 0)
511 if ((r = this[i] - a[i]) != 0) return r
512 return 0
513}
514
515// returns bit length of the integer x
516function nbits(x) {
517 var r = 1,
518 t
519 if ((t = x >>> 16) != 0) {
520 x = t
521 r += 16
522 }
523 if ((t = x >> 8) != 0) {
524 x = t
525 r += 8
526 }
527 if ((t = x >> 4) != 0) {
528 x = t
529 r += 4
530 }
531 if ((t = x >> 2) != 0) {
532 x = t
533 r += 2
534 }
535 if ((t = x >> 1) != 0) {
536 x = t
537 r += 1
538 }
539 return r
540}
541
542// (public) return the number of bits in "this"
543function bnBitLength() {
544 if (this.t <= 0) return 0
545 return this.DB * (this.t - 1) + nbits(this[this.t - 1] ^ (this.s & this.DM))
546}
547
548// (public) return the number of bytes in "this"
549function bnByteLength() {
550 return this.bitLength() >> 3
551}
552
553// (protected) r = this << n*DB
554function bnpDLShiftTo(n, r) {
555 var i
556 for (i = this.t - 1; i >= 0; --i) r[i + n] = this[i]
557 for (i = n - 1; i >= 0; --i) r[i] = 0
558 r.t = this.t + n
559 r.s = this.s
560}
561
562// (protected) r = this >> n*DB
563function bnpDRShiftTo(n, r) {
564 for (var i = n; i < this.t; ++i) r[i - n] = this[i]
565 r.t = Math.max(this.t - n, 0)
566 r.s = this.s
567}
568
569// (protected) r = this << n
570function bnpLShiftTo(n, r) {
571 var self = this
572 var bs = n % self.DB
573 var cbs = self.DB - bs
574 var bm = (1 << cbs) - 1
575 var ds = Math.floor(n / self.DB),
576 c = (self.s << bs) & self.DM,
577 i
578 for (i = self.t - 1; i >= 0; --i) {
579 r[i + ds + 1] = (self[i] >> cbs) | c
580 c = (self[i] & bm) << bs
581 }
582 for (i = ds - 1; i >= 0; --i) r[i] = 0
583 r[ds] = c
584 r.t = self.t + ds + 1
585 r.s = self.s
586 r.clamp()
587}
588
589// (protected) r = this >> n
590function bnpRShiftTo(n, r) {
591 var self = this
592 r.s = self.s
593 var ds = Math.floor(n / self.DB)
594 if (ds >= self.t) {
595 r.t = 0
596 return
597 }
598 var bs = n % self.DB
599 var cbs = self.DB - bs
600 var bm = (1 << bs) - 1
601 r[0] = self[ds] >> bs
602 for (var i = ds + 1; i < self.t; ++i) {
603 r[i - ds - 1] |= (self[i] & bm) << cbs
604 r[i - ds] = self[i] >> bs
605 }
606 if (bs > 0) r[self.t - ds - 1] |= (self.s & bm) << cbs
607 r.t = self.t - ds
608 r.clamp()
609}
610
611// (protected) r = this - a
612function bnpSubTo(a, r) {
613 var self = this
614 var i = 0,
615 c = 0,
616 m = Math.min(a.t, self.t)
617 while (i < m) {
618 c += self[i] - a[i]
619 r[i++] = c & self.DM
620 c >>= self.DB
621 }
622 if (a.t < self.t) {
623 c -= a.s
624 while (i < self.t) {
625 c += self[i]
626 r[i++] = c & self.DM
627 c >>= self.DB
628 }
629 c += self.s
630 } else {
631 c += self.s
632 while (i < a.t) {
633 c -= a[i]
634 r[i++] = c & self.DM
635 c >>= self.DB
636 }
637 c -= a.s
638 }
639 r.s = (c < 0) ? -1 : 0
640 if (c < -1) r[i++] = self.DV + c
641 else if (c > 0) r[i++] = c
642 r.t = i
643 r.clamp()
644}
645
646// (protected) r = this * a, r != this,a (HAC 14.12)
647// "this" should be the larger one if appropriate.
648function bnpMultiplyTo(a, r) {
649 var x = this.abs(),
650 y = a.abs()
651 var i = x.t
652 r.t = i + y.t
653 while (--i >= 0) r[i] = 0
654 for (i = 0; i < y.t; ++i) r[i + x.t] = x.am(0, y[i], r, i, 0, x.t)
655 r.s = 0
656 r.clamp()
657 if (this.s != a.s) BigInteger.ZERO.subTo(r, r)
658}
659
660// (protected) r = this^2, r != this (HAC 14.16)
661function bnpSquareTo(r) {
662 var x = this.abs()
663 var i = r.t = 2 * x.t
664 while (--i >= 0) r[i] = 0
665 for (i = 0; i < x.t - 1; ++i) {
666 var c = x.am(i, x[i], r, 2 * i, 0, 1)
667 if ((r[i + x.t] += x.am(i + 1, 2 * x[i], r, 2 * i + 1, c, x.t - i - 1)) >= x.DV) {
668 r[i + x.t] -= x.DV
669 r[i + x.t + 1] = 1
670 }
671 }
672 if (r.t > 0) r[r.t - 1] += x.am(i, x[i], r, 2 * i, 0, 1)
673 r.s = 0
674 r.clamp()
675}
676
677// (protected) divide this by m, quotient and remainder to q, r (HAC 14.20)
678// r != q, this != m. q or r may be null.
679function bnpDivRemTo(m, q, r) {
680 var self = this
681 var pm = m.abs()
682 if (pm.t <= 0) return
683 var pt = self.abs()
684 if (pt.t < pm.t) {
685 if (q != null) q.fromInt(0)
686 if (r != null) self.copyTo(r)
687 return
688 }
689 if (r == null) r = new BigInteger()
690 var y = new BigInteger(),
691 ts = self.s,
692 ms = m.s
693 var nsh = self.DB - nbits(pm[pm.t - 1]); // normalize modulus
694 if (nsh > 0) {
695 pm.lShiftTo(nsh, y)
696 pt.lShiftTo(nsh, r)
697 } else {
698 pm.copyTo(y)
699 pt.copyTo(r)
700 }
701 var ys = y.t
702 var y0 = y[ys - 1]
703 if (y0 == 0) return
704 var yt = y0 * (1 << self.F1) + ((ys > 1) ? y[ys - 2] >> self.F2 : 0)
705 var d1 = self.FV / yt,
706 d2 = (1 << self.F1) / yt,
707 e = 1 << self.F2
708 var i = r.t,
709 j = i - ys,
710 t = (q == null) ? new BigInteger() : q
711 y.dlShiftTo(j, t)
712 if (r.compareTo(t) >= 0) {
713 r[r.t++] = 1
714 r.subTo(t, r)
715 }
716 BigInteger.ONE.dlShiftTo(ys, t)
717 t.subTo(y, y); // "negative" y so we can replace sub with am later
718 while (y.t < ys) y[y.t++] = 0
719 while (--j >= 0) {
720 // Estimate quotient digit
721 var qd = (r[--i] == y0) ? self.DM : Math.floor(r[i] * d1 + (r[i - 1] + e) * d2)
722 if ((r[i] += y.am(0, qd, r, j, 0, ys)) < qd) { // Try it out
723 y.dlShiftTo(j, t)
724 r.subTo(t, r)
725 while (r[i] < --qd) r.subTo(t, r)
726 }
727 }
728 if (q != null) {
729 r.drShiftTo(ys, q)
730 if (ts != ms) BigInteger.ZERO.subTo(q, q)
731 }
732 r.t = ys
733 r.clamp()
734 if (nsh > 0) r.rShiftTo(nsh, r); // Denormalize remainder
735 if (ts < 0) BigInteger.ZERO.subTo(r, r)
736}
737
738// (public) this mod a
739function bnMod(a) {
740 var r = new BigInteger()
741 this.abs()
742 .divRemTo(a, null, r)
743 if (this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r, r)
744 return r
745}
746
747// Modular reduction using "classic" algorithm
748function Classic(m) {
749 this.m = m
750}
751
752function cConvert(x) {
753 if (x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m)
754 else return x
755}
756
757function cRevert(x) {
758 return x
759}
760
761function cReduce(x) {
762 x.divRemTo(this.m, null, x)
763}
764
765function cMulTo(x, y, r) {
766 x.multiplyTo(y, r)
767 this.reduce(r)
768}
769
770function cSqrTo(x, r) {
771 x.squareTo(r)
772 this.reduce(r)
773}
774
775Classic.prototype.convert = cConvert
776Classic.prototype.revert = cRevert
777Classic.prototype.reduce = cReduce
778Classic.prototype.mulTo = cMulTo
779Classic.prototype.sqrTo = cSqrTo
780
781// (protected) return "-1/this % 2^DB"; useful for Mont. reduction
782// justification:
783// xy == 1 (mod m)
784// xy = 1+km
785// xy(2-xy) = (1+km)(1-km)
786// x[y(2-xy)] = 1-k^2m^2
787// x[y(2-xy)] == 1 (mod m^2)
788// if y is 1/x mod m, then y(2-xy) is 1/x mod m^2
789// should reduce x and y(2-xy) by m^2 at each step to keep size bounded.
790// JS multiply "overflows" differently from C/C++, so care is needed here.
791function bnpInvDigit() {
792 if (this.t < 1) return 0
793 var x = this[0]
794 if ((x & 1) == 0) return 0
795 var y = x & 3; // y == 1/x mod 2^2
796 y = (y * (2 - (x & 0xf) * y)) & 0xf; // y == 1/x mod 2^4
797 y = (y * (2 - (x & 0xff) * y)) & 0xff; // y == 1/x mod 2^8
798 y = (y * (2 - (((x & 0xffff) * y) & 0xffff))) & 0xffff; // y == 1/x mod 2^16
799 // last step - calculate inverse mod DV directly
800 // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints
801 y = (y * (2 - x * y % this.DV)) % this.DV; // y == 1/x mod 2^dbits
802 // we really want the negative inverse, and -DV < y < DV
803 return (y > 0) ? this.DV - y : -y
804}
805
806// Montgomery reduction
807function Montgomery(m) {
808 this.m = m
809 this.mp = m.invDigit()
810 this.mpl = this.mp & 0x7fff
811 this.mph = this.mp >> 15
812 this.um = (1 << (m.DB - 15)) - 1
813 this.mt2 = 2 * m.t
814}
815
816// xR mod m
817function montConvert(x) {
818 var r = new BigInteger()
819 x.abs()
820 .dlShiftTo(this.m.t, r)
821 r.divRemTo(this.m, null, r)
822 if (x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r, r)
823 return r
824}
825
826// x/R mod m
827function montRevert(x) {
828 var r = new BigInteger()
829 x.copyTo(r)
830 this.reduce(r)
831 return r
832}
833
834// x = x/R mod m (HAC 14.32)
835function montReduce(x) {
836 while (x.t <= this.mt2) // pad x so am has enough room later
837 x[x.t++] = 0
838 for (var i = 0; i < this.m.t; ++i) {
839 // faster way of calculating u0 = x[i]*mp mod DV
840 var j = x[i] & 0x7fff
841 var u0 = (j * this.mpl + (((j * this.mph + (x[i] >> 15) * this.mpl) & this.um) << 15)) & x.DM
842 // use am to combine the multiply-shift-add into one call
843 j = i + this.m.t
844 x[j] += this.m.am(0, u0, x, i, 0, this.m.t)
845 // propagate carry
846 while (x[j] >= x.DV) {
847 x[j] -= x.DV
848 x[++j]++
849 }
850 }
851 x.clamp()
852 x.drShiftTo(this.m.t, x)
853 if (x.compareTo(this.m) >= 0) x.subTo(this.m, x)
854}
855
856// r = "x^2/R mod m"; x != r
857function montSqrTo(x, r) {
858 x.squareTo(r)
859 this.reduce(r)
860}
861
862// r = "xy/R mod m"; x,y != r
863function montMulTo(x, y, r) {
864 x.multiplyTo(y, r)
865 this.reduce(r)
866}
867
868Montgomery.prototype.convert = montConvert
869Montgomery.prototype.revert = montRevert
870Montgomery.prototype.reduce = montReduce
871Montgomery.prototype.mulTo = montMulTo
872Montgomery.prototype.sqrTo = montSqrTo
873
874// (protected) true iff this is even
875function bnpIsEven() {
876 return ((this.t > 0) ? (this[0] & 1) : this.s) == 0
877}
878
879// (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79)
880function bnpExp(e, z) {
881 if (e > 0xffffffff || e < 1) return BigInteger.ONE
882 var r = new BigInteger(),
883 r2 = new BigInteger(),
884 g = z.convert(this),
885 i = nbits(e) - 1
886 g.copyTo(r)
887 while (--i >= 0) {
888 z.sqrTo(r, r2)
889 if ((e & (1 << i)) > 0) z.mulTo(r2, g, r)
890 else {
891 var t = r
892 r = r2
893 r2 = t
894 }
895 }
896 return z.revert(r)
897}
898
899// (public) this^e % m, 0 <= e < 2^32
900function bnModPowInt(e, m) {
901 var z
902 if (e < 256 || m.isEven()) z = new Classic(m)
903 else z = new Montgomery(m)
904 return this.exp(e, z)
905}
906
907// protected
908proto.copyTo = bnpCopyTo
909proto.fromInt = bnpFromInt
910proto.fromString = bnpFromString
911proto.clamp = bnpClamp
912proto.dlShiftTo = bnpDLShiftTo
913proto.drShiftTo = bnpDRShiftTo
914proto.lShiftTo = bnpLShiftTo
915proto.rShiftTo = bnpRShiftTo
916proto.subTo = bnpSubTo
917proto.multiplyTo = bnpMultiplyTo
918proto.squareTo = bnpSquareTo
919proto.divRemTo = bnpDivRemTo
920proto.invDigit = bnpInvDigit
921proto.isEven = bnpIsEven
922proto.exp = bnpExp
923
924// public
925proto.toString = bnToString
926proto.negate = bnNegate
927proto.abs = bnAbs
928proto.compareTo = bnCompareTo
929proto.bitLength = bnBitLength
930proto.byteLength = bnByteLength
931proto.mod = bnMod
932proto.modPowInt = bnModPowInt
933
934// (public)
935function bnClone() {
936 var r = new BigInteger()
937 this.copyTo(r)
938 return r
939}
940
941// (public) return value as integer
942function bnIntValue() {
943 if (this.s < 0) {
944 if (this.t == 1) return this[0] - this.DV
945 else if (this.t == 0) return -1
946 } else if (this.t == 1) return this[0]
947 else if (this.t == 0) return 0
948 // assumes 16 < DB < 32
949 return ((this[1] & ((1 << (32 - this.DB)) - 1)) << this.DB) | this[0]
950}
951
952// (public) return value as byte
953function bnByteValue() {
954 return (this.t == 0) ? this.s : (this[0] << 24) >> 24
955}
956
957// (public) return value as short (assumes DB>=16)
958function bnShortValue() {
959 return (this.t == 0) ? this.s : (this[0] << 16) >> 16
960}
961
962// (protected) return x s.t. r^x < DV
963function bnpChunkSize(r) {
964 return Math.floor(Math.LN2 * this.DB / Math.log(r))
965}
966
967// (public) 0 if this == 0, 1 if this > 0
968function bnSigNum() {
969 if (this.s < 0) return -1
970 else if (this.t <= 0 || (this.t == 1 && this[0] <= 0)) return 0
971 else return 1
972}
973
974// (protected) convert to radix string
975function bnpToRadix(b) {
976 if (b == null) b = 10
977 if (this.signum() == 0 || b < 2 || b > 36) return "0"
978 var cs = this.chunkSize(b)
979 var a = Math.pow(b, cs)
980 var d = nbv(a),
981 y = new BigInteger(),
982 z = new BigInteger(),
983 r = ""
984 this.divRemTo(d, y, z)
985 while (y.signum() > 0) {
986 r = (a + z.intValue())
987 .toString(b)
988 .substr(1) + r
989 y.divRemTo(d, y, z)
990 }
991 return z.intValue()
992 .toString(b) + r
993}
994
995// (protected) convert from radix string
996function bnpFromRadix(s, b) {
997 var self = this
998 self.fromInt(0)
999 if (b == null) b = 10
1000 var cs = self.chunkSize(b)
1001 var d = Math.pow(b, cs),
1002 mi = false,
1003 j = 0,
1004 w = 0
1005 for (var i = 0; i < s.length; ++i) {
1006 var x = intAt(s, i)
1007 if (x < 0) {
1008 if (s.charAt(i) == "-" && self.signum() == 0) mi = true
1009 continue
1010 }
1011 w = b * w + x
1012 if (++j >= cs) {
1013 self.dMultiply(d)
1014 self.dAddOffset(w, 0)
1015 j = 0
1016 w = 0
1017 }
1018 }
1019 if (j > 0) {
1020 self.dMultiply(Math.pow(b, j))
1021 self.dAddOffset(w, 0)
1022 }
1023 if (mi) BigInteger.ZERO.subTo(self, self)
1024}
1025
1026// (protected) alternate constructor
1027function bnpFromNumber(a, b, c) {
1028 var self = this
1029 if ("number" == typeof b) {
1030 // new BigInteger(int,int,RNG)
1031 if (a < 2) self.fromInt(1)
1032 else {
1033 self.fromNumber(a, c)
1034 if (!self.testBit(a - 1)) // force MSB set
1035 self.bitwiseTo(BigInteger.ONE.shiftLeft(a - 1), op_or, self)
1036 if (self.isEven()) self.dAddOffset(1, 0); // force odd
1037 while (!self.isProbablePrime(b)) {
1038 self.dAddOffset(2, 0)
1039 if (self.bitLength() > a) self.subTo(BigInteger.ONE.shiftLeft(a - 1), self)
1040 }
1041 }
1042 } else {
1043 // new BigInteger(int,RNG)
1044 var x = new Array(),
1045 t = a & 7
1046 x.length = (a >> 3) + 1
1047 b.nextBytes(x)
1048 if (t > 0) x[0] &= ((1 << t) - 1)
1049 else x[0] = 0
1050 self.fromString(x, 256)
1051 }
1052}
1053
1054// (public) convert to bigendian byte array
1055function bnToByteArray() {
1056 var self = this
1057 var i = self.t,
1058 r = new Array()
1059 r[0] = self.s
1060 var p = self.DB - (i * self.DB) % 8,
1061 d, k = 0
1062 if (i-- > 0) {
1063 if (p < self.DB && (d = self[i] >> p) != (self.s & self.DM) >> p)
1064 r[k++] = d | (self.s << (self.DB - p))
1065 while (i >= 0) {
1066 if (p < 8) {
1067 d = (self[i] & ((1 << p) - 1)) << (8 - p)
1068 d |= self[--i] >> (p += self.DB - 8)
1069 } else {
1070 d = (self[i] >> (p -= 8)) & 0xff
1071 if (p <= 0) {
1072 p += self.DB
1073 --i
1074 }
1075 }
1076 if ((d & 0x80) != 0) d |= -256
1077 if (k === 0 && (self.s & 0x80) != (d & 0x80))++k
1078 if (k > 0 || d != self.s) r[k++] = d
1079 }
1080 }
1081 return r
1082}
1083
1084function bnEquals(a) {
1085 return (this.compareTo(a) == 0)
1086}
1087
1088function bnMin(a) {
1089 return (this.compareTo(a) < 0) ? this : a
1090}
1091
1092function bnMax(a) {
1093 return (this.compareTo(a) > 0) ? this : a
1094}
1095
1096// (protected) r = this op a (bitwise)
1097function bnpBitwiseTo(a, op, r) {
1098 var self = this
1099 var i, f, m = Math.min(a.t, self.t)
1100 for (i = 0; i < m; ++i) r[i] = op(self[i], a[i])
1101 if (a.t < self.t) {
1102 f = a.s & self.DM
1103 for (i = m; i < self.t; ++i) r[i] = op(self[i], f)
1104 r.t = self.t
1105 } else {
1106 f = self.s & self.DM
1107 for (i = m; i < a.t; ++i) r[i] = op(f, a[i])
1108 r.t = a.t
1109 }
1110 r.s = op(self.s, a.s)
1111 r.clamp()
1112}
1113
1114// (public) this & a
1115function op_and(x, y) {
1116 return x & y
1117}
1118
1119function bnAnd(a) {
1120 var r = new BigInteger()
1121 this.bitwiseTo(a, op_and, r)
1122 return r
1123}
1124
1125// (public) this | a
1126function op_or(x, y) {
1127 return x | y
1128}
1129
1130function bnOr(a) {
1131 var r = new BigInteger()
1132 this.bitwiseTo(a, op_or, r)
1133 return r
1134}
1135
1136// (public) this ^ a
1137function op_xor(x, y) {
1138 return x ^ y
1139}
1140
1141function bnXor(a) {
1142 var r = new BigInteger()
1143 this.bitwiseTo(a, op_xor, r)
1144 return r
1145}
1146
1147// (public) this & ~a
1148function op_andnot(x, y) {
1149 return x & ~y
1150}
1151
1152function bnAndNot(a) {
1153 var r = new BigInteger()
1154 this.bitwiseTo(a, op_andnot, r)
1155 return r
1156}
1157
1158// (public) ~this
1159function bnNot() {
1160 var r = new BigInteger()
1161 for (var i = 0; i < this.t; ++i) r[i] = this.DM & ~this[i]
1162 r.t = this.t
1163 r.s = ~this.s
1164 return r
1165}
1166
1167// (public) this << n
1168function bnShiftLeft(n) {
1169 var r = new BigInteger()
1170 if (n < 0) this.rShiftTo(-n, r)
1171 else this.lShiftTo(n, r)
1172 return r
1173}
1174
1175// (public) this >> n
1176function bnShiftRight(n) {
1177 var r = new BigInteger()
1178 if (n < 0) this.lShiftTo(-n, r)
1179 else this.rShiftTo(n, r)
1180 return r
1181}
1182
1183// return index of lowest 1-bit in x, x < 2^31
1184function lbit(x) {
1185 if (x == 0) return -1
1186 var r = 0
1187 if ((x & 0xffff) == 0) {
1188 x >>= 16
1189 r += 16
1190 }
1191 if ((x & 0xff) == 0) {
1192 x >>= 8
1193 r += 8
1194 }
1195 if ((x & 0xf) == 0) {
1196 x >>= 4
1197 r += 4
1198 }
1199 if ((x & 3) == 0) {
1200 x >>= 2
1201 r += 2
1202 }
1203 if ((x & 1) == 0)++r
1204 return r
1205}
1206
1207// (public) returns index of lowest 1-bit (or -1 if none)
1208function bnGetLowestSetBit() {
1209 for (var i = 0; i < this.t; ++i)
1210 if (this[i] != 0) return i * this.DB + lbit(this[i])
1211 if (this.s < 0) return this.t * this.DB
1212 return -1
1213}
1214
1215// return number of 1 bits in x
1216function cbit(x) {
1217 var r = 0
1218 while (x != 0) {
1219 x &= x - 1
1220 ++r
1221 }
1222 return r
1223}
1224
1225// (public) return number of set bits
1226function bnBitCount() {
1227 var r = 0,
1228 x = this.s & this.DM
1229 for (var i = 0; i < this.t; ++i) r += cbit(this[i] ^ x)
1230 return r
1231}
1232
1233// (public) true iff nth bit is set
1234function bnTestBit(n) {
1235 var j = Math.floor(n / this.DB)
1236 if (j >= this.t) return (this.s != 0)
1237 return ((this[j] & (1 << (n % this.DB))) != 0)
1238}
1239
1240// (protected) this op (1<<n)
1241function bnpChangeBit(n, op) {
1242 var r = BigInteger.ONE.shiftLeft(n)
1243 this.bitwiseTo(r, op, r)
1244 return r
1245}
1246
1247// (public) this | (1<<n)
1248function bnSetBit(n) {
1249 return this.changeBit(n, op_or)
1250}
1251
1252// (public) this & ~(1<<n)
1253function bnClearBit(n) {
1254 return this.changeBit(n, op_andnot)
1255}
1256
1257// (public) this ^ (1<<n)
1258function bnFlipBit(n) {
1259 return this.changeBit(n, op_xor)
1260}
1261
1262// (protected) r = this + a
1263function bnpAddTo(a, r) {
1264 var self = this
1265
1266 var i = 0,
1267 c = 0,
1268 m = Math.min(a.t, self.t)
1269 while (i < m) {
1270 c += self[i] + a[i]
1271 r[i++] = c & self.DM
1272 c >>= self.DB
1273 }
1274 if (a.t < self.t) {
1275 c += a.s
1276 while (i < self.t) {
1277 c += self[i]
1278 r[i++] = c & self.DM
1279 c >>= self.DB
1280 }
1281 c += self.s
1282 } else {
1283 c += self.s
1284 while (i < a.t) {
1285 c += a[i]
1286 r[i++] = c & self.DM
1287 c >>= self.DB
1288 }
1289 c += a.s
1290 }
1291 r.s = (c < 0) ? -1 : 0
1292 if (c > 0) r[i++] = c
1293 else if (c < -1) r[i++] = self.DV + c
1294 r.t = i
1295 r.clamp()
1296}
1297
1298// (public) this + a
1299function bnAdd(a) {
1300 var r = new BigInteger()
1301 this.addTo(a, r)
1302 return r
1303}
1304
1305// (public) this - a
1306function bnSubtract(a) {
1307 var r = new BigInteger()
1308 this.subTo(a, r)
1309 return r
1310}
1311
1312// (public) this * a
1313function bnMultiply(a) {
1314 var r = new BigInteger()
1315 this.multiplyTo(a, r)
1316 return r
1317}
1318
1319// (public) this^2
1320function bnSquare() {
1321 var r = new BigInteger()
1322 this.squareTo(r)
1323 return r
1324}
1325
1326// (public) this / a
1327function bnDivide(a) {
1328 var r = new BigInteger()
1329 this.divRemTo(a, r, null)
1330 return r
1331}
1332
1333// (public) this % a
1334function bnRemainder(a) {
1335 var r = new BigInteger()
1336 this.divRemTo(a, null, r)
1337 return r
1338}
1339
1340// (public) [this/a,this%a]
1341function bnDivideAndRemainder(a) {
1342 var q = new BigInteger(),
1343 r = new BigInteger()
1344 this.divRemTo(a, q, r)
1345 return new Array(q, r)
1346}
1347
1348// (protected) this *= n, this >= 0, 1 < n < DV
1349function bnpDMultiply(n) {
1350 this[this.t] = this.am(0, n - 1, this, 0, 0, this.t)
1351 ++this.t
1352 this.clamp()
1353}
1354
1355// (protected) this += n << w words, this >= 0
1356function bnpDAddOffset(n, w) {
1357 if (n == 0) return
1358 while (this.t <= w) this[this.t++] = 0
1359 this[w] += n
1360 while (this[w] >= this.DV) {
1361 this[w] -= this.DV
1362 if (++w >= this.t) this[this.t++] = 0
1363 ++this[w]
1364 }
1365}
1366
1367// A "null" reducer
1368function NullExp() {}
1369
1370function nNop(x) {
1371 return x
1372}
1373
1374function nMulTo(x, y, r) {
1375 x.multiplyTo(y, r)
1376}
1377
1378function nSqrTo(x, r) {
1379 x.squareTo(r)
1380}
1381
1382NullExp.prototype.convert = nNop
1383NullExp.prototype.revert = nNop
1384NullExp.prototype.mulTo = nMulTo
1385NullExp.prototype.sqrTo = nSqrTo
1386
1387// (public) this^e
1388function bnPow(e) {
1389 return this.exp(e, new NullExp())
1390}
1391
1392// (protected) r = lower n words of "this * a", a.t <= n
1393// "this" should be the larger one if appropriate.
1394function bnpMultiplyLowerTo(a, n, r) {
1395 var i = Math.min(this.t + a.t, n)
1396 r.s = 0; // assumes a,this >= 0
1397 r.t = i
1398 while (i > 0) r[--i] = 0
1399 var j
1400 for (j = r.t - this.t; i < j; ++i) r[i + this.t] = this.am(0, a[i], r, i, 0, this.t)
1401 for (j = Math.min(a.t, n); i < j; ++i) this.am(0, a[i], r, i, 0, n - i)
1402 r.clamp()
1403}
1404
1405// (protected) r = "this * a" without lower n words, n > 0
1406// "this" should be the larger one if appropriate.
1407function bnpMultiplyUpperTo(a, n, r) {
1408 --n
1409 var i = r.t = this.t + a.t - n
1410 r.s = 0; // assumes a,this >= 0
1411 while (--i >= 0) r[i] = 0
1412 for (i = Math.max(n - this.t, 0); i < a.t; ++i)
1413 r[this.t + i - n] = this.am(n - i, a[i], r, 0, 0, this.t + i - n)
1414 r.clamp()
1415 r.drShiftTo(1, r)
1416}
1417
1418// Barrett modular reduction
1419function Barrett(m) {
1420 // setup Barrett
1421 this.r2 = new BigInteger()
1422 this.q3 = new BigInteger()
1423 BigInteger.ONE.dlShiftTo(2 * m.t, this.r2)
1424 this.mu = this.r2.divide(m)
1425 this.m = m
1426}
1427
1428function barrettConvert(x) {
1429 if (x.s < 0 || x.t > 2 * this.m.t) return x.mod(this.m)
1430 else if (x.compareTo(this.m) < 0) return x
1431 else {
1432 var r = new BigInteger()
1433 x.copyTo(r)
1434 this.reduce(r)
1435 return r
1436 }
1437}
1438
1439function barrettRevert(x) {
1440 return x
1441}
1442
1443// x = x mod m (HAC 14.42)
1444function barrettReduce(x) {
1445 var self = this
1446 x.drShiftTo(self.m.t - 1, self.r2)
1447 if (x.t > self.m.t + 1) {
1448 x.t = self.m.t + 1
1449 x.clamp()
1450 }
1451 self.mu.multiplyUpperTo(self.r2, self.m.t + 1, self.q3)
1452 self.m.multiplyLowerTo(self.q3, self.m.t + 1, self.r2)
1453 while (x.compareTo(self.r2) < 0) x.dAddOffset(1, self.m.t + 1)
1454 x.subTo(self.r2, x)
1455 while (x.compareTo(self.m) >= 0) x.subTo(self.m, x)
1456}
1457
1458// r = x^2 mod m; x != r
1459function barrettSqrTo(x, r) {
1460 x.squareTo(r)
1461 this.reduce(r)
1462}
1463
1464// r = x*y mod m; x,y != r
1465function barrettMulTo(x, y, r) {
1466 x.multiplyTo(y, r)
1467 this.reduce(r)
1468}
1469
1470Barrett.prototype.convert = barrettConvert
1471Barrett.prototype.revert = barrettRevert
1472Barrett.prototype.reduce = barrettReduce
1473Barrett.prototype.mulTo = barrettMulTo
1474Barrett.prototype.sqrTo = barrettSqrTo
1475
1476// (public) this^e % m (HAC 14.85)
1477function bnModPow(e, m) {
1478 var i = e.bitLength(),
1479 k, r = nbv(1),
1480 z
1481 if (i <= 0) return r
1482 else if (i < 18) k = 1
1483 else if (i < 48) k = 3
1484 else if (i < 144) k = 4
1485 else if (i < 768) k = 5
1486 else k = 6
1487 if (i < 8)
1488 z = new Classic(m)
1489 else if (m.isEven())
1490 z = new Barrett(m)
1491 else
1492 z = new Montgomery(m)
1493
1494 // precomputation
1495 var g = new Array(),
1496 n = 3,
1497 k1 = k - 1,
1498 km = (1 << k) - 1
1499 g[1] = z.convert(this)
1500 if (k > 1) {
1501 var g2 = new BigInteger()
1502 z.sqrTo(g[1], g2)
1503 while (n <= km) {
1504 g[n] = new BigInteger()
1505 z.mulTo(g2, g[n - 2], g[n])
1506 n += 2
1507 }
1508 }
1509
1510 var j = e.t - 1,
1511 w, is1 = true,
1512 r2 = new BigInteger(),
1513 t
1514 i = nbits(e[j]) - 1
1515 while (j >= 0) {
1516 if (i >= k1) w = (e[j] >> (i - k1)) & km
1517 else {
1518 w = (e[j] & ((1 << (i + 1)) - 1)) << (k1 - i)
1519 if (j > 0) w |= e[j - 1] >> (this.DB + i - k1)
1520 }
1521
1522 n = k
1523 while ((w & 1) == 0) {
1524 w >>= 1
1525 --n
1526 }
1527 if ((i -= n) < 0) {
1528 i += this.DB
1529 --j
1530 }
1531 if (is1) { // ret == 1, don't bother squaring or multiplying it
1532 g[w].copyTo(r)
1533 is1 = false
1534 } else {
1535 while (n > 1) {
1536 z.sqrTo(r, r2)
1537 z.sqrTo(r2, r)
1538 n -= 2
1539 }
1540 if (n > 0) z.sqrTo(r, r2)
1541 else {
1542 t = r
1543 r = r2
1544 r2 = t
1545 }
1546 z.mulTo(r2, g[w], r)
1547 }
1548
1549 while (j >= 0 && (e[j] & (1 << i)) == 0) {
1550 z.sqrTo(r, r2)
1551 t = r
1552 r = r2
1553 r2 = t
1554 if (--i < 0) {
1555 i = this.DB - 1
1556 --j
1557 }
1558 }
1559 }
1560 return z.revert(r)
1561}
1562
1563// (public) gcd(this,a) (HAC 14.54)
1564function bnGCD(a) {
1565 var x = (this.s < 0) ? this.negate() : this.clone()
1566 var y = (a.s < 0) ? a.negate() : a.clone()
1567 if (x.compareTo(y) < 0) {
1568 var t = x
1569 x = y
1570 y = t
1571 }
1572 var i = x.getLowestSetBit(),
1573 g = y.getLowestSetBit()
1574 if (g < 0) return x
1575 if (i < g) g = i
1576 if (g > 0) {
1577 x.rShiftTo(g, x)
1578 y.rShiftTo(g, y)
1579 }
1580 while (x.signum() > 0) {
1581 if ((i = x.getLowestSetBit()) > 0) x.rShiftTo(i, x)
1582 if ((i = y.getLowestSetBit()) > 0) y.rShiftTo(i, y)
1583 if (x.compareTo(y) >= 0) {
1584 x.subTo(y, x)
1585 x.rShiftTo(1, x)
1586 } else {
1587 y.subTo(x, y)
1588 y.rShiftTo(1, y)
1589 }
1590 }
1591 if (g > 0) y.lShiftTo(g, y)
1592 return y
1593}
1594
1595// (protected) this % n, n < 2^26
1596function bnpModInt(n) {
1597 if (n <= 0) return 0
1598 var d = this.DV % n,
1599 r = (this.s < 0) ? n - 1 : 0
1600 if (this.t > 0)
1601 if (d == 0) r = this[0] % n
1602 else
1603 for (var i = this.t - 1; i >= 0; --i) r = (d * r + this[i]) % n
1604 return r
1605}
1606
1607// (public) 1/this % m (HAC 14.61)
1608function bnModInverse(m) {
1609 var ac = m.isEven()
1610 if (this.signum() === 0) throw new Error('division by zero')
1611 if ((this.isEven() && ac) || m.signum() == 0) return BigInteger.ZERO
1612 var u = m.clone(),
1613 v = this.clone()
1614 var a = nbv(1),
1615 b = nbv(0),
1616 c = nbv(0),
1617 d = nbv(1)
1618 while (u.signum() != 0) {
1619 while (u.isEven()) {
1620 u.rShiftTo(1, u)
1621 if (ac) {
1622 if (!a.isEven() || !b.isEven()) {
1623 a.addTo(this, a)
1624 b.subTo(m, b)
1625 }
1626 a.rShiftTo(1, a)
1627 } else if (!b.isEven()) b.subTo(m, b)
1628 b.rShiftTo(1, b)
1629 }
1630 while (v.isEven()) {
1631 v.rShiftTo(1, v)
1632 if (ac) {
1633 if (!c.isEven() || !d.isEven()) {
1634 c.addTo(this, c)
1635 d.subTo(m, d)
1636 }
1637 c.rShiftTo(1, c)
1638 } else if (!d.isEven()) d.subTo(m, d)
1639 d.rShiftTo(1, d)
1640 }
1641 if (u.compareTo(v) >= 0) {
1642 u.subTo(v, u)
1643 if (ac) a.subTo(c, a)
1644 b.subTo(d, b)
1645 } else {
1646 v.subTo(u, v)
1647 if (ac) c.subTo(a, c)
1648 d.subTo(b, d)
1649 }
1650 }
1651 if (v.compareTo(BigInteger.ONE) != 0) return BigInteger.ZERO
1652 while (d.compareTo(m) >= 0) d.subTo(m, d)
1653 while (d.signum() < 0) d.addTo(m, d)
1654 return d
1655}
1656
1657var lowprimes = [
1658 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
1659 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151,
1660 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233,
1661 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317,
1662 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419,
1663 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503,
1664 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607,
1665 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701,
1666 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811,
1667 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911,
1668 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997
1669]
1670
1671var lplim = (1 << 26) / lowprimes[lowprimes.length - 1]
1672
1673// (public) test primality with certainty >= 1-.5^t
1674function bnIsProbablePrime(t) {
1675 var i, x = this.abs()
1676 if (x.t == 1 && x[0] <= lowprimes[lowprimes.length - 1]) {
1677 for (i = 0; i < lowprimes.length; ++i)
1678 if (x[0] == lowprimes[i]) return true
1679 return false
1680 }
1681 if (x.isEven()) return false
1682 i = 1
1683 while (i < lowprimes.length) {
1684 var m = lowprimes[i],
1685 j = i + 1
1686 while (j < lowprimes.length && m < lplim) m *= lowprimes[j++]
1687 m = x.modInt(m)
1688 while (i < j) if (m % lowprimes[i++] == 0) return false
1689 }
1690 return x.millerRabin(t)
1691}
1692
1693// (protected) true if probably prime (HAC 4.24, Miller-Rabin)
1694function bnpMillerRabin(t) {
1695 var n1 = this.subtract(BigInteger.ONE)
1696 var k = n1.getLowestSetBit()
1697 if (k <= 0) return false
1698 var r = n1.shiftRight(k)
1699 t = (t + 1) >> 1
1700 if (t > lowprimes.length) t = lowprimes.length
1701 var a = new BigInteger(null)
1702 var j, bases = []
1703 for (var i = 0; i < t; ++i) {
1704 for (;;) {
1705 j = lowprimes[Math.floor(Math.random() * lowprimes.length)]
1706 if (bases.indexOf(j) == -1) break
1707 }
1708 bases.push(j)
1709 a.fromInt(j)
1710 var y = a.modPow(r, this)
1711 if (y.compareTo(BigInteger.ONE) != 0 && y.compareTo(n1) != 0) {
1712 var j = 1
1713 while (j++ < k && y.compareTo(n1) != 0) {
1714 y = y.modPowInt(2, this)
1715 if (y.compareTo(BigInteger.ONE) == 0) return false
1716 }
1717 if (y.compareTo(n1) != 0) return false
1718 }
1719 }
1720 return true
1721}
1722
1723// protected
1724proto.chunkSize = bnpChunkSize
1725proto.toRadix = bnpToRadix
1726proto.fromRadix = bnpFromRadix
1727proto.fromNumber = bnpFromNumber
1728proto.bitwiseTo = bnpBitwiseTo
1729proto.changeBit = bnpChangeBit
1730proto.addTo = bnpAddTo
1731proto.dMultiply = bnpDMultiply
1732proto.dAddOffset = bnpDAddOffset
1733proto.multiplyLowerTo = bnpMultiplyLowerTo
1734proto.multiplyUpperTo = bnpMultiplyUpperTo
1735proto.modInt = bnpModInt
1736proto.millerRabin = bnpMillerRabin
1737
1738// public
1739proto.clone = bnClone
1740proto.intValue = bnIntValue
1741proto.byteValue = bnByteValue
1742proto.shortValue = bnShortValue
1743proto.signum = bnSigNum
1744proto.toByteArray = bnToByteArray
1745proto.equals = bnEquals
1746proto.min = bnMin
1747proto.max = bnMax
1748proto.and = bnAnd
1749proto.or = bnOr
1750proto.xor = bnXor
1751proto.andNot = bnAndNot
1752proto.not = bnNot
1753proto.shiftLeft = bnShiftLeft
1754proto.shiftRight = bnShiftRight
1755proto.getLowestSetBit = bnGetLowestSetBit
1756proto.bitCount = bnBitCount
1757proto.testBit = bnTestBit
1758proto.setBit = bnSetBit
1759proto.clearBit = bnClearBit
1760proto.flipBit = bnFlipBit
1761proto.add = bnAdd
1762proto.subtract = bnSubtract
1763proto.multiply = bnMultiply
1764proto.divide = bnDivide
1765proto.remainder = bnRemainder
1766proto.divideAndRemainder = bnDivideAndRemainder
1767proto.modPow = bnModPow
1768proto.modInverse = bnModInverse
1769proto.pow = bnPow
1770proto.gcd = bnGCD
1771proto.isProbablePrime = bnIsProbablePrime
1772
1773// JSBN-specific extension
1774proto.square = bnSquare
1775
1776// constants
1777BigInteger.ZERO = nbv(0)
1778BigInteger.ONE = nbv(1)
1779BigInteger.valueOf = nbv
1780
1781module.exports = BigInteger
1782
1783},{"../package.json":6}],4:[function(require,module,exports){
1784(function (Buffer){
1785// FIXME: Kind of a weird way to throw exceptions, consider removing
1786var assert = require('assert')
1787var BigInteger = require('./bigi')
1788
1789/**
1790 * Turns a byte array into a big integer.
1791 *
1792 * This function will interpret a byte array as a big integer in big
1793 * endian notation.
1794 */
1795BigInteger.fromByteArrayUnsigned = function(byteArray) {
1796 // BigInteger expects a DER integer conformant byte array
1797 if (byteArray[0] & 0x80) {
1798 return new BigInteger([0].concat(byteArray))
1799 }
1800
1801 return new BigInteger(byteArray)
1802}
1803
1804/**
1805 * Returns a byte array representation of the big integer.
1806 *
1807 * This returns the absolute of the contained value in big endian
1808 * form. A value of zero results in an empty array.
1809 */
1810BigInteger.prototype.toByteArrayUnsigned = function() {
1811 var byteArray = this.toByteArray()
1812 return byteArray[0] === 0 ? byteArray.slice(1) : byteArray
1813}
1814
1815BigInteger.fromDERInteger = function(byteArray) {
1816 return new BigInteger(byteArray)
1817}
1818
1819/*
1820 * Converts BigInteger to a DER integer representation.
1821 *
1822 * The format for this value uses the most significant bit as a sign
1823 * bit. If the most significant bit is already set and the integer is
1824 * positive, a 0x00 is prepended.
1825 *
1826 * Examples:
1827 *
1828 * 0 => 0x00
1829 * 1 => 0x01
1830 * -1 => 0xff
1831 * 127 => 0x7f
1832 * -127 => 0x81
1833 * 128 => 0x0080
1834 * -128 => 0x80
1835 * 255 => 0x00ff
1836 * -255 => 0xff01
1837 * 16300 => 0x3fac
1838 * -16300 => 0xc054
1839 * 62300 => 0x00f35c
1840 * -62300 => 0xff0ca4
1841*/
1842BigInteger.prototype.toDERInteger = BigInteger.prototype.toByteArray
1843
1844BigInteger.fromBuffer = function(buffer) {
1845 // BigInteger expects a DER integer conformant byte array
1846 if (buffer[0] & 0x80) {
1847 var byteArray = Array.prototype.slice.call(buffer)
1848
1849 return new BigInteger([0].concat(byteArray))
1850 }
1851
1852 return new BigInteger(buffer)
1853}
1854
1855BigInteger.fromHex = function(hex) {
1856 if (hex === '') return BigInteger.ZERO
1857
1858 assert.equal(hex, hex.match(/^[A-Fa-f0-9]+/), 'Invalid hex string')
1859 assert.equal(hex.length % 2, 0, 'Incomplete hex')
1860 return new BigInteger(hex, 16)
1861}
1862
1863BigInteger.prototype.toBuffer = function(size) {
1864 var byteArray = this.toByteArrayUnsigned()
1865 var zeros = []
1866
1867 var padding = size - byteArray.length
1868 while (zeros.length < padding) zeros.push(0)
1869
1870 return new Buffer(zeros.concat(byteArray))
1871}
1872
1873BigInteger.prototype.toHex = function(size) {
1874 return this.toBuffer(size).toString('hex')
1875}
1876
1877}).call(this,require("buffer").Buffer)
1878},{"./bigi":3,"assert":90,"buffer":96}],5:[function(require,module,exports){
1879var BigInteger = require('./bigi')
1880
1881//addons
1882require('./convert')
1883
1884module.exports = BigInteger
1885},{"./bigi":3,"./convert":4}],6:[function(require,module,exports){
1886module.exports={
1887 "_args": [
1888 [
1889 "bigi@^1.4.0",
1890 "/home/hashengineering/hashengineering/groestlcoinjs-lib"
1891 ]
1892 ],
1893 "_from": "bigi@>=1.4.0 <2.0.0",
1894 "_id": "bigi@1.4.2",
1895 "_inCache": true,
1896 "_installable": true,
1897 "_location": "/bigi",
1898 "_nodeVersion": "6.1.0",
1899 "_npmOperationalInternal": {
1900 "host": "packages-12-west.internal.npmjs.com",
1901 "tmp": "tmp/bigi-1.4.2.tgz_1469584192413_0.6801238611806184"
1902 },
1903 "_npmUser": {
1904 "email": "jprichardson@gmail.com",
1905 "name": "jprichardson"
1906 },
1907 "_npmVersion": "3.8.6",
1908 "_phantomChildren": {},
1909 "_requested": {
1910 "name": "bigi",
1911 "raw": "bigi@^1.4.0",
1912 "rawSpec": "^1.4.0",
1913 "scope": null,
1914 "spec": ">=1.4.0 <2.0.0",
1915 "type": "range"
1916 },
1917 "_requiredBy": [
1918 "/"
1919 ],
1920 "_resolved": "https://registry.npmjs.org/bigi/-/bigi-1.4.2.tgz",
1921 "_shasum": "9c665a95f88b8b08fc05cfd731f561859d725825",
1922 "_shrinkwrap": null,
1923 "_spec": "bigi@^1.4.0",
1924 "_where": "/home/hashengineering/hashengineering/groestlcoinjs-lib",
1925 "bugs": {
1926 "url": "https://github.com/cryptocoinjs/bigi/issues"
1927 },
1928 "dependencies": {},
1929 "description": "Big integers.",
1930 "devDependencies": {
1931 "coveralls": "^2.11.2",
1932 "istanbul": "^0.3.5",
1933 "jshint": "^2.5.1",
1934 "mocha": "^2.1.0",
1935 "mochify": "^2.1.0"
1936 },
1937 "directories": {},
1938 "dist": {
1939 "shasum": "9c665a95f88b8b08fc05cfd731f561859d725825",
1940 "tarball": "https://registry.npmjs.org/bigi/-/bigi-1.4.2.tgz"
1941 },
1942 "gitHead": "c25308081c896ff84702303722bf5ecd8b3f78e3",
1943 "homepage": "https://github.com/cryptocoinjs/bigi#readme",
1944 "keywords": [
1945 "arbitrary",
1946 "arithmetic",
1947 "big",
1948 "bigint",
1949 "biginteger",
1950 "bignumber",
1951 "bitcoin",
1952 "cryptography",
1953 "decimal",
1954 "float",
1955 "int",
1956 "integer",
1957 "math",
1958 "number",
1959 "precision"
1960 ],
1961 "main": "./lib/index.js",
1962 "maintainers": [
1963 {
1964 "name": "midnightlightning",
1965 "email": "boydb@midnightdesign.ws"
1966 },
1967 {
1968 "name": "sidazhang",
1969 "email": "sidazhang89@gmail.com"
1970 },
1971 {
1972 "name": "nadav",
1973 "email": "npm@shesek.info"
1974 },
1975 {
1976 "name": "jprichardson",
1977 "email": "jprichardson@gmail.com"
1978 }
1979 ],
1980 "name": "bigi",
1981 "optionalDependencies": {},
1982 "readme": "ERROR: No README data found!",
1983 "repository": {
1984 "type": "git",
1985 "url": "git+https://github.com/cryptocoinjs/bigi.git"
1986 },
1987 "scripts": {
1988 "browser-test": "mochify --wd -R spec",
1989 "coverage": "istanbul cover ./node_modules/.bin/_mocha -- --reporter list test/*.js",
1990 "coveralls": "npm run-script coverage && node ./node_modules/.bin/coveralls < coverage/lcov.info",
1991 "jshint": "jshint --config jshint.json lib/*.js ; true",
1992 "test": "_mocha -- test/*.js",
1993 "unit": "mocha"
1994 },
1995 "testling": {
1996 "browsers": [
1997 "android-browser/4.2..latest",
1998 "chrome/latest",
1999 "firefox/latest",
2000 "ie/9..latest",
2001 "iphone/6.0..latest",
2002 "safari/6.0..latest"
2003 ],
2004 "files": "test/*.js",
2005 "harness": "mocha"
2006 },
2007 "version": "1.4.2"
2008}
2009
2010},{}],7:[function(require,module,exports){
2011// Reference https://github.com/bitcoin/bips/blob/master/bip-0066.mediawiki
2012// Format: 0x30 [total-length] 0x02 [R-length] [R] 0x02 [S-length] [S]
2013// NOTE: SIGHASH byte ignored AND restricted, truncate before use
2014
2015var Buffer = require('safe-buffer').Buffer
2016
2017function check (buffer) {
2018 if (buffer.length < 8) return false
2019 if (buffer.length > 72) return false
2020 if (buffer[0] !== 0x30) return false
2021 if (buffer[1] !== buffer.length - 2) return false
2022 if (buffer[2] !== 0x02) return false
2023
2024 var lenR = buffer[3]
2025 if (lenR === 0) return false
2026 if (5 + lenR >= buffer.length) return false
2027 if (buffer[4 + lenR] !== 0x02) return false
2028
2029 var lenS = buffer[5 + lenR]
2030 if (lenS === 0) return false
2031 if ((6 + lenR + lenS) !== buffer.length) return false
2032
2033 if (buffer[4] & 0x80) return false
2034 if (lenR > 1 && (buffer[4] === 0x00) && !(buffer[5] & 0x80)) return false
2035
2036 if (buffer[lenR + 6] & 0x80) return false
2037 if (lenS > 1 && (buffer[lenR + 6] === 0x00) && !(buffer[lenR + 7] & 0x80)) return false
2038 return true
2039}
2040
2041function decode (buffer) {
2042 if (buffer.length < 8) throw new Error('DER sequence length is too short')
2043 if (buffer.length > 72) throw new Error('DER sequence length is too long')
2044 if (buffer[0] !== 0x30) throw new Error('Expected DER sequence')
2045 if (buffer[1] !== buffer.length - 2) throw new Error('DER sequence length is invalid')
2046 if (buffer[2] !== 0x02) throw new Error('Expected DER integer')
2047
2048 var lenR = buffer[3]
2049 if (lenR === 0) throw new Error('R length is zero')
2050 if (5 + lenR >= buffer.length) throw new Error('R length is too long')
2051 if (buffer[4 + lenR] !== 0x02) throw new Error('Expected DER integer (2)')
2052
2053 var lenS = buffer[5 + lenR]
2054 if (lenS === 0) throw new Error('S length is zero')
2055 if ((6 + lenR + lenS) !== buffer.length) throw new Error('S length is invalid')
2056
2057 if (buffer[4] & 0x80) throw new Error('R value is negative')
2058 if (lenR > 1 && (buffer[4] === 0x00) && !(buffer[5] & 0x80)) throw new Error('R value excessively padded')
2059
2060 if (buffer[lenR + 6] & 0x80) throw new Error('S value is negative')
2061 if (lenS > 1 && (buffer[lenR + 6] === 0x00) && !(buffer[lenR + 7] & 0x80)) throw new Error('S value excessively padded')
2062
2063 // non-BIP66 - extract R, S values
2064 return {
2065 r: buffer.slice(4, 4 + lenR),
2066 s: buffer.slice(6 + lenR)
2067 }
2068}
2069
2070/*
2071 * Expects r and s to be positive DER integers.
2072 *
2073 * The DER format uses the most significant bit as a sign bit (& 0x80).
2074 * If the significant bit is set AND the integer is positive, a 0x00 is prepended.
2075 *
2076 * Examples:
2077 *
2078 * 0 => 0x00
2079 * 1 => 0x01
2080 * -1 => 0xff
2081 * 127 => 0x7f
2082 * -127 => 0x81
2083 * 128 => 0x0080
2084 * -128 => 0x80
2085 * 255 => 0x00ff
2086 * -255 => 0xff01
2087 * 16300 => 0x3fac
2088 * -16300 => 0xc054
2089 * 62300 => 0x00f35c
2090 * -62300 => 0xff0ca4
2091*/
2092function encode (r, s) {
2093 var lenR = r.length
2094 var lenS = s.length
2095 if (lenR === 0) throw new Error('R length is zero')
2096 if (lenS === 0) throw new Error('S length is zero')
2097 if (lenR > 33) throw new Error('R length is too long')
2098 if (lenS > 33) throw new Error('S length is too long')
2099 if (r[0] & 0x80) throw new Error('R value is negative')
2100 if (s[0] & 0x80) throw new Error('S value is negative')
2101 if (lenR > 1 && (r[0] === 0x00) && !(r[1] & 0x80)) throw new Error('R value excessively padded')
2102 if (lenS > 1 && (s[0] === 0x00) && !(s[1] & 0x80)) throw new Error('S value excessively padded')
2103
2104 var signature = Buffer.allocUnsafe(6 + lenR + lenS)
2105
2106 // 0x30 [total-length] 0x02 [R-length] [R] 0x02 [S-length] [S]
2107 signature[0] = 0x30
2108 signature[1] = signature.length - 2
2109 signature[2] = 0x02
2110 signature[3] = r.length
2111 r.copy(signature, 4)
2112 signature[4 + lenR] = 0x02
2113 signature[5 + lenR] = s.length
2114 s.copy(signature, 6 + lenR)
2115
2116 return signature
2117}
2118
2119module.exports = {
2120 check: check,
2121 decode: decode,
2122 encode: encode
2123}
2124
2125},{"safe-buffer":38}],8:[function(require,module,exports){
2126module.exports={
2127 "OP_FALSE": 0,
2128 "OP_0": 0,
2129 "OP_PUSHDATA1": 76,
2130 "OP_PUSHDATA2": 77,
2131 "OP_PUSHDATA4": 78,
2132 "OP_1NEGATE": 79,
2133 "OP_RESERVED": 80,
2134 "OP_TRUE": 81,
2135 "OP_1": 81,
2136 "OP_2": 82,
2137 "OP_3": 83,
2138 "OP_4": 84,
2139 "OP_5": 85,
2140 "OP_6": 86,
2141 "OP_7": 87,
2142 "OP_8": 88,
2143 "OP_9": 89,
2144 "OP_10": 90,
2145 "OP_11": 91,
2146 "OP_12": 92,
2147 "OP_13": 93,
2148 "OP_14": 94,
2149 "OP_15": 95,
2150 "OP_16": 96,
2151
2152 "OP_NOP": 97,
2153 "OP_VER": 98,
2154 "OP_IF": 99,
2155 "OP_NOTIF": 100,
2156 "OP_VERIF": 101,
2157 "OP_VERNOTIF": 102,
2158 "OP_ELSE": 103,
2159 "OP_ENDIF": 104,
2160 "OP_VERIFY": 105,
2161 "OP_RETURN": 106,
2162
2163 "OP_TOALTSTACK": 107,
2164 "OP_FROMALTSTACK": 108,
2165 "OP_2DROP": 109,
2166 "OP_2DUP": 110,
2167 "OP_3DUP": 111,
2168 "OP_2OVER": 112,
2169 "OP_2ROT": 113,
2170 "OP_2SWAP": 114,
2171 "OP_IFDUP": 115,
2172 "OP_DEPTH": 116,
2173 "OP_DROP": 117,
2174 "OP_DUP": 118,
2175 "OP_NIP": 119,
2176 "OP_OVER": 120,
2177 "OP_PICK": 121,
2178 "OP_ROLL": 122,
2179 "OP_ROT": 123,
2180 "OP_SWAP": 124,
2181 "OP_TUCK": 125,
2182
2183 "OP_CAT": 126,
2184 "OP_SUBSTR": 127,
2185 "OP_LEFT": 128,
2186 "OP_RIGHT": 129,
2187 "OP_SIZE": 130,
2188
2189 "OP_INVERT": 131,
2190 "OP_AND": 132,
2191 "OP_OR": 133,
2192 "OP_XOR": 134,
2193 "OP_EQUAL": 135,
2194 "OP_EQUALVERIFY": 136,
2195 "OP_RESERVED1": 137,
2196 "OP_RESERVED2": 138,
2197
2198 "OP_1ADD": 139,
2199 "OP_1SUB": 140,
2200 "OP_2MUL": 141,
2201 "OP_2DIV": 142,
2202 "OP_NEGATE": 143,
2203 "OP_ABS": 144,
2204 "OP_NOT": 145,
2205 "OP_0NOTEQUAL": 146,
2206 "OP_ADD": 147,
2207 "OP_SUB": 148,
2208 "OP_MUL": 149,
2209 "OP_DIV": 150,
2210 "OP_MOD": 151,
2211 "OP_LSHIFT": 152,
2212 "OP_RSHIFT": 153,
2213
2214 "OP_BOOLAND": 154,
2215 "OP_BOOLOR": 155,
2216 "OP_NUMEQUAL": 156,
2217 "OP_NUMEQUALVERIFY": 157,
2218 "OP_NUMNOTEQUAL": 158,
2219 "OP_LESSTHAN": 159,
2220 "OP_GREATERTHAN": 160,
2221 "OP_LESSTHANOREQUAL": 161,
2222 "OP_GREATERTHANOREQUAL": 162,
2223 "OP_MIN": 163,
2224 "OP_MAX": 164,
2225
2226 "OP_WITHIN": 165,
2227
2228 "OP_RIPEMD160": 166,
2229 "OP_SHA1": 167,
2230 "OP_SHA256": 168,
2231 "OP_HASH160": 169,
2232 "OP_HASH256": 170,
2233 "OP_CODESEPARATOR": 171,
2234 "OP_CHECKSIG": 172,
2235 "OP_CHECKSIGVERIFY": 173,
2236 "OP_CHECKMULTISIG": 174,
2237 "OP_CHECKMULTISIGVERIFY": 175,
2238
2239 "OP_NOP1": 176,
2240
2241 "OP_NOP2": 177,
2242 "OP_CHECKLOCKTIMEVERIFY": 177,
2243
2244 "OP_NOP3": 178,
2245 "OP_CHECKSEQUENCEVERIFY": 178,
2246
2247 "OP_NOP4": 179,
2248 "OP_NOP5": 180,
2249 "OP_NOP6": 181,
2250 "OP_NOP7": 182,
2251 "OP_NOP8": 183,
2252 "OP_NOP9": 184,
2253 "OP_NOP10": 185,
2254
2255 "OP_PUBKEYHASH": 253,
2256 "OP_PUBKEY": 254,
2257 "OP_INVALIDOPCODE": 255
2258}
2259
2260},{}],9:[function(require,module,exports){
2261var OPS = require('./index.json')
2262
2263var map = {}
2264for (var op in OPS) {
2265 var code = OPS[op]
2266 map[code] = op
2267}
2268
2269module.exports = map
2270
2271},{"./index.json":8}],10:[function(require,module,exports){
2272var basex = require('base-x')
2273var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
2274
2275module.exports = basex(ALPHABET)
2276
2277},{"base-x":1}],11:[function(require,module,exports){
2278'use strict'
2279
2280var base58 = require('bs58')
2281var Buffer = require('safe-buffer').Buffer
2282
2283module.exports = function (checksumFn) {
2284 // Encode a buffer as a base58-check encoded string
2285 function encode (payload) {
2286 var checksum = checksumFn(payload)
2287
2288 return base58.encode(Buffer.concat([
2289 payload,
2290 checksum
2291 ], payload.length + 4))
2292 }
2293
2294 function decodeRaw (buffer) {
2295 var payload = buffer.slice(0, -4)
2296 var checksum = buffer.slice(-4)
2297 var newChecksum = checksumFn(payload)
2298
2299 if (checksum[0] ^ newChecksum[0] |
2300 checksum[1] ^ newChecksum[1] |
2301 checksum[2] ^ newChecksum[2] |
2302 checksum[3] ^ newChecksum[3]) return
2303
2304 return payload
2305 }
2306
2307 // Decode a base58-check encoded string to a buffer, no result if checksum is wrong
2308 function decodeUnsafe (string) {
2309 var buffer = base58.decodeUnsafe(string)
2310 if (!buffer) return
2311
2312 return decodeRaw(buffer)
2313 }
2314
2315 function decode (string) {
2316 var buffer = base58.decode(string)
2317 var payload = decodeRaw(buffer, checksumFn)
2318 if (!payload) throw new Error('Invalid checksum')
2319 return payload
2320 }
2321
2322 return {
2323 encode: encode,
2324 decode: decode,
2325 decodeUnsafe: decodeUnsafe
2326 }
2327}
2328
2329},{"bs58":10,"safe-buffer":38}],12:[function(require,module,exports){
2330(function (Buffer){
2331'use strict'
2332
2333var createHash = require('create-hash')
2334var bs58grscheckBase = require('./base')
2335var groestlhash = require('groestl-hash-js')
2336
2337// GROESTL512(GROESTL512(buffer))
2338function groestl (buffer) {
2339 return Buffer(groestlhash.groestl_2(buffer, 1, 1))
2340}
2341
2342module.exports = bs58grscheckBase(groestl)
2343
2344}).call(this,require("buffer").Buffer)
2345},{"./base":11,"buffer":96,"create-hash":14,"groestl-hash-js":27}],13:[function(require,module,exports){
2346var Buffer = require('safe-buffer').Buffer
2347var Transform = require('stream').Transform
2348var StringDecoder = require('string_decoder').StringDecoder
2349var inherits = require('inherits')
2350
2351function CipherBase (hashMode) {
2352 Transform.call(this)
2353 this.hashMode = typeof hashMode === 'string'
2354 if (this.hashMode) {
2355 this[hashMode] = this._finalOrDigest
2356 } else {
2357 this.final = this._finalOrDigest
2358 }
2359 if (this._final) {
2360 this.__final = this._final
2361 this._final = null
2362 }
2363 this._decoder = null
2364 this._encoding = null
2365}
2366inherits(CipherBase, Transform)
2367
2368CipherBase.prototype.update = function (data, inputEnc, outputEnc) {
2369 if (typeof data === 'string') {
2370 data = Buffer.from(data, inputEnc)
2371 }
2372
2373 var outData = this._update(data)
2374 if (this.hashMode) return this
2375
2376 if (outputEnc) {
2377 outData = this._toString(outData, outputEnc)
2378 }
2379
2380 return outData
2381}
2382
2383CipherBase.prototype.setAutoPadding = function () {}
2384CipherBase.prototype.getAuthTag = function () {
2385 throw new Error('trying to get auth tag in unsupported state')
2386}
2387
2388CipherBase.prototype.setAuthTag = function () {
2389 throw new Error('trying to set auth tag in unsupported state')
2390}
2391
2392CipherBase.prototype.setAAD = function () {
2393 throw new Error('trying to set aad in unsupported state')
2394}
2395
2396CipherBase.prototype._transform = function (data, _, next) {
2397 var err
2398 try {
2399 if (this.hashMode) {
2400 this._update(data)
2401 } else {
2402 this.push(this._update(data))
2403 }
2404 } catch (e) {
2405 err = e
2406 } finally {
2407 next(err)
2408 }
2409}
2410CipherBase.prototype._flush = function (done) {
2411 var err
2412 try {
2413 this.push(this.__final())
2414 } catch (e) {
2415 err = e
2416 }
2417
2418 done(err)
2419}
2420CipherBase.prototype._finalOrDigest = function (outputEnc) {
2421 var outData = this.__final() || Buffer.alloc(0)
2422 if (outputEnc) {
2423 outData = this._toString(outData, outputEnc, true)
2424 }
2425 return outData
2426}
2427
2428CipherBase.prototype._toString = function (value, enc, fin) {
2429 if (!this._decoder) {
2430 this._decoder = new StringDecoder(enc)
2431 this._encoding = enc
2432 }
2433
2434 if (this._encoding !== enc) throw new Error('can\'t switch encodings')
2435
2436 var out = this._decoder.write(value)
2437 if (fin) {
2438 out += this._decoder.end()
2439 }
2440
2441 return out
2442}
2443
2444module.exports = CipherBase
2445
2446},{"inherits":32,"safe-buffer":38,"stream":122,"string_decoder":123}],14:[function(require,module,exports){
2447'use strict'
2448var inherits = require('inherits')
2449var MD5 = require('md5.js')
2450var RIPEMD160 = require('ripemd160')
2451var sha = require('sha.js')
2452var Base = require('cipher-base')
2453
2454function Hash (hash) {
2455 Base.call(this, 'digest')
2456
2457 this._hash = hash
2458}
2459
2460inherits(Hash, Base)
2461
2462Hash.prototype._update = function (data) {
2463 this._hash.update(data)
2464}
2465
2466Hash.prototype._final = function () {
2467 return this._hash.digest()
2468}
2469
2470module.exports = function createHash (alg) {
2471 alg = alg.toLowerCase()
2472 if (alg === 'md5') return new MD5()
2473 if (alg === 'rmd160' || alg === 'ripemd160') return new RIPEMD160()
2474
2475 return new Hash(sha(alg))
2476}
2477
2478},{"cipher-base":13,"inherits":32,"md5.js":33,"ripemd160":37,"sha.js":40}],15:[function(require,module,exports){
2479var MD5 = require('md5.js')
2480
2481module.exports = function (buffer) {
2482 return new MD5().update(buffer).digest()
2483}
2484
2485},{"md5.js":33}],16:[function(require,module,exports){
2486'use strict'
2487var inherits = require('inherits')
2488var Legacy = require('./legacy')
2489var Base = require('cipher-base')
2490var Buffer = require('safe-buffer').Buffer
2491var md5 = require('create-hash/md5')
2492var RIPEMD160 = require('ripemd160')
2493
2494var sha = require('sha.js')
2495
2496var ZEROS = Buffer.alloc(128)
2497
2498function Hmac (alg, key) {
2499 Base.call(this, 'digest')
2500 if (typeof key === 'string') {
2501 key = Buffer.from(key)
2502 }
2503
2504 var blocksize = (alg === 'sha512' || alg === 'sha384') ? 128 : 64
2505
2506 this._alg = alg
2507 this._key = key
2508 if (key.length > blocksize) {
2509 var hash = alg === 'rmd160' ? new RIPEMD160() : sha(alg)
2510 key = hash.update(key).digest()
2511 } else if (key.length < blocksize) {
2512 key = Buffer.concat([key, ZEROS], blocksize)
2513 }
2514
2515 var ipad = this._ipad = Buffer.allocUnsafe(blocksize)
2516 var opad = this._opad = Buffer.allocUnsafe(blocksize)
2517
2518 for (var i = 0; i < blocksize; i++) {
2519 ipad[i] = key[i] ^ 0x36
2520 opad[i] = key[i] ^ 0x5C
2521 }
2522 this._hash = alg === 'rmd160' ? new RIPEMD160() : sha(alg)
2523 this._hash.update(ipad)
2524}
2525
2526inherits(Hmac, Base)
2527
2528Hmac.prototype._update = function (data) {
2529 this._hash.update(data)
2530}
2531
2532Hmac.prototype._final = function () {
2533 var h = this._hash.digest()
2534 var hash = this._alg === 'rmd160' ? new RIPEMD160() : sha(this._alg)
2535 return hash.update(this._opad).update(h).digest()
2536}
2537
2538module.exports = function createHmac (alg, key) {
2539 alg = alg.toLowerCase()
2540 if (alg === 'rmd160' || alg === 'ripemd160') {
2541 return new Hmac('rmd160', key)
2542 }
2543 if (alg === 'md5') {
2544 return new Legacy(md5, key)
2545 }
2546 return new Hmac(alg, key)
2547}
2548
2549},{"./legacy":17,"cipher-base":13,"create-hash/md5":15,"inherits":32,"ripemd160":37,"safe-buffer":38,"sha.js":40}],17:[function(require,module,exports){
2550'use strict'
2551var inherits = require('inherits')
2552var Buffer = require('safe-buffer').Buffer
2553
2554var Base = require('cipher-base')
2555
2556var ZEROS = Buffer.alloc(128)
2557var blocksize = 64
2558
2559function Hmac (alg, key) {
2560 Base.call(this, 'digest')
2561 if (typeof key === 'string') {
2562 key = Buffer.from(key)
2563 }
2564
2565 this._alg = alg
2566 this._key = key
2567
2568 if (key.length > blocksize) {
2569 key = alg(key)
2570 } else if (key.length < blocksize) {
2571 key = Buffer.concat([key, ZEROS], blocksize)
2572 }
2573
2574 var ipad = this._ipad = Buffer.allocUnsafe(blocksize)
2575 var opad = this._opad = Buffer.allocUnsafe(blocksize)
2576
2577 for (var i = 0; i < blocksize; i++) {
2578 ipad[i] = key[i] ^ 0x36
2579 opad[i] = key[i] ^ 0x5C
2580 }
2581
2582 this._hash = [ipad]
2583}
2584
2585inherits(Hmac, Base)
2586
2587Hmac.prototype._update = function (data) {
2588 this._hash.push(data)
2589}
2590
2591Hmac.prototype._final = function () {
2592 var h = this._alg(Buffer.concat(this._hash))
2593 return this._alg(Buffer.concat([this._opad, h]))
2594}
2595module.exports = Hmac
2596
2597},{"cipher-base":13,"inherits":32,"safe-buffer":38}],18:[function(require,module,exports){
2598var assert = require('assert')
2599var BigInteger = require('bigi')
2600
2601var Point = require('./point')
2602
2603function Curve (p, a, b, Gx, Gy, n, h) {
2604 this.p = p
2605 this.a = a
2606 this.b = b
2607 this.G = Point.fromAffine(this, Gx, Gy)
2608 this.n = n
2609 this.h = h
2610
2611 this.infinity = new Point(this, null, null, BigInteger.ZERO)
2612
2613 // result caching
2614 this.pOverFour = p.add(BigInteger.ONE).shiftRight(2)
2615
2616 // determine size of p in bytes
2617 this.pLength = Math.floor((this.p.bitLength() + 7) / 8)
2618}
2619
2620Curve.prototype.pointFromX = function (isOdd, x) {
2621 var alpha = x.pow(3).add(this.a.multiply(x)).add(this.b).mod(this.p)
2622 var beta = alpha.modPow(this.pOverFour, this.p) // XXX: not compatible with all curves
2623
2624 var y = beta
2625 if (beta.isEven() ^ !isOdd) {
2626 y = this.p.subtract(y) // -y % p
2627 }
2628
2629 return Point.fromAffine(this, x, y)
2630}
2631
2632Curve.prototype.isInfinity = function (Q) {
2633 if (Q === this.infinity) return true
2634
2635 return Q.z.signum() === 0 && Q.y.signum() !== 0
2636}
2637
2638Curve.prototype.isOnCurve = function (Q) {
2639 if (this.isInfinity(Q)) return true
2640
2641 var x = Q.affineX
2642 var y = Q.affineY
2643 var a = this.a
2644 var b = this.b
2645 var p = this.p
2646
2647 // Check that xQ and yQ are integers in the interval [0, p - 1]
2648 if (x.signum() < 0 || x.compareTo(p) >= 0) return false
2649 if (y.signum() < 0 || y.compareTo(p) >= 0) return false
2650
2651 // and check that y^2 = x^3 + ax + b (mod p)
2652 var lhs = y.square().mod(p)
2653 var rhs = x.pow(3).add(a.multiply(x)).add(b).mod(p)
2654 return lhs.equals(rhs)
2655}
2656
2657/**
2658 * Validate an elliptic curve point.
2659 *
2660 * See SEC 1, section 3.2.2.1: Elliptic Curve Public Key Validation Primitive
2661 */
2662Curve.prototype.validate = function (Q) {
2663 // Check Q != O
2664 assert(!this.isInfinity(Q), 'Point is at infinity')
2665 assert(this.isOnCurve(Q), 'Point is not on the curve')
2666
2667 // Check nQ = O (where Q is a scalar multiple of G)
2668 var nQ = Q.multiply(this.n)
2669 assert(this.isInfinity(nQ), 'Point is not a scalar multiple of G')
2670
2671 return true
2672}
2673
2674module.exports = Curve
2675
2676},{"./point":22,"assert":90,"bigi":25}],19:[function(require,module,exports){
2677module.exports={
2678 "secp128r1": {
2679 "p": "fffffffdffffffffffffffffffffffff",
2680 "a": "fffffffdfffffffffffffffffffffffc",
2681 "b": "e87579c11079f43dd824993c2cee5ed3",
2682 "n": "fffffffe0000000075a30d1b9038a115",
2683 "h": "01",
2684 "Gx": "161ff7528b899b2d0c28607ca52c5b86",
2685 "Gy": "cf5ac8395bafeb13c02da292dded7a83"
2686 },
2687 "secp160k1": {
2688 "p": "fffffffffffffffffffffffffffffffeffffac73",
2689 "a": "00",
2690 "b": "07",
2691 "n": "0100000000000000000001b8fa16dfab9aca16b6b3",
2692 "h": "01",
2693 "Gx": "3b4c382ce37aa192a4019e763036f4f5dd4d7ebb",
2694 "Gy": "938cf935318fdced6bc28286531733c3f03c4fee"
2695 },
2696 "secp160r1": {
2697 "p": "ffffffffffffffffffffffffffffffff7fffffff",
2698 "a": "ffffffffffffffffffffffffffffffff7ffffffc",
2699 "b": "1c97befc54bd7a8b65acf89f81d4d4adc565fa45",
2700 "n": "0100000000000000000001f4c8f927aed3ca752257",
2701 "h": "01",
2702 "Gx": "4a96b5688ef573284664698968c38bb913cbfc82",
2703 "Gy": "23a628553168947d59dcc912042351377ac5fb32"
2704 },
2705 "secp192k1": {
2706 "p": "fffffffffffffffffffffffffffffffffffffffeffffee37",
2707 "a": "00",
2708 "b": "03",
2709 "n": "fffffffffffffffffffffffe26f2fc170f69466a74defd8d",
2710 "h": "01",
2711 "Gx": "db4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d",
2712 "Gy": "9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d"
2713 },
2714 "secp192r1": {
2715 "p": "fffffffffffffffffffffffffffffffeffffffffffffffff",
2716 "a": "fffffffffffffffffffffffffffffffefffffffffffffffc",
2717 "b": "64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1",
2718 "n": "ffffffffffffffffffffffff99def836146bc9b1b4d22831",
2719 "h": "01",
2720 "Gx": "188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012",
2721 "Gy": "07192b95ffc8da78631011ed6b24cdd573f977a11e794811"
2722 },
2723 "secp256k1": {
2724 "p": "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",
2725 "a": "00",
2726 "b": "07",
2727 "n": "fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",
2728 "h": "01",
2729 "Gx": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
2730 "Gy": "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"
2731 },
2732 "secp256r1": {
2733 "p": "ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",
2734 "a": "ffffffff00000001000000000000000000000000fffffffffffffffffffffffc",
2735 "b": "5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b",
2736 "n": "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",
2737 "h": "01",
2738 "Gx": "6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296",
2739 "Gy": "4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"
2740 }
2741}
2742
2743},{}],20:[function(require,module,exports){
2744var Point = require('./point')
2745var Curve = require('./curve')
2746
2747var getCurveByName = require('./names')
2748
2749module.exports = {
2750 Curve: Curve,
2751 Point: Point,
2752 getCurveByName: getCurveByName
2753}
2754
2755},{"./curve":18,"./names":21,"./point":22}],21:[function(require,module,exports){
2756var BigInteger = require('bigi')
2757
2758var curves = require('./curves.json')
2759var Curve = require('./curve')
2760
2761function getCurveByName (name) {
2762 var curve = curves[name]
2763 if (!curve) return null
2764
2765 var p = new BigInteger(curve.p, 16)
2766 var a = new BigInteger(curve.a, 16)
2767 var b = new BigInteger(curve.b, 16)
2768 var n = new BigInteger(curve.n, 16)
2769 var h = new BigInteger(curve.h, 16)
2770 var Gx = new BigInteger(curve.Gx, 16)
2771 var Gy = new BigInteger(curve.Gy, 16)
2772
2773 return new Curve(p, a, b, Gx, Gy, n, h)
2774}
2775
2776module.exports = getCurveByName
2777
2778},{"./curve":18,"./curves.json":19,"bigi":25}],22:[function(require,module,exports){
2779var assert = require('assert')
2780var Buffer = require('safe-buffer').Buffer
2781var BigInteger = require('bigi')
2782
2783var THREE = BigInteger.valueOf(3)
2784
2785function Point (curve, x, y, z) {
2786 assert.notStrictEqual(z, undefined, 'Missing Z coordinate')
2787
2788 this.curve = curve
2789 this.x = x
2790 this.y = y
2791 this.z = z
2792 this._zInv = null
2793
2794 this.compressed = true
2795}
2796
2797Object.defineProperty(Point.prototype, 'zInv', {
2798 get: function () {
2799 if (this._zInv === null) {
2800 this._zInv = this.z.modInverse(this.curve.p)
2801 }
2802
2803 return this._zInv
2804 }
2805})
2806
2807Object.defineProperty(Point.prototype, 'affineX', {
2808 get: function () {
2809 return this.x.multiply(this.zInv).mod(this.curve.p)
2810 }
2811})
2812
2813Object.defineProperty(Point.prototype, 'affineY', {
2814 get: function () {
2815 return this.y.multiply(this.zInv).mod(this.curve.p)
2816 }
2817})
2818
2819Point.fromAffine = function (curve, x, y) {
2820 return new Point(curve, x, y, BigInteger.ONE)
2821}
2822
2823Point.prototype.equals = function (other) {
2824 if (other === this) return true
2825 if (this.curve.isInfinity(this)) return this.curve.isInfinity(other)
2826 if (this.curve.isInfinity(other)) return this.curve.isInfinity(this)
2827
2828 // u = Y2 * Z1 - Y1 * Z2
2829 var u = other.y.multiply(this.z).subtract(this.y.multiply(other.z)).mod(this.curve.p)
2830
2831 if (u.signum() !== 0) return false
2832
2833 // v = X2 * Z1 - X1 * Z2
2834 var v = other.x.multiply(this.z).subtract(this.x.multiply(other.z)).mod(this.curve.p)
2835
2836 return v.signum() === 0
2837}
2838
2839Point.prototype.negate = function () {
2840 var y = this.curve.p.subtract(this.y)
2841
2842 return new Point(this.curve, this.x, y, this.z)
2843}
2844
2845Point.prototype.add = function (b) {
2846 if (this.curve.isInfinity(this)) return b
2847 if (this.curve.isInfinity(b)) return this
2848
2849 var x1 = this.x
2850 var y1 = this.y
2851 var x2 = b.x
2852 var y2 = b.y
2853
2854 // u = Y2 * Z1 - Y1 * Z2
2855 var u = y2.multiply(this.z).subtract(y1.multiply(b.z)).mod(this.curve.p)
2856 // v = X2 * Z1 - X1 * Z2
2857 var v = x2.multiply(this.z).subtract(x1.multiply(b.z)).mod(this.curve.p)
2858
2859 if (v.signum() === 0) {
2860 if (u.signum() === 0) {
2861 return this.twice() // this == b, so double
2862 }
2863
2864 return this.curve.infinity // this = -b, so infinity
2865 }
2866
2867 var v2 = v.square()
2868 var v3 = v2.multiply(v)
2869 var x1v2 = x1.multiply(v2)
2870 var zu2 = u.square().multiply(this.z)
2871
2872 // x3 = v * (z2 * (z1 * u^2 - 2 * x1 * v^2) - v^3)
2873 var x3 = zu2.subtract(x1v2.shiftLeft(1)).multiply(b.z).subtract(v3).multiply(v).mod(this.curve.p)
2874 // y3 = z2 * (3 * x1 * u * v^2 - y1 * v^3 - z1 * u^3) + u * v^3
2875 var y3 = x1v2.multiply(THREE).multiply(u).subtract(y1.multiply(v3)).subtract(zu2.multiply(u)).multiply(b.z).add(u.multiply(v3)).mod(this.curve.p)
2876 // z3 = v^3 * z1 * z2
2877 var z3 = v3.multiply(this.z).multiply(b.z).mod(this.curve.p)
2878
2879 return new Point(this.curve, x3, y3, z3)
2880}
2881
2882Point.prototype.twice = function () {
2883 if (this.curve.isInfinity(this)) return this
2884 if (this.y.signum() === 0) return this.curve.infinity
2885
2886 var x1 = this.x
2887 var y1 = this.y
2888
2889 var y1z1 = y1.multiply(this.z).mod(this.curve.p)
2890 var y1sqz1 = y1z1.multiply(y1).mod(this.curve.p)
2891 var a = this.curve.a
2892
2893 // w = 3 * x1^2 + a * z1^2
2894 var w = x1.square().multiply(THREE)
2895
2896 if (a.signum() !== 0) {
2897 w = w.add(this.z.square().multiply(a))
2898 }
2899
2900 w = w.mod(this.curve.p)
2901 // x3 = 2 * y1 * z1 * (w^2 - 8 * x1 * y1^2 * z1)
2902 var x3 = w.square().subtract(x1.shiftLeft(3).multiply(y1sqz1)).shiftLeft(1).multiply(y1z1).mod(this.curve.p)
2903 // y3 = 4 * y1^2 * z1 * (3 * w * x1 - 2 * y1^2 * z1) - w^3
2904 var y3 = w.multiply(THREE).multiply(x1).subtract(y1sqz1.shiftLeft(1)).shiftLeft(2).multiply(y1sqz1).subtract(w.pow(3)).mod(this.curve.p)
2905 // z3 = 8 * (y1 * z1)^3
2906 var z3 = y1z1.pow(3).shiftLeft(3).mod(this.curve.p)
2907
2908 return new Point(this.curve, x3, y3, z3)
2909}
2910
2911// Simple NAF (Non-Adjacent Form) multiplication algorithm
2912// TODO: modularize the multiplication algorithm
2913Point.prototype.multiply = function (k) {
2914 if (this.curve.isInfinity(this)) return this
2915 if (k.signum() === 0) return this.curve.infinity
2916
2917 var e = k
2918 var h = e.multiply(THREE)
2919
2920 var neg = this.negate()
2921 var R = this
2922
2923 for (var i = h.bitLength() - 2; i > 0; --i) {
2924 var hBit = h.testBit(i)
2925 var eBit = e.testBit(i)
2926
2927 R = R.twice()
2928
2929 if (hBit !== eBit) {
2930 R = R.add(hBit ? this : neg)
2931 }
2932 }
2933
2934 return R
2935}
2936
2937// Compute this*j + x*k (simultaneous multiplication)
2938Point.prototype.multiplyTwo = function (j, x, k) {
2939 var i = Math.max(j.bitLength(), k.bitLength()) - 1
2940 var R = this.curve.infinity
2941 var both = this.add(x)
2942
2943 while (i >= 0) {
2944 var jBit = j.testBit(i)
2945 var kBit = k.testBit(i)
2946
2947 R = R.twice()
2948
2949 if (jBit) {
2950 if (kBit) {
2951 R = R.add(both)
2952 } else {
2953 R = R.add(this)
2954 }
2955 } else if (kBit) {
2956 R = R.add(x)
2957 }
2958 --i
2959 }
2960
2961 return R
2962}
2963
2964Point.prototype.getEncoded = function (compressed) {
2965 if (compressed == null) compressed = this.compressed
2966 if (this.curve.isInfinity(this)) return Buffer.alloc(1, 0) // Infinity point encoded is simply '00'
2967
2968 var x = this.affineX
2969 var y = this.affineY
2970 var byteLength = this.curve.pLength
2971 var buffer
2972
2973 // 0x02/0x03 | X
2974 if (compressed) {
2975 buffer = Buffer.allocUnsafe(1 + byteLength)
2976 buffer.writeUInt8(y.isEven() ? 0x02 : 0x03, 0)
2977
2978 // 0x04 | X | Y
2979 } else {
2980 buffer = Buffer.allocUnsafe(1 + byteLength + byteLength)
2981 buffer.writeUInt8(0x04, 0)
2982
2983 y.toBuffer(byteLength).copy(buffer, 1 + byteLength)
2984 }
2985
2986 x.toBuffer(byteLength).copy(buffer, 1)
2987
2988 return buffer
2989}
2990
2991Point.decodeFrom = function (curve, buffer) {
2992 var type = buffer.readUInt8(0)
2993 var compressed = (type !== 4)
2994
2995 var byteLength = Math.floor((curve.p.bitLength() + 7) / 8)
2996 var x = BigInteger.fromBuffer(buffer.slice(1, 1 + byteLength))
2997
2998 var Q
2999 if (compressed) {
3000 assert.equal(buffer.length, byteLength + 1, 'Invalid sequence length')
3001 assert(type === 0x02 || type === 0x03, 'Invalid sequence tag')
3002
3003 var isOdd = (type === 0x03)
3004 Q = curve.pointFromX(isOdd, x)
3005 } else {
3006 assert.equal(buffer.length, 1 + byteLength + byteLength, 'Invalid sequence length')
3007
3008 var y = BigInteger.fromBuffer(buffer.slice(1 + byteLength))
3009 Q = Point.fromAffine(curve, x, y)
3010 }
3011
3012 Q.compressed = compressed
3013 return Q
3014}
3015
3016Point.prototype.toString = function () {
3017 if (this.curve.isInfinity(this)) return '(INFINITY)'
3018
3019 return '(' + this.affineX.toString() + ',' + this.affineY.toString() + ')'
3020}
3021
3022module.exports = Point
3023
3024},{"assert":90,"bigi":25,"safe-buffer":38}],23:[function(require,module,exports){
3025arguments[4][3][0].apply(exports,arguments)
3026},{"../package.json":26,"dup":3}],24:[function(require,module,exports){
3027arguments[4][4][0].apply(exports,arguments)
3028},{"./bigi":23,"assert":90,"buffer":96,"dup":4}],25:[function(require,module,exports){
3029arguments[4][5][0].apply(exports,arguments)
3030},{"./bigi":23,"./convert":24,"dup":5}],26:[function(require,module,exports){
3031module.exports={
3032 "_args": [
3033 [
3034 "bigi@^1.1.0",
3035 "/home/hashengineering/hashengineering/groestlcoinjs-lib/node_modules/ecurve"
3036 ]
3037 ],
3038 "_from": "bigi@>=1.1.0 <2.0.0",
3039 "_id": "bigi@1.4.2",
3040 "_inCache": true,
3041 "_installable": true,
3042 "_location": "/ecurve/bigi",
3043 "_nodeVersion": "6.1.0",
3044 "_npmOperationalInternal": {
3045 "host": "packages-12-west.internal.npmjs.com",
3046 "tmp": "tmp/bigi-1.4.2.tgz_1469584192413_0.6801238611806184"
3047 },
3048 "_npmUser": {
3049 "email": "jprichardson@gmail.com",
3050 "name": "jprichardson"
3051 },
3052 "_npmVersion": "3.8.6",
3053 "_phantomChildren": {},
3054 "_requested": {
3055 "name": "bigi",
3056 "raw": "bigi@^1.1.0",
3057 "rawSpec": "^1.1.0",
3058 "scope": null,
3059 "spec": ">=1.1.0 <2.0.0",
3060 "type": "range"
3061 },
3062 "_requiredBy": [
3063 "/ecurve"
3064 ],
3065 "_resolved": "https://registry.npmjs.org/bigi/-/bigi-1.4.2.tgz",
3066 "_shasum": "9c665a95f88b8b08fc05cfd731f561859d725825",
3067 "_shrinkwrap": null,
3068 "_spec": "bigi@^1.1.0",
3069 "_where": "/home/hashengineering/hashengineering/groestlcoinjs-lib/node_modules/ecurve",
3070 "bugs": {
3071 "url": "https://github.com/cryptocoinjs/bigi/issues"
3072 },
3073 "dependencies": {},
3074 "description": "Big integers.",
3075 "devDependencies": {
3076 "coveralls": "^2.11.2",
3077 "istanbul": "^0.3.5",
3078 "jshint": "^2.5.1",
3079 "mocha": "^2.1.0",
3080 "mochify": "^2.1.0"
3081 },
3082 "directories": {},
3083 "dist": {
3084 "shasum": "9c665a95f88b8b08fc05cfd731f561859d725825",
3085 "tarball": "https://registry.npmjs.org/bigi/-/bigi-1.4.2.tgz"
3086 },
3087 "gitHead": "c25308081c896ff84702303722bf5ecd8b3f78e3",
3088 "homepage": "https://github.com/cryptocoinjs/bigi#readme",
3089 "keywords": [
3090 "arbitrary",
3091 "arithmetic",
3092 "big",
3093 "bigint",
3094 "biginteger",
3095 "bignumber",
3096 "bitcoin",
3097 "cryptography",
3098 "decimal",
3099 "float",
3100 "int",
3101 "integer",
3102 "math",
3103 "number",
3104 "precision"
3105 ],
3106 "main": "./lib/index.js",
3107 "maintainers": [
3108 {
3109 "name": "midnightlightning",
3110 "email": "boydb@midnightdesign.ws"
3111 },
3112 {
3113 "name": "sidazhang",
3114 "email": "sidazhang89@gmail.com"
3115 },
3116 {
3117 "name": "nadav",
3118 "email": "npm@shesek.info"
3119 },
3120 {
3121 "name": "jprichardson",
3122 "email": "jprichardson@gmail.com"
3123 }
3124 ],
3125 "name": "bigi",
3126 "optionalDependencies": {},
3127 "readme": "ERROR: No README data found!",
3128 "repository": {
3129 "type": "git",
3130 "url": "git+https://github.com/cryptocoinjs/bigi.git"
3131 },
3132 "scripts": {
3133 "browser-test": "mochify --wd -R spec",
3134 "coverage": "istanbul cover ./node_modules/.bin/_mocha -- --reporter list test/*.js",
3135 "coveralls": "npm run-script coverage && node ./node_modules/.bin/coveralls < coverage/lcov.info",
3136 "jshint": "jshint --config jshint.json lib/*.js ; true",
3137 "test": "_mocha -- test/*.js",
3138 "unit": "mocha"
3139 },
3140 "testling": {
3141 "browsers": [
3142 "android-browser/4.2..latest",
3143 "chrome/latest",
3144 "firefox/latest",
3145 "ie/9..latest",
3146 "iphone/6.0..latest",
3147 "safari/6.0..latest"
3148 ],
3149 "files": "test/*.js",
3150 "harness": "mocha"
3151 },
3152 "version": "1.4.2"
3153}
3154
3155},{}],27:[function(require,module,exports){
3156'use strict';
3157
3158var groestl = require('./lib/groestl');
3159var h = require('./lib/helper');
3160
3161var x11hash = module.exports;
3162
3163module.exports.groestl512 = function(str,format, output) {
3164 return groestl(str,format,output);
3165}
3166
3167module.exports.groestl = function(str,format, output) {
3168 var a = groestl(str,format,2);
3169 a = a.slice(0,8);
3170 if (output === 2) {
3171 return a;
3172 }
3173 else if (output === 1) {
3174 return h.int32Buffer2Bytes(a);
3175 }
3176 else {
3177 return h.int32ArrayToHexString(a);
3178 }
3179}
3180
3181module.exports.groestl_2 = function(str,format, output) {
3182 var a = groestl(str,format,2);
3183 a = groestl(a,2,2);
3184 a = a.slice(0,8);
3185 if (output === 2) {
3186 return a;
3187 }
3188 else if (output === 1) {
3189 return h.int32Buffer2Bytes(a);
3190 }
3191 else {
3192 return h.int32ArrayToHexString(a);
3193 }
3194}
3195},{"./lib/groestl":28,"./lib/helper":29}],28:[function(require,module,exports){
3196/////////////////////////////////////
3197//////////// groestl ///////////////
3198
3199//// Written by Quantum Explorer ////
3200////////// Dash Foundation //////////
3201/// Released under the MIT License //
3202/////////////////////////////////////
3203
3204var o = require('./op');
3205var h = require('./helper');
3206
3207var T0 = h.bytes2Int64Buffer(h.b64Decode("xjL0pfSXpcb4b5eEl+uE+O5esJmwx5nu9nqMjYz3jfb/6BcNF+UN/9YK3L3ct73W3hbIscinsd6RbfxU/DlUkWCQ8FDwwFBgAgcFAwUEAwLOLuCp4IepzlbRh32HrH1W58wrGSvVGee1E6ZipnFitU18MeYxmuZN7Fm1mrXDmuyPQM9FzwVFjx+jvJ28Pp0fiUnAQMAJQIn6aJKHku+H+u/QPxU/xRXvspQm6yZ/67KOzkDJQAfJjvvmHQsd7Qv7QW4v7C+C7EGzGqlnqX1ns19DHP0cvv1fRWAl6iWK6kUj+dq/2ka/I1NRAvcCpvdT5EWhlqHTluSbdu1b7S1bm3UoXcJd6sJ14cUkHCTZHOE91Omu6XquPUzyvmq+mGpMbILuWu7YWmx+vcNBw/xBfvXzBgIG8QL1g1LRT9EdT4NojORc5NBcaFFWB/QHovRR0Y1cNFy5NNH54RgIGOkI+eJMrpOu35Piqz6Vc5VNc6til/VT9cRTYiprQT9BVD8qCBwUDBQQDAiVY/ZS9jFSlUbpr2WvjGVGnX/iXuIhXp0wSHgoeGAoMDfP+KH4bqE3ChsRDxEUDwov68S1xF61Lw4VGwkbHAkOJH5aNlpINiQbrbabtjabG9+YRz1HpT3fzadqJmqBJs1O9btpu5xpTn8zTM1M/s1/6lC6n7rPn+oSPy0bLSQbEh2kuZ65Op4dWMScdJywdFg0RnIucmguNDZBdy13bC023BHNss2jsty0nSnuKXPutFtNFvsWtvtbpKU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o.u(0xffe8170d, 0x17e50dff), o.u(0xd60adcbd, 0xdcb7bdd6),
3220// o.u(0xde16c8b1, 0xc8a7b1de), o.u(0x916dfc54, 0xfc395491),
3221// o.u(0x6090f050, 0xf0c05060), o.u(0x02070503, 0x05040302),
3222// o.u(0xce2ee0a9, 0xe087a9ce), o.u(0x56d1877d, 0x87ac7d56),
3223// o.u(0xe7cc2b19, 0x2bd519e7), o.u(0xb513a662, 0xa67162b5),
3224// o.u(0x4d7c31e6, 0x319ae64d), o.u(0xec59b59a, 0xb5c39aec),
3225// o.u(0x8f40cf45, 0xcf05458f), o.u(0x1fa3bc9d, 0xbc3e9d1f),
3226// o.u(0x8949c040, 0xc0094089), o.u(0xfa689287, 0x92ef87fa),
3227// o.u(0xefd03f15, 0x3fc515ef), o.u(0xb29426eb, 0x267febb2),
3228// o.u(0x8ece40c9, 0x4007c98e), o.u(0xfbe61d0b, 0x1ded0bfb),
3229// o.u(0x416e2fec, 0x2f82ec41), o.u(0xb31aa967, 0xa97d67b3),
3230// o.u(0x5f431cfd, 0x1cbefd5f), o.u(0x456025ea, 0x258aea45),
3231// o.u(0x23f9dabf, 0xda46bf23), o.u(0x535102f7, 0x02a6f753),
3232// o.u(0xe445a196, 0xa1d396e4), o.u(0x9b76ed5b, 0xed2d5b9b),
3233// o.u(0x75285dc2, 0x5deac275), o.u(0xe1c5241c, 0x24d91ce1),
3234// o.u(0x3dd4e9ae, 0xe97aae3d), o.u(0x4cf2be6a, 0xbe986a4c),
3235// o.u(0x6c82ee5a, 0xeed85a6c), o.u(0x7ebdc341, 0xc3fc417e),
3236// o.u(0xf5f30602, 0x06f102f5), o.u(0x8352d14f, 0xd11d4f83),
3237// o.u(0x688ce45c, 0xe4d05c68), o.u(0x515607f4, 0x07a2f451),
3238// o.u(0xd18d5c34, 0x5cb934d1), o.u(0xf9e11808, 0x18e908f9),
3239// o.u(0xe24cae93, 0xaedf93e2), o.u(0xab3e9573, 0x954d73ab),
3240// o.u(0x6297f553, 0xf5c45362), o.u(0x2a6b413f, 0x41543f2a),
3241// o.u(0x081c140c, 0x14100c08), o.u(0x9563f652, 0xf6315295),
3242// o.u(0x46e9af65, 0xaf8c6546), o.u(0x9d7fe25e, 0xe2215e9d),
3243// o.u(0x30487828, 0x78602830), o.u(0x37cff8a1, 0xf86ea137),
3244// o.u(0x0a1b110f, 0x11140f0a), o.u(0x2febc4b5, 0xc45eb52f),
3245// o.u(0x0e151b09, 0x1b1c090e), o.u(0x247e5a36, 0x5a483624),
3246// o.u(0x1badb69b, 0xb6369b1b), o.u(0xdf98473d, 0x47a53ddf),
3247// o.u(0xcda76a26, 0x6a8126cd), o.u(0x4ef5bb69, 0xbb9c694e),
3248// o.u(0x7f334ccd, 0x4cfecd7f), o.u(0xea50ba9f, 0xbacf9fea),
3249// o.u(0x123f2d1b, 0x2d241b12), o.u(0x1da4b99e, 0xb93a9e1d),
3250// o.u(0x58c49c74, 0x9cb07458), o.u(0x3446722e, 0x72682e34),
3251// o.u(0x3641772d, 0x776c2d36), o.u(0xdc11cdb2, 0xcda3b2dc),
3252// o.u(0xb49d29ee, 0x2973eeb4), o.u(0x5b4d16fb, 0x16b6fb5b),
3253// o.u(0xa4a501f6, 0x0153f6a4), o.u(0x76a1d74d, 0xd7ec4d76),
3254// o.u(0xb714a361, 0xa37561b7), o.u(0x7d3449ce, 0x49face7d),
3255// o.u(0x52df8d7b, 0x8da47b52), o.u(0xdd9f423e, 0x42a13edd),
3256// o.u(0x5ecd9371, 0x93bc715e), o.u(0x13b1a297, 0xa2269713),
3257// o.u(0xa6a204f5, 0x0457f5a6), o.u(0xb901b868, 0xb86968b9),
3258// o.u(0x00000000, 0x00000000), o.u(0xc1b5742c, 0x74992cc1),
3259// o.u(0x40e0a060, 0xa0806040), o.u(0xe3c2211f, 0x21dd1fe3),
3260// o.u(0x793a43c8, 0x43f2c879), o.u(0xb69a2ced, 0x2c77edb6),
3261// o.u(0xd40dd9be, 0xd9b3bed4), o.u(0x8d47ca46, 0xca01468d),
3262// o.u(0x671770d9, 0x70ced967), o.u(0x72afdd4b, 0xdde44b72),
3263// o.u(0x94ed79de, 0x7933de94), o.u(0x98ff67d4, 0x672bd498),
3264// o.u(0xb09323e8, 0x237be8b0), o.u(0x855bde4a, 0xde114a85),
3265// o.u(0xbb06bd6b, 0xbd6d6bbb), o.u(0xc5bb7e2a, 0x7e912ac5),
3266// o.u(0x4f7b34e5, 0x349ee54f), o.u(0xedd73a16, 0x3ac116ed),
3267// o.u(0x86d254c5, 0x5417c586), o.u(0x9af862d7, 0x622fd79a),
3268// o.u(0x6699ff55, 0xffcc5566), o.u(0x11b6a794, 0xa7229411),
3269// o.u(0x8ac04acf, 0x4a0fcf8a), o.u(0xe9d93010, 0x30c910e9),
3270// o.u(0x040e0a06, 0x0a080604), o.u(0xfe669881, 0x98e781fe),
3271// o.u(0xa0ab0bf0, 0x0b5bf0a0), o.u(0x78b4cc44, 0xccf04478),
3272// o.u(0x25f0d5ba, 0xd54aba25), o.u(0x4b753ee3, 0x3e96e34b),
3273// o.u(0xa2ac0ef3, 0x0e5ff3a2), o.u(0x5d4419fe, 0x19bafe5d),
3274// o.u(0x80db5bc0, 0x5b1bc080), o.u(0x0580858a, 0x850a8a05),
3275// o.u(0x3fd3ecad, 0xec7ead3f), o.u(0x21fedfbc, 0xdf42bc21),
3276// o.u(0x70a8d848, 0xd8e04870), o.u(0xf1fd0c04, 0x0cf904f1),
3277// o.u(0x63197adf, 0x7ac6df63), o.u(0x772f58c1, 0x58eec177),
3278// o.u(0xaf309f75, 0x9f4575af), o.u(0x42e7a563, 0xa5846342),
3279// o.u(0x20705030, 0x50403020), o.u(0xe5cb2e1a, 0x2ed11ae5),
3280// o.u(0xfdef120e, 0x12e10efd), o.u(0xbf08b76d, 0xb7656dbf),
3281// o.u(0x8155d44c, 0xd4194c81), o.u(0x18243c14, 0x3c301418),
3282// o.u(0x26795f35, 0x5f4c3526), o.u(0xc3b2712f, 0x719d2fc3),
3283// o.u(0xbe8638e1, 0x3867e1be), o.u(0x35c8fda2, 0xfd6aa235),
3284// o.u(0x88c74fcc, 0x4f0bcc88), o.u(0x2e654b39, 0x4b5c392e),
3285// o.u(0x936af957, 0xf93d5793), o.u(0x55580df2, 0x0daaf255),
3286// o.u(0xfc619d82, 0x9de382fc), o.u(0x7ab3c947, 0xc9f4477a),
3287// o.u(0xc827efac, 0xef8bacc8), o.u(0xba8832e7, 0x326fe7ba),
3288// o.u(0x324f7d2b, 0x7d642b32), o.u(0xe642a495, 0xa4d795e6),
3289// o.u(0xc03bfba0, 0xfb9ba0c0), o.u(0x19aab398, 0xb3329819),
3290// o.u(0x9ef668d1, 0x6827d19e), o.u(0xa322817f, 0x815d7fa3),
3291// o.u(0x44eeaa66, 0xaa886644), o.u(0x54d6827e, 0x82a87e54),
3292// o.u(0x3bdde6ab, 0xe676ab3b), o.u(0x0b959e83, 0x9e16830b),
3293// o.u(0x8cc945ca, 0x4503ca8c), o.u(0xc7bc7b29, 0x7b9529c7),
3294// o.u(0x6b056ed3, 0x6ed6d36b), o.u(0x286c443c, 0x44503c28),
3295// o.u(0xa72c8b79, 0x8b5579a7), o.u(0xbc813de2, 0x3d63e2bc),
3296// o.u(0x1631271d, 0x272c1d16), o.u(0xad379a76, 0x9a4176ad),
3297// o.u(0xdb964d3b, 0x4dad3bdb), o.u(0x649efa56, 0xfac85664),
3298// o.u(0x74a6d24e, 0xd2e84e74), o.u(0x1436221e, 0x22281e14),
3299// o.u(0x92e476db, 0x763fdb92), o.u(0x0c121e0a, 0x1e180a0c),
3300// o.u(0x48fcb46c, 0xb4906c48), o.u(0xb88f37e4, 0x376be4b8),
3301// o.u(0x9f78e75d, 0xe7255d9f), o.u(0xbd0fb26e, 0xb2616ebd),
3302// o.u(0x43692aef, 0x2a86ef43), o.u(0xc435f1a6, 0xf193a6c4),
3303// o.u(0x39dae3a8, 0xe372a839), o.u(0x31c6f7a4, 0xf762a431),
3304// o.u(0xd38a5937, 0x59bd37d3), o.u(0xf274868b, 0x86ff8bf2),
3305// o.u(0xd5835632, 0x56b132d5), o.u(0x8b4ec543, 0xc50d438b),
3306// o.u(0x6e85eb59, 0xebdc596e), o.u(0xda18c2b7, 0xc2afb7da),
3307// o.u(0x018e8f8c, 0x8f028c01), o.u(0xb11dac64, 0xac7964b1),
3308// o.u(0x9cf16dd2, 0x6d23d29c), o.u(0x49723be0, 0x3b92e049),
3309// o.u(0xd81fc7b4, 0xc7abb4d8), o.u(0xacb915fa, 0x1543faac),
3310// o.u(0xf3fa0907, 0x09fd07f3), o.u(0xcfa06f25, 0x6f8525cf),
3311// o.u(0xca20eaaf, 0xea8fafca), o.u(0xf47d898e, 0x89f38ef4),
3312// o.u(0x476720e9, 0x208ee947), o.u(0x10382818, 0x28201810),
3313// o.u(0x6f0b64d5, 0x64ded56f), o.u(0xf0738388, 0x83fb88f0),
3314// o.u(0x4afbb16f, 0xb1946f4a), o.u(0x5cca9672, 0x96b8725c),
3315// o.u(0x38546c24, 0x6c702438), o.u(0x575f08f1, 0x08aef157),
3316// o.u(0x732152c7, 0x52e6c773), o.u(0x9764f351, 0xf3355197),
3317// o.u(0xcbae6523, 0x658d23cb), o.u(0xa125847c, 0x84597ca1),
3318// o.u(0xe857bf9c, 0xbfcb9ce8), o.u(0x3e5d6321, 0x637c213e),
3319// o.u(0x96ea7cdd, 0x7c37dd96), o.u(0x611e7fdc, 0x7fc2dc61),
3320// o.u(0x0d9c9186, 0x911a860d), o.u(0x0f9b9485, 0x941e850f),
3321// o.u(0xe04bab90, 0xabdb90e0), o.u(0x7cbac642, 0xc6f8427c),
3322// o.u(0x712657c4, 0x57e2c471), o.u(0xcc29e5aa, 0xe583aacc),
3323// o.u(0x90e373d8, 0x733bd890), o.u(0x06090f05, 0x0f0c0506),
3324// o.u(0xf7f40301, 0x03f501f7), o.u(0x1c2a3612, 0x3638121c),
3325// o.u(0xc23cfea3, 0xfe9fa3c2), o.u(0x6a8be15f, 0xe1d45f6a),
3326// o.u(0xaebe10f9, 0x1047f9ae), o.u(0x69026bd0, 0x6bd2d069),
3327// o.u(0x17bfa891, 0xa82e9117), o.u(0x9971e858, 0xe8295899),
3328// o.u(0x3a536927, 0x6974273a), o.u(0x27f7d0b9, 0xd04eb927),
3329// o.u(0xd9914838, 0x48a938d9), o.u(0xebde3513, 0x35cd13eb),
3330// o.u(0x2be5ceb3, 0xce56b32b), o.u(0x22775533, 0x55443322),
3331// o.u(0xd204d6bb, 0xd6bfbbd2), o.u(0xa9399070, 0x904970a9),
3332// o.u(0x07878089, 0x800e8907), o.u(0x33c1f2a7, 0xf266a733),
3333// o.u(0x2decc1b6, 0xc15ab62d), o.u(0x3c5a6622, 0x6678223c),
3334// o.u(0x15b8ad92, 0xad2a9215), o.u(0xc9a96020, 0x608920c9),
3335// o.u(0x875cdb49, 0xdb154987), o.u(0xaab01aff, 0x1a4fffaa),
3336// o.u(0x50d88878, 0x88a07850), o.u(0xa52b8e7a, 0x8e517aa5),
3337// o.u(0x03898a8f, 0x8a068f03), o.u(0x594a13f8, 0x13b2f859),
3338// o.u(0x09929b80, 0x9b128009), o.u(0x1a233917, 0x3934171a),
3339// o.u(0x651075da, 0x75cada65), o.u(0xd7845331, 0x53b531d7),
3340// o.u(0x84d551c6, 0x5113c684), o.u(0xd003d3b8, 0xd3bbb8d0),
3341// o.u(0x82dc5ec3, 0x5e1fc382), o.u(0x29e2cbb0, 0xcb52b029),
3342// o.u(0x5ac39977, 0x99b4775a), o.u(0x1e2d3311, 0x333c111e),
3343// o.u(0x7b3d46cb, 0x46f6cb7b), o.u(0xa8b71ffc, 0x1f4bfca8),
3344// o.u(0x6d0c61d6, 0x61dad66d), o.u(0x2c624e3a, 0x4e583a2c)
3345// ];
3346
3347// var T1 = [
3348// o.u(0xc6c632f4, 0xa5f497a5), o.u(0xf8f86f97, 0x8497eb84),
3349// o.u(0xeeee5eb0, 0x99b0c799), o.u(0xf6f67a8c, 0x8d8cf78d),
3350// o.u(0xffffe817, 0xd17e50d), o.u(0xd6d60adc, 0xbddcb7bd),
3351// o.u(0xdede16c8, 0xb1c8a7b1), o.u(0x91916dfc, 0x54fc3954),
3352// o.u(0x606090f0, 0x50f0c050), o.u(0x2020705, 0x3050403),
3353// o.u(0xcece2ee0, 0xa9e087a9), o.u(0x5656d187, 0x7d87ac7d),
3354// o.u(0xe7e7cc2b, 0x192bd519), o.u(0xb5b513a6, 0x62a67162),
3355// o.u(0x4d4d7c31, 0xe6319ae6), o.u(0xecec59b5, 0x9ab5c39a),
3356// o.u(0x8f8f40cf, 0x45cf0545), o.u(0x1f1fa3bc, 0x9dbc3e9d),
3357// o.u(0x898949c0, 0x40c00940), o.u(0xfafa6892, 0x8792ef87),
3358// o.u(0xefefd03f, 0x153fc515), o.u(0xb2b29426, 0xeb267feb),
3359// o.u(0x8e8ece40, 0xc94007c9), o.u(0xfbfbe61d, 0xb1ded0b),
3360// o.u(0x41416e2f, 0xec2f82ec), o.u(0xb3b31aa9, 0x67a97d67),
3361// o.u(0x5f5f431c, 0xfd1cbefd), o.u(0x45456025, 0xea258aea),
3362// o.u(0x2323f9da, 0xbfda46bf), o.u(0x53535102, 0xf702a6f7),
3363// o.u(0xe4e445a1, 0x96a1d396), o.u(0x9b9b76ed, 0x5bed2d5b),
3364// o.u(0x7575285d, 0xc25deac2), o.u(0xe1e1c524, 0x1c24d91c),
3365// o.u(0x3d3dd4e9, 0xaee97aae), o.u(0x4c4cf2be, 0x6abe986a),
3366// o.u(0x6c6c82ee, 0x5aeed85a), o.u(0x7e7ebdc3, 0x41c3fc41),
3367// o.u(0xf5f5f306, 0x206f102), o.u(0x838352d1, 0x4fd11d4f),
3368// o.u(0x68688ce4, 0x5ce4d05c), o.u(0x51515607, 0xf407a2f4),
3369// o.u(0xd1d18d5c, 0x345cb934), o.u(0xf9f9e118, 0x818e908),
3370// o.u(0xe2e24cae, 0x93aedf93), o.u(0xabab3e95, 0x73954d73),
3371// o.u(0x626297f5, 0x53f5c453), o.u(0x2a2a6b41, 0x3f41543f),
3372// o.u(0x8081c14, 0xc14100c), o.u(0x959563f6, 0x52f63152),
3373// o.u(0x4646e9af, 0x65af8c65), o.u(0x9d9d7fe2, 0x5ee2215e),
3374// o.u(0x30304878, 0x28786028), o.u(0x3737cff8, 0xa1f86ea1),
3375// o.u(0xa0a1b11, 0xf11140f), o.u(0x2f2febc4, 0xb5c45eb5),
3376// o.u(0xe0e151b, 0x91b1c09), o.u(0x24247e5a, 0x365a4836),
3377// o.u(0x1b1badb6, 0x9bb6369b), o.u(0xdfdf9847, 0x3d47a53d),
3378// o.u(0xcdcda76a, 0x266a8126), o.u(0x4e4ef5bb, 0x69bb9c69),
3379// o.u(0x7f7f334c, 0xcd4cfecd), o.u(0xeaea50ba, 0x9fbacf9f),
3380// o.u(0x12123f2d, 0x1b2d241b), o.u(0x1d1da4b9, 0x9eb93a9e),
3381// o.u(0x5858c49c, 0x749cb074), o.u(0x34344672, 0x2e72682e),
3382// o.u(0x36364177, 0x2d776c2d), o.u(0xdcdc11cd, 0xb2cda3b2),
3383// o.u(0xb4b49d29, 0xee2973ee), o.u(0x5b5b4d16, 0xfb16b6fb),
3384// o.u(0xa4a4a501, 0xf60153f6), o.u(0x7676a1d7, 0x4dd7ec4d),
3385// o.u(0xb7b714a3, 0x61a37561), o.u(0x7d7d3449, 0xce49face),
3386// o.u(0x5252df8d, 0x7b8da47b), o.u(0xdddd9f42, 0x3e42a13e),
3387// o.u(0x5e5ecd93, 0x7193bc71), o.u(0x1313b1a2, 0x97a22697),
3388// o.u(0xa6a6a204, 0xf50457f5), o.u(0xb9b901b8, 0x68b86968),
3389// o.u(0x0, 0x0), o.u(0xc1c1b574, 0x2c74992c),
3390// o.u(0x4040e0a0, 0x60a08060), o.u(0xe3e3c221, 0x1f21dd1f),
3391// o.u(0x79793a43, 0xc843f2c8), o.u(0xb6b69a2c, 0xed2c77ed),
3392// o.u(0xd4d40dd9, 0xbed9b3be), o.u(0x8d8d47ca, 0x46ca0146),
3393// o.u(0x67671770, 0xd970ced9), o.u(0x7272afdd, 0x4bdde44b),
3394// o.u(0x9494ed79, 0xde7933de), o.u(0x9898ff67, 0xd4672bd4),
3395// o.u(0xb0b09323, 0xe8237be8), o.u(0x85855bde, 0x4ade114a),
3396// o.u(0xbbbb06bd, 0x6bbd6d6b), o.u(0xc5c5bb7e, 0x2a7e912a),
3397// o.u(0x4f4f7b34, 0xe5349ee5), o.u(0xededd73a, 0x163ac116),
3398// o.u(0x8686d254, 0xc55417c5), o.u(0x9a9af862, 0xd7622fd7),
3399// o.u(0x666699ff, 0x55ffcc55), o.u(0x1111b6a7, 0x94a72294),
3400// o.u(0x8a8ac04a, 0xcf4a0fcf), o.u(0xe9e9d930, 0x1030c910),
3401// o.u(0x4040e0a, 0x60a0806), o.u(0xfefe6698, 0x8198e781),
3402// o.u(0xa0a0ab0b, 0xf00b5bf0), o.u(0x7878b4cc, 0x44ccf044),
3403// o.u(0x2525f0d5, 0xbad54aba), o.u(0x4b4b753e, 0xe33e96e3),
3404// o.u(0xa2a2ac0e, 0xf30e5ff3), o.u(0x5d5d4419, 0xfe19bafe),
3405// o.u(0x8080db5b, 0xc05b1bc0), o.u(0x5058085, 0x8a850a8a),
3406// o.u(0x3f3fd3ec, 0xadec7ead), o.u(0x2121fedf, 0xbcdf42bc),
3407// o.u(0x7070a8d8, 0x48d8e048), o.u(0xf1f1fd0c, 0x40cf904),
3408// o.u(0x6363197a, 0xdf7ac6df), o.u(0x77772f58, 0xc158eec1),
3409// o.u(0xafaf309f, 0x759f4575), o.u(0x4242e7a5, 0x63a58463),
3410// o.u(0x20207050, 0x30504030), o.u(0xe5e5cb2e, 0x1a2ed11a),
3411// o.u(0xfdfdef12, 0xe12e10e), o.u(0xbfbf08b7, 0x6db7656d),
3412// o.u(0x818155d4, 0x4cd4194c), o.u(0x1818243c, 0x143c3014),
3413// o.u(0x2626795f, 0x355f4c35), o.u(0xc3c3b271, 0x2f719d2f),
3414// o.u(0xbebe8638, 0xe13867e1), o.u(0x3535c8fd, 0xa2fd6aa2),
3415// o.u(0x8888c74f, 0xcc4f0bcc), o.u(0x2e2e654b, 0x394b5c39),
3416// o.u(0x93936af9, 0x57f93d57), o.u(0x5555580d, 0xf20daaf2),
3417// o.u(0xfcfc619d, 0x829de382), o.u(0x7a7ab3c9, 0x47c9f447),
3418// o.u(0xc8c827ef, 0xacef8bac), o.u(0xbaba8832, 0xe7326fe7),
3419// o.u(0x32324f7d, 0x2b7d642b), o.u(0xe6e642a4, 0x95a4d795),
3420// o.u(0xc0c03bfb, 0xa0fb9ba0), o.u(0x1919aab3, 0x98b33298),
3421// o.u(0x9e9ef668, 0xd16827d1), o.u(0xa3a32281, 0x7f815d7f),
3422// o.u(0x4444eeaa, 0x66aa8866), o.u(0x5454d682, 0x7e82a87e),
3423// o.u(0x3b3bdde6, 0xabe676ab), o.u(0xb0b959e, 0x839e1683),
3424// o.u(0x8c8cc945, 0xca4503ca), o.u(0xc7c7bc7b, 0x297b9529),
3425// o.u(0x6b6b056e, 0xd36ed6d3), o.u(0x28286c44, 0x3c44503c),
3426// o.u(0xa7a72c8b, 0x798b5579), o.u(0xbcbc813d, 0xe23d63e2),
3427// o.u(0x16163127, 0x1d272c1d), o.u(0xadad379a, 0x769a4176),
3428// o.u(0xdbdb964d, 0x3b4dad3b), o.u(0x64649efa, 0x56fac856),
3429// o.u(0x7474a6d2, 0x4ed2e84e), o.u(0x14143622, 0x1e22281e),
3430// o.u(0x9292e476, 0xdb763fdb), o.u(0xc0c121e, 0xa1e180a),
3431// o.u(0x4848fcb4, 0x6cb4906c), o.u(0xb8b88f37, 0xe4376be4),
3432// o.u(0x9f9f78e7, 0x5de7255d), o.u(0xbdbd0fb2, 0x6eb2616e),
3433// o.u(0x4343692a, 0xef2a86ef), o.u(0xc4c435f1, 0xa6f193a6),
3434// o.u(0x3939dae3, 0xa8e372a8), o.u(0x3131c6f7, 0xa4f762a4),
3435// o.u(0xd3d38a59, 0x3759bd37), o.u(0xf2f27486, 0x8b86ff8b),
3436// o.u(0xd5d58356, 0x3256b132), o.u(0x8b8b4ec5, 0x43c50d43),
3437// o.u(0x6e6e85eb, 0x59ebdc59), o.u(0xdada18c2, 0xb7c2afb7),
3438// o.u(0x1018e8f, 0x8c8f028c), o.u(0xb1b11dac, 0x64ac7964),
3439// o.u(0x9c9cf16d, 0xd26d23d2), o.u(0x4949723b, 0xe03b92e0),
3440// o.u(0xd8d81fc7, 0xb4c7abb4), o.u(0xacacb915, 0xfa1543fa),
3441// o.u(0xf3f3fa09, 0x709fd07), o.u(0xcfcfa06f, 0x256f8525),
3442// o.u(0xcaca20ea, 0xafea8faf), o.u(0xf4f47d89, 0x8e89f38e),
3443// o.u(0x47476720, 0xe9208ee9), o.u(0x10103828, 0x18282018),
3444// o.u(0x6f6f0b64, 0xd564ded5), o.u(0xf0f07383, 0x8883fb88),
3445// o.u(0x4a4afbb1, 0x6fb1946f), o.u(0x5c5cca96, 0x7296b872),
3446// o.u(0x3838546c, 0x246c7024), o.u(0x57575f08, 0xf108aef1),
3447// o.u(0x73732152, 0xc752e6c7), o.u(0x979764f3, 0x51f33551),
3448// o.u(0xcbcbae65, 0x23658d23), o.u(0xa1a12584, 0x7c84597c),
3449// o.u(0xe8e857bf, 0x9cbfcb9c), o.u(0x3e3e5d63, 0x21637c21),
3450// o.u(0x9696ea7c, 0xdd7c37dd), o.u(0x61611e7f, 0xdc7fc2dc),
3451// o.u(0xd0d9c91, 0x86911a86), o.u(0xf0f9b94, 0x85941e85),
3452// o.u(0xe0e04bab, 0x90abdb90), o.u(0x7c7cbac6, 0x42c6f842),
3453// o.u(0x71712657, 0xc457e2c4), o.u(0xcccc29e5, 0xaae583aa),
3454// o.u(0x9090e373, 0xd8733bd8), o.u(0x606090f, 0x50f0c05),
3455// o.u(0xf7f7f403, 0x103f501), o.u(0x1c1c2a36, 0x12363812),
3456// o.u(0xc2c23cfe, 0xa3fe9fa3), o.u(0x6a6a8be1, 0x5fe1d45f),
3457// o.u(0xaeaebe10, 0xf91047f9), o.u(0x6969026b, 0xd06bd2d0),
3458// o.u(0x1717bfa8, 0x91a82e91), o.u(0x999971e8, 0x58e82958),
3459// o.u(0x3a3a5369, 0x27697427), o.u(0x2727f7d0, 0xb9d04eb9),
3460// o.u(0xd9d99148, 0x3848a938), o.u(0xebebde35, 0x1335cd13),
3461// o.u(0x2b2be5ce, 0xb3ce56b3), o.u(0x22227755, 0x33554433),
3462// o.u(0xd2d204d6, 0xbbd6bfbb), o.u(0xa9a93990, 0x70904970),
3463// o.u(0x7078780, 0x89800e89), o.u(0x3333c1f2, 0xa7f266a7),
3464// o.u(0x2d2decc1, 0xb6c15ab6), o.u(0x3c3c5a66, 0x22667822),
3465// o.u(0x1515b8ad, 0x92ad2a92), o.u(0xc9c9a960, 0x20608920),
3466// o.u(0x87875cdb, 0x49db1549), o.u(0xaaaab01a, 0xff1a4fff),
3467// o.u(0x5050d888, 0x7888a078), o.u(0xa5a52b8e, 0x7a8e517a),
3468// o.u(0x303898a, 0x8f8a068f), o.u(0x59594a13, 0xf813b2f8),
3469// o.u(0x909929b, 0x809b1280), o.u(0x1a1a2339, 0x17393417),
3470// o.u(0x65651075, 0xda75cada), o.u(0xd7d78453, 0x3153b531),
3471// o.u(0x8484d551, 0xc65113c6), o.u(0xd0d003d3, 0xb8d3bbb8),
3472// o.u(0x8282dc5e, 0xc35e1fc3), o.u(0x2929e2cb, 0xb0cb52b0),
3473// o.u(0x5a5ac399, 0x7799b477), o.u(0x1e1e2d33, 0x11333c11),
3474// o.u(0x7b7b3d46, 0xcb46f6cb), o.u(0xa8a8b71f, 0xfc1f4bfc),
3475// o.u(0x6d6d0c61, 0xd661dad6), o.u(0x2c2c624e, 0x3a4e583a)
3476// ];
3477
3478// var T2 = [
3479// o.u(0xa5c6c632, 0xf4a5f497), o.u(0x84f8f86f, 0x978497eb),
3480// o.u(0x99eeee5e, 0xb099b0c7), o.u(0x8df6f67a, 0x8c8d8cf7),
3481// o.u(0xdffffe8, 0x170d17e5), o.u(0xbdd6d60a, 0xdcbddcb7),
3482// o.u(0xb1dede16, 0xc8b1c8a7), o.u(0x5491916d, 0xfc54fc39),
3483// o.u(0x50606090, 0xf050f0c0), o.u(0x3020207, 0x5030504),
3484// o.u(0xa9cece2e, 0xe0a9e087), o.u(0x7d5656d1, 0x877d87ac),
3485// o.u(0x19e7e7cc, 0x2b192bd5), o.u(0x62b5b513, 0xa662a671),
3486// o.u(0xe64d4d7c, 0x31e6319a), o.u(0x9aecec59, 0xb59ab5c3),
3487// o.u(0x458f8f40, 0xcf45cf05), o.u(0x9d1f1fa3, 0xbc9dbc3e),
3488// o.u(0x40898949, 0xc040c009), o.u(0x87fafa68, 0x928792ef),
3489// o.u(0x15efefd0, 0x3f153fc5), o.u(0xebb2b294, 0x26eb267f),
3490// o.u(0xc98e8ece, 0x40c94007), o.u(0xbfbfbe6, 0x1d0b1ded),
3491// o.u(0xec41416e, 0x2fec2f82), o.u(0x67b3b31a, 0xa967a97d),
3492// o.u(0xfd5f5f43, 0x1cfd1cbe), o.u(0xea454560, 0x25ea258a),
3493// o.u(0xbf2323f9, 0xdabfda46), o.u(0xf7535351, 0x2f702a6),
3494// o.u(0x96e4e445, 0xa196a1d3), o.u(0x5b9b9b76, 0xed5bed2d),
3495// o.u(0xc2757528, 0x5dc25dea), o.u(0x1ce1e1c5, 0x241c24d9),
3496// o.u(0xae3d3dd4, 0xe9aee97a), o.u(0x6a4c4cf2, 0xbe6abe98),
3497// o.u(0x5a6c6c82, 0xee5aeed8), o.u(0x417e7ebd, 0xc341c3fc),
3498// o.u(0x2f5f5f3, 0x60206f1), o.u(0x4f838352, 0xd14fd11d),
3499// o.u(0x5c68688c, 0xe45ce4d0), o.u(0xf4515156, 0x7f407a2),
3500// o.u(0x34d1d18d, 0x5c345cb9), o.u(0x8f9f9e1, 0x180818e9),
3501// o.u(0x93e2e24c, 0xae93aedf), o.u(0x73abab3e, 0x9573954d),
3502// o.u(0x53626297, 0xf553f5c4), o.u(0x3f2a2a6b, 0x413f4154),
3503// o.u(0xc08081c, 0x140c1410), o.u(0x52959563, 0xf652f631),
3504// o.u(0x654646e9, 0xaf65af8c), o.u(0x5e9d9d7f, 0xe25ee221),
3505// o.u(0x28303048, 0x78287860), o.u(0xa13737cf, 0xf8a1f86e),
3506// o.u(0xf0a0a1b, 0x110f1114), o.u(0xb52f2feb, 0xc4b5c45e),
3507// o.u(0x90e0e15, 0x1b091b1c), o.u(0x3624247e, 0x5a365a48),
3508// o.u(0x9b1b1bad, 0xb69bb636), o.u(0x3ddfdf98, 0x473d47a5),
3509// o.u(0x26cdcda7, 0x6a266a81), o.u(0x694e4ef5, 0xbb69bb9c),
3510// o.u(0xcd7f7f33, 0x4ccd4cfe), o.u(0x9feaea50, 0xba9fbacf),
3511// o.u(0x1b12123f, 0x2d1b2d24), o.u(0x9e1d1da4, 0xb99eb93a),
3512// o.u(0x745858c4, 0x9c749cb0), o.u(0x2e343446, 0x722e7268),
3513// o.u(0x2d363641, 0x772d776c), o.u(0xb2dcdc11, 0xcdb2cda3),
3514// o.u(0xeeb4b49d, 0x29ee2973), o.u(0xfb5b5b4d, 0x16fb16b6),
3515// o.u(0xf6a4a4a5, 0x1f60153), o.u(0x4d7676a1, 0xd74dd7ec),
3516// o.u(0x61b7b714, 0xa361a375), o.u(0xce7d7d34, 0x49ce49fa),
3517// o.u(0x7b5252df, 0x8d7b8da4), o.u(0x3edddd9f, 0x423e42a1),
3518// o.u(0x715e5ecd, 0x937193bc), o.u(0x971313b1, 0xa297a226),
3519// o.u(0xf5a6a6a2, 0x4f50457), o.u(0x68b9b901, 0xb868b869),
3520// o.u(0x0, 0x0), o.u(0x2cc1c1b5, 0x742c7499),
3521// o.u(0x604040e0, 0xa060a080), o.u(0x1fe3e3c2, 0x211f21dd),
3522// o.u(0xc879793a, 0x43c843f2), o.u(0xedb6b69a, 0x2ced2c77),
3523// o.u(0xbed4d40d, 0xd9bed9b3), o.u(0x468d8d47, 0xca46ca01),
3524// o.u(0xd9676717, 0x70d970ce), o.u(0x4b7272af, 0xdd4bdde4),
3525// o.u(0xde9494ed, 0x79de7933), o.u(0xd49898ff, 0x67d4672b),
3526// o.u(0xe8b0b093, 0x23e8237b), o.u(0x4a85855b, 0xde4ade11),
3527// o.u(0x6bbbbb06, 0xbd6bbd6d), o.u(0x2ac5c5bb, 0x7e2a7e91),
3528// o.u(0xe54f4f7b, 0x34e5349e), o.u(0x16ededd7, 0x3a163ac1),
3529// o.u(0xc58686d2, 0x54c55417), o.u(0xd79a9af8, 0x62d7622f),
3530// o.u(0x55666699, 0xff55ffcc), o.u(0x941111b6, 0xa794a722),
3531// o.u(0xcf8a8ac0, 0x4acf4a0f), o.u(0x10e9e9d9, 0x301030c9),
3532// o.u(0x604040e, 0xa060a08), o.u(0x81fefe66, 0x988198e7),
3533// o.u(0xf0a0a0ab, 0xbf00b5b), o.u(0x447878b4, 0xcc44ccf0),
3534// o.u(0xba2525f0, 0xd5bad54a), o.u(0xe34b4b75, 0x3ee33e96),
3535// o.u(0xf3a2a2ac, 0xef30e5f), o.u(0xfe5d5d44, 0x19fe19ba),
3536// o.u(0xc08080db, 0x5bc05b1b), o.u(0x8a050580, 0x858a850a),
3537// o.u(0xad3f3fd3, 0xecadec7e), o.u(0xbc2121fe, 0xdfbcdf42),
3538// o.u(0x487070a8, 0xd848d8e0), o.u(0x4f1f1fd, 0xc040cf9),
3539// o.u(0xdf636319, 0x7adf7ac6), o.u(0xc177772f, 0x58c158ee),
3540// o.u(0x75afaf30, 0x9f759f45), o.u(0x634242e7, 0xa563a584),
3541// o.u(0x30202070, 0x50305040), o.u(0x1ae5e5cb, 0x2e1a2ed1),
3542// o.u(0xefdfdef, 0x120e12e1), o.u(0x6dbfbf08, 0xb76db765),
3543// o.u(0x4c818155, 0xd44cd419), o.u(0x14181824, 0x3c143c30),
3544// o.u(0x35262679, 0x5f355f4c), o.u(0x2fc3c3b2, 0x712f719d),
3545// o.u(0xe1bebe86, 0x38e13867), o.u(0xa23535c8, 0xfda2fd6a),
3546// o.u(0xcc8888c7, 0x4fcc4f0b), o.u(0x392e2e65, 0x4b394b5c),
3547// o.u(0x5793936a, 0xf957f93d), o.u(0xf2555558, 0xdf20daa),
3548// o.u(0x82fcfc61, 0x9d829de3), o.u(0x477a7ab3, 0xc947c9f4),
3549// o.u(0xacc8c827, 0xefacef8b), o.u(0xe7baba88, 0x32e7326f),
3550// o.u(0x2b32324f, 0x7d2b7d64), o.u(0x95e6e642, 0xa495a4d7),
3551// o.u(0xa0c0c03b, 0xfba0fb9b), o.u(0x981919aa, 0xb398b332),
3552// o.u(0xd19e9ef6, 0x68d16827), o.u(0x7fa3a322, 0x817f815d),
3553// o.u(0x664444ee, 0xaa66aa88), o.u(0x7e5454d6, 0x827e82a8),
3554// o.u(0xab3b3bdd, 0xe6abe676), o.u(0x830b0b95, 0x9e839e16),
3555// o.u(0xca8c8cc9, 0x45ca4503), o.u(0x29c7c7bc, 0x7b297b95),
3556// o.u(0xd36b6b05, 0x6ed36ed6), o.u(0x3c28286c, 0x443c4450),
3557// o.u(0x79a7a72c, 0x8b798b55), o.u(0xe2bcbc81, 0x3de23d63),
3558// o.u(0x1d161631, 0x271d272c), o.u(0x76adad37, 0x9a769a41),
3559// o.u(0x3bdbdb96, 0x4d3b4dad), o.u(0x5664649e, 0xfa56fac8),
3560// o.u(0x4e7474a6, 0xd24ed2e8), o.u(0x1e141436, 0x221e2228),
3561// o.u(0xdb9292e4, 0x76db763f), o.u(0xa0c0c12, 0x1e0a1e18),
3562// o.u(0x6c4848fc, 0xb46cb490), o.u(0xe4b8b88f, 0x37e4376b),
3563// o.u(0x5d9f9f78, 0xe75de725), o.u(0x6ebdbd0f, 0xb26eb261),
3564// o.u(0xef434369, 0x2aef2a86), o.u(0xa6c4c435, 0xf1a6f193),
3565// o.u(0xa83939da, 0xe3a8e372), o.u(0xa43131c6, 0xf7a4f762),
3566// o.u(0x37d3d38a, 0x593759bd), o.u(0x8bf2f274, 0x868b86ff),
3567// o.u(0x32d5d583, 0x563256b1), o.u(0x438b8b4e, 0xc543c50d),
3568// o.u(0x596e6e85, 0xeb59ebdc), o.u(0xb7dada18, 0xc2b7c2af),
3569// o.u(0x8c01018e, 0x8f8c8f02), o.u(0x64b1b11d, 0xac64ac79),
3570// o.u(0xd29c9cf1, 0x6dd26d23), o.u(0xe0494972, 0x3be03b92),
3571// o.u(0xb4d8d81f, 0xc7b4c7ab), o.u(0xfaacacb9, 0x15fa1543),
3572// o.u(0x7f3f3fa, 0x90709fd), o.u(0x25cfcfa0, 0x6f256f85),
3573// o.u(0xafcaca20, 0xeaafea8f), o.u(0x8ef4f47d, 0x898e89f3),
3574// o.u(0xe9474767, 0x20e9208e), o.u(0x18101038, 0x28182820),
3575// o.u(0xd56f6f0b, 0x64d564de), o.u(0x88f0f073, 0x838883fb),
3576// o.u(0x6f4a4afb, 0xb16fb194), o.u(0x725c5cca, 0x967296b8),
3577// o.u(0x24383854, 0x6c246c70), o.u(0xf157575f, 0x8f108ae),
3578// o.u(0xc7737321, 0x52c752e6), o.u(0x51979764, 0xf351f335),
3579// o.u(0x23cbcbae, 0x6523658d), o.u(0x7ca1a125, 0x847c8459),
3580// o.u(0x9ce8e857, 0xbf9cbfcb), o.u(0x213e3e5d, 0x6321637c),
3581// o.u(0xdd9696ea, 0x7cdd7c37), o.u(0xdc61611e, 0x7fdc7fc2),
3582// o.u(0x860d0d9c, 0x9186911a), o.u(0x850f0f9b, 0x9485941e),
3583// o.u(0x90e0e04b, 0xab90abdb), o.u(0x427c7cba, 0xc642c6f8),
3584// o.u(0xc4717126, 0x57c457e2), o.u(0xaacccc29, 0xe5aae583),
3585// o.u(0xd89090e3, 0x73d8733b), o.u(0x5060609, 0xf050f0c),
3586// o.u(0x1f7f7f4, 0x30103f5), o.u(0x121c1c2a, 0x36123638),
3587// o.u(0xa3c2c23c, 0xfea3fe9f), o.u(0x5f6a6a8b, 0xe15fe1d4),
3588// o.u(0xf9aeaebe, 0x10f91047), o.u(0xd0696902, 0x6bd06bd2),
3589// o.u(0x911717bf, 0xa891a82e), o.u(0x58999971, 0xe858e829),
3590// o.u(0x273a3a53, 0x69276974), o.u(0xb92727f7, 0xd0b9d04e),
3591// o.u(0x38d9d991, 0x483848a9), o.u(0x13ebebde, 0x351335cd),
3592// o.u(0xb32b2be5, 0xceb3ce56), o.u(0x33222277, 0x55335544),
3593// o.u(0xbbd2d204, 0xd6bbd6bf), o.u(0x70a9a939, 0x90709049),
3594// o.u(0x89070787, 0x8089800e), o.u(0xa73333c1, 0xf2a7f266),
3595// o.u(0xb62d2dec, 0xc1b6c15a), o.u(0x223c3c5a, 0x66226678),
3596// o.u(0x921515b8, 0xad92ad2a), o.u(0x20c9c9a9, 0x60206089),
3597// o.u(0x4987875c, 0xdb49db15), o.u(0xffaaaab0, 0x1aff1a4f),
3598// o.u(0x785050d8, 0x887888a0), o.u(0x7aa5a52b, 0x8e7a8e51),
3599// o.u(0x8f030389, 0x8a8f8a06), o.u(0xf859594a, 0x13f813b2),
3600// o.u(0x80090992, 0x9b809b12), o.u(0x171a1a23, 0x39173934),
3601// o.u(0xda656510, 0x75da75ca), o.u(0x31d7d784, 0x533153b5),
3602// o.u(0xc68484d5, 0x51c65113), o.u(0xb8d0d003, 0xd3b8d3bb),
3603// o.u(0xc38282dc, 0x5ec35e1f), o.u(0xb02929e2, 0xcbb0cb52),
3604// o.u(0x775a5ac3, 0x997799b4), o.u(0x111e1e2d, 0x3311333c),
3605// o.u(0xcb7b7b3d, 0x46cb46f6), o.u(0xfca8a8b7, 0x1ffc1f4b),
3606// o.u(0xd66d6d0c, 0x61d661da), o.u(0x3a2c2c62, 0x4e3a4e58)
3607// ];
3608
3609// var T3 = [
3610// o.u(0x97a5c6c6, 0x32f4a5f4), o.u(0xeb84f8f8, 0x6f978497),
3611// o.u(0xc799eeee, 0x5eb099b0), o.u(0xf78df6f6, 0x7a8c8d8c),
3612// o.u(0xe50dffff, 0xe8170d17), o.u(0xb7bdd6d6, 0xadcbddc),
3613// o.u(0xa7b1dede, 0x16c8b1c8), o.u(0x39549191, 0x6dfc54fc),
3614// o.u(0xc0506060, 0x90f050f0), o.u(0x4030202, 0x7050305),
3615// o.u(0x87a9cece, 0x2ee0a9e0), o.u(0xac7d5656, 0xd1877d87),
3616// o.u(0xd519e7e7, 0xcc2b192b), o.u(0x7162b5b5, 0x13a662a6),
3617// o.u(0x9ae64d4d, 0x7c31e631), o.u(0xc39aecec, 0x59b59ab5),
3618// o.u(0x5458f8f, 0x40cf45cf), o.u(0x3e9d1f1f, 0xa3bc9dbc),
3619// o.u(0x9408989, 0x49c040c0), o.u(0xef87fafa, 0x68928792),
3620// o.u(0xc515efef, 0xd03f153f), o.u(0x7febb2b2, 0x9426eb26),
3621// o.u(0x7c98e8e, 0xce40c940), o.u(0xed0bfbfb, 0xe61d0b1d),
3622// o.u(0x82ec4141, 0x6e2fec2f), o.u(0x7d67b3b3, 0x1aa967a9),
3623// o.u(0xbefd5f5f, 0x431cfd1c), o.u(0x8aea4545, 0x6025ea25),
3624// o.u(0x46bf2323, 0xf9dabfda), o.u(0xa6f75353, 0x5102f702),
3625// o.u(0xd396e4e4, 0x45a196a1), o.u(0x2d5b9b9b, 0x76ed5bed),
3626// o.u(0xeac27575, 0x285dc25d), o.u(0xd91ce1e1, 0xc5241c24),
3627// o.u(0x7aae3d3d, 0xd4e9aee9), o.u(0x986a4c4c, 0xf2be6abe),
3628// o.u(0xd85a6c6c, 0x82ee5aee), o.u(0xfc417e7e, 0xbdc341c3),
3629// o.u(0xf102f5f5, 0xf3060206), o.u(0x1d4f8383, 0x52d14fd1),
3630// o.u(0xd05c6868, 0x8ce45ce4), o.u(0xa2f45151, 0x5607f407),
3631// o.u(0xb934d1d1, 0x8d5c345c), o.u(0xe908f9f9, 0xe1180818),
3632// o.u(0xdf93e2e2, 0x4cae93ae), o.u(0x4d73abab, 0x3e957395),
3633// o.u(0xc4536262, 0x97f553f5), o.u(0x543f2a2a, 0x6b413f41),
3634// o.u(0x100c0808, 0x1c140c14), o.u(0x31529595, 0x63f652f6),
3635// o.u(0x8c654646, 0xe9af65af), o.u(0x215e9d9d, 0x7fe25ee2),
3636// o.u(0x60283030, 0x48782878), o.u(0x6ea13737, 0xcff8a1f8),
3637// o.u(0x140f0a0a, 0x1b110f11), o.u(0x5eb52f2f, 0xebc4b5c4),
3638// o.u(0x1c090e0e, 0x151b091b), o.u(0x48362424, 0x7e5a365a),
3639// o.u(0x369b1b1b, 0xadb69bb6), o.u(0xa53ddfdf, 0x98473d47),
3640// o.u(0x8126cdcd, 0xa76a266a), o.u(0x9c694e4e, 0xf5bb69bb),
3641// o.u(0xfecd7f7f, 0x334ccd4c), o.u(0xcf9feaea, 0x50ba9fba),
3642// o.u(0x241b1212, 0x3f2d1b2d), o.u(0x3a9e1d1d, 0xa4b99eb9),
3643// o.u(0xb0745858, 0xc49c749c), o.u(0x682e3434, 0x46722e72),
3644// o.u(0x6c2d3636, 0x41772d77), o.u(0xa3b2dcdc, 0x11cdb2cd),
3645// o.u(0x73eeb4b4, 0x9d29ee29), o.u(0xb6fb5b5b, 0x4d16fb16),
3646// o.u(0x53f6a4a4, 0xa501f601), o.u(0xec4d7676, 0xa1d74dd7),
3647// o.u(0x7561b7b7, 0x14a361a3), o.u(0xface7d7d, 0x3449ce49),
3648// o.u(0xa47b5252, 0xdf8d7b8d), o.u(0xa13edddd, 0x9f423e42),
3649// o.u(0xbc715e5e, 0xcd937193), o.u(0x26971313, 0xb1a297a2),
3650// o.u(0x57f5a6a6, 0xa204f504), o.u(0x6968b9b9, 0x1b868b8),
3651// o.u(0x0, 0x0), o.u(0x992cc1c1, 0xb5742c74),
3652// o.u(0x80604040, 0xe0a060a0), o.u(0xdd1fe3e3, 0xc2211f21),
3653// o.u(0xf2c87979, 0x3a43c843), o.u(0x77edb6b6, 0x9a2ced2c),
3654// o.u(0xb3bed4d4, 0xdd9bed9), o.u(0x1468d8d, 0x47ca46ca),
3655// o.u(0xced96767, 0x1770d970), o.u(0xe44b7272, 0xafdd4bdd),
3656// o.u(0x33de9494, 0xed79de79), o.u(0x2bd49898, 0xff67d467),
3657// o.u(0x7be8b0b0, 0x9323e823), o.u(0x114a8585, 0x5bde4ade),
3658// o.u(0x6d6bbbbb, 0x6bd6bbd), o.u(0x912ac5c5, 0xbb7e2a7e),
3659// o.u(0x9ee54f4f, 0x7b34e534), o.u(0xc116eded, 0xd73a163a),
3660// o.u(0x17c58686, 0xd254c554), o.u(0x2fd79a9a, 0xf862d762),
3661// o.u(0xcc556666, 0x99ff55ff), o.u(0x22941111, 0xb6a794a7),
3662// o.u(0xfcf8a8a, 0xc04acf4a), o.u(0xc910e9e9, 0xd9301030),
3663// o.u(0x8060404, 0xe0a060a), o.u(0xe781fefe, 0x66988198),
3664// o.u(0x5bf0a0a0, 0xab0bf00b), o.u(0xf0447878, 0xb4cc44cc),
3665// o.u(0x4aba2525, 0xf0d5bad5), o.u(0x96e34b4b, 0x753ee33e),
3666// o.u(0x5ff3a2a2, 0xac0ef30e), o.u(0xbafe5d5d, 0x4419fe19),
3667// o.u(0x1bc08080, 0xdb5bc05b), o.u(0xa8a0505, 0x80858a85),
3668// o.u(0x7ead3f3f, 0xd3ecadec), o.u(0x42bc2121, 0xfedfbcdf),
3669// o.u(0xe0487070, 0xa8d848d8), o.u(0xf904f1f1, 0xfd0c040c),
3670// o.u(0xc6df6363, 0x197adf7a), o.u(0xeec17777, 0x2f58c158),
3671// o.u(0x4575afaf, 0x309f759f), o.u(0x84634242, 0xe7a563a5),
3672// o.u(0x40302020, 0x70503050), o.u(0xd11ae5e5, 0xcb2e1a2e),
3673// o.u(0xe10efdfd, 0xef120e12), o.u(0x656dbfbf, 0x8b76db7),
3674// o.u(0x194c8181, 0x55d44cd4), o.u(0x30141818, 0x243c143c),
3675// o.u(0x4c352626, 0x795f355f), o.u(0x9d2fc3c3, 0xb2712f71),
3676// o.u(0x67e1bebe, 0x8638e138), o.u(0x6aa23535, 0xc8fda2fd),
3677// o.u(0xbcc8888, 0xc74fcc4f), o.u(0x5c392e2e, 0x654b394b),
3678// o.u(0x3d579393, 0x6af957f9), o.u(0xaaf25555, 0x580df20d),
3679// o.u(0xe382fcfc, 0x619d829d), o.u(0xf4477a7a, 0xb3c947c9),
3680// o.u(0x8bacc8c8, 0x27efacef), o.u(0x6fe7baba, 0x8832e732),
3681// o.u(0x642b3232, 0x4f7d2b7d), o.u(0xd795e6e6, 0x42a495a4),
3682// o.u(0x9ba0c0c0, 0x3bfba0fb), o.u(0x32981919, 0xaab398b3),
3683// o.u(0x27d19e9e, 0xf668d168), o.u(0x5d7fa3a3, 0x22817f81),
3684// o.u(0x88664444, 0xeeaa66aa), o.u(0xa87e5454, 0xd6827e82),
3685// o.u(0x76ab3b3b, 0xdde6abe6), o.u(0x16830b0b, 0x959e839e),
3686// o.u(0x3ca8c8c, 0xc945ca45), o.u(0x9529c7c7, 0xbc7b297b),
3687// o.u(0xd6d36b6b, 0x56ed36e), o.u(0x503c2828, 0x6c443c44),
3688// o.u(0x5579a7a7, 0x2c8b798b), o.u(0x63e2bcbc, 0x813de23d),
3689// o.u(0x2c1d1616, 0x31271d27), o.u(0x4176adad, 0x379a769a),
3690// o.u(0xad3bdbdb, 0x964d3b4d), o.u(0xc8566464, 0x9efa56fa),
3691// o.u(0xe84e7474, 0xa6d24ed2), o.u(0x281e1414, 0x36221e22),
3692// o.u(0x3fdb9292, 0xe476db76), o.u(0x180a0c0c, 0x121e0a1e),
3693// o.u(0x906c4848, 0xfcb46cb4), o.u(0x6be4b8b8, 0x8f37e437),
3694// o.u(0x255d9f9f, 0x78e75de7), o.u(0x616ebdbd, 0xfb26eb2),
3695// o.u(0x86ef4343, 0x692aef2a), o.u(0x93a6c4c4, 0x35f1a6f1),
3696// o.u(0x72a83939, 0xdae3a8e3), o.u(0x62a43131, 0xc6f7a4f7),
3697// o.u(0xbd37d3d3, 0x8a593759), o.u(0xff8bf2f2, 0x74868b86),
3698// o.u(0xb132d5d5, 0x83563256), o.u(0xd438b8b, 0x4ec543c5),
3699// o.u(0xdc596e6e, 0x85eb59eb), o.u(0xafb7dada, 0x18c2b7c2),
3700// o.u(0x28c0101, 0x8e8f8c8f), o.u(0x7964b1b1, 0x1dac64ac),
3701// o.u(0x23d29c9c, 0xf16dd26d), o.u(0x92e04949, 0x723be03b),
3702// o.u(0xabb4d8d8, 0x1fc7b4c7), o.u(0x43faacac, 0xb915fa15),
3703// o.u(0xfd07f3f3, 0xfa090709), o.u(0x8525cfcf, 0xa06f256f),
3704// o.u(0x8fafcaca, 0x20eaafea), o.u(0xf38ef4f4, 0x7d898e89),
3705// o.u(0x8ee94747, 0x6720e920), o.u(0x20181010, 0x38281828),
3706// o.u(0xded56f6f, 0xb64d564), o.u(0xfb88f0f0, 0x73838883),
3707// o.u(0x946f4a4a, 0xfbb16fb1), o.u(0xb8725c5c, 0xca967296),
3708// o.u(0x70243838, 0x546c246c), o.u(0xaef15757, 0x5f08f108),
3709// o.u(0xe6c77373, 0x2152c752), o.u(0x35519797, 0x64f351f3),
3710// o.u(0x8d23cbcb, 0xae652365), o.u(0x597ca1a1, 0x25847c84),
3711// o.u(0xcb9ce8e8, 0x57bf9cbf), o.u(0x7c213e3e, 0x5d632163),
3712// o.u(0x37dd9696, 0xea7cdd7c), o.u(0xc2dc6161, 0x1e7fdc7f),
3713// o.u(0x1a860d0d, 0x9c918691), o.u(0x1e850f0f, 0x9b948594),
3714// o.u(0xdb90e0e0, 0x4bab90ab), o.u(0xf8427c7c, 0xbac642c6),
3715// o.u(0xe2c47171, 0x2657c457), o.u(0x83aacccc, 0x29e5aae5),
3716// o.u(0x3bd89090, 0xe373d873), o.u(0xc050606, 0x90f050f),
3717// o.u(0xf501f7f7, 0xf4030103), o.u(0x38121c1c, 0x2a361236),
3718// o.u(0x9fa3c2c2, 0x3cfea3fe), o.u(0xd45f6a6a, 0x8be15fe1),
3719// o.u(0x47f9aeae, 0xbe10f910), o.u(0xd2d06969, 0x26bd06b),
3720// o.u(0x2e911717, 0xbfa891a8), o.u(0x29589999, 0x71e858e8),
3721// o.u(0x74273a3a, 0x53692769), o.u(0x4eb92727, 0xf7d0b9d0),
3722// o.u(0xa938d9d9, 0x91483848), o.u(0xcd13ebeb, 0xde351335),
3723// o.u(0x56b32b2b, 0xe5ceb3ce), o.u(0x44332222, 0x77553355),
3724// o.u(0xbfbbd2d2, 0x4d6bbd6), o.u(0x4970a9a9, 0x39907090),
3725// o.u(0xe890707, 0x87808980), o.u(0x66a73333, 0xc1f2a7f2),
3726// o.u(0x5ab62d2d, 0xecc1b6c1), o.u(0x78223c3c, 0x5a662266),
3727// o.u(0x2a921515, 0xb8ad92ad), o.u(0x8920c9c9, 0xa9602060),
3728// o.u(0x15498787, 0x5cdb49db), o.u(0x4fffaaaa, 0xb01aff1a),
3729// o.u(0xa0785050, 0xd8887888), o.u(0x517aa5a5, 0x2b8e7a8e),
3730// o.u(0x68f0303, 0x898a8f8a), o.u(0xb2f85959, 0x4a13f813),
3731// o.u(0x12800909, 0x929b809b), o.u(0x34171a1a, 0x23391739),
3732// o.u(0xcada6565, 0x1075da75), o.u(0xb531d7d7, 0x84533153),
3733// o.u(0x13c68484, 0xd551c651), o.u(0xbbb8d0d0, 0x3d3b8d3),
3734// o.u(0x1fc38282, 0xdc5ec35e), o.u(0x52b02929, 0xe2cbb0cb),
3735// o.u(0xb4775a5a, 0xc3997799), o.u(0x3c111e1e, 0x2d331133),
3736// o.u(0xf6cb7b7b, 0x3d46cb46), o.u(0x4bfca8a8, 0xb71ffc1f),
3737// o.u(0xdad66d6d, 0xc61d661), o.u(0x583a2c2c, 0x624e3a4e)
3738// ]
3739
3740// var T4 = [
3741// o.u(0xf497a5c6, 0xc632f4a5), o.u(0x97eb84f8, 0xf86f9784),
3742// o.u(0xb0c799ee, 0xee5eb099), o.u(0x8cf78df6, 0xf67a8c8d),
3743// o.u(0x17e50dff, 0xffe8170d), o.u(0xdcb7bdd6, 0xd60adcbd),
3744// o.u(0xc8a7b1de, 0xde16c8b1), o.u(0xfc395491, 0x916dfc54),
3745// o.u(0xf0c05060, 0x6090f050), o.u(0x05040302, 0x02070503),
3746// o.u(0xe087a9ce, 0xce2ee0a9), o.u(0x87ac7d56, 0x56d1877d),
3747// o.u(0x2bd519e7, 0xe7cc2b19), o.u(0xa67162b5, 0xb513a662),
3748// o.u(0x319ae64d, 0x4d7c31e6), o.u(0xb5c39aec, 0xec59b59a),
3749// o.u(0xcf05458f, 0x8f40cf45), o.u(0xbc3e9d1f, 0x1fa3bc9d),
3750// o.u(0xc0094089, 0x8949c040), o.u(0x92ef87fa, 0xfa689287),
3751// o.u(0x3fc515ef, 0xefd03f15), o.u(0x267febb2, 0xb29426eb),
3752// o.u(0x4007c98e, 0x8ece40c9), o.u(0x1ded0bfb, 0xfbe61d0b),
3753// o.u(0x2f82ec41, 0x416e2fec), o.u(0xa97d67b3, 0xb31aa967),
3754// o.u(0x1cbefd5f, 0x5f431cfd), o.u(0x258aea45, 0x456025ea),
3755// o.u(0xda46bf23, 0x23f9dabf), o.u(0x02a6f753, 0x535102f7),
3756// o.u(0xa1d396e4, 0xe445a196), o.u(0xed2d5b9b, 0x9b76ed5b),
3757// o.u(0x5deac275, 0x75285dc2), o.u(0x24d91ce1, 0xe1c5241c),
3758// o.u(0xe97aae3d, 0x3dd4e9ae), o.u(0xbe986a4c, 0x4cf2be6a),
3759// o.u(0xeed85a6c, 0x6c82ee5a), o.u(0xc3fc417e, 0x7ebdc341),
3760// o.u(0x06f102f5, 0xf5f30602), o.u(0xd11d4f83, 0x8352d14f),
3761// o.u(0xe4d05c68, 0x688ce45c), o.u(0x07a2f451, 0x515607f4),
3762// o.u(0x5cb934d1, 0xd18d5c34), o.u(0x18e908f9, 0xf9e11808),
3763// o.u(0xaedf93e2, 0xe24cae93), o.u(0x954d73ab, 0xab3e9573),
3764// o.u(0xf5c45362, 0x6297f553), o.u(0x41543f2a, 0x2a6b413f),
3765// o.u(0x14100c08, 0x081c140c), o.u(0xf6315295, 0x9563f652),
3766// o.u(0xaf8c6546, 0x46e9af65), o.u(0xe2215e9d, 0x9d7fe25e),
3767// o.u(0x78602830, 0x30487828), o.u(0xf86ea137, 0x37cff8a1),
3768// o.u(0x11140f0a, 0x0a1b110f), o.u(0xc45eb52f, 0x2febc4b5),
3769// o.u(0x1b1c090e, 0x0e151b09), o.u(0x5a483624, 0x247e5a36),
3770// o.u(0xb6369b1b, 0x1badb69b), o.u(0x47a53ddf, 0xdf98473d),
3771// o.u(0x6a8126cd, 0xcda76a26), o.u(0xbb9c694e, 0x4ef5bb69),
3772// o.u(0x4cfecd7f, 0x7f334ccd), o.u(0xbacf9fea, 0xea50ba9f),
3773// o.u(0x2d241b12, 0x123f2d1b), o.u(0xb93a9e1d, 0x1da4b99e),
3774// o.u(0x9cb07458, 0x58c49c74), o.u(0x72682e34, 0x3446722e),
3775// o.u(0x776c2d36, 0x3641772d), o.u(0xcda3b2dc, 0xdc11cdb2),
3776// o.u(0x2973eeb4, 0xb49d29ee), o.u(0x16b6fb5b, 0x5b4d16fb),
3777// o.u(0x0153f6a4, 0xa4a501f6), o.u(0xd7ec4d76, 0x76a1d74d),
3778// o.u(0xa37561b7, 0xb714a361), o.u(0x49face7d, 0x7d3449ce),
3779// o.u(0x8da47b52, 0x52df8d7b), o.u(0x42a13edd, 0xdd9f423e),
3780// o.u(0x93bc715e, 0x5ecd9371), o.u(0xa2269713, 0x13b1a297),
3781// o.u(0x0457f5a6, 0xa6a204f5), o.u(0xb86968b9, 0xb901b868),
3782// o.u(0x00000000, 0x00000000), o.u(0x74992cc1, 0xc1b5742c),
3783// o.u(0xa0806040, 0x40e0a060), o.u(0x21dd1fe3, 0xe3c2211f),
3784// o.u(0x43f2c879, 0x793a43c8), o.u(0x2c77edb6, 0xb69a2ced),
3785// o.u(0xd9b3bed4, 0xd40dd9be), o.u(0xca01468d, 0x8d47ca46),
3786// o.u(0x70ced967, 0x671770d9), o.u(0xdde44b72, 0x72afdd4b),
3787// o.u(0x7933de94, 0x94ed79de), o.u(0x672bd498, 0x98ff67d4),
3788// o.u(0x237be8b0, 0xb09323e8), o.u(0xde114a85, 0x855bde4a),
3789// o.u(0xbd6d6bbb, 0xbb06bd6b), o.u(0x7e912ac5, 0xc5bb7e2a),
3790// o.u(0x349ee54f, 0x4f7b34e5), o.u(0x3ac116ed, 0xedd73a16),
3791// o.u(0x5417c586, 0x86d254c5), o.u(0x622fd79a, 0x9af862d7),
3792// o.u(0xffcc5566, 0x6699ff55), o.u(0xa7229411, 0x11b6a794),
3793// o.u(0x4a0fcf8a, 0x8ac04acf), o.u(0x30c910e9, 0xe9d93010),
3794// o.u(0x0a080604, 0x040e0a06), o.u(0x98e781fe, 0xfe669881),
3795// o.u(0x0b5bf0a0, 0xa0ab0bf0), o.u(0xccf04478, 0x78b4cc44),
3796// o.u(0xd54aba25, 0x25f0d5ba), o.u(0x3e96e34b, 0x4b753ee3),
3797// o.u(0x0e5ff3a2, 0xa2ac0ef3), o.u(0x19bafe5d, 0x5d4419fe),
3798// o.u(0x5b1bc080, 0x80db5bc0), o.u(0x850a8a05, 0x0580858a),
3799// o.u(0xec7ead3f, 0x3fd3ecad), o.u(0xdf42bc21, 0x21fedfbc),
3800// o.u(0xd8e04870, 0x70a8d848), o.u(0x0cf904f1, 0xf1fd0c04),
3801// o.u(0x7ac6df63, 0x63197adf), o.u(0x58eec177, 0x772f58c1),
3802// o.u(0x9f4575af, 0xaf309f75), o.u(0xa5846342, 0x42e7a563),
3803// o.u(0x50403020, 0x20705030), o.u(0x2ed11ae5, 0xe5cb2e1a),
3804// o.u(0x12e10efd, 0xfdef120e), o.u(0xb7656dbf, 0xbf08b76d),
3805// o.u(0xd4194c81, 0x8155d44c), o.u(0x3c301418, 0x18243c14),
3806// o.u(0x5f4c3526, 0x26795f35), o.u(0x719d2fc3, 0xc3b2712f),
3807// o.u(0x3867e1be, 0xbe8638e1), o.u(0xfd6aa235, 0x35c8fda2),
3808// o.u(0x4f0bcc88, 0x88c74fcc), o.u(0x4b5c392e, 0x2e654b39),
3809// o.u(0xf93d5793, 0x936af957), o.u(0x0daaf255, 0x55580df2),
3810// o.u(0x9de382fc, 0xfc619d82), o.u(0xc9f4477a, 0x7ab3c947),
3811// o.u(0xef8bacc8, 0xc827efac), o.u(0x326fe7ba, 0xba8832e7),
3812// o.u(0x7d642b32, 0x324f7d2b), o.u(0xa4d795e6, 0xe642a495),
3813// o.u(0xfb9ba0c0, 0xc03bfba0), o.u(0xb3329819, 0x19aab398),
3814// o.u(0x6827d19e, 0x9ef668d1), o.u(0x815d7fa3, 0xa322817f),
3815// o.u(0xaa886644, 0x44eeaa66), o.u(0x82a87e54, 0x54d6827e),
3816// o.u(0xe676ab3b, 0x3bdde6ab), o.u(0x9e16830b, 0x0b959e83),
3817// o.u(0x4503ca8c, 0x8cc945ca), o.u(0x7b9529c7, 0xc7bc7b29),
3818// o.u(0x6ed6d36b, 0x6b056ed3), o.u(0x44503c28, 0x286c443c),
3819// o.u(0x8b5579a7, 0xa72c8b79), o.u(0x3d63e2bc, 0xbc813de2),
3820// o.u(0x272c1d16, 0x1631271d), o.u(0x9a4176ad, 0xad379a76),
3821// o.u(0x4dad3bdb, 0xdb964d3b), o.u(0xfac85664, 0x649efa56),
3822// o.u(0xd2e84e74, 0x74a6d24e), o.u(0x22281e14, 0x1436221e),
3823// o.u(0x763fdb92, 0x92e476db), o.u(0x1e180a0c, 0x0c121e0a),
3824// o.u(0xb4906c48, 0x48fcb46c), o.u(0x376be4b8, 0xb88f37e4),
3825// o.u(0xe7255d9f, 0x9f78e75d), o.u(0xb2616ebd, 0xbd0fb26e),
3826// o.u(0x2a86ef43, 0x43692aef), o.u(0xf193a6c4, 0xc435f1a6),
3827// o.u(0xe372a839, 0x39dae3a8), o.u(0xf762a431, 0x31c6f7a4),
3828// o.u(0x59bd37d3, 0xd38a5937), o.u(0x86ff8bf2, 0xf274868b),
3829// o.u(0x56b132d5, 0xd5835632), o.u(0xc50d438b, 0x8b4ec543),
3830// o.u(0xebdc596e, 0x6e85eb59), o.u(0xc2afb7da, 0xda18c2b7),
3831// o.u(0x8f028c01, 0x018e8f8c), o.u(0xac7964b1, 0xb11dac64),
3832// o.u(0x6d23d29c, 0x9cf16dd2), o.u(0x3b92e049, 0x49723be0),
3833// o.u(0xc7abb4d8, 0xd81fc7b4), o.u(0x1543faac, 0xacb915fa),
3834// o.u(0x09fd07f3, 0xf3fa0907), o.u(0x6f8525cf, 0xcfa06f25),
3835// o.u(0xea8fafca, 0xca20eaaf), o.u(0x89f38ef4, 0xf47d898e),
3836// o.u(0x208ee947, 0x476720e9), o.u(0x28201810, 0x10382818),
3837// o.u(0x64ded56f, 0x6f0b64d5), o.u(0x83fb88f0, 0xf0738388),
3838// o.u(0xb1946f4a, 0x4afbb16f), o.u(0x96b8725c, 0x5cca9672),
3839// o.u(0x6c702438, 0x38546c24), o.u(0x08aef157, 0x575f08f1),
3840// o.u(0x52e6c773, 0x732152c7), o.u(0xf3355197, 0x9764f351),
3841// o.u(0x658d23cb, 0xcbae6523), o.u(0x84597ca1, 0xa125847c),
3842// o.u(0xbfcb9ce8, 0xe857bf9c), o.u(0x637c213e, 0x3e5d6321),
3843// o.u(0x7c37dd96, 0x96ea7cdd), o.u(0x7fc2dc61, 0x611e7fdc),
3844// o.u(0x911a860d, 0x0d9c9186), o.u(0x941e850f, 0x0f9b9485),
3845// o.u(0xabdb90e0, 0xe04bab90), o.u(0xc6f8427c, 0x7cbac642),
3846// o.u(0x57e2c471, 0x712657c4), o.u(0xe583aacc, 0xcc29e5aa),
3847// o.u(0x733bd890, 0x90e373d8), o.u(0x0f0c0506, 0x06090f05),
3848// o.u(0x03f501f7, 0xf7f40301), o.u(0x3638121c, 0x1c2a3612),
3849// o.u(0xfe9fa3c2, 0xc23cfea3), o.u(0xe1d45f6a, 0x6a8be15f),
3850// o.u(0x1047f9ae, 0xaebe10f9), o.u(0x6bd2d069, 0x69026bd0),
3851// o.u(0xa82e9117, 0x17bfa891), o.u(0xe8295899, 0x9971e858),
3852// o.u(0x6974273a, 0x3a536927), o.u(0xd04eb927, 0x27f7d0b9),
3853// o.u(0x48a938d9, 0xd9914838), o.u(0x35cd13eb, 0xebde3513),
3854// o.u(0xce56b32b, 0x2be5ceb3), o.u(0x55443322, 0x22775533),
3855// o.u(0xd6bfbbd2, 0xd204d6bb), o.u(0x904970a9, 0xa9399070),
3856// o.u(0x800e8907, 0x07878089), o.u(0xf266a733, 0x33c1f2a7),
3857// o.u(0xc15ab62d, 0x2decc1b6), o.u(0x6678223c, 0x3c5a6622),
3858// o.u(0xad2a9215, 0x15b8ad92), o.u(0x608920c9, 0xc9a96020),
3859// o.u(0xdb154987, 0x875cdb49), o.u(0x1a4fffaa, 0xaab01aff),
3860// o.u(0x88a07850, 0x50d88878), o.u(0x8e517aa5, 0xa52b8e7a),
3861// o.u(0x8a068f03, 0x03898a8f), o.u(0x13b2f859, 0x594a13f8),
3862// o.u(0x9b128009, 0x09929b80), o.u(0x3934171a, 0x1a233917),
3863// o.u(0x75cada65, 0x651075da), o.u(0x53b531d7, 0xd7845331),
3864// o.u(0x5113c684, 0x84d551c6), o.u(0xd3bbb8d0, 0xd003d3b8),
3865// o.u(0x5e1fc382, 0x82dc5ec3), o.u(0xcb52b029, 0x29e2cbb0),
3866// o.u(0x99b4775a, 0x5ac39977), o.u(0x333c111e, 0x1e2d3311),
3867// o.u(0x46f6cb7b, 0x7b3d46cb), o.u(0x1f4bfca8, 0xa8b71ffc),
3868// o.u(0x61dad66d, 0x6d0c61d6), o.u(0x4e583a2c, 0x2c624e3a)
3869// ];
3870
3871// var T5 = [
3872// o.u(0xa5f497a5, 0xc6c632f4), o.u(0x8497eb84, 0xf8f86f97),
3873// o.u(0x99b0c799, 0xeeee5eb0), o.u(0x8d8cf78d, 0xf6f67a8c),
3874// o.u(0xd17e50d, 0xffffe817), o.u(0xbddcb7bd, 0xd6d60adc),
3875// o.u(0xb1c8a7b1, 0xdede16c8), o.u(0x54fc3954, 0x91916dfc),
3876// o.u(0x50f0c050, 0x606090f0), o.u(0x3050403, 0x2020705),
3877// o.u(0xa9e087a9, 0xcece2ee0), o.u(0x7d87ac7d, 0x5656d187),
3878// o.u(0x192bd519, 0xe7e7cc2b), o.u(0x62a67162, 0xb5b513a6),
3879// o.u(0xe6319ae6, 0x4d4d7c31), o.u(0x9ab5c39a, 0xecec59b5),
3880// o.u(0x45cf0545, 0x8f8f40cf), o.u(0x9dbc3e9d, 0x1f1fa3bc),
3881// o.u(0x40c00940, 0x898949c0), o.u(0x8792ef87, 0xfafa6892),
3882// o.u(0x153fc515, 0xefefd03f), o.u(0xeb267feb, 0xb2b29426),
3883// o.u(0xc94007c9, 0x8e8ece40), o.u(0xb1ded0b, 0xfbfbe61d),
3884// o.u(0xec2f82ec, 0x41416e2f), o.u(0x67a97d67, 0xb3b31aa9),
3885// o.u(0xfd1cbefd, 0x5f5f431c), o.u(0xea258aea, 0x45456025),
3886// o.u(0xbfda46bf, 0x2323f9da), o.u(0xf702a6f7, 0x53535102),
3887// o.u(0x96a1d396, 0xe4e445a1), o.u(0x5bed2d5b, 0x9b9b76ed),
3888// o.u(0xc25deac2, 0x7575285d), o.u(0x1c24d91c, 0xe1e1c524),
3889// o.u(0xaee97aae, 0x3d3dd4e9), o.u(0x6abe986a, 0x4c4cf2be),
3890// o.u(0x5aeed85a, 0x6c6c82ee), o.u(0x41c3fc41, 0x7e7ebdc3),
3891// o.u(0x206f102, 0xf5f5f306), o.u(0x4fd11d4f, 0x838352d1),
3892// o.u(0x5ce4d05c, 0x68688ce4), o.u(0xf407a2f4, 0x51515607),
3893// o.u(0x345cb934, 0xd1d18d5c), o.u(0x818e908, 0xf9f9e118),
3894// o.u(0x93aedf93, 0xe2e24cae), o.u(0x73954d73, 0xabab3e95),
3895// o.u(0x53f5c453, 0x626297f5), o.u(0x3f41543f, 0x2a2a6b41),
3896// o.u(0xc14100c, 0x8081c14), o.u(0x52f63152, 0x959563f6),
3897// o.u(0x65af8c65, 0x4646e9af), o.u(0x5ee2215e, 0x9d9d7fe2),
3898// o.u(0x28786028, 0x30304878), o.u(0xa1f86ea1, 0x3737cff8),
3899// o.u(0xf11140f, 0xa0a1b11), o.u(0xb5c45eb5, 0x2f2febc4),
3900// o.u(0x91b1c09, 0xe0e151b), o.u(0x365a4836, 0x24247e5a),
3901// o.u(0x9bb6369b, 0x1b1badb6), o.u(0x3d47a53d, 0xdfdf9847),
3902// o.u(0x266a8126, 0xcdcda76a), o.u(0x69bb9c69, 0x4e4ef5bb),
3903// o.u(0xcd4cfecd, 0x7f7f334c), o.u(0x9fbacf9f, 0xeaea50ba),
3904// o.u(0x1b2d241b, 0x12123f2d), o.u(0x9eb93a9e, 0x1d1da4b9),
3905// o.u(0x749cb074, 0x5858c49c), o.u(0x2e72682e, 0x34344672),
3906// o.u(0x2d776c2d, 0x36364177), o.u(0xb2cda3b2, 0xdcdc11cd),
3907// o.u(0xee2973ee, 0xb4b49d29), o.u(0xfb16b6fb, 0x5b5b4d16),
3908// o.u(0xf60153f6, 0xa4a4a501), o.u(0x4dd7ec4d, 0x7676a1d7),
3909// o.u(0x61a37561, 0xb7b714a3), o.u(0xce49face, 0x7d7d3449),
3910// o.u(0x7b8da47b, 0x5252df8d), o.u(0x3e42a13e, 0xdddd9f42),
3911// o.u(0x7193bc71, 0x5e5ecd93), o.u(0x97a22697, 0x1313b1a2),
3912// o.u(0xf50457f5, 0xa6a6a204), o.u(0x68b86968, 0xb9b901b8),
3913// o.u(0x0, 0x0), o.u(0x2c74992c, 0xc1c1b574),
3914// o.u(0x60a08060, 0x4040e0a0), o.u(0x1f21dd1f, 0xe3e3c221),
3915// o.u(0xc843f2c8, 0x79793a43), o.u(0xed2c77ed, 0xb6b69a2c),
3916// o.u(0xbed9b3be, 0xd4d40dd9), o.u(0x46ca0146, 0x8d8d47ca),
3917// o.u(0xd970ced9, 0x67671770), o.u(0x4bdde44b, 0x7272afdd),
3918// o.u(0xde7933de, 0x9494ed79), o.u(0xd4672bd4, 0x9898ff67),
3919// o.u(0xe8237be8, 0xb0b09323), o.u(0x4ade114a, 0x85855bde),
3920// o.u(0x6bbd6d6b, 0xbbbb06bd), o.u(0x2a7e912a, 0xc5c5bb7e),
3921// o.u(0xe5349ee5, 0x4f4f7b34), o.u(0x163ac116, 0xededd73a),
3922// o.u(0xc55417c5, 0x8686d254), o.u(0xd7622fd7, 0x9a9af862),
3923// o.u(0x55ffcc55, 0x666699ff), o.u(0x94a72294, 0x1111b6a7),
3924// o.u(0xcf4a0fcf, 0x8a8ac04a), o.u(0x1030c910, 0xe9e9d930),
3925// o.u(0x60a0806, 0x4040e0a), o.u(0x8198e781, 0xfefe6698),
3926// o.u(0xf00b5bf0, 0xa0a0ab0b), o.u(0x44ccf044, 0x7878b4cc),
3927// o.u(0xbad54aba, 0x2525f0d5), o.u(0xe33e96e3, 0x4b4b753e),
3928// o.u(0xf30e5ff3, 0xa2a2ac0e), o.u(0xfe19bafe, 0x5d5d4419),
3929// o.u(0xc05b1bc0, 0x8080db5b), o.u(0x8a850a8a, 0x5058085),
3930// o.u(0xadec7ead, 0x3f3fd3ec), o.u(0xbcdf42bc, 0x2121fedf),
3931// o.u(0x48d8e048, 0x7070a8d8), o.u(0x40cf904, 0xf1f1fd0c),
3932// o.u(0xdf7ac6df, 0x6363197a), o.u(0xc158eec1, 0x77772f58),
3933// o.u(0x759f4575, 0xafaf309f), o.u(0x63a58463, 0x4242e7a5),
3934// o.u(0x30504030, 0x20207050), o.u(0x1a2ed11a, 0xe5e5cb2e),
3935// o.u(0xe12e10e, 0xfdfdef12), o.u(0x6db7656d, 0xbfbf08b7),
3936// o.u(0x4cd4194c, 0x818155d4), o.u(0x143c3014, 0x1818243c),
3937// o.u(0x355f4c35, 0x2626795f), o.u(0x2f719d2f, 0xc3c3b271),
3938// o.u(0xe13867e1, 0xbebe8638), o.u(0xa2fd6aa2, 0x3535c8fd),
3939// o.u(0xcc4f0bcc, 0x8888c74f), o.u(0x394b5c39, 0x2e2e654b),
3940// o.u(0x57f93d57, 0x93936af9), o.u(0xf20daaf2, 0x5555580d),
3941// o.u(0x829de382, 0xfcfc619d), o.u(0x47c9f447, 0x7a7ab3c9),
3942// o.u(0xacef8bac, 0xc8c827ef), o.u(0xe7326fe7, 0xbaba8832),
3943// o.u(0x2b7d642b, 0x32324f7d), o.u(0x95a4d795, 0xe6e642a4),
3944// o.u(0xa0fb9ba0, 0xc0c03bfb), o.u(0x98b33298, 0x1919aab3),
3945// o.u(0xd16827d1, 0x9e9ef668), o.u(0x7f815d7f, 0xa3a32281),
3946// o.u(0x66aa8866, 0x4444eeaa), o.u(0x7e82a87e, 0x5454d682),
3947// o.u(0xabe676ab, 0x3b3bdde6), o.u(0x839e1683, 0xb0b959e),
3948// o.u(0xca4503ca, 0x8c8cc945), o.u(0x297b9529, 0xc7c7bc7b),
3949// o.u(0xd36ed6d3, 0x6b6b056e), o.u(0x3c44503c, 0x28286c44),
3950// o.u(0x798b5579, 0xa7a72c8b), o.u(0xe23d63e2, 0xbcbc813d),
3951// o.u(0x1d272c1d, 0x16163127), o.u(0x769a4176, 0xadad379a),
3952// o.u(0x3b4dad3b, 0xdbdb964d), o.u(0x56fac856, 0x64649efa),
3953// o.u(0x4ed2e84e, 0x7474a6d2), o.u(0x1e22281e, 0x14143622),
3954// o.u(0xdb763fdb, 0x9292e476), o.u(0xa1e180a, 0xc0c121e),
3955// o.u(0x6cb4906c, 0x4848fcb4), o.u(0xe4376be4, 0xb8b88f37),
3956// o.u(0x5de7255d, 0x9f9f78e7), o.u(0x6eb2616e, 0xbdbd0fb2),
3957// o.u(0xef2a86ef, 0x4343692a), o.u(0xa6f193a6, 0xc4c435f1),
3958// o.u(0xa8e372a8, 0x3939dae3), o.u(0xa4f762a4, 0x3131c6f7),
3959// o.u(0x3759bd37, 0xd3d38a59), o.u(0x8b86ff8b, 0xf2f27486),
3960// o.u(0x3256b132, 0xd5d58356), o.u(0x43c50d43, 0x8b8b4ec5),
3961// o.u(0x59ebdc59, 0x6e6e85eb), o.u(0xb7c2afb7, 0xdada18c2),
3962// o.u(0x8c8f028c, 0x1018e8f), o.u(0x64ac7964, 0xb1b11dac),
3963// o.u(0xd26d23d2, 0x9c9cf16d), o.u(0xe03b92e0, 0x4949723b),
3964// o.u(0xb4c7abb4, 0xd8d81fc7), o.u(0xfa1543fa, 0xacacb915),
3965// o.u(0x709fd07, 0xf3f3fa09), o.u(0x256f8525, 0xcfcfa06f),
3966// o.u(0xafea8faf, 0xcaca20ea), o.u(0x8e89f38e, 0xf4f47d89),
3967// o.u(0xe9208ee9, 0x47476720), o.u(0x18282018, 0x10103828),
3968// o.u(0xd564ded5, 0x6f6f0b64), o.u(0x8883fb88, 0xf0f07383),
3969// o.u(0x6fb1946f, 0x4a4afbb1), o.u(0x7296b872, 0x5c5cca96),
3970// o.u(0x246c7024, 0x3838546c), o.u(0xf108aef1, 0x57575f08),
3971// o.u(0xc752e6c7, 0x73732152), o.u(0x51f33551, 0x979764f3),
3972// o.u(0x23658d23, 0xcbcbae65), o.u(0x7c84597c, 0xa1a12584),
3973// o.u(0x9cbfcb9c, 0xe8e857bf), o.u(0x21637c21, 0x3e3e5d63),
3974// o.u(0xdd7c37dd, 0x9696ea7c), o.u(0xdc7fc2dc, 0x61611e7f),
3975// o.u(0x86911a86, 0xd0d9c91), o.u(0x85941e85, 0xf0f9b94),
3976// o.u(0x90abdb90, 0xe0e04bab), o.u(0x42c6f842, 0x7c7cbac6),
3977// o.u(0xc457e2c4, 0x71712657), o.u(0xaae583aa, 0xcccc29e5),
3978// o.u(0xd8733bd8, 0x9090e373), o.u(0x50f0c05, 0x606090f),
3979// o.u(0x103f501, 0xf7f7f403), o.u(0x12363812, 0x1c1c2a36),
3980// o.u(0xa3fe9fa3, 0xc2c23cfe), o.u(0x5fe1d45f, 0x6a6a8be1),
3981// o.u(0xf91047f9, 0xaeaebe10), o.u(0xd06bd2d0, 0x6969026b),
3982// o.u(0x91a82e91, 0x1717bfa8), o.u(0x58e82958, 0x999971e8),
3983// o.u(0x27697427, 0x3a3a5369), o.u(0xb9d04eb9, 0x2727f7d0),
3984// o.u(0x3848a938, 0xd9d99148), o.u(0x1335cd13, 0xebebde35),
3985// o.u(0xb3ce56b3, 0x2b2be5ce), o.u(0x33554433, 0x22227755),
3986// o.u(0xbbd6bfbb, 0xd2d204d6), o.u(0x70904970, 0xa9a93990),
3987// o.u(0x89800e89, 0x7078780), o.u(0xa7f266a7, 0x3333c1f2),
3988// o.u(0xb6c15ab6, 0x2d2decc1), o.u(0x22667822, 0x3c3c5a66),
3989// o.u(0x92ad2a92, 0x1515b8ad), o.u(0x20608920, 0xc9c9a960),
3990// o.u(0x49db1549, 0x87875cdb), o.u(0xff1a4fff, 0xaaaab01a),
3991// o.u(0x7888a078, 0x5050d888), o.u(0x7a8e517a, 0xa5a52b8e),
3992// o.u(0x8f8a068f, 0x303898a), o.u(0xf813b2f8, 0x59594a13),
3993// o.u(0x809b1280, 0x909929b), o.u(0x17393417, 0x1a1a2339),
3994// o.u(0xda75cada, 0x65651075), o.u(0x3153b531, 0xd7d78453),
3995// o.u(0xc65113c6, 0x8484d551), o.u(0xb8d3bbb8, 0xd0d003d3),
3996// o.u(0xc35e1fc3, 0x8282dc5e), o.u(0xb0cb52b0, 0x2929e2cb),
3997// o.u(0x7799b477, 0x5a5ac399), o.u(0x11333c11, 0x1e1e2d33),
3998// o.u(0xcb46f6cb, 0x7b7b3d46), o.u(0xfc1f4bfc, 0xa8a8b71f),
3999// o.u(0xd661dad6, 0x6d6d0c61), o.u(0x3a4e583a, 0x2c2c624e)
4000// ];
4001
4002// var T6 = [
4003// o.u(0xf4a5f497, 0xa5c6c632), o.u(0x978497eb, 0x84f8f86f),
4004// o.u(0xb099b0c7, 0x99eeee5e), o.u(0x8c8d8cf7, 0x8df6f67a),
4005// o.u(0x170d17e5, 0xdffffe8), o.u(0xdcbddcb7, 0xbdd6d60a),
4006// o.u(0xc8b1c8a7, 0xb1dede16), o.u(0xfc54fc39, 0x5491916d),
4007// o.u(0xf050f0c0, 0x50606090), o.u(0x5030504, 0x3020207),
4008// o.u(0xe0a9e087, 0xa9cece2e), o.u(0x877d87ac, 0x7d5656d1),
4009// o.u(0x2b192bd5, 0x19e7e7cc), o.u(0xa662a671, 0x62b5b513),
4010// o.u(0x31e6319a, 0xe64d4d7c), o.u(0xb59ab5c3, 0x9aecec59),
4011// o.u(0xcf45cf05, 0x458f8f40), o.u(0xbc9dbc3e, 0x9d1f1fa3),
4012// o.u(0xc040c009, 0x40898949), o.u(0x928792ef, 0x87fafa68),
4013// o.u(0x3f153fc5, 0x15efefd0), o.u(0x26eb267f, 0xebb2b294),
4014// o.u(0x40c94007, 0xc98e8ece), o.u(0x1d0b1ded, 0xbfbfbe6),
4015// o.u(0x2fec2f82, 0xec41416e), o.u(0xa967a97d, 0x67b3b31a),
4016// o.u(0x1cfd1cbe, 0xfd5f5f43), o.u(0x25ea258a, 0xea454560),
4017// o.u(0xdabfda46, 0xbf2323f9), o.u(0x2f702a6, 0xf7535351),
4018// o.u(0xa196a1d3, 0x96e4e445), o.u(0xed5bed2d, 0x5b9b9b76),
4019// o.u(0x5dc25dea, 0xc2757528), o.u(0x241c24d9, 0x1ce1e1c5),
4020// o.u(0xe9aee97a, 0xae3d3dd4), o.u(0xbe6abe98, 0x6a4c4cf2),
4021// o.u(0xee5aeed8, 0x5a6c6c82), o.u(0xc341c3fc, 0x417e7ebd),
4022// o.u(0x60206f1, 0x2f5f5f3), o.u(0xd14fd11d, 0x4f838352),
4023// o.u(0xe45ce4d0, 0x5c68688c), o.u(0x7f407a2, 0xf4515156),
4024// o.u(0x5c345cb9, 0x34d1d18d), o.u(0x180818e9, 0x8f9f9e1),
4025// o.u(0xae93aedf, 0x93e2e24c), o.u(0x9573954d, 0x73abab3e),
4026// o.u(0xf553f5c4, 0x53626297), o.u(0x413f4154, 0x3f2a2a6b),
4027// o.u(0x140c1410, 0xc08081c), o.u(0xf652f631, 0x52959563),
4028// o.u(0xaf65af8c, 0x654646e9), o.u(0xe25ee221, 0x5e9d9d7f),
4029// o.u(0x78287860, 0x28303048), o.u(0xf8a1f86e, 0xa13737cf),
4030// o.u(0x110f1114, 0xf0a0a1b), o.u(0xc4b5c45e, 0xb52f2feb),
4031// o.u(0x1b091b1c, 0x90e0e15), o.u(0x5a365a48, 0x3624247e),
4032// o.u(0xb69bb636, 0x9b1b1bad), o.u(0x473d47a5, 0x3ddfdf98),
4033// o.u(0x6a266a81, 0x26cdcda7), o.u(0xbb69bb9c, 0x694e4ef5),
4034// o.u(0x4ccd4cfe, 0xcd7f7f33), o.u(0xba9fbacf, 0x9feaea50),
4035// o.u(0x2d1b2d24, 0x1b12123f), o.u(0xb99eb93a, 0x9e1d1da4),
4036// o.u(0x9c749cb0, 0x745858c4), o.u(0x722e7268, 0x2e343446),
4037// o.u(0x772d776c, 0x2d363641), o.u(0xcdb2cda3, 0xb2dcdc11),
4038// o.u(0x29ee2973, 0xeeb4b49d), o.u(0x16fb16b6, 0xfb5b5b4d),
4039// o.u(0x1f60153, 0xf6a4a4a5), o.u(0xd74dd7ec, 0x4d7676a1),
4040// o.u(0xa361a375, 0x61b7b714), o.u(0x49ce49fa, 0xce7d7d34),
4041// o.u(0x8d7b8da4, 0x7b5252df), o.u(0x423e42a1, 0x3edddd9f),
4042// o.u(0x937193bc, 0x715e5ecd), o.u(0xa297a226, 0x971313b1),
4043// o.u(0x4f50457, 0xf5a6a6a2), o.u(0xb868b869, 0x68b9b901),
4044// o.u(0x0, 0x0), o.u(0x742c7499, 0x2cc1c1b5),
4045// o.u(0xa060a080, 0x604040e0), o.u(0x211f21dd, 0x1fe3e3c2),
4046// o.u(0x43c843f2, 0xc879793a), o.u(0x2ced2c77, 0xedb6b69a),
4047// o.u(0xd9bed9b3, 0xbed4d40d), o.u(0xca46ca01, 0x468d8d47),
4048// o.u(0x70d970ce, 0xd9676717), o.u(0xdd4bdde4, 0x4b7272af),
4049// o.u(0x79de7933, 0xde9494ed), o.u(0x67d4672b, 0xd49898ff),
4050// o.u(0x23e8237b, 0xe8b0b093), o.u(0xde4ade11, 0x4a85855b),
4051// o.u(0xbd6bbd6d, 0x6bbbbb06), o.u(0x7e2a7e91, 0x2ac5c5bb),
4052// o.u(0x34e5349e, 0xe54f4f7b), o.u(0x3a163ac1, 0x16ededd7),
4053// o.u(0x54c55417, 0xc58686d2), o.u(0x62d7622f, 0xd79a9af8),
4054// o.u(0xff55ffcc, 0x55666699), o.u(0xa794a722, 0x941111b6),
4055// o.u(0x4acf4a0f, 0xcf8a8ac0), o.u(0x301030c9, 0x10e9e9d9),
4056// o.u(0xa060a08, 0x604040e), o.u(0x988198e7, 0x81fefe66),
4057// o.u(0xbf00b5b, 0xf0a0a0ab), o.u(0xcc44ccf0, 0x447878b4),
4058// o.u(0xd5bad54a, 0xba2525f0), o.u(0x3ee33e96, 0xe34b4b75),
4059// o.u(0xef30e5f, 0xf3a2a2ac), o.u(0x19fe19ba, 0xfe5d5d44),
4060// o.u(0x5bc05b1b, 0xc08080db), o.u(0x858a850a, 0x8a050580),
4061// o.u(0xecadec7e, 0xad3f3fd3), o.u(0xdfbcdf42, 0xbc2121fe),
4062// o.u(0xd848d8e0, 0x487070a8), o.u(0xc040cf9, 0x4f1f1fd),
4063// o.u(0x7adf7ac6, 0xdf636319), o.u(0x58c158ee, 0xc177772f),
4064// o.u(0x9f759f45, 0x75afaf30), o.u(0xa563a584, 0x634242e7),
4065// o.u(0x50305040, 0x30202070), o.u(0x2e1a2ed1, 0x1ae5e5cb),
4066// o.u(0x120e12e1, 0xefdfdef), o.u(0xb76db765, 0x6dbfbf08),
4067// o.u(0xd44cd419, 0x4c818155), o.u(0x3c143c30, 0x14181824),
4068// o.u(0x5f355f4c, 0x35262679), o.u(0x712f719d, 0x2fc3c3b2),
4069// o.u(0x38e13867, 0xe1bebe86), o.u(0xfda2fd6a, 0xa23535c8),
4070// o.u(0x4fcc4f0b, 0xcc8888c7), o.u(0x4b394b5c, 0x392e2e65),
4071// o.u(0xf957f93d, 0x5793936a), o.u(0xdf20daa, 0xf2555558),
4072// o.u(0x9d829de3, 0x82fcfc61), o.u(0xc947c9f4, 0x477a7ab3),
4073// o.u(0xefacef8b, 0xacc8c827), o.u(0x32e7326f, 0xe7baba88),
4074// o.u(0x7d2b7d64, 0x2b32324f), o.u(0xa495a4d7, 0x95e6e642),
4075// o.u(0xfba0fb9b, 0xa0c0c03b), o.u(0xb398b332, 0x981919aa),
4076// o.u(0x68d16827, 0xd19e9ef6), o.u(0x817f815d, 0x7fa3a322),
4077// o.u(0xaa66aa88, 0x664444ee), o.u(0x827e82a8, 0x7e5454d6),
4078// o.u(0xe6abe676, 0xab3b3bdd), o.u(0x9e839e16, 0x830b0b95),
4079// o.u(0x45ca4503, 0xca8c8cc9), o.u(0x7b297b95, 0x29c7c7bc),
4080// o.u(0x6ed36ed6, 0xd36b6b05), o.u(0x443c4450, 0x3c28286c),
4081// o.u(0x8b798b55, 0x79a7a72c), o.u(0x3de23d63, 0xe2bcbc81),
4082// o.u(0x271d272c, 0x1d161631), o.u(0x9a769a41, 0x76adad37),
4083// o.u(0x4d3b4dad, 0x3bdbdb96), o.u(0xfa56fac8, 0x5664649e),
4084// o.u(0xd24ed2e8, 0x4e7474a6), o.u(0x221e2228, 0x1e141436),
4085// o.u(0x76db763f, 0xdb9292e4), o.u(0x1e0a1e18, 0xa0c0c12),
4086// o.u(0xb46cb490, 0x6c4848fc), o.u(0x37e4376b, 0xe4b8b88f),
4087// o.u(0xe75de725, 0x5d9f9f78), o.u(0xb26eb261, 0x6ebdbd0f),
4088// o.u(0x2aef2a86, 0xef434369), o.u(0xf1a6f193, 0xa6c4c435),
4089// o.u(0xe3a8e372, 0xa83939da), o.u(0xf7a4f762, 0xa43131c6),
4090// o.u(0x593759bd, 0x37d3d38a), o.u(0x868b86ff, 0x8bf2f274),
4091// o.u(0x563256b1, 0x32d5d583), o.u(0xc543c50d, 0x438b8b4e),
4092// o.u(0xeb59ebdc, 0x596e6e85), o.u(0xc2b7c2af, 0xb7dada18),
4093// o.u(0x8f8c8f02, 0x8c01018e), o.u(0xac64ac79, 0x64b1b11d),
4094// o.u(0x6dd26d23, 0xd29c9cf1), o.u(0x3be03b92, 0xe0494972),
4095// o.u(0xc7b4c7ab, 0xb4d8d81f), o.u(0x15fa1543, 0xfaacacb9),
4096// o.u(0x90709fd, 0x7f3f3fa), o.u(0x6f256f85, 0x25cfcfa0),
4097// o.u(0xeaafea8f, 0xafcaca20), o.u(0x898e89f3, 0x8ef4f47d),
4098// o.u(0x20e9208e, 0xe9474767), o.u(0x28182820, 0x18101038),
4099// o.u(0x64d564de, 0xd56f6f0b), o.u(0x838883fb, 0x88f0f073),
4100// o.u(0xb16fb194, 0x6f4a4afb), o.u(0x967296b8, 0x725c5cca),
4101// o.u(0x6c246c70, 0x24383854), o.u(0x8f108ae, 0xf157575f),
4102// o.u(0x52c752e6, 0xc7737321), o.u(0xf351f335, 0x51979764),
4103// o.u(0x6523658d, 0x23cbcbae), o.u(0x847c8459, 0x7ca1a125),
4104// o.u(0xbf9cbfcb, 0x9ce8e857), o.u(0x6321637c, 0x213e3e5d),
4105// o.u(0x7cdd7c37, 0xdd9696ea), o.u(0x7fdc7fc2, 0xdc61611e),
4106// o.u(0x9186911a, 0x860d0d9c), o.u(0x9485941e, 0x850f0f9b),
4107// o.u(0xab90abdb, 0x90e0e04b), o.u(0xc642c6f8, 0x427c7cba),
4108// o.u(0x57c457e2, 0xc4717126), o.u(0xe5aae583, 0xaacccc29),
4109// o.u(0x73d8733b, 0xd89090e3), o.u(0xf050f0c, 0x5060609),
4110// o.u(0x30103f5, 0x1f7f7f4), o.u(0x36123638, 0x121c1c2a),
4111// o.u(0xfea3fe9f, 0xa3c2c23c), o.u(0xe15fe1d4, 0x5f6a6a8b),
4112// o.u(0x10f91047, 0xf9aeaebe), o.u(0x6bd06bd2, 0xd0696902),
4113// o.u(0xa891a82e, 0x911717bf), o.u(0xe858e829, 0x58999971),
4114// o.u(0x69276974, 0x273a3a53), o.u(0xd0b9d04e, 0xb92727f7),
4115// o.u(0x483848a9, 0x38d9d991), o.u(0x351335cd, 0x13ebebde),
4116// o.u(0xceb3ce56, 0xb32b2be5), o.u(0x55335544, 0x33222277),
4117// o.u(0xd6bbd6bf, 0xbbd2d204), o.u(0x90709049, 0x70a9a939),
4118// o.u(0x8089800e, 0x89070787), o.u(0xf2a7f266, 0xa73333c1),
4119// o.u(0xc1b6c15a, 0xb62d2dec), o.u(0x66226678, 0x223c3c5a),
4120// o.u(0xad92ad2a, 0x921515b8), o.u(0x60206089, 0x20c9c9a9),
4121// o.u(0xdb49db15, 0x4987875c), o.u(0x1aff1a4f, 0xffaaaab0),
4122// o.u(0x887888a0, 0x785050d8), o.u(0x8e7a8e51, 0x7aa5a52b),
4123// o.u(0x8a8f8a06, 0x8f030389), o.u(0x13f813b2, 0xf859594a),
4124// o.u(0x9b809b12, 0x80090992), o.u(0x39173934, 0x171a1a23),
4125// o.u(0x75da75ca, 0xda656510), o.u(0x533153b5, 0x31d7d784),
4126// o.u(0x51c65113, 0xc68484d5), o.u(0xd3b8d3bb, 0xb8d0d003),
4127// o.u(0x5ec35e1f, 0xc38282dc), o.u(0xcbb0cb52, 0xb02929e2),
4128// o.u(0x997799b4, 0x775a5ac3), o.u(0x3311333c, 0x111e1e2d),
4129// o.u(0x46cb46f6, 0xcb7b7b3d), o.u(0x1ffc1f4b, 0xfca8a8b7),
4130// o.u(0x61d661da, 0xd66d6d0c), o.u(0x4e3a4e58, 0x3a2c2c62)
4131// ];
4132
4133// var T7 = [
4134// o.u(0x32f4a5f4, 0x97a5c6c6), o.u(0x6f978497, 0xeb84f8f8),
4135// o.u(0x5eb099b0, 0xc799eeee), o.u(0x7a8c8d8c, 0xf78df6f6),
4136// o.u(0xe8170d17, 0xe50dffff), o.u(0xadcbddc, 0xb7bdd6d6),
4137// o.u(0x16c8b1c8, 0xa7b1dede), o.u(0x6dfc54fc, 0x39549191),
4138// o.u(0x90f050f0, 0xc0506060), o.u(0x7050305, 0x4030202),
4139// o.u(0x2ee0a9e0, 0x87a9cece), o.u(0xd1877d87, 0xac7d5656),
4140// o.u(0xcc2b192b, 0xd519e7e7), o.u(0x13a662a6, 0x7162b5b5),
4141// o.u(0x7c31e631, 0x9ae64d4d), o.u(0x59b59ab5, 0xc39aecec),
4142// o.u(0x40cf45cf, 0x5458f8f), o.u(0xa3bc9dbc, 0x3e9d1f1f),
4143// o.u(0x49c040c0, 0x9408989), o.u(0x68928792, 0xef87fafa),
4144// o.u(0xd03f153f, 0xc515efef), o.u(0x9426eb26, 0x7febb2b2),
4145// o.u(0xce40c940, 0x7c98e8e), o.u(0xe61d0b1d, 0xed0bfbfb),
4146// o.u(0x6e2fec2f, 0x82ec4141), o.u(0x1aa967a9, 0x7d67b3b3),
4147// o.u(0x431cfd1c, 0xbefd5f5f), o.u(0x6025ea25, 0x8aea4545),
4148// o.u(0xf9dabfda, 0x46bf2323), o.u(0x5102f702, 0xa6f75353),
4149// o.u(0x45a196a1, 0xd396e4e4), o.u(0x76ed5bed, 0x2d5b9b9b),
4150// o.u(0x285dc25d, 0xeac27575), o.u(0xc5241c24, 0xd91ce1e1),
4151// o.u(0xd4e9aee9, 0x7aae3d3d), o.u(0xf2be6abe, 0x986a4c4c),
4152// o.u(0x82ee5aee, 0xd85a6c6c), o.u(0xbdc341c3, 0xfc417e7e),
4153// o.u(0xf3060206, 0xf102f5f5), o.u(0x52d14fd1, 0x1d4f8383),
4154// o.u(0x8ce45ce4, 0xd05c6868), o.u(0x5607f407, 0xa2f45151),
4155// o.u(0x8d5c345c, 0xb934d1d1), o.u(0xe1180818, 0xe908f9f9),
4156// o.u(0x4cae93ae, 0xdf93e2e2), o.u(0x3e957395, 0x4d73abab),
4157// o.u(0x97f553f5, 0xc4536262), o.u(0x6b413f41, 0x543f2a2a),
4158// o.u(0x1c140c14, 0x100c0808), o.u(0x63f652f6, 0x31529595),
4159// o.u(0xe9af65af, 0x8c654646), o.u(0x7fe25ee2, 0x215e9d9d),
4160// o.u(0x48782878, 0x60283030), o.u(0xcff8a1f8, 0x6ea13737),
4161// o.u(0x1b110f11, 0x140f0a0a), o.u(0xebc4b5c4, 0x5eb52f2f),
4162// o.u(0x151b091b, 0x1c090e0e), o.u(0x7e5a365a, 0x48362424),
4163// o.u(0xadb69bb6, 0x369b1b1b), o.u(0x98473d47, 0xa53ddfdf),
4164// o.u(0xa76a266a, 0x8126cdcd), o.u(0xf5bb69bb, 0x9c694e4e),
4165// o.u(0x334ccd4c, 0xfecd7f7f), o.u(0x50ba9fba, 0xcf9feaea),
4166// o.u(0x3f2d1b2d, 0x241b1212), o.u(0xa4b99eb9, 0x3a9e1d1d),
4167// o.u(0xc49c749c, 0xb0745858), o.u(0x46722e72, 0x682e3434),
4168// o.u(0x41772d77, 0x6c2d3636), o.u(0x11cdb2cd, 0xa3b2dcdc),
4169// o.u(0x9d29ee29, 0x73eeb4b4), o.u(0x4d16fb16, 0xb6fb5b5b),
4170// o.u(0xa501f601, 0x53f6a4a4), o.u(0xa1d74dd7, 0xec4d7676),
4171// o.u(0x14a361a3, 0x7561b7b7), o.u(0x3449ce49, 0xface7d7d),
4172// o.u(0xdf8d7b8d, 0xa47b5252), o.u(0x9f423e42, 0xa13edddd),
4173// o.u(0xcd937193, 0xbc715e5e), o.u(0xb1a297a2, 0x26971313),
4174// o.u(0xa204f504, 0x57f5a6a6), o.u(0x1b868b8, 0x6968b9b9),
4175// o.u(0x0, 0x0), o.u(0xb5742c74, 0x992cc1c1),
4176// o.u(0xe0a060a0, 0x80604040), o.u(0xc2211f21, 0xdd1fe3e3),
4177// o.u(0x3a43c843, 0xf2c87979), o.u(0x9a2ced2c, 0x77edb6b6),
4178// o.u(0xdd9bed9, 0xb3bed4d4), o.u(0x47ca46ca, 0x1468d8d),
4179// o.u(0x1770d970, 0xced96767), o.u(0xafdd4bdd, 0xe44b7272),
4180// o.u(0xed79de79, 0x33de9494), o.u(0xff67d467, 0x2bd49898),
4181// o.u(0x9323e823, 0x7be8b0b0), o.u(0x5bde4ade, 0x114a8585),
4182// o.u(0x6bd6bbd, 0x6d6bbbbb), o.u(0xbb7e2a7e, 0x912ac5c5),
4183// o.u(0x7b34e534, 0x9ee54f4f), o.u(0xd73a163a, 0xc116eded),
4184// o.u(0xd254c554, 0x17c58686), o.u(0xf862d762, 0x2fd79a9a),
4185// o.u(0x99ff55ff, 0xcc556666), o.u(0xb6a794a7, 0x22941111),
4186// o.u(0xc04acf4a, 0xfcf8a8a), o.u(0xd9301030, 0xc910e9e9),
4187// o.u(0xe0a060a, 0x8060404), o.u(0x66988198, 0xe781fefe),
4188// o.u(0xab0bf00b, 0x5bf0a0a0), o.u(0xb4cc44cc, 0xf0447878),
4189// o.u(0xf0d5bad5, 0x4aba2525), o.u(0x753ee33e, 0x96e34b4b),
4190// o.u(0xac0ef30e, 0x5ff3a2a2), o.u(0x4419fe19, 0xbafe5d5d),
4191// o.u(0xdb5bc05b, 0x1bc08080), o.u(0x80858a85, 0xa8a0505),
4192// o.u(0xd3ecadec, 0x7ead3f3f), o.u(0xfedfbcdf, 0x42bc2121),
4193// o.u(0xa8d848d8, 0xe0487070), o.u(0xfd0c040c, 0xf904f1f1),
4194// o.u(0x197adf7a, 0xc6df6363), o.u(0x2f58c158, 0xeec17777),
4195// o.u(0x309f759f, 0x4575afaf), o.u(0xe7a563a5, 0x84634242),
4196// o.u(0x70503050, 0x40302020), o.u(0xcb2e1a2e, 0xd11ae5e5),
4197// o.u(0xef120e12, 0xe10efdfd), o.u(0x8b76db7, 0x656dbfbf),
4198// o.u(0x55d44cd4, 0x194c8181), o.u(0x243c143c, 0x30141818),
4199// o.u(0x795f355f, 0x4c352626), o.u(0xb2712f71, 0x9d2fc3c3),
4200// o.u(0x8638e138, 0x67e1bebe), o.u(0xc8fda2fd, 0x6aa23535),
4201// o.u(0xc74fcc4f, 0xbcc8888), o.u(0x654b394b, 0x5c392e2e),
4202// o.u(0x6af957f9, 0x3d579393), o.u(0x580df20d, 0xaaf25555),
4203// o.u(0x619d829d, 0xe382fcfc), o.u(0xb3c947c9, 0xf4477a7a),
4204// o.u(0x27efacef, 0x8bacc8c8), o.u(0x8832e732, 0x6fe7baba),
4205// o.u(0x4f7d2b7d, 0x642b3232), o.u(0x42a495a4, 0xd795e6e6),
4206// o.u(0x3bfba0fb, 0x9ba0c0c0), o.u(0xaab398b3, 0x32981919),
4207// o.u(0xf668d168, 0x27d19e9e), o.u(0x22817f81, 0x5d7fa3a3),
4208// o.u(0xeeaa66aa, 0x88664444), o.u(0xd6827e82, 0xa87e5454),
4209// o.u(0xdde6abe6, 0x76ab3b3b), o.u(0x959e839e, 0x16830b0b),
4210// o.u(0xc945ca45, 0x3ca8c8c), o.u(0xbc7b297b, 0x9529c7c7),
4211// o.u(0x56ed36e, 0xd6d36b6b), o.u(0x6c443c44, 0x503c2828),
4212// o.u(0x2c8b798b, 0x5579a7a7), o.u(0x813de23d, 0x63e2bcbc),
4213// o.u(0x31271d27, 0x2c1d1616), o.u(0x379a769a, 0x4176adad),
4214// o.u(0x964d3b4d, 0xad3bdbdb), o.u(0x9efa56fa, 0xc8566464),
4215// o.u(0xa6d24ed2, 0xe84e7474), o.u(0x36221e22, 0x281e1414),
4216// o.u(0xe476db76, 0x3fdb9292), o.u(0x121e0a1e, 0x180a0c0c),
4217// o.u(0xfcb46cb4, 0x906c4848), o.u(0x8f37e437, 0x6be4b8b8),
4218// o.u(0x78e75de7, 0x255d9f9f), o.u(0xfb26eb2, 0x616ebdbd),
4219// o.u(0x692aef2a, 0x86ef4343), o.u(0x35f1a6f1, 0x93a6c4c4),
4220// o.u(0xdae3a8e3, 0x72a83939), o.u(0xc6f7a4f7, 0x62a43131),
4221// o.u(0x8a593759, 0xbd37d3d3), o.u(0x74868b86, 0xff8bf2f2),
4222// o.u(0x83563256, 0xb132d5d5), o.u(0x4ec543c5, 0xd438b8b),
4223// o.u(0x85eb59eb, 0xdc596e6e), o.u(0x18c2b7c2, 0xafb7dada),
4224// o.u(0x8e8f8c8f, 0x28c0101), o.u(0x1dac64ac, 0x7964b1b1),
4225// o.u(0xf16dd26d, 0x23d29c9c), o.u(0x723be03b, 0x92e04949),
4226// o.u(0x1fc7b4c7, 0xabb4d8d8), o.u(0xb915fa15, 0x43faacac),
4227// o.u(0xfa090709, 0xfd07f3f3), o.u(0xa06f256f, 0x8525cfcf),
4228// o.u(0x20eaafea, 0x8fafcaca), o.u(0x7d898e89, 0xf38ef4f4),
4229// o.u(0x6720e920, 0x8ee94747), o.u(0x38281828, 0x20181010),
4230// o.u(0xb64d564, 0xded56f6f), o.u(0x73838883, 0xfb88f0f0),
4231// o.u(0xfbb16fb1, 0x946f4a4a), o.u(0xca967296, 0xb8725c5c),
4232// o.u(0x546c246c, 0x70243838), o.u(0x5f08f108, 0xaef15757),
4233// o.u(0x2152c752, 0xe6c77373), o.u(0x64f351f3, 0x35519797),
4234// o.u(0xae652365, 0x8d23cbcb), o.u(0x25847c84, 0x597ca1a1),
4235// o.u(0x57bf9cbf, 0xcb9ce8e8), o.u(0x5d632163, 0x7c213e3e),
4236// o.u(0xea7cdd7c, 0x37dd9696), o.u(0x1e7fdc7f, 0xc2dc6161),
4237// o.u(0x9c918691, 0x1a860d0d), o.u(0x9b948594, 0x1e850f0f),
4238// o.u(0x4bab90ab, 0xdb90e0e0), o.u(0xbac642c6, 0xf8427c7c),
4239// o.u(0x2657c457, 0xe2c47171), o.u(0x29e5aae5, 0x83aacccc),
4240// o.u(0xe373d873, 0x3bd89090), o.u(0x90f050f, 0xc050606),
4241// o.u(0xf4030103, 0xf501f7f7), o.u(0x2a361236, 0x38121c1c),
4242// o.u(0x3cfea3fe, 0x9fa3c2c2), o.u(0x8be15fe1, 0xd45f6a6a),
4243// o.u(0xbe10f910, 0x47f9aeae), o.u(0x26bd06b, 0xd2d06969),
4244// o.u(0xbfa891a8, 0x2e911717), o.u(0x71e858e8, 0x29589999),
4245// o.u(0x53692769, 0x74273a3a), o.u(0xf7d0b9d0, 0x4eb92727),
4246// o.u(0x91483848, 0xa938d9d9), o.u(0xde351335, 0xcd13ebeb),
4247// o.u(0xe5ceb3ce, 0x56b32b2b), o.u(0x77553355, 0x44332222),
4248// o.u(0x4d6bbd6, 0xbfbbd2d2), o.u(0x39907090, 0x4970a9a9),
4249// o.u(0x87808980, 0xe890707), o.u(0xc1f2a7f2, 0x66a73333),
4250// o.u(0xecc1b6c1, 0x5ab62d2d), o.u(0x5a662266, 0x78223c3c),
4251// o.u(0xb8ad92ad, 0x2a921515), o.u(0xa9602060, 0x8920c9c9),
4252// o.u(0x5cdb49db, 0x15498787), o.u(0xb01aff1a, 0x4fffaaaa),
4253// o.u(0xd8887888, 0xa0785050), o.u(0x2b8e7a8e, 0x517aa5a5),
4254// o.u(0x898a8f8a, 0x68f0303), o.u(0x4a13f813, 0xb2f85959),
4255// o.u(0x929b809b, 0x12800909), o.u(0x23391739, 0x34171a1a),
4256// o.u(0x1075da75, 0xcada6565), o.u(0x84533153, 0xb531d7d7),
4257// o.u(0xd551c651, 0x13c68484), o.u(0x3d3b8d3, 0xbbb8d0d0),
4258// o.u(0xdc5ec35e, 0x1fc38282), o.u(0xe2cbb0cb, 0x52b02929),
4259// o.u(0xc3997799, 0xb4775a5a), o.u(0x2d331133, 0x3c111e1e),
4260// o.u(0x3d46cb46, 0xf6cb7b7b), o.u(0xb71ffc1f, 0x4bfca8a8),
4261// o.u(0xc61d661, 0xdad66d6d), o.u(0x624e3a4e, 0x583a2c2c)
4262// ];
4263
4264var B64 = function(n, x) {
4265 if (n === 7) {
4266 return x.lo & 0xFF;
4267 }
4268 var bits = (7 - n) * 8;
4269 if (bits >= 32) { //faster than >= 32
4270 return (x.hi >>> (bits - 32)) & 0xFF;
4271 }
4272 else {
4273 var bitsOff32 = 32 - bits,
4274 toMoveDown = this.hi << bitsOff32 >>> bitsOff32;
4275 return (x.lo >>> bits | (toMoveDown << bitsOff32)) & 0xFF;
4276 }
4277}
4278
4279var j64 = [o.u(0, 0), o.u(0, 0x10), o.u(0, 0x20), o.u(0, 0x30), o.u(0, 0x40), o.u(0, 0x50), o.u(0, 0x60),
4280 o.u(0, 0x70), o.u(0, 0x80), o.u(0, 0x90), o.u(0, 0xA0), o.u(0, 0xB0), o.u(0, 0xC0),
4281 o.u(0, 0xD0), o.u(0, 0xE0), o.u(0, 0xF0)
4282];
4283
4284var nj64 = [o.u(0xFFFFFFFF, 0xFFFFFFFF), o.u(0xFFFFFFFF, 0xFFFFFFEF), o.u(0xFFFFFFFF, 0xFFFFFFDF), o.u(0xFFFFFFFF, 0xFFFFFFCF), o.u(0xFFFFFFFF, 0xFFFFFFBF), o.u(0xFFFFFFFF, 0xFFFFFFAF), o.u(0xFFFFFFFF, 0xFFFFFF9F),
4285 o.u(0xFFFFFFFF, 0xFFFFFF8F), o.u(0xFFFFFFFF, 0xFFFFFF7F), o.u(0xFFFFFFFF, 0xFFFFFF6F), o.u(0xFFFFFFFF, 0xFFFFFF5F), o.u(0xFFFFFFFF, 0xFFFFFF4F), o.u(0xFFFFFFFF, 0xFFFFFF3F),
4286 o.u(0xFFFFFFFF, 0xFFFFFF2F), o.u(0xFFFFFFFF, 0xFFFFFF1F), o.u(0xFFFFFFFF, 0xFFFFFF0F)
4287];
4288
4289var r64 = [o.u(0, 0), o.u(0, 1), o.u(0, 2), o.u(0, 3), o.u(0, 4), o.u(0, 5), o.u(0, 6), o.u(0, 7),
4290 o.u(0, 8), o.u(0, 9), o.u(0, 10), o.u(0, 11), o.u(0, 12), o.u(0, 13)
4291];
4292
4293var compress = function(int64buf, state) {
4294 var g = new Array(16);
4295 var m = new Array(16);
4296 for (var u = 0; u < 16; u++) {
4297 m[u] = int64buf[u];
4298 g[u] = m[u].xor(state[u]);
4299 }
4300 var t = new Array(16);
4301 for (var r = 0; r < 14; r++) {
4302 for (var i = 0; i < 16; i++) {
4303 g[i].setxor64(j64[i].plus(r64[r]).setShiftLeft(56));
4304 }
4305
4306 for (var u = 0; u < 16; u++) {
4307 t[u] = o.xor64(T0[B64(0, g[u])], T1[B64(1, g[(u + 1) & 0xF])], T2[B64(2, g[(u + 2) & 0xF])], T3[B64(3, g[(u + 3) & 0xF])], T4[B64(4, g[(u + 4) & 0xF])], T5[B64(5, g[(u + 5) & 0xF])], T6[B64(6, g[(u + 6) & 0xF])], T7[B64(7, g[(u + 11) & 0xF])]);
4308 }
4309 var temp = g;
4310 g = t;
4311 t = temp;
4312 }
4313 for (var r = 0; r < 14; r++) {
4314 for (var i = 0; i < 16; i++) {
4315 m[i].setxor64(r64[r], nj64[i]);
4316 }
4317 for (var u = 0; u < 16; u++) {
4318 t[u] = o.xor64(T0[B64(0, m[(u + 1) & 0xF])], T1[B64(1, m[(u + 3) & 0xF])], T2[B64(2, m[(u + 5) & 0xF])], T3[B64(3, m[(u + 11) & 0xF])], T4[B64(4, m[(u + 0) & 0xF])], T5[B64(5, m[(u + 2) & 0xF])], T6[B64(6, m[(u + 4) & 0xF])], T7[B64(7, m[(u + 6) & 0xF])]);
4319 }
4320 var temp = m;
4321 m = t;
4322 t = temp;
4323 }
4324 for (var u = 0; u < 16; u++) {
4325 state[u].setxor64(g[u], m[u]);
4326 }
4327}
4328
4329var final = function(state) {
4330 var g = new Array(16);
4331 o.bufferInsert64(g, 0, state, 16);
4332 var t = new Array(16);
4333 for (var r = 0; r < 14; r++) {
4334
4335 for (var i = 0; i < 16; i++) {
4336 g[i].setxor64(j64[i].plus(r64[r]).setShiftLeft(56));
4337 }
4338
4339 for (var u = 0; u < 16; u++) {
4340 t[u] = o.xor64(T0[B64(0, g[u])], T1[B64(1, g[(u + 1) & 0xF])], T2[B64(2, g[(u + 2) & 0xF])], T3[B64(3, g[(u + 3) & 0xF])], T4[B64(4, g[(u + 4) & 0xF])], T5[B64(5, g[(u + 5) & 0xF])], T6[B64(6, g[(u + 6) & 0xF])], T7[B64(7, g[(u + 11) & 0xF])]);
4341 }
4342 var temp = g;
4343 g = t;
4344 t = temp;
4345 }
4346 for (var u = 0; u < 16; u++)
4347 state[u].setxor64(g[u]);
4348}
4349
4350var groestl = function(ctx, data, len) {
4351 var buf, ptr;
4352 //create a local copy of states
4353 var V = new Array(16);
4354 buf = ctx.buffer;
4355 ptr = ctx.ptr;
4356 if (len < ctx.buffer.length - ptr) {
4357 o.bufferInsert(buf, ptr, data, data.length);
4358 ptr += data.length;
4359 ctx.ptr = ptr;
4360 return;
4361 }
4362 //perform a deep copy of current state
4363 o.bufferInsert(V, 0, ctx.state, 16);
4364 while (len > 0) {
4365 var clen = ctx.buffer.length - ptr;
4366 if (clen > len) clen = len;
4367 o.bufferInsert(buf, ptr, data, clen);
4368 ptr += clen;
4369 data = data.slice(clen);
4370 len -= clen;
4371 if (ptr === ctx.buffer.length) {
4372 var int64Buf = h.bytes2Int64Buffer(buf);
4373 compress(int64Buf, V);
4374 ctx.count.addOne();
4375 ptr = 0;
4376 }
4377 }
4378 ctx.state = V;
4379 ctx.ptr = ptr;
4380}
4381
4382var groestlClose = function(ctx) {
4383 var buf = ctx.buffer;
4384 var ptr = ctx.ptr;
4385 var pad = new Array(136);
4386 var len = buf.length;
4387 var padLen;
4388 var count;
4389 pad[0] = 0x80;
4390 if (ptr < 120) {
4391 padLen = 128 - ptr;
4392 count = ctx.count.plus(o.u(0, 1));
4393 }
4394 else {
4395 padLen = 256 - ptr;
4396 count = ctx.count.plus(o.u(0, 2));
4397 }
4398 o.bufferSet(pad, 1, 0, padLen - 9);
4399 h.bufferEncode64(pad, padLen - 8, count);
4400 groestl(ctx, pad, padLen);
4401 final(ctx.state);
4402 var out = new Array(16);
4403 for (var u = 0, v = 8; u < 8; u++, v++) {
4404 out[2 * u] = ctx.state[v].hi;
4405 out[2 * u + 1] = ctx.state[v].lo;
4406 }
4407 return out;
4408}
4409
4410module.exports = function(input, format, output) {
4411 var msg;
4412 if (format === 1) {
4413 msg = input;
4414 }
4415 else if (format === 2) {
4416 msg = h.int32Buffer2Bytes(input);
4417 }
4418 else {
4419 msg = h.string2bytes(input);
4420 }
4421 var ctx = {};
4422 ctx.state = new Array(16);
4423 for (var i = 0; i < 15; i++) {
4424 ctx.state[i] = new o.u64(0, 0);
4425 }
4426 ctx.state[15] = new o.u64(0, 512);
4427 ctx.ptr = 0;
4428 ctx.count = new o.u64(0,0);
4429 ctx.buffer = new Array(128);
4430 groestl(ctx, msg, msg.length);
4431 var r = groestlClose(ctx, 0, 0);
4432 var out;
4433 if (output === 2) {
4434 out = r;
4435 }
4436 else if (output === 1) {
4437 out = h.int32Buffer2Bytes(r)
4438 }
4439 else {
4440 out = h.int32ArrayToHexString(r)
4441 }
4442 return out;
4443}
4444},{"./helper":29,"./op":30}],29:[function(require,module,exports){
4445'use strict';
4446// String functions
4447
4448var op = require('./op.js');
4449
4450module.exports.int8ArrayToHexString = function toString(array) {
4451 var string = '';
4452
4453 for (var i = 0; i < array.length; i++) {
4454 if (array[i] < 16) {
4455 string += '0' + array[i].toString(16);
4456 }
4457 else {
4458 string += array[i].toString(16);
4459 }
4460 }
4461 return string;
4462}
4463
4464module.exports.int32ArrayToHexString = function toString(array) {
4465 var string = '';
4466 var len = array.length;
4467 for (var i = 0; i < len; i++) {
4468 var s = array[i];
4469 if (s < 0) {
4470 s = 0xFFFFFFFF + array[i] + 1;
4471 }
4472 var l = s.toString(16);
4473 var padding = 8;
4474 while (l.length < padding) {
4475 l = "0" + l;
4476 }
4477 string += l;
4478 }
4479 return string;
4480}
4481
4482module.exports.hex2string = function toString(s) {
4483 for (var c = [], len = s.length, i = 0; i < len; i += 2)
4484 c.push(String.fromCharCode(parseInt(s.substring(i, i + 2), 16)));
4485 return c.join('');
4486}
4487
4488module.exports.hex2bytes = function toString(s) {
4489 for (var c = [], len = s.length, i = 0; i < len; i += 2)
4490 c.push(parseInt(s.substring(i, i + 2), 16));
4491 return c;
4492}
4493/*
4494module.exports.string2hex = function toString(s) {
4495
4496 for (var p = [], len = s.length, i = 0; i < len; i++) {
4497 p.push((256 + s.charCodeAt(i)).toString(16).substring(1));
4498 }
4499 return p.join('');
4500}
4501*/
4502module.exports.string2bytes = function(s) {
4503 var len = s.length;
4504 var b = new Array(len);
4505 var i = 0;
4506 while (i < len) {
4507 b[i] = s.charCodeAt(i);
4508 i++;
4509 }
4510 return b;
4511}
4512/*
4513module.exports.bytes2Int16Buffer = function(b) {
4514 var len = b.length;
4515 var bufferLength = len ? (((len - 1) >>> 1) + 1) : 0;
4516 var buffer = new Array(bufferLength);
4517 var i = 0;
4518 var j = 0;
4519 while (i < len) {
4520 buffer[j] = (buffer[j] << 8) | b[i];
4521 i++;
4522 if (!(i % 2)) j++;
4523 }
4524 return buffer;
4525}
4526*/
4527
4528module.exports.bytes2Int32Buffer = function(b) {
4529 if (!b) return [];
4530 var len = b.length ? (((b.length - 1) >>> 2) + 1) : 0;
4531 var buffer = new Array(len);
4532 var j = 0;
4533 while (j < len) {
4534 buffer[j] = (b[j * 4] << 24) | (b[j * 4 + 1] << 16) | (b[j * 4 + 2] << 8) | b[j * 4 + 3];
4535 j++;
4536 }
4537 return buffer;
4538}
4539/*
4540module.exports.bytes2Int32BufferLeAligned = function(b) {
4541 var len = b.length;
4542 if (!len) return [];
4543 var len2 = len ? (((len - 1) >>> 2) + 1) : 0;
4544 var buffer = new Array(len);
4545 var j = 0;
4546 while (j < len2) {
4547 buffer[j] = (b[j * 4 + 3] << 24) | (b[j * 4 + 2] << 16) | (b[j * 4 + 1] << 8) | b[j * 4];
4548 j++;
4549 };
4550 return buffer;
4551}
4552*/
4553module.exports.bytes2Int64Buffer = function(b) {
4554 if (!b) return [];
4555 var len = b.length ? (((b.length - 1) >>> 3) + 1) : 0;
4556 var buffer = new Array(len);
4557 var j = 0;
4558 while (j < len) {
4559 buffer[j] = new op.u64((b[j * 8] << 24) | (b[j * 8 + 1] << 16) | (b[j * 8 + 2] << 8) | b[j * 8 + 3], (b[j * 8 + 4] << 24) | (b[j * 8 + 5] << 16) | (b[j * 8 + 6] << 8) | b[j * 8 + 7]);
4560 j++;
4561 }
4562 return buffer;
4563}
4564
4565module.exports.bytes2Int64BufferLeAligned = function(b) {
4566 if (!b) return [];
4567 var len = b.length ? ((( b.length - 1) >>> 3) + 1) : 0;
4568 var buffer = new Array(len);
4569 var j = 0;
4570 while (j < len) {
4571 buffer[j] = new op.u64((b[j * 8 + 7] << 24) | (b[j * 8 + 6] << 16) | (b[j * 8 + 5] << 8) | b[j * 8 + 4], (b[j * 8 + 3] << 24) | (b[j * 8 + 2] << 16) | (b[j * 8 + 1] << 8) | b[j * 8]);
4572 j++;
4573 }
4574 return buffer;
4575}
4576
4577module.exports.bufferEncode64leAligned = function(buffer, offset, uint64) {
4578 buffer[offset + 7] = uint64.hi >>> 24;
4579 buffer[offset + 6] = uint64.hi >>> 16 & 0xFF;
4580 buffer[offset + 5] = uint64.hi >>> 8 & 0xFF;
4581 buffer[offset + 4] = uint64.hi & 0xFF;
4582 buffer[offset + 3] = uint64.lo >>> 24;
4583 buffer[offset + 2] = uint64.lo >>> 16 & 0xFF;
4584 buffer[offset + 1] = uint64.lo >>> 8 & 0xFF;
4585 buffer[offset + 0] = uint64.lo & 0xFF;
4586}
4587
4588module.exports.bufferEncode64 = function(buffer, offset, uint64) {
4589 buffer[offset] = uint64.hi >>> 24;
4590 buffer[offset + 1] = uint64.hi >>> 16 & 0xFF;
4591 buffer[offset + 2] = uint64.hi >>> 8 & 0xFF;
4592 buffer[offset + 3] = uint64.hi & 0xFF;
4593 buffer[offset + 4] = uint64.lo >>> 24;
4594 buffer[offset + 5] = uint64.lo >>> 16 & 0xFF;
4595 buffer[offset + 6] = uint64.lo >>> 8 & 0xFF;
4596 buffer[offset + 7] = uint64.lo & 0xFF;
4597}
4598
4599module.exports.int32Buffer2Bytes = function(b) {
4600 var buffer = new Array(b.length);
4601 var len = b.length;
4602 var i = 0;
4603 while (i < len) {
4604 buffer[i * 4] = (b[i] & 0xFF000000) >>> 24;
4605 buffer[i * 4 + 1] = (b[i] & 0x00FF0000) >>> 16;
4606 buffer[i * 4 + 2] = (b[i] & 0x0000FF00) >>> 8;
4607 buffer[i * 4 + 3] = (b[i] & 0x000000FF);
4608 i++;
4609 }
4610 return buffer;
4611}
4612/*
4613module.exports.int64Buffer2Bytes = function(b) {
4614 var buffer = new Array(b.length);
4615 var i = 0;
4616 while (i < b.length) {
4617 buffer[i * 8] = (b[i].hi & 0xFF000000) >>> 24;
4618 buffer[i * 8 + 1] = (b[i].hi & 0x00FF0000) >>> 16;
4619 buffer[i * 8 + 2] = (b[i].hi & 0x0000FF00) >>> 8;
4620 buffer[i * 8 + 3] = (b[i].hi & 0x000000FF);
4621 buffer[i * 8 + 4] = (b[i].lo & 0xFF000000) >>> 24;
4622 buffer[i * 8 + 5] = (b[i].lo & 0x00FF0000) >>> 16;
4623 buffer[i * 8 + 6] = (b[i].lo & 0x0000FF00) >>> 8;
4624 buffer[i * 8 + 7] = (b[i].lo & 0x000000FF);
4625 i++;
4626 }
4627 return buffer;
4628}
4629*/
4630
4631module.exports.string2Int32Buffer = function(s) {
4632 return this.bytes2Int32Buffer(this.string2bytes(s));
4633}
4634
4635var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
4636
4637module.exports.b64Encode = function(input) {
4638 var output = "";
4639 var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
4640 var i = 0;
4641
4642 while (i < input.length) {
4643
4644 chr1 = input[i++];
4645 chr2 = input[i++];
4646 chr3 = input[i++];
4647
4648 enc1 = chr1 >> 2;
4649 enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
4650 enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
4651 enc4 = chr3 & 63;
4652
4653 if (isNaN(chr2)) {
4654 enc3 = enc4 = 64;
4655 }
4656 else if (isNaN(chr3)) {
4657 enc4 = 64;
4658 }
4659
4660 output +=
4661 keyStr.charAt(enc1) + keyStr.charAt(enc2) +
4662 keyStr.charAt(enc3) + keyStr.charAt(enc4);
4663 }
4664
4665 return output;
4666};
4667
4668module.exports.b64Decode = function(input) {
4669 var output = [];
4670 var chr1, chr2, chr3;
4671 var enc1, enc2, enc3, enc4;
4672 var i = 0;
4673
4674 input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
4675
4676 while (i < input.length) {
4677
4678 enc1 = keyStr.indexOf(input.charAt(i++));
4679 enc2 = keyStr.indexOf(input.charAt(i++));
4680 enc3 = keyStr.indexOf(input.charAt(i++));
4681 enc4 = keyStr.indexOf(input.charAt(i++));
4682
4683 chr1 = (enc1 << 2) | (enc2 >> 4);
4684 chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
4685 chr3 = ((enc3 & 3) << 6) | enc4;
4686
4687 output.push(chr1);
4688
4689 if (enc3 != 64) {
4690 output.push(chr2);
4691 }
4692 if (enc4 != 64) {
4693 output.push(chr3);
4694 }
4695 }
4696 return output;
4697};
4698},{"./op.js":30}],30:[function(require,module,exports){
4699'use strict';
4700//the right shift is important, it has to do with 32 bit operations in javascript, it will make things faster
4701function u64(h, l) {
4702 this.hi = h >>> 0;
4703 this.lo = l >>> 0;
4704}
4705
4706u64.prototype.set = function(oWord) {
4707 this.lo = oWord.lo;
4708 this.hi = oWord.hi;
4709}
4710
4711u64.prototype.add = function(oWord) {
4712 var lowest, lowMid, highMid, highest; //four parts of the whole 64 bit number..
4713
4714 //need to add the respective parts from each number and the carry if on is present..
4715 lowest = (this.lo & 0XFFFF) + (oWord.lo & 0XFFFF);
4716 lowMid = (this.lo >>> 16) + (oWord.lo >>> 16) + (lowest >>> 16);
4717 highMid = (this.hi & 0XFFFF) + (oWord.hi & 0XFFFF) + (lowMid >>> 16);
4718 highest = (this.hi >>> 16) + (oWord.hi >>> 16) + (highMid >>> 16);
4719
4720 //now set the hgih and the low accordingly..
4721 this.lo = (lowMid << 16) | (lowest & 0XFFFF);
4722 this.hi = (highest << 16) | (highMid & 0XFFFF);
4723
4724 return this; //for chaining..
4725};
4726
4727u64.prototype.addOne = function() {
4728 if (this.lo === -1 || this.lo === 0xFFFFFFFF) {
4729 this.lo = 0;
4730 this.hi++;
4731 }
4732 else {
4733 this.lo++;
4734 }
4735}
4736
4737u64.prototype.plus = function(oWord) {
4738 var c = new u64(0, 0);
4739 var lowest, lowMid, highMid, highest; //four parts of the whole 64 bit number..
4740
4741 //need to add the respective parts from each number and the carry if on is present..
4742 lowest = (this.lo & 0XFFFF) + (oWord.lo & 0XFFFF);
4743 lowMid = (this.lo >>> 16) + (oWord.lo >>> 16) + (lowest >>> 16);
4744 highMid = (this.hi & 0XFFFF) + (oWord.hi & 0XFFFF) + (lowMid >>> 16);
4745 highest = (this.hi >>> 16) + (oWord.hi >>> 16) + (highMid >>> 16);
4746
4747 //now set the hgih and the low accordingly..
4748 c.lo = (lowMid << 16) | (lowest & 0XFFFF);
4749 c.hi = (highest << 16) | (highMid & 0XFFFF);
4750
4751 return c; //for chaining..
4752};
4753
4754u64.prototype.not = function() {
4755 return new u64(~this.hi, ~this.lo);
4756}
4757
4758u64.prototype.one = function() {
4759 return new u64(0x0, 0x1);
4760}
4761
4762u64.prototype.zero = function() {
4763 return new u64(0x0, 0x0);
4764}
4765
4766u64.prototype.neg = function() {
4767 return this.not().plus(this.one());
4768}
4769
4770u64.prototype.minus = function(oWord) {
4771 return this.plus(oWord.neg());
4772};
4773
4774u64.prototype.isZero = function() {
4775 return (this.lo === 0) && (this.hi === 0);
4776}
4777
4778function isLong(obj) {
4779 return (obj && obj["__isLong__"]) === true;
4780}
4781
4782function fromNumber(value) {
4783 if (isNaN(value) || !isFinite(value))
4784 return this.zero();
4785 var pow32 = (1 << 32);
4786 return new u64((value % pow32) | 0, (value / pow32) | 0);
4787}
4788
4789u64.prototype.multiply = function(multiplier) {
4790 if (this.isZero())
4791 return this.zero();
4792 if (!isLong(multiplier))
4793 multiplier = fromNumber(multiplier);
4794 if (multiplier.isZero())
4795 return this.zero();
4796
4797 // Divide each long into 4 chunks of 16 bits, and then add up 4x4 products.
4798 // We can skip products that would overflow.
4799
4800 var a48 = this.hi >>> 16;
4801 var a32 = this.hi & 0xFFFF;
4802 var a16 = this.lo >>> 16;
4803 var a00 = this.lo & 0xFFFF;
4804
4805 var b48 = multiplier.hi >>> 16;
4806 var b32 = multiplier.hi & 0xFFFF;
4807 var b16 = multiplier.lo >>> 16;
4808 var b00 = multiplier.lo & 0xFFFF;
4809
4810 var c48 = 0,
4811 c32 = 0,
4812 c16 = 0,
4813 c00 = 0;
4814 c00 += a00 * b00;
4815 c16 += c00 >>> 16;
4816 c00 &= 0xFFFF;
4817 c16 += a16 * b00;
4818 c32 += c16 >>> 16;
4819 c16 &= 0xFFFF;
4820 c16 += a00 * b16;
4821 c32 += c16 >>> 16;
4822 c16 &= 0xFFFF;
4823 c32 += a32 * b00;
4824 c48 += c32 >>> 16;
4825 c32 &= 0xFFFF;
4826 c32 += a16 * b16;
4827 c48 += c32 >>> 16;
4828 c32 &= 0xFFFF;
4829 c32 += a00 * b32;
4830 c48 += c32 >>> 16;
4831 c32 &= 0xFFFF;
4832 c48 += a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48;
4833 c48 &= 0xFFFF;
4834 return new u64((c48 << 16) | c32, (c16 << 16) | c00);
4835};
4836
4837u64.prototype.shiftLeft = function(bits) {
4838 bits = bits % 64;
4839 var c = new u64(0, 0);
4840 if (bits === 0) {
4841 return this.clone();
4842 }
4843 else if (bits > 31) {
4844 c.lo = 0;
4845 c.hi = this.lo << (bits - 32);
4846 }
4847 else {
4848 var toMoveUp = this.lo >>> 32 - bits;
4849 c.lo = this.lo << bits;
4850 c.hi = (this.hi << bits) | toMoveUp;
4851 }
4852 return c; //for chaining..
4853};
4854
4855u64.prototype.setShiftLeft = function(bits) {
4856 if (bits === 0) {
4857 return this;
4858 }
4859 if (bits > 63) {
4860 bits = bits % 64;
4861 }
4862
4863 if (bits > 31) {
4864 this.hi = this.lo << (bits - 32);
4865 this.lo = 0;
4866 }
4867 else {
4868 var toMoveUp = this.lo >>> 32 - bits;
4869 this.lo <<= bits;
4870 this.hi = (this.hi << bits) | toMoveUp;
4871 }
4872 return this; //for chaining..
4873};
4874//Shifts this word by the given number of bits to the right (max 32)..
4875u64.prototype.shiftRight = function(bits) {
4876 bits = bits % 64;
4877 var c = new u64(0, 0);
4878 if (bits === 0) {
4879 return this.clone();
4880 }
4881 else if (bits >= 32) {
4882 c.hi = 0;
4883 c.lo = this.hi >>> (bits - 32);
4884 }
4885 else {
4886 var bitsOff32 = 32 - bits,
4887 toMoveDown = this.hi << bitsOff32 >>> bitsOff32;
4888 c.hi = this.hi >>> bits;
4889 c.lo = this.lo >>> bits | (toMoveDown << bitsOff32);
4890 }
4891 return c; //for chaining..
4892};
4893//Rotates the bits of this word round to the left (max 32)..
4894u64.prototype.rotateLeft = function(bits) {
4895 if (bits > 32) {
4896 return this.rotateRight(64 - bits);
4897 }
4898 var c = new u64(0, 0);
4899 if (bits === 0) {
4900 c.lo = this.lo >>> 0;
4901 c.hi = this.hi >>> 0;
4902 }
4903 else if (bits === 32) { //just switch high and low over in this case..
4904 c.lo = this.hi;
4905 c.hi = this.lo;
4906 }
4907 else {
4908 c.lo = (this.lo << bits) | (this.hi >>> (32 - bits));
4909 c.hi = (this.hi << bits) | (this.lo >>> (32 - bits));
4910 }
4911 return c; //for chaining..
4912};
4913
4914u64.prototype.setRotateLeft = function(bits) {
4915 if (bits > 32) {
4916 return this.setRotateRight(64 - bits);
4917 }
4918 var newHigh;
4919 if (bits === 0) {
4920 return this;
4921 }
4922 else if (bits === 32) { //just switch high and low over in this case..
4923 newHigh = this.lo;
4924 this.lo = this.hi;
4925 this.hi = newHigh;
4926 }
4927 else {
4928 newHigh = (this.hi << bits) | (this.lo >>> (32 - bits));
4929 this.lo = (this.lo << bits) | (this.hi >>> (32 - bits));
4930 this.hi = newHigh;
4931 }
4932 return this; //for chaining..
4933};
4934//Rotates the bits of this word round to the right (max 32)..
4935u64.prototype.rotateRight = function(bits) {
4936 if (bits > 32) {
4937 return this.rotateLeft(64 - bits);
4938 }
4939 var c = new u64(0, 0);
4940 if (bits === 0) {
4941 c.lo = this.lo >>> 0;
4942 c.hi = this.hi >>> 0;
4943 }
4944 else if (bits === 32) { //just switch high and low over in this case..
4945 c.lo = this.hi;
4946 c.hi = this.lo;
4947 }
4948 else {
4949 c.lo = (this.hi << (32 - bits)) | (this.lo >>> bits);
4950 c.hi = (this.lo << (32 - bits)) | (this.hi >>> bits);
4951 }
4952 return c; //for chaining..
4953};
4954u64.prototype.setFlip = function() {
4955 var newHigh;
4956 newHigh = this.lo;
4957 this.lo = this.hi;
4958 this.hi = newHigh;
4959 return this;
4960};
4961//Rotates the bits of this word round to the right (max 32)..
4962u64.prototype.setRotateRight = function(bits) {
4963 if (bits > 32) {
4964 return this.setRotateLeft(64 - bits);
4965 }
4966
4967 if (bits === 0) {
4968 return this;
4969 }
4970 else if (bits === 32) { //just switch high and low over in this case..
4971 var newHigh;
4972 newHigh = this.lo;
4973 this.lo = this.hi;
4974 this.hi = newHigh;
4975 }
4976 else {
4977 newHigh = (this.lo << (32 - bits)) | (this.hi >>> bits);
4978 this.lo = (this.hi << (32 - bits)) | (this.lo >>> bits);
4979 this.hi = newHigh;
4980 }
4981 return this; //for chaining..
4982};
4983//Xors this word with the given other..
4984u64.prototype.xor = function(oWord) {
4985 var c = new u64(0, 0);
4986 c.hi = this.hi ^ oWord.hi;
4987 c.lo = this.lo ^ oWord.lo;
4988 return c; //for chaining..
4989};
4990//Xors this word with the given other..
4991u64.prototype.setxorOne = function(oWord) {
4992 this.hi ^= oWord.hi;
4993 this.lo ^= oWord.lo;
4994 return this; //for chaining..
4995};
4996//Ands this word with the given other..
4997u64.prototype.and = function(oWord) {
4998 var c = new u64(0, 0);
4999 c.hi = this.hi & oWord.hi;
5000 c.lo = this.lo & oWord.lo;
5001 return c; //for chaining..
5002};
5003
5004//Creates a deep copy of this Word..
5005u64.prototype.clone = function() {
5006 return new u64(this.hi, this.lo);
5007};
5008
5009u64.prototype.setxor64 = function() {
5010 var a = arguments;
5011 var i = a.length;
5012 while (i--) {
5013 this.hi ^= a[i].hi;
5014 this.lo ^= a[i].lo;
5015 }
5016 return this;
5017}
5018
5019module.exports.u64 = u64;
5020
5021module.exports.u = function(h, l) {
5022 return new u64(h, l);
5023}
5024/*
5025module.exports.add64 = function(a, b) {
5026 var lowest, lowMid, highMid, highest; //four parts of the whole 64 bit number..
5027
5028 //need to add the respective parts from each number and the carry if on is present..
5029 lowest = (a.lo & 0XFFFF) + (b.lo & 0XFFFF);
5030 lowMid = (a.lo >>> 16) + (b.lo >>> 16) + (lowest >>> 16);
5031 highMid = (a.hi & 0XFFFF) + (b.hi & 0XFFFF) + (lowMid >>> 16);
5032 highest = (a.hi >>> 16) + (b.hi >>> 16) + (highMid >>> 16);
5033
5034 var r = new this.u64((highest << 16) | (highMid & 0XFFFF), (lowMid << 16) | (lowest & 0XFFFF));
5035
5036 return r;
5037};
5038*/
5039module.exports.xor64 = function() {
5040 var a = arguments,
5041 h = a[0].hi,
5042 l = a[0].lo;
5043 var i = a.length-1;
5044 do {
5045 h ^= a[i].hi;
5046 l ^= a[i].lo;
5047 i--;
5048 } while (i>0);
5049 return new this.u64(h, l);
5050}
5051
5052module.exports.clone64Array = function(array) {
5053 var i = 0;
5054 var len = array.length;
5055 var a = new Array(len);
5056 while(i<len) {
5057 a[i] = array[i];
5058 i++;
5059 }
5060 return a;
5061}
5062
5063//this shouldn't be a problem, but who knows in the future javascript might support 64bits
5064module.exports.t32 = function(x) {
5065 return (x & 0xFFFFFFFF)
5066}
5067
5068module.exports.rotl32 = function(x, c) {
5069 return (((x) << (c)) | ((x) >>> (32 - (c)))) & (0xFFFFFFFF);
5070}
5071
5072module.exports.rotr32 = function(x, c) {
5073 return this.rotl32(x, (32 - (c)));
5074}
5075
5076module.exports.swap32 = function(val) {
5077 return ((val & 0xFF) << 24) |
5078 ((val & 0xFF00) << 8) |
5079 ((val >>> 8) & 0xFF00) |
5080 ((val >>> 24) & 0xFF);
5081}
5082
5083module.exports.swap32Array = function(a) {
5084 //can't do this with map because of support for IE8 (Don't hate me plz).
5085 var i = 0, len = a.length;
5086 var r = new Array(i);
5087 while (i<len) {
5088 r[i] = (this.swap32(a[i]));
5089 i++;
5090 }
5091 return r;
5092}
5093
5094module.exports.xnd64 = function(x, y, z) {
5095 return new this.u64(x.hi ^ ((~y.hi) & z.hi), x.lo ^ ((~y.lo) & z.lo));
5096}
5097/*
5098module.exports.load64 = function(x, i) {
5099 var l = x[i] | (x[i + 1] << 8) | (x[i + 2] << 16) | (x[i + 3] << 24);
5100 var h = x[i + 4] | (x[i + 5] << 8) | (x[i + 6] << 16) | (x[i + 7] << 24);
5101 return new this.u64(h, l);
5102}
5103*/
5104module.exports.bufferInsert = function(buffer, bufferOffset, data, len, dataOffset) {
5105 dataOffset = dataOffset | 0;
5106 var i = 0;
5107 while (i < len) {
5108 buffer[i + bufferOffset] = data[i + dataOffset];
5109 i++;
5110 }
5111}
5112
5113module.exports.bufferInsert64 = function(buffer, bufferOffset, data, len) {
5114 var i = 0;
5115 while (i < len) {
5116 buffer[i + bufferOffset] = data[i].clone();
5117 i++;
5118 }
5119}
5120/*
5121module.exports.buffer2Insert = function(buffer, bufferOffset, bufferOffset2, data, len, len2) {
5122 while (len--) {
5123 var j = len2;
5124 while (j--) {
5125 buffer[len + bufferOffset][j + bufferOffset2] = data[len][j];
5126 }
5127 }
5128}
5129*/
5130module.exports.bufferInsertBackwards = function(buffer, bufferOffset, data, len) {
5131 var i = 0;
5132 while (i < len) {
5133 buffer[i + bufferOffset] = data[len - 1 - i];
5134 i++;
5135 }
5136}
5137
5138module.exports.bufferSet = function(buffer, bufferOffset, value, len) {
5139 var i = 0;
5140 while (i < len) {
5141 buffer[i + bufferOffset] = value;
5142 i++;
5143 }
5144}
5145
5146module.exports.bufferXORInsert = function(buffer, bufferOffset, data, dataOffset, len) {
5147 var i = 0;
5148 while (i < len) {
5149 buffer[i + bufferOffset] ^= data[i + dataOffset];
5150 i++;
5151 }
5152}
5153
5154module.exports.xORTable = function(d, s1, s2, len) {
5155 var i = 0;
5156 while (i < len) {
5157 d[i] = s1[i] ^ s2[i];
5158 i++
5159 }
5160}
5161
5162},{}],31:[function(require,module,exports){
5163'use strict'
5164var Buffer = require('safe-buffer').Buffer
5165var Transform = require('stream').Transform
5166var inherits = require('inherits')
5167
5168function throwIfNotStringOrBuffer (val, prefix) {
5169 if (!Buffer.isBuffer(val) && typeof val !== 'string') {
5170 throw new TypeError(prefix + ' must be a string or a buffer')
5171 }
5172}
5173
5174function HashBase (blockSize) {
5175 Transform.call(this)
5176
5177 this._block = Buffer.allocUnsafe(blockSize)
5178 this._blockSize = blockSize
5179 this._blockOffset = 0
5180 this._length = [0, 0, 0, 0]
5181
5182 this._finalized = false
5183}
5184
5185inherits(HashBase, Transform)
5186
5187HashBase.prototype._transform = function (chunk, encoding, callback) {
5188 var error = null
5189 try {
5190 this.update(chunk, encoding)
5191 } catch (err) {
5192 error = err
5193 }
5194
5195 callback(error)
5196}
5197
5198HashBase.prototype._flush = function (callback) {
5199 var error = null
5200 try {
5201 this.push(this.digest())
5202 } catch (err) {
5203 error = err
5204 }
5205
5206 callback(error)
5207}
5208
5209HashBase.prototype.update = function (data, encoding) {
5210 throwIfNotStringOrBuffer(data, 'Data')
5211 if (this._finalized) throw new Error('Digest already called')
5212 if (!Buffer.isBuffer(data)) data = Buffer.from(data, encoding)
5213
5214 // consume data
5215 var block = this._block
5216 var offset = 0
5217 while (this._blockOffset + data.length - offset >= this._blockSize) {
5218 for (var i = this._blockOffset; i < this._blockSize;) block[i++] = data[offset++]
5219 this._update()
5220 this._blockOffset = 0
5221 }
5222 while (offset < data.length) block[this._blockOffset++] = data[offset++]
5223
5224 // update length
5225 for (var j = 0, carry = data.length * 8; carry > 0; ++j) {
5226 this._length[j] += carry
5227 carry = (this._length[j] / 0x0100000000) | 0
5228 if (carry > 0) this._length[j] -= 0x0100000000 * carry
5229 }
5230
5231 return this
5232}
5233
5234HashBase.prototype._update = function () {
5235 throw new Error('_update is not implemented')
5236}
5237
5238HashBase.prototype.digest = function (encoding) {
5239 if (this._finalized) throw new Error('Digest already called')
5240 this._finalized = true
5241
5242 var digest = this._digest()
5243 if (encoding !== undefined) digest = digest.toString(encoding)
5244
5245 // reset state
5246 this._block.fill(0)
5247 this._blockOffset = 0
5248 for (var i = 0; i < 4; ++i) this._length[i] = 0
5249
5250 return digest
5251}
5252
5253HashBase.prototype._digest = function () {
5254 throw new Error('_digest is not implemented')
5255}
5256
5257module.exports = HashBase
5258
5259},{"inherits":32,"safe-buffer":38,"stream":122}],32:[function(require,module,exports){
5260if (typeof Object.create === 'function') {
5261 // implementation from standard node.js 'util' module
5262 module.exports = function inherits(ctor, superCtor) {
5263 if (superCtor) {
5264 ctor.super_ = superCtor
5265 ctor.prototype = Object.create(superCtor.prototype, {
5266 constructor: {
5267 value: ctor,
5268 enumerable: false,
5269 writable: true,
5270 configurable: true
5271 }
5272 })
5273 }
5274 };
5275} else {
5276 // old school shim for old browsers
5277 module.exports = function inherits(ctor, superCtor) {
5278 if (superCtor) {
5279 ctor.super_ = superCtor
5280 var TempCtor = function () {}
5281 TempCtor.prototype = superCtor.prototype
5282 ctor.prototype = new TempCtor()
5283 ctor.prototype.constructor = ctor
5284 }
5285 }
5286}
5287
5288},{}],33:[function(require,module,exports){
5289'use strict'
5290var inherits = require('inherits')
5291var HashBase = require('hash-base')
5292var Buffer = require('safe-buffer').Buffer
5293
5294var ARRAY16 = new Array(16)
5295
5296function MD5 () {
5297 HashBase.call(this, 64)
5298
5299 // state
5300 this._a = 0x67452301
5301 this._b = 0xefcdab89
5302 this._c = 0x98badcfe
5303 this._d = 0x10325476
5304}
5305
5306inherits(MD5, HashBase)
5307
5308MD5.prototype._update = function () {
5309 var M = ARRAY16
5310 for (var i = 0; i < 16; ++i) M[i] = this._block.readInt32LE(i * 4)
5311
5312 var a = this._a
5313 var b = this._b
5314 var c = this._c
5315 var d = this._d
5316
5317 a = fnF(a, b, c, d, M[0], 0xd76aa478, 7)
5318 d = fnF(d, a, b, c, M[1], 0xe8c7b756, 12)
5319 c = fnF(c, d, a, b, M[2], 0x242070db, 17)
5320 b = fnF(b, c, d, a, M[3], 0xc1bdceee, 22)
5321 a = fnF(a, b, c, d, M[4], 0xf57c0faf, 7)
5322 d = fnF(d, a, b, c, M[5], 0x4787c62a, 12)
5323 c = fnF(c, d, a, b, M[6], 0xa8304613, 17)
5324 b = fnF(b, c, d, a, M[7], 0xfd469501, 22)
5325 a = fnF(a, b, c, d, M[8], 0x698098d8, 7)
5326 d = fnF(d, a, b, c, M[9], 0x8b44f7af, 12)
5327 c = fnF(c, d, a, b, M[10], 0xffff5bb1, 17)
5328 b = fnF(b, c, d, a, M[11], 0x895cd7be, 22)
5329 a = fnF(a, b, c, d, M[12], 0x6b901122, 7)
5330 d = fnF(d, a, b, c, M[13], 0xfd987193, 12)
5331 c = fnF(c, d, a, b, M[14], 0xa679438e, 17)
5332 b = fnF(b, c, d, a, M[15], 0x49b40821, 22)
5333
5334 a = fnG(a, b, c, d, M[1], 0xf61e2562, 5)
5335 d = fnG(d, a, b, c, M[6], 0xc040b340, 9)
5336 c = fnG(c, d, a, b, M[11], 0x265e5a51, 14)
5337 b = fnG(b, c, d, a, M[0], 0xe9b6c7aa, 20)
5338 a = fnG(a, b, c, d, M[5], 0xd62f105d, 5)
5339 d = fnG(d, a, b, c, M[10], 0x02441453, 9)
5340 c = fnG(c, d, a, b, M[15], 0xd8a1e681, 14)
5341 b = fnG(b, c, d, a, M[4], 0xe7d3fbc8, 20)
5342 a = fnG(a, b, c, d, M[9], 0x21e1cde6, 5)
5343 d = fnG(d, a, b, c, M[14], 0xc33707d6, 9)
5344 c = fnG(c, d, a, b, M[3], 0xf4d50d87, 14)
5345 b = fnG(b, c, d, a, M[8], 0x455a14ed, 20)
5346 a = fnG(a, b, c, d, M[13], 0xa9e3e905, 5)
5347 d = fnG(d, a, b, c, M[2], 0xfcefa3f8, 9)
5348 c = fnG(c, d, a, b, M[7], 0x676f02d9, 14)
5349 b = fnG(b, c, d, a, M[12], 0x8d2a4c8a, 20)
5350
5351 a = fnH(a, b, c, d, M[5], 0xfffa3942, 4)
5352 d = fnH(d, a, b, c, M[8], 0x8771f681, 11)
5353 c = fnH(c, d, a, b, M[11], 0x6d9d6122, 16)
5354 b = fnH(b, c, d, a, M[14], 0xfde5380c, 23)
5355 a = fnH(a, b, c, d, M[1], 0xa4beea44, 4)
5356 d = fnH(d, a, b, c, M[4], 0x4bdecfa9, 11)
5357 c = fnH(c, d, a, b, M[7], 0xf6bb4b60, 16)
5358 b = fnH(b, c, d, a, M[10], 0xbebfbc70, 23)
5359 a = fnH(a, b, c, d, M[13], 0x289b7ec6, 4)
5360 d = fnH(d, a, b, c, M[0], 0xeaa127fa, 11)
5361 c = fnH(c, d, a, b, M[3], 0xd4ef3085, 16)
5362 b = fnH(b, c, d, a, M[6], 0x04881d05, 23)
5363 a = fnH(a, b, c, d, M[9], 0xd9d4d039, 4)
5364 d = fnH(d, a, b, c, M[12], 0xe6db99e5, 11)
5365 c = fnH(c, d, a, b, M[15], 0x1fa27cf8, 16)
5366 b = fnH(b, c, d, a, M[2], 0xc4ac5665, 23)
5367
5368 a = fnI(a, b, c, d, M[0], 0xf4292244, 6)
5369 d = fnI(d, a, b, c, M[7], 0x432aff97, 10)
5370 c = fnI(c, d, a, b, M[14], 0xab9423a7, 15)
5371 b = fnI(b, c, d, a, M[5], 0xfc93a039, 21)
5372 a = fnI(a, b, c, d, M[12], 0x655b59c3, 6)
5373 d = fnI(d, a, b, c, M[3], 0x8f0ccc92, 10)
5374 c = fnI(c, d, a, b, M[10], 0xffeff47d, 15)
5375 b = fnI(b, c, d, a, M[1], 0x85845dd1, 21)
5376 a = fnI(a, b, c, d, M[8], 0x6fa87e4f, 6)
5377 d = fnI(d, a, b, c, M[15], 0xfe2ce6e0, 10)
5378 c = fnI(c, d, a, b, M[6], 0xa3014314, 15)
5379 b = fnI(b, c, d, a, M[13], 0x4e0811a1, 21)
5380 a = fnI(a, b, c, d, M[4], 0xf7537e82, 6)
5381 d = fnI(d, a, b, c, M[11], 0xbd3af235, 10)
5382 c = fnI(c, d, a, b, M[2], 0x2ad7d2bb, 15)
5383 b = fnI(b, c, d, a, M[9], 0xeb86d391, 21)
5384
5385 this._a = (this._a + a) | 0
5386 this._b = (this._b + b) | 0
5387 this._c = (this._c + c) | 0
5388 this._d = (this._d + d) | 0
5389}
5390
5391MD5.prototype._digest = function () {
5392 // create padding and handle blocks
5393 this._block[this._blockOffset++] = 0x80
5394 if (this._blockOffset > 56) {
5395 this._block.fill(0, this._blockOffset, 64)
5396 this._update()
5397 this._blockOffset = 0
5398 }
5399
5400 this._block.fill(0, this._blockOffset, 56)
5401 this._block.writeUInt32LE(this._length[0], 56)
5402 this._block.writeUInt32LE(this._length[1], 60)
5403 this._update()
5404
5405 // produce result
5406 var buffer = Buffer.allocUnsafe(16)
5407 buffer.writeInt32LE(this._a, 0)
5408 buffer.writeInt32LE(this._b, 4)
5409 buffer.writeInt32LE(this._c, 8)
5410 buffer.writeInt32LE(this._d, 12)
5411 return buffer
5412}
5413
5414function rotl (x, n) {
5415 return (x << n) | (x >>> (32 - n))
5416}
5417
5418function fnF (a, b, c, d, m, k, s) {
5419 return (rotl((a + ((b & c) | ((~b) & d)) + m + k) | 0, s) + b) | 0
5420}
5421
5422function fnG (a, b, c, d, m, k, s) {
5423 return (rotl((a + ((b & d) | (c & (~d))) + m + k) | 0, s) + b) | 0
5424}
5425
5426function fnH (a, b, c, d, m, k, s) {
5427 return (rotl((a + (b ^ c ^ d) + m + k) | 0, s) + b) | 0
5428}
5429
5430function fnI (a, b, c, d, m, k, s) {
5431 return (rotl((a + ((c ^ (b | (~d)))) + m + k) | 0, s) + b) | 0
5432}
5433
5434module.exports = MD5
5435
5436},{"hash-base":31,"inherits":32,"safe-buffer":38}],34:[function(require,module,exports){
5437(function (Buffer){
5438// constant-space merkle root calculation algorithm
5439module.exports = function fastRoot (values, digestFn) {
5440 if (!Array.isArray(values)) throw TypeError('Expected values Array')
5441 if (typeof digestFn !== 'function') throw TypeError('Expected digest Function')
5442
5443 var length = values.length
5444 var results = values.concat()
5445
5446 while (length > 1) {
5447 var j = 0
5448
5449 for (var i = 0; i < length; i += 2, ++j) {
5450 var left = results[i]
5451 var right = i + 1 === length ? left : results[i + 1]
5452 var data = Buffer.concat([left, right])
5453
5454 results[j] = digestFn(data)
5455 }
5456
5457 length = j
5458 }
5459
5460 return results[0]
5461}
5462
5463}).call(this,require("buffer").Buffer)
5464},{"buffer":96}],35:[function(require,module,exports){
5465var OPS = require('bitcoin-ops')
5466
5467function encodingLength (i) {
5468 return i < OPS.OP_PUSHDATA1 ? 1
5469 : i <= 0xff ? 2
5470 : i <= 0xffff ? 3
5471 : 5
5472}
5473
5474function encode (buffer, number, offset) {
5475 var size = encodingLength(number)
5476
5477 // ~6 bit
5478 if (size === 1) {
5479 buffer.writeUInt8(number, offset)
5480
5481 // 8 bit
5482 } else if (size === 2) {
5483 buffer.writeUInt8(OPS.OP_PUSHDATA1, offset)
5484 buffer.writeUInt8(number, offset + 1)
5485
5486 // 16 bit
5487 } else if (size === 3) {
5488 buffer.writeUInt8(OPS.OP_PUSHDATA2, offset)
5489 buffer.writeUInt16LE(number, offset + 1)
5490
5491 // 32 bit
5492 } else {
5493 buffer.writeUInt8(OPS.OP_PUSHDATA4, offset)
5494 buffer.writeUInt32LE(number, offset + 1)
5495 }
5496
5497 return size
5498}
5499
5500function decode (buffer, offset) {
5501 var opcode = buffer.readUInt8(offset)
5502 var number, size
5503
5504 // ~6 bit
5505 if (opcode < OPS.OP_PUSHDATA1) {
5506 number = opcode
5507 size = 1
5508
5509 // 8 bit
5510 } else if (opcode === OPS.OP_PUSHDATA1) {
5511 if (offset + 2 > buffer.length) return null
5512 number = buffer.readUInt8(offset + 1)
5513 size = 2
5514
5515 // 16 bit
5516 } else if (opcode === OPS.OP_PUSHDATA2) {
5517 if (offset + 3 > buffer.length) return null
5518 number = buffer.readUInt16LE(offset + 1)
5519 size = 3
5520
5521 // 32 bit
5522 } else {
5523 if (offset + 5 > buffer.length) return null
5524 if (opcode !== OPS.OP_PUSHDATA4) throw new Error('Unexpected opcode')
5525
5526 number = buffer.readUInt32LE(offset + 1)
5527 size = 5
5528 }
5529
5530 return {
5531 opcode: opcode,
5532 number: number,
5533 size: size
5534 }
5535}
5536
5537module.exports = {
5538 encodingLength: encodingLength,
5539 encode: encode,
5540 decode: decode
5541}
5542
5543},{"bitcoin-ops":8}],36:[function(require,module,exports){
5544(function (process,global){
5545'use strict'
5546
5547// limit of Crypto.getRandomValues()
5548// https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues
5549var MAX_BYTES = 65536
5550
5551// Node supports requesting up to this number of bytes
5552// https://github.com/nodejs/node/blob/master/lib/internal/crypto/random.js#L48
5553var MAX_UINT32 = 4294967295
5554
5555function oldBrowser () {
5556 throw new Error('Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11')
5557}
5558
5559var Buffer = require('safe-buffer').Buffer
5560var crypto = global.crypto || global.msCrypto
5561
5562if (crypto && crypto.getRandomValues) {
5563 module.exports = randomBytes
5564} else {
5565 module.exports = oldBrowser
5566}
5567
5568function randomBytes (size, cb) {
5569 // phantomjs needs to throw
5570 if (size > MAX_UINT32) throw new RangeError('requested too many random bytes')
5571
5572 var bytes = Buffer.allocUnsafe(size)
5573
5574 if (size > 0) { // getRandomValues fails on IE if size == 0
5575 if (size > MAX_BYTES) { // this is the max bytes crypto.getRandomValues
5576 // can do at once see https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues
5577 for (var generated = 0; generated < size; generated += MAX_BYTES) {
5578 // buffer.slice automatically checks if the end is past the end of
5579 // the buffer so we don't have to here
5580 crypto.getRandomValues(bytes.slice(generated, generated + MAX_BYTES))
5581 }
5582 } else {
5583 crypto.getRandomValues(bytes)
5584 }
5585 }
5586
5587 if (typeof cb === 'function') {
5588 return process.nextTick(function () {
5589 cb(null, bytes)
5590 })
5591 }
5592
5593 return bytes
5594}
5595
5596}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
5597},{"_process":105,"safe-buffer":38}],37:[function(require,module,exports){
5598'use strict'
5599var Buffer = require('buffer').Buffer
5600var inherits = require('inherits')
5601var HashBase = require('hash-base')
5602
5603var ARRAY16 = new Array(16)
5604
5605var zl = [
5606 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
5607 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
5608 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
5609 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
5610 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
5611]
5612
5613var zr = [
5614 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
5615 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
5616 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
5617 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
5618 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
5619]
5620
5621var sl = [
5622 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
5623 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
5624 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
5625 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
5626 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
5627]
5628
5629var sr = [
5630 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
5631 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
5632 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
5633 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
5634 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
5635]
5636
5637var hl = [0x00000000, 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xa953fd4e]
5638var hr = [0x50a28be6, 0x5c4dd124, 0x6d703ef3, 0x7a6d76e9, 0x00000000]
5639
5640function RIPEMD160 () {
5641 HashBase.call(this, 64)
5642
5643 // state
5644 this._a = 0x67452301
5645 this._b = 0xefcdab89
5646 this._c = 0x98badcfe
5647 this._d = 0x10325476
5648 this._e = 0xc3d2e1f0
5649}
5650
5651inherits(RIPEMD160, HashBase)
5652
5653RIPEMD160.prototype._update = function () {
5654 var words = ARRAY16
5655 for (var j = 0; j < 16; ++j) words[j] = this._block.readInt32LE(j * 4)
5656
5657 var al = this._a | 0
5658 var bl = this._b | 0
5659 var cl = this._c | 0
5660 var dl = this._d | 0
5661 var el = this._e | 0
5662
5663 var ar = this._a | 0
5664 var br = this._b | 0
5665 var cr = this._c | 0
5666 var dr = this._d | 0
5667 var er = this._e | 0
5668
5669 // computation
5670 for (var i = 0; i < 80; i += 1) {
5671 var tl
5672 var tr
5673 if (i < 16) {
5674 tl = fn1(al, bl, cl, dl, el, words[zl[i]], hl[0], sl[i])
5675 tr = fn5(ar, br, cr, dr, er, words[zr[i]], hr[0], sr[i])
5676 } else if (i < 32) {
5677 tl = fn2(al, bl, cl, dl, el, words[zl[i]], hl[1], sl[i])
5678 tr = fn4(ar, br, cr, dr, er, words[zr[i]], hr[1], sr[i])
5679 } else if (i < 48) {
5680 tl = fn3(al, bl, cl, dl, el, words[zl[i]], hl[2], sl[i])
5681 tr = fn3(ar, br, cr, dr, er, words[zr[i]], hr[2], sr[i])
5682 } else if (i < 64) {
5683 tl = fn4(al, bl, cl, dl, el, words[zl[i]], hl[3], sl[i])
5684 tr = fn2(ar, br, cr, dr, er, words[zr[i]], hr[3], sr[i])
5685 } else { // if (i<80) {
5686 tl = fn5(al, bl, cl, dl, el, words[zl[i]], hl[4], sl[i])
5687 tr = fn1(ar, br, cr, dr, er, words[zr[i]], hr[4], sr[i])
5688 }
5689
5690 al = el
5691 el = dl
5692 dl = rotl(cl, 10)
5693 cl = bl
5694 bl = tl
5695
5696 ar = er
5697 er = dr
5698 dr = rotl(cr, 10)
5699 cr = br
5700 br = tr
5701 }
5702
5703 // update state
5704 var t = (this._b + cl + dr) | 0
5705 this._b = (this._c + dl + er) | 0
5706 this._c = (this._d + el + ar) | 0
5707 this._d = (this._e + al + br) | 0
5708 this._e = (this._a + bl + cr) | 0
5709 this._a = t
5710}
5711
5712RIPEMD160.prototype._digest = function () {
5713 // create padding and handle blocks
5714 this._block[this._blockOffset++] = 0x80
5715 if (this._blockOffset > 56) {
5716 this._block.fill(0, this._blockOffset, 64)
5717 this._update()
5718 this._blockOffset = 0
5719 }
5720
5721 this._block.fill(0, this._blockOffset, 56)
5722 this._block.writeUInt32LE(this._length[0], 56)
5723 this._block.writeUInt32LE(this._length[1], 60)
5724 this._update()
5725
5726 // produce result
5727 var buffer = Buffer.alloc ? Buffer.alloc(20) : new Buffer(20)
5728 buffer.writeInt32LE(this._a, 0)
5729 buffer.writeInt32LE(this._b, 4)
5730 buffer.writeInt32LE(this._c, 8)
5731 buffer.writeInt32LE(this._d, 12)
5732 buffer.writeInt32LE(this._e, 16)
5733 return buffer
5734}
5735
5736function rotl (x, n) {
5737 return (x << n) | (x >>> (32 - n))
5738}
5739
5740function fn1 (a, b, c, d, e, m, k, s) {
5741 return (rotl((a + (b ^ c ^ d) + m + k) | 0, s) + e) | 0
5742}
5743
5744function fn2 (a, b, c, d, e, m, k, s) {
5745 return (rotl((a + ((b & c) | ((~b) & d)) + m + k) | 0, s) + e) | 0
5746}
5747
5748function fn3 (a, b, c, d, e, m, k, s) {
5749 return (rotl((a + ((b | (~c)) ^ d) + m + k) | 0, s) + e) | 0
5750}
5751
5752function fn4 (a, b, c, d, e, m, k, s) {
5753 return (rotl((a + ((b & d) | (c & (~d))) + m + k) | 0, s) + e) | 0
5754}
5755
5756function fn5 (a, b, c, d, e, m, k, s) {
5757 return (rotl((a + (b ^ (c | (~d))) + m + k) | 0, s) + e) | 0
5758}
5759
5760module.exports = RIPEMD160
5761
5762},{"buffer":96,"hash-base":31,"inherits":32}],38:[function(require,module,exports){
5763/* eslint-disable node/no-deprecated-api */
5764var buffer = require('buffer')
5765var Buffer = buffer.Buffer
5766
5767// alternative to using Object.keys for old browsers
5768function copyProps (src, dst) {
5769 for (var key in src) {
5770 dst[key] = src[key]
5771 }
5772}
5773if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
5774 module.exports = buffer
5775} else {
5776 // Copy properties from require('buffer')
5777 copyProps(buffer, exports)
5778 exports.Buffer = SafeBuffer
5779}
5780
5781function SafeBuffer (arg, encodingOrOffset, length) {
5782 return Buffer(arg, encodingOrOffset, length)
5783}
5784
5785SafeBuffer.prototype = Object.create(Buffer.prototype)
5786
5787// Copy static methods from Buffer
5788copyProps(Buffer, SafeBuffer)
5789
5790SafeBuffer.from = function (arg, encodingOrOffset, length) {
5791 if (typeof arg === 'number') {
5792 throw new TypeError('Argument must not be a number')
5793 }
5794 return Buffer(arg, encodingOrOffset, length)
5795}
5796
5797SafeBuffer.alloc = function (size, fill, encoding) {
5798 if (typeof size !== 'number') {
5799 throw new TypeError('Argument must be a number')
5800 }
5801 var buf = Buffer(size)
5802 if (fill !== undefined) {
5803 if (typeof encoding === 'string') {
5804 buf.fill(fill, encoding)
5805 } else {
5806 buf.fill(fill)
5807 }
5808 } else {
5809 buf.fill(0)
5810 }
5811 return buf
5812}
5813
5814SafeBuffer.allocUnsafe = function (size) {
5815 if (typeof size !== 'number') {
5816 throw new TypeError('Argument must be a number')
5817 }
5818 return Buffer(size)
5819}
5820
5821SafeBuffer.allocUnsafeSlow = function (size) {
5822 if (typeof size !== 'number') {
5823 throw new TypeError('Argument must be a number')
5824 }
5825 return buffer.SlowBuffer(size)
5826}
5827
5828},{"buffer":96}],39:[function(require,module,exports){
5829var Buffer = require('safe-buffer').Buffer
5830
5831// prototype class for hash functions
5832function Hash (blockSize, finalSize) {
5833 this._block = Buffer.alloc(blockSize)
5834 this._finalSize = finalSize
5835 this._blockSize = blockSize
5836 this._len = 0
5837}
5838
5839Hash.prototype.update = function (data, enc) {
5840 if (typeof data === 'string') {
5841 enc = enc || 'utf8'
5842 data = Buffer.from(data, enc)
5843 }
5844
5845 var block = this._block
5846 var blockSize = this._blockSize
5847 var length = data.length
5848 var accum = this._len
5849
5850 for (var offset = 0; offset < length;) {
5851 var assigned = accum % blockSize
5852 var remainder = Math.min(length - offset, blockSize - assigned)
5853
5854 for (var i = 0; i < remainder; i++) {
5855 block[assigned + i] = data[offset + i]
5856 }
5857
5858 accum += remainder
5859 offset += remainder
5860
5861 if ((accum % blockSize) === 0) {
5862 this._update(block)
5863 }
5864 }
5865
5866 this._len += length
5867 return this
5868}
5869
5870Hash.prototype.digest = function (enc) {
5871 var rem = this._len % this._blockSize
5872
5873 this._block[rem] = 0x80
5874
5875 // zero (rem + 1) trailing bits, where (rem + 1) is the smallest
5876 // non-negative solution to the equation (length + 1 + (rem + 1)) === finalSize mod blockSize
5877 this._block.fill(0, rem + 1)
5878
5879 if (rem >= this._finalSize) {
5880 this._update(this._block)
5881 this._block.fill(0)
5882 }
5883
5884 var bits = this._len * 8
5885
5886 // uint32
5887 if (bits <= 0xffffffff) {
5888 this._block.writeUInt32BE(bits, this._blockSize - 4)
5889
5890 // uint64
5891 } else {
5892 var lowBits = (bits & 0xffffffff) >>> 0
5893 var highBits = (bits - lowBits) / 0x100000000
5894
5895 this._block.writeUInt32BE(highBits, this._blockSize - 8)
5896 this._block.writeUInt32BE(lowBits, this._blockSize - 4)
5897 }
5898
5899 this._update(this._block)
5900 var hash = this._hash()
5901
5902 return enc ? hash.toString(enc) : hash
5903}
5904
5905Hash.prototype._update = function () {
5906 throw new Error('_update must be implemented by subclass')
5907}
5908
5909module.exports = Hash
5910
5911},{"safe-buffer":38}],40:[function(require,module,exports){
5912var exports = module.exports = function SHA (algorithm) {
5913 algorithm = algorithm.toLowerCase()
5914
5915 var Algorithm = exports[algorithm]
5916 if (!Algorithm) throw new Error(algorithm + ' is not supported (we accept pull requests)')
5917
5918 return new Algorithm()
5919}
5920
5921exports.sha = require('./sha')
5922exports.sha1 = require('./sha1')
5923exports.sha224 = require('./sha224')
5924exports.sha256 = require('./sha256')
5925exports.sha384 = require('./sha384')
5926exports.sha512 = require('./sha512')
5927
5928},{"./sha":41,"./sha1":42,"./sha224":43,"./sha256":44,"./sha384":45,"./sha512":46}],41:[function(require,module,exports){
5929/*
5930 * A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined
5931 * in FIPS PUB 180-1
5932 * This source code is derived from sha1.js of the same repository.
5933 * The difference between SHA-0 and SHA-1 is just a bitwise rotate left
5934 * operation was added.
5935 */
5936
5937var inherits = require('inherits')
5938var Hash = require('./hash')
5939var Buffer = require('safe-buffer').Buffer
5940
5941var K = [
5942 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
5943]
5944
5945var W = new Array(80)
5946
5947function Sha () {
5948 this.init()
5949 this._w = W
5950
5951 Hash.call(this, 64, 56)
5952}
5953
5954inherits(Sha, Hash)
5955
5956Sha.prototype.init = function () {
5957 this._a = 0x67452301
5958 this._b = 0xefcdab89
5959 this._c = 0x98badcfe
5960 this._d = 0x10325476
5961 this._e = 0xc3d2e1f0
5962
5963 return this
5964}
5965
5966function rotl5 (num) {
5967 return (num << 5) | (num >>> 27)
5968}
5969
5970function rotl30 (num) {
5971 return (num << 30) | (num >>> 2)
5972}
5973
5974function ft (s, b, c, d) {
5975 if (s === 0) return (b & c) | ((~b) & d)
5976 if (s === 2) return (b & c) | (b & d) | (c & d)
5977 return b ^ c ^ d
5978}
5979
5980Sha.prototype._update = function (M) {
5981 var W = this._w
5982
5983 var a = this._a | 0
5984 var b = this._b | 0
5985 var c = this._c | 0
5986 var d = this._d | 0
5987 var e = this._e | 0
5988
5989 for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
5990 for (; i < 80; ++i) W[i] = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]
5991
5992 for (var j = 0; j < 80; ++j) {
5993 var s = ~~(j / 20)
5994 var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0
5995
5996 e = d
5997 d = c
5998 c = rotl30(b)
5999 b = a
6000 a = t
6001 }
6002
6003 this._a = (a + this._a) | 0
6004 this._b = (b + this._b) | 0
6005 this._c = (c + this._c) | 0
6006 this._d = (d + this._d) | 0
6007 this._e = (e + this._e) | 0
6008}
6009
6010Sha.prototype._hash = function () {
6011 var H = Buffer.allocUnsafe(20)
6012
6013 H.writeInt32BE(this._a | 0, 0)
6014 H.writeInt32BE(this._b | 0, 4)
6015 H.writeInt32BE(this._c | 0, 8)
6016 H.writeInt32BE(this._d | 0, 12)
6017 H.writeInt32BE(this._e | 0, 16)
6018
6019 return H
6020}
6021
6022module.exports = Sha
6023
6024},{"./hash":39,"inherits":32,"safe-buffer":38}],42:[function(require,module,exports){
6025/*
6026 * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
6027 * in FIPS PUB 180-1
6028 * Version 2.1a Copyright Paul Johnston 2000 - 2002.
6029 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
6030 * Distributed under the BSD License
6031 * See http://pajhome.org.uk/crypt/md5 for details.
6032 */
6033
6034var inherits = require('inherits')
6035var Hash = require('./hash')
6036var Buffer = require('safe-buffer').Buffer
6037
6038var K = [
6039 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
6040]
6041
6042var W = new Array(80)
6043
6044function Sha1 () {
6045 this.init()
6046 this._w = W
6047
6048 Hash.call(this, 64, 56)
6049}
6050
6051inherits(Sha1, Hash)
6052
6053Sha1.prototype.init = function () {
6054 this._a = 0x67452301
6055 this._b = 0xefcdab89
6056 this._c = 0x98badcfe
6057 this._d = 0x10325476
6058 this._e = 0xc3d2e1f0
6059
6060 return this
6061}
6062
6063function rotl1 (num) {
6064 return (num << 1) | (num >>> 31)
6065}
6066
6067function rotl5 (num) {
6068 return (num << 5) | (num >>> 27)
6069}
6070
6071function rotl30 (num) {
6072 return (num << 30) | (num >>> 2)
6073}
6074
6075function ft (s, b, c, d) {
6076 if (s === 0) return (b & c) | ((~b) & d)
6077 if (s === 2) return (b & c) | (b & d) | (c & d)
6078 return b ^ c ^ d
6079}
6080
6081Sha1.prototype._update = function (M) {
6082 var W = this._w
6083
6084 var a = this._a | 0
6085 var b = this._b | 0
6086 var c = this._c | 0
6087 var d = this._d | 0
6088 var e = this._e | 0
6089
6090 for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
6091 for (; i < 80; ++i) W[i] = rotl1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16])
6092
6093 for (var j = 0; j < 80; ++j) {
6094 var s = ~~(j / 20)
6095 var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0
6096
6097 e = d
6098 d = c
6099 c = rotl30(b)
6100 b = a
6101 a = t
6102 }
6103
6104 this._a = (a + this._a) | 0
6105 this._b = (b + this._b) | 0
6106 this._c = (c + this._c) | 0
6107 this._d = (d + this._d) | 0
6108 this._e = (e + this._e) | 0
6109}
6110
6111Sha1.prototype._hash = function () {
6112 var H = Buffer.allocUnsafe(20)
6113
6114 H.writeInt32BE(this._a | 0, 0)
6115 H.writeInt32BE(this._b | 0, 4)
6116 H.writeInt32BE(this._c | 0, 8)
6117 H.writeInt32BE(this._d | 0, 12)
6118 H.writeInt32BE(this._e | 0, 16)
6119
6120 return H
6121}
6122
6123module.exports = Sha1
6124
6125},{"./hash":39,"inherits":32,"safe-buffer":38}],43:[function(require,module,exports){
6126/**
6127 * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
6128 * in FIPS 180-2
6129 * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
6130 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
6131 *
6132 */
6133
6134var inherits = require('inherits')
6135var Sha256 = require('./sha256')
6136var Hash = require('./hash')
6137var Buffer = require('safe-buffer').Buffer
6138
6139var W = new Array(64)
6140
6141function Sha224 () {
6142 this.init()
6143
6144 this._w = W // new Array(64)
6145
6146 Hash.call(this, 64, 56)
6147}
6148
6149inherits(Sha224, Sha256)
6150
6151Sha224.prototype.init = function () {
6152 this._a = 0xc1059ed8
6153 this._b = 0x367cd507
6154 this._c = 0x3070dd17
6155 this._d = 0xf70e5939
6156 this._e = 0xffc00b31
6157 this._f = 0x68581511
6158 this._g = 0x64f98fa7
6159 this._h = 0xbefa4fa4
6160
6161 return this
6162}
6163
6164Sha224.prototype._hash = function () {
6165 var H = Buffer.allocUnsafe(28)
6166
6167 H.writeInt32BE(this._a, 0)
6168 H.writeInt32BE(this._b, 4)
6169 H.writeInt32BE(this._c, 8)
6170 H.writeInt32BE(this._d, 12)
6171 H.writeInt32BE(this._e, 16)
6172 H.writeInt32BE(this._f, 20)
6173 H.writeInt32BE(this._g, 24)
6174
6175 return H
6176}
6177
6178module.exports = Sha224
6179
6180},{"./hash":39,"./sha256":44,"inherits":32,"safe-buffer":38}],44:[function(require,module,exports){
6181/**
6182 * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
6183 * in FIPS 180-2
6184 * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
6185 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
6186 *
6187 */
6188
6189var inherits = require('inherits')
6190var Hash = require('./hash')
6191var Buffer = require('safe-buffer').Buffer
6192
6193var K = [
6194 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,
6195 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,
6196 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,
6197 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174,
6198 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC,
6199 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,
6200 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7,
6201 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967,
6202 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,
6203 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85,
6204 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3,
6205 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,
6206 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5,
6207 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3,
6208 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,
6209 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2
6210]
6211
6212var W = new Array(64)
6213
6214function Sha256 () {
6215 this.init()
6216
6217 this._w = W // new Array(64)
6218
6219 Hash.call(this, 64, 56)
6220}
6221
6222inherits(Sha256, Hash)
6223
6224Sha256.prototype.init = function () {
6225 this._a = 0x6a09e667
6226 this._b = 0xbb67ae85
6227 this._c = 0x3c6ef372
6228 this._d = 0xa54ff53a
6229 this._e = 0x510e527f
6230 this._f = 0x9b05688c
6231 this._g = 0x1f83d9ab
6232 this._h = 0x5be0cd19
6233
6234 return this
6235}
6236
6237function ch (x, y, z) {
6238 return z ^ (x & (y ^ z))
6239}
6240
6241function maj (x, y, z) {
6242 return (x & y) | (z & (x | y))
6243}
6244
6245function sigma0 (x) {
6246 return (x >>> 2 | x << 30) ^ (x >>> 13 | x << 19) ^ (x >>> 22 | x << 10)
6247}
6248
6249function sigma1 (x) {
6250 return (x >>> 6 | x << 26) ^ (x >>> 11 | x << 21) ^ (x >>> 25 | x << 7)
6251}
6252
6253function gamma0 (x) {
6254 return (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ (x >>> 3)
6255}
6256
6257function gamma1 (x) {
6258 return (x >>> 17 | x << 15) ^ (x >>> 19 | x << 13) ^ (x >>> 10)
6259}
6260
6261Sha256.prototype._update = function (M) {
6262 var W = this._w
6263
6264 var a = this._a | 0
6265 var b = this._b | 0
6266 var c = this._c | 0
6267 var d = this._d | 0
6268 var e = this._e | 0
6269 var f = this._f | 0
6270 var g = this._g | 0
6271 var h = this._h | 0
6272
6273 for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
6274 for (; i < 64; ++i) W[i] = (gamma1(W[i - 2]) + W[i - 7] + gamma0(W[i - 15]) + W[i - 16]) | 0
6275
6276 for (var j = 0; j < 64; ++j) {
6277 var T1 = (h + sigma1(e) + ch(e, f, g) + K[j] + W[j]) | 0
6278 var T2 = (sigma0(a) + maj(a, b, c)) | 0
6279
6280 h = g
6281 g = f
6282 f = e
6283 e = (d + T1) | 0
6284 d = c
6285 c = b
6286 b = a
6287 a = (T1 + T2) | 0
6288 }
6289
6290 this._a = (a + this._a) | 0
6291 this._b = (b + this._b) | 0
6292 this._c = (c + this._c) | 0
6293 this._d = (d + this._d) | 0
6294 this._e = (e + this._e) | 0
6295 this._f = (f + this._f) | 0
6296 this._g = (g + this._g) | 0
6297 this._h = (h + this._h) | 0
6298}
6299
6300Sha256.prototype._hash = function () {
6301 var H = Buffer.allocUnsafe(32)
6302
6303 H.writeInt32BE(this._a, 0)
6304 H.writeInt32BE(this._b, 4)
6305 H.writeInt32BE(this._c, 8)
6306 H.writeInt32BE(this._d, 12)
6307 H.writeInt32BE(this._e, 16)
6308 H.writeInt32BE(this._f, 20)
6309 H.writeInt32BE(this._g, 24)
6310 H.writeInt32BE(this._h, 28)
6311
6312 return H
6313}
6314
6315module.exports = Sha256
6316
6317},{"./hash":39,"inherits":32,"safe-buffer":38}],45:[function(require,module,exports){
6318var inherits = require('inherits')
6319var SHA512 = require('./sha512')
6320var Hash = require('./hash')
6321var Buffer = require('safe-buffer').Buffer
6322
6323var W = new Array(160)
6324
6325function Sha384 () {
6326 this.init()
6327 this._w = W
6328
6329 Hash.call(this, 128, 112)
6330}
6331
6332inherits(Sha384, SHA512)
6333
6334Sha384.prototype.init = function () {
6335 this._ah = 0xcbbb9d5d
6336 this._bh = 0x629a292a
6337 this._ch = 0x9159015a
6338 this._dh = 0x152fecd8
6339 this._eh = 0x67332667
6340 this._fh = 0x8eb44a87
6341 this._gh = 0xdb0c2e0d
6342 this._hh = 0x47b5481d
6343
6344 this._al = 0xc1059ed8
6345 this._bl = 0x367cd507
6346 this._cl = 0x3070dd17
6347 this._dl = 0xf70e5939
6348 this._el = 0xffc00b31
6349 this._fl = 0x68581511
6350 this._gl = 0x64f98fa7
6351 this._hl = 0xbefa4fa4
6352
6353 return this
6354}
6355
6356Sha384.prototype._hash = function () {
6357 var H = Buffer.allocUnsafe(48)
6358
6359 function writeInt64BE (h, l, offset) {
6360 H.writeInt32BE(h, offset)
6361 H.writeInt32BE(l, offset + 4)
6362 }
6363
6364 writeInt64BE(this._ah, this._al, 0)
6365 writeInt64BE(this._bh, this._bl, 8)
6366 writeInt64BE(this._ch, this._cl, 16)
6367 writeInt64BE(this._dh, this._dl, 24)
6368 writeInt64BE(this._eh, this._el, 32)
6369 writeInt64BE(this._fh, this._fl, 40)
6370
6371 return H
6372}
6373
6374module.exports = Sha384
6375
6376},{"./hash":39,"./sha512":46,"inherits":32,"safe-buffer":38}],46:[function(require,module,exports){
6377var inherits = require('inherits')
6378var Hash = require('./hash')
6379var Buffer = require('safe-buffer').Buffer
6380
6381var K = [
6382 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
6383 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
6384 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
6385 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
6386 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
6387 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
6388 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
6389 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
6390 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
6391 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
6392 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
6393 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
6394 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
6395 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
6396 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
6397 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
6398 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
6399 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
6400 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
6401 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
6402 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
6403 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
6404 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
6405 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
6406 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
6407 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
6408 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
6409 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
6410 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
6411 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
6412 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
6413 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
6414 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
6415 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
6416 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
6417 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
6418 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
6419 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
6420 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
6421 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
6422]
6423
6424var W = new Array(160)
6425
6426function Sha512 () {
6427 this.init()
6428 this._w = W
6429
6430 Hash.call(this, 128, 112)
6431}
6432
6433inherits(Sha512, Hash)
6434
6435Sha512.prototype.init = function () {
6436 this._ah = 0x6a09e667
6437 this._bh = 0xbb67ae85
6438 this._ch = 0x3c6ef372
6439 this._dh = 0xa54ff53a
6440 this._eh = 0x510e527f
6441 this._fh = 0x9b05688c
6442 this._gh = 0x1f83d9ab
6443 this._hh = 0x5be0cd19
6444
6445 this._al = 0xf3bcc908
6446 this._bl = 0x84caa73b
6447 this._cl = 0xfe94f82b
6448 this._dl = 0x5f1d36f1
6449 this._el = 0xade682d1
6450 this._fl = 0x2b3e6c1f
6451 this._gl = 0xfb41bd6b
6452 this._hl = 0x137e2179
6453
6454 return this
6455}
6456
6457function Ch (x, y, z) {
6458 return z ^ (x & (y ^ z))
6459}
6460
6461function maj (x, y, z) {
6462 return (x & y) | (z & (x | y))
6463}
6464
6465function sigma0 (x, xl) {
6466 return (x >>> 28 | xl << 4) ^ (xl >>> 2 | x << 30) ^ (xl >>> 7 | x << 25)
6467}
6468
6469function sigma1 (x, xl) {
6470 return (x >>> 14 | xl << 18) ^ (x >>> 18 | xl << 14) ^ (xl >>> 9 | x << 23)
6471}
6472
6473function Gamma0 (x, xl) {
6474 return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7)
6475}
6476
6477function Gamma0l (x, xl) {
6478 return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7 | xl << 25)
6479}
6480
6481function Gamma1 (x, xl) {
6482 return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6)
6483}
6484
6485function Gamma1l (x, xl) {
6486 return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6 | xl << 26)
6487}
6488
6489function getCarry (a, b) {
6490 return (a >>> 0) < (b >>> 0) ? 1 : 0
6491}
6492
6493Sha512.prototype._update = function (M) {
6494 var W = this._w
6495
6496 var ah = this._ah | 0
6497 var bh = this._bh | 0
6498 var ch = this._ch | 0
6499 var dh = this._dh | 0
6500 var eh = this._eh | 0
6501 var fh = this._fh | 0
6502 var gh = this._gh | 0
6503 var hh = this._hh | 0
6504
6505 var al = this._al | 0
6506 var bl = this._bl | 0
6507 var cl = this._cl | 0
6508 var dl = this._dl | 0
6509 var el = this._el | 0
6510 var fl = this._fl | 0
6511 var gl = this._gl | 0
6512 var hl = this._hl | 0
6513
6514 for (var i = 0; i < 32; i += 2) {
6515 W[i] = M.readInt32BE(i * 4)
6516 W[i + 1] = M.readInt32BE(i * 4 + 4)
6517 }
6518 for (; i < 160; i += 2) {
6519 var xh = W[i - 15 * 2]
6520 var xl = W[i - 15 * 2 + 1]
6521 var gamma0 = Gamma0(xh, xl)
6522 var gamma0l = Gamma0l(xl, xh)
6523
6524 xh = W[i - 2 * 2]
6525 xl = W[i - 2 * 2 + 1]
6526 var gamma1 = Gamma1(xh, xl)
6527 var gamma1l = Gamma1l(xl, xh)
6528
6529 // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
6530 var Wi7h = W[i - 7 * 2]
6531 var Wi7l = W[i - 7 * 2 + 1]
6532
6533 var Wi16h = W[i - 16 * 2]
6534 var Wi16l = W[i - 16 * 2 + 1]
6535
6536 var Wil = (gamma0l + Wi7l) | 0
6537 var Wih = (gamma0 + Wi7h + getCarry(Wil, gamma0l)) | 0
6538 Wil = (Wil + gamma1l) | 0
6539 Wih = (Wih + gamma1 + getCarry(Wil, gamma1l)) | 0
6540 Wil = (Wil + Wi16l) | 0
6541 Wih = (Wih + Wi16h + getCarry(Wil, Wi16l)) | 0
6542
6543 W[i] = Wih
6544 W[i + 1] = Wil
6545 }
6546
6547 for (var j = 0; j < 160; j += 2) {
6548 Wih = W[j]
6549 Wil = W[j + 1]
6550
6551 var majh = maj(ah, bh, ch)
6552 var majl = maj(al, bl, cl)
6553
6554 var sigma0h = sigma0(ah, al)
6555 var sigma0l = sigma0(al, ah)
6556 var sigma1h = sigma1(eh, el)
6557 var sigma1l = sigma1(el, eh)
6558
6559 // t1 = h + sigma1 + ch + K[j] + W[j]
6560 var Kih = K[j]
6561 var Kil = K[j + 1]
6562
6563 var chh = Ch(eh, fh, gh)
6564 var chl = Ch(el, fl, gl)
6565
6566 var t1l = (hl + sigma1l) | 0
6567 var t1h = (hh + sigma1h + getCarry(t1l, hl)) | 0
6568 t1l = (t1l + chl) | 0
6569 t1h = (t1h + chh + getCarry(t1l, chl)) | 0
6570 t1l = (t1l + Kil) | 0
6571 t1h = (t1h + Kih + getCarry(t1l, Kil)) | 0
6572 t1l = (t1l + Wil) | 0
6573 t1h = (t1h + Wih + getCarry(t1l, Wil)) | 0
6574
6575 // t2 = sigma0 + maj
6576 var t2l = (sigma0l + majl) | 0
6577 var t2h = (sigma0h + majh + getCarry(t2l, sigma0l)) | 0
6578
6579 hh = gh
6580 hl = gl
6581 gh = fh
6582 gl = fl
6583 fh = eh
6584 fl = el
6585 el = (dl + t1l) | 0
6586 eh = (dh + t1h + getCarry(el, dl)) | 0
6587 dh = ch
6588 dl = cl
6589 ch = bh
6590 cl = bl
6591 bh = ah
6592 bl = al
6593 al = (t1l + t2l) | 0
6594 ah = (t1h + t2h + getCarry(al, t1l)) | 0
6595 }
6596
6597 this._al = (this._al + al) | 0
6598 this._bl = (this._bl + bl) | 0
6599 this._cl = (this._cl + cl) | 0
6600 this._dl = (this._dl + dl) | 0
6601 this._el = (this._el + el) | 0
6602 this._fl = (this._fl + fl) | 0
6603 this._gl = (this._gl + gl) | 0
6604 this._hl = (this._hl + hl) | 0
6605
6606 this._ah = (this._ah + ah + getCarry(this._al, al)) | 0
6607 this._bh = (this._bh + bh + getCarry(this._bl, bl)) | 0
6608 this._ch = (this._ch + ch + getCarry(this._cl, cl)) | 0
6609 this._dh = (this._dh + dh + getCarry(this._dl, dl)) | 0
6610 this._eh = (this._eh + eh + getCarry(this._el, el)) | 0
6611 this._fh = (this._fh + fh + getCarry(this._fl, fl)) | 0
6612 this._gh = (this._gh + gh + getCarry(this._gl, gl)) | 0
6613 this._hh = (this._hh + hh + getCarry(this._hl, hl)) | 0
6614}
6615
6616Sha512.prototype._hash = function () {
6617 var H = Buffer.allocUnsafe(64)
6618
6619 function writeInt64BE (h, l, offset) {
6620 H.writeInt32BE(h, offset)
6621 H.writeInt32BE(l, offset + 4)
6622 }
6623
6624 writeInt64BE(this._ah, this._al, 0)
6625 writeInt64BE(this._bh, this._bl, 8)
6626 writeInt64BE(this._ch, this._cl, 16)
6627 writeInt64BE(this._dh, this._dl, 24)
6628 writeInt64BE(this._eh, this._el, 32)
6629 writeInt64BE(this._fh, this._fl, 40)
6630 writeInt64BE(this._gh, this._gl, 48)
6631 writeInt64BE(this._hh, this._hl, 56)
6632
6633 return H
6634}
6635
6636module.exports = Sha512
6637
6638},{"./hash":39,"inherits":32,"safe-buffer":38}],47:[function(require,module,exports){
6639var native = require('./native')
6640
6641function getTypeName (fn) {
6642 return fn.name || fn.toString().match(/function (.*?)\s*\(/)[1]
6643}
6644
6645function getValueTypeName (value) {
6646 return native.Nil(value) ? '' : getTypeName(value.constructor)
6647}
6648
6649function getValue (value) {
6650 if (native.Function(value)) return ''
6651 if (native.String(value)) return JSON.stringify(value)
6652 if (value && native.Object(value)) return ''
6653 return value
6654}
6655
6656function captureStackTrace (e, t) {
6657 if (Error.captureStackTrace) {
6658 Error.captureStackTrace(e, t)
6659 }
6660}
6661
6662function tfJSON (type) {
6663 if (native.Function(type)) return type.toJSON ? type.toJSON() : getTypeName(type)
6664 if (native.Array(type)) return 'Array'
6665 if (type && native.Object(type)) return 'Object'
6666
6667 return type !== undefined ? type : ''
6668}
6669
6670function tfErrorString (type, value, valueTypeName) {
6671 var valueJson = getValue(value)
6672
6673 return 'Expected ' + tfJSON(type) + ', got' +
6674 (valueTypeName !== '' ? ' ' + valueTypeName : '') +
6675 (valueJson !== '' ? ' ' + valueJson : '')
6676}
6677
6678function TfTypeError (type, value, valueTypeName) {
6679 valueTypeName = valueTypeName || getValueTypeName(value)
6680 this.message = tfErrorString(type, value, valueTypeName)
6681
6682 captureStackTrace(this, TfTypeError)
6683 this.__type = type
6684 this.__value = value
6685 this.__valueTypeName = valueTypeName
6686}
6687
6688TfTypeError.prototype = Object.create(Error.prototype)
6689TfTypeError.prototype.constructor = TfTypeError
6690
6691function tfPropertyErrorString (type, label, name, value, valueTypeName) {
6692 var description = '" of type '
6693 if (label === 'key') description = '" with key type '
6694
6695 return tfErrorString('property "' + tfJSON(name) + description + tfJSON(type), value, valueTypeName)
6696}
6697
6698function TfPropertyTypeError (type, property, label, value, valueTypeName) {
6699 if (type) {
6700 valueTypeName = valueTypeName || getValueTypeName(value)
6701 this.message = tfPropertyErrorString(type, label, property, value, valueTypeName)
6702 } else {
6703 this.message = 'Unexpected property "' + property + '"'
6704 }
6705
6706 captureStackTrace(this, TfTypeError)
6707 this.__label = label
6708 this.__property = property
6709 this.__type = type
6710 this.__value = value
6711 this.__valueTypeName = valueTypeName
6712}
6713
6714TfPropertyTypeError.prototype = Object.create(Error.prototype)
6715TfPropertyTypeError.prototype.constructor = TfTypeError
6716
6717function tfCustomError (expected, actual) {
6718 return new TfTypeError(expected, {}, actual)
6719}
6720
6721function tfSubError (e, property, label) {
6722 // sub child?
6723 if (e instanceof TfPropertyTypeError) {
6724 property = property + '.' + e.__property
6725
6726 e = new TfPropertyTypeError(
6727 e.__type, property, e.__label, e.__value, e.__valueTypeName
6728 )
6729
6730 // child?
6731 } else if (e instanceof TfTypeError) {
6732 e = new TfPropertyTypeError(
6733 e.__type, property, label, e.__value, e.__valueTypeName
6734 )
6735 }
6736
6737 captureStackTrace(e)
6738 return e
6739}
6740
6741module.exports = {
6742 TfTypeError: TfTypeError,
6743 TfPropertyTypeError: TfPropertyTypeError,
6744 tfCustomError: tfCustomError,
6745 tfSubError: tfSubError,
6746 tfJSON: tfJSON,
6747 getValueTypeName: getValueTypeName
6748}
6749
6750},{"./native":50}],48:[function(require,module,exports){
6751(function (Buffer){
6752var NATIVE = require('./native')
6753var ERRORS = require('./errors')
6754
6755function _Buffer (value) {
6756 return Buffer.isBuffer(value)
6757}
6758
6759function Hex (value) {
6760 return typeof value === 'string' && /^([0-9a-f]{2})+$/i.test(value)
6761}
6762
6763function _LengthN (type, length) {
6764 var name = type.toJSON()
6765
6766 function Length (value) {
6767 if (!type(value)) return false
6768 if (value.length === length) return true
6769
6770 throw ERRORS.tfCustomError(name + '(Length: ' + length + ')', name + '(Length: ' + value.length + ')')
6771 }
6772 Length.toJSON = function () { return name }
6773
6774 return Length
6775}
6776
6777var _ArrayN = _LengthN.bind(null, NATIVE.Array)
6778var _BufferN = _LengthN.bind(null, _Buffer)
6779var _HexN = _LengthN.bind(null, Hex)
6780var _StringN = _LengthN.bind(null, NATIVE.String)
6781
6782function Range (a, b, f) {
6783 f = f || NATIVE.Number
6784 function _range (value, strict) {
6785 return f(value, strict) && (value > a) && (value < b)
6786 }
6787 _range.toJSON = function () {
6788 return `${f.toJSON()} between [${a}, ${b}]`
6789 }
6790 return _range
6791}
6792
6793var INT53_MAX = Math.pow(2, 53) - 1
6794
6795function Finite (value) {
6796 return typeof value === 'number' && isFinite(value)
6797}
6798function Int8 (value) { return ((value << 24) >> 24) === value }
6799function Int16 (value) { return ((value << 16) >> 16) === value }
6800function Int32 (value) { return (value | 0) === value }
6801function Int53 (value) {
6802 return typeof value === 'number' &&
6803 value >= -INT53_MAX &&
6804 value <= INT53_MAX &&
6805 Math.floor(value) === value
6806}
6807function UInt8 (value) { return (value & 0xff) === value }
6808function UInt16 (value) { return (value & 0xffff) === value }
6809function UInt32 (value) { return (value >>> 0) === value }
6810function UInt53 (value) {
6811 return typeof value === 'number' &&
6812 value >= 0 &&
6813 value <= INT53_MAX &&
6814 Math.floor(value) === value
6815}
6816
6817var types = {
6818 ArrayN: _ArrayN,
6819 Buffer: _Buffer,
6820 BufferN: _BufferN,
6821 Finite: Finite,
6822 Hex: Hex,
6823 HexN: _HexN,
6824 Int8: Int8,
6825 Int16: Int16,
6826 Int32: Int32,
6827 Int53: Int53,
6828 Range: Range,
6829 StringN: _StringN,
6830 UInt8: UInt8,
6831 UInt16: UInt16,
6832 UInt32: UInt32,
6833 UInt53: UInt53
6834}
6835
6836for (var typeName in types) {
6837 types[typeName].toJSON = function (t) {
6838 return t
6839 }.bind(null, typeName)
6840}
6841
6842module.exports = types
6843
6844}).call(this,{"isBuffer":require("../../../../../../usr/local/lib/node_modules/browserify/node_modules/is-buffer/index.js")})
6845},{"../../../../../../usr/local/lib/node_modules/browserify/node_modules/is-buffer/index.js":101,"./errors":47,"./native":50}],49:[function(require,module,exports){
6846var ERRORS = require('./errors')
6847var NATIVE = require('./native')
6848
6849// short-hand
6850var tfJSON = ERRORS.tfJSON
6851var TfTypeError = ERRORS.TfTypeError
6852var TfPropertyTypeError = ERRORS.TfPropertyTypeError
6853var tfSubError = ERRORS.tfSubError
6854var getValueTypeName = ERRORS.getValueTypeName
6855
6856var TYPES = {
6857 arrayOf: function arrayOf (type, options) {
6858 type = compile(type)
6859 options = options || {}
6860
6861 function _arrayOf (array, strict) {
6862 if (!NATIVE.Array(array)) return false
6863 if (NATIVE.Nil(array)) return false
6864 if (options.minLength !== undefined && array.length < options.minLength) return false
6865 if (options.maxLength !== undefined && array.length > options.maxLength) return false
6866 if (options.length !== undefined && array.length !== options.length) return false
6867
6868 return array.every(function (value, i) {
6869 try {
6870 return typeforce(type, value, strict)
6871 } catch (e) {
6872 throw tfSubError(e, i)
6873 }
6874 })
6875 }
6876 _arrayOf.toJSON = function () {
6877 var str = '[' + tfJSON(type) + ']'
6878 if (options.length !== undefined) {
6879 str += '{' + options.length + '}'
6880 } else if (options.minLength !== undefined || options.maxLength !== undefined) {
6881 str += '{' +
6882 (options.minLength === undefined ? 0 : options.minLength) + ',' +
6883 (options.maxLength === undefined ? Infinity : options.maxLength) + '}'
6884 }
6885 return str
6886 }
6887
6888 return _arrayOf
6889 },
6890
6891 maybe: function maybe (type) {
6892 type = compile(type)
6893
6894 function _maybe (value, strict) {
6895 return NATIVE.Nil(value) || type(value, strict, maybe)
6896 }
6897 _maybe.toJSON = function () { return '?' + tfJSON(type) }
6898
6899 return _maybe
6900 },
6901
6902 map: function map (propertyType, propertyKeyType) {
6903 propertyType = compile(propertyType)
6904 if (propertyKeyType) propertyKeyType = compile(propertyKeyType)
6905
6906 function _map (value, strict) {
6907 if (!NATIVE.Object(value)) return false
6908 if (NATIVE.Nil(value)) return false
6909
6910 for (var propertyName in value) {
6911 try {
6912 if (propertyKeyType) {
6913 typeforce(propertyKeyType, propertyName, strict)
6914 }
6915 } catch (e) {
6916 throw tfSubError(e, propertyName, 'key')
6917 }
6918
6919 try {
6920 var propertyValue = value[propertyName]
6921 typeforce(propertyType, propertyValue, strict)
6922 } catch (e) {
6923 throw tfSubError(e, propertyName)
6924 }
6925 }
6926
6927 return true
6928 }
6929
6930 if (propertyKeyType) {
6931 _map.toJSON = function () {
6932 return '{' + tfJSON(propertyKeyType) + ': ' + tfJSON(propertyType) + '}'
6933 }
6934 } else {
6935 _map.toJSON = function () { return '{' + tfJSON(propertyType) + '}' }
6936 }
6937
6938 return _map
6939 },
6940
6941 object: function object (uncompiled) {
6942 var type = {}
6943
6944 for (var typePropertyName in uncompiled) {
6945 type[typePropertyName] = compile(uncompiled[typePropertyName])
6946 }
6947
6948 function _object (value, strict) {
6949 if (!NATIVE.Object(value)) return false
6950 if (NATIVE.Nil(value)) return false
6951
6952 var propertyName
6953
6954 try {
6955 for (propertyName in type) {
6956 var propertyType = type[propertyName]
6957 var propertyValue = value[propertyName]
6958
6959 typeforce(propertyType, propertyValue, strict)
6960 }
6961 } catch (e) {
6962 throw tfSubError(e, propertyName)
6963 }
6964
6965 if (strict) {
6966 for (propertyName in value) {
6967 if (type[propertyName]) continue
6968
6969 throw new TfPropertyTypeError(undefined, propertyName)
6970 }
6971 }
6972
6973 return true
6974 }
6975 _object.toJSON = function () { return tfJSON(type) }
6976
6977 return _object
6978 },
6979
6980 anyOf: function anyOf () {
6981 var types = [].slice.call(arguments).map(compile)
6982
6983 function _anyOf (value, strict) {
6984 return types.some(function (type) {
6985 try {
6986 return typeforce(type, value, strict)
6987 } catch (e) {
6988 return false
6989 }
6990 })
6991 }
6992 _anyOf.toJSON = function () { return types.map(tfJSON).join('|') }
6993
6994 return _anyOf
6995 },
6996
6997 allOf: function allOf () {
6998 var types = [].slice.call(arguments).map(compile)
6999
7000 function _allOf (value, strict) {
7001 return types.every(function (type) {
7002 try {
7003 return typeforce(type, value, strict)
7004 } catch (e) {
7005 return false
7006 }
7007 })
7008 }
7009 _allOf.toJSON = function () { return types.map(tfJSON).join(' & ') }
7010
7011 return _allOf
7012 },
7013
7014 quacksLike: function quacksLike (type) {
7015 function _quacksLike (value) {
7016 return type === getValueTypeName(value)
7017 }
7018 _quacksLike.toJSON = function () { return type }
7019
7020 return _quacksLike
7021 },
7022
7023 tuple: function tuple () {
7024 var types = [].slice.call(arguments).map(compile)
7025
7026 function _tuple (values, strict) {
7027 if (NATIVE.Nil(values)) return false
7028 if (NATIVE.Nil(values.length)) return false
7029 if (strict && (values.length !== types.length)) return false
7030
7031 return types.every(function (type, i) {
7032 try {
7033 return typeforce(type, values[i], strict)
7034 } catch (e) {
7035 throw tfSubError(e, i)
7036 }
7037 })
7038 }
7039 _tuple.toJSON = function () { return '(' + types.map(tfJSON).join(', ') + ')' }
7040
7041 return _tuple
7042 },
7043
7044 value: function value (expected) {
7045 function _value (actual) {
7046 return actual === expected
7047 }
7048 _value.toJSON = function () { return expected }
7049
7050 return _value
7051 }
7052}
7053
7054// TODO: deprecate
7055TYPES.oneOf = TYPES.anyOf
7056
7057function compile (type) {
7058 if (NATIVE.String(type)) {
7059 if (type[0] === '?') return TYPES.maybe(type.slice(1))
7060
7061 return NATIVE[type] || TYPES.quacksLike(type)
7062 } else if (type && NATIVE.Object(type)) {
7063 if (NATIVE.Array(type)) {
7064 if (type.length !== 1) throw new TypeError('Expected compile() parameter of type Array of length 1')
7065 return TYPES.arrayOf(type[0])
7066 }
7067
7068 return TYPES.object(type)
7069 } else if (NATIVE.Function(type)) {
7070 return type
7071 }
7072
7073 return TYPES.value(type)
7074}
7075
7076function typeforce (type, value, strict, surrogate) {
7077 if (NATIVE.Function(type)) {
7078 if (type(value, strict)) return true
7079
7080 throw new TfTypeError(surrogate || type, value)
7081 }
7082
7083 // JIT
7084 return typeforce(compile(type), value, strict)
7085}
7086
7087// assign types to typeforce function
7088for (var typeName in NATIVE) {
7089 typeforce[typeName] = NATIVE[typeName]
7090}
7091
7092for (typeName in TYPES) {
7093 typeforce[typeName] = TYPES[typeName]
7094}
7095
7096var EXTRA = require('./extra')
7097for (typeName in EXTRA) {
7098 typeforce[typeName] = EXTRA[typeName]
7099}
7100
7101typeforce.compile = compile
7102typeforce.TfTypeError = TfTypeError
7103typeforce.TfPropertyTypeError = TfPropertyTypeError
7104
7105module.exports = typeforce
7106
7107},{"./errors":47,"./extra":48,"./native":50}],50:[function(require,module,exports){
7108var types = {
7109 Array: function (value) { return value !== null && value !== undefined && value.constructor === Array },
7110 Boolean: function (value) { return typeof value === 'boolean' },
7111 Function: function (value) { return typeof value === 'function' },
7112 Nil: function (value) { return value === undefined || value === null },
7113 Number: function (value) { return typeof value === 'number' },
7114 Object: function (value) { return typeof value === 'object' },
7115 String: function (value) { return typeof value === 'string' },
7116 '': function () { return true }
7117}
7118
7119// TODO: deprecate
7120types.Null = types.Nil
7121
7122for (var typeName in types) {
7123 types[typeName].toJSON = function (t) {
7124 return t
7125 }.bind(null, typeName)
7126}
7127
7128module.exports = types
7129
7130},{}],51:[function(require,module,exports){
7131'use strict'
7132var Buffer = require('safe-buffer').Buffer
7133
7134// Number.MAX_SAFE_INTEGER
7135var MAX_SAFE_INTEGER = 9007199254740991
7136
7137function checkUInt53 (n) {
7138 if (n < 0 || n > MAX_SAFE_INTEGER || n % 1 !== 0) throw new RangeError('value out of range')
7139}
7140
7141function encode (number, buffer, offset) {
7142 checkUInt53(number)
7143
7144 if (!buffer) buffer = Buffer.allocUnsafe(encodingLength(number))
7145 if (!Buffer.isBuffer(buffer)) throw new TypeError('buffer must be a Buffer instance')
7146 if (!offset) offset = 0
7147
7148 // 8 bit
7149 if (number < 0xfd) {
7150 buffer.writeUInt8(number, offset)
7151 encode.bytes = 1
7152
7153 // 16 bit
7154 } else if (number <= 0xffff) {
7155 buffer.writeUInt8(0xfd, offset)
7156 buffer.writeUInt16LE(number, offset + 1)
7157 encode.bytes = 3
7158
7159 // 32 bit
7160 } else if (number <= 0xffffffff) {
7161 buffer.writeUInt8(0xfe, offset)
7162 buffer.writeUInt32LE(number, offset + 1)
7163 encode.bytes = 5
7164
7165 // 64 bit
7166 } else {
7167 buffer.writeUInt8(0xff, offset)
7168 buffer.writeUInt32LE(number >>> 0, offset + 1)
7169 buffer.writeUInt32LE((number / 0x100000000) | 0, offset + 5)
7170 encode.bytes = 9
7171 }
7172
7173 return buffer
7174}
7175
7176function decode (buffer, offset) {
7177 if (!Buffer.isBuffer(buffer)) throw new TypeError('buffer must be a Buffer instance')
7178 if (!offset) offset = 0
7179
7180 var first = buffer.readUInt8(offset)
7181
7182 // 8 bit
7183 if (first < 0xfd) {
7184 decode.bytes = 1
7185 return first
7186
7187 // 16 bit
7188 } else if (first === 0xfd) {
7189 decode.bytes = 3
7190 return buffer.readUInt16LE(offset + 1)
7191
7192 // 32 bit
7193 } else if (first === 0xfe) {
7194 decode.bytes = 5
7195 return buffer.readUInt32LE(offset + 1)
7196
7197 // 64 bit
7198 } else {
7199 decode.bytes = 9
7200 var lo = buffer.readUInt32LE(offset + 1)
7201 var hi = buffer.readUInt32LE(offset + 5)
7202 var number = hi * 0x0100000000 + lo
7203 checkUInt53(number)
7204
7205 return number
7206 }
7207}
7208
7209function encodingLength (number) {
7210 checkUInt53(number)
7211
7212 return (
7213 number < 0xfd ? 1
7214 : number <= 0xffff ? 3
7215 : number <= 0xffffffff ? 5
7216 : 9
7217 )
7218}
7219
7220module.exports = { encode: encode, decode: decode, encodingLength: encodingLength }
7221
7222},{"safe-buffer":38}],52:[function(require,module,exports){
7223var bs58grscheck = require('bs58grscheck')
7224var Buffer = require('safe-buffer').Buffer
7225
7226function decodeRaw (buffer, version) {
7227 // check version only if defined
7228 if (version !== undefined && buffer[0] !== version) throw new Error('Invalid network version')
7229
7230 // uncompressed
7231 if (buffer.length === 33) {
7232 return {
7233 version: buffer[0],
7234 privateKey: buffer.slice(1, 33),
7235 compressed: false
7236 }
7237 }
7238
7239 // invalid length
7240 if (buffer.length !== 34) throw new Error('Invalid WIF length')
7241
7242 // invalid compression flag
7243 if (buffer[33] !== 0x01) throw new Error('Invalid compression flag')
7244
7245 return {
7246 version: buffer[0],
7247 privateKey: buffer.slice(1, 33),
7248 compressed: true
7249 }
7250}
7251
7252function encodeRaw (version, privateKey, compressed) {
7253 if (privateKey.length !== 32) throw new TypeError('Invalid privateKey length')
7254
7255 var result = Buffer.alloc(compressed ? 34 : 33)
7256 result.writeUInt8(version, 0)
7257 privateKey.copy(result, 1)
7258
7259 if (compressed) {
7260 result[33] = 0x01
7261 }
7262
7263 return result
7264}
7265
7266function decode (string, version) {
7267 return decodeRaw(bs58grscheck.decode(string), version)
7268}
7269
7270function encode (version, privateKey, compressed) {
7271 if (typeof version === 'number') return bs58grscheck.encode(encodeRaw(version, privateKey, compressed))
7272
7273 return bs58grscheck.encode(
7274 encodeRaw(
7275 version.version,
7276 version.privateKey,
7277 version.compressed
7278 )
7279 )
7280}
7281
7282module.exports = {
7283 decode: decode,
7284 decodeRaw: decodeRaw,
7285 encode: encode,
7286 encodeRaw: encodeRaw
7287}
7288
7289},{"bs58grscheck":12,"safe-buffer":38}],53:[function(require,module,exports){
7290var Buffer = require('safe-buffer').Buffer
7291var bech32 = require('bech32')
7292var bs58grscheck = require('bs58grscheck')
7293var bscript = require('./script')
7294var btemplates = require('./templates')
7295var networks = require('./networks')
7296var typeforce = require('typeforce')
7297var types = require('./types')
7298
7299function fromBase58GrsCheck (address) {
7300 var payload = bs58grscheck.decode(address)
7301
7302 // TODO: 4.0.0, move to "toOutputScript"
7303 if (payload.length < 21) throw new TypeError(address + ' is too short')
7304 if (payload.length > 21) throw new TypeError(address + ' is too long')
7305
7306 var version = payload.readUInt8(0)
7307 var hash = payload.slice(1)
7308
7309 return { version: version, hash: hash }
7310}
7311
7312function fromBech32 (address) {
7313 var result = bech32.decode(address)
7314 var data = bech32.fromWords(result.words.slice(1))
7315
7316 return {
7317 version: result.words[0],
7318 prefix: result.prefix,
7319 data: Buffer.from(data)
7320 }
7321}
7322
7323function toBase58GrsCheck (hash, version) {
7324 typeforce(types.tuple(types.Hash160bit, types.UInt8), arguments)
7325
7326 var payload = Buffer.allocUnsafe(21)
7327 payload.writeUInt8(version, 0)
7328 hash.copy(payload, 1)
7329
7330 return bs58grscheck.encode(payload)
7331}
7332
7333function toBech32 (data, version, prefix) {
7334 var words = bech32.toWords(data)
7335 words.unshift(version)
7336
7337 return bech32.encode(prefix, words)
7338}
7339
7340function fromOutputScript (outputScript, network) {
7341 network = network || networks.bitcoin
7342
7343 if (btemplates.pubKeyHash.output.check(outputScript)) return toBase58GrsCheck(bscript.compile(outputScript).slice(3, 23), network.pubKeyHash)
7344 if (btemplates.scriptHash.output.check(outputScript)) return toBase58GrsCheck(bscript.compile(outputScript).slice(2, 22), network.scriptHash)
7345 if (btemplates.witnessPubKeyHash.output.check(outputScript)) return toBech32(bscript.compile(outputScript).slice(2, 22), 0, network.bech32)
7346 if (btemplates.witnessScriptHash.output.check(outputScript)) return toBech32(bscript.compile(outputScript).slice(2, 34), 0, network.bech32)
7347
7348 throw new Error(bscript.toASM(outputScript) + ' has no matching Address')
7349}
7350
7351function toOutputScript (address, network) {
7352 network = network || networks.bitcoin
7353
7354 var decode
7355 try {
7356 decode = fromBase58GrsCheck(address)
7357 } catch (e) {}
7358
7359 if (decode) {
7360 if (decode.version === network.pubKeyHash) return btemplates.pubKeyHash.output.encode(decode.hash)
7361 if (decode.version === network.scriptHash) return btemplates.scriptHash.output.encode(decode.hash)
7362 } else {
7363 try {
7364 decode = fromBech32(address)
7365 } catch (e) {}
7366
7367 if (decode) {
7368 if (decode.prefix !== network.bech32) throw new Error(address + ' has an invalid prefix')
7369 if (decode.version === 0) {
7370 if (decode.data.length === 20) return btemplates.witnessPubKeyHash.output.encode(decode.data)
7371 if (decode.data.length === 32) return btemplates.witnessScriptHash.output.encode(decode.data)
7372 }
7373 }
7374 }
7375
7376 throw new Error(address + ' has no matching Script')
7377}
7378
7379module.exports = {
7380 fromBase58GrsCheck: fromBase58GrsCheck,
7381 fromBech32: fromBech32,
7382 fromOutputScript: fromOutputScript,
7383 toBase58GrsCheck: toBase58GrsCheck,
7384 toBech32: toBech32,
7385 toOutputScript: toOutputScript
7386}
7387
7388},{"./networks":62,"./script":63,"./templates":65,"./types":89,"bech32":2,"bs58grscheck":12,"safe-buffer":38,"typeforce":49}],54:[function(require,module,exports){
7389var Buffer = require('safe-buffer').Buffer
7390var bcrypto = require('./crypto')
7391var fastMerkleRoot = require('merkle-lib/fastRoot')
7392var typeforce = require('typeforce')
7393var types = require('./types')
7394var varuint = require('varuint-bitcoin')
7395
7396var Transaction = require('./transaction')
7397
7398function Block () {
7399 this.version = 1
7400 this.prevHash = null
7401 this.merkleRoot = null
7402 this.timestamp = 0
7403 this.bits = 0
7404 this.nonce = 0
7405}
7406
7407Block.fromBuffer = function (buffer) {
7408 if (buffer.length < 80) throw new Error('Buffer too small (< 80 bytes)')
7409
7410 var offset = 0
7411 function readSlice (n) {
7412 offset += n
7413 return buffer.slice(offset - n, offset)
7414 }
7415
7416 function readUInt32 () {
7417 var i = buffer.readUInt32LE(offset)
7418 offset += 4
7419 return i
7420 }
7421
7422 function readInt32 () {
7423 var i = buffer.readInt32LE(offset)
7424 offset += 4
7425 return i
7426 }
7427
7428 var block = new Block()
7429 block.version = readInt32()
7430 block.prevHash = readSlice(32)
7431 block.merkleRoot = readSlice(32)
7432 block.timestamp = readUInt32()
7433 block.bits = readUInt32()
7434 block.nonce = readUInt32()
7435
7436 if (buffer.length === 80) return block
7437
7438 function readVarInt () {
7439 var vi = varuint.decode(buffer, offset)
7440 offset += varuint.decode.bytes
7441 return vi
7442 }
7443
7444 function readTransaction () {
7445 var tx = Transaction.fromBuffer(buffer.slice(offset), true)
7446 offset += tx.byteLength()
7447 return tx
7448 }
7449
7450 var nTransactions = readVarInt()
7451 block.transactions = []
7452
7453 for (var i = 0; i < nTransactions; ++i) {
7454 var tx = readTransaction()
7455 block.transactions.push(tx)
7456 }
7457
7458 return block
7459}
7460
7461Block.prototype.byteLength = function (headersOnly) {
7462 if (headersOnly || !this.transactions) return 80
7463
7464 return 80 + varuint.encodingLength(this.transactions.length) + this.transactions.reduce(function (a, x) {
7465 return a + x.byteLength()
7466 }, 0)
7467}
7468
7469Block.fromHex = function (hex) {
7470 return Block.fromBuffer(Buffer.from(hex, 'hex'))
7471}
7472
7473Block.prototype.getHash = function () {
7474 return bcrypto.groestl(this.toBuffer(true))
7475}
7476
7477Block.prototype.getId = function () {
7478 return this.getHash().reverse().toString('hex')
7479}
7480
7481Block.prototype.getUTCDate = function () {
7482 var date = new Date(0) // epoch
7483 date.setUTCSeconds(this.timestamp)
7484
7485 return date
7486}
7487
7488// TODO: buffer, offset compatibility
7489Block.prototype.toBuffer = function (headersOnly) {
7490 var buffer = Buffer.allocUnsafe(this.byteLength(headersOnly))
7491
7492 var offset = 0
7493 function writeSlice (slice) {
7494 slice.copy(buffer, offset)
7495 offset += slice.length
7496 }
7497
7498 function writeInt32 (i) {
7499 buffer.writeInt32LE(i, offset)
7500 offset += 4
7501 }
7502 function writeUInt32 (i) {
7503 buffer.writeUInt32LE(i, offset)
7504 offset += 4
7505 }
7506
7507 writeInt32(this.version)
7508 writeSlice(this.prevHash)
7509 writeSlice(this.merkleRoot)
7510 writeUInt32(this.timestamp)
7511 writeUInt32(this.bits)
7512 writeUInt32(this.nonce)
7513
7514 if (headersOnly || !this.transactions) return buffer
7515
7516 varuint.encode(this.transactions.length, buffer, offset)
7517 offset += varuint.encode.bytes
7518
7519 this.transactions.forEach(function (tx) {
7520 var txSize = tx.byteLength() // TODO: extract from toBuffer?
7521 tx.toBuffer(buffer, offset)
7522 offset += txSize
7523 })
7524
7525 return buffer
7526}
7527
7528Block.prototype.toHex = function (headersOnly) {
7529 return this.toBuffer(headersOnly).toString('hex')
7530}
7531
7532Block.calculateTarget = function (bits) {
7533 var exponent = ((bits & 0xff000000) >> 24) - 3
7534 var mantissa = bits & 0x007fffff
7535 var target = Buffer.alloc(32, 0)
7536 target.writeUInt32BE(mantissa, 28 - exponent)
7537 return target
7538}
7539
7540Block.calculateMerkleRoot = function (transactions) {
7541 typeforce([{ getHash: types.Function }], transactions)
7542 if (transactions.length === 0) throw TypeError('Cannot compute merkle root for zero transactions')
7543
7544 var hashes = transactions.map(function (transaction) {
7545 return transaction.getHash()
7546 })
7547
7548 return fastMerkleRoot(hashes, bcrypto.hash256)
7549}
7550
7551Block.prototype.checkMerkleRoot = function () {
7552 if (!this.transactions) return false
7553
7554 var actualMerkleRoot = Block.calculateMerkleRoot(this.transactions)
7555 return this.merkleRoot.compare(actualMerkleRoot) === 0
7556}
7557
7558Block.prototype.checkProofOfWork = function () {
7559 var hash = this.getHash().reverse()
7560 var target = Block.calculateTarget(this.bits)
7561
7562 return hash.compare(target) <= 0
7563}
7564
7565module.exports = Block
7566
7567},{"./crypto":56,"./transaction":87,"./types":89,"merkle-lib/fastRoot":34,"safe-buffer":38,"typeforce":49,"varuint-bitcoin":51}],55:[function(require,module,exports){
7568var pushdata = require('pushdata-bitcoin')
7569var varuint = require('varuint-bitcoin')
7570
7571// https://github.com/feross/buffer/blob/master/index.js#L1127
7572function verifuint (value, max) {
7573 if (typeof value !== 'number') throw new Error('cannot write a non-number as a number')
7574 if (value < 0) throw new Error('specified a negative value for writing an unsigned value')
7575 if (value > max) throw new Error('RangeError: value out of range')
7576 if (Math.floor(value) !== value) throw new Error('value has a fractional component')
7577}
7578
7579function readUInt64LE (buffer, offset) {
7580 var a = buffer.readUInt32LE(offset)
7581 var b = buffer.readUInt32LE(offset + 4)
7582 b *= 0x100000000
7583
7584 verifuint(b + a, 0x001fffffffffffff)
7585
7586 return b + a
7587}
7588
7589function writeUInt64LE (buffer, value, offset) {
7590 verifuint(value, 0x001fffffffffffff)
7591
7592 buffer.writeInt32LE(value & -1, offset)
7593 buffer.writeUInt32LE(Math.floor(value / 0x100000000), offset + 4)
7594 return offset + 8
7595}
7596
7597// TODO: remove in 4.0.0?
7598function readVarInt (buffer, offset) {
7599 var result = varuint.decode(buffer, offset)
7600
7601 return {
7602 number: result,
7603 size: varuint.decode.bytes
7604 }
7605}
7606
7607// TODO: remove in 4.0.0?
7608function writeVarInt (buffer, number, offset) {
7609 varuint.encode(number, buffer, offset)
7610 return varuint.encode.bytes
7611}
7612
7613module.exports = {
7614 pushDataSize: pushdata.encodingLength,
7615 readPushDataInt: pushdata.decode,
7616 readUInt64LE: readUInt64LE,
7617 readVarInt: readVarInt,
7618 varIntBuffer: varuint.encode,
7619 varIntSize: varuint.encodingLength,
7620 writePushDataInt: pushdata.encode,
7621 writeUInt64LE: writeUInt64LE,
7622 writeVarInt: writeVarInt
7623}
7624
7625},{"pushdata-bitcoin":35,"varuint-bitcoin":51}],56:[function(require,module,exports){
7626(function (Buffer){
7627var createHash = require('create-hash')
7628var groestlhash = require('groestl-hash-js')
7629
7630function ripemd160 (buffer) {
7631 return createHash('rmd160').update(buffer).digest()
7632}
7633
7634function sha1 (buffer) {
7635 return createHash('sha1').update(buffer).digest()
7636}
7637
7638function sha256 (buffer) {
7639 return createHash('sha256').update(buffer).digest()
7640}
7641
7642function hash160 (buffer) {
7643 return ripemd160(sha256(buffer))
7644}
7645
7646function hash256 (buffer) {
7647 return sha256(sha256(buffer))
7648}
7649
7650function groestl (buffer) {
7651 return Buffer(groestlhash.groestl_2(buffer, 1, 1))
7652}
7653
7654module.exports = {
7655 hash160: hash160,
7656 hash256: hash256,
7657 ripemd160: ripemd160,
7658 sha1: sha1,
7659 sha256: sha256,
7660 groestl: groestl
7661}
7662
7663}).call(this,require("buffer").Buffer)
7664},{"buffer":96,"create-hash":14,"groestl-hash-js":27}],57:[function(require,module,exports){
7665var Buffer = require('safe-buffer').Buffer
7666var createHmac = require('create-hmac')
7667var typeforce = require('typeforce')
7668var types = require('./types')
7669
7670var BigInteger = require('bigi')
7671var ECSignature = require('./ecsignature')
7672
7673var ZERO = Buffer.alloc(1, 0)
7674var ONE = Buffer.alloc(1, 1)
7675
7676var ecurve = require('ecurve')
7677var secp256k1 = ecurve.getCurveByName('secp256k1')
7678
7679// https://tools.ietf.org/html/rfc6979#section-3.2
7680function deterministicGenerateK (hash, x, checkSig) {
7681 typeforce(types.tuple(
7682 types.Hash256bit,
7683 types.Buffer256bit,
7684 types.Function
7685 ), arguments)
7686
7687 // Step A, ignored as hash already provided
7688 // Step B
7689 // Step C
7690 var k = Buffer.alloc(32, 0)
7691 var v = Buffer.alloc(32, 1)
7692
7693 // Step D
7694 k = createHmac('sha256', k)
7695 .update(v)
7696 .update(ZERO)
7697 .update(x)
7698 .update(hash)
7699 .digest()
7700
7701 // Step E
7702 v = createHmac('sha256', k).update(v).digest()
7703
7704 // Step F
7705 k = createHmac('sha256', k)
7706 .update(v)
7707 .update(ONE)
7708 .update(x)
7709 .update(hash)
7710 .digest()
7711
7712 // Step G
7713 v = createHmac('sha256', k).update(v).digest()
7714
7715 // Step H1/H2a, ignored as tlen === qlen (256 bit)
7716 // Step H2b
7717 v = createHmac('sha256', k).update(v).digest()
7718
7719 var T = BigInteger.fromBuffer(v)
7720
7721 // Step H3, repeat until T is within the interval [1, n - 1] and is suitable for ECDSA
7722 while (T.signum() <= 0 || T.compareTo(secp256k1.n) >= 0 || !checkSig(T)) {
7723 k = createHmac('sha256', k)
7724 .update(v)
7725 .update(ZERO)
7726 .digest()
7727
7728 v = createHmac('sha256', k).update(v).digest()
7729
7730 // Step H1/H2a, again, ignored as tlen === qlen (256 bit)
7731 // Step H2b again
7732 v = createHmac('sha256', k).update(v).digest()
7733 T = BigInteger.fromBuffer(v)
7734 }
7735
7736 return T
7737}
7738
7739var N_OVER_TWO = secp256k1.n.shiftRight(1)
7740
7741function sign (hash, d) {
7742 typeforce(types.tuple(types.Hash256bit, types.BigInt), arguments)
7743
7744 var x = d.toBuffer(32)
7745 var e = BigInteger.fromBuffer(hash)
7746 var n = secp256k1.n
7747 var G = secp256k1.G
7748
7749 var r, s
7750 deterministicGenerateK(hash, x, function (k) {
7751 var Q = G.multiply(k)
7752
7753 if (secp256k1.isInfinity(Q)) return false
7754
7755 r = Q.affineX.mod(n)
7756 if (r.signum() === 0) return false
7757
7758 s = k.modInverse(n).multiply(e.add(d.multiply(r))).mod(n)
7759 if (s.signum() === 0) return false
7760
7761 return true
7762 })
7763
7764 // enforce low S values, see bip62: 'low s values in signatures'
7765 if (s.compareTo(N_OVER_TWO) > 0) {
7766 s = n.subtract(s)
7767 }
7768
7769 return new ECSignature(r, s)
7770}
7771
7772function verify (hash, signature, Q) {
7773 typeforce(types.tuple(
7774 types.Hash256bit,
7775 types.ECSignature,
7776 types.ECPoint
7777 ), arguments)
7778
7779 var n = secp256k1.n
7780 var G = secp256k1.G
7781
7782 var r = signature.r
7783 var s = signature.s
7784
7785 // 1.4.1 Enforce r and s are both integers in the interval [1, n − 1]
7786 if (r.signum() <= 0 || r.compareTo(n) >= 0) return false
7787 if (s.signum() <= 0 || s.compareTo(n) >= 0) return false
7788
7789 // 1.4.2 H = Hash(M), already done by the user
7790 // 1.4.3 e = H
7791 var e = BigInteger.fromBuffer(hash)
7792
7793 // Compute s^-1
7794 var sInv = s.modInverse(n)
7795
7796 // 1.4.4 Compute u1 = es^−1 mod n
7797 // u2 = rs^−1 mod n
7798 var u1 = e.multiply(sInv).mod(n)
7799 var u2 = r.multiply(sInv).mod(n)
7800
7801 // 1.4.5 Compute R = (xR, yR)
7802 // R = u1G + u2Q
7803 var R = G.multiplyTwo(u1, Q, u2)
7804
7805 // 1.4.5 (cont.) Enforce R is not at infinity
7806 if (secp256k1.isInfinity(R)) return false
7807
7808 // 1.4.6 Convert the field element R.x to an integer
7809 var xR = R.affineX
7810
7811 // 1.4.7 Set v = xR mod n
7812 var v = xR.mod(n)
7813
7814 // 1.4.8 If v = r, output "valid", and if v != r, output "invalid"
7815 return v.equals(r)
7816}
7817
7818module.exports = {
7819 deterministicGenerateK: deterministicGenerateK,
7820 sign: sign,
7821 verify: verify,
7822
7823 // TODO: remove
7824 __curve: secp256k1
7825}
7826
7827},{"./ecsignature":59,"./types":89,"bigi":5,"create-hmac":16,"ecurve":20,"safe-buffer":38,"typeforce":49}],58:[function(require,module,exports){
7828var baddress = require('./address')
7829var bcrypto = require('./crypto')
7830var ecdsa = require('./ecdsa')
7831var randomBytes = require('randombytes')
7832var typeforce = require('typeforce')
7833var types = require('./types')
7834var wif = require('wifgrs')
7835
7836var NETWORKS = require('./networks')
7837var BigInteger = require('bigi')
7838
7839var ecurve = require('ecurve')
7840var secp256k1 = ecdsa.__curve
7841
7842function ECPair (d, Q, options) {
7843 if (options) {
7844 typeforce({
7845 compressed: types.maybe(types.Boolean),
7846 network: types.maybe(types.Network)
7847 }, options)
7848 }
7849
7850 options = options || {}
7851
7852 if (d) {
7853 if (d.signum() <= 0) throw new Error('Private key must be greater than 0')
7854 if (d.compareTo(secp256k1.n) >= 0) throw new Error('Private key must be less than the curve order')
7855 if (Q) throw new TypeError('Unexpected publicKey parameter')
7856
7857 this.d = d
7858 } else {
7859 typeforce(types.ECPoint, Q)
7860
7861 this.__Q = Q
7862 }
7863
7864 this.compressed = options.compressed === undefined ? true : options.compressed
7865 this.network = options.network || NETWORKS.bitcoin
7866}
7867
7868Object.defineProperty(ECPair.prototype, 'Q', {
7869 get: function () {
7870 if (!this.__Q && this.d) {
7871 this.__Q = secp256k1.G.multiply(this.d)
7872 }
7873
7874 return this.__Q
7875 }
7876})
7877
7878ECPair.fromPublicKeyBuffer = function (buffer, network) {
7879 var Q = ecurve.Point.decodeFrom(secp256k1, buffer)
7880
7881 return new ECPair(null, Q, {
7882 compressed: Q.compressed,
7883 network: network
7884 })
7885}
7886
7887ECPair.fromWIF = function (string, network) {
7888 var decoded = wif.decode(string)
7889 var version = decoded.version
7890
7891 // list of networks?
7892 if (types.Array(network)) {
7893 network = network.filter(function (x) {
7894 return version === x.wif
7895 }).pop()
7896
7897 if (!network) throw new Error('Unknown network version')
7898
7899 // otherwise, assume a network object (or default to bitcoin)
7900 } else {
7901 network = network || NETWORKS.bitcoin
7902
7903 if (version !== network.wif) throw new Error('Invalid network version')
7904 }
7905
7906 var d = BigInteger.fromBuffer(decoded.privateKey)
7907
7908 return new ECPair(d, null, {
7909 compressed: decoded.compressed,
7910 network: network
7911 })
7912}
7913
7914ECPair.makeRandom = function (options) {
7915 options = options || {}
7916
7917 var rng = options.rng || randomBytes
7918
7919 var d
7920 do {
7921 var buffer = rng(32)
7922 typeforce(types.Buffer256bit, buffer)
7923
7924 d = BigInteger.fromBuffer(buffer)
7925 } while (d.signum() <= 0 || d.compareTo(secp256k1.n) >= 0)
7926
7927 return new ECPair(d, null, options)
7928}
7929
7930ECPair.prototype.getAddress = function () {
7931 return baddress.toBase58GrsCheck(bcrypto.hash160(this.getPublicKeyBuffer()), this.getNetwork().pubKeyHash)
7932}
7933
7934ECPair.prototype.getNetwork = function () {
7935 return this.network
7936}
7937
7938ECPair.prototype.getPublicKeyBuffer = function () {
7939 return this.Q.getEncoded(this.compressed)
7940}
7941
7942ECPair.prototype.sign = function (hash) {
7943 if (!this.d) throw new Error('Missing private key')
7944
7945 return ecdsa.sign(hash, this.d)
7946}
7947
7948ECPair.prototype.toWIF = function () {
7949 if (!this.d) throw new Error('Missing private key')
7950
7951 return wif.encode(this.network.wif, this.d.toBuffer(32), this.compressed)
7952}
7953
7954ECPair.prototype.verify = function (hash, signature) {
7955 return ecdsa.verify(hash, signature, this.Q)
7956}
7957
7958module.exports = ECPair
7959
7960},{"./address":53,"./crypto":56,"./ecdsa":57,"./networks":62,"./types":89,"bigi":5,"ecurve":20,"randombytes":36,"typeforce":49,"wifgrs":52}],59:[function(require,module,exports){
7961(function (Buffer){
7962var bip66 = require('bip66')
7963var typeforce = require('typeforce')
7964var types = require('./types')
7965
7966var BigInteger = require('bigi')
7967
7968function ECSignature (r, s) {
7969 typeforce(types.tuple(types.BigInt, types.BigInt), arguments)
7970
7971 this.r = r
7972 this.s = s
7973}
7974
7975ECSignature.parseCompact = function (buffer) {
7976 typeforce(types.BufferN(65), buffer)
7977
7978 var flagByte = buffer.readUInt8(0) - 27
7979 if (flagByte !== (flagByte & 7)) throw new Error('Invalid signature parameter')
7980
7981 var compressed = !!(flagByte & 4)
7982 var recoveryParam = flagByte & 3
7983 var signature = ECSignature.fromRSBuffer(buffer.slice(1))
7984
7985 return {
7986 compressed: compressed,
7987 i: recoveryParam,
7988 signature: signature
7989 }
7990}
7991
7992ECSignature.fromRSBuffer = function (buffer) {
7993 typeforce(types.BufferN(64), buffer)
7994
7995 var r = BigInteger.fromBuffer(buffer.slice(0, 32))
7996 var s = BigInteger.fromBuffer(buffer.slice(32, 64))
7997 return new ECSignature(r, s)
7998}
7999
8000ECSignature.fromDER = function (buffer) {
8001 var decode = bip66.decode(buffer)
8002 var r = BigInteger.fromDERInteger(decode.r)
8003 var s = BigInteger.fromDERInteger(decode.s)
8004
8005 return new ECSignature(r, s)
8006}
8007
8008// BIP62: 1 byte hashType flag (only 0x01, 0x02, 0x03, 0x81, 0x82 and 0x83 are allowed)
8009ECSignature.parseScriptSignature = function (buffer) {
8010 var hashType = buffer.readUInt8(buffer.length - 1)
8011 var hashTypeMod = hashType & ~0x80
8012
8013 if (hashTypeMod <= 0x00 || hashTypeMod >= 0x04) throw new Error('Invalid hashType ' + hashType)
8014
8015 return {
8016 signature: ECSignature.fromDER(buffer.slice(0, -1)),
8017 hashType: hashType
8018 }
8019}
8020
8021ECSignature.prototype.toCompact = function (i, compressed) {
8022 if (compressed) {
8023 i += 4
8024 }
8025
8026 i += 27
8027
8028 var buffer = Buffer.alloc(65)
8029 buffer.writeUInt8(i, 0)
8030 this.toRSBuffer(buffer, 1)
8031 return buffer
8032}
8033
8034ECSignature.prototype.toDER = function () {
8035 var r = Buffer.from(this.r.toDERInteger())
8036 var s = Buffer.from(this.s.toDERInteger())
8037
8038 return bip66.encode(r, s)
8039}
8040
8041ECSignature.prototype.toRSBuffer = function (buffer, offset) {
8042 buffer = buffer || Buffer.alloc(64)
8043 this.r.toBuffer(32).copy(buffer, offset)
8044 this.s.toBuffer(32).copy(buffer, offset + 32)
8045 return buffer
8046}
8047
8048ECSignature.prototype.toScriptSignature = function (hashType) {
8049 var hashTypeMod = hashType & ~0x80
8050 if (hashTypeMod <= 0 || hashTypeMod >= 4) throw new Error('Invalid hashType ' + hashType)
8051
8052 var hashTypeBuffer = Buffer.alloc(1)
8053 hashTypeBuffer.writeUInt8(hashType, 0)
8054
8055 return Buffer.concat([this.toDER(), hashTypeBuffer])
8056}
8057
8058module.exports = ECSignature
8059
8060}).call(this,require("buffer").Buffer)
8061},{"./types":89,"bigi":5,"bip66":7,"buffer":96,"typeforce":49}],60:[function(require,module,exports){
8062var Buffer = require('safe-buffer').Buffer
8063var base58grscheck = require('bs58grscheck')
8064var bcrypto = require('./crypto')
8065var createHmac = require('create-hmac')
8066var typeforce = require('typeforce')
8067var types = require('./types')
8068var NETWORKS = require('./networks')
8069
8070var BigInteger = require('bigi')
8071var ECPair = require('./ecpair')
8072
8073var ecurve = require('ecurve')
8074var curve = ecurve.getCurveByName('secp256k1')
8075
8076function HDNode (keyPair, chainCode) {
8077 typeforce(types.tuple('ECPair', types.Buffer256bit), arguments)
8078
8079 if (!keyPair.compressed) throw new TypeError('BIP32 only allows compressed keyPairs')
8080
8081 this.keyPair = keyPair
8082 this.chainCode = chainCode
8083 this.depth = 0
8084 this.index = 0
8085 this.parentFingerprint = 0x00000000
8086}
8087
8088HDNode.HIGHEST_BIT = 0x80000000
8089HDNode.LENGTH = 78
8090HDNode.MASTER_SECRET = Buffer.from('Bitcoin seed', 'utf8')
8091
8092HDNode.fromSeedBuffer = function (seed, network) {
8093 typeforce(types.tuple(types.Buffer, types.maybe(types.Network)), arguments)
8094
8095 if (seed.length < 16) throw new TypeError('Seed should be at least 128 bits')
8096 if (seed.length > 64) throw new TypeError('Seed should be at most 512 bits')
8097
8098 var I = createHmac('sha512', HDNode.MASTER_SECRET).update(seed).digest()
8099 var IL = I.slice(0, 32)
8100 var IR = I.slice(32)
8101
8102 // In case IL is 0 or >= n, the master key is invalid
8103 // This is handled by the ECPair constructor
8104 var pIL = BigInteger.fromBuffer(IL)
8105 var keyPair = new ECPair(pIL, null, {
8106 network: network
8107 })
8108
8109 return new HDNode(keyPair, IR)
8110}
8111
8112HDNode.fromSeedHex = function (hex, network) {
8113 return HDNode.fromSeedBuffer(Buffer.from(hex, 'hex'), network)
8114}
8115
8116HDNode.fromBase58 = function (string, networks) {
8117 var buffer = base58grscheck.decode(string)
8118 if (buffer.length !== 78) throw new Error('Invalid buffer length')
8119
8120 // 4 bytes: version bytes
8121 var version = buffer.readUInt32BE(0)
8122 var network
8123
8124 // list of networks?
8125 if (Array.isArray(networks)) {
8126 network = networks.filter(function (x) {
8127 return version === x.bip32.private ||
8128 version === x.bip32.public
8129 }).pop()
8130
8131 if (!network) throw new Error('Unknown network version')
8132
8133 // otherwise, assume a network object (or default to bitcoin)
8134 } else {
8135 network = networks || NETWORKS.bitcoin
8136 }
8137
8138 if (version !== network.bip32.private &&
8139 version !== network.bip32.public) throw new Error('Invalid network version')
8140
8141 // 1 byte: depth: 0x00 for master nodes, 0x01 for level-1 descendants, ...
8142 var depth = buffer[4]
8143
8144 // 4 bytes: the fingerprint of the parent's key (0x00000000 if master key)
8145 var parentFingerprint = buffer.readUInt32BE(5)
8146 if (depth === 0) {
8147 if (parentFingerprint !== 0x00000000) throw new Error('Invalid parent fingerprint')
8148 }
8149
8150 // 4 bytes: child number. This is the number i in xi = xpar/i, with xi the key being serialized.
8151 // This is encoded in MSB order. (0x00000000 if master key)
8152 var index = buffer.readUInt32BE(9)
8153 if (depth === 0 && index !== 0) throw new Error('Invalid index')
8154
8155 // 32 bytes: the chain code
8156 var chainCode = buffer.slice(13, 45)
8157 var keyPair
8158
8159 // 33 bytes: private key data (0x00 + k)
8160 if (version === network.bip32.private) {
8161 if (buffer.readUInt8(45) !== 0x00) throw new Error('Invalid private key')
8162
8163 var d = BigInteger.fromBuffer(buffer.slice(46, 78))
8164 keyPair = new ECPair(d, null, { network: network })
8165
8166 // 33 bytes: public key data (0x02 + X or 0x03 + X)
8167 } else {
8168 var Q = ecurve.Point.decodeFrom(curve, buffer.slice(45, 78))
8169 // Q.compressed is assumed, if somehow this assumption is broken, `new HDNode` will throw
8170
8171 // Verify that the X coordinate in the public point corresponds to a point on the curve.
8172 // If not, the extended public key is invalid.
8173 curve.validate(Q)
8174
8175 keyPair = new ECPair(null, Q, { network: network })
8176 }
8177
8178 var hd = new HDNode(keyPair, chainCode)
8179 hd.depth = depth
8180 hd.index = index
8181 hd.parentFingerprint = parentFingerprint
8182
8183 return hd
8184}
8185
8186HDNode.prototype.getAddress = function () {
8187 return this.keyPair.getAddress()
8188}
8189
8190HDNode.prototype.getIdentifier = function () {
8191 return bcrypto.hash160(this.keyPair.getPublicKeyBuffer())
8192}
8193
8194HDNode.prototype.getFingerprint = function () {
8195 return this.getIdentifier().slice(0, 4)
8196}
8197
8198HDNode.prototype.getNetwork = function () {
8199 return this.keyPair.getNetwork()
8200}
8201
8202HDNode.prototype.getPublicKeyBuffer = function () {
8203 return this.keyPair.getPublicKeyBuffer()
8204}
8205
8206HDNode.prototype.neutered = function () {
8207 var neuteredKeyPair = new ECPair(null, this.keyPair.Q, {
8208 network: this.keyPair.network
8209 })
8210
8211 var neutered = new HDNode(neuteredKeyPair, this.chainCode)
8212 neutered.depth = this.depth
8213 neutered.index = this.index
8214 neutered.parentFingerprint = this.parentFingerprint
8215
8216 return neutered
8217}
8218
8219HDNode.prototype.sign = function (hash) {
8220 return this.keyPair.sign(hash)
8221}
8222
8223HDNode.prototype.verify = function (hash, signature) {
8224 return this.keyPair.verify(hash, signature)
8225}
8226
8227HDNode.prototype.toBase58 = function (__isPrivate) {
8228 if (__isPrivate !== undefined) throw new TypeError('Unsupported argument in 2.0.0')
8229
8230 // Version
8231 var network = this.keyPair.network
8232 var version = (!this.isNeutered()) ? network.bip32.private : network.bip32.public
8233 var buffer = Buffer.allocUnsafe(78)
8234
8235 // 4 bytes: version bytes
8236 buffer.writeUInt32BE(version, 0)
8237
8238 // 1 byte: depth: 0x00 for master nodes, 0x01 for level-1 descendants, ....
8239 buffer.writeUInt8(this.depth, 4)
8240
8241 // 4 bytes: the fingerprint of the parent's key (0x00000000 if master key)
8242 buffer.writeUInt32BE(this.parentFingerprint, 5)
8243
8244 // 4 bytes: child number. This is the number i in xi = xpar/i, with xi the key being serialized.
8245 // This is encoded in big endian. (0x00000000 if master key)
8246 buffer.writeUInt32BE(this.index, 9)
8247
8248 // 32 bytes: the chain code
8249 this.chainCode.copy(buffer, 13)
8250
8251 // 33 bytes: the public key or private key data
8252 if (!this.isNeutered()) {
8253 // 0x00 + k for private keys
8254 buffer.writeUInt8(0, 45)
8255 this.keyPair.d.toBuffer(32).copy(buffer, 46)
8256
8257 // 33 bytes: the public key
8258 } else {
8259 // X9.62 encoding for public keys
8260 this.keyPair.getPublicKeyBuffer().copy(buffer, 45)
8261 }
8262
8263 return base58grscheck.encode(buffer)
8264}
8265
8266// https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#child-key-derivation-ckd-functions
8267HDNode.prototype.derive = function (index) {
8268 typeforce(types.UInt32, index)
8269
8270 var isHardened = index >= HDNode.HIGHEST_BIT
8271 var data = Buffer.allocUnsafe(37)
8272
8273 // Hardened child
8274 if (isHardened) {
8275 if (this.isNeutered()) throw new TypeError('Could not derive hardened child key')
8276
8277 // data = 0x00 || ser256(kpar) || ser32(index)
8278 data[0] = 0x00
8279 this.keyPair.d.toBuffer(32).copy(data, 1)
8280 data.writeUInt32BE(index, 33)
8281
8282 // Normal child
8283 } else {
8284 // data = serP(point(kpar)) || ser32(index)
8285 // = serP(Kpar) || ser32(index)
8286 this.keyPair.getPublicKeyBuffer().copy(data, 0)
8287 data.writeUInt32BE(index, 33)
8288 }
8289
8290 var I = createHmac('sha512', this.chainCode).update(data).digest()
8291 var IL = I.slice(0, 32)
8292 var IR = I.slice(32)
8293
8294 var pIL = BigInteger.fromBuffer(IL)
8295
8296 // In case parse256(IL) >= n, proceed with the next value for i
8297 if (pIL.compareTo(curve.n) >= 0) {
8298 return this.derive(index + 1)
8299 }
8300
8301 // Private parent key -> private child key
8302 var derivedKeyPair
8303 if (!this.isNeutered()) {
8304 // ki = parse256(IL) + kpar (mod n)
8305 var ki = pIL.add(this.keyPair.d).mod(curve.n)
8306
8307 // In case ki == 0, proceed with the next value for i
8308 if (ki.signum() === 0) {
8309 return this.derive(index + 1)
8310 }
8311
8312 derivedKeyPair = new ECPair(ki, null, {
8313 network: this.keyPair.network
8314 })
8315
8316 // Public parent key -> public child key
8317 } else {
8318 // Ki = point(parse256(IL)) + Kpar
8319 // = G*IL + Kpar
8320 var Ki = curve.G.multiply(pIL).add(this.keyPair.Q)
8321
8322 // In case Ki is the point at infinity, proceed with the next value for i
8323 if (curve.isInfinity(Ki)) {
8324 return this.derive(index + 1)
8325 }
8326
8327 derivedKeyPair = new ECPair(null, Ki, {
8328 network: this.keyPair.network
8329 })
8330 }
8331
8332 var hd = new HDNode(derivedKeyPair, IR)
8333 hd.depth = this.depth + 1
8334 hd.index = index
8335 hd.parentFingerprint = this.getFingerprint().readUInt32BE(0)
8336
8337 return hd
8338}
8339
8340HDNode.prototype.deriveHardened = function (index) {
8341 typeforce(types.UInt31, index)
8342
8343 // Only derives hardened private keys by default
8344 return this.derive(index + HDNode.HIGHEST_BIT)
8345}
8346
8347// Private === not neutered
8348// Public === neutered
8349HDNode.prototype.isNeutered = function () {
8350 return !(this.keyPair.d)
8351}
8352
8353HDNode.prototype.derivePath = function (path) {
8354 typeforce(types.BIP32Path, path)
8355
8356 var splitPath = path.split('/')
8357 if (splitPath[0] === 'm') {
8358 if (this.parentFingerprint) {
8359 throw new Error('Not a master node')
8360 }
8361
8362 splitPath = splitPath.slice(1)
8363 }
8364
8365 return splitPath.reduce(function (prevHd, indexStr) {
8366 var index
8367 if (indexStr.slice(-1) === "'") {
8368 index = parseInt(indexStr.slice(0, -1), 10)
8369 return prevHd.deriveHardened(index)
8370 } else {
8371 index = parseInt(indexStr, 10)
8372 return prevHd.derive(index)
8373 }
8374 }, this)
8375}
8376
8377module.exports = HDNode
8378
8379},{"./crypto":56,"./ecpair":58,"./networks":62,"./types":89,"bigi":5,"bs58grscheck":12,"create-hmac":16,"ecurve":20,"safe-buffer":38,"typeforce":49}],61:[function(require,module,exports){
8380var script = require('./script')
8381
8382var templates = require('./templates')
8383for (var key in templates) {
8384 script[key] = templates[key]
8385}
8386
8387module.exports = {
8388 bufferutils: require('./bufferutils'), // TODO: remove in 4.0.0
8389
8390 Block: require('./block'),
8391 ECPair: require('./ecpair'),
8392 ECSignature: require('./ecsignature'),
8393 HDNode: require('./hdnode'),
8394 Transaction: require('./transaction'),
8395 TransactionBuilder: require('./transaction_builder'),
8396
8397 address: require('./address'),
8398 crypto: require('./crypto'),
8399 networks: require('./networks'),
8400 opcodes: require('bitcoin-ops'),
8401 script: script
8402}
8403
8404},{"./address":53,"./block":54,"./bufferutils":55,"./crypto":56,"./ecpair":58,"./ecsignature":59,"./hdnode":60,"./networks":62,"./script":63,"./templates":65,"./transaction":87,"./transaction_builder":88,"bitcoin-ops":8}],62:[function(require,module,exports){
8405// https://en.bitcoin.it/wiki/List_of_address_prefixes
8406// Dogecoin BIP32 is a proposed standard: https://bitcointalk.org/index.php?topic=409731
8407
8408module.exports = {
8409 bitcoin: {
8410 messagePrefix: '\x1cGroestlCoin Signed Message:\n',
8411 bech32: 'grs',
8412 bip32: {
8413 public: 0x0488b21e,
8414 private: 0x0488ade4
8415 },
8416 pubKeyHash: 0x24,
8417 scriptHash: 0x05,
8418 wif: 0x80
8419 },
8420 testnet: {
8421 messagePrefix: '\x1cGroestlCoin Signed Message:\n',
8422 bech32: 'tgrs',
8423 bip32: {
8424 public: 0x043587cf,
8425 private: 0x04358394
8426 },
8427 pubKeyHash: 0x6f,
8428 scriptHash: 0xc4,
8429 wif: 0xef
8430 },
8431 litecoin: {
8432 messagePrefix: '\x19Litecoin Signed Message:\n',
8433 bip32: {
8434 public: 0x019da462,
8435 private: 0x019d9cfe
8436 },
8437 pubKeyHash: 0x30,
8438 scriptHash: 0x32,
8439 wif: 0xb0
8440 }
8441}
8442
8443},{}],63:[function(require,module,exports){
8444var Buffer = require('safe-buffer').Buffer
8445var bip66 = require('bip66')
8446var pushdata = require('pushdata-bitcoin')
8447var typeforce = require('typeforce')
8448var types = require('./types')
8449var scriptNumber = require('./script_number')
8450
8451var OPS = require('bitcoin-ops')
8452var REVERSE_OPS = require('bitcoin-ops/map')
8453var OP_INT_BASE = OPS.OP_RESERVED // OP_1 - 1
8454
8455function isOPInt (value) {
8456 return types.Number(value) &&
8457 ((value === OPS.OP_0) ||
8458 (value >= OPS.OP_1 && value <= OPS.OP_16) ||
8459 (value === OPS.OP_1NEGATE))
8460}
8461
8462function isPushOnlyChunk (value) {
8463 return types.Buffer(value) || isOPInt(value)
8464}
8465
8466function isPushOnly (value) {
8467 return types.Array(value) && value.every(isPushOnlyChunk)
8468}
8469
8470function asMinimalOP (buffer) {
8471 if (buffer.length === 0) return OPS.OP_0
8472 if (buffer.length !== 1) return
8473 if (buffer[0] >= 1 && buffer[0] <= 16) return OP_INT_BASE + buffer[0]
8474 if (buffer[0] === 0x81) return OPS.OP_1NEGATE
8475}
8476
8477function compile (chunks) {
8478 // TODO: remove me
8479 if (Buffer.isBuffer(chunks)) return chunks
8480
8481 typeforce(types.Array, chunks)
8482
8483 var bufferSize = chunks.reduce(function (accum, chunk) {
8484 // data chunk
8485 if (Buffer.isBuffer(chunk)) {
8486 // adhere to BIP62.3, minimal push policy
8487 if (chunk.length === 1 && asMinimalOP(chunk) !== undefined) {
8488 return accum + 1
8489 }
8490
8491 return accum + pushdata.encodingLength(chunk.length) + chunk.length
8492 }
8493
8494 // opcode
8495 return accum + 1
8496 }, 0.0)
8497
8498 var buffer = Buffer.allocUnsafe(bufferSize)
8499 var offset = 0
8500
8501 chunks.forEach(function (chunk) {
8502 // data chunk
8503 if (Buffer.isBuffer(chunk)) {
8504 // adhere to BIP62.3, minimal push policy
8505 var opcode = asMinimalOP(chunk)
8506 if (opcode !== undefined) {
8507 buffer.writeUInt8(opcode, offset)
8508 offset += 1
8509 return
8510 }
8511
8512 offset += pushdata.encode(buffer, chunk.length, offset)
8513 chunk.copy(buffer, offset)
8514 offset += chunk.length
8515
8516 // opcode
8517 } else {
8518 buffer.writeUInt8(chunk, offset)
8519 offset += 1
8520 }
8521 })
8522
8523 if (offset !== buffer.length) throw new Error('Could not decode chunks')
8524 return buffer
8525}
8526
8527function decompile (buffer) {
8528 // TODO: remove me
8529 if (types.Array(buffer)) return buffer
8530
8531 typeforce(types.Buffer, buffer)
8532
8533 var chunks = []
8534 var i = 0
8535
8536 while (i < buffer.length) {
8537 var opcode = buffer[i]
8538
8539 // data chunk
8540 if ((opcode > OPS.OP_0) && (opcode <= OPS.OP_PUSHDATA4)) {
8541 var d = pushdata.decode(buffer, i)
8542
8543 // did reading a pushDataInt fail? empty script
8544 if (d === null) return []
8545 i += d.size
8546
8547 // attempt to read too much data? empty script
8548 if (i + d.number > buffer.length) return []
8549
8550 var data = buffer.slice(i, i + d.number)
8551 i += d.number
8552
8553 // decompile minimally
8554 var op = asMinimalOP(data)
8555 if (op !== undefined) {
8556 chunks.push(op)
8557 } else {
8558 chunks.push(data)
8559 }
8560
8561 // opcode
8562 } else {
8563 chunks.push(opcode)
8564
8565 i += 1
8566 }
8567 }
8568
8569 return chunks
8570}
8571
8572function toASM (chunks) {
8573 if (Buffer.isBuffer(chunks)) {
8574 chunks = decompile(chunks)
8575 }
8576
8577 return chunks.map(function (chunk) {
8578 // data?
8579 if (Buffer.isBuffer(chunk)) {
8580 var op = asMinimalOP(chunk)
8581 if (op === undefined) return chunk.toString('hex')
8582 chunk = op
8583 }
8584
8585 // opcode!
8586 return REVERSE_OPS[chunk]
8587 }).join(' ')
8588}
8589
8590function fromASM (asm) {
8591 typeforce(types.String, asm)
8592
8593 return compile(asm.split(' ').map(function (chunkStr) {
8594 // opcode?
8595 if (OPS[chunkStr] !== undefined) return OPS[chunkStr]
8596 typeforce(types.Hex, chunkStr)
8597
8598 // data!
8599 return Buffer.from(chunkStr, 'hex')
8600 }))
8601}
8602
8603function toStack (chunks) {
8604 chunks = decompile(chunks)
8605 typeforce(isPushOnly, chunks)
8606
8607 return chunks.map(function (op) {
8608 if (Buffer.isBuffer(op)) return op
8609 if (op === OPS.OP_0) return Buffer.allocUnsafe(0)
8610
8611 return scriptNumber.encode(op - OP_INT_BASE)
8612 })
8613}
8614
8615function isCanonicalPubKey (buffer) {
8616 if (!Buffer.isBuffer(buffer)) return false
8617 if (buffer.length < 33) return false
8618
8619 switch (buffer[0]) {
8620 case 0x02:
8621 case 0x03:
8622 return buffer.length === 33
8623 case 0x04:
8624 return buffer.length === 65
8625 }
8626
8627 return false
8628}
8629
8630function isDefinedHashType (hashType) {
8631 var hashTypeMod = hashType & ~0x80
8632
8633// return hashTypeMod > SIGHASH_ALL && hashTypeMod < SIGHASH_SINGLE
8634 return hashTypeMod > 0x00 && hashTypeMod < 0x04
8635}
8636
8637function isCanonicalSignature (buffer) {
8638 if (!Buffer.isBuffer(buffer)) return false
8639 if (!isDefinedHashType(buffer[buffer.length - 1])) return false
8640
8641 return bip66.check(buffer.slice(0, -1))
8642}
8643
8644module.exports = {
8645 compile: compile,
8646 decompile: decompile,
8647 fromASM: fromASM,
8648 toASM: toASM,
8649 toStack: toStack,
8650
8651 number: require('./script_number'),
8652
8653 isCanonicalPubKey: isCanonicalPubKey,
8654 isCanonicalSignature: isCanonicalSignature,
8655 isPushOnly: isPushOnly,
8656 isDefinedHashType: isDefinedHashType
8657}
8658
8659},{"./script_number":64,"./types":89,"bip66":7,"bitcoin-ops":8,"bitcoin-ops/map":9,"pushdata-bitcoin":35,"safe-buffer":38,"typeforce":49}],64:[function(require,module,exports){
8660var Buffer = require('safe-buffer').Buffer
8661
8662function decode (buffer, maxLength, minimal) {
8663 maxLength = maxLength || 4
8664 minimal = minimal === undefined ? true : minimal
8665
8666 var length = buffer.length
8667 if (length === 0) return 0
8668 if (length > maxLength) throw new TypeError('Script number overflow')
8669 if (minimal) {
8670 if ((buffer[length - 1] & 0x7f) === 0) {
8671 if (length <= 1 || (buffer[length - 2] & 0x80) === 0) throw new Error('Non-minimally encoded script number')
8672 }
8673 }
8674
8675 // 40-bit
8676 if (length === 5) {
8677 var a = buffer.readUInt32LE(0)
8678 var b = buffer.readUInt8(4)
8679
8680 if (b & 0x80) return -(((b & ~0x80) * 0x100000000) + a)
8681 return (b * 0x100000000) + a
8682 }
8683
8684 var result = 0
8685
8686 // 32-bit / 24-bit / 16-bit / 8-bit
8687 for (var i = 0; i < length; ++i) {
8688 result |= buffer[i] << (8 * i)
8689 }
8690
8691 if (buffer[length - 1] & 0x80) return -(result & ~(0x80 << (8 * (length - 1))))
8692 return result
8693}
8694
8695function scriptNumSize (i) {
8696 return i > 0x7fffffff ? 5
8697 : i > 0x7fffff ? 4
8698 : i > 0x7fff ? 3
8699 : i > 0x7f ? 2
8700 : i > 0x00 ? 1
8701 : 0
8702}
8703
8704function encode (number) {
8705 var value = Math.abs(number)
8706 var size = scriptNumSize(value)
8707 var buffer = Buffer.allocUnsafe(size)
8708 var negative = number < 0
8709
8710 for (var i = 0; i < size; ++i) {
8711 buffer.writeUInt8(value & 0xff, i)
8712 value >>= 8
8713 }
8714
8715 if (buffer[size - 1] & 0x80) {
8716 buffer.writeUInt8(negative ? 0x80 : 0x00, size - 1)
8717 } else if (negative) {
8718 buffer[size - 1] |= 0x80
8719 }
8720
8721 return buffer
8722}
8723
8724module.exports = {
8725 decode: decode,
8726 encode: encode
8727}
8728
8729},{"safe-buffer":38}],65:[function(require,module,exports){
8730var decompile = require('../script').decompile
8731var multisig = require('./multisig')
8732var nullData = require('./nulldata')
8733var pubKey = require('./pubkey')
8734var pubKeyHash = require('./pubkeyhash')
8735var scriptHash = require('./scripthash')
8736var witnessPubKeyHash = require('./witnesspubkeyhash')
8737var witnessScriptHash = require('./witnessscripthash')
8738var witnessCommitment = require('./witnesscommitment')
8739
8740var types = {
8741 MULTISIG: 'multisig',
8742 NONSTANDARD: 'nonstandard',
8743 NULLDATA: 'nulldata',
8744 P2PK: 'pubkey',
8745 P2PKH: 'pubkeyhash',
8746 P2SH: 'scripthash',
8747 P2WPKH: 'witnesspubkeyhash',
8748 P2WSH: 'witnessscripthash',
8749 WITNESS_COMMITMENT: 'witnesscommitment'
8750}
8751
8752function classifyOutput (script) {
8753 if (witnessPubKeyHash.output.check(script)) return types.P2WPKH
8754 if (witnessScriptHash.output.check(script)) return types.P2WSH
8755 if (pubKeyHash.output.check(script)) return types.P2PKH
8756 if (scriptHash.output.check(script)) return types.P2SH
8757
8758 // XXX: optimization, below functions .decompile before use
8759 var chunks = decompile(script)
8760 if (multisig.output.check(chunks)) return types.MULTISIG
8761 if (pubKey.output.check(chunks)) return types.P2PK
8762 if (witnessCommitment.output.check(chunks)) return types.WITNESS_COMMITMENT
8763 if (nullData.output.check(chunks)) return types.NULLDATA
8764
8765 return types.NONSTANDARD
8766}
8767
8768function classifyInput (script, allowIncomplete) {
8769 // XXX: optimization, below functions .decompile before use
8770 var chunks = decompile(script)
8771
8772 if (pubKeyHash.input.check(chunks)) return types.P2PKH
8773 if (scriptHash.input.check(chunks, allowIncomplete)) return types.P2SH
8774 if (multisig.input.check(chunks, allowIncomplete)) return types.MULTISIG
8775 if (pubKey.input.check(chunks)) return types.P2PK
8776
8777 return types.NONSTANDARD
8778}
8779
8780function classifyWitness (script, allowIncomplete) {
8781 // XXX: optimization, below functions .decompile before use
8782 var chunks = decompile(script)
8783
8784 if (witnessPubKeyHash.input.check(chunks)) return types.P2WPKH
8785 if (witnessScriptHash.input.check(chunks, allowIncomplete)) return types.P2WSH
8786
8787 return types.NONSTANDARD
8788}
8789
8790module.exports = {
8791 classifyInput: classifyInput,
8792 classifyOutput: classifyOutput,
8793 classifyWitness: classifyWitness,
8794 multisig: multisig,
8795 nullData: nullData,
8796 pubKey: pubKey,
8797 pubKeyHash: pubKeyHash,
8798 scriptHash: scriptHash,
8799 witnessPubKeyHash: witnessPubKeyHash,
8800 witnessScriptHash: witnessScriptHash,
8801 witnessCommitment: witnessCommitment,
8802 types: types
8803}
8804
8805},{"../script":63,"./multisig":66,"./nulldata":69,"./pubkey":70,"./pubkeyhash":73,"./scripthash":76,"./witnesscommitment":79,"./witnesspubkeyhash":81,"./witnessscripthash":84}],66:[function(require,module,exports){
8806module.exports = {
8807 input: require('./input'),
8808 output: require('./output')
8809}
8810
8811},{"./input":67,"./output":68}],67:[function(require,module,exports){
8812// OP_0 [signatures ...]
8813
8814var Buffer = require('safe-buffer').Buffer
8815var bscript = require('../../script')
8816var p2mso = require('./output')
8817var typeforce = require('typeforce')
8818var OPS = require('bitcoin-ops')
8819
8820function partialSignature (value) {
8821 return value === OPS.OP_0 || bscript.isCanonicalSignature(value)
8822}
8823
8824function check (script, allowIncomplete) {
8825 var chunks = bscript.decompile(script)
8826 if (chunks.length < 2) return false
8827 if (chunks[0] !== OPS.OP_0) return false
8828
8829 if (allowIncomplete) {
8830 return chunks.slice(1).every(partialSignature)
8831 }
8832
8833 return chunks.slice(1).every(bscript.isCanonicalSignature)
8834}
8835check.toJSON = function () { return 'multisig input' }
8836
8837var EMPTY_BUFFER = Buffer.allocUnsafe(0)
8838
8839function encodeStack (signatures, scriptPubKey) {
8840 typeforce([partialSignature], signatures)
8841
8842 if (scriptPubKey) {
8843 var scriptData = p2mso.decode(scriptPubKey)
8844
8845 if (signatures.length < scriptData.m) {
8846 throw new TypeError('Not enough signatures provided')
8847 }
8848
8849 if (signatures.length > scriptData.pubKeys.length) {
8850 throw new TypeError('Too many signatures provided')
8851 }
8852 }
8853
8854 return [].concat(EMPTY_BUFFER, signatures.map(function (sig) {
8855 if (sig === OPS.OP_0) {
8856 return EMPTY_BUFFER
8857 }
8858 return sig
8859 }))
8860}
8861
8862function encode (signatures, scriptPubKey) {
8863 return bscript.compile(encodeStack(signatures, scriptPubKey))
8864}
8865
8866function decodeStack (stack, allowIncomplete) {
8867 typeforce(typeforce.Array, stack)
8868 typeforce(check, stack, allowIncomplete)
8869 return stack.slice(1)
8870}
8871
8872function decode (buffer, allowIncomplete) {
8873 var stack = bscript.decompile(buffer)
8874 return decodeStack(stack, allowIncomplete)
8875}
8876
8877module.exports = {
8878 check: check,
8879 decode: decode,
8880 decodeStack: decodeStack,
8881 encode: encode,
8882 encodeStack: encodeStack
8883}
8884
8885},{"../../script":63,"./output":68,"bitcoin-ops":8,"safe-buffer":38,"typeforce":49}],68:[function(require,module,exports){
8886// m [pubKeys ...] n OP_CHECKMULTISIG
8887
8888var bscript = require('../../script')
8889var types = require('../../types')
8890var typeforce = require('typeforce')
8891var OPS = require('bitcoin-ops')
8892var OP_INT_BASE = OPS.OP_RESERVED // OP_1 - 1
8893
8894function check (script, allowIncomplete) {
8895 var chunks = bscript.decompile(script)
8896
8897 if (chunks.length < 4) return false
8898 if (chunks[chunks.length - 1] !== OPS.OP_CHECKMULTISIG) return false
8899 if (!types.Number(chunks[0])) return false
8900 if (!types.Number(chunks[chunks.length - 2])) return false
8901 var m = chunks[0] - OP_INT_BASE
8902 var n = chunks[chunks.length - 2] - OP_INT_BASE
8903
8904 if (m <= 0) return false
8905 if (n > 16) return false
8906 if (m > n) return false
8907 if (n !== chunks.length - 3) return false
8908 if (allowIncomplete) return true
8909
8910 var keys = chunks.slice(1, -2)
8911 return keys.every(bscript.isCanonicalPubKey)
8912}
8913check.toJSON = function () { return 'multi-sig output' }
8914
8915function encode (m, pubKeys) {
8916 typeforce({
8917 m: types.Number,
8918 pubKeys: [bscript.isCanonicalPubKey]
8919 }, {
8920 m: m,
8921 pubKeys: pubKeys
8922 })
8923
8924 var n = pubKeys.length
8925 if (n < m) throw new TypeError('Not enough pubKeys provided')
8926
8927 return bscript.compile([].concat(
8928 OP_INT_BASE + m,
8929 pubKeys,
8930 OP_INT_BASE + n,
8931 OPS.OP_CHECKMULTISIG
8932 ))
8933}
8934
8935function decode (buffer, allowIncomplete) {
8936 var chunks = bscript.decompile(buffer)
8937 typeforce(check, chunks, allowIncomplete)
8938
8939 return {
8940 m: chunks[0] - OP_INT_BASE,
8941 pubKeys: chunks.slice(1, -2)
8942 }
8943}
8944
8945module.exports = {
8946 check: check,
8947 decode: decode,
8948 encode: encode
8949}
8950
8951},{"../../script":63,"../../types":89,"bitcoin-ops":8,"typeforce":49}],69:[function(require,module,exports){
8952// OP_RETURN {data}
8953
8954var bscript = require('../script')
8955var types = require('../types')
8956var typeforce = require('typeforce')
8957var OPS = require('bitcoin-ops')
8958
8959function check (script) {
8960 var buffer = bscript.compile(script)
8961
8962 return buffer.length > 1 &&
8963 buffer[0] === OPS.OP_RETURN
8964}
8965check.toJSON = function () { return 'null data output' }
8966
8967function encode (data) {
8968 typeforce(types.Buffer, data)
8969
8970 return bscript.compile([OPS.OP_RETURN, data])
8971}
8972
8973function decode (buffer) {
8974 typeforce(check, buffer)
8975
8976 return buffer.slice(2)
8977}
8978
8979module.exports = {
8980 output: {
8981 check: check,
8982 decode: decode,
8983 encode: encode
8984 }
8985}
8986
8987},{"../script":63,"../types":89,"bitcoin-ops":8,"typeforce":49}],70:[function(require,module,exports){
8988arguments[4][66][0].apply(exports,arguments)
8989},{"./input":71,"./output":72,"dup":66}],71:[function(require,module,exports){
8990// {signature}
8991
8992var bscript = require('../../script')
8993var typeforce = require('typeforce')
8994
8995function check (script) {
8996 var chunks = bscript.decompile(script)
8997
8998 return chunks.length === 1 &&
8999 bscript.isCanonicalSignature(chunks[0])
9000}
9001check.toJSON = function () { return 'pubKey input' }
9002
9003function encodeStack (signature) {
9004 typeforce(bscript.isCanonicalSignature, signature)
9005 return [signature]
9006}
9007
9008function encode (signature) {
9009 return bscript.compile(encodeStack(signature))
9010}
9011
9012function decodeStack (stack) {
9013 typeforce(typeforce.Array, stack)
9014 typeforce(check, stack)
9015 return stack[0]
9016}
9017
9018function decode (buffer) {
9019 var stack = bscript.decompile(buffer)
9020 return decodeStack(stack)
9021}
9022
9023module.exports = {
9024 check: check,
9025 decode: decode,
9026 decodeStack: decodeStack,
9027 encode: encode,
9028 encodeStack: encodeStack
9029}
9030
9031},{"../../script":63,"typeforce":49}],72:[function(require,module,exports){
9032// {pubKey} OP_CHECKSIG
9033
9034var bscript = require('../../script')
9035var typeforce = require('typeforce')
9036var OPS = require('bitcoin-ops')
9037
9038function check (script) {
9039 var chunks = bscript.decompile(script)
9040
9041 return chunks.length === 2 &&
9042 bscript.isCanonicalPubKey(chunks[0]) &&
9043 chunks[1] === OPS.OP_CHECKSIG
9044}
9045check.toJSON = function () { return 'pubKey output' }
9046
9047function encode (pubKey) {
9048 typeforce(bscript.isCanonicalPubKey, pubKey)
9049
9050 return bscript.compile([pubKey, OPS.OP_CHECKSIG])
9051}
9052
9053function decode (buffer) {
9054 var chunks = bscript.decompile(buffer)
9055 typeforce(check, chunks)
9056
9057 return chunks[0]
9058}
9059
9060module.exports = {
9061 check: check,
9062 decode: decode,
9063 encode: encode
9064}
9065
9066},{"../../script":63,"bitcoin-ops":8,"typeforce":49}],73:[function(require,module,exports){
9067arguments[4][66][0].apply(exports,arguments)
9068},{"./input":74,"./output":75,"dup":66}],74:[function(require,module,exports){
9069// {signature} {pubKey}
9070
9071var bscript = require('../../script')
9072var typeforce = require('typeforce')
9073
9074function check (script) {
9075 var chunks = bscript.decompile(script)
9076
9077 return chunks.length === 2 &&
9078 bscript.isCanonicalSignature(chunks[0]) &&
9079 bscript.isCanonicalPubKey(chunks[1])
9080}
9081check.toJSON = function () { return 'pubKeyHash input' }
9082
9083function encodeStack (signature, pubKey) {
9084 typeforce({
9085 signature: bscript.isCanonicalSignature,
9086 pubKey: bscript.isCanonicalPubKey
9087 }, {
9088 signature: signature,
9089 pubKey: pubKey
9090 })
9091
9092 return [signature, pubKey]
9093}
9094
9095function encode (signature, pubKey) {
9096 return bscript.compile(encodeStack(signature, pubKey))
9097}
9098
9099function decodeStack (stack) {
9100 typeforce(typeforce.Array, stack)
9101 typeforce(check, stack)
9102
9103 return {
9104 signature: stack[0],
9105 pubKey: stack[1]
9106 }
9107}
9108
9109function decode (buffer) {
9110 var stack = bscript.decompile(buffer)
9111 return decodeStack(stack)
9112}
9113
9114module.exports = {
9115 check: check,
9116 decode: decode,
9117 decodeStack: decodeStack,
9118 encode: encode,
9119 encodeStack: encodeStack
9120}
9121
9122},{"../../script":63,"typeforce":49}],75:[function(require,module,exports){
9123// OP_DUP OP_HASH160 {pubKeyHash} OP_EQUALVERIFY OP_CHECKSIG
9124
9125var bscript = require('../../script')
9126var types = require('../../types')
9127var typeforce = require('typeforce')
9128var OPS = require('bitcoin-ops')
9129
9130function check (script) {
9131 var buffer = bscript.compile(script)
9132
9133 return buffer.length === 25 &&
9134 buffer[0] === OPS.OP_DUP &&
9135 buffer[1] === OPS.OP_HASH160 &&
9136 buffer[2] === 0x14 &&
9137 buffer[23] === OPS.OP_EQUALVERIFY &&
9138 buffer[24] === OPS.OP_CHECKSIG
9139}
9140check.toJSON = function () { return 'pubKeyHash output' }
9141
9142function encode (pubKeyHash) {
9143 typeforce(types.Hash160bit, pubKeyHash)
9144
9145 return bscript.compile([
9146 OPS.OP_DUP,
9147 OPS.OP_HASH160,
9148 pubKeyHash,
9149 OPS.OP_EQUALVERIFY,
9150 OPS.OP_CHECKSIG
9151 ])
9152}
9153
9154function decode (buffer) {
9155 typeforce(check, buffer)
9156
9157 return buffer.slice(3, 23)
9158}
9159
9160module.exports = {
9161 check: check,
9162 decode: decode,
9163 encode: encode
9164}
9165
9166},{"../../script":63,"../../types":89,"bitcoin-ops":8,"typeforce":49}],76:[function(require,module,exports){
9167arguments[4][66][0].apply(exports,arguments)
9168},{"./input":77,"./output":78,"dup":66}],77:[function(require,module,exports){
9169// <scriptSig> {serialized scriptPubKey script}
9170
9171var Buffer = require('safe-buffer').Buffer
9172var bscript = require('../../script')
9173var typeforce = require('typeforce')
9174
9175var p2ms = require('../multisig/')
9176var p2pk = require('../pubkey/')
9177var p2pkh = require('../pubkeyhash/')
9178var p2wpkho = require('../witnesspubkeyhash/output')
9179var p2wsho = require('../witnessscripthash/output')
9180
9181function check (script, allowIncomplete) {
9182 var chunks = bscript.decompile(script)
9183 if (chunks.length < 1) return false
9184
9185 var lastChunk = chunks[chunks.length - 1]
9186 if (!Buffer.isBuffer(lastChunk)) return false
9187
9188 var scriptSigChunks = bscript.decompile(bscript.compile(chunks.slice(0, -1)))
9189 var redeemScriptChunks = bscript.decompile(lastChunk)
9190
9191 // is redeemScript a valid script?
9192 if (redeemScriptChunks.length === 0) return false
9193
9194 // is redeemScriptSig push only?
9195 if (!bscript.isPushOnly(scriptSigChunks)) return false
9196
9197 // is witness?
9198 if (chunks.length === 1) {
9199 return p2wsho.check(redeemScriptChunks) ||
9200 p2wpkho.check(redeemScriptChunks)
9201 }
9202
9203 // match types
9204 if (p2pkh.input.check(scriptSigChunks) &&
9205 p2pkh.output.check(redeemScriptChunks)) return true
9206
9207 if (p2ms.input.check(scriptSigChunks, allowIncomplete) &&
9208 p2ms.output.check(redeemScriptChunks)) return true
9209
9210 if (p2pk.input.check(scriptSigChunks) &&
9211 p2pk.output.check(redeemScriptChunks)) return true
9212
9213 return false
9214}
9215check.toJSON = function () { return 'scriptHash input' }
9216
9217function encodeStack (redeemScriptStack, redeemScript) {
9218 var serializedScriptPubKey = bscript.compile(redeemScript)
9219
9220 return [].concat(redeemScriptStack, serializedScriptPubKey)
9221}
9222
9223function encode (redeemScriptSig, redeemScript) {
9224 var redeemScriptStack = bscript.decompile(redeemScriptSig)
9225
9226 return bscript.compile(encodeStack(redeemScriptStack, redeemScript))
9227}
9228
9229function decodeStack (stack) {
9230 typeforce(typeforce.Array, stack)
9231 typeforce(check, stack)
9232
9233 return {
9234 redeemScriptStack: stack.slice(0, -1),
9235 redeemScript: stack[stack.length - 1]
9236 }
9237}
9238
9239function decode (buffer) {
9240 var stack = bscript.decompile(buffer)
9241 var result = decodeStack(stack)
9242 result.redeemScriptSig = bscript.compile(result.redeemScriptStack)
9243 delete result.redeemScriptStack
9244 return result
9245}
9246
9247module.exports = {
9248 check: check,
9249 decode: decode,
9250 decodeStack: decodeStack,
9251 encode: encode,
9252 encodeStack: encodeStack
9253}
9254
9255},{"../../script":63,"../multisig/":66,"../pubkey/":70,"../pubkeyhash/":73,"../witnesspubkeyhash/output":83,"../witnessscripthash/output":86,"safe-buffer":38,"typeforce":49}],78:[function(require,module,exports){
9256// OP_HASH160 {scriptHash} OP_EQUAL
9257
9258var bscript = require('../../script')
9259var types = require('../../types')
9260var typeforce = require('typeforce')
9261var OPS = require('bitcoin-ops')
9262
9263function check (script) {
9264 var buffer = bscript.compile(script)
9265
9266 return buffer.length === 23 &&
9267 buffer[0] === OPS.OP_HASH160 &&
9268 buffer[1] === 0x14 &&
9269 buffer[22] === OPS.OP_EQUAL
9270}
9271check.toJSON = function () { return 'scriptHash output' }
9272
9273function encode (scriptHash) {
9274 typeforce(types.Hash160bit, scriptHash)
9275
9276 return bscript.compile([OPS.OP_HASH160, scriptHash, OPS.OP_EQUAL])
9277}
9278
9279function decode (buffer) {
9280 typeforce(check, buffer)
9281
9282 return buffer.slice(2, 22)
9283}
9284
9285module.exports = {
9286 check: check,
9287 decode: decode,
9288 encode: encode
9289}
9290
9291},{"../../script":63,"../../types":89,"bitcoin-ops":8,"typeforce":49}],79:[function(require,module,exports){
9292module.exports = {
9293 output: require('./output')
9294}
9295
9296},{"./output":80}],80:[function(require,module,exports){
9297// OP_RETURN {aa21a9ed} {commitment}
9298
9299var Buffer = require('safe-buffer').Buffer
9300var bscript = require('../../script')
9301var types = require('../../types')
9302var typeforce = require('typeforce')
9303var OPS = require('bitcoin-ops')
9304
9305var HEADER = Buffer.from('aa21a9ed', 'hex')
9306
9307function check (script) {
9308 var buffer = bscript.compile(script)
9309
9310 return buffer.length > 37 &&
9311 buffer[0] === OPS.OP_RETURN &&
9312 buffer[1] === 0x24 &&
9313 buffer.slice(2, 6).equals(HEADER)
9314}
9315
9316check.toJSON = function () { return 'Witness commitment output' }
9317
9318function encode (commitment) {
9319 typeforce(types.Hash256bit, commitment)
9320
9321 var buffer = Buffer.allocUnsafe(36)
9322 HEADER.copy(buffer, 0)
9323 commitment.copy(buffer, 4)
9324
9325 return bscript.compile([OPS.OP_RETURN, buffer])
9326}
9327
9328function decode (buffer) {
9329 typeforce(check, buffer)
9330
9331 return bscript.decompile(buffer)[1].slice(4, 36)
9332}
9333
9334module.exports = {
9335 check: check,
9336 decode: decode,
9337 encode: encode
9338}
9339
9340},{"../../script":63,"../../types":89,"bitcoin-ops":8,"safe-buffer":38,"typeforce":49}],81:[function(require,module,exports){
9341arguments[4][66][0].apply(exports,arguments)
9342},{"./input":82,"./output":83,"dup":66}],82:[function(require,module,exports){
9343// {signature} {pubKey}
9344
9345var bscript = require('../../script')
9346var typeforce = require('typeforce')
9347
9348function isCompressedCanonicalPubKey (pubKey) {
9349 return bscript.isCanonicalPubKey(pubKey) && pubKey.length === 33
9350}
9351
9352function check (script) {
9353 var chunks = bscript.decompile(script)
9354
9355 return chunks.length === 2 &&
9356 bscript.isCanonicalSignature(chunks[0]) &&
9357 isCompressedCanonicalPubKey(chunks[1])
9358}
9359check.toJSON = function () { return 'witnessPubKeyHash input' }
9360
9361function encodeStack (signature, pubKey) {
9362 typeforce({
9363 signature: bscript.isCanonicalSignature,
9364 pubKey: isCompressedCanonicalPubKey
9365 }, {
9366 signature: signature,
9367 pubKey: pubKey
9368 })
9369
9370 return [signature, pubKey]
9371}
9372
9373function decodeStack (stack) {
9374 typeforce(typeforce.Array, stack)
9375 typeforce(check, stack)
9376
9377 return {
9378 signature: stack[0],
9379 pubKey: stack[1]
9380 }
9381}
9382
9383module.exports = {
9384 check: check,
9385 decodeStack: decodeStack,
9386 encodeStack: encodeStack
9387}
9388
9389},{"../../script":63,"typeforce":49}],83:[function(require,module,exports){
9390// OP_0 {pubKeyHash}
9391
9392var bscript = require('../../script')
9393var types = require('../../types')
9394var typeforce = require('typeforce')
9395var OPS = require('bitcoin-ops')
9396
9397function check (script) {
9398 var buffer = bscript.compile(script)
9399
9400 return buffer.length === 22 &&
9401 buffer[0] === OPS.OP_0 &&
9402 buffer[1] === 0x14
9403}
9404check.toJSON = function () { return 'Witness pubKeyHash output' }
9405
9406function encode (pubKeyHash) {
9407 typeforce(types.Hash160bit, pubKeyHash)
9408
9409 return bscript.compile([OPS.OP_0, pubKeyHash])
9410}
9411
9412function decode (buffer) {
9413 typeforce(check, buffer)
9414
9415 return buffer.slice(2)
9416}
9417
9418module.exports = {
9419 check: check,
9420 decode: decode,
9421 encode: encode
9422}
9423
9424},{"../../script":63,"../../types":89,"bitcoin-ops":8,"typeforce":49}],84:[function(require,module,exports){
9425arguments[4][66][0].apply(exports,arguments)
9426},{"./input":85,"./output":86,"dup":66}],85:[function(require,module,exports){
9427(function (Buffer){
9428// <scriptSig> {serialized scriptPubKey script}
9429
9430var bscript = require('../../script')
9431var types = require('../../types')
9432var typeforce = require('typeforce')
9433
9434var p2ms = require('../multisig/')
9435var p2pk = require('../pubkey/')
9436var p2pkh = require('../pubkeyhash/')
9437
9438function check (chunks, allowIncomplete) {
9439 typeforce(types.Array, chunks)
9440 if (chunks.length < 1) return false
9441
9442 var witnessScript = chunks[chunks.length - 1]
9443 if (!Buffer.isBuffer(witnessScript)) return false
9444
9445 var witnessScriptChunks = bscript.decompile(witnessScript)
9446
9447 // is witnessScript a valid script?
9448 if (witnessScriptChunks.length === 0) return false
9449
9450 var witnessRawScriptSig = bscript.compile(chunks.slice(0, -1))
9451
9452 // match types
9453 if (p2pkh.input.check(witnessRawScriptSig) &&
9454 p2pkh.output.check(witnessScriptChunks)) return true
9455
9456 if (p2ms.input.check(witnessRawScriptSig, allowIncomplete) &&
9457 p2ms.output.check(witnessScriptChunks)) return true
9458
9459 if (p2pk.input.check(witnessRawScriptSig) &&
9460 p2pk.output.check(witnessScriptChunks)) return true
9461
9462 return false
9463}
9464check.toJSON = function () { return 'witnessScriptHash input' }
9465
9466function encodeStack (witnessData, witnessScript) {
9467 typeforce({
9468 witnessData: [types.Buffer],
9469 witnessScript: types.Buffer
9470 }, {
9471 witnessData: witnessData,
9472 witnessScript: witnessScript
9473 })
9474
9475 return [].concat(witnessData, witnessScript)
9476}
9477
9478function decodeStack (stack) {
9479 typeforce(typeforce.Array, stack)
9480 typeforce(check, stack)
9481 return {
9482 witnessData: stack.slice(0, -1),
9483 witnessScript: stack[stack.length - 1]
9484 }
9485}
9486
9487module.exports = {
9488 check: check,
9489 decodeStack: decodeStack,
9490 encodeStack: encodeStack
9491}
9492
9493}).call(this,{"isBuffer":require("../../../../../../../usr/local/lib/node_modules/browserify/node_modules/is-buffer/index.js")})
9494},{"../../../../../../../usr/local/lib/node_modules/browserify/node_modules/is-buffer/index.js":101,"../../script":63,"../../types":89,"../multisig/":66,"../pubkey/":70,"../pubkeyhash/":73,"typeforce":49}],86:[function(require,module,exports){
9495// OP_0 {scriptHash}
9496
9497var bscript = require('../../script')
9498var types = require('../../types')
9499var typeforce = require('typeforce')
9500var OPS = require('bitcoin-ops')
9501
9502function check (script) {
9503 var buffer = bscript.compile(script)
9504
9505 return buffer.length === 34 &&
9506 buffer[0] === OPS.OP_0 &&
9507 buffer[1] === 0x20
9508}
9509check.toJSON = function () { return 'Witness scriptHash output' }
9510
9511function encode (scriptHash) {
9512 typeforce(types.Hash256bit, scriptHash)
9513
9514 return bscript.compile([OPS.OP_0, scriptHash])
9515}
9516
9517function decode (buffer) {
9518 typeforce(check, buffer)
9519
9520 return buffer.slice(2)
9521}
9522
9523module.exports = {
9524 check: check,
9525 decode: decode,
9526 encode: encode
9527}
9528
9529},{"../../script":63,"../../types":89,"bitcoin-ops":8,"typeforce":49}],87:[function(require,module,exports){
9530var Buffer = require('safe-buffer').Buffer
9531var bcrypto = require('./crypto')
9532var bscript = require('./script')
9533var bufferutils = require('./bufferutils')
9534var opcodes = require('bitcoin-ops')
9535var typeforce = require('typeforce')
9536var types = require('./types')
9537var varuint = require('varuint-bitcoin')
9538
9539function varSliceSize (someScript) {
9540 var length = someScript.length
9541
9542 return varuint.encodingLength(length) + length
9543}
9544
9545function vectorSize (someVector) {
9546 var length = someVector.length
9547
9548 return varuint.encodingLength(length) + someVector.reduce(function (sum, witness) {
9549 return sum + varSliceSize(witness)
9550 }, 0)
9551}
9552
9553function Transaction () {
9554 this.version = 1
9555 this.locktime = 0
9556 this.ins = []
9557 this.outs = []
9558}
9559
9560Transaction.DEFAULT_SEQUENCE = 0xffffffff
9561Transaction.SIGHASH_ALL = 0x01
9562Transaction.SIGHASH_NONE = 0x02
9563Transaction.SIGHASH_SINGLE = 0x03
9564Transaction.SIGHASH_ANYONECANPAY = 0x80
9565Transaction.ADVANCED_TRANSACTION_MARKER = 0x00
9566Transaction.ADVANCED_TRANSACTION_FLAG = 0x01
9567
9568var EMPTY_SCRIPT = Buffer.allocUnsafe(0)
9569var EMPTY_WITNESS = []
9570var ZERO = Buffer.from('0000000000000000000000000000000000000000000000000000000000000000', 'hex')
9571var ONE = Buffer.from('0000000000000000000000000000000000000000000000000000000000000001', 'hex')
9572var VALUE_UINT64_MAX = Buffer.from('ffffffffffffffff', 'hex')
9573var BLANK_OUTPUT = {
9574 script: EMPTY_SCRIPT,
9575 valueBuffer: VALUE_UINT64_MAX
9576}
9577
9578Transaction.fromBuffer = function (buffer, __noStrict) {
9579 var offset = 0
9580 function readSlice (n) {
9581 offset += n
9582 return buffer.slice(offset - n, offset)
9583 }
9584
9585 function readUInt32 () {
9586 var i = buffer.readUInt32LE(offset)
9587 offset += 4
9588 return i
9589 }
9590
9591 function readInt32 () {
9592 var i = buffer.readInt32LE(offset)
9593 offset += 4
9594 return i
9595 }
9596
9597 function readUInt64 () {
9598 var i = bufferutils.readUInt64LE(buffer, offset)
9599 offset += 8
9600 return i
9601 }
9602
9603 function readVarInt () {
9604 var vi = varuint.decode(buffer, offset)
9605 offset += varuint.decode.bytes
9606 return vi
9607 }
9608
9609 function readVarSlice () {
9610 return readSlice(readVarInt())
9611 }
9612
9613 function readVector () {
9614 var count = readVarInt()
9615 var vector = []
9616 for (var i = 0; i < count; i++) vector.push(readVarSlice())
9617 return vector
9618 }
9619
9620 var tx = new Transaction()
9621 tx.version = readInt32()
9622
9623 var marker = buffer.readUInt8(offset)
9624 var flag = buffer.readUInt8(offset + 1)
9625
9626 var hasWitnesses = false
9627 if (marker === Transaction.ADVANCED_TRANSACTION_MARKER &&
9628 flag === Transaction.ADVANCED_TRANSACTION_FLAG) {
9629 offset += 2
9630 hasWitnesses = true
9631 }
9632
9633 var vinLen = readVarInt()
9634 for (var i = 0; i < vinLen; ++i) {
9635 tx.ins.push({
9636 hash: readSlice(32),
9637 index: readUInt32(),
9638 script: readVarSlice(),
9639 sequence: readUInt32(),
9640 witness: EMPTY_WITNESS
9641 })
9642 }
9643
9644 var voutLen = readVarInt()
9645 for (i = 0; i < voutLen; ++i) {
9646 tx.outs.push({
9647 value: readUInt64(),
9648 script: readVarSlice()
9649 })
9650 }
9651
9652 if (hasWitnesses) {
9653 for (i = 0; i < vinLen; ++i) {
9654 tx.ins[i].witness = readVector()
9655 }
9656
9657 // was this pointless?
9658 if (!tx.hasWitnesses()) throw new Error('Transaction has superfluous witness data')
9659 }
9660
9661 tx.locktime = readUInt32()
9662
9663 if (__noStrict) return tx
9664 if (offset !== buffer.length) throw new Error('Transaction has unexpected data')
9665
9666 return tx
9667}
9668
9669Transaction.fromHex = function (hex) {
9670 return Transaction.fromBuffer(Buffer.from(hex, 'hex'))
9671}
9672
9673Transaction.isCoinbaseHash = function (buffer) {
9674 typeforce(types.Hash256bit, buffer)
9675 for (var i = 0; i < 32; ++i) {
9676 if (buffer[i] !== 0) return false
9677 }
9678 return true
9679}
9680
9681Transaction.prototype.isCoinbase = function () {
9682 return this.ins.length === 1 && Transaction.isCoinbaseHash(this.ins[0].hash)
9683}
9684
9685Transaction.prototype.addInput = function (hash, index, sequence, scriptSig) {
9686 typeforce(types.tuple(
9687 types.Hash256bit,
9688 types.UInt32,
9689 types.maybe(types.UInt32),
9690 types.maybe(types.Buffer)
9691 ), arguments)
9692
9693 if (types.Null(sequence)) {
9694 sequence = Transaction.DEFAULT_SEQUENCE
9695 }
9696
9697 // Add the input and return the input's index
9698 return (this.ins.push({
9699 hash: hash,
9700 index: index,
9701 script: scriptSig || EMPTY_SCRIPT,
9702 sequence: sequence,
9703 witness: EMPTY_WITNESS
9704 }) - 1)
9705}
9706
9707Transaction.prototype.addOutput = function (scriptPubKey, value) {
9708 typeforce(types.tuple(types.Buffer, types.Satoshi), arguments)
9709
9710 // Add the output and return the output's index
9711 return (this.outs.push({
9712 script: scriptPubKey,
9713 value: value
9714 }) - 1)
9715}
9716
9717Transaction.prototype.hasWitnesses = function () {
9718 return this.ins.some(function (x) {
9719 return x.witness.length !== 0
9720 })
9721}
9722
9723Transaction.prototype.weight = function () {
9724 var base = this.__byteLength(false)
9725 var total = this.__byteLength(true)
9726 return base * 3 + total
9727}
9728
9729Transaction.prototype.virtualSize = function () {
9730 return Math.ceil(this.weight() / 4)
9731}
9732
9733Transaction.prototype.byteLength = function () {
9734 return this.__byteLength(true)
9735}
9736
9737Transaction.prototype.__byteLength = function (__allowWitness) {
9738 var hasWitnesses = __allowWitness && this.hasWitnesses()
9739
9740 return (
9741 (hasWitnesses ? 10 : 8) +
9742 varuint.encodingLength(this.ins.length) +
9743 varuint.encodingLength(this.outs.length) +
9744 this.ins.reduce(function (sum, input) { return sum + 40 + varSliceSize(input.script) }, 0) +
9745 this.outs.reduce(function (sum, output) { return sum + 8 + varSliceSize(output.script) }, 0) +
9746 (hasWitnesses ? this.ins.reduce(function (sum, input) { return sum + vectorSize(input.witness) }, 0) : 0)
9747 )
9748}
9749
9750Transaction.prototype.clone = function () {
9751 var newTx = new Transaction()
9752 newTx.version = this.version
9753 newTx.locktime = this.locktime
9754
9755 newTx.ins = this.ins.map(function (txIn) {
9756 return {
9757 hash: txIn.hash,
9758 index: txIn.index,
9759 script: txIn.script,
9760 sequence: txIn.sequence,
9761 witness: txIn.witness
9762 }
9763 })
9764
9765 newTx.outs = this.outs.map(function (txOut) {
9766 return {
9767 script: txOut.script,
9768 value: txOut.value
9769 }
9770 })
9771
9772 return newTx
9773}
9774
9775/**
9776 * Hash transaction for signing a specific input.
9777 *
9778 * Bitcoin uses a different hash for each signed transaction input.
9779 * This method copies the transaction, makes the necessary changes based on the
9780 * hashType, and then hashes the result.
9781 * This hash can then be used to sign the provided transaction input.
9782 */
9783Transaction.prototype.hashForSignature = function (inIndex, prevOutScript, hashType) {
9784 typeforce(types.tuple(types.UInt32, types.Buffer, /* types.UInt8 */ types.Number), arguments)
9785
9786 // https://github.com/bitcoin/bitcoin/blob/master/src/test/sighash_tests.cpp#L29
9787 if (inIndex >= this.ins.length) return ONE
9788
9789 // ignore OP_CODESEPARATOR
9790 var ourScript = bscript.compile(bscript.decompile(prevOutScript).filter(function (x) {
9791 return x !== opcodes.OP_CODESEPARATOR
9792 }))
9793
9794 var txTmp = this.clone()
9795
9796 // SIGHASH_NONE: ignore all outputs? (wildcard payee)
9797 if ((hashType & 0x1f) === Transaction.SIGHASH_NONE) {
9798 txTmp.outs = []
9799
9800 // ignore sequence numbers (except at inIndex)
9801 txTmp.ins.forEach(function (input, i) {
9802 if (i === inIndex) return
9803
9804 input.sequence = 0
9805 })
9806
9807 // SIGHASH_SINGLE: ignore all outputs, except at the same index?
9808 } else if ((hashType & 0x1f) === Transaction.SIGHASH_SINGLE) {
9809 // https://github.com/bitcoin/bitcoin/blob/master/src/test/sighash_tests.cpp#L60
9810 if (inIndex >= this.outs.length) return ONE
9811
9812 // truncate outputs after
9813 txTmp.outs.length = inIndex + 1
9814
9815 // "blank" outputs before
9816 for (var i = 0; i < inIndex; i++) {
9817 txTmp.outs[i] = BLANK_OUTPUT
9818 }
9819
9820 // ignore sequence numbers (except at inIndex)
9821 txTmp.ins.forEach(function (input, y) {
9822 if (y === inIndex) return
9823
9824 input.sequence = 0
9825 })
9826 }
9827
9828 // SIGHASH_ANYONECANPAY: ignore inputs entirely?
9829 if (hashType & Transaction.SIGHASH_ANYONECANPAY) {
9830 txTmp.ins = [txTmp.ins[inIndex]]
9831 txTmp.ins[0].script = ourScript
9832
9833 // SIGHASH_ALL: only ignore input scripts
9834 } else {
9835 // "blank" others input scripts
9836 txTmp.ins.forEach(function (input) { input.script = EMPTY_SCRIPT })
9837 txTmp.ins[inIndex].script = ourScript
9838 }
9839
9840 // serialize and hash
9841 var buffer = Buffer.allocUnsafe(txTmp.__byteLength(false) + 4)
9842 buffer.writeInt32LE(hashType, buffer.length - 4)
9843 txTmp.__toBuffer(buffer, 0, false)
9844
9845 return bcrypto.sha256(buffer)
9846}
9847
9848Transaction.prototype.hashForWitnessV0 = function (inIndex, prevOutScript, value, hashType) {
9849 typeforce(types.tuple(types.UInt32, types.Buffer, types.Satoshi, types.UInt32), arguments)
9850
9851 var tbuffer, toffset
9852 function writeSlice (slice) { toffset += slice.copy(tbuffer, toffset) }
9853 function writeUInt32 (i) { toffset = tbuffer.writeUInt32LE(i, toffset) }
9854 function writeUInt64 (i) { toffset = bufferutils.writeUInt64LE(tbuffer, i, toffset) }
9855 function writeVarInt (i) {
9856 varuint.encode(i, tbuffer, toffset)
9857 toffset += varuint.encode.bytes
9858 }
9859 function writeVarSlice (slice) { writeVarInt(slice.length); writeSlice(slice) }
9860
9861 var hashOutputs = ZERO
9862 var hashPrevouts = ZERO
9863 var hashSequence = ZERO
9864
9865 if (!(hashType & Transaction.SIGHASH_ANYONECANPAY)) {
9866 tbuffer = Buffer.allocUnsafe(36 * this.ins.length)
9867 toffset = 0
9868
9869 this.ins.forEach(function (txIn) {
9870 writeSlice(txIn.hash)
9871 writeUInt32(txIn.index)
9872 })
9873
9874 hashPrevouts = bcrypto.sha256(tbuffer)
9875 }
9876
9877 if (!(hashType & Transaction.SIGHASH_ANYONECANPAY) &&
9878 (hashType & 0x1f) !== Transaction.SIGHASH_SINGLE &&
9879 (hashType & 0x1f) !== Transaction.SIGHASH_NONE) {
9880 tbuffer = Buffer.allocUnsafe(4 * this.ins.length)
9881 toffset = 0
9882
9883 this.ins.forEach(function (txIn) {
9884 writeUInt32(txIn.sequence)
9885 })
9886
9887 hashSequence = bcrypto.sha256(tbuffer)
9888 }
9889
9890 if ((hashType & 0x1f) !== Transaction.SIGHASH_SINGLE &&
9891 (hashType & 0x1f) !== Transaction.SIGHASH_NONE) {
9892 var txOutsSize = this.outs.reduce(function (sum, output) {
9893 return sum + 8 + varSliceSize(output.script)
9894 }, 0)
9895
9896 tbuffer = Buffer.allocUnsafe(txOutsSize)
9897 toffset = 0
9898
9899 this.outs.forEach(function (out) {
9900 writeUInt64(out.value)
9901 writeVarSlice(out.script)
9902 })
9903
9904 hashOutputs = bcrypto.sha256(tbuffer)
9905 } else if ((hashType & 0x1f) === Transaction.SIGHASH_SINGLE && inIndex < this.outs.length) {
9906 var output = this.outs[inIndex]
9907
9908 tbuffer = Buffer.allocUnsafe(8 + varSliceSize(output.script))
9909 toffset = 0
9910 writeUInt64(output.value)
9911 writeVarSlice(output.script)
9912
9913 hashOutputs = bcrypto.sha256(tbuffer)
9914 }
9915
9916 tbuffer = Buffer.allocUnsafe(156 + varSliceSize(prevOutScript))
9917 toffset = 0
9918
9919 var input = this.ins[inIndex]
9920 writeUInt32(this.version)
9921 writeSlice(hashPrevouts)
9922 writeSlice(hashSequence)
9923 writeSlice(input.hash)
9924 writeUInt32(input.index)
9925 writeVarSlice(prevOutScript)
9926 writeUInt64(value)
9927 writeUInt32(input.sequence)
9928 writeSlice(hashOutputs)
9929 writeUInt32(this.locktime)
9930 writeUInt32(hashType)
9931 return bcrypto.sha256(tbuffer)
9932}
9933
9934Transaction.prototype.getHash = function () {
9935 return bcrypto.sha256(this.__toBuffer(undefined, undefined, false))
9936}
9937
9938Transaction.prototype.getId = function () {
9939 // transaction hash's are displayed in reverse order
9940 return this.getHash().reverse().toString('hex')
9941}
9942
9943Transaction.prototype.toBuffer = function (buffer, initialOffset) {
9944 return this.__toBuffer(buffer, initialOffset, true)
9945}
9946
9947Transaction.prototype.__toBuffer = function (buffer, initialOffset, __allowWitness) {
9948 if (!buffer) buffer = Buffer.allocUnsafe(this.__byteLength(__allowWitness))
9949
9950 var offset = initialOffset || 0
9951 function writeSlice (slice) { offset += slice.copy(buffer, offset) }
9952 function writeUInt8 (i) { offset = buffer.writeUInt8(i, offset) }
9953 function writeUInt32 (i) { offset = buffer.writeUInt32LE(i, offset) }
9954 function writeInt32 (i) { offset = buffer.writeInt32LE(i, offset) }
9955 function writeUInt64 (i) { offset = bufferutils.writeUInt64LE(buffer, i, offset) }
9956 function writeVarInt (i) {
9957 varuint.encode(i, buffer, offset)
9958 offset += varuint.encode.bytes
9959 }
9960 function writeVarSlice (slice) { writeVarInt(slice.length); writeSlice(slice) }
9961 function writeVector (vector) { writeVarInt(vector.length); vector.forEach(writeVarSlice) }
9962
9963 writeInt32(this.version)
9964
9965 var hasWitnesses = __allowWitness && this.hasWitnesses()
9966
9967 if (hasWitnesses) {
9968 writeUInt8(Transaction.ADVANCED_TRANSACTION_MARKER)
9969 writeUInt8(Transaction.ADVANCED_TRANSACTION_FLAG)
9970 }
9971
9972 writeVarInt(this.ins.length)
9973
9974 this.ins.forEach(function (txIn) {
9975 writeSlice(txIn.hash)
9976 writeUInt32(txIn.index)
9977 writeVarSlice(txIn.script)
9978 writeUInt32(txIn.sequence)
9979 })
9980
9981 writeVarInt(this.outs.length)
9982 this.outs.forEach(function (txOut) {
9983 if (!txOut.valueBuffer) {
9984 writeUInt64(txOut.value)
9985 } else {
9986 writeSlice(txOut.valueBuffer)
9987 }
9988
9989 writeVarSlice(txOut.script)
9990 })
9991
9992 if (hasWitnesses) {
9993 this.ins.forEach(function (input) {
9994 writeVector(input.witness)
9995 })
9996 }
9997
9998 writeUInt32(this.locktime)
9999
10000 // avoid slicing unless necessary
10001 if (initialOffset !== undefined) return buffer.slice(initialOffset, offset)
10002 return buffer
10003}
10004
10005Transaction.prototype.toHex = function () {
10006 return this.toBuffer().toString('hex')
10007}
10008
10009Transaction.prototype.setInputScript = function (index, scriptSig) {
10010 typeforce(types.tuple(types.Number, types.Buffer), arguments)
10011
10012 this.ins[index].script = scriptSig
10013}
10014
10015Transaction.prototype.setWitness = function (index, witness) {
10016 typeforce(types.tuple(types.Number, [types.Buffer]), arguments)
10017
10018 this.ins[index].witness = witness
10019}
10020
10021module.exports = Transaction
10022
10023},{"./bufferutils":55,"./crypto":56,"./script":63,"./types":89,"bitcoin-ops":8,"safe-buffer":38,"typeforce":49,"varuint-bitcoin":51}],88:[function(require,module,exports){
10024var Buffer = require('safe-buffer').Buffer
10025var baddress = require('./address')
10026var bcrypto = require('./crypto')
10027var bscript = require('./script')
10028var btemplates = require('./templates')
10029var networks = require('./networks')
10030var ops = require('bitcoin-ops')
10031var typeforce = require('typeforce')
10032var types = require('./types')
10033var scriptTypes = btemplates.types
10034var SIGNABLE = [btemplates.types.P2PKH, btemplates.types.P2PK, btemplates.types.MULTISIG]
10035var P2SH = SIGNABLE.concat([btemplates.types.P2WPKH, btemplates.types.P2WSH])
10036
10037var ECPair = require('./ecpair')
10038var ECSignature = require('./ecsignature')
10039var Transaction = require('./transaction')
10040
10041function supportedType (type) {
10042 return SIGNABLE.indexOf(type) !== -1
10043}
10044
10045function supportedP2SHType (type) {
10046 return P2SH.indexOf(type) !== -1
10047}
10048
10049function extractChunks (type, chunks, script) {
10050 var pubKeys = []
10051 var signatures = []
10052 switch (type) {
10053 case scriptTypes.P2PKH:
10054 // if (redeemScript) throw new Error('Nonstandard... P2SH(P2PKH)')
10055 pubKeys = chunks.slice(1)
10056 signatures = chunks.slice(0, 1)
10057 break
10058
10059 case scriptTypes.P2PK:
10060 pubKeys[0] = script ? btemplates.pubKey.output.decode(script) : undefined
10061 signatures = chunks.slice(0, 1)
10062 break
10063
10064 case scriptTypes.MULTISIG:
10065 if (script) {
10066 var multisig = btemplates.multisig.output.decode(script)
10067 pubKeys = multisig.pubKeys
10068 }
10069
10070 signatures = chunks.slice(1).map(function (chunk) {
10071 return chunk.length === 0 ? undefined : chunk
10072 })
10073 break
10074 }
10075
10076 return {
10077 pubKeys: pubKeys,
10078 signatures: signatures
10079 }
10080}
10081function expandInput (scriptSig, witnessStack) {
10082 if (scriptSig.length === 0 && witnessStack.length === 0) return {}
10083
10084 var prevOutScript
10085 var prevOutType
10086 var scriptType
10087 var script
10088 var redeemScript
10089 var witnessScript
10090 var witnessScriptType
10091 var redeemScriptType
10092 var witness = false
10093 var p2wsh = false
10094 var p2sh = false
10095 var witnessProgram
10096 var chunks
10097
10098 var scriptSigChunks = bscript.decompile(scriptSig)
10099 var sigType = btemplates.classifyInput(scriptSigChunks, true)
10100 if (sigType === scriptTypes.P2SH) {
10101 p2sh = true
10102 redeemScript = scriptSigChunks[scriptSigChunks.length - 1]
10103 redeemScriptType = btemplates.classifyOutput(redeemScript)
10104 prevOutScript = btemplates.scriptHash.output.encode(bcrypto.hash160(redeemScript))
10105 prevOutType = scriptTypes.P2SH
10106 script = redeemScript
10107 }
10108
10109 var classifyWitness = btemplates.classifyWitness(witnessStack, true)
10110 if (classifyWitness === scriptTypes.P2WSH) {
10111 witnessScript = witnessStack[witnessStack.length - 1]
10112 witnessScriptType = btemplates.classifyOutput(witnessScript)
10113 p2wsh = true
10114 witness = true
10115 if (scriptSig.length === 0) {
10116 prevOutScript = btemplates.witnessScriptHash.output.encode(bcrypto.sha256(witnessScript))
10117 prevOutType = scriptTypes.P2WSH
10118 if (redeemScript !== undefined) {
10119 throw new Error('Redeem script given when unnecessary')
10120 }
10121 // bare witness
10122 } else {
10123 if (!redeemScript) {
10124 throw new Error('No redeemScript provided for P2WSH, but scriptSig non-empty')
10125 }
10126 witnessProgram = btemplates.witnessScriptHash.output.encode(bcrypto.sha256(witnessScript))
10127 if (!redeemScript.equals(witnessProgram)) {
10128 throw new Error('Redeem script didn\'t match witnessScript')
10129 }
10130 }
10131
10132 if (!supportedType(btemplates.classifyOutput(witnessScript))) {
10133 throw new Error('unsupported witness script')
10134 }
10135
10136 script = witnessScript
10137 scriptType = witnessScriptType
10138 chunks = witnessStack.slice(0, -1)
10139 } else if (classifyWitness === scriptTypes.P2WPKH) {
10140 witness = true
10141 var key = witnessStack[witnessStack.length - 1]
10142 var keyHash = bcrypto.hash160(key)
10143 if (scriptSig.length === 0) {
10144 prevOutScript = btemplates.witnessPubKeyHash.output.encode(keyHash)
10145 prevOutType = scriptTypes.P2WPKH
10146 if (typeof redeemScript !== 'undefined') {
10147 throw new Error('Redeem script given when unnecessary')
10148 }
10149 } else {
10150 if (!redeemScript) {
10151 throw new Error('No redeemScript provided for P2WPKH, but scriptSig wasn\'t empty')
10152 }
10153 witnessProgram = btemplates.witnessPubKeyHash.output.encode(keyHash)
10154 if (!redeemScript.equals(witnessProgram)) {
10155 throw new Error('Redeem script did not have the right witness program')
10156 }
10157 }
10158
10159 scriptType = scriptTypes.P2PKH
10160 chunks = witnessStack
10161 } else if (redeemScript) {
10162 if (!supportedP2SHType(redeemScriptType)) {
10163 throw new Error('Bad redeemscript!')
10164 }
10165
10166 script = redeemScript
10167 scriptType = redeemScriptType
10168 chunks = scriptSigChunks.slice(0, -1)
10169 } else {
10170 prevOutType = scriptType = btemplates.classifyInput(scriptSig)
10171 chunks = scriptSigChunks
10172 }
10173
10174 var expanded = extractChunks(scriptType, chunks, script)
10175
10176 var result = {
10177 pubKeys: expanded.pubKeys,
10178 signatures: expanded.signatures,
10179 prevOutScript: prevOutScript,
10180 prevOutType: prevOutType,
10181 signType: scriptType,
10182 signScript: script,
10183 witness: Boolean(witness)
10184 }
10185
10186 if (p2sh) {
10187 result.redeemScript = redeemScript
10188 result.redeemScriptType = redeemScriptType
10189 }
10190
10191 if (p2wsh) {
10192 result.witnessScript = witnessScript
10193 result.witnessScriptType = witnessScriptType
10194 }
10195
10196 return result
10197}
10198
10199// could be done in expandInput, but requires the original Transaction for hashForSignature
10200function fixMultisigOrder (input, transaction, vin) {
10201 if (input.redeemScriptType !== scriptTypes.MULTISIG || !input.redeemScript) return
10202 if (input.pubKeys.length === input.signatures.length) return
10203
10204 var unmatched = input.signatures.concat()
10205
10206 input.signatures = input.pubKeys.map(function (pubKey) {
10207 var keyPair = ECPair.fromPublicKeyBuffer(pubKey)
10208 var match
10209
10210 // check for a signature
10211 unmatched.some(function (signature, i) {
10212 // skip if undefined || OP_0
10213 if (!signature) return false
10214
10215 // TODO: avoid O(n) hashForSignature
10216 var parsed = ECSignature.parseScriptSignature(signature)
10217 var hash = transaction.hashForSignature(vin, input.redeemScript, parsed.hashType)
10218
10219 // skip if signature does not match pubKey
10220 if (!keyPair.verify(hash, parsed.signature)) return false
10221
10222 // remove matched signature from unmatched
10223 unmatched[i] = undefined
10224 match = signature
10225
10226 return true
10227 })
10228
10229 return match
10230 })
10231}
10232
10233function expandOutput (script, scriptType, ourPubKey) {
10234 typeforce(types.Buffer, script)
10235
10236 var scriptChunks = bscript.decompile(script)
10237 if (!scriptType) {
10238 scriptType = btemplates.classifyOutput(script)
10239 }
10240
10241 var pubKeys = []
10242
10243 switch (scriptType) {
10244 // does our hash160(pubKey) match the output scripts?
10245 case scriptTypes.P2PKH:
10246 if (!ourPubKey) break
10247
10248 var pkh1 = scriptChunks[2]
10249 var pkh2 = bcrypto.hash160(ourPubKey)
10250 if (pkh1.equals(pkh2)) pubKeys = [ourPubKey]
10251 break
10252
10253 // does our hash160(pubKey) match the output scripts?
10254 case scriptTypes.P2WPKH:
10255 if (!ourPubKey) break
10256
10257 var wpkh1 = scriptChunks[1]
10258 var wpkh2 = bcrypto.hash160(ourPubKey)
10259 if (wpkh1.equals(wpkh2)) pubKeys = [ourPubKey]
10260 break
10261
10262 case scriptTypes.P2PK:
10263 pubKeys = scriptChunks.slice(0, 1)
10264 break
10265
10266 case scriptTypes.MULTISIG:
10267 pubKeys = scriptChunks.slice(1, -2)
10268 break
10269
10270 default: return { scriptType: scriptType }
10271 }
10272
10273 return {
10274 pubKeys: pubKeys,
10275 scriptType: scriptType,
10276 signatures: pubKeys.map(function () { return undefined })
10277 }
10278}
10279
10280function checkP2SHInput (input, redeemScriptHash) {
10281 if (input.prevOutType) {
10282 if (input.prevOutType !== scriptTypes.P2SH) throw new Error('PrevOutScript must be P2SH')
10283
10284 var prevOutScriptScriptHash = bscript.decompile(input.prevOutScript)[1]
10285 if (!prevOutScriptScriptHash.equals(redeemScriptHash)) throw new Error('Inconsistent hash160(RedeemScript)')
10286 }
10287}
10288
10289function checkP2WSHInput (input, witnessScriptHash) {
10290 if (input.prevOutType) {
10291 if (input.prevOutType !== scriptTypes.P2WSH) throw new Error('PrevOutScript must be P2WSH')
10292
10293 var scriptHash = bscript.decompile(input.prevOutScript)[1]
10294 if (!scriptHash.equals(witnessScriptHash)) throw new Error('Inconsistent sha25(WitnessScript)')
10295 }
10296}
10297
10298function prepareInput (input, kpPubKey, redeemScript, witnessValue, witnessScript) {
10299 var expanded
10300 var prevOutType
10301 var prevOutScript
10302
10303 var p2sh = false
10304 var p2shType
10305 var redeemScriptHash
10306
10307 var witness = false
10308 var p2wsh = false
10309 var witnessType
10310 var witnessScriptHash
10311
10312 var signType
10313 var signScript
10314
10315 if (redeemScript && witnessScript) {
10316 redeemScriptHash = bcrypto.hash160(redeemScript)
10317 witnessScriptHash = bcrypto.sha256(witnessScript)
10318 checkP2SHInput(input, redeemScriptHash)
10319
10320 if (!redeemScript.equals(btemplates.witnessScriptHash.output.encode(witnessScriptHash))) throw new Error('Witness script inconsistent with redeem script')
10321
10322 expanded = expandOutput(witnessScript, undefined, kpPubKey)
10323 if (!expanded.pubKeys) throw new Error('WitnessScript not supported "' + bscript.toASM(redeemScript) + '"')
10324
10325 prevOutType = btemplates.types.P2SH
10326 prevOutScript = btemplates.scriptHash.output.encode(redeemScriptHash)
10327 p2sh = witness = p2wsh = true
10328 p2shType = btemplates.types.P2WSH
10329 signType = witnessType = expanded.scriptType
10330 signScript = witnessScript
10331 } else if (redeemScript) {
10332 redeemScriptHash = bcrypto.hash160(redeemScript)
10333 checkP2SHInput(input, redeemScriptHash)
10334
10335 expanded = expandOutput(redeemScript, undefined, kpPubKey)
10336 if (!expanded.pubKeys) throw new Error('RedeemScript not supported "' + bscript.toASM(redeemScript) + '"')
10337
10338 prevOutType = btemplates.types.P2SH
10339 prevOutScript = btemplates.scriptHash.output.encode(redeemScriptHash)
10340 p2sh = true
10341 signType = p2shType = expanded.scriptType
10342 signScript = redeemScript
10343 witness = signType === btemplates.types.P2WPKH
10344 } else if (witnessScript) {
10345 witnessScriptHash = bcrypto.sha256(witnessScript)
10346 checkP2WSHInput(input, witnessScriptHash)
10347
10348 expanded = expandOutput(witnessScript, undefined, kpPubKey)
10349 if (!expanded.pubKeys) throw new Error('WitnessScript not supported "' + bscript.toASM(redeemScript) + '"')
10350
10351 prevOutType = btemplates.types.P2WSH
10352 prevOutScript = btemplates.witnessScriptHash.output.encode(witnessScriptHash)
10353 witness = p2wsh = true
10354 signType = witnessType = expanded.scriptType
10355 signScript = witnessScript
10356 } else if (input.prevOutType) {
10357 // embedded scripts are not possible without a redeemScript
10358 if (input.prevOutType === scriptTypes.P2SH ||
10359 input.prevOutType === scriptTypes.P2WSH) {
10360 throw new Error('PrevOutScript is ' + input.prevOutType + ', requires redeemScript')
10361 }
10362
10363 prevOutType = input.prevOutType
10364 prevOutScript = input.prevOutScript
10365 expanded = expandOutput(input.prevOutScript, input.prevOutType, kpPubKey)
10366 if (!expanded.pubKeys) return
10367
10368 witness = (input.prevOutType === scriptTypes.P2WPKH)
10369 signType = prevOutType
10370 signScript = prevOutScript
10371 } else {
10372 prevOutScript = btemplates.pubKeyHash.output.encode(bcrypto.hash160(kpPubKey))
10373 expanded = expandOutput(prevOutScript, scriptTypes.P2PKH, kpPubKey)
10374
10375 prevOutType = scriptTypes.P2PKH
10376 witness = false
10377 signType = prevOutType
10378 signScript = prevOutScript
10379 }
10380
10381 if (signType === scriptTypes.P2WPKH) {
10382 signScript = btemplates.pubKeyHash.output.encode(btemplates.witnessPubKeyHash.output.decode(signScript))
10383 }
10384
10385 if (p2sh) {
10386 input.redeemScript = redeemScript
10387 input.redeemScriptType = p2shType
10388 }
10389
10390 if (p2wsh) {
10391 input.witnessScript = witnessScript
10392 input.witnessScriptType = witnessType
10393 }
10394
10395 input.pubKeys = expanded.pubKeys
10396 input.signatures = expanded.signatures
10397 input.signScript = signScript
10398 input.signType = signType
10399 input.prevOutScript = prevOutScript
10400 input.prevOutType = prevOutType
10401 input.witness = witness
10402}
10403
10404function buildStack (type, signatures, pubKeys, allowIncomplete) {
10405 if (type === scriptTypes.P2PKH) {
10406 if (signatures.length === 1 && Buffer.isBuffer(signatures[0]) && pubKeys.length === 1) return btemplates.pubKeyHash.input.encodeStack(signatures[0], pubKeys[0])
10407 } else if (type === scriptTypes.P2PK) {
10408 if (signatures.length === 1 && Buffer.isBuffer(signatures[0])) return btemplates.pubKey.input.encodeStack(signatures[0])
10409 } else if (type === scriptTypes.MULTISIG) {
10410 if (signatures.length > 0) {
10411 signatures = signatures.map(function (signature) {
10412 return signature || ops.OP_0
10413 })
10414 if (!allowIncomplete) {
10415 // remove blank signatures
10416 signatures = signatures.filter(function (x) { return x !== ops.OP_0 })
10417 }
10418
10419 return btemplates.multisig.input.encodeStack(signatures)
10420 }
10421 } else {
10422 throw new Error('Not yet supported')
10423 }
10424
10425 if (!allowIncomplete) throw new Error('Not enough signatures provided')
10426 return []
10427}
10428
10429function buildInput (input, allowIncomplete) {
10430 var scriptType = input.prevOutType
10431 var sig = []
10432 var witness = []
10433
10434 if (supportedType(scriptType)) {
10435 sig = buildStack(scriptType, input.signatures, input.pubKeys, allowIncomplete)
10436 }
10437
10438 var p2sh = false
10439 if (scriptType === btemplates.types.P2SH) {
10440 // We can remove this error later when we have a guarantee prepareInput
10441 // rejects unsignable scripts - it MUST be signable at this point.
10442 if (!allowIncomplete && !supportedP2SHType(input.redeemScriptType)) {
10443 throw new Error('Impossible to sign this type')
10444 }
10445
10446 if (supportedType(input.redeemScriptType)) {
10447 sig = buildStack(input.redeemScriptType, input.signatures, input.pubKeys, allowIncomplete)
10448 }
10449
10450 // If it wasn't SIGNABLE, it's witness, defer to that
10451 if (input.redeemScriptType) {
10452 p2sh = true
10453 scriptType = input.redeemScriptType
10454 }
10455 }
10456
10457 switch (scriptType) {
10458 // P2WPKH is a special case of P2PKH
10459 case btemplates.types.P2WPKH:
10460 witness = buildStack(btemplates.types.P2PKH, input.signatures, input.pubKeys, allowIncomplete)
10461 break
10462
10463 case btemplates.types.P2WSH:
10464 // We can remove this check later
10465 if (!allowIncomplete && !supportedType(input.witnessScriptType)) {
10466 throw new Error('Impossible to sign this type')
10467 }
10468
10469 if (supportedType(input.witnessScriptType)) {
10470 witness = buildStack(input.witnessScriptType, input.signatures, input.pubKeys, allowIncomplete)
10471 witness.push(input.witnessScript)
10472 scriptType = input.witnessScriptType
10473 }
10474
10475 break
10476 }
10477
10478 // append redeemScript if necessary
10479 if (p2sh) {
10480 sig.push(input.redeemScript)
10481 }
10482
10483 return {
10484 type: scriptType,
10485 script: bscript.compile(sig),
10486 witness: witness
10487 }
10488}
10489
10490function TransactionBuilder (network, maximumFeeRate) {
10491 this.prevTxMap = {}
10492 this.network = network || networks.bitcoin
10493
10494 // WARNING: This is __NOT__ to be relied on, its just another potential safety mechanism (safety in-depth)
10495 this.maximumFeeRate = maximumFeeRate || 2500
10496
10497 this.inputs = []
10498 this.tx = new Transaction()
10499}
10500
10501TransactionBuilder.prototype.setLockTime = function (locktime) {
10502 typeforce(types.UInt32, locktime)
10503
10504 // if any signatures exist, throw
10505 if (this.inputs.some(function (input) {
10506 if (!input.signatures) return false
10507
10508 return input.signatures.some(function (s) { return s })
10509 })) {
10510 throw new Error('No, this would invalidate signatures')
10511 }
10512
10513 this.tx.locktime = locktime
10514}
10515
10516TransactionBuilder.prototype.setVersion = function (version) {
10517 typeforce(types.UInt32, version)
10518
10519 // XXX: this might eventually become more complex depending on what the versions represent
10520 this.tx.version = version
10521}
10522
10523TransactionBuilder.fromTransaction = function (transaction, network) {
10524 var txb = new TransactionBuilder(network)
10525
10526 // Copy transaction fields
10527 txb.setVersion(transaction.version)
10528 txb.setLockTime(transaction.locktime)
10529
10530 // Copy outputs (done first to avoid signature invalidation)
10531 transaction.outs.forEach(function (txOut) {
10532 txb.addOutput(txOut.script, txOut.value)
10533 })
10534
10535 // Copy inputs
10536 transaction.ins.forEach(function (txIn) {
10537 txb.__addInputUnsafe(txIn.hash, txIn.index, {
10538 sequence: txIn.sequence,
10539 script: txIn.script,
10540 witness: txIn.witness
10541 })
10542 })
10543
10544 // fix some things not possible through the public API
10545 txb.inputs.forEach(function (input, i) {
10546 fixMultisigOrder(input, transaction, i)
10547 })
10548
10549 return txb
10550}
10551
10552TransactionBuilder.prototype.addInput = function (txHash, vout, sequence, prevOutScript) {
10553 if (!this.__canModifyInputs()) {
10554 throw new Error('No, this would invalidate signatures')
10555 }
10556
10557 var value
10558
10559 // is it a hex string?
10560 if (typeof txHash === 'string') {
10561 // transaction hashs's are displayed in reverse order, un-reverse it
10562 txHash = Buffer.from(txHash, 'hex').reverse()
10563
10564 // is it a Transaction object?
10565 } else if (txHash instanceof Transaction) {
10566 var txOut = txHash.outs[vout]
10567 prevOutScript = txOut.script
10568 value = txOut.value
10569
10570 txHash = txHash.getHash()
10571 }
10572
10573 return this.__addInputUnsafe(txHash, vout, {
10574 sequence: sequence,
10575 prevOutScript: prevOutScript,
10576 value: value
10577 })
10578}
10579
10580TransactionBuilder.prototype.__addInputUnsafe = function (txHash, vout, options) {
10581 if (Transaction.isCoinbaseHash(txHash)) {
10582 throw new Error('coinbase inputs not supported')
10583 }
10584
10585 var prevTxOut = txHash.toString('hex') + ':' + vout
10586 if (this.prevTxMap[prevTxOut] !== undefined) throw new Error('Duplicate TxOut: ' + prevTxOut)
10587
10588 var input = {}
10589
10590 // derive what we can from the scriptSig
10591 if (options.script !== undefined) {
10592 input = expandInput(options.script, options.witness || [])
10593 }
10594
10595 // if an input value was given, retain it
10596 if (options.value !== undefined) {
10597 input.value = options.value
10598 }
10599
10600 // derive what we can from the previous transactions output script
10601 if (!input.prevOutScript && options.prevOutScript) {
10602 var prevOutType
10603
10604 if (!input.pubKeys && !input.signatures) {
10605 var expanded = expandOutput(options.prevOutScript)
10606
10607 if (expanded.pubKeys) {
10608 input.pubKeys = expanded.pubKeys
10609 input.signatures = expanded.signatures
10610 }
10611
10612 prevOutType = expanded.scriptType
10613 }
10614
10615 input.prevOutScript = options.prevOutScript
10616 input.prevOutType = prevOutType || btemplates.classifyOutput(options.prevOutScript)
10617 }
10618
10619 var vin = this.tx.addInput(txHash, vout, options.sequence, options.scriptSig)
10620 this.inputs[vin] = input
10621 this.prevTxMap[prevTxOut] = vin
10622 return vin
10623}
10624
10625TransactionBuilder.prototype.addOutput = function (scriptPubKey, value) {
10626 if (!this.__canModifyOutputs()) {
10627 throw new Error('No, this would invalidate signatures')
10628 }
10629
10630 // Attempt to get a script if it's a base58 address string
10631 if (typeof scriptPubKey === 'string') {
10632 scriptPubKey = baddress.toOutputScript(scriptPubKey, this.network)
10633 }
10634
10635 return this.tx.addOutput(scriptPubKey, value)
10636}
10637
10638TransactionBuilder.prototype.build = function () {
10639 return this.__build(false)
10640}
10641TransactionBuilder.prototype.buildIncomplete = function () {
10642 return this.__build(true)
10643}
10644
10645TransactionBuilder.prototype.__build = function (allowIncomplete) {
10646 if (!allowIncomplete) {
10647 if (!this.tx.ins.length) throw new Error('Transaction has no inputs')
10648 if (!this.tx.outs.length) throw new Error('Transaction has no outputs')
10649 }
10650
10651 var tx = this.tx.clone()
10652 // Create script signatures from inputs
10653 this.inputs.forEach(function (input, i) {
10654 var scriptType = input.witnessScriptType || input.redeemScriptType || input.prevOutType
10655 if (!scriptType && !allowIncomplete) throw new Error('Transaction is not complete')
10656 var result = buildInput(input, allowIncomplete)
10657
10658 // skip if no result
10659 if (!allowIncomplete) {
10660 if (!supportedType(result.type) && result.type !== btemplates.types.P2WPKH) {
10661 throw new Error(result.type + ' not supported')
10662 }
10663 }
10664
10665 tx.setInputScript(i, result.script)
10666 tx.setWitness(i, result.witness)
10667 })
10668
10669 if (!allowIncomplete) {
10670 // do not rely on this, its merely a last resort
10671 if (this.__overMaximumFees(tx.virtualSize())) {
10672 throw new Error('Transaction has absurd fees')
10673 }
10674 }
10675
10676 return tx
10677}
10678
10679function canSign (input) {
10680 return input.prevOutScript !== undefined &&
10681 input.signScript !== undefined &&
10682 input.pubKeys !== undefined &&
10683 input.signatures !== undefined &&
10684 input.signatures.length === input.pubKeys.length &&
10685 input.pubKeys.length > 0 &&
10686 (
10687 input.witness === false ||
10688 (input.witness === true && input.value !== undefined)
10689 )
10690}
10691
10692TransactionBuilder.prototype.sign = function (vin, keyPair, redeemScript, hashType, witnessValue, witnessScript) {
10693 // TODO: remove keyPair.network matching in 4.0.0
10694 if (keyPair.network && keyPair.network !== this.network) throw new TypeError('Inconsistent network')
10695 if (!this.inputs[vin]) throw new Error('No input at index: ' + vin)
10696 hashType = hashType || Transaction.SIGHASH_ALL
10697
10698 var input = this.inputs[vin]
10699
10700 // if redeemScript was previously provided, enforce consistency
10701 if (input.redeemScript !== undefined &&
10702 redeemScript &&
10703 !input.redeemScript.equals(redeemScript)) {
10704 throw new Error('Inconsistent redeemScript')
10705 }
10706
10707 var kpPubKey = keyPair.publicKey || keyPair.getPublicKeyBuffer()
10708 if (!canSign(input)) {
10709 if (witnessValue !== undefined) {
10710 if (input.value !== undefined && input.value !== witnessValue) throw new Error('Input didn\'t match witnessValue')
10711 typeforce(types.Satoshi, witnessValue)
10712 input.value = witnessValue
10713 }
10714
10715 if (!canSign(input)) prepareInput(input, kpPubKey, redeemScript, witnessValue, witnessScript)
10716 if (!canSign(input)) throw Error(input.prevOutType + ' not supported')
10717 }
10718
10719 // ready to sign
10720 var signatureHash
10721 if (input.witness) {
10722 signatureHash = this.tx.hashForWitnessV0(vin, input.signScript, input.value, hashType)
10723 } else {
10724 signatureHash = this.tx.hashForSignature(vin, input.signScript, hashType)
10725 }
10726
10727 // enforce in order signing of public keys
10728 var signed = input.pubKeys.some(function (pubKey, i) {
10729 if (!kpPubKey.equals(pubKey)) return false
10730 if (input.signatures[i]) throw new Error('Signature already exists')
10731 if (kpPubKey.length !== 33 &&
10732 input.signType === scriptTypes.P2WPKH) throw new Error('BIP143 rejects uncompressed public keys in P2WPKH or P2WSH')
10733
10734 var signature = keyPair.sign(signatureHash)
10735 if (Buffer.isBuffer(signature)) signature = ECSignature.fromRSBuffer(signature)
10736
10737 input.signatures[i] = signature.toScriptSignature(hashType)
10738 return true
10739 })
10740
10741 if (!signed) throw new Error('Key pair cannot sign for this input')
10742}
10743
10744function signatureHashType (buffer) {
10745 return buffer.readUInt8(buffer.length - 1)
10746}
10747
10748TransactionBuilder.prototype.__canModifyInputs = function () {
10749 return this.inputs.every(function (input) {
10750 // any signatures?
10751 if (input.signatures === undefined) return true
10752
10753 return input.signatures.every(function (signature) {
10754 if (!signature) return true
10755 var hashType = signatureHashType(signature)
10756
10757 // if SIGHASH_ANYONECANPAY is set, signatures would not
10758 // be invalidated by more inputs
10759 return hashType & Transaction.SIGHASH_ANYONECANPAY
10760 })
10761 })
10762}
10763
10764TransactionBuilder.prototype.__canModifyOutputs = function () {
10765 var nInputs = this.tx.ins.length
10766 var nOutputs = this.tx.outs.length
10767
10768 return this.inputs.every(function (input) {
10769 if (input.signatures === undefined) return true
10770
10771 return input.signatures.every(function (signature) {
10772 if (!signature) return true
10773 var hashType = signatureHashType(signature)
10774
10775 var hashTypeMod = hashType & 0x1f
10776 if (hashTypeMod === Transaction.SIGHASH_NONE) return true
10777 if (hashTypeMod === Transaction.SIGHASH_SINGLE) {
10778 // if SIGHASH_SINGLE is set, and nInputs > nOutputs
10779 // some signatures would be invalidated by the addition
10780 // of more outputs
10781 return nInputs <= nOutputs
10782 }
10783 })
10784 })
10785}
10786
10787TransactionBuilder.prototype.__overMaximumFees = function (bytes) {
10788 // not all inputs will have .value defined
10789 var incoming = this.inputs.reduce(function (a, x) { return a + (x.value >>> 0) }, 0)
10790
10791 // but all outputs do, and if we have any input value
10792 // we can immediately determine if the outputs are too small
10793 var outgoing = this.tx.outs.reduce(function (a, x) { return a + x.value }, 0)
10794 var fee = incoming - outgoing
10795 var feeRate = fee / bytes
10796
10797 return feeRate > this.maximumFeeRate
10798}
10799
10800module.exports = TransactionBuilder
10801
10802},{"./address":53,"./crypto":56,"./ecpair":58,"./ecsignature":59,"./networks":62,"./script":63,"./templates":65,"./transaction":87,"./types":89,"bitcoin-ops":8,"safe-buffer":38,"typeforce":49}],89:[function(require,module,exports){
10803var typeforce = require('typeforce')
10804
10805var UINT31_MAX = Math.pow(2, 31) - 1
10806function UInt31 (value) {
10807 return typeforce.UInt32(value) && value <= UINT31_MAX
10808}
10809
10810function BIP32Path (value) {
10811 return typeforce.String(value) && value.match(/^(m\/)?(\d+'?\/)*\d+'?$/)
10812}
10813BIP32Path.toJSON = function () { return 'BIP32 derivation path' }
10814
10815var SATOSHI_MAX = 105 * 1e14
10816function Satoshi (value) {
10817 return typeforce.UInt53(value) && value <= SATOSHI_MAX
10818}
10819
10820// external dependent types
10821var BigInt = typeforce.quacksLike('BigInteger')
10822var ECPoint = typeforce.quacksLike('Point')
10823
10824// exposed, external API
10825var ECSignature = typeforce.compile({ r: BigInt, s: BigInt })
10826var Network = typeforce.compile({
10827 messagePrefix: typeforce.oneOf(typeforce.Buffer, typeforce.String),
10828 bip32: {
10829 public: typeforce.UInt32,
10830 private: typeforce.UInt32
10831 },
10832 pubKeyHash: typeforce.UInt8,
10833 scriptHash: typeforce.UInt8,
10834 wif: typeforce.UInt8
10835})
10836
10837// extend typeforce types with ours
10838var types = {
10839 BigInt: BigInt,
10840 BIP32Path: BIP32Path,
10841 Buffer256bit: typeforce.BufferN(32),
10842 ECPoint: ECPoint,
10843 ECSignature: ECSignature,
10844 Hash160bit: typeforce.BufferN(20),
10845 Hash256bit: typeforce.BufferN(32),
10846 Network: Network,
10847 Satoshi: Satoshi,
10848 UInt31: UInt31
10849}
10850
10851for (var typeName in typeforce) {
10852 types[typeName] = typeforce[typeName]
10853}
10854
10855module.exports = types
10856
10857},{"typeforce":49}],90:[function(require,module,exports){
10858(function (global){
10859'use strict';
10860
10861var objectAssign = require('object-assign');
10862
10863// compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js
10864// original notice:
10865
10866/*!
10867 * The buffer module from node.js, for the browser.
10868 *
10869 * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
10870 * @license MIT
10871 */
10872function compare(a, b) {
10873 if (a === b) {
10874 return 0;
10875 }
10876
10877 var x = a.length;
10878 var y = b.length;
10879
10880 for (var i = 0, len = Math.min(x, y); i < len; ++i) {
10881 if (a[i] !== b[i]) {
10882 x = a[i];
10883 y = b[i];
10884 break;
10885 }
10886 }
10887
10888 if (x < y) {
10889 return -1;
10890 }
10891 if (y < x) {
10892 return 1;
10893 }
10894 return 0;
10895}
10896function isBuffer(b) {
10897 if (global.Buffer && typeof global.Buffer.isBuffer === 'function') {
10898 return global.Buffer.isBuffer(b);
10899 }
10900 return !!(b != null && b._isBuffer);
10901}
10902
10903// based on node assert, original notice:
10904// NB: The URL to the CommonJS spec is kept just for tradition.
10905// node-assert has evolved a lot since then, both in API and behavior.
10906
10907// http://wiki.commonjs.org/wiki/Unit_Testing/1.0
10908//
10909// THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
10910//
10911// Originally from narwhal.js (http://narwhaljs.org)
10912// Copyright (c) 2009 Thomas Robinson <280north.com>
10913//
10914// Permission is hereby granted, free of charge, to any person obtaining a copy
10915// of this software and associated documentation files (the 'Software'), to
10916// deal in the Software without restriction, including without limitation the
10917// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10918// sell copies of the Software, and to permit persons to whom the Software is
10919// furnished to do so, subject to the following conditions:
10920//
10921// The above copyright notice and this permission notice shall be included in
10922// all copies or substantial portions of the Software.
10923//
10924// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
10925// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
10926// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
10927// AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
10928// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
10929// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10930
10931var util = require('util/');
10932var hasOwn = Object.prototype.hasOwnProperty;
10933var pSlice = Array.prototype.slice;
10934var functionsHaveNames = (function () {
10935 return function foo() {}.name === 'foo';
10936}());
10937function pToString (obj) {
10938 return Object.prototype.toString.call(obj);
10939}
10940function isView(arrbuf) {
10941 if (isBuffer(arrbuf)) {
10942 return false;
10943 }
10944 if (typeof global.ArrayBuffer !== 'function') {
10945 return false;
10946 }
10947 if (typeof ArrayBuffer.isView === 'function') {
10948 return ArrayBuffer.isView(arrbuf);
10949 }
10950 if (!arrbuf) {
10951 return false;
10952 }
10953 if (arrbuf instanceof DataView) {
10954 return true;
10955 }
10956 if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) {
10957 return true;
10958 }
10959 return false;
10960}
10961// 1. The assert module provides functions that throw
10962// AssertionError's when particular conditions are not met. The
10963// assert module must conform to the following interface.
10964
10965var assert = module.exports = ok;
10966
10967// 2. The AssertionError is defined in assert.
10968// new assert.AssertionError({ message: message,
10969// actual: actual,
10970// expected: expected })
10971
10972var regex = /\s*function\s+([^\(\s]*)\s*/;
10973// based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js
10974function getName(func) {
10975 if (!util.isFunction(func)) {
10976 return;
10977 }
10978 if (functionsHaveNames) {
10979 return func.name;
10980 }
10981 var str = func.toString();
10982 var match = str.match(regex);
10983 return match && match[1];
10984}
10985assert.AssertionError = function AssertionError(options) {
10986 this.name = 'AssertionError';
10987 this.actual = options.actual;
10988 this.expected = options.expected;
10989 this.operator = options.operator;
10990 if (options.message) {
10991 this.message = options.message;
10992 this.generatedMessage = false;
10993 } else {
10994 this.message = getMessage(this);
10995 this.generatedMessage = true;
10996 }
10997 var stackStartFunction = options.stackStartFunction || fail;
10998 if (Error.captureStackTrace) {
10999 Error.captureStackTrace(this, stackStartFunction);
11000 } else {
11001 // non v8 browsers so we can have a stacktrace
11002 var err = new Error();
11003 if (err.stack) {
11004 var out = err.stack;
11005
11006 // try to strip useless frames
11007 var fn_name = getName(stackStartFunction);
11008 var idx = out.indexOf('\n' + fn_name);
11009 if (idx >= 0) {
11010 // once we have located the function frame
11011 // we need to strip out everything before it (and its line)
11012 var next_line = out.indexOf('\n', idx + 1);
11013 out = out.substring(next_line + 1);
11014 }
11015
11016 this.stack = out;
11017 }
11018 }
11019};
11020
11021// assert.AssertionError instanceof Error
11022util.inherits(assert.AssertionError, Error);
11023
11024function truncate(s, n) {
11025 if (typeof s === 'string') {
11026 return s.length < n ? s : s.slice(0, n);
11027 } else {
11028 return s;
11029 }
11030}
11031function inspect(something) {
11032 if (functionsHaveNames || !util.isFunction(something)) {
11033 return util.inspect(something);
11034 }
11035 var rawname = getName(something);
11036 var name = rawname ? ': ' + rawname : '';
11037 return '[Function' + name + ']';
11038}
11039function getMessage(self) {
11040 return truncate(inspect(self.actual), 128) + ' ' +
11041 self.operator + ' ' +
11042 truncate(inspect(self.expected), 128);
11043}
11044
11045// At present only the three keys mentioned above are used and
11046// understood by the spec. Implementations or sub modules can pass
11047// other keys to the AssertionError's constructor - they will be
11048// ignored.
11049
11050// 3. All of the following functions must throw an AssertionError
11051// when a corresponding condition is not met, with a message that
11052// may be undefined if not provided. All assertion methods provide
11053// both the actual and expected values to the assertion error for
11054// display purposes.
11055
11056function fail(actual, expected, message, operator, stackStartFunction) {
11057 throw new assert.AssertionError({
11058 message: message,
11059 actual: actual,
11060 expected: expected,
11061 operator: operator,
11062 stackStartFunction: stackStartFunction
11063 });
11064}
11065
11066// EXTENSION! allows for well behaved errors defined elsewhere.
11067assert.fail = fail;
11068
11069// 4. Pure assertion tests whether a value is truthy, as determined
11070// by !!guard.
11071// assert.ok(guard, message_opt);
11072// This statement is equivalent to assert.equal(true, !!guard,
11073// message_opt);. To test strictly for the value true, use
11074// assert.strictEqual(true, guard, message_opt);.
11075
11076function ok(value, message) {
11077 if (!value) fail(value, true, message, '==', assert.ok);
11078}
11079assert.ok = ok;
11080
11081// 5. The equality assertion tests shallow, coercive equality with
11082// ==.
11083// assert.equal(actual, expected, message_opt);
11084
11085assert.equal = function equal(actual, expected, message) {
11086 if (actual != expected) fail(actual, expected, message, '==', assert.equal);
11087};
11088
11089// 6. The non-equality assertion tests for whether two objects are not equal
11090// with != assert.notEqual(actual, expected, message_opt);
11091
11092assert.notEqual = function notEqual(actual, expected, message) {
11093 if (actual == expected) {
11094 fail(actual, expected, message, '!=', assert.notEqual);
11095 }
11096};
11097
11098// 7. The equivalence assertion tests a deep equality relation.
11099// assert.deepEqual(actual, expected, message_opt);
11100
11101assert.deepEqual = function deepEqual(actual, expected, message) {
11102 if (!_deepEqual(actual, expected, false)) {
11103 fail(actual, expected, message, 'deepEqual', assert.deepEqual);
11104 }
11105};
11106
11107assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) {
11108 if (!_deepEqual(actual, expected, true)) {
11109 fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual);
11110 }
11111};
11112
11113function _deepEqual(actual, expected, strict, memos) {
11114 // 7.1. All identical values are equivalent, as determined by ===.
11115 if (actual === expected) {
11116 return true;
11117 } else if (isBuffer(actual) && isBuffer(expected)) {
11118 return compare(actual, expected) === 0;
11119
11120 // 7.2. If the expected value is a Date object, the actual value is
11121 // equivalent if it is also a Date object that refers to the same time.
11122 } else if (util.isDate(actual) && util.isDate(expected)) {
11123 return actual.getTime() === expected.getTime();
11124
11125 // 7.3 If the expected value is a RegExp object, the actual value is
11126 // equivalent if it is also a RegExp object with the same source and
11127 // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
11128 } else if (util.isRegExp(actual) && util.isRegExp(expected)) {
11129 return actual.source === expected.source &&
11130 actual.global === expected.global &&
11131 actual.multiline === expected.multiline &&
11132 actual.lastIndex === expected.lastIndex &&
11133 actual.ignoreCase === expected.ignoreCase;
11134
11135 // 7.4. Other pairs that do not both pass typeof value == 'object',
11136 // equivalence is determined by ==.
11137 } else if ((actual === null || typeof actual !== 'object') &&
11138 (expected === null || typeof expected !== 'object')) {
11139 return strict ? actual === expected : actual == expected;
11140
11141 // If both values are instances of typed arrays, wrap their underlying
11142 // ArrayBuffers in a Buffer each to increase performance
11143 // This optimization requires the arrays to have the same type as checked by
11144 // Object.prototype.toString (aka pToString). Never perform binary
11145 // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their
11146 // bit patterns are not identical.
11147 } else if (isView(actual) && isView(expected) &&
11148 pToString(actual) === pToString(expected) &&
11149 !(actual instanceof Float32Array ||
11150 actual instanceof Float64Array)) {
11151 return compare(new Uint8Array(actual.buffer),
11152 new Uint8Array(expected.buffer)) === 0;
11153
11154 // 7.5 For all other Object pairs, including Array objects, equivalence is
11155 // determined by having the same number of owned properties (as verified
11156 // with Object.prototype.hasOwnProperty.call), the same set of keys
11157 // (although not necessarily the same order), equivalent values for every
11158 // corresponding key, and an identical 'prototype' property. Note: this
11159 // accounts for both named and indexed properties on Arrays.
11160 } else if (isBuffer(actual) !== isBuffer(expected)) {
11161 return false;
11162 } else {
11163 memos = memos || {actual: [], expected: []};
11164
11165 var actualIndex = memos.actual.indexOf(actual);
11166 if (actualIndex !== -1) {
11167 if (actualIndex === memos.expected.indexOf(expected)) {
11168 return true;
11169 }
11170 }
11171
11172 memos.actual.push(actual);
11173 memos.expected.push(expected);
11174
11175 return objEquiv(actual, expected, strict, memos);
11176 }
11177}
11178
11179function isArguments(object) {
11180 return Object.prototype.toString.call(object) == '[object Arguments]';
11181}
11182
11183function objEquiv(a, b, strict, actualVisitedObjects) {
11184 if (a === null || a === undefined || b === null || b === undefined)
11185 return false;
11186 // if one is a primitive, the other must be same
11187 if (util.isPrimitive(a) || util.isPrimitive(b))
11188 return a === b;
11189 if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b))
11190 return false;
11191 var aIsArgs = isArguments(a);
11192 var bIsArgs = isArguments(b);
11193 if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
11194 return false;
11195 if (aIsArgs) {
11196 a = pSlice.call(a);
11197 b = pSlice.call(b);
11198 return _deepEqual(a, b, strict);
11199 }
11200 var ka = objectKeys(a);
11201 var kb = objectKeys(b);
11202 var key, i;
11203 // having the same number of owned properties (keys incorporates
11204 // hasOwnProperty)
11205 if (ka.length !== kb.length)
11206 return false;
11207 //the same set of keys (although not necessarily the same order),
11208 ka.sort();
11209 kb.sort();
11210 //~~~cheap key test
11211 for (i = ka.length - 1; i >= 0; i--) {
11212 if (ka[i] !== kb[i])
11213 return false;
11214 }
11215 //equivalent values for every corresponding key, and
11216 //~~~possibly expensive deep test
11217 for (i = ka.length - 1; i >= 0; i--) {
11218 key = ka[i];
11219 if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects))
11220 return false;
11221 }
11222 return true;
11223}
11224
11225// 8. The non-equivalence assertion tests for any deep inequality.
11226// assert.notDeepEqual(actual, expected, message_opt);
11227
11228assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
11229 if (_deepEqual(actual, expected, false)) {
11230 fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
11231 }
11232};
11233
11234assert.notDeepStrictEqual = notDeepStrictEqual;
11235function notDeepStrictEqual(actual, expected, message) {
11236 if (_deepEqual(actual, expected, true)) {
11237 fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual);
11238 }
11239}
11240
11241
11242// 9. The strict equality assertion tests strict equality, as determined by ===.
11243// assert.strictEqual(actual, expected, message_opt);
11244
11245assert.strictEqual = function strictEqual(actual, expected, message) {
11246 if (actual !== expected) {
11247 fail(actual, expected, message, '===', assert.strictEqual);
11248 }
11249};
11250
11251// 10. The strict non-equality assertion tests for strict inequality, as
11252// determined by !==. assert.notStrictEqual(actual, expected, message_opt);
11253
11254assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
11255 if (actual === expected) {
11256 fail(actual, expected, message, '!==', assert.notStrictEqual);
11257 }
11258};
11259
11260function expectedException(actual, expected) {
11261 if (!actual || !expected) {
11262 return false;
11263 }
11264
11265 if (Object.prototype.toString.call(expected) == '[object RegExp]') {
11266 return expected.test(actual);
11267 }
11268
11269 try {
11270 if (actual instanceof expected) {
11271 return true;
11272 }
11273 } catch (e) {
11274 // Ignore. The instanceof check doesn't work for arrow functions.
11275 }
11276
11277 if (Error.isPrototypeOf(expected)) {
11278 return false;
11279 }
11280
11281 return expected.call({}, actual) === true;
11282}
11283
11284function _tryBlock(block) {
11285 var error;
11286 try {
11287 block();
11288 } catch (e) {
11289 error = e;
11290 }
11291 return error;
11292}
11293
11294function _throws(shouldThrow, block, expected, message) {
11295 var actual;
11296
11297 if (typeof block !== 'function') {
11298 throw new TypeError('"block" argument must be a function');
11299 }
11300
11301 if (typeof expected === 'string') {
11302 message = expected;
11303 expected = null;
11304 }
11305
11306 actual = _tryBlock(block);
11307
11308 message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
11309 (message ? ' ' + message : '.');
11310
11311 if (shouldThrow && !actual) {
11312 fail(actual, expected, 'Missing expected exception' + message);
11313 }
11314
11315 var userProvidedMessage = typeof message === 'string';
11316 var isUnwantedException = !shouldThrow && util.isError(actual);
11317 var isUnexpectedException = !shouldThrow && actual && !expected;
11318
11319 if ((isUnwantedException &&
11320 userProvidedMessage &&
11321 expectedException(actual, expected)) ||
11322 isUnexpectedException) {
11323 fail(actual, expected, 'Got unwanted exception' + message);
11324 }
11325
11326 if ((shouldThrow && actual && expected &&
11327 !expectedException(actual, expected)) || (!shouldThrow && actual)) {
11328 throw actual;
11329 }
11330}
11331
11332// 11. Expected to throw an error:
11333// assert.throws(block, Error_opt, message_opt);
11334
11335assert.throws = function(block, /*optional*/error, /*optional*/message) {
11336 _throws(true, block, error, message);
11337};
11338
11339// EXTENSION! This is annoying to write outside this module.
11340assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) {
11341 _throws(false, block, error, message);
11342};
11343
11344assert.ifError = function(err) { if (err) throw err; };
11345
11346// Expose a strict only variant of assert
11347function strict(value, message) {
11348 if (!value) fail(value, true, message, '==', strict);
11349}
11350assert.strict = objectAssign(strict, assert, {
11351 equal: assert.strictEqual,
11352 deepEqual: assert.deepStrictEqual,
11353 notEqual: assert.notStrictEqual,
11354 notDeepEqual: assert.notDeepStrictEqual
11355});
11356assert.strict.strict = assert.strict;
11357
11358var objectKeys = Object.keys || function (obj) {
11359 var keys = [];
11360 for (var key in obj) {
11361 if (hasOwn.call(obj, key)) keys.push(key);
11362 }
11363 return keys;
11364};
11365
11366}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
11367},{"object-assign":103,"util/":93}],91:[function(require,module,exports){
11368if (typeof Object.create === 'function') {
11369 // implementation from standard node.js 'util' module
11370 module.exports = function inherits(ctor, superCtor) {
11371 ctor.super_ = superCtor
11372 ctor.prototype = Object.create(superCtor.prototype, {
11373 constructor: {
11374 value: ctor,
11375 enumerable: false,
11376 writable: true,
11377 configurable: true
11378 }
11379 });
11380 };
11381} else {
11382 // old school shim for old browsers
11383 module.exports = function inherits(ctor, superCtor) {
11384 ctor.super_ = superCtor
11385 var TempCtor = function () {}
11386 TempCtor.prototype = superCtor.prototype
11387 ctor.prototype = new TempCtor()
11388 ctor.prototype.constructor = ctor
11389 }
11390}
11391
11392},{}],92:[function(require,module,exports){
11393module.exports = function isBuffer(arg) {
11394 return arg && typeof arg === 'object'
11395 && typeof arg.copy === 'function'
11396 && typeof arg.fill === 'function'
11397 && typeof arg.readUInt8 === 'function';
11398}
11399},{}],93:[function(require,module,exports){
11400(function (process,global){
11401// Copyright Joyent, Inc. and other Node contributors.
11402//
11403// Permission is hereby granted, free of charge, to any person obtaining a
11404// copy of this software and associated documentation files (the
11405// "Software"), to deal in the Software without restriction, including
11406// without limitation the rights to use, copy, modify, merge, publish,
11407// distribute, sublicense, and/or sell copies of the Software, and to permit
11408// persons to whom the Software is furnished to do so, subject to the
11409// following conditions:
11410//
11411// The above copyright notice and this permission notice shall be included
11412// in all copies or substantial portions of the Software.
11413//
11414// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
11415// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
11416// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
11417// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
11418// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
11419// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
11420// USE OR OTHER DEALINGS IN THE SOFTWARE.
11421
11422var formatRegExp = /%[sdj%]/g;
11423exports.format = function(f) {
11424 if (!isString(f)) {
11425 var objects = [];
11426 for (var i = 0; i < arguments.length; i++) {
11427 objects.push(inspect(arguments[i]));
11428 }
11429 return objects.join(' ');
11430 }
11431
11432 var i = 1;
11433 var args = arguments;
11434 var len = args.length;
11435 var str = String(f).replace(formatRegExp, function(x) {
11436 if (x === '%%') return '%';
11437 if (i >= len) return x;
11438 switch (x) {
11439 case '%s': return String(args[i++]);
11440 case '%d': return Number(args[i++]);
11441 case '%j':
11442 try {
11443 return JSON.stringify(args[i++]);
11444 } catch (_) {
11445 return '[Circular]';
11446 }
11447 default:
11448 return x;
11449 }
11450 });
11451 for (var x = args[i]; i < len; x = args[++i]) {
11452 if (isNull(x) || !isObject(x)) {
11453 str += ' ' + x;
11454 } else {
11455 str += ' ' + inspect(x);
11456 }
11457 }
11458 return str;
11459};
11460
11461
11462// Mark that a method should not be used.
11463// Returns a modified function which warns once by default.
11464// If --no-deprecation is set, then it is a no-op.
11465exports.deprecate = function(fn, msg) {
11466 // Allow for deprecating things in the process of starting up.
11467 if (isUndefined(global.process)) {
11468 return function() {
11469 return exports.deprecate(fn, msg).apply(this, arguments);
11470 };
11471 }
11472
11473 if (process.noDeprecation === true) {
11474 return fn;
11475 }
11476
11477 var warned = false;
11478 function deprecated() {
11479 if (!warned) {
11480 if (process.throwDeprecation) {
11481 throw new Error(msg);
11482 } else if (process.traceDeprecation) {
11483 console.trace(msg);
11484 } else {
11485 console.error(msg);
11486 }
11487 warned = true;
11488 }
11489 return fn.apply(this, arguments);
11490 }
11491
11492 return deprecated;
11493};
11494
11495
11496var debugs = {};
11497var debugEnviron;
11498exports.debuglog = function(set) {
11499 if (isUndefined(debugEnviron))
11500 debugEnviron = process.env.NODE_DEBUG || '';
11501 set = set.toUpperCase();
11502 if (!debugs[set]) {
11503 if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
11504 var pid = process.pid;
11505 debugs[set] = function() {
11506 var msg = exports.format.apply(exports, arguments);
11507 console.error('%s %d: %s', set, pid, msg);
11508 };
11509 } else {
11510 debugs[set] = function() {};
11511 }
11512 }
11513 return debugs[set];
11514};
11515
11516
11517/**
11518 * Echos the value of a value. Trys to print the value out
11519 * in the best way possible given the different types.
11520 *
11521 * @param {Object} obj The object to print out.
11522 * @param {Object} opts Optional options object that alters the output.
11523 */
11524/* legacy: obj, showHidden, depth, colors*/
11525function inspect(obj, opts) {
11526 // default options
11527 var ctx = {
11528 seen: [],
11529 stylize: stylizeNoColor
11530 };
11531 // legacy...
11532 if (arguments.length >= 3) ctx.depth = arguments[2];
11533 if (arguments.length >= 4) ctx.colors = arguments[3];
11534 if (isBoolean(opts)) {
11535 // legacy...
11536 ctx.showHidden = opts;
11537 } else if (opts) {
11538 // got an "options" object
11539 exports._extend(ctx, opts);
11540 }
11541 // set default options
11542 if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
11543 if (isUndefined(ctx.depth)) ctx.depth = 2;
11544 if (isUndefined(ctx.colors)) ctx.colors = false;
11545 if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
11546 if (ctx.colors) ctx.stylize = stylizeWithColor;
11547 return formatValue(ctx, obj, ctx.depth);
11548}
11549exports.inspect = inspect;
11550
11551
11552// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
11553inspect.colors = {
11554 'bold' : [1, 22],
11555 'italic' : [3, 23],
11556 'underline' : [4, 24],
11557 'inverse' : [7, 27],
11558 'white' : [37, 39],
11559 'grey' : [90, 39],
11560 'black' : [30, 39],
11561 'blue' : [34, 39],
11562 'cyan' : [36, 39],
11563 'green' : [32, 39],
11564 'magenta' : [35, 39],
11565 'red' : [31, 39],
11566 'yellow' : [33, 39]
11567};
11568
11569// Don't use 'blue' not visible on cmd.exe
11570inspect.styles = {
11571 'special': 'cyan',
11572 'number': 'yellow',
11573 'boolean': 'yellow',
11574 'undefined': 'grey',
11575 'null': 'bold',
11576 'string': 'green',
11577 'date': 'magenta',
11578 // "name": intentionally not styling
11579 'regexp': 'red'
11580};
11581
11582
11583function stylizeWithColor(str, styleType) {
11584 var style = inspect.styles[styleType];
11585
11586 if (style) {
11587 return '\u001b[' + inspect.colors[style][0] + 'm' + str +
11588 '\u001b[' + inspect.colors[style][1] + 'm';
11589 } else {
11590 return str;
11591 }
11592}
11593
11594
11595function stylizeNoColor(str, styleType) {
11596 return str;
11597}
11598
11599
11600function arrayToHash(array) {
11601 var hash = {};
11602
11603 array.forEach(function(val, idx) {
11604 hash[val] = true;
11605 });
11606
11607 return hash;
11608}
11609
11610
11611function formatValue(ctx, value, recurseTimes) {
11612 // Provide a hook for user-specified inspect functions.
11613 // Check that value is an object with an inspect function on it
11614 if (ctx.customInspect &&
11615 value &&
11616 isFunction(value.inspect) &&
11617 // Filter out the util module, it's inspect function is special
11618 value.inspect !== exports.inspect &&
11619 // Also filter out any prototype objects using the circular check.
11620 !(value.constructor && value.constructor.prototype === value)) {
11621 var ret = value.inspect(recurseTimes, ctx);
11622 if (!isString(ret)) {
11623 ret = formatValue(ctx, ret, recurseTimes);
11624 }
11625 return ret;
11626 }
11627
11628 // Primitive types cannot have properties
11629 var primitive = formatPrimitive(ctx, value);
11630 if (primitive) {
11631 return primitive;
11632 }
11633
11634 // Look up the keys of the object.
11635 var keys = Object.keys(value);
11636 var visibleKeys = arrayToHash(keys);
11637
11638 if (ctx.showHidden) {
11639 keys = Object.getOwnPropertyNames(value);
11640 }
11641
11642 // IE doesn't make error fields non-enumerable
11643 // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
11644 if (isError(value)
11645 && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
11646 return formatError(value);
11647 }
11648
11649 // Some type of object without properties can be shortcutted.
11650 if (keys.length === 0) {
11651 if (isFunction(value)) {
11652 var name = value.name ? ': ' + value.name : '';
11653 return ctx.stylize('[Function' + name + ']', 'special');
11654 }
11655 if (isRegExp(value)) {
11656 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
11657 }
11658 if (isDate(value)) {
11659 return ctx.stylize(Date.prototype.toString.call(value), 'date');
11660 }
11661 if (isError(value)) {
11662 return formatError(value);
11663 }
11664 }
11665
11666 var base = '', array = false, braces = ['{', '}'];
11667
11668 // Make Array say that they are Array
11669 if (isArray(value)) {
11670 array = true;
11671 braces = ['[', ']'];
11672 }
11673
11674 // Make functions say that they are functions
11675 if (isFunction(value)) {
11676 var n = value.name ? ': ' + value.name : '';
11677 base = ' [Function' + n + ']';
11678 }
11679
11680 // Make RegExps say that they are RegExps
11681 if (isRegExp(value)) {
11682 base = ' ' + RegExp.prototype.toString.call(value);
11683 }
11684
11685 // Make dates with properties first say the date
11686 if (isDate(value)) {
11687 base = ' ' + Date.prototype.toUTCString.call(value);
11688 }
11689
11690 // Make error with message first say the error
11691 if (isError(value)) {
11692 base = ' ' + formatError(value);
11693 }
11694
11695 if (keys.length === 0 && (!array || value.length == 0)) {
11696 return braces[0] + base + braces[1];
11697 }
11698
11699 if (recurseTimes < 0) {
11700 if (isRegExp(value)) {
11701 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
11702 } else {
11703 return ctx.stylize('[Object]', 'special');
11704 }
11705 }
11706
11707 ctx.seen.push(value);
11708
11709 var output;
11710 if (array) {
11711 output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
11712 } else {
11713 output = keys.map(function(key) {
11714 return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
11715 });
11716 }
11717
11718 ctx.seen.pop();
11719
11720 return reduceToSingleString(output, base, braces);
11721}
11722
11723
11724function formatPrimitive(ctx, value) {
11725 if (isUndefined(value))
11726 return ctx.stylize('undefined', 'undefined');
11727 if (isString(value)) {
11728 var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
11729 .replace(/'/g, "\\'")
11730 .replace(/\\"/g, '"') + '\'';
11731 return ctx.stylize(simple, 'string');
11732 }
11733 if (isNumber(value))
11734 return ctx.stylize('' + value, 'number');
11735 if (isBoolean(value))
11736 return ctx.stylize('' + value, 'boolean');
11737 // For some reason typeof null is "object", so special case here.
11738 if (isNull(value))
11739 return ctx.stylize('null', 'null');
11740}
11741
11742
11743function formatError(value) {
11744 return '[' + Error.prototype.toString.call(value) + ']';
11745}
11746
11747
11748function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
11749 var output = [];
11750 for (var i = 0, l = value.length; i < l; ++i) {
11751 if (hasOwnProperty(value, String(i))) {
11752 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
11753 String(i), true));
11754 } else {
11755 output.push('');
11756 }
11757 }
11758 keys.forEach(function(key) {
11759 if (!key.match(/^\d+$/)) {
11760 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
11761 key, true));
11762 }
11763 });
11764 return output;
11765}
11766
11767
11768function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
11769 var name, str, desc;
11770 desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
11771 if (desc.get) {
11772 if (desc.set) {
11773 str = ctx.stylize('[Getter/Setter]', 'special');
11774 } else {
11775 str = ctx.stylize('[Getter]', 'special');
11776 }
11777 } else {
11778 if (desc.set) {
11779 str = ctx.stylize('[Setter]', 'special');
11780 }
11781 }
11782 if (!hasOwnProperty(visibleKeys, key)) {
11783 name = '[' + key + ']';
11784 }
11785 if (!str) {
11786 if (ctx.seen.indexOf(desc.value) < 0) {
11787 if (isNull(recurseTimes)) {
11788 str = formatValue(ctx, desc.value, null);
11789 } else {
11790 str = formatValue(ctx, desc.value, recurseTimes - 1);
11791 }
11792 if (str.indexOf('\n') > -1) {
11793 if (array) {
11794 str = str.split('\n').map(function(line) {
11795 return ' ' + line;
11796 }).join('\n').substr(2);
11797 } else {
11798 str = '\n' + str.split('\n').map(function(line) {
11799 return ' ' + line;
11800 }).join('\n');
11801 }
11802 }
11803 } else {
11804 str = ctx.stylize('[Circular]', 'special');
11805 }
11806 }
11807 if (isUndefined(name)) {
11808 if (array && key.match(/^\d+$/)) {
11809 return str;
11810 }
11811 name = JSON.stringify('' + key);
11812 if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
11813 name = name.substr(1, name.length - 2);
11814 name = ctx.stylize(name, 'name');
11815 } else {
11816 name = name.replace(/'/g, "\\'")
11817 .replace(/\\"/g, '"')
11818 .replace(/(^"|"$)/g, "'");
11819 name = ctx.stylize(name, 'string');
11820 }
11821 }
11822
11823 return name + ': ' + str;
11824}
11825
11826
11827function reduceToSingleString(output, base, braces) {
11828 var numLinesEst = 0;
11829 var length = output.reduce(function(prev, cur) {
11830 numLinesEst++;
11831 if (cur.indexOf('\n') >= 0) numLinesEst++;
11832 return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
11833 }, 0);
11834
11835 if (length > 60) {
11836 return braces[0] +
11837 (base === '' ? '' : base + '\n ') +
11838 ' ' +
11839 output.join(',\n ') +
11840 ' ' +
11841 braces[1];
11842 }
11843
11844 return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
11845}
11846
11847
11848// NOTE: These type checking functions intentionally don't use `instanceof`
11849// because it is fragile and can be easily faked with `Object.create()`.
11850function isArray(ar) {
11851 return Array.isArray(ar);
11852}
11853exports.isArray = isArray;
11854
11855function isBoolean(arg) {
11856 return typeof arg === 'boolean';
11857}
11858exports.isBoolean = isBoolean;
11859
11860function isNull(arg) {
11861 return arg === null;
11862}
11863exports.isNull = isNull;
11864
11865function isNullOrUndefined(arg) {
11866 return arg == null;
11867}
11868exports.isNullOrUndefined = isNullOrUndefined;
11869
11870function isNumber(arg) {
11871 return typeof arg === 'number';
11872}
11873exports.isNumber = isNumber;
11874
11875function isString(arg) {
11876 return typeof arg === 'string';
11877}
11878exports.isString = isString;
11879
11880function isSymbol(arg) {
11881 return typeof arg === 'symbol';
11882}
11883exports.isSymbol = isSymbol;
11884
11885function isUndefined(arg) {
11886 return arg === void 0;
11887}
11888exports.isUndefined = isUndefined;
11889
11890function isRegExp(re) {
11891 return isObject(re) && objectToString(re) === '[object RegExp]';
11892}
11893exports.isRegExp = isRegExp;
11894
11895function isObject(arg) {
11896 return typeof arg === 'object' && arg !== null;
11897}
11898exports.isObject = isObject;
11899
11900function isDate(d) {
11901 return isObject(d) && objectToString(d) === '[object Date]';
11902}
11903exports.isDate = isDate;
11904
11905function isError(e) {
11906 return isObject(e) &&
11907 (objectToString(e) === '[object Error]' || e instanceof Error);
11908}
11909exports.isError = isError;
11910
11911function isFunction(arg) {
11912 return typeof arg === 'function';
11913}
11914exports.isFunction = isFunction;
11915
11916function isPrimitive(arg) {
11917 return arg === null ||
11918 typeof arg === 'boolean' ||
11919 typeof arg === 'number' ||
11920 typeof arg === 'string' ||
11921 typeof arg === 'symbol' || // ES6 symbol
11922 typeof arg === 'undefined';
11923}
11924exports.isPrimitive = isPrimitive;
11925
11926exports.isBuffer = require('./support/isBuffer');
11927
11928function objectToString(o) {
11929 return Object.prototype.toString.call(o);
11930}
11931
11932
11933function pad(n) {
11934 return n < 10 ? '0' + n.toString(10) : n.toString(10);
11935}
11936
11937
11938var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
11939 'Oct', 'Nov', 'Dec'];
11940
11941// 26 Feb 16:19:34
11942function timestamp() {
11943 var d = new Date();
11944 var time = [pad(d.getHours()),
11945 pad(d.getMinutes()),
11946 pad(d.getSeconds())].join(':');
11947 return [d.getDate(), months[d.getMonth()], time].join(' ');
11948}
11949
11950
11951// log is just a thin wrapper to console.log that prepends a timestamp
11952exports.log = function() {
11953 console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
11954};
11955
11956
11957/**
11958 * Inherit the prototype methods from one constructor into another.
11959 *
11960 * The Function.prototype.inherits from lang.js rewritten as a standalone
11961 * function (not on Function.prototype). NOTE: If this file is to be loaded
11962 * during bootstrapping this function needs to be rewritten using some native
11963 * functions as prototype setup using normal JavaScript does not work as
11964 * expected during bootstrapping (see mirror.js in r114903).
11965 *
11966 * @param {function} ctor Constructor function which needs to inherit the
11967 * prototype.
11968 * @param {function} superCtor Constructor function to inherit prototype from.
11969 */
11970exports.inherits = require('inherits');
11971
11972exports._extend = function(origin, add) {
11973 // Don't do anything if add isn't an object
11974 if (!add || !isObject(add)) return origin;
11975
11976 var keys = Object.keys(add);
11977 var i = keys.length;
11978 while (i--) {
11979 origin[keys[i]] = add[keys[i]];
11980 }
11981 return origin;
11982};
11983
11984function hasOwnProperty(obj, prop) {
11985 return Object.prototype.hasOwnProperty.call(obj, prop);
11986}
11987
11988}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
11989},{"./support/isBuffer":92,"_process":105,"inherits":91}],94:[function(require,module,exports){
11990'use strict'
11991
11992exports.byteLength = byteLength
11993exports.toByteArray = toByteArray
11994exports.fromByteArray = fromByteArray
11995
11996var lookup = []
11997var revLookup = []
11998var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
11999
12000var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
12001for (var i = 0, len = code.length; i < len; ++i) {
12002 lookup[i] = code[i]
12003 revLookup[code.charCodeAt(i)] = i
12004}
12005
12006// Support decoding URL-safe base64 strings, as Node.js does.
12007// See: https://en.wikipedia.org/wiki/Base64#URL_applications
12008revLookup['-'.charCodeAt(0)] = 62
12009revLookup['_'.charCodeAt(0)] = 63
12010
12011function getLens (b64) {
12012 var len = b64.length
12013
12014 if (len % 4 > 0) {
12015 throw new Error('Invalid string. Length must be a multiple of 4')
12016 }
12017
12018 // Trim off extra bytes after placeholder bytes are found
12019 // See: https://github.com/beatgammit/base64-js/issues/42
12020 var validLen = b64.indexOf('=')
12021 if (validLen === -1) validLen = len
12022
12023 var placeHoldersLen = validLen === len
12024 ? 0
12025 : 4 - (validLen % 4)
12026
12027 return [validLen, placeHoldersLen]
12028}
12029
12030// base64 is 4/3 + up to two characters of the original data
12031function byteLength (b64) {
12032 var lens = getLens(b64)
12033 var validLen = lens[0]
12034 var placeHoldersLen = lens[1]
12035 return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
12036}
12037
12038function _byteLength (b64, validLen, placeHoldersLen) {
12039 return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
12040}
12041
12042function toByteArray (b64) {
12043 var tmp
12044 var lens = getLens(b64)
12045 var validLen = lens[0]
12046 var placeHoldersLen = lens[1]
12047
12048 var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
12049
12050 var curByte = 0
12051
12052 // if there are placeholders, only get up to the last complete 4 chars
12053 var len = placeHoldersLen > 0
12054 ? validLen - 4
12055 : validLen
12056
12057 var i
12058 for (i = 0; i < len; i += 4) {
12059 tmp =
12060 (revLookup[b64.charCodeAt(i)] << 18) |
12061 (revLookup[b64.charCodeAt(i + 1)] << 12) |
12062 (revLookup[b64.charCodeAt(i + 2)] << 6) |
12063 revLookup[b64.charCodeAt(i + 3)]
12064 arr[curByte++] = (tmp >> 16) & 0xFF
12065 arr[curByte++] = (tmp >> 8) & 0xFF
12066 arr[curByte++] = tmp & 0xFF
12067 }
12068
12069 if (placeHoldersLen === 2) {
12070 tmp =
12071 (revLookup[b64.charCodeAt(i)] << 2) |
12072 (revLookup[b64.charCodeAt(i + 1)] >> 4)
12073 arr[curByte++] = tmp & 0xFF
12074 }
12075
12076 if (placeHoldersLen === 1) {
12077 tmp =
12078 (revLookup[b64.charCodeAt(i)] << 10) |
12079 (revLookup[b64.charCodeAt(i + 1)] << 4) |
12080 (revLookup[b64.charCodeAt(i + 2)] >> 2)
12081 arr[curByte++] = (tmp >> 8) & 0xFF
12082 arr[curByte++] = tmp & 0xFF
12083 }
12084
12085 return arr
12086}
12087
12088function tripletToBase64 (num) {
12089 return lookup[num >> 18 & 0x3F] +
12090 lookup[num >> 12 & 0x3F] +
12091 lookup[num >> 6 & 0x3F] +
12092 lookup[num & 0x3F]
12093}
12094
12095function encodeChunk (uint8, start, end) {
12096 var tmp
12097 var output = []
12098 for (var i = start; i < end; i += 3) {
12099 tmp =
12100 ((uint8[i] << 16) & 0xFF0000) +
12101 ((uint8[i + 1] << 8) & 0xFF00) +
12102 (uint8[i + 2] & 0xFF)
12103 output.push(tripletToBase64(tmp))
12104 }
12105 return output.join('')
12106}
12107
12108function fromByteArray (uint8) {
12109 var tmp
12110 var len = uint8.length
12111 var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
12112 var parts = []
12113 var maxChunkLength = 16383 // must be multiple of 3
12114
12115 // go through the array every three bytes, we'll deal with trailing stuff later
12116 for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
12117 parts.push(encodeChunk(
12118 uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
12119 ))
12120 }
12121
12122 // pad the end with zeros, but make sure to not forget the extra bytes
12123 if (extraBytes === 1) {
12124 tmp = uint8[len - 1]
12125 parts.push(
12126 lookup[tmp >> 2] +
12127 lookup[(tmp << 4) & 0x3F] +
12128 '=='
12129 )
12130 } else if (extraBytes === 2) {
12131 tmp = (uint8[len - 2] << 8) + uint8[len - 1]
12132 parts.push(
12133 lookup[tmp >> 10] +
12134 lookup[(tmp >> 4) & 0x3F] +
12135 lookup[(tmp << 2) & 0x3F] +
12136 '='
12137 )
12138 }
12139
12140 return parts.join('')
12141}
12142
12143},{}],95:[function(require,module,exports){
12144
12145},{}],96:[function(require,module,exports){
12146(function (Buffer){
12147/*!
12148 * The buffer module from node.js, for the browser.
12149 *
12150 * @author Feross Aboukhadijeh <https://feross.org>
12151 * @license MIT
12152 */
12153/* eslint-disable no-proto */
12154
12155'use strict'
12156
12157var base64 = require('base64-js')
12158var ieee754 = require('ieee754')
12159var customInspectSymbol =
12160 (typeof Symbol === 'function' && typeof Symbol.for === 'function')
12161 ? Symbol.for('nodejs.util.inspect.custom')
12162 : null
12163
12164exports.Buffer = Buffer
12165exports.SlowBuffer = SlowBuffer
12166exports.INSPECT_MAX_BYTES = 50
12167
12168var K_MAX_LENGTH = 0x7fffffff
12169exports.kMaxLength = K_MAX_LENGTH
12170
12171/**
12172 * If `Buffer.TYPED_ARRAY_SUPPORT`:
12173 * === true Use Uint8Array implementation (fastest)
12174 * === false Print warning and recommend using `buffer` v4.x which has an Object
12175 * implementation (most compatible, even IE6)
12176 *
12177 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
12178 * Opera 11.6+, iOS 4.2+.
12179 *
12180 * We report that the browser does not support typed arrays if the are not subclassable
12181 * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
12182 * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
12183 * for __proto__ and has a buggy typed array implementation.
12184 */
12185Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
12186
12187if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
12188 typeof console.error === 'function') {
12189 console.error(
12190 'This browser lacks typed array (Uint8Array) support which is required by ' +
12191 '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
12192 )
12193}
12194
12195function typedArraySupport () {
12196 // Can typed array instances can be augmented?
12197 try {
12198 var arr = new Uint8Array(1)
12199 var proto = { foo: function () { return 42 } }
12200 Object.setPrototypeOf(proto, Uint8Array.prototype)
12201 Object.setPrototypeOf(arr, proto)
12202 return arr.foo() === 42
12203 } catch (e) {
12204 return false
12205 }
12206}
12207
12208Object.defineProperty(Buffer.prototype, 'parent', {
12209 enumerable: true,
12210 get: function () {
12211 if (!Buffer.isBuffer(this)) return undefined
12212 return this.buffer
12213 }
12214})
12215
12216Object.defineProperty(Buffer.prototype, 'offset', {
12217 enumerable: true,
12218 get: function () {
12219 if (!Buffer.isBuffer(this)) return undefined
12220 return this.byteOffset
12221 }
12222})
12223
12224function createBuffer (length) {
12225 if (length > K_MAX_LENGTH) {
12226 throw new RangeError('The value "' + length + '" is invalid for option "size"')
12227 }
12228 // Return an augmented `Uint8Array` instance
12229 var buf = new Uint8Array(length)
12230 Object.setPrototypeOf(buf, Buffer.prototype)
12231 return buf
12232}
12233
12234/**
12235 * The Buffer constructor returns instances of `Uint8Array` that have their
12236 * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
12237 * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
12238 * and the `Uint8Array` methods. Square bracket notation works as expected -- it
12239 * returns a single octet.
12240 *
12241 * The `Uint8Array` prototype remains unmodified.
12242 */
12243
12244function Buffer (arg, encodingOrOffset, length) {
12245 // Common case.
12246 if (typeof arg === 'number') {
12247 if (typeof encodingOrOffset === 'string') {
12248 throw new TypeError(
12249 'The "string" argument must be of type string. Received type number'
12250 )
12251 }
12252 return allocUnsafe(arg)
12253 }
12254 return from(arg, encodingOrOffset, length)
12255}
12256
12257// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
12258if (typeof Symbol !== 'undefined' && Symbol.species != null &&
12259 Buffer[Symbol.species] === Buffer) {
12260 Object.defineProperty(Buffer, Symbol.species, {
12261 value: null,
12262 configurable: true,
12263 enumerable: false,
12264 writable: false
12265 })
12266}
12267
12268Buffer.poolSize = 8192 // not used by this implementation
12269
12270function from (value, encodingOrOffset, length) {
12271 if (typeof value === 'string') {
12272 return fromString(value, encodingOrOffset)
12273 }
12274
12275 if (ArrayBuffer.isView(value)) {
12276 return fromArrayLike(value)
12277 }
12278
12279 if (value == null) {
12280 throw new TypeError(
12281 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
12282 'or Array-like Object. Received type ' + (typeof value)
12283 )
12284 }
12285
12286 if (isInstance(value, ArrayBuffer) ||
12287 (value && isInstance(value.buffer, ArrayBuffer))) {
12288 return fromArrayBuffer(value, encodingOrOffset, length)
12289 }
12290
12291 if (typeof value === 'number') {
12292 throw new TypeError(
12293 'The "value" argument must not be of type number. Received type number'
12294 )
12295 }
12296
12297 var valueOf = value.valueOf && value.valueOf()
12298 if (valueOf != null && valueOf !== value) {
12299 return Buffer.from(valueOf, encodingOrOffset, length)
12300 }
12301
12302 var b = fromObject(value)
12303 if (b) return b
12304
12305 if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
12306 typeof value[Symbol.toPrimitive] === 'function') {
12307 return Buffer.from(
12308 value[Symbol.toPrimitive]('string'), encodingOrOffset, length
12309 )
12310 }
12311
12312 throw new TypeError(
12313 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
12314 'or Array-like Object. Received type ' + (typeof value)
12315 )
12316}
12317
12318/**
12319 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
12320 * if value is a number.
12321 * Buffer.from(str[, encoding])
12322 * Buffer.from(array)
12323 * Buffer.from(buffer)
12324 * Buffer.from(arrayBuffer[, byteOffset[, length]])
12325 **/
12326Buffer.from = function (value, encodingOrOffset, length) {
12327 return from(value, encodingOrOffset, length)
12328}
12329
12330// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
12331// https://github.com/feross/buffer/pull/148
12332Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype)
12333Object.setPrototypeOf(Buffer, Uint8Array)
12334
12335function assertSize (size) {
12336 if (typeof size !== 'number') {
12337 throw new TypeError('"size" argument must be of type number')
12338 } else if (size < 0) {
12339 throw new RangeError('The value "' + size + '" is invalid for option "size"')
12340 }
12341}
12342
12343function alloc (size, fill, encoding) {
12344 assertSize(size)
12345 if (size <= 0) {
12346 return createBuffer(size)
12347 }
12348 if (fill !== undefined) {
12349 // Only pay attention to encoding if it's a string. This
12350 // prevents accidentally sending in a number that would
12351 // be interpretted as a start offset.
12352 return typeof encoding === 'string'
12353 ? createBuffer(size).fill(fill, encoding)
12354 : createBuffer(size).fill(fill)
12355 }
12356 return createBuffer(size)
12357}
12358
12359/**
12360 * Creates a new filled Buffer instance.
12361 * alloc(size[, fill[, encoding]])
12362 **/
12363Buffer.alloc = function (size, fill, encoding) {
12364 return alloc(size, fill, encoding)
12365}
12366
12367function allocUnsafe (size) {
12368 assertSize(size)
12369 return createBuffer(size < 0 ? 0 : checked(size) | 0)
12370}
12371
12372/**
12373 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
12374 * */
12375Buffer.allocUnsafe = function (size) {
12376 return allocUnsafe(size)
12377}
12378/**
12379 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
12380 */
12381Buffer.allocUnsafeSlow = function (size) {
12382 return allocUnsafe(size)
12383}
12384
12385function fromString (string, encoding) {
12386 if (typeof encoding !== 'string' || encoding === '') {
12387 encoding = 'utf8'
12388 }
12389
12390 if (!Buffer.isEncoding(encoding)) {
12391 throw new TypeError('Unknown encoding: ' + encoding)
12392 }
12393
12394 var length = byteLength(string, encoding) | 0
12395 var buf = createBuffer(length)
12396
12397 var actual = buf.write(string, encoding)
12398
12399 if (actual !== length) {
12400 // Writing a hex string, for example, that contains invalid characters will
12401 // cause everything after the first invalid character to be ignored. (e.g.
12402 // 'abxxcd' will be treated as 'ab')
12403 buf = buf.slice(0, actual)
12404 }
12405
12406 return buf
12407}
12408
12409function fromArrayLike (array) {
12410 var length = array.length < 0 ? 0 : checked(array.length) | 0
12411 var buf = createBuffer(length)
12412 for (var i = 0; i < length; i += 1) {
12413 buf[i] = array[i] & 255
12414 }
12415 return buf
12416}
12417
12418function fromArrayBuffer (array, byteOffset, length) {
12419 if (byteOffset < 0 || array.byteLength < byteOffset) {
12420 throw new RangeError('"offset" is outside of buffer bounds')
12421 }
12422
12423 if (array.byteLength < byteOffset + (length || 0)) {
12424 throw new RangeError('"length" is outside of buffer bounds')
12425 }
12426
12427 var buf
12428 if (byteOffset === undefined && length === undefined) {
12429 buf = new Uint8Array(array)
12430 } else if (length === undefined) {
12431 buf = new Uint8Array(array, byteOffset)
12432 } else {
12433 buf = new Uint8Array(array, byteOffset, length)
12434 }
12435
12436 // Return an augmented `Uint8Array` instance
12437 Object.setPrototypeOf(buf, Buffer.prototype)
12438
12439 return buf
12440}
12441
12442function fromObject (obj) {
12443 if (Buffer.isBuffer(obj)) {
12444 var len = checked(obj.length) | 0
12445 var buf = createBuffer(len)
12446
12447 if (buf.length === 0) {
12448 return buf
12449 }
12450
12451 obj.copy(buf, 0, 0, len)
12452 return buf
12453 }
12454
12455 if (obj.length !== undefined) {
12456 if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
12457 return createBuffer(0)
12458 }
12459 return fromArrayLike(obj)
12460 }
12461
12462 if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
12463 return fromArrayLike(obj.data)
12464 }
12465}
12466
12467function checked (length) {
12468 // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
12469 // length is NaN (which is otherwise coerced to zero.)
12470 if (length >= K_MAX_LENGTH) {
12471 throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
12472 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
12473 }
12474 return length | 0
12475}
12476
12477function SlowBuffer (length) {
12478 if (+length != length) { // eslint-disable-line eqeqeq
12479 length = 0
12480 }
12481 return Buffer.alloc(+length)
12482}
12483
12484Buffer.isBuffer = function isBuffer (b) {
12485 return b != null && b._isBuffer === true &&
12486 b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
12487}
12488
12489Buffer.compare = function compare (a, b) {
12490 if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)
12491 if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)
12492 if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
12493 throw new TypeError(
12494 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
12495 )
12496 }
12497
12498 if (a === b) return 0
12499
12500 var x = a.length
12501 var y = b.length
12502
12503 for (var i = 0, len = Math.min(x, y); i < len; ++i) {
12504 if (a[i] !== b[i]) {
12505 x = a[i]
12506 y = b[i]
12507 break
12508 }
12509 }
12510
12511 if (x < y) return -1
12512 if (y < x) return 1
12513 return 0
12514}
12515
12516Buffer.isEncoding = function isEncoding (encoding) {
12517 switch (String(encoding).toLowerCase()) {
12518 case 'hex':
12519 case 'utf8':
12520 case 'utf-8':
12521 case 'ascii':
12522 case 'latin1':
12523 case 'binary':
12524 case 'base64':
12525 case 'ucs2':
12526 case 'ucs-2':
12527 case 'utf16le':
12528 case 'utf-16le':
12529 return true
12530 default:
12531 return false
12532 }
12533}
12534
12535Buffer.concat = function concat (list, length) {
12536 if (!Array.isArray(list)) {
12537 throw new TypeError('"list" argument must be an Array of Buffers')
12538 }
12539
12540 if (list.length === 0) {
12541 return Buffer.alloc(0)
12542 }
12543
12544 var i
12545 if (length === undefined) {
12546 length = 0
12547 for (i = 0; i < list.length; ++i) {
12548 length += list[i].length
12549 }
12550 }
12551
12552 var buffer = Buffer.allocUnsafe(length)
12553 var pos = 0
12554 for (i = 0; i < list.length; ++i) {
12555 var buf = list[i]
12556 if (isInstance(buf, Uint8Array)) {
12557 buf = Buffer.from(buf)
12558 }
12559 if (!Buffer.isBuffer(buf)) {
12560 throw new TypeError('"list" argument must be an Array of Buffers')
12561 }
12562 buf.copy(buffer, pos)
12563 pos += buf.length
12564 }
12565 return buffer
12566}
12567
12568function byteLength (string, encoding) {
12569 if (Buffer.isBuffer(string)) {
12570 return string.length
12571 }
12572 if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
12573 return string.byteLength
12574 }
12575 if (typeof string !== 'string') {
12576 throw new TypeError(
12577 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
12578 'Received type ' + typeof string
12579 )
12580 }
12581
12582 var len = string.length
12583 var mustMatch = (arguments.length > 2 && arguments[2] === true)
12584 if (!mustMatch && len === 0) return 0
12585
12586 // Use a for loop to avoid recursion
12587 var loweredCase = false
12588 for (;;) {
12589 switch (encoding) {
12590 case 'ascii':
12591 case 'latin1':
12592 case 'binary':
12593 return len
12594 case 'utf8':
12595 case 'utf-8':
12596 return utf8ToBytes(string).length
12597 case 'ucs2':
12598 case 'ucs-2':
12599 case 'utf16le':
12600 case 'utf-16le':
12601 return len * 2
12602 case 'hex':
12603 return len >>> 1
12604 case 'base64':
12605 return base64ToBytes(string).length
12606 default:
12607 if (loweredCase) {
12608 return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
12609 }
12610 encoding = ('' + encoding).toLowerCase()
12611 loweredCase = true
12612 }
12613 }
12614}
12615Buffer.byteLength = byteLength
12616
12617function slowToString (encoding, start, end) {
12618 var loweredCase = false
12619
12620 // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
12621 // property of a typed array.
12622
12623 // This behaves neither like String nor Uint8Array in that we set start/end
12624 // to their upper/lower bounds if the value passed is out of range.
12625 // undefined is handled specially as per ECMA-262 6th Edition,
12626 // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
12627 if (start === undefined || start < 0) {
12628 start = 0
12629 }
12630 // Return early if start > this.length. Done here to prevent potential uint32
12631 // coercion fail below.
12632 if (start > this.length) {
12633 return ''
12634 }
12635
12636 if (end === undefined || end > this.length) {
12637 end = this.length
12638 }
12639
12640 if (end <= 0) {
12641 return ''
12642 }
12643
12644 // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
12645 end >>>= 0
12646 start >>>= 0
12647
12648 if (end <= start) {
12649 return ''
12650 }
12651
12652 if (!encoding) encoding = 'utf8'
12653
12654 while (true) {
12655 switch (encoding) {
12656 case 'hex':
12657 return hexSlice(this, start, end)
12658
12659 case 'utf8':
12660 case 'utf-8':
12661 return utf8Slice(this, start, end)
12662
12663 case 'ascii':
12664 return asciiSlice(this, start, end)
12665
12666 case 'latin1':
12667 case 'binary':
12668 return latin1Slice(this, start, end)
12669
12670 case 'base64':
12671 return base64Slice(this, start, end)
12672
12673 case 'ucs2':
12674 case 'ucs-2':
12675 case 'utf16le':
12676 case 'utf-16le':
12677 return utf16leSlice(this, start, end)
12678
12679 default:
12680 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
12681 encoding = (encoding + '').toLowerCase()
12682 loweredCase = true
12683 }
12684 }
12685}
12686
12687// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
12688// to detect a Buffer instance. It's not possible to use `instanceof Buffer`
12689// reliably in a browserify context because there could be multiple different
12690// copies of the 'buffer' package in use. This method works even for Buffer
12691// instances that were created from another copy of the `buffer` package.
12692// See: https://github.com/feross/buffer/issues/154
12693Buffer.prototype._isBuffer = true
12694
12695function swap (b, n, m) {
12696 var i = b[n]
12697 b[n] = b[m]
12698 b[m] = i
12699}
12700
12701Buffer.prototype.swap16 = function swap16 () {
12702 var len = this.length
12703 if (len % 2 !== 0) {
12704 throw new RangeError('Buffer size must be a multiple of 16-bits')
12705 }
12706 for (var i = 0; i < len; i += 2) {
12707 swap(this, i, i + 1)
12708 }
12709 return this
12710}
12711
12712Buffer.prototype.swap32 = function swap32 () {
12713 var len = this.length
12714 if (len % 4 !== 0) {
12715 throw new RangeError('Buffer size must be a multiple of 32-bits')
12716 }
12717 for (var i = 0; i < len; i += 4) {
12718 swap(this, i, i + 3)
12719 swap(this, i + 1, i + 2)
12720 }
12721 return this
12722}
12723
12724Buffer.prototype.swap64 = function swap64 () {
12725 var len = this.length
12726 if (len % 8 !== 0) {
12727 throw new RangeError('Buffer size must be a multiple of 64-bits')
12728 }
12729 for (var i = 0; i < len; i += 8) {
12730 swap(this, i, i + 7)
12731 swap(this, i + 1, i + 6)
12732 swap(this, i + 2, i + 5)
12733 swap(this, i + 3, i + 4)
12734 }
12735 return this
12736}
12737
12738Buffer.prototype.toString = function toString () {
12739 var length = this.length
12740 if (length === 0) return ''
12741 if (arguments.length === 0) return utf8Slice(this, 0, length)
12742 return slowToString.apply(this, arguments)
12743}
12744
12745Buffer.prototype.toLocaleString = Buffer.prototype.toString
12746
12747Buffer.prototype.equals = function equals (b) {
12748 if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
12749 if (this === b) return true
12750 return Buffer.compare(this, b) === 0
12751}
12752
12753Buffer.prototype.inspect = function inspect () {
12754 var str = ''
12755 var max = exports.INSPECT_MAX_BYTES
12756 str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()
12757 if (this.length > max) str += ' ... '
12758 return '<Buffer ' + str + '>'
12759}
12760if (customInspectSymbol) {
12761 Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect
12762}
12763
12764Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
12765 if (isInstance(target, Uint8Array)) {
12766 target = Buffer.from(target, target.offset, target.byteLength)
12767 }
12768 if (!Buffer.isBuffer(target)) {
12769 throw new TypeError(
12770 'The "target" argument must be one of type Buffer or Uint8Array. ' +
12771 'Received type ' + (typeof target)
12772 )
12773 }
12774
12775 if (start === undefined) {
12776 start = 0
12777 }
12778 if (end === undefined) {
12779 end = target ? target.length : 0
12780 }
12781 if (thisStart === undefined) {
12782 thisStart = 0
12783 }
12784 if (thisEnd === undefined) {
12785 thisEnd = this.length
12786 }
12787
12788 if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
12789 throw new RangeError('out of range index')
12790 }
12791
12792 if (thisStart >= thisEnd && start >= end) {
12793 return 0
12794 }
12795 if (thisStart >= thisEnd) {
12796 return -1
12797 }
12798 if (start >= end) {
12799 return 1
12800 }
12801
12802 start >>>= 0
12803 end >>>= 0
12804 thisStart >>>= 0
12805 thisEnd >>>= 0
12806
12807 if (this === target) return 0
12808
12809 var x = thisEnd - thisStart
12810 var y = end - start
12811 var len = Math.min(x, y)
12812
12813 var thisCopy = this.slice(thisStart, thisEnd)
12814 var targetCopy = target.slice(start, end)
12815
12816 for (var i = 0; i < len; ++i) {
12817 if (thisCopy[i] !== targetCopy[i]) {
12818 x = thisCopy[i]
12819 y = targetCopy[i]
12820 break
12821 }
12822 }
12823
12824 if (x < y) return -1
12825 if (y < x) return 1
12826 return 0
12827}
12828
12829// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
12830// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
12831//
12832// Arguments:
12833// - buffer - a Buffer to search
12834// - val - a string, Buffer, or number
12835// - byteOffset - an index into `buffer`; will be clamped to an int32
12836// - encoding - an optional encoding, relevant is val is a string
12837// - dir - true for indexOf, false for lastIndexOf
12838function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
12839 // Empty buffer means no match
12840 if (buffer.length === 0) return -1
12841
12842 // Normalize byteOffset
12843 if (typeof byteOffset === 'string') {
12844 encoding = byteOffset
12845 byteOffset = 0
12846 } else if (byteOffset > 0x7fffffff) {
12847 byteOffset = 0x7fffffff
12848 } else if (byteOffset < -0x80000000) {
12849 byteOffset = -0x80000000
12850 }
12851 byteOffset = +byteOffset // Coerce to Number.
12852 if (numberIsNaN(byteOffset)) {
12853 // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
12854 byteOffset = dir ? 0 : (buffer.length - 1)
12855 }
12856
12857 // Normalize byteOffset: negative offsets start from the end of the buffer
12858 if (byteOffset < 0) byteOffset = buffer.length + byteOffset
12859 if (byteOffset >= buffer.length) {
12860 if (dir) return -1
12861 else byteOffset = buffer.length - 1
12862 } else if (byteOffset < 0) {
12863 if (dir) byteOffset = 0
12864 else return -1
12865 }
12866
12867 // Normalize val
12868 if (typeof val === 'string') {
12869 val = Buffer.from(val, encoding)
12870 }
12871
12872 // Finally, search either indexOf (if dir is true) or lastIndexOf
12873 if (Buffer.isBuffer(val)) {
12874 // Special case: looking for empty string/buffer always fails
12875 if (val.length === 0) {
12876 return -1
12877 }
12878 return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
12879 } else if (typeof val === 'number') {
12880 val = val & 0xFF // Search for a byte value [0-255]
12881 if (typeof Uint8Array.prototype.indexOf === 'function') {
12882 if (dir) {
12883 return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
12884 } else {
12885 return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
12886 }
12887 }
12888 return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)
12889 }
12890
12891 throw new TypeError('val must be string, number or Buffer')
12892}
12893
12894function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
12895 var indexSize = 1
12896 var arrLength = arr.length
12897 var valLength = val.length
12898
12899 if (encoding !== undefined) {
12900 encoding = String(encoding).toLowerCase()
12901 if (encoding === 'ucs2' || encoding === 'ucs-2' ||
12902 encoding === 'utf16le' || encoding === 'utf-16le') {
12903 if (arr.length < 2 || val.length < 2) {
12904 return -1
12905 }
12906 indexSize = 2
12907 arrLength /= 2
12908 valLength /= 2
12909 byteOffset /= 2
12910 }
12911 }
12912
12913 function read (buf, i) {
12914 if (indexSize === 1) {
12915 return buf[i]
12916 } else {
12917 return buf.readUInt16BE(i * indexSize)
12918 }
12919 }
12920
12921 var i
12922 if (dir) {
12923 var foundIndex = -1
12924 for (i = byteOffset; i < arrLength; i++) {
12925 if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
12926 if (foundIndex === -1) foundIndex = i
12927 if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
12928 } else {
12929 if (foundIndex !== -1) i -= i - foundIndex
12930 foundIndex = -1
12931 }
12932 }
12933 } else {
12934 if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
12935 for (i = byteOffset; i >= 0; i--) {
12936 var found = true
12937 for (var j = 0; j < valLength; j++) {
12938 if (read(arr, i + j) !== read(val, j)) {
12939 found = false
12940 break
12941 }
12942 }
12943 if (found) return i
12944 }
12945 }
12946
12947 return -1
12948}
12949
12950Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
12951 return this.indexOf(val, byteOffset, encoding) !== -1
12952}
12953
12954Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
12955 return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
12956}
12957
12958Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
12959 return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
12960}
12961
12962function hexWrite (buf, string, offset, length) {
12963 offset = Number(offset) || 0
12964 var remaining = buf.length - offset
12965 if (!length) {
12966 length = remaining
12967 } else {
12968 length = Number(length)
12969 if (length > remaining) {
12970 length = remaining
12971 }
12972 }
12973
12974 var strLen = string.length
12975
12976 if (length > strLen / 2) {
12977 length = strLen / 2
12978 }
12979 for (var i = 0; i < length; ++i) {
12980 var parsed = parseInt(string.substr(i * 2, 2), 16)
12981 if (numberIsNaN(parsed)) return i
12982 buf[offset + i] = parsed
12983 }
12984 return i
12985}
12986
12987function utf8Write (buf, string, offset, length) {
12988 return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
12989}
12990
12991function asciiWrite (buf, string, offset, length) {
12992 return blitBuffer(asciiToBytes(string), buf, offset, length)
12993}
12994
12995function latin1Write (buf, string, offset, length) {
12996 return asciiWrite(buf, string, offset, length)
12997}
12998
12999function base64Write (buf, string, offset, length) {
13000 return blitBuffer(base64ToBytes(string), buf, offset, length)
13001}
13002
13003function ucs2Write (buf, string, offset, length) {
13004 return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
13005}
13006
13007Buffer.prototype.write = function write (string, offset, length, encoding) {
13008 // Buffer#write(string)
13009 if (offset === undefined) {
13010 encoding = 'utf8'
13011 length = this.length
13012 offset = 0
13013 // Buffer#write(string, encoding)
13014 } else if (length === undefined && typeof offset === 'string') {
13015 encoding = offset
13016 length = this.length
13017 offset = 0
13018 // Buffer#write(string, offset[, length][, encoding])
13019 } else if (isFinite(offset)) {
13020 offset = offset >>> 0
13021 if (isFinite(length)) {
13022 length = length >>> 0
13023 if (encoding === undefined) encoding = 'utf8'
13024 } else {
13025 encoding = length
13026 length = undefined
13027 }
13028 } else {
13029 throw new Error(
13030 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
13031 )
13032 }
13033
13034 var remaining = this.length - offset
13035 if (length === undefined || length > remaining) length = remaining
13036
13037 if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
13038 throw new RangeError('Attempt to write outside buffer bounds')
13039 }
13040
13041 if (!encoding) encoding = 'utf8'
13042
13043 var loweredCase = false
13044 for (;;) {
13045 switch (encoding) {
13046 case 'hex':
13047 return hexWrite(this, string, offset, length)
13048
13049 case 'utf8':
13050 case 'utf-8':
13051 return utf8Write(this, string, offset, length)
13052
13053 case 'ascii':
13054 return asciiWrite(this, string, offset, length)
13055
13056 case 'latin1':
13057 case 'binary':
13058 return latin1Write(this, string, offset, length)
13059
13060 case 'base64':
13061 // Warning: maxLength not taken into account in base64Write
13062 return base64Write(this, string, offset, length)
13063
13064 case 'ucs2':
13065 case 'ucs-2':
13066 case 'utf16le':
13067 case 'utf-16le':
13068 return ucs2Write(this, string, offset, length)
13069
13070 default:
13071 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
13072 encoding = ('' + encoding).toLowerCase()
13073 loweredCase = true
13074 }
13075 }
13076}
13077
13078Buffer.prototype.toJSON = function toJSON () {
13079 return {
13080 type: 'Buffer',
13081 data: Array.prototype.slice.call(this._arr || this, 0)
13082 }
13083}
13084
13085function base64Slice (buf, start, end) {
13086 if (start === 0 && end === buf.length) {
13087 return base64.fromByteArray(buf)
13088 } else {
13089 return base64.fromByteArray(buf.slice(start, end))
13090 }
13091}
13092
13093function utf8Slice (buf, start, end) {
13094 end = Math.min(buf.length, end)
13095 var res = []
13096
13097 var i = start
13098 while (i < end) {
13099 var firstByte = buf[i]
13100 var codePoint = null
13101 var bytesPerSequence = (firstByte > 0xEF) ? 4
13102 : (firstByte > 0xDF) ? 3
13103 : (firstByte > 0xBF) ? 2
13104 : 1
13105
13106 if (i + bytesPerSequence <= end) {
13107 var secondByte, thirdByte, fourthByte, tempCodePoint
13108
13109 switch (bytesPerSequence) {
13110 case 1:
13111 if (firstByte < 0x80) {
13112 codePoint = firstByte
13113 }
13114 break
13115 case 2:
13116 secondByte = buf[i + 1]
13117 if ((secondByte & 0xC0) === 0x80) {
13118 tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
13119 if (tempCodePoint > 0x7F) {
13120 codePoint = tempCodePoint
13121 }
13122 }
13123 break
13124 case 3:
13125 secondByte = buf[i + 1]
13126 thirdByte = buf[i + 2]
13127 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
13128 tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
13129 if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
13130 codePoint = tempCodePoint
13131 }
13132 }
13133 break
13134 case 4:
13135 secondByte = buf[i + 1]
13136 thirdByte = buf[i + 2]
13137 fourthByte = buf[i + 3]
13138 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
13139 tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
13140 if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
13141 codePoint = tempCodePoint
13142 }
13143 }
13144 }
13145 }
13146
13147 if (codePoint === null) {
13148 // we did not generate a valid codePoint so insert a
13149 // replacement char (U+FFFD) and advance only 1 byte
13150 codePoint = 0xFFFD
13151 bytesPerSequence = 1
13152 } else if (codePoint > 0xFFFF) {
13153 // encode to utf16 (surrogate pair dance)
13154 codePoint -= 0x10000
13155 res.push(codePoint >>> 10 & 0x3FF | 0xD800)
13156 codePoint = 0xDC00 | codePoint & 0x3FF
13157 }
13158
13159 res.push(codePoint)
13160 i += bytesPerSequence
13161 }
13162
13163 return decodeCodePointsArray(res)
13164}
13165
13166// Based on http://stackoverflow.com/a/22747272/680742, the browser with
13167// the lowest limit is Chrome, with 0x10000 args.
13168// We go 1 magnitude less, for safety
13169var MAX_ARGUMENTS_LENGTH = 0x1000
13170
13171function decodeCodePointsArray (codePoints) {
13172 var len = codePoints.length
13173 if (len <= MAX_ARGUMENTS_LENGTH) {
13174 return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
13175 }
13176
13177 // Decode in chunks to avoid "call stack size exceeded".
13178 var res = ''
13179 var i = 0
13180 while (i < len) {
13181 res += String.fromCharCode.apply(
13182 String,
13183 codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
13184 )
13185 }
13186 return res
13187}
13188
13189function asciiSlice (buf, start, end) {
13190 var ret = ''
13191 end = Math.min(buf.length, end)
13192
13193 for (var i = start; i < end; ++i) {
13194 ret += String.fromCharCode(buf[i] & 0x7F)
13195 }
13196 return ret
13197}
13198
13199function latin1Slice (buf, start, end) {
13200 var ret = ''
13201 end = Math.min(buf.length, end)
13202
13203 for (var i = start; i < end; ++i) {
13204 ret += String.fromCharCode(buf[i])
13205 }
13206 return ret
13207}
13208
13209function hexSlice (buf, start, end) {
13210 var len = buf.length
13211
13212 if (!start || start < 0) start = 0
13213 if (!end || end < 0 || end > len) end = len
13214
13215 var out = ''
13216 for (var i = start; i < end; ++i) {
13217 out += toHex(buf[i])
13218 }
13219 return out
13220}
13221
13222function utf16leSlice (buf, start, end) {
13223 var bytes = buf.slice(start, end)
13224 var res = ''
13225 for (var i = 0; i < bytes.length; i += 2) {
13226 res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
13227 }
13228 return res
13229}
13230
13231Buffer.prototype.slice = function slice (start, end) {
13232 var len = this.length
13233 start = ~~start
13234 end = end === undefined ? len : ~~end
13235
13236 if (start < 0) {
13237 start += len
13238 if (start < 0) start = 0
13239 } else if (start > len) {
13240 start = len
13241 }
13242
13243 if (end < 0) {
13244 end += len
13245 if (end < 0) end = 0
13246 } else if (end > len) {
13247 end = len
13248 }
13249
13250 if (end < start) end = start
13251
13252 var newBuf = this.subarray(start, end)
13253 // Return an augmented `Uint8Array` instance
13254 Object.setPrototypeOf(newBuf, Buffer.prototype)
13255
13256 return newBuf
13257}
13258
13259/*
13260 * Need to make sure that buffer isn't trying to write out of bounds.
13261 */
13262function checkOffset (offset, ext, length) {
13263 if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
13264 if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
13265}
13266
13267Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
13268 offset = offset >>> 0
13269 byteLength = byteLength >>> 0
13270 if (!noAssert) checkOffset(offset, byteLength, this.length)
13271
13272 var val = this[offset]
13273 var mul = 1
13274 var i = 0
13275 while (++i < byteLength && (mul *= 0x100)) {
13276 val += this[offset + i] * mul
13277 }
13278
13279 return val
13280}
13281
13282Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
13283 offset = offset >>> 0
13284 byteLength = byteLength >>> 0
13285 if (!noAssert) {
13286 checkOffset(offset, byteLength, this.length)
13287 }
13288
13289 var val = this[offset + --byteLength]
13290 var mul = 1
13291 while (byteLength > 0 && (mul *= 0x100)) {
13292 val += this[offset + --byteLength] * mul
13293 }
13294
13295 return val
13296}
13297
13298Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
13299 offset = offset >>> 0
13300 if (!noAssert) checkOffset(offset, 1, this.length)
13301 return this[offset]
13302}
13303
13304Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
13305 offset = offset >>> 0
13306 if (!noAssert) checkOffset(offset, 2, this.length)
13307 return this[offset] | (this[offset + 1] << 8)
13308}
13309
13310Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
13311 offset = offset >>> 0
13312 if (!noAssert) checkOffset(offset, 2, this.length)
13313 return (this[offset] << 8) | this[offset + 1]
13314}
13315
13316Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
13317 offset = offset >>> 0
13318 if (!noAssert) checkOffset(offset, 4, this.length)
13319
13320 return ((this[offset]) |
13321 (this[offset + 1] << 8) |
13322 (this[offset + 2] << 16)) +
13323 (this[offset + 3] * 0x1000000)
13324}
13325
13326Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
13327 offset = offset >>> 0
13328 if (!noAssert) checkOffset(offset, 4, this.length)
13329
13330 return (this[offset] * 0x1000000) +
13331 ((this[offset + 1] << 16) |
13332 (this[offset + 2] << 8) |
13333 this[offset + 3])
13334}
13335
13336Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
13337 offset = offset >>> 0
13338 byteLength = byteLength >>> 0
13339 if (!noAssert) checkOffset(offset, byteLength, this.length)
13340
13341 var val = this[offset]
13342 var mul = 1
13343 var i = 0
13344 while (++i < byteLength && (mul *= 0x100)) {
13345 val += this[offset + i] * mul
13346 }
13347 mul *= 0x80
13348
13349 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
13350
13351 return val
13352}
13353
13354Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
13355 offset = offset >>> 0
13356 byteLength = byteLength >>> 0
13357 if (!noAssert) checkOffset(offset, byteLength, this.length)
13358
13359 var i = byteLength
13360 var mul = 1
13361 var val = this[offset + --i]
13362 while (i > 0 && (mul *= 0x100)) {
13363 val += this[offset + --i] * mul
13364 }
13365 mul *= 0x80
13366
13367 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
13368
13369 return val
13370}
13371
13372Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
13373 offset = offset >>> 0
13374 if (!noAssert) checkOffset(offset, 1, this.length)
13375 if (!(this[offset] & 0x80)) return (this[offset])
13376 return ((0xff - this[offset] + 1) * -1)
13377}
13378
13379Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
13380 offset = offset >>> 0
13381 if (!noAssert) checkOffset(offset, 2, this.length)
13382 var val = this[offset] | (this[offset + 1] << 8)
13383 return (val & 0x8000) ? val | 0xFFFF0000 : val
13384}
13385
13386Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
13387 offset = offset >>> 0
13388 if (!noAssert) checkOffset(offset, 2, this.length)
13389 var val = this[offset + 1] | (this[offset] << 8)
13390 return (val & 0x8000) ? val | 0xFFFF0000 : val
13391}
13392
13393Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
13394 offset = offset >>> 0
13395 if (!noAssert) checkOffset(offset, 4, this.length)
13396
13397 return (this[offset]) |
13398 (this[offset + 1] << 8) |
13399 (this[offset + 2] << 16) |
13400 (this[offset + 3] << 24)
13401}
13402
13403Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
13404 offset = offset >>> 0
13405 if (!noAssert) checkOffset(offset, 4, this.length)
13406
13407 return (this[offset] << 24) |
13408 (this[offset + 1] << 16) |
13409 (this[offset + 2] << 8) |
13410 (this[offset + 3])
13411}
13412
13413Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
13414 offset = offset >>> 0
13415 if (!noAssert) checkOffset(offset, 4, this.length)
13416 return ieee754.read(this, offset, true, 23, 4)
13417}
13418
13419Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
13420 offset = offset >>> 0
13421 if (!noAssert) checkOffset(offset, 4, this.length)
13422 return ieee754.read(this, offset, false, 23, 4)
13423}
13424
13425Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
13426 offset = offset >>> 0
13427 if (!noAssert) checkOffset(offset, 8, this.length)
13428 return ieee754.read(this, offset, true, 52, 8)
13429}
13430
13431Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
13432 offset = offset >>> 0
13433 if (!noAssert) checkOffset(offset, 8, this.length)
13434 return ieee754.read(this, offset, false, 52, 8)
13435}
13436
13437function checkInt (buf, value, offset, ext, max, min) {
13438 if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
13439 if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
13440 if (offset + ext > buf.length) throw new RangeError('Index out of range')
13441}
13442
13443Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
13444 value = +value
13445 offset = offset >>> 0
13446 byteLength = byteLength >>> 0
13447 if (!noAssert) {
13448 var maxBytes = Math.pow(2, 8 * byteLength) - 1
13449 checkInt(this, value, offset, byteLength, maxBytes, 0)
13450 }
13451
13452 var mul = 1
13453 var i = 0
13454 this[offset] = value & 0xFF
13455 while (++i < byteLength && (mul *= 0x100)) {
13456 this[offset + i] = (value / mul) & 0xFF
13457 }
13458
13459 return offset + byteLength
13460}
13461
13462Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
13463 value = +value
13464 offset = offset >>> 0
13465 byteLength = byteLength >>> 0
13466 if (!noAssert) {
13467 var maxBytes = Math.pow(2, 8 * byteLength) - 1
13468 checkInt(this, value, offset, byteLength, maxBytes, 0)
13469 }
13470
13471 var i = byteLength - 1
13472 var mul = 1
13473 this[offset + i] = value & 0xFF
13474 while (--i >= 0 && (mul *= 0x100)) {
13475 this[offset + i] = (value / mul) & 0xFF
13476 }
13477
13478 return offset + byteLength
13479}
13480
13481Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
13482 value = +value
13483 offset = offset >>> 0
13484 if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
13485 this[offset] = (value & 0xff)
13486 return offset + 1
13487}
13488
13489Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
13490 value = +value
13491 offset = offset >>> 0
13492 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
13493 this[offset] = (value & 0xff)
13494 this[offset + 1] = (value >>> 8)
13495 return offset + 2
13496}
13497
13498Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
13499 value = +value
13500 offset = offset >>> 0
13501 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
13502 this[offset] = (value >>> 8)
13503 this[offset + 1] = (value & 0xff)
13504 return offset + 2
13505}
13506
13507Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
13508 value = +value
13509 offset = offset >>> 0
13510 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
13511 this[offset + 3] = (value >>> 24)
13512 this[offset + 2] = (value >>> 16)
13513 this[offset + 1] = (value >>> 8)
13514 this[offset] = (value & 0xff)
13515 return offset + 4
13516}
13517
13518Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
13519 value = +value
13520 offset = offset >>> 0
13521 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
13522 this[offset] = (value >>> 24)
13523 this[offset + 1] = (value >>> 16)
13524 this[offset + 2] = (value >>> 8)
13525 this[offset + 3] = (value & 0xff)
13526 return offset + 4
13527}
13528
13529Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
13530 value = +value
13531 offset = offset >>> 0
13532 if (!noAssert) {
13533 var limit = Math.pow(2, (8 * byteLength) - 1)
13534
13535 checkInt(this, value, offset, byteLength, limit - 1, -limit)
13536 }
13537
13538 var i = 0
13539 var mul = 1
13540 var sub = 0
13541 this[offset] = value & 0xFF
13542 while (++i < byteLength && (mul *= 0x100)) {
13543 if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
13544 sub = 1
13545 }
13546 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
13547 }
13548
13549 return offset + byteLength
13550}
13551
13552Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
13553 value = +value
13554 offset = offset >>> 0
13555 if (!noAssert) {
13556 var limit = Math.pow(2, (8 * byteLength) - 1)
13557
13558 checkInt(this, value, offset, byteLength, limit - 1, -limit)
13559 }
13560
13561 var i = byteLength - 1
13562 var mul = 1
13563 var sub = 0
13564 this[offset + i] = value & 0xFF
13565 while (--i >= 0 && (mul *= 0x100)) {
13566 if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
13567 sub = 1
13568 }
13569 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
13570 }
13571
13572 return offset + byteLength
13573}
13574
13575Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
13576 value = +value
13577 offset = offset >>> 0
13578 if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
13579 if (value < 0) value = 0xff + value + 1
13580 this[offset] = (value & 0xff)
13581 return offset + 1
13582}
13583
13584Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
13585 value = +value
13586 offset = offset >>> 0
13587 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
13588 this[offset] = (value & 0xff)
13589 this[offset + 1] = (value >>> 8)
13590 return offset + 2
13591}
13592
13593Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
13594 value = +value
13595 offset = offset >>> 0
13596 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
13597 this[offset] = (value >>> 8)
13598 this[offset + 1] = (value & 0xff)
13599 return offset + 2
13600}
13601
13602Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
13603 value = +value
13604 offset = offset >>> 0
13605 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
13606 this[offset] = (value & 0xff)
13607 this[offset + 1] = (value >>> 8)
13608 this[offset + 2] = (value >>> 16)
13609 this[offset + 3] = (value >>> 24)
13610 return offset + 4
13611}
13612
13613Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
13614 value = +value
13615 offset = offset >>> 0
13616 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
13617 if (value < 0) value = 0xffffffff + value + 1
13618 this[offset] = (value >>> 24)
13619 this[offset + 1] = (value >>> 16)
13620 this[offset + 2] = (value >>> 8)
13621 this[offset + 3] = (value & 0xff)
13622 return offset + 4
13623}
13624
13625function checkIEEE754 (buf, value, offset, ext, max, min) {
13626 if (offset + ext > buf.length) throw new RangeError('Index out of range')
13627 if (offset < 0) throw new RangeError('Index out of range')
13628}
13629
13630function writeFloat (buf, value, offset, littleEndian, noAssert) {
13631 value = +value
13632 offset = offset >>> 0
13633 if (!noAssert) {
13634 checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
13635 }
13636 ieee754.write(buf, value, offset, littleEndian, 23, 4)
13637 return offset + 4
13638}
13639
13640Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
13641 return writeFloat(this, value, offset, true, noAssert)
13642}
13643
13644Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
13645 return writeFloat(this, value, offset, false, noAssert)
13646}
13647
13648function writeDouble (buf, value, offset, littleEndian, noAssert) {
13649 value = +value
13650 offset = offset >>> 0
13651 if (!noAssert) {
13652 checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
13653 }
13654 ieee754.write(buf, value, offset, littleEndian, 52, 8)
13655 return offset + 8
13656}
13657
13658Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
13659 return writeDouble(this, value, offset, true, noAssert)
13660}
13661
13662Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
13663 return writeDouble(this, value, offset, false, noAssert)
13664}
13665
13666// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
13667Buffer.prototype.copy = function copy (target, targetStart, start, end) {
13668 if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
13669 if (!start) start = 0
13670 if (!end && end !== 0) end = this.length
13671 if (targetStart >= target.length) targetStart = target.length
13672 if (!targetStart) targetStart = 0
13673 if (end > 0 && end < start) end = start
13674
13675 // Copy 0 bytes; we're done
13676 if (end === start) return 0
13677 if (target.length === 0 || this.length === 0) return 0
13678
13679 // Fatal error conditions
13680 if (targetStart < 0) {
13681 throw new RangeError('targetStart out of bounds')
13682 }
13683 if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
13684 if (end < 0) throw new RangeError('sourceEnd out of bounds')
13685
13686 // Are we oob?
13687 if (end > this.length) end = this.length
13688 if (target.length - targetStart < end - start) {
13689 end = target.length - targetStart + start
13690 }
13691
13692 var len = end - start
13693
13694 if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
13695 // Use built-in when available, missing from IE11
13696 this.copyWithin(targetStart, start, end)
13697 } else if (this === target && start < targetStart && targetStart < end) {
13698 // descending copy from end
13699 for (var i = len - 1; i >= 0; --i) {
13700 target[i + targetStart] = this[i + start]
13701 }
13702 } else {
13703 Uint8Array.prototype.set.call(
13704 target,
13705 this.subarray(start, end),
13706 targetStart
13707 )
13708 }
13709
13710 return len
13711}
13712
13713// Usage:
13714// buffer.fill(number[, offset[, end]])
13715// buffer.fill(buffer[, offset[, end]])
13716// buffer.fill(string[, offset[, end]][, encoding])
13717Buffer.prototype.fill = function fill (val, start, end, encoding) {
13718 // Handle string cases:
13719 if (typeof val === 'string') {
13720 if (typeof start === 'string') {
13721 encoding = start
13722 start = 0
13723 end = this.length
13724 } else if (typeof end === 'string') {
13725 encoding = end
13726 end = this.length
13727 }
13728 if (encoding !== undefined && typeof encoding !== 'string') {
13729 throw new TypeError('encoding must be a string')
13730 }
13731 if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
13732 throw new TypeError('Unknown encoding: ' + encoding)
13733 }
13734 if (val.length === 1) {
13735 var code = val.charCodeAt(0)
13736 if ((encoding === 'utf8' && code < 128) ||
13737 encoding === 'latin1') {
13738 // Fast path: If `val` fits into a single byte, use that numeric value.
13739 val = code
13740 }
13741 }
13742 } else if (typeof val === 'number') {
13743 val = val & 255
13744 } else if (typeof val === 'boolean') {
13745 val = Number(val)
13746 }
13747
13748 // Invalid ranges are not set to a default, so can range check early.
13749 if (start < 0 || this.length < start || this.length < end) {
13750 throw new RangeError('Out of range index')
13751 }
13752
13753 if (end <= start) {
13754 return this
13755 }
13756
13757 start = start >>> 0
13758 end = end === undefined ? this.length : end >>> 0
13759
13760 if (!val) val = 0
13761
13762 var i
13763 if (typeof val === 'number') {
13764 for (i = start; i < end; ++i) {
13765 this[i] = val
13766 }
13767 } else {
13768 var bytes = Buffer.isBuffer(val)
13769 ? val
13770 : Buffer.from(val, encoding)
13771 var len = bytes.length
13772 if (len === 0) {
13773 throw new TypeError('The value "' + val +
13774 '" is invalid for argument "value"')
13775 }
13776 for (i = 0; i < end - start; ++i) {
13777 this[i + start] = bytes[i % len]
13778 }
13779 }
13780
13781 return this
13782}
13783
13784// HELPER FUNCTIONS
13785// ================
13786
13787var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
13788
13789function base64clean (str) {
13790 // Node takes equal signs as end of the Base64 encoding
13791 str = str.split('=')[0]
13792 // Node strips out invalid characters like \n and \t from the string, base64-js does not
13793 str = str.trim().replace(INVALID_BASE64_RE, '')
13794 // Node converts strings with length < 2 to ''
13795 if (str.length < 2) return ''
13796 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
13797 while (str.length % 4 !== 0) {
13798 str = str + '='
13799 }
13800 return str
13801}
13802
13803function toHex (n) {
13804 if (n < 16) return '0' + n.toString(16)
13805 return n.toString(16)
13806}
13807
13808function utf8ToBytes (string, units) {
13809 units = units || Infinity
13810 var codePoint
13811 var length = string.length
13812 var leadSurrogate = null
13813 var bytes = []
13814
13815 for (var i = 0; i < length; ++i) {
13816 codePoint = string.charCodeAt(i)
13817
13818 // is surrogate component
13819 if (codePoint > 0xD7FF && codePoint < 0xE000) {
13820 // last char was a lead
13821 if (!leadSurrogate) {
13822 // no lead yet
13823 if (codePoint > 0xDBFF) {
13824 // unexpected trail
13825 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
13826 continue
13827 } else if (i + 1 === length) {
13828 // unpaired lead
13829 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
13830 continue
13831 }
13832
13833 // valid lead
13834 leadSurrogate = codePoint
13835
13836 continue
13837 }
13838
13839 // 2 leads in a row
13840 if (codePoint < 0xDC00) {
13841 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
13842 leadSurrogate = codePoint
13843 continue
13844 }
13845
13846 // valid surrogate pair
13847 codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
13848 } else if (leadSurrogate) {
13849 // valid bmp char, but last char was a lead
13850 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
13851 }
13852
13853 leadSurrogate = null
13854
13855 // encode utf8
13856 if (codePoint < 0x80) {
13857 if ((units -= 1) < 0) break
13858 bytes.push(codePoint)
13859 } else if (codePoint < 0x800) {
13860 if ((units -= 2) < 0) break
13861 bytes.push(
13862 codePoint >> 0x6 | 0xC0,
13863 codePoint & 0x3F | 0x80
13864 )
13865 } else if (codePoint < 0x10000) {
13866 if ((units -= 3) < 0) break
13867 bytes.push(
13868 codePoint >> 0xC | 0xE0,
13869 codePoint >> 0x6 & 0x3F | 0x80,
13870 codePoint & 0x3F | 0x80
13871 )
13872 } else if (codePoint < 0x110000) {
13873 if ((units -= 4) < 0) break
13874 bytes.push(
13875 codePoint >> 0x12 | 0xF0,
13876 codePoint >> 0xC & 0x3F | 0x80,
13877 codePoint >> 0x6 & 0x3F | 0x80,
13878 codePoint & 0x3F | 0x80
13879 )
13880 } else {
13881 throw new Error('Invalid code point')
13882 }
13883 }
13884
13885 return bytes
13886}
13887
13888function asciiToBytes (str) {
13889 var byteArray = []
13890 for (var i = 0; i < str.length; ++i) {
13891 // Node's code seems to be doing this and not & 0x7F..
13892 byteArray.push(str.charCodeAt(i) & 0xFF)
13893 }
13894 return byteArray
13895}
13896
13897function utf16leToBytes (str, units) {
13898 var c, hi, lo
13899 var byteArray = []
13900 for (var i = 0; i < str.length; ++i) {
13901 if ((units -= 2) < 0) break
13902
13903 c = str.charCodeAt(i)
13904 hi = c >> 8
13905 lo = c % 256
13906 byteArray.push(lo)
13907 byteArray.push(hi)
13908 }
13909
13910 return byteArray
13911}
13912
13913function base64ToBytes (str) {
13914 return base64.toByteArray(base64clean(str))
13915}
13916
13917function blitBuffer (src, dst, offset, length) {
13918 for (var i = 0; i < length; ++i) {
13919 if ((i + offset >= dst.length) || (i >= src.length)) break
13920 dst[i + offset] = src[i]
13921 }
13922 return i
13923}
13924
13925// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
13926// the `instanceof` check but they should be treated as of that type.
13927// See: https://github.com/feross/buffer/issues/166
13928function isInstance (obj, type) {
13929 return obj instanceof type ||
13930 (obj != null && obj.constructor != null && obj.constructor.name != null &&
13931 obj.constructor.name === type.name)
13932}
13933function numberIsNaN (obj) {
13934 // For IE11 support
13935 return obj !== obj // eslint-disable-line no-self-compare
13936}
13937
13938}).call(this,require("buffer").Buffer)
13939},{"base64-js":94,"buffer":96,"ieee754":99}],97:[function(require,module,exports){
13940(function (Buffer){
13941// Copyright Joyent, Inc. and other Node contributors.
13942//
13943// Permission is hereby granted, free of charge, to any person obtaining a
13944// copy of this software and associated documentation files (the
13945// "Software"), to deal in the Software without restriction, including
13946// without limitation the rights to use, copy, modify, merge, publish,
13947// distribute, sublicense, and/or sell copies of the Software, and to permit
13948// persons to whom the Software is furnished to do so, subject to the
13949// following conditions:
13950//
13951// The above copyright notice and this permission notice shall be included
13952// in all copies or substantial portions of the Software.
13953//
13954// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
13955// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
13956// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
13957// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
13958// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
13959// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
13960// USE OR OTHER DEALINGS IN THE SOFTWARE.
13961
13962// NOTE: These type checking functions intentionally don't use `instanceof`
13963// because it is fragile and can be easily faked with `Object.create()`.
13964
13965function isArray(arg) {
13966 if (Array.isArray) {
13967 return Array.isArray(arg);
13968 }
13969 return objectToString(arg) === '[object Array]';
13970}
13971exports.isArray = isArray;
13972
13973function isBoolean(arg) {
13974 return typeof arg === 'boolean';
13975}
13976exports.isBoolean = isBoolean;
13977
13978function isNull(arg) {
13979 return arg === null;
13980}
13981exports.isNull = isNull;
13982
13983function isNullOrUndefined(arg) {
13984 return arg == null;
13985}
13986exports.isNullOrUndefined = isNullOrUndefined;
13987
13988function isNumber(arg) {
13989 return typeof arg === 'number';
13990}
13991exports.isNumber = isNumber;
13992
13993function isString(arg) {
13994 return typeof arg === 'string';
13995}
13996exports.isString = isString;
13997
13998function isSymbol(arg) {
13999 return typeof arg === 'symbol';
14000}
14001exports.isSymbol = isSymbol;
14002
14003function isUndefined(arg) {
14004 return arg === void 0;
14005}
14006exports.isUndefined = isUndefined;
14007
14008function isRegExp(re) {
14009 return objectToString(re) === '[object RegExp]';
14010}
14011exports.isRegExp = isRegExp;
14012
14013function isObject(arg) {
14014 return typeof arg === 'object' && arg !== null;
14015}
14016exports.isObject = isObject;
14017
14018function isDate(d) {
14019 return objectToString(d) === '[object Date]';
14020}
14021exports.isDate = isDate;
14022
14023function isError(e) {
14024 return (objectToString(e) === '[object Error]' || e instanceof Error);
14025}
14026exports.isError = isError;
14027
14028function isFunction(arg) {
14029 return typeof arg === 'function';
14030}
14031exports.isFunction = isFunction;
14032
14033function isPrimitive(arg) {
14034 return arg === null ||
14035 typeof arg === 'boolean' ||
14036 typeof arg === 'number' ||
14037 typeof arg === 'string' ||
14038 typeof arg === 'symbol' || // ES6 symbol
14039 typeof arg === 'undefined';
14040}
14041exports.isPrimitive = isPrimitive;
14042
14043exports.isBuffer = Buffer.isBuffer;
14044
14045function objectToString(o) {
14046 return Object.prototype.toString.call(o);
14047}
14048
14049}).call(this,{"isBuffer":require("../../is-buffer/index.js")})
14050},{"../../is-buffer/index.js":101}],98:[function(require,module,exports){
14051// Copyright Joyent, Inc. and other Node contributors.
14052//
14053// Permission is hereby granted, free of charge, to any person obtaining a
14054// copy of this software and associated documentation files (the
14055// "Software"), to deal in the Software without restriction, including
14056// without limitation the rights to use, copy, modify, merge, publish,
14057// distribute, sublicense, and/or sell copies of the Software, and to permit
14058// persons to whom the Software is furnished to do so, subject to the
14059// following conditions:
14060//
14061// The above copyright notice and this permission notice shall be included
14062// in all copies or substantial portions of the Software.
14063//
14064// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14065// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14066// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
14067// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
14068// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
14069// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
14070// USE OR OTHER DEALINGS IN THE SOFTWARE.
14071
14072var objectCreate = Object.create || objectCreatePolyfill
14073var objectKeys = Object.keys || objectKeysPolyfill
14074var bind = Function.prototype.bind || functionBindPolyfill
14075
14076function EventEmitter() {
14077 if (!this._events || !Object.prototype.hasOwnProperty.call(this, '_events')) {
14078 this._events = objectCreate(null);
14079 this._eventsCount = 0;
14080 }
14081
14082 this._maxListeners = this._maxListeners || undefined;
14083}
14084module.exports = EventEmitter;
14085
14086// Backwards-compat with node 0.10.x
14087EventEmitter.EventEmitter = EventEmitter;
14088
14089EventEmitter.prototype._events = undefined;
14090EventEmitter.prototype._maxListeners = undefined;
14091
14092// By default EventEmitters will print a warning if more than 10 listeners are
14093// added to it. This is a useful default which helps finding memory leaks.
14094var defaultMaxListeners = 10;
14095
14096var hasDefineProperty;
14097try {
14098 var o = {};
14099 if (Object.defineProperty) Object.defineProperty(o, 'x', { value: 0 });
14100 hasDefineProperty = o.x === 0;
14101} catch (err) { hasDefineProperty = false }
14102if (hasDefineProperty) {
14103 Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
14104 enumerable: true,
14105 get: function() {
14106 return defaultMaxListeners;
14107 },
14108 set: function(arg) {
14109 // check whether the input is a positive number (whose value is zero or
14110 // greater and not a NaN).
14111 if (typeof arg !== 'number' || arg < 0 || arg !== arg)
14112 throw new TypeError('"defaultMaxListeners" must be a positive number');
14113 defaultMaxListeners = arg;
14114 }
14115 });
14116} else {
14117 EventEmitter.defaultMaxListeners = defaultMaxListeners;
14118}
14119
14120// Obviously not all Emitters should be limited to 10. This function allows
14121// that to be increased. Set to zero for unlimited.
14122EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
14123 if (typeof n !== 'number' || n < 0 || isNaN(n))
14124 throw new TypeError('"n" argument must be a positive number');
14125 this._maxListeners = n;
14126 return this;
14127};
14128
14129function $getMaxListeners(that) {
14130 if (that._maxListeners === undefined)
14131 return EventEmitter.defaultMaxListeners;
14132 return that._maxListeners;
14133}
14134
14135EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
14136 return $getMaxListeners(this);
14137};
14138
14139// These standalone emit* functions are used to optimize calling of event
14140// handlers for fast cases because emit() itself often has a variable number of
14141// arguments and can be deoptimized because of that. These functions always have
14142// the same number of arguments and thus do not get deoptimized, so the code
14143// inside them can execute faster.
14144function emitNone(handler, isFn, self) {
14145 if (isFn)
14146 handler.call(self);
14147 else {
14148 var len = handler.length;
14149 var listeners = arrayClone(handler, len);
14150 for (var i = 0; i < len; ++i)
14151 listeners[i].call(self);
14152 }
14153}
14154function emitOne(handler, isFn, self, arg1) {
14155 if (isFn)
14156 handler.call(self, arg1);
14157 else {
14158 var len = handler.length;
14159 var listeners = arrayClone(handler, len);
14160 for (var i = 0; i < len; ++i)
14161 listeners[i].call(self, arg1);
14162 }
14163}
14164function emitTwo(handler, isFn, self, arg1, arg2) {
14165 if (isFn)
14166 handler.call(self, arg1, arg2);
14167 else {
14168 var len = handler.length;
14169 var listeners = arrayClone(handler, len);
14170 for (var i = 0; i < len; ++i)
14171 listeners[i].call(self, arg1, arg2);
14172 }
14173}
14174function emitThree(handler, isFn, self, arg1, arg2, arg3) {
14175 if (isFn)
14176 handler.call(self, arg1, arg2, arg3);
14177 else {
14178 var len = handler.length;
14179 var listeners = arrayClone(handler, len);
14180 for (var i = 0; i < len; ++i)
14181 listeners[i].call(self, arg1, arg2, arg3);
14182 }
14183}
14184
14185function emitMany(handler, isFn, self, args) {
14186 if (isFn)
14187 handler.apply(self, args);
14188 else {
14189 var len = handler.length;
14190 var listeners = arrayClone(handler, len);
14191 for (var i = 0; i < len; ++i)
14192 listeners[i].apply(self, args);
14193 }
14194}
14195
14196EventEmitter.prototype.emit = function emit(type) {
14197 var er, handler, len, args, i, events;
14198 var doError = (type === 'error');
14199
14200 events = this._events;
14201 if (events)
14202 doError = (doError && events.error == null);
14203 else if (!doError)
14204 return false;
14205
14206 // If there is no 'error' event listener then throw.
14207 if (doError) {
14208 if (arguments.length > 1)
14209 er = arguments[1];
14210 if (er instanceof Error) {
14211 throw er; // Unhandled 'error' event
14212 } else {
14213 // At least give some kind of context to the user
14214 var err = new Error('Unhandled "error" event. (' + er + ')');
14215 err.context = er;
14216 throw err;
14217 }
14218 return false;
14219 }
14220
14221 handler = events[type];
14222
14223 if (!handler)
14224 return false;
14225
14226 var isFn = typeof handler === 'function';
14227 len = arguments.length;
14228 switch (len) {
14229 // fast cases
14230 case 1:
14231 emitNone(handler, isFn, this);
14232 break;
14233 case 2:
14234 emitOne(handler, isFn, this, arguments[1]);
14235 break;
14236 case 3:
14237 emitTwo(handler, isFn, this, arguments[1], arguments[2]);
14238 break;
14239 case 4:
14240 emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
14241 break;
14242 // slower
14243 default:
14244 args = new Array(len - 1);
14245 for (i = 1; i < len; i++)
14246 args[i - 1] = arguments[i];
14247 emitMany(handler, isFn, this, args);
14248 }
14249
14250 return true;
14251};
14252
14253function _addListener(target, type, listener, prepend) {
14254 var m;
14255 var events;
14256 var existing;
14257
14258 if (typeof listener !== 'function')
14259 throw new TypeError('"listener" argument must be a function');
14260
14261 events = target._events;
14262 if (!events) {
14263 events = target._events = objectCreate(null);
14264 target._eventsCount = 0;
14265 } else {
14266 // To avoid recursion in the case that type === "newListener"! Before
14267 // adding it to the listeners, first emit "newListener".
14268 if (events.newListener) {
14269 target.emit('newListener', type,
14270 listener.listener ? listener.listener : listener);
14271
14272 // Re-assign `events` because a newListener handler could have caused the
14273 // this._events to be assigned to a new object
14274 events = target._events;
14275 }
14276 existing = events[type];
14277 }
14278
14279 if (!existing) {
14280 // Optimize the case of one listener. Don't need the extra array object.
14281 existing = events[type] = listener;
14282 ++target._eventsCount;
14283 } else {
14284 if (typeof existing === 'function') {
14285 // Adding the second element, need to change to array.
14286 existing = events[type] =
14287 prepend ? [listener, existing] : [existing, listener];
14288 } else {
14289 // If we've already got an array, just append.
14290 if (prepend) {
14291 existing.unshift(listener);
14292 } else {
14293 existing.push(listener);
14294 }
14295 }
14296
14297 // Check for listener leak
14298 if (!existing.warned) {
14299 m = $getMaxListeners(target);
14300 if (m && m > 0 && existing.length > m) {
14301 existing.warned = true;
14302 var w = new Error('Possible EventEmitter memory leak detected. ' +
14303 existing.length + ' "' + String(type) + '" listeners ' +
14304 'added. Use emitter.setMaxListeners() to ' +
14305 'increase limit.');
14306 w.name = 'MaxListenersExceededWarning';
14307 w.emitter = target;
14308 w.type = type;
14309 w.count = existing.length;
14310 if (typeof console === 'object' && console.warn) {
14311 console.warn('%s: %s', w.name, w.message);
14312 }
14313 }
14314 }
14315 }
14316
14317 return target;
14318}
14319
14320EventEmitter.prototype.addListener = function addListener(type, listener) {
14321 return _addListener(this, type, listener, false);
14322};
14323
14324EventEmitter.prototype.on = EventEmitter.prototype.addListener;
14325
14326EventEmitter.prototype.prependListener =
14327 function prependListener(type, listener) {
14328 return _addListener(this, type, listener, true);
14329 };
14330
14331function onceWrapper() {
14332 if (!this.fired) {
14333 this.target.removeListener(this.type, this.wrapFn);
14334 this.fired = true;
14335 switch (arguments.length) {
14336 case 0:
14337 return this.listener.call(this.target);
14338 case 1:
14339 return this.listener.call(this.target, arguments[0]);
14340 case 2:
14341 return this.listener.call(this.target, arguments[0], arguments[1]);
14342 case 3:
14343 return this.listener.call(this.target, arguments[0], arguments[1],
14344 arguments[2]);
14345 default:
14346 var args = new Array(arguments.length);
14347 for (var i = 0; i < args.length; ++i)
14348 args[i] = arguments[i];
14349 this.listener.apply(this.target, args);
14350 }
14351 }
14352}
14353
14354function _onceWrap(target, type, listener) {
14355 var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
14356 var wrapped = bind.call(onceWrapper, state);
14357 wrapped.listener = listener;
14358 state.wrapFn = wrapped;
14359 return wrapped;
14360}
14361
14362EventEmitter.prototype.once = function once(type, listener) {
14363 if (typeof listener !== 'function')
14364 throw new TypeError('"listener" argument must be a function');
14365 this.on(type, _onceWrap(this, type, listener));
14366 return this;
14367};
14368
14369EventEmitter.prototype.prependOnceListener =
14370 function prependOnceListener(type, listener) {
14371 if (typeof listener !== 'function')
14372 throw new TypeError('"listener" argument must be a function');
14373 this.prependListener(type, _onceWrap(this, type, listener));
14374 return this;
14375 };
14376
14377// Emits a 'removeListener' event if and only if the listener was removed.
14378EventEmitter.prototype.removeListener =
14379 function removeListener(type, listener) {
14380 var list, events, position, i, originalListener;
14381
14382 if (typeof listener !== 'function')
14383 throw new TypeError('"listener" argument must be a function');
14384
14385 events = this._events;
14386 if (!events)
14387 return this;
14388
14389 list = events[type];
14390 if (!list)
14391 return this;
14392
14393 if (list === listener || list.listener === listener) {
14394 if (--this._eventsCount === 0)
14395 this._events = objectCreate(null);
14396 else {
14397 delete events[type];
14398 if (events.removeListener)
14399 this.emit('removeListener', type, list.listener || listener);
14400 }
14401 } else if (typeof list !== 'function') {
14402 position = -1;
14403
14404 for (i = list.length - 1; i >= 0; i--) {
14405 if (list[i] === listener || list[i].listener === listener) {
14406 originalListener = list[i].listener;
14407 position = i;
14408 break;
14409 }
14410 }
14411
14412 if (position < 0)
14413 return this;
14414
14415 if (position === 0)
14416 list.shift();
14417 else
14418 spliceOne(list, position);
14419
14420 if (list.length === 1)
14421 events[type] = list[0];
14422
14423 if (events.removeListener)
14424 this.emit('removeListener', type, originalListener || listener);
14425 }
14426
14427 return this;
14428 };
14429
14430EventEmitter.prototype.removeAllListeners =
14431 function removeAllListeners(type) {
14432 var listeners, events, i;
14433
14434 events = this._events;
14435 if (!events)
14436 return this;
14437
14438 // not listening for removeListener, no need to emit
14439 if (!events.removeListener) {
14440 if (arguments.length === 0) {
14441 this._events = objectCreate(null);
14442 this._eventsCount = 0;
14443 } else if (events[type]) {
14444 if (--this._eventsCount === 0)
14445 this._events = objectCreate(null);
14446 else
14447 delete events[type];
14448 }
14449 return this;
14450 }
14451
14452 // emit removeListener for all listeners on all events
14453 if (arguments.length === 0) {
14454 var keys = objectKeys(events);
14455 var key;
14456 for (i = 0; i < keys.length; ++i) {
14457 key = keys[i];
14458 if (key === 'removeListener') continue;
14459 this.removeAllListeners(key);
14460 }
14461 this.removeAllListeners('removeListener');
14462 this._events = objectCreate(null);
14463 this._eventsCount = 0;
14464 return this;
14465 }
14466
14467 listeners = events[type];
14468
14469 if (typeof listeners === 'function') {
14470 this.removeListener(type, listeners);
14471 } else if (listeners) {
14472 // LIFO order
14473 for (i = listeners.length - 1; i >= 0; i--) {
14474 this.removeListener(type, listeners[i]);
14475 }
14476 }
14477
14478 return this;
14479 };
14480
14481function _listeners(target, type, unwrap) {
14482 var events = target._events;
14483
14484 if (!events)
14485 return [];
14486
14487 var evlistener = events[type];
14488 if (!evlistener)
14489 return [];
14490
14491 if (typeof evlistener === 'function')
14492 return unwrap ? [evlistener.listener || evlistener] : [evlistener];
14493
14494 return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
14495}
14496
14497EventEmitter.prototype.listeners = function listeners(type) {
14498 return _listeners(this, type, true);
14499};
14500
14501EventEmitter.prototype.rawListeners = function rawListeners(type) {
14502 return _listeners(this, type, false);
14503};
14504
14505EventEmitter.listenerCount = function(emitter, type) {
14506 if (typeof emitter.listenerCount === 'function') {
14507 return emitter.listenerCount(type);
14508 } else {
14509 return listenerCount.call(emitter, type);
14510 }
14511};
14512
14513EventEmitter.prototype.listenerCount = listenerCount;
14514function listenerCount(type) {
14515 var events = this._events;
14516
14517 if (events) {
14518 var evlistener = events[type];
14519
14520 if (typeof evlistener === 'function') {
14521 return 1;
14522 } else if (evlistener) {
14523 return evlistener.length;
14524 }
14525 }
14526
14527 return 0;
14528}
14529
14530EventEmitter.prototype.eventNames = function eventNames() {
14531 return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
14532};
14533
14534// About 1.5x faster than the two-arg version of Array#splice().
14535function spliceOne(list, index) {
14536 for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1)
14537 list[i] = list[k];
14538 list.pop();
14539}
14540
14541function arrayClone(arr, n) {
14542 var copy = new Array(n);
14543 for (var i = 0; i < n; ++i)
14544 copy[i] = arr[i];
14545 return copy;
14546}
14547
14548function unwrapListeners(arr) {
14549 var ret = new Array(arr.length);
14550 for (var i = 0; i < ret.length; ++i) {
14551 ret[i] = arr[i].listener || arr[i];
14552 }
14553 return ret;
14554}
14555
14556function objectCreatePolyfill(proto) {
14557 var F = function() {};
14558 F.prototype = proto;
14559 return new F;
14560}
14561function objectKeysPolyfill(obj) {
14562 var keys = [];
14563 for (var k in obj) if (Object.prototype.hasOwnProperty.call(obj, k)) {
14564 keys.push(k);
14565 }
14566 return k;
14567}
14568function functionBindPolyfill(context) {
14569 var fn = this;
14570 return function () {
14571 return fn.apply(context, arguments);
14572 };
14573}
14574
14575},{}],99:[function(require,module,exports){
14576exports.read = function (buffer, offset, isLE, mLen, nBytes) {
14577 var e, m
14578 var eLen = (nBytes * 8) - mLen - 1
14579 var eMax = (1 << eLen) - 1
14580 var eBias = eMax >> 1
14581 var nBits = -7
14582 var i = isLE ? (nBytes - 1) : 0
14583 var d = isLE ? -1 : 1
14584 var s = buffer[offset + i]
14585
14586 i += d
14587
14588 e = s & ((1 << (-nBits)) - 1)
14589 s >>= (-nBits)
14590 nBits += eLen
14591 for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
14592
14593 m = e & ((1 << (-nBits)) - 1)
14594 e >>= (-nBits)
14595 nBits += mLen
14596 for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
14597
14598 if (e === 0) {
14599 e = 1 - eBias
14600 } else if (e === eMax) {
14601 return m ? NaN : ((s ? -1 : 1) * Infinity)
14602 } else {
14603 m = m + Math.pow(2, mLen)
14604 e = e - eBias
14605 }
14606 return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
14607}
14608
14609exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
14610 var e, m, c
14611 var eLen = (nBytes * 8) - mLen - 1
14612 var eMax = (1 << eLen) - 1
14613 var eBias = eMax >> 1
14614 var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
14615 var i = isLE ? 0 : (nBytes - 1)
14616 var d = isLE ? 1 : -1
14617 var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
14618
14619 value = Math.abs(value)
14620
14621 if (isNaN(value) || value === Infinity) {
14622 m = isNaN(value) ? 1 : 0
14623 e = eMax
14624 } else {
14625 e = Math.floor(Math.log(value) / Math.LN2)
14626 if (value * (c = Math.pow(2, -e)) < 1) {
14627 e--
14628 c *= 2
14629 }
14630 if (e + eBias >= 1) {
14631 value += rt / c
14632 } else {
14633 value += rt * Math.pow(2, 1 - eBias)
14634 }
14635 if (value * c >= 2) {
14636 e++
14637 c /= 2
14638 }
14639
14640 if (e + eBias >= eMax) {
14641 m = 0
14642 e = eMax
14643 } else if (e + eBias >= 1) {
14644 m = ((value * c) - 1) * Math.pow(2, mLen)
14645 e = e + eBias
14646 } else {
14647 m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
14648 e = 0
14649 }
14650 }
14651
14652 for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
14653
14654 e = (e << mLen) | m
14655 eLen += mLen
14656 for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
14657
14658 buffer[offset + i - d] |= s * 128
14659}
14660
14661},{}],100:[function(require,module,exports){
14662arguments[4][32][0].apply(exports,arguments)
14663},{"dup":32}],101:[function(require,module,exports){
14664/*!
14665 * Determine if an object is a Buffer
14666 *
14667 * @author Feross Aboukhadijeh <https://feross.org>
14668 * @license MIT
14669 */
14670
14671// The _isBuffer check is for Safari 5-7 support, because it's missing
14672// Object.prototype.constructor. Remove this eventually
14673module.exports = function (obj) {
14674 return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
14675}
14676
14677function isBuffer (obj) {
14678 return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
14679}
14680
14681// For Node v0.10 support. Remove this eventually.
14682function isSlowBuffer (obj) {
14683 return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
14684}
14685
14686},{}],102:[function(require,module,exports){
14687var toString = {}.toString;
14688
14689module.exports = Array.isArray || function (arr) {
14690 return toString.call(arr) == '[object Array]';
14691};
14692
14693},{}],103:[function(require,module,exports){
14694/*
14695object-assign
14696(c) Sindre Sorhus
14697@license MIT
14698*/
14699
14700'use strict';
14701/* eslint-disable no-unused-vars */
14702var getOwnPropertySymbols = Object.getOwnPropertySymbols;
14703var hasOwnProperty = Object.prototype.hasOwnProperty;
14704var propIsEnumerable = Object.prototype.propertyIsEnumerable;
14705
14706function toObject(val) {
14707 if (val === null || val === undefined) {
14708 throw new TypeError('Object.assign cannot be called with null or undefined');
14709 }
14710
14711 return Object(val);
14712}
14713
14714function shouldUseNative() {
14715 try {
14716 if (!Object.assign) {
14717 return false;
14718 }
14719
14720 // Detect buggy property enumeration order in older V8 versions.
14721
14722 // https://bugs.chromium.org/p/v8/issues/detail?id=4118
14723 var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
14724 test1[5] = 'de';
14725 if (Object.getOwnPropertyNames(test1)[0] === '5') {
14726 return false;
14727 }
14728
14729 // https://bugs.chromium.org/p/v8/issues/detail?id=3056
14730 var test2 = {};
14731 for (var i = 0; i < 10; i++) {
14732 test2['_' + String.fromCharCode(i)] = i;
14733 }
14734 var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
14735 return test2[n];
14736 });
14737 if (order2.join('') !== '0123456789') {
14738 return false;
14739 }
14740
14741 // https://bugs.chromium.org/p/v8/issues/detail?id=3056
14742 var test3 = {};
14743 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
14744 test3[letter] = letter;
14745 });
14746 if (Object.keys(Object.assign({}, test3)).join('') !==
14747 'abcdefghijklmnopqrst') {
14748 return false;
14749 }
14750
14751 return true;
14752 } catch (err) {
14753 // We don't expect any of the above to throw, but better to be safe.
14754 return false;
14755 }
14756}
14757
14758module.exports = shouldUseNative() ? Object.assign : function (target, source) {
14759 var from;
14760 var to = toObject(target);
14761 var symbols;
14762
14763 for (var s = 1; s < arguments.length; s++) {
14764 from = Object(arguments[s]);
14765
14766 for (var key in from) {
14767 if (hasOwnProperty.call(from, key)) {
14768 to[key] = from[key];
14769 }
14770 }
14771
14772 if (getOwnPropertySymbols) {
14773 symbols = getOwnPropertySymbols(from);
14774 for (var i = 0; i < symbols.length; i++) {
14775 if (propIsEnumerable.call(from, symbols[i])) {
14776 to[symbols[i]] = from[symbols[i]];
14777 }
14778 }
14779 }
14780 }
14781
14782 return to;
14783};
14784
14785},{}],104:[function(require,module,exports){
14786(function (process){
14787'use strict';
14788
14789if (typeof process === 'undefined' ||
14790 !process.version ||
14791 process.version.indexOf('v0.') === 0 ||
14792 process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
14793 module.exports = { nextTick: nextTick };
14794} else {
14795 module.exports = process
14796}
14797
14798function nextTick(fn, arg1, arg2, arg3) {
14799 if (typeof fn !== 'function') {
14800 throw new TypeError('"callback" argument must be a function');
14801 }
14802 var len = arguments.length;
14803 var args, i;
14804 switch (len) {
14805 case 0:
14806 case 1:
14807 return process.nextTick(fn);
14808 case 2:
14809 return process.nextTick(function afterTickOne() {
14810 fn.call(null, arg1);
14811 });
14812 case 3:
14813 return process.nextTick(function afterTickTwo() {
14814 fn.call(null, arg1, arg2);
14815 });
14816 case 4:
14817 return process.nextTick(function afterTickThree() {
14818 fn.call(null, arg1, arg2, arg3);
14819 });
14820 default:
14821 args = new Array(len - 1);
14822 i = 0;
14823 while (i < args.length) {
14824 args[i++] = arguments[i];
14825 }
14826 return process.nextTick(function afterTick() {
14827 fn.apply(null, args);
14828 });
14829 }
14830}
14831
14832
14833}).call(this,require('_process'))
14834},{"_process":105}],105:[function(require,module,exports){
14835// shim for using process in browser
14836var process = module.exports = {};
14837
14838// cached from whatever global is present so that test runners that stub it
14839// don't break things. But we need to wrap it in a try catch in case it is
14840// wrapped in strict mode code which doesn't define any globals. It's inside a
14841// function because try/catches deoptimize in certain engines.
14842
14843var cachedSetTimeout;
14844var cachedClearTimeout;
14845
14846function defaultSetTimout() {
14847 throw new Error('setTimeout has not been defined');
14848}
14849function defaultClearTimeout () {
14850 throw new Error('clearTimeout has not been defined');
14851}
14852(function () {
14853 try {
14854 if (typeof setTimeout === 'function') {
14855 cachedSetTimeout = setTimeout;
14856 } else {
14857 cachedSetTimeout = defaultSetTimout;
14858 }
14859 } catch (e) {
14860 cachedSetTimeout = defaultSetTimout;
14861 }
14862 try {
14863 if (typeof clearTimeout === 'function') {
14864 cachedClearTimeout = clearTimeout;
14865 } else {
14866 cachedClearTimeout = defaultClearTimeout;
14867 }
14868 } catch (e) {
14869 cachedClearTimeout = defaultClearTimeout;
14870 }
14871} ())
14872function runTimeout(fun) {
14873 if (cachedSetTimeout === setTimeout) {
14874 //normal enviroments in sane situations
14875 return setTimeout(fun, 0);
14876 }
14877 // if setTimeout wasn't available but was latter defined
14878 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
14879 cachedSetTimeout = setTimeout;
14880 return setTimeout(fun, 0);
14881 }
14882 try {
14883 // when when somebody has screwed with setTimeout but no I.E. maddness
14884 return cachedSetTimeout(fun, 0);
14885 } catch(e){
14886 try {
14887 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
14888 return cachedSetTimeout.call(null, fun, 0);
14889 } catch(e){
14890 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
14891 return cachedSetTimeout.call(this, fun, 0);
14892 }
14893 }
14894
14895
14896}
14897function runClearTimeout(marker) {
14898 if (cachedClearTimeout === clearTimeout) {
14899 //normal enviroments in sane situations
14900 return clearTimeout(marker);
14901 }
14902 // if clearTimeout wasn't available but was latter defined
14903 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
14904 cachedClearTimeout = clearTimeout;
14905 return clearTimeout(marker);
14906 }
14907 try {
14908 // when when somebody has screwed with setTimeout but no I.E. maddness
14909 return cachedClearTimeout(marker);
14910 } catch (e){
14911 try {
14912 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
14913 return cachedClearTimeout.call(null, marker);
14914 } catch (e){
14915 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
14916 // Some versions of I.E. have different rules for clearTimeout vs setTimeout
14917 return cachedClearTimeout.call(this, marker);
14918 }
14919 }
14920
14921
14922
14923}
14924var queue = [];
14925var draining = false;
14926var currentQueue;
14927var queueIndex = -1;
14928
14929function cleanUpNextTick() {
14930 if (!draining || !currentQueue) {
14931 return;
14932 }
14933 draining = false;
14934 if (currentQueue.length) {
14935 queue = currentQueue.concat(queue);
14936 } else {
14937 queueIndex = -1;
14938 }
14939 if (queue.length) {
14940 drainQueue();
14941 }
14942}
14943
14944function drainQueue() {
14945 if (draining) {
14946 return;
14947 }
14948 var timeout = runTimeout(cleanUpNextTick);
14949 draining = true;
14950
14951 var len = queue.length;
14952 while(len) {
14953 currentQueue = queue;
14954 queue = [];
14955 while (++queueIndex < len) {
14956 if (currentQueue) {
14957 currentQueue[queueIndex].run();
14958 }
14959 }
14960 queueIndex = -1;
14961 len = queue.length;
14962 }
14963 currentQueue = null;
14964 draining = false;
14965 runClearTimeout(timeout);
14966}
14967
14968process.nextTick = function (fun) {
14969 var args = new Array(arguments.length - 1);
14970 if (arguments.length > 1) {
14971 for (var i = 1; i < arguments.length; i++) {
14972 args[i - 1] = arguments[i];
14973 }
14974 }
14975 queue.push(new Item(fun, args));
14976 if (queue.length === 1 && !draining) {
14977 runTimeout(drainQueue);
14978 }
14979};
14980
14981// v8 likes predictible objects
14982function Item(fun, array) {
14983 this.fun = fun;
14984 this.array = array;
14985}
14986Item.prototype.run = function () {
14987 this.fun.apply(null, this.array);
14988};
14989process.title = 'browser';
14990process.browser = true;
14991process.env = {};
14992process.argv = [];
14993process.version = ''; // empty string to avoid regexp issues
14994process.versions = {};
14995
14996function noop() {}
14997
14998process.on = noop;
14999process.addListener = noop;
15000process.once = noop;
15001process.off = noop;
15002process.removeListener = noop;
15003process.removeAllListeners = noop;
15004process.emit = noop;
15005process.prependListener = noop;
15006process.prependOnceListener = noop;
15007
15008process.listeners = function (name) { return [] }
15009
15010process.binding = function (name) {
15011 throw new Error('process.binding is not supported');
15012};
15013
15014process.cwd = function () { return '/' };
15015process.chdir = function (dir) {
15016 throw new Error('process.chdir is not supported');
15017};
15018process.umask = function() { return 0; };
15019
15020},{}],106:[function(require,module,exports){
15021module.exports = require('./lib/_stream_duplex.js');
15022
15023},{"./lib/_stream_duplex.js":107}],107:[function(require,module,exports){
15024// Copyright Joyent, Inc. and other Node contributors.
15025//
15026// Permission is hereby granted, free of charge, to any person obtaining a
15027// copy of this software and associated documentation files (the
15028// "Software"), to deal in the Software without restriction, including
15029// without limitation the rights to use, copy, modify, merge, publish,
15030// distribute, sublicense, and/or sell copies of the Software, and to permit
15031// persons to whom the Software is furnished to do so, subject to the
15032// following conditions:
15033//
15034// The above copyright notice and this permission notice shall be included
15035// in all copies or substantial portions of the Software.
15036//
15037// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15038// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15039// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
15040// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
15041// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15042// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
15043// USE OR OTHER DEALINGS IN THE SOFTWARE.
15044
15045// a duplex stream is just a stream that is both readable and writable.
15046// Since JS doesn't have multiple prototypal inheritance, this class
15047// prototypally inherits from Readable, and then parasitically from
15048// Writable.
15049
15050'use strict';
15051
15052/*<replacement>*/
15053
15054var pna = require('process-nextick-args');
15055/*</replacement>*/
15056
15057/*<replacement>*/
15058var objectKeys = Object.keys || function (obj) {
15059 var keys = [];
15060 for (var key in obj) {
15061 keys.push(key);
15062 }return keys;
15063};
15064/*</replacement>*/
15065
15066module.exports = Duplex;
15067
15068/*<replacement>*/
15069var util = require('core-util-is');
15070util.inherits = require('inherits');
15071/*</replacement>*/
15072
15073var Readable = require('./_stream_readable');
15074var Writable = require('./_stream_writable');
15075
15076util.inherits(Duplex, Readable);
15077
15078{
15079 // avoid scope creep, the keys array can then be collected
15080 var keys = objectKeys(Writable.prototype);
15081 for (var v = 0; v < keys.length; v++) {
15082 var method = keys[v];
15083 if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
15084 }
15085}
15086
15087function Duplex(options) {
15088 if (!(this instanceof Duplex)) return new Duplex(options);
15089
15090 Readable.call(this, options);
15091 Writable.call(this, options);
15092
15093 if (options && options.readable === false) this.readable = false;
15094
15095 if (options && options.writable === false) this.writable = false;
15096
15097 this.allowHalfOpen = true;
15098 if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
15099
15100 this.once('end', onend);
15101}
15102
15103Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
15104 // making it explicit this property is not enumerable
15105 // because otherwise some prototype manipulation in
15106 // userland will fail
15107 enumerable: false,
15108 get: function () {
15109 return this._writableState.highWaterMark;
15110 }
15111});
15112
15113// the no-half-open enforcer
15114function onend() {
15115 // if we allow half-open state, or if the writable side ended,
15116 // then we're ok.
15117 if (this.allowHalfOpen || this._writableState.ended) return;
15118
15119 // no more data can be written.
15120 // But allow more writes to happen in this tick.
15121 pna.nextTick(onEndNT, this);
15122}
15123
15124function onEndNT(self) {
15125 self.end();
15126}
15127
15128Object.defineProperty(Duplex.prototype, 'destroyed', {
15129 get: function () {
15130 if (this._readableState === undefined || this._writableState === undefined) {
15131 return false;
15132 }
15133 return this._readableState.destroyed && this._writableState.destroyed;
15134 },
15135 set: function (value) {
15136 // we ignore the value if the stream
15137 // has not been initialized yet
15138 if (this._readableState === undefined || this._writableState === undefined) {
15139 return;
15140 }
15141
15142 // backward compatibility, the user is explicitly
15143 // managing destroyed
15144 this._readableState.destroyed = value;
15145 this._writableState.destroyed = value;
15146 }
15147});
15148
15149Duplex.prototype._destroy = function (err, cb) {
15150 this.push(null);
15151 this.end();
15152
15153 pna.nextTick(cb, err);
15154};
15155},{"./_stream_readable":109,"./_stream_writable":111,"core-util-is":97,"inherits":100,"process-nextick-args":104}],108:[function(require,module,exports){
15156// Copyright Joyent, Inc. and other Node contributors.
15157//
15158// Permission is hereby granted, free of charge, to any person obtaining a
15159// copy of this software and associated documentation files (the
15160// "Software"), to deal in the Software without restriction, including
15161// without limitation the rights to use, copy, modify, merge, publish,
15162// distribute, sublicense, and/or sell copies of the Software, and to permit
15163// persons to whom the Software is furnished to do so, subject to the
15164// following conditions:
15165//
15166// The above copyright notice and this permission notice shall be included
15167// in all copies or substantial portions of the Software.
15168//
15169// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15170// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15171// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
15172// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
15173// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15174// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
15175// USE OR OTHER DEALINGS IN THE SOFTWARE.
15176
15177// a passthrough stream.
15178// basically just the most minimal sort of Transform stream.
15179// Every written chunk gets output as-is.
15180
15181'use strict';
15182
15183module.exports = PassThrough;
15184
15185var Transform = require('./_stream_transform');
15186
15187/*<replacement>*/
15188var util = require('core-util-is');
15189util.inherits = require('inherits');
15190/*</replacement>*/
15191
15192util.inherits(PassThrough, Transform);
15193
15194function PassThrough(options) {
15195 if (!(this instanceof PassThrough)) return new PassThrough(options);
15196
15197 Transform.call(this, options);
15198}
15199
15200PassThrough.prototype._transform = function (chunk, encoding, cb) {
15201 cb(null, chunk);
15202};
15203},{"./_stream_transform":110,"core-util-is":97,"inherits":100}],109:[function(require,module,exports){
15204(function (process,global){
15205// Copyright Joyent, Inc. and other Node contributors.
15206//
15207// Permission is hereby granted, free of charge, to any person obtaining a
15208// copy of this software and associated documentation files (the
15209// "Software"), to deal in the Software without restriction, including
15210// without limitation the rights to use, copy, modify, merge, publish,
15211// distribute, sublicense, and/or sell copies of the Software, and to permit
15212// persons to whom the Software is furnished to do so, subject to the
15213// following conditions:
15214//
15215// The above copyright notice and this permission notice shall be included
15216// in all copies or substantial portions of the Software.
15217//
15218// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15219// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15220// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
15221// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
15222// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15223// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
15224// USE OR OTHER DEALINGS IN THE SOFTWARE.
15225
15226'use strict';
15227
15228/*<replacement>*/
15229
15230var pna = require('process-nextick-args');
15231/*</replacement>*/
15232
15233module.exports = Readable;
15234
15235/*<replacement>*/
15236var isArray = require('isarray');
15237/*</replacement>*/
15238
15239/*<replacement>*/
15240var Duplex;
15241/*</replacement>*/
15242
15243Readable.ReadableState = ReadableState;
15244
15245/*<replacement>*/
15246var EE = require('events').EventEmitter;
15247
15248var EElistenerCount = function (emitter, type) {
15249 return emitter.listeners(type).length;
15250};
15251/*</replacement>*/
15252
15253/*<replacement>*/
15254var Stream = require('./internal/streams/stream');
15255/*</replacement>*/
15256
15257/*<replacement>*/
15258
15259var Buffer = require('safe-buffer').Buffer;
15260var OurUint8Array = global.Uint8Array || function () {};
15261function _uint8ArrayToBuffer(chunk) {
15262 return Buffer.from(chunk);
15263}
15264function _isUint8Array(obj) {
15265 return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
15266}
15267
15268/*</replacement>*/
15269
15270/*<replacement>*/
15271var util = require('core-util-is');
15272util.inherits = require('inherits');
15273/*</replacement>*/
15274
15275/*<replacement>*/
15276var debugUtil = require('util');
15277var debug = void 0;
15278if (debugUtil && debugUtil.debuglog) {
15279 debug = debugUtil.debuglog('stream');
15280} else {
15281 debug = function () {};
15282}
15283/*</replacement>*/
15284
15285var BufferList = require('./internal/streams/BufferList');
15286var destroyImpl = require('./internal/streams/destroy');
15287var StringDecoder;
15288
15289util.inherits(Readable, Stream);
15290
15291var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
15292
15293function prependListener(emitter, event, fn) {
15294 // Sadly this is not cacheable as some libraries bundle their own
15295 // event emitter implementation with them.
15296 if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);
15297
15298 // This is a hack to make sure that our error handler is attached before any
15299 // userland ones. NEVER DO THIS. This is here only because this code needs
15300 // to continue to work with older versions of Node.js that do not include
15301 // the prependListener() method. The goal is to eventually remove this hack.
15302 if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
15303}
15304
15305function ReadableState(options, stream) {
15306 Duplex = Duplex || require('./_stream_duplex');
15307
15308 options = options || {};
15309
15310 // Duplex streams are both readable and writable, but share
15311 // the same options object.
15312 // However, some cases require setting options to different
15313 // values for the readable and the writable sides of the duplex stream.
15314 // These options can be provided separately as readableXXX and writableXXX.
15315 var isDuplex = stream instanceof Duplex;
15316
15317 // object stream flag. Used to make read(n) ignore n and to
15318 // make all the buffer merging and length checks go away
15319 this.objectMode = !!options.objectMode;
15320
15321 if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
15322
15323 // the point at which it stops calling _read() to fill the buffer
15324 // Note: 0 is a valid value, means "don't call _read preemptively ever"
15325 var hwm = options.highWaterMark;
15326 var readableHwm = options.readableHighWaterMark;
15327 var defaultHwm = this.objectMode ? 16 : 16 * 1024;
15328
15329 if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;
15330
15331 // cast to ints.
15332 this.highWaterMark = Math.floor(this.highWaterMark);
15333
15334 // A linked list is used to store data chunks instead of an array because the
15335 // linked list can remove elements from the beginning faster than
15336 // array.shift()
15337 this.buffer = new BufferList();
15338 this.length = 0;
15339 this.pipes = null;
15340 this.pipesCount = 0;
15341 this.flowing = null;
15342 this.ended = false;
15343 this.endEmitted = false;
15344 this.reading = false;
15345
15346 // a flag to be able to tell if the event 'readable'/'data' is emitted
15347 // immediately, or on a later tick. We set this to true at first, because
15348 // any actions that shouldn't happen until "later" should generally also
15349 // not happen before the first read call.
15350 this.sync = true;
15351
15352 // whenever we return null, then we set a flag to say
15353 // that we're awaiting a 'readable' event emission.
15354 this.needReadable = false;
15355 this.emittedReadable = false;
15356 this.readableListening = false;
15357 this.resumeScheduled = false;
15358
15359 // has it been destroyed
15360 this.destroyed = false;
15361
15362 // Crypto is kind of old and crusty. Historically, its default string
15363 // encoding is 'binary' so we have to make this configurable.
15364 // Everything else in the universe uses 'utf8', though.
15365 this.defaultEncoding = options.defaultEncoding || 'utf8';
15366
15367 // the number of writers that are awaiting a drain event in .pipe()s
15368 this.awaitDrain = 0;
15369
15370 // if true, a maybeReadMore has been scheduled
15371 this.readingMore = false;
15372
15373 this.decoder = null;
15374 this.encoding = null;
15375 if (options.encoding) {
15376 if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
15377 this.decoder = new StringDecoder(options.encoding);
15378 this.encoding = options.encoding;
15379 }
15380}
15381
15382function Readable(options) {
15383 Duplex = Duplex || require('./_stream_duplex');
15384
15385 if (!(this instanceof Readable)) return new Readable(options);
15386
15387 this._readableState = new ReadableState(options, this);
15388
15389 // legacy
15390 this.readable = true;
15391
15392 if (options) {
15393 if (typeof options.read === 'function') this._read = options.read;
15394
15395 if (typeof options.destroy === 'function') this._destroy = options.destroy;
15396 }
15397
15398 Stream.call(this);
15399}
15400
15401Object.defineProperty(Readable.prototype, 'destroyed', {
15402 get: function () {
15403 if (this._readableState === undefined) {
15404 return false;
15405 }
15406 return this._readableState.destroyed;
15407 },
15408 set: function (value) {
15409 // we ignore the value if the stream
15410 // has not been initialized yet
15411 if (!this._readableState) {
15412 return;
15413 }
15414
15415 // backward compatibility, the user is explicitly
15416 // managing destroyed
15417 this._readableState.destroyed = value;
15418 }
15419});
15420
15421Readable.prototype.destroy = destroyImpl.destroy;
15422Readable.prototype._undestroy = destroyImpl.undestroy;
15423Readable.prototype._destroy = function (err, cb) {
15424 this.push(null);
15425 cb(err);
15426};
15427
15428// Manually shove something into the read() buffer.
15429// This returns true if the highWaterMark has not been hit yet,
15430// similar to how Writable.write() returns true if you should
15431// write() some more.
15432Readable.prototype.push = function (chunk, encoding) {
15433 var state = this._readableState;
15434 var skipChunkCheck;
15435
15436 if (!state.objectMode) {
15437 if (typeof chunk === 'string') {
15438 encoding = encoding || state.defaultEncoding;
15439 if (encoding !== state.encoding) {
15440 chunk = Buffer.from(chunk, encoding);
15441 encoding = '';
15442 }
15443 skipChunkCheck = true;
15444 }
15445 } else {
15446 skipChunkCheck = true;
15447 }
15448
15449 return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
15450};
15451
15452// Unshift should *always* be something directly out of read()
15453Readable.prototype.unshift = function (chunk) {
15454 return readableAddChunk(this, chunk, null, true, false);
15455};
15456
15457function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
15458 var state = stream._readableState;
15459 if (chunk === null) {
15460 state.reading = false;
15461 onEofChunk(stream, state);
15462 } else {
15463 var er;
15464 if (!skipChunkCheck) er = chunkInvalid(state, chunk);
15465 if (er) {
15466 stream.emit('error', er);
15467 } else if (state.objectMode || chunk && chunk.length > 0) {
15468 if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
15469 chunk = _uint8ArrayToBuffer(chunk);
15470 }
15471
15472 if (addToFront) {
15473 if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
15474 } else if (state.ended) {
15475 stream.emit('error', new Error('stream.push() after EOF'));
15476 } else {
15477 state.reading = false;
15478 if (state.decoder && !encoding) {
15479 chunk = state.decoder.write(chunk);
15480 if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
15481 } else {
15482 addChunk(stream, state, chunk, false);
15483 }
15484 }
15485 } else if (!addToFront) {
15486 state.reading = false;
15487 }
15488 }
15489
15490 return needMoreData(state);
15491}
15492
15493function addChunk(stream, state, chunk, addToFront) {
15494 if (state.flowing && state.length === 0 && !state.sync) {
15495 stream.emit('data', chunk);
15496 stream.read(0);
15497 } else {
15498 // update the buffer info.
15499 state.length += state.objectMode ? 1 : chunk.length;
15500 if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
15501
15502 if (state.needReadable) emitReadable(stream);
15503 }
15504 maybeReadMore(stream, state);
15505}
15506
15507function chunkInvalid(state, chunk) {
15508 var er;
15509 if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
15510 er = new TypeError('Invalid non-string/buffer chunk');
15511 }
15512 return er;
15513}
15514
15515// if it's past the high water mark, we can push in some more.
15516// Also, if we have no data yet, we can stand some
15517// more bytes. This is to work around cases where hwm=0,
15518// such as the repl. Also, if the push() triggered a
15519// readable event, and the user called read(largeNumber) such that
15520// needReadable was set, then we ought to push more, so that another
15521// 'readable' event will be triggered.
15522function needMoreData(state) {
15523 return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
15524}
15525
15526Readable.prototype.isPaused = function () {
15527 return this._readableState.flowing === false;
15528};
15529
15530// backwards compatibility.
15531Readable.prototype.setEncoding = function (enc) {
15532 if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
15533 this._readableState.decoder = new StringDecoder(enc);
15534 this._readableState.encoding = enc;
15535 return this;
15536};
15537
15538// Don't raise the hwm > 8MB
15539var MAX_HWM = 0x800000;
15540function computeNewHighWaterMark(n) {
15541 if (n >= MAX_HWM) {
15542 n = MAX_HWM;
15543 } else {
15544 // Get the next highest power of 2 to prevent increasing hwm excessively in
15545 // tiny amounts
15546 n--;
15547 n |= n >>> 1;
15548 n |= n >>> 2;
15549 n |= n >>> 4;
15550 n |= n >>> 8;
15551 n |= n >>> 16;
15552 n++;
15553 }
15554 return n;
15555}
15556
15557// This function is designed to be inlinable, so please take care when making
15558// changes to the function body.
15559function howMuchToRead(n, state) {
15560 if (n <= 0 || state.length === 0 && state.ended) return 0;
15561 if (state.objectMode) return 1;
15562 if (n !== n) {
15563 // Only flow one buffer at a time
15564 if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
15565 }
15566 // If we're asking for more than the current hwm, then raise the hwm.
15567 if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
15568 if (n <= state.length) return n;
15569 // Don't have enough
15570 if (!state.ended) {
15571 state.needReadable = true;
15572 return 0;
15573 }
15574 return state.length;
15575}
15576
15577// you can override either this method, or the async _read(n) below.
15578Readable.prototype.read = function (n) {
15579 debug('read', n);
15580 n = parseInt(n, 10);
15581 var state = this._readableState;
15582 var nOrig = n;
15583
15584 if (n !== 0) state.emittedReadable = false;
15585
15586 // if we're doing read(0) to trigger a readable event, but we
15587 // already have a bunch of data in the buffer, then just trigger
15588 // the 'readable' event and move on.
15589 if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
15590 debug('read: emitReadable', state.length, state.ended);
15591 if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
15592 return null;
15593 }
15594
15595 n = howMuchToRead(n, state);
15596
15597 // if we've ended, and we're now clear, then finish it up.
15598 if (n === 0 && state.ended) {
15599 if (state.length === 0) endReadable(this);
15600 return null;
15601 }
15602
15603 // All the actual chunk generation logic needs to be
15604 // *below* the call to _read. The reason is that in certain
15605 // synthetic stream cases, such as passthrough streams, _read
15606 // may be a completely synchronous operation which may change
15607 // the state of the read buffer, providing enough data when
15608 // before there was *not* enough.
15609 //
15610 // So, the steps are:
15611 // 1. Figure out what the state of things will be after we do
15612 // a read from the buffer.
15613 //
15614 // 2. If that resulting state will trigger a _read, then call _read.
15615 // Note that this may be asynchronous, or synchronous. Yes, it is
15616 // deeply ugly to write APIs this way, but that still doesn't mean
15617 // that the Readable class should behave improperly, as streams are
15618 // designed to be sync/async agnostic.
15619 // Take note if the _read call is sync or async (ie, if the read call
15620 // has returned yet), so that we know whether or not it's safe to emit
15621 // 'readable' etc.
15622 //
15623 // 3. Actually pull the requested chunks out of the buffer and return.
15624
15625 // if we need a readable event, then we need to do some reading.
15626 var doRead = state.needReadable;
15627 debug('need readable', doRead);
15628
15629 // if we currently have less than the highWaterMark, then also read some
15630 if (state.length === 0 || state.length - n < state.highWaterMark) {
15631 doRead = true;
15632 debug('length less than watermark', doRead);
15633 }
15634
15635 // however, if we've ended, then there's no point, and if we're already
15636 // reading, then it's unnecessary.
15637 if (state.ended || state.reading) {
15638 doRead = false;
15639 debug('reading or ended', doRead);
15640 } else if (doRead) {
15641 debug('do read');
15642 state.reading = true;
15643 state.sync = true;
15644 // if the length is currently zero, then we *need* a readable event.
15645 if (state.length === 0) state.needReadable = true;
15646 // call internal read method
15647 this._read(state.highWaterMark);
15648 state.sync = false;
15649 // If _read pushed data synchronously, then `reading` will be false,
15650 // and we need to re-evaluate how much data we can return to the user.
15651 if (!state.reading) n = howMuchToRead(nOrig, state);
15652 }
15653
15654 var ret;
15655 if (n > 0) ret = fromList(n, state);else ret = null;
15656
15657 if (ret === null) {
15658 state.needReadable = true;
15659 n = 0;
15660 } else {
15661 state.length -= n;
15662 }
15663
15664 if (state.length === 0) {
15665 // If we have nothing in the buffer, then we want to know
15666 // as soon as we *do* get something into the buffer.
15667 if (!state.ended) state.needReadable = true;
15668
15669 // If we tried to read() past the EOF, then emit end on the next tick.
15670 if (nOrig !== n && state.ended) endReadable(this);
15671 }
15672
15673 if (ret !== null) this.emit('data', ret);
15674
15675 return ret;
15676};
15677
15678function onEofChunk(stream, state) {
15679 if (state.ended) return;
15680 if (state.decoder) {
15681 var chunk = state.decoder.end();
15682 if (chunk && chunk.length) {
15683 state.buffer.push(chunk);
15684 state.length += state.objectMode ? 1 : chunk.length;
15685 }
15686 }
15687 state.ended = true;
15688
15689 // emit 'readable' now to make sure it gets picked up.
15690 emitReadable(stream);
15691}
15692
15693// Don't emit readable right away in sync mode, because this can trigger
15694// another read() call => stack overflow. This way, it might trigger
15695// a nextTick recursion warning, but that's not so bad.
15696function emitReadable(stream) {
15697 var state = stream._readableState;
15698 state.needReadable = false;
15699 if (!state.emittedReadable) {
15700 debug('emitReadable', state.flowing);
15701 state.emittedReadable = true;
15702 if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);
15703 }
15704}
15705
15706function emitReadable_(stream) {
15707 debug('emit readable');
15708 stream.emit('readable');
15709 flow(stream);
15710}
15711
15712// at this point, the user has presumably seen the 'readable' event,
15713// and called read() to consume some data. that may have triggered
15714// in turn another _read(n) call, in which case reading = true if
15715// it's in progress.
15716// However, if we're not ended, or reading, and the length < hwm,
15717// then go ahead and try to read some more preemptively.
15718function maybeReadMore(stream, state) {
15719 if (!state.readingMore) {
15720 state.readingMore = true;
15721 pna.nextTick(maybeReadMore_, stream, state);
15722 }
15723}
15724
15725function maybeReadMore_(stream, state) {
15726 var len = state.length;
15727 while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
15728 debug('maybeReadMore read 0');
15729 stream.read(0);
15730 if (len === state.length)
15731 // didn't get any data, stop spinning.
15732 break;else len = state.length;
15733 }
15734 state.readingMore = false;
15735}
15736
15737// abstract method. to be overridden in specific implementation classes.
15738// call cb(er, data) where data is <= n in length.
15739// for virtual (non-string, non-buffer) streams, "length" is somewhat
15740// arbitrary, and perhaps not very meaningful.
15741Readable.prototype._read = function (n) {
15742 this.emit('error', new Error('_read() is not implemented'));
15743};
15744
15745Readable.prototype.pipe = function (dest, pipeOpts) {
15746 var src = this;
15747 var state = this._readableState;
15748
15749 switch (state.pipesCount) {
15750 case 0:
15751 state.pipes = dest;
15752 break;
15753 case 1:
15754 state.pipes = [state.pipes, dest];
15755 break;
15756 default:
15757 state.pipes.push(dest);
15758 break;
15759 }
15760 state.pipesCount += 1;
15761 debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
15762
15763 var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
15764
15765 var endFn = doEnd ? onend : unpipe;
15766 if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);
15767
15768 dest.on('unpipe', onunpipe);
15769 function onunpipe(readable, unpipeInfo) {
15770 debug('onunpipe');
15771 if (readable === src) {
15772 if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
15773 unpipeInfo.hasUnpiped = true;
15774 cleanup();
15775 }
15776 }
15777 }
15778
15779 function onend() {
15780 debug('onend');
15781 dest.end();
15782 }
15783
15784 // when the dest drains, it reduces the awaitDrain counter
15785 // on the source. This would be more elegant with a .once()
15786 // handler in flow(), but adding and removing repeatedly is
15787 // too slow.
15788 var ondrain = pipeOnDrain(src);
15789 dest.on('drain', ondrain);
15790
15791 var cleanedUp = false;
15792 function cleanup() {
15793 debug('cleanup');
15794 // cleanup event handlers once the pipe is broken
15795 dest.removeListener('close', onclose);
15796 dest.removeListener('finish', onfinish);
15797 dest.removeListener('drain', ondrain);
15798 dest.removeListener('error', onerror);
15799 dest.removeListener('unpipe', onunpipe);
15800 src.removeListener('end', onend);
15801 src.removeListener('end', unpipe);
15802 src.removeListener('data', ondata);
15803
15804 cleanedUp = true;
15805
15806 // if the reader is waiting for a drain event from this
15807 // specific writer, then it would cause it to never start
15808 // flowing again.
15809 // So, if this is awaiting a drain, then we just call it now.
15810 // If we don't know, then assume that we are waiting for one.
15811 if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
15812 }
15813
15814 // If the user pushes more data while we're writing to dest then we'll end up
15815 // in ondata again. However, we only want to increase awaitDrain once because
15816 // dest will only emit one 'drain' event for the multiple writes.
15817 // => Introduce a guard on increasing awaitDrain.
15818 var increasedAwaitDrain = false;
15819 src.on('data', ondata);
15820 function ondata(chunk) {
15821 debug('ondata');
15822 increasedAwaitDrain = false;
15823 var ret = dest.write(chunk);
15824 if (false === ret && !increasedAwaitDrain) {
15825 // If the user unpiped during `dest.write()`, it is possible
15826 // to get stuck in a permanently paused state if that write
15827 // also returned false.
15828 // => Check whether `dest` is still a piping destination.
15829 if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
15830 debug('false write response, pause', src._readableState.awaitDrain);
15831 src._readableState.awaitDrain++;
15832 increasedAwaitDrain = true;
15833 }
15834 src.pause();
15835 }
15836 }
15837
15838 // if the dest has an error, then stop piping into it.
15839 // however, don't suppress the throwing behavior for this.
15840 function onerror(er) {
15841 debug('onerror', er);
15842 unpipe();
15843 dest.removeListener('error', onerror);
15844 if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
15845 }
15846
15847 // Make sure our error handler is attached before userland ones.
15848 prependListener(dest, 'error', onerror);
15849
15850 // Both close and finish should trigger unpipe, but only once.
15851 function onclose() {
15852 dest.removeListener('finish', onfinish);
15853 unpipe();
15854 }
15855 dest.once('close', onclose);
15856 function onfinish() {
15857 debug('onfinish');
15858 dest.removeListener('close', onclose);
15859 unpipe();
15860 }
15861 dest.once('finish', onfinish);
15862
15863 function unpipe() {
15864 debug('unpipe');
15865 src.unpipe(dest);
15866 }
15867
15868 // tell the dest that it's being piped to
15869 dest.emit('pipe', src);
15870
15871 // start the flow if it hasn't been started already.
15872 if (!state.flowing) {
15873 debug('pipe resume');
15874 src.resume();
15875 }
15876
15877 return dest;
15878};
15879
15880function pipeOnDrain(src) {
15881 return function () {
15882 var state = src._readableState;
15883 debug('pipeOnDrain', state.awaitDrain);
15884 if (state.awaitDrain) state.awaitDrain--;
15885 if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
15886 state.flowing = true;
15887 flow(src);
15888 }
15889 };
15890}
15891
15892Readable.prototype.unpipe = function (dest) {
15893 var state = this._readableState;
15894 var unpipeInfo = { hasUnpiped: false };
15895
15896 // if we're not piping anywhere, then do nothing.
15897 if (state.pipesCount === 0) return this;
15898
15899 // just one destination. most common case.
15900 if (state.pipesCount === 1) {
15901 // passed in one, but it's not the right one.
15902 if (dest && dest !== state.pipes) return this;
15903
15904 if (!dest) dest = state.pipes;
15905
15906 // got a match.
15907 state.pipes = null;
15908 state.pipesCount = 0;
15909 state.flowing = false;
15910 if (dest) dest.emit('unpipe', this, unpipeInfo);
15911 return this;
15912 }
15913
15914 // slow case. multiple pipe destinations.
15915
15916 if (!dest) {
15917 // remove all.
15918 var dests = state.pipes;
15919 var len = state.pipesCount;
15920 state.pipes = null;
15921 state.pipesCount = 0;
15922 state.flowing = false;
15923
15924 for (var i = 0; i < len; i++) {
15925 dests[i].emit('unpipe', this, unpipeInfo);
15926 }return this;
15927 }
15928
15929 // try to find the right one.
15930 var index = indexOf(state.pipes, dest);
15931 if (index === -1) return this;
15932
15933 state.pipes.splice(index, 1);
15934 state.pipesCount -= 1;
15935 if (state.pipesCount === 1) state.pipes = state.pipes[0];
15936
15937 dest.emit('unpipe', this, unpipeInfo);
15938
15939 return this;
15940};
15941
15942// set up data events if they are asked for
15943// Ensure readable listeners eventually get something
15944Readable.prototype.on = function (ev, fn) {
15945 var res = Stream.prototype.on.call(this, ev, fn);
15946
15947 if (ev === 'data') {
15948 // Start flowing on next tick if stream isn't explicitly paused
15949 if (this._readableState.flowing !== false) this.resume();
15950 } else if (ev === 'readable') {
15951 var state = this._readableState;
15952 if (!state.endEmitted && !state.readableListening) {
15953 state.readableListening = state.needReadable = true;
15954 state.emittedReadable = false;
15955 if (!state.reading) {
15956 pna.nextTick(nReadingNextTick, this);
15957 } else if (state.length) {
15958 emitReadable(this);
15959 }
15960 }
15961 }
15962
15963 return res;
15964};
15965Readable.prototype.addListener = Readable.prototype.on;
15966
15967function nReadingNextTick(self) {
15968 debug('readable nexttick read 0');
15969 self.read(0);
15970}
15971
15972// pause() and resume() are remnants of the legacy readable stream API
15973// If the user uses them, then switch into old mode.
15974Readable.prototype.resume = function () {
15975 var state = this._readableState;
15976 if (!state.flowing) {
15977 debug('resume');
15978 state.flowing = true;
15979 resume(this, state);
15980 }
15981 return this;
15982};
15983
15984function resume(stream, state) {
15985 if (!state.resumeScheduled) {
15986 state.resumeScheduled = true;
15987 pna.nextTick(resume_, stream, state);
15988 }
15989}
15990
15991function resume_(stream, state) {
15992 if (!state.reading) {
15993 debug('resume read 0');
15994 stream.read(0);
15995 }
15996
15997 state.resumeScheduled = false;
15998 state.awaitDrain = 0;
15999 stream.emit('resume');
16000 flow(stream);
16001 if (state.flowing && !state.reading) stream.read(0);
16002}
16003
16004Readable.prototype.pause = function () {
16005 debug('call pause flowing=%j', this._readableState.flowing);
16006 if (false !== this._readableState.flowing) {
16007 debug('pause');
16008 this._readableState.flowing = false;
16009 this.emit('pause');
16010 }
16011 return this;
16012};
16013
16014function flow(stream) {
16015 var state = stream._readableState;
16016 debug('flow', state.flowing);
16017 while (state.flowing && stream.read() !== null) {}
16018}
16019
16020// wrap an old-style stream as the async data source.
16021// This is *not* part of the readable stream interface.
16022// It is an ugly unfortunate mess of history.
16023Readable.prototype.wrap = function (stream) {
16024 var _this = this;
16025
16026 var state = this._readableState;
16027 var paused = false;
16028
16029 stream.on('end', function () {
16030 debug('wrapped end');
16031 if (state.decoder && !state.ended) {
16032 var chunk = state.decoder.end();
16033 if (chunk && chunk.length) _this.push(chunk);
16034 }
16035
16036 _this.push(null);
16037 });
16038
16039 stream.on('data', function (chunk) {
16040 debug('wrapped data');
16041 if (state.decoder) chunk = state.decoder.write(chunk);
16042
16043 // don't skip over falsy values in objectMode
16044 if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
16045
16046 var ret = _this.push(chunk);
16047 if (!ret) {
16048 paused = true;
16049 stream.pause();
16050 }
16051 });
16052
16053 // proxy all the other methods.
16054 // important when wrapping filters and duplexes.
16055 for (var i in stream) {
16056 if (this[i] === undefined && typeof stream[i] === 'function') {
16057 this[i] = function (method) {
16058 return function () {
16059 return stream[method].apply(stream, arguments);
16060 };
16061 }(i);
16062 }
16063 }
16064
16065 // proxy certain important events.
16066 for (var n = 0; n < kProxyEvents.length; n++) {
16067 stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
16068 }
16069
16070 // when we try to consume some more bytes, simply unpause the
16071 // underlying stream.
16072 this._read = function (n) {
16073 debug('wrapped _read', n);
16074 if (paused) {
16075 paused = false;
16076 stream.resume();
16077 }
16078 };
16079
16080 return this;
16081};
16082
16083Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
16084 // making it explicit this property is not enumerable
16085 // because otherwise some prototype manipulation in
16086 // userland will fail
16087 enumerable: false,
16088 get: function () {
16089 return this._readableState.highWaterMark;
16090 }
16091});
16092
16093// exposed for testing purposes only.
16094Readable._fromList = fromList;
16095
16096// Pluck off n bytes from an array of buffers.
16097// Length is the combined lengths of all the buffers in the list.
16098// This function is designed to be inlinable, so please take care when making
16099// changes to the function body.
16100function fromList(n, state) {
16101 // nothing buffered
16102 if (state.length === 0) return null;
16103
16104 var ret;
16105 if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
16106 // read it all, truncate the list
16107 if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);
16108 state.buffer.clear();
16109 } else {
16110 // read part of list
16111 ret = fromListPartial(n, state.buffer, state.decoder);
16112 }
16113
16114 return ret;
16115}
16116
16117// Extracts only enough buffered data to satisfy the amount requested.
16118// This function is designed to be inlinable, so please take care when making
16119// changes to the function body.
16120function fromListPartial(n, list, hasStrings) {
16121 var ret;
16122 if (n < list.head.data.length) {
16123 // slice is the same for buffers and strings
16124 ret = list.head.data.slice(0, n);
16125 list.head.data = list.head.data.slice(n);
16126 } else if (n === list.head.data.length) {
16127 // first chunk is a perfect match
16128 ret = list.shift();
16129 } else {
16130 // result spans more than one buffer
16131 ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
16132 }
16133 return ret;
16134}
16135
16136// Copies a specified amount of characters from the list of buffered data
16137// chunks.
16138// This function is designed to be inlinable, so please take care when making
16139// changes to the function body.
16140function copyFromBufferString(n, list) {
16141 var p = list.head;
16142 var c = 1;
16143 var ret = p.data;
16144 n -= ret.length;
16145 while (p = p.next) {
16146 var str = p.data;
16147 var nb = n > str.length ? str.length : n;
16148 if (nb === str.length) ret += str;else ret += str.slice(0, n);
16149 n -= nb;
16150 if (n === 0) {
16151 if (nb === str.length) {
16152 ++c;
16153 if (p.next) list.head = p.next;else list.head = list.tail = null;
16154 } else {
16155 list.head = p;
16156 p.data = str.slice(nb);
16157 }
16158 break;
16159 }
16160 ++c;
16161 }
16162 list.length -= c;
16163 return ret;
16164}
16165
16166// Copies a specified amount of bytes from the list of buffered data chunks.
16167// This function is designed to be inlinable, so please take care when making
16168// changes to the function body.
16169function copyFromBuffer(n, list) {
16170 var ret = Buffer.allocUnsafe(n);
16171 var p = list.head;
16172 var c = 1;
16173 p.data.copy(ret);
16174 n -= p.data.length;
16175 while (p = p.next) {
16176 var buf = p.data;
16177 var nb = n > buf.length ? buf.length : n;
16178 buf.copy(ret, ret.length - n, 0, nb);
16179 n -= nb;
16180 if (n === 0) {
16181 if (nb === buf.length) {
16182 ++c;
16183 if (p.next) list.head = p.next;else list.head = list.tail = null;
16184 } else {
16185 list.head = p;
16186 p.data = buf.slice(nb);
16187 }
16188 break;
16189 }
16190 ++c;
16191 }
16192 list.length -= c;
16193 return ret;
16194}
16195
16196function endReadable(stream) {
16197 var state = stream._readableState;
16198
16199 // If we get here before consuming all the bytes, then that is a
16200 // bug in node. Should never happen.
16201 if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
16202
16203 if (!state.endEmitted) {
16204 state.ended = true;
16205 pna.nextTick(endReadableNT, state, stream);
16206 }
16207}
16208
16209function endReadableNT(state, stream) {
16210 // Check that we didn't get one last unshift.
16211 if (!state.endEmitted && state.length === 0) {
16212 state.endEmitted = true;
16213 stream.readable = false;
16214 stream.emit('end');
16215 }
16216}
16217
16218function indexOf(xs, x) {
16219 for (var i = 0, l = xs.length; i < l; i++) {
16220 if (xs[i] === x) return i;
16221 }
16222 return -1;
16223}
16224}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
16225},{"./_stream_duplex":107,"./internal/streams/BufferList":112,"./internal/streams/destroy":113,"./internal/streams/stream":114,"_process":105,"core-util-is":97,"events":98,"inherits":100,"isarray":102,"process-nextick-args":104,"safe-buffer":115,"string_decoder/":116,"util":95}],110:[function(require,module,exports){
16226// Copyright Joyent, Inc. and other Node contributors.
16227//
16228// Permission is hereby granted, free of charge, to any person obtaining a
16229// copy of this software and associated documentation files (the
16230// "Software"), to deal in the Software without restriction, including
16231// without limitation the rights to use, copy, modify, merge, publish,
16232// distribute, sublicense, and/or sell copies of the Software, and to permit
16233// persons to whom the Software is furnished to do so, subject to the
16234// following conditions:
16235//
16236// The above copyright notice and this permission notice shall be included
16237// in all copies or substantial portions of the Software.
16238//
16239// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16240// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16241// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
16242// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
16243// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16244// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
16245// USE OR OTHER DEALINGS IN THE SOFTWARE.
16246
16247// a transform stream is a readable/writable stream where you do
16248// something with the data. Sometimes it's called a "filter",
16249// but that's not a great name for it, since that implies a thing where
16250// some bits pass through, and others are simply ignored. (That would
16251// be a valid example of a transform, of course.)
16252//
16253// While the output is causally related to the input, it's not a
16254// necessarily symmetric or synchronous transformation. For example,
16255// a zlib stream might take multiple plain-text writes(), and then
16256// emit a single compressed chunk some time in the future.
16257//
16258// Here's how this works:
16259//
16260// The Transform stream has all the aspects of the readable and writable
16261// stream classes. When you write(chunk), that calls _write(chunk,cb)
16262// internally, and returns false if there's a lot of pending writes
16263// buffered up. When you call read(), that calls _read(n) until
16264// there's enough pending readable data buffered up.
16265//
16266// In a transform stream, the written data is placed in a buffer. When
16267// _read(n) is called, it transforms the queued up data, calling the
16268// buffered _write cb's as it consumes chunks. If consuming a single
16269// written chunk would result in multiple output chunks, then the first
16270// outputted bit calls the readcb, and subsequent chunks just go into
16271// the read buffer, and will cause it to emit 'readable' if necessary.
16272//
16273// This way, back-pressure is actually determined by the reading side,
16274// since _read has to be called to start processing a new chunk. However,
16275// a pathological inflate type of transform can cause excessive buffering
16276// here. For example, imagine a stream where every byte of input is
16277// interpreted as an integer from 0-255, and then results in that many
16278// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
16279// 1kb of data being output. In this case, you could write a very small
16280// amount of input, and end up with a very large amount of output. In
16281// such a pathological inflating mechanism, there'd be no way to tell
16282// the system to stop doing the transform. A single 4MB write could
16283// cause the system to run out of memory.
16284//
16285// However, even in such a pathological case, only a single written chunk
16286// would be consumed, and then the rest would wait (un-transformed) until
16287// the results of the previous transformed chunk were consumed.
16288
16289'use strict';
16290
16291module.exports = Transform;
16292
16293var Duplex = require('./_stream_duplex');
16294
16295/*<replacement>*/
16296var util = require('core-util-is');
16297util.inherits = require('inherits');
16298/*</replacement>*/
16299
16300util.inherits(Transform, Duplex);
16301
16302function afterTransform(er, data) {
16303 var ts = this._transformState;
16304 ts.transforming = false;
16305
16306 var cb = ts.writecb;
16307
16308 if (!cb) {
16309 return this.emit('error', new Error('write callback called multiple times'));
16310 }
16311
16312 ts.writechunk = null;
16313 ts.writecb = null;
16314
16315 if (data != null) // single equals check for both `null` and `undefined`
16316 this.push(data);
16317
16318 cb(er);
16319
16320 var rs = this._readableState;
16321 rs.reading = false;
16322 if (rs.needReadable || rs.length < rs.highWaterMark) {
16323 this._read(rs.highWaterMark);
16324 }
16325}
16326
16327function Transform(options) {
16328 if (!(this instanceof Transform)) return new Transform(options);
16329
16330 Duplex.call(this, options);
16331
16332 this._transformState = {
16333 afterTransform: afterTransform.bind(this),
16334 needTransform: false,
16335 transforming: false,
16336 writecb: null,
16337 writechunk: null,
16338 writeencoding: null
16339 };
16340
16341 // start out asking for a readable event once data is transformed.
16342 this._readableState.needReadable = true;
16343
16344 // we have implemented the _read method, and done the other things
16345 // that Readable wants before the first _read call, so unset the
16346 // sync guard flag.
16347 this._readableState.sync = false;
16348
16349 if (options) {
16350 if (typeof options.transform === 'function') this._transform = options.transform;
16351
16352 if (typeof options.flush === 'function') this._flush = options.flush;
16353 }
16354
16355 // When the writable side finishes, then flush out anything remaining.
16356 this.on('prefinish', prefinish);
16357}
16358
16359function prefinish() {
16360 var _this = this;
16361
16362 if (typeof this._flush === 'function') {
16363 this._flush(function (er, data) {
16364 done(_this, er, data);
16365 });
16366 } else {
16367 done(this, null, null);
16368 }
16369}
16370
16371Transform.prototype.push = function (chunk, encoding) {
16372 this._transformState.needTransform = false;
16373 return Duplex.prototype.push.call(this, chunk, encoding);
16374};
16375
16376// This is the part where you do stuff!
16377// override this function in implementation classes.
16378// 'chunk' is an input chunk.
16379//
16380// Call `push(newChunk)` to pass along transformed output
16381// to the readable side. You may call 'push' zero or more times.
16382//
16383// Call `cb(err)` when you are done with this chunk. If you pass
16384// an error, then that'll put the hurt on the whole operation. If you
16385// never call cb(), then you'll never get another chunk.
16386Transform.prototype._transform = function (chunk, encoding, cb) {
16387 throw new Error('_transform() is not implemented');
16388};
16389
16390Transform.prototype._write = function (chunk, encoding, cb) {
16391 var ts = this._transformState;
16392 ts.writecb = cb;
16393 ts.writechunk = chunk;
16394 ts.writeencoding = encoding;
16395 if (!ts.transforming) {
16396 var rs = this._readableState;
16397 if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
16398 }
16399};
16400
16401// Doesn't matter what the args are here.
16402// _transform does all the work.
16403// That we got here means that the readable side wants more data.
16404Transform.prototype._read = function (n) {
16405 var ts = this._transformState;
16406
16407 if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
16408 ts.transforming = true;
16409 this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
16410 } else {
16411 // mark that we need a transform, so that any data that comes in
16412 // will get processed, now that we've asked for it.
16413 ts.needTransform = true;
16414 }
16415};
16416
16417Transform.prototype._destroy = function (err, cb) {
16418 var _this2 = this;
16419
16420 Duplex.prototype._destroy.call(this, err, function (err2) {
16421 cb(err2);
16422 _this2.emit('close');
16423 });
16424};
16425
16426function done(stream, er, data) {
16427 if (er) return stream.emit('error', er);
16428
16429 if (data != null) // single equals check for both `null` and `undefined`
16430 stream.push(data);
16431
16432 // if there's nothing in the write buffer, then that means
16433 // that nothing more will ever be provided
16434 if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
16435
16436 if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
16437
16438 return stream.push(null);
16439}
16440},{"./_stream_duplex":107,"core-util-is":97,"inherits":100}],111:[function(require,module,exports){
16441(function (process,global,setImmediate){
16442// Copyright Joyent, Inc. and other Node contributors.
16443//
16444// Permission is hereby granted, free of charge, to any person obtaining a
16445// copy of this software and associated documentation files (the
16446// "Software"), to deal in the Software without restriction, including
16447// without limitation the rights to use, copy, modify, merge, publish,
16448// distribute, sublicense, and/or sell copies of the Software, and to permit
16449// persons to whom the Software is furnished to do so, subject to the
16450// following conditions:
16451//
16452// The above copyright notice and this permission notice shall be included
16453// in all copies or substantial portions of the Software.
16454//
16455// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16456// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16457// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
16458// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
16459// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16460// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
16461// USE OR OTHER DEALINGS IN THE SOFTWARE.
16462
16463// A bit simpler than readable streams.
16464// Implement an async ._write(chunk, encoding, cb), and it'll handle all
16465// the drain event emission and buffering.
16466
16467'use strict';
16468
16469/*<replacement>*/
16470
16471var pna = require('process-nextick-args');
16472/*</replacement>*/
16473
16474module.exports = Writable;
16475
16476/* <replacement> */
16477function WriteReq(chunk, encoding, cb) {
16478 this.chunk = chunk;
16479 this.encoding = encoding;
16480 this.callback = cb;
16481 this.next = null;
16482}
16483
16484// It seems a linked list but it is not
16485// there will be only 2 of these for each stream
16486function CorkedRequest(state) {
16487 var _this = this;
16488
16489 this.next = null;
16490 this.entry = null;
16491 this.finish = function () {
16492 onCorkedFinish(_this, state);
16493 };
16494}
16495/* </replacement> */
16496
16497/*<replacement>*/
16498var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
16499/*</replacement>*/
16500
16501/*<replacement>*/
16502var Duplex;
16503/*</replacement>*/
16504
16505Writable.WritableState = WritableState;
16506
16507/*<replacement>*/
16508var util = require('core-util-is');
16509util.inherits = require('inherits');
16510/*</replacement>*/
16511
16512/*<replacement>*/
16513var internalUtil = {
16514 deprecate: require('util-deprecate')
16515};
16516/*</replacement>*/
16517
16518/*<replacement>*/
16519var Stream = require('./internal/streams/stream');
16520/*</replacement>*/
16521
16522/*<replacement>*/
16523
16524var Buffer = require('safe-buffer').Buffer;
16525var OurUint8Array = global.Uint8Array || function () {};
16526function _uint8ArrayToBuffer(chunk) {
16527 return Buffer.from(chunk);
16528}
16529function _isUint8Array(obj) {
16530 return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
16531}
16532
16533/*</replacement>*/
16534
16535var destroyImpl = require('./internal/streams/destroy');
16536
16537util.inherits(Writable, Stream);
16538
16539function nop() {}
16540
16541function WritableState(options, stream) {
16542 Duplex = Duplex || require('./_stream_duplex');
16543
16544 options = options || {};
16545
16546 // Duplex streams are both readable and writable, but share
16547 // the same options object.
16548 // However, some cases require setting options to different
16549 // values for the readable and the writable sides of the duplex stream.
16550 // These options can be provided separately as readableXXX and writableXXX.
16551 var isDuplex = stream instanceof Duplex;
16552
16553 // object stream flag to indicate whether or not this stream
16554 // contains buffers or objects.
16555 this.objectMode = !!options.objectMode;
16556
16557 if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
16558
16559 // the point at which write() starts returning false
16560 // Note: 0 is a valid value, means that we always return false if
16561 // the entire buffer is not flushed immediately on write()
16562 var hwm = options.highWaterMark;
16563 var writableHwm = options.writableHighWaterMark;
16564 var defaultHwm = this.objectMode ? 16 : 16 * 1024;
16565
16566 if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;
16567
16568 // cast to ints.
16569 this.highWaterMark = Math.floor(this.highWaterMark);
16570
16571 // if _final has been called
16572 this.finalCalled = false;
16573
16574 // drain event flag.
16575 this.needDrain = false;
16576 // at the start of calling end()
16577 this.ending = false;
16578 // when end() has been called, and returned
16579 this.ended = false;
16580 // when 'finish' is emitted
16581 this.finished = false;
16582
16583 // has it been destroyed
16584 this.destroyed = false;
16585
16586 // should we decode strings into buffers before passing to _write?
16587 // this is here so that some node-core streams can optimize string
16588 // handling at a lower level.
16589 var noDecode = options.decodeStrings === false;
16590 this.decodeStrings = !noDecode;
16591
16592 // Crypto is kind of old and crusty. Historically, its default string
16593 // encoding is 'binary' so we have to make this configurable.
16594 // Everything else in the universe uses 'utf8', though.
16595 this.defaultEncoding = options.defaultEncoding || 'utf8';
16596
16597 // not an actual buffer we keep track of, but a measurement
16598 // of how much we're waiting to get pushed to some underlying
16599 // socket or file.
16600 this.length = 0;
16601
16602 // a flag to see when we're in the middle of a write.
16603 this.writing = false;
16604
16605 // when true all writes will be buffered until .uncork() call
16606 this.corked = 0;
16607
16608 // a flag to be able to tell if the onwrite cb is called immediately,
16609 // or on a later tick. We set this to true at first, because any
16610 // actions that shouldn't happen until "later" should generally also
16611 // not happen before the first write call.
16612 this.sync = true;
16613
16614 // a flag to know if we're processing previously buffered items, which
16615 // may call the _write() callback in the same tick, so that we don't
16616 // end up in an overlapped onwrite situation.
16617 this.bufferProcessing = false;
16618
16619 // the callback that's passed to _write(chunk,cb)
16620 this.onwrite = function (er) {
16621 onwrite(stream, er);
16622 };
16623
16624 // the callback that the user supplies to write(chunk,encoding,cb)
16625 this.writecb = null;
16626
16627 // the amount that is being written when _write is called.
16628 this.writelen = 0;
16629
16630 this.bufferedRequest = null;
16631 this.lastBufferedRequest = null;
16632
16633 // number of pending user-supplied write callbacks
16634 // this must be 0 before 'finish' can be emitted
16635 this.pendingcb = 0;
16636
16637 // emit prefinish if the only thing we're waiting for is _write cbs
16638 // This is relevant for synchronous Transform streams
16639 this.prefinished = false;
16640
16641 // True if the error was already emitted and should not be thrown again
16642 this.errorEmitted = false;
16643
16644 // count buffered requests
16645 this.bufferedRequestCount = 0;
16646
16647 // allocate the first CorkedRequest, there is always
16648 // one allocated and free to use, and we maintain at most two
16649 this.corkedRequestsFree = new CorkedRequest(this);
16650}
16651
16652WritableState.prototype.getBuffer = function getBuffer() {
16653 var current = this.bufferedRequest;
16654 var out = [];
16655 while (current) {
16656 out.push(current);
16657 current = current.next;
16658 }
16659 return out;
16660};
16661
16662(function () {
16663 try {
16664 Object.defineProperty(WritableState.prototype, 'buffer', {
16665 get: internalUtil.deprecate(function () {
16666 return this.getBuffer();
16667 }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
16668 });
16669 } catch (_) {}
16670})();
16671
16672// Test _writableState for inheritance to account for Duplex streams,
16673// whose prototype chain only points to Readable.
16674var realHasInstance;
16675if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
16676 realHasInstance = Function.prototype[Symbol.hasInstance];
16677 Object.defineProperty(Writable, Symbol.hasInstance, {
16678 value: function (object) {
16679 if (realHasInstance.call(this, object)) return true;
16680 if (this !== Writable) return false;
16681
16682 return object && object._writableState instanceof WritableState;
16683 }
16684 });
16685} else {
16686 realHasInstance = function (object) {
16687 return object instanceof this;
16688 };
16689}
16690
16691function Writable(options) {
16692 Duplex = Duplex || require('./_stream_duplex');
16693
16694 // Writable ctor is applied to Duplexes, too.
16695 // `realHasInstance` is necessary because using plain `instanceof`
16696 // would return false, as no `_writableState` property is attached.
16697
16698 // Trying to use the custom `instanceof` for Writable here will also break the
16699 // Node.js LazyTransform implementation, which has a non-trivial getter for
16700 // `_writableState` that would lead to infinite recursion.
16701 if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
16702 return new Writable(options);
16703 }
16704
16705 this._writableState = new WritableState(options, this);
16706
16707 // legacy.
16708 this.writable = true;
16709
16710 if (options) {
16711 if (typeof options.write === 'function') this._write = options.write;
16712
16713 if (typeof options.writev === 'function') this._writev = options.writev;
16714
16715 if (typeof options.destroy === 'function') this._destroy = options.destroy;
16716
16717 if (typeof options.final === 'function') this._final = options.final;
16718 }
16719
16720 Stream.call(this);
16721}
16722
16723// Otherwise people can pipe Writable streams, which is just wrong.
16724Writable.prototype.pipe = function () {
16725 this.emit('error', new Error('Cannot pipe, not readable'));
16726};
16727
16728function writeAfterEnd(stream, cb) {
16729 var er = new Error('write after end');
16730 // TODO: defer error events consistently everywhere, not just the cb
16731 stream.emit('error', er);
16732 pna.nextTick(cb, er);
16733}
16734
16735// Checks that a user-supplied chunk is valid, especially for the particular
16736// mode the stream is in. Currently this means that `null` is never accepted
16737// and undefined/non-string values are only allowed in object mode.
16738function validChunk(stream, state, chunk, cb) {
16739 var valid = true;
16740 var er = false;
16741
16742 if (chunk === null) {
16743 er = new TypeError('May not write null values to stream');
16744 } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
16745 er = new TypeError('Invalid non-string/buffer chunk');
16746 }
16747 if (er) {
16748 stream.emit('error', er);
16749 pna.nextTick(cb, er);
16750 valid = false;
16751 }
16752 return valid;
16753}
16754
16755Writable.prototype.write = function (chunk, encoding, cb) {
16756 var state = this._writableState;
16757 var ret = false;
16758 var isBuf = !state.objectMode && _isUint8Array(chunk);
16759
16760 if (isBuf && !Buffer.isBuffer(chunk)) {
16761 chunk = _uint8ArrayToBuffer(chunk);
16762 }
16763
16764 if (typeof encoding === 'function') {
16765 cb = encoding;
16766 encoding = null;
16767 }
16768
16769 if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
16770
16771 if (typeof cb !== 'function') cb = nop;
16772
16773 if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
16774 state.pendingcb++;
16775 ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
16776 }
16777
16778 return ret;
16779};
16780
16781Writable.prototype.cork = function () {
16782 var state = this._writableState;
16783
16784 state.corked++;
16785};
16786
16787Writable.prototype.uncork = function () {
16788 var state = this._writableState;
16789
16790 if (state.corked) {
16791 state.corked--;
16792
16793 if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
16794 }
16795};
16796
16797Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
16798 // node::ParseEncoding() requires lower case.
16799 if (typeof encoding === 'string') encoding = encoding.toLowerCase();
16800 if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
16801 this._writableState.defaultEncoding = encoding;
16802 return this;
16803};
16804
16805function decodeChunk(state, chunk, encoding) {
16806 if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
16807 chunk = Buffer.from(chunk, encoding);
16808 }
16809 return chunk;
16810}
16811
16812Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
16813 // making it explicit this property is not enumerable
16814 // because otherwise some prototype manipulation in
16815 // userland will fail
16816 enumerable: false,
16817 get: function () {
16818 return this._writableState.highWaterMark;
16819 }
16820});
16821
16822// if we're already writing something, then just put this
16823// in the queue, and wait our turn. Otherwise, call _write
16824// If we return false, then we need a drain event, so set that flag.
16825function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
16826 if (!isBuf) {
16827 var newChunk = decodeChunk(state, chunk, encoding);
16828 if (chunk !== newChunk) {
16829 isBuf = true;
16830 encoding = 'buffer';
16831 chunk = newChunk;
16832 }
16833 }
16834 var len = state.objectMode ? 1 : chunk.length;
16835
16836 state.length += len;
16837
16838 var ret = state.length < state.highWaterMark;
16839 // we must ensure that previous needDrain will not be reset to false.
16840 if (!ret) state.needDrain = true;
16841
16842 if (state.writing || state.corked) {
16843 var last = state.lastBufferedRequest;
16844 state.lastBufferedRequest = {
16845 chunk: chunk,
16846 encoding: encoding,
16847 isBuf: isBuf,
16848 callback: cb,
16849 next: null
16850 };
16851 if (last) {
16852 last.next = state.lastBufferedRequest;
16853 } else {
16854 state.bufferedRequest = state.lastBufferedRequest;
16855 }
16856 state.bufferedRequestCount += 1;
16857 } else {
16858 doWrite(stream, state, false, len, chunk, encoding, cb);
16859 }
16860
16861 return ret;
16862}
16863
16864function doWrite(stream, state, writev, len, chunk, encoding, cb) {
16865 state.writelen = len;
16866 state.writecb = cb;
16867 state.writing = true;
16868 state.sync = true;
16869 if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
16870 state.sync = false;
16871}
16872
16873function onwriteError(stream, state, sync, er, cb) {
16874 --state.pendingcb;
16875
16876 if (sync) {
16877 // defer the callback if we are being called synchronously
16878 // to avoid piling up things on the stack
16879 pna.nextTick(cb, er);
16880 // this can emit finish, and it will always happen
16881 // after error
16882 pna.nextTick(finishMaybe, stream, state);
16883 stream._writableState.errorEmitted = true;
16884 stream.emit('error', er);
16885 } else {
16886 // the caller expect this to happen before if
16887 // it is async
16888 cb(er);
16889 stream._writableState.errorEmitted = true;
16890 stream.emit('error', er);
16891 // this can emit finish, but finish must
16892 // always follow error
16893 finishMaybe(stream, state);
16894 }
16895}
16896
16897function onwriteStateUpdate(state) {
16898 state.writing = false;
16899 state.writecb = null;
16900 state.length -= state.writelen;
16901 state.writelen = 0;
16902}
16903
16904function onwrite(stream, er) {
16905 var state = stream._writableState;
16906 var sync = state.sync;
16907 var cb = state.writecb;
16908
16909 onwriteStateUpdate(state);
16910
16911 if (er) onwriteError(stream, state, sync, er, cb);else {
16912 // Check if we're actually ready to finish, but don't emit yet
16913 var finished = needFinish(state);
16914
16915 if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
16916 clearBuffer(stream, state);
16917 }
16918
16919 if (sync) {
16920 /*<replacement>*/
16921 asyncWrite(afterWrite, stream, state, finished, cb);
16922 /*</replacement>*/
16923 } else {
16924 afterWrite(stream, state, finished, cb);
16925 }
16926 }
16927}
16928
16929function afterWrite(stream, state, finished, cb) {
16930 if (!finished) onwriteDrain(stream, state);
16931 state.pendingcb--;
16932 cb();
16933 finishMaybe(stream, state);
16934}
16935
16936// Must force callback to be called on nextTick, so that we don't
16937// emit 'drain' before the write() consumer gets the 'false' return
16938// value, and has a chance to attach a 'drain' listener.
16939function onwriteDrain(stream, state) {
16940 if (state.length === 0 && state.needDrain) {
16941 state.needDrain = false;
16942 stream.emit('drain');
16943 }
16944}
16945
16946// if there's something in the buffer waiting, then process it
16947function clearBuffer(stream, state) {
16948 state.bufferProcessing = true;
16949 var entry = state.bufferedRequest;
16950
16951 if (stream._writev && entry && entry.next) {
16952 // Fast case, write everything using _writev()
16953 var l = state.bufferedRequestCount;
16954 var buffer = new Array(l);
16955 var holder = state.corkedRequestsFree;
16956 holder.entry = entry;
16957
16958 var count = 0;
16959 var allBuffers = true;
16960 while (entry) {
16961 buffer[count] = entry;
16962 if (!entry.isBuf) allBuffers = false;
16963 entry = entry.next;
16964 count += 1;
16965 }
16966 buffer.allBuffers = allBuffers;
16967
16968 doWrite(stream, state, true, state.length, buffer, '', holder.finish);
16969
16970 // doWrite is almost always async, defer these to save a bit of time
16971 // as the hot path ends with doWrite
16972 state.pendingcb++;
16973 state.lastBufferedRequest = null;
16974 if (holder.next) {
16975 state.corkedRequestsFree = holder.next;
16976 holder.next = null;
16977 } else {
16978 state.corkedRequestsFree = new CorkedRequest(state);
16979 }
16980 state.bufferedRequestCount = 0;
16981 } else {
16982 // Slow case, write chunks one-by-one
16983 while (entry) {
16984 var chunk = entry.chunk;
16985 var encoding = entry.encoding;
16986 var cb = entry.callback;
16987 var len = state.objectMode ? 1 : chunk.length;
16988
16989 doWrite(stream, state, false, len, chunk, encoding, cb);
16990 entry = entry.next;
16991 state.bufferedRequestCount--;
16992 // if we didn't call the onwrite immediately, then
16993 // it means that we need to wait until it does.
16994 // also, that means that the chunk and cb are currently
16995 // being processed, so move the buffer counter past them.
16996 if (state.writing) {
16997 break;
16998 }
16999 }
17000
17001 if (entry === null) state.lastBufferedRequest = null;
17002 }
17003
17004 state.bufferedRequest = entry;
17005 state.bufferProcessing = false;
17006}
17007
17008Writable.prototype._write = function (chunk, encoding, cb) {
17009 cb(new Error('_write() is not implemented'));
17010};
17011
17012Writable.prototype._writev = null;
17013
17014Writable.prototype.end = function (chunk, encoding, cb) {
17015 var state = this._writableState;
17016
17017 if (typeof chunk === 'function') {
17018 cb = chunk;
17019 chunk = null;
17020 encoding = null;
17021 } else if (typeof encoding === 'function') {
17022 cb = encoding;
17023 encoding = null;
17024 }
17025
17026 if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
17027
17028 // .end() fully uncorks
17029 if (state.corked) {
17030 state.corked = 1;
17031 this.uncork();
17032 }
17033
17034 // ignore unnecessary end() calls.
17035 if (!state.ending && !state.finished) endWritable(this, state, cb);
17036};
17037
17038function needFinish(state) {
17039 return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
17040}
17041function callFinal(stream, state) {
17042 stream._final(function (err) {
17043 state.pendingcb--;
17044 if (err) {
17045 stream.emit('error', err);
17046 }
17047 state.prefinished = true;
17048 stream.emit('prefinish');
17049 finishMaybe(stream, state);
17050 });
17051}
17052function prefinish(stream, state) {
17053 if (!state.prefinished && !state.finalCalled) {
17054 if (typeof stream._final === 'function') {
17055 state.pendingcb++;
17056 state.finalCalled = true;
17057 pna.nextTick(callFinal, stream, state);
17058 } else {
17059 state.prefinished = true;
17060 stream.emit('prefinish');
17061 }
17062 }
17063}
17064
17065function finishMaybe(stream, state) {
17066 var need = needFinish(state);
17067 if (need) {
17068 prefinish(stream, state);
17069 if (state.pendingcb === 0) {
17070 state.finished = true;
17071 stream.emit('finish');
17072 }
17073 }
17074 return need;
17075}
17076
17077function endWritable(stream, state, cb) {
17078 state.ending = true;
17079 finishMaybe(stream, state);
17080 if (cb) {
17081 if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
17082 }
17083 state.ended = true;
17084 stream.writable = false;
17085}
17086
17087function onCorkedFinish(corkReq, state, err) {
17088 var entry = corkReq.entry;
17089 corkReq.entry = null;
17090 while (entry) {
17091 var cb = entry.callback;
17092 state.pendingcb--;
17093 cb(err);
17094 entry = entry.next;
17095 }
17096 if (state.corkedRequestsFree) {
17097 state.corkedRequestsFree.next = corkReq;
17098 } else {
17099 state.corkedRequestsFree = corkReq;
17100 }
17101}
17102
17103Object.defineProperty(Writable.prototype, 'destroyed', {
17104 get: function () {
17105 if (this._writableState === undefined) {
17106 return false;
17107 }
17108 return this._writableState.destroyed;
17109 },
17110 set: function (value) {
17111 // we ignore the value if the stream
17112 // has not been initialized yet
17113 if (!this._writableState) {
17114 return;
17115 }
17116
17117 // backward compatibility, the user is explicitly
17118 // managing destroyed
17119 this._writableState.destroyed = value;
17120 }
17121});
17122
17123Writable.prototype.destroy = destroyImpl.destroy;
17124Writable.prototype._undestroy = destroyImpl.undestroy;
17125Writable.prototype._destroy = function (err, cb) {
17126 this.end();
17127 cb(err);
17128};
17129}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").setImmediate)
17130},{"./_stream_duplex":107,"./internal/streams/destroy":113,"./internal/streams/stream":114,"_process":105,"core-util-is":97,"inherits":100,"process-nextick-args":104,"safe-buffer":115,"timers":124,"util-deprecate":125}],112:[function(require,module,exports){
17131'use strict';
17132
17133function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17134
17135var Buffer = require('safe-buffer').Buffer;
17136var util = require('util');
17137
17138function copyBuffer(src, target, offset) {
17139 src.copy(target, offset);
17140}
17141
17142module.exports = function () {
17143 function BufferList() {
17144 _classCallCheck(this, BufferList);
17145
17146 this.head = null;
17147 this.tail = null;
17148 this.length = 0;
17149 }
17150
17151 BufferList.prototype.push = function push(v) {
17152 var entry = { data: v, next: null };
17153 if (this.length > 0) this.tail.next = entry;else this.head = entry;
17154 this.tail = entry;
17155 ++this.length;
17156 };
17157
17158 BufferList.prototype.unshift = function unshift(v) {
17159 var entry = { data: v, next: this.head };
17160 if (this.length === 0) this.tail = entry;
17161 this.head = entry;
17162 ++this.length;
17163 };
17164
17165 BufferList.prototype.shift = function shift() {
17166 if (this.length === 0) return;
17167 var ret = this.head.data;
17168 if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
17169 --this.length;
17170 return ret;
17171 };
17172
17173 BufferList.prototype.clear = function clear() {
17174 this.head = this.tail = null;
17175 this.length = 0;
17176 };
17177
17178 BufferList.prototype.join = function join(s) {
17179 if (this.length === 0) return '';
17180 var p = this.head;
17181 var ret = '' + p.data;
17182 while (p = p.next) {
17183 ret += s + p.data;
17184 }return ret;
17185 };
17186
17187 BufferList.prototype.concat = function concat(n) {
17188 if (this.length === 0) return Buffer.alloc(0);
17189 if (this.length === 1) return this.head.data;
17190 var ret = Buffer.allocUnsafe(n >>> 0);
17191 var p = this.head;
17192 var i = 0;
17193 while (p) {
17194 copyBuffer(p.data, ret, i);
17195 i += p.data.length;
17196 p = p.next;
17197 }
17198 return ret;
17199 };
17200
17201 return BufferList;
17202}();
17203
17204if (util && util.inspect && util.inspect.custom) {
17205 module.exports.prototype[util.inspect.custom] = function () {
17206 var obj = util.inspect({ length: this.length });
17207 return this.constructor.name + ' ' + obj;
17208 };
17209}
17210},{"safe-buffer":115,"util":95}],113:[function(require,module,exports){
17211'use strict';
17212
17213/*<replacement>*/
17214
17215var pna = require('process-nextick-args');
17216/*</replacement>*/
17217
17218// undocumented cb() API, needed for core, not for public API
17219function destroy(err, cb) {
17220 var _this = this;
17221
17222 var readableDestroyed = this._readableState && this._readableState.destroyed;
17223 var writableDestroyed = this._writableState && this._writableState.destroyed;
17224
17225 if (readableDestroyed || writableDestroyed) {
17226 if (cb) {
17227 cb(err);
17228 } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
17229 pna.nextTick(emitErrorNT, this, err);
17230 }
17231 return this;
17232 }
17233
17234 // we set destroyed to true before firing error callbacks in order
17235 // to make it re-entrance safe in case destroy() is called within callbacks
17236
17237 if (this._readableState) {
17238 this._readableState.destroyed = true;
17239 }
17240
17241 // if this is a duplex stream mark the writable part as destroyed as well
17242 if (this._writableState) {
17243 this._writableState.destroyed = true;
17244 }
17245
17246 this._destroy(err || null, function (err) {
17247 if (!cb && err) {
17248 pna.nextTick(emitErrorNT, _this, err);
17249 if (_this._writableState) {
17250 _this._writableState.errorEmitted = true;
17251 }
17252 } else if (cb) {
17253 cb(err);
17254 }
17255 });
17256
17257 return this;
17258}
17259
17260function undestroy() {
17261 if (this._readableState) {
17262 this._readableState.destroyed = false;
17263 this._readableState.reading = false;
17264 this._readableState.ended = false;
17265 this._readableState.endEmitted = false;
17266 }
17267
17268 if (this._writableState) {
17269 this._writableState.destroyed = false;
17270 this._writableState.ended = false;
17271 this._writableState.ending = false;
17272 this._writableState.finished = false;
17273 this._writableState.errorEmitted = false;
17274 }
17275}
17276
17277function emitErrorNT(self, err) {
17278 self.emit('error', err);
17279}
17280
17281module.exports = {
17282 destroy: destroy,
17283 undestroy: undestroy
17284};
17285},{"process-nextick-args":104}],114:[function(require,module,exports){
17286module.exports = require('events').EventEmitter;
17287
17288},{"events":98}],115:[function(require,module,exports){
17289/* eslint-disable node/no-deprecated-api */
17290var buffer = require('buffer')
17291var Buffer = buffer.Buffer
17292
17293// alternative to using Object.keys for old browsers
17294function copyProps (src, dst) {
17295 for (var key in src) {
17296 dst[key] = src[key]
17297 }
17298}
17299if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
17300 module.exports = buffer
17301} else {
17302 // Copy properties from require('buffer')
17303 copyProps(buffer, exports)
17304 exports.Buffer = SafeBuffer
17305}
17306
17307function SafeBuffer (arg, encodingOrOffset, length) {
17308 return Buffer(arg, encodingOrOffset, length)
17309}
17310
17311// Copy static methods from Buffer
17312copyProps(Buffer, SafeBuffer)
17313
17314SafeBuffer.from = function (arg, encodingOrOffset, length) {
17315 if (typeof arg === 'number') {
17316 throw new TypeError('Argument must not be a number')
17317 }
17318 return Buffer(arg, encodingOrOffset, length)
17319}
17320
17321SafeBuffer.alloc = function (size, fill, encoding) {
17322 if (typeof size !== 'number') {
17323 throw new TypeError('Argument must be a number')
17324 }
17325 var buf = Buffer(size)
17326 if (fill !== undefined) {
17327 if (typeof encoding === 'string') {
17328 buf.fill(fill, encoding)
17329 } else {
17330 buf.fill(fill)
17331 }
17332 } else {
17333 buf.fill(0)
17334 }
17335 return buf
17336}
17337
17338SafeBuffer.allocUnsafe = function (size) {
17339 if (typeof size !== 'number') {
17340 throw new TypeError('Argument must be a number')
17341 }
17342 return Buffer(size)
17343}
17344
17345SafeBuffer.allocUnsafeSlow = function (size) {
17346 if (typeof size !== 'number') {
17347 throw new TypeError('Argument must be a number')
17348 }
17349 return buffer.SlowBuffer(size)
17350}
17351
17352},{"buffer":96}],116:[function(require,module,exports){
17353// Copyright Joyent, Inc. and other Node contributors.
17354//
17355// Permission is hereby granted, free of charge, to any person obtaining a
17356// copy of this software and associated documentation files (the
17357// "Software"), to deal in the Software without restriction, including
17358// without limitation the rights to use, copy, modify, merge, publish,
17359// distribute, sublicense, and/or sell copies of the Software, and to permit
17360// persons to whom the Software is furnished to do so, subject to the
17361// following conditions:
17362//
17363// The above copyright notice and this permission notice shall be included
17364// in all copies or substantial portions of the Software.
17365//
17366// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17367// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17368// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17369// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17370// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
17371// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
17372// USE OR OTHER DEALINGS IN THE SOFTWARE.
17373
17374'use strict';
17375
17376/*<replacement>*/
17377
17378var Buffer = require('safe-buffer').Buffer;
17379/*</replacement>*/
17380
17381var isEncoding = Buffer.isEncoding || function (encoding) {
17382 encoding = '' + encoding;
17383 switch (encoding && encoding.toLowerCase()) {
17384 case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':
17385 return true;
17386 default:
17387 return false;
17388 }
17389};
17390
17391function _normalizeEncoding(enc) {
17392 if (!enc) return 'utf8';
17393 var retried;
17394 while (true) {
17395 switch (enc) {
17396 case 'utf8':
17397 case 'utf-8':
17398 return 'utf8';
17399 case 'ucs2':
17400 case 'ucs-2':
17401 case 'utf16le':
17402 case 'utf-16le':
17403 return 'utf16le';
17404 case 'latin1':
17405 case 'binary':
17406 return 'latin1';
17407 case 'base64':
17408 case 'ascii':
17409 case 'hex':
17410 return enc;
17411 default:
17412 if (retried) return; // undefined
17413 enc = ('' + enc).toLowerCase();
17414 retried = true;
17415 }
17416 }
17417};
17418
17419// Do not cache `Buffer.isEncoding` when checking encoding names as some
17420// modules monkey-patch it to support additional encodings
17421function normalizeEncoding(enc) {
17422 var nenc = _normalizeEncoding(enc);
17423 if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
17424 return nenc || enc;
17425}
17426
17427// StringDecoder provides an interface for efficiently splitting a series of
17428// buffers into a series of JS strings without breaking apart multi-byte
17429// characters.
17430exports.StringDecoder = StringDecoder;
17431function StringDecoder(encoding) {
17432 this.encoding = normalizeEncoding(encoding);
17433 var nb;
17434 switch (this.encoding) {
17435 case 'utf16le':
17436 this.text = utf16Text;
17437 this.end = utf16End;
17438 nb = 4;
17439 break;
17440 case 'utf8':
17441 this.fillLast = utf8FillLast;
17442 nb = 4;
17443 break;
17444 case 'base64':
17445 this.text = base64Text;
17446 this.end = base64End;
17447 nb = 3;
17448 break;
17449 default:
17450 this.write = simpleWrite;
17451 this.end = simpleEnd;
17452 return;
17453 }
17454 this.lastNeed = 0;
17455 this.lastTotal = 0;
17456 this.lastChar = Buffer.allocUnsafe(nb);
17457}
17458
17459StringDecoder.prototype.write = function (buf) {
17460 if (buf.length === 0) return '';
17461 var r;
17462 var i;
17463 if (this.lastNeed) {
17464 r = this.fillLast(buf);
17465 if (r === undefined) return '';
17466 i = this.lastNeed;
17467 this.lastNeed = 0;
17468 } else {
17469 i = 0;
17470 }
17471 if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
17472 return r || '';
17473};
17474
17475StringDecoder.prototype.end = utf8End;
17476
17477// Returns only complete characters in a Buffer
17478StringDecoder.prototype.text = utf8Text;
17479
17480// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
17481StringDecoder.prototype.fillLast = function (buf) {
17482 if (this.lastNeed <= buf.length) {
17483 buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
17484 return this.lastChar.toString(this.encoding, 0, this.lastTotal);
17485 }
17486 buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
17487 this.lastNeed -= buf.length;
17488};
17489
17490// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
17491// continuation byte. If an invalid byte is detected, -2 is returned.
17492function utf8CheckByte(byte) {
17493 if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
17494 return byte >> 6 === 0x02 ? -1 : -2;
17495}
17496
17497// Checks at most 3 bytes at the end of a Buffer in order to detect an
17498// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
17499// needed to complete the UTF-8 character (if applicable) are returned.
17500function utf8CheckIncomplete(self, buf, i) {
17501 var j = buf.length - 1;
17502 if (j < i) return 0;
17503 var nb = utf8CheckByte(buf[j]);
17504 if (nb >= 0) {
17505 if (nb > 0) self.lastNeed = nb - 1;
17506 return nb;
17507 }
17508 if (--j < i || nb === -2) return 0;
17509 nb = utf8CheckByte(buf[j]);
17510 if (nb >= 0) {
17511 if (nb > 0) self.lastNeed = nb - 2;
17512 return nb;
17513 }
17514 if (--j < i || nb === -2) return 0;
17515 nb = utf8CheckByte(buf[j]);
17516 if (nb >= 0) {
17517 if (nb > 0) {
17518 if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
17519 }
17520 return nb;
17521 }
17522 return 0;
17523}
17524
17525// Validates as many continuation bytes for a multi-byte UTF-8 character as
17526// needed or are available. If we see a non-continuation byte where we expect
17527// one, we "replace" the validated continuation bytes we've seen so far with
17528// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
17529// behavior. The continuation byte check is included three times in the case
17530// where all of the continuation bytes for a character exist in the same buffer.
17531// It is also done this way as a slight performance increase instead of using a
17532// loop.
17533function utf8CheckExtraBytes(self, buf, p) {
17534 if ((buf[0] & 0xC0) !== 0x80) {
17535 self.lastNeed = 0;
17536 return '\ufffd';
17537 }
17538 if (self.lastNeed > 1 && buf.length > 1) {
17539 if ((buf[1] & 0xC0) !== 0x80) {
17540 self.lastNeed = 1;
17541 return '\ufffd';
17542 }
17543 if (self.lastNeed > 2 && buf.length > 2) {
17544 if ((buf[2] & 0xC0) !== 0x80) {
17545 self.lastNeed = 2;
17546 return '\ufffd';
17547 }
17548 }
17549 }
17550}
17551
17552// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
17553function utf8FillLast(buf) {
17554 var p = this.lastTotal - this.lastNeed;
17555 var r = utf8CheckExtraBytes(this, buf, p);
17556 if (r !== undefined) return r;
17557 if (this.lastNeed <= buf.length) {
17558 buf.copy(this.lastChar, p, 0, this.lastNeed);
17559 return this.lastChar.toString(this.encoding, 0, this.lastTotal);
17560 }
17561 buf.copy(this.lastChar, p, 0, buf.length);
17562 this.lastNeed -= buf.length;
17563}
17564
17565// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
17566// partial character, the character's bytes are buffered until the required
17567// number of bytes are available.
17568function utf8Text(buf, i) {
17569 var total = utf8CheckIncomplete(this, buf, i);
17570 if (!this.lastNeed) return buf.toString('utf8', i);
17571 this.lastTotal = total;
17572 var end = buf.length - (total - this.lastNeed);
17573 buf.copy(this.lastChar, 0, end);
17574 return buf.toString('utf8', i, end);
17575}
17576
17577// For UTF-8, a replacement character is added when ending on a partial
17578// character.
17579function utf8End(buf) {
17580 var r = buf && buf.length ? this.write(buf) : '';
17581 if (this.lastNeed) return r + '\ufffd';
17582 return r;
17583}
17584
17585// UTF-16LE typically needs two bytes per character, but even if we have an even
17586// number of bytes available, we need to check if we end on a leading/high
17587// surrogate. In that case, we need to wait for the next two bytes in order to
17588// decode the last character properly.
17589function utf16Text(buf, i) {
17590 if ((buf.length - i) % 2 === 0) {
17591 var r = buf.toString('utf16le', i);
17592 if (r) {
17593 var c = r.charCodeAt(r.length - 1);
17594 if (c >= 0xD800 && c <= 0xDBFF) {
17595 this.lastNeed = 2;
17596 this.lastTotal = 4;
17597 this.lastChar[0] = buf[buf.length - 2];
17598 this.lastChar[1] = buf[buf.length - 1];
17599 return r.slice(0, -1);
17600 }
17601 }
17602 return r;
17603 }
17604 this.lastNeed = 1;
17605 this.lastTotal = 2;
17606 this.lastChar[0] = buf[buf.length - 1];
17607 return buf.toString('utf16le', i, buf.length - 1);
17608}
17609
17610// For UTF-16LE we do not explicitly append special replacement characters if we
17611// end on a partial character, we simply let v8 handle that.
17612function utf16End(buf) {
17613 var r = buf && buf.length ? this.write(buf) : '';
17614 if (this.lastNeed) {
17615 var end = this.lastTotal - this.lastNeed;
17616 return r + this.lastChar.toString('utf16le', 0, end);
17617 }
17618 return r;
17619}
17620
17621function base64Text(buf, i) {
17622 var n = (buf.length - i) % 3;
17623 if (n === 0) return buf.toString('base64', i);
17624 this.lastNeed = 3 - n;
17625 this.lastTotal = 3;
17626 if (n === 1) {
17627 this.lastChar[0] = buf[buf.length - 1];
17628 } else {
17629 this.lastChar[0] = buf[buf.length - 2];
17630 this.lastChar[1] = buf[buf.length - 1];
17631 }
17632 return buf.toString('base64', i, buf.length - n);
17633}
17634
17635function base64End(buf) {
17636 var r = buf && buf.length ? this.write(buf) : '';
17637 if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
17638 return r;
17639}
17640
17641// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
17642function simpleWrite(buf) {
17643 return buf.toString(this.encoding);
17644}
17645
17646function simpleEnd(buf) {
17647 return buf && buf.length ? this.write(buf) : '';
17648}
17649},{"safe-buffer":115}],117:[function(require,module,exports){
17650module.exports = require('./readable').PassThrough
17651
17652},{"./readable":118}],118:[function(require,module,exports){
17653exports = module.exports = require('./lib/_stream_readable.js');
17654exports.Stream = exports;
17655exports.Readable = exports;
17656exports.Writable = require('./lib/_stream_writable.js');
17657exports.Duplex = require('./lib/_stream_duplex.js');
17658exports.Transform = require('./lib/_stream_transform.js');
17659exports.PassThrough = require('./lib/_stream_passthrough.js');
17660
17661},{"./lib/_stream_duplex.js":107,"./lib/_stream_passthrough.js":108,"./lib/_stream_readable.js":109,"./lib/_stream_transform.js":110,"./lib/_stream_writable.js":111}],119:[function(require,module,exports){
17662module.exports = require('./readable').Transform
17663
17664},{"./readable":118}],120:[function(require,module,exports){
17665module.exports = require('./lib/_stream_writable.js');
17666
17667},{"./lib/_stream_writable.js":111}],121:[function(require,module,exports){
17668arguments[4][38][0].apply(exports,arguments)
17669},{"buffer":96,"dup":38}],122:[function(require,module,exports){
17670// Copyright Joyent, Inc. and other Node contributors.
17671//
17672// Permission is hereby granted, free of charge, to any person obtaining a
17673// copy of this software and associated documentation files (the
17674// "Software"), to deal in the Software without restriction, including
17675// without limitation the rights to use, copy, modify, merge, publish,
17676// distribute, sublicense, and/or sell copies of the Software, and to permit
17677// persons to whom the Software is furnished to do so, subject to the
17678// following conditions:
17679//
17680// The above copyright notice and this permission notice shall be included
17681// in all copies or substantial portions of the Software.
17682//
17683// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17684// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17685// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17686// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17687// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
17688// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
17689// USE OR OTHER DEALINGS IN THE SOFTWARE.
17690
17691module.exports = Stream;
17692
17693var EE = require('events').EventEmitter;
17694var inherits = require('inherits');
17695
17696inherits(Stream, EE);
17697Stream.Readable = require('readable-stream/readable.js');
17698Stream.Writable = require('readable-stream/writable.js');
17699Stream.Duplex = require('readable-stream/duplex.js');
17700Stream.Transform = require('readable-stream/transform.js');
17701Stream.PassThrough = require('readable-stream/passthrough.js');
17702
17703// Backwards-compat with node 0.4.x
17704Stream.Stream = Stream;
17705
17706
17707
17708// old-style streams. Note that the pipe method (the only relevant
17709// part of this class) is overridden in the Readable class.
17710
17711function Stream() {
17712 EE.call(this);
17713}
17714
17715Stream.prototype.pipe = function(dest, options) {
17716 var source = this;
17717
17718 function ondata(chunk) {
17719 if (dest.writable) {
17720 if (false === dest.write(chunk) && source.pause) {
17721 source.pause();
17722 }
17723 }
17724 }
17725
17726 source.on('data', ondata);
17727
17728 function ondrain() {
17729 if (source.readable && source.resume) {
17730 source.resume();
17731 }
17732 }
17733
17734 dest.on('drain', ondrain);
17735
17736 // If the 'end' option is not supplied, dest.end() will be called when
17737 // source gets the 'end' or 'close' events. Only dest.end() once.
17738 if (!dest._isStdio && (!options || options.end !== false)) {
17739 source.on('end', onend);
17740 source.on('close', onclose);
17741 }
17742
17743 var didOnEnd = false;
17744 function onend() {
17745 if (didOnEnd) return;
17746 didOnEnd = true;
17747
17748 dest.end();
17749 }
17750
17751
17752 function onclose() {
17753 if (didOnEnd) return;
17754 didOnEnd = true;
17755
17756 if (typeof dest.destroy === 'function') dest.destroy();
17757 }
17758
17759 // don't leave dangling pipes when there are errors.
17760 function onerror(er) {
17761 cleanup();
17762 if (EE.listenerCount(this, 'error') === 0) {
17763 throw er; // Unhandled stream error in pipe.
17764 }
17765 }
17766
17767 source.on('error', onerror);
17768 dest.on('error', onerror);
17769
17770 // remove all the event listeners that were added.
17771 function cleanup() {
17772 source.removeListener('data', ondata);
17773 dest.removeListener('drain', ondrain);
17774
17775 source.removeListener('end', onend);
17776 source.removeListener('close', onclose);
17777
17778 source.removeListener('error', onerror);
17779 dest.removeListener('error', onerror);
17780
17781 source.removeListener('end', cleanup);
17782 source.removeListener('close', cleanup);
17783
17784 dest.removeListener('close', cleanup);
17785 }
17786
17787 source.on('end', cleanup);
17788 source.on('close', cleanup);
17789
17790 dest.on('close', cleanup);
17791
17792 dest.emit('pipe', source);
17793
17794 // Allow for unix-like usage: A.pipe(B).pipe(C)
17795 return dest;
17796};
17797
17798},{"events":98,"inherits":100,"readable-stream/duplex.js":106,"readable-stream/passthrough.js":117,"readable-stream/readable.js":118,"readable-stream/transform.js":119,"readable-stream/writable.js":120}],123:[function(require,module,exports){
17799arguments[4][116][0].apply(exports,arguments)
17800},{"dup":116,"safe-buffer":121}],124:[function(require,module,exports){
17801(function (setImmediate,clearImmediate){
17802var nextTick = require('process/browser.js').nextTick;
17803var apply = Function.prototype.apply;
17804var slice = Array.prototype.slice;
17805var immediateIds = {};
17806var nextImmediateId = 0;
17807
17808// DOM APIs, for completeness
17809
17810exports.setTimeout = function() {
17811 return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
17812};
17813exports.setInterval = function() {
17814 return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
17815};
17816exports.clearTimeout =
17817exports.clearInterval = function(timeout) { timeout.close(); };
17818
17819function Timeout(id, clearFn) {
17820 this._id = id;
17821 this._clearFn = clearFn;
17822}
17823Timeout.prototype.unref = Timeout.prototype.ref = function() {};
17824Timeout.prototype.close = function() {
17825 this._clearFn.call(window, this._id);
17826};
17827
17828// Does not start the time, just sets up the members needed.
17829exports.enroll = function(item, msecs) {
17830 clearTimeout(item._idleTimeoutId);
17831 item._idleTimeout = msecs;
17832};
17833
17834exports.unenroll = function(item) {
17835 clearTimeout(item._idleTimeoutId);
17836 item._idleTimeout = -1;
17837};
17838
17839exports._unrefActive = exports.active = function(item) {
17840 clearTimeout(item._idleTimeoutId);
17841
17842 var msecs = item._idleTimeout;
17843 if (msecs >= 0) {
17844 item._idleTimeoutId = setTimeout(function onTimeout() {
17845 if (item._onTimeout)
17846 item._onTimeout();
17847 }, msecs);
17848 }
17849};
17850
17851// That's not how node.js implements it but the exposed api is the same.
17852exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) {
17853 var id = nextImmediateId++;
17854 var args = arguments.length < 2 ? false : slice.call(arguments, 1);
17855
17856 immediateIds[id] = true;
17857
17858 nextTick(function onNextTick() {
17859 if (immediateIds[id]) {
17860 // fn.call() is faster so we optimize for the common use-case
17861 // @see http://jsperf.com/call-apply-segu
17862 if (args) {
17863 fn.apply(null, args);
17864 } else {
17865 fn.call(null);
17866 }
17867 // Prevent ids from leaking
17868 exports.clearImmediate(id);
17869 }
17870 });
17871
17872 return id;
17873};
17874
17875exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) {
17876 delete immediateIds[id];
17877};
17878}).call(this,require("timers").setImmediate,require("timers").clearImmediate)
17879},{"process/browser.js":105,"timers":124}],125:[function(require,module,exports){
17880(function (global){
17881
17882/**
17883 * Module exports.
17884 */
17885
17886module.exports = deprecate;
17887
17888/**
17889 * Mark that a method should not be used.
17890 * Returns a modified function which warns once by default.
17891 *
17892 * If `localStorage.noDeprecation = true` is set, then it is a no-op.
17893 *
17894 * If `localStorage.throwDeprecation = true` is set, then deprecated functions
17895 * will throw an Error when invoked.
17896 *
17897 * If `localStorage.traceDeprecation = true` is set, then deprecated functions
17898 * will invoke `console.trace()` instead of `console.error()`.
17899 *
17900 * @param {Function} fn - the function to deprecate
17901 * @param {String} msg - the string to print to the console when `fn` is invoked
17902 * @returns {Function} a new "deprecated" version of `fn`
17903 * @api public
17904 */
17905
17906function deprecate (fn, msg) {
17907 if (config('noDeprecation')) {
17908 return fn;
17909 }
17910
17911 var warned = false;
17912 function deprecated() {
17913 if (!warned) {
17914 if (config('throwDeprecation')) {
17915 throw new Error(msg);
17916 } else if (config('traceDeprecation')) {
17917 console.trace(msg);
17918 } else {
17919 console.warn(msg);
17920 }
17921 warned = true;
17922 }
17923 return fn.apply(this, arguments);
17924 }
17925
17926 return deprecated;
17927}
17928
17929/**
17930 * Checks `localStorage` for boolean values for the given `name`.
17931 *
17932 * @param {String} name
17933 * @returns {Boolean}
17934 * @api private
17935 */
17936
17937function config (name) {
17938 // accessing global.localStorage can trigger a DOMException in sandboxed iframes
17939 try {
17940 if (!global.localStorage) return false;
17941 } catch (_) {
17942 return false;
17943 }
17944 var val = global.localStorage[name];
17945 if (null == val) return false;
17946 return String(val).toLowerCase() === 'true';
17947}
17948
17949}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
17950},{}]},{},[61])(61)
17951});
diff --git a/src/js/groestlcoinjs-bip38-2.0.2.js b/src/js/groestlcoinjs-bip38-2.0.2.js
new file mode 100644
index 0000000..073e578
--- /dev/null
+++ b/src/js/groestlcoinjs-bip38-2.0.2.js
@@ -0,0 +1,28732 @@
1(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.groestlcoinjsBip38 = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
2var aes = require('browserify-aes')
3var assert = require('assert')
4var Buffer = require('safe-buffer').Buffer
5var bs58check = require('bs58check')
6var bs58grscheck = require('bs58grscheck')
7var createHash = require('create-hash')
8var scrypt = require('scryptsy')
9var xor = require('buffer-xor/inplace')
10
11var ecurve = require('ecurve')
12var curve = ecurve.getCurveByName('secp256k1')
13
14var BigInteger = require('bigi')
15
16// constants
17var SCRYPT_PARAMS = {
18 N: 16384, // specified by BIP38
19 r: 8,
20 p: 8
21}
22var NULL = Buffer.alloc(0)
23
24function hash160 (buffer) {
25 return createHash('rmd160').update(
26 createHash('sha256').update(buffer).digest()
27 ).digest()
28}
29
30function hash256 (buffer) {
31 return createHash('sha256').update(
32 createHash('sha256').update(buffer).digest()
33 ).digest()
34}
35
36function getAddress (d, compressed, testnet) {
37 var Q = curve.G.multiply(d).getEncoded(compressed)
38 var hash = hash160(Q)
39 var payload = Buffer.allocUnsafe(21)
40 payload.writeUInt8(testnet ? 0x6f : 0x24, 0) // XXX TODO FIXME bitcoin only??? damn you BIP38
41 hash.copy(payload, 1)
42
43 return bs58grscheck.encode(payload)
44}
45
46function encryptRaw (buffer, compressed, passphrase, progressCallback, scryptParams, testnet) {
47 if (buffer.length !== 32) throw new Error('Invalid private key length')
48 scryptParams = scryptParams || SCRYPT_PARAMS
49
50 var d = BigInteger.fromBuffer(buffer)
51 var address = getAddress(d, compressed, testnet)
52 var secret = Buffer.from(passphrase, 'utf8')
53 var salt = hash256(address).slice(0, 4)
54
55 var N = scryptParams.N
56 var r = scryptParams.r
57 var p = scryptParams.p
58
59 var scryptBuf = scrypt(secret, salt, N, r, p, 64, progressCallback)
60 var derivedHalf1 = scryptBuf.slice(0, 32)
61 var derivedHalf2 = scryptBuf.slice(32, 64)
62
63 var xorBuf = xor(derivedHalf1, buffer)
64 var cipher = aes.createCipheriv('aes-256-ecb', derivedHalf2, NULL)
65 cipher.setAutoPadding(false)
66 cipher.end(xorBuf)
67
68 var cipherText = cipher.read()
69
70 // 0x01 | 0x42 | flagByte | salt (4) | cipherText (32)
71 var result = Buffer.allocUnsafe(7 + 32)
72 result.writeUInt8(0x01, 0)
73 result.writeUInt8(0x42, 1)
74 result.writeUInt8(compressed ? 0xe0 : 0xc0, 2)
75 salt.copy(result, 3)
76 cipherText.copy(result, 7)
77
78 return result
79}
80
81function encrypt (buffer, compressed, passphrase, progressCallback, scryptParams, testnet) {
82 return bs58check.encode(encryptRaw(buffer, compressed, passphrase, progressCallback, scryptParams, testnet))
83}
84
85// some of the techniques borrowed from: https://github.com/pointbiz/bitaddress.org
86function decryptRaw (buffer, passphrase, progressCallback, scryptParams, testnet) {
87 // 39 bytes: 2 bytes prefix, 37 bytes payload
88 if (buffer.length !== 39) throw new Error('Invalid BIP38 data length')
89 if (buffer.readUInt8(0) !== 0x01) throw new Error('Invalid BIP38 prefix')
90 scryptParams = scryptParams || SCRYPT_PARAMS
91
92 // check if BIP38 EC multiply
93 var type = buffer.readUInt8(1)
94 if (type === 0x43) return decryptECMult(buffer, passphrase, progressCallback, scryptParams)
95 if (type !== 0x42) throw new Error('Invalid BIP38 type')
96
97 passphrase = Buffer.from(passphrase, 'utf8')
98
99 var flagByte = buffer.readUInt8(2)
100 var compressed = flagByte === 0xe0
101 if (!compressed && flagByte !== 0xc0) throw new Error('Invalid BIP38 compression flag')
102
103 var N = scryptParams.N
104 var r = scryptParams.r
105 var p = scryptParams.p
106
107 var salt = buffer.slice(3, 7)
108 var scryptBuf = scrypt(passphrase, salt, N, r, p, 64, progressCallback)
109 var derivedHalf1 = scryptBuf.slice(0, 32)
110 var derivedHalf2 = scryptBuf.slice(32, 64)
111
112 var privKeyBuf = buffer.slice(7, 7 + 32)
113 var decipher = aes.createDecipheriv('aes-256-ecb', derivedHalf2, NULL)
114 decipher.setAutoPadding(false)
115 decipher.end(privKeyBuf)
116
117 var plainText = decipher.read()
118 var privateKey = xor(derivedHalf1, plainText)
119
120 // verify salt matches address
121 var d = BigInteger.fromBuffer(privateKey)
122 var address = getAddress(d, compressed, address)
123 var checksum = hash256(address).slice(0, 4)
124 assert.deepEqual(salt, checksum)
125
126 return {
127 privateKey: privateKey,
128 compressed: compressed
129 }
130}
131
132function decrypt (string, passphrase, progressCallback, scryptParams, testnet) {
133 return decryptRaw(bs58check.decode(string), passphrase, progressCallback, scryptParams, testnet)
134}
135
136function decryptECMult (buffer, passphrase, progressCallback, scryptParams) {
137 passphrase = Buffer.from(passphrase, 'utf8')
138 buffer = buffer.slice(1) // FIXME: we can avoid this
139 scryptParams = scryptParams || SCRYPT_PARAMS
140
141 var flag = buffer.readUInt8(1)
142 var compressed = (flag & 0x20) !== 0
143 var hasLotSeq = (flag & 0x04) !== 0
144
145 assert.equal((flag & 0x24), flag, 'Invalid private key.')
146
147 var addressHash = buffer.slice(2, 6)
148 var ownerEntropy = buffer.slice(6, 14)
149 var ownerSalt
150
151 // 4 bytes ownerSalt if 4 bytes lot/sequence
152 if (hasLotSeq) {
153 ownerSalt = ownerEntropy.slice(0, 4)
154
155 // else, 8 bytes ownerSalt
156 } else {
157 ownerSalt = ownerEntropy
158 }
159
160 var encryptedPart1 = buffer.slice(14, 22) // First 8 bytes
161 var encryptedPart2 = buffer.slice(22, 38) // 16 bytes
162
163 var N = scryptParams.N
164 var r = scryptParams.r
165 var p = scryptParams.p
166 var preFactor = scrypt(passphrase, ownerSalt, N, r, p, 32, progressCallback)
167
168 var passFactor
169 if (hasLotSeq) {
170 var hashTarget = Buffer.concat([preFactor, ownerEntropy])
171 passFactor = hash256(hashTarget)
172 } else {
173 passFactor = preFactor
174 }
175
176 var passInt = BigInteger.fromBuffer(passFactor)
177 var passPoint = curve.G.multiply(passInt).getEncoded(true)
178
179 var seedBPass = scrypt(passPoint, Buffer.concat([addressHash, ownerEntropy]), 1024, 1, 1, 64)
180 var derivedHalf1 = seedBPass.slice(0, 32)
181 var derivedHalf2 = seedBPass.slice(32, 64)
182
183 var decipher = aes.createDecipheriv('aes-256-ecb', derivedHalf2, Buffer.alloc(0))
184 decipher.setAutoPadding(false)
185 decipher.end(encryptedPart2)
186
187 var decryptedPart2 = decipher.read()
188 var tmp = xor(decryptedPart2, derivedHalf1.slice(16, 32))
189 var seedBPart2 = tmp.slice(8, 16)
190
191 var decipher2 = aes.createDecipheriv('aes-256-ecb', derivedHalf2, Buffer.alloc(0))
192 decipher2.setAutoPadding(false)
193 decipher2.write(encryptedPart1) // first 8 bytes
194 decipher2.end(tmp.slice(0, 8)) // last 8 bytes
195
196 var seedBPart1 = xor(decipher2.read(), derivedHalf1.slice(0, 16))
197 var seedB = Buffer.concat([seedBPart1, seedBPart2], 24)
198 var factorB = BigInteger.fromBuffer(hash256(seedB))
199
200 // d = passFactor * factorB (mod n)
201 var d = passInt.multiply(factorB).mod(curve.n)
202
203 return {
204 privateKey: d.toBuffer(32),
205 compressed: compressed
206 }
207}
208
209function verify (string) {
210 var decoded = bs58grscheck.decodeUnsafe(string)
211 if (!decoded) return false
212
213 if (decoded.length !== 39) return false
214 if (decoded.readUInt8(0) !== 0x01) return false
215
216 var type = decoded.readUInt8(1)
217 var flag = decoded.readUInt8(2)
218
219 // encrypted WIF
220 if (type === 0x42) {
221 if (flag !== 0xc0 && flag !== 0xe0) return false
222
223 // EC mult
224 } else if (type === 0x43) {
225 if ((flag & ~0x24)) return false
226 } else {
227 return false
228 }
229
230 return true
231}
232
233module.exports = {
234 decrypt: decrypt,
235 decryptECMult: decryptECMult,
236 decryptRaw: decryptRaw,
237 encrypt: encrypt,
238 encryptRaw: encryptRaw,
239 verify: verify
240}
241
242},{"assert":74,"bigi":5,"browserify-aes":9,"bs58check":26,"bs58grscheck":28,"buffer-xor/inplace":30,"create-hash":32,"ecurve":35,"safe-buffer":47,"scryptsy":48}],2:[function(require,module,exports){
243'use strict'
244// base-x encoding / decoding
245// Copyright (c) 2018 base-x contributors
246// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
247// Distributed under the MIT software license, see the accompanying
248// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
249// @ts-ignore
250var _Buffer = require('safe-buffer').Buffer
251function base (ALPHABET) {
252 if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
253 var BASE_MAP = new Uint8Array(256)
254 BASE_MAP.fill(255)
255 for (var i = 0; i < ALPHABET.length; i++) {
256 var x = ALPHABET.charAt(i)
257 var xc = x.charCodeAt(0)
258 if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
259 BASE_MAP[xc] = i
260 }
261 var BASE = ALPHABET.length
262 var LEADER = ALPHABET.charAt(0)
263 var FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up
264 var iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up
265 function encode (source) {
266 if (!_Buffer.isBuffer(source)) { throw new TypeError('Expected Buffer') }
267 if (source.length === 0) { return '' }
268 // Skip & count leading zeroes.
269 var zeroes = 0
270 var length = 0
271 var pbegin = 0
272 var pend = source.length
273 while (pbegin !== pend && source[pbegin] === 0) {
274 pbegin++
275 zeroes++
276 }
277 // Allocate enough space in big-endian base58 representation.
278 var size = ((pend - pbegin) * iFACTOR + 1) >>> 0
279 var b58 = new Uint8Array(size)
280 // Process the bytes.
281 while (pbegin !== pend) {
282 var carry = source[pbegin]
283 // Apply "b58 = b58 * 256 + ch".
284 var i = 0
285 for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
286 carry += (256 * b58[it1]) >>> 0
287 b58[it1] = (carry % BASE) >>> 0
288 carry = (carry / BASE) >>> 0
289 }
290 if (carry !== 0) { throw new Error('Non-zero carry') }
291 length = i
292 pbegin++
293 }
294 // Skip leading zeroes in base58 result.
295 var it2 = size - length
296 while (it2 !== size && b58[it2] === 0) {
297 it2++
298 }
299 // Translate the result into a string.
300 var str = LEADER.repeat(zeroes)
301 for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]) }
302 return str
303 }
304 function decodeUnsafe (source) {
305 if (typeof source !== 'string') { throw new TypeError('Expected String') }
306 if (source.length === 0) { return _Buffer.alloc(0) }
307 var psz = 0
308 // Skip leading spaces.
309 if (source[psz] === ' ') { return }
310 // Skip and count leading '1's.
311 var zeroes = 0
312 var length = 0
313 while (source[psz] === LEADER) {
314 zeroes++
315 psz++
316 }
317 // Allocate enough space in big-endian base256 representation.
318 var size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up.
319 var b256 = new Uint8Array(size)
320 // Process the characters.
321 while (source[psz]) {
322 // Decode character
323 var carry = BASE_MAP[source.charCodeAt(psz)]
324 // Invalid character
325 if (carry === 255) { return }
326 var i = 0
327 for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
328 carry += (BASE * b256[it3]) >>> 0
329 b256[it3] = (carry % 256) >>> 0
330 carry = (carry / 256) >>> 0
331 }
332 if (carry !== 0) { throw new Error('Non-zero carry') }
333 length = i
334 psz++
335 }
336 // Skip trailing spaces.
337 if (source[psz] === ' ') { return }
338 // Skip leading zeroes in b256.
339 var it4 = size - length
340 while (it4 !== size && b256[it4] === 0) {
341 it4++
342 }
343 var vch = _Buffer.allocUnsafe(zeroes + (size - it4))
344 vch.fill(0x00, 0, zeroes)
345 var j = zeroes
346 while (it4 !== size) {
347 vch[j++] = b256[it4++]
348 }
349 return vch
350 }
351 function decode (string) {
352 var buffer = decodeUnsafe(string)
353 if (buffer) { return buffer }
354 throw new Error('Non-base' + BASE + ' character')
355 }
356 return {
357 encode: encode,
358 decodeUnsafe: decodeUnsafe,
359 decode: decode
360 }
361}
362module.exports = base
363
364},{"safe-buffer":47}],3:[function(require,module,exports){
365// (public) Constructor
366function BigInteger(a, b, c) {
367 if (!(this instanceof BigInteger))
368 return new BigInteger(a, b, c)
369
370 if (a != null) {
371 if ("number" == typeof a) this.fromNumber(a, b, c)
372 else if (b == null && "string" != typeof a) this.fromString(a, 256)
373 else this.fromString(a, b)
374 }
375}
376
377var proto = BigInteger.prototype
378
379// duck-typed isBigInteger
380proto.__bigi = require('../package.json').version
381BigInteger.isBigInteger = function (obj, check_ver) {
382 return obj && obj.__bigi && (!check_ver || obj.__bigi === proto.__bigi)
383}
384
385// Bits per digit
386var dbits
387
388// am: Compute w_j += (x*this_i), propagate carries,
389// c is initial carry, returns final carry.
390// c < 3*dvalue, x < 2*dvalue, this_i < dvalue
391// We need to select the fastest one that works in this environment.
392
393// am1: use a single mult and divide to get the high bits,
394// max digit bits should be 26 because
395// max internal value = 2*dvalue^2-2*dvalue (< 2^53)
396function am1(i, x, w, j, c, n) {
397 while (--n >= 0) {
398 var v = x * this[i++] + w[j] + c
399 c = Math.floor(v / 0x4000000)
400 w[j++] = v & 0x3ffffff
401 }
402 return c
403}
404// am2 avoids a big mult-and-extract completely.
405// Max digit bits should be <= 30 because we do bitwise ops
406// on values up to 2*hdvalue^2-hdvalue-1 (< 2^31)
407function am2(i, x, w, j, c, n) {
408 var xl = x & 0x7fff,
409 xh = x >> 15
410 while (--n >= 0) {
411 var l = this[i] & 0x7fff
412 var h = this[i++] >> 15
413 var m = xh * l + h * xl
414 l = xl * l + ((m & 0x7fff) << 15) + w[j] + (c & 0x3fffffff)
415 c = (l >>> 30) + (m >>> 15) + xh * h + (c >>> 30)
416 w[j++] = l & 0x3fffffff
417 }
418 return c
419}
420// Alternately, set max digit bits to 28 since some
421// browsers slow down when dealing with 32-bit numbers.
422function am3(i, x, w, j, c, n) {
423 var xl = x & 0x3fff,
424 xh = x >> 14
425 while (--n >= 0) {
426 var l = this[i] & 0x3fff
427 var h = this[i++] >> 14
428 var m = xh * l + h * xl
429 l = xl * l + ((m & 0x3fff) << 14) + w[j] + c
430 c = (l >> 28) + (m >> 14) + xh * h
431 w[j++] = l & 0xfffffff
432 }
433 return c
434}
435
436// wtf?
437BigInteger.prototype.am = am1
438dbits = 26
439
440BigInteger.prototype.DB = dbits
441BigInteger.prototype.DM = ((1 << dbits) - 1)
442var DV = BigInteger.prototype.DV = (1 << dbits)
443
444var BI_FP = 52
445BigInteger.prototype.FV = Math.pow(2, BI_FP)
446BigInteger.prototype.F1 = BI_FP - dbits
447BigInteger.prototype.F2 = 2 * dbits - BI_FP
448
449// Digit conversions
450var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz"
451var BI_RC = new Array()
452var rr, vv
453rr = "0".charCodeAt(0)
454for (vv = 0; vv <= 9; ++vv) BI_RC[rr++] = vv
455rr = "a".charCodeAt(0)
456for (vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv
457rr = "A".charCodeAt(0)
458for (vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv
459
460function int2char(n) {
461 return BI_RM.charAt(n)
462}
463
464function intAt(s, i) {
465 var c = BI_RC[s.charCodeAt(i)]
466 return (c == null) ? -1 : c
467}
468
469// (protected) copy this to r
470function bnpCopyTo(r) {
471 for (var i = this.t - 1; i >= 0; --i) r[i] = this[i]
472 r.t = this.t
473 r.s = this.s
474}
475
476// (protected) set from integer value x, -DV <= x < DV
477function bnpFromInt(x) {
478 this.t = 1
479 this.s = (x < 0) ? -1 : 0
480 if (x > 0) this[0] = x
481 else if (x < -1) this[0] = x + DV
482 else this.t = 0
483}
484
485// return bigint initialized to value
486function nbv(i) {
487 var r = new BigInteger()
488 r.fromInt(i)
489 return r
490}
491
492// (protected) set from string and radix
493function bnpFromString(s, b) {
494 var self = this
495
496 var k
497 if (b == 16) k = 4
498 else if (b == 8) k = 3
499 else if (b == 256) k = 8; // byte array
500 else if (b == 2) k = 1
501 else if (b == 32) k = 5
502 else if (b == 4) k = 2
503 else {
504 self.fromRadix(s, b)
505 return
506 }
507 self.t = 0
508 self.s = 0
509 var i = s.length,
510 mi = false,
511 sh = 0
512 while (--i >= 0) {
513 var x = (k == 8) ? s[i] & 0xff : intAt(s, i)
514 if (x < 0) {
515 if (s.charAt(i) == "-") mi = true
516 continue
517 }
518 mi = false
519 if (sh == 0)
520 self[self.t++] = x
521 else if (sh + k > self.DB) {
522 self[self.t - 1] |= (x & ((1 << (self.DB - sh)) - 1)) << sh
523 self[self.t++] = (x >> (self.DB - sh))
524 } else
525 self[self.t - 1] |= x << sh
526 sh += k
527 if (sh >= self.DB) sh -= self.DB
528 }
529 if (k == 8 && (s[0] & 0x80) != 0) {
530 self.s = -1
531 if (sh > 0) self[self.t - 1] |= ((1 << (self.DB - sh)) - 1) << sh
532 }
533 self.clamp()
534 if (mi) BigInteger.ZERO.subTo(self, self)
535}
536
537// (protected) clamp off excess high words
538function bnpClamp() {
539 var c = this.s & this.DM
540 while (this.t > 0 && this[this.t - 1] == c)--this.t
541}
542
543// (public) return string representation in given radix
544function bnToString(b) {
545 var self = this
546 if (self.s < 0) return "-" + self.negate()
547 .toString(b)
548 var k
549 if (b == 16) k = 4
550 else if (b == 8) k = 3
551 else if (b == 2) k = 1
552 else if (b == 32) k = 5
553 else if (b == 4) k = 2
554 else return self.toRadix(b)
555 var km = (1 << k) - 1,
556 d, m = false,
557 r = "",
558 i = self.t
559 var p = self.DB - (i * self.DB) % k
560 if (i-- > 0) {
561 if (p < self.DB && (d = self[i] >> p) > 0) {
562 m = true
563 r = int2char(d)
564 }
565 while (i >= 0) {
566 if (p < k) {
567 d = (self[i] & ((1 << p) - 1)) << (k - p)
568 d |= self[--i] >> (p += self.DB - k)
569 } else {
570 d = (self[i] >> (p -= k)) & km
571 if (p <= 0) {
572 p += self.DB
573 --i
574 }
575 }
576 if (d > 0) m = true
577 if (m) r += int2char(d)
578 }
579 }
580 return m ? r : "0"
581}
582
583// (public) -this
584function bnNegate() {
585 var r = new BigInteger()
586 BigInteger.ZERO.subTo(this, r)
587 return r
588}
589
590// (public) |this|
591function bnAbs() {
592 return (this.s < 0) ? this.negate() : this
593}
594
595// (public) return + if this > a, - if this < a, 0 if equal
596function bnCompareTo(a) {
597 var r = this.s - a.s
598 if (r != 0) return r
599 var i = this.t
600 r = i - a.t
601 if (r != 0) return (this.s < 0) ? -r : r
602 while (--i >= 0)
603 if ((r = this[i] - a[i]) != 0) return r
604 return 0
605}
606
607// returns bit length of the integer x
608function nbits(x) {
609 var r = 1,
610 t
611 if ((t = x >>> 16) != 0) {
612 x = t
613 r += 16
614 }
615 if ((t = x >> 8) != 0) {
616 x = t
617 r += 8
618 }
619 if ((t = x >> 4) != 0) {
620 x = t
621 r += 4
622 }
623 if ((t = x >> 2) != 0) {
624 x = t
625 r += 2
626 }
627 if ((t = x >> 1) != 0) {
628 x = t
629 r += 1
630 }
631 return r
632}
633
634// (public) return the number of bits in "this"
635function bnBitLength() {
636 if (this.t <= 0) return 0
637 return this.DB * (this.t - 1) + nbits(this[this.t - 1] ^ (this.s & this.DM))
638}
639
640// (public) return the number of bytes in "this"
641function bnByteLength() {
642 return this.bitLength() >> 3
643}
644
645// (protected) r = this << n*DB
646function bnpDLShiftTo(n, r) {
647 var i
648 for (i = this.t - 1; i >= 0; --i) r[i + n] = this[i]
649 for (i = n - 1; i >= 0; --i) r[i] = 0
650 r.t = this.t + n
651 r.s = this.s
652}
653
654// (protected) r = this >> n*DB
655function bnpDRShiftTo(n, r) {
656 for (var i = n; i < this.t; ++i) r[i - n] = this[i]
657 r.t = Math.max(this.t - n, 0)
658 r.s = this.s
659}
660
661// (protected) r = this << n
662function bnpLShiftTo(n, r) {
663 var self = this
664 var bs = n % self.DB
665 var cbs = self.DB - bs
666 var bm = (1 << cbs) - 1
667 var ds = Math.floor(n / self.DB),
668 c = (self.s << bs) & self.DM,
669 i
670 for (i = self.t - 1; i >= 0; --i) {
671 r[i + ds + 1] = (self[i] >> cbs) | c
672 c = (self[i] & bm) << bs
673 }
674 for (i = ds - 1; i >= 0; --i) r[i] = 0
675 r[ds] = c
676 r.t = self.t + ds + 1
677 r.s = self.s
678 r.clamp()
679}
680
681// (protected) r = this >> n
682function bnpRShiftTo(n, r) {
683 var self = this
684 r.s = self.s
685 var ds = Math.floor(n / self.DB)
686 if (ds >= self.t) {
687 r.t = 0
688 return
689 }
690 var bs = n % self.DB
691 var cbs = self.DB - bs
692 var bm = (1 << bs) - 1
693 r[0] = self[ds] >> bs
694 for (var i = ds + 1; i < self.t; ++i) {
695 r[i - ds - 1] |= (self[i] & bm) << cbs
696 r[i - ds] = self[i] >> bs
697 }
698 if (bs > 0) r[self.t - ds - 1] |= (self.s & bm) << cbs
699 r.t = self.t - ds
700 r.clamp()
701}
702
703// (protected) r = this - a
704function bnpSubTo(a, r) {
705 var self = this
706 var i = 0,
707 c = 0,
708 m = Math.min(a.t, self.t)
709 while (i < m) {
710 c += self[i] - a[i]
711 r[i++] = c & self.DM
712 c >>= self.DB
713 }
714 if (a.t < self.t) {
715 c -= a.s
716 while (i < self.t) {
717 c += self[i]
718 r[i++] = c & self.DM
719 c >>= self.DB
720 }
721 c += self.s
722 } else {
723 c += self.s
724 while (i < a.t) {
725 c -= a[i]
726 r[i++] = c & self.DM
727 c >>= self.DB
728 }
729 c -= a.s
730 }
731 r.s = (c < 0) ? -1 : 0
732 if (c < -1) r[i++] = self.DV + c
733 else if (c > 0) r[i++] = c
734 r.t = i
735 r.clamp()
736}
737
738// (protected) r = this * a, r != this,a (HAC 14.12)
739// "this" should be the larger one if appropriate.
740function bnpMultiplyTo(a, r) {
741 var x = this.abs(),
742 y = a.abs()
743 var i = x.t
744 r.t = i + y.t
745 while (--i >= 0) r[i] = 0
746 for (i = 0; i < y.t; ++i) r[i + x.t] = x.am(0, y[i], r, i, 0, x.t)
747 r.s = 0
748 r.clamp()
749 if (this.s != a.s) BigInteger.ZERO.subTo(r, r)
750}
751
752// (protected) r = this^2, r != this (HAC 14.16)
753function bnpSquareTo(r) {
754 var x = this.abs()
755 var i = r.t = 2 * x.t
756 while (--i >= 0) r[i] = 0
757 for (i = 0; i < x.t - 1; ++i) {
758 var c = x.am(i, x[i], r, 2 * i, 0, 1)
759 if ((r[i + x.t] += x.am(i + 1, 2 * x[i], r, 2 * i + 1, c, x.t - i - 1)) >= x.DV) {
760 r[i + x.t] -= x.DV
761 r[i + x.t + 1] = 1
762 }
763 }
764 if (r.t > 0) r[r.t - 1] += x.am(i, x[i], r, 2 * i, 0, 1)
765 r.s = 0
766 r.clamp()
767}
768
769// (protected) divide this by m, quotient and remainder to q, r (HAC 14.20)
770// r != q, this != m. q or r may be null.
771function bnpDivRemTo(m, q, r) {
772 var self = this
773 var pm = m.abs()
774 if (pm.t <= 0) return
775 var pt = self.abs()
776 if (pt.t < pm.t) {
777 if (q != null) q.fromInt(0)
778 if (r != null) self.copyTo(r)
779 return
780 }
781 if (r == null) r = new BigInteger()
782 var y = new BigInteger(),
783 ts = self.s,
784 ms = m.s
785 var nsh = self.DB - nbits(pm[pm.t - 1]); // normalize modulus
786 if (nsh > 0) {
787 pm.lShiftTo(nsh, y)
788 pt.lShiftTo(nsh, r)
789 } else {
790 pm.copyTo(y)
791 pt.copyTo(r)
792 }
793 var ys = y.t
794 var y0 = y[ys - 1]
795 if (y0 == 0) return
796 var yt = y0 * (1 << self.F1) + ((ys > 1) ? y[ys - 2] >> self.F2 : 0)
797 var d1 = self.FV / yt,
798 d2 = (1 << self.F1) / yt,
799 e = 1 << self.F2
800 var i = r.t,
801 j = i - ys,
802 t = (q == null) ? new BigInteger() : q
803 y.dlShiftTo(j, t)
804 if (r.compareTo(t) >= 0) {
805 r[r.t++] = 1
806 r.subTo(t, r)
807 }
808 BigInteger.ONE.dlShiftTo(ys, t)
809 t.subTo(y, y); // "negative" y so we can replace sub with am later
810 while (y.t < ys) y[y.t++] = 0
811 while (--j >= 0) {
812 // Estimate quotient digit
813 var qd = (r[--i] == y0) ? self.DM : Math.floor(r[i] * d1 + (r[i - 1] + e) * d2)
814 if ((r[i] += y.am(0, qd, r, j, 0, ys)) < qd) { // Try it out
815 y.dlShiftTo(j, t)
816 r.subTo(t, r)
817 while (r[i] < --qd) r.subTo(t, r)
818 }
819 }
820 if (q != null) {
821 r.drShiftTo(ys, q)
822 if (ts != ms) BigInteger.ZERO.subTo(q, q)
823 }
824 r.t = ys
825 r.clamp()
826 if (nsh > 0) r.rShiftTo(nsh, r); // Denormalize remainder
827 if (ts < 0) BigInteger.ZERO.subTo(r, r)
828}
829
830// (public) this mod a
831function bnMod(a) {
832 var r = new BigInteger()
833 this.abs()
834 .divRemTo(a, null, r)
835 if (this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r, r)
836 return r
837}
838
839// Modular reduction using "classic" algorithm
840function Classic(m) {
841 this.m = m
842}
843
844function cConvert(x) {
845 if (x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m)
846 else return x
847}
848
849function cRevert(x) {
850 return x
851}
852
853function cReduce(x) {
854 x.divRemTo(this.m, null, x)
855}
856
857function cMulTo(x, y, r) {
858 x.multiplyTo(y, r)
859 this.reduce(r)
860}
861
862function cSqrTo(x, r) {
863 x.squareTo(r)
864 this.reduce(r)
865}
866
867Classic.prototype.convert = cConvert
868Classic.prototype.revert = cRevert
869Classic.prototype.reduce = cReduce
870Classic.prototype.mulTo = cMulTo
871Classic.prototype.sqrTo = cSqrTo
872
873// (protected) return "-1/this % 2^DB"; useful for Mont. reduction
874// justification:
875// xy == 1 (mod m)
876// xy = 1+km
877// xy(2-xy) = (1+km)(1-km)
878// x[y(2-xy)] = 1-k^2m^2
879// x[y(2-xy)] == 1 (mod m^2)
880// if y is 1/x mod m, then y(2-xy) is 1/x mod m^2
881// should reduce x and y(2-xy) by m^2 at each step to keep size bounded.
882// JS multiply "overflows" differently from C/C++, so care is needed here.
883function bnpInvDigit() {
884 if (this.t < 1) return 0
885 var x = this[0]
886 if ((x & 1) == 0) return 0
887 var y = x & 3; // y == 1/x mod 2^2
888 y = (y * (2 - (x & 0xf) * y)) & 0xf; // y == 1/x mod 2^4
889 y = (y * (2 - (x & 0xff) * y)) & 0xff; // y == 1/x mod 2^8
890 y = (y * (2 - (((x & 0xffff) * y) & 0xffff))) & 0xffff; // y == 1/x mod 2^16
891 // last step - calculate inverse mod DV directly
892 // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints
893 y = (y * (2 - x * y % this.DV)) % this.DV; // y == 1/x mod 2^dbits
894 // we really want the negative inverse, and -DV < y < DV
895 return (y > 0) ? this.DV - y : -y
896}
897
898// Montgomery reduction
899function Montgomery(m) {
900 this.m = m
901 this.mp = m.invDigit()
902 this.mpl = this.mp & 0x7fff
903 this.mph = this.mp >> 15
904 this.um = (1 << (m.DB - 15)) - 1
905 this.mt2 = 2 * m.t
906}
907
908// xR mod m
909function montConvert(x) {
910 var r = new BigInteger()
911 x.abs()
912 .dlShiftTo(this.m.t, r)
913 r.divRemTo(this.m, null, r)
914 if (x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r, r)
915 return r
916}
917
918// x/R mod m
919function montRevert(x) {
920 var r = new BigInteger()
921 x.copyTo(r)
922 this.reduce(r)
923 return r
924}
925
926// x = x/R mod m (HAC 14.32)
927function montReduce(x) {
928 while (x.t <= this.mt2) // pad x so am has enough room later
929 x[x.t++] = 0
930 for (var i = 0; i < this.m.t; ++i) {
931 // faster way of calculating u0 = x[i]*mp mod DV
932 var j = x[i] & 0x7fff
933 var u0 = (j * this.mpl + (((j * this.mph + (x[i] >> 15) * this.mpl) & this.um) << 15)) & x.DM
934 // use am to combine the multiply-shift-add into one call
935 j = i + this.m.t
936 x[j] += this.m.am(0, u0, x, i, 0, this.m.t)
937 // propagate carry
938 while (x[j] >= x.DV) {
939 x[j] -= x.DV
940 x[++j]++
941 }
942 }
943 x.clamp()
944 x.drShiftTo(this.m.t, x)
945 if (x.compareTo(this.m) >= 0) x.subTo(this.m, x)
946}
947
948// r = "x^2/R mod m"; x != r
949function montSqrTo(x, r) {
950 x.squareTo(r)
951 this.reduce(r)
952}
953
954// r = "xy/R mod m"; x,y != r
955function montMulTo(x, y, r) {
956 x.multiplyTo(y, r)
957 this.reduce(r)
958}
959
960Montgomery.prototype.convert = montConvert
961Montgomery.prototype.revert = montRevert
962Montgomery.prototype.reduce = montReduce
963Montgomery.prototype.mulTo = montMulTo
964Montgomery.prototype.sqrTo = montSqrTo
965
966// (protected) true iff this is even
967function bnpIsEven() {
968 return ((this.t > 0) ? (this[0] & 1) : this.s) == 0
969}
970
971// (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79)
972function bnpExp(e, z) {
973 if (e > 0xffffffff || e < 1) return BigInteger.ONE
974 var r = new BigInteger(),
975 r2 = new BigInteger(),
976 g = z.convert(this),
977 i = nbits(e) - 1
978 g.copyTo(r)
979 while (--i >= 0) {
980 z.sqrTo(r, r2)
981 if ((e & (1 << i)) > 0) z.mulTo(r2, g, r)
982 else {
983 var t = r
984 r = r2
985 r2 = t
986 }
987 }
988 return z.revert(r)
989}
990
991// (public) this^e % m, 0 <= e < 2^32
992function bnModPowInt(e, m) {
993 var z
994 if (e < 256 || m.isEven()) z = new Classic(m)
995 else z = new Montgomery(m)
996 return this.exp(e, z)
997}
998
999// protected
1000proto.copyTo = bnpCopyTo
1001proto.fromInt = bnpFromInt
1002proto.fromString = bnpFromString
1003proto.clamp = bnpClamp
1004proto.dlShiftTo = bnpDLShiftTo
1005proto.drShiftTo = bnpDRShiftTo
1006proto.lShiftTo = bnpLShiftTo
1007proto.rShiftTo = bnpRShiftTo
1008proto.subTo = bnpSubTo
1009proto.multiplyTo = bnpMultiplyTo
1010proto.squareTo = bnpSquareTo
1011proto.divRemTo = bnpDivRemTo
1012proto.invDigit = bnpInvDigit
1013proto.isEven = bnpIsEven
1014proto.exp = bnpExp
1015
1016// public
1017proto.toString = bnToString
1018proto.negate = bnNegate
1019proto.abs = bnAbs
1020proto.compareTo = bnCompareTo
1021proto.bitLength = bnBitLength
1022proto.byteLength = bnByteLength
1023proto.mod = bnMod
1024proto.modPowInt = bnModPowInt
1025
1026// (public)
1027function bnClone() {
1028 var r = new BigInteger()
1029 this.copyTo(r)
1030 return r
1031}
1032
1033// (public) return value as integer
1034function bnIntValue() {
1035 if (this.s < 0) {
1036 if (this.t == 1) return this[0] - this.DV
1037 else if (this.t == 0) return -1
1038 } else if (this.t == 1) return this[0]
1039 else if (this.t == 0) return 0
1040 // assumes 16 < DB < 32
1041 return ((this[1] & ((1 << (32 - this.DB)) - 1)) << this.DB) | this[0]
1042}
1043
1044// (public) return value as byte
1045function bnByteValue() {
1046 return (this.t == 0) ? this.s : (this[0] << 24) >> 24
1047}
1048
1049// (public) return value as short (assumes DB>=16)
1050function bnShortValue() {
1051 return (this.t == 0) ? this.s : (this[0] << 16) >> 16
1052}
1053
1054// (protected) return x s.t. r^x < DV
1055function bnpChunkSize(r) {
1056 return Math.floor(Math.LN2 * this.DB / Math.log(r))
1057}
1058
1059// (public) 0 if this == 0, 1 if this > 0
1060function bnSigNum() {
1061 if (this.s < 0) return -1
1062 else if (this.t <= 0 || (this.t == 1 && this[0] <= 0)) return 0
1063 else return 1
1064}
1065
1066// (protected) convert to radix string
1067function bnpToRadix(b) {
1068 if (b == null) b = 10
1069 if (this.signum() == 0 || b < 2 || b > 36) return "0"
1070 var cs = this.chunkSize(b)
1071 var a = Math.pow(b, cs)
1072 var d = nbv(a),
1073 y = new BigInteger(),
1074 z = new BigInteger(),
1075 r = ""
1076 this.divRemTo(d, y, z)
1077 while (y.signum() > 0) {
1078 r = (a + z.intValue())
1079 .toString(b)
1080 .substr(1) + r
1081 y.divRemTo(d, y, z)
1082 }
1083 return z.intValue()
1084 .toString(b) + r
1085}
1086
1087// (protected) convert from radix string
1088function bnpFromRadix(s, b) {
1089 var self = this
1090 self.fromInt(0)
1091 if (b == null) b = 10
1092 var cs = self.chunkSize(b)
1093 var d = Math.pow(b, cs),
1094 mi = false,
1095 j = 0,
1096 w = 0
1097 for (var i = 0; i < s.length; ++i) {
1098 var x = intAt(s, i)
1099 if (x < 0) {
1100 if (s.charAt(i) == "-" && self.signum() == 0) mi = true
1101 continue
1102 }
1103 w = b * w + x
1104 if (++j >= cs) {
1105 self.dMultiply(d)
1106 self.dAddOffset(w, 0)
1107 j = 0
1108 w = 0
1109 }
1110 }
1111 if (j > 0) {
1112 self.dMultiply(Math.pow(b, j))
1113 self.dAddOffset(w, 0)
1114 }
1115 if (mi) BigInteger.ZERO.subTo(self, self)
1116}
1117
1118// (protected) alternate constructor
1119function bnpFromNumber(a, b, c) {
1120 var self = this
1121 if ("number" == typeof b) {
1122 // new BigInteger(int,int,RNG)
1123 if (a < 2) self.fromInt(1)
1124 else {
1125 self.fromNumber(a, c)
1126 if (!self.testBit(a - 1)) // force MSB set
1127 self.bitwiseTo(BigInteger.ONE.shiftLeft(a - 1), op_or, self)
1128 if (self.isEven()) self.dAddOffset(1, 0); // force odd
1129 while (!self.isProbablePrime(b)) {
1130 self.dAddOffset(2, 0)
1131 if (self.bitLength() > a) self.subTo(BigInteger.ONE.shiftLeft(a - 1), self)
1132 }
1133 }
1134 } else {
1135 // new BigInteger(int,RNG)
1136 var x = new Array(),
1137 t = a & 7
1138 x.length = (a >> 3) + 1
1139 b.nextBytes(x)
1140 if (t > 0) x[0] &= ((1 << t) - 1)
1141 else x[0] = 0
1142 self.fromString(x, 256)
1143 }
1144}
1145
1146// (public) convert to bigendian byte array
1147function bnToByteArray() {
1148 var self = this
1149 var i = self.t,
1150 r = new Array()
1151 r[0] = self.s
1152 var p = self.DB - (i * self.DB) % 8,
1153 d, k = 0
1154 if (i-- > 0) {
1155 if (p < self.DB && (d = self[i] >> p) != (self.s & self.DM) >> p)
1156 r[k++] = d | (self.s << (self.DB - p))
1157 while (i >= 0) {
1158 if (p < 8) {
1159 d = (self[i] & ((1 << p) - 1)) << (8 - p)
1160 d |= self[--i] >> (p += self.DB - 8)
1161 } else {
1162 d = (self[i] >> (p -= 8)) & 0xff
1163 if (p <= 0) {
1164 p += self.DB
1165 --i
1166 }
1167 }
1168 if ((d & 0x80) != 0) d |= -256
1169 if (k === 0 && (self.s & 0x80) != (d & 0x80))++k
1170 if (k > 0 || d != self.s) r[k++] = d
1171 }
1172 }
1173 return r
1174}
1175
1176function bnEquals(a) {
1177 return (this.compareTo(a) == 0)
1178}
1179
1180function bnMin(a) {
1181 return (this.compareTo(a) < 0) ? this : a
1182}
1183
1184function bnMax(a) {
1185 return (this.compareTo(a) > 0) ? this : a
1186}
1187
1188// (protected) r = this op a (bitwise)
1189function bnpBitwiseTo(a, op, r) {
1190 var self = this
1191 var i, f, m = Math.min(a.t, self.t)
1192 for (i = 0; i < m; ++i) r[i] = op(self[i], a[i])
1193 if (a.t < self.t) {
1194 f = a.s & self.DM
1195 for (i = m; i < self.t; ++i) r[i] = op(self[i], f)
1196 r.t = self.t
1197 } else {
1198 f = self.s & self.DM
1199 for (i = m; i < a.t; ++i) r[i] = op(f, a[i])
1200 r.t = a.t
1201 }
1202 r.s = op(self.s, a.s)
1203 r.clamp()
1204}
1205
1206// (public) this & a
1207function op_and(x, y) {
1208 return x & y
1209}
1210
1211function bnAnd(a) {
1212 var r = new BigInteger()
1213 this.bitwiseTo(a, op_and, r)
1214 return r
1215}
1216
1217// (public) this | a
1218function op_or(x, y) {
1219 return x | y
1220}
1221
1222function bnOr(a) {
1223 var r = new BigInteger()
1224 this.bitwiseTo(a, op_or, r)
1225 return r
1226}
1227
1228// (public) this ^ a
1229function op_xor(x, y) {
1230 return x ^ y
1231}
1232
1233function bnXor(a) {
1234 var r = new BigInteger()
1235 this.bitwiseTo(a, op_xor, r)
1236 return r
1237}
1238
1239// (public) this & ~a
1240function op_andnot(x, y) {
1241 return x & ~y
1242}
1243
1244function bnAndNot(a) {
1245 var r = new BigInteger()
1246 this.bitwiseTo(a, op_andnot, r)
1247 return r
1248}
1249
1250// (public) ~this
1251function bnNot() {
1252 var r = new BigInteger()
1253 for (var i = 0; i < this.t; ++i) r[i] = this.DM & ~this[i]
1254 r.t = this.t
1255 r.s = ~this.s
1256 return r
1257}
1258
1259// (public) this << n
1260function bnShiftLeft(n) {
1261 var r = new BigInteger()
1262 if (n < 0) this.rShiftTo(-n, r)
1263 else this.lShiftTo(n, r)
1264 return r
1265}
1266
1267// (public) this >> n
1268function bnShiftRight(n) {
1269 var r = new BigInteger()
1270 if (n < 0) this.lShiftTo(-n, r)
1271 else this.rShiftTo(n, r)
1272 return r
1273}
1274
1275// return index of lowest 1-bit in x, x < 2^31
1276function lbit(x) {
1277 if (x == 0) return -1
1278 var r = 0
1279 if ((x & 0xffff) == 0) {
1280 x >>= 16
1281 r += 16
1282 }
1283 if ((x & 0xff) == 0) {
1284 x >>= 8
1285 r += 8
1286 }
1287 if ((x & 0xf) == 0) {
1288 x >>= 4
1289 r += 4
1290 }
1291 if ((x & 3) == 0) {
1292 x >>= 2
1293 r += 2
1294 }
1295 if ((x & 1) == 0)++r
1296 return r
1297}
1298
1299// (public) returns index of lowest 1-bit (or -1 if none)
1300function bnGetLowestSetBit() {
1301 for (var i = 0; i < this.t; ++i)
1302 if (this[i] != 0) return i * this.DB + lbit(this[i])
1303 if (this.s < 0) return this.t * this.DB
1304 return -1
1305}
1306
1307// return number of 1 bits in x
1308function cbit(x) {
1309 var r = 0
1310 while (x != 0) {
1311 x &= x - 1
1312 ++r
1313 }
1314 return r
1315}
1316
1317// (public) return number of set bits
1318function bnBitCount() {
1319 var r = 0,
1320 x = this.s & this.DM
1321 for (var i = 0; i < this.t; ++i) r += cbit(this[i] ^ x)
1322 return r
1323}
1324
1325// (public) true iff nth bit is set
1326function bnTestBit(n) {
1327 var j = Math.floor(n / this.DB)
1328 if (j >= this.t) return (this.s != 0)
1329 return ((this[j] & (1 << (n % this.DB))) != 0)
1330}
1331
1332// (protected) this op (1<<n)
1333function bnpChangeBit(n, op) {
1334 var r = BigInteger.ONE.shiftLeft(n)
1335 this.bitwiseTo(r, op, r)
1336 return r
1337}
1338
1339// (public) this | (1<<n)
1340function bnSetBit(n) {
1341 return this.changeBit(n, op_or)
1342}
1343
1344// (public) this & ~(1<<n)
1345function bnClearBit(n) {
1346 return this.changeBit(n, op_andnot)
1347}
1348
1349// (public) this ^ (1<<n)
1350function bnFlipBit(n) {
1351 return this.changeBit(n, op_xor)
1352}
1353
1354// (protected) r = this + a
1355function bnpAddTo(a, r) {
1356 var self = this
1357
1358 var i = 0,
1359 c = 0,
1360 m = Math.min(a.t, self.t)
1361 while (i < m) {
1362 c += self[i] + a[i]
1363 r[i++] = c & self.DM
1364 c >>= self.DB
1365 }
1366 if (a.t < self.t) {
1367 c += a.s
1368 while (i < self.t) {
1369 c += self[i]
1370 r[i++] = c & self.DM
1371 c >>= self.DB
1372 }
1373 c += self.s
1374 } else {
1375 c += self.s
1376 while (i < a.t) {
1377 c += a[i]
1378 r[i++] = c & self.DM
1379 c >>= self.DB
1380 }
1381 c += a.s
1382 }
1383 r.s = (c < 0) ? -1 : 0
1384 if (c > 0) r[i++] = c
1385 else if (c < -1) r[i++] = self.DV + c
1386 r.t = i
1387 r.clamp()
1388}
1389
1390// (public) this + a
1391function bnAdd(a) {
1392 var r = new BigInteger()
1393 this.addTo(a, r)
1394 return r
1395}
1396
1397// (public) this - a
1398function bnSubtract(a) {
1399 var r = new BigInteger()
1400 this.subTo(a, r)
1401 return r
1402}
1403
1404// (public) this * a
1405function bnMultiply(a) {
1406 var r = new BigInteger()
1407 this.multiplyTo(a, r)
1408 return r
1409}
1410
1411// (public) this^2
1412function bnSquare() {
1413 var r = new BigInteger()
1414 this.squareTo(r)
1415 return r
1416}
1417
1418// (public) this / a
1419function bnDivide(a) {
1420 var r = new BigInteger()
1421 this.divRemTo(a, r, null)
1422 return r
1423}
1424
1425// (public) this % a
1426function bnRemainder(a) {
1427 var r = new BigInteger()
1428 this.divRemTo(a, null, r)
1429 return r
1430}
1431
1432// (public) [this/a,this%a]
1433function bnDivideAndRemainder(a) {
1434 var q = new BigInteger(),
1435 r = new BigInteger()
1436 this.divRemTo(a, q, r)
1437 return new Array(q, r)
1438}
1439
1440// (protected) this *= n, this >= 0, 1 < n < DV
1441function bnpDMultiply(n) {
1442 this[this.t] = this.am(0, n - 1, this, 0, 0, this.t)
1443 ++this.t
1444 this.clamp()
1445}
1446
1447// (protected) this += n << w words, this >= 0
1448function bnpDAddOffset(n, w) {
1449 if (n == 0) return
1450 while (this.t <= w) this[this.t++] = 0
1451 this[w] += n
1452 while (this[w] >= this.DV) {
1453 this[w] -= this.DV
1454 if (++w >= this.t) this[this.t++] = 0
1455 ++this[w]
1456 }
1457}
1458
1459// A "null" reducer
1460function NullExp() {}
1461
1462function nNop(x) {
1463 return x
1464}
1465
1466function nMulTo(x, y, r) {
1467 x.multiplyTo(y, r)
1468}
1469
1470function nSqrTo(x, r) {
1471 x.squareTo(r)
1472}
1473
1474NullExp.prototype.convert = nNop
1475NullExp.prototype.revert = nNop
1476NullExp.prototype.mulTo = nMulTo
1477NullExp.prototype.sqrTo = nSqrTo
1478
1479// (public) this^e
1480function bnPow(e) {
1481 return this.exp(e, new NullExp())
1482}
1483
1484// (protected) r = lower n words of "this * a", a.t <= n
1485// "this" should be the larger one if appropriate.
1486function bnpMultiplyLowerTo(a, n, r) {
1487 var i = Math.min(this.t + a.t, n)
1488 r.s = 0; // assumes a,this >= 0
1489 r.t = i
1490 while (i > 0) r[--i] = 0
1491 var j
1492 for (j = r.t - this.t; i < j; ++i) r[i + this.t] = this.am(0, a[i], r, i, 0, this.t)
1493 for (j = Math.min(a.t, n); i < j; ++i) this.am(0, a[i], r, i, 0, n - i)
1494 r.clamp()
1495}
1496
1497// (protected) r = "this * a" without lower n words, n > 0
1498// "this" should be the larger one if appropriate.
1499function bnpMultiplyUpperTo(a, n, r) {
1500 --n
1501 var i = r.t = this.t + a.t - n
1502 r.s = 0; // assumes a,this >= 0
1503 while (--i >= 0) r[i] = 0
1504 for (i = Math.max(n - this.t, 0); i < a.t; ++i)
1505 r[this.t + i - n] = this.am(n - i, a[i], r, 0, 0, this.t + i - n)
1506 r.clamp()
1507 r.drShiftTo(1, r)
1508}
1509
1510// Barrett modular reduction
1511function Barrett(m) {
1512 // setup Barrett
1513 this.r2 = new BigInteger()
1514 this.q3 = new BigInteger()
1515 BigInteger.ONE.dlShiftTo(2 * m.t, this.r2)
1516 this.mu = this.r2.divide(m)
1517 this.m = m
1518}
1519
1520function barrettConvert(x) {
1521 if (x.s < 0 || x.t > 2 * this.m.t) return x.mod(this.m)
1522 else if (x.compareTo(this.m) < 0) return x
1523 else {
1524 var r = new BigInteger()
1525 x.copyTo(r)
1526 this.reduce(r)
1527 return r
1528 }
1529}
1530
1531function barrettRevert(x) {
1532 return x
1533}
1534
1535// x = x mod m (HAC 14.42)
1536function barrettReduce(x) {
1537 var self = this
1538 x.drShiftTo(self.m.t - 1, self.r2)
1539 if (x.t > self.m.t + 1) {
1540 x.t = self.m.t + 1
1541 x.clamp()
1542 }
1543 self.mu.multiplyUpperTo(self.r2, self.m.t + 1, self.q3)
1544 self.m.multiplyLowerTo(self.q3, self.m.t + 1, self.r2)
1545 while (x.compareTo(self.r2) < 0) x.dAddOffset(1, self.m.t + 1)
1546 x.subTo(self.r2, x)
1547 while (x.compareTo(self.m) >= 0) x.subTo(self.m, x)
1548}
1549
1550// r = x^2 mod m; x != r
1551function barrettSqrTo(x, r) {
1552 x.squareTo(r)
1553 this.reduce(r)
1554}
1555
1556// r = x*y mod m; x,y != r
1557function barrettMulTo(x, y, r) {
1558 x.multiplyTo(y, r)
1559 this.reduce(r)
1560}
1561
1562Barrett.prototype.convert = barrettConvert
1563Barrett.prototype.revert = barrettRevert
1564Barrett.prototype.reduce = barrettReduce
1565Barrett.prototype.mulTo = barrettMulTo
1566Barrett.prototype.sqrTo = barrettSqrTo
1567
1568// (public) this^e % m (HAC 14.85)
1569function bnModPow(e, m) {
1570 var i = e.bitLength(),
1571 k, r = nbv(1),
1572 z
1573 if (i <= 0) return r
1574 else if (i < 18) k = 1
1575 else if (i < 48) k = 3
1576 else if (i < 144) k = 4
1577 else if (i < 768) k = 5
1578 else k = 6
1579 if (i < 8)
1580 z = new Classic(m)
1581 else if (m.isEven())
1582 z = new Barrett(m)
1583 else
1584 z = new Montgomery(m)
1585
1586 // precomputation
1587 var g = new Array(),
1588 n = 3,
1589 k1 = k - 1,
1590 km = (1 << k) - 1
1591 g[1] = z.convert(this)
1592 if (k > 1) {
1593 var g2 = new BigInteger()
1594 z.sqrTo(g[1], g2)
1595 while (n <= km) {
1596 g[n] = new BigInteger()
1597 z.mulTo(g2, g[n - 2], g[n])
1598 n += 2
1599 }
1600 }
1601
1602 var j = e.t - 1,
1603 w, is1 = true,
1604 r2 = new BigInteger(),
1605 t
1606 i = nbits(e[j]) - 1
1607 while (j >= 0) {
1608 if (i >= k1) w = (e[j] >> (i - k1)) & km
1609 else {
1610 w = (e[j] & ((1 << (i + 1)) - 1)) << (k1 - i)
1611 if (j > 0) w |= e[j - 1] >> (this.DB + i - k1)
1612 }
1613
1614 n = k
1615 while ((w & 1) == 0) {
1616 w >>= 1
1617 --n
1618 }
1619 if ((i -= n) < 0) {
1620 i += this.DB
1621 --j
1622 }
1623 if (is1) { // ret == 1, don't bother squaring or multiplying it
1624 g[w].copyTo(r)
1625 is1 = false
1626 } else {
1627 while (n > 1) {
1628 z.sqrTo(r, r2)
1629 z.sqrTo(r2, r)
1630 n -= 2
1631 }
1632 if (n > 0) z.sqrTo(r, r2)
1633 else {
1634 t = r
1635 r = r2
1636 r2 = t
1637 }
1638 z.mulTo(r2, g[w], r)
1639 }
1640
1641 while (j >= 0 && (e[j] & (1 << i)) == 0) {
1642 z.sqrTo(r, r2)
1643 t = r
1644 r = r2
1645 r2 = t
1646 if (--i < 0) {
1647 i = this.DB - 1
1648 --j
1649 }
1650 }
1651 }
1652 return z.revert(r)
1653}
1654
1655// (public) gcd(this,a) (HAC 14.54)
1656function bnGCD(a) {
1657 var x = (this.s < 0) ? this.negate() : this.clone()
1658 var y = (a.s < 0) ? a.negate() : a.clone()
1659 if (x.compareTo(y) < 0) {
1660 var t = x
1661 x = y
1662 y = t
1663 }
1664 var i = x.getLowestSetBit(),
1665 g = y.getLowestSetBit()
1666 if (g < 0) return x
1667 if (i < g) g = i
1668 if (g > 0) {
1669 x.rShiftTo(g, x)
1670 y.rShiftTo(g, y)
1671 }
1672 while (x.signum() > 0) {
1673 if ((i = x.getLowestSetBit()) > 0) x.rShiftTo(i, x)
1674 if ((i = y.getLowestSetBit()) > 0) y.rShiftTo(i, y)
1675 if (x.compareTo(y) >= 0) {
1676 x.subTo(y, x)
1677 x.rShiftTo(1, x)
1678 } else {
1679 y.subTo(x, y)
1680 y.rShiftTo(1, y)
1681 }
1682 }
1683 if (g > 0) y.lShiftTo(g, y)
1684 return y
1685}
1686
1687// (protected) this % n, n < 2^26
1688function bnpModInt(n) {
1689 if (n <= 0) return 0
1690 var d = this.DV % n,
1691 r = (this.s < 0) ? n - 1 : 0
1692 if (this.t > 0)
1693 if (d == 0) r = this[0] % n
1694 else
1695 for (var i = this.t - 1; i >= 0; --i) r = (d * r + this[i]) % n
1696 return r
1697}
1698
1699// (public) 1/this % m (HAC 14.61)
1700function bnModInverse(m) {
1701 var ac = m.isEven()
1702 if (this.signum() === 0) throw new Error('division by zero')
1703 if ((this.isEven() && ac) || m.signum() == 0) return BigInteger.ZERO
1704 var u = m.clone(),
1705 v = this.clone()
1706 var a = nbv(1),
1707 b = nbv(0),
1708 c = nbv(0),
1709 d = nbv(1)
1710 while (u.signum() != 0) {
1711 while (u.isEven()) {
1712 u.rShiftTo(1, u)
1713 if (ac) {
1714 if (!a.isEven() || !b.isEven()) {
1715 a.addTo(this, a)
1716 b.subTo(m, b)
1717 }
1718 a.rShiftTo(1, a)
1719 } else if (!b.isEven()) b.subTo(m, b)
1720 b.rShiftTo(1, b)
1721 }
1722 while (v.isEven()) {
1723 v.rShiftTo(1, v)
1724 if (ac) {
1725 if (!c.isEven() || !d.isEven()) {
1726 c.addTo(this, c)
1727 d.subTo(m, d)
1728 }
1729 c.rShiftTo(1, c)
1730 } else if (!d.isEven()) d.subTo(m, d)
1731 d.rShiftTo(1, d)
1732 }
1733 if (u.compareTo(v) >= 0) {
1734 u.subTo(v, u)
1735 if (ac) a.subTo(c, a)
1736 b.subTo(d, b)
1737 } else {
1738 v.subTo(u, v)
1739 if (ac) c.subTo(a, c)
1740 d.subTo(b, d)
1741 }
1742 }
1743 if (v.compareTo(BigInteger.ONE) != 0) return BigInteger.ZERO
1744 while (d.compareTo(m) >= 0) d.subTo(m, d)
1745 while (d.signum() < 0) d.addTo(m, d)
1746 return d
1747}
1748
1749var lowprimes = [
1750 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
1751 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151,
1752 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233,
1753 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317,
1754 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419,
1755 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503,
1756 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607,
1757 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701,
1758 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811,
1759 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911,
1760 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997
1761]
1762
1763var lplim = (1 << 26) / lowprimes[lowprimes.length - 1]
1764
1765// (public) test primality with certainty >= 1-.5^t
1766function bnIsProbablePrime(t) {
1767 var i, x = this.abs()
1768 if (x.t == 1 && x[0] <= lowprimes[lowprimes.length - 1]) {
1769 for (i = 0; i < lowprimes.length; ++i)
1770 if (x[0] == lowprimes[i]) return true
1771 return false
1772 }
1773 if (x.isEven()) return false
1774 i = 1
1775 while (i < lowprimes.length) {
1776 var m = lowprimes[i],
1777 j = i + 1
1778 while (j < lowprimes.length && m < lplim) m *= lowprimes[j++]
1779 m = x.modInt(m)
1780 while (i < j) if (m % lowprimes[i++] == 0) return false
1781 }
1782 return x.millerRabin(t)
1783}
1784
1785// (protected) true if probably prime (HAC 4.24, Miller-Rabin)
1786function bnpMillerRabin(t) {
1787 var n1 = this.subtract(BigInteger.ONE)
1788 var k = n1.getLowestSetBit()
1789 if (k <= 0) return false
1790 var r = n1.shiftRight(k)
1791 t = (t + 1) >> 1
1792 if (t > lowprimes.length) t = lowprimes.length
1793 var a = new BigInteger(null)
1794 var j, bases = []
1795 for (var i = 0; i < t; ++i) {
1796 for (;;) {
1797 j = lowprimes[Math.floor(Math.random() * lowprimes.length)]
1798 if (bases.indexOf(j) == -1) break
1799 }
1800 bases.push(j)
1801 a.fromInt(j)
1802 var y = a.modPow(r, this)
1803 if (y.compareTo(BigInteger.ONE) != 0 && y.compareTo(n1) != 0) {
1804 var j = 1
1805 while (j++ < k && y.compareTo(n1) != 0) {
1806 y = y.modPowInt(2, this)
1807 if (y.compareTo(BigInteger.ONE) == 0) return false
1808 }
1809 if (y.compareTo(n1) != 0) return false
1810 }
1811 }
1812 return true
1813}
1814
1815// protected
1816proto.chunkSize = bnpChunkSize
1817proto.toRadix = bnpToRadix
1818proto.fromRadix = bnpFromRadix
1819proto.fromNumber = bnpFromNumber
1820proto.bitwiseTo = bnpBitwiseTo
1821proto.changeBit = bnpChangeBit
1822proto.addTo = bnpAddTo
1823proto.dMultiply = bnpDMultiply
1824proto.dAddOffset = bnpDAddOffset
1825proto.multiplyLowerTo = bnpMultiplyLowerTo
1826proto.multiplyUpperTo = bnpMultiplyUpperTo
1827proto.modInt = bnpModInt
1828proto.millerRabin = bnpMillerRabin
1829
1830// public
1831proto.clone = bnClone
1832proto.intValue = bnIntValue
1833proto.byteValue = bnByteValue
1834proto.shortValue = bnShortValue
1835proto.signum = bnSigNum
1836proto.toByteArray = bnToByteArray
1837proto.equals = bnEquals
1838proto.min = bnMin
1839proto.max = bnMax
1840proto.and = bnAnd
1841proto.or = bnOr
1842proto.xor = bnXor
1843proto.andNot = bnAndNot
1844proto.not = bnNot
1845proto.shiftLeft = bnShiftLeft
1846proto.shiftRight = bnShiftRight
1847proto.getLowestSetBit = bnGetLowestSetBit
1848proto.bitCount = bnBitCount
1849proto.testBit = bnTestBit
1850proto.setBit = bnSetBit
1851proto.clearBit = bnClearBit
1852proto.flipBit = bnFlipBit
1853proto.add = bnAdd
1854proto.subtract = bnSubtract
1855proto.multiply = bnMultiply
1856proto.divide = bnDivide
1857proto.remainder = bnRemainder
1858proto.divideAndRemainder = bnDivideAndRemainder
1859proto.modPow = bnModPow
1860proto.modInverse = bnModInverse
1861proto.pow = bnPow
1862proto.gcd = bnGCD
1863proto.isProbablePrime = bnIsProbablePrime
1864
1865// JSBN-specific extension
1866proto.square = bnSquare
1867
1868// constants
1869BigInteger.ZERO = nbv(0)
1870BigInteger.ONE = nbv(1)
1871BigInteger.valueOf = nbv
1872
1873module.exports = BigInteger
1874
1875},{"../package.json":6}],4:[function(require,module,exports){
1876(function (Buffer){
1877// FIXME: Kind of a weird way to throw exceptions, consider removing
1878var assert = require('assert')
1879var BigInteger = require('./bigi')
1880
1881/**
1882 * Turns a byte array into a big integer.
1883 *
1884 * This function will interpret a byte array as a big integer in big
1885 * endian notation.
1886 */
1887BigInteger.fromByteArrayUnsigned = function(byteArray) {
1888 // BigInteger expects a DER integer conformant byte array
1889 if (byteArray[0] & 0x80) {
1890 return new BigInteger([0].concat(byteArray))
1891 }
1892
1893 return new BigInteger(byteArray)
1894}
1895
1896/**
1897 * Returns a byte array representation of the big integer.
1898 *
1899 * This returns the absolute of the contained value in big endian
1900 * form. A value of zero results in an empty array.
1901 */
1902BigInteger.prototype.toByteArrayUnsigned = function() {
1903 var byteArray = this.toByteArray()
1904 return byteArray[0] === 0 ? byteArray.slice(1) : byteArray
1905}
1906
1907BigInteger.fromDERInteger = function(byteArray) {
1908 return new BigInteger(byteArray)
1909}
1910
1911/*
1912 * Converts BigInteger to a DER integer representation.
1913 *
1914 * The format for this value uses the most significant bit as a sign
1915 * bit. If the most significant bit is already set and the integer is
1916 * positive, a 0x00 is prepended.
1917 *
1918 * Examples:
1919 *
1920 * 0 => 0x00
1921 * 1 => 0x01
1922 * -1 => 0xff
1923 * 127 => 0x7f
1924 * -127 => 0x81
1925 * 128 => 0x0080
1926 * -128 => 0x80
1927 * 255 => 0x00ff
1928 * -255 => 0xff01
1929 * 16300 => 0x3fac
1930 * -16300 => 0xc054
1931 * 62300 => 0x00f35c
1932 * -62300 => 0xff0ca4
1933*/
1934BigInteger.prototype.toDERInteger = BigInteger.prototype.toByteArray
1935
1936BigInteger.fromBuffer = function(buffer) {
1937 // BigInteger expects a DER integer conformant byte array
1938 if (buffer[0] & 0x80) {
1939 var byteArray = Array.prototype.slice.call(buffer)
1940
1941 return new BigInteger([0].concat(byteArray))
1942 }
1943
1944 return new BigInteger(buffer)
1945}
1946
1947BigInteger.fromHex = function(hex) {
1948 if (hex === '') return BigInteger.ZERO
1949
1950 assert.equal(hex, hex.match(/^[A-Fa-f0-9]+/), 'Invalid hex string')
1951 assert.equal(hex.length % 2, 0, 'Incomplete hex')
1952 return new BigInteger(hex, 16)
1953}
1954
1955BigInteger.prototype.toBuffer = function(size) {
1956 var byteArray = this.toByteArrayUnsigned()
1957 var zeros = []
1958
1959 var padding = size - byteArray.length
1960 while (zeros.length < padding) zeros.push(0)
1961
1962 return new Buffer(zeros.concat(byteArray))
1963}
1964
1965BigInteger.prototype.toHex = function(size) {
1966 return this.toBuffer(size).toString('hex')
1967}
1968
1969}).call(this,require("buffer").Buffer)
1970},{"./bigi":3,"assert":74,"buffer":110}],5:[function(require,module,exports){
1971var BigInteger = require('./bigi')
1972
1973//addons
1974require('./convert')
1975
1976module.exports = BigInteger
1977},{"./bigi":3,"./convert":4}],6:[function(require,module,exports){
1978module.exports={
1979 "_args": [
1980 [
1981 "bigi@^1.2.0",
1982 "/home/hashengineering/hashengineering/bip38grs"
1983 ]
1984 ],
1985 "_from": "bigi@>=1.2.0 <2.0.0",
1986 "_id": "bigi@1.4.2",
1987 "_inCache": true,
1988 "_installable": true,
1989 "_location": "/bigi",
1990 "_nodeVersion": "6.1.0",
1991 "_npmOperationalInternal": {
1992 "host": "packages-12-west.internal.npmjs.com",
1993 "tmp": "tmp/bigi-1.4.2.tgz_1469584192413_0.6801238611806184"
1994 },
1995 "_npmUser": {
1996 "email": "jprichardson@gmail.com",
1997 "name": "jprichardson"
1998 },
1999 "_npmVersion": "3.8.6",
2000 "_phantomChildren": {},
2001 "_requested": {
2002 "name": "bigi",
2003 "raw": "bigi@^1.2.0",
2004 "rawSpec": "^1.2.0",
2005 "scope": null,
2006 "spec": ">=1.2.0 <2.0.0",
2007 "type": "range"
2008 },
2009 "_requiredBy": [
2010 "/",
2011 "/ecurve"
2012 ],
2013 "_resolved": "https://registry.npmjs.org/bigi/-/bigi-1.4.2.tgz",
2014 "_shasum": "9c665a95f88b8b08fc05cfd731f561859d725825",
2015 "_shrinkwrap": null,
2016 "_spec": "bigi@^1.2.0",
2017 "_where": "/home/hashengineering/hashengineering/bip38grs",
2018 "bugs": {
2019 "url": "https://github.com/cryptocoinjs/bigi/issues"
2020 },
2021 "dependencies": {},
2022 "description": "Big integers.",
2023 "devDependencies": {
2024 "coveralls": "^2.11.2",
2025 "istanbul": "^0.3.5",
2026 "jshint": "^2.5.1",
2027 "mocha": "^2.1.0",
2028 "mochify": "^2.1.0"
2029 },
2030 "directories": {},
2031 "dist": {
2032 "shasum": "9c665a95f88b8b08fc05cfd731f561859d725825",
2033 "tarball": "https://registry.npmjs.org/bigi/-/bigi-1.4.2.tgz"
2034 },
2035 "gitHead": "c25308081c896ff84702303722bf5ecd8b3f78e3",
2036 "homepage": "https://github.com/cryptocoinjs/bigi#readme",
2037 "keywords": [
2038 "arbitrary",
2039 "arithmetic",
2040 "big",
2041 "bigint",
2042 "biginteger",
2043 "bignumber",
2044 "bitcoin",
2045 "cryptography",
2046 "decimal",
2047 "float",
2048 "int",
2049 "integer",
2050 "math",
2051 "number",
2052 "precision"
2053 ],
2054 "main": "./lib/index.js",
2055 "maintainers": [
2056 {
2057 "name": "midnightlightning",
2058 "email": "boydb@midnightdesign.ws"
2059 },
2060 {
2061 "name": "sidazhang",
2062 "email": "sidazhang89@gmail.com"
2063 },
2064 {
2065 "name": "nadav",
2066 "email": "npm@shesek.info"
2067 },
2068 {
2069 "name": "jprichardson",
2070 "email": "jprichardson@gmail.com"
2071 }
2072 ],
2073 "name": "bigi",
2074 "optionalDependencies": {},
2075 "readme": "ERROR: No README data found!",
2076 "repository": {
2077 "type": "git",
2078 "url": "git+https://github.com/cryptocoinjs/bigi.git"
2079 },
2080 "scripts": {
2081 "browser-test": "mochify --wd -R spec",
2082 "coverage": "istanbul cover ./node_modules/.bin/_mocha -- --reporter list test/*.js",
2083 "coveralls": "npm run-script coverage && node ./node_modules/.bin/coveralls < coverage/lcov.info",
2084 "jshint": "jshint --config jshint.json lib/*.js ; true",
2085 "test": "_mocha -- test/*.js",
2086 "unit": "mocha"
2087 },
2088 "testling": {
2089 "browsers": [
2090 "android-browser/4.2..latest",
2091 "chrome/latest",
2092 "firefox/latest",
2093 "ie/9..latest",
2094 "iphone/6.0..latest",
2095 "safari/6.0..latest"
2096 ],
2097 "files": "test/*.js",
2098 "harness": "mocha"
2099 },
2100 "version": "1.4.2"
2101}
2102
2103},{}],7:[function(require,module,exports){
2104// based on the aes implimentation in triple sec
2105// https://github.com/keybase/triplesec
2106// which is in turn based on the one from crypto-js
2107// https://code.google.com/p/crypto-js/
2108
2109var Buffer = require('safe-buffer').Buffer
2110
2111function asUInt32Array (buf) {
2112 if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf)
2113
2114 var len = (buf.length / 4) | 0
2115 var out = new Array(len)
2116
2117 for (var i = 0; i < len; i++) {
2118 out[i] = buf.readUInt32BE(i * 4)
2119 }
2120
2121 return out
2122}
2123
2124function scrubVec (v) {
2125 for (var i = 0; i < v.length; v++) {
2126 v[i] = 0
2127 }
2128}
2129
2130function cryptBlock (M, keySchedule, SUB_MIX, SBOX, nRounds) {
2131 var SUB_MIX0 = SUB_MIX[0]
2132 var SUB_MIX1 = SUB_MIX[1]
2133 var SUB_MIX2 = SUB_MIX[2]
2134 var SUB_MIX3 = SUB_MIX[3]
2135
2136 var s0 = M[0] ^ keySchedule[0]
2137 var s1 = M[1] ^ keySchedule[1]
2138 var s2 = M[2] ^ keySchedule[2]
2139 var s3 = M[3] ^ keySchedule[3]
2140 var t0, t1, t2, t3
2141 var ksRow = 4
2142
2143 for (var round = 1; round < nRounds; round++) {
2144 t0 = SUB_MIX0[s0 >>> 24] ^ SUB_MIX1[(s1 >>> 16) & 0xff] ^ SUB_MIX2[(s2 >>> 8) & 0xff] ^ SUB_MIX3[s3 & 0xff] ^ keySchedule[ksRow++]
2145 t1 = SUB_MIX0[s1 >>> 24] ^ SUB_MIX1[(s2 >>> 16) & 0xff] ^ SUB_MIX2[(s3 >>> 8) & 0xff] ^ SUB_MIX3[s0 & 0xff] ^ keySchedule[ksRow++]
2146 t2 = SUB_MIX0[s2 >>> 24] ^ SUB_MIX1[(s3 >>> 16) & 0xff] ^ SUB_MIX2[(s0 >>> 8) & 0xff] ^ SUB_MIX3[s1 & 0xff] ^ keySchedule[ksRow++]
2147 t3 = SUB_MIX0[s3 >>> 24] ^ SUB_MIX1[(s0 >>> 16) & 0xff] ^ SUB_MIX2[(s1 >>> 8) & 0xff] ^ SUB_MIX3[s2 & 0xff] ^ keySchedule[ksRow++]
2148 s0 = t0
2149 s1 = t1
2150 s2 = t2
2151 s3 = t3
2152 }
2153
2154 t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++]
2155 t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++]
2156 t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++]
2157 t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++]
2158 t0 = t0 >>> 0
2159 t1 = t1 >>> 0
2160 t2 = t2 >>> 0
2161 t3 = t3 >>> 0
2162
2163 return [t0, t1, t2, t3]
2164}
2165
2166// AES constants
2167var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36]
2168var G = (function () {
2169 // Compute double table
2170 var d = new Array(256)
2171 for (var j = 0; j < 256; j++) {
2172 if (j < 128) {
2173 d[j] = j << 1
2174 } else {
2175 d[j] = (j << 1) ^ 0x11b
2176 }
2177 }
2178
2179 var SBOX = []
2180 var INV_SBOX = []
2181 var SUB_MIX = [[], [], [], []]
2182 var INV_SUB_MIX = [[], [], [], []]
2183
2184 // Walk GF(2^8)
2185 var x = 0
2186 var xi = 0
2187 for (var i = 0; i < 256; ++i) {
2188 // Compute sbox
2189 var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4)
2190 sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63
2191 SBOX[x] = sx
2192 INV_SBOX[sx] = x
2193
2194 // Compute multiplication
2195 var x2 = d[x]
2196 var x4 = d[x2]
2197 var x8 = d[x4]
2198
2199 // Compute sub bytes, mix columns tables
2200 var t = (d[sx] * 0x101) ^ (sx * 0x1010100)
2201 SUB_MIX[0][x] = (t << 24) | (t >>> 8)
2202 SUB_MIX[1][x] = (t << 16) | (t >>> 16)
2203 SUB_MIX[2][x] = (t << 8) | (t >>> 24)
2204 SUB_MIX[3][x] = t
2205
2206 // Compute inv sub bytes, inv mix columns tables
2207 t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100)
2208 INV_SUB_MIX[0][sx] = (t << 24) | (t >>> 8)
2209 INV_SUB_MIX[1][sx] = (t << 16) | (t >>> 16)
2210 INV_SUB_MIX[2][sx] = (t << 8) | (t >>> 24)
2211 INV_SUB_MIX[3][sx] = t
2212
2213 if (x === 0) {
2214 x = xi = 1
2215 } else {
2216 x = x2 ^ d[d[d[x8 ^ x2]]]
2217 xi ^= d[d[xi]]
2218 }
2219 }
2220
2221 return {
2222 SBOX: SBOX,
2223 INV_SBOX: INV_SBOX,
2224 SUB_MIX: SUB_MIX,
2225 INV_SUB_MIX: INV_SUB_MIX
2226 }
2227})()
2228
2229function AES (key) {
2230 this._key = asUInt32Array(key)
2231 this._reset()
2232}
2233
2234AES.blockSize = 4 * 4
2235AES.keySize = 256 / 8
2236AES.prototype.blockSize = AES.blockSize
2237AES.prototype.keySize = AES.keySize
2238AES.prototype._reset = function () {
2239 var keyWords = this._key
2240 var keySize = keyWords.length
2241 var nRounds = keySize + 6
2242 var ksRows = (nRounds + 1) * 4
2243
2244 var keySchedule = []
2245 for (var k = 0; k < keySize; k++) {
2246 keySchedule[k] = keyWords[k]
2247 }
2248
2249 for (k = keySize; k < ksRows; k++) {
2250 var t = keySchedule[k - 1]
2251
2252 if (k % keySize === 0) {
2253 t = (t << 8) | (t >>> 24)
2254 t =
2255 (G.SBOX[t >>> 24] << 24) |
2256 (G.SBOX[(t >>> 16) & 0xff] << 16) |
2257 (G.SBOX[(t >>> 8) & 0xff] << 8) |
2258 (G.SBOX[t & 0xff])
2259
2260 t ^= RCON[(k / keySize) | 0] << 24
2261 } else if (keySize > 6 && k % keySize === 4) {
2262 t =
2263 (G.SBOX[t >>> 24] << 24) |
2264 (G.SBOX[(t >>> 16) & 0xff] << 16) |
2265 (G.SBOX[(t >>> 8) & 0xff] << 8) |
2266 (G.SBOX[t & 0xff])
2267 }
2268
2269 keySchedule[k] = keySchedule[k - keySize] ^ t
2270 }
2271
2272 var invKeySchedule = []
2273 for (var ik = 0; ik < ksRows; ik++) {
2274 var ksR = ksRows - ik
2275 var tt = keySchedule[ksR - (ik % 4 ? 0 : 4)]
2276
2277 if (ik < 4 || ksR <= 4) {
2278 invKeySchedule[ik] = tt
2279 } else {
2280 invKeySchedule[ik] =
2281 G.INV_SUB_MIX[0][G.SBOX[tt >>> 24]] ^
2282 G.INV_SUB_MIX[1][G.SBOX[(tt >>> 16) & 0xff]] ^
2283 G.INV_SUB_MIX[2][G.SBOX[(tt >>> 8) & 0xff]] ^
2284 G.INV_SUB_MIX[3][G.SBOX[tt & 0xff]]
2285 }
2286 }
2287
2288 this._nRounds = nRounds
2289 this._keySchedule = keySchedule
2290 this._invKeySchedule = invKeySchedule
2291}
2292
2293AES.prototype.encryptBlockRaw = function (M) {
2294 M = asUInt32Array(M)
2295 return cryptBlock(M, this._keySchedule, G.SUB_MIX, G.SBOX, this._nRounds)
2296}
2297
2298AES.prototype.encryptBlock = function (M) {
2299 var out = this.encryptBlockRaw(M)
2300 var buf = Buffer.allocUnsafe(16)
2301 buf.writeUInt32BE(out[0], 0)
2302 buf.writeUInt32BE(out[1], 4)
2303 buf.writeUInt32BE(out[2], 8)
2304 buf.writeUInt32BE(out[3], 12)
2305 return buf
2306}
2307
2308AES.prototype.decryptBlock = function (M) {
2309 M = asUInt32Array(M)
2310
2311 // swap
2312 var m1 = M[1]
2313 M[1] = M[3]
2314 M[3] = m1
2315
2316 var out = cryptBlock(M, this._invKeySchedule, G.INV_SUB_MIX, G.INV_SBOX, this._nRounds)
2317 var buf = Buffer.allocUnsafe(16)
2318 buf.writeUInt32BE(out[0], 0)
2319 buf.writeUInt32BE(out[3], 4)
2320 buf.writeUInt32BE(out[2], 8)
2321 buf.writeUInt32BE(out[1], 12)
2322 return buf
2323}
2324
2325AES.prototype.scrub = function () {
2326 scrubVec(this._keySchedule)
2327 scrubVec(this._invKeySchedule)
2328 scrubVec(this._key)
2329}
2330
2331module.exports.AES = AES
2332
2333},{"safe-buffer":47}],8:[function(require,module,exports){
2334var aes = require('./aes')
2335var Buffer = require('safe-buffer').Buffer
2336var Transform = require('cipher-base')
2337var inherits = require('inherits')
2338var GHASH = require('./ghash')
2339var xor = require('buffer-xor')
2340var incr32 = require('./incr32')
2341
2342function xorTest (a, b) {
2343 var out = 0
2344 if (a.length !== b.length) out++
2345
2346 var len = Math.min(a.length, b.length)
2347 for (var i = 0; i < len; ++i) {
2348 out += (a[i] ^ b[i])
2349 }
2350
2351 return out
2352}
2353
2354function calcIv (self, iv, ck) {
2355 if (iv.length === 12) {
2356 self._finID = Buffer.concat([iv, Buffer.from([0, 0, 0, 1])])
2357 return Buffer.concat([iv, Buffer.from([0, 0, 0, 2])])
2358 }
2359 var ghash = new GHASH(ck)
2360 var len = iv.length
2361 var toPad = len % 16
2362 ghash.update(iv)
2363 if (toPad) {
2364 toPad = 16 - toPad
2365 ghash.update(Buffer.alloc(toPad, 0))
2366 }
2367 ghash.update(Buffer.alloc(8, 0))
2368 var ivBits = len * 8
2369 var tail = Buffer.alloc(8)
2370 tail.writeUIntBE(ivBits, 0, 8)
2371 ghash.update(tail)
2372 self._finID = ghash.state
2373 var out = Buffer.from(self._finID)
2374 incr32(out)
2375 return out
2376}
2377function StreamCipher (mode, key, iv, decrypt) {
2378 Transform.call(this)
2379
2380 var h = Buffer.alloc(4, 0)
2381
2382 this._cipher = new aes.AES(key)
2383 var ck = this._cipher.encryptBlock(h)
2384 this._ghash = new GHASH(ck)
2385 iv = calcIv(this, iv, ck)
2386
2387 this._prev = Buffer.from(iv)
2388 this._cache = Buffer.allocUnsafe(0)
2389 this._secCache = Buffer.allocUnsafe(0)
2390 this._decrypt = decrypt
2391 this._alen = 0
2392 this._len = 0
2393 this._mode = mode
2394
2395 this._authTag = null
2396 this._called = false
2397}
2398
2399inherits(StreamCipher, Transform)
2400
2401StreamCipher.prototype._update = function (chunk) {
2402 if (!this._called && this._alen) {
2403 var rump = 16 - (this._alen % 16)
2404 if (rump < 16) {
2405 rump = Buffer.alloc(rump, 0)
2406 this._ghash.update(rump)
2407 }
2408 }
2409
2410 this._called = true
2411 var out = this._mode.encrypt(this, chunk)
2412 if (this._decrypt) {
2413 this._ghash.update(chunk)
2414 } else {
2415 this._ghash.update(out)
2416 }
2417 this._len += chunk.length
2418 return out
2419}
2420
2421StreamCipher.prototype._final = function () {
2422 if (this._decrypt && !this._authTag) throw new Error('Unsupported state or unable to authenticate data')
2423
2424 var tag = xor(this._ghash.final(this._alen * 8, this._len * 8), this._cipher.encryptBlock(this._finID))
2425 if (this._decrypt && xorTest(tag, this._authTag)) throw new Error('Unsupported state or unable to authenticate data')
2426
2427 this._authTag = tag
2428 this._cipher.scrub()
2429}
2430
2431StreamCipher.prototype.getAuthTag = function getAuthTag () {
2432 if (this._decrypt || !Buffer.isBuffer(this._authTag)) throw new Error('Attempting to get auth tag in unsupported state')
2433
2434 return this._authTag
2435}
2436
2437StreamCipher.prototype.setAuthTag = function setAuthTag (tag) {
2438 if (!this._decrypt) throw new Error('Attempting to set auth tag in unsupported state')
2439
2440 this._authTag = tag
2441}
2442
2443StreamCipher.prototype.setAAD = function setAAD (buf) {
2444 if (this._called) throw new Error('Attempting to set AAD in unsupported state')
2445
2446 this._ghash.update(buf)
2447 this._alen += buf.length
2448}
2449
2450module.exports = StreamCipher
2451
2452},{"./aes":7,"./ghash":12,"./incr32":13,"buffer-xor":29,"cipher-base":31,"inherits":44,"safe-buffer":47}],9:[function(require,module,exports){
2453var ciphers = require('./encrypter')
2454var deciphers = require('./decrypter')
2455var modes = require('./modes/list.json')
2456
2457function getCiphers () {
2458 return Object.keys(modes)
2459}
2460
2461exports.createCipher = exports.Cipher = ciphers.createCipher
2462exports.createCipheriv = exports.Cipheriv = ciphers.createCipheriv
2463exports.createDecipher = exports.Decipher = deciphers.createDecipher
2464exports.createDecipheriv = exports.Decipheriv = deciphers.createDecipheriv
2465exports.listCiphers = exports.getCiphers = getCiphers
2466
2467},{"./decrypter":10,"./encrypter":11,"./modes/list.json":21}],10:[function(require,module,exports){
2468var AuthCipher = require('./authCipher')
2469var Buffer = require('safe-buffer').Buffer
2470var MODES = require('./modes')
2471var StreamCipher = require('./streamCipher')
2472var Transform = require('cipher-base')
2473var aes = require('./aes')
2474var ebtk = require('evp_bytestokey')
2475var inherits = require('inherits')
2476
2477function Decipher (mode, key, iv) {
2478 Transform.call(this)
2479
2480 this._cache = new Splitter()
2481 this._last = void 0
2482 this._cipher = new aes.AES(key)
2483 this._prev = Buffer.from(iv)
2484 this._mode = mode
2485 this._autopadding = true
2486}
2487
2488inherits(Decipher, Transform)
2489
2490Decipher.prototype._update = function (data) {
2491 this._cache.add(data)
2492 var chunk
2493 var thing
2494 var out = []
2495 while ((chunk = this._cache.get(this._autopadding))) {
2496 thing = this._mode.decrypt(this, chunk)
2497 out.push(thing)
2498 }
2499 return Buffer.concat(out)
2500}
2501
2502Decipher.prototype._final = function () {
2503 var chunk = this._cache.flush()
2504 if (this._autopadding) {
2505 return unpad(this._mode.decrypt(this, chunk))
2506 } else if (chunk) {
2507 throw new Error('data not multiple of block length')
2508 }
2509}
2510
2511Decipher.prototype.setAutoPadding = function (setTo) {
2512 this._autopadding = !!setTo
2513 return this
2514}
2515
2516function Splitter () {
2517 this.cache = Buffer.allocUnsafe(0)
2518}
2519
2520Splitter.prototype.add = function (data) {
2521 this.cache = Buffer.concat([this.cache, data])
2522}
2523
2524Splitter.prototype.get = function (autoPadding) {
2525 var out
2526 if (autoPadding) {
2527 if (this.cache.length > 16) {
2528 out = this.cache.slice(0, 16)
2529 this.cache = this.cache.slice(16)
2530 return out
2531 }
2532 } else {
2533 if (this.cache.length >= 16) {
2534 out = this.cache.slice(0, 16)
2535 this.cache = this.cache.slice(16)
2536 return out
2537 }
2538 }
2539
2540 return null
2541}
2542
2543Splitter.prototype.flush = function () {
2544 if (this.cache.length) return this.cache
2545}
2546
2547function unpad (last) {
2548 var padded = last[15]
2549 if (padded < 1 || padded > 16) {
2550 throw new Error('unable to decrypt data')
2551 }
2552 var i = -1
2553 while (++i < padded) {
2554 if (last[(i + (16 - padded))] !== padded) {
2555 throw new Error('unable to decrypt data')
2556 }
2557 }
2558 if (padded === 16) return
2559
2560 return last.slice(0, 16 - padded)
2561}
2562
2563function createDecipheriv (suite, password, iv) {
2564 var config = MODES[suite.toLowerCase()]
2565 if (!config) throw new TypeError('invalid suite type')
2566
2567 if (typeof iv === 'string') iv = Buffer.from(iv)
2568 if (config.mode !== 'GCM' && iv.length !== config.iv) throw new TypeError('invalid iv length ' + iv.length)
2569
2570 if (typeof password === 'string') password = Buffer.from(password)
2571 if (password.length !== config.key / 8) throw new TypeError('invalid key length ' + password.length)
2572
2573 if (config.type === 'stream') {
2574 return new StreamCipher(config.module, password, iv, true)
2575 } else if (config.type === 'auth') {
2576 return new AuthCipher(config.module, password, iv, true)
2577 }
2578
2579 return new Decipher(config.module, password, iv)
2580}
2581
2582function createDecipher (suite, password) {
2583 var config = MODES[suite.toLowerCase()]
2584 if (!config) throw new TypeError('invalid suite type')
2585
2586 var keys = ebtk(password, false, config.key, config.iv)
2587 return createDecipheriv(suite, keys.key, keys.iv)
2588}
2589
2590exports.createDecipher = createDecipher
2591exports.createDecipheriv = createDecipheriv
2592
2593},{"./aes":7,"./authCipher":8,"./modes":20,"./streamCipher":23,"cipher-base":31,"evp_bytestokey":38,"inherits":44,"safe-buffer":47}],11:[function(require,module,exports){
2594var MODES = require('./modes')
2595var AuthCipher = require('./authCipher')
2596var Buffer = require('safe-buffer').Buffer
2597var StreamCipher = require('./streamCipher')
2598var Transform = require('cipher-base')
2599var aes = require('./aes')
2600var ebtk = require('evp_bytestokey')
2601var inherits = require('inherits')
2602
2603function Cipher (mode, key, iv) {
2604 Transform.call(this)
2605
2606 this._cache = new Splitter()
2607 this._cipher = new aes.AES(key)
2608 this._prev = Buffer.from(iv)
2609 this._mode = mode
2610 this._autopadding = true
2611}
2612
2613inherits(Cipher, Transform)
2614
2615Cipher.prototype._update = function (data) {
2616 this._cache.add(data)
2617 var chunk
2618 var thing
2619 var out = []
2620
2621 while ((chunk = this._cache.get())) {
2622 thing = this._mode.encrypt(this, chunk)
2623 out.push(thing)
2624 }
2625
2626 return Buffer.concat(out)
2627}
2628
2629var PADDING = Buffer.alloc(16, 0x10)
2630
2631Cipher.prototype._final = function () {
2632 var chunk = this._cache.flush()
2633 if (this._autopadding) {
2634 chunk = this._mode.encrypt(this, chunk)
2635 this._cipher.scrub()
2636 return chunk
2637 }
2638
2639 if (!chunk.equals(PADDING)) {
2640 this._cipher.scrub()
2641 throw new Error('data not multiple of block length')
2642 }
2643}
2644
2645Cipher.prototype.setAutoPadding = function (setTo) {
2646 this._autopadding = !!setTo
2647 return this
2648}
2649
2650function Splitter () {
2651 this.cache = Buffer.allocUnsafe(0)
2652}
2653
2654Splitter.prototype.add = function (data) {
2655 this.cache = Buffer.concat([this.cache, data])
2656}
2657
2658Splitter.prototype.get = function () {
2659 if (this.cache.length > 15) {
2660 var out = this.cache.slice(0, 16)
2661 this.cache = this.cache.slice(16)
2662 return out
2663 }
2664 return null
2665}
2666
2667Splitter.prototype.flush = function () {
2668 var len = 16 - this.cache.length
2669 var padBuff = Buffer.allocUnsafe(len)
2670
2671 var i = -1
2672 while (++i < len) {
2673 padBuff.writeUInt8(len, i)
2674 }
2675
2676 return Buffer.concat([this.cache, padBuff])
2677}
2678
2679function createCipheriv (suite, password, iv) {
2680 var config = MODES[suite.toLowerCase()]
2681 if (!config) throw new TypeError('invalid suite type')
2682
2683 if (typeof password === 'string') password = Buffer.from(password)
2684 if (password.length !== config.key / 8) throw new TypeError('invalid key length ' + password.length)
2685
2686 if (typeof iv === 'string') iv = Buffer.from(iv)
2687 if (config.mode !== 'GCM' && iv.length !== config.iv) throw new TypeError('invalid iv length ' + iv.length)
2688
2689 if (config.type === 'stream') {
2690 return new StreamCipher(config.module, password, iv)
2691 } else if (config.type === 'auth') {
2692 return new AuthCipher(config.module, password, iv)
2693 }
2694
2695 return new Cipher(config.module, password, iv)
2696}
2697
2698function createCipher (suite, password) {
2699 var config = MODES[suite.toLowerCase()]
2700 if (!config) throw new TypeError('invalid suite type')
2701
2702 var keys = ebtk(password, false, config.key, config.iv)
2703 return createCipheriv(suite, keys.key, keys.iv)
2704}
2705
2706exports.createCipheriv = createCipheriv
2707exports.createCipher = createCipher
2708
2709},{"./aes":7,"./authCipher":8,"./modes":20,"./streamCipher":23,"cipher-base":31,"evp_bytestokey":38,"inherits":44,"safe-buffer":47}],12:[function(require,module,exports){
2710var Buffer = require('safe-buffer').Buffer
2711var ZEROES = Buffer.alloc(16, 0)
2712
2713function toArray (buf) {
2714 return [
2715 buf.readUInt32BE(0),
2716 buf.readUInt32BE(4),
2717 buf.readUInt32BE(8),
2718 buf.readUInt32BE(12)
2719 ]
2720}
2721
2722function fromArray (out) {
2723 var buf = Buffer.allocUnsafe(16)
2724 buf.writeUInt32BE(out[0] >>> 0, 0)
2725 buf.writeUInt32BE(out[1] >>> 0, 4)
2726 buf.writeUInt32BE(out[2] >>> 0, 8)
2727 buf.writeUInt32BE(out[3] >>> 0, 12)
2728 return buf
2729}
2730
2731function GHASH (key) {
2732 this.h = key
2733 this.state = Buffer.alloc(16, 0)
2734 this.cache = Buffer.allocUnsafe(0)
2735}
2736
2737// from http://bitwiseshiftleft.github.io/sjcl/doc/symbols/src/core_gcm.js.html
2738// by Juho Vähä-Herttua
2739GHASH.prototype.ghash = function (block) {
2740 var i = -1
2741 while (++i < block.length) {
2742 this.state[i] ^= block[i]
2743 }
2744 this._multiply()
2745}
2746
2747GHASH.prototype._multiply = function () {
2748 var Vi = toArray(this.h)
2749 var Zi = [0, 0, 0, 0]
2750 var j, xi, lsbVi
2751 var i = -1
2752 while (++i < 128) {
2753 xi = (this.state[~~(i / 8)] & (1 << (7 - (i % 8)))) !== 0
2754 if (xi) {
2755 // Z_i+1 = Z_i ^ V_i
2756 Zi[0] ^= Vi[0]
2757 Zi[1] ^= Vi[1]
2758 Zi[2] ^= Vi[2]
2759 Zi[3] ^= Vi[3]
2760 }
2761
2762 // Store the value of LSB(V_i)
2763 lsbVi = (Vi[3] & 1) !== 0
2764
2765 // V_i+1 = V_i >> 1
2766 for (j = 3; j > 0; j--) {
2767 Vi[j] = (Vi[j] >>> 1) | ((Vi[j - 1] & 1) << 31)
2768 }
2769 Vi[0] = Vi[0] >>> 1
2770
2771 // If LSB(V_i) is 1, V_i+1 = (V_i >> 1) ^ R
2772 if (lsbVi) {
2773 Vi[0] = Vi[0] ^ (0xe1 << 24)
2774 }
2775 }
2776 this.state = fromArray(Zi)
2777}
2778
2779GHASH.prototype.update = function (buf) {
2780 this.cache = Buffer.concat([this.cache, buf])
2781 var chunk
2782 while (this.cache.length >= 16) {
2783 chunk = this.cache.slice(0, 16)
2784 this.cache = this.cache.slice(16)
2785 this.ghash(chunk)
2786 }
2787}
2788
2789GHASH.prototype.final = function (abl, bl) {
2790 if (this.cache.length) {
2791 this.ghash(Buffer.concat([this.cache, ZEROES], 16))
2792 }
2793
2794 this.ghash(fromArray([0, abl, 0, bl]))
2795 return this.state
2796}
2797
2798module.exports = GHASH
2799
2800},{"safe-buffer":47}],13:[function(require,module,exports){
2801function incr32 (iv) {
2802 var len = iv.length
2803 var item
2804 while (len--) {
2805 item = iv.readUInt8(len)
2806 if (item === 255) {
2807 iv.writeUInt8(0, len)
2808 } else {
2809 item++
2810 iv.writeUInt8(item, len)
2811 break
2812 }
2813 }
2814}
2815module.exports = incr32
2816
2817},{}],14:[function(require,module,exports){
2818var xor = require('buffer-xor')
2819
2820exports.encrypt = function (self, block) {
2821 var data = xor(block, self._prev)
2822
2823 self._prev = self._cipher.encryptBlock(data)
2824 return self._prev
2825}
2826
2827exports.decrypt = function (self, block) {
2828 var pad = self._prev
2829
2830 self._prev = block
2831 var out = self._cipher.decryptBlock(block)
2832
2833 return xor(out, pad)
2834}
2835
2836},{"buffer-xor":29}],15:[function(require,module,exports){
2837var Buffer = require('safe-buffer').Buffer
2838var xor = require('buffer-xor')
2839
2840function encryptStart (self, data, decrypt) {
2841 var len = data.length
2842 var out = xor(data, self._cache)
2843 self._cache = self._cache.slice(len)
2844 self._prev = Buffer.concat([self._prev, decrypt ? data : out])
2845 return out
2846}
2847
2848exports.encrypt = function (self, data, decrypt) {
2849 var out = Buffer.allocUnsafe(0)
2850 var len
2851
2852 while (data.length) {
2853 if (self._cache.length === 0) {
2854 self._cache = self._cipher.encryptBlock(self._prev)
2855 self._prev = Buffer.allocUnsafe(0)
2856 }
2857
2858 if (self._cache.length <= data.length) {
2859 len = self._cache.length
2860 out = Buffer.concat([out, encryptStart(self, data.slice(0, len), decrypt)])
2861 data = data.slice(len)
2862 } else {
2863 out = Buffer.concat([out, encryptStart(self, data, decrypt)])
2864 break
2865 }
2866 }
2867
2868 return out
2869}
2870
2871},{"buffer-xor":29,"safe-buffer":47}],16:[function(require,module,exports){
2872var Buffer = require('safe-buffer').Buffer
2873
2874function encryptByte (self, byteParam, decrypt) {
2875 var pad
2876 var i = -1
2877 var len = 8
2878 var out = 0
2879 var bit, value
2880 while (++i < len) {
2881 pad = self._cipher.encryptBlock(self._prev)
2882 bit = (byteParam & (1 << (7 - i))) ? 0x80 : 0
2883 value = pad[0] ^ bit
2884 out += ((value & 0x80) >> (i % 8))
2885 self._prev = shiftIn(self._prev, decrypt ? bit : value)
2886 }
2887 return out
2888}
2889
2890function shiftIn (buffer, value) {
2891 var len = buffer.length
2892 var i = -1
2893 var out = Buffer.allocUnsafe(buffer.length)
2894 buffer = Buffer.concat([buffer, Buffer.from([value])])
2895
2896 while (++i < len) {
2897 out[i] = buffer[i] << 1 | buffer[i + 1] >> (7)
2898 }
2899
2900 return out
2901}
2902
2903exports.encrypt = function (self, chunk, decrypt) {
2904 var len = chunk.length
2905 var out = Buffer.allocUnsafe(len)
2906 var i = -1
2907
2908 while (++i < len) {
2909 out[i] = encryptByte(self, chunk[i], decrypt)
2910 }
2911
2912 return out
2913}
2914
2915},{"safe-buffer":47}],17:[function(require,module,exports){
2916var Buffer = require('safe-buffer').Buffer
2917
2918function encryptByte (self, byteParam, decrypt) {
2919 var pad = self._cipher.encryptBlock(self._prev)
2920 var out = pad[0] ^ byteParam
2921
2922 self._prev = Buffer.concat([
2923 self._prev.slice(1),
2924 Buffer.from([decrypt ? byteParam : out])
2925 ])
2926
2927 return out
2928}
2929
2930exports.encrypt = function (self, chunk, decrypt) {
2931 var len = chunk.length
2932 var out = Buffer.allocUnsafe(len)
2933 var i = -1
2934
2935 while (++i < len) {
2936 out[i] = encryptByte(self, chunk[i], decrypt)
2937 }
2938
2939 return out
2940}
2941
2942},{"safe-buffer":47}],18:[function(require,module,exports){
2943var xor = require('buffer-xor')
2944var Buffer = require('safe-buffer').Buffer
2945var incr32 = require('../incr32')
2946
2947function getBlock (self) {
2948 var out = self._cipher.encryptBlockRaw(self._prev)
2949 incr32(self._prev)
2950 return out
2951}
2952
2953var blockSize = 16
2954exports.encrypt = function (self, chunk) {
2955 var chunkNum = Math.ceil(chunk.length / blockSize)
2956 var start = self._cache.length
2957 self._cache = Buffer.concat([
2958 self._cache,
2959 Buffer.allocUnsafe(chunkNum * blockSize)
2960 ])
2961 for (var i = 0; i < chunkNum; i++) {
2962 var out = getBlock(self)
2963 var offset = start + i * blockSize
2964 self._cache.writeUInt32BE(out[0], offset + 0)
2965 self._cache.writeUInt32BE(out[1], offset + 4)
2966 self._cache.writeUInt32BE(out[2], offset + 8)
2967 self._cache.writeUInt32BE(out[3], offset + 12)
2968 }
2969 var pad = self._cache.slice(0, chunk.length)
2970 self._cache = self._cache.slice(chunk.length)
2971 return xor(chunk, pad)
2972}
2973
2974},{"../incr32":13,"buffer-xor":29,"safe-buffer":47}],19:[function(require,module,exports){
2975exports.encrypt = function (self, block) {
2976 return self._cipher.encryptBlock(block)
2977}
2978
2979exports.decrypt = function (self, block) {
2980 return self._cipher.decryptBlock(block)
2981}
2982
2983},{}],20:[function(require,module,exports){
2984var modeModules = {
2985 ECB: require('./ecb'),
2986 CBC: require('./cbc'),
2987 CFB: require('./cfb'),
2988 CFB8: require('./cfb8'),
2989 CFB1: require('./cfb1'),
2990 OFB: require('./ofb'),
2991 CTR: require('./ctr'),
2992 GCM: require('./ctr')
2993}
2994
2995var modes = require('./list.json')
2996
2997for (var key in modes) {
2998 modes[key].module = modeModules[modes[key].mode]
2999}
3000
3001module.exports = modes
3002
3003},{"./cbc":14,"./cfb":15,"./cfb1":16,"./cfb8":17,"./ctr":18,"./ecb":19,"./list.json":21,"./ofb":22}],21:[function(require,module,exports){
3004module.exports={
3005 "aes-128-ecb": {
3006 "cipher": "AES",
3007 "key": 128,
3008 "iv": 0,
3009 "mode": "ECB",
3010 "type": "block"
3011 },
3012 "aes-192-ecb": {
3013 "cipher": "AES",
3014 "key": 192,
3015 "iv": 0,
3016 "mode": "ECB",
3017 "type": "block"
3018 },
3019 "aes-256-ecb": {
3020 "cipher": "AES",
3021 "key": 256,
3022 "iv": 0,
3023 "mode": "ECB",
3024 "type": "block"
3025 },
3026 "aes-128-cbc": {
3027 "cipher": "AES",
3028 "key": 128,
3029 "iv": 16,
3030 "mode": "CBC",
3031 "type": "block"
3032 },
3033 "aes-192-cbc": {
3034 "cipher": "AES",
3035 "key": 192,
3036 "iv": 16,
3037 "mode": "CBC",
3038 "type": "block"
3039 },
3040 "aes-256-cbc": {
3041 "cipher": "AES",
3042 "key": 256,
3043 "iv": 16,
3044 "mode": "CBC",
3045 "type": "block"
3046 },
3047 "aes128": {
3048 "cipher": "AES",
3049 "key": 128,
3050 "iv": 16,
3051 "mode": "CBC",
3052 "type": "block"
3053 },
3054 "aes192": {
3055 "cipher": "AES",
3056 "key": 192,
3057 "iv": 16,
3058 "mode": "CBC",
3059 "type": "block"
3060 },
3061 "aes256": {
3062 "cipher": "AES",
3063 "key": 256,
3064 "iv": 16,
3065 "mode": "CBC",
3066 "type": "block"
3067 },
3068 "aes-128-cfb": {
3069 "cipher": "AES",
3070 "key": 128,
3071 "iv": 16,
3072 "mode": "CFB",
3073 "type": "stream"
3074 },
3075 "aes-192-cfb": {
3076 "cipher": "AES",
3077 "key": 192,
3078 "iv": 16,
3079 "mode": "CFB",
3080 "type": "stream"
3081 },
3082 "aes-256-cfb": {
3083 "cipher": "AES",
3084 "key": 256,
3085 "iv": 16,
3086 "mode": "CFB",
3087 "type": "stream"
3088 },
3089 "aes-128-cfb8": {
3090 "cipher": "AES",
3091 "key": 128,
3092 "iv": 16,
3093 "mode": "CFB8",
3094 "type": "stream"
3095 },
3096 "aes-192-cfb8": {
3097 "cipher": "AES",
3098 "key": 192,
3099 "iv": 16,
3100 "mode": "CFB8",
3101 "type": "stream"
3102 },
3103 "aes-256-cfb8": {
3104 "cipher": "AES",
3105 "key": 256,
3106 "iv": 16,
3107 "mode": "CFB8",
3108 "type": "stream"
3109 },
3110 "aes-128-cfb1": {
3111 "cipher": "AES",
3112 "key": 128,
3113 "iv": 16,
3114 "mode": "CFB1",
3115 "type": "stream"
3116 },
3117 "aes-192-cfb1": {
3118 "cipher": "AES",
3119 "key": 192,
3120 "iv": 16,
3121 "mode": "CFB1",
3122 "type": "stream"
3123 },
3124 "aes-256-cfb1": {
3125 "cipher": "AES",
3126 "key": 256,
3127 "iv": 16,
3128 "mode": "CFB1",
3129 "type": "stream"
3130 },
3131 "aes-128-ofb": {
3132 "cipher": "AES",
3133 "key": 128,
3134 "iv": 16,
3135 "mode": "OFB",
3136 "type": "stream"
3137 },
3138 "aes-192-ofb": {
3139 "cipher": "AES",
3140 "key": 192,
3141 "iv": 16,
3142 "mode": "OFB",
3143 "type": "stream"
3144 },
3145 "aes-256-ofb": {
3146 "cipher": "AES",
3147 "key": 256,
3148 "iv": 16,
3149 "mode": "OFB",
3150 "type": "stream"
3151 },
3152 "aes-128-ctr": {
3153 "cipher": "AES",
3154 "key": 128,
3155 "iv": 16,
3156 "mode": "CTR",
3157 "type": "stream"
3158 },
3159 "aes-192-ctr": {
3160 "cipher": "AES",
3161 "key": 192,
3162 "iv": 16,
3163 "mode": "CTR",
3164 "type": "stream"
3165 },
3166 "aes-256-ctr": {
3167 "cipher": "AES",
3168 "key": 256,
3169 "iv": 16,
3170 "mode": "CTR",
3171 "type": "stream"
3172 },
3173 "aes-128-gcm": {
3174 "cipher": "AES",
3175 "key": 128,
3176 "iv": 12,
3177 "mode": "GCM",
3178 "type": "auth"
3179 },
3180 "aes-192-gcm": {
3181 "cipher": "AES",
3182 "key": 192,
3183 "iv": 12,
3184 "mode": "GCM",
3185 "type": "auth"
3186 },
3187 "aes-256-gcm": {
3188 "cipher": "AES",
3189 "key": 256,
3190 "iv": 12,
3191 "mode": "GCM",
3192 "type": "auth"
3193 }
3194}
3195
3196},{}],22:[function(require,module,exports){
3197(function (Buffer){
3198var xor = require('buffer-xor')
3199
3200function getBlock (self) {
3201 self._prev = self._cipher.encryptBlock(self._prev)
3202 return self._prev
3203}
3204
3205exports.encrypt = function (self, chunk) {
3206 while (self._cache.length < chunk.length) {
3207 self._cache = Buffer.concat([self._cache, getBlock(self)])
3208 }
3209
3210 var pad = self._cache.slice(0, chunk.length)
3211 self._cache = self._cache.slice(chunk.length)
3212 return xor(chunk, pad)
3213}
3214
3215}).call(this,require("buffer").Buffer)
3216},{"buffer":110,"buffer-xor":29}],23:[function(require,module,exports){
3217var aes = require('./aes')
3218var Buffer = require('safe-buffer').Buffer
3219var Transform = require('cipher-base')
3220var inherits = require('inherits')
3221
3222function StreamCipher (mode, key, iv, decrypt) {
3223 Transform.call(this)
3224
3225 this._cipher = new aes.AES(key)
3226 this._prev = Buffer.from(iv)
3227 this._cache = Buffer.allocUnsafe(0)
3228 this._secCache = Buffer.allocUnsafe(0)
3229 this._decrypt = decrypt
3230 this._mode = mode
3231}
3232
3233inherits(StreamCipher, Transform)
3234
3235StreamCipher.prototype._update = function (chunk) {
3236 return this._mode.encrypt(this, chunk, this._decrypt)
3237}
3238
3239StreamCipher.prototype._final = function () {
3240 this._cipher.scrub()
3241}
3242
3243module.exports = StreamCipher
3244
3245},{"./aes":7,"cipher-base":31,"inherits":44,"safe-buffer":47}],24:[function(require,module,exports){
3246var basex = require('base-x')
3247var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
3248
3249module.exports = basex(ALPHABET)
3250
3251},{"base-x":2}],25:[function(require,module,exports){
3252'use strict'
3253
3254var base58 = require('bs58')
3255var Buffer = require('safe-buffer').Buffer
3256
3257module.exports = function (checksumFn) {
3258 // Encode a buffer as a base58-check encoded string
3259 function encode (payload) {
3260 var checksum = checksumFn(payload)
3261
3262 return base58.encode(Buffer.concat([
3263 payload,
3264 checksum
3265 ], payload.length + 4))
3266 }
3267
3268 function decodeRaw (buffer) {
3269 var payload = buffer.slice(0, -4)
3270 var checksum = buffer.slice(-4)
3271 var newChecksum = checksumFn(payload)
3272
3273 if (checksum[0] ^ newChecksum[0] |
3274 checksum[1] ^ newChecksum[1] |
3275 checksum[2] ^ newChecksum[2] |
3276 checksum[3] ^ newChecksum[3]) return
3277
3278 return payload
3279 }
3280
3281 // Decode a base58-check encoded string to a buffer, no result if checksum is wrong
3282 function decodeUnsafe (string) {
3283 var buffer = base58.decodeUnsafe(string)
3284 if (!buffer) return
3285
3286 return decodeRaw(buffer)
3287 }
3288
3289 function decode (string) {
3290 var buffer = base58.decode(string)
3291 var payload = decodeRaw(buffer, checksumFn)
3292 if (!payload) throw new Error('Invalid checksum')
3293 return payload
3294 }
3295
3296 return {
3297 encode: encode,
3298 decode: decode,
3299 decodeUnsafe: decodeUnsafe
3300 }
3301}
3302
3303},{"bs58":24,"safe-buffer":47}],26:[function(require,module,exports){
3304'use strict'
3305
3306var createHash = require('create-hash')
3307var bs58checkBase = require('./base')
3308
3309// SHA256(SHA256(buffer))
3310function sha256x2 (buffer) {
3311 var tmp = createHash('sha256').update(buffer).digest()
3312 return createHash('sha256').update(tmp).digest()
3313}
3314
3315module.exports = bs58checkBase(sha256x2)
3316
3317},{"./base":25,"create-hash":32}],27:[function(require,module,exports){
3318arguments[4][25][0].apply(exports,arguments)
3319},{"bs58":24,"dup":25,"safe-buffer":47}],28:[function(require,module,exports){
3320(function (Buffer){
3321'use strict'
3322
3323var createHash = require('create-hash')
3324var bs58grscheckBase = require('./base')
3325var groestlhash = require('groestl-hash-js')
3326
3327// GROESTL512(GROESTL512(buffer))
3328function groestl (buffer) {
3329 return Buffer(groestlhash.groestl_2(buffer, 1, 1))
3330}
3331
3332module.exports = bs58grscheckBase(groestl)
3333
3334}).call(this,require("buffer").Buffer)
3335},{"./base":27,"buffer":110,"create-hash":32,"groestl-hash-js":39}],29:[function(require,module,exports){
3336(function (Buffer){
3337module.exports = function xor (a, b) {
3338 var length = Math.min(a.length, b.length)
3339 var buffer = new Buffer(length)
3340
3341 for (var i = 0; i < length; ++i) {
3342 buffer[i] = a[i] ^ b[i]
3343 }
3344
3345 return buffer
3346}
3347
3348}).call(this,require("buffer").Buffer)
3349},{"buffer":110}],30:[function(require,module,exports){
3350module.exports = function xorInplace (a, b) {
3351 var length = Math.min(a.length, b.length)
3352
3353 for (var i = 0; i < length; ++i) {
3354 a[i] = a[i] ^ b[i]
3355 }
3356
3357 return a.slice(0, length)
3358}
3359
3360},{}],31:[function(require,module,exports){
3361var Buffer = require('safe-buffer').Buffer
3362var Transform = require('stream').Transform
3363var StringDecoder = require('string_decoder').StringDecoder
3364var inherits = require('inherits')
3365
3366function CipherBase (hashMode) {
3367 Transform.call(this)
3368 this.hashMode = typeof hashMode === 'string'
3369 if (this.hashMode) {
3370 this[hashMode] = this._finalOrDigest
3371 } else {
3372 this.final = this._finalOrDigest
3373 }
3374 if (this._final) {
3375 this.__final = this._final
3376 this._final = null
3377 }
3378 this._decoder = null
3379 this._encoding = null
3380}
3381inherits(CipherBase, Transform)
3382
3383CipherBase.prototype.update = function (data, inputEnc, outputEnc) {
3384 if (typeof data === 'string') {
3385 data = Buffer.from(data, inputEnc)
3386 }
3387
3388 var outData = this._update(data)
3389 if (this.hashMode) return this
3390
3391 if (outputEnc) {
3392 outData = this._toString(outData, outputEnc)
3393 }
3394
3395 return outData
3396}
3397
3398CipherBase.prototype.setAutoPadding = function () {}
3399CipherBase.prototype.getAuthTag = function () {
3400 throw new Error('trying to get auth tag in unsupported state')
3401}
3402
3403CipherBase.prototype.setAuthTag = function () {
3404 throw new Error('trying to set auth tag in unsupported state')
3405}
3406
3407CipherBase.prototype.setAAD = function () {
3408 throw new Error('trying to set aad in unsupported state')
3409}
3410
3411CipherBase.prototype._transform = function (data, _, next) {
3412 var err
3413 try {
3414 if (this.hashMode) {
3415 this._update(data)
3416 } else {
3417 this.push(this._update(data))
3418 }
3419 } catch (e) {
3420 err = e
3421 } finally {
3422 next(err)
3423 }
3424}
3425CipherBase.prototype._flush = function (done) {
3426 var err
3427 try {
3428 this.push(this.__final())
3429 } catch (e) {
3430 err = e
3431 }
3432
3433 done(err)
3434}
3435CipherBase.prototype._finalOrDigest = function (outputEnc) {
3436 var outData = this.__final() || Buffer.alloc(0)
3437 if (outputEnc) {
3438 outData = this._toString(outData, outputEnc, true)
3439 }
3440 return outData
3441}
3442
3443CipherBase.prototype._toString = function (value, enc, fin) {
3444 if (!this._decoder) {
3445 this._decoder = new StringDecoder(enc)
3446 this._encoding = enc
3447 }
3448
3449 if (this._encoding !== enc) throw new Error('can\'t switch encodings')
3450
3451 var out = this._decoder.write(value)
3452 if (fin) {
3453 out += this._decoder.end()
3454 }
3455
3456 return out
3457}
3458
3459module.exports = CipherBase
3460
3461},{"inherits":44,"safe-buffer":47,"stream":215,"string_decoder":216}],32:[function(require,module,exports){
3462'use strict'
3463var inherits = require('inherits')
3464var MD5 = require('md5.js')
3465var RIPEMD160 = require('ripemd160')
3466var sha = require('sha.js')
3467var Base = require('cipher-base')
3468
3469function Hash (hash) {
3470 Base.call(this, 'digest')
3471
3472 this._hash = hash
3473}
3474
3475inherits(Hash, Base)
3476
3477Hash.prototype._update = function (data) {
3478 this._hash.update(data)
3479}
3480
3481Hash.prototype._final = function () {
3482 return this._hash.digest()
3483}
3484
3485module.exports = function createHash (alg) {
3486 alg = alg.toLowerCase()
3487 if (alg === 'md5') return new MD5()
3488 if (alg === 'rmd160' || alg === 'ripemd160') return new RIPEMD160()
3489
3490 return new Hash(sha(alg))
3491}
3492
3493},{"cipher-base":31,"inherits":44,"md5.js":45,"ripemd160":46,"sha.js":53}],33:[function(require,module,exports){
3494var assert = require('assert')
3495var BigInteger = require('bigi')
3496
3497var Point = require('./point')
3498
3499function Curve (p, a, b, Gx, Gy, n, h) {
3500 this.p = p
3501 this.a = a
3502 this.b = b
3503 this.G = Point.fromAffine(this, Gx, Gy)
3504 this.n = n
3505 this.h = h
3506
3507 this.infinity = new Point(this, null, null, BigInteger.ZERO)
3508
3509 // result caching
3510 this.pOverFour = p.add(BigInteger.ONE).shiftRight(2)
3511
3512 // determine size of p in bytes
3513 this.pLength = Math.floor((this.p.bitLength() + 7) / 8)
3514}
3515
3516Curve.prototype.pointFromX = function (isOdd, x) {
3517 var alpha = x.pow(3).add(this.a.multiply(x)).add(this.b).mod(this.p)
3518 var beta = alpha.modPow(this.pOverFour, this.p) // XXX: not compatible with all curves
3519
3520 var y = beta
3521 if (beta.isEven() ^ !isOdd) {
3522 y = this.p.subtract(y) // -y % p
3523 }
3524
3525 return Point.fromAffine(this, x, y)
3526}
3527
3528Curve.prototype.isInfinity = function (Q) {
3529 if (Q === this.infinity) return true
3530
3531 return Q.z.signum() === 0 && Q.y.signum() !== 0
3532}
3533
3534Curve.prototype.isOnCurve = function (Q) {
3535 if (this.isInfinity(Q)) return true
3536
3537 var x = Q.affineX
3538 var y = Q.affineY
3539 var a = this.a
3540 var b = this.b
3541 var p = this.p
3542
3543 // Check that xQ and yQ are integers in the interval [0, p - 1]
3544 if (x.signum() < 0 || x.compareTo(p) >= 0) return false
3545 if (y.signum() < 0 || y.compareTo(p) >= 0) return false
3546
3547 // and check that y^2 = x^3 + ax + b (mod p)
3548 var lhs = y.square().mod(p)
3549 var rhs = x.pow(3).add(a.multiply(x)).add(b).mod(p)
3550 return lhs.equals(rhs)
3551}
3552
3553/**
3554 * Validate an elliptic curve point.
3555 *
3556 * See SEC 1, section 3.2.2.1: Elliptic Curve Public Key Validation Primitive
3557 */
3558Curve.prototype.validate = function (Q) {
3559 // Check Q != O
3560 assert(!this.isInfinity(Q), 'Point is at infinity')
3561 assert(this.isOnCurve(Q), 'Point is not on the curve')
3562
3563 // Check nQ = O (where Q is a scalar multiple of G)
3564 var nQ = Q.multiply(this.n)
3565 assert(this.isInfinity(nQ), 'Point is not a scalar multiple of G')
3566
3567 return true
3568}
3569
3570module.exports = Curve
3571
3572},{"./point":37,"assert":74,"bigi":5}],34:[function(require,module,exports){
3573module.exports={
3574 "secp128r1": {
3575 "p": "fffffffdffffffffffffffffffffffff",
3576 "a": "fffffffdfffffffffffffffffffffffc",
3577 "b": "e87579c11079f43dd824993c2cee5ed3",
3578 "n": "fffffffe0000000075a30d1b9038a115",
3579 "h": "01",
3580 "Gx": "161ff7528b899b2d0c28607ca52c5b86",
3581 "Gy": "cf5ac8395bafeb13c02da292dded7a83"
3582 },
3583 "secp160k1": {
3584 "p": "fffffffffffffffffffffffffffffffeffffac73",
3585 "a": "00",
3586 "b": "07",
3587 "n": "0100000000000000000001b8fa16dfab9aca16b6b3",
3588 "h": "01",
3589 "Gx": "3b4c382ce37aa192a4019e763036f4f5dd4d7ebb",
3590 "Gy": "938cf935318fdced6bc28286531733c3f03c4fee"
3591 },
3592 "secp160r1": {
3593 "p": "ffffffffffffffffffffffffffffffff7fffffff",
3594 "a": "ffffffffffffffffffffffffffffffff7ffffffc",
3595 "b": "1c97befc54bd7a8b65acf89f81d4d4adc565fa45",
3596 "n": "0100000000000000000001f4c8f927aed3ca752257",
3597 "h": "01",
3598 "Gx": "4a96b5688ef573284664698968c38bb913cbfc82",
3599 "Gy": "23a628553168947d59dcc912042351377ac5fb32"
3600 },
3601 "secp192k1": {
3602 "p": "fffffffffffffffffffffffffffffffffffffffeffffee37",
3603 "a": "00",
3604 "b": "03",
3605 "n": "fffffffffffffffffffffffe26f2fc170f69466a74defd8d",
3606 "h": "01",
3607 "Gx": "db4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d",
3608 "Gy": "9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d"
3609 },
3610 "secp192r1": {
3611 "p": "fffffffffffffffffffffffffffffffeffffffffffffffff",
3612 "a": "fffffffffffffffffffffffffffffffefffffffffffffffc",
3613 "b": "64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1",
3614 "n": "ffffffffffffffffffffffff99def836146bc9b1b4d22831",
3615 "h": "01",
3616 "Gx": "188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012",
3617 "Gy": "07192b95ffc8da78631011ed6b24cdd573f977a11e794811"
3618 },
3619 "secp256k1": {
3620 "p": "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",
3621 "a": "00",
3622 "b": "07",
3623 "n": "fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",
3624 "h": "01",
3625 "Gx": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
3626 "Gy": "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"
3627 },
3628 "secp256r1": {
3629 "p": "ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",
3630 "a": "ffffffff00000001000000000000000000000000fffffffffffffffffffffffc",
3631 "b": "5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b",
3632 "n": "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",
3633 "h": "01",
3634 "Gx": "6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296",
3635 "Gy": "4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"
3636 }
3637}
3638
3639},{}],35:[function(require,module,exports){
3640var Point = require('./point')
3641var Curve = require('./curve')
3642
3643var getCurveByName = require('./names')
3644
3645module.exports = {
3646 Curve: Curve,
3647 Point: Point,
3648 getCurveByName: getCurveByName
3649}
3650
3651},{"./curve":33,"./names":36,"./point":37}],36:[function(require,module,exports){
3652var BigInteger = require('bigi')
3653
3654var curves = require('./curves.json')
3655var Curve = require('./curve')
3656
3657function getCurveByName (name) {
3658 var curve = curves[name]
3659 if (!curve) return null
3660
3661 var p = new BigInteger(curve.p, 16)
3662 var a = new BigInteger(curve.a, 16)
3663 var b = new BigInteger(curve.b, 16)
3664 var n = new BigInteger(curve.n, 16)
3665 var h = new BigInteger(curve.h, 16)
3666 var Gx = new BigInteger(curve.Gx, 16)
3667 var Gy = new BigInteger(curve.Gy, 16)
3668
3669 return new Curve(p, a, b, Gx, Gy, n, h)
3670}
3671
3672module.exports = getCurveByName
3673
3674},{"./curve":33,"./curves.json":34,"bigi":5}],37:[function(require,module,exports){
3675var assert = require('assert')
3676var Buffer = require('safe-buffer').Buffer
3677var BigInteger = require('bigi')
3678
3679var THREE = BigInteger.valueOf(3)
3680
3681function Point (curve, x, y, z) {
3682 assert.notStrictEqual(z, undefined, 'Missing Z coordinate')
3683
3684 this.curve = curve
3685 this.x = x
3686 this.y = y
3687 this.z = z
3688 this._zInv = null
3689
3690 this.compressed = true
3691}
3692
3693Object.defineProperty(Point.prototype, 'zInv', {
3694 get: function () {
3695 if (this._zInv === null) {
3696 this._zInv = this.z.modInverse(this.curve.p)
3697 }
3698
3699 return this._zInv
3700 }
3701})
3702
3703Object.defineProperty(Point.prototype, 'affineX', {
3704 get: function () {
3705 return this.x.multiply(this.zInv).mod(this.curve.p)
3706 }
3707})
3708
3709Object.defineProperty(Point.prototype, 'affineY', {
3710 get: function () {
3711 return this.y.multiply(this.zInv).mod(this.curve.p)
3712 }
3713})
3714
3715Point.fromAffine = function (curve, x, y) {
3716 return new Point(curve, x, y, BigInteger.ONE)
3717}
3718
3719Point.prototype.equals = function (other) {
3720 if (other === this) return true
3721 if (this.curve.isInfinity(this)) return this.curve.isInfinity(other)
3722 if (this.curve.isInfinity(other)) return this.curve.isInfinity(this)
3723
3724 // u = Y2 * Z1 - Y1 * Z2
3725 var u = other.y.multiply(this.z).subtract(this.y.multiply(other.z)).mod(this.curve.p)
3726
3727 if (u.signum() !== 0) return false
3728
3729 // v = X2 * Z1 - X1 * Z2
3730 var v = other.x.multiply(this.z).subtract(this.x.multiply(other.z)).mod(this.curve.p)
3731
3732 return v.signum() === 0
3733}
3734
3735Point.prototype.negate = function () {
3736 var y = this.curve.p.subtract(this.y)
3737
3738 return new Point(this.curve, this.x, y, this.z)
3739}
3740
3741Point.prototype.add = function (b) {
3742 if (this.curve.isInfinity(this)) return b
3743 if (this.curve.isInfinity(b)) return this
3744
3745 var x1 = this.x
3746 var y1 = this.y
3747 var x2 = b.x
3748 var y2 = b.y
3749
3750 // u = Y2 * Z1 - Y1 * Z2
3751 var u = y2.multiply(this.z).subtract(y1.multiply(b.z)).mod(this.curve.p)
3752 // v = X2 * Z1 - X1 * Z2
3753 var v = x2.multiply(this.z).subtract(x1.multiply(b.z)).mod(this.curve.p)
3754
3755 if (v.signum() === 0) {
3756 if (u.signum() === 0) {
3757 return this.twice() // this == b, so double
3758 }
3759
3760 return this.curve.infinity // this = -b, so infinity
3761 }
3762
3763 var v2 = v.square()
3764 var v3 = v2.multiply(v)
3765 var x1v2 = x1.multiply(v2)
3766 var zu2 = u.square().multiply(this.z)
3767
3768 // x3 = v * (z2 * (z1 * u^2 - 2 * x1 * v^2) - v^3)
3769 var x3 = zu2.subtract(x1v2.shiftLeft(1)).multiply(b.z).subtract(v3).multiply(v).mod(this.curve.p)
3770 // y3 = z2 * (3 * x1 * u * v^2 - y1 * v^3 - z1 * u^3) + u * v^3
3771 var y3 = x1v2.multiply(THREE).multiply(u).subtract(y1.multiply(v3)).subtract(zu2.multiply(u)).multiply(b.z).add(u.multiply(v3)).mod(this.curve.p)
3772 // z3 = v^3 * z1 * z2
3773 var z3 = v3.multiply(this.z).multiply(b.z).mod(this.curve.p)
3774
3775 return new Point(this.curve, x3, y3, z3)
3776}
3777
3778Point.prototype.twice = function () {
3779 if (this.curve.isInfinity(this)) return this
3780 if (this.y.signum() === 0) return this.curve.infinity
3781
3782 var x1 = this.x
3783 var y1 = this.y
3784
3785 var y1z1 = y1.multiply(this.z).mod(this.curve.p)
3786 var y1sqz1 = y1z1.multiply(y1).mod(this.curve.p)
3787 var a = this.curve.a
3788
3789 // w = 3 * x1^2 + a * z1^2
3790 var w = x1.square().multiply(THREE)
3791
3792 if (a.signum() !== 0) {
3793 w = w.add(this.z.square().multiply(a))
3794 }
3795
3796 w = w.mod(this.curve.p)
3797 // x3 = 2 * y1 * z1 * (w^2 - 8 * x1 * y1^2 * z1)
3798 var x3 = w.square().subtract(x1.shiftLeft(3).multiply(y1sqz1)).shiftLeft(1).multiply(y1z1).mod(this.curve.p)
3799 // y3 = 4 * y1^2 * z1 * (3 * w * x1 - 2 * y1^2 * z1) - w^3
3800 var y3 = w.multiply(THREE).multiply(x1).subtract(y1sqz1.shiftLeft(1)).shiftLeft(2).multiply(y1sqz1).subtract(w.pow(3)).mod(this.curve.p)
3801 // z3 = 8 * (y1 * z1)^3
3802 var z3 = y1z1.pow(3).shiftLeft(3).mod(this.curve.p)
3803
3804 return new Point(this.curve, x3, y3, z3)
3805}
3806
3807// Simple NAF (Non-Adjacent Form) multiplication algorithm
3808// TODO: modularize the multiplication algorithm
3809Point.prototype.multiply = function (k) {
3810 if (this.curve.isInfinity(this)) return this
3811 if (k.signum() === 0) return this.curve.infinity
3812
3813 var e = k
3814 var h = e.multiply(THREE)
3815
3816 var neg = this.negate()
3817 var R = this
3818
3819 for (var i = h.bitLength() - 2; i > 0; --i) {
3820 var hBit = h.testBit(i)
3821 var eBit = e.testBit(i)
3822
3823 R = R.twice()
3824
3825 if (hBit !== eBit) {
3826 R = R.add(hBit ? this : neg)
3827 }
3828 }
3829
3830 return R
3831}
3832
3833// Compute this*j + x*k (simultaneous multiplication)
3834Point.prototype.multiplyTwo = function (j, x, k) {
3835 var i = Math.max(j.bitLength(), k.bitLength()) - 1
3836 var R = this.curve.infinity
3837 var both = this.add(x)
3838
3839 while (i >= 0) {
3840 var jBit = j.testBit(i)
3841 var kBit = k.testBit(i)
3842
3843 R = R.twice()
3844
3845 if (jBit) {
3846 if (kBit) {
3847 R = R.add(both)
3848 } else {
3849 R = R.add(this)
3850 }
3851 } else if (kBit) {
3852 R = R.add(x)
3853 }
3854 --i
3855 }
3856
3857 return R
3858}
3859
3860Point.prototype.getEncoded = function (compressed) {
3861 if (compressed == null) compressed = this.compressed
3862 if (this.curve.isInfinity(this)) return Buffer.alloc(1, 0) // Infinity point encoded is simply '00'
3863
3864 var x = this.affineX
3865 var y = this.affineY
3866 var byteLength = this.curve.pLength
3867 var buffer
3868
3869 // 0x02/0x03 | X
3870 if (compressed) {
3871 buffer = Buffer.allocUnsafe(1 + byteLength)
3872 buffer.writeUInt8(y.isEven() ? 0x02 : 0x03, 0)
3873
3874 // 0x04 | X | Y
3875 } else {
3876 buffer = Buffer.allocUnsafe(1 + byteLength + byteLength)
3877 buffer.writeUInt8(0x04, 0)
3878
3879 y.toBuffer(byteLength).copy(buffer, 1 + byteLength)
3880 }
3881
3882 x.toBuffer(byteLength).copy(buffer, 1)
3883
3884 return buffer
3885}
3886
3887Point.decodeFrom = function (curve, buffer) {
3888 var type = buffer.readUInt8(0)
3889 var compressed = (type !== 4)
3890
3891 var byteLength = Math.floor((curve.p.bitLength() + 7) / 8)
3892 var x = BigInteger.fromBuffer(buffer.slice(1, 1 + byteLength))
3893
3894 var Q
3895 if (compressed) {
3896 assert.equal(buffer.length, byteLength + 1, 'Invalid sequence length')
3897 assert(type === 0x02 || type === 0x03, 'Invalid sequence tag')
3898
3899 var isOdd = (type === 0x03)
3900 Q = curve.pointFromX(isOdd, x)
3901 } else {
3902 assert.equal(buffer.length, 1 + byteLength + byteLength, 'Invalid sequence length')
3903
3904 var y = BigInteger.fromBuffer(buffer.slice(1 + byteLength))
3905 Q = Point.fromAffine(curve, x, y)
3906 }
3907
3908 Q.compressed = compressed
3909 return Q
3910}
3911
3912Point.prototype.toString = function () {
3913 if (this.curve.isInfinity(this)) return '(INFINITY)'
3914
3915 return '(' + this.affineX.toString() + ',' + this.affineY.toString() + ')'
3916}
3917
3918module.exports = Point
3919
3920},{"assert":74,"bigi":5,"safe-buffer":47}],38:[function(require,module,exports){
3921var Buffer = require('safe-buffer').Buffer
3922var MD5 = require('md5.js')
3923
3924/* eslint-disable camelcase */
3925function EVP_BytesToKey (password, salt, keyBits, ivLen) {
3926 if (!Buffer.isBuffer(password)) password = Buffer.from(password, 'binary')
3927 if (salt) {
3928 if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, 'binary')
3929 if (salt.length !== 8) throw new RangeError('salt should be Buffer with 8 byte length')
3930 }
3931
3932 var keyLen = keyBits / 8
3933 var key = Buffer.alloc(keyLen)
3934 var iv = Buffer.alloc(ivLen || 0)
3935 var tmp = Buffer.alloc(0)
3936
3937 while (keyLen > 0 || ivLen > 0) {
3938 var hash = new MD5()
3939 hash.update(tmp)
3940 hash.update(password)
3941 if (salt) hash.update(salt)
3942 tmp = hash.digest()
3943
3944 var used = 0
3945
3946 if (keyLen > 0) {
3947 var keyStart = key.length - keyLen
3948 used = Math.min(keyLen, tmp.length)
3949 tmp.copy(key, keyStart, 0, used)
3950 keyLen -= used
3951 }
3952
3953 if (used < tmp.length && ivLen > 0) {
3954 var ivStart = iv.length - ivLen
3955 var length = Math.min(ivLen, tmp.length - used)
3956 tmp.copy(iv, ivStart, used, used + length)
3957 ivLen -= length
3958 }
3959 }
3960
3961 tmp.fill(0)
3962 return { key: key, iv: iv }
3963}
3964
3965module.exports = EVP_BytesToKey
3966
3967},{"md5.js":45,"safe-buffer":47}],39:[function(require,module,exports){
3968'use strict';
3969
3970var groestl = require('./lib/groestl');
3971var h = require('./lib/helper');
3972
3973var x11hash = module.exports;
3974
3975module.exports.groestl512 = function(str,format, output) {
3976 return groestl(str,format,output);
3977}
3978
3979module.exports.groestl = function(str,format, output) {
3980 var a = groestl(str,format,2);
3981 a = a.slice(0,8);
3982 if (output === 2) {
3983 return a;
3984 }
3985 else if (output === 1) {
3986 return h.int32Buffer2Bytes(a);
3987 }
3988 else {
3989 return h.int32ArrayToHexString(a);
3990 }
3991}
3992
3993module.exports.groestl_2 = function(str,format, output) {
3994 var a = groestl(str,format,2);
3995 a = groestl(a,2,2);
3996 a = a.slice(0,8);
3997 if (output === 2) {
3998 return a;
3999 }
4000 else if (output === 1) {
4001 return h.int32Buffer2Bytes(a);
4002 }
4003 else {
4004 return h.int32ArrayToHexString(a);
4005 }
4006}
4007},{"./lib/groestl":40,"./lib/helper":41}],40:[function(require,module,exports){
4008/////////////////////////////////////
4009//////////// groestl ///////////////
4010
4011//// Written by Quantum Explorer ////
4012////////// Dash Foundation //////////
4013/// Released under the MIT License //
4014/////////////////////////////////////
4015
4016var o = require('./op');
4017var h = require('./helper');
4018
4019var T0 = h.bytes2Int64Buffer(h.b64Decode("xjL0pfSXpcb4b5eEl+uE+O5esJmwx5nu9nqMjYz3jfb/6BcNF+UN/9YK3L3ct73W3hbIscinsd6RbfxU/DlUkWCQ8FDwwFBgAgcFAwUEAwLOLuCp4IepzlbRh32HrH1W58wrGSvVGee1E6ZipnFitU18MeYxmuZN7Fm1mrXDmuyPQM9FzwVFjx+jvJ28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DwwFBgb0AwED9QH39yo2EjY4EhwcPP6j/p+jwsKL4V/h1F9qar4Q+RBH+a6uAmvQa9LQaWm/qJGoLpEXF3HoWOgpWJmZU2knaXQnOjr30LnQTrknJ5FIOEipONnZ3jUTNc0T6+vlzrPOVrMrK3dVM1VEMyIiBNa71r+70tI5kHCQSXCpqYeAiYAOiQcHwfKn8manMzPswbbBWrYtLVpmImZ4Ijw8uK2SrSqSFRWpYCBgiSDJyVzbSdsVSYeHsBr/Gk//qqrYiHiIoHhQUCuOeo5ReqWliYqPigaPAwNKE/gTsvhZWZKbgJsSgAkJIzkXOTQXGhoQddp1ytplZYRTMVO1MdfX1VHGURPGhIQD07jTu7jQ0Nxew14fw4KC4suwy1KwKSnDmXeZtHdaWi0zETM8ER4ePUbLRvbLe3u3H/wfS/yoqAxh1mHa1m1tYk46Tlg6LCw="));
4027
4028// var T0 = [
4029// o.u(0xc632f4a5, 0xf497a5c6), o.u(0xf86f9784, 0x97eb84f8),
4030// o.u(0xee5eb099, 0xb0c799ee), o.u(0xf67a8c8d, 0x8cf78df6),
4031// o.u(0xffe8170d, 0x17e50dff), o.u(0xd60adcbd, 0xdcb7bdd6),
4032// o.u(0xde16c8b1, 0xc8a7b1de), o.u(0x916dfc54, 0xfc395491),
4033// o.u(0x6090f050, 0xf0c05060), o.u(0x02070503, 0x05040302),
4034// o.u(0xce2ee0a9, 0xe087a9ce), o.u(0x56d1877d, 0x87ac7d56),
4035// o.u(0xe7cc2b19, 0x2bd519e7), o.u(0xb513a662, 0xa67162b5),
4036// o.u(0x4d7c31e6, 0x319ae64d), o.u(0xec59b59a, 0xb5c39aec),
4037// o.u(0x8f40cf45, 0xcf05458f), o.u(0x1fa3bc9d, 0xbc3e9d1f),
4038// o.u(0x8949c040, 0xc0094089), o.u(0xfa689287, 0x92ef87fa),
4039// o.u(0xefd03f15, 0x3fc515ef), o.u(0xb29426eb, 0x267febb2),
4040// o.u(0x8ece40c9, 0x4007c98e), o.u(0xfbe61d0b, 0x1ded0bfb),
4041// o.u(0x416e2fec, 0x2f82ec41), o.u(0xb31aa967, 0xa97d67b3),
4042// o.u(0x5f431cfd, 0x1cbefd5f), o.u(0x456025ea, 0x258aea45),
4043// o.u(0x23f9dabf, 0xda46bf23), o.u(0x535102f7, 0x02a6f753),
4044// o.u(0xe445a196, 0xa1d396e4), o.u(0x9b76ed5b, 0xed2d5b9b),
4045// o.u(0x75285dc2, 0x5deac275), o.u(0xe1c5241c, 0x24d91ce1),
4046// o.u(0x3dd4e9ae, 0xe97aae3d), o.u(0x4cf2be6a, 0xbe986a4c),
4047// o.u(0x6c82ee5a, 0xeed85a6c), o.u(0x7ebdc341, 0xc3fc417e),
4048// o.u(0xf5f30602, 0x06f102f5), o.u(0x8352d14f, 0xd11d4f83),
4049// o.u(0x688ce45c, 0xe4d05c68), o.u(0x515607f4, 0x07a2f451),
4050// o.u(0xd18d5c34, 0x5cb934d1), o.u(0xf9e11808, 0x18e908f9),
4051// o.u(0xe24cae93, 0xaedf93e2), o.u(0xab3e9573, 0x954d73ab),
4052// o.u(0x6297f553, 0xf5c45362), o.u(0x2a6b413f, 0x41543f2a),
4053// o.u(0x081c140c, 0x14100c08), o.u(0x9563f652, 0xf6315295),
4054// o.u(0x46e9af65, 0xaf8c6546), o.u(0x9d7fe25e, 0xe2215e9d),
4055// o.u(0x30487828, 0x78602830), o.u(0x37cff8a1, 0xf86ea137),
4056// o.u(0x0a1b110f, 0x11140f0a), o.u(0x2febc4b5, 0xc45eb52f),
4057// o.u(0x0e151b09, 0x1b1c090e), o.u(0x247e5a36, 0x5a483624),
4058// o.u(0x1badb69b, 0xb6369b1b), o.u(0xdf98473d, 0x47a53ddf),
4059// o.u(0xcda76a26, 0x6a8126cd), o.u(0x4ef5bb69, 0xbb9c694e),
4060// o.u(0x7f334ccd, 0x4cfecd7f), o.u(0xea50ba9f, 0xbacf9fea),
4061// o.u(0x123f2d1b, 0x2d241b12), o.u(0x1da4b99e, 0xb93a9e1d),
4062// o.u(0x58c49c74, 0x9cb07458), o.u(0x3446722e, 0x72682e34),
4063// o.u(0x3641772d, 0x776c2d36), o.u(0xdc11cdb2, 0xcda3b2dc),
4064// o.u(0xb49d29ee, 0x2973eeb4), o.u(0x5b4d16fb, 0x16b6fb5b),
4065// o.u(0xa4a501f6, 0x0153f6a4), o.u(0x76a1d74d, 0xd7ec4d76),
4066// o.u(0xb714a361, 0xa37561b7), o.u(0x7d3449ce, 0x49face7d),
4067// o.u(0x52df8d7b, 0x8da47b52), o.u(0xdd9f423e, 0x42a13edd),
4068// o.u(0x5ecd9371, 0x93bc715e), o.u(0x13b1a297, 0xa2269713),
4069// o.u(0xa6a204f5, 0x0457f5a6), o.u(0xb901b868, 0xb86968b9),
4070// o.u(0x00000000, 0x00000000), o.u(0xc1b5742c, 0x74992cc1),
4071// o.u(0x40e0a060, 0xa0806040), o.u(0xe3c2211f, 0x21dd1fe3),
4072// o.u(0x793a43c8, 0x43f2c879), o.u(0xb69a2ced, 0x2c77edb6),
4073// o.u(0xd40dd9be, 0xd9b3bed4), o.u(0x8d47ca46, 0xca01468d),
4074// o.u(0x671770d9, 0x70ced967), o.u(0x72afdd4b, 0xdde44b72),
4075// o.u(0x94ed79de, 0x7933de94), o.u(0x98ff67d4, 0x672bd498),
4076// o.u(0xb09323e8, 0x237be8b0), o.u(0x855bde4a, 0xde114a85),
4077// o.u(0xbb06bd6b, 0xbd6d6bbb), o.u(0xc5bb7e2a, 0x7e912ac5),
4078// o.u(0x4f7b34e5, 0x349ee54f), o.u(0xedd73a16, 0x3ac116ed),
4079// o.u(0x86d254c5, 0x5417c586), o.u(0x9af862d7, 0x622fd79a),
4080// o.u(0x6699ff55, 0xffcc5566), o.u(0x11b6a794, 0xa7229411),
4081// o.u(0x8ac04acf, 0x4a0fcf8a), o.u(0xe9d93010, 0x30c910e9),
4082// o.u(0x040e0a06, 0x0a080604), o.u(0xfe669881, 0x98e781fe),
4083// o.u(0xa0ab0bf0, 0x0b5bf0a0), o.u(0x78b4cc44, 0xccf04478),
4084// o.u(0x25f0d5ba, 0xd54aba25), o.u(0x4b753ee3, 0x3e96e34b),
4085// o.u(0xa2ac0ef3, 0x0e5ff3a2), o.u(0x5d4419fe, 0x19bafe5d),
4086// o.u(0x80db5bc0, 0x5b1bc080), o.u(0x0580858a, 0x850a8a05),
4087// o.u(0x3fd3ecad, 0xec7ead3f), o.u(0x21fedfbc, 0xdf42bc21),
4088// o.u(0x70a8d848, 0xd8e04870), o.u(0xf1fd0c04, 0x0cf904f1),
4089// o.u(0x63197adf, 0x7ac6df63), o.u(0x772f58c1, 0x58eec177),
4090// o.u(0xaf309f75, 0x9f4575af), o.u(0x42e7a563, 0xa5846342),
4091// o.u(0x20705030, 0x50403020), o.u(0xe5cb2e1a, 0x2ed11ae5),
4092// o.u(0xfdef120e, 0x12e10efd), o.u(0xbf08b76d, 0xb7656dbf),
4093// o.u(0x8155d44c, 0xd4194c81), o.u(0x18243c14, 0x3c301418),
4094// o.u(0x26795f35, 0x5f4c3526), o.u(0xc3b2712f, 0x719d2fc3),
4095// o.u(0xbe8638e1, 0x3867e1be), o.u(0x35c8fda2, 0xfd6aa235),
4096// o.u(0x88c74fcc, 0x4f0bcc88), o.u(0x2e654b39, 0x4b5c392e),
4097// o.u(0x936af957, 0xf93d5793), o.u(0x55580df2, 0x0daaf255),
4098// o.u(0xfc619d82, 0x9de382fc), o.u(0x7ab3c947, 0xc9f4477a),
4099// o.u(0xc827efac, 0xef8bacc8), o.u(0xba8832e7, 0x326fe7ba),
4100// o.u(0x324f7d2b, 0x7d642b32), o.u(0xe642a495, 0xa4d795e6),
4101// o.u(0xc03bfba0, 0xfb9ba0c0), o.u(0x19aab398, 0xb3329819),
4102// o.u(0x9ef668d1, 0x6827d19e), o.u(0xa322817f, 0x815d7fa3),
4103// o.u(0x44eeaa66, 0xaa886644), o.u(0x54d6827e, 0x82a87e54),
4104// o.u(0x3bdde6ab, 0xe676ab3b), o.u(0x0b959e83, 0x9e16830b),
4105// o.u(0x8cc945ca, 0x4503ca8c), o.u(0xc7bc7b29, 0x7b9529c7),
4106// o.u(0x6b056ed3, 0x6ed6d36b), o.u(0x286c443c, 0x44503c28),
4107// o.u(0xa72c8b79, 0x8b5579a7), o.u(0xbc813de2, 0x3d63e2bc),
4108// o.u(0x1631271d, 0x272c1d16), o.u(0xad379a76, 0x9a4176ad),
4109// o.u(0xdb964d3b, 0x4dad3bdb), o.u(0x649efa56, 0xfac85664),
4110// o.u(0x74a6d24e, 0xd2e84e74), o.u(0x1436221e, 0x22281e14),
4111// o.u(0x92e476db, 0x763fdb92), o.u(0x0c121e0a, 0x1e180a0c),
4112// o.u(0x48fcb46c, 0xb4906c48), o.u(0xb88f37e4, 0x376be4b8),
4113// o.u(0x9f78e75d, 0xe7255d9f), o.u(0xbd0fb26e, 0xb2616ebd),
4114// o.u(0x43692aef, 0x2a86ef43), o.u(0xc435f1a6, 0xf193a6c4),
4115// o.u(0x39dae3a8, 0xe372a839), o.u(0x31c6f7a4, 0xf762a431),
4116// o.u(0xd38a5937, 0x59bd37d3), o.u(0xf274868b, 0x86ff8bf2),
4117// o.u(0xd5835632, 0x56b132d5), o.u(0x8b4ec543, 0xc50d438b),
4118// o.u(0x6e85eb59, 0xebdc596e), o.u(0xda18c2b7, 0xc2afb7da),
4119// o.u(0x018e8f8c, 0x8f028c01), o.u(0xb11dac64, 0xac7964b1),
4120// o.u(0x9cf16dd2, 0x6d23d29c), o.u(0x49723be0, 0x3b92e049),
4121// o.u(0xd81fc7b4, 0xc7abb4d8), o.u(0xacb915fa, 0x1543faac),
4122// o.u(0xf3fa0907, 0x09fd07f3), o.u(0xcfa06f25, 0x6f8525cf),
4123// o.u(0xca20eaaf, 0xea8fafca), o.u(0xf47d898e, 0x89f38ef4),
4124// o.u(0x476720e9, 0x208ee947), o.u(0x10382818, 0x28201810),
4125// o.u(0x6f0b64d5, 0x64ded56f), o.u(0xf0738388, 0x83fb88f0),
4126// o.u(0x4afbb16f, 0xb1946f4a), o.u(0x5cca9672, 0x96b8725c),
4127// o.u(0x38546c24, 0x6c702438), o.u(0x575f08f1, 0x08aef157),
4128// o.u(0x732152c7, 0x52e6c773), o.u(0x9764f351, 0xf3355197),
4129// o.u(0xcbae6523, 0x658d23cb), o.u(0xa125847c, 0x84597ca1),
4130// o.u(0xe857bf9c, 0xbfcb9ce8), o.u(0x3e5d6321, 0x637c213e),
4131// o.u(0x96ea7cdd, 0x7c37dd96), o.u(0x611e7fdc, 0x7fc2dc61),
4132// o.u(0x0d9c9186, 0x911a860d), o.u(0x0f9b9485, 0x941e850f),
4133// o.u(0xe04bab90, 0xabdb90e0), o.u(0x7cbac642, 0xc6f8427c),
4134// o.u(0x712657c4, 0x57e2c471), o.u(0xcc29e5aa, 0xe583aacc),
4135// o.u(0x90e373d8, 0x733bd890), o.u(0x06090f05, 0x0f0c0506),
4136// o.u(0xf7f40301, 0x03f501f7), o.u(0x1c2a3612, 0x3638121c),
4137// o.u(0xc23cfea3, 0xfe9fa3c2), o.u(0x6a8be15f, 0xe1d45f6a),
4138// o.u(0xaebe10f9, 0x1047f9ae), o.u(0x69026bd0, 0x6bd2d069),
4139// o.u(0x17bfa891, 0xa82e9117), o.u(0x9971e858, 0xe8295899),
4140// o.u(0x3a536927, 0x6974273a), o.u(0x27f7d0b9, 0xd04eb927),
4141// o.u(0xd9914838, 0x48a938d9), o.u(0xebde3513, 0x35cd13eb),
4142// o.u(0x2be5ceb3, 0xce56b32b), o.u(0x22775533, 0x55443322),
4143// o.u(0xd204d6bb, 0xd6bfbbd2), o.u(0xa9399070, 0x904970a9),
4144// o.u(0x07878089, 0x800e8907), o.u(0x33c1f2a7, 0xf266a733),
4145// o.u(0x2decc1b6, 0xc15ab62d), o.u(0x3c5a6622, 0x6678223c),
4146// o.u(0x15b8ad92, 0xad2a9215), o.u(0xc9a96020, 0x608920c9),
4147// o.u(0x875cdb49, 0xdb154987), o.u(0xaab01aff, 0x1a4fffaa),
4148// o.u(0x50d88878, 0x88a07850), o.u(0xa52b8e7a, 0x8e517aa5),
4149// o.u(0x03898a8f, 0x8a068f03), o.u(0x594a13f8, 0x13b2f859),
4150// o.u(0x09929b80, 0x9b128009), o.u(0x1a233917, 0x3934171a),
4151// o.u(0x651075da, 0x75cada65), o.u(0xd7845331, 0x53b531d7),
4152// o.u(0x84d551c6, 0x5113c684), o.u(0xd003d3b8, 0xd3bbb8d0),
4153// o.u(0x82dc5ec3, 0x5e1fc382), o.u(0x29e2cbb0, 0xcb52b029),
4154// o.u(0x5ac39977, 0x99b4775a), o.u(0x1e2d3311, 0x333c111e),
4155// o.u(0x7b3d46cb, 0x46f6cb7b), o.u(0xa8b71ffc, 0x1f4bfca8),
4156// o.u(0x6d0c61d6, 0x61dad66d), o.u(0x2c624e3a, 0x4e583a2c)
4157// ];
4158
4159// var T1 = [
4160// o.u(0xc6c632f4, 0xa5f497a5), o.u(0xf8f86f97, 0x8497eb84),
4161// o.u(0xeeee5eb0, 0x99b0c799), o.u(0xf6f67a8c, 0x8d8cf78d),
4162// o.u(0xffffe817, 0xd17e50d), o.u(0xd6d60adc, 0xbddcb7bd),
4163// o.u(0xdede16c8, 0xb1c8a7b1), o.u(0x91916dfc, 0x54fc3954),
4164// o.u(0x606090f0, 0x50f0c050), o.u(0x2020705, 0x3050403),
4165// o.u(0xcece2ee0, 0xa9e087a9), o.u(0x5656d187, 0x7d87ac7d),
4166// o.u(0xe7e7cc2b, 0x192bd519), o.u(0xb5b513a6, 0x62a67162),
4167// o.u(0x4d4d7c31, 0xe6319ae6), o.u(0xecec59b5, 0x9ab5c39a),
4168// o.u(0x8f8f40cf, 0x45cf0545), o.u(0x1f1fa3bc, 0x9dbc3e9d),
4169// o.u(0x898949c0, 0x40c00940), o.u(0xfafa6892, 0x8792ef87),
4170// o.u(0xefefd03f, 0x153fc515), o.u(0xb2b29426, 0xeb267feb),
4171// o.u(0x8e8ece40, 0xc94007c9), o.u(0xfbfbe61d, 0xb1ded0b),
4172// o.u(0x41416e2f, 0xec2f82ec), o.u(0xb3b31aa9, 0x67a97d67),
4173// o.u(0x5f5f431c, 0xfd1cbefd), o.u(0x45456025, 0xea258aea),
4174// o.u(0x2323f9da, 0xbfda46bf), o.u(0x53535102, 0xf702a6f7),
4175// o.u(0xe4e445a1, 0x96a1d396), o.u(0x9b9b76ed, 0x5bed2d5b),
4176// o.u(0x7575285d, 0xc25deac2), o.u(0xe1e1c524, 0x1c24d91c),
4177// o.u(0x3d3dd4e9, 0xaee97aae), o.u(0x4c4cf2be, 0x6abe986a),
4178// o.u(0x6c6c82ee, 0x5aeed85a), o.u(0x7e7ebdc3, 0x41c3fc41),
4179// o.u(0xf5f5f306, 0x206f102), o.u(0x838352d1, 0x4fd11d4f),
4180// o.u(0x68688ce4, 0x5ce4d05c), o.u(0x51515607, 0xf407a2f4),
4181// o.u(0xd1d18d5c, 0x345cb934), o.u(0xf9f9e118, 0x818e908),
4182// o.u(0xe2e24cae, 0x93aedf93), o.u(0xabab3e95, 0x73954d73),
4183// o.u(0x626297f5, 0x53f5c453), o.u(0x2a2a6b41, 0x3f41543f),
4184// o.u(0x8081c14, 0xc14100c), o.u(0x959563f6, 0x52f63152),
4185// o.u(0x4646e9af, 0x65af8c65), o.u(0x9d9d7fe2, 0x5ee2215e),
4186// o.u(0x30304878, 0x28786028), o.u(0x3737cff8, 0xa1f86ea1),
4187// o.u(0xa0a1b11, 0xf11140f), o.u(0x2f2febc4, 0xb5c45eb5),
4188// o.u(0xe0e151b, 0x91b1c09), o.u(0x24247e5a, 0x365a4836),
4189// o.u(0x1b1badb6, 0x9bb6369b), o.u(0xdfdf9847, 0x3d47a53d),
4190// o.u(0xcdcda76a, 0x266a8126), o.u(0x4e4ef5bb, 0x69bb9c69),
4191// o.u(0x7f7f334c, 0xcd4cfecd), o.u(0xeaea50ba, 0x9fbacf9f),
4192// o.u(0x12123f2d, 0x1b2d241b), o.u(0x1d1da4b9, 0x9eb93a9e),
4193// o.u(0x5858c49c, 0x749cb074), o.u(0x34344672, 0x2e72682e),
4194// o.u(0x36364177, 0x2d776c2d), o.u(0xdcdc11cd, 0xb2cda3b2),
4195// o.u(0xb4b49d29, 0xee2973ee), o.u(0x5b5b4d16, 0xfb16b6fb),
4196// o.u(0xa4a4a501, 0xf60153f6), o.u(0x7676a1d7, 0x4dd7ec4d),
4197// o.u(0xb7b714a3, 0x61a37561), o.u(0x7d7d3449, 0xce49face),
4198// o.u(0x5252df8d, 0x7b8da47b), o.u(0xdddd9f42, 0x3e42a13e),
4199// o.u(0x5e5ecd93, 0x7193bc71), o.u(0x1313b1a2, 0x97a22697),
4200// o.u(0xa6a6a204, 0xf50457f5), o.u(0xb9b901b8, 0x68b86968),
4201// o.u(0x0, 0x0), o.u(0xc1c1b574, 0x2c74992c),
4202// o.u(0x4040e0a0, 0x60a08060), o.u(0xe3e3c221, 0x1f21dd1f),
4203// o.u(0x79793a43, 0xc843f2c8), o.u(0xb6b69a2c, 0xed2c77ed),
4204// o.u(0xd4d40dd9, 0xbed9b3be), o.u(0x8d8d47ca, 0x46ca0146),
4205// o.u(0x67671770, 0xd970ced9), o.u(0x7272afdd, 0x4bdde44b),
4206// o.u(0x9494ed79, 0xde7933de), o.u(0x9898ff67, 0xd4672bd4),
4207// o.u(0xb0b09323, 0xe8237be8), o.u(0x85855bde, 0x4ade114a),
4208// o.u(0xbbbb06bd, 0x6bbd6d6b), o.u(0xc5c5bb7e, 0x2a7e912a),
4209// o.u(0x4f4f7b34, 0xe5349ee5), o.u(0xededd73a, 0x163ac116),
4210// o.u(0x8686d254, 0xc55417c5), o.u(0x9a9af862, 0xd7622fd7),
4211// o.u(0x666699ff, 0x55ffcc55), o.u(0x1111b6a7, 0x94a72294),
4212// o.u(0x8a8ac04a, 0xcf4a0fcf), o.u(0xe9e9d930, 0x1030c910),
4213// o.u(0x4040e0a, 0x60a0806), o.u(0xfefe6698, 0x8198e781),
4214// o.u(0xa0a0ab0b, 0xf00b5bf0), o.u(0x7878b4cc, 0x44ccf044),
4215// o.u(0x2525f0d5, 0xbad54aba), o.u(0x4b4b753e, 0xe33e96e3),
4216// o.u(0xa2a2ac0e, 0xf30e5ff3), o.u(0x5d5d4419, 0xfe19bafe),
4217// o.u(0x8080db5b, 0xc05b1bc0), o.u(0x5058085, 0x8a850a8a),
4218// o.u(0x3f3fd3ec, 0xadec7ead), o.u(0x2121fedf, 0xbcdf42bc),
4219// o.u(0x7070a8d8, 0x48d8e048), o.u(0xf1f1fd0c, 0x40cf904),
4220// o.u(0x6363197a, 0xdf7ac6df), o.u(0x77772f58, 0xc158eec1),
4221// o.u(0xafaf309f, 0x759f4575), o.u(0x4242e7a5, 0x63a58463),
4222// o.u(0x20207050, 0x30504030), o.u(0xe5e5cb2e, 0x1a2ed11a),
4223// o.u(0xfdfdef12, 0xe12e10e), o.u(0xbfbf08b7, 0x6db7656d),
4224// o.u(0x818155d4, 0x4cd4194c), o.u(0x1818243c, 0x143c3014),
4225// o.u(0x2626795f, 0x355f4c35), o.u(0xc3c3b271, 0x2f719d2f),
4226// o.u(0xbebe8638, 0xe13867e1), o.u(0x3535c8fd, 0xa2fd6aa2),
4227// o.u(0x8888c74f, 0xcc4f0bcc), o.u(0x2e2e654b, 0x394b5c39),
4228// o.u(0x93936af9, 0x57f93d57), o.u(0x5555580d, 0xf20daaf2),
4229// o.u(0xfcfc619d, 0x829de382), o.u(0x7a7ab3c9, 0x47c9f447),
4230// o.u(0xc8c827ef, 0xacef8bac), o.u(0xbaba8832, 0xe7326fe7),
4231// o.u(0x32324f7d, 0x2b7d642b), o.u(0xe6e642a4, 0x95a4d795),
4232// o.u(0xc0c03bfb, 0xa0fb9ba0), o.u(0x1919aab3, 0x98b33298),
4233// o.u(0x9e9ef668, 0xd16827d1), o.u(0xa3a32281, 0x7f815d7f),
4234// o.u(0x4444eeaa, 0x66aa8866), o.u(0x5454d682, 0x7e82a87e),
4235// o.u(0x3b3bdde6, 0xabe676ab), o.u(0xb0b959e, 0x839e1683),
4236// o.u(0x8c8cc945, 0xca4503ca), o.u(0xc7c7bc7b, 0x297b9529),
4237// o.u(0x6b6b056e, 0xd36ed6d3), o.u(0x28286c44, 0x3c44503c),
4238// o.u(0xa7a72c8b, 0x798b5579), o.u(0xbcbc813d, 0xe23d63e2),
4239// o.u(0x16163127, 0x1d272c1d), o.u(0xadad379a, 0x769a4176),
4240// o.u(0xdbdb964d, 0x3b4dad3b), o.u(0x64649efa, 0x56fac856),
4241// o.u(0x7474a6d2, 0x4ed2e84e), o.u(0x14143622, 0x1e22281e),
4242// o.u(0x9292e476, 0xdb763fdb), o.u(0xc0c121e, 0xa1e180a),
4243// o.u(0x4848fcb4, 0x6cb4906c), o.u(0xb8b88f37, 0xe4376be4),
4244// o.u(0x9f9f78e7, 0x5de7255d), o.u(0xbdbd0fb2, 0x6eb2616e),
4245// o.u(0x4343692a, 0xef2a86ef), o.u(0xc4c435f1, 0xa6f193a6),
4246// o.u(0x3939dae3, 0xa8e372a8), o.u(0x3131c6f7, 0xa4f762a4),
4247// o.u(0xd3d38a59, 0x3759bd37), o.u(0xf2f27486, 0x8b86ff8b),
4248// o.u(0xd5d58356, 0x3256b132), o.u(0x8b8b4ec5, 0x43c50d43),
4249// o.u(0x6e6e85eb, 0x59ebdc59), o.u(0xdada18c2, 0xb7c2afb7),
4250// o.u(0x1018e8f, 0x8c8f028c), o.u(0xb1b11dac, 0x64ac7964),
4251// o.u(0x9c9cf16d, 0xd26d23d2), o.u(0x4949723b, 0xe03b92e0),
4252// o.u(0xd8d81fc7, 0xb4c7abb4), o.u(0xacacb915, 0xfa1543fa),
4253// o.u(0xf3f3fa09, 0x709fd07), o.u(0xcfcfa06f, 0x256f8525),
4254// o.u(0xcaca20ea, 0xafea8faf), o.u(0xf4f47d89, 0x8e89f38e),
4255// o.u(0x47476720, 0xe9208ee9), o.u(0x10103828, 0x18282018),
4256// o.u(0x6f6f0b64, 0xd564ded5), o.u(0xf0f07383, 0x8883fb88),
4257// o.u(0x4a4afbb1, 0x6fb1946f), o.u(0x5c5cca96, 0x7296b872),
4258// o.u(0x3838546c, 0x246c7024), o.u(0x57575f08, 0xf108aef1),
4259// o.u(0x73732152, 0xc752e6c7), o.u(0x979764f3, 0x51f33551),
4260// o.u(0xcbcbae65, 0x23658d23), o.u(0xa1a12584, 0x7c84597c),
4261// o.u(0xe8e857bf, 0x9cbfcb9c), o.u(0x3e3e5d63, 0x21637c21),
4262// o.u(0x9696ea7c, 0xdd7c37dd), o.u(0x61611e7f, 0xdc7fc2dc),
4263// o.u(0xd0d9c91, 0x86911a86), o.u(0xf0f9b94, 0x85941e85),
4264// o.u(0xe0e04bab, 0x90abdb90), o.u(0x7c7cbac6, 0x42c6f842),
4265// o.u(0x71712657, 0xc457e2c4), o.u(0xcccc29e5, 0xaae583aa),
4266// o.u(0x9090e373, 0xd8733bd8), o.u(0x606090f, 0x50f0c05),
4267// o.u(0xf7f7f403, 0x103f501), o.u(0x1c1c2a36, 0x12363812),
4268// o.u(0xc2c23cfe, 0xa3fe9fa3), o.u(0x6a6a8be1, 0x5fe1d45f),
4269// o.u(0xaeaebe10, 0xf91047f9), o.u(0x6969026b, 0xd06bd2d0),
4270// o.u(0x1717bfa8, 0x91a82e91), o.u(0x999971e8, 0x58e82958),
4271// o.u(0x3a3a5369, 0x27697427), o.u(0x2727f7d0, 0xb9d04eb9),
4272// o.u(0xd9d99148, 0x3848a938), o.u(0xebebde35, 0x1335cd13),
4273// o.u(0x2b2be5ce, 0xb3ce56b3), o.u(0x22227755, 0x33554433),
4274// o.u(0xd2d204d6, 0xbbd6bfbb), o.u(0xa9a93990, 0x70904970),
4275// o.u(0x7078780, 0x89800e89), o.u(0x3333c1f2, 0xa7f266a7),
4276// o.u(0x2d2decc1, 0xb6c15ab6), o.u(0x3c3c5a66, 0x22667822),
4277// o.u(0x1515b8ad, 0x92ad2a92), o.u(0xc9c9a960, 0x20608920),
4278// o.u(0x87875cdb, 0x49db1549), o.u(0xaaaab01a, 0xff1a4fff),
4279// o.u(0x5050d888, 0x7888a078), o.u(0xa5a52b8e, 0x7a8e517a),
4280// o.u(0x303898a, 0x8f8a068f), o.u(0x59594a13, 0xf813b2f8),
4281// o.u(0x909929b, 0x809b1280), o.u(0x1a1a2339, 0x17393417),
4282// o.u(0x65651075, 0xda75cada), o.u(0xd7d78453, 0x3153b531),
4283// o.u(0x8484d551, 0xc65113c6), o.u(0xd0d003d3, 0xb8d3bbb8),
4284// o.u(0x8282dc5e, 0xc35e1fc3), o.u(0x2929e2cb, 0xb0cb52b0),
4285// o.u(0x5a5ac399, 0x7799b477), o.u(0x1e1e2d33, 0x11333c11),
4286// o.u(0x7b7b3d46, 0xcb46f6cb), o.u(0xa8a8b71f, 0xfc1f4bfc),
4287// o.u(0x6d6d0c61, 0xd661dad6), o.u(0x2c2c624e, 0x3a4e583a)
4288// ];
4289
4290// var T2 = [
4291// o.u(0xa5c6c632, 0xf4a5f497), o.u(0x84f8f86f, 0x978497eb),
4292// o.u(0x99eeee5e, 0xb099b0c7), o.u(0x8df6f67a, 0x8c8d8cf7),
4293// o.u(0xdffffe8, 0x170d17e5), o.u(0xbdd6d60a, 0xdcbddcb7),
4294// o.u(0xb1dede16, 0xc8b1c8a7), o.u(0x5491916d, 0xfc54fc39),
4295// o.u(0x50606090, 0xf050f0c0), o.u(0x3020207, 0x5030504),
4296// o.u(0xa9cece2e, 0xe0a9e087), o.u(0x7d5656d1, 0x877d87ac),
4297// o.u(0x19e7e7cc, 0x2b192bd5), o.u(0x62b5b513, 0xa662a671),
4298// o.u(0xe64d4d7c, 0x31e6319a), o.u(0x9aecec59, 0xb59ab5c3),
4299// o.u(0x458f8f40, 0xcf45cf05), o.u(0x9d1f1fa3, 0xbc9dbc3e),
4300// o.u(0x40898949, 0xc040c009), o.u(0x87fafa68, 0x928792ef),
4301// o.u(0x15efefd0, 0x3f153fc5), o.u(0xebb2b294, 0x26eb267f),
4302// o.u(0xc98e8ece, 0x40c94007), o.u(0xbfbfbe6, 0x1d0b1ded),
4303// o.u(0xec41416e, 0x2fec2f82), o.u(0x67b3b31a, 0xa967a97d),
4304// o.u(0xfd5f5f43, 0x1cfd1cbe), o.u(0xea454560, 0x25ea258a),
4305// o.u(0xbf2323f9, 0xdabfda46), o.u(0xf7535351, 0x2f702a6),
4306// o.u(0x96e4e445, 0xa196a1d3), o.u(0x5b9b9b76, 0xed5bed2d),
4307// o.u(0xc2757528, 0x5dc25dea), o.u(0x1ce1e1c5, 0x241c24d9),
4308// o.u(0xae3d3dd4, 0xe9aee97a), o.u(0x6a4c4cf2, 0xbe6abe98),
4309// o.u(0x5a6c6c82, 0xee5aeed8), o.u(0x417e7ebd, 0xc341c3fc),
4310// o.u(0x2f5f5f3, 0x60206f1), o.u(0x4f838352, 0xd14fd11d),
4311// o.u(0x5c68688c, 0xe45ce4d0), o.u(0xf4515156, 0x7f407a2),
4312// o.u(0x34d1d18d, 0x5c345cb9), o.u(0x8f9f9e1, 0x180818e9),
4313// o.u(0x93e2e24c, 0xae93aedf), o.u(0x73abab3e, 0x9573954d),
4314// o.u(0x53626297, 0xf553f5c4), o.u(0x3f2a2a6b, 0x413f4154),
4315// o.u(0xc08081c, 0x140c1410), o.u(0x52959563, 0xf652f631),
4316// o.u(0x654646e9, 0xaf65af8c), o.u(0x5e9d9d7f, 0xe25ee221),
4317// o.u(0x28303048, 0x78287860), o.u(0xa13737cf, 0xf8a1f86e),
4318// o.u(0xf0a0a1b, 0x110f1114), o.u(0xb52f2feb, 0xc4b5c45e),
4319// o.u(0x90e0e15, 0x1b091b1c), o.u(0x3624247e, 0x5a365a48),
4320// o.u(0x9b1b1bad, 0xb69bb636), o.u(0x3ddfdf98, 0x473d47a5),
4321// o.u(0x26cdcda7, 0x6a266a81), o.u(0x694e4ef5, 0xbb69bb9c),
4322// o.u(0xcd7f7f33, 0x4ccd4cfe), o.u(0x9feaea50, 0xba9fbacf),
4323// o.u(0x1b12123f, 0x2d1b2d24), o.u(0x9e1d1da4, 0xb99eb93a),
4324// o.u(0x745858c4, 0x9c749cb0), o.u(0x2e343446, 0x722e7268),
4325// o.u(0x2d363641, 0x772d776c), o.u(0xb2dcdc11, 0xcdb2cda3),
4326// o.u(0xeeb4b49d, 0x29ee2973), o.u(0xfb5b5b4d, 0x16fb16b6),
4327// o.u(0xf6a4a4a5, 0x1f60153), o.u(0x4d7676a1, 0xd74dd7ec),
4328// o.u(0x61b7b714, 0xa361a375), o.u(0xce7d7d34, 0x49ce49fa),
4329// o.u(0x7b5252df, 0x8d7b8da4), o.u(0x3edddd9f, 0x423e42a1),
4330// o.u(0x715e5ecd, 0x937193bc), o.u(0x971313b1, 0xa297a226),
4331// o.u(0xf5a6a6a2, 0x4f50457), o.u(0x68b9b901, 0xb868b869),
4332// o.u(0x0, 0x0), o.u(0x2cc1c1b5, 0x742c7499),
4333// o.u(0x604040e0, 0xa060a080), o.u(0x1fe3e3c2, 0x211f21dd),
4334// o.u(0xc879793a, 0x43c843f2), o.u(0xedb6b69a, 0x2ced2c77),
4335// o.u(0xbed4d40d, 0xd9bed9b3), o.u(0x468d8d47, 0xca46ca01),
4336// o.u(0xd9676717, 0x70d970ce), o.u(0x4b7272af, 0xdd4bdde4),
4337// o.u(0xde9494ed, 0x79de7933), o.u(0xd49898ff, 0x67d4672b),
4338// o.u(0xe8b0b093, 0x23e8237b), o.u(0x4a85855b, 0xde4ade11),
4339// o.u(0x6bbbbb06, 0xbd6bbd6d), o.u(0x2ac5c5bb, 0x7e2a7e91),
4340// o.u(0xe54f4f7b, 0x34e5349e), o.u(0x16ededd7, 0x3a163ac1),
4341// o.u(0xc58686d2, 0x54c55417), o.u(0xd79a9af8, 0x62d7622f),
4342// o.u(0x55666699, 0xff55ffcc), o.u(0x941111b6, 0xa794a722),
4343// o.u(0xcf8a8ac0, 0x4acf4a0f), o.u(0x10e9e9d9, 0x301030c9),
4344// o.u(0x604040e, 0xa060a08), o.u(0x81fefe66, 0x988198e7),
4345// o.u(0xf0a0a0ab, 0xbf00b5b), o.u(0x447878b4, 0xcc44ccf0),
4346// o.u(0xba2525f0, 0xd5bad54a), o.u(0xe34b4b75, 0x3ee33e96),
4347// o.u(0xf3a2a2ac, 0xef30e5f), o.u(0xfe5d5d44, 0x19fe19ba),
4348// o.u(0xc08080db, 0x5bc05b1b), o.u(0x8a050580, 0x858a850a),
4349// o.u(0xad3f3fd3, 0xecadec7e), o.u(0xbc2121fe, 0xdfbcdf42),
4350// o.u(0x487070a8, 0xd848d8e0), o.u(0x4f1f1fd, 0xc040cf9),
4351// o.u(0xdf636319, 0x7adf7ac6), o.u(0xc177772f, 0x58c158ee),
4352// o.u(0x75afaf30, 0x9f759f45), o.u(0x634242e7, 0xa563a584),
4353// o.u(0x30202070, 0x50305040), o.u(0x1ae5e5cb, 0x2e1a2ed1),
4354// o.u(0xefdfdef, 0x120e12e1), o.u(0x6dbfbf08, 0xb76db765),
4355// o.u(0x4c818155, 0xd44cd419), o.u(0x14181824, 0x3c143c30),
4356// o.u(0x35262679, 0x5f355f4c), o.u(0x2fc3c3b2, 0x712f719d),
4357// o.u(0xe1bebe86, 0x38e13867), o.u(0xa23535c8, 0xfda2fd6a),
4358// o.u(0xcc8888c7, 0x4fcc4f0b), o.u(0x392e2e65, 0x4b394b5c),
4359// o.u(0x5793936a, 0xf957f93d), o.u(0xf2555558, 0xdf20daa),
4360// o.u(0x82fcfc61, 0x9d829de3), o.u(0x477a7ab3, 0xc947c9f4),
4361// o.u(0xacc8c827, 0xefacef8b), o.u(0xe7baba88, 0x32e7326f),
4362// o.u(0x2b32324f, 0x7d2b7d64), o.u(0x95e6e642, 0xa495a4d7),
4363// o.u(0xa0c0c03b, 0xfba0fb9b), o.u(0x981919aa, 0xb398b332),
4364// o.u(0xd19e9ef6, 0x68d16827), o.u(0x7fa3a322, 0x817f815d),
4365// o.u(0x664444ee, 0xaa66aa88), o.u(0x7e5454d6, 0x827e82a8),
4366// o.u(0xab3b3bdd, 0xe6abe676), o.u(0x830b0b95, 0x9e839e16),
4367// o.u(0xca8c8cc9, 0x45ca4503), o.u(0x29c7c7bc, 0x7b297b95),
4368// o.u(0xd36b6b05, 0x6ed36ed6), o.u(0x3c28286c, 0x443c4450),
4369// o.u(0x79a7a72c, 0x8b798b55), o.u(0xe2bcbc81, 0x3de23d63),
4370// o.u(0x1d161631, 0x271d272c), o.u(0x76adad37, 0x9a769a41),
4371// o.u(0x3bdbdb96, 0x4d3b4dad), o.u(0x5664649e, 0xfa56fac8),
4372// o.u(0x4e7474a6, 0xd24ed2e8), o.u(0x1e141436, 0x221e2228),
4373// o.u(0xdb9292e4, 0x76db763f), o.u(0xa0c0c12, 0x1e0a1e18),
4374// o.u(0x6c4848fc, 0xb46cb490), o.u(0xe4b8b88f, 0x37e4376b),
4375// o.u(0x5d9f9f78, 0xe75de725), o.u(0x6ebdbd0f, 0xb26eb261),
4376// o.u(0xef434369, 0x2aef2a86), o.u(0xa6c4c435, 0xf1a6f193),
4377// o.u(0xa83939da, 0xe3a8e372), o.u(0xa43131c6, 0xf7a4f762),
4378// o.u(0x37d3d38a, 0x593759bd), o.u(0x8bf2f274, 0x868b86ff),
4379// o.u(0x32d5d583, 0x563256b1), o.u(0x438b8b4e, 0xc543c50d),
4380// o.u(0x596e6e85, 0xeb59ebdc), o.u(0xb7dada18, 0xc2b7c2af),
4381// o.u(0x8c01018e, 0x8f8c8f02), o.u(0x64b1b11d, 0xac64ac79),
4382// o.u(0xd29c9cf1, 0x6dd26d23), o.u(0xe0494972, 0x3be03b92),
4383// o.u(0xb4d8d81f, 0xc7b4c7ab), o.u(0xfaacacb9, 0x15fa1543),
4384// o.u(0x7f3f3fa, 0x90709fd), o.u(0x25cfcfa0, 0x6f256f85),
4385// o.u(0xafcaca20, 0xeaafea8f), o.u(0x8ef4f47d, 0x898e89f3),
4386// o.u(0xe9474767, 0x20e9208e), o.u(0x18101038, 0x28182820),
4387// o.u(0xd56f6f0b, 0x64d564de), o.u(0x88f0f073, 0x838883fb),
4388// o.u(0x6f4a4afb, 0xb16fb194), o.u(0x725c5cca, 0x967296b8),
4389// o.u(0x24383854, 0x6c246c70), o.u(0xf157575f, 0x8f108ae),
4390// o.u(0xc7737321, 0x52c752e6), o.u(0x51979764, 0xf351f335),
4391// o.u(0x23cbcbae, 0x6523658d), o.u(0x7ca1a125, 0x847c8459),
4392// o.u(0x9ce8e857, 0xbf9cbfcb), o.u(0x213e3e5d, 0x6321637c),
4393// o.u(0xdd9696ea, 0x7cdd7c37), o.u(0xdc61611e, 0x7fdc7fc2),
4394// o.u(0x860d0d9c, 0x9186911a), o.u(0x850f0f9b, 0x9485941e),
4395// o.u(0x90e0e04b, 0xab90abdb), o.u(0x427c7cba, 0xc642c6f8),
4396// o.u(0xc4717126, 0x57c457e2), o.u(0xaacccc29, 0xe5aae583),
4397// o.u(0xd89090e3, 0x73d8733b), o.u(0x5060609, 0xf050f0c),
4398// o.u(0x1f7f7f4, 0x30103f5), o.u(0x121c1c2a, 0x36123638),
4399// o.u(0xa3c2c23c, 0xfea3fe9f), o.u(0x5f6a6a8b, 0xe15fe1d4),
4400// o.u(0xf9aeaebe, 0x10f91047), o.u(0xd0696902, 0x6bd06bd2),
4401// o.u(0x911717bf, 0xa891a82e), o.u(0x58999971, 0xe858e829),
4402// o.u(0x273a3a53, 0x69276974), o.u(0xb92727f7, 0xd0b9d04e),
4403// o.u(0x38d9d991, 0x483848a9), o.u(0x13ebebde, 0x351335cd),
4404// o.u(0xb32b2be5, 0xceb3ce56), o.u(0x33222277, 0x55335544),
4405// o.u(0xbbd2d204, 0xd6bbd6bf), o.u(0x70a9a939, 0x90709049),
4406// o.u(0x89070787, 0x8089800e), o.u(0xa73333c1, 0xf2a7f266),
4407// o.u(0xb62d2dec, 0xc1b6c15a), o.u(0x223c3c5a, 0x66226678),
4408// o.u(0x921515b8, 0xad92ad2a), o.u(0x20c9c9a9, 0x60206089),
4409// o.u(0x4987875c, 0xdb49db15), o.u(0xffaaaab0, 0x1aff1a4f),
4410// o.u(0x785050d8, 0x887888a0), o.u(0x7aa5a52b, 0x8e7a8e51),
4411// o.u(0x8f030389, 0x8a8f8a06), o.u(0xf859594a, 0x13f813b2),
4412// o.u(0x80090992, 0x9b809b12), o.u(0x171a1a23, 0x39173934),
4413// o.u(0xda656510, 0x75da75ca), o.u(0x31d7d784, 0x533153b5),
4414// o.u(0xc68484d5, 0x51c65113), o.u(0xb8d0d003, 0xd3b8d3bb),
4415// o.u(0xc38282dc, 0x5ec35e1f), o.u(0xb02929e2, 0xcbb0cb52),
4416// o.u(0x775a5ac3, 0x997799b4), o.u(0x111e1e2d, 0x3311333c),
4417// o.u(0xcb7b7b3d, 0x46cb46f6), o.u(0xfca8a8b7, 0x1ffc1f4b),
4418// o.u(0xd66d6d0c, 0x61d661da), o.u(0x3a2c2c62, 0x4e3a4e58)
4419// ];
4420
4421// var T3 = [
4422// o.u(0x97a5c6c6, 0x32f4a5f4), o.u(0xeb84f8f8, 0x6f978497),
4423// o.u(0xc799eeee, 0x5eb099b0), o.u(0xf78df6f6, 0x7a8c8d8c),
4424// o.u(0xe50dffff, 0xe8170d17), o.u(0xb7bdd6d6, 0xadcbddc),
4425// o.u(0xa7b1dede, 0x16c8b1c8), o.u(0x39549191, 0x6dfc54fc),
4426// o.u(0xc0506060, 0x90f050f0), o.u(0x4030202, 0x7050305),
4427// o.u(0x87a9cece, 0x2ee0a9e0), o.u(0xac7d5656, 0xd1877d87),
4428// o.u(0xd519e7e7, 0xcc2b192b), o.u(0x7162b5b5, 0x13a662a6),
4429// o.u(0x9ae64d4d, 0x7c31e631), o.u(0xc39aecec, 0x59b59ab5),
4430// o.u(0x5458f8f, 0x40cf45cf), o.u(0x3e9d1f1f, 0xa3bc9dbc),
4431// o.u(0x9408989, 0x49c040c0), o.u(0xef87fafa, 0x68928792),
4432// o.u(0xc515efef, 0xd03f153f), o.u(0x7febb2b2, 0x9426eb26),
4433// o.u(0x7c98e8e, 0xce40c940), o.u(0xed0bfbfb, 0xe61d0b1d),
4434// o.u(0x82ec4141, 0x6e2fec2f), o.u(0x7d67b3b3, 0x1aa967a9),
4435// o.u(0xbefd5f5f, 0x431cfd1c), o.u(0x8aea4545, 0x6025ea25),
4436// o.u(0x46bf2323, 0xf9dabfda), o.u(0xa6f75353, 0x5102f702),
4437// o.u(0xd396e4e4, 0x45a196a1), o.u(0x2d5b9b9b, 0x76ed5bed),
4438// o.u(0xeac27575, 0x285dc25d), o.u(0xd91ce1e1, 0xc5241c24),
4439// o.u(0x7aae3d3d, 0xd4e9aee9), o.u(0x986a4c4c, 0xf2be6abe),
4440// o.u(0xd85a6c6c, 0x82ee5aee), o.u(0xfc417e7e, 0xbdc341c3),
4441// o.u(0xf102f5f5, 0xf3060206), o.u(0x1d4f8383, 0x52d14fd1),
4442// o.u(0xd05c6868, 0x8ce45ce4), o.u(0xa2f45151, 0x5607f407),
4443// o.u(0xb934d1d1, 0x8d5c345c), o.u(0xe908f9f9, 0xe1180818),
4444// o.u(0xdf93e2e2, 0x4cae93ae), o.u(0x4d73abab, 0x3e957395),
4445// o.u(0xc4536262, 0x97f553f5), o.u(0x543f2a2a, 0x6b413f41),
4446// o.u(0x100c0808, 0x1c140c14), o.u(0x31529595, 0x63f652f6),
4447// o.u(0x8c654646, 0xe9af65af), o.u(0x215e9d9d, 0x7fe25ee2),
4448// o.u(0x60283030, 0x48782878), o.u(0x6ea13737, 0xcff8a1f8),
4449// o.u(0x140f0a0a, 0x1b110f11), o.u(0x5eb52f2f, 0xebc4b5c4),
4450// o.u(0x1c090e0e, 0x151b091b), o.u(0x48362424, 0x7e5a365a),
4451// o.u(0x369b1b1b, 0xadb69bb6), o.u(0xa53ddfdf, 0x98473d47),
4452// o.u(0x8126cdcd, 0xa76a266a), o.u(0x9c694e4e, 0xf5bb69bb),
4453// o.u(0xfecd7f7f, 0x334ccd4c), o.u(0xcf9feaea, 0x50ba9fba),
4454// o.u(0x241b1212, 0x3f2d1b2d), o.u(0x3a9e1d1d, 0xa4b99eb9),
4455// o.u(0xb0745858, 0xc49c749c), o.u(0x682e3434, 0x46722e72),
4456// o.u(0x6c2d3636, 0x41772d77), o.u(0xa3b2dcdc, 0x11cdb2cd),
4457// o.u(0x73eeb4b4, 0x9d29ee29), o.u(0xb6fb5b5b, 0x4d16fb16),
4458// o.u(0x53f6a4a4, 0xa501f601), o.u(0xec4d7676, 0xa1d74dd7),
4459// o.u(0x7561b7b7, 0x14a361a3), o.u(0xface7d7d, 0x3449ce49),
4460// o.u(0xa47b5252, 0xdf8d7b8d), o.u(0xa13edddd, 0x9f423e42),
4461// o.u(0xbc715e5e, 0xcd937193), o.u(0x26971313, 0xb1a297a2),
4462// o.u(0x57f5a6a6, 0xa204f504), o.u(0x6968b9b9, 0x1b868b8),
4463// o.u(0x0, 0x0), o.u(0x992cc1c1, 0xb5742c74),
4464// o.u(0x80604040, 0xe0a060a0), o.u(0xdd1fe3e3, 0xc2211f21),
4465// o.u(0xf2c87979, 0x3a43c843), o.u(0x77edb6b6, 0x9a2ced2c),
4466// o.u(0xb3bed4d4, 0xdd9bed9), o.u(0x1468d8d, 0x47ca46ca),
4467// o.u(0xced96767, 0x1770d970), o.u(0xe44b7272, 0xafdd4bdd),
4468// o.u(0x33de9494, 0xed79de79), o.u(0x2bd49898, 0xff67d467),
4469// o.u(0x7be8b0b0, 0x9323e823), o.u(0x114a8585, 0x5bde4ade),
4470// o.u(0x6d6bbbbb, 0x6bd6bbd), o.u(0x912ac5c5, 0xbb7e2a7e),
4471// o.u(0x9ee54f4f, 0x7b34e534), o.u(0xc116eded, 0xd73a163a),
4472// o.u(0x17c58686, 0xd254c554), o.u(0x2fd79a9a, 0xf862d762),
4473// o.u(0xcc556666, 0x99ff55ff), o.u(0x22941111, 0xb6a794a7),
4474// o.u(0xfcf8a8a, 0xc04acf4a), o.u(0xc910e9e9, 0xd9301030),
4475// o.u(0x8060404, 0xe0a060a), o.u(0xe781fefe, 0x66988198),
4476// o.u(0x5bf0a0a0, 0xab0bf00b), o.u(0xf0447878, 0xb4cc44cc),
4477// o.u(0x4aba2525, 0xf0d5bad5), o.u(0x96e34b4b, 0x753ee33e),
4478// o.u(0x5ff3a2a2, 0xac0ef30e), o.u(0xbafe5d5d, 0x4419fe19),
4479// o.u(0x1bc08080, 0xdb5bc05b), o.u(0xa8a0505, 0x80858a85),
4480// o.u(0x7ead3f3f, 0xd3ecadec), o.u(0x42bc2121, 0xfedfbcdf),
4481// o.u(0xe0487070, 0xa8d848d8), o.u(0xf904f1f1, 0xfd0c040c),
4482// o.u(0xc6df6363, 0x197adf7a), o.u(0xeec17777, 0x2f58c158),
4483// o.u(0x4575afaf, 0x309f759f), o.u(0x84634242, 0xe7a563a5),
4484// o.u(0x40302020, 0x70503050), o.u(0xd11ae5e5, 0xcb2e1a2e),
4485// o.u(0xe10efdfd, 0xef120e12), o.u(0x656dbfbf, 0x8b76db7),
4486// o.u(0x194c8181, 0x55d44cd4), o.u(0x30141818, 0x243c143c),
4487// o.u(0x4c352626, 0x795f355f), o.u(0x9d2fc3c3, 0xb2712f71),
4488// o.u(0x67e1bebe, 0x8638e138), o.u(0x6aa23535, 0xc8fda2fd),
4489// o.u(0xbcc8888, 0xc74fcc4f), o.u(0x5c392e2e, 0x654b394b),
4490// o.u(0x3d579393, 0x6af957f9), o.u(0xaaf25555, 0x580df20d),
4491// o.u(0xe382fcfc, 0x619d829d), o.u(0xf4477a7a, 0xb3c947c9),
4492// o.u(0x8bacc8c8, 0x27efacef), o.u(0x6fe7baba, 0x8832e732),
4493// o.u(0x642b3232, 0x4f7d2b7d), o.u(0xd795e6e6, 0x42a495a4),
4494// o.u(0x9ba0c0c0, 0x3bfba0fb), o.u(0x32981919, 0xaab398b3),
4495// o.u(0x27d19e9e, 0xf668d168), o.u(0x5d7fa3a3, 0x22817f81),
4496// o.u(0x88664444, 0xeeaa66aa), o.u(0xa87e5454, 0xd6827e82),
4497// o.u(0x76ab3b3b, 0xdde6abe6), o.u(0x16830b0b, 0x959e839e),
4498// o.u(0x3ca8c8c, 0xc945ca45), o.u(0x9529c7c7, 0xbc7b297b),
4499// o.u(0xd6d36b6b, 0x56ed36e), o.u(0x503c2828, 0x6c443c44),
4500// o.u(0x5579a7a7, 0x2c8b798b), o.u(0x63e2bcbc, 0x813de23d),
4501// o.u(0x2c1d1616, 0x31271d27), o.u(0x4176adad, 0x379a769a),
4502// o.u(0xad3bdbdb, 0x964d3b4d), o.u(0xc8566464, 0x9efa56fa),
4503// o.u(0xe84e7474, 0xa6d24ed2), o.u(0x281e1414, 0x36221e22),
4504// o.u(0x3fdb9292, 0xe476db76), o.u(0x180a0c0c, 0x121e0a1e),
4505// o.u(0x906c4848, 0xfcb46cb4), o.u(0x6be4b8b8, 0x8f37e437),
4506// o.u(0x255d9f9f, 0x78e75de7), o.u(0x616ebdbd, 0xfb26eb2),
4507// o.u(0x86ef4343, 0x692aef2a), o.u(0x93a6c4c4, 0x35f1a6f1),
4508// o.u(0x72a83939, 0xdae3a8e3), o.u(0x62a43131, 0xc6f7a4f7),
4509// o.u(0xbd37d3d3, 0x8a593759), o.u(0xff8bf2f2, 0x74868b86),
4510// o.u(0xb132d5d5, 0x83563256), o.u(0xd438b8b, 0x4ec543c5),
4511// o.u(0xdc596e6e, 0x85eb59eb), o.u(0xafb7dada, 0x18c2b7c2),
4512// o.u(0x28c0101, 0x8e8f8c8f), o.u(0x7964b1b1, 0x1dac64ac),
4513// o.u(0x23d29c9c, 0xf16dd26d), o.u(0x92e04949, 0x723be03b),
4514// o.u(0xabb4d8d8, 0x1fc7b4c7), o.u(0x43faacac, 0xb915fa15),
4515// o.u(0xfd07f3f3, 0xfa090709), o.u(0x8525cfcf, 0xa06f256f),
4516// o.u(0x8fafcaca, 0x20eaafea), o.u(0xf38ef4f4, 0x7d898e89),
4517// o.u(0x8ee94747, 0x6720e920), o.u(0x20181010, 0x38281828),
4518// o.u(0xded56f6f, 0xb64d564), o.u(0xfb88f0f0, 0x73838883),
4519// o.u(0x946f4a4a, 0xfbb16fb1), o.u(0xb8725c5c, 0xca967296),
4520// o.u(0x70243838, 0x546c246c), o.u(0xaef15757, 0x5f08f108),
4521// o.u(0xe6c77373, 0x2152c752), o.u(0x35519797, 0x64f351f3),
4522// o.u(0x8d23cbcb, 0xae652365), o.u(0x597ca1a1, 0x25847c84),
4523// o.u(0xcb9ce8e8, 0x57bf9cbf), o.u(0x7c213e3e, 0x5d632163),
4524// o.u(0x37dd9696, 0xea7cdd7c), o.u(0xc2dc6161, 0x1e7fdc7f),
4525// o.u(0x1a860d0d, 0x9c918691), o.u(0x1e850f0f, 0x9b948594),
4526// o.u(0xdb90e0e0, 0x4bab90ab), o.u(0xf8427c7c, 0xbac642c6),
4527// o.u(0xe2c47171, 0x2657c457), o.u(0x83aacccc, 0x29e5aae5),
4528// o.u(0x3bd89090, 0xe373d873), o.u(0xc050606, 0x90f050f),
4529// o.u(0xf501f7f7, 0xf4030103), o.u(0x38121c1c, 0x2a361236),
4530// o.u(0x9fa3c2c2, 0x3cfea3fe), o.u(0xd45f6a6a, 0x8be15fe1),
4531// o.u(0x47f9aeae, 0xbe10f910), o.u(0xd2d06969, 0x26bd06b),
4532// o.u(0x2e911717, 0xbfa891a8), o.u(0x29589999, 0x71e858e8),
4533// o.u(0x74273a3a, 0x53692769), o.u(0x4eb92727, 0xf7d0b9d0),
4534// o.u(0xa938d9d9, 0x91483848), o.u(0xcd13ebeb, 0xde351335),
4535// o.u(0x56b32b2b, 0xe5ceb3ce), o.u(0x44332222, 0x77553355),
4536// o.u(0xbfbbd2d2, 0x4d6bbd6), o.u(0x4970a9a9, 0x39907090),
4537// o.u(0xe890707, 0x87808980), o.u(0x66a73333, 0xc1f2a7f2),
4538// o.u(0x5ab62d2d, 0xecc1b6c1), o.u(0x78223c3c, 0x5a662266),
4539// o.u(0x2a921515, 0xb8ad92ad), o.u(0x8920c9c9, 0xa9602060),
4540// o.u(0x15498787, 0x5cdb49db), o.u(0x4fffaaaa, 0xb01aff1a),
4541// o.u(0xa0785050, 0xd8887888), o.u(0x517aa5a5, 0x2b8e7a8e),
4542// o.u(0x68f0303, 0x898a8f8a), o.u(0xb2f85959, 0x4a13f813),
4543// o.u(0x12800909, 0x929b809b), o.u(0x34171a1a, 0x23391739),
4544// o.u(0xcada6565, 0x1075da75), o.u(0xb531d7d7, 0x84533153),
4545// o.u(0x13c68484, 0xd551c651), o.u(0xbbb8d0d0, 0x3d3b8d3),
4546// o.u(0x1fc38282, 0xdc5ec35e), o.u(0x52b02929, 0xe2cbb0cb),
4547// o.u(0xb4775a5a, 0xc3997799), o.u(0x3c111e1e, 0x2d331133),
4548// o.u(0xf6cb7b7b, 0x3d46cb46), o.u(0x4bfca8a8, 0xb71ffc1f),
4549// o.u(0xdad66d6d, 0xc61d661), o.u(0x583a2c2c, 0x624e3a4e)
4550// ]
4551
4552// var T4 = [
4553// o.u(0xf497a5c6, 0xc632f4a5), o.u(0x97eb84f8, 0xf86f9784),
4554// o.u(0xb0c799ee, 0xee5eb099), o.u(0x8cf78df6, 0xf67a8c8d),
4555// o.u(0x17e50dff, 0xffe8170d), o.u(0xdcb7bdd6, 0xd60adcbd),
4556// o.u(0xc8a7b1de, 0xde16c8b1), o.u(0xfc395491, 0x916dfc54),
4557// o.u(0xf0c05060, 0x6090f050), o.u(0x05040302, 0x02070503),
4558// o.u(0xe087a9ce, 0xce2ee0a9), o.u(0x87ac7d56, 0x56d1877d),
4559// o.u(0x2bd519e7, 0xe7cc2b19), o.u(0xa67162b5, 0xb513a662),
4560// o.u(0x319ae64d, 0x4d7c31e6), o.u(0xb5c39aec, 0xec59b59a),
4561// o.u(0xcf05458f, 0x8f40cf45), o.u(0xbc3e9d1f, 0x1fa3bc9d),
4562// o.u(0xc0094089, 0x8949c040), o.u(0x92ef87fa, 0xfa689287),
4563// o.u(0x3fc515ef, 0xefd03f15), o.u(0x267febb2, 0xb29426eb),
4564// o.u(0x4007c98e, 0x8ece40c9), o.u(0x1ded0bfb, 0xfbe61d0b),
4565// o.u(0x2f82ec41, 0x416e2fec), o.u(0xa97d67b3, 0xb31aa967),
4566// o.u(0x1cbefd5f, 0x5f431cfd), o.u(0x258aea45, 0x456025ea),
4567// o.u(0xda46bf23, 0x23f9dabf), o.u(0x02a6f753, 0x535102f7),
4568// o.u(0xa1d396e4, 0xe445a196), o.u(0xed2d5b9b, 0x9b76ed5b),
4569// o.u(0x5deac275, 0x75285dc2), o.u(0x24d91ce1, 0xe1c5241c),
4570// o.u(0xe97aae3d, 0x3dd4e9ae), o.u(0xbe986a4c, 0x4cf2be6a),
4571// o.u(0xeed85a6c, 0x6c82ee5a), o.u(0xc3fc417e, 0x7ebdc341),
4572// o.u(0x06f102f5, 0xf5f30602), o.u(0xd11d4f83, 0x8352d14f),
4573// o.u(0xe4d05c68, 0x688ce45c), o.u(0x07a2f451, 0x515607f4),
4574// o.u(0x5cb934d1, 0xd18d5c34), o.u(0x18e908f9, 0xf9e11808),
4575// o.u(0xaedf93e2, 0xe24cae93), o.u(0x954d73ab, 0xab3e9573),
4576// o.u(0xf5c45362, 0x6297f553), o.u(0x41543f2a, 0x2a6b413f),
4577// o.u(0x14100c08, 0x081c140c), o.u(0xf6315295, 0x9563f652),
4578// o.u(0xaf8c6546, 0x46e9af65), o.u(0xe2215e9d, 0x9d7fe25e),
4579// o.u(0x78602830, 0x30487828), o.u(0xf86ea137, 0x37cff8a1),
4580// o.u(0x11140f0a, 0x0a1b110f), o.u(0xc45eb52f, 0x2febc4b5),
4581// o.u(0x1b1c090e, 0x0e151b09), o.u(0x5a483624, 0x247e5a36),
4582// o.u(0xb6369b1b, 0x1badb69b), o.u(0x47a53ddf, 0xdf98473d),
4583// o.u(0x6a8126cd, 0xcda76a26), o.u(0xbb9c694e, 0x4ef5bb69),
4584// o.u(0x4cfecd7f, 0x7f334ccd), o.u(0xbacf9fea, 0xea50ba9f),
4585// o.u(0x2d241b12, 0x123f2d1b), o.u(0xb93a9e1d, 0x1da4b99e),
4586// o.u(0x9cb07458, 0x58c49c74), o.u(0x72682e34, 0x3446722e),
4587// o.u(0x776c2d36, 0x3641772d), o.u(0xcda3b2dc, 0xdc11cdb2),
4588// o.u(0x2973eeb4, 0xb49d29ee), o.u(0x16b6fb5b, 0x5b4d16fb),
4589// o.u(0x0153f6a4, 0xa4a501f6), o.u(0xd7ec4d76, 0x76a1d74d),
4590// o.u(0xa37561b7, 0xb714a361), o.u(0x49face7d, 0x7d3449ce),
4591// o.u(0x8da47b52, 0x52df8d7b), o.u(0x42a13edd, 0xdd9f423e),
4592// o.u(0x93bc715e, 0x5ecd9371), o.u(0xa2269713, 0x13b1a297),
4593// o.u(0x0457f5a6, 0xa6a204f5), o.u(0xb86968b9, 0xb901b868),
4594// o.u(0x00000000, 0x00000000), o.u(0x74992cc1, 0xc1b5742c),
4595// o.u(0xa0806040, 0x40e0a060), o.u(0x21dd1fe3, 0xe3c2211f),
4596// o.u(0x43f2c879, 0x793a43c8), o.u(0x2c77edb6, 0xb69a2ced),
4597// o.u(0xd9b3bed4, 0xd40dd9be), o.u(0xca01468d, 0x8d47ca46),
4598// o.u(0x70ced967, 0x671770d9), o.u(0xdde44b72, 0x72afdd4b),
4599// o.u(0x7933de94, 0x94ed79de), o.u(0x672bd498, 0x98ff67d4),
4600// o.u(0x237be8b0, 0xb09323e8), o.u(0xde114a85, 0x855bde4a),
4601// o.u(0xbd6d6bbb, 0xbb06bd6b), o.u(0x7e912ac5, 0xc5bb7e2a),
4602// o.u(0x349ee54f, 0x4f7b34e5), o.u(0x3ac116ed, 0xedd73a16),
4603// o.u(0x5417c586, 0x86d254c5), o.u(0x622fd79a, 0x9af862d7),
4604// o.u(0xffcc5566, 0x6699ff55), o.u(0xa7229411, 0x11b6a794),
4605// o.u(0x4a0fcf8a, 0x8ac04acf), o.u(0x30c910e9, 0xe9d93010),
4606// o.u(0x0a080604, 0x040e0a06), o.u(0x98e781fe, 0xfe669881),
4607// o.u(0x0b5bf0a0, 0xa0ab0bf0), o.u(0xccf04478, 0x78b4cc44),
4608// o.u(0xd54aba25, 0x25f0d5ba), o.u(0x3e96e34b, 0x4b753ee3),
4609// o.u(0x0e5ff3a2, 0xa2ac0ef3), o.u(0x19bafe5d, 0x5d4419fe),
4610// o.u(0x5b1bc080, 0x80db5bc0), o.u(0x850a8a05, 0x0580858a),
4611// o.u(0xec7ead3f, 0x3fd3ecad), o.u(0xdf42bc21, 0x21fedfbc),
4612// o.u(0xd8e04870, 0x70a8d848), o.u(0x0cf904f1, 0xf1fd0c04),
4613// o.u(0x7ac6df63, 0x63197adf), o.u(0x58eec177, 0x772f58c1),
4614// o.u(0x9f4575af, 0xaf309f75), o.u(0xa5846342, 0x42e7a563),
4615// o.u(0x50403020, 0x20705030), o.u(0x2ed11ae5, 0xe5cb2e1a),
4616// o.u(0x12e10efd, 0xfdef120e), o.u(0xb7656dbf, 0xbf08b76d),
4617// o.u(0xd4194c81, 0x8155d44c), o.u(0x3c301418, 0x18243c14),
4618// o.u(0x5f4c3526, 0x26795f35), o.u(0x719d2fc3, 0xc3b2712f),
4619// o.u(0x3867e1be, 0xbe8638e1), o.u(0xfd6aa235, 0x35c8fda2),
4620// o.u(0x4f0bcc88, 0x88c74fcc), o.u(0x4b5c392e, 0x2e654b39),
4621// o.u(0xf93d5793, 0x936af957), o.u(0x0daaf255, 0x55580df2),
4622// o.u(0x9de382fc, 0xfc619d82), o.u(0xc9f4477a, 0x7ab3c947),
4623// o.u(0xef8bacc8, 0xc827efac), o.u(0x326fe7ba, 0xba8832e7),
4624// o.u(0x7d642b32, 0x324f7d2b), o.u(0xa4d795e6, 0xe642a495),
4625// o.u(0xfb9ba0c0, 0xc03bfba0), o.u(0xb3329819, 0x19aab398),
4626// o.u(0x6827d19e, 0x9ef668d1), o.u(0x815d7fa3, 0xa322817f),
4627// o.u(0xaa886644, 0x44eeaa66), o.u(0x82a87e54, 0x54d6827e),
4628// o.u(0xe676ab3b, 0x3bdde6ab), o.u(0x9e16830b, 0x0b959e83),
4629// o.u(0x4503ca8c, 0x8cc945ca), o.u(0x7b9529c7, 0xc7bc7b29),
4630// o.u(0x6ed6d36b, 0x6b056ed3), o.u(0x44503c28, 0x286c443c),
4631// o.u(0x8b5579a7, 0xa72c8b79), o.u(0x3d63e2bc, 0xbc813de2),
4632// o.u(0x272c1d16, 0x1631271d), o.u(0x9a4176ad, 0xad379a76),
4633// o.u(0x4dad3bdb, 0xdb964d3b), o.u(0xfac85664, 0x649efa56),
4634// o.u(0xd2e84e74, 0x74a6d24e), o.u(0x22281e14, 0x1436221e),
4635// o.u(0x763fdb92, 0x92e476db), o.u(0x1e180a0c, 0x0c121e0a),
4636// o.u(0xb4906c48, 0x48fcb46c), o.u(0x376be4b8, 0xb88f37e4),
4637// o.u(0xe7255d9f, 0x9f78e75d), o.u(0xb2616ebd, 0xbd0fb26e),
4638// o.u(0x2a86ef43, 0x43692aef), o.u(0xf193a6c4, 0xc435f1a6),
4639// o.u(0xe372a839, 0x39dae3a8), o.u(0xf762a431, 0x31c6f7a4),
4640// o.u(0x59bd37d3, 0xd38a5937), o.u(0x86ff8bf2, 0xf274868b),
4641// o.u(0x56b132d5, 0xd5835632), o.u(0xc50d438b, 0x8b4ec543),
4642// o.u(0xebdc596e, 0x6e85eb59), o.u(0xc2afb7da, 0xda18c2b7),
4643// o.u(0x8f028c01, 0x018e8f8c), o.u(0xac7964b1, 0xb11dac64),
4644// o.u(0x6d23d29c, 0x9cf16dd2), o.u(0x3b92e049, 0x49723be0),
4645// o.u(0xc7abb4d8, 0xd81fc7b4), o.u(0x1543faac, 0xacb915fa),
4646// o.u(0x09fd07f3, 0xf3fa0907), o.u(0x6f8525cf, 0xcfa06f25),
4647// o.u(0xea8fafca, 0xca20eaaf), o.u(0x89f38ef4, 0xf47d898e),
4648// o.u(0x208ee947, 0x476720e9), o.u(0x28201810, 0x10382818),
4649// o.u(0x64ded56f, 0x6f0b64d5), o.u(0x83fb88f0, 0xf0738388),
4650// o.u(0xb1946f4a, 0x4afbb16f), o.u(0x96b8725c, 0x5cca9672),
4651// o.u(0x6c702438, 0x38546c24), o.u(0x08aef157, 0x575f08f1),
4652// o.u(0x52e6c773, 0x732152c7), o.u(0xf3355197, 0x9764f351),
4653// o.u(0x658d23cb, 0xcbae6523), o.u(0x84597ca1, 0xa125847c),
4654// o.u(0xbfcb9ce8, 0xe857bf9c), o.u(0x637c213e, 0x3e5d6321),
4655// o.u(0x7c37dd96, 0x96ea7cdd), o.u(0x7fc2dc61, 0x611e7fdc),
4656// o.u(0x911a860d, 0x0d9c9186), o.u(0x941e850f, 0x0f9b9485),
4657// o.u(0xabdb90e0, 0xe04bab90), o.u(0xc6f8427c, 0x7cbac642),
4658// o.u(0x57e2c471, 0x712657c4), o.u(0xe583aacc, 0xcc29e5aa),
4659// o.u(0x733bd890, 0x90e373d8), o.u(0x0f0c0506, 0x06090f05),
4660// o.u(0x03f501f7, 0xf7f40301), o.u(0x3638121c, 0x1c2a3612),
4661// o.u(0xfe9fa3c2, 0xc23cfea3), o.u(0xe1d45f6a, 0x6a8be15f),
4662// o.u(0x1047f9ae, 0xaebe10f9), o.u(0x6bd2d069, 0x69026bd0),
4663// o.u(0xa82e9117, 0x17bfa891), o.u(0xe8295899, 0x9971e858),
4664// o.u(0x6974273a, 0x3a536927), o.u(0xd04eb927, 0x27f7d0b9),
4665// o.u(0x48a938d9, 0xd9914838), o.u(0x35cd13eb, 0xebde3513),
4666// o.u(0xce56b32b, 0x2be5ceb3), o.u(0x55443322, 0x22775533),
4667// o.u(0xd6bfbbd2, 0xd204d6bb), o.u(0x904970a9, 0xa9399070),
4668// o.u(0x800e8907, 0x07878089), o.u(0xf266a733, 0x33c1f2a7),
4669// o.u(0xc15ab62d, 0x2decc1b6), o.u(0x6678223c, 0x3c5a6622),
4670// o.u(0xad2a9215, 0x15b8ad92), o.u(0x608920c9, 0xc9a96020),
4671// o.u(0xdb154987, 0x875cdb49), o.u(0x1a4fffaa, 0xaab01aff),
4672// o.u(0x88a07850, 0x50d88878), o.u(0x8e517aa5, 0xa52b8e7a),
4673// o.u(0x8a068f03, 0x03898a8f), o.u(0x13b2f859, 0x594a13f8),
4674// o.u(0x9b128009, 0x09929b80), o.u(0x3934171a, 0x1a233917),
4675// o.u(0x75cada65, 0x651075da), o.u(0x53b531d7, 0xd7845331),
4676// o.u(0x5113c684, 0x84d551c6), o.u(0xd3bbb8d0, 0xd003d3b8),
4677// o.u(0x5e1fc382, 0x82dc5ec3), o.u(0xcb52b029, 0x29e2cbb0),
4678// o.u(0x99b4775a, 0x5ac39977), o.u(0x333c111e, 0x1e2d3311),
4679// o.u(0x46f6cb7b, 0x7b3d46cb), o.u(0x1f4bfca8, 0xa8b71ffc),
4680// o.u(0x61dad66d, 0x6d0c61d6), o.u(0x4e583a2c, 0x2c624e3a)
4681// ];
4682
4683// var T5 = [
4684// o.u(0xa5f497a5, 0xc6c632f4), o.u(0x8497eb84, 0xf8f86f97),
4685// o.u(0x99b0c799, 0xeeee5eb0), o.u(0x8d8cf78d, 0xf6f67a8c),
4686// o.u(0xd17e50d, 0xffffe817), o.u(0xbddcb7bd, 0xd6d60adc),
4687// o.u(0xb1c8a7b1, 0xdede16c8), o.u(0x54fc3954, 0x91916dfc),
4688// o.u(0x50f0c050, 0x606090f0), o.u(0x3050403, 0x2020705),
4689// o.u(0xa9e087a9, 0xcece2ee0), o.u(0x7d87ac7d, 0x5656d187),
4690// o.u(0x192bd519, 0xe7e7cc2b), o.u(0x62a67162, 0xb5b513a6),
4691// o.u(0xe6319ae6, 0x4d4d7c31), o.u(0x9ab5c39a, 0xecec59b5),
4692// o.u(0x45cf0545, 0x8f8f40cf), o.u(0x9dbc3e9d, 0x1f1fa3bc),
4693// o.u(0x40c00940, 0x898949c0), o.u(0x8792ef87, 0xfafa6892),
4694// o.u(0x153fc515, 0xefefd03f), o.u(0xeb267feb, 0xb2b29426),
4695// o.u(0xc94007c9, 0x8e8ece40), o.u(0xb1ded0b, 0xfbfbe61d),
4696// o.u(0xec2f82ec, 0x41416e2f), o.u(0x67a97d67, 0xb3b31aa9),
4697// o.u(0xfd1cbefd, 0x5f5f431c), o.u(0xea258aea, 0x45456025),
4698// o.u(0xbfda46bf, 0x2323f9da), o.u(0xf702a6f7, 0x53535102),
4699// o.u(0x96a1d396, 0xe4e445a1), o.u(0x5bed2d5b, 0x9b9b76ed),
4700// o.u(0xc25deac2, 0x7575285d), o.u(0x1c24d91c, 0xe1e1c524),
4701// o.u(0xaee97aae, 0x3d3dd4e9), o.u(0x6abe986a, 0x4c4cf2be),
4702// o.u(0x5aeed85a, 0x6c6c82ee), o.u(0x41c3fc41, 0x7e7ebdc3),
4703// o.u(0x206f102, 0xf5f5f306), o.u(0x4fd11d4f, 0x838352d1),
4704// o.u(0x5ce4d05c, 0x68688ce4), o.u(0xf407a2f4, 0x51515607),
4705// o.u(0x345cb934, 0xd1d18d5c), o.u(0x818e908, 0xf9f9e118),
4706// o.u(0x93aedf93, 0xe2e24cae), o.u(0x73954d73, 0xabab3e95),
4707// o.u(0x53f5c453, 0x626297f5), o.u(0x3f41543f, 0x2a2a6b41),
4708// o.u(0xc14100c, 0x8081c14), o.u(0x52f63152, 0x959563f6),
4709// o.u(0x65af8c65, 0x4646e9af), o.u(0x5ee2215e, 0x9d9d7fe2),
4710// o.u(0x28786028, 0x30304878), o.u(0xa1f86ea1, 0x3737cff8),
4711// o.u(0xf11140f, 0xa0a1b11), o.u(0xb5c45eb5, 0x2f2febc4),
4712// o.u(0x91b1c09, 0xe0e151b), o.u(0x365a4836, 0x24247e5a),
4713// o.u(0x9bb6369b, 0x1b1badb6), o.u(0x3d47a53d, 0xdfdf9847),
4714// o.u(0x266a8126, 0xcdcda76a), o.u(0x69bb9c69, 0x4e4ef5bb),
4715// o.u(0xcd4cfecd, 0x7f7f334c), o.u(0x9fbacf9f, 0xeaea50ba),
4716// o.u(0x1b2d241b, 0x12123f2d), o.u(0x9eb93a9e, 0x1d1da4b9),
4717// o.u(0x749cb074, 0x5858c49c), o.u(0x2e72682e, 0x34344672),
4718// o.u(0x2d776c2d, 0x36364177), o.u(0xb2cda3b2, 0xdcdc11cd),
4719// o.u(0xee2973ee, 0xb4b49d29), o.u(0xfb16b6fb, 0x5b5b4d16),
4720// o.u(0xf60153f6, 0xa4a4a501), o.u(0x4dd7ec4d, 0x7676a1d7),
4721// o.u(0x61a37561, 0xb7b714a3), o.u(0xce49face, 0x7d7d3449),
4722// o.u(0x7b8da47b, 0x5252df8d), o.u(0x3e42a13e, 0xdddd9f42),
4723// o.u(0x7193bc71, 0x5e5ecd93), o.u(0x97a22697, 0x1313b1a2),
4724// o.u(0xf50457f5, 0xa6a6a204), o.u(0x68b86968, 0xb9b901b8),
4725// o.u(0x0, 0x0), o.u(0x2c74992c, 0xc1c1b574),
4726// o.u(0x60a08060, 0x4040e0a0), o.u(0x1f21dd1f, 0xe3e3c221),
4727// o.u(0xc843f2c8, 0x79793a43), o.u(0xed2c77ed, 0xb6b69a2c),
4728// o.u(0xbed9b3be, 0xd4d40dd9), o.u(0x46ca0146, 0x8d8d47ca),
4729// o.u(0xd970ced9, 0x67671770), o.u(0x4bdde44b, 0x7272afdd),
4730// o.u(0xde7933de, 0x9494ed79), o.u(0xd4672bd4, 0x9898ff67),
4731// o.u(0xe8237be8, 0xb0b09323), o.u(0x4ade114a, 0x85855bde),
4732// o.u(0x6bbd6d6b, 0xbbbb06bd), o.u(0x2a7e912a, 0xc5c5bb7e),
4733// o.u(0xe5349ee5, 0x4f4f7b34), o.u(0x163ac116, 0xededd73a),
4734// o.u(0xc55417c5, 0x8686d254), o.u(0xd7622fd7, 0x9a9af862),
4735// o.u(0x55ffcc55, 0x666699ff), o.u(0x94a72294, 0x1111b6a7),
4736// o.u(0xcf4a0fcf, 0x8a8ac04a), o.u(0x1030c910, 0xe9e9d930),
4737// o.u(0x60a0806, 0x4040e0a), o.u(0x8198e781, 0xfefe6698),
4738// o.u(0xf00b5bf0, 0xa0a0ab0b), o.u(0x44ccf044, 0x7878b4cc),
4739// o.u(0xbad54aba, 0x2525f0d5), o.u(0xe33e96e3, 0x4b4b753e),
4740// o.u(0xf30e5ff3, 0xa2a2ac0e), o.u(0xfe19bafe, 0x5d5d4419),
4741// o.u(0xc05b1bc0, 0x8080db5b), o.u(0x8a850a8a, 0x5058085),
4742// o.u(0xadec7ead, 0x3f3fd3ec), o.u(0xbcdf42bc, 0x2121fedf),
4743// o.u(0x48d8e048, 0x7070a8d8), o.u(0x40cf904, 0xf1f1fd0c),
4744// o.u(0xdf7ac6df, 0x6363197a), o.u(0xc158eec1, 0x77772f58),
4745// o.u(0x759f4575, 0xafaf309f), o.u(0x63a58463, 0x4242e7a5),
4746// o.u(0x30504030, 0x20207050), o.u(0x1a2ed11a, 0xe5e5cb2e),
4747// o.u(0xe12e10e, 0xfdfdef12), o.u(0x6db7656d, 0xbfbf08b7),
4748// o.u(0x4cd4194c, 0x818155d4), o.u(0x143c3014, 0x1818243c),
4749// o.u(0x355f4c35, 0x2626795f), o.u(0x2f719d2f, 0xc3c3b271),
4750// o.u(0xe13867e1, 0xbebe8638), o.u(0xa2fd6aa2, 0x3535c8fd),
4751// o.u(0xcc4f0bcc, 0x8888c74f), o.u(0x394b5c39, 0x2e2e654b),
4752// o.u(0x57f93d57, 0x93936af9), o.u(0xf20daaf2, 0x5555580d),
4753// o.u(0x829de382, 0xfcfc619d), o.u(0x47c9f447, 0x7a7ab3c9),
4754// o.u(0xacef8bac, 0xc8c827ef), o.u(0xe7326fe7, 0xbaba8832),
4755// o.u(0x2b7d642b, 0x32324f7d), o.u(0x95a4d795, 0xe6e642a4),
4756// o.u(0xa0fb9ba0, 0xc0c03bfb), o.u(0x98b33298, 0x1919aab3),
4757// o.u(0xd16827d1, 0x9e9ef668), o.u(0x7f815d7f, 0xa3a32281),
4758// o.u(0x66aa8866, 0x4444eeaa), o.u(0x7e82a87e, 0x5454d682),
4759// o.u(0xabe676ab, 0x3b3bdde6), o.u(0x839e1683, 0xb0b959e),
4760// o.u(0xca4503ca, 0x8c8cc945), o.u(0x297b9529, 0xc7c7bc7b),
4761// o.u(0xd36ed6d3, 0x6b6b056e), o.u(0x3c44503c, 0x28286c44),
4762// o.u(0x798b5579, 0xa7a72c8b), o.u(0xe23d63e2, 0xbcbc813d),
4763// o.u(0x1d272c1d, 0x16163127), o.u(0x769a4176, 0xadad379a),
4764// o.u(0x3b4dad3b, 0xdbdb964d), o.u(0x56fac856, 0x64649efa),
4765// o.u(0x4ed2e84e, 0x7474a6d2), o.u(0x1e22281e, 0x14143622),
4766// o.u(0xdb763fdb, 0x9292e476), o.u(0xa1e180a, 0xc0c121e),
4767// o.u(0x6cb4906c, 0x4848fcb4), o.u(0xe4376be4, 0xb8b88f37),
4768// o.u(0x5de7255d, 0x9f9f78e7), o.u(0x6eb2616e, 0xbdbd0fb2),
4769// o.u(0xef2a86ef, 0x4343692a), o.u(0xa6f193a6, 0xc4c435f1),
4770// o.u(0xa8e372a8, 0x3939dae3), o.u(0xa4f762a4, 0x3131c6f7),
4771// o.u(0x3759bd37, 0xd3d38a59), o.u(0x8b86ff8b, 0xf2f27486),
4772// o.u(0x3256b132, 0xd5d58356), o.u(0x43c50d43, 0x8b8b4ec5),
4773// o.u(0x59ebdc59, 0x6e6e85eb), o.u(0xb7c2afb7, 0xdada18c2),
4774// o.u(0x8c8f028c, 0x1018e8f), o.u(0x64ac7964, 0xb1b11dac),
4775// o.u(0xd26d23d2, 0x9c9cf16d), o.u(0xe03b92e0, 0x4949723b),
4776// o.u(0xb4c7abb4, 0xd8d81fc7), o.u(0xfa1543fa, 0xacacb915),
4777// o.u(0x709fd07, 0xf3f3fa09), o.u(0x256f8525, 0xcfcfa06f),
4778// o.u(0xafea8faf, 0xcaca20ea), o.u(0x8e89f38e, 0xf4f47d89),
4779// o.u(0xe9208ee9, 0x47476720), o.u(0x18282018, 0x10103828),
4780// o.u(0xd564ded5, 0x6f6f0b64), o.u(0x8883fb88, 0xf0f07383),
4781// o.u(0x6fb1946f, 0x4a4afbb1), o.u(0x7296b872, 0x5c5cca96),
4782// o.u(0x246c7024, 0x3838546c), o.u(0xf108aef1, 0x57575f08),
4783// o.u(0xc752e6c7, 0x73732152), o.u(0x51f33551, 0x979764f3),
4784// o.u(0x23658d23, 0xcbcbae65), o.u(0x7c84597c, 0xa1a12584),
4785// o.u(0x9cbfcb9c, 0xe8e857bf), o.u(0x21637c21, 0x3e3e5d63),
4786// o.u(0xdd7c37dd, 0x9696ea7c), o.u(0xdc7fc2dc, 0x61611e7f),
4787// o.u(0x86911a86, 0xd0d9c91), o.u(0x85941e85, 0xf0f9b94),
4788// o.u(0x90abdb90, 0xe0e04bab), o.u(0x42c6f842, 0x7c7cbac6),
4789// o.u(0xc457e2c4, 0x71712657), o.u(0xaae583aa, 0xcccc29e5),
4790// o.u(0xd8733bd8, 0x9090e373), o.u(0x50f0c05, 0x606090f),
4791// o.u(0x103f501, 0xf7f7f403), o.u(0x12363812, 0x1c1c2a36),
4792// o.u(0xa3fe9fa3, 0xc2c23cfe), o.u(0x5fe1d45f, 0x6a6a8be1),
4793// o.u(0xf91047f9, 0xaeaebe10), o.u(0xd06bd2d0, 0x6969026b),
4794// o.u(0x91a82e91, 0x1717bfa8), o.u(0x58e82958, 0x999971e8),
4795// o.u(0x27697427, 0x3a3a5369), o.u(0xb9d04eb9, 0x2727f7d0),
4796// o.u(0x3848a938, 0xd9d99148), o.u(0x1335cd13, 0xebebde35),
4797// o.u(0xb3ce56b3, 0x2b2be5ce), o.u(0x33554433, 0x22227755),
4798// o.u(0xbbd6bfbb, 0xd2d204d6), o.u(0x70904970, 0xa9a93990),
4799// o.u(0x89800e89, 0x7078780), o.u(0xa7f266a7, 0x3333c1f2),
4800// o.u(0xb6c15ab6, 0x2d2decc1), o.u(0x22667822, 0x3c3c5a66),
4801// o.u(0x92ad2a92, 0x1515b8ad), o.u(0x20608920, 0xc9c9a960),
4802// o.u(0x49db1549, 0x87875cdb), o.u(0xff1a4fff, 0xaaaab01a),
4803// o.u(0x7888a078, 0x5050d888), o.u(0x7a8e517a, 0xa5a52b8e),
4804// o.u(0x8f8a068f, 0x303898a), o.u(0xf813b2f8, 0x59594a13),
4805// o.u(0x809b1280, 0x909929b), o.u(0x17393417, 0x1a1a2339),
4806// o.u(0xda75cada, 0x65651075), o.u(0x3153b531, 0xd7d78453),
4807// o.u(0xc65113c6, 0x8484d551), o.u(0xb8d3bbb8, 0xd0d003d3),
4808// o.u(0xc35e1fc3, 0x8282dc5e), o.u(0xb0cb52b0, 0x2929e2cb),
4809// o.u(0x7799b477, 0x5a5ac399), o.u(0x11333c11, 0x1e1e2d33),
4810// o.u(0xcb46f6cb, 0x7b7b3d46), o.u(0xfc1f4bfc, 0xa8a8b71f),
4811// o.u(0xd661dad6, 0x6d6d0c61), o.u(0x3a4e583a, 0x2c2c624e)
4812// ];
4813
4814// var T6 = [
4815// o.u(0xf4a5f497, 0xa5c6c632), o.u(0x978497eb, 0x84f8f86f),
4816// o.u(0xb099b0c7, 0x99eeee5e), o.u(0x8c8d8cf7, 0x8df6f67a),
4817// o.u(0x170d17e5, 0xdffffe8), o.u(0xdcbddcb7, 0xbdd6d60a),
4818// o.u(0xc8b1c8a7, 0xb1dede16), o.u(0xfc54fc39, 0x5491916d),
4819// o.u(0xf050f0c0, 0x50606090), o.u(0x5030504, 0x3020207),
4820// o.u(0xe0a9e087, 0xa9cece2e), o.u(0x877d87ac, 0x7d5656d1),
4821// o.u(0x2b192bd5, 0x19e7e7cc), o.u(0xa662a671, 0x62b5b513),
4822// o.u(0x31e6319a, 0xe64d4d7c), o.u(0xb59ab5c3, 0x9aecec59),
4823// o.u(0xcf45cf05, 0x458f8f40), o.u(0xbc9dbc3e, 0x9d1f1fa3),
4824// o.u(0xc040c009, 0x40898949), o.u(0x928792ef, 0x87fafa68),
4825// o.u(0x3f153fc5, 0x15efefd0), o.u(0x26eb267f, 0xebb2b294),
4826// o.u(0x40c94007, 0xc98e8ece), o.u(0x1d0b1ded, 0xbfbfbe6),
4827// o.u(0x2fec2f82, 0xec41416e), o.u(0xa967a97d, 0x67b3b31a),
4828// o.u(0x1cfd1cbe, 0xfd5f5f43), o.u(0x25ea258a, 0xea454560),
4829// o.u(0xdabfda46, 0xbf2323f9), o.u(0x2f702a6, 0xf7535351),
4830// o.u(0xa196a1d3, 0x96e4e445), o.u(0xed5bed2d, 0x5b9b9b76),
4831// o.u(0x5dc25dea, 0xc2757528), o.u(0x241c24d9, 0x1ce1e1c5),
4832// o.u(0xe9aee97a, 0xae3d3dd4), o.u(0xbe6abe98, 0x6a4c4cf2),
4833// o.u(0xee5aeed8, 0x5a6c6c82), o.u(0xc341c3fc, 0x417e7ebd),
4834// o.u(0x60206f1, 0x2f5f5f3), o.u(0xd14fd11d, 0x4f838352),
4835// o.u(0xe45ce4d0, 0x5c68688c), o.u(0x7f407a2, 0xf4515156),
4836// o.u(0x5c345cb9, 0x34d1d18d), o.u(0x180818e9, 0x8f9f9e1),
4837// o.u(0xae93aedf, 0x93e2e24c), o.u(0x9573954d, 0x73abab3e),
4838// o.u(0xf553f5c4, 0x53626297), o.u(0x413f4154, 0x3f2a2a6b),
4839// o.u(0x140c1410, 0xc08081c), o.u(0xf652f631, 0x52959563),
4840// o.u(0xaf65af8c, 0x654646e9), o.u(0xe25ee221, 0x5e9d9d7f),
4841// o.u(0x78287860, 0x28303048), o.u(0xf8a1f86e, 0xa13737cf),
4842// o.u(0x110f1114, 0xf0a0a1b), o.u(0xc4b5c45e, 0xb52f2feb),
4843// o.u(0x1b091b1c, 0x90e0e15), o.u(0x5a365a48, 0x3624247e),
4844// o.u(0xb69bb636, 0x9b1b1bad), o.u(0x473d47a5, 0x3ddfdf98),
4845// o.u(0x6a266a81, 0x26cdcda7), o.u(0xbb69bb9c, 0x694e4ef5),
4846// o.u(0x4ccd4cfe, 0xcd7f7f33), o.u(0xba9fbacf, 0x9feaea50),
4847// o.u(0x2d1b2d24, 0x1b12123f), o.u(0xb99eb93a, 0x9e1d1da4),
4848// o.u(0x9c749cb0, 0x745858c4), o.u(0x722e7268, 0x2e343446),
4849// o.u(0x772d776c, 0x2d363641), o.u(0xcdb2cda3, 0xb2dcdc11),
4850// o.u(0x29ee2973, 0xeeb4b49d), o.u(0x16fb16b6, 0xfb5b5b4d),
4851// o.u(0x1f60153, 0xf6a4a4a5), o.u(0xd74dd7ec, 0x4d7676a1),
4852// o.u(0xa361a375, 0x61b7b714), o.u(0x49ce49fa, 0xce7d7d34),
4853// o.u(0x8d7b8da4, 0x7b5252df), o.u(0x423e42a1, 0x3edddd9f),
4854// o.u(0x937193bc, 0x715e5ecd), o.u(0xa297a226, 0x971313b1),
4855// o.u(0x4f50457, 0xf5a6a6a2), o.u(0xb868b869, 0x68b9b901),
4856// o.u(0x0, 0x0), o.u(0x742c7499, 0x2cc1c1b5),
4857// o.u(0xa060a080, 0x604040e0), o.u(0x211f21dd, 0x1fe3e3c2),
4858// o.u(0x43c843f2, 0xc879793a), o.u(0x2ced2c77, 0xedb6b69a),
4859// o.u(0xd9bed9b3, 0xbed4d40d), o.u(0xca46ca01, 0x468d8d47),
4860// o.u(0x70d970ce, 0xd9676717), o.u(0xdd4bdde4, 0x4b7272af),
4861// o.u(0x79de7933, 0xde9494ed), o.u(0x67d4672b, 0xd49898ff),
4862// o.u(0x23e8237b, 0xe8b0b093), o.u(0xde4ade11, 0x4a85855b),
4863// o.u(0xbd6bbd6d, 0x6bbbbb06), o.u(0x7e2a7e91, 0x2ac5c5bb),
4864// o.u(0x34e5349e, 0xe54f4f7b), o.u(0x3a163ac1, 0x16ededd7),
4865// o.u(0x54c55417, 0xc58686d2), o.u(0x62d7622f, 0xd79a9af8),
4866// o.u(0xff55ffcc, 0x55666699), o.u(0xa794a722, 0x941111b6),
4867// o.u(0x4acf4a0f, 0xcf8a8ac0), o.u(0x301030c9, 0x10e9e9d9),
4868// o.u(0xa060a08, 0x604040e), o.u(0x988198e7, 0x81fefe66),
4869// o.u(0xbf00b5b, 0xf0a0a0ab), o.u(0xcc44ccf0, 0x447878b4),
4870// o.u(0xd5bad54a, 0xba2525f0), o.u(0x3ee33e96, 0xe34b4b75),
4871// o.u(0xef30e5f, 0xf3a2a2ac), o.u(0x19fe19ba, 0xfe5d5d44),
4872// o.u(0x5bc05b1b, 0xc08080db), o.u(0x858a850a, 0x8a050580),
4873// o.u(0xecadec7e, 0xad3f3fd3), o.u(0xdfbcdf42, 0xbc2121fe),
4874// o.u(0xd848d8e0, 0x487070a8), o.u(0xc040cf9, 0x4f1f1fd),
4875// o.u(0x7adf7ac6, 0xdf636319), o.u(0x58c158ee, 0xc177772f),
4876// o.u(0x9f759f45, 0x75afaf30), o.u(0xa563a584, 0x634242e7),
4877// o.u(0x50305040, 0x30202070), o.u(0x2e1a2ed1, 0x1ae5e5cb),
4878// o.u(0x120e12e1, 0xefdfdef), o.u(0xb76db765, 0x6dbfbf08),
4879// o.u(0xd44cd419, 0x4c818155), o.u(0x3c143c30, 0x14181824),
4880// o.u(0x5f355f4c, 0x35262679), o.u(0x712f719d, 0x2fc3c3b2),
4881// o.u(0x38e13867, 0xe1bebe86), o.u(0xfda2fd6a, 0xa23535c8),
4882// o.u(0x4fcc4f0b, 0xcc8888c7), o.u(0x4b394b5c, 0x392e2e65),
4883// o.u(0xf957f93d, 0x5793936a), o.u(0xdf20daa, 0xf2555558),
4884// o.u(0x9d829de3, 0x82fcfc61), o.u(0xc947c9f4, 0x477a7ab3),
4885// o.u(0xefacef8b, 0xacc8c827), o.u(0x32e7326f, 0xe7baba88),
4886// o.u(0x7d2b7d64, 0x2b32324f), o.u(0xa495a4d7, 0x95e6e642),
4887// o.u(0xfba0fb9b, 0xa0c0c03b), o.u(0xb398b332, 0x981919aa),
4888// o.u(0x68d16827, 0xd19e9ef6), o.u(0x817f815d, 0x7fa3a322),
4889// o.u(0xaa66aa88, 0x664444ee), o.u(0x827e82a8, 0x7e5454d6),
4890// o.u(0xe6abe676, 0xab3b3bdd), o.u(0x9e839e16, 0x830b0b95),
4891// o.u(0x45ca4503, 0xca8c8cc9), o.u(0x7b297b95, 0x29c7c7bc),
4892// o.u(0x6ed36ed6, 0xd36b6b05), o.u(0x443c4450, 0x3c28286c),
4893// o.u(0x8b798b55, 0x79a7a72c), o.u(0x3de23d63, 0xe2bcbc81),
4894// o.u(0x271d272c, 0x1d161631), o.u(0x9a769a41, 0x76adad37),
4895// o.u(0x4d3b4dad, 0x3bdbdb96), o.u(0xfa56fac8, 0x5664649e),
4896// o.u(0xd24ed2e8, 0x4e7474a6), o.u(0x221e2228, 0x1e141436),
4897// o.u(0x76db763f, 0xdb9292e4), o.u(0x1e0a1e18, 0xa0c0c12),
4898// o.u(0xb46cb490, 0x6c4848fc), o.u(0x37e4376b, 0xe4b8b88f),
4899// o.u(0xe75de725, 0x5d9f9f78), o.u(0xb26eb261, 0x6ebdbd0f),
4900// o.u(0x2aef2a86, 0xef434369), o.u(0xf1a6f193, 0xa6c4c435),
4901// o.u(0xe3a8e372, 0xa83939da), o.u(0xf7a4f762, 0xa43131c6),
4902// o.u(0x593759bd, 0x37d3d38a), o.u(0x868b86ff, 0x8bf2f274),
4903// o.u(0x563256b1, 0x32d5d583), o.u(0xc543c50d, 0x438b8b4e),
4904// o.u(0xeb59ebdc, 0x596e6e85), o.u(0xc2b7c2af, 0xb7dada18),
4905// o.u(0x8f8c8f02, 0x8c01018e), o.u(0xac64ac79, 0x64b1b11d),
4906// o.u(0x6dd26d23, 0xd29c9cf1), o.u(0x3be03b92, 0xe0494972),
4907// o.u(0xc7b4c7ab, 0xb4d8d81f), o.u(0x15fa1543, 0xfaacacb9),
4908// o.u(0x90709fd, 0x7f3f3fa), o.u(0x6f256f85, 0x25cfcfa0),
4909// o.u(0xeaafea8f, 0xafcaca20), o.u(0x898e89f3, 0x8ef4f47d),
4910// o.u(0x20e9208e, 0xe9474767), o.u(0x28182820, 0x18101038),
4911// o.u(0x64d564de, 0xd56f6f0b), o.u(0x838883fb, 0x88f0f073),
4912// o.u(0xb16fb194, 0x6f4a4afb), o.u(0x967296b8, 0x725c5cca),
4913// o.u(0x6c246c70, 0x24383854), o.u(0x8f108ae, 0xf157575f),
4914// o.u(0x52c752e6, 0xc7737321), o.u(0xf351f335, 0x51979764),
4915// o.u(0x6523658d, 0x23cbcbae), o.u(0x847c8459, 0x7ca1a125),
4916// o.u(0xbf9cbfcb, 0x9ce8e857), o.u(0x6321637c, 0x213e3e5d),
4917// o.u(0x7cdd7c37, 0xdd9696ea), o.u(0x7fdc7fc2, 0xdc61611e),
4918// o.u(0x9186911a, 0x860d0d9c), o.u(0x9485941e, 0x850f0f9b),
4919// o.u(0xab90abdb, 0x90e0e04b), o.u(0xc642c6f8, 0x427c7cba),
4920// o.u(0x57c457e2, 0xc4717126), o.u(0xe5aae583, 0xaacccc29),
4921// o.u(0x73d8733b, 0xd89090e3), o.u(0xf050f0c, 0x5060609),
4922// o.u(0x30103f5, 0x1f7f7f4), o.u(0x36123638, 0x121c1c2a),
4923// o.u(0xfea3fe9f, 0xa3c2c23c), o.u(0xe15fe1d4, 0x5f6a6a8b),
4924// o.u(0x10f91047, 0xf9aeaebe), o.u(0x6bd06bd2, 0xd0696902),
4925// o.u(0xa891a82e, 0x911717bf), o.u(0xe858e829, 0x58999971),
4926// o.u(0x69276974, 0x273a3a53), o.u(0xd0b9d04e, 0xb92727f7),
4927// o.u(0x483848a9, 0x38d9d991), o.u(0x351335cd, 0x13ebebde),
4928// o.u(0xceb3ce56, 0xb32b2be5), o.u(0x55335544, 0x33222277),
4929// o.u(0xd6bbd6bf, 0xbbd2d204), o.u(0x90709049, 0x70a9a939),
4930// o.u(0x8089800e, 0x89070787), o.u(0xf2a7f266, 0xa73333c1),
4931// o.u(0xc1b6c15a, 0xb62d2dec), o.u(0x66226678, 0x223c3c5a),
4932// o.u(0xad92ad2a, 0x921515b8), o.u(0x60206089, 0x20c9c9a9),
4933// o.u(0xdb49db15, 0x4987875c), o.u(0x1aff1a4f, 0xffaaaab0),
4934// o.u(0x887888a0, 0x785050d8), o.u(0x8e7a8e51, 0x7aa5a52b),
4935// o.u(0x8a8f8a06, 0x8f030389), o.u(0x13f813b2, 0xf859594a),
4936// o.u(0x9b809b12, 0x80090992), o.u(0x39173934, 0x171a1a23),
4937// o.u(0x75da75ca, 0xda656510), o.u(0x533153b5, 0x31d7d784),
4938// o.u(0x51c65113, 0xc68484d5), o.u(0xd3b8d3bb, 0xb8d0d003),
4939// o.u(0x5ec35e1f, 0xc38282dc), o.u(0xcbb0cb52, 0xb02929e2),
4940// o.u(0x997799b4, 0x775a5ac3), o.u(0x3311333c, 0x111e1e2d),
4941// o.u(0x46cb46f6, 0xcb7b7b3d), o.u(0x1ffc1f4b, 0xfca8a8b7),
4942// o.u(0x61d661da, 0xd66d6d0c), o.u(0x4e3a4e58, 0x3a2c2c62)
4943// ];
4944
4945// var T7 = [
4946// o.u(0x32f4a5f4, 0x97a5c6c6), o.u(0x6f978497, 0xeb84f8f8),
4947// o.u(0x5eb099b0, 0xc799eeee), o.u(0x7a8c8d8c, 0xf78df6f6),
4948// o.u(0xe8170d17, 0xe50dffff), o.u(0xadcbddc, 0xb7bdd6d6),
4949// o.u(0x16c8b1c8, 0xa7b1dede), o.u(0x6dfc54fc, 0x39549191),
4950// o.u(0x90f050f0, 0xc0506060), o.u(0x7050305, 0x4030202),
4951// o.u(0x2ee0a9e0, 0x87a9cece), o.u(0xd1877d87, 0xac7d5656),
4952// o.u(0xcc2b192b, 0xd519e7e7), o.u(0x13a662a6, 0x7162b5b5),
4953// o.u(0x7c31e631, 0x9ae64d4d), o.u(0x59b59ab5, 0xc39aecec),
4954// o.u(0x40cf45cf, 0x5458f8f), o.u(0xa3bc9dbc, 0x3e9d1f1f),
4955// o.u(0x49c040c0, 0x9408989), o.u(0x68928792, 0xef87fafa),
4956// o.u(0xd03f153f, 0xc515efef), o.u(0x9426eb26, 0x7febb2b2),
4957// o.u(0xce40c940, 0x7c98e8e), o.u(0xe61d0b1d, 0xed0bfbfb),
4958// o.u(0x6e2fec2f, 0x82ec4141), o.u(0x1aa967a9, 0x7d67b3b3),
4959// o.u(0x431cfd1c, 0xbefd5f5f), o.u(0x6025ea25, 0x8aea4545),
4960// o.u(0xf9dabfda, 0x46bf2323), o.u(0x5102f702, 0xa6f75353),
4961// o.u(0x45a196a1, 0xd396e4e4), o.u(0x76ed5bed, 0x2d5b9b9b),
4962// o.u(0x285dc25d, 0xeac27575), o.u(0xc5241c24, 0xd91ce1e1),
4963// o.u(0xd4e9aee9, 0x7aae3d3d), o.u(0xf2be6abe, 0x986a4c4c),
4964// o.u(0x82ee5aee, 0xd85a6c6c), o.u(0xbdc341c3, 0xfc417e7e),
4965// o.u(0xf3060206, 0xf102f5f5), o.u(0x52d14fd1, 0x1d4f8383),
4966// o.u(0x8ce45ce4, 0xd05c6868), o.u(0x5607f407, 0xa2f45151),
4967// o.u(0x8d5c345c, 0xb934d1d1), o.u(0xe1180818, 0xe908f9f9),
4968// o.u(0x4cae93ae, 0xdf93e2e2), o.u(0x3e957395, 0x4d73abab),
4969// o.u(0x97f553f5, 0xc4536262), o.u(0x6b413f41, 0x543f2a2a),
4970// o.u(0x1c140c14, 0x100c0808), o.u(0x63f652f6, 0x31529595),
4971// o.u(0xe9af65af, 0x8c654646), o.u(0x7fe25ee2, 0x215e9d9d),
4972// o.u(0x48782878, 0x60283030), o.u(0xcff8a1f8, 0x6ea13737),
4973// o.u(0x1b110f11, 0x140f0a0a), o.u(0xebc4b5c4, 0x5eb52f2f),
4974// o.u(0x151b091b, 0x1c090e0e), o.u(0x7e5a365a, 0x48362424),
4975// o.u(0xadb69bb6, 0x369b1b1b), o.u(0x98473d47, 0xa53ddfdf),
4976// o.u(0xa76a266a, 0x8126cdcd), o.u(0xf5bb69bb, 0x9c694e4e),
4977// o.u(0x334ccd4c, 0xfecd7f7f), o.u(0x50ba9fba, 0xcf9feaea),
4978// o.u(0x3f2d1b2d, 0x241b1212), o.u(0xa4b99eb9, 0x3a9e1d1d),
4979// o.u(0xc49c749c, 0xb0745858), o.u(0x46722e72, 0x682e3434),
4980// o.u(0x41772d77, 0x6c2d3636), o.u(0x11cdb2cd, 0xa3b2dcdc),
4981// o.u(0x9d29ee29, 0x73eeb4b4), o.u(0x4d16fb16, 0xb6fb5b5b),
4982// o.u(0xa501f601, 0x53f6a4a4), o.u(0xa1d74dd7, 0xec4d7676),
4983// o.u(0x14a361a3, 0x7561b7b7), o.u(0x3449ce49, 0xface7d7d),
4984// o.u(0xdf8d7b8d, 0xa47b5252), o.u(0x9f423e42, 0xa13edddd),
4985// o.u(0xcd937193, 0xbc715e5e), o.u(0xb1a297a2, 0x26971313),
4986// o.u(0xa204f504, 0x57f5a6a6), o.u(0x1b868b8, 0x6968b9b9),
4987// o.u(0x0, 0x0), o.u(0xb5742c74, 0x992cc1c1),
4988// o.u(0xe0a060a0, 0x80604040), o.u(0xc2211f21, 0xdd1fe3e3),
4989// o.u(0x3a43c843, 0xf2c87979), o.u(0x9a2ced2c, 0x77edb6b6),
4990// o.u(0xdd9bed9, 0xb3bed4d4), o.u(0x47ca46ca, 0x1468d8d),
4991// o.u(0x1770d970, 0xced96767), o.u(0xafdd4bdd, 0xe44b7272),
4992// o.u(0xed79de79, 0x33de9494), o.u(0xff67d467, 0x2bd49898),
4993// o.u(0x9323e823, 0x7be8b0b0), o.u(0x5bde4ade, 0x114a8585),
4994// o.u(0x6bd6bbd, 0x6d6bbbbb), o.u(0xbb7e2a7e, 0x912ac5c5),
4995// o.u(0x7b34e534, 0x9ee54f4f), o.u(0xd73a163a, 0xc116eded),
4996// o.u(0xd254c554, 0x17c58686), o.u(0xf862d762, 0x2fd79a9a),
4997// o.u(0x99ff55ff, 0xcc556666), o.u(0xb6a794a7, 0x22941111),
4998// o.u(0xc04acf4a, 0xfcf8a8a), o.u(0xd9301030, 0xc910e9e9),
4999// o.u(0xe0a060a, 0x8060404), o.u(0x66988198, 0xe781fefe),
5000// o.u(0xab0bf00b, 0x5bf0a0a0), o.u(0xb4cc44cc, 0xf0447878),
5001// o.u(0xf0d5bad5, 0x4aba2525), o.u(0x753ee33e, 0x96e34b4b),
5002// o.u(0xac0ef30e, 0x5ff3a2a2), o.u(0x4419fe19, 0xbafe5d5d),
5003// o.u(0xdb5bc05b, 0x1bc08080), o.u(0x80858a85, 0xa8a0505),
5004// o.u(0xd3ecadec, 0x7ead3f3f), o.u(0xfedfbcdf, 0x42bc2121),
5005// o.u(0xa8d848d8, 0xe0487070), o.u(0xfd0c040c, 0xf904f1f1),
5006// o.u(0x197adf7a, 0xc6df6363), o.u(0x2f58c158, 0xeec17777),
5007// o.u(0x309f759f, 0x4575afaf), o.u(0xe7a563a5, 0x84634242),
5008// o.u(0x70503050, 0x40302020), o.u(0xcb2e1a2e, 0xd11ae5e5),
5009// o.u(0xef120e12, 0xe10efdfd), o.u(0x8b76db7, 0x656dbfbf),
5010// o.u(0x55d44cd4, 0x194c8181), o.u(0x243c143c, 0x30141818),
5011// o.u(0x795f355f, 0x4c352626), o.u(0xb2712f71, 0x9d2fc3c3),
5012// o.u(0x8638e138, 0x67e1bebe), o.u(0xc8fda2fd, 0x6aa23535),
5013// o.u(0xc74fcc4f, 0xbcc8888), o.u(0x654b394b, 0x5c392e2e),
5014// o.u(0x6af957f9, 0x3d579393), o.u(0x580df20d, 0xaaf25555),
5015// o.u(0x619d829d, 0xe382fcfc), o.u(0xb3c947c9, 0xf4477a7a),
5016// o.u(0x27efacef, 0x8bacc8c8), o.u(0x8832e732, 0x6fe7baba),
5017// o.u(0x4f7d2b7d, 0x642b3232), o.u(0x42a495a4, 0xd795e6e6),
5018// o.u(0x3bfba0fb, 0x9ba0c0c0), o.u(0xaab398b3, 0x32981919),
5019// o.u(0xf668d168, 0x27d19e9e), o.u(0x22817f81, 0x5d7fa3a3),
5020// o.u(0xeeaa66aa, 0x88664444), o.u(0xd6827e82, 0xa87e5454),
5021// o.u(0xdde6abe6, 0x76ab3b3b), o.u(0x959e839e, 0x16830b0b),
5022// o.u(0xc945ca45, 0x3ca8c8c), o.u(0xbc7b297b, 0x9529c7c7),
5023// o.u(0x56ed36e, 0xd6d36b6b), o.u(0x6c443c44, 0x503c2828),
5024// o.u(0x2c8b798b, 0x5579a7a7), o.u(0x813de23d, 0x63e2bcbc),
5025// o.u(0x31271d27, 0x2c1d1616), o.u(0x379a769a, 0x4176adad),
5026// o.u(0x964d3b4d, 0xad3bdbdb), o.u(0x9efa56fa, 0xc8566464),
5027// o.u(0xa6d24ed2, 0xe84e7474), o.u(0x36221e22, 0x281e1414),
5028// o.u(0xe476db76, 0x3fdb9292), o.u(0x121e0a1e, 0x180a0c0c),
5029// o.u(0xfcb46cb4, 0x906c4848), o.u(0x8f37e437, 0x6be4b8b8),
5030// o.u(0x78e75de7, 0x255d9f9f), o.u(0xfb26eb2, 0x616ebdbd),
5031// o.u(0x692aef2a, 0x86ef4343), o.u(0x35f1a6f1, 0x93a6c4c4),
5032// o.u(0xdae3a8e3, 0x72a83939), o.u(0xc6f7a4f7, 0x62a43131),
5033// o.u(0x8a593759, 0xbd37d3d3), o.u(0x74868b86, 0xff8bf2f2),
5034// o.u(0x83563256, 0xb132d5d5), o.u(0x4ec543c5, 0xd438b8b),
5035// o.u(0x85eb59eb, 0xdc596e6e), o.u(0x18c2b7c2, 0xafb7dada),
5036// o.u(0x8e8f8c8f, 0x28c0101), o.u(0x1dac64ac, 0x7964b1b1),
5037// o.u(0xf16dd26d, 0x23d29c9c), o.u(0x723be03b, 0x92e04949),
5038// o.u(0x1fc7b4c7, 0xabb4d8d8), o.u(0xb915fa15, 0x43faacac),
5039// o.u(0xfa090709, 0xfd07f3f3), o.u(0xa06f256f, 0x8525cfcf),
5040// o.u(0x20eaafea, 0x8fafcaca), o.u(0x7d898e89, 0xf38ef4f4),
5041// o.u(0x6720e920, 0x8ee94747), o.u(0x38281828, 0x20181010),
5042// o.u(0xb64d564, 0xded56f6f), o.u(0x73838883, 0xfb88f0f0),
5043// o.u(0xfbb16fb1, 0x946f4a4a), o.u(0xca967296, 0xb8725c5c),
5044// o.u(0x546c246c, 0x70243838), o.u(0x5f08f108, 0xaef15757),
5045// o.u(0x2152c752, 0xe6c77373), o.u(0x64f351f3, 0x35519797),
5046// o.u(0xae652365, 0x8d23cbcb), o.u(0x25847c84, 0x597ca1a1),
5047// o.u(0x57bf9cbf, 0xcb9ce8e8), o.u(0x5d632163, 0x7c213e3e),
5048// o.u(0xea7cdd7c, 0x37dd9696), o.u(0x1e7fdc7f, 0xc2dc6161),
5049// o.u(0x9c918691, 0x1a860d0d), o.u(0x9b948594, 0x1e850f0f),
5050// o.u(0x4bab90ab, 0xdb90e0e0), o.u(0xbac642c6, 0xf8427c7c),
5051// o.u(0x2657c457, 0xe2c47171), o.u(0x29e5aae5, 0x83aacccc),
5052// o.u(0xe373d873, 0x3bd89090), o.u(0x90f050f, 0xc050606),
5053// o.u(0xf4030103, 0xf501f7f7), o.u(0x2a361236, 0x38121c1c),
5054// o.u(0x3cfea3fe, 0x9fa3c2c2), o.u(0x8be15fe1, 0xd45f6a6a),
5055// o.u(0xbe10f910, 0x47f9aeae), o.u(0x26bd06b, 0xd2d06969),
5056// o.u(0xbfa891a8, 0x2e911717), o.u(0x71e858e8, 0x29589999),
5057// o.u(0x53692769, 0x74273a3a), o.u(0xf7d0b9d0, 0x4eb92727),
5058// o.u(0x91483848, 0xa938d9d9), o.u(0xde351335, 0xcd13ebeb),
5059// o.u(0xe5ceb3ce, 0x56b32b2b), o.u(0x77553355, 0x44332222),
5060// o.u(0x4d6bbd6, 0xbfbbd2d2), o.u(0x39907090, 0x4970a9a9),
5061// o.u(0x87808980, 0xe890707), o.u(0xc1f2a7f2, 0x66a73333),
5062// o.u(0xecc1b6c1, 0x5ab62d2d), o.u(0x5a662266, 0x78223c3c),
5063// o.u(0xb8ad92ad, 0x2a921515), o.u(0xa9602060, 0x8920c9c9),
5064// o.u(0x5cdb49db, 0x15498787), o.u(0xb01aff1a, 0x4fffaaaa),
5065// o.u(0xd8887888, 0xa0785050), o.u(0x2b8e7a8e, 0x517aa5a5),
5066// o.u(0x898a8f8a, 0x68f0303), o.u(0x4a13f813, 0xb2f85959),
5067// o.u(0x929b809b, 0x12800909), o.u(0x23391739, 0x34171a1a),
5068// o.u(0x1075da75, 0xcada6565), o.u(0x84533153, 0xb531d7d7),
5069// o.u(0xd551c651, 0x13c68484), o.u(0x3d3b8d3, 0xbbb8d0d0),
5070// o.u(0xdc5ec35e, 0x1fc38282), o.u(0xe2cbb0cb, 0x52b02929),
5071// o.u(0xc3997799, 0xb4775a5a), o.u(0x2d331133, 0x3c111e1e),
5072// o.u(0x3d46cb46, 0xf6cb7b7b), o.u(0xb71ffc1f, 0x4bfca8a8),
5073// o.u(0xc61d661, 0xdad66d6d), o.u(0x624e3a4e, 0x583a2c2c)
5074// ];
5075
5076var B64 = function(n, x) {
5077 if (n === 7) {
5078 return x.lo & 0xFF;
5079 }
5080 var bits = (7 - n) * 8;
5081 if (bits >= 32) { //faster than >= 32
5082 return (x.hi >>> (bits - 32)) & 0xFF;
5083 }
5084 else {
5085 var bitsOff32 = 32 - bits,
5086 toMoveDown = this.hi << bitsOff32 >>> bitsOff32;
5087 return (x.lo >>> bits | (toMoveDown << bitsOff32)) & 0xFF;
5088 }
5089}
5090
5091var j64 = [o.u(0, 0), o.u(0, 0x10), o.u(0, 0x20), o.u(0, 0x30), o.u(0, 0x40), o.u(0, 0x50), o.u(0, 0x60),
5092 o.u(0, 0x70), o.u(0, 0x80), o.u(0, 0x90), o.u(0, 0xA0), o.u(0, 0xB0), o.u(0, 0xC0),
5093 o.u(0, 0xD0), o.u(0, 0xE0), o.u(0, 0xF0)
5094];
5095
5096var nj64 = [o.u(0xFFFFFFFF, 0xFFFFFFFF), o.u(0xFFFFFFFF, 0xFFFFFFEF), o.u(0xFFFFFFFF, 0xFFFFFFDF), o.u(0xFFFFFFFF, 0xFFFFFFCF), o.u(0xFFFFFFFF, 0xFFFFFFBF), o.u(0xFFFFFFFF, 0xFFFFFFAF), o.u(0xFFFFFFFF, 0xFFFFFF9F),
5097 o.u(0xFFFFFFFF, 0xFFFFFF8F), o.u(0xFFFFFFFF, 0xFFFFFF7F), o.u(0xFFFFFFFF, 0xFFFFFF6F), o.u(0xFFFFFFFF, 0xFFFFFF5F), o.u(0xFFFFFFFF, 0xFFFFFF4F), o.u(0xFFFFFFFF, 0xFFFFFF3F),
5098 o.u(0xFFFFFFFF, 0xFFFFFF2F), o.u(0xFFFFFFFF, 0xFFFFFF1F), o.u(0xFFFFFFFF, 0xFFFFFF0F)
5099];
5100
5101var r64 = [o.u(0, 0), o.u(0, 1), o.u(0, 2), o.u(0, 3), o.u(0, 4), o.u(0, 5), o.u(0, 6), o.u(0, 7),
5102 o.u(0, 8), o.u(0, 9), o.u(0, 10), o.u(0, 11), o.u(0, 12), o.u(0, 13)
5103];
5104
5105var compress = function(int64buf, state) {
5106 var g = new Array(16);
5107 var m = new Array(16);
5108 for (var u = 0; u < 16; u++) {
5109 m[u] = int64buf[u];
5110 g[u] = m[u].xor(state[u]);
5111 }
5112 var t = new Array(16);
5113 for (var r = 0; r < 14; r++) {
5114 for (var i = 0; i < 16; i++) {
5115 g[i].setxor64(j64[i].plus(r64[r]).setShiftLeft(56));
5116 }
5117
5118 for (var u = 0; u < 16; u++) {
5119 t[u] = o.xor64(T0[B64(0, g[u])], T1[B64(1, g[(u + 1) & 0xF])], T2[B64(2, g[(u + 2) & 0xF])], T3[B64(3, g[(u + 3) & 0xF])], T4[B64(4, g[(u + 4) & 0xF])], T5[B64(5, g[(u + 5) & 0xF])], T6[B64(6, g[(u + 6) & 0xF])], T7[B64(7, g[(u + 11) & 0xF])]);
5120 }
5121 var temp = g;
5122 g = t;
5123 t = temp;
5124 }
5125 for (var r = 0; r < 14; r++) {
5126 for (var i = 0; i < 16; i++) {
5127 m[i].setxor64(r64[r], nj64[i]);
5128 }
5129 for (var u = 0; u < 16; u++) {
5130 t[u] = o.xor64(T0[B64(0, m[(u + 1) & 0xF])], T1[B64(1, m[(u + 3) & 0xF])], T2[B64(2, m[(u + 5) & 0xF])], T3[B64(3, m[(u + 11) & 0xF])], T4[B64(4, m[(u + 0) & 0xF])], T5[B64(5, m[(u + 2) & 0xF])], T6[B64(6, m[(u + 4) & 0xF])], T7[B64(7, m[(u + 6) & 0xF])]);
5131 }
5132 var temp = m;
5133 m = t;
5134 t = temp;
5135 }
5136 for (var u = 0; u < 16; u++) {
5137 state[u].setxor64(g[u], m[u]);
5138 }
5139}
5140
5141var final = function(state) {
5142 var g = new Array(16);
5143 o.bufferInsert64(g, 0, state, 16);
5144 var t = new Array(16);
5145 for (var r = 0; r < 14; r++) {
5146
5147 for (var i = 0; i < 16; i++) {
5148 g[i].setxor64(j64[i].plus(r64[r]).setShiftLeft(56));
5149 }
5150
5151 for (var u = 0; u < 16; u++) {
5152 t[u] = o.xor64(T0[B64(0, g[u])], T1[B64(1, g[(u + 1) & 0xF])], T2[B64(2, g[(u + 2) & 0xF])], T3[B64(3, g[(u + 3) & 0xF])], T4[B64(4, g[(u + 4) & 0xF])], T5[B64(5, g[(u + 5) & 0xF])], T6[B64(6, g[(u + 6) & 0xF])], T7[B64(7, g[(u + 11) & 0xF])]);
5153 }
5154 var temp = g;
5155 g = t;
5156 t = temp;
5157 }
5158 for (var u = 0; u < 16; u++)
5159 state[u].setxor64(g[u]);
5160}
5161
5162var groestl = function(ctx, data, len) {
5163 var buf, ptr;
5164 //create a local copy of states
5165 var V = new Array(16);
5166 buf = ctx.buffer;
5167 ptr = ctx.ptr;
5168 if (len < ctx.buffer.length - ptr) {
5169 o.bufferInsert(buf, ptr, data, data.length);
5170 ptr += data.length;
5171 ctx.ptr = ptr;
5172 return;
5173 }
5174 //perform a deep copy of current state
5175 o.bufferInsert(V, 0, ctx.state, 16);
5176 while (len > 0) {
5177 var clen = ctx.buffer.length - ptr;
5178 if (clen > len) clen = len;
5179 o.bufferInsert(buf, ptr, data, clen);
5180 ptr += clen;
5181 data = data.slice(clen);
5182 len -= clen;
5183 if (ptr === ctx.buffer.length) {
5184 var int64Buf = h.bytes2Int64Buffer(buf);
5185 compress(int64Buf, V);
5186 ctx.count.addOne();
5187 ptr = 0;
5188 }
5189 }
5190 ctx.state = V;
5191 ctx.ptr = ptr;
5192}
5193
5194var groestlClose = function(ctx) {
5195 var buf = ctx.buffer;
5196 var ptr = ctx.ptr;
5197 var pad = new Array(136);
5198 var len = buf.length;
5199 var padLen;
5200 var count;
5201 pad[0] = 0x80;
5202 if (ptr < 120) {
5203 padLen = 128 - ptr;
5204 count = ctx.count.plus(o.u(0, 1));
5205 }
5206 else {
5207 padLen = 256 - ptr;
5208 count = ctx.count.plus(o.u(0, 2));
5209 }
5210 o.bufferSet(pad, 1, 0, padLen - 9);
5211 h.bufferEncode64(pad, padLen - 8, count);
5212 groestl(ctx, pad, padLen);
5213 final(ctx.state);
5214 var out = new Array(16);
5215 for (var u = 0, v = 8; u < 8; u++, v++) {
5216 out[2 * u] = ctx.state[v].hi;
5217 out[2 * u + 1] = ctx.state[v].lo;
5218 }
5219 return out;
5220}
5221
5222module.exports = function(input, format, output) {
5223 var msg;
5224 if (format === 1) {
5225 msg = input;
5226 }
5227 else if (format === 2) {
5228 msg = h.int32Buffer2Bytes(input);
5229 }
5230 else {
5231 msg = h.string2bytes(input);
5232 }
5233 var ctx = {};
5234 ctx.state = new Array(16);
5235 for (var i = 0; i < 15; i++) {
5236 ctx.state[i] = new o.u64(0, 0);
5237 }
5238 ctx.state[15] = new o.u64(0, 512);
5239 ctx.ptr = 0;
5240 ctx.count = new o.u64(0,0);
5241 ctx.buffer = new Array(128);
5242 groestl(ctx, msg, msg.length);
5243 var r = groestlClose(ctx, 0, 0);
5244 var out;
5245 if (output === 2) {
5246 out = r;
5247 }
5248 else if (output === 1) {
5249 out = h.int32Buffer2Bytes(r)
5250 }
5251 else {
5252 out = h.int32ArrayToHexString(r)
5253 }
5254 return out;
5255}
5256},{"./helper":41,"./op":42}],41:[function(require,module,exports){
5257'use strict';
5258// String functions
5259
5260var op = require('./op.js');
5261
5262module.exports.int8ArrayToHexString = function toString(array) {
5263 var string = '';
5264
5265 for (var i = 0; i < array.length; i++) {
5266 if (array[i] < 16) {
5267 string += '0' + array[i].toString(16);
5268 }
5269 else {
5270 string += array[i].toString(16);
5271 }
5272 }
5273 return string;
5274}
5275
5276module.exports.int32ArrayToHexString = function toString(array) {
5277 var string = '';
5278 var len = array.length;
5279 for (var i = 0; i < len; i++) {
5280 var s = array[i];
5281 if (s < 0) {
5282 s = 0xFFFFFFFF + array[i] + 1;
5283 }
5284 var l = s.toString(16);
5285 var padding = 8;
5286 while (l.length < padding) {
5287 l = "0" + l;
5288 }
5289 string += l;
5290 }
5291 return string;
5292}
5293
5294module.exports.hex2string = function toString(s) {
5295 for (var c = [], len = s.length, i = 0; i < len; i += 2)
5296 c.push(String.fromCharCode(parseInt(s.substring(i, i + 2), 16)));
5297 return c.join('');
5298}
5299
5300module.exports.hex2bytes = function toString(s) {
5301 for (var c = [], len = s.length, i = 0; i < len; i += 2)
5302 c.push(parseInt(s.substring(i, i + 2), 16));
5303 return c;
5304}
5305/*
5306module.exports.string2hex = function toString(s) {
5307
5308 for (var p = [], len = s.length, i = 0; i < len; i++) {
5309 p.push((256 + s.charCodeAt(i)).toString(16).substring(1));
5310 }
5311 return p.join('');
5312}
5313*/
5314module.exports.string2bytes = function(s) {
5315 var len = s.length;
5316 var b = new Array(len);
5317 var i = 0;
5318 while (i < len) {
5319 b[i] = s.charCodeAt(i);
5320 i++;
5321 }
5322 return b;
5323}
5324/*
5325module.exports.bytes2Int16Buffer = function(b) {
5326 var len = b.length;
5327 var bufferLength = len ? (((len - 1) >>> 1) + 1) : 0;
5328 var buffer = new Array(bufferLength);
5329 var i = 0;
5330 var j = 0;
5331 while (i < len) {
5332 buffer[j] = (buffer[j] << 8) | b[i];
5333 i++;
5334 if (!(i % 2)) j++;
5335 }
5336 return buffer;
5337}
5338*/
5339
5340module.exports.bytes2Int32Buffer = function(b) {
5341 if (!b) return [];
5342 var len = b.length ? (((b.length - 1) >>> 2) + 1) : 0;
5343 var buffer = new Array(len);
5344 var j = 0;
5345 while (j < len) {
5346 buffer[j] = (b[j * 4] << 24) | (b[j * 4 + 1] << 16) | (b[j * 4 + 2] << 8) | b[j * 4 + 3];
5347 j++;
5348 }
5349 return buffer;
5350}
5351/*
5352module.exports.bytes2Int32BufferLeAligned = function(b) {
5353 var len = b.length;
5354 if (!len) return [];
5355 var len2 = len ? (((len - 1) >>> 2) + 1) : 0;
5356 var buffer = new Array(len);
5357 var j = 0;
5358 while (j < len2) {
5359 buffer[j] = (b[j * 4 + 3] << 24) | (b[j * 4 + 2] << 16) | (b[j * 4 + 1] << 8) | b[j * 4];
5360 j++;
5361 };
5362 return buffer;
5363}
5364*/
5365module.exports.bytes2Int64Buffer = function(b) {
5366 if (!b) return [];
5367 var len = b.length ? (((b.length - 1) >>> 3) + 1) : 0;
5368 var buffer = new Array(len);
5369 var j = 0;
5370 while (j < len) {
5371 buffer[j] = new op.u64((b[j * 8] << 24) | (b[j * 8 + 1] << 16) | (b[j * 8 + 2] << 8) | b[j * 8 + 3], (b[j * 8 + 4] << 24) | (b[j * 8 + 5] << 16) | (b[j * 8 + 6] << 8) | b[j * 8 + 7]);
5372 j++;
5373 }
5374 return buffer;
5375}
5376
5377module.exports.bytes2Int64BufferLeAligned = function(b) {
5378 if (!b) return [];
5379 var len = b.length ? ((( b.length - 1) >>> 3) + 1) : 0;
5380 var buffer = new Array(len);
5381 var j = 0;
5382 while (j < len) {
5383 buffer[j] = new op.u64((b[j * 8 + 7] << 24) | (b[j * 8 + 6] << 16) | (b[j * 8 + 5] << 8) | b[j * 8 + 4], (b[j * 8 + 3] << 24) | (b[j * 8 + 2] << 16) | (b[j * 8 + 1] << 8) | b[j * 8]);
5384 j++;
5385 }
5386 return buffer;
5387}
5388
5389module.exports.bufferEncode64leAligned = function(buffer, offset, uint64) {
5390 buffer[offset + 7] = uint64.hi >>> 24;
5391 buffer[offset + 6] = uint64.hi >>> 16 & 0xFF;
5392 buffer[offset + 5] = uint64.hi >>> 8 & 0xFF;
5393 buffer[offset + 4] = uint64.hi & 0xFF;
5394 buffer[offset + 3] = uint64.lo >>> 24;
5395 buffer[offset + 2] = uint64.lo >>> 16 & 0xFF;
5396 buffer[offset + 1] = uint64.lo >>> 8 & 0xFF;
5397 buffer[offset + 0] = uint64.lo & 0xFF;
5398}
5399
5400module.exports.bufferEncode64 = function(buffer, offset, uint64) {
5401 buffer[offset] = uint64.hi >>> 24;
5402 buffer[offset + 1] = uint64.hi >>> 16 & 0xFF;
5403 buffer[offset + 2] = uint64.hi >>> 8 & 0xFF;
5404 buffer[offset + 3] = uint64.hi & 0xFF;
5405 buffer[offset + 4] = uint64.lo >>> 24;
5406 buffer[offset + 5] = uint64.lo >>> 16 & 0xFF;
5407 buffer[offset + 6] = uint64.lo >>> 8 & 0xFF;
5408 buffer[offset + 7] = uint64.lo & 0xFF;
5409}
5410
5411module.exports.int32Buffer2Bytes = function(b) {
5412 var buffer = new Array(b.length);
5413 var len = b.length;
5414 var i = 0;
5415 while (i < len) {
5416 buffer[i * 4] = (b[i] & 0xFF000000) >>> 24;
5417 buffer[i * 4 + 1] = (b[i] & 0x00FF0000) >>> 16;
5418 buffer[i * 4 + 2] = (b[i] & 0x0000FF00) >>> 8;
5419 buffer[i * 4 + 3] = (b[i] & 0x000000FF);
5420 i++;
5421 }
5422 return buffer;
5423}
5424/*
5425module.exports.int64Buffer2Bytes = function(b) {
5426 var buffer = new Array(b.length);
5427 var i = 0;
5428 while (i < b.length) {
5429 buffer[i * 8] = (b[i].hi & 0xFF000000) >>> 24;
5430 buffer[i * 8 + 1] = (b[i].hi & 0x00FF0000) >>> 16;
5431 buffer[i * 8 + 2] = (b[i].hi & 0x0000FF00) >>> 8;
5432 buffer[i * 8 + 3] = (b[i].hi & 0x000000FF);
5433 buffer[i * 8 + 4] = (b[i].lo & 0xFF000000) >>> 24;
5434 buffer[i * 8 + 5] = (b[i].lo & 0x00FF0000) >>> 16;
5435 buffer[i * 8 + 6] = (b[i].lo & 0x0000FF00) >>> 8;
5436 buffer[i * 8 + 7] = (b[i].lo & 0x000000FF);
5437 i++;
5438 }
5439 return buffer;
5440}
5441*/
5442
5443module.exports.string2Int32Buffer = function(s) {
5444 return this.bytes2Int32Buffer(this.string2bytes(s));
5445}
5446
5447var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
5448
5449module.exports.b64Encode = function(input) {
5450 var output = "";
5451 var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
5452 var i = 0;
5453
5454 while (i < input.length) {
5455
5456 chr1 = input[i++];
5457 chr2 = input[i++];
5458 chr3 = input[i++];
5459
5460 enc1 = chr1 >> 2;
5461 enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
5462 enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
5463 enc4 = chr3 & 63;
5464
5465 if (isNaN(chr2)) {
5466 enc3 = enc4 = 64;
5467 }
5468 else if (isNaN(chr3)) {
5469 enc4 = 64;
5470 }
5471
5472 output +=
5473 keyStr.charAt(enc1) + keyStr.charAt(enc2) +
5474 keyStr.charAt(enc3) + keyStr.charAt(enc4);
5475 }
5476
5477 return output;
5478};
5479
5480module.exports.b64Decode = function(input) {
5481 var output = [];
5482 var chr1, chr2, chr3;
5483 var enc1, enc2, enc3, enc4;
5484 var i = 0;
5485
5486 input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
5487
5488 while (i < input.length) {
5489
5490 enc1 = keyStr.indexOf(input.charAt(i++));
5491 enc2 = keyStr.indexOf(input.charAt(i++));
5492 enc3 = keyStr.indexOf(input.charAt(i++));
5493 enc4 = keyStr.indexOf(input.charAt(i++));
5494
5495 chr1 = (enc1 << 2) | (enc2 >> 4);
5496 chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
5497 chr3 = ((enc3 & 3) << 6) | enc4;
5498
5499 output.push(chr1);
5500
5501 if (enc3 != 64) {
5502 output.push(chr2);
5503 }
5504 if (enc4 != 64) {
5505 output.push(chr3);
5506 }
5507 }
5508 return output;
5509};
5510},{"./op.js":42}],42:[function(require,module,exports){
5511'use strict';
5512//the right shift is important, it has to do with 32 bit operations in javascript, it will make things faster
5513function u64(h, l) {
5514 this.hi = h >>> 0;
5515 this.lo = l >>> 0;
5516}
5517
5518u64.prototype.set = function(oWord) {
5519 this.lo = oWord.lo;
5520 this.hi = oWord.hi;
5521}
5522
5523u64.prototype.add = function(oWord) {
5524 var lowest, lowMid, highMid, highest; //four parts of the whole 64 bit number..
5525
5526 //need to add the respective parts from each number and the carry if on is present..
5527 lowest = (this.lo & 0XFFFF) + (oWord.lo & 0XFFFF);
5528 lowMid = (this.lo >>> 16) + (oWord.lo >>> 16) + (lowest >>> 16);
5529 highMid = (this.hi & 0XFFFF) + (oWord.hi & 0XFFFF) + (lowMid >>> 16);
5530 highest = (this.hi >>> 16) + (oWord.hi >>> 16) + (highMid >>> 16);
5531
5532 //now set the hgih and the low accordingly..
5533 this.lo = (lowMid << 16) | (lowest & 0XFFFF);
5534 this.hi = (highest << 16) | (highMid & 0XFFFF);
5535
5536 return this; //for chaining..
5537};
5538
5539u64.prototype.addOne = function() {
5540 if (this.lo === -1 || this.lo === 0xFFFFFFFF) {
5541 this.lo = 0;
5542 this.hi++;
5543 }
5544 else {
5545 this.lo++;
5546 }
5547}
5548
5549u64.prototype.plus = function(oWord) {
5550 var c = new u64(0, 0);
5551 var lowest, lowMid, highMid, highest; //four parts of the whole 64 bit number..
5552
5553 //need to add the respective parts from each number and the carry if on is present..
5554 lowest = (this.lo & 0XFFFF) + (oWord.lo & 0XFFFF);
5555 lowMid = (this.lo >>> 16) + (oWord.lo >>> 16) + (lowest >>> 16);
5556 highMid = (this.hi & 0XFFFF) + (oWord.hi & 0XFFFF) + (lowMid >>> 16);
5557 highest = (this.hi >>> 16) + (oWord.hi >>> 16) + (highMid >>> 16);
5558
5559 //now set the hgih and the low accordingly..
5560 c.lo = (lowMid << 16) | (lowest & 0XFFFF);
5561 c.hi = (highest << 16) | (highMid & 0XFFFF);
5562
5563 return c; //for chaining..
5564};
5565
5566u64.prototype.not = function() {
5567 return new u64(~this.hi, ~this.lo);
5568}
5569
5570u64.prototype.one = function() {
5571 return new u64(0x0, 0x1);
5572}
5573
5574u64.prototype.zero = function() {
5575 return new u64(0x0, 0x0);
5576}
5577
5578u64.prototype.neg = function() {
5579 return this.not().plus(this.one());
5580}
5581
5582u64.prototype.minus = function(oWord) {
5583 return this.plus(oWord.neg());
5584};
5585
5586u64.prototype.isZero = function() {
5587 return (this.lo === 0) && (this.hi === 0);
5588}
5589
5590function isLong(obj) {
5591 return (obj && obj["__isLong__"]) === true;
5592}
5593
5594function fromNumber(value) {
5595 if (isNaN(value) || !isFinite(value))
5596 return this.zero();
5597 var pow32 = (1 << 32);
5598 return new u64((value % pow32) | 0, (value / pow32) | 0);
5599}
5600
5601u64.prototype.multiply = function(multiplier) {
5602 if (this.isZero())
5603 return this.zero();
5604 if (!isLong(multiplier))
5605 multiplier = fromNumber(multiplier);
5606 if (multiplier.isZero())
5607 return this.zero();
5608
5609 // Divide each long into 4 chunks of 16 bits, and then add up 4x4 products.
5610 // We can skip products that would overflow.
5611
5612 var a48 = this.hi >>> 16;
5613 var a32 = this.hi & 0xFFFF;
5614 var a16 = this.lo >>> 16;
5615 var a00 = this.lo & 0xFFFF;
5616
5617 var b48 = multiplier.hi >>> 16;
5618 var b32 = multiplier.hi & 0xFFFF;
5619 var b16 = multiplier.lo >>> 16;
5620 var b00 = multiplier.lo & 0xFFFF;
5621
5622 var c48 = 0,
5623 c32 = 0,
5624 c16 = 0,
5625 c00 = 0;
5626 c00 += a00 * b00;
5627 c16 += c00 >>> 16;
5628 c00 &= 0xFFFF;
5629 c16 += a16 * b00;
5630 c32 += c16 >>> 16;
5631 c16 &= 0xFFFF;
5632 c16 += a00 * b16;
5633 c32 += c16 >>> 16;
5634 c16 &= 0xFFFF;
5635 c32 += a32 * b00;
5636 c48 += c32 >>> 16;
5637 c32 &= 0xFFFF;
5638 c32 += a16 * b16;
5639 c48 += c32 >>> 16;
5640 c32 &= 0xFFFF;
5641 c32 += a00 * b32;
5642 c48 += c32 >>> 16;
5643 c32 &= 0xFFFF;
5644 c48 += a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48;
5645 c48 &= 0xFFFF;
5646 return new u64((c48 << 16) | c32, (c16 << 16) | c00);
5647};
5648
5649u64.prototype.shiftLeft = function(bits) {
5650 bits = bits % 64;
5651 var c = new u64(0, 0);
5652 if (bits === 0) {
5653 return this.clone();
5654 }
5655 else if (bits > 31) {
5656 c.lo = 0;
5657 c.hi = this.lo << (bits - 32);
5658 }
5659 else {
5660 var toMoveUp = this.lo >>> 32 - bits;
5661 c.lo = this.lo << bits;
5662 c.hi = (this.hi << bits) | toMoveUp;
5663 }
5664 return c; //for chaining..
5665};
5666
5667u64.prototype.setShiftLeft = function(bits) {
5668 if (bits === 0) {
5669 return this;
5670 }
5671 if (bits > 63) {
5672 bits = bits % 64;
5673 }
5674
5675 if (bits > 31) {
5676 this.hi = this.lo << (bits - 32);
5677 this.lo = 0;
5678 }
5679 else {
5680 var toMoveUp = this.lo >>> 32 - bits;
5681 this.lo <<= bits;
5682 this.hi = (this.hi << bits) | toMoveUp;
5683 }
5684 return this; //for chaining..
5685};
5686//Shifts this word by the given number of bits to the right (max 32)..
5687u64.prototype.shiftRight = function(bits) {
5688 bits = bits % 64;
5689 var c = new u64(0, 0);
5690 if (bits === 0) {
5691 return this.clone();
5692 }
5693 else if (bits >= 32) {
5694 c.hi = 0;
5695 c.lo = this.hi >>> (bits - 32);
5696 }
5697 else {
5698 var bitsOff32 = 32 - bits,
5699 toMoveDown = this.hi << bitsOff32 >>> bitsOff32;
5700 c.hi = this.hi >>> bits;
5701 c.lo = this.lo >>> bits | (toMoveDown << bitsOff32);
5702 }
5703 return c; //for chaining..
5704};
5705//Rotates the bits of this word round to the left (max 32)..
5706u64.prototype.rotateLeft = function(bits) {
5707 if (bits > 32) {
5708 return this.rotateRight(64 - bits);
5709 }
5710 var c = new u64(0, 0);
5711 if (bits === 0) {
5712 c.lo = this.lo >>> 0;
5713 c.hi = this.hi >>> 0;
5714 }
5715 else if (bits === 32) { //just switch high and low over in this case..
5716 c.lo = this.hi;
5717 c.hi = this.lo;
5718 }
5719 else {
5720 c.lo = (this.lo << bits) | (this.hi >>> (32 - bits));
5721 c.hi = (this.hi << bits) | (this.lo >>> (32 - bits));
5722 }
5723 return c; //for chaining..
5724};
5725
5726u64.prototype.setRotateLeft = function(bits) {
5727 if (bits > 32) {
5728 return this.setRotateRight(64 - bits);
5729 }
5730 var newHigh;
5731 if (bits === 0) {
5732 return this;
5733 }
5734 else if (bits === 32) { //just switch high and low over in this case..
5735 newHigh = this.lo;
5736 this.lo = this.hi;
5737 this.hi = newHigh;
5738 }
5739 else {
5740 newHigh = (this.hi << bits) | (this.lo >>> (32 - bits));
5741 this.lo = (this.lo << bits) | (this.hi >>> (32 - bits));
5742 this.hi = newHigh;
5743 }
5744 return this; //for chaining..
5745};
5746//Rotates the bits of this word round to the right (max 32)..
5747u64.prototype.rotateRight = function(bits) {
5748 if (bits > 32) {
5749 return this.rotateLeft(64 - bits);
5750 }
5751 var c = new u64(0, 0);
5752 if (bits === 0) {
5753 c.lo = this.lo >>> 0;
5754 c.hi = this.hi >>> 0;
5755 }
5756 else if (bits === 32) { //just switch high and low over in this case..
5757 c.lo = this.hi;
5758 c.hi = this.lo;
5759 }
5760 else {
5761 c.lo = (this.hi << (32 - bits)) | (this.lo >>> bits);
5762 c.hi = (this.lo << (32 - bits)) | (this.hi >>> bits);
5763 }
5764 return c; //for chaining..
5765};
5766u64.prototype.setFlip = function() {
5767 var newHigh;
5768 newHigh = this.lo;
5769 this.lo = this.hi;
5770 this.hi = newHigh;
5771 return this;
5772};
5773//Rotates the bits of this word round to the right (max 32)..
5774u64.prototype.setRotateRight = function(bits) {
5775 if (bits > 32) {
5776 return this.setRotateLeft(64 - bits);
5777 }
5778
5779 if (bits === 0) {
5780 return this;
5781 }
5782 else if (bits === 32) { //just switch high and low over in this case..
5783 var newHigh;
5784 newHigh = this.lo;
5785 this.lo = this.hi;
5786 this.hi = newHigh;
5787 }
5788 else {
5789 newHigh = (this.lo << (32 - bits)) | (this.hi >>> bits);
5790 this.lo = (this.hi << (32 - bits)) | (this.lo >>> bits);
5791 this.hi = newHigh;
5792 }
5793 return this; //for chaining..
5794};
5795//Xors this word with the given other..
5796u64.prototype.xor = function(oWord) {
5797 var c = new u64(0, 0);
5798 c.hi = this.hi ^ oWord.hi;
5799 c.lo = this.lo ^ oWord.lo;
5800 return c; //for chaining..
5801};
5802//Xors this word with the given other..
5803u64.prototype.setxorOne = function(oWord) {
5804 this.hi ^= oWord.hi;
5805 this.lo ^= oWord.lo;
5806 return this; //for chaining..
5807};
5808//Ands this word with the given other..
5809u64.prototype.and = function(oWord) {
5810 var c = new u64(0, 0);
5811 c.hi = this.hi & oWord.hi;
5812 c.lo = this.lo & oWord.lo;
5813 return c; //for chaining..
5814};
5815
5816//Creates a deep copy of this Word..
5817u64.prototype.clone = function() {
5818 return new u64(this.hi, this.lo);
5819};
5820
5821u64.prototype.setxor64 = function() {
5822 var a = arguments;
5823 var i = a.length;
5824 while (i--) {
5825 this.hi ^= a[i].hi;
5826 this.lo ^= a[i].lo;
5827 }
5828 return this;
5829}
5830
5831module.exports.u64 = u64;
5832
5833module.exports.u = function(h, l) {
5834 return new u64(h, l);
5835}
5836/*
5837module.exports.add64 = function(a, b) {
5838 var lowest, lowMid, highMid, highest; //four parts of the whole 64 bit number..
5839
5840 //need to add the respective parts from each number and the carry if on is present..
5841 lowest = (a.lo & 0XFFFF) + (b.lo & 0XFFFF);
5842 lowMid = (a.lo >>> 16) + (b.lo >>> 16) + (lowest >>> 16);
5843 highMid = (a.hi & 0XFFFF) + (b.hi & 0XFFFF) + (lowMid >>> 16);
5844 highest = (a.hi >>> 16) + (b.hi >>> 16) + (highMid >>> 16);
5845
5846 var r = new this.u64((highest << 16) | (highMid & 0XFFFF), (lowMid << 16) | (lowest & 0XFFFF));
5847
5848 return r;
5849};
5850*/
5851module.exports.xor64 = function() {
5852 var a = arguments,
5853 h = a[0].hi,
5854 l = a[0].lo;
5855 var i = a.length-1;
5856 do {
5857 h ^= a[i].hi;
5858 l ^= a[i].lo;
5859 i--;
5860 } while (i>0);
5861 return new this.u64(h, l);
5862}
5863
5864module.exports.clone64Array = function(array) {
5865 var i = 0;
5866 var len = array.length;
5867 var a = new Array(len);
5868 while(i<len) {
5869 a[i] = array[i];
5870 i++;
5871 }
5872 return a;
5873}
5874
5875//this shouldn't be a problem, but who knows in the future javascript might support 64bits
5876module.exports.t32 = function(x) {
5877 return (x & 0xFFFFFFFF)
5878}
5879
5880module.exports.rotl32 = function(x, c) {
5881 return (((x) << (c)) | ((x) >>> (32 - (c)))) & (0xFFFFFFFF);
5882}
5883
5884module.exports.rotr32 = function(x, c) {
5885 return this.rotl32(x, (32 - (c)));
5886}
5887
5888module.exports.swap32 = function(val) {
5889 return ((val & 0xFF) << 24) |
5890 ((val & 0xFF00) << 8) |
5891 ((val >>> 8) & 0xFF00) |
5892 ((val >>> 24) & 0xFF);
5893}
5894
5895module.exports.swap32Array = function(a) {
5896 //can't do this with map because of support for IE8 (Don't hate me plz).
5897 var i = 0, len = a.length;
5898 var r = new Array(i);
5899 while (i<len) {
5900 r[i] = (this.swap32(a[i]));
5901 i++;
5902 }
5903 return r;
5904}
5905
5906module.exports.xnd64 = function(x, y, z) {
5907 return new this.u64(x.hi ^ ((~y.hi) & z.hi), x.lo ^ ((~y.lo) & z.lo));
5908}
5909/*
5910module.exports.load64 = function(x, i) {
5911 var l = x[i] | (x[i + 1] << 8) | (x[i + 2] << 16) | (x[i + 3] << 24);
5912 var h = x[i + 4] | (x[i + 5] << 8) | (x[i + 6] << 16) | (x[i + 7] << 24);
5913 return new this.u64(h, l);
5914}
5915*/
5916module.exports.bufferInsert = function(buffer, bufferOffset, data, len, dataOffset) {
5917 dataOffset = dataOffset | 0;
5918 var i = 0;
5919 while (i < len) {
5920 buffer[i + bufferOffset] = data[i + dataOffset];
5921 i++;
5922 }
5923}
5924
5925module.exports.bufferInsert64 = function(buffer, bufferOffset, data, len) {
5926 var i = 0;
5927 while (i < len) {
5928 buffer[i + bufferOffset] = data[i].clone();
5929 i++;
5930 }
5931}
5932/*
5933module.exports.buffer2Insert = function(buffer, bufferOffset, bufferOffset2, data, len, len2) {
5934 while (len--) {
5935 var j = len2;
5936 while (j--) {
5937 buffer[len + bufferOffset][j + bufferOffset2] = data[len][j];
5938 }
5939 }
5940}
5941*/
5942module.exports.bufferInsertBackwards = function(buffer, bufferOffset, data, len) {
5943 var i = 0;
5944 while (i < len) {
5945 buffer[i + bufferOffset] = data[len - 1 - i];
5946 i++;
5947 }
5948}
5949
5950module.exports.bufferSet = function(buffer, bufferOffset, value, len) {
5951 var i = 0;
5952 while (i < len) {
5953 buffer[i + bufferOffset] = value;
5954 i++;
5955 }
5956}
5957
5958module.exports.bufferXORInsert = function(buffer, bufferOffset, data, dataOffset, len) {
5959 var i = 0;
5960 while (i < len) {
5961 buffer[i + bufferOffset] ^= data[i + dataOffset];
5962 i++;
5963 }
5964}
5965
5966module.exports.xORTable = function(d, s1, s2, len) {
5967 var i = 0;
5968 while (i < len) {
5969 d[i] = s1[i] ^ s2[i];
5970 i++
5971 }
5972}
5973
5974},{}],43:[function(require,module,exports){
5975'use strict'
5976var Buffer = require('safe-buffer').Buffer
5977var Transform = require('stream').Transform
5978var inherits = require('inherits')
5979
5980function throwIfNotStringOrBuffer (val, prefix) {
5981 if (!Buffer.isBuffer(val) && typeof val !== 'string') {
5982 throw new TypeError(prefix + ' must be a string or a buffer')
5983 }
5984}
5985
5986function HashBase (blockSize) {
5987 Transform.call(this)
5988
5989 this._block = Buffer.allocUnsafe(blockSize)
5990 this._blockSize = blockSize
5991 this._blockOffset = 0
5992 this._length = [0, 0, 0, 0]
5993
5994 this._finalized = false
5995}
5996
5997inherits(HashBase, Transform)
5998
5999HashBase.prototype._transform = function (chunk, encoding, callback) {
6000 var error = null
6001 try {
6002 this.update(chunk, encoding)
6003 } catch (err) {
6004 error = err
6005 }
6006
6007 callback(error)
6008}
6009
6010HashBase.prototype._flush = function (callback) {
6011 var error = null
6012 try {
6013 this.push(this.digest())
6014 } catch (err) {
6015 error = err
6016 }
6017
6018 callback(error)
6019}
6020
6021HashBase.prototype.update = function (data, encoding) {
6022 throwIfNotStringOrBuffer(data, 'Data')
6023 if (this._finalized) throw new Error('Digest already called')
6024 if (!Buffer.isBuffer(data)) data = Buffer.from(data, encoding)
6025
6026 // consume data
6027 var block = this._block
6028 var offset = 0
6029 while (this._blockOffset + data.length - offset >= this._blockSize) {
6030 for (var i = this._blockOffset; i < this._blockSize;) block[i++] = data[offset++]
6031 this._update()
6032 this._blockOffset = 0
6033 }
6034 while (offset < data.length) block[this._blockOffset++] = data[offset++]
6035
6036 // update length
6037 for (var j = 0, carry = data.length * 8; carry > 0; ++j) {
6038 this._length[j] += carry
6039 carry = (this._length[j] / 0x0100000000) | 0
6040 if (carry > 0) this._length[j] -= 0x0100000000 * carry
6041 }
6042
6043 return this
6044}
6045
6046HashBase.prototype._update = function () {
6047 throw new Error('_update is not implemented')
6048}
6049
6050HashBase.prototype.digest = function (encoding) {
6051 if (this._finalized) throw new Error('Digest already called')
6052 this._finalized = true
6053
6054 var digest = this._digest()
6055 if (encoding !== undefined) digest = digest.toString(encoding)
6056
6057 // reset state
6058 this._block.fill(0)
6059 this._blockOffset = 0
6060 for (var i = 0; i < 4; ++i) this._length[i] = 0
6061
6062 return digest
6063}
6064
6065HashBase.prototype._digest = function () {
6066 throw new Error('_digest is not implemented')
6067}
6068
6069module.exports = HashBase
6070
6071},{"inherits":44,"safe-buffer":47,"stream":215}],44:[function(require,module,exports){
6072if (typeof Object.create === 'function') {
6073 // implementation from standard node.js 'util' module
6074 module.exports = function inherits(ctor, superCtor) {
6075 if (superCtor) {
6076 ctor.super_ = superCtor
6077 ctor.prototype = Object.create(superCtor.prototype, {
6078 constructor: {
6079 value: ctor,
6080 enumerable: false,
6081 writable: true,
6082 configurable: true
6083 }
6084 })
6085 }
6086 };
6087} else {
6088 // old school shim for old browsers
6089 module.exports = function inherits(ctor, superCtor) {
6090 if (superCtor) {
6091 ctor.super_ = superCtor
6092 var TempCtor = function () {}
6093 TempCtor.prototype = superCtor.prototype
6094 ctor.prototype = new TempCtor()
6095 ctor.prototype.constructor = ctor
6096 }
6097 }
6098}
6099
6100},{}],45:[function(require,module,exports){
6101'use strict'
6102var inherits = require('inherits')
6103var HashBase = require('hash-base')
6104var Buffer = require('safe-buffer').Buffer
6105
6106var ARRAY16 = new Array(16)
6107
6108function MD5 () {
6109 HashBase.call(this, 64)
6110
6111 // state
6112 this._a = 0x67452301
6113 this._b = 0xefcdab89
6114 this._c = 0x98badcfe
6115 this._d = 0x10325476
6116}
6117
6118inherits(MD5, HashBase)
6119
6120MD5.prototype._update = function () {
6121 var M = ARRAY16
6122 for (var i = 0; i < 16; ++i) M[i] = this._block.readInt32LE(i * 4)
6123
6124 var a = this._a
6125 var b = this._b
6126 var c = this._c
6127 var d = this._d
6128
6129 a = fnF(a, b, c, d, M[0], 0xd76aa478, 7)
6130 d = fnF(d, a, b, c, M[1], 0xe8c7b756, 12)
6131 c = fnF(c, d, a, b, M[2], 0x242070db, 17)
6132 b = fnF(b, c, d, a, M[3], 0xc1bdceee, 22)
6133 a = fnF(a, b, c, d, M[4], 0xf57c0faf, 7)
6134 d = fnF(d, a, b, c, M[5], 0x4787c62a, 12)
6135 c = fnF(c, d, a, b, M[6], 0xa8304613, 17)
6136 b = fnF(b, c, d, a, M[7], 0xfd469501, 22)
6137 a = fnF(a, b, c, d, M[8], 0x698098d8, 7)
6138 d = fnF(d, a, b, c, M[9], 0x8b44f7af, 12)
6139 c = fnF(c, d, a, b, M[10], 0xffff5bb1, 17)
6140 b = fnF(b, c, d, a, M[11], 0x895cd7be, 22)
6141 a = fnF(a, b, c, d, M[12], 0x6b901122, 7)
6142 d = fnF(d, a, b, c, M[13], 0xfd987193, 12)
6143 c = fnF(c, d, a, b, M[14], 0xa679438e, 17)
6144 b = fnF(b, c, d, a, M[15], 0x49b40821, 22)
6145
6146 a = fnG(a, b, c, d, M[1], 0xf61e2562, 5)
6147 d = fnG(d, a, b, c, M[6], 0xc040b340, 9)
6148 c = fnG(c, d, a, b, M[11], 0x265e5a51, 14)
6149 b = fnG(b, c, d, a, M[0], 0xe9b6c7aa, 20)
6150 a = fnG(a, b, c, d, M[5], 0xd62f105d, 5)
6151 d = fnG(d, a, b, c, M[10], 0x02441453, 9)
6152 c = fnG(c, d, a, b, M[15], 0xd8a1e681, 14)
6153 b = fnG(b, c, d, a, M[4], 0xe7d3fbc8, 20)
6154 a = fnG(a, b, c, d, M[9], 0x21e1cde6, 5)
6155 d = fnG(d, a, b, c, M[14], 0xc33707d6, 9)
6156 c = fnG(c, d, a, b, M[3], 0xf4d50d87, 14)
6157 b = fnG(b, c, d, a, M[8], 0x455a14ed, 20)
6158 a = fnG(a, b, c, d, M[13], 0xa9e3e905, 5)
6159 d = fnG(d, a, b, c, M[2], 0xfcefa3f8, 9)
6160 c = fnG(c, d, a, b, M[7], 0x676f02d9, 14)
6161 b = fnG(b, c, d, a, M[12], 0x8d2a4c8a, 20)
6162
6163 a = fnH(a, b, c, d, M[5], 0xfffa3942, 4)
6164 d = fnH(d, a, b, c, M[8], 0x8771f681, 11)
6165 c = fnH(c, d, a, b, M[11], 0x6d9d6122, 16)
6166 b = fnH(b, c, d, a, M[14], 0xfde5380c, 23)
6167 a = fnH(a, b, c, d, M[1], 0xa4beea44, 4)
6168 d = fnH(d, a, b, c, M[4], 0x4bdecfa9, 11)
6169 c = fnH(c, d, a, b, M[7], 0xf6bb4b60, 16)
6170 b = fnH(b, c, d, a, M[10], 0xbebfbc70, 23)
6171 a = fnH(a, b, c, d, M[13], 0x289b7ec6, 4)
6172 d = fnH(d, a, b, c, M[0], 0xeaa127fa, 11)
6173 c = fnH(c, d, a, b, M[3], 0xd4ef3085, 16)
6174 b = fnH(b, c, d, a, M[6], 0x04881d05, 23)
6175 a = fnH(a, b, c, d, M[9], 0xd9d4d039, 4)
6176 d = fnH(d, a, b, c, M[12], 0xe6db99e5, 11)
6177 c = fnH(c, d, a, b, M[15], 0x1fa27cf8, 16)
6178 b = fnH(b, c, d, a, M[2], 0xc4ac5665, 23)
6179
6180 a = fnI(a, b, c, d, M[0], 0xf4292244, 6)
6181 d = fnI(d, a, b, c, M[7], 0x432aff97, 10)
6182 c = fnI(c, d, a, b, M[14], 0xab9423a7, 15)
6183 b = fnI(b, c, d, a, M[5], 0xfc93a039, 21)
6184 a = fnI(a, b, c, d, M[12], 0x655b59c3, 6)
6185 d = fnI(d, a, b, c, M[3], 0x8f0ccc92, 10)
6186 c = fnI(c, d, a, b, M[10], 0xffeff47d, 15)
6187 b = fnI(b, c, d, a, M[1], 0x85845dd1, 21)
6188 a = fnI(a, b, c, d, M[8], 0x6fa87e4f, 6)
6189 d = fnI(d, a, b, c, M[15], 0xfe2ce6e0, 10)
6190 c = fnI(c, d, a, b, M[6], 0xa3014314, 15)
6191 b = fnI(b, c, d, a, M[13], 0x4e0811a1, 21)
6192 a = fnI(a, b, c, d, M[4], 0xf7537e82, 6)
6193 d = fnI(d, a, b, c, M[11], 0xbd3af235, 10)
6194 c = fnI(c, d, a, b, M[2], 0x2ad7d2bb, 15)
6195 b = fnI(b, c, d, a, M[9], 0xeb86d391, 21)
6196
6197 this._a = (this._a + a) | 0
6198 this._b = (this._b + b) | 0
6199 this._c = (this._c + c) | 0
6200 this._d = (this._d + d) | 0
6201}
6202
6203MD5.prototype._digest = function () {
6204 // create padding and handle blocks
6205 this._block[this._blockOffset++] = 0x80
6206 if (this._blockOffset > 56) {
6207 this._block.fill(0, this._blockOffset, 64)
6208 this._update()
6209 this._blockOffset = 0
6210 }
6211
6212 this._block.fill(0, this._blockOffset, 56)
6213 this._block.writeUInt32LE(this._length[0], 56)
6214 this._block.writeUInt32LE(this._length[1], 60)
6215 this._update()
6216
6217 // produce result
6218 var buffer = Buffer.allocUnsafe(16)
6219 buffer.writeInt32LE(this._a, 0)
6220 buffer.writeInt32LE(this._b, 4)
6221 buffer.writeInt32LE(this._c, 8)
6222 buffer.writeInt32LE(this._d, 12)
6223 return buffer
6224}
6225
6226function rotl (x, n) {
6227 return (x << n) | (x >>> (32 - n))
6228}
6229
6230function fnF (a, b, c, d, m, k, s) {
6231 return (rotl((a + ((b & c) | ((~b) & d)) + m + k) | 0, s) + b) | 0
6232}
6233
6234function fnG (a, b, c, d, m, k, s) {
6235 return (rotl((a + ((b & d) | (c & (~d))) + m + k) | 0, s) + b) | 0
6236}
6237
6238function fnH (a, b, c, d, m, k, s) {
6239 return (rotl((a + (b ^ c ^ d) + m + k) | 0, s) + b) | 0
6240}
6241
6242function fnI (a, b, c, d, m, k, s) {
6243 return (rotl((a + ((c ^ (b | (~d)))) + m + k) | 0, s) + b) | 0
6244}
6245
6246module.exports = MD5
6247
6248},{"hash-base":43,"inherits":44,"safe-buffer":47}],46:[function(require,module,exports){
6249'use strict'
6250var Buffer = require('buffer').Buffer
6251var inherits = require('inherits')
6252var HashBase = require('hash-base')
6253
6254var ARRAY16 = new Array(16)
6255
6256var zl = [
6257 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
6258 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
6259 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
6260 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
6261 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
6262]
6263
6264var zr = [
6265 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
6266 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
6267 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
6268 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
6269 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
6270]
6271
6272var sl = [
6273 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
6274 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
6275 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
6276 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
6277 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
6278]
6279
6280var sr = [
6281 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
6282 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
6283 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
6284 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
6285 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
6286]
6287
6288var hl = [0x00000000, 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xa953fd4e]
6289var hr = [0x50a28be6, 0x5c4dd124, 0x6d703ef3, 0x7a6d76e9, 0x00000000]
6290
6291function RIPEMD160 () {
6292 HashBase.call(this, 64)
6293
6294 // state
6295 this._a = 0x67452301
6296 this._b = 0xefcdab89
6297 this._c = 0x98badcfe
6298 this._d = 0x10325476
6299 this._e = 0xc3d2e1f0
6300}
6301
6302inherits(RIPEMD160, HashBase)
6303
6304RIPEMD160.prototype._update = function () {
6305 var words = ARRAY16
6306 for (var j = 0; j < 16; ++j) words[j] = this._block.readInt32LE(j * 4)
6307
6308 var al = this._a | 0
6309 var bl = this._b | 0
6310 var cl = this._c | 0
6311 var dl = this._d | 0
6312 var el = this._e | 0
6313
6314 var ar = this._a | 0
6315 var br = this._b | 0
6316 var cr = this._c | 0
6317 var dr = this._d | 0
6318 var er = this._e | 0
6319
6320 // computation
6321 for (var i = 0; i < 80; i += 1) {
6322 var tl
6323 var tr
6324 if (i < 16) {
6325 tl = fn1(al, bl, cl, dl, el, words[zl[i]], hl[0], sl[i])
6326 tr = fn5(ar, br, cr, dr, er, words[zr[i]], hr[0], sr[i])
6327 } else if (i < 32) {
6328 tl = fn2(al, bl, cl, dl, el, words[zl[i]], hl[1], sl[i])
6329 tr = fn4(ar, br, cr, dr, er, words[zr[i]], hr[1], sr[i])
6330 } else if (i < 48) {
6331 tl = fn3(al, bl, cl, dl, el, words[zl[i]], hl[2], sl[i])
6332 tr = fn3(ar, br, cr, dr, er, words[zr[i]], hr[2], sr[i])
6333 } else if (i < 64) {
6334 tl = fn4(al, bl, cl, dl, el, words[zl[i]], hl[3], sl[i])
6335 tr = fn2(ar, br, cr, dr, er, words[zr[i]], hr[3], sr[i])
6336 } else { // if (i<80) {
6337 tl = fn5(al, bl, cl, dl, el, words[zl[i]], hl[4], sl[i])
6338 tr = fn1(ar, br, cr, dr, er, words[zr[i]], hr[4], sr[i])
6339 }
6340
6341 al = el
6342 el = dl
6343 dl = rotl(cl, 10)
6344 cl = bl
6345 bl = tl
6346
6347 ar = er
6348 er = dr
6349 dr = rotl(cr, 10)
6350 cr = br
6351 br = tr
6352 }
6353
6354 // update state
6355 var t = (this._b + cl + dr) | 0
6356 this._b = (this._c + dl + er) | 0
6357 this._c = (this._d + el + ar) | 0
6358 this._d = (this._e + al + br) | 0
6359 this._e = (this._a + bl + cr) | 0
6360 this._a = t
6361}
6362
6363RIPEMD160.prototype._digest = function () {
6364 // create padding and handle blocks
6365 this._block[this._blockOffset++] = 0x80
6366 if (this._blockOffset > 56) {
6367 this._block.fill(0, this._blockOffset, 64)
6368 this._update()
6369 this._blockOffset = 0
6370 }
6371
6372 this._block.fill(0, this._blockOffset, 56)
6373 this._block.writeUInt32LE(this._length[0], 56)
6374 this._block.writeUInt32LE(this._length[1], 60)
6375 this._update()
6376
6377 // produce result
6378 var buffer = Buffer.alloc ? Buffer.alloc(20) : new Buffer(20)
6379 buffer.writeInt32LE(this._a, 0)
6380 buffer.writeInt32LE(this._b, 4)
6381 buffer.writeInt32LE(this._c, 8)
6382 buffer.writeInt32LE(this._d, 12)
6383 buffer.writeInt32LE(this._e, 16)
6384 return buffer
6385}
6386
6387function rotl (x, n) {
6388 return (x << n) | (x >>> (32 - n))
6389}
6390
6391function fn1 (a, b, c, d, e, m, k, s) {
6392 return (rotl((a + (b ^ c ^ d) + m + k) | 0, s) + e) | 0
6393}
6394
6395function fn2 (a, b, c, d, e, m, k, s) {
6396 return (rotl((a + ((b & c) | ((~b) & d)) + m + k) | 0, s) + e) | 0
6397}
6398
6399function fn3 (a, b, c, d, e, m, k, s) {
6400 return (rotl((a + ((b | (~c)) ^ d) + m + k) | 0, s) + e) | 0
6401}
6402
6403function fn4 (a, b, c, d, e, m, k, s) {
6404 return (rotl((a + ((b & d) | (c & (~d))) + m + k) | 0, s) + e) | 0
6405}
6406
6407function fn5 (a, b, c, d, e, m, k, s) {
6408 return (rotl((a + (b ^ (c | (~d))) + m + k) | 0, s) + e) | 0
6409}
6410
6411module.exports = RIPEMD160
6412
6413},{"buffer":110,"hash-base":43,"inherits":44}],47:[function(require,module,exports){
6414/* eslint-disable node/no-deprecated-api */
6415var buffer = require('buffer')
6416var Buffer = buffer.Buffer
6417
6418// alternative to using Object.keys for old browsers
6419function copyProps (src, dst) {
6420 for (var key in src) {
6421 dst[key] = src[key]
6422 }
6423}
6424if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
6425 module.exports = buffer
6426} else {
6427 // Copy properties from require('buffer')
6428 copyProps(buffer, exports)
6429 exports.Buffer = SafeBuffer
6430}
6431
6432function SafeBuffer (arg, encodingOrOffset, length) {
6433 return Buffer(arg, encodingOrOffset, length)
6434}
6435
6436SafeBuffer.prototype = Object.create(Buffer.prototype)
6437
6438// Copy static methods from Buffer
6439copyProps(Buffer, SafeBuffer)
6440
6441SafeBuffer.from = function (arg, encodingOrOffset, length) {
6442 if (typeof arg === 'number') {
6443 throw new TypeError('Argument must not be a number')
6444 }
6445 return Buffer(arg, encodingOrOffset, length)
6446}
6447
6448SafeBuffer.alloc = function (size, fill, encoding) {
6449 if (typeof size !== 'number') {
6450 throw new TypeError('Argument must be a number')
6451 }
6452 var buf = Buffer(size)
6453 if (fill !== undefined) {
6454 if (typeof encoding === 'string') {
6455 buf.fill(fill, encoding)
6456 } else {
6457 buf.fill(fill)
6458 }
6459 } else {
6460 buf.fill(0)
6461 }
6462 return buf
6463}
6464
6465SafeBuffer.allocUnsafe = function (size) {
6466 if (typeof size !== 'number') {
6467 throw new TypeError('Argument must be a number')
6468 }
6469 return Buffer(size)
6470}
6471
6472SafeBuffer.allocUnsafeSlow = function (size) {
6473 if (typeof size !== 'number') {
6474 throw new TypeError('Argument must be a number')
6475 }
6476 return buffer.SlowBuffer(size)
6477}
6478
6479},{"buffer":110}],48:[function(require,module,exports){
6480const scrypt = require('./scryptSync')
6481scrypt.async = require('./scrypt')
6482module.exports = scrypt
6483
6484},{"./scrypt":49,"./scryptSync":50}],49:[function(require,module,exports){
6485const crypto = require('crypto')
6486const {
6487 checkAndInit,
6488 smix
6489} = require('./utils')
6490
6491// N = Cpu cost, r = Memory cost, p = parallelization cost
6492async function scrypt (key, salt, N, r, p, dkLen, progressCallback, promiseInterval) {
6493 const {
6494 XY,
6495 V,
6496 B32,
6497 x,
6498 _X,
6499 B,
6500 tickCallback
6501 } = checkAndInit(key, salt, N, r, p, dkLen, progressCallback)
6502
6503 for (var i = 0; i < p; i++) {
6504 await smix(B, i * 128 * r, r, N, V, XY, _X, B32, x, tickCallback, promiseInterval)
6505 }
6506
6507 return crypto.pbkdf2Sync(key, B, 1, dkLen, 'sha256')
6508}
6509
6510module.exports = scrypt
6511
6512},{"./utils":51,"crypto":118}],50:[function(require,module,exports){
6513const crypto = require('crypto')
6514const {
6515 checkAndInit,
6516 smixSync
6517} = require('./utils')
6518
6519// N = Cpu cost, r = Memory cost, p = parallelization cost
6520function scrypt (key, salt, N, r, p, dkLen, progressCallback) {
6521 const {
6522 XY,
6523 V,
6524 B32,
6525 x,
6526 _X,
6527 B,
6528 tickCallback
6529 } = checkAndInit(key, salt, N, r, p, dkLen, progressCallback)
6530
6531 for (var i = 0; i < p; i++) {
6532 smixSync(B, i * 128 * r, r, N, V, XY, _X, B32, x, tickCallback)
6533 }
6534
6535 return crypto.pbkdf2Sync(key, B, 1, dkLen, 'sha256')
6536}
6537
6538module.exports = scrypt
6539
6540},{"./utils":51,"crypto":118}],51:[function(require,module,exports){
6541(function (Buffer,setImmediate){
6542const crypto = require('crypto')
6543const MAX_VALUE = 0x7fffffff
6544const DEFAULT_PROMISE_INTERVAL = 5000
6545/* eslint-disable camelcase */
6546
6547function checkAndInit (key, salt, N, r, p, dkLen, progressCallback) {
6548 if (N === 0 || (N & (N - 1)) !== 0) throw Error('N must be > 0 and a power of 2')
6549
6550 if (N > MAX_VALUE / 128 / r) throw Error('Parameter N is too large')
6551 if (r > MAX_VALUE / 128 / p) throw Error('Parameter r is too large')
6552
6553 let XY = Buffer.alloc(256 * r)
6554 let V = Buffer.alloc(128 * r * N)
6555
6556 // pseudo global
6557 let B32 = new Int32Array(16) // salsa20_8
6558 let x = new Int32Array(16) // salsa20_8
6559 let _X = Buffer.alloc(64) // blockmix_salsa8
6560
6561 // pseudo global
6562 let B = crypto.pbkdf2Sync(key, salt, 1, p * 128 * r, 'sha256')
6563
6564 let tickCallback
6565 if (progressCallback) {
6566 let totalOps = p * N * 2
6567 let currentOp = 0
6568
6569 tickCallback = function () {
6570 ++currentOp
6571
6572 // send progress notifications once every 1,000 ops
6573 if (currentOp % 1000 === 0) {
6574 progressCallback({
6575 current: currentOp,
6576 total: totalOps,
6577 percent: (currentOp / totalOps) * 100.0
6578 })
6579 }
6580 }
6581 }
6582 return {
6583 XY,
6584 V,
6585 B32,
6586 x,
6587 _X,
6588 B,
6589 tickCallback
6590 }
6591}
6592
6593async function smix (B, Bi, r, N, V, XY, _X, B32, x, tickCallback, promiseInterval) {
6594 promiseInterval = promiseInterval || DEFAULT_PROMISE_INTERVAL
6595 let Xi = 0
6596 let Yi = 128 * r
6597 let i
6598
6599 B.copy(XY, Xi, Bi, Bi + Yi)
6600
6601 for (i = 0; i < N; i++) {
6602 XY.copy(V, i * Yi, Xi, Xi + Yi)
6603 if (i % promiseInterval === 0) {
6604 await new Promise(resolve => setImmediate(resolve))
6605 }
6606 blockmix_salsa8(XY, Xi, Yi, r, _X, B32, x)
6607
6608 if (tickCallback) tickCallback()
6609 }
6610
6611 for (i = 0; i < N; i++) {
6612 let offset = Xi + (2 * r - 1) * 64
6613 let j = XY.readUInt32LE(offset) & (N - 1)
6614 blockxor(V, j * Yi, XY, Xi, Yi)
6615 if (i % promiseInterval === 0) {
6616 await new Promise(resolve => setImmediate(resolve))
6617 }
6618 blockmix_salsa8(XY, Xi, Yi, r, _X, B32, x)
6619
6620 if (tickCallback) tickCallback()
6621 }
6622
6623 XY.copy(B, Bi, Xi, Xi + Yi)
6624}
6625
6626function smixSync (B, Bi, r, N, V, XY, _X, B32, x, tickCallback) {
6627 let Xi = 0
6628 let Yi = 128 * r
6629 let i
6630
6631 B.copy(XY, Xi, Bi, Bi + Yi)
6632
6633 for (i = 0; i < N; i++) {
6634 XY.copy(V, i * Yi, Xi, Xi + Yi)
6635 blockmix_salsa8(XY, Xi, Yi, r, _X, B32, x)
6636
6637 if (tickCallback) tickCallback()
6638 }
6639
6640 for (i = 0; i < N; i++) {
6641 let offset = Xi + (2 * r - 1) * 64
6642 let j = XY.readUInt32LE(offset) & (N - 1)
6643 blockxor(V, j * Yi, XY, Xi, Yi)
6644 blockmix_salsa8(XY, Xi, Yi, r, _X, B32, x)
6645
6646 if (tickCallback) tickCallback()
6647 }
6648
6649 XY.copy(B, Bi, Xi, Xi + Yi)
6650}
6651
6652function blockmix_salsa8 (BY, Bi, Yi, r, _X, B32, x) {
6653 let i
6654
6655 arraycopy(BY, Bi + (2 * r - 1) * 64, _X, 0, 64)
6656
6657 for (i = 0; i < 2 * r; i++) {
6658 blockxor(BY, i * 64, _X, 0, 64)
6659 salsa20_8(_X, B32, x)
6660 arraycopy(_X, 0, BY, Yi + (i * 64), 64)
6661 }
6662
6663 for (i = 0; i < r; i++) {
6664 arraycopy(BY, Yi + (i * 2) * 64, BY, Bi + (i * 64), 64)
6665 }
6666
6667 for (i = 0; i < r; i++) {
6668 arraycopy(BY, Yi + (i * 2 + 1) * 64, BY, Bi + (i + r) * 64, 64)
6669 }
6670}
6671
6672function R (a, b) {
6673 return (a << b) | (a >>> (32 - b))
6674}
6675
6676function salsa20_8 (B, B32, x) {
6677 let i
6678
6679 for (i = 0; i < 16; i++) {
6680 B32[i] = (B[i * 4 + 0] & 0xff) << 0
6681 B32[i] |= (B[i * 4 + 1] & 0xff) << 8
6682 B32[i] |= (B[i * 4 + 2] & 0xff) << 16
6683 B32[i] |= (B[i * 4 + 3] & 0xff) << 24
6684 // B32[i] = B.readUInt32LE(i*4) <--- this is signficantly slower even in Node.js
6685 }
6686
6687 arraycopy(B32, 0, x, 0, 16)
6688
6689 for (i = 8; i > 0; i -= 2) {
6690 x[4] ^= R(x[0] + x[12], 7)
6691 x[8] ^= R(x[4] + x[0], 9)
6692 x[12] ^= R(x[8] + x[4], 13)
6693 x[0] ^= R(x[12] + x[8], 18)
6694 x[9] ^= R(x[5] + x[1], 7)
6695 x[13] ^= R(x[9] + x[5], 9)
6696 x[1] ^= R(x[13] + x[9], 13)
6697 x[5] ^= R(x[1] + x[13], 18)
6698 x[14] ^= R(x[10] + x[6], 7)
6699 x[2] ^= R(x[14] + x[10], 9)
6700 x[6] ^= R(x[2] + x[14], 13)
6701 x[10] ^= R(x[6] + x[2], 18)
6702 x[3] ^= R(x[15] + x[11], 7)
6703 x[7] ^= R(x[3] + x[15], 9)
6704 x[11] ^= R(x[7] + x[3], 13)
6705 x[15] ^= R(x[11] + x[7], 18)
6706 x[1] ^= R(x[0] + x[3], 7)
6707 x[2] ^= R(x[1] + x[0], 9)
6708 x[3] ^= R(x[2] + x[1], 13)
6709 x[0] ^= R(x[3] + x[2], 18)
6710 x[6] ^= R(x[5] + x[4], 7)
6711 x[7] ^= R(x[6] + x[5], 9)
6712 x[4] ^= R(x[7] + x[6], 13)
6713 x[5] ^= R(x[4] + x[7], 18)
6714 x[11] ^= R(x[10] + x[9], 7)
6715 x[8] ^= R(x[11] + x[10], 9)
6716 x[9] ^= R(x[8] + x[11], 13)
6717 x[10] ^= R(x[9] + x[8], 18)
6718 x[12] ^= R(x[15] + x[14], 7)
6719 x[13] ^= R(x[12] + x[15], 9)
6720 x[14] ^= R(x[13] + x[12], 13)
6721 x[15] ^= R(x[14] + x[13], 18)
6722 }
6723
6724 for (i = 0; i < 16; ++i) B32[i] = x[i] + B32[i]
6725
6726 for (i = 0; i < 16; i++) {
6727 let bi = i * 4
6728 B[bi + 0] = (B32[i] >> 0 & 0xff)
6729 B[bi + 1] = (B32[i] >> 8 & 0xff)
6730 B[bi + 2] = (B32[i] >> 16 & 0xff)
6731 B[bi + 3] = (B32[i] >> 24 & 0xff)
6732 // B.writeInt32LE(B32[i], i*4) //<--- this is signficantly slower even in Node.js
6733 }
6734}
6735
6736// naive approach... going back to loop unrolling may yield additional performance
6737function blockxor (S, Si, D, Di, len) {
6738 for (let i = 0; i < len; i++) {
6739 D[Di + i] ^= S[Si + i]
6740 }
6741}
6742
6743function arraycopy (src, srcPos, dest, destPos, length) {
6744 if (Buffer.isBuffer(src) && Buffer.isBuffer(dest)) {
6745 src.copy(dest, destPos, srcPos, srcPos + length)
6746 } else {
6747 while (length--) {
6748 dest[destPos++] = src[srcPos++]
6749 }
6750 }
6751}
6752
6753module.exports = {
6754 checkAndInit,
6755 smix,
6756 smixSync
6757}
6758
6759}).call(this,require("buffer").Buffer,require("timers").setImmediate)
6760},{"buffer":110,"crypto":118,"timers":217}],52:[function(require,module,exports){
6761var Buffer = require('safe-buffer').Buffer
6762
6763// prototype class for hash functions
6764function Hash (blockSize, finalSize) {
6765 this._block = Buffer.alloc(blockSize)
6766 this._finalSize = finalSize
6767 this._blockSize = blockSize
6768 this._len = 0
6769}
6770
6771Hash.prototype.update = function (data, enc) {
6772 if (typeof data === 'string') {
6773 enc = enc || 'utf8'
6774 data = Buffer.from(data, enc)
6775 }
6776
6777 var block = this._block
6778 var blockSize = this._blockSize
6779 var length = data.length
6780 var accum = this._len
6781
6782 for (var offset = 0; offset < length;) {
6783 var assigned = accum % blockSize
6784 var remainder = Math.min(length - offset, blockSize - assigned)
6785
6786 for (var i = 0; i < remainder; i++) {
6787 block[assigned + i] = data[offset + i]
6788 }
6789
6790 accum += remainder
6791 offset += remainder
6792
6793 if ((accum % blockSize) === 0) {
6794 this._update(block)
6795 }
6796 }
6797
6798 this._len += length
6799 return this
6800}
6801
6802Hash.prototype.digest = function (enc) {
6803 var rem = this._len % this._blockSize
6804
6805 this._block[rem] = 0x80
6806
6807 // zero (rem + 1) trailing bits, where (rem + 1) is the smallest
6808 // non-negative solution to the equation (length + 1 + (rem + 1)) === finalSize mod blockSize
6809 this._block.fill(0, rem + 1)
6810
6811 if (rem >= this._finalSize) {
6812 this._update(this._block)
6813 this._block.fill(0)
6814 }
6815
6816 var bits = this._len * 8
6817
6818 // uint32
6819 if (bits <= 0xffffffff) {
6820 this._block.writeUInt32BE(bits, this._blockSize - 4)
6821
6822 // uint64
6823 } else {
6824 var lowBits = (bits & 0xffffffff) >>> 0
6825 var highBits = (bits - lowBits) / 0x100000000
6826
6827 this._block.writeUInt32BE(highBits, this._blockSize - 8)
6828 this._block.writeUInt32BE(lowBits, this._blockSize - 4)
6829 }
6830
6831 this._update(this._block)
6832 var hash = this._hash()
6833
6834 return enc ? hash.toString(enc) : hash
6835}
6836
6837Hash.prototype._update = function () {
6838 throw new Error('_update must be implemented by subclass')
6839}
6840
6841module.exports = Hash
6842
6843},{"safe-buffer":47}],53:[function(require,module,exports){
6844var exports = module.exports = function SHA (algorithm) {
6845 algorithm = algorithm.toLowerCase()
6846
6847 var Algorithm = exports[algorithm]
6848 if (!Algorithm) throw new Error(algorithm + ' is not supported (we accept pull requests)')
6849
6850 return new Algorithm()
6851}
6852
6853exports.sha = require('./sha')
6854exports.sha1 = require('./sha1')
6855exports.sha224 = require('./sha224')
6856exports.sha256 = require('./sha256')
6857exports.sha384 = require('./sha384')
6858exports.sha512 = require('./sha512')
6859
6860},{"./sha":54,"./sha1":55,"./sha224":56,"./sha256":57,"./sha384":58,"./sha512":59}],54:[function(require,module,exports){
6861/*
6862 * A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined
6863 * in FIPS PUB 180-1
6864 * This source code is derived from sha1.js of the same repository.
6865 * The difference between SHA-0 and SHA-1 is just a bitwise rotate left
6866 * operation was added.
6867 */
6868
6869var inherits = require('inherits')
6870var Hash = require('./hash')
6871var Buffer = require('safe-buffer').Buffer
6872
6873var K = [
6874 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
6875]
6876
6877var W = new Array(80)
6878
6879function Sha () {
6880 this.init()
6881 this._w = W
6882
6883 Hash.call(this, 64, 56)
6884}
6885
6886inherits(Sha, Hash)
6887
6888Sha.prototype.init = function () {
6889 this._a = 0x67452301
6890 this._b = 0xefcdab89
6891 this._c = 0x98badcfe
6892 this._d = 0x10325476
6893 this._e = 0xc3d2e1f0
6894
6895 return this
6896}
6897
6898function rotl5 (num) {
6899 return (num << 5) | (num >>> 27)
6900}
6901
6902function rotl30 (num) {
6903 return (num << 30) | (num >>> 2)
6904}
6905
6906function ft (s, b, c, d) {
6907 if (s === 0) return (b & c) | ((~b) & d)
6908 if (s === 2) return (b & c) | (b & d) | (c & d)
6909 return b ^ c ^ d
6910}
6911
6912Sha.prototype._update = function (M) {
6913 var W = this._w
6914
6915 var a = this._a | 0
6916 var b = this._b | 0
6917 var c = this._c | 0
6918 var d = this._d | 0
6919 var e = this._e | 0
6920
6921 for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
6922 for (; i < 80; ++i) W[i] = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]
6923
6924 for (var j = 0; j < 80; ++j) {
6925 var s = ~~(j / 20)
6926 var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0
6927
6928 e = d
6929 d = c
6930 c = rotl30(b)
6931 b = a
6932 a = t
6933 }
6934
6935 this._a = (a + this._a) | 0
6936 this._b = (b + this._b) | 0
6937 this._c = (c + this._c) | 0
6938 this._d = (d + this._d) | 0
6939 this._e = (e + this._e) | 0
6940}
6941
6942Sha.prototype._hash = function () {
6943 var H = Buffer.allocUnsafe(20)
6944
6945 H.writeInt32BE(this._a | 0, 0)
6946 H.writeInt32BE(this._b | 0, 4)
6947 H.writeInt32BE(this._c | 0, 8)
6948 H.writeInt32BE(this._d | 0, 12)
6949 H.writeInt32BE(this._e | 0, 16)
6950
6951 return H
6952}
6953
6954module.exports = Sha
6955
6956},{"./hash":52,"inherits":44,"safe-buffer":47}],55:[function(require,module,exports){
6957/*
6958 * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
6959 * in FIPS PUB 180-1
6960 * Version 2.1a Copyright Paul Johnston 2000 - 2002.
6961 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
6962 * Distributed under the BSD License
6963 * See http://pajhome.org.uk/crypt/md5 for details.
6964 */
6965
6966var inherits = require('inherits')
6967var Hash = require('./hash')
6968var Buffer = require('safe-buffer').Buffer
6969
6970var K = [
6971 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
6972]
6973
6974var W = new Array(80)
6975
6976function Sha1 () {
6977 this.init()
6978 this._w = W
6979
6980 Hash.call(this, 64, 56)
6981}
6982
6983inherits(Sha1, Hash)
6984
6985Sha1.prototype.init = function () {
6986 this._a = 0x67452301
6987 this._b = 0xefcdab89
6988 this._c = 0x98badcfe
6989 this._d = 0x10325476
6990 this._e = 0xc3d2e1f0
6991
6992 return this
6993}
6994
6995function rotl1 (num) {
6996 return (num << 1) | (num >>> 31)
6997}
6998
6999function rotl5 (num) {
7000 return (num << 5) | (num >>> 27)
7001}
7002
7003function rotl30 (num) {
7004 return (num << 30) | (num >>> 2)
7005}
7006
7007function ft (s, b, c, d) {
7008 if (s === 0) return (b & c) | ((~b) & d)
7009 if (s === 2) return (b & c) | (b & d) | (c & d)
7010 return b ^ c ^ d
7011}
7012
7013Sha1.prototype._update = function (M) {
7014 var W = this._w
7015
7016 var a = this._a | 0
7017 var b = this._b | 0
7018 var c = this._c | 0
7019 var d = this._d | 0
7020 var e = this._e | 0
7021
7022 for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
7023 for (; i < 80; ++i) W[i] = rotl1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16])
7024
7025 for (var j = 0; j < 80; ++j) {
7026 var s = ~~(j / 20)
7027 var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0
7028
7029 e = d
7030 d = c
7031 c = rotl30(b)
7032 b = a
7033 a = t
7034 }
7035
7036 this._a = (a + this._a) | 0
7037 this._b = (b + this._b) | 0
7038 this._c = (c + this._c) | 0
7039 this._d = (d + this._d) | 0
7040 this._e = (e + this._e) | 0
7041}
7042
7043Sha1.prototype._hash = function () {
7044 var H = Buffer.allocUnsafe(20)
7045
7046 H.writeInt32BE(this._a | 0, 0)
7047 H.writeInt32BE(this._b | 0, 4)
7048 H.writeInt32BE(this._c | 0, 8)
7049 H.writeInt32BE(this._d | 0, 12)
7050 H.writeInt32BE(this._e | 0, 16)
7051
7052 return H
7053}
7054
7055module.exports = Sha1
7056
7057},{"./hash":52,"inherits":44,"safe-buffer":47}],56:[function(require,module,exports){
7058/**
7059 * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
7060 * in FIPS 180-2
7061 * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
7062 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
7063 *
7064 */
7065
7066var inherits = require('inherits')
7067var Sha256 = require('./sha256')
7068var Hash = require('./hash')
7069var Buffer = require('safe-buffer').Buffer
7070
7071var W = new Array(64)
7072
7073function Sha224 () {
7074 this.init()
7075
7076 this._w = W // new Array(64)
7077
7078 Hash.call(this, 64, 56)
7079}
7080
7081inherits(Sha224, Sha256)
7082
7083Sha224.prototype.init = function () {
7084 this._a = 0xc1059ed8
7085 this._b = 0x367cd507
7086 this._c = 0x3070dd17
7087 this._d = 0xf70e5939
7088 this._e = 0xffc00b31
7089 this._f = 0x68581511
7090 this._g = 0x64f98fa7
7091 this._h = 0xbefa4fa4
7092
7093 return this
7094}
7095
7096Sha224.prototype._hash = function () {
7097 var H = Buffer.allocUnsafe(28)
7098
7099 H.writeInt32BE(this._a, 0)
7100 H.writeInt32BE(this._b, 4)
7101 H.writeInt32BE(this._c, 8)
7102 H.writeInt32BE(this._d, 12)
7103 H.writeInt32BE(this._e, 16)
7104 H.writeInt32BE(this._f, 20)
7105 H.writeInt32BE(this._g, 24)
7106
7107 return H
7108}
7109
7110module.exports = Sha224
7111
7112},{"./hash":52,"./sha256":57,"inherits":44,"safe-buffer":47}],57:[function(require,module,exports){
7113/**
7114 * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
7115 * in FIPS 180-2
7116 * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
7117 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
7118 *
7119 */
7120
7121var inherits = require('inherits')
7122var Hash = require('./hash')
7123var Buffer = require('safe-buffer').Buffer
7124
7125var K = [
7126 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,
7127 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,
7128 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,
7129 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174,
7130 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC,
7131 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,
7132 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7,
7133 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967,
7134 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,
7135 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85,
7136 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3,
7137 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,
7138 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5,
7139 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3,
7140 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,
7141 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2
7142]
7143
7144var W = new Array(64)
7145
7146function Sha256 () {
7147 this.init()
7148
7149 this._w = W // new Array(64)
7150
7151 Hash.call(this, 64, 56)
7152}
7153
7154inherits(Sha256, Hash)
7155
7156Sha256.prototype.init = function () {
7157 this._a = 0x6a09e667
7158 this._b = 0xbb67ae85
7159 this._c = 0x3c6ef372
7160 this._d = 0xa54ff53a
7161 this._e = 0x510e527f
7162 this._f = 0x9b05688c
7163 this._g = 0x1f83d9ab
7164 this._h = 0x5be0cd19
7165
7166 return this
7167}
7168
7169function ch (x, y, z) {
7170 return z ^ (x & (y ^ z))
7171}
7172
7173function maj (x, y, z) {
7174 return (x & y) | (z & (x | y))
7175}
7176
7177function sigma0 (x) {
7178 return (x >>> 2 | x << 30) ^ (x >>> 13 | x << 19) ^ (x >>> 22 | x << 10)
7179}
7180
7181function sigma1 (x) {
7182 return (x >>> 6 | x << 26) ^ (x >>> 11 | x << 21) ^ (x >>> 25 | x << 7)
7183}
7184
7185function gamma0 (x) {
7186 return (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ (x >>> 3)
7187}
7188
7189function gamma1 (x) {
7190 return (x >>> 17 | x << 15) ^ (x >>> 19 | x << 13) ^ (x >>> 10)
7191}
7192
7193Sha256.prototype._update = function (M) {
7194 var W = this._w
7195
7196 var a = this._a | 0
7197 var b = this._b | 0
7198 var c = this._c | 0
7199 var d = this._d | 0
7200 var e = this._e | 0
7201 var f = this._f | 0
7202 var g = this._g | 0
7203 var h = this._h | 0
7204
7205 for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
7206 for (; i < 64; ++i) W[i] = (gamma1(W[i - 2]) + W[i - 7] + gamma0(W[i - 15]) + W[i - 16]) | 0
7207
7208 for (var j = 0; j < 64; ++j) {
7209 var T1 = (h + sigma1(e) + ch(e, f, g) + K[j] + W[j]) | 0
7210 var T2 = (sigma0(a) + maj(a, b, c)) | 0
7211
7212 h = g
7213 g = f
7214 f = e
7215 e = (d + T1) | 0
7216 d = c
7217 c = b
7218 b = a
7219 a = (T1 + T2) | 0
7220 }
7221
7222 this._a = (a + this._a) | 0
7223 this._b = (b + this._b) | 0
7224 this._c = (c + this._c) | 0
7225 this._d = (d + this._d) | 0
7226 this._e = (e + this._e) | 0
7227 this._f = (f + this._f) | 0
7228 this._g = (g + this._g) | 0
7229 this._h = (h + this._h) | 0
7230}
7231
7232Sha256.prototype._hash = function () {
7233 var H = Buffer.allocUnsafe(32)
7234
7235 H.writeInt32BE(this._a, 0)
7236 H.writeInt32BE(this._b, 4)
7237 H.writeInt32BE(this._c, 8)
7238 H.writeInt32BE(this._d, 12)
7239 H.writeInt32BE(this._e, 16)
7240 H.writeInt32BE(this._f, 20)
7241 H.writeInt32BE(this._g, 24)
7242 H.writeInt32BE(this._h, 28)
7243
7244 return H
7245}
7246
7247module.exports = Sha256
7248
7249},{"./hash":52,"inherits":44,"safe-buffer":47}],58:[function(require,module,exports){
7250var inherits = require('inherits')
7251var SHA512 = require('./sha512')
7252var Hash = require('./hash')
7253var Buffer = require('safe-buffer').Buffer
7254
7255var W = new Array(160)
7256
7257function Sha384 () {
7258 this.init()
7259 this._w = W
7260
7261 Hash.call(this, 128, 112)
7262}
7263
7264inherits(Sha384, SHA512)
7265
7266Sha384.prototype.init = function () {
7267 this._ah = 0xcbbb9d5d
7268 this._bh = 0x629a292a
7269 this._ch = 0x9159015a
7270 this._dh = 0x152fecd8
7271 this._eh = 0x67332667
7272 this._fh = 0x8eb44a87
7273 this._gh = 0xdb0c2e0d
7274 this._hh = 0x47b5481d
7275
7276 this._al = 0xc1059ed8
7277 this._bl = 0x367cd507
7278 this._cl = 0x3070dd17
7279 this._dl = 0xf70e5939
7280 this._el = 0xffc00b31
7281 this._fl = 0x68581511
7282 this._gl = 0x64f98fa7
7283 this._hl = 0xbefa4fa4
7284
7285 return this
7286}
7287
7288Sha384.prototype._hash = function () {
7289 var H = Buffer.allocUnsafe(48)
7290
7291 function writeInt64BE (h, l, offset) {
7292 H.writeInt32BE(h, offset)
7293 H.writeInt32BE(l, offset + 4)
7294 }
7295
7296 writeInt64BE(this._ah, this._al, 0)
7297 writeInt64BE(this._bh, this._bl, 8)
7298 writeInt64BE(this._ch, this._cl, 16)
7299 writeInt64BE(this._dh, this._dl, 24)
7300 writeInt64BE(this._eh, this._el, 32)
7301 writeInt64BE(this._fh, this._fl, 40)
7302
7303 return H
7304}
7305
7306module.exports = Sha384
7307
7308},{"./hash":52,"./sha512":59,"inherits":44,"safe-buffer":47}],59:[function(require,module,exports){
7309var inherits = require('inherits')
7310var Hash = require('./hash')
7311var Buffer = require('safe-buffer').Buffer
7312
7313var K = [
7314 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
7315 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
7316 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
7317 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
7318 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
7319 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
7320 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
7321 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
7322 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
7323 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
7324 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
7325 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
7326 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
7327 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
7328 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
7329 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
7330 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
7331 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
7332 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
7333 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
7334 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
7335 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
7336 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
7337 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
7338 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
7339 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
7340 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
7341 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
7342 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
7343 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
7344 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
7345 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
7346 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
7347 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
7348 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
7349 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
7350 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
7351 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
7352 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
7353 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
7354]
7355
7356var W = new Array(160)
7357
7358function Sha512 () {
7359 this.init()
7360 this._w = W
7361
7362 Hash.call(this, 128, 112)
7363}
7364
7365inherits(Sha512, Hash)
7366
7367Sha512.prototype.init = function () {
7368 this._ah = 0x6a09e667
7369 this._bh = 0xbb67ae85
7370 this._ch = 0x3c6ef372
7371 this._dh = 0xa54ff53a
7372 this._eh = 0x510e527f
7373 this._fh = 0x9b05688c
7374 this._gh = 0x1f83d9ab
7375 this._hh = 0x5be0cd19
7376
7377 this._al = 0xf3bcc908
7378 this._bl = 0x84caa73b
7379 this._cl = 0xfe94f82b
7380 this._dl = 0x5f1d36f1
7381 this._el = 0xade682d1
7382 this._fl = 0x2b3e6c1f
7383 this._gl = 0xfb41bd6b
7384 this._hl = 0x137e2179
7385
7386 return this
7387}
7388
7389function Ch (x, y, z) {
7390 return z ^ (x & (y ^ z))
7391}
7392
7393function maj (x, y, z) {
7394 return (x & y) | (z & (x | y))
7395}
7396
7397function sigma0 (x, xl) {
7398 return (x >>> 28 | xl << 4) ^ (xl >>> 2 | x << 30) ^ (xl >>> 7 | x << 25)
7399}
7400
7401function sigma1 (x, xl) {
7402 return (x >>> 14 | xl << 18) ^ (x >>> 18 | xl << 14) ^ (xl >>> 9 | x << 23)
7403}
7404
7405function Gamma0 (x, xl) {
7406 return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7)
7407}
7408
7409function Gamma0l (x, xl) {
7410 return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7 | xl << 25)
7411}
7412
7413function Gamma1 (x, xl) {
7414 return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6)
7415}
7416
7417function Gamma1l (x, xl) {
7418 return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6 | xl << 26)
7419}
7420
7421function getCarry (a, b) {
7422 return (a >>> 0) < (b >>> 0) ? 1 : 0
7423}
7424
7425Sha512.prototype._update = function (M) {
7426 var W = this._w
7427
7428 var ah = this._ah | 0
7429 var bh = this._bh | 0
7430 var ch = this._ch | 0
7431 var dh = this._dh | 0
7432 var eh = this._eh | 0
7433 var fh = this._fh | 0
7434 var gh = this._gh | 0
7435 var hh = this._hh | 0
7436
7437 var al = this._al | 0
7438 var bl = this._bl | 0
7439 var cl = this._cl | 0
7440 var dl = this._dl | 0
7441 var el = this._el | 0
7442 var fl = this._fl | 0
7443 var gl = this._gl | 0
7444 var hl = this._hl | 0
7445
7446 for (var i = 0; i < 32; i += 2) {
7447 W[i] = M.readInt32BE(i * 4)
7448 W[i + 1] = M.readInt32BE(i * 4 + 4)
7449 }
7450 for (; i < 160; i += 2) {
7451 var xh = W[i - 15 * 2]
7452 var xl = W[i - 15 * 2 + 1]
7453 var gamma0 = Gamma0(xh, xl)
7454 var gamma0l = Gamma0l(xl, xh)
7455
7456 xh = W[i - 2 * 2]
7457 xl = W[i - 2 * 2 + 1]
7458 var gamma1 = Gamma1(xh, xl)
7459 var gamma1l = Gamma1l(xl, xh)
7460
7461 // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
7462 var Wi7h = W[i - 7 * 2]
7463 var Wi7l = W[i - 7 * 2 + 1]
7464
7465 var Wi16h = W[i - 16 * 2]
7466 var Wi16l = W[i - 16 * 2 + 1]
7467
7468 var Wil = (gamma0l + Wi7l) | 0
7469 var Wih = (gamma0 + Wi7h + getCarry(Wil, gamma0l)) | 0
7470 Wil = (Wil + gamma1l) | 0
7471 Wih = (Wih + gamma1 + getCarry(Wil, gamma1l)) | 0
7472 Wil = (Wil + Wi16l) | 0
7473 Wih = (Wih + Wi16h + getCarry(Wil, Wi16l)) | 0
7474
7475 W[i] = Wih
7476 W[i + 1] = Wil
7477 }
7478
7479 for (var j = 0; j < 160; j += 2) {
7480 Wih = W[j]
7481 Wil = W[j + 1]
7482
7483 var majh = maj(ah, bh, ch)
7484 var majl = maj(al, bl, cl)
7485
7486 var sigma0h = sigma0(ah, al)
7487 var sigma0l = sigma0(al, ah)
7488 var sigma1h = sigma1(eh, el)
7489 var sigma1l = sigma1(el, eh)
7490
7491 // t1 = h + sigma1 + ch + K[j] + W[j]
7492 var Kih = K[j]
7493 var Kil = K[j + 1]
7494
7495 var chh = Ch(eh, fh, gh)
7496 var chl = Ch(el, fl, gl)
7497
7498 var t1l = (hl + sigma1l) | 0
7499 var t1h = (hh + sigma1h + getCarry(t1l, hl)) | 0
7500 t1l = (t1l + chl) | 0
7501 t1h = (t1h + chh + getCarry(t1l, chl)) | 0
7502 t1l = (t1l + Kil) | 0
7503 t1h = (t1h + Kih + getCarry(t1l, Kil)) | 0
7504 t1l = (t1l + Wil) | 0
7505 t1h = (t1h + Wih + getCarry(t1l, Wil)) | 0
7506
7507 // t2 = sigma0 + maj
7508 var t2l = (sigma0l + majl) | 0
7509 var t2h = (sigma0h + majh + getCarry(t2l, sigma0l)) | 0
7510
7511 hh = gh
7512 hl = gl
7513 gh = fh
7514 gl = fl
7515 fh = eh
7516 fl = el
7517 el = (dl + t1l) | 0
7518 eh = (dh + t1h + getCarry(el, dl)) | 0
7519 dh = ch
7520 dl = cl
7521 ch = bh
7522 cl = bl
7523 bh = ah
7524 bl = al
7525 al = (t1l + t2l) | 0
7526 ah = (t1h + t2h + getCarry(al, t1l)) | 0
7527 }
7528
7529 this._al = (this._al + al) | 0
7530 this._bl = (this._bl + bl) | 0
7531 this._cl = (this._cl + cl) | 0
7532 this._dl = (this._dl + dl) | 0
7533 this._el = (this._el + el) | 0
7534 this._fl = (this._fl + fl) | 0
7535 this._gl = (this._gl + gl) | 0
7536 this._hl = (this._hl + hl) | 0
7537
7538 this._ah = (this._ah + ah + getCarry(this._al, al)) | 0
7539 this._bh = (this._bh + bh + getCarry(this._bl, bl)) | 0
7540 this._ch = (this._ch + ch + getCarry(this._cl, cl)) | 0
7541 this._dh = (this._dh + dh + getCarry(this._dl, dl)) | 0
7542 this._eh = (this._eh + eh + getCarry(this._el, el)) | 0
7543 this._fh = (this._fh + fh + getCarry(this._fl, fl)) | 0
7544 this._gh = (this._gh + gh + getCarry(this._gl, gl)) | 0
7545 this._hh = (this._hh + hh + getCarry(this._hl, hl)) | 0
7546}
7547
7548Sha512.prototype._hash = function () {
7549 var H = Buffer.allocUnsafe(64)
7550
7551 function writeInt64BE (h, l, offset) {
7552 H.writeInt32BE(h, offset)
7553 H.writeInt32BE(l, offset + 4)
7554 }
7555
7556 writeInt64BE(this._ah, this._al, 0)
7557 writeInt64BE(this._bh, this._bl, 8)
7558 writeInt64BE(this._ch, this._cl, 16)
7559 writeInt64BE(this._dh, this._dl, 24)
7560 writeInt64BE(this._eh, this._el, 32)
7561 writeInt64BE(this._fh, this._fl, 40)
7562 writeInt64BE(this._gh, this._gl, 48)
7563 writeInt64BE(this._hh, this._hl, 56)
7564
7565 return H
7566}
7567
7568module.exports = Sha512
7569
7570},{"./hash":52,"inherits":44,"safe-buffer":47}],60:[function(require,module,exports){
7571var asn1 = exports;
7572
7573asn1.bignum = require('bn.js');
7574
7575asn1.define = require('./asn1/api').define;
7576asn1.base = require('./asn1/base');
7577asn1.constants = require('./asn1/constants');
7578asn1.decoders = require('./asn1/decoders');
7579asn1.encoders = require('./asn1/encoders');
7580
7581},{"./asn1/api":61,"./asn1/base":63,"./asn1/constants":67,"./asn1/decoders":69,"./asn1/encoders":72,"bn.js":79}],61:[function(require,module,exports){
7582var asn1 = require('../asn1');
7583var inherits = require('inherits');
7584
7585var api = exports;
7586
7587api.define = function define(name, body) {
7588 return new Entity(name, body);
7589};
7590
7591function Entity(name, body) {
7592 this.name = name;
7593 this.body = body;
7594
7595 this.decoders = {};
7596 this.encoders = {};
7597};
7598
7599Entity.prototype._createNamed = function createNamed(base) {
7600 var named;
7601 try {
7602 named = require('vm').runInThisContext(
7603 '(function ' + this.name + '(entity) {\n' +
7604 ' this._initNamed(entity);\n' +
7605 '})'
7606 );
7607 } catch (e) {
7608 named = function (entity) {
7609 this._initNamed(entity);
7610 };
7611 }
7612 inherits(named, base);
7613 named.prototype._initNamed = function initnamed(entity) {
7614 base.call(this, entity);
7615 };
7616
7617 return new named(this);
7618};
7619
7620Entity.prototype._getDecoder = function _getDecoder(enc) {
7621 enc = enc || 'der';
7622 // Lazily create decoder
7623 if (!this.decoders.hasOwnProperty(enc))
7624 this.decoders[enc] = this._createNamed(asn1.decoders[enc]);
7625 return this.decoders[enc];
7626};
7627
7628Entity.prototype.decode = function decode(data, enc, options) {
7629 return this._getDecoder(enc).decode(data, options);
7630};
7631
7632Entity.prototype._getEncoder = function _getEncoder(enc) {
7633 enc = enc || 'der';
7634 // Lazily create encoder
7635 if (!this.encoders.hasOwnProperty(enc))
7636 this.encoders[enc] = this._createNamed(asn1.encoders[enc]);
7637 return this.encoders[enc];
7638};
7639
7640Entity.prototype.encode = function encode(data, enc, /* internal */ reporter) {
7641 return this._getEncoder(enc).encode(data, reporter);
7642};
7643
7644},{"../asn1":60,"inherits":162,"vm":219}],62:[function(require,module,exports){
7645var inherits = require('inherits');
7646var Reporter = require('../base').Reporter;
7647var Buffer = require('buffer').Buffer;
7648
7649function DecoderBuffer(base, options) {
7650 Reporter.call(this, options);
7651 if (!Buffer.isBuffer(base)) {
7652 this.error('Input not Buffer');
7653 return;
7654 }
7655
7656 this.base = base;
7657 this.offset = 0;
7658 this.length = base.length;
7659}
7660inherits(DecoderBuffer, Reporter);
7661exports.DecoderBuffer = DecoderBuffer;
7662
7663DecoderBuffer.prototype.save = function save() {
7664 return { offset: this.offset, reporter: Reporter.prototype.save.call(this) };
7665};
7666
7667DecoderBuffer.prototype.restore = function restore(save) {
7668 // Return skipped data
7669 var res = new DecoderBuffer(this.base);
7670 res.offset = save.offset;
7671 res.length = this.offset;
7672
7673 this.offset = save.offset;
7674 Reporter.prototype.restore.call(this, save.reporter);
7675
7676 return res;
7677};
7678
7679DecoderBuffer.prototype.isEmpty = function isEmpty() {
7680 return this.offset === this.length;
7681};
7682
7683DecoderBuffer.prototype.readUInt8 = function readUInt8(fail) {
7684 if (this.offset + 1 <= this.length)
7685 return this.base.readUInt8(this.offset++, true);
7686 else
7687 return this.error(fail || 'DecoderBuffer overrun');
7688}
7689
7690DecoderBuffer.prototype.skip = function skip(bytes, fail) {
7691 if (!(this.offset + bytes <= this.length))
7692 return this.error(fail || 'DecoderBuffer overrun');
7693
7694 var res = new DecoderBuffer(this.base);
7695
7696 // Share reporter state
7697 res._reporterState = this._reporterState;
7698
7699 res.offset = this.offset;
7700 res.length = this.offset + bytes;
7701 this.offset += bytes;
7702 return res;
7703}
7704
7705DecoderBuffer.prototype.raw = function raw(save) {
7706 return this.base.slice(save ? save.offset : this.offset, this.length);
7707}
7708
7709function EncoderBuffer(value, reporter) {
7710 if (Array.isArray(value)) {
7711 this.length = 0;
7712 this.value = value.map(function(item) {
7713 if (!(item instanceof EncoderBuffer))
7714 item = new EncoderBuffer(item, reporter);
7715 this.length += item.length;
7716 return item;
7717 }, this);
7718 } else if (typeof value === 'number') {
7719 if (!(0 <= value && value <= 0xff))
7720 return reporter.error('non-byte EncoderBuffer value');
7721 this.value = value;
7722 this.length = 1;
7723 } else if (typeof value === 'string') {
7724 this.value = value;
7725 this.length = Buffer.byteLength(value);
7726 } else if (Buffer.isBuffer(value)) {
7727 this.value = value;
7728 this.length = value.length;
7729 } else {
7730 return reporter.error('Unsupported type: ' + typeof value);
7731 }
7732}
7733exports.EncoderBuffer = EncoderBuffer;
7734
7735EncoderBuffer.prototype.join = function join(out, offset) {
7736 if (!out)
7737 out = new Buffer(this.length);
7738 if (!offset)
7739 offset = 0;
7740
7741 if (this.length === 0)
7742 return out;
7743
7744 if (Array.isArray(this.value)) {
7745 this.value.forEach(function(item) {
7746 item.join(out, offset);
7747 offset += item.length;
7748 });
7749 } else {
7750 if (typeof this.value === 'number')
7751 out[offset] = this.value;
7752 else if (typeof this.value === 'string')
7753 out.write(this.value, offset);
7754 else if (Buffer.isBuffer(this.value))
7755 this.value.copy(out, offset);
7756 offset += this.length;
7757 }
7758
7759 return out;
7760};
7761
7762},{"../base":63,"buffer":110,"inherits":162}],63:[function(require,module,exports){
7763var base = exports;
7764
7765base.Reporter = require('./reporter').Reporter;
7766base.DecoderBuffer = require('./buffer').DecoderBuffer;
7767base.EncoderBuffer = require('./buffer').EncoderBuffer;
7768base.Node = require('./node');
7769
7770},{"./buffer":62,"./node":64,"./reporter":65}],64:[function(require,module,exports){
7771var Reporter = require('../base').Reporter;
7772var EncoderBuffer = require('../base').EncoderBuffer;
7773var DecoderBuffer = require('../base').DecoderBuffer;
7774var assert = require('minimalistic-assert');
7775
7776// Supported tags
7777var tags = [
7778 'seq', 'seqof', 'set', 'setof', 'objid', 'bool',
7779 'gentime', 'utctime', 'null_', 'enum', 'int', 'objDesc',
7780 'bitstr', 'bmpstr', 'charstr', 'genstr', 'graphstr', 'ia5str', 'iso646str',
7781 'numstr', 'octstr', 'printstr', 't61str', 'unistr', 'utf8str', 'videostr'
7782];
7783
7784// Public methods list
7785var methods = [
7786 'key', 'obj', 'use', 'optional', 'explicit', 'implicit', 'def', 'choice',
7787 'any', 'contains'
7788].concat(tags);
7789
7790// Overrided methods list
7791var overrided = [
7792 '_peekTag', '_decodeTag', '_use',
7793 '_decodeStr', '_decodeObjid', '_decodeTime',
7794 '_decodeNull', '_decodeInt', '_decodeBool', '_decodeList',
7795
7796 '_encodeComposite', '_encodeStr', '_encodeObjid', '_encodeTime',
7797 '_encodeNull', '_encodeInt', '_encodeBool'
7798];
7799
7800function Node(enc, parent) {
7801 var state = {};
7802 this._baseState = state;
7803
7804 state.enc = enc;
7805
7806 state.parent = parent || null;
7807 state.children = null;
7808
7809 // State
7810 state.tag = null;
7811 state.args = null;
7812 state.reverseArgs = null;
7813 state.choice = null;
7814 state.optional = false;
7815 state.any = false;
7816 state.obj = false;
7817 state.use = null;
7818 state.useDecoder = null;
7819 state.key = null;
7820 state['default'] = null;
7821 state.explicit = null;
7822 state.implicit = null;
7823 state.contains = null;
7824
7825 // Should create new instance on each method
7826 if (!state.parent) {
7827 state.children = [];
7828 this._wrap();
7829 }
7830}
7831module.exports = Node;
7832
7833var stateProps = [
7834 'enc', 'parent', 'children', 'tag', 'args', 'reverseArgs', 'choice',
7835 'optional', 'any', 'obj', 'use', 'alteredUse', 'key', 'default', 'explicit',
7836 'implicit', 'contains'
7837];
7838
7839Node.prototype.clone = function clone() {
7840 var state = this._baseState;
7841 var cstate = {};
7842 stateProps.forEach(function(prop) {
7843 cstate[prop] = state[prop];
7844 });
7845 var res = new this.constructor(cstate.parent);
7846 res._baseState = cstate;
7847 return res;
7848};
7849
7850Node.prototype._wrap = function wrap() {
7851 var state = this._baseState;
7852 methods.forEach(function(method) {
7853 this[method] = function _wrappedMethod() {
7854 var clone = new this.constructor(this);
7855 state.children.push(clone);
7856 return clone[method].apply(clone, arguments);
7857 };
7858 }, this);
7859};
7860
7861Node.prototype._init = function init(body) {
7862 var state = this._baseState;
7863
7864 assert(state.parent === null);
7865 body.call(this);
7866
7867 // Filter children
7868 state.children = state.children.filter(function(child) {
7869 return child._baseState.parent === this;
7870 }, this);
7871 assert.equal(state.children.length, 1, 'Root node can have only one child');
7872};
7873
7874Node.prototype._useArgs = function useArgs(args) {
7875 var state = this._baseState;
7876
7877 // Filter children and args
7878 var children = args.filter(function(arg) {
7879 return arg instanceof this.constructor;
7880 }, this);
7881 args = args.filter(function(arg) {
7882 return !(arg instanceof this.constructor);
7883 }, this);
7884
7885 if (children.length !== 0) {
7886 assert(state.children === null);
7887 state.children = children;
7888
7889 // Replace parent to maintain backward link
7890 children.forEach(function(child) {
7891 child._baseState.parent = this;
7892 }, this);
7893 }
7894 if (args.length !== 0) {
7895 assert(state.args === null);
7896 state.args = args;
7897 state.reverseArgs = args.map(function(arg) {
7898 if (typeof arg !== 'object' || arg.constructor !== Object)
7899 return arg;
7900
7901 var res = {};
7902 Object.keys(arg).forEach(function(key) {
7903 if (key == (key | 0))
7904 key |= 0;
7905 var value = arg[key];
7906 res[value] = key;
7907 });
7908 return res;
7909 });
7910 }
7911};
7912
7913//
7914// Overrided methods
7915//
7916
7917overrided.forEach(function(method) {
7918 Node.prototype[method] = function _overrided() {
7919 var state = this._baseState;
7920 throw new Error(method + ' not implemented for encoding: ' + state.enc);
7921 };
7922});
7923
7924//
7925// Public methods
7926//
7927
7928tags.forEach(function(tag) {
7929 Node.prototype[tag] = function _tagMethod() {
7930 var state = this._baseState;
7931 var args = Array.prototype.slice.call(arguments);
7932
7933 assert(state.tag === null);
7934 state.tag = tag;
7935
7936 this._useArgs(args);
7937
7938 return this;
7939 };
7940});
7941
7942Node.prototype.use = function use(item) {
7943 assert(item);
7944 var state = this._baseState;
7945
7946 assert(state.use === null);
7947 state.use = item;
7948
7949 return this;
7950};
7951
7952Node.prototype.optional = function optional() {
7953 var state = this._baseState;
7954
7955 state.optional = true;
7956
7957 return this;
7958};
7959
7960Node.prototype.def = function def(val) {
7961 var state = this._baseState;
7962
7963 assert(state['default'] === null);
7964 state['default'] = val;
7965 state.optional = true;
7966
7967 return this;
7968};
7969
7970Node.prototype.explicit = function explicit(num) {
7971 var state = this._baseState;
7972
7973 assert(state.explicit === null && state.implicit === null);
7974 state.explicit = num;
7975
7976 return this;
7977};
7978
7979Node.prototype.implicit = function implicit(num) {
7980 var state = this._baseState;
7981
7982 assert(state.explicit === null && state.implicit === null);
7983 state.implicit = num;
7984
7985 return this;
7986};
7987
7988Node.prototype.obj = function obj() {
7989 var state = this._baseState;
7990 var args = Array.prototype.slice.call(arguments);
7991
7992 state.obj = true;
7993
7994 if (args.length !== 0)
7995 this._useArgs(args);
7996
7997 return this;
7998};
7999
8000Node.prototype.key = function key(newKey) {
8001 var state = this._baseState;
8002
8003 assert(state.key === null);
8004 state.key = newKey;
8005
8006 return this;
8007};
8008
8009Node.prototype.any = function any() {
8010 var state = this._baseState;
8011
8012 state.any = true;
8013
8014 return this;
8015};
8016
8017Node.prototype.choice = function choice(obj) {
8018 var state = this._baseState;
8019
8020 assert(state.choice === null);
8021 state.choice = obj;
8022 this._useArgs(Object.keys(obj).map(function(key) {
8023 return obj[key];
8024 }));
8025
8026 return this;
8027};
8028
8029Node.prototype.contains = function contains(item) {
8030 var state = this._baseState;
8031
8032 assert(state.use === null);
8033 state.contains = item;
8034
8035 return this;
8036};
8037
8038//
8039// Decoding
8040//
8041
8042Node.prototype._decode = function decode(input, options) {
8043 var state = this._baseState;
8044
8045 // Decode root node
8046 if (state.parent === null)
8047 return input.wrapResult(state.children[0]._decode(input, options));
8048
8049 var result = state['default'];
8050 var present = true;
8051
8052 var prevKey = null;
8053 if (state.key !== null)
8054 prevKey = input.enterKey(state.key);
8055
8056 // Check if tag is there
8057 if (state.optional) {
8058 var tag = null;
8059 if (state.explicit !== null)
8060 tag = state.explicit;
8061 else if (state.implicit !== null)
8062 tag = state.implicit;
8063 else if (state.tag !== null)
8064 tag = state.tag;
8065
8066 if (tag === null && !state.any) {
8067 // Trial and Error
8068 var save = input.save();
8069 try {
8070 if (state.choice === null)
8071 this._decodeGeneric(state.tag, input, options);
8072 else
8073 this._decodeChoice(input, options);
8074 present = true;
8075 } catch (e) {
8076 present = false;
8077 }
8078 input.restore(save);
8079 } else {
8080 present = this._peekTag(input, tag, state.any);
8081
8082 if (input.isError(present))
8083 return present;
8084 }
8085 }
8086
8087 // Push object on stack
8088 var prevObj;
8089 if (state.obj && present)
8090 prevObj = input.enterObject();
8091
8092 if (present) {
8093 // Unwrap explicit values
8094 if (state.explicit !== null) {
8095 var explicit = this._decodeTag(input, state.explicit);
8096 if (input.isError(explicit))
8097 return explicit;
8098 input = explicit;
8099 }
8100
8101 var start = input.offset;
8102
8103 // Unwrap implicit and normal values
8104 if (state.use === null && state.choice === null) {
8105 if (state.any)
8106 var save = input.save();
8107 var body = this._decodeTag(
8108 input,
8109 state.implicit !== null ? state.implicit : state.tag,
8110 state.any
8111 );
8112 if (input.isError(body))
8113 return body;
8114
8115 if (state.any)
8116 result = input.raw(save);
8117 else
8118 input = body;
8119 }
8120
8121 if (options && options.track && state.tag !== null)
8122 options.track(input.path(), start, input.length, 'tagged');
8123
8124 if (options && options.track && state.tag !== null)
8125 options.track(input.path(), input.offset, input.length, 'content');
8126
8127 // Select proper method for tag
8128 if (state.any)
8129 result = result;
8130 else if (state.choice === null)
8131 result = this._decodeGeneric(state.tag, input, options);
8132 else
8133 result = this._decodeChoice(input, options);
8134
8135 if (input.isError(result))
8136 return result;
8137
8138 // Decode children
8139 if (!state.any && state.choice === null && state.children !== null) {
8140 state.children.forEach(function decodeChildren(child) {
8141 // NOTE: We are ignoring errors here, to let parser continue with other
8142 // parts of encoded data
8143 child._decode(input, options);
8144 });
8145 }
8146
8147 // Decode contained/encoded by schema, only in bit or octet strings
8148 if (state.contains && (state.tag === 'octstr' || state.tag === 'bitstr')) {
8149 var data = new DecoderBuffer(result);
8150 result = this._getUse(state.contains, input._reporterState.obj)
8151 ._decode(data, options);
8152 }
8153 }
8154
8155 // Pop object
8156 if (state.obj && present)
8157 result = input.leaveObject(prevObj);
8158
8159 // Set key
8160 if (state.key !== null && (result !== null || present === true))
8161 input.leaveKey(prevKey, state.key, result);
8162 else if (prevKey !== null)
8163 input.exitKey(prevKey);
8164
8165 return result;
8166};
8167
8168Node.prototype._decodeGeneric = function decodeGeneric(tag, input, options) {
8169 var state = this._baseState;
8170
8171 if (tag === 'seq' || tag === 'set')
8172 return null;
8173 if (tag === 'seqof' || tag === 'setof')
8174 return this._decodeList(input, tag, state.args[0], options);
8175 else if (/str$/.test(tag))
8176 return this._decodeStr(input, tag, options);
8177 else if (tag === 'objid' && state.args)
8178 return this._decodeObjid(input, state.args[0], state.args[1], options);
8179 else if (tag === 'objid')
8180 return this._decodeObjid(input, null, null, options);
8181 else if (tag === 'gentime' || tag === 'utctime')
8182 return this._decodeTime(input, tag, options);
8183 else if (tag === 'null_')
8184 return this._decodeNull(input, options);
8185 else if (tag === 'bool')
8186 return this._decodeBool(input, options);
8187 else if (tag === 'objDesc')
8188 return this._decodeStr(input, tag, options);
8189 else if (tag === 'int' || tag === 'enum')
8190 return this._decodeInt(input, state.args && state.args[0], options);
8191
8192 if (state.use !== null) {
8193 return this._getUse(state.use, input._reporterState.obj)
8194 ._decode(input, options);
8195 } else {
8196 return input.error('unknown tag: ' + tag);
8197 }
8198};
8199
8200Node.prototype._getUse = function _getUse(entity, obj) {
8201
8202 var state = this._baseState;
8203 // Create altered use decoder if implicit is set
8204 state.useDecoder = this._use(entity, obj);
8205 assert(state.useDecoder._baseState.parent === null);
8206 state.useDecoder = state.useDecoder._baseState.children[0];
8207 if (state.implicit !== state.useDecoder._baseState.implicit) {
8208 state.useDecoder = state.useDecoder.clone();
8209 state.useDecoder._baseState.implicit = state.implicit;
8210 }
8211 return state.useDecoder;
8212};
8213
8214Node.prototype._decodeChoice = function decodeChoice(input, options) {
8215 var state = this._baseState;
8216 var result = null;
8217 var match = false;
8218
8219 Object.keys(state.choice).some(function(key) {
8220 var save = input.save();
8221 var node = state.choice[key];
8222 try {
8223 var value = node._decode(input, options);
8224 if (input.isError(value))
8225 return false;
8226
8227 result = { type: key, value: value };
8228 match = true;
8229 } catch (e) {
8230 input.restore(save);
8231 return false;
8232 }
8233 return true;
8234 }, this);
8235
8236 if (!match)
8237 return input.error('Choice not matched');
8238
8239 return result;
8240};
8241
8242//
8243// Encoding
8244//
8245
8246Node.prototype._createEncoderBuffer = function createEncoderBuffer(data) {
8247 return new EncoderBuffer(data, this.reporter);
8248};
8249
8250Node.prototype._encode = function encode(data, reporter, parent) {
8251 var state = this._baseState;
8252 if (state['default'] !== null && state['default'] === data)
8253 return;
8254
8255 var result = this._encodeValue(data, reporter, parent);
8256 if (result === undefined)
8257 return;
8258
8259 if (this._skipDefault(result, reporter, parent))
8260 return;
8261
8262 return result;
8263};
8264
8265Node.prototype._encodeValue = function encode(data, reporter, parent) {
8266 var state = this._baseState;
8267
8268 // Decode root node
8269 if (state.parent === null)
8270 return state.children[0]._encode(data, reporter || new Reporter());
8271
8272 var result = null;
8273
8274 // Set reporter to share it with a child class
8275 this.reporter = reporter;
8276
8277 // Check if data is there
8278 if (state.optional && data === undefined) {
8279 if (state['default'] !== null)
8280 data = state['default']
8281 else
8282 return;
8283 }
8284
8285 // Encode children first
8286 var content = null;
8287 var primitive = false;
8288 if (state.any) {
8289 // Anything that was given is translated to buffer
8290 result = this._createEncoderBuffer(data);
8291 } else if (state.choice) {
8292 result = this._encodeChoice(data, reporter);
8293 } else if (state.contains) {
8294 content = this._getUse(state.contains, parent)._encode(data, reporter);
8295 primitive = true;
8296 } else if (state.children) {
8297 content = state.children.map(function(child) {
8298 if (child._baseState.tag === 'null_')
8299 return child._encode(null, reporter, data);
8300
8301 if (child._baseState.key === null)
8302 return reporter.error('Child should have a key');
8303 var prevKey = reporter.enterKey(child._baseState.key);
8304
8305 if (typeof data !== 'object')
8306 return reporter.error('Child expected, but input is not object');
8307
8308 var res = child._encode(data[child._baseState.key], reporter, data);
8309 reporter.leaveKey(prevKey);
8310
8311 return res;
8312 }, this).filter(function(child) {
8313 return child;
8314 });
8315 content = this._createEncoderBuffer(content);
8316 } else {
8317 if (state.tag === 'seqof' || state.tag === 'setof') {
8318 // TODO(indutny): this should be thrown on DSL level
8319 if (!(state.args && state.args.length === 1))
8320 return reporter.error('Too many args for : ' + state.tag);
8321
8322 if (!Array.isArray(data))
8323 return reporter.error('seqof/setof, but data is not Array');
8324
8325 var child = this.clone();
8326 child._baseState.implicit = null;
8327 content = this._createEncoderBuffer(data.map(function(item) {
8328 var state = this._baseState;
8329
8330 return this._getUse(state.args[0], data)._encode(item, reporter);
8331 }, child));
8332 } else if (state.use !== null) {
8333 result = this._getUse(state.use, parent)._encode(data, reporter);
8334 } else {
8335 content = this._encodePrimitive(state.tag, data);
8336 primitive = true;
8337 }
8338 }
8339
8340 // Encode data itself
8341 var result;
8342 if (!state.any && state.choice === null) {
8343 var tag = state.implicit !== null ? state.implicit : state.tag;
8344 var cls = state.implicit === null ? 'universal' : 'context';
8345
8346 if (tag === null) {
8347 if (state.use === null)
8348 reporter.error('Tag could be omitted only for .use()');
8349 } else {
8350 if (state.use === null)
8351 result = this._encodeComposite(tag, primitive, cls, content);
8352 }
8353 }
8354
8355 // Wrap in explicit
8356 if (state.explicit !== null)
8357 result = this._encodeComposite(state.explicit, false, 'context', result);
8358
8359 return result;
8360};
8361
8362Node.prototype._encodeChoice = function encodeChoice(data, reporter) {
8363 var state = this._baseState;
8364
8365 var node = state.choice[data.type];
8366 if (!node) {
8367 assert(
8368 false,
8369 data.type + ' not found in ' +
8370 JSON.stringify(Object.keys(state.choice)));
8371 }
8372 return node._encode(data.value, reporter);
8373};
8374
8375Node.prototype._encodePrimitive = function encodePrimitive(tag, data) {
8376 var state = this._baseState;
8377
8378 if (/str$/.test(tag))
8379 return this._encodeStr(data, tag);
8380 else if (tag === 'objid' && state.args)
8381 return this._encodeObjid(data, state.reverseArgs[0], state.args[1]);
8382 else if (tag === 'objid')
8383 return this._encodeObjid(data, null, null);
8384 else if (tag === 'gentime' || tag === 'utctime')
8385 return this._encodeTime(data, tag);
8386 else if (tag === 'null_')
8387 return this._encodeNull();
8388 else if (tag === 'int' || tag === 'enum')
8389 return this._encodeInt(data, state.args && state.reverseArgs[0]);
8390 else if (tag === 'bool')
8391 return this._encodeBool(data);
8392 else if (tag === 'objDesc')
8393 return this._encodeStr(data, tag);
8394 else
8395 throw new Error('Unsupported tag: ' + tag);
8396};
8397
8398Node.prototype._isNumstr = function isNumstr(str) {
8399 return /^[0-9 ]*$/.test(str);
8400};
8401
8402Node.prototype._isPrintstr = function isPrintstr(str) {
8403 return /^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(str);
8404};
8405
8406},{"../base":63,"minimalistic-assert":167}],65:[function(require,module,exports){
8407var inherits = require('inherits');
8408
8409function Reporter(options) {
8410 this._reporterState = {
8411 obj: null,
8412 path: [],
8413 options: options || {},
8414 errors: []
8415 };
8416}
8417exports.Reporter = Reporter;
8418
8419Reporter.prototype.isError = function isError(obj) {
8420 return obj instanceof ReporterError;
8421};
8422
8423Reporter.prototype.save = function save() {
8424 var state = this._reporterState;
8425
8426 return { obj: state.obj, pathLen: state.path.length };
8427};
8428
8429Reporter.prototype.restore = function restore(data) {
8430 var state = this._reporterState;
8431
8432 state.obj = data.obj;
8433 state.path = state.path.slice(0, data.pathLen);
8434};
8435
8436Reporter.prototype.enterKey = function enterKey(key) {
8437 return this._reporterState.path.push(key);
8438};
8439
8440Reporter.prototype.exitKey = function exitKey(index) {
8441 var state = this._reporterState;
8442
8443 state.path = state.path.slice(0, index - 1);
8444};
8445
8446Reporter.prototype.leaveKey = function leaveKey(index, key, value) {
8447 var state = this._reporterState;
8448
8449 this.exitKey(index);
8450 if (state.obj !== null)
8451 state.obj[key] = value;
8452};
8453
8454Reporter.prototype.path = function path() {
8455 return this._reporterState.path.join('/');
8456};
8457
8458Reporter.prototype.enterObject = function enterObject() {
8459 var state = this._reporterState;
8460
8461 var prev = state.obj;
8462 state.obj = {};
8463 return prev;
8464};
8465
8466Reporter.prototype.leaveObject = function leaveObject(prev) {
8467 var state = this._reporterState;
8468
8469 var now = state.obj;
8470 state.obj = prev;
8471 return now;
8472};
8473
8474Reporter.prototype.error = function error(msg) {
8475 var err;
8476 var state = this._reporterState;
8477
8478 var inherited = msg instanceof ReporterError;
8479 if (inherited) {
8480 err = msg;
8481 } else {
8482 err = new ReporterError(state.path.map(function(elem) {
8483 return '[' + JSON.stringify(elem) + ']';
8484 }).join(''), msg.message || msg, msg.stack);
8485 }
8486
8487 if (!state.options.partial)
8488 throw err;
8489
8490 if (!inherited)
8491 state.errors.push(err);
8492
8493 return err;
8494};
8495
8496Reporter.prototype.wrapResult = function wrapResult(result) {
8497 var state = this._reporterState;
8498 if (!state.options.partial)
8499 return result;
8500
8501 return {
8502 result: this.isError(result) ? null : result,
8503 errors: state.errors
8504 };
8505};
8506
8507function ReporterError(path, msg) {
8508 this.path = path;
8509 this.rethrow(msg);
8510};
8511inherits(ReporterError, Error);
8512
8513ReporterError.prototype.rethrow = function rethrow(msg) {
8514 this.message = msg + ' at: ' + (this.path || '(shallow)');
8515 if (Error.captureStackTrace)
8516 Error.captureStackTrace(this, ReporterError);
8517
8518 if (!this.stack) {
8519 try {
8520 // IE only adds stack when thrown
8521 throw new Error(this.message);
8522 } catch (e) {
8523 this.stack = e.stack;
8524 }
8525 }
8526 return this;
8527};
8528
8529},{"inherits":162}],66:[function(require,module,exports){
8530var constants = require('../constants');
8531
8532exports.tagClass = {
8533 0: 'universal',
8534 1: 'application',
8535 2: 'context',
8536 3: 'private'
8537};
8538exports.tagClassByName = constants._reverse(exports.tagClass);
8539
8540exports.tag = {
8541 0x00: 'end',
8542 0x01: 'bool',
8543 0x02: 'int',
8544 0x03: 'bitstr',
8545 0x04: 'octstr',
8546 0x05: 'null_',
8547 0x06: 'objid',
8548 0x07: 'objDesc',
8549 0x08: 'external',
8550 0x09: 'real',
8551 0x0a: 'enum',
8552 0x0b: 'embed',
8553 0x0c: 'utf8str',
8554 0x0d: 'relativeOid',
8555 0x10: 'seq',
8556 0x11: 'set',
8557 0x12: 'numstr',
8558 0x13: 'printstr',
8559 0x14: 't61str',
8560 0x15: 'videostr',
8561 0x16: 'ia5str',
8562 0x17: 'utctime',
8563 0x18: 'gentime',
8564 0x19: 'graphstr',
8565 0x1a: 'iso646str',
8566 0x1b: 'genstr',
8567 0x1c: 'unistr',
8568 0x1d: 'charstr',
8569 0x1e: 'bmpstr'
8570};
8571exports.tagByName = constants._reverse(exports.tag);
8572
8573},{"../constants":67}],67:[function(require,module,exports){
8574var constants = exports;
8575
8576// Helper
8577constants._reverse = function reverse(map) {
8578 var res = {};
8579
8580 Object.keys(map).forEach(function(key) {
8581 // Convert key to integer if it is stringified
8582 if ((key | 0) == key)
8583 key = key | 0;
8584
8585 var value = map[key];
8586 res[value] = key;
8587 });
8588
8589 return res;
8590};
8591
8592constants.der = require('./der');
8593
8594},{"./der":66}],68:[function(require,module,exports){
8595var inherits = require('inherits');
8596
8597var asn1 = require('../../asn1');
8598var base = asn1.base;
8599var bignum = asn1.bignum;
8600
8601// Import DER constants
8602var der = asn1.constants.der;
8603
8604function DERDecoder(entity) {
8605 this.enc = 'der';
8606 this.name = entity.name;
8607 this.entity = entity;
8608
8609 // Construct base tree
8610 this.tree = new DERNode();
8611 this.tree._init(entity.body);
8612};
8613module.exports = DERDecoder;
8614
8615DERDecoder.prototype.decode = function decode(data, options) {
8616 if (!(data instanceof base.DecoderBuffer))
8617 data = new base.DecoderBuffer(data, options);
8618
8619 return this.tree._decode(data, options);
8620};
8621
8622// Tree methods
8623
8624function DERNode(parent) {
8625 base.Node.call(this, 'der', parent);
8626}
8627inherits(DERNode, base.Node);
8628
8629DERNode.prototype._peekTag = function peekTag(buffer, tag, any) {
8630 if (buffer.isEmpty())
8631 return false;
8632
8633 var state = buffer.save();
8634 var decodedTag = derDecodeTag(buffer, 'Failed to peek tag: "' + tag + '"');
8635 if (buffer.isError(decodedTag))
8636 return decodedTag;
8637
8638 buffer.restore(state);
8639
8640 return decodedTag.tag === tag || decodedTag.tagStr === tag ||
8641 (decodedTag.tagStr + 'of') === tag || any;
8642};
8643
8644DERNode.prototype._decodeTag = function decodeTag(buffer, tag, any) {
8645 var decodedTag = derDecodeTag(buffer,
8646 'Failed to decode tag of "' + tag + '"');
8647 if (buffer.isError(decodedTag))
8648 return decodedTag;
8649
8650 var len = derDecodeLen(buffer,
8651 decodedTag.primitive,
8652 'Failed to get length of "' + tag + '"');
8653
8654 // Failure
8655 if (buffer.isError(len))
8656 return len;
8657
8658 if (!any &&
8659 decodedTag.tag !== tag &&
8660 decodedTag.tagStr !== tag &&
8661 decodedTag.tagStr + 'of' !== tag) {
8662 return buffer.error('Failed to match tag: "' + tag + '"');
8663 }
8664
8665 if (decodedTag.primitive || len !== null)
8666 return buffer.skip(len, 'Failed to match body of: "' + tag + '"');
8667
8668 // Indefinite length... find END tag
8669 var state = buffer.save();
8670 var res = this._skipUntilEnd(
8671 buffer,
8672 'Failed to skip indefinite length body: "' + this.tag + '"');
8673 if (buffer.isError(res))
8674 return res;
8675
8676 len = buffer.offset - state.offset;
8677 buffer.restore(state);
8678 return buffer.skip(len, 'Failed to match body of: "' + tag + '"');
8679};
8680
8681DERNode.prototype._skipUntilEnd = function skipUntilEnd(buffer, fail) {
8682 while (true) {
8683 var tag = derDecodeTag(buffer, fail);
8684 if (buffer.isError(tag))
8685 return tag;
8686 var len = derDecodeLen(buffer, tag.primitive, fail);
8687 if (buffer.isError(len))
8688 return len;
8689
8690 var res;
8691 if (tag.primitive || len !== null)
8692 res = buffer.skip(len)
8693 else
8694 res = this._skipUntilEnd(buffer, fail);
8695
8696 // Failure
8697 if (buffer.isError(res))
8698 return res;
8699
8700 if (tag.tagStr === 'end')
8701 break;
8702 }
8703};
8704
8705DERNode.prototype._decodeList = function decodeList(buffer, tag, decoder,
8706 options) {
8707 var result = [];
8708 while (!buffer.isEmpty()) {
8709 var possibleEnd = this._peekTag(buffer, 'end');
8710 if (buffer.isError(possibleEnd))
8711 return possibleEnd;
8712
8713 var res = decoder.decode(buffer, 'der', options);
8714 if (buffer.isError(res) && possibleEnd)
8715 break;
8716 result.push(res);
8717 }
8718 return result;
8719};
8720
8721DERNode.prototype._decodeStr = function decodeStr(buffer, tag) {
8722 if (tag === 'bitstr') {
8723 var unused = buffer.readUInt8();
8724 if (buffer.isError(unused))
8725 return unused;
8726 return { unused: unused, data: buffer.raw() };
8727 } else if (tag === 'bmpstr') {
8728 var raw = buffer.raw();
8729 if (raw.length % 2 === 1)
8730 return buffer.error('Decoding of string type: bmpstr length mismatch');
8731
8732 var str = '';
8733 for (var i = 0; i < raw.length / 2; i++) {
8734 str += String.fromCharCode(raw.readUInt16BE(i * 2));
8735 }
8736 return str;
8737 } else if (tag === 'numstr') {
8738 var numstr = buffer.raw().toString('ascii');
8739 if (!this._isNumstr(numstr)) {
8740 return buffer.error('Decoding of string type: ' +
8741 'numstr unsupported characters');
8742 }
8743 return numstr;
8744 } else if (tag === 'octstr') {
8745 return buffer.raw();
8746 } else if (tag === 'objDesc') {
8747 return buffer.raw();
8748 } else if (tag === 'printstr') {
8749 var printstr = buffer.raw().toString('ascii');
8750 if (!this._isPrintstr(printstr)) {
8751 return buffer.error('Decoding of string type: ' +
8752 'printstr unsupported characters');
8753 }
8754 return printstr;
8755 } else if (/str$/.test(tag)) {
8756 return buffer.raw().toString();
8757 } else {
8758 return buffer.error('Decoding of string type: ' + tag + ' unsupported');
8759 }
8760};
8761
8762DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) {
8763 var result;
8764 var identifiers = [];
8765 var ident = 0;
8766 while (!buffer.isEmpty()) {
8767 var subident = buffer.readUInt8();
8768 ident <<= 7;
8769 ident |= subident & 0x7f;
8770 if ((subident & 0x80) === 0) {
8771 identifiers.push(ident);
8772 ident = 0;
8773 }
8774 }
8775 if (subident & 0x80)
8776 identifiers.push(ident);
8777
8778 var first = (identifiers[0] / 40) | 0;
8779 var second = identifiers[0] % 40;
8780
8781 if (relative)
8782 result = identifiers;
8783 else
8784 result = [first, second].concat(identifiers.slice(1));
8785
8786 if (values) {
8787 var tmp = values[result.join(' ')];
8788 if (tmp === undefined)
8789 tmp = values[result.join('.')];
8790 if (tmp !== undefined)
8791 result = tmp;
8792 }
8793
8794 return result;
8795};
8796
8797DERNode.prototype._decodeTime = function decodeTime(buffer, tag) {
8798 var str = buffer.raw().toString();
8799 if (tag === 'gentime') {
8800 var year = str.slice(0, 4) | 0;
8801 var mon = str.slice(4, 6) | 0;
8802 var day = str.slice(6, 8) | 0;
8803 var hour = str.slice(8, 10) | 0;
8804 var min = str.slice(10, 12) | 0;
8805 var sec = str.slice(12, 14) | 0;
8806 } else if (tag === 'utctime') {
8807 var year = str.slice(0, 2) | 0;
8808 var mon = str.slice(2, 4) | 0;
8809 var day = str.slice(4, 6) | 0;
8810 var hour = str.slice(6, 8) | 0;
8811 var min = str.slice(8, 10) | 0;
8812 var sec = str.slice(10, 12) | 0;
8813 if (year < 70)
8814 year = 2000 + year;
8815 else
8816 year = 1900 + year;
8817 } else {
8818 return buffer.error('Decoding ' + tag + ' time is not supported yet');
8819 }
8820
8821 return Date.UTC(year, mon - 1, day, hour, min, sec, 0);
8822};
8823
8824DERNode.prototype._decodeNull = function decodeNull(buffer) {
8825 return null;
8826};
8827
8828DERNode.prototype._decodeBool = function decodeBool(buffer) {
8829 var res = buffer.readUInt8();
8830 if (buffer.isError(res))
8831 return res;
8832 else
8833 return res !== 0;
8834};
8835
8836DERNode.prototype._decodeInt = function decodeInt(buffer, values) {
8837 // Bigint, return as it is (assume big endian)
8838 var raw = buffer.raw();
8839 var res = new bignum(raw);
8840
8841 if (values)
8842 res = values[res.toString(10)] || res;
8843
8844 return res;
8845};
8846
8847DERNode.prototype._use = function use(entity, obj) {
8848 if (typeof entity === 'function')
8849 entity = entity(obj);
8850 return entity._getDecoder('der').tree;
8851};
8852
8853// Utility methods
8854
8855function derDecodeTag(buf, fail) {
8856 var tag = buf.readUInt8(fail);
8857 if (buf.isError(tag))
8858 return tag;
8859
8860 var cls = der.tagClass[tag >> 6];
8861 var primitive = (tag & 0x20) === 0;
8862
8863 // Multi-octet tag - load
8864 if ((tag & 0x1f) === 0x1f) {
8865 var oct = tag;
8866 tag = 0;
8867 while ((oct & 0x80) === 0x80) {
8868 oct = buf.readUInt8(fail);
8869 if (buf.isError(oct))
8870 return oct;
8871
8872 tag <<= 7;
8873 tag |= oct & 0x7f;
8874 }
8875 } else {
8876 tag &= 0x1f;
8877 }
8878 var tagStr = der.tag[tag];
8879
8880 return {
8881 cls: cls,
8882 primitive: primitive,
8883 tag: tag,
8884 tagStr: tagStr
8885 };
8886}
8887
8888function derDecodeLen(buf, primitive, fail) {
8889 var len = buf.readUInt8(fail);
8890 if (buf.isError(len))
8891 return len;
8892
8893 // Indefinite form
8894 if (!primitive && len === 0x80)
8895 return null;
8896
8897 // Definite form
8898 if ((len & 0x80) === 0) {
8899 // Short form
8900 return len;
8901 }
8902
8903 // Long form
8904 var num = len & 0x7f;
8905 if (num > 4)
8906 return buf.error('length octect is too long');
8907
8908 len = 0;
8909 for (var i = 0; i < num; i++) {
8910 len <<= 8;
8911 var j = buf.readUInt8(fail);
8912 if (buf.isError(j))
8913 return j;
8914 len |= j;
8915 }
8916
8917 return len;
8918}
8919
8920},{"../../asn1":60,"inherits":162}],69:[function(require,module,exports){
8921var decoders = exports;
8922
8923decoders.der = require('./der');
8924decoders.pem = require('./pem');
8925
8926},{"./der":68,"./pem":70}],70:[function(require,module,exports){
8927var inherits = require('inherits');
8928var Buffer = require('buffer').Buffer;
8929
8930var DERDecoder = require('./der');
8931
8932function PEMDecoder(entity) {
8933 DERDecoder.call(this, entity);
8934 this.enc = 'pem';
8935};
8936inherits(PEMDecoder, DERDecoder);
8937module.exports = PEMDecoder;
8938
8939PEMDecoder.prototype.decode = function decode(data, options) {
8940 var lines = data.toString().split(/[\r\n]+/g);
8941
8942 var label = options.label.toUpperCase();
8943
8944 var re = /^-----(BEGIN|END) ([^-]+)-----$/;
8945 var start = -1;
8946 var end = -1;
8947 for (var i = 0; i < lines.length; i++) {
8948 var match = lines[i].match(re);
8949 if (match === null)
8950 continue;
8951
8952 if (match[2] !== label)
8953 continue;
8954
8955 if (start === -1) {
8956 if (match[1] !== 'BEGIN')
8957 break;
8958 start = i;
8959 } else {
8960 if (match[1] !== 'END')
8961 break;
8962 end = i;
8963 break;
8964 }
8965 }
8966 if (start === -1 || end === -1)
8967 throw new Error('PEM section not found for: ' + label);
8968
8969 var base64 = lines.slice(start + 1, end).join('');
8970 // Remove excessive symbols
8971 base64.replace(/[^a-z0-9\+\/=]+/gi, '');
8972
8973 var input = new Buffer(base64, 'base64');
8974 return DERDecoder.prototype.decode.call(this, input, options);
8975};
8976
8977},{"./der":68,"buffer":110,"inherits":162}],71:[function(require,module,exports){
8978var inherits = require('inherits');
8979var Buffer = require('buffer').Buffer;
8980
8981var asn1 = require('../../asn1');
8982var base = asn1.base;
8983
8984// Import DER constants
8985var der = asn1.constants.der;
8986
8987function DEREncoder(entity) {
8988 this.enc = 'der';
8989 this.name = entity.name;
8990 this.entity = entity;
8991
8992 // Construct base tree
8993 this.tree = new DERNode();
8994 this.tree._init(entity.body);
8995};
8996module.exports = DEREncoder;
8997
8998DEREncoder.prototype.encode = function encode(data, reporter) {
8999 return this.tree._encode(data, reporter).join();
9000};
9001
9002// Tree methods
9003
9004function DERNode(parent) {
9005 base.Node.call(this, 'der', parent);
9006}
9007inherits(DERNode, base.Node);
9008
9009DERNode.prototype._encodeComposite = function encodeComposite(tag,
9010 primitive,
9011 cls,
9012 content) {
9013 var encodedTag = encodeTag(tag, primitive, cls, this.reporter);
9014
9015 // Short form
9016 if (content.length < 0x80) {
9017 var header = new Buffer(2);
9018 header[0] = encodedTag;
9019 header[1] = content.length;
9020 return this._createEncoderBuffer([ header, content ]);
9021 }
9022
9023 // Long form
9024 // Count octets required to store length
9025 var lenOctets = 1;
9026 for (var i = content.length; i >= 0x100; i >>= 8)
9027 lenOctets++;
9028
9029 var header = new Buffer(1 + 1 + lenOctets);
9030 header[0] = encodedTag;
9031 header[1] = 0x80 | lenOctets;
9032
9033 for (var i = 1 + lenOctets, j = content.length; j > 0; i--, j >>= 8)
9034 header[i] = j & 0xff;
9035
9036 return this._createEncoderBuffer([ header, content ]);
9037};
9038
9039DERNode.prototype._encodeStr = function encodeStr(str, tag) {
9040 if (tag === 'bitstr') {
9041 return this._createEncoderBuffer([ str.unused | 0, str.data ]);
9042 } else if (tag === 'bmpstr') {
9043 var buf = new Buffer(str.length * 2);
9044 for (var i = 0; i < str.length; i++) {
9045 buf.writeUInt16BE(str.charCodeAt(i), i * 2);
9046 }
9047 return this._createEncoderBuffer(buf);
9048 } else if (tag === 'numstr') {
9049 if (!this._isNumstr(str)) {
9050 return this.reporter.error('Encoding of string type: numstr supports ' +
9051 'only digits and space');
9052 }
9053 return this._createEncoderBuffer(str);
9054 } else if (tag === 'printstr') {
9055 if (!this._isPrintstr(str)) {
9056 return this.reporter.error('Encoding of string type: printstr supports ' +
9057 'only latin upper and lower case letters, ' +
9058 'digits, space, apostrophe, left and rigth ' +
9059 'parenthesis, plus sign, comma, hyphen, ' +
9060 'dot, slash, colon, equal sign, ' +
9061 'question mark');
9062 }
9063 return this._createEncoderBuffer(str);
9064 } else if (/str$/.test(tag)) {
9065 return this._createEncoderBuffer(str);
9066 } else if (tag === 'objDesc') {
9067 return this._createEncoderBuffer(str);
9068 } else {
9069 return this.reporter.error('Encoding of string type: ' + tag +
9070 ' unsupported');
9071 }
9072};
9073
9074DERNode.prototype._encodeObjid = function encodeObjid(id, values, relative) {
9075 if (typeof id === 'string') {
9076 if (!values)
9077 return this.reporter.error('string objid given, but no values map found');
9078 if (!values.hasOwnProperty(id))
9079 return this.reporter.error('objid not found in values map');
9080 id = values[id].split(/[\s\.]+/g);
9081 for (var i = 0; i < id.length; i++)
9082 id[i] |= 0;
9083 } else if (Array.isArray(id)) {
9084 id = id.slice();
9085 for (var i = 0; i < id.length; i++)
9086 id[i] |= 0;
9087 }
9088
9089 if (!Array.isArray(id)) {
9090 return this.reporter.error('objid() should be either array or string, ' +
9091 'got: ' + JSON.stringify(id));
9092 }
9093
9094 if (!relative) {
9095 if (id[1] >= 40)
9096 return this.reporter.error('Second objid identifier OOB');
9097 id.splice(0, 2, id[0] * 40 + id[1]);
9098 }
9099
9100 // Count number of octets
9101 var size = 0;
9102 for (var i = 0; i < id.length; i++) {
9103 var ident = id[i];
9104 for (size++; ident >= 0x80; ident >>= 7)
9105 size++;
9106 }
9107
9108 var objid = new Buffer(size);
9109 var offset = objid.length - 1;
9110 for (var i = id.length - 1; i >= 0; i--) {
9111 var ident = id[i];
9112 objid[offset--] = ident & 0x7f;
9113 while ((ident >>= 7) > 0)
9114 objid[offset--] = 0x80 | (ident & 0x7f);
9115 }
9116
9117 return this._createEncoderBuffer(objid);
9118};
9119
9120function two(num) {
9121 if (num < 10)
9122 return '0' + num;
9123 else
9124 return num;
9125}
9126
9127DERNode.prototype._encodeTime = function encodeTime(time, tag) {
9128 var str;
9129 var date = new Date(time);
9130
9131 if (tag === 'gentime') {
9132 str = [
9133 two(date.getFullYear()),
9134 two(date.getUTCMonth() + 1),
9135 two(date.getUTCDate()),
9136 two(date.getUTCHours()),
9137 two(date.getUTCMinutes()),
9138 two(date.getUTCSeconds()),
9139 'Z'
9140 ].join('');
9141 } else if (tag === 'utctime') {
9142 str = [
9143 two(date.getFullYear() % 100),
9144 two(date.getUTCMonth() + 1),
9145 two(date.getUTCDate()),
9146 two(date.getUTCHours()),
9147 two(date.getUTCMinutes()),
9148 two(date.getUTCSeconds()),
9149 'Z'
9150 ].join('');
9151 } else {
9152 this.reporter.error('Encoding ' + tag + ' time is not supported yet');
9153 }
9154
9155 return this._encodeStr(str, 'octstr');
9156};
9157
9158DERNode.prototype._encodeNull = function encodeNull() {
9159 return this._createEncoderBuffer('');
9160};
9161
9162DERNode.prototype._encodeInt = function encodeInt(num, values) {
9163 if (typeof num === 'string') {
9164 if (!values)
9165 return this.reporter.error('String int or enum given, but no values map');
9166 if (!values.hasOwnProperty(num)) {
9167 return this.reporter.error('Values map doesn\'t contain: ' +
9168 JSON.stringify(num));
9169 }
9170 num = values[num];
9171 }
9172
9173 // Bignum, assume big endian
9174 if (typeof num !== 'number' && !Buffer.isBuffer(num)) {
9175 var numArray = num.toArray();
9176 if (!num.sign && numArray[0] & 0x80) {
9177 numArray.unshift(0);
9178 }
9179 num = new Buffer(numArray);
9180 }
9181
9182 if (Buffer.isBuffer(num)) {
9183 var size = num.length;
9184 if (num.length === 0)
9185 size++;
9186
9187 var out = new Buffer(size);
9188 num.copy(out);
9189 if (num.length === 0)
9190 out[0] = 0
9191 return this._createEncoderBuffer(out);
9192 }
9193
9194 if (num < 0x80)
9195 return this._createEncoderBuffer(num);
9196
9197 if (num < 0x100)
9198 return this._createEncoderBuffer([0, num]);
9199
9200 var size = 1;
9201 for (var i = num; i >= 0x100; i >>= 8)
9202 size++;
9203
9204 var out = new Array(size);
9205 for (var i = out.length - 1; i >= 0; i--) {
9206 out[i] = num & 0xff;
9207 num >>= 8;
9208 }
9209 if(out[0] & 0x80) {
9210 out.unshift(0);
9211 }
9212
9213 return this._createEncoderBuffer(new Buffer(out));
9214};
9215
9216DERNode.prototype._encodeBool = function encodeBool(value) {
9217 return this._createEncoderBuffer(value ? 0xff : 0);
9218};
9219
9220DERNode.prototype._use = function use(entity, obj) {
9221 if (typeof entity === 'function')
9222 entity = entity(obj);
9223 return entity._getEncoder('der').tree;
9224};
9225
9226DERNode.prototype._skipDefault = function skipDefault(dataBuffer, reporter, parent) {
9227 var state = this._baseState;
9228 var i;
9229 if (state['default'] === null)
9230 return false;
9231
9232 var data = dataBuffer.join();
9233 if (state.defaultBuffer === undefined)
9234 state.defaultBuffer = this._encodeValue(state['default'], reporter, parent).join();
9235
9236 if (data.length !== state.defaultBuffer.length)
9237 return false;
9238
9239 for (i=0; i < data.length; i++)
9240 if (data[i] !== state.defaultBuffer[i])
9241 return false;
9242
9243 return true;
9244};
9245
9246// Utility methods
9247
9248function encodeTag(tag, primitive, cls, reporter) {
9249 var res;
9250
9251 if (tag === 'seqof')
9252 tag = 'seq';
9253 else if (tag === 'setof')
9254 tag = 'set';
9255
9256 if (der.tagByName.hasOwnProperty(tag))
9257 res = der.tagByName[tag];
9258 else if (typeof tag === 'number' && (tag | 0) === tag)
9259 res = tag;
9260 else
9261 return reporter.error('Unknown tag: ' + tag);
9262
9263 if (res >= 0x1f)
9264 return reporter.error('Multi-octet tag encoding unsupported');
9265
9266 if (!primitive)
9267 res |= 0x20;
9268
9269 res |= (der.tagClassByName[cls || 'universal'] << 6);
9270
9271 return res;
9272}
9273
9274},{"../../asn1":60,"buffer":110,"inherits":162}],72:[function(require,module,exports){
9275var encoders = exports;
9276
9277encoders.der = require('./der');
9278encoders.pem = require('./pem');
9279
9280},{"./der":71,"./pem":73}],73:[function(require,module,exports){
9281var inherits = require('inherits');
9282
9283var DEREncoder = require('./der');
9284
9285function PEMEncoder(entity) {
9286 DEREncoder.call(this, entity);
9287 this.enc = 'pem';
9288};
9289inherits(PEMEncoder, DEREncoder);
9290module.exports = PEMEncoder;
9291
9292PEMEncoder.prototype.encode = function encode(data, options) {
9293 var buf = DEREncoder.prototype.encode.call(this, data);
9294
9295 var p = buf.toString('base64');
9296 var out = [ '-----BEGIN ' + options.label + '-----' ];
9297 for (var i = 0; i < p.length; i += 64)
9298 out.push(p.slice(i, i + 64));
9299 out.push('-----END ' + options.label + '-----');
9300 return out.join('\n');
9301};
9302
9303},{"./der":71,"inherits":162}],74:[function(require,module,exports){
9304(function (global){
9305'use strict';
9306
9307var objectAssign = require('object-assign');
9308
9309// compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js
9310// original notice:
9311
9312/*!
9313 * The buffer module from node.js, for the browser.
9314 *
9315 * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
9316 * @license MIT
9317 */
9318function compare(a, b) {
9319 if (a === b) {
9320 return 0;
9321 }
9322
9323 var x = a.length;
9324 var y = b.length;
9325
9326 for (var i = 0, len = Math.min(x, y); i < len; ++i) {
9327 if (a[i] !== b[i]) {
9328 x = a[i];
9329 y = b[i];
9330 break;
9331 }
9332 }
9333
9334 if (x < y) {
9335 return -1;
9336 }
9337 if (y < x) {
9338 return 1;
9339 }
9340 return 0;
9341}
9342function isBuffer(b) {
9343 if (global.Buffer && typeof global.Buffer.isBuffer === 'function') {
9344 return global.Buffer.isBuffer(b);
9345 }
9346 return !!(b != null && b._isBuffer);
9347}
9348
9349// based on node assert, original notice:
9350// NB: The URL to the CommonJS spec is kept just for tradition.
9351// node-assert has evolved a lot since then, both in API and behavior.
9352
9353// http://wiki.commonjs.org/wiki/Unit_Testing/1.0
9354//
9355// THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
9356//
9357// Originally from narwhal.js (http://narwhaljs.org)
9358// Copyright (c) 2009 Thomas Robinson <280north.com>
9359//
9360// Permission is hereby granted, free of charge, to any person obtaining a copy
9361// of this software and associated documentation files (the 'Software'), to
9362// deal in the Software without restriction, including without limitation the
9363// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9364// sell copies of the Software, and to permit persons to whom the Software is
9365// furnished to do so, subject to the following conditions:
9366//
9367// The above copyright notice and this permission notice shall be included in
9368// all copies or substantial portions of the Software.
9369//
9370// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
9371// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9372// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
9373// AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
9374// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
9375// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9376
9377var util = require('util/');
9378var hasOwn = Object.prototype.hasOwnProperty;
9379var pSlice = Array.prototype.slice;
9380var functionsHaveNames = (function () {
9381 return function foo() {}.name === 'foo';
9382}());
9383function pToString (obj) {
9384 return Object.prototype.toString.call(obj);
9385}
9386function isView(arrbuf) {
9387 if (isBuffer(arrbuf)) {
9388 return false;
9389 }
9390 if (typeof global.ArrayBuffer !== 'function') {
9391 return false;
9392 }
9393 if (typeof ArrayBuffer.isView === 'function') {
9394 return ArrayBuffer.isView(arrbuf);
9395 }
9396 if (!arrbuf) {
9397 return false;
9398 }
9399 if (arrbuf instanceof DataView) {
9400 return true;
9401 }
9402 if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) {
9403 return true;
9404 }
9405 return false;
9406}
9407// 1. The assert module provides functions that throw
9408// AssertionError's when particular conditions are not met. The
9409// assert module must conform to the following interface.
9410
9411var assert = module.exports = ok;
9412
9413// 2. The AssertionError is defined in assert.
9414// new assert.AssertionError({ message: message,
9415// actual: actual,
9416// expected: expected })
9417
9418var regex = /\s*function\s+([^\(\s]*)\s*/;
9419// based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js
9420function getName(func) {
9421 if (!util.isFunction(func)) {
9422 return;
9423 }
9424 if (functionsHaveNames) {
9425 return func.name;
9426 }
9427 var str = func.toString();
9428 var match = str.match(regex);
9429 return match && match[1];
9430}
9431assert.AssertionError = function AssertionError(options) {
9432 this.name = 'AssertionError';
9433 this.actual = options.actual;
9434 this.expected = options.expected;
9435 this.operator = options.operator;
9436 if (options.message) {
9437 this.message = options.message;
9438 this.generatedMessage = false;
9439 } else {
9440 this.message = getMessage(this);
9441 this.generatedMessage = true;
9442 }
9443 var stackStartFunction = options.stackStartFunction || fail;
9444 if (Error.captureStackTrace) {
9445 Error.captureStackTrace(this, stackStartFunction);
9446 } else {
9447 // non v8 browsers so we can have a stacktrace
9448 var err = new Error();
9449 if (err.stack) {
9450 var out = err.stack;
9451
9452 // try to strip useless frames
9453 var fn_name = getName(stackStartFunction);
9454 var idx = out.indexOf('\n' + fn_name);
9455 if (idx >= 0) {
9456 // once we have located the function frame
9457 // we need to strip out everything before it (and its line)
9458 var next_line = out.indexOf('\n', idx + 1);
9459 out = out.substring(next_line + 1);
9460 }
9461
9462 this.stack = out;
9463 }
9464 }
9465};
9466
9467// assert.AssertionError instanceof Error
9468util.inherits(assert.AssertionError, Error);
9469
9470function truncate(s, n) {
9471 if (typeof s === 'string') {
9472 return s.length < n ? s : s.slice(0, n);
9473 } else {
9474 return s;
9475 }
9476}
9477function inspect(something) {
9478 if (functionsHaveNames || !util.isFunction(something)) {
9479 return util.inspect(something);
9480 }
9481 var rawname = getName(something);
9482 var name = rawname ? ': ' + rawname : '';
9483 return '[Function' + name + ']';
9484}
9485function getMessage(self) {
9486 return truncate(inspect(self.actual), 128) + ' ' +
9487 self.operator + ' ' +
9488 truncate(inspect(self.expected), 128);
9489}
9490
9491// At present only the three keys mentioned above are used and
9492// understood by the spec. Implementations or sub modules can pass
9493// other keys to the AssertionError's constructor - they will be
9494// ignored.
9495
9496// 3. All of the following functions must throw an AssertionError
9497// when a corresponding condition is not met, with a message that
9498// may be undefined if not provided. All assertion methods provide
9499// both the actual and expected values to the assertion error for
9500// display purposes.
9501
9502function fail(actual, expected, message, operator, stackStartFunction) {
9503 throw new assert.AssertionError({
9504 message: message,
9505 actual: actual,
9506 expected: expected,
9507 operator: operator,
9508 stackStartFunction: stackStartFunction
9509 });
9510}
9511
9512// EXTENSION! allows for well behaved errors defined elsewhere.
9513assert.fail = fail;
9514
9515// 4. Pure assertion tests whether a value is truthy, as determined
9516// by !!guard.
9517// assert.ok(guard, message_opt);
9518// This statement is equivalent to assert.equal(true, !!guard,
9519// message_opt);. To test strictly for the value true, use
9520// assert.strictEqual(true, guard, message_opt);.
9521
9522function ok(value, message) {
9523 if (!value) fail(value, true, message, '==', assert.ok);
9524}
9525assert.ok = ok;
9526
9527// 5. The equality assertion tests shallow, coercive equality with
9528// ==.
9529// assert.equal(actual, expected, message_opt);
9530
9531assert.equal = function equal(actual, expected, message) {
9532 if (actual != expected) fail(actual, expected, message, '==', assert.equal);
9533};
9534
9535// 6. The non-equality assertion tests for whether two objects are not equal
9536// with != assert.notEqual(actual, expected, message_opt);
9537
9538assert.notEqual = function notEqual(actual, expected, message) {
9539 if (actual == expected) {
9540 fail(actual, expected, message, '!=', assert.notEqual);
9541 }
9542};
9543
9544// 7. The equivalence assertion tests a deep equality relation.
9545// assert.deepEqual(actual, expected, message_opt);
9546
9547assert.deepEqual = function deepEqual(actual, expected, message) {
9548 if (!_deepEqual(actual, expected, false)) {
9549 fail(actual, expected, message, 'deepEqual', assert.deepEqual);
9550 }
9551};
9552
9553assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) {
9554 if (!_deepEqual(actual, expected, true)) {
9555 fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual);
9556 }
9557};
9558
9559function _deepEqual(actual, expected, strict, memos) {
9560 // 7.1. All identical values are equivalent, as determined by ===.
9561 if (actual === expected) {
9562 return true;
9563 } else if (isBuffer(actual) && isBuffer(expected)) {
9564 return compare(actual, expected) === 0;
9565
9566 // 7.2. If the expected value is a Date object, the actual value is
9567 // equivalent if it is also a Date object that refers to the same time.
9568 } else if (util.isDate(actual) && util.isDate(expected)) {
9569 return actual.getTime() === expected.getTime();
9570
9571 // 7.3 If the expected value is a RegExp object, the actual value is
9572 // equivalent if it is also a RegExp object with the same source and
9573 // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
9574 } else if (util.isRegExp(actual) && util.isRegExp(expected)) {
9575 return actual.source === expected.source &&
9576 actual.global === expected.global &&
9577 actual.multiline === expected.multiline &&
9578 actual.lastIndex === expected.lastIndex &&
9579 actual.ignoreCase === expected.ignoreCase;
9580
9581 // 7.4. Other pairs that do not both pass typeof value == 'object',
9582 // equivalence is determined by ==.
9583 } else if ((actual === null || typeof actual !== 'object') &&
9584 (expected === null || typeof expected !== 'object')) {
9585 return strict ? actual === expected : actual == expected;
9586
9587 // If both values are instances of typed arrays, wrap their underlying
9588 // ArrayBuffers in a Buffer each to increase performance
9589 // This optimization requires the arrays to have the same type as checked by
9590 // Object.prototype.toString (aka pToString). Never perform binary
9591 // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their
9592 // bit patterns are not identical.
9593 } else if (isView(actual) && isView(expected) &&
9594 pToString(actual) === pToString(expected) &&
9595 !(actual instanceof Float32Array ||
9596 actual instanceof Float64Array)) {
9597 return compare(new Uint8Array(actual.buffer),
9598 new Uint8Array(expected.buffer)) === 0;
9599
9600 // 7.5 For all other Object pairs, including Array objects, equivalence is
9601 // determined by having the same number of owned properties (as verified
9602 // with Object.prototype.hasOwnProperty.call), the same set of keys
9603 // (although not necessarily the same order), equivalent values for every
9604 // corresponding key, and an identical 'prototype' property. Note: this
9605 // accounts for both named and indexed properties on Arrays.
9606 } else if (isBuffer(actual) !== isBuffer(expected)) {
9607 return false;
9608 } else {
9609 memos = memos || {actual: [], expected: []};
9610
9611 var actualIndex = memos.actual.indexOf(actual);
9612 if (actualIndex !== -1) {
9613 if (actualIndex === memos.expected.indexOf(expected)) {
9614 return true;
9615 }
9616 }
9617
9618 memos.actual.push(actual);
9619 memos.expected.push(expected);
9620
9621 return objEquiv(actual, expected, strict, memos);
9622 }
9623}
9624
9625function isArguments(object) {
9626 return Object.prototype.toString.call(object) == '[object Arguments]';
9627}
9628
9629function objEquiv(a, b, strict, actualVisitedObjects) {
9630 if (a === null || a === undefined || b === null || b === undefined)
9631 return false;
9632 // if one is a primitive, the other must be same
9633 if (util.isPrimitive(a) || util.isPrimitive(b))
9634 return a === b;
9635 if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b))
9636 return false;
9637 var aIsArgs = isArguments(a);
9638 var bIsArgs = isArguments(b);
9639 if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
9640 return false;
9641 if (aIsArgs) {
9642 a = pSlice.call(a);
9643 b = pSlice.call(b);
9644 return _deepEqual(a, b, strict);
9645 }
9646 var ka = objectKeys(a);
9647 var kb = objectKeys(b);
9648 var key, i;
9649 // having the same number of owned properties (keys incorporates
9650 // hasOwnProperty)
9651 if (ka.length !== kb.length)
9652 return false;
9653 //the same set of keys (although not necessarily the same order),
9654 ka.sort();
9655 kb.sort();
9656 //~~~cheap key test
9657 for (i = ka.length - 1; i >= 0; i--) {
9658 if (ka[i] !== kb[i])
9659 return false;
9660 }
9661 //equivalent values for every corresponding key, and
9662 //~~~possibly expensive deep test
9663 for (i = ka.length - 1; i >= 0; i--) {
9664 key = ka[i];
9665 if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects))
9666 return false;
9667 }
9668 return true;
9669}
9670
9671// 8. The non-equivalence assertion tests for any deep inequality.
9672// assert.notDeepEqual(actual, expected, message_opt);
9673
9674assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
9675 if (_deepEqual(actual, expected, false)) {
9676 fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
9677 }
9678};
9679
9680assert.notDeepStrictEqual = notDeepStrictEqual;
9681function notDeepStrictEqual(actual, expected, message) {
9682 if (_deepEqual(actual, expected, true)) {
9683 fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual);
9684 }
9685}
9686
9687
9688// 9. The strict equality assertion tests strict equality, as determined by ===.
9689// assert.strictEqual(actual, expected, message_opt);
9690
9691assert.strictEqual = function strictEqual(actual, expected, message) {
9692 if (actual !== expected) {
9693 fail(actual, expected, message, '===', assert.strictEqual);
9694 }
9695};
9696
9697// 10. The strict non-equality assertion tests for strict inequality, as
9698// determined by !==. assert.notStrictEqual(actual, expected, message_opt);
9699
9700assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
9701 if (actual === expected) {
9702 fail(actual, expected, message, '!==', assert.notStrictEqual);
9703 }
9704};
9705
9706function expectedException(actual, expected) {
9707 if (!actual || !expected) {
9708 return false;
9709 }
9710
9711 if (Object.prototype.toString.call(expected) == '[object RegExp]') {
9712 return expected.test(actual);
9713 }
9714
9715 try {
9716 if (actual instanceof expected) {
9717 return true;
9718 }
9719 } catch (e) {
9720 // Ignore. The instanceof check doesn't work for arrow functions.
9721 }
9722
9723 if (Error.isPrototypeOf(expected)) {
9724 return false;
9725 }
9726
9727 return expected.call({}, actual) === true;
9728}
9729
9730function _tryBlock(block) {
9731 var error;
9732 try {
9733 block();
9734 } catch (e) {
9735 error = e;
9736 }
9737 return error;
9738}
9739
9740function _throws(shouldThrow, block, expected, message) {
9741 var actual;
9742
9743 if (typeof block !== 'function') {
9744 throw new TypeError('"block" argument must be a function');
9745 }
9746
9747 if (typeof expected === 'string') {
9748 message = expected;
9749 expected = null;
9750 }
9751
9752 actual = _tryBlock(block);
9753
9754 message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
9755 (message ? ' ' + message : '.');
9756
9757 if (shouldThrow && !actual) {
9758 fail(actual, expected, 'Missing expected exception' + message);
9759 }
9760
9761 var userProvidedMessage = typeof message === 'string';
9762 var isUnwantedException = !shouldThrow && util.isError(actual);
9763 var isUnexpectedException = !shouldThrow && actual && !expected;
9764
9765 if ((isUnwantedException &&
9766 userProvidedMessage &&
9767 expectedException(actual, expected)) ||
9768 isUnexpectedException) {
9769 fail(actual, expected, 'Got unwanted exception' + message);
9770 }
9771
9772 if ((shouldThrow && actual && expected &&
9773 !expectedException(actual, expected)) || (!shouldThrow && actual)) {
9774 throw actual;
9775 }
9776}
9777
9778// 11. Expected to throw an error:
9779// assert.throws(block, Error_opt, message_opt);
9780
9781assert.throws = function(block, /*optional*/error, /*optional*/message) {
9782 _throws(true, block, error, message);
9783};
9784
9785// EXTENSION! This is annoying to write outside this module.
9786assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) {
9787 _throws(false, block, error, message);
9788};
9789
9790assert.ifError = function(err) { if (err) throw err; };
9791
9792// Expose a strict only variant of assert
9793function strict(value, message) {
9794 if (!value) fail(value, true, message, '==', strict);
9795}
9796assert.strict = objectAssign(strict, assert, {
9797 equal: assert.strictEqual,
9798 deepEqual: assert.deepStrictEqual,
9799 notEqual: assert.notStrictEqual,
9800 notDeepEqual: assert.notDeepStrictEqual
9801});
9802assert.strict.strict = assert.strict;
9803
9804var objectKeys = Object.keys || function (obj) {
9805 var keys = [];
9806 for (var key in obj) {
9807 if (hasOwn.call(obj, key)) keys.push(key);
9808 }
9809 return keys;
9810};
9811
9812}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
9813},{"object-assign":169,"util/":77}],75:[function(require,module,exports){
9814if (typeof Object.create === 'function') {
9815 // implementation from standard node.js 'util' module
9816 module.exports = function inherits(ctor, superCtor) {
9817 ctor.super_ = superCtor
9818 ctor.prototype = Object.create(superCtor.prototype, {
9819 constructor: {
9820 value: ctor,
9821 enumerable: false,
9822 writable: true,
9823 configurable: true
9824 }
9825 });
9826 };
9827} else {
9828 // old school shim for old browsers
9829 module.exports = function inherits(ctor, superCtor) {
9830 ctor.super_ = superCtor
9831 var TempCtor = function () {}
9832 TempCtor.prototype = superCtor.prototype
9833 ctor.prototype = new TempCtor()
9834 ctor.prototype.constructor = ctor
9835 }
9836}
9837
9838},{}],76:[function(require,module,exports){
9839module.exports = function isBuffer(arg) {
9840 return arg && typeof arg === 'object'
9841 && typeof arg.copy === 'function'
9842 && typeof arg.fill === 'function'
9843 && typeof arg.readUInt8 === 'function';
9844}
9845},{}],77:[function(require,module,exports){
9846(function (process,global){
9847// Copyright Joyent, Inc. and other Node contributors.
9848//
9849// Permission is hereby granted, free of charge, to any person obtaining a
9850// copy of this software and associated documentation files (the
9851// "Software"), to deal in the Software without restriction, including
9852// without limitation the rights to use, copy, modify, merge, publish,
9853// distribute, sublicense, and/or sell copies of the Software, and to permit
9854// persons to whom the Software is furnished to do so, subject to the
9855// following conditions:
9856//
9857// The above copyright notice and this permission notice shall be included
9858// in all copies or substantial portions of the Software.
9859//
9860// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
9861// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
9862// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
9863// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
9864// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
9865// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
9866// USE OR OTHER DEALINGS IN THE SOFTWARE.
9867
9868var formatRegExp = /%[sdj%]/g;
9869exports.format = function(f) {
9870 if (!isString(f)) {
9871 var objects = [];
9872 for (var i = 0; i < arguments.length; i++) {
9873 objects.push(inspect(arguments[i]));
9874 }
9875 return objects.join(' ');
9876 }
9877
9878 var i = 1;
9879 var args = arguments;
9880 var len = args.length;
9881 var str = String(f).replace(formatRegExp, function(x) {
9882 if (x === '%%') return '%';
9883 if (i >= len) return x;
9884 switch (x) {
9885 case '%s': return String(args[i++]);
9886 case '%d': return Number(args[i++]);
9887 case '%j':
9888 try {
9889 return JSON.stringify(args[i++]);
9890 } catch (_) {
9891 return '[Circular]';
9892 }
9893 default:
9894 return x;
9895 }
9896 });
9897 for (var x = args[i]; i < len; x = args[++i]) {
9898 if (isNull(x) || !isObject(x)) {
9899 str += ' ' + x;
9900 } else {
9901 str += ' ' + inspect(x);
9902 }
9903 }
9904 return str;
9905};
9906
9907
9908// Mark that a method should not be used.
9909// Returns a modified function which warns once by default.
9910// If --no-deprecation is set, then it is a no-op.
9911exports.deprecate = function(fn, msg) {
9912 // Allow for deprecating things in the process of starting up.
9913 if (isUndefined(global.process)) {
9914 return function() {
9915 return exports.deprecate(fn, msg).apply(this, arguments);
9916 };
9917 }
9918
9919 if (process.noDeprecation === true) {
9920 return fn;
9921 }
9922
9923 var warned = false;
9924 function deprecated() {
9925 if (!warned) {
9926 if (process.throwDeprecation) {
9927 throw new Error(msg);
9928 } else if (process.traceDeprecation) {
9929 console.trace(msg);
9930 } else {
9931 console.error(msg);
9932 }
9933 warned = true;
9934 }
9935 return fn.apply(this, arguments);
9936 }
9937
9938 return deprecated;
9939};
9940
9941
9942var debugs = {};
9943var debugEnviron;
9944exports.debuglog = function(set) {
9945 if (isUndefined(debugEnviron))
9946 debugEnviron = process.env.NODE_DEBUG || '';
9947 set = set.toUpperCase();
9948 if (!debugs[set]) {
9949 if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
9950 var pid = process.pid;
9951 debugs[set] = function() {
9952 var msg = exports.format.apply(exports, arguments);
9953 console.error('%s %d: %s', set, pid, msg);
9954 };
9955 } else {
9956 debugs[set] = function() {};
9957 }
9958 }
9959 return debugs[set];
9960};
9961
9962
9963/**
9964 * Echos the value of a value. Trys to print the value out
9965 * in the best way possible given the different types.
9966 *
9967 * @param {Object} obj The object to print out.
9968 * @param {Object} opts Optional options object that alters the output.
9969 */
9970/* legacy: obj, showHidden, depth, colors*/
9971function inspect(obj, opts) {
9972 // default options
9973 var ctx = {
9974 seen: [],
9975 stylize: stylizeNoColor
9976 };
9977 // legacy...
9978 if (arguments.length >= 3) ctx.depth = arguments[2];
9979 if (arguments.length >= 4) ctx.colors = arguments[3];
9980 if (isBoolean(opts)) {
9981 // legacy...
9982 ctx.showHidden = opts;
9983 } else if (opts) {
9984 // got an "options" object
9985 exports._extend(ctx, opts);
9986 }
9987 // set default options
9988 if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
9989 if (isUndefined(ctx.depth)) ctx.depth = 2;
9990 if (isUndefined(ctx.colors)) ctx.colors = false;
9991 if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
9992 if (ctx.colors) ctx.stylize = stylizeWithColor;
9993 return formatValue(ctx, obj, ctx.depth);
9994}
9995exports.inspect = inspect;
9996
9997
9998// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
9999inspect.colors = {
10000 'bold' : [1, 22],
10001 'italic' : [3, 23],
10002 'underline' : [4, 24],
10003 'inverse' : [7, 27],
10004 'white' : [37, 39],
10005 'grey' : [90, 39],
10006 'black' : [30, 39],
10007 'blue' : [34, 39],
10008 'cyan' : [36, 39],
10009 'green' : [32, 39],
10010 'magenta' : [35, 39],
10011 'red' : [31, 39],
10012 'yellow' : [33, 39]
10013};
10014
10015// Don't use 'blue' not visible on cmd.exe
10016inspect.styles = {
10017 'special': 'cyan',
10018 'number': 'yellow',
10019 'boolean': 'yellow',
10020 'undefined': 'grey',
10021 'null': 'bold',
10022 'string': 'green',
10023 'date': 'magenta',
10024 // "name": intentionally not styling
10025 'regexp': 'red'
10026};
10027
10028
10029function stylizeWithColor(str, styleType) {
10030 var style = inspect.styles[styleType];
10031
10032 if (style) {
10033 return '\u001b[' + inspect.colors[style][0] + 'm' + str +
10034 '\u001b[' + inspect.colors[style][1] + 'm';
10035 } else {
10036 return str;
10037 }
10038}
10039
10040
10041function stylizeNoColor(str, styleType) {
10042 return str;
10043}
10044
10045
10046function arrayToHash(array) {
10047 var hash = {};
10048
10049 array.forEach(function(val, idx) {
10050 hash[val] = true;
10051 });
10052
10053 return hash;
10054}
10055
10056
10057function formatValue(ctx, value, recurseTimes) {
10058 // Provide a hook for user-specified inspect functions.
10059 // Check that value is an object with an inspect function on it
10060 if (ctx.customInspect &&
10061 value &&
10062 isFunction(value.inspect) &&
10063 // Filter out the util module, it's inspect function is special
10064 value.inspect !== exports.inspect &&
10065 // Also filter out any prototype objects using the circular check.
10066 !(value.constructor && value.constructor.prototype === value)) {
10067 var ret = value.inspect(recurseTimes, ctx);
10068 if (!isString(ret)) {
10069 ret = formatValue(ctx, ret, recurseTimes);
10070 }
10071 return ret;
10072 }
10073
10074 // Primitive types cannot have properties
10075 var primitive = formatPrimitive(ctx, value);
10076 if (primitive) {
10077 return primitive;
10078 }
10079
10080 // Look up the keys of the object.
10081 var keys = Object.keys(value);
10082 var visibleKeys = arrayToHash(keys);
10083
10084 if (ctx.showHidden) {
10085 keys = Object.getOwnPropertyNames(value);
10086 }
10087
10088 // IE doesn't make error fields non-enumerable
10089 // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
10090 if (isError(value)
10091 && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
10092 return formatError(value);
10093 }
10094
10095 // Some type of object without properties can be shortcutted.
10096 if (keys.length === 0) {
10097 if (isFunction(value)) {
10098 var name = value.name ? ': ' + value.name : '';
10099 return ctx.stylize('[Function' + name + ']', 'special');
10100 }
10101 if (isRegExp(value)) {
10102 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
10103 }
10104 if (isDate(value)) {
10105 return ctx.stylize(Date.prototype.toString.call(value), 'date');
10106 }
10107 if (isError(value)) {
10108 return formatError(value);
10109 }
10110 }
10111
10112 var base = '', array = false, braces = ['{', '}'];
10113
10114 // Make Array say that they are Array
10115 if (isArray(value)) {
10116 array = true;
10117 braces = ['[', ']'];
10118 }
10119
10120 // Make functions say that they are functions
10121 if (isFunction(value)) {
10122 var n = value.name ? ': ' + value.name : '';
10123 base = ' [Function' + n + ']';
10124 }
10125
10126 // Make RegExps say that they are RegExps
10127 if (isRegExp(value)) {
10128 base = ' ' + RegExp.prototype.toString.call(value);
10129 }
10130
10131 // Make dates with properties first say the date
10132 if (isDate(value)) {
10133 base = ' ' + Date.prototype.toUTCString.call(value);
10134 }
10135
10136 // Make error with message first say the error
10137 if (isError(value)) {
10138 base = ' ' + formatError(value);
10139 }
10140
10141 if (keys.length === 0 && (!array || value.length == 0)) {
10142 return braces[0] + base + braces[1];
10143 }
10144
10145 if (recurseTimes < 0) {
10146 if (isRegExp(value)) {
10147 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
10148 } else {
10149 return ctx.stylize('[Object]', 'special');
10150 }
10151 }
10152
10153 ctx.seen.push(value);
10154
10155 var output;
10156 if (array) {
10157 output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
10158 } else {
10159 output = keys.map(function(key) {
10160 return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
10161 });
10162 }
10163
10164 ctx.seen.pop();
10165
10166 return reduceToSingleString(output, base, braces);
10167}
10168
10169
10170function formatPrimitive(ctx, value) {
10171 if (isUndefined(value))
10172 return ctx.stylize('undefined', 'undefined');
10173 if (isString(value)) {
10174 var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
10175 .replace(/'/g, "\\'")
10176 .replace(/\\"/g, '"') + '\'';
10177 return ctx.stylize(simple, 'string');
10178 }
10179 if (isNumber(value))
10180 return ctx.stylize('' + value, 'number');
10181 if (isBoolean(value))
10182 return ctx.stylize('' + value, 'boolean');
10183 // For some reason typeof null is "object", so special case here.
10184 if (isNull(value))
10185 return ctx.stylize('null', 'null');
10186}
10187
10188
10189function formatError(value) {
10190 return '[' + Error.prototype.toString.call(value) + ']';
10191}
10192
10193
10194function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
10195 var output = [];
10196 for (var i = 0, l = value.length; i < l; ++i) {
10197 if (hasOwnProperty(value, String(i))) {
10198 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
10199 String(i), true));
10200 } else {
10201 output.push('');
10202 }
10203 }
10204 keys.forEach(function(key) {
10205 if (!key.match(/^\d+$/)) {
10206 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
10207 key, true));
10208 }
10209 });
10210 return output;
10211}
10212
10213
10214function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
10215 var name, str, desc;
10216 desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
10217 if (desc.get) {
10218 if (desc.set) {
10219 str = ctx.stylize('[Getter/Setter]', 'special');
10220 } else {
10221 str = ctx.stylize('[Getter]', 'special');
10222 }
10223 } else {
10224 if (desc.set) {
10225 str = ctx.stylize('[Setter]', 'special');
10226 }
10227 }
10228 if (!hasOwnProperty(visibleKeys, key)) {
10229 name = '[' + key + ']';
10230 }
10231 if (!str) {
10232 if (ctx.seen.indexOf(desc.value) < 0) {
10233 if (isNull(recurseTimes)) {
10234 str = formatValue(ctx, desc.value, null);
10235 } else {
10236 str = formatValue(ctx, desc.value, recurseTimes - 1);
10237 }
10238 if (str.indexOf('\n') > -1) {
10239 if (array) {
10240 str = str.split('\n').map(function(line) {
10241 return ' ' + line;
10242 }).join('\n').substr(2);
10243 } else {
10244 str = '\n' + str.split('\n').map(function(line) {
10245 return ' ' + line;
10246 }).join('\n');
10247 }
10248 }
10249 } else {
10250 str = ctx.stylize('[Circular]', 'special');
10251 }
10252 }
10253 if (isUndefined(name)) {
10254 if (array && key.match(/^\d+$/)) {
10255 return str;
10256 }
10257 name = JSON.stringify('' + key);
10258 if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
10259 name = name.substr(1, name.length - 2);
10260 name = ctx.stylize(name, 'name');
10261 } else {
10262 name = name.replace(/'/g, "\\'")
10263 .replace(/\\"/g, '"')
10264 .replace(/(^"|"$)/g, "'");
10265 name = ctx.stylize(name, 'string');
10266 }
10267 }
10268
10269 return name + ': ' + str;
10270}
10271
10272
10273function reduceToSingleString(output, base, braces) {
10274 var numLinesEst = 0;
10275 var length = output.reduce(function(prev, cur) {
10276 numLinesEst++;
10277 if (cur.indexOf('\n') >= 0) numLinesEst++;
10278 return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
10279 }, 0);
10280
10281 if (length > 60) {
10282 return braces[0] +
10283 (base === '' ? '' : base + '\n ') +
10284 ' ' +
10285 output.join(',\n ') +
10286 ' ' +
10287 braces[1];
10288 }
10289
10290 return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
10291}
10292
10293
10294// NOTE: These type checking functions intentionally don't use `instanceof`
10295// because it is fragile and can be easily faked with `Object.create()`.
10296function isArray(ar) {
10297 return Array.isArray(ar);
10298}
10299exports.isArray = isArray;
10300
10301function isBoolean(arg) {
10302 return typeof arg === 'boolean';
10303}
10304exports.isBoolean = isBoolean;
10305
10306function isNull(arg) {
10307 return arg === null;
10308}
10309exports.isNull = isNull;
10310
10311function isNullOrUndefined(arg) {
10312 return arg == null;
10313}
10314exports.isNullOrUndefined = isNullOrUndefined;
10315
10316function isNumber(arg) {
10317 return typeof arg === 'number';
10318}
10319exports.isNumber = isNumber;
10320
10321function isString(arg) {
10322 return typeof arg === 'string';
10323}
10324exports.isString = isString;
10325
10326function isSymbol(arg) {
10327 return typeof arg === 'symbol';
10328}
10329exports.isSymbol = isSymbol;
10330
10331function isUndefined(arg) {
10332 return arg === void 0;
10333}
10334exports.isUndefined = isUndefined;
10335
10336function isRegExp(re) {
10337 return isObject(re) && objectToString(re) === '[object RegExp]';
10338}
10339exports.isRegExp = isRegExp;
10340
10341function isObject(arg) {
10342 return typeof arg === 'object' && arg !== null;
10343}
10344exports.isObject = isObject;
10345
10346function isDate(d) {
10347 return isObject(d) && objectToString(d) === '[object Date]';
10348}
10349exports.isDate = isDate;
10350
10351function isError(e) {
10352 return isObject(e) &&
10353 (objectToString(e) === '[object Error]' || e instanceof Error);
10354}
10355exports.isError = isError;
10356
10357function isFunction(arg) {
10358 return typeof arg === 'function';
10359}
10360exports.isFunction = isFunction;
10361
10362function isPrimitive(arg) {
10363 return arg === null ||
10364 typeof arg === 'boolean' ||
10365 typeof arg === 'number' ||
10366 typeof arg === 'string' ||
10367 typeof arg === 'symbol' || // ES6 symbol
10368 typeof arg === 'undefined';
10369}
10370exports.isPrimitive = isPrimitive;
10371
10372exports.isBuffer = require('./support/isBuffer');
10373
10374function objectToString(o) {
10375 return Object.prototype.toString.call(o);
10376}
10377
10378
10379function pad(n) {
10380 return n < 10 ? '0' + n.toString(10) : n.toString(10);
10381}
10382
10383
10384var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
10385 'Oct', 'Nov', 'Dec'];
10386
10387// 26 Feb 16:19:34
10388function timestamp() {
10389 var d = new Date();
10390 var time = [pad(d.getHours()),
10391 pad(d.getMinutes()),
10392 pad(d.getSeconds())].join(':');
10393 return [d.getDate(), months[d.getMonth()], time].join(' ');
10394}
10395
10396
10397// log is just a thin wrapper to console.log that prepends a timestamp
10398exports.log = function() {
10399 console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
10400};
10401
10402
10403/**
10404 * Inherit the prototype methods from one constructor into another.
10405 *
10406 * The Function.prototype.inherits from lang.js rewritten as a standalone
10407 * function (not on Function.prototype). NOTE: If this file is to be loaded
10408 * during bootstrapping this function needs to be rewritten using some native
10409 * functions as prototype setup using normal JavaScript does not work as
10410 * expected during bootstrapping (see mirror.js in r114903).
10411 *
10412 * @param {function} ctor Constructor function which needs to inherit the
10413 * prototype.
10414 * @param {function} superCtor Constructor function to inherit prototype from.
10415 */
10416exports.inherits = require('inherits');
10417
10418exports._extend = function(origin, add) {
10419 // Don't do anything if add isn't an object
10420 if (!add || !isObject(add)) return origin;
10421
10422 var keys = Object.keys(add);
10423 var i = keys.length;
10424 while (i--) {
10425 origin[keys[i]] = add[keys[i]];
10426 }
10427 return origin;
10428};
10429
10430function hasOwnProperty(obj, prop) {
10431 return Object.prototype.hasOwnProperty.call(obj, prop);
10432}
10433
10434}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
10435},{"./support/isBuffer":76,"_process":181,"inherits":75}],78:[function(require,module,exports){
10436'use strict'
10437
10438exports.byteLength = byteLength
10439exports.toByteArray = toByteArray
10440exports.fromByteArray = fromByteArray
10441
10442var lookup = []
10443var revLookup = []
10444var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
10445
10446var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
10447for (var i = 0, len = code.length; i < len; ++i) {
10448 lookup[i] = code[i]
10449 revLookup[code.charCodeAt(i)] = i
10450}
10451
10452// Support decoding URL-safe base64 strings, as Node.js does.
10453// See: https://en.wikipedia.org/wiki/Base64#URL_applications
10454revLookup['-'.charCodeAt(0)] = 62
10455revLookup['_'.charCodeAt(0)] = 63
10456
10457function getLens (b64) {
10458 var len = b64.length
10459
10460 if (len % 4 > 0) {
10461 throw new Error('Invalid string. Length must be a multiple of 4')
10462 }
10463
10464 // Trim off extra bytes after placeholder bytes are found
10465 // See: https://github.com/beatgammit/base64-js/issues/42
10466 var validLen = b64.indexOf('=')
10467 if (validLen === -1) validLen = len
10468
10469 var placeHoldersLen = validLen === len
10470 ? 0
10471 : 4 - (validLen % 4)
10472
10473 return [validLen, placeHoldersLen]
10474}
10475
10476// base64 is 4/3 + up to two characters of the original data
10477function byteLength (b64) {
10478 var lens = getLens(b64)
10479 var validLen = lens[0]
10480 var placeHoldersLen = lens[1]
10481 return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
10482}
10483
10484function _byteLength (b64, validLen, placeHoldersLen) {
10485 return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
10486}
10487
10488function toByteArray (b64) {
10489 var tmp
10490 var lens = getLens(b64)
10491 var validLen = lens[0]
10492 var placeHoldersLen = lens[1]
10493
10494 var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
10495
10496 var curByte = 0
10497
10498 // if there are placeholders, only get up to the last complete 4 chars
10499 var len = placeHoldersLen > 0
10500 ? validLen - 4
10501 : validLen
10502
10503 var i
10504 for (i = 0; i < len; i += 4) {
10505 tmp =
10506 (revLookup[b64.charCodeAt(i)] << 18) |
10507 (revLookup[b64.charCodeAt(i + 1)] << 12) |
10508 (revLookup[b64.charCodeAt(i + 2)] << 6) |
10509 revLookup[b64.charCodeAt(i + 3)]
10510 arr[curByte++] = (tmp >> 16) & 0xFF
10511 arr[curByte++] = (tmp >> 8) & 0xFF
10512 arr[curByte++] = tmp & 0xFF
10513 }
10514
10515 if (placeHoldersLen === 2) {
10516 tmp =
10517 (revLookup[b64.charCodeAt(i)] << 2) |
10518 (revLookup[b64.charCodeAt(i + 1)] >> 4)
10519 arr[curByte++] = tmp & 0xFF
10520 }
10521
10522 if (placeHoldersLen === 1) {
10523 tmp =
10524 (revLookup[b64.charCodeAt(i)] << 10) |
10525 (revLookup[b64.charCodeAt(i + 1)] << 4) |
10526 (revLookup[b64.charCodeAt(i + 2)] >> 2)
10527 arr[curByte++] = (tmp >> 8) & 0xFF
10528 arr[curByte++] = tmp & 0xFF
10529 }
10530
10531 return arr
10532}
10533
10534function tripletToBase64 (num) {
10535 return lookup[num >> 18 & 0x3F] +
10536 lookup[num >> 12 & 0x3F] +
10537 lookup[num >> 6 & 0x3F] +
10538 lookup[num & 0x3F]
10539}
10540
10541function encodeChunk (uint8, start, end) {
10542 var tmp
10543 var output = []
10544 for (var i = start; i < end; i += 3) {
10545 tmp =
10546 ((uint8[i] << 16) & 0xFF0000) +
10547 ((uint8[i + 1] << 8) & 0xFF00) +
10548 (uint8[i + 2] & 0xFF)
10549 output.push(tripletToBase64(tmp))
10550 }
10551 return output.join('')
10552}
10553
10554function fromByteArray (uint8) {
10555 var tmp
10556 var len = uint8.length
10557 var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
10558 var parts = []
10559 var maxChunkLength = 16383 // must be multiple of 3
10560
10561 // go through the array every three bytes, we'll deal with trailing stuff later
10562 for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
10563 parts.push(encodeChunk(
10564 uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
10565 ))
10566 }
10567
10568 // pad the end with zeros, but make sure to not forget the extra bytes
10569 if (extraBytes === 1) {
10570 tmp = uint8[len - 1]
10571 parts.push(
10572 lookup[tmp >> 2] +
10573 lookup[(tmp << 4) & 0x3F] +
10574 '=='
10575 )
10576 } else if (extraBytes === 2) {
10577 tmp = (uint8[len - 2] << 8) + uint8[len - 1]
10578 parts.push(
10579 lookup[tmp >> 10] +
10580 lookup[(tmp >> 4) & 0x3F] +
10581 lookup[(tmp << 2) & 0x3F] +
10582 '='
10583 )
10584 }
10585
10586 return parts.join('')
10587}
10588
10589},{}],79:[function(require,module,exports){
10590(function (module, exports) {
10591 'use strict';
10592
10593 // Utils
10594 function assert (val, msg) {
10595 if (!val) throw new Error(msg || 'Assertion failed');
10596 }
10597
10598 // Could use `inherits` module, but don't want to move from single file
10599 // architecture yet.
10600 function inherits (ctor, superCtor) {
10601 ctor.super_ = superCtor;
10602 var TempCtor = function () {};
10603 TempCtor.prototype = superCtor.prototype;
10604 ctor.prototype = new TempCtor();
10605 ctor.prototype.constructor = ctor;
10606 }
10607
10608 // BN
10609
10610 function BN (number, base, endian) {
10611 if (BN.isBN(number)) {
10612 return number;
10613 }
10614
10615 this.negative = 0;
10616 this.words = null;
10617 this.length = 0;
10618
10619 // Reduction context
10620 this.red = null;
10621
10622 if (number !== null) {
10623 if (base === 'le' || base === 'be') {
10624 endian = base;
10625 base = 10;
10626 }
10627
10628 this._init(number || 0, base || 10, endian || 'be');
10629 }
10630 }
10631 if (typeof module === 'object') {
10632 module.exports = BN;
10633 } else {
10634 exports.BN = BN;
10635 }
10636
10637 BN.BN = BN;
10638 BN.wordSize = 26;
10639
10640 var Buffer;
10641 try {
10642 Buffer = require('buffer').Buffer;
10643 } catch (e) {
10644 }
10645
10646 BN.isBN = function isBN (num) {
10647 if (num instanceof BN) {
10648 return true;
10649 }
10650
10651 return num !== null && typeof num === 'object' &&
10652 num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);
10653 };
10654
10655 BN.max = function max (left, right) {
10656 if (left.cmp(right) > 0) return left;
10657 return right;
10658 };
10659
10660 BN.min = function min (left, right) {
10661 if (left.cmp(right) < 0) return left;
10662 return right;
10663 };
10664
10665 BN.prototype._init = function init (number, base, endian) {
10666 if (typeof number === 'number') {
10667 return this._initNumber(number, base, endian);
10668 }
10669
10670 if (typeof number === 'object') {
10671 return this._initArray(number, base, endian);
10672 }
10673
10674 if (base === 'hex') {
10675 base = 16;
10676 }
10677 assert(base === (base | 0) && base >= 2 && base <= 36);
10678
10679 number = number.toString().replace(/\s+/g, '');
10680 var start = 0;
10681 if (number[0] === '-') {
10682 start++;
10683 }
10684
10685 if (base === 16) {
10686 this._parseHex(number, start);
10687 } else {
10688 this._parseBase(number, base, start);
10689 }
10690
10691 if (number[0] === '-') {
10692 this.negative = 1;
10693 }
10694
10695 this.strip();
10696
10697 if (endian !== 'le') return;
10698
10699 this._initArray(this.toArray(), base, endian);
10700 };
10701
10702 BN.prototype._initNumber = function _initNumber (number, base, endian) {
10703 if (number < 0) {
10704 this.negative = 1;
10705 number = -number;
10706 }
10707 if (number < 0x4000000) {
10708 this.words = [ number & 0x3ffffff ];
10709 this.length = 1;
10710 } else if (number < 0x10000000000000) {
10711 this.words = [
10712 number & 0x3ffffff,
10713 (number / 0x4000000) & 0x3ffffff
10714 ];
10715 this.length = 2;
10716 } else {
10717 assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)
10718 this.words = [
10719 number & 0x3ffffff,
10720 (number / 0x4000000) & 0x3ffffff,
10721 1
10722 ];
10723 this.length = 3;
10724 }
10725
10726 if (endian !== 'le') return;
10727
10728 // Reverse the bytes
10729 this._initArray(this.toArray(), base, endian);
10730 };
10731
10732 BN.prototype._initArray = function _initArray (number, base, endian) {
10733 // Perhaps a Uint8Array
10734 assert(typeof number.length === 'number');
10735 if (number.length <= 0) {
10736 this.words = [ 0 ];
10737 this.length = 1;
10738 return this;
10739 }
10740
10741 this.length = Math.ceil(number.length / 3);
10742 this.words = new Array(this.length);
10743 for (var i = 0; i < this.length; i++) {
10744 this.words[i] = 0;
10745 }
10746
10747 var j, w;
10748 var off = 0;
10749 if (endian === 'be') {
10750 for (i = number.length - 1, j = 0; i >= 0; i -= 3) {
10751 w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16);
10752 this.words[j] |= (w << off) & 0x3ffffff;
10753 this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
10754 off += 24;
10755 if (off >= 26) {
10756 off -= 26;
10757 j++;
10758 }
10759 }
10760 } else if (endian === 'le') {
10761 for (i = 0, j = 0; i < number.length; i += 3) {
10762 w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16);
10763 this.words[j] |= (w << off) & 0x3ffffff;
10764 this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
10765 off += 24;
10766 if (off >= 26) {
10767 off -= 26;
10768 j++;
10769 }
10770 }
10771 }
10772 return this.strip();
10773 };
10774
10775 function parseHex (str, start, end) {
10776 var r = 0;
10777 var len = Math.min(str.length, end);
10778 for (var i = start; i < len; i++) {
10779 var c = str.charCodeAt(i) - 48;
10780
10781 r <<= 4;
10782
10783 // 'a' - 'f'
10784 if (c >= 49 && c <= 54) {
10785 r |= c - 49 + 0xa;
10786
10787 // 'A' - 'F'
10788 } else if (c >= 17 && c <= 22) {
10789 r |= c - 17 + 0xa;
10790
10791 // '0' - '9'
10792 } else {
10793 r |= c & 0xf;
10794 }
10795 }
10796 return r;
10797 }
10798
10799 BN.prototype._parseHex = function _parseHex (number, start) {
10800 // Create possibly bigger array to ensure that it fits the number
10801 this.length = Math.ceil((number.length - start) / 6);
10802 this.words = new Array(this.length);
10803 for (var i = 0; i < this.length; i++) {
10804 this.words[i] = 0;
10805 }
10806
10807 var j, w;
10808 // Scan 24-bit chunks and add them to the number
10809 var off = 0;
10810 for (i = number.length - 6, j = 0; i >= start; i -= 6) {
10811 w = parseHex(number, i, i + 6);
10812 this.words[j] |= (w << off) & 0x3ffffff;
10813 // NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb
10814 this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;
10815 off += 24;
10816 if (off >= 26) {
10817 off -= 26;
10818 j++;
10819 }
10820 }
10821 if (i + 6 !== start) {
10822 w = parseHex(number, start, i + 6);
10823 this.words[j] |= (w << off) & 0x3ffffff;
10824 this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;
10825 }
10826 this.strip();
10827 };
10828
10829 function parseBase (str, start, end, mul) {
10830 var r = 0;
10831 var len = Math.min(str.length, end);
10832 for (var i = start; i < len; i++) {
10833 var c = str.charCodeAt(i) - 48;
10834
10835 r *= mul;
10836
10837 // 'a'
10838 if (c >= 49) {
10839 r += c - 49 + 0xa;
10840
10841 // 'A'
10842 } else if (c >= 17) {
10843 r += c - 17 + 0xa;
10844
10845 // '0' - '9'
10846 } else {
10847 r += c;
10848 }
10849 }
10850 return r;
10851 }
10852
10853 BN.prototype._parseBase = function _parseBase (number, base, start) {
10854 // Initialize as zero
10855 this.words = [ 0 ];
10856 this.length = 1;
10857
10858 // Find length of limb in base
10859 for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {
10860 limbLen++;
10861 }
10862 limbLen--;
10863 limbPow = (limbPow / base) | 0;
10864
10865 var total = number.length - start;
10866 var mod = total % limbLen;
10867 var end = Math.min(total, total - mod) + start;
10868
10869 var word = 0;
10870 for (var i = start; i < end; i += limbLen) {
10871 word = parseBase(number, i, i + limbLen, base);
10872
10873 this.imuln(limbPow);
10874 if (this.words[0] + word < 0x4000000) {
10875 this.words[0] += word;
10876 } else {
10877 this._iaddn(word);
10878 }
10879 }
10880
10881 if (mod !== 0) {
10882 var pow = 1;
10883 word = parseBase(number, i, number.length, base);
10884
10885 for (i = 0; i < mod; i++) {
10886 pow *= base;
10887 }
10888
10889 this.imuln(pow);
10890 if (this.words[0] + word < 0x4000000) {
10891 this.words[0] += word;
10892 } else {
10893 this._iaddn(word);
10894 }
10895 }
10896 };
10897
10898 BN.prototype.copy = function copy (dest) {
10899 dest.words = new Array(this.length);
10900 for (var i = 0; i < this.length; i++) {
10901 dest.words[i] = this.words[i];
10902 }
10903 dest.length = this.length;
10904 dest.negative = this.negative;
10905 dest.red = this.red;
10906 };
10907
10908 BN.prototype.clone = function clone () {
10909 var r = new BN(null);
10910 this.copy(r);
10911 return r;
10912 };
10913
10914 BN.prototype._expand = function _expand (size) {
10915 while (this.length < size) {
10916 this.words[this.length++] = 0;
10917 }
10918 return this;
10919 };
10920
10921 // Remove leading `0` from `this`
10922 BN.prototype.strip = function strip () {
10923 while (this.length > 1 && this.words[this.length - 1] === 0) {
10924 this.length--;
10925 }
10926 return this._normSign();
10927 };
10928
10929 BN.prototype._normSign = function _normSign () {
10930 // -0 = 0
10931 if (this.length === 1 && this.words[0] === 0) {
10932 this.negative = 0;
10933 }
10934 return this;
10935 };
10936
10937 BN.prototype.inspect = function inspect () {
10938 return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';
10939 };
10940
10941 /*
10942
10943 var zeros = [];
10944 var groupSizes = [];
10945 var groupBases = [];
10946
10947 var s = '';
10948 var i = -1;
10949 while (++i < BN.wordSize) {
10950 zeros[i] = s;
10951 s += '0';
10952 }
10953 groupSizes[0] = 0;
10954 groupSizes[1] = 0;
10955 groupBases[0] = 0;
10956 groupBases[1] = 0;
10957 var base = 2 - 1;
10958 while (++base < 36 + 1) {
10959 var groupSize = 0;
10960 var groupBase = 1;
10961 while (groupBase < (1 << BN.wordSize) / base) {
10962 groupBase *= base;
10963 groupSize += 1;
10964 }
10965 groupSizes[base] = groupSize;
10966 groupBases[base] = groupBase;
10967 }
10968
10969 */
10970
10971 var zeros = [
10972 '',
10973 '0',
10974 '00',
10975 '000',
10976 '0000',
10977 '00000',
10978 '000000',
10979 '0000000',
10980 '00000000',
10981 '000000000',
10982 '0000000000',
10983 '00000000000',
10984 '000000000000',
10985 '0000000000000',
10986 '00000000000000',
10987 '000000000000000',
10988 '0000000000000000',
10989 '00000000000000000',
10990 '000000000000000000',
10991 '0000000000000000000',
10992 '00000000000000000000',
10993 '000000000000000000000',
10994 '0000000000000000000000',
10995 '00000000000000000000000',
10996 '000000000000000000000000',
10997 '0000000000000000000000000'
10998 ];
10999
11000 var groupSizes = [
11001 0, 0,
11002 25, 16, 12, 11, 10, 9, 8,
11003 8, 7, 7, 7, 7, 6, 6,
11004 6, 6, 6, 6, 6, 5, 5,
11005 5, 5, 5, 5, 5, 5, 5,
11006 5, 5, 5, 5, 5, 5, 5
11007 ];
11008
11009 var groupBases = [
11010 0, 0,
11011 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216,
11012 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625,
11013 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632,
11014 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149,
11015 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176
11016 ];
11017
11018 BN.prototype.toString = function toString (base, padding) {
11019 base = base || 10;
11020 padding = padding | 0 || 1;
11021
11022 var out;
11023 if (base === 16 || base === 'hex') {
11024 out = '';
11025 var off = 0;
11026 var carry = 0;
11027 for (var i = 0; i < this.length; i++) {
11028 var w = this.words[i];
11029 var word = (((w << off) | carry) & 0xffffff).toString(16);
11030 carry = (w >>> (24 - off)) & 0xffffff;
11031 if (carry !== 0 || i !== this.length - 1) {
11032 out = zeros[6 - word.length] + word + out;
11033 } else {
11034 out = word + out;
11035 }
11036 off += 2;
11037 if (off >= 26) {
11038 off -= 26;
11039 i--;
11040 }
11041 }
11042 if (carry !== 0) {
11043 out = carry.toString(16) + out;
11044 }
11045 while (out.length % padding !== 0) {
11046 out = '0' + out;
11047 }
11048 if (this.negative !== 0) {
11049 out = '-' + out;
11050 }
11051 return out;
11052 }
11053
11054 if (base === (base | 0) && base >= 2 && base <= 36) {
11055 // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));
11056 var groupSize = groupSizes[base];
11057 // var groupBase = Math.pow(base, groupSize);
11058 var groupBase = groupBases[base];
11059 out = '';
11060 var c = this.clone();
11061 c.negative = 0;
11062 while (!c.isZero()) {
11063 var r = c.modn(groupBase).toString(base);
11064 c = c.idivn(groupBase);
11065
11066 if (!c.isZero()) {
11067 out = zeros[groupSize - r.length] + r + out;
11068 } else {
11069 out = r + out;
11070 }
11071 }
11072 if (this.isZero()) {
11073 out = '0' + out;
11074 }
11075 while (out.length % padding !== 0) {
11076 out = '0' + out;
11077 }
11078 if (this.negative !== 0) {
11079 out = '-' + out;
11080 }
11081 return out;
11082 }
11083
11084 assert(false, 'Base should be between 2 and 36');
11085 };
11086
11087 BN.prototype.toNumber = function toNumber () {
11088 var ret = this.words[0];
11089 if (this.length === 2) {
11090 ret += this.words[1] * 0x4000000;
11091 } else if (this.length === 3 && this.words[2] === 0x01) {
11092 // NOTE: at this stage it is known that the top bit is set
11093 ret += 0x10000000000000 + (this.words[1] * 0x4000000);
11094 } else if (this.length > 2) {
11095 assert(false, 'Number can only safely store up to 53 bits');
11096 }
11097 return (this.negative !== 0) ? -ret : ret;
11098 };
11099
11100 BN.prototype.toJSON = function toJSON () {
11101 return this.toString(16);
11102 };
11103
11104 BN.prototype.toBuffer = function toBuffer (endian, length) {
11105 assert(typeof Buffer !== 'undefined');
11106 return this.toArrayLike(Buffer, endian, length);
11107 };
11108
11109 BN.prototype.toArray = function toArray (endian, length) {
11110 return this.toArrayLike(Array, endian, length);
11111 };
11112
11113 BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) {
11114 var byteLength = this.byteLength();
11115 var reqLength = length || Math.max(1, byteLength);
11116 assert(byteLength <= reqLength, 'byte array longer than desired length');
11117 assert(reqLength > 0, 'Requested array length <= 0');
11118
11119 this.strip();
11120 var littleEndian = endian === 'le';
11121 var res = new ArrayType(reqLength);
11122
11123 var b, i;
11124 var q = this.clone();
11125 if (!littleEndian) {
11126 // Assume big-endian
11127 for (i = 0; i < reqLength - byteLength; i++) {
11128 res[i] = 0;
11129 }
11130
11131 for (i = 0; !q.isZero(); i++) {
11132 b = q.andln(0xff);
11133 q.iushrn(8);
11134
11135 res[reqLength - i - 1] = b;
11136 }
11137 } else {
11138 for (i = 0; !q.isZero(); i++) {
11139 b = q.andln(0xff);
11140 q.iushrn(8);
11141
11142 res[i] = b;
11143 }
11144
11145 for (; i < reqLength; i++) {
11146 res[i] = 0;
11147 }
11148 }
11149
11150 return res;
11151 };
11152
11153 if (Math.clz32) {
11154 BN.prototype._countBits = function _countBits (w) {
11155 return 32 - Math.clz32(w);
11156 };
11157 } else {
11158 BN.prototype._countBits = function _countBits (w) {
11159 var t = w;
11160 var r = 0;
11161 if (t >= 0x1000) {
11162 r += 13;
11163 t >>>= 13;
11164 }
11165 if (t >= 0x40) {
11166 r += 7;
11167 t >>>= 7;
11168 }
11169 if (t >= 0x8) {
11170 r += 4;
11171 t >>>= 4;
11172 }
11173 if (t >= 0x02) {
11174 r += 2;
11175 t >>>= 2;
11176 }
11177 return r + t;
11178 };
11179 }
11180
11181 BN.prototype._zeroBits = function _zeroBits (w) {
11182 // Short-cut
11183 if (w === 0) return 26;
11184
11185 var t = w;
11186 var r = 0;
11187 if ((t & 0x1fff) === 0) {
11188 r += 13;
11189 t >>>= 13;
11190 }
11191 if ((t & 0x7f) === 0) {
11192 r += 7;
11193 t >>>= 7;
11194 }
11195 if ((t & 0xf) === 0) {
11196 r += 4;
11197 t >>>= 4;
11198 }
11199 if ((t & 0x3) === 0) {
11200 r += 2;
11201 t >>>= 2;
11202 }
11203 if ((t & 0x1) === 0) {
11204 r++;
11205 }
11206 return r;
11207 };
11208
11209 // Return number of used bits in a BN
11210 BN.prototype.bitLength = function bitLength () {
11211 var w = this.words[this.length - 1];
11212 var hi = this._countBits(w);
11213 return (this.length - 1) * 26 + hi;
11214 };
11215
11216 function toBitArray (num) {
11217 var w = new Array(num.bitLength());
11218
11219 for (var bit = 0; bit < w.length; bit++) {
11220 var off = (bit / 26) | 0;
11221 var wbit = bit % 26;
11222
11223 w[bit] = (num.words[off] & (1 << wbit)) >>> wbit;
11224 }
11225
11226 return w;
11227 }
11228
11229 // Number of trailing zero bits
11230 BN.prototype.zeroBits = function zeroBits () {
11231 if (this.isZero()) return 0;
11232
11233 var r = 0;
11234 for (var i = 0; i < this.length; i++) {
11235 var b = this._zeroBits(this.words[i]);
11236 r += b;
11237 if (b !== 26) break;
11238 }
11239 return r;
11240 };
11241
11242 BN.prototype.byteLength = function byteLength () {
11243 return Math.ceil(this.bitLength() / 8);
11244 };
11245
11246 BN.prototype.toTwos = function toTwos (width) {
11247 if (this.negative !== 0) {
11248 return this.abs().inotn(width).iaddn(1);
11249 }
11250 return this.clone();
11251 };
11252
11253 BN.prototype.fromTwos = function fromTwos (width) {
11254 if (this.testn(width - 1)) {
11255 return this.notn(width).iaddn(1).ineg();
11256 }
11257 return this.clone();
11258 };
11259
11260 BN.prototype.isNeg = function isNeg () {
11261 return this.negative !== 0;
11262 };
11263
11264 // Return negative clone of `this`
11265 BN.prototype.neg = function neg () {
11266 return this.clone().ineg();
11267 };
11268
11269 BN.prototype.ineg = function ineg () {
11270 if (!this.isZero()) {
11271 this.negative ^= 1;
11272 }
11273
11274 return this;
11275 };
11276
11277 // Or `num` with `this` in-place
11278 BN.prototype.iuor = function iuor (num) {
11279 while (this.length < num.length) {
11280 this.words[this.length++] = 0;
11281 }
11282
11283 for (var i = 0; i < num.length; i++) {
11284 this.words[i] = this.words[i] | num.words[i];
11285 }
11286
11287 return this.strip();
11288 };
11289
11290 BN.prototype.ior = function ior (num) {
11291 assert((this.negative | num.negative) === 0);
11292 return this.iuor(num);
11293 };
11294
11295 // Or `num` with `this`
11296 BN.prototype.or = function or (num) {
11297 if (this.length > num.length) return this.clone().ior(num);
11298 return num.clone().ior(this);
11299 };
11300
11301 BN.prototype.uor = function uor (num) {
11302 if (this.length > num.length) return this.clone().iuor(num);
11303 return num.clone().iuor(this);
11304 };
11305
11306 // And `num` with `this` in-place
11307 BN.prototype.iuand = function iuand (num) {
11308 // b = min-length(num, this)
11309 var b;
11310 if (this.length > num.length) {
11311 b = num;
11312 } else {
11313 b = this;
11314 }
11315
11316 for (var i = 0; i < b.length; i++) {
11317 this.words[i] = this.words[i] & num.words[i];
11318 }
11319
11320 this.length = b.length;
11321
11322 return this.strip();
11323 };
11324
11325 BN.prototype.iand = function iand (num) {
11326 assert((this.negative | num.negative) === 0);
11327 return this.iuand(num);
11328 };
11329
11330 // And `num` with `this`
11331 BN.prototype.and = function and (num) {
11332 if (this.length > num.length) return this.clone().iand(num);
11333 return num.clone().iand(this);
11334 };
11335
11336 BN.prototype.uand = function uand (num) {
11337 if (this.length > num.length) return this.clone().iuand(num);
11338 return num.clone().iuand(this);
11339 };
11340
11341 // Xor `num` with `this` in-place
11342 BN.prototype.iuxor = function iuxor (num) {
11343 // a.length > b.length
11344 var a;
11345 var b;
11346 if (this.length > num.length) {
11347 a = this;
11348 b = num;
11349 } else {
11350 a = num;
11351 b = this;
11352 }
11353
11354 for (var i = 0; i < b.length; i++) {
11355 this.words[i] = a.words[i] ^ b.words[i];
11356 }
11357
11358 if (this !== a) {
11359 for (; i < a.length; i++) {
11360 this.words[i] = a.words[i];
11361 }
11362 }
11363
11364 this.length = a.length;
11365
11366 return this.strip();
11367 };
11368
11369 BN.prototype.ixor = function ixor (num) {
11370 assert((this.negative | num.negative) === 0);
11371 return this.iuxor(num);
11372 };
11373
11374 // Xor `num` with `this`
11375 BN.prototype.xor = function xor (num) {
11376 if (this.length > num.length) return this.clone().ixor(num);
11377 return num.clone().ixor(this);
11378 };
11379
11380 BN.prototype.uxor = function uxor (num) {
11381 if (this.length > num.length) return this.clone().iuxor(num);
11382 return num.clone().iuxor(this);
11383 };
11384
11385 // Not ``this`` with ``width`` bitwidth
11386 BN.prototype.inotn = function inotn (width) {
11387 assert(typeof width === 'number' && width >= 0);
11388
11389 var bytesNeeded = Math.ceil(width / 26) | 0;
11390 var bitsLeft = width % 26;
11391
11392 // Extend the buffer with leading zeroes
11393 this._expand(bytesNeeded);
11394
11395 if (bitsLeft > 0) {
11396 bytesNeeded--;
11397 }
11398
11399 // Handle complete words
11400 for (var i = 0; i < bytesNeeded; i++) {
11401 this.words[i] = ~this.words[i] & 0x3ffffff;
11402 }
11403
11404 // Handle the residue
11405 if (bitsLeft > 0) {
11406 this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft));
11407 }
11408
11409 // And remove leading zeroes
11410 return this.strip();
11411 };
11412
11413 BN.prototype.notn = function notn (width) {
11414 return this.clone().inotn(width);
11415 };
11416
11417 // Set `bit` of `this`
11418 BN.prototype.setn = function setn (bit, val) {
11419 assert(typeof bit === 'number' && bit >= 0);
11420
11421 var off = (bit / 26) | 0;
11422 var wbit = bit % 26;
11423
11424 this._expand(off + 1);
11425
11426 if (val) {
11427 this.words[off] = this.words[off] | (1 << wbit);
11428 } else {
11429 this.words[off] = this.words[off] & ~(1 << wbit);
11430 }
11431
11432 return this.strip();
11433 };
11434
11435 // Add `num` to `this` in-place
11436 BN.prototype.iadd = function iadd (num) {
11437 var r;
11438
11439 // negative + positive
11440 if (this.negative !== 0 && num.negative === 0) {
11441 this.negative = 0;
11442 r = this.isub(num);
11443 this.negative ^= 1;
11444 return this._normSign();
11445
11446 // positive + negative
11447 } else if (this.negative === 0 && num.negative !== 0) {
11448 num.negative = 0;
11449 r = this.isub(num);
11450 num.negative = 1;
11451 return r._normSign();
11452 }
11453
11454 // a.length > b.length
11455 var a, b;
11456 if (this.length > num.length) {
11457 a = this;
11458 b = num;
11459 } else {
11460 a = num;
11461 b = this;
11462 }
11463
11464 var carry = 0;
11465 for (var i = 0; i < b.length; i++) {
11466 r = (a.words[i] | 0) + (b.words[i] | 0) + carry;
11467 this.words[i] = r & 0x3ffffff;
11468 carry = r >>> 26;
11469 }
11470 for (; carry !== 0 && i < a.length; i++) {
11471 r = (a.words[i] | 0) + carry;
11472 this.words[i] = r & 0x3ffffff;
11473 carry = r >>> 26;
11474 }
11475
11476 this.length = a.length;
11477 if (carry !== 0) {
11478 this.words[this.length] = carry;
11479 this.length++;
11480 // Copy the rest of the words
11481 } else if (a !== this) {
11482 for (; i < a.length; i++) {
11483 this.words[i] = a.words[i];
11484 }
11485 }
11486
11487 return this;
11488 };
11489
11490 // Add `num` to `this`
11491 BN.prototype.add = function add (num) {
11492 var res;
11493 if (num.negative !== 0 && this.negative === 0) {
11494 num.negative = 0;
11495 res = this.sub(num);
11496 num.negative ^= 1;
11497 return res;
11498 } else if (num.negative === 0 && this.negative !== 0) {
11499 this.negative = 0;
11500 res = num.sub(this);
11501 this.negative = 1;
11502 return res;
11503 }
11504
11505 if (this.length > num.length) return this.clone().iadd(num);
11506
11507 return num.clone().iadd(this);
11508 };
11509
11510 // Subtract `num` from `this` in-place
11511 BN.prototype.isub = function isub (num) {
11512 // this - (-num) = this + num
11513 if (num.negative !== 0) {
11514 num.negative = 0;
11515 var r = this.iadd(num);
11516 num.negative = 1;
11517 return r._normSign();
11518
11519 // -this - num = -(this + num)
11520 } else if (this.negative !== 0) {
11521 this.negative = 0;
11522 this.iadd(num);
11523 this.negative = 1;
11524 return this._normSign();
11525 }
11526
11527 // At this point both numbers are positive
11528 var cmp = this.cmp(num);
11529
11530 // Optimization - zeroify
11531 if (cmp === 0) {
11532 this.negative = 0;
11533 this.length = 1;
11534 this.words[0] = 0;
11535 return this;
11536 }
11537
11538 // a > b
11539 var a, b;
11540 if (cmp > 0) {
11541 a = this;
11542 b = num;
11543 } else {
11544 a = num;
11545 b = this;
11546 }
11547
11548 var carry = 0;
11549 for (var i = 0; i < b.length; i++) {
11550 r = (a.words[i] | 0) - (b.words[i] | 0) + carry;
11551 carry = r >> 26;
11552 this.words[i] = r & 0x3ffffff;
11553 }
11554 for (; carry !== 0 && i < a.length; i++) {
11555 r = (a.words[i] | 0) + carry;
11556 carry = r >> 26;
11557 this.words[i] = r & 0x3ffffff;
11558 }
11559
11560 // Copy rest of the words
11561 if (carry === 0 && i < a.length && a !== this) {
11562 for (; i < a.length; i++) {
11563 this.words[i] = a.words[i];
11564 }
11565 }
11566
11567 this.length = Math.max(this.length, i);
11568
11569 if (a !== this) {
11570 this.negative = 1;
11571 }
11572
11573 return this.strip();
11574 };
11575
11576 // Subtract `num` from `this`
11577 BN.prototype.sub = function sub (num) {
11578 return this.clone().isub(num);
11579 };
11580
11581 function smallMulTo (self, num, out) {
11582 out.negative = num.negative ^ self.negative;
11583 var len = (self.length + num.length) | 0;
11584 out.length = len;
11585 len = (len - 1) | 0;
11586
11587 // Peel one iteration (compiler can't do it, because of code complexity)
11588 var a = self.words[0] | 0;
11589 var b = num.words[0] | 0;
11590 var r = a * b;
11591
11592 var lo = r & 0x3ffffff;
11593 var carry = (r / 0x4000000) | 0;
11594 out.words[0] = lo;
11595
11596 for (var k = 1; k < len; k++) {
11597 // Sum all words with the same `i + j = k` and accumulate `ncarry`,
11598 // note that ncarry could be >= 0x3ffffff
11599 var ncarry = carry >>> 26;
11600 var rword = carry & 0x3ffffff;
11601 var maxJ = Math.min(k, num.length - 1);
11602 for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
11603 var i = (k - j) | 0;
11604 a = self.words[i] | 0;
11605 b = num.words[j] | 0;
11606 r = a * b + rword;
11607 ncarry += (r / 0x4000000) | 0;
11608 rword = r & 0x3ffffff;
11609 }
11610 out.words[k] = rword | 0;
11611 carry = ncarry | 0;
11612 }
11613 if (carry !== 0) {
11614 out.words[k] = carry | 0;
11615 } else {
11616 out.length--;
11617 }
11618
11619 return out.strip();
11620 }
11621
11622 // TODO(indutny): it may be reasonable to omit it for users who don't need
11623 // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit
11624 // multiplication (like elliptic secp256k1).
11625 var comb10MulTo = function comb10MulTo (self, num, out) {
11626 var a = self.words;
11627 var b = num.words;
11628 var o = out.words;
11629 var c = 0;
11630 var lo;
11631 var mid;
11632 var hi;
11633 var a0 = a[0] | 0;
11634 var al0 = a0 & 0x1fff;
11635 var ah0 = a0 >>> 13;
11636 var a1 = a[1] | 0;
11637 var al1 = a1 & 0x1fff;
11638 var ah1 = a1 >>> 13;
11639 var a2 = a[2] | 0;
11640 var al2 = a2 & 0x1fff;
11641 var ah2 = a2 >>> 13;
11642 var a3 = a[3] | 0;
11643 var al3 = a3 & 0x1fff;
11644 var ah3 = a3 >>> 13;
11645 var a4 = a[4] | 0;
11646 var al4 = a4 & 0x1fff;
11647 var ah4 = a4 >>> 13;
11648 var a5 = a[5] | 0;
11649 var al5 = a5 & 0x1fff;
11650 var ah5 = a5 >>> 13;
11651 var a6 = a[6] | 0;
11652 var al6 = a6 & 0x1fff;
11653 var ah6 = a6 >>> 13;
11654 var a7 = a[7] | 0;
11655 var al7 = a7 & 0x1fff;
11656 var ah7 = a7 >>> 13;
11657 var a8 = a[8] | 0;
11658 var al8 = a8 & 0x1fff;
11659 var ah8 = a8 >>> 13;
11660 var a9 = a[9] | 0;
11661 var al9 = a9 & 0x1fff;
11662 var ah9 = a9 >>> 13;
11663 var b0 = b[0] | 0;
11664 var bl0 = b0 & 0x1fff;
11665 var bh0 = b0 >>> 13;
11666 var b1 = b[1] | 0;
11667 var bl1 = b1 & 0x1fff;
11668 var bh1 = b1 >>> 13;
11669 var b2 = b[2] | 0;
11670 var bl2 = b2 & 0x1fff;
11671 var bh2 = b2 >>> 13;
11672 var b3 = b[3] | 0;
11673 var bl3 = b3 & 0x1fff;
11674 var bh3 = b3 >>> 13;
11675 var b4 = b[4] | 0;
11676 var bl4 = b4 & 0x1fff;
11677 var bh4 = b4 >>> 13;
11678 var b5 = b[5] | 0;
11679 var bl5 = b5 & 0x1fff;
11680 var bh5 = b5 >>> 13;
11681 var b6 = b[6] | 0;
11682 var bl6 = b6 & 0x1fff;
11683 var bh6 = b6 >>> 13;
11684 var b7 = b[7] | 0;
11685 var bl7 = b7 & 0x1fff;
11686 var bh7 = b7 >>> 13;
11687 var b8 = b[8] | 0;
11688 var bl8 = b8 & 0x1fff;
11689 var bh8 = b8 >>> 13;
11690 var b9 = b[9] | 0;
11691 var bl9 = b9 & 0x1fff;
11692 var bh9 = b9 >>> 13;
11693
11694 out.negative = self.negative ^ num.negative;
11695 out.length = 19;
11696 /* k = 0 */
11697 lo = Math.imul(al0, bl0);
11698 mid = Math.imul(al0, bh0);
11699 mid = (mid + Math.imul(ah0, bl0)) | 0;
11700 hi = Math.imul(ah0, bh0);
11701 var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
11702 c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0;
11703 w0 &= 0x3ffffff;
11704 /* k = 1 */
11705 lo = Math.imul(al1, bl0);
11706 mid = Math.imul(al1, bh0);
11707 mid = (mid + Math.imul(ah1, bl0)) | 0;
11708 hi = Math.imul(ah1, bh0);
11709 lo = (lo + Math.imul(al0, bl1)) | 0;
11710 mid = (mid + Math.imul(al0, bh1)) | 0;
11711 mid = (mid + Math.imul(ah0, bl1)) | 0;
11712 hi = (hi + Math.imul(ah0, bh1)) | 0;
11713 var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
11714 c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0;
11715 w1 &= 0x3ffffff;
11716 /* k = 2 */
11717 lo = Math.imul(al2, bl0);
11718 mid = Math.imul(al2, bh0);
11719 mid = (mid + Math.imul(ah2, bl0)) | 0;
11720 hi = Math.imul(ah2, bh0);
11721 lo = (lo + Math.imul(al1, bl1)) | 0;
11722 mid = (mid + Math.imul(al1, bh1)) | 0;
11723 mid = (mid + Math.imul(ah1, bl1)) | 0;
11724 hi = (hi + Math.imul(ah1, bh1)) | 0;
11725 lo = (lo + Math.imul(al0, bl2)) | 0;
11726 mid = (mid + Math.imul(al0, bh2)) | 0;
11727 mid = (mid + Math.imul(ah0, bl2)) | 0;
11728 hi = (hi + Math.imul(ah0, bh2)) | 0;
11729 var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
11730 c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0;
11731 w2 &= 0x3ffffff;
11732 /* k = 3 */
11733 lo = Math.imul(al3, bl0);
11734 mid = Math.imul(al3, bh0);
11735 mid = (mid + Math.imul(ah3, bl0)) | 0;
11736 hi = Math.imul(ah3, bh0);
11737 lo = (lo + Math.imul(al2, bl1)) | 0;
11738 mid = (mid + Math.imul(al2, bh1)) | 0;
11739 mid = (mid + Math.imul(ah2, bl1)) | 0;
11740 hi = (hi + Math.imul(ah2, bh1)) | 0;
11741 lo = (lo + Math.imul(al1, bl2)) | 0;
11742 mid = (mid + Math.imul(al1, bh2)) | 0;
11743 mid = (mid + Math.imul(ah1, bl2)) | 0;
11744 hi = (hi + Math.imul(ah1, bh2)) | 0;
11745 lo = (lo + Math.imul(al0, bl3)) | 0;
11746 mid = (mid + Math.imul(al0, bh3)) | 0;
11747 mid = (mid + Math.imul(ah0, bl3)) | 0;
11748 hi = (hi + Math.imul(ah0, bh3)) | 0;
11749 var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
11750 c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0;
11751 w3 &= 0x3ffffff;
11752 /* k = 4 */
11753 lo = Math.imul(al4, bl0);
11754 mid = Math.imul(al4, bh0);
11755 mid = (mid + Math.imul(ah4, bl0)) | 0;
11756 hi = Math.imul(ah4, bh0);
11757 lo = (lo + Math.imul(al3, bl1)) | 0;
11758 mid = (mid + Math.imul(al3, bh1)) | 0;
11759 mid = (mid + Math.imul(ah3, bl1)) | 0;
11760 hi = (hi + Math.imul(ah3, bh1)) | 0;
11761 lo = (lo + Math.imul(al2, bl2)) | 0;
11762 mid = (mid + Math.imul(al2, bh2)) | 0;
11763 mid = (mid + Math.imul(ah2, bl2)) | 0;
11764 hi = (hi + Math.imul(ah2, bh2)) | 0;
11765 lo = (lo + Math.imul(al1, bl3)) | 0;
11766 mid = (mid + Math.imul(al1, bh3)) | 0;
11767 mid = (mid + Math.imul(ah1, bl3)) | 0;
11768 hi = (hi + Math.imul(ah1, bh3)) | 0;
11769 lo = (lo + Math.imul(al0, bl4)) | 0;
11770 mid = (mid + Math.imul(al0, bh4)) | 0;
11771 mid = (mid + Math.imul(ah0, bl4)) | 0;
11772 hi = (hi + Math.imul(ah0, bh4)) | 0;
11773 var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
11774 c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0;
11775 w4 &= 0x3ffffff;
11776 /* k = 5 */
11777 lo = Math.imul(al5, bl0);
11778 mid = Math.imul(al5, bh0);
11779 mid = (mid + Math.imul(ah5, bl0)) | 0;
11780 hi = Math.imul(ah5, bh0);
11781 lo = (lo + Math.imul(al4, bl1)) | 0;
11782 mid = (mid + Math.imul(al4, bh1)) | 0;
11783 mid = (mid + Math.imul(ah4, bl1)) | 0;
11784 hi = (hi + Math.imul(ah4, bh1)) | 0;
11785 lo = (lo + Math.imul(al3, bl2)) | 0;
11786 mid = (mid + Math.imul(al3, bh2)) | 0;
11787 mid = (mid + Math.imul(ah3, bl2)) | 0;
11788 hi = (hi + Math.imul(ah3, bh2)) | 0;
11789 lo = (lo + Math.imul(al2, bl3)) | 0;
11790 mid = (mid + Math.imul(al2, bh3)) | 0;
11791 mid = (mid + Math.imul(ah2, bl3)) | 0;
11792 hi = (hi + Math.imul(ah2, bh3)) | 0;
11793 lo = (lo + Math.imul(al1, bl4)) | 0;
11794 mid = (mid + Math.imul(al1, bh4)) | 0;
11795 mid = (mid + Math.imul(ah1, bl4)) | 0;
11796 hi = (hi + Math.imul(ah1, bh4)) | 0;
11797 lo = (lo + Math.imul(al0, bl5)) | 0;
11798 mid = (mid + Math.imul(al0, bh5)) | 0;
11799 mid = (mid + Math.imul(ah0, bl5)) | 0;
11800 hi = (hi + Math.imul(ah0, bh5)) | 0;
11801 var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
11802 c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0;
11803 w5 &= 0x3ffffff;
11804 /* k = 6 */
11805 lo = Math.imul(al6, bl0);
11806 mid = Math.imul(al6, bh0);
11807 mid = (mid + Math.imul(ah6, bl0)) | 0;
11808 hi = Math.imul(ah6, bh0);
11809 lo = (lo + Math.imul(al5, bl1)) | 0;
11810 mid = (mid + Math.imul(al5, bh1)) | 0;
11811 mid = (mid + Math.imul(ah5, bl1)) | 0;
11812 hi = (hi + Math.imul(ah5, bh1)) | 0;
11813 lo = (lo + Math.imul(al4, bl2)) | 0;
11814 mid = (mid + Math.imul(al4, bh2)) | 0;
11815 mid = (mid + Math.imul(ah4, bl2)) | 0;
11816 hi = (hi + Math.imul(ah4, bh2)) | 0;
11817 lo = (lo + Math.imul(al3, bl3)) | 0;
11818 mid = (mid + Math.imul(al3, bh3)) | 0;
11819 mid = (mid + Math.imul(ah3, bl3)) | 0;
11820 hi = (hi + Math.imul(ah3, bh3)) | 0;
11821 lo = (lo + Math.imul(al2, bl4)) | 0;
11822 mid = (mid + Math.imul(al2, bh4)) | 0;
11823 mid = (mid + Math.imul(ah2, bl4)) | 0;
11824 hi = (hi + Math.imul(ah2, bh4)) | 0;
11825 lo = (lo + Math.imul(al1, bl5)) | 0;
11826 mid = (mid + Math.imul(al1, bh5)) | 0;
11827 mid = (mid + Math.imul(ah1, bl5)) | 0;
11828 hi = (hi + Math.imul(ah1, bh5)) | 0;
11829 lo = (lo + Math.imul(al0, bl6)) | 0;
11830 mid = (mid + Math.imul(al0, bh6)) | 0;
11831 mid = (mid + Math.imul(ah0, bl6)) | 0;
11832 hi = (hi + Math.imul(ah0, bh6)) | 0;
11833 var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
11834 c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0;
11835 w6 &= 0x3ffffff;
11836 /* k = 7 */
11837 lo = Math.imul(al7, bl0);
11838 mid = Math.imul(al7, bh0);
11839 mid = (mid + Math.imul(ah7, bl0)) | 0;
11840 hi = Math.imul(ah7, bh0);
11841 lo = (lo + Math.imul(al6, bl1)) | 0;
11842 mid = (mid + Math.imul(al6, bh1)) | 0;
11843 mid = (mid + Math.imul(ah6, bl1)) | 0;
11844 hi = (hi + Math.imul(ah6, bh1)) | 0;
11845 lo = (lo + Math.imul(al5, bl2)) | 0;
11846 mid = (mid + Math.imul(al5, bh2)) | 0;
11847 mid = (mid + Math.imul(ah5, bl2)) | 0;
11848 hi = (hi + Math.imul(ah5, bh2)) | 0;
11849 lo = (lo + Math.imul(al4, bl3)) | 0;
11850 mid = (mid + Math.imul(al4, bh3)) | 0;
11851 mid = (mid + Math.imul(ah4, bl3)) | 0;
11852 hi = (hi + Math.imul(ah4, bh3)) | 0;
11853 lo = (lo + Math.imul(al3, bl4)) | 0;
11854 mid = (mid + Math.imul(al3, bh4)) | 0;
11855 mid = (mid + Math.imul(ah3, bl4)) | 0;
11856 hi = (hi + Math.imul(ah3, bh4)) | 0;
11857 lo = (lo + Math.imul(al2, bl5)) | 0;
11858 mid = (mid + Math.imul(al2, bh5)) | 0;
11859 mid = (mid + Math.imul(ah2, bl5)) | 0;
11860 hi = (hi + Math.imul(ah2, bh5)) | 0;
11861 lo = (lo + Math.imul(al1, bl6)) | 0;
11862 mid = (mid + Math.imul(al1, bh6)) | 0;
11863 mid = (mid + Math.imul(ah1, bl6)) | 0;
11864 hi = (hi + Math.imul(ah1, bh6)) | 0;
11865 lo = (lo + Math.imul(al0, bl7)) | 0;
11866 mid = (mid + Math.imul(al0, bh7)) | 0;
11867 mid = (mid + Math.imul(ah0, bl7)) | 0;
11868 hi = (hi + Math.imul(ah0, bh7)) | 0;
11869 var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
11870 c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0;
11871 w7 &= 0x3ffffff;
11872 /* k = 8 */
11873 lo = Math.imul(al8, bl0);
11874 mid = Math.imul(al8, bh0);
11875 mid = (mid + Math.imul(ah8, bl0)) | 0;
11876 hi = Math.imul(ah8, bh0);
11877 lo = (lo + Math.imul(al7, bl1)) | 0;
11878 mid = (mid + Math.imul(al7, bh1)) | 0;
11879 mid = (mid + Math.imul(ah7, bl1)) | 0;
11880 hi = (hi + Math.imul(ah7, bh1)) | 0;
11881 lo = (lo + Math.imul(al6, bl2)) | 0;
11882 mid = (mid + Math.imul(al6, bh2)) | 0;
11883 mid = (mid + Math.imul(ah6, bl2)) | 0;
11884 hi = (hi + Math.imul(ah6, bh2)) | 0;
11885 lo = (lo + Math.imul(al5, bl3)) | 0;
11886 mid = (mid + Math.imul(al5, bh3)) | 0;
11887 mid = (mid + Math.imul(ah5, bl3)) | 0;
11888 hi = (hi + Math.imul(ah5, bh3)) | 0;
11889 lo = (lo + Math.imul(al4, bl4)) | 0;
11890 mid = (mid + Math.imul(al4, bh4)) | 0;
11891 mid = (mid + Math.imul(ah4, bl4)) | 0;
11892 hi = (hi + Math.imul(ah4, bh4)) | 0;
11893 lo = (lo + Math.imul(al3, bl5)) | 0;
11894 mid = (mid + Math.imul(al3, bh5)) | 0;
11895 mid = (mid + Math.imul(ah3, bl5)) | 0;
11896 hi = (hi + Math.imul(ah3, bh5)) | 0;
11897 lo = (lo + Math.imul(al2, bl6)) | 0;
11898 mid = (mid + Math.imul(al2, bh6)) | 0;
11899 mid = (mid + Math.imul(ah2, bl6)) | 0;
11900 hi = (hi + Math.imul(ah2, bh6)) | 0;
11901 lo = (lo + Math.imul(al1, bl7)) | 0;
11902 mid = (mid + Math.imul(al1, bh7)) | 0;
11903 mid = (mid + Math.imul(ah1, bl7)) | 0;
11904 hi = (hi + Math.imul(ah1, bh7)) | 0;
11905 lo = (lo + Math.imul(al0, bl8)) | 0;
11906 mid = (mid + Math.imul(al0, bh8)) | 0;
11907 mid = (mid + Math.imul(ah0, bl8)) | 0;
11908 hi = (hi + Math.imul(ah0, bh8)) | 0;
11909 var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
11910 c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0;
11911 w8 &= 0x3ffffff;
11912 /* k = 9 */
11913 lo = Math.imul(al9, bl0);
11914 mid = Math.imul(al9, bh0);
11915 mid = (mid + Math.imul(ah9, bl0)) | 0;
11916 hi = Math.imul(ah9, bh0);
11917 lo = (lo + Math.imul(al8, bl1)) | 0;
11918 mid = (mid + Math.imul(al8, bh1)) | 0;
11919 mid = (mid + Math.imul(ah8, bl1)) | 0;
11920 hi = (hi + Math.imul(ah8, bh1)) | 0;
11921 lo = (lo + Math.imul(al7, bl2)) | 0;
11922 mid = (mid + Math.imul(al7, bh2)) | 0;
11923 mid = (mid + Math.imul(ah7, bl2)) | 0;
11924 hi = (hi + Math.imul(ah7, bh2)) | 0;
11925 lo = (lo + Math.imul(al6, bl3)) | 0;
11926 mid = (mid + Math.imul(al6, bh3)) | 0;
11927 mid = (mid + Math.imul(ah6, bl3)) | 0;
11928 hi = (hi + Math.imul(ah6, bh3)) | 0;
11929 lo = (lo + Math.imul(al5, bl4)) | 0;
11930 mid = (mid + Math.imul(al5, bh4)) | 0;
11931 mid = (mid + Math.imul(ah5, bl4)) | 0;
11932 hi = (hi + Math.imul(ah5, bh4)) | 0;
11933 lo = (lo + Math.imul(al4, bl5)) | 0;
11934 mid = (mid + Math.imul(al4, bh5)) | 0;
11935 mid = (mid + Math.imul(ah4, bl5)) | 0;
11936 hi = (hi + Math.imul(ah4, bh5)) | 0;
11937 lo = (lo + Math.imul(al3, bl6)) | 0;
11938 mid = (mid + Math.imul(al3, bh6)) | 0;
11939 mid = (mid + Math.imul(ah3, bl6)) | 0;
11940 hi = (hi + Math.imul(ah3, bh6)) | 0;
11941 lo = (lo + Math.imul(al2, bl7)) | 0;
11942 mid = (mid + Math.imul(al2, bh7)) | 0;
11943 mid = (mid + Math.imul(ah2, bl7)) | 0;
11944 hi = (hi + Math.imul(ah2, bh7)) | 0;
11945 lo = (lo + Math.imul(al1, bl8)) | 0;
11946 mid = (mid + Math.imul(al1, bh8)) | 0;
11947 mid = (mid + Math.imul(ah1, bl8)) | 0;
11948 hi = (hi + Math.imul(ah1, bh8)) | 0;
11949 lo = (lo + Math.imul(al0, bl9)) | 0;
11950 mid = (mid + Math.imul(al0, bh9)) | 0;
11951 mid = (mid + Math.imul(ah0, bl9)) | 0;
11952 hi = (hi + Math.imul(ah0, bh9)) | 0;
11953 var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
11954 c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0;
11955 w9 &= 0x3ffffff;
11956 /* k = 10 */
11957 lo = Math.imul(al9, bl1);
11958 mid = Math.imul(al9, bh1);
11959 mid = (mid + Math.imul(ah9, bl1)) | 0;
11960 hi = Math.imul(ah9, bh1);
11961 lo = (lo + Math.imul(al8, bl2)) | 0;
11962 mid = (mid + Math.imul(al8, bh2)) | 0;
11963 mid = (mid + Math.imul(ah8, bl2)) | 0;
11964 hi = (hi + Math.imul(ah8, bh2)) | 0;
11965 lo = (lo + Math.imul(al7, bl3)) | 0;
11966 mid = (mid + Math.imul(al7, bh3)) | 0;
11967 mid = (mid + Math.imul(ah7, bl3)) | 0;
11968 hi = (hi + Math.imul(ah7, bh3)) | 0;
11969 lo = (lo + Math.imul(al6, bl4)) | 0;
11970 mid = (mid + Math.imul(al6, bh4)) | 0;
11971 mid = (mid + Math.imul(ah6, bl4)) | 0;
11972 hi = (hi + Math.imul(ah6, bh4)) | 0;
11973 lo = (lo + Math.imul(al5, bl5)) | 0;
11974 mid = (mid + Math.imul(al5, bh5)) | 0;
11975 mid = (mid + Math.imul(ah5, bl5)) | 0;
11976 hi = (hi + Math.imul(ah5, bh5)) | 0;
11977 lo = (lo + Math.imul(al4, bl6)) | 0;
11978 mid = (mid + Math.imul(al4, bh6)) | 0;
11979 mid = (mid + Math.imul(ah4, bl6)) | 0;
11980 hi = (hi + Math.imul(ah4, bh6)) | 0;
11981 lo = (lo + Math.imul(al3, bl7)) | 0;
11982 mid = (mid + Math.imul(al3, bh7)) | 0;
11983 mid = (mid + Math.imul(ah3, bl7)) | 0;
11984 hi = (hi + Math.imul(ah3, bh7)) | 0;
11985 lo = (lo + Math.imul(al2, bl8)) | 0;
11986 mid = (mid + Math.imul(al2, bh8)) | 0;
11987 mid = (mid + Math.imul(ah2, bl8)) | 0;
11988 hi = (hi + Math.imul(ah2, bh8)) | 0;
11989 lo = (lo + Math.imul(al1, bl9)) | 0;
11990 mid = (mid + Math.imul(al1, bh9)) | 0;
11991 mid = (mid + Math.imul(ah1, bl9)) | 0;
11992 hi = (hi + Math.imul(ah1, bh9)) | 0;
11993 var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
11994 c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0;
11995 w10 &= 0x3ffffff;
11996 /* k = 11 */
11997 lo = Math.imul(al9, bl2);
11998 mid = Math.imul(al9, bh2);
11999 mid = (mid + Math.imul(ah9, bl2)) | 0;
12000 hi = Math.imul(ah9, bh2);
12001 lo = (lo + Math.imul(al8, bl3)) | 0;
12002 mid = (mid + Math.imul(al8, bh3)) | 0;
12003 mid = (mid + Math.imul(ah8, bl3)) | 0;
12004 hi = (hi + Math.imul(ah8, bh3)) | 0;
12005 lo = (lo + Math.imul(al7, bl4)) | 0;
12006 mid = (mid + Math.imul(al7, bh4)) | 0;
12007 mid = (mid + Math.imul(ah7, bl4)) | 0;
12008 hi = (hi + Math.imul(ah7, bh4)) | 0;
12009 lo = (lo + Math.imul(al6, bl5)) | 0;
12010 mid = (mid + Math.imul(al6, bh5)) | 0;
12011 mid = (mid + Math.imul(ah6, bl5)) | 0;
12012 hi = (hi + Math.imul(ah6, bh5)) | 0;
12013 lo = (lo + Math.imul(al5, bl6)) | 0;
12014 mid = (mid + Math.imul(al5, bh6)) | 0;
12015 mid = (mid + Math.imul(ah5, bl6)) | 0;
12016 hi = (hi + Math.imul(ah5, bh6)) | 0;
12017 lo = (lo + Math.imul(al4, bl7)) | 0;
12018 mid = (mid + Math.imul(al4, bh7)) | 0;
12019 mid = (mid + Math.imul(ah4, bl7)) | 0;
12020 hi = (hi + Math.imul(ah4, bh7)) | 0;
12021 lo = (lo + Math.imul(al3, bl8)) | 0;
12022 mid = (mid + Math.imul(al3, bh8)) | 0;
12023 mid = (mid + Math.imul(ah3, bl8)) | 0;
12024 hi = (hi + Math.imul(ah3, bh8)) | 0;
12025 lo = (lo + Math.imul(al2, bl9)) | 0;
12026 mid = (mid + Math.imul(al2, bh9)) | 0;
12027 mid = (mid + Math.imul(ah2, bl9)) | 0;
12028 hi = (hi + Math.imul(ah2, bh9)) | 0;
12029 var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
12030 c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0;
12031 w11 &= 0x3ffffff;
12032 /* k = 12 */
12033 lo = Math.imul(al9, bl3);
12034 mid = Math.imul(al9, bh3);
12035 mid = (mid + Math.imul(ah9, bl3)) | 0;
12036 hi = Math.imul(ah9, bh3);
12037 lo = (lo + Math.imul(al8, bl4)) | 0;
12038 mid = (mid + Math.imul(al8, bh4)) | 0;
12039 mid = (mid + Math.imul(ah8, bl4)) | 0;
12040 hi = (hi + Math.imul(ah8, bh4)) | 0;
12041 lo = (lo + Math.imul(al7, bl5)) | 0;
12042 mid = (mid + Math.imul(al7, bh5)) | 0;
12043 mid = (mid + Math.imul(ah7, bl5)) | 0;
12044 hi = (hi + Math.imul(ah7, bh5)) | 0;
12045 lo = (lo + Math.imul(al6, bl6)) | 0;
12046 mid = (mid + Math.imul(al6, bh6)) | 0;
12047 mid = (mid + Math.imul(ah6, bl6)) | 0;
12048 hi = (hi + Math.imul(ah6, bh6)) | 0;
12049 lo = (lo + Math.imul(al5, bl7)) | 0;
12050 mid = (mid + Math.imul(al5, bh7)) | 0;
12051 mid = (mid + Math.imul(ah5, bl7)) | 0;
12052 hi = (hi + Math.imul(ah5, bh7)) | 0;
12053 lo = (lo + Math.imul(al4, bl8)) | 0;
12054 mid = (mid + Math.imul(al4, bh8)) | 0;
12055 mid = (mid + Math.imul(ah4, bl8)) | 0;
12056 hi = (hi + Math.imul(ah4, bh8)) | 0;
12057 lo = (lo + Math.imul(al3, bl9)) | 0;
12058 mid = (mid + Math.imul(al3, bh9)) | 0;
12059 mid = (mid + Math.imul(ah3, bl9)) | 0;
12060 hi = (hi + Math.imul(ah3, bh9)) | 0;
12061 var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
12062 c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0;
12063 w12 &= 0x3ffffff;
12064 /* k = 13 */
12065 lo = Math.imul(al9, bl4);
12066 mid = Math.imul(al9, bh4);
12067 mid = (mid + Math.imul(ah9, bl4)) | 0;
12068 hi = Math.imul(ah9, bh4);
12069 lo = (lo + Math.imul(al8, bl5)) | 0;
12070 mid = (mid + Math.imul(al8, bh5)) | 0;
12071 mid = (mid + Math.imul(ah8, bl5)) | 0;
12072 hi = (hi + Math.imul(ah8, bh5)) | 0;
12073 lo = (lo + Math.imul(al7, bl6)) | 0;
12074 mid = (mid + Math.imul(al7, bh6)) | 0;
12075 mid = (mid + Math.imul(ah7, bl6)) | 0;
12076 hi = (hi + Math.imul(ah7, bh6)) | 0;
12077 lo = (lo + Math.imul(al6, bl7)) | 0;
12078 mid = (mid + Math.imul(al6, bh7)) | 0;
12079 mid = (mid + Math.imul(ah6, bl7)) | 0;
12080 hi = (hi + Math.imul(ah6, bh7)) | 0;
12081 lo = (lo + Math.imul(al5, bl8)) | 0;
12082 mid = (mid + Math.imul(al5, bh8)) | 0;
12083 mid = (mid + Math.imul(ah5, bl8)) | 0;
12084 hi = (hi + Math.imul(ah5, bh8)) | 0;
12085 lo = (lo + Math.imul(al4, bl9)) | 0;
12086 mid = (mid + Math.imul(al4, bh9)) | 0;
12087 mid = (mid + Math.imul(ah4, bl9)) | 0;
12088 hi = (hi + Math.imul(ah4, bh9)) | 0;
12089 var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
12090 c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0;
12091 w13 &= 0x3ffffff;
12092 /* k = 14 */
12093 lo = Math.imul(al9, bl5);
12094 mid = Math.imul(al9, bh5);
12095 mid = (mid + Math.imul(ah9, bl5)) | 0;
12096 hi = Math.imul(ah9, bh5);
12097 lo = (lo + Math.imul(al8, bl6)) | 0;
12098 mid = (mid + Math.imul(al8, bh6)) | 0;
12099 mid = (mid + Math.imul(ah8, bl6)) | 0;
12100 hi = (hi + Math.imul(ah8, bh6)) | 0;
12101 lo = (lo + Math.imul(al7, bl7)) | 0;
12102 mid = (mid + Math.imul(al7, bh7)) | 0;
12103 mid = (mid + Math.imul(ah7, bl7)) | 0;
12104 hi = (hi + Math.imul(ah7, bh7)) | 0;
12105 lo = (lo + Math.imul(al6, bl8)) | 0;
12106 mid = (mid + Math.imul(al6, bh8)) | 0;
12107 mid = (mid + Math.imul(ah6, bl8)) | 0;
12108 hi = (hi + Math.imul(ah6, bh8)) | 0;
12109 lo = (lo + Math.imul(al5, bl9)) | 0;
12110 mid = (mid + Math.imul(al5, bh9)) | 0;
12111 mid = (mid + Math.imul(ah5, bl9)) | 0;
12112 hi = (hi + Math.imul(ah5, bh9)) | 0;
12113 var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
12114 c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0;
12115 w14 &= 0x3ffffff;
12116 /* k = 15 */
12117 lo = Math.imul(al9, bl6);
12118 mid = Math.imul(al9, bh6);
12119 mid = (mid + Math.imul(ah9, bl6)) | 0;
12120 hi = Math.imul(ah9, bh6);
12121 lo = (lo + Math.imul(al8, bl7)) | 0;
12122 mid = (mid + Math.imul(al8, bh7)) | 0;
12123 mid = (mid + Math.imul(ah8, bl7)) | 0;
12124 hi = (hi + Math.imul(ah8, bh7)) | 0;
12125 lo = (lo + Math.imul(al7, bl8)) | 0;
12126 mid = (mid + Math.imul(al7, bh8)) | 0;
12127 mid = (mid + Math.imul(ah7, bl8)) | 0;
12128 hi = (hi + Math.imul(ah7, bh8)) | 0;
12129 lo = (lo + Math.imul(al6, bl9)) | 0;
12130 mid = (mid + Math.imul(al6, bh9)) | 0;
12131 mid = (mid + Math.imul(ah6, bl9)) | 0;
12132 hi = (hi + Math.imul(ah6, bh9)) | 0;
12133 var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
12134 c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0;
12135 w15 &= 0x3ffffff;
12136 /* k = 16 */
12137 lo = Math.imul(al9, bl7);
12138 mid = Math.imul(al9, bh7);
12139 mid = (mid + Math.imul(ah9, bl7)) | 0;
12140 hi = Math.imul(ah9, bh7);
12141 lo = (lo + Math.imul(al8, bl8)) | 0;
12142 mid = (mid + Math.imul(al8, bh8)) | 0;
12143 mid = (mid + Math.imul(ah8, bl8)) | 0;
12144 hi = (hi + Math.imul(ah8, bh8)) | 0;
12145 lo = (lo + Math.imul(al7, bl9)) | 0;
12146 mid = (mid + Math.imul(al7, bh9)) | 0;
12147 mid = (mid + Math.imul(ah7, bl9)) | 0;
12148 hi = (hi + Math.imul(ah7, bh9)) | 0;
12149 var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
12150 c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0;
12151 w16 &= 0x3ffffff;
12152 /* k = 17 */
12153 lo = Math.imul(al9, bl8);
12154 mid = Math.imul(al9, bh8);
12155 mid = (mid + Math.imul(ah9, bl8)) | 0;
12156 hi = Math.imul(ah9, bh8);
12157 lo = (lo + Math.imul(al8, bl9)) | 0;
12158 mid = (mid + Math.imul(al8, bh9)) | 0;
12159 mid = (mid + Math.imul(ah8, bl9)) | 0;
12160 hi = (hi + Math.imul(ah8, bh9)) | 0;
12161 var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
12162 c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0;
12163 w17 &= 0x3ffffff;
12164 /* k = 18 */
12165 lo = Math.imul(al9, bl9);
12166 mid = Math.imul(al9, bh9);
12167 mid = (mid + Math.imul(ah9, bl9)) | 0;
12168 hi = Math.imul(ah9, bh9);
12169 var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
12170 c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0;
12171 w18 &= 0x3ffffff;
12172 o[0] = w0;
12173 o[1] = w1;
12174 o[2] = w2;
12175 o[3] = w3;
12176 o[4] = w4;
12177 o[5] = w5;
12178 o[6] = w6;
12179 o[7] = w7;
12180 o[8] = w8;
12181 o[9] = w9;
12182 o[10] = w10;
12183 o[11] = w11;
12184 o[12] = w12;
12185 o[13] = w13;
12186 o[14] = w14;
12187 o[15] = w15;
12188 o[16] = w16;
12189 o[17] = w17;
12190 o[18] = w18;
12191 if (c !== 0) {
12192 o[19] = c;
12193 out.length++;
12194 }
12195 return out;
12196 };
12197
12198 // Polyfill comb
12199 if (!Math.imul) {
12200 comb10MulTo = smallMulTo;
12201 }
12202
12203 function bigMulTo (self, num, out) {
12204 out.negative = num.negative ^ self.negative;
12205 out.length = self.length + num.length;
12206
12207 var carry = 0;
12208 var hncarry = 0;
12209 for (var k = 0; k < out.length - 1; k++) {
12210 // Sum all words with the same `i + j = k` and accumulate `ncarry`,
12211 // note that ncarry could be >= 0x3ffffff
12212 var ncarry = hncarry;
12213 hncarry = 0;
12214 var rword = carry & 0x3ffffff;
12215 var maxJ = Math.min(k, num.length - 1);
12216 for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
12217 var i = k - j;
12218 var a = self.words[i] | 0;
12219 var b = num.words[j] | 0;
12220 var r = a * b;
12221
12222 var lo = r & 0x3ffffff;
12223 ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0;
12224 lo = (lo + rword) | 0;
12225 rword = lo & 0x3ffffff;
12226 ncarry = (ncarry + (lo >>> 26)) | 0;
12227
12228 hncarry += ncarry >>> 26;
12229 ncarry &= 0x3ffffff;
12230 }
12231 out.words[k] = rword;
12232 carry = ncarry;
12233 ncarry = hncarry;
12234 }
12235 if (carry !== 0) {
12236 out.words[k] = carry;
12237 } else {
12238 out.length--;
12239 }
12240
12241 return out.strip();
12242 }
12243
12244 function jumboMulTo (self, num, out) {
12245 var fftm = new FFTM();
12246 return fftm.mulp(self, num, out);
12247 }
12248
12249 BN.prototype.mulTo = function mulTo (num, out) {
12250 var res;
12251 var len = this.length + num.length;
12252 if (this.length === 10 && num.length === 10) {
12253 res = comb10MulTo(this, num, out);
12254 } else if (len < 63) {
12255 res = smallMulTo(this, num, out);
12256 } else if (len < 1024) {
12257 res = bigMulTo(this, num, out);
12258 } else {
12259 res = jumboMulTo(this, num, out);
12260 }
12261
12262 return res;
12263 };
12264
12265 // Cooley-Tukey algorithm for FFT
12266 // slightly revisited to rely on looping instead of recursion
12267
12268 function FFTM (x, y) {
12269 this.x = x;
12270 this.y = y;
12271 }
12272
12273 FFTM.prototype.makeRBT = function makeRBT (N) {
12274 var t = new Array(N);
12275 var l = BN.prototype._countBits(N) - 1;
12276 for (var i = 0; i < N; i++) {
12277 t[i] = this.revBin(i, l, N);
12278 }
12279
12280 return t;
12281 };
12282
12283 // Returns binary-reversed representation of `x`
12284 FFTM.prototype.revBin = function revBin (x, l, N) {
12285 if (x === 0 || x === N - 1) return x;
12286
12287 var rb = 0;
12288 for (var i = 0; i < l; i++) {
12289 rb |= (x & 1) << (l - i - 1);
12290 x >>= 1;
12291 }
12292
12293 return rb;
12294 };
12295
12296 // Performs "tweedling" phase, therefore 'emulating'
12297 // behaviour of the recursive algorithm
12298 FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) {
12299 for (var i = 0; i < N; i++) {
12300 rtws[i] = rws[rbt[i]];
12301 itws[i] = iws[rbt[i]];
12302 }
12303 };
12304
12305 FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) {
12306 this.permute(rbt, rws, iws, rtws, itws, N);
12307
12308 for (var s = 1; s < N; s <<= 1) {
12309 var l = s << 1;
12310
12311 var rtwdf = Math.cos(2 * Math.PI / l);
12312 var itwdf = Math.sin(2 * Math.PI / l);
12313
12314 for (var p = 0; p < N; p += l) {
12315 var rtwdf_ = rtwdf;
12316 var itwdf_ = itwdf;
12317
12318 for (var j = 0; j < s; j++) {
12319 var re = rtws[p + j];
12320 var ie = itws[p + j];
12321
12322 var ro = rtws[p + j + s];
12323 var io = itws[p + j + s];
12324
12325 var rx = rtwdf_ * ro - itwdf_ * io;
12326
12327 io = rtwdf_ * io + itwdf_ * ro;
12328 ro = rx;
12329
12330 rtws[p + j] = re + ro;
12331 itws[p + j] = ie + io;
12332
12333 rtws[p + j + s] = re - ro;
12334 itws[p + j + s] = ie - io;
12335
12336 /* jshint maxdepth : false */
12337 if (j !== l) {
12338 rx = rtwdf * rtwdf_ - itwdf * itwdf_;
12339
12340 itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;
12341 rtwdf_ = rx;
12342 }
12343 }
12344 }
12345 }
12346 };
12347
12348 FFTM.prototype.guessLen13b = function guessLen13b (n, m) {
12349 var N = Math.max(m, n) | 1;
12350 var odd = N & 1;
12351 var i = 0;
12352 for (N = N / 2 | 0; N; N = N >>> 1) {
12353 i++;
12354 }
12355
12356 return 1 << i + 1 + odd;
12357 };
12358
12359 FFTM.prototype.conjugate = function conjugate (rws, iws, N) {
12360 if (N <= 1) return;
12361
12362 for (var i = 0; i < N / 2; i++) {
12363 var t = rws[i];
12364
12365 rws[i] = rws[N - i - 1];
12366 rws[N - i - 1] = t;
12367
12368 t = iws[i];
12369
12370 iws[i] = -iws[N - i - 1];
12371 iws[N - i - 1] = -t;
12372 }
12373 };
12374
12375 FFTM.prototype.normalize13b = function normalize13b (ws, N) {
12376 var carry = 0;
12377 for (var i = 0; i < N / 2; i++) {
12378 var w = Math.round(ws[2 * i + 1] / N) * 0x2000 +
12379 Math.round(ws[2 * i] / N) +
12380 carry;
12381
12382 ws[i] = w & 0x3ffffff;
12383
12384 if (w < 0x4000000) {
12385 carry = 0;
12386 } else {
12387 carry = w / 0x4000000 | 0;
12388 }
12389 }
12390
12391 return ws;
12392 };
12393
12394 FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) {
12395 var carry = 0;
12396 for (var i = 0; i < len; i++) {
12397 carry = carry + (ws[i] | 0);
12398
12399 rws[2 * i] = carry & 0x1fff; carry = carry >>> 13;
12400 rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13;
12401 }
12402
12403 // Pad with zeroes
12404 for (i = 2 * len; i < N; ++i) {
12405 rws[i] = 0;
12406 }
12407
12408 assert(carry === 0);
12409 assert((carry & ~0x1fff) === 0);
12410 };
12411
12412 FFTM.prototype.stub = function stub (N) {
12413 var ph = new Array(N);
12414 for (var i = 0; i < N; i++) {
12415 ph[i] = 0;
12416 }
12417
12418 return ph;
12419 };
12420
12421 FFTM.prototype.mulp = function mulp (x, y, out) {
12422 var N = 2 * this.guessLen13b(x.length, y.length);
12423
12424 var rbt = this.makeRBT(N);
12425
12426 var _ = this.stub(N);
12427
12428 var rws = new Array(N);
12429 var rwst = new Array(N);
12430 var iwst = new Array(N);
12431
12432 var nrws = new Array(N);
12433 var nrwst = new Array(N);
12434 var niwst = new Array(N);
12435
12436 var rmws = out.words;
12437 rmws.length = N;
12438
12439 this.convert13b(x.words, x.length, rws, N);
12440 this.convert13b(y.words, y.length, nrws, N);
12441
12442 this.transform(rws, _, rwst, iwst, N, rbt);
12443 this.transform(nrws, _, nrwst, niwst, N, rbt);
12444
12445 for (var i = 0; i < N; i++) {
12446 var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];
12447 iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];
12448 rwst[i] = rx;
12449 }
12450
12451 this.conjugate(rwst, iwst, N);
12452 this.transform(rwst, iwst, rmws, _, N, rbt);
12453 this.conjugate(rmws, _, N);
12454 this.normalize13b(rmws, N);
12455
12456 out.negative = x.negative ^ y.negative;
12457 out.length = x.length + y.length;
12458 return out.strip();
12459 };
12460
12461 // Multiply `this` by `num`
12462 BN.prototype.mul = function mul (num) {
12463 var out = new BN(null);
12464 out.words = new Array(this.length + num.length);
12465 return this.mulTo(num, out);
12466 };
12467
12468 // Multiply employing FFT
12469 BN.prototype.mulf = function mulf (num) {
12470 var out = new BN(null);
12471 out.words = new Array(this.length + num.length);
12472 return jumboMulTo(this, num, out);
12473 };
12474
12475 // In-place Multiplication
12476 BN.prototype.imul = function imul (num) {
12477 return this.clone().mulTo(num, this);
12478 };
12479
12480 BN.prototype.imuln = function imuln (num) {
12481 assert(typeof num === 'number');
12482 assert(num < 0x4000000);
12483
12484 // Carry
12485 var carry = 0;
12486 for (var i = 0; i < this.length; i++) {
12487 var w = (this.words[i] | 0) * num;
12488 var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);
12489 carry >>= 26;
12490 carry += (w / 0x4000000) | 0;
12491 // NOTE: lo is 27bit maximum
12492 carry += lo >>> 26;
12493 this.words[i] = lo & 0x3ffffff;
12494 }
12495
12496 if (carry !== 0) {
12497 this.words[i] = carry;
12498 this.length++;
12499 }
12500
12501 return this;
12502 };
12503
12504 BN.prototype.muln = function muln (num) {
12505 return this.clone().imuln(num);
12506 };
12507
12508 // `this` * `this`
12509 BN.prototype.sqr = function sqr () {
12510 return this.mul(this);
12511 };
12512
12513 // `this` * `this` in-place
12514 BN.prototype.isqr = function isqr () {
12515 return this.imul(this.clone());
12516 };
12517
12518 // Math.pow(`this`, `num`)
12519 BN.prototype.pow = function pow (num) {
12520 var w = toBitArray(num);
12521 if (w.length === 0) return new BN(1);
12522
12523 // Skip leading zeroes
12524 var res = this;
12525 for (var i = 0; i < w.length; i++, res = res.sqr()) {
12526 if (w[i] !== 0) break;
12527 }
12528
12529 if (++i < w.length) {
12530 for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {
12531 if (w[i] === 0) continue;
12532
12533 res = res.mul(q);
12534 }
12535 }
12536
12537 return res;
12538 };
12539
12540 // Shift-left in-place
12541 BN.prototype.iushln = function iushln (bits) {
12542 assert(typeof bits === 'number' && bits >= 0);
12543 var r = bits % 26;
12544 var s = (bits - r) / 26;
12545 var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r);
12546 var i;
12547
12548 if (r !== 0) {
12549 var carry = 0;
12550
12551 for (i = 0; i < this.length; i++) {
12552 var newCarry = this.words[i] & carryMask;
12553 var c = ((this.words[i] | 0) - newCarry) << r;
12554 this.words[i] = c | carry;
12555 carry = newCarry >>> (26 - r);
12556 }
12557
12558 if (carry) {
12559 this.words[i] = carry;
12560 this.length++;
12561 }
12562 }
12563
12564 if (s !== 0) {
12565 for (i = this.length - 1; i >= 0; i--) {
12566 this.words[i + s] = this.words[i];
12567 }
12568
12569 for (i = 0; i < s; i++) {
12570 this.words[i] = 0;
12571 }
12572
12573 this.length += s;
12574 }
12575
12576 return this.strip();
12577 };
12578
12579 BN.prototype.ishln = function ishln (bits) {
12580 // TODO(indutny): implement me
12581 assert(this.negative === 0);
12582 return this.iushln(bits);
12583 };
12584
12585 // Shift-right in-place
12586 // NOTE: `hint` is a lowest bit before trailing zeroes
12587 // NOTE: if `extended` is present - it will be filled with destroyed bits
12588 BN.prototype.iushrn = function iushrn (bits, hint, extended) {
12589 assert(typeof bits === 'number' && bits >= 0);
12590 var h;
12591 if (hint) {
12592 h = (hint - (hint % 26)) / 26;
12593 } else {
12594 h = 0;
12595 }
12596
12597 var r = bits % 26;
12598 var s = Math.min((bits - r) / 26, this.length);
12599 var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
12600 var maskedWords = extended;
12601
12602 h -= s;
12603 h = Math.max(0, h);
12604
12605 // Extended mode, copy masked part
12606 if (maskedWords) {
12607 for (var i = 0; i < s; i++) {
12608 maskedWords.words[i] = this.words[i];
12609 }
12610 maskedWords.length = s;
12611 }
12612
12613 if (s === 0) {
12614 // No-op, we should not move anything at all
12615 } else if (this.length > s) {
12616 this.length -= s;
12617 for (i = 0; i < this.length; i++) {
12618 this.words[i] = this.words[i + s];
12619 }
12620 } else {
12621 this.words[0] = 0;
12622 this.length = 1;
12623 }
12624
12625 var carry = 0;
12626 for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {
12627 var word = this.words[i] | 0;
12628 this.words[i] = (carry << (26 - r)) | (word >>> r);
12629 carry = word & mask;
12630 }
12631
12632 // Push carried bits as a mask
12633 if (maskedWords && carry !== 0) {
12634 maskedWords.words[maskedWords.length++] = carry;
12635 }
12636
12637 if (this.length === 0) {
12638 this.words[0] = 0;
12639 this.length = 1;
12640 }
12641
12642 return this.strip();
12643 };
12644
12645 BN.prototype.ishrn = function ishrn (bits, hint, extended) {
12646 // TODO(indutny): implement me
12647 assert(this.negative === 0);
12648 return this.iushrn(bits, hint, extended);
12649 };
12650
12651 // Shift-left
12652 BN.prototype.shln = function shln (bits) {
12653 return this.clone().ishln(bits);
12654 };
12655
12656 BN.prototype.ushln = function ushln (bits) {
12657 return this.clone().iushln(bits);
12658 };
12659
12660 // Shift-right
12661 BN.prototype.shrn = function shrn (bits) {
12662 return this.clone().ishrn(bits);
12663 };
12664
12665 BN.prototype.ushrn = function ushrn (bits) {
12666 return this.clone().iushrn(bits);
12667 };
12668
12669 // Test if n bit is set
12670 BN.prototype.testn = function testn (bit) {
12671 assert(typeof bit === 'number' && bit >= 0);
12672 var r = bit % 26;
12673 var s = (bit - r) / 26;
12674 var q = 1 << r;
12675
12676 // Fast case: bit is much higher than all existing words
12677 if (this.length <= s) return false;
12678
12679 // Check bit and return
12680 var w = this.words[s];
12681
12682 return !!(w & q);
12683 };
12684
12685 // Return only lowers bits of number (in-place)
12686 BN.prototype.imaskn = function imaskn (bits) {
12687 assert(typeof bits === 'number' && bits >= 0);
12688 var r = bits % 26;
12689 var s = (bits - r) / 26;
12690
12691 assert(this.negative === 0, 'imaskn works only with positive numbers');
12692
12693 if (this.length <= s) {
12694 return this;
12695 }
12696
12697 if (r !== 0) {
12698 s++;
12699 }
12700 this.length = Math.min(s, this.length);
12701
12702 if (r !== 0) {
12703 var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
12704 this.words[this.length - 1] &= mask;
12705 }
12706
12707 return this.strip();
12708 };
12709
12710 // Return only lowers bits of number
12711 BN.prototype.maskn = function maskn (bits) {
12712 return this.clone().imaskn(bits);
12713 };
12714
12715 // Add plain number `num` to `this`
12716 BN.prototype.iaddn = function iaddn (num) {
12717 assert(typeof num === 'number');
12718 assert(num < 0x4000000);
12719 if (num < 0) return this.isubn(-num);
12720
12721 // Possible sign change
12722 if (this.negative !== 0) {
12723 if (this.length === 1 && (this.words[0] | 0) < num) {
12724 this.words[0] = num - (this.words[0] | 0);
12725 this.negative = 0;
12726 return this;
12727 }
12728
12729 this.negative = 0;
12730 this.isubn(num);
12731 this.negative = 1;
12732 return this;
12733 }
12734
12735 // Add without checks
12736 return this._iaddn(num);
12737 };
12738
12739 BN.prototype._iaddn = function _iaddn (num) {
12740 this.words[0] += num;
12741
12742 // Carry
12743 for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {
12744 this.words[i] -= 0x4000000;
12745 if (i === this.length - 1) {
12746 this.words[i + 1] = 1;
12747 } else {
12748 this.words[i + 1]++;
12749 }
12750 }
12751 this.length = Math.max(this.length, i + 1);
12752
12753 return this;
12754 };
12755
12756 // Subtract plain number `num` from `this`
12757 BN.prototype.isubn = function isubn (num) {
12758 assert(typeof num === 'number');
12759 assert(num < 0x4000000);
12760 if (num < 0) return this.iaddn(-num);
12761
12762 if (this.negative !== 0) {
12763 this.negative = 0;
12764 this.iaddn(num);
12765 this.negative = 1;
12766 return this;
12767 }
12768
12769 this.words[0] -= num;
12770
12771 if (this.length === 1 && this.words[0] < 0) {
12772 this.words[0] = -this.words[0];
12773 this.negative = 1;
12774 } else {
12775 // Carry
12776 for (var i = 0; i < this.length && this.words[i] < 0; i++) {
12777 this.words[i] += 0x4000000;
12778 this.words[i + 1] -= 1;
12779 }
12780 }
12781
12782 return this.strip();
12783 };
12784
12785 BN.prototype.addn = function addn (num) {
12786 return this.clone().iaddn(num);
12787 };
12788
12789 BN.prototype.subn = function subn (num) {
12790 return this.clone().isubn(num);
12791 };
12792
12793 BN.prototype.iabs = function iabs () {
12794 this.negative = 0;
12795
12796 return this;
12797 };
12798
12799 BN.prototype.abs = function abs () {
12800 return this.clone().iabs();
12801 };
12802
12803 BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) {
12804 var len = num.length + shift;
12805 var i;
12806
12807 this._expand(len);
12808
12809 var w;
12810 var carry = 0;
12811 for (i = 0; i < num.length; i++) {
12812 w = (this.words[i + shift] | 0) + carry;
12813 var right = (num.words[i] | 0) * mul;
12814 w -= right & 0x3ffffff;
12815 carry = (w >> 26) - ((right / 0x4000000) | 0);
12816 this.words[i + shift] = w & 0x3ffffff;
12817 }
12818 for (; i < this.length - shift; i++) {
12819 w = (this.words[i + shift] | 0) + carry;
12820 carry = w >> 26;
12821 this.words[i + shift] = w & 0x3ffffff;
12822 }
12823
12824 if (carry === 0) return this.strip();
12825
12826 // Subtraction overflow
12827 assert(carry === -1);
12828 carry = 0;
12829 for (i = 0; i < this.length; i++) {
12830 w = -(this.words[i] | 0) + carry;
12831 carry = w >> 26;
12832 this.words[i] = w & 0x3ffffff;
12833 }
12834 this.negative = 1;
12835
12836 return this.strip();
12837 };
12838
12839 BN.prototype._wordDiv = function _wordDiv (num, mode) {
12840 var shift = this.length - num.length;
12841
12842 var a = this.clone();
12843 var b = num;
12844
12845 // Normalize
12846 var bhi = b.words[b.length - 1] | 0;
12847 var bhiBits = this._countBits(bhi);
12848 shift = 26 - bhiBits;
12849 if (shift !== 0) {
12850 b = b.ushln(shift);
12851 a.iushln(shift);
12852 bhi = b.words[b.length - 1] | 0;
12853 }
12854
12855 // Initialize quotient
12856 var m = a.length - b.length;
12857 var q;
12858
12859 if (mode !== 'mod') {
12860 q = new BN(null);
12861 q.length = m + 1;
12862 q.words = new Array(q.length);
12863 for (var i = 0; i < q.length; i++) {
12864 q.words[i] = 0;
12865 }
12866 }
12867
12868 var diff = a.clone()._ishlnsubmul(b, 1, m);
12869 if (diff.negative === 0) {
12870 a = diff;
12871 if (q) {
12872 q.words[m] = 1;
12873 }
12874 }
12875
12876 for (var j = m - 1; j >= 0; j--) {
12877 var qj = (a.words[b.length + j] | 0) * 0x4000000 +
12878 (a.words[b.length + j - 1] | 0);
12879
12880 // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max
12881 // (0x7ffffff)
12882 qj = Math.min((qj / bhi) | 0, 0x3ffffff);
12883
12884 a._ishlnsubmul(b, qj, j);
12885 while (a.negative !== 0) {
12886 qj--;
12887 a.negative = 0;
12888 a._ishlnsubmul(b, 1, j);
12889 if (!a.isZero()) {
12890 a.negative ^= 1;
12891 }
12892 }
12893 if (q) {
12894 q.words[j] = qj;
12895 }
12896 }
12897 if (q) {
12898 q.strip();
12899 }
12900 a.strip();
12901
12902 // Denormalize
12903 if (mode !== 'div' && shift !== 0) {
12904 a.iushrn(shift);
12905 }
12906
12907 return {
12908 div: q || null,
12909 mod: a
12910 };
12911 };
12912
12913 // NOTE: 1) `mode` can be set to `mod` to request mod only,
12914 // to `div` to request div only, or be absent to
12915 // request both div & mod
12916 // 2) `positive` is true if unsigned mod is requested
12917 BN.prototype.divmod = function divmod (num, mode, positive) {
12918 assert(!num.isZero());
12919
12920 if (this.isZero()) {
12921 return {
12922 div: new BN(0),
12923 mod: new BN(0)
12924 };
12925 }
12926
12927 var div, mod, res;
12928 if (this.negative !== 0 && num.negative === 0) {
12929 res = this.neg().divmod(num, mode);
12930
12931 if (mode !== 'mod') {
12932 div = res.div.neg();
12933 }
12934
12935 if (mode !== 'div') {
12936 mod = res.mod.neg();
12937 if (positive && mod.negative !== 0) {
12938 mod.iadd(num);
12939 }
12940 }
12941
12942 return {
12943 div: div,
12944 mod: mod
12945 };
12946 }
12947
12948 if (this.negative === 0 && num.negative !== 0) {
12949 res = this.divmod(num.neg(), mode);
12950
12951 if (mode !== 'mod') {
12952 div = res.div.neg();
12953 }
12954
12955 return {
12956 div: div,
12957 mod: res.mod
12958 };
12959 }
12960
12961 if ((this.negative & num.negative) !== 0) {
12962 res = this.neg().divmod(num.neg(), mode);
12963
12964 if (mode !== 'div') {
12965 mod = res.mod.neg();
12966 if (positive && mod.negative !== 0) {
12967 mod.isub(num);
12968 }
12969 }
12970
12971 return {
12972 div: res.div,
12973 mod: mod
12974 };
12975 }
12976
12977 // Both numbers are positive at this point
12978
12979 // Strip both numbers to approximate shift value
12980 if (num.length > this.length || this.cmp(num) < 0) {
12981 return {
12982 div: new BN(0),
12983 mod: this
12984 };
12985 }
12986
12987 // Very short reduction
12988 if (num.length === 1) {
12989 if (mode === 'div') {
12990 return {
12991 div: this.divn(num.words[0]),
12992 mod: null
12993 };
12994 }
12995
12996 if (mode === 'mod') {
12997 return {
12998 div: null,
12999 mod: new BN(this.modn(num.words[0]))
13000 };
13001 }
13002
13003 return {
13004 div: this.divn(num.words[0]),
13005 mod: new BN(this.modn(num.words[0]))
13006 };
13007 }
13008
13009 return this._wordDiv(num, mode);
13010 };
13011
13012 // Find `this` / `num`
13013 BN.prototype.div = function div (num) {
13014 return this.divmod(num, 'div', false).div;
13015 };
13016
13017 // Find `this` % `num`
13018 BN.prototype.mod = function mod (num) {
13019 return this.divmod(num, 'mod', false).mod;
13020 };
13021
13022 BN.prototype.umod = function umod (num) {
13023 return this.divmod(num, 'mod', true).mod;
13024 };
13025
13026 // Find Round(`this` / `num`)
13027 BN.prototype.divRound = function divRound (num) {
13028 var dm = this.divmod(num);
13029
13030 // Fast case - exact division
13031 if (dm.mod.isZero()) return dm.div;
13032
13033 var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
13034
13035 var half = num.ushrn(1);
13036 var r2 = num.andln(1);
13037 var cmp = mod.cmp(half);
13038
13039 // Round down
13040 if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;
13041
13042 // Round up
13043 return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
13044 };
13045
13046 BN.prototype.modn = function modn (num) {
13047 assert(num <= 0x3ffffff);
13048 var p = (1 << 26) % num;
13049
13050 var acc = 0;
13051 for (var i = this.length - 1; i >= 0; i--) {
13052 acc = (p * acc + (this.words[i] | 0)) % num;
13053 }
13054
13055 return acc;
13056 };
13057
13058 // In-place division by number
13059 BN.prototype.idivn = function idivn (num) {
13060 assert(num <= 0x3ffffff);
13061
13062 var carry = 0;
13063 for (var i = this.length - 1; i >= 0; i--) {
13064 var w = (this.words[i] | 0) + carry * 0x4000000;
13065 this.words[i] = (w / num) | 0;
13066 carry = w % num;
13067 }
13068
13069 return this.strip();
13070 };
13071
13072 BN.prototype.divn = function divn (num) {
13073 return this.clone().idivn(num);
13074 };
13075
13076 BN.prototype.egcd = function egcd (p) {
13077 assert(p.negative === 0);
13078 assert(!p.isZero());
13079
13080 var x = this;
13081 var y = p.clone();
13082
13083 if (x.negative !== 0) {
13084 x = x.umod(p);
13085 } else {
13086 x = x.clone();
13087 }
13088
13089 // A * x + B * y = x
13090 var A = new BN(1);
13091 var B = new BN(0);
13092
13093 // C * x + D * y = y
13094 var C = new BN(0);
13095 var D = new BN(1);
13096
13097 var g = 0;
13098
13099 while (x.isEven() && y.isEven()) {
13100 x.iushrn(1);
13101 y.iushrn(1);
13102 ++g;
13103 }
13104
13105 var yp = y.clone();
13106 var xp = x.clone();
13107
13108 while (!x.isZero()) {
13109 for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
13110 if (i > 0) {
13111 x.iushrn(i);
13112 while (i-- > 0) {
13113 if (A.isOdd() || B.isOdd()) {
13114 A.iadd(yp);
13115 B.isub(xp);
13116 }
13117
13118 A.iushrn(1);
13119 B.iushrn(1);
13120 }
13121 }
13122
13123 for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
13124 if (j > 0) {
13125 y.iushrn(j);
13126 while (j-- > 0) {
13127 if (C.isOdd() || D.isOdd()) {
13128 C.iadd(yp);
13129 D.isub(xp);
13130 }
13131
13132 C.iushrn(1);
13133 D.iushrn(1);
13134 }
13135 }
13136
13137 if (x.cmp(y) >= 0) {
13138 x.isub(y);
13139 A.isub(C);
13140 B.isub(D);
13141 } else {
13142 y.isub(x);
13143 C.isub(A);
13144 D.isub(B);
13145 }
13146 }
13147
13148 return {
13149 a: C,
13150 b: D,
13151 gcd: y.iushln(g)
13152 };
13153 };
13154
13155 // This is reduced incarnation of the binary EEA
13156 // above, designated to invert members of the
13157 // _prime_ fields F(p) at a maximal speed
13158 BN.prototype._invmp = function _invmp (p) {
13159 assert(p.negative === 0);
13160 assert(!p.isZero());
13161
13162 var a = this;
13163 var b = p.clone();
13164
13165 if (a.negative !== 0) {
13166 a = a.umod(p);
13167 } else {
13168 a = a.clone();
13169 }
13170
13171 var x1 = new BN(1);
13172 var x2 = new BN(0);
13173
13174 var delta = b.clone();
13175
13176 while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
13177 for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
13178 if (i > 0) {
13179 a.iushrn(i);
13180 while (i-- > 0) {
13181 if (x1.isOdd()) {
13182 x1.iadd(delta);
13183 }
13184
13185 x1.iushrn(1);
13186 }
13187 }
13188
13189 for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
13190 if (j > 0) {
13191 b.iushrn(j);
13192 while (j-- > 0) {
13193 if (x2.isOdd()) {
13194 x2.iadd(delta);
13195 }
13196
13197 x2.iushrn(1);
13198 }
13199 }
13200
13201 if (a.cmp(b) >= 0) {
13202 a.isub(b);
13203 x1.isub(x2);
13204 } else {
13205 b.isub(a);
13206 x2.isub(x1);
13207 }
13208 }
13209
13210 var res;
13211 if (a.cmpn(1) === 0) {
13212 res = x1;
13213 } else {
13214 res = x2;
13215 }
13216
13217 if (res.cmpn(0) < 0) {
13218 res.iadd(p);
13219 }
13220
13221 return res;
13222 };
13223
13224 BN.prototype.gcd = function gcd (num) {
13225 if (this.isZero()) return num.abs();
13226 if (num.isZero()) return this.abs();
13227
13228 var a = this.clone();
13229 var b = num.clone();
13230 a.negative = 0;
13231 b.negative = 0;
13232
13233 // Remove common factor of two
13234 for (var shift = 0; a.isEven() && b.isEven(); shift++) {
13235 a.iushrn(1);
13236 b.iushrn(1);
13237 }
13238
13239 do {
13240 while (a.isEven()) {
13241 a.iushrn(1);
13242 }
13243 while (b.isEven()) {
13244 b.iushrn(1);
13245 }
13246
13247 var r = a.cmp(b);
13248 if (r < 0) {
13249 // Swap `a` and `b` to make `a` always bigger than `b`
13250 var t = a;
13251 a = b;
13252 b = t;
13253 } else if (r === 0 || b.cmpn(1) === 0) {
13254 break;
13255 }
13256
13257 a.isub(b);
13258 } while (true);
13259
13260 return b.iushln(shift);
13261 };
13262
13263 // Invert number in the field F(num)
13264 BN.prototype.invm = function invm (num) {
13265 return this.egcd(num).a.umod(num);
13266 };
13267
13268 BN.prototype.isEven = function isEven () {
13269 return (this.words[0] & 1) === 0;
13270 };
13271
13272 BN.prototype.isOdd = function isOdd () {
13273 return (this.words[0] & 1) === 1;
13274 };
13275
13276 // And first word and num
13277 BN.prototype.andln = function andln (num) {
13278 return this.words[0] & num;
13279 };
13280
13281 // Increment at the bit position in-line
13282 BN.prototype.bincn = function bincn (bit) {
13283 assert(typeof bit === 'number');
13284 var r = bit % 26;
13285 var s = (bit - r) / 26;
13286 var q = 1 << r;
13287
13288 // Fast case: bit is much higher than all existing words
13289 if (this.length <= s) {
13290 this._expand(s + 1);
13291 this.words[s] |= q;
13292 return this;
13293 }
13294
13295 // Add bit and propagate, if needed
13296 var carry = q;
13297 for (var i = s; carry !== 0 && i < this.length; i++) {
13298 var w = this.words[i] | 0;
13299 w += carry;
13300 carry = w >>> 26;
13301 w &= 0x3ffffff;
13302 this.words[i] = w;
13303 }
13304 if (carry !== 0) {
13305 this.words[i] = carry;
13306 this.length++;
13307 }
13308 return this;
13309 };
13310
13311 BN.prototype.isZero = function isZero () {
13312 return this.length === 1 && this.words[0] === 0;
13313 };
13314
13315 BN.prototype.cmpn = function cmpn (num) {
13316 var negative = num < 0;
13317
13318 if (this.negative !== 0 && !negative) return -1;
13319 if (this.negative === 0 && negative) return 1;
13320
13321 this.strip();
13322
13323 var res;
13324 if (this.length > 1) {
13325 res = 1;
13326 } else {
13327 if (negative) {
13328 num = -num;
13329 }
13330
13331 assert(num <= 0x3ffffff, 'Number is too big');
13332
13333 var w = this.words[0] | 0;
13334 res = w === num ? 0 : w < num ? -1 : 1;
13335 }
13336 if (this.negative !== 0) return -res | 0;
13337 return res;
13338 };
13339
13340 // Compare two numbers and return:
13341 // 1 - if `this` > `num`
13342 // 0 - if `this` == `num`
13343 // -1 - if `this` < `num`
13344 BN.prototype.cmp = function cmp (num) {
13345 if (this.negative !== 0 && num.negative === 0) return -1;
13346 if (this.negative === 0 && num.negative !== 0) return 1;
13347
13348 var res = this.ucmp(num);
13349 if (this.negative !== 0) return -res | 0;
13350 return res;
13351 };
13352
13353 // Unsigned comparison
13354 BN.prototype.ucmp = function ucmp (num) {
13355 // At this point both numbers have the same sign
13356 if (this.length > num.length) return 1;
13357 if (this.length < num.length) return -1;
13358
13359 var res = 0;
13360 for (var i = this.length - 1; i >= 0; i--) {
13361 var a = this.words[i] | 0;
13362 var b = num.words[i] | 0;
13363
13364 if (a === b) continue;
13365 if (a < b) {
13366 res = -1;
13367 } else if (a > b) {
13368 res = 1;
13369 }
13370 break;
13371 }
13372 return res;
13373 };
13374
13375 BN.prototype.gtn = function gtn (num) {
13376 return this.cmpn(num) === 1;
13377 };
13378
13379 BN.prototype.gt = function gt (num) {
13380 return this.cmp(num) === 1;
13381 };
13382
13383 BN.prototype.gten = function gten (num) {
13384 return this.cmpn(num) >= 0;
13385 };
13386
13387 BN.prototype.gte = function gte (num) {
13388 return this.cmp(num) >= 0;
13389 };
13390
13391 BN.prototype.ltn = function ltn (num) {
13392 return this.cmpn(num) === -1;
13393 };
13394
13395 BN.prototype.lt = function lt (num) {
13396 return this.cmp(num) === -1;
13397 };
13398
13399 BN.prototype.lten = function lten (num) {
13400 return this.cmpn(num) <= 0;
13401 };
13402
13403 BN.prototype.lte = function lte (num) {
13404 return this.cmp(num) <= 0;
13405 };
13406
13407 BN.prototype.eqn = function eqn (num) {
13408 return this.cmpn(num) === 0;
13409 };
13410
13411 BN.prototype.eq = function eq (num) {
13412 return this.cmp(num) === 0;
13413 };
13414
13415 //
13416 // A reduce context, could be using montgomery or something better, depending
13417 // on the `m` itself.
13418 //
13419 BN.red = function red (num) {
13420 return new Red(num);
13421 };
13422
13423 BN.prototype.toRed = function toRed (ctx) {
13424 assert(!this.red, 'Already a number in reduction context');
13425 assert(this.negative === 0, 'red works only with positives');
13426 return ctx.convertTo(this)._forceRed(ctx);
13427 };
13428
13429 BN.prototype.fromRed = function fromRed () {
13430 assert(this.red, 'fromRed works only with numbers in reduction context');
13431 return this.red.convertFrom(this);
13432 };
13433
13434 BN.prototype._forceRed = function _forceRed (ctx) {
13435 this.red = ctx;
13436 return this;
13437 };
13438
13439 BN.prototype.forceRed = function forceRed (ctx) {
13440 assert(!this.red, 'Already a number in reduction context');
13441 return this._forceRed(ctx);
13442 };
13443
13444 BN.prototype.redAdd = function redAdd (num) {
13445 assert(this.red, 'redAdd works only with red numbers');
13446 return this.red.add(this, num);
13447 };
13448
13449 BN.prototype.redIAdd = function redIAdd (num) {
13450 assert(this.red, 'redIAdd works only with red numbers');
13451 return this.red.iadd(this, num);
13452 };
13453
13454 BN.prototype.redSub = function redSub (num) {
13455 assert(this.red, 'redSub works only with red numbers');
13456 return this.red.sub(this, num);
13457 };
13458
13459 BN.prototype.redISub = function redISub (num) {
13460 assert(this.red, 'redISub works only with red numbers');
13461 return this.red.isub(this, num);
13462 };
13463
13464 BN.prototype.redShl = function redShl (num) {
13465 assert(this.red, 'redShl works only with red numbers');
13466 return this.red.shl(this, num);
13467 };
13468
13469 BN.prototype.redMul = function redMul (num) {
13470 assert(this.red, 'redMul works only with red numbers');
13471 this.red._verify2(this, num);
13472 return this.red.mul(this, num);
13473 };
13474
13475 BN.prototype.redIMul = function redIMul (num) {
13476 assert(this.red, 'redMul works only with red numbers');
13477 this.red._verify2(this, num);
13478 return this.red.imul(this, num);
13479 };
13480
13481 BN.prototype.redSqr = function redSqr () {
13482 assert(this.red, 'redSqr works only with red numbers');
13483 this.red._verify1(this);
13484 return this.red.sqr(this);
13485 };
13486
13487 BN.prototype.redISqr = function redISqr () {
13488 assert(this.red, 'redISqr works only with red numbers');
13489 this.red._verify1(this);
13490 return this.red.isqr(this);
13491 };
13492
13493 // Square root over p
13494 BN.prototype.redSqrt = function redSqrt () {
13495 assert(this.red, 'redSqrt works only with red numbers');
13496 this.red._verify1(this);
13497 return this.red.sqrt(this);
13498 };
13499
13500 BN.prototype.redInvm = function redInvm () {
13501 assert(this.red, 'redInvm works only with red numbers');
13502 this.red._verify1(this);
13503 return this.red.invm(this);
13504 };
13505
13506 // Return negative clone of `this` % `red modulo`
13507 BN.prototype.redNeg = function redNeg () {
13508 assert(this.red, 'redNeg works only with red numbers');
13509 this.red._verify1(this);
13510 return this.red.neg(this);
13511 };
13512
13513 BN.prototype.redPow = function redPow (num) {
13514 assert(this.red && !num.red, 'redPow(normalNum)');
13515 this.red._verify1(this);
13516 return this.red.pow(this, num);
13517 };
13518
13519 // Prime numbers with efficient reduction
13520 var primes = {
13521 k256: null,
13522 p224: null,
13523 p192: null,
13524 p25519: null
13525 };
13526
13527 // Pseudo-Mersenne prime
13528 function MPrime (name, p) {
13529 // P = 2 ^ N - K
13530 this.name = name;
13531 this.p = new BN(p, 16);
13532 this.n = this.p.bitLength();
13533 this.k = new BN(1).iushln(this.n).isub(this.p);
13534
13535 this.tmp = this._tmp();
13536 }
13537
13538 MPrime.prototype._tmp = function _tmp () {
13539 var tmp = new BN(null);
13540 tmp.words = new Array(Math.ceil(this.n / 13));
13541 return tmp;
13542 };
13543
13544 MPrime.prototype.ireduce = function ireduce (num) {
13545 // Assumes that `num` is less than `P^2`
13546 // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)
13547 var r = num;
13548 var rlen;
13549
13550 do {
13551 this.split(r, this.tmp);
13552 r = this.imulK(r);
13553 r = r.iadd(this.tmp);
13554 rlen = r.bitLength();
13555 } while (rlen > this.n);
13556
13557 var cmp = rlen < this.n ? -1 : r.ucmp(this.p);
13558 if (cmp === 0) {
13559 r.words[0] = 0;
13560 r.length = 1;
13561 } else if (cmp > 0) {
13562 r.isub(this.p);
13563 } else {
13564 r.strip();
13565 }
13566
13567 return r;
13568 };
13569
13570 MPrime.prototype.split = function split (input, out) {
13571 input.iushrn(this.n, 0, out);
13572 };
13573
13574 MPrime.prototype.imulK = function imulK (num) {
13575 return num.imul(this.k);
13576 };
13577
13578 function K256 () {
13579 MPrime.call(
13580 this,
13581 'k256',
13582 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');
13583 }
13584 inherits(K256, MPrime);
13585
13586 K256.prototype.split = function split (input, output) {
13587 // 256 = 9 * 26 + 22
13588 var mask = 0x3fffff;
13589
13590 var outLen = Math.min(input.length, 9);
13591 for (var i = 0; i < outLen; i++) {
13592 output.words[i] = input.words[i];
13593 }
13594 output.length = outLen;
13595
13596 if (input.length <= 9) {
13597 input.words[0] = 0;
13598 input.length = 1;
13599 return;
13600 }
13601
13602 // Shift by 9 limbs
13603 var prev = input.words[9];
13604 output.words[output.length++] = prev & mask;
13605
13606 for (i = 10; i < input.length; i++) {
13607 var next = input.words[i] | 0;
13608 input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22);
13609 prev = next;
13610 }
13611 prev >>>= 22;
13612 input.words[i - 10] = prev;
13613 if (prev === 0 && input.length > 10) {
13614 input.length -= 10;
13615 } else {
13616 input.length -= 9;
13617 }
13618 };
13619
13620 K256.prototype.imulK = function imulK (num) {
13621 // K = 0x1000003d1 = [ 0x40, 0x3d1 ]
13622 num.words[num.length] = 0;
13623 num.words[num.length + 1] = 0;
13624 num.length += 2;
13625
13626 // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390
13627 var lo = 0;
13628 for (var i = 0; i < num.length; i++) {
13629 var w = num.words[i] | 0;
13630 lo += w * 0x3d1;
13631 num.words[i] = lo & 0x3ffffff;
13632 lo = w * 0x40 + ((lo / 0x4000000) | 0);
13633 }
13634
13635 // Fast length reduction
13636 if (num.words[num.length - 1] === 0) {
13637 num.length--;
13638 if (num.words[num.length - 1] === 0) {
13639 num.length--;
13640 }
13641 }
13642 return num;
13643 };
13644
13645 function P224 () {
13646 MPrime.call(
13647 this,
13648 'p224',
13649 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');
13650 }
13651 inherits(P224, MPrime);
13652
13653 function P192 () {
13654 MPrime.call(
13655 this,
13656 'p192',
13657 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');
13658 }
13659 inherits(P192, MPrime);
13660
13661 function P25519 () {
13662 // 2 ^ 255 - 19
13663 MPrime.call(
13664 this,
13665 '25519',
13666 '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');
13667 }
13668 inherits(P25519, MPrime);
13669
13670 P25519.prototype.imulK = function imulK (num) {
13671 // K = 0x13
13672 var carry = 0;
13673 for (var i = 0; i < num.length; i++) {
13674 var hi = (num.words[i] | 0) * 0x13 + carry;
13675 var lo = hi & 0x3ffffff;
13676 hi >>>= 26;
13677
13678 num.words[i] = lo;
13679 carry = hi;
13680 }
13681 if (carry !== 0) {
13682 num.words[num.length++] = carry;
13683 }
13684 return num;
13685 };
13686
13687 // Exported mostly for testing purposes, use plain name instead
13688 BN._prime = function prime (name) {
13689 // Cached version of prime
13690 if (primes[name]) return primes[name];
13691
13692 var prime;
13693 if (name === 'k256') {
13694 prime = new K256();
13695 } else if (name === 'p224') {
13696 prime = new P224();
13697 } else if (name === 'p192') {
13698 prime = new P192();
13699 } else if (name === 'p25519') {
13700 prime = new P25519();
13701 } else {
13702 throw new Error('Unknown prime ' + name);
13703 }
13704 primes[name] = prime;
13705
13706 return prime;
13707 };
13708
13709 //
13710 // Base reduction engine
13711 //
13712 function Red (m) {
13713 if (typeof m === 'string') {
13714 var prime = BN._prime(m);
13715 this.m = prime.p;
13716 this.prime = prime;
13717 } else {
13718 assert(m.gtn(1), 'modulus must be greater than 1');
13719 this.m = m;
13720 this.prime = null;
13721 }
13722 }
13723
13724 Red.prototype._verify1 = function _verify1 (a) {
13725 assert(a.negative === 0, 'red works only with positives');
13726 assert(a.red, 'red works only with red numbers');
13727 };
13728
13729 Red.prototype._verify2 = function _verify2 (a, b) {
13730 assert((a.negative | b.negative) === 0, 'red works only with positives');
13731 assert(a.red && a.red === b.red,
13732 'red works only with red numbers');
13733 };
13734
13735 Red.prototype.imod = function imod (a) {
13736 if (this.prime) return this.prime.ireduce(a)._forceRed(this);
13737 return a.umod(this.m)._forceRed(this);
13738 };
13739
13740 Red.prototype.neg = function neg (a) {
13741 if (a.isZero()) {
13742 return a.clone();
13743 }
13744
13745 return this.m.sub(a)._forceRed(this);
13746 };
13747
13748 Red.prototype.add = function add (a, b) {
13749 this._verify2(a, b);
13750
13751 var res = a.add(b);
13752 if (res.cmp(this.m) >= 0) {
13753 res.isub(this.m);
13754 }
13755 return res._forceRed(this);
13756 };
13757
13758 Red.prototype.iadd = function iadd (a, b) {
13759 this._verify2(a, b);
13760
13761 var res = a.iadd(b);
13762 if (res.cmp(this.m) >= 0) {
13763 res.isub(this.m);
13764 }
13765 return res;
13766 };
13767
13768 Red.prototype.sub = function sub (a, b) {
13769 this._verify2(a, b);
13770
13771 var res = a.sub(b);
13772 if (res.cmpn(0) < 0) {
13773 res.iadd(this.m);
13774 }
13775 return res._forceRed(this);
13776 };
13777
13778 Red.prototype.isub = function isub (a, b) {
13779 this._verify2(a, b);
13780
13781 var res = a.isub(b);
13782 if (res.cmpn(0) < 0) {
13783 res.iadd(this.m);
13784 }
13785 return res;
13786 };
13787
13788 Red.prototype.shl = function shl (a, num) {
13789 this._verify1(a);
13790 return this.imod(a.ushln(num));
13791 };
13792
13793 Red.prototype.imul = function imul (a, b) {
13794 this._verify2(a, b);
13795 return this.imod(a.imul(b));
13796 };
13797
13798 Red.prototype.mul = function mul (a, b) {
13799 this._verify2(a, b);
13800 return this.imod(a.mul(b));
13801 };
13802
13803 Red.prototype.isqr = function isqr (a) {
13804 return this.imul(a, a.clone());
13805 };
13806
13807 Red.prototype.sqr = function sqr (a) {
13808 return this.mul(a, a);
13809 };
13810
13811 Red.prototype.sqrt = function sqrt (a) {
13812 if (a.isZero()) return a.clone();
13813
13814 var mod3 = this.m.andln(3);
13815 assert(mod3 % 2 === 1);
13816
13817 // Fast case
13818 if (mod3 === 3) {
13819 var pow = this.m.add(new BN(1)).iushrn(2);
13820 return this.pow(a, pow);
13821 }
13822
13823 // Tonelli-Shanks algorithm (Totally unoptimized and slow)
13824 //
13825 // Find Q and S, that Q * 2 ^ S = (P - 1)
13826 var q = this.m.subn(1);
13827 var s = 0;
13828 while (!q.isZero() && q.andln(1) === 0) {
13829 s++;
13830 q.iushrn(1);
13831 }
13832 assert(!q.isZero());
13833
13834 var one = new BN(1).toRed(this);
13835 var nOne = one.redNeg();
13836
13837 // Find quadratic non-residue
13838 // NOTE: Max is such because of generalized Riemann hypothesis.
13839 var lpow = this.m.subn(1).iushrn(1);
13840 var z = this.m.bitLength();
13841 z = new BN(2 * z * z).toRed(this);
13842
13843 while (this.pow(z, lpow).cmp(nOne) !== 0) {
13844 z.redIAdd(nOne);
13845 }
13846
13847 var c = this.pow(z, q);
13848 var r = this.pow(a, q.addn(1).iushrn(1));
13849 var t = this.pow(a, q);
13850 var m = s;
13851 while (t.cmp(one) !== 0) {
13852 var tmp = t;
13853 for (var i = 0; tmp.cmp(one) !== 0; i++) {
13854 tmp = tmp.redSqr();
13855 }
13856 assert(i < m);
13857 var b = this.pow(c, new BN(1).iushln(m - i - 1));
13858
13859 r = r.redMul(b);
13860 c = b.redSqr();
13861 t = t.redMul(c);
13862 m = i;
13863 }
13864
13865 return r;
13866 };
13867
13868 Red.prototype.invm = function invm (a) {
13869 var inv = a._invmp(this.m);
13870 if (inv.negative !== 0) {
13871 inv.negative = 0;
13872 return this.imod(inv).redNeg();
13873 } else {
13874 return this.imod(inv);
13875 }
13876 };
13877
13878 Red.prototype.pow = function pow (a, num) {
13879 if (num.isZero()) return new BN(1).toRed(this);
13880 if (num.cmpn(1) === 0) return a.clone();
13881
13882 var windowSize = 4;
13883 var wnd = new Array(1 << windowSize);
13884 wnd[0] = new BN(1).toRed(this);
13885 wnd[1] = a;
13886 for (var i = 2; i < wnd.length; i++) {
13887 wnd[i] = this.mul(wnd[i - 1], a);
13888 }
13889
13890 var res = wnd[0];
13891 var current = 0;
13892 var currentLen = 0;
13893 var start = num.bitLength() % 26;
13894 if (start === 0) {
13895 start = 26;
13896 }
13897
13898 for (i = num.length - 1; i >= 0; i--) {
13899 var word = num.words[i];
13900 for (var j = start - 1; j >= 0; j--) {
13901 var bit = (word >> j) & 1;
13902 if (res !== wnd[0]) {
13903 res = this.sqr(res);
13904 }
13905
13906 if (bit === 0 && current === 0) {
13907 currentLen = 0;
13908 continue;
13909 }
13910
13911 current <<= 1;
13912 current |= bit;
13913 currentLen++;
13914 if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;
13915
13916 res = this.mul(res, wnd[current]);
13917 currentLen = 0;
13918 current = 0;
13919 }
13920 start = 26;
13921 }
13922
13923 return res;
13924 };
13925
13926 Red.prototype.convertTo = function convertTo (num) {
13927 var r = num.umod(this.m);
13928
13929 return r === num ? r.clone() : r;
13930 };
13931
13932 Red.prototype.convertFrom = function convertFrom (num) {
13933 var res = num.clone();
13934 res.red = null;
13935 return res;
13936 };
13937
13938 //
13939 // Montgomery method engine
13940 //
13941
13942 BN.mont = function mont (num) {
13943 return new Mont(num);
13944 };
13945
13946 function Mont (m) {
13947 Red.call(this, m);
13948
13949 this.shift = this.m.bitLength();
13950 if (this.shift % 26 !== 0) {
13951 this.shift += 26 - (this.shift % 26);
13952 }
13953
13954 this.r = new BN(1).iushln(this.shift);
13955 this.r2 = this.imod(this.r.sqr());
13956 this.rinv = this.r._invmp(this.m);
13957
13958 this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
13959 this.minv = this.minv.umod(this.r);
13960 this.minv = this.r.sub(this.minv);
13961 }
13962 inherits(Mont, Red);
13963
13964 Mont.prototype.convertTo = function convertTo (num) {
13965 return this.imod(num.ushln(this.shift));
13966 };
13967
13968 Mont.prototype.convertFrom = function convertFrom (num) {
13969 var r = this.imod(num.mul(this.rinv));
13970 r.red = null;
13971 return r;
13972 };
13973
13974 Mont.prototype.imul = function imul (a, b) {
13975 if (a.isZero() || b.isZero()) {
13976 a.words[0] = 0;
13977 a.length = 1;
13978 return a;
13979 }
13980
13981 var t = a.imul(b);
13982 var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
13983 var u = t.isub(c).iushrn(this.shift);
13984 var res = u;
13985
13986 if (u.cmp(this.m) >= 0) {
13987 res = u.isub(this.m);
13988 } else if (u.cmpn(0) < 0) {
13989 res = u.iadd(this.m);
13990 }
13991
13992 return res._forceRed(this);
13993 };
13994
13995 Mont.prototype.mul = function mul (a, b) {
13996 if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);
13997
13998 var t = a.mul(b);
13999 var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
14000 var u = t.isub(c).iushrn(this.shift);
14001 var res = u;
14002 if (u.cmp(this.m) >= 0) {
14003 res = u.isub(this.m);
14004 } else if (u.cmpn(0) < 0) {
14005 res = u.iadd(this.m);
14006 }
14007
14008 return res._forceRed(this);
14009 };
14010
14011 Mont.prototype.invm = function invm (a) {
14012 // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R
14013 var res = this.imod(a._invmp(this.m).mul(this.r2));
14014 return res._forceRed(this);
14015 };
14016})(typeof module === 'undefined' || module, this);
14017
14018},{"buffer":81}],80:[function(require,module,exports){
14019var r;
14020
14021module.exports = function rand(len) {
14022 if (!r)
14023 r = new Rand(null);
14024
14025 return r.generate(len);
14026};
14027
14028function Rand(rand) {
14029 this.rand = rand;
14030}
14031module.exports.Rand = Rand;
14032
14033Rand.prototype.generate = function generate(len) {
14034 return this._rand(len);
14035};
14036
14037// Emulate crypto API using randy
14038Rand.prototype._rand = function _rand(n) {
14039 if (this.rand.getBytes)
14040 return this.rand.getBytes(n);
14041
14042 var res = new Uint8Array(n);
14043 for (var i = 0; i < res.length; i++)
14044 res[i] = this.rand.getByte();
14045 return res;
14046};
14047
14048if (typeof self === 'object') {
14049 if (self.crypto && self.crypto.getRandomValues) {
14050 // Modern browsers
14051 Rand.prototype._rand = function _rand(n) {
14052 var arr = new Uint8Array(n);
14053 self.crypto.getRandomValues(arr);
14054 return arr;
14055 };
14056 } else if (self.msCrypto && self.msCrypto.getRandomValues) {
14057 // IE
14058 Rand.prototype._rand = function _rand(n) {
14059 var arr = new Uint8Array(n);
14060 self.msCrypto.getRandomValues(arr);
14061 return arr;
14062 };
14063
14064 // Safari's WebWorkers do not have `crypto`
14065 } else if (typeof window === 'object') {
14066 // Old junk
14067 Rand.prototype._rand = function() {
14068 throw new Error('Not implemented yet');
14069 };
14070 }
14071} else {
14072 // Node.js or Web worker with no crypto support
14073 try {
14074 var crypto = require('crypto');
14075 if (typeof crypto.randomBytes !== 'function')
14076 throw new Error('Not supported');
14077
14078 Rand.prototype._rand = function _rand(n) {
14079 return crypto.randomBytes(n);
14080 };
14081 } catch (e) {
14082 }
14083}
14084
14085},{"crypto":81}],81:[function(require,module,exports){
14086
14087},{}],82:[function(require,module,exports){
14088arguments[4][7][0].apply(exports,arguments)
14089},{"dup":7,"safe-buffer":206}],83:[function(require,module,exports){
14090arguments[4][8][0].apply(exports,arguments)
14091},{"./aes":82,"./ghash":87,"./incr32":88,"buffer-xor":109,"cipher-base":111,"dup":8,"inherits":162,"safe-buffer":206}],84:[function(require,module,exports){
14092arguments[4][9][0].apply(exports,arguments)
14093},{"./decrypter":85,"./encrypter":86,"./modes/list.json":96,"dup":9}],85:[function(require,module,exports){
14094arguments[4][10][0].apply(exports,arguments)
14095},{"./aes":82,"./authCipher":83,"./modes":95,"./streamCipher":98,"cipher-base":111,"dup":10,"evp_bytestokey":146,"inherits":162,"safe-buffer":206}],86:[function(require,module,exports){
14096arguments[4][11][0].apply(exports,arguments)
14097},{"./aes":82,"./authCipher":83,"./modes":95,"./streamCipher":98,"cipher-base":111,"dup":11,"evp_bytestokey":146,"inherits":162,"safe-buffer":206}],87:[function(require,module,exports){
14098arguments[4][12][0].apply(exports,arguments)
14099},{"dup":12,"safe-buffer":206}],88:[function(require,module,exports){
14100arguments[4][13][0].apply(exports,arguments)
14101},{"dup":13}],89:[function(require,module,exports){
14102arguments[4][14][0].apply(exports,arguments)
14103},{"buffer-xor":109,"dup":14}],90:[function(require,module,exports){
14104arguments[4][15][0].apply(exports,arguments)
14105},{"buffer-xor":109,"dup":15,"safe-buffer":206}],91:[function(require,module,exports){
14106arguments[4][16][0].apply(exports,arguments)
14107},{"dup":16,"safe-buffer":206}],92:[function(require,module,exports){
14108arguments[4][17][0].apply(exports,arguments)
14109},{"dup":17,"safe-buffer":206}],93:[function(require,module,exports){
14110arguments[4][18][0].apply(exports,arguments)
14111},{"../incr32":88,"buffer-xor":109,"dup":18,"safe-buffer":206}],94:[function(require,module,exports){
14112arguments[4][19][0].apply(exports,arguments)
14113},{"dup":19}],95:[function(require,module,exports){
14114arguments[4][20][0].apply(exports,arguments)
14115},{"./cbc":89,"./cfb":90,"./cfb1":91,"./cfb8":92,"./ctr":93,"./ecb":94,"./list.json":96,"./ofb":97,"dup":20}],96:[function(require,module,exports){
14116arguments[4][21][0].apply(exports,arguments)
14117},{"dup":21}],97:[function(require,module,exports){
14118arguments[4][22][0].apply(exports,arguments)
14119},{"buffer":110,"buffer-xor":109,"dup":22}],98:[function(require,module,exports){
14120arguments[4][23][0].apply(exports,arguments)
14121},{"./aes":82,"cipher-base":111,"dup":23,"inherits":162,"safe-buffer":206}],99:[function(require,module,exports){
14122var DES = require('browserify-des')
14123var aes = require('browserify-aes/browser')
14124var aesModes = require('browserify-aes/modes')
14125var desModes = require('browserify-des/modes')
14126var ebtk = require('evp_bytestokey')
14127
14128function createCipher (suite, password) {
14129 suite = suite.toLowerCase()
14130
14131 var keyLen, ivLen
14132 if (aesModes[suite]) {
14133 keyLen = aesModes[suite].key
14134 ivLen = aesModes[suite].iv
14135 } else if (desModes[suite]) {
14136 keyLen = desModes[suite].key * 8
14137 ivLen = desModes[suite].iv
14138 } else {
14139 throw new TypeError('invalid suite type')
14140 }
14141
14142 var keys = ebtk(password, false, keyLen, ivLen)
14143 return createCipheriv(suite, keys.key, keys.iv)
14144}
14145
14146function createDecipher (suite, password) {
14147 suite = suite.toLowerCase()
14148
14149 var keyLen, ivLen
14150 if (aesModes[suite]) {
14151 keyLen = aesModes[suite].key
14152 ivLen = aesModes[suite].iv
14153 } else if (desModes[suite]) {
14154 keyLen = desModes[suite].key * 8
14155 ivLen = desModes[suite].iv
14156 } else {
14157 throw new TypeError('invalid suite type')
14158 }
14159
14160 var keys = ebtk(password, false, keyLen, ivLen)
14161 return createDecipheriv(suite, keys.key, keys.iv)
14162}
14163
14164function createCipheriv (suite, key, iv) {
14165 suite = suite.toLowerCase()
14166 if (aesModes[suite]) return aes.createCipheriv(suite, key, iv)
14167 if (desModes[suite]) return new DES({ key: key, iv: iv, mode: suite })
14168
14169 throw new TypeError('invalid suite type')
14170}
14171
14172function createDecipheriv (suite, key, iv) {
14173 suite = suite.toLowerCase()
14174 if (aesModes[suite]) return aes.createDecipheriv(suite, key, iv)
14175 if (desModes[suite]) return new DES({ key: key, iv: iv, mode: suite, decrypt: true })
14176
14177 throw new TypeError('invalid suite type')
14178}
14179
14180function getCiphers () {
14181 return Object.keys(desModes).concat(aes.getCiphers())
14182}
14183
14184exports.createCipher = exports.Cipher = createCipher
14185exports.createCipheriv = exports.Cipheriv = createCipheriv
14186exports.createDecipher = exports.Decipher = createDecipher
14187exports.createDecipheriv = exports.Decipheriv = createDecipheriv
14188exports.listCiphers = exports.getCiphers = getCiphers
14189
14190},{"browserify-aes/browser":84,"browserify-aes/modes":95,"browserify-des":100,"browserify-des/modes":101,"evp_bytestokey":146}],100:[function(require,module,exports){
14191var CipherBase = require('cipher-base')
14192var des = require('des.js')
14193var inherits = require('inherits')
14194var Buffer = require('safe-buffer').Buffer
14195
14196var modes = {
14197 'des-ede3-cbc': des.CBC.instantiate(des.EDE),
14198 'des-ede3': des.EDE,
14199 'des-ede-cbc': des.CBC.instantiate(des.EDE),
14200 'des-ede': des.EDE,
14201 'des-cbc': des.CBC.instantiate(des.DES),
14202 'des-ecb': des.DES
14203}
14204modes.des = modes['des-cbc']
14205modes.des3 = modes['des-ede3-cbc']
14206module.exports = DES
14207inherits(DES, CipherBase)
14208function DES (opts) {
14209 CipherBase.call(this)
14210 var modeName = opts.mode.toLowerCase()
14211 var mode = modes[modeName]
14212 var type
14213 if (opts.decrypt) {
14214 type = 'decrypt'
14215 } else {
14216 type = 'encrypt'
14217 }
14218 var key = opts.key
14219 if (!Buffer.isBuffer(key)) {
14220 key = Buffer.from(key)
14221 }
14222 if (modeName === 'des-ede' || modeName === 'des-ede-cbc') {
14223 key = Buffer.concat([key, key.slice(0, 8)])
14224 }
14225 var iv = opts.iv
14226 if (!Buffer.isBuffer(iv)) {
14227 iv = Buffer.from(iv)
14228 }
14229 this._des = mode.create({
14230 key: key,
14231 iv: iv,
14232 type: type
14233 })
14234}
14235DES.prototype._update = function (data) {
14236 return Buffer.from(this._des.update(data))
14237}
14238DES.prototype._final = function () {
14239 return Buffer.from(this._des.final())
14240}
14241
14242},{"cipher-base":111,"des.js":119,"inherits":162,"safe-buffer":206}],101:[function(require,module,exports){
14243exports['des-ecb'] = {
14244 key: 8,
14245 iv: 0
14246}
14247exports['des-cbc'] = exports.des = {
14248 key: 8,
14249 iv: 8
14250}
14251exports['des-ede3-cbc'] = exports.des3 = {
14252 key: 24,
14253 iv: 8
14254}
14255exports['des-ede3'] = {
14256 key: 24,
14257 iv: 0
14258}
14259exports['des-ede-cbc'] = {
14260 key: 16,
14261 iv: 8
14262}
14263exports['des-ede'] = {
14264 key: 16,
14265 iv: 0
14266}
14267
14268},{}],102:[function(require,module,exports){
14269(function (Buffer){
14270var bn = require('bn.js');
14271var randomBytes = require('randombytes');
14272module.exports = crt;
14273function blind(priv) {
14274 var r = getr(priv);
14275 var blinder = r.toRed(bn.mont(priv.modulus))
14276 .redPow(new bn(priv.publicExponent)).fromRed();
14277 return {
14278 blinder: blinder,
14279 unblinder:r.invm(priv.modulus)
14280 };
14281}
14282function crt(msg, priv) {
14283 var blinds = blind(priv);
14284 var len = priv.modulus.byteLength();
14285 var mod = bn.mont(priv.modulus);
14286 var blinded = new bn(msg).mul(blinds.blinder).umod(priv.modulus);
14287 var c1 = blinded.toRed(bn.mont(priv.prime1));
14288 var c2 = blinded.toRed(bn.mont(priv.prime2));
14289 var qinv = priv.coefficient;
14290 var p = priv.prime1;
14291 var q = priv.prime2;
14292 var m1 = c1.redPow(priv.exponent1);
14293 var m2 = c2.redPow(priv.exponent2);
14294 m1 = m1.fromRed();
14295 m2 = m2.fromRed();
14296 var h = m1.isub(m2).imul(qinv).umod(p);
14297 h.imul(q);
14298 m2.iadd(h);
14299 return new Buffer(m2.imul(blinds.unblinder).umod(priv.modulus).toArray(false, len));
14300}
14301crt.getr = getr;
14302function getr(priv) {
14303 var len = priv.modulus.byteLength();
14304 var r = new bn(randomBytes(len));
14305 while (r.cmp(priv.modulus) >= 0 || !r.umod(priv.prime1) || !r.umod(priv.prime2)) {
14306 r = new bn(randomBytes(len));
14307 }
14308 return r;
14309}
14310
14311}).call(this,require("buffer").Buffer)
14312},{"bn.js":79,"buffer":110,"randombytes":188}],103:[function(require,module,exports){
14313module.exports = require('./browser/algorithms.json')
14314
14315},{"./browser/algorithms.json":104}],104:[function(require,module,exports){
14316module.exports={
14317 "sha224WithRSAEncryption": {
14318 "sign": "rsa",
14319 "hash": "sha224",
14320 "id": "302d300d06096086480165030402040500041c"
14321 },
14322 "RSA-SHA224": {
14323 "sign": "ecdsa/rsa",
14324 "hash": "sha224",
14325 "id": "302d300d06096086480165030402040500041c"
14326 },
14327 "sha256WithRSAEncryption": {
14328 "sign": "rsa",
14329 "hash": "sha256",
14330 "id": "3031300d060960864801650304020105000420"
14331 },
14332 "RSA-SHA256": {
14333 "sign": "ecdsa/rsa",
14334 "hash": "sha256",
14335 "id": "3031300d060960864801650304020105000420"
14336 },
14337 "sha384WithRSAEncryption": {
14338 "sign": "rsa",
14339 "hash": "sha384",
14340 "id": "3041300d060960864801650304020205000430"
14341 },
14342 "RSA-SHA384": {
14343 "sign": "ecdsa/rsa",
14344 "hash": "sha384",
14345 "id": "3041300d060960864801650304020205000430"
14346 },
14347 "sha512WithRSAEncryption": {
14348 "sign": "rsa",
14349 "hash": "sha512",
14350 "id": "3051300d060960864801650304020305000440"
14351 },
14352 "RSA-SHA512": {
14353 "sign": "ecdsa/rsa",
14354 "hash": "sha512",
14355 "id": "3051300d060960864801650304020305000440"
14356 },
14357 "RSA-SHA1": {
14358 "sign": "rsa",
14359 "hash": "sha1",
14360 "id": "3021300906052b0e03021a05000414"
14361 },
14362 "ecdsa-with-SHA1": {
14363 "sign": "ecdsa",
14364 "hash": "sha1",
14365 "id": ""
14366 },
14367 "sha256": {
14368 "sign": "ecdsa",
14369 "hash": "sha256",
14370 "id": ""
14371 },
14372 "sha224": {
14373 "sign": "ecdsa",
14374 "hash": "sha224",
14375 "id": ""
14376 },
14377 "sha384": {
14378 "sign": "ecdsa",
14379 "hash": "sha384",
14380 "id": ""
14381 },
14382 "sha512": {
14383 "sign": "ecdsa",
14384 "hash": "sha512",
14385 "id": ""
14386 },
14387 "DSA-SHA": {
14388 "sign": "dsa",
14389 "hash": "sha1",
14390 "id": ""
14391 },
14392 "DSA-SHA1": {
14393 "sign": "dsa",
14394 "hash": "sha1",
14395 "id": ""
14396 },
14397 "DSA": {
14398 "sign": "dsa",
14399 "hash": "sha1",
14400 "id": ""
14401 },
14402 "DSA-WITH-SHA224": {
14403 "sign": "dsa",
14404 "hash": "sha224",
14405 "id": ""
14406 },
14407 "DSA-SHA224": {
14408 "sign": "dsa",
14409 "hash": "sha224",
14410 "id": ""
14411 },
14412 "DSA-WITH-SHA256": {
14413 "sign": "dsa",
14414 "hash": "sha256",
14415 "id": ""
14416 },
14417 "DSA-SHA256": {
14418 "sign": "dsa",
14419 "hash": "sha256",
14420 "id": ""
14421 },
14422 "DSA-WITH-SHA384": {
14423 "sign": "dsa",
14424 "hash": "sha384",
14425 "id": ""
14426 },
14427 "DSA-SHA384": {
14428 "sign": "dsa",
14429 "hash": "sha384",
14430 "id": ""
14431 },
14432 "DSA-WITH-SHA512": {
14433 "sign": "dsa",
14434 "hash": "sha512",
14435 "id": ""
14436 },
14437 "DSA-SHA512": {
14438 "sign": "dsa",
14439 "hash": "sha512",
14440 "id": ""
14441 },
14442 "DSA-RIPEMD160": {
14443 "sign": "dsa",
14444 "hash": "rmd160",
14445 "id": ""
14446 },
14447 "ripemd160WithRSA": {
14448 "sign": "rsa",
14449 "hash": "rmd160",
14450 "id": "3021300906052b2403020105000414"
14451 },
14452 "RSA-RIPEMD160": {
14453 "sign": "rsa",
14454 "hash": "rmd160",
14455 "id": "3021300906052b2403020105000414"
14456 },
14457 "md5WithRSAEncryption": {
14458 "sign": "rsa",
14459 "hash": "md5",
14460 "id": "3020300c06082a864886f70d020505000410"
14461 },
14462 "RSA-MD5": {
14463 "sign": "rsa",
14464 "hash": "md5",
14465 "id": "3020300c06082a864886f70d020505000410"
14466 }
14467}
14468
14469},{}],105:[function(require,module,exports){
14470module.exports={
14471 "1.3.132.0.10": "secp256k1",
14472 "1.3.132.0.33": "p224",
14473 "1.2.840.10045.3.1.1": "p192",
14474 "1.2.840.10045.3.1.7": "p256",
14475 "1.3.132.0.34": "p384",
14476 "1.3.132.0.35": "p521"
14477}
14478
14479},{}],106:[function(require,module,exports){
14480(function (Buffer){
14481var createHash = require('create-hash')
14482var stream = require('stream')
14483var inherits = require('inherits')
14484var sign = require('./sign')
14485var verify = require('./verify')
14486
14487var algorithms = require('./algorithms.json')
14488Object.keys(algorithms).forEach(function (key) {
14489 algorithms[key].id = new Buffer(algorithms[key].id, 'hex')
14490 algorithms[key.toLowerCase()] = algorithms[key]
14491})
14492
14493function Sign (algorithm) {
14494 stream.Writable.call(this)
14495
14496 var data = algorithms[algorithm]
14497 if (!data) throw new Error('Unknown message digest')
14498
14499 this._hashType = data.hash
14500 this._hash = createHash(data.hash)
14501 this._tag = data.id
14502 this._signType = data.sign
14503}
14504inherits(Sign, stream.Writable)
14505
14506Sign.prototype._write = function _write (data, _, done) {
14507 this._hash.update(data)
14508 done()
14509}
14510
14511Sign.prototype.update = function update (data, enc) {
14512 if (typeof data === 'string') data = new Buffer(data, enc)
14513
14514 this._hash.update(data)
14515 return this
14516}
14517
14518Sign.prototype.sign = function signMethod (key, enc) {
14519 this.end()
14520 var hash = this._hash.digest()
14521 var sig = sign(hash, key, this._hashType, this._signType, this._tag)
14522
14523 return enc ? sig.toString(enc) : sig
14524}
14525
14526function Verify (algorithm) {
14527 stream.Writable.call(this)
14528
14529 var data = algorithms[algorithm]
14530 if (!data) throw new Error('Unknown message digest')
14531
14532 this._hash = createHash(data.hash)
14533 this._tag = data.id
14534 this._signType = data.sign
14535}
14536inherits(Verify, stream.Writable)
14537
14538Verify.prototype._write = function _write (data, _, done) {
14539 this._hash.update(data)
14540 done()
14541}
14542
14543Verify.prototype.update = function update (data, enc) {
14544 if (typeof data === 'string') data = new Buffer(data, enc)
14545
14546 this._hash.update(data)
14547 return this
14548}
14549
14550Verify.prototype.verify = function verifyMethod (key, sig, enc) {
14551 if (typeof sig === 'string') sig = new Buffer(sig, enc)
14552
14553 this.end()
14554 var hash = this._hash.digest()
14555 return verify(sig, hash, key, this._signType, this._tag)
14556}
14557
14558function createSign (algorithm) {
14559 return new Sign(algorithm)
14560}
14561
14562function createVerify (algorithm) {
14563 return new Verify(algorithm)
14564}
14565
14566module.exports = {
14567 Sign: createSign,
14568 Verify: createVerify,
14569 createSign: createSign,
14570 createVerify: createVerify
14571}
14572
14573}).call(this,require("buffer").Buffer)
14574},{"./algorithms.json":104,"./sign":107,"./verify":108,"buffer":110,"create-hash":114,"inherits":162,"stream":215}],107:[function(require,module,exports){
14575(function (Buffer){
14576// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js
14577var createHmac = require('create-hmac')
14578var crt = require('browserify-rsa')
14579var EC = require('elliptic').ec
14580var BN = require('bn.js')
14581var parseKeys = require('parse-asn1')
14582var curves = require('./curves.json')
14583
14584function sign (hash, key, hashType, signType, tag) {
14585 var priv = parseKeys(key)
14586 if (priv.curve) {
14587 // rsa keys can be interpreted as ecdsa ones in openssl
14588 if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type')
14589 return ecSign(hash, priv)
14590 } else if (priv.type === 'dsa') {
14591 if (signType !== 'dsa') throw new Error('wrong private key type')
14592 return dsaSign(hash, priv, hashType)
14593 } else {
14594 if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type')
14595 }
14596 hash = Buffer.concat([tag, hash])
14597 var len = priv.modulus.byteLength()
14598 var pad = [ 0, 1 ]
14599 while (hash.length + pad.length + 1 < len) pad.push(0xff)
14600 pad.push(0x00)
14601 var i = -1
14602 while (++i < hash.length) pad.push(hash[i])
14603
14604 var out = crt(pad, priv)
14605 return out
14606}
14607
14608function ecSign (hash, priv) {
14609 var curveId = curves[priv.curve.join('.')]
14610 if (!curveId) throw new Error('unknown curve ' + priv.curve.join('.'))
14611
14612 var curve = new EC(curveId)
14613 var key = curve.keyFromPrivate(priv.privateKey)
14614 var out = key.sign(hash)
14615
14616 return new Buffer(out.toDER())
14617}
14618
14619function dsaSign (hash, priv, algo) {
14620 var x = priv.params.priv_key
14621 var p = priv.params.p
14622 var q = priv.params.q
14623 var g = priv.params.g
14624 var r = new BN(0)
14625 var k
14626 var H = bits2int(hash, q).mod(q)
14627 var s = false
14628 var kv = getKey(x, q, hash, algo)
14629 while (s === false) {
14630 k = makeKey(q, kv, algo)
14631 r = makeR(g, k, p, q)
14632 s = k.invm(q).imul(H.add(x.mul(r))).mod(q)
14633 if (s.cmpn(0) === 0) {
14634 s = false
14635 r = new BN(0)
14636 }
14637 }
14638 return toDER(r, s)
14639}
14640
14641function toDER (r, s) {
14642 r = r.toArray()
14643 s = s.toArray()
14644
14645 // Pad values
14646 if (r[0] & 0x80) r = [ 0 ].concat(r)
14647 if (s[0] & 0x80) s = [ 0 ].concat(s)
14648
14649 var total = r.length + s.length + 4
14650 var res = [ 0x30, total, 0x02, r.length ]
14651 res = res.concat(r, [ 0x02, s.length ], s)
14652 return new Buffer(res)
14653}
14654
14655function getKey (x, q, hash, algo) {
14656 x = new Buffer(x.toArray())
14657 if (x.length < q.byteLength()) {
14658 var zeros = new Buffer(q.byteLength() - x.length)
14659 zeros.fill(0)
14660 x = Buffer.concat([ zeros, x ])
14661 }
14662 var hlen = hash.length
14663 var hbits = bits2octets(hash, q)
14664 var v = new Buffer(hlen)
14665 v.fill(1)
14666 var k = new Buffer(hlen)
14667 k.fill(0)
14668 k = createHmac(algo, k).update(v).update(new Buffer([ 0 ])).update(x).update(hbits).digest()
14669 v = createHmac(algo, k).update(v).digest()
14670 k = createHmac(algo, k).update(v).update(new Buffer([ 1 ])).update(x).update(hbits).digest()
14671 v = createHmac(algo, k).update(v).digest()
14672 return { k: k, v: v }
14673}
14674
14675function bits2int (obits, q) {
14676 var bits = new BN(obits)
14677 var shift = (obits.length << 3) - q.bitLength()
14678 if (shift > 0) bits.ishrn(shift)
14679 return bits
14680}
14681
14682function bits2octets (bits, q) {
14683 bits = bits2int(bits, q)
14684 bits = bits.mod(q)
14685 var out = new Buffer(bits.toArray())
14686 if (out.length < q.byteLength()) {
14687 var zeros = new Buffer(q.byteLength() - out.length)
14688 zeros.fill(0)
14689 out = Buffer.concat([ zeros, out ])
14690 }
14691 return out
14692}
14693
14694function makeKey (q, kv, algo) {
14695 var t
14696 var k
14697
14698 do {
14699 t = new Buffer(0)
14700
14701 while (t.length * 8 < q.bitLength()) {
14702 kv.v = createHmac(algo, kv.k).update(kv.v).digest()
14703 t = Buffer.concat([ t, kv.v ])
14704 }
14705
14706 k = bits2int(t, q)
14707 kv.k = createHmac(algo, kv.k).update(kv.v).update(new Buffer([ 0 ])).digest()
14708 kv.v = createHmac(algo, kv.k).update(kv.v).digest()
14709 } while (k.cmp(q) !== -1)
14710
14711 return k
14712}
14713
14714function makeR (g, k, p, q) {
14715 return g.toRed(BN.mont(p)).redPow(k).fromRed().mod(q)
14716}
14717
14718module.exports = sign
14719module.exports.getKey = getKey
14720module.exports.makeKey = makeKey
14721
14722}).call(this,require("buffer").Buffer)
14723},{"./curves.json":105,"bn.js":79,"browserify-rsa":102,"buffer":110,"create-hmac":116,"elliptic":129,"parse-asn1":174}],108:[function(require,module,exports){
14724(function (Buffer){
14725// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js
14726var BN = require('bn.js')
14727var EC = require('elliptic').ec
14728var parseKeys = require('parse-asn1')
14729var curves = require('./curves.json')
14730
14731function verify (sig, hash, key, signType, tag) {
14732 var pub = parseKeys(key)
14733 if (pub.type === 'ec') {
14734 // rsa keys can be interpreted as ecdsa ones in openssl
14735 if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type')
14736 return ecVerify(sig, hash, pub)
14737 } else if (pub.type === 'dsa') {
14738 if (signType !== 'dsa') throw new Error('wrong public key type')
14739 return dsaVerify(sig, hash, pub)
14740 } else {
14741 if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type')
14742 }
14743 hash = Buffer.concat([tag, hash])
14744 var len = pub.modulus.byteLength()
14745 var pad = [ 1 ]
14746 var padNum = 0
14747 while (hash.length + pad.length + 2 < len) {
14748 pad.push(0xff)
14749 padNum++
14750 }
14751 pad.push(0x00)
14752 var i = -1
14753 while (++i < hash.length) {
14754 pad.push(hash[i])
14755 }
14756 pad = new Buffer(pad)
14757 var red = BN.mont(pub.modulus)
14758 sig = new BN(sig).toRed(red)
14759
14760 sig = sig.redPow(new BN(pub.publicExponent))
14761 sig = new Buffer(sig.fromRed().toArray())
14762 var out = padNum < 8 ? 1 : 0
14763 len = Math.min(sig.length, pad.length)
14764 if (sig.length !== pad.length) out = 1
14765
14766 i = -1
14767 while (++i < len) out |= sig[i] ^ pad[i]
14768 return out === 0
14769}
14770
14771function ecVerify (sig, hash, pub) {
14772 var curveId = curves[pub.data.algorithm.curve.join('.')]
14773 if (!curveId) throw new Error('unknown curve ' + pub.data.algorithm.curve.join('.'))
14774
14775 var curve = new EC(curveId)
14776 var pubkey = pub.data.subjectPrivateKey.data
14777
14778 return curve.verify(hash, sig, pubkey)
14779}
14780
14781function dsaVerify (sig, hash, pub) {
14782 var p = pub.data.p
14783 var q = pub.data.q
14784 var g = pub.data.g
14785 var y = pub.data.pub_key
14786 var unpacked = parseKeys.signature.decode(sig, 'der')
14787 var s = unpacked.s
14788 var r = unpacked.r
14789 checkValue(s, q)
14790 checkValue(r, q)
14791 var montp = BN.mont(p)
14792 var w = s.invm(q)
14793 var v = g.toRed(montp)
14794 .redPow(new BN(hash).mul(w).mod(q))
14795 .fromRed()
14796 .mul(y.toRed(montp).redPow(r.mul(w).mod(q)).fromRed())
14797 .mod(p)
14798 .mod(q)
14799 return v.cmp(r) === 0
14800}
14801
14802function checkValue (b, q) {
14803 if (b.cmpn(0) <= 0) throw new Error('invalid sig')
14804 if (b.cmp(q) >= q) throw new Error('invalid sig')
14805}
14806
14807module.exports = verify
14808
14809}).call(this,require("buffer").Buffer)
14810},{"./curves.json":105,"bn.js":79,"buffer":110,"elliptic":129,"parse-asn1":174}],109:[function(require,module,exports){
14811arguments[4][29][0].apply(exports,arguments)
14812},{"buffer":110,"dup":29}],110:[function(require,module,exports){
14813(function (Buffer){
14814/*!
14815 * The buffer module from node.js, for the browser.
14816 *
14817 * @author Feross Aboukhadijeh <https://feross.org>
14818 * @license MIT
14819 */
14820/* eslint-disable no-proto */
14821
14822'use strict'
14823
14824var base64 = require('base64-js')
14825var ieee754 = require('ieee754')
14826var customInspectSymbol =
14827 (typeof Symbol === 'function' && typeof Symbol.for === 'function')
14828 ? Symbol.for('nodejs.util.inspect.custom')
14829 : null
14830
14831exports.Buffer = Buffer
14832exports.SlowBuffer = SlowBuffer
14833exports.INSPECT_MAX_BYTES = 50
14834
14835var K_MAX_LENGTH = 0x7fffffff
14836exports.kMaxLength = K_MAX_LENGTH
14837
14838/**
14839 * If `Buffer.TYPED_ARRAY_SUPPORT`:
14840 * === true Use Uint8Array implementation (fastest)
14841 * === false Print warning and recommend using `buffer` v4.x which has an Object
14842 * implementation (most compatible, even IE6)
14843 *
14844 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
14845 * Opera 11.6+, iOS 4.2+.
14846 *
14847 * We report that the browser does not support typed arrays if the are not subclassable
14848 * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
14849 * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
14850 * for __proto__ and has a buggy typed array implementation.
14851 */
14852Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
14853
14854if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
14855 typeof console.error === 'function') {
14856 console.error(
14857 'This browser lacks typed array (Uint8Array) support which is required by ' +
14858 '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
14859 )
14860}
14861
14862function typedArraySupport () {
14863 // Can typed array instances can be augmented?
14864 try {
14865 var arr = new Uint8Array(1)
14866 var proto = { foo: function () { return 42 } }
14867 Object.setPrototypeOf(proto, Uint8Array.prototype)
14868 Object.setPrototypeOf(arr, proto)
14869 return arr.foo() === 42
14870 } catch (e) {
14871 return false
14872 }
14873}
14874
14875Object.defineProperty(Buffer.prototype, 'parent', {
14876 enumerable: true,
14877 get: function () {
14878 if (!Buffer.isBuffer(this)) return undefined
14879 return this.buffer
14880 }
14881})
14882
14883Object.defineProperty(Buffer.prototype, 'offset', {
14884 enumerable: true,
14885 get: function () {
14886 if (!Buffer.isBuffer(this)) return undefined
14887 return this.byteOffset
14888 }
14889})
14890
14891function createBuffer (length) {
14892 if (length > K_MAX_LENGTH) {
14893 throw new RangeError('The value "' + length + '" is invalid for option "size"')
14894 }
14895 // Return an augmented `Uint8Array` instance
14896 var buf = new Uint8Array(length)
14897 Object.setPrototypeOf(buf, Buffer.prototype)
14898 return buf
14899}
14900
14901/**
14902 * The Buffer constructor returns instances of `Uint8Array` that have their
14903 * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
14904 * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
14905 * and the `Uint8Array` methods. Square bracket notation works as expected -- it
14906 * returns a single octet.
14907 *
14908 * The `Uint8Array` prototype remains unmodified.
14909 */
14910
14911function Buffer (arg, encodingOrOffset, length) {
14912 // Common case.
14913 if (typeof arg === 'number') {
14914 if (typeof encodingOrOffset === 'string') {
14915 throw new TypeError(
14916 'The "string" argument must be of type string. Received type number'
14917 )
14918 }
14919 return allocUnsafe(arg)
14920 }
14921 return from(arg, encodingOrOffset, length)
14922}
14923
14924// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
14925if (typeof Symbol !== 'undefined' && Symbol.species != null &&
14926 Buffer[Symbol.species] === Buffer) {
14927 Object.defineProperty(Buffer, Symbol.species, {
14928 value: null,
14929 configurable: true,
14930 enumerable: false,
14931 writable: false
14932 })
14933}
14934
14935Buffer.poolSize = 8192 // not used by this implementation
14936
14937function from (value, encodingOrOffset, length) {
14938 if (typeof value === 'string') {
14939 return fromString(value, encodingOrOffset)
14940 }
14941
14942 if (ArrayBuffer.isView(value)) {
14943 return fromArrayLike(value)
14944 }
14945
14946 if (value == null) {
14947 throw new TypeError(
14948 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
14949 'or Array-like Object. Received type ' + (typeof value)
14950 )
14951 }
14952
14953 if (isInstance(value, ArrayBuffer) ||
14954 (value && isInstance(value.buffer, ArrayBuffer))) {
14955 return fromArrayBuffer(value, encodingOrOffset, length)
14956 }
14957
14958 if (typeof value === 'number') {
14959 throw new TypeError(
14960 'The "value" argument must not be of type number. Received type number'
14961 )
14962 }
14963
14964 var valueOf = value.valueOf && value.valueOf()
14965 if (valueOf != null && valueOf !== value) {
14966 return Buffer.from(valueOf, encodingOrOffset, length)
14967 }
14968
14969 var b = fromObject(value)
14970 if (b) return b
14971
14972 if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
14973 typeof value[Symbol.toPrimitive] === 'function') {
14974 return Buffer.from(
14975 value[Symbol.toPrimitive]('string'), encodingOrOffset, length
14976 )
14977 }
14978
14979 throw new TypeError(
14980 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
14981 'or Array-like Object. Received type ' + (typeof value)
14982 )
14983}
14984
14985/**
14986 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
14987 * if value is a number.
14988 * Buffer.from(str[, encoding])
14989 * Buffer.from(array)
14990 * Buffer.from(buffer)
14991 * Buffer.from(arrayBuffer[, byteOffset[, length]])
14992 **/
14993Buffer.from = function (value, encodingOrOffset, length) {
14994 return from(value, encodingOrOffset, length)
14995}
14996
14997// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
14998// https://github.com/feross/buffer/pull/148
14999Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype)
15000Object.setPrototypeOf(Buffer, Uint8Array)
15001
15002function assertSize (size) {
15003 if (typeof size !== 'number') {
15004 throw new TypeError('"size" argument must be of type number')
15005 } else if (size < 0) {
15006 throw new RangeError('The value "' + size + '" is invalid for option "size"')
15007 }
15008}
15009
15010function alloc (size, fill, encoding) {
15011 assertSize(size)
15012 if (size <= 0) {
15013 return createBuffer(size)
15014 }
15015 if (fill !== undefined) {
15016 // Only pay attention to encoding if it's a string. This
15017 // prevents accidentally sending in a number that would
15018 // be interpretted as a start offset.
15019 return typeof encoding === 'string'
15020 ? createBuffer(size).fill(fill, encoding)
15021 : createBuffer(size).fill(fill)
15022 }
15023 return createBuffer(size)
15024}
15025
15026/**
15027 * Creates a new filled Buffer instance.
15028 * alloc(size[, fill[, encoding]])
15029 **/
15030Buffer.alloc = function (size, fill, encoding) {
15031 return alloc(size, fill, encoding)
15032}
15033
15034function allocUnsafe (size) {
15035 assertSize(size)
15036 return createBuffer(size < 0 ? 0 : checked(size) | 0)
15037}
15038
15039/**
15040 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
15041 * */
15042Buffer.allocUnsafe = function (size) {
15043 return allocUnsafe(size)
15044}
15045/**
15046 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
15047 */
15048Buffer.allocUnsafeSlow = function (size) {
15049 return allocUnsafe(size)
15050}
15051
15052function fromString (string, encoding) {
15053 if (typeof encoding !== 'string' || encoding === '') {
15054 encoding = 'utf8'
15055 }
15056
15057 if (!Buffer.isEncoding(encoding)) {
15058 throw new TypeError('Unknown encoding: ' + encoding)
15059 }
15060
15061 var length = byteLength(string, encoding) | 0
15062 var buf = createBuffer(length)
15063
15064 var actual = buf.write(string, encoding)
15065
15066 if (actual !== length) {
15067 // Writing a hex string, for example, that contains invalid characters will
15068 // cause everything after the first invalid character to be ignored. (e.g.
15069 // 'abxxcd' will be treated as 'ab')
15070 buf = buf.slice(0, actual)
15071 }
15072
15073 return buf
15074}
15075
15076function fromArrayLike (array) {
15077 var length = array.length < 0 ? 0 : checked(array.length) | 0
15078 var buf = createBuffer(length)
15079 for (var i = 0; i < length; i += 1) {
15080 buf[i] = array[i] & 255
15081 }
15082 return buf
15083}
15084
15085function fromArrayBuffer (array, byteOffset, length) {
15086 if (byteOffset < 0 || array.byteLength < byteOffset) {
15087 throw new RangeError('"offset" is outside of buffer bounds')
15088 }
15089
15090 if (array.byteLength < byteOffset + (length || 0)) {
15091 throw new RangeError('"length" is outside of buffer bounds')
15092 }
15093
15094 var buf
15095 if (byteOffset === undefined && length === undefined) {
15096 buf = new Uint8Array(array)
15097 } else if (length === undefined) {
15098 buf = new Uint8Array(array, byteOffset)
15099 } else {
15100 buf = new Uint8Array(array, byteOffset, length)
15101 }
15102
15103 // Return an augmented `Uint8Array` instance
15104 Object.setPrototypeOf(buf, Buffer.prototype)
15105
15106 return buf
15107}
15108
15109function fromObject (obj) {
15110 if (Buffer.isBuffer(obj)) {
15111 var len = checked(obj.length) | 0
15112 var buf = createBuffer(len)
15113
15114 if (buf.length === 0) {
15115 return buf
15116 }
15117
15118 obj.copy(buf, 0, 0, len)
15119 return buf
15120 }
15121
15122 if (obj.length !== undefined) {
15123 if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
15124 return createBuffer(0)
15125 }
15126 return fromArrayLike(obj)
15127 }
15128
15129 if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
15130 return fromArrayLike(obj.data)
15131 }
15132}
15133
15134function checked (length) {
15135 // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
15136 // length is NaN (which is otherwise coerced to zero.)
15137 if (length >= K_MAX_LENGTH) {
15138 throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
15139 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
15140 }
15141 return length | 0
15142}
15143
15144function SlowBuffer (length) {
15145 if (+length != length) { // eslint-disable-line eqeqeq
15146 length = 0
15147 }
15148 return Buffer.alloc(+length)
15149}
15150
15151Buffer.isBuffer = function isBuffer (b) {
15152 return b != null && b._isBuffer === true &&
15153 b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
15154}
15155
15156Buffer.compare = function compare (a, b) {
15157 if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)
15158 if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)
15159 if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
15160 throw new TypeError(
15161 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
15162 )
15163 }
15164
15165 if (a === b) return 0
15166
15167 var x = a.length
15168 var y = b.length
15169
15170 for (var i = 0, len = Math.min(x, y); i < len; ++i) {
15171 if (a[i] !== b[i]) {
15172 x = a[i]
15173 y = b[i]
15174 break
15175 }
15176 }
15177
15178 if (x < y) return -1
15179 if (y < x) return 1
15180 return 0
15181}
15182
15183Buffer.isEncoding = function isEncoding (encoding) {
15184 switch (String(encoding).toLowerCase()) {
15185 case 'hex':
15186 case 'utf8':
15187 case 'utf-8':
15188 case 'ascii':
15189 case 'latin1':
15190 case 'binary':
15191 case 'base64':
15192 case 'ucs2':
15193 case 'ucs-2':
15194 case 'utf16le':
15195 case 'utf-16le':
15196 return true
15197 default:
15198 return false
15199 }
15200}
15201
15202Buffer.concat = function concat (list, length) {
15203 if (!Array.isArray(list)) {
15204 throw new TypeError('"list" argument must be an Array of Buffers')
15205 }
15206
15207 if (list.length === 0) {
15208 return Buffer.alloc(0)
15209 }
15210
15211 var i
15212 if (length === undefined) {
15213 length = 0
15214 for (i = 0; i < list.length; ++i) {
15215 length += list[i].length
15216 }
15217 }
15218
15219 var buffer = Buffer.allocUnsafe(length)
15220 var pos = 0
15221 for (i = 0; i < list.length; ++i) {
15222 var buf = list[i]
15223 if (isInstance(buf, Uint8Array)) {
15224 buf = Buffer.from(buf)
15225 }
15226 if (!Buffer.isBuffer(buf)) {
15227 throw new TypeError('"list" argument must be an Array of Buffers')
15228 }
15229 buf.copy(buffer, pos)
15230 pos += buf.length
15231 }
15232 return buffer
15233}
15234
15235function byteLength (string, encoding) {
15236 if (Buffer.isBuffer(string)) {
15237 return string.length
15238 }
15239 if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
15240 return string.byteLength
15241 }
15242 if (typeof string !== 'string') {
15243 throw new TypeError(
15244 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
15245 'Received type ' + typeof string
15246 )
15247 }
15248
15249 var len = string.length
15250 var mustMatch = (arguments.length > 2 && arguments[2] === true)
15251 if (!mustMatch && len === 0) return 0
15252
15253 // Use a for loop to avoid recursion
15254 var loweredCase = false
15255 for (;;) {
15256 switch (encoding) {
15257 case 'ascii':
15258 case 'latin1':
15259 case 'binary':
15260 return len
15261 case 'utf8':
15262 case 'utf-8':
15263 return utf8ToBytes(string).length
15264 case 'ucs2':
15265 case 'ucs-2':
15266 case 'utf16le':
15267 case 'utf-16le':
15268 return len * 2
15269 case 'hex':
15270 return len >>> 1
15271 case 'base64':
15272 return base64ToBytes(string).length
15273 default:
15274 if (loweredCase) {
15275 return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
15276 }
15277 encoding = ('' + encoding).toLowerCase()
15278 loweredCase = true
15279 }
15280 }
15281}
15282Buffer.byteLength = byteLength
15283
15284function slowToString (encoding, start, end) {
15285 var loweredCase = false
15286
15287 // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
15288 // property of a typed array.
15289
15290 // This behaves neither like String nor Uint8Array in that we set start/end
15291 // to their upper/lower bounds if the value passed is out of range.
15292 // undefined is handled specially as per ECMA-262 6th Edition,
15293 // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
15294 if (start === undefined || start < 0) {
15295 start = 0
15296 }
15297 // Return early if start > this.length. Done here to prevent potential uint32
15298 // coercion fail below.
15299 if (start > this.length) {
15300 return ''
15301 }
15302
15303 if (end === undefined || end > this.length) {
15304 end = this.length
15305 }
15306
15307 if (end <= 0) {
15308 return ''
15309 }
15310
15311 // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
15312 end >>>= 0
15313 start >>>= 0
15314
15315 if (end <= start) {
15316 return ''
15317 }
15318
15319 if (!encoding) encoding = 'utf8'
15320
15321 while (true) {
15322 switch (encoding) {
15323 case 'hex':
15324 return hexSlice(this, start, end)
15325
15326 case 'utf8':
15327 case 'utf-8':
15328 return utf8Slice(this, start, end)
15329
15330 case 'ascii':
15331 return asciiSlice(this, start, end)
15332
15333 case 'latin1':
15334 case 'binary':
15335 return latin1Slice(this, start, end)
15336
15337 case 'base64':
15338 return base64Slice(this, start, end)
15339
15340 case 'ucs2':
15341 case 'ucs-2':
15342 case 'utf16le':
15343 case 'utf-16le':
15344 return utf16leSlice(this, start, end)
15345
15346 default:
15347 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
15348 encoding = (encoding + '').toLowerCase()
15349 loweredCase = true
15350 }
15351 }
15352}
15353
15354// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
15355// to detect a Buffer instance. It's not possible to use `instanceof Buffer`
15356// reliably in a browserify context because there could be multiple different
15357// copies of the 'buffer' package in use. This method works even for Buffer
15358// instances that were created from another copy of the `buffer` package.
15359// See: https://github.com/feross/buffer/issues/154
15360Buffer.prototype._isBuffer = true
15361
15362function swap (b, n, m) {
15363 var i = b[n]
15364 b[n] = b[m]
15365 b[m] = i
15366}
15367
15368Buffer.prototype.swap16 = function swap16 () {
15369 var len = this.length
15370 if (len % 2 !== 0) {
15371 throw new RangeError('Buffer size must be a multiple of 16-bits')
15372 }
15373 for (var i = 0; i < len; i += 2) {
15374 swap(this, i, i + 1)
15375 }
15376 return this
15377}
15378
15379Buffer.prototype.swap32 = function swap32 () {
15380 var len = this.length
15381 if (len % 4 !== 0) {
15382 throw new RangeError('Buffer size must be a multiple of 32-bits')
15383 }
15384 for (var i = 0; i < len; i += 4) {
15385 swap(this, i, i + 3)
15386 swap(this, i + 1, i + 2)
15387 }
15388 return this
15389}
15390
15391Buffer.prototype.swap64 = function swap64 () {
15392 var len = this.length
15393 if (len % 8 !== 0) {
15394 throw new RangeError('Buffer size must be a multiple of 64-bits')
15395 }
15396 for (var i = 0; i < len; i += 8) {
15397 swap(this, i, i + 7)
15398 swap(this, i + 1, i + 6)
15399 swap(this, i + 2, i + 5)
15400 swap(this, i + 3, i + 4)
15401 }
15402 return this
15403}
15404
15405Buffer.prototype.toString = function toString () {
15406 var length = this.length
15407 if (length === 0) return ''
15408 if (arguments.length === 0) return utf8Slice(this, 0, length)
15409 return slowToString.apply(this, arguments)
15410}
15411
15412Buffer.prototype.toLocaleString = Buffer.prototype.toString
15413
15414Buffer.prototype.equals = function equals (b) {
15415 if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
15416 if (this === b) return true
15417 return Buffer.compare(this, b) === 0
15418}
15419
15420Buffer.prototype.inspect = function inspect () {
15421 var str = ''
15422 var max = exports.INSPECT_MAX_BYTES
15423 str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()
15424 if (this.length > max) str += ' ... '
15425 return '<Buffer ' + str + '>'
15426}
15427if (customInspectSymbol) {
15428 Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect
15429}
15430
15431Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
15432 if (isInstance(target, Uint8Array)) {
15433 target = Buffer.from(target, target.offset, target.byteLength)
15434 }
15435 if (!Buffer.isBuffer(target)) {
15436 throw new TypeError(
15437 'The "target" argument must be one of type Buffer or Uint8Array. ' +
15438 'Received type ' + (typeof target)
15439 )
15440 }
15441
15442 if (start === undefined) {
15443 start = 0
15444 }
15445 if (end === undefined) {
15446 end = target ? target.length : 0
15447 }
15448 if (thisStart === undefined) {
15449 thisStart = 0
15450 }
15451 if (thisEnd === undefined) {
15452 thisEnd = this.length
15453 }
15454
15455 if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
15456 throw new RangeError('out of range index')
15457 }
15458
15459 if (thisStart >= thisEnd && start >= end) {
15460 return 0
15461 }
15462 if (thisStart >= thisEnd) {
15463 return -1
15464 }
15465 if (start >= end) {
15466 return 1
15467 }
15468
15469 start >>>= 0
15470 end >>>= 0
15471 thisStart >>>= 0
15472 thisEnd >>>= 0
15473
15474 if (this === target) return 0
15475
15476 var x = thisEnd - thisStart
15477 var y = end - start
15478 var len = Math.min(x, y)
15479
15480 var thisCopy = this.slice(thisStart, thisEnd)
15481 var targetCopy = target.slice(start, end)
15482
15483 for (var i = 0; i < len; ++i) {
15484 if (thisCopy[i] !== targetCopy[i]) {
15485 x = thisCopy[i]
15486 y = targetCopy[i]
15487 break
15488 }
15489 }
15490
15491 if (x < y) return -1
15492 if (y < x) return 1
15493 return 0
15494}
15495
15496// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
15497// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
15498//
15499// Arguments:
15500// - buffer - a Buffer to search
15501// - val - a string, Buffer, or number
15502// - byteOffset - an index into `buffer`; will be clamped to an int32
15503// - encoding - an optional encoding, relevant is val is a string
15504// - dir - true for indexOf, false for lastIndexOf
15505function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
15506 // Empty buffer means no match
15507 if (buffer.length === 0) return -1
15508
15509 // Normalize byteOffset
15510 if (typeof byteOffset === 'string') {
15511 encoding = byteOffset
15512 byteOffset = 0
15513 } else if (byteOffset > 0x7fffffff) {
15514 byteOffset = 0x7fffffff
15515 } else if (byteOffset < -0x80000000) {
15516 byteOffset = -0x80000000
15517 }
15518 byteOffset = +byteOffset // Coerce to Number.
15519 if (numberIsNaN(byteOffset)) {
15520 // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
15521 byteOffset = dir ? 0 : (buffer.length - 1)
15522 }
15523
15524 // Normalize byteOffset: negative offsets start from the end of the buffer
15525 if (byteOffset < 0) byteOffset = buffer.length + byteOffset
15526 if (byteOffset >= buffer.length) {
15527 if (dir) return -1
15528 else byteOffset = buffer.length - 1
15529 } else if (byteOffset < 0) {
15530 if (dir) byteOffset = 0
15531 else return -1
15532 }
15533
15534 // Normalize val
15535 if (typeof val === 'string') {
15536 val = Buffer.from(val, encoding)
15537 }
15538
15539 // Finally, search either indexOf (if dir is true) or lastIndexOf
15540 if (Buffer.isBuffer(val)) {
15541 // Special case: looking for empty string/buffer always fails
15542 if (val.length === 0) {
15543 return -1
15544 }
15545 return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
15546 } else if (typeof val === 'number') {
15547 val = val & 0xFF // Search for a byte value [0-255]
15548 if (typeof Uint8Array.prototype.indexOf === 'function') {
15549 if (dir) {
15550 return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
15551 } else {
15552 return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
15553 }
15554 }
15555 return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)
15556 }
15557
15558 throw new TypeError('val must be string, number or Buffer')
15559}
15560
15561function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
15562 var indexSize = 1
15563 var arrLength = arr.length
15564 var valLength = val.length
15565
15566 if (encoding !== undefined) {
15567 encoding = String(encoding).toLowerCase()
15568 if (encoding === 'ucs2' || encoding === 'ucs-2' ||
15569 encoding === 'utf16le' || encoding === 'utf-16le') {
15570 if (arr.length < 2 || val.length < 2) {
15571 return -1
15572 }
15573 indexSize = 2
15574 arrLength /= 2
15575 valLength /= 2
15576 byteOffset /= 2
15577 }
15578 }
15579
15580 function read (buf, i) {
15581 if (indexSize === 1) {
15582 return buf[i]
15583 } else {
15584 return buf.readUInt16BE(i * indexSize)
15585 }
15586 }
15587
15588 var i
15589 if (dir) {
15590 var foundIndex = -1
15591 for (i = byteOffset; i < arrLength; i++) {
15592 if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
15593 if (foundIndex === -1) foundIndex = i
15594 if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
15595 } else {
15596 if (foundIndex !== -1) i -= i - foundIndex
15597 foundIndex = -1
15598 }
15599 }
15600 } else {
15601 if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
15602 for (i = byteOffset; i >= 0; i--) {
15603 var found = true
15604 for (var j = 0; j < valLength; j++) {
15605 if (read(arr, i + j) !== read(val, j)) {
15606 found = false
15607 break
15608 }
15609 }
15610 if (found) return i
15611 }
15612 }
15613
15614 return -1
15615}
15616
15617Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
15618 return this.indexOf(val, byteOffset, encoding) !== -1
15619}
15620
15621Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
15622 return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
15623}
15624
15625Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
15626 return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
15627}
15628
15629function hexWrite (buf, string, offset, length) {
15630 offset = Number(offset) || 0
15631 var remaining = buf.length - offset
15632 if (!length) {
15633 length = remaining
15634 } else {
15635 length = Number(length)
15636 if (length > remaining) {
15637 length = remaining
15638 }
15639 }
15640
15641 var strLen = string.length
15642
15643 if (length > strLen / 2) {
15644 length = strLen / 2
15645 }
15646 for (var i = 0; i < length; ++i) {
15647 var parsed = parseInt(string.substr(i * 2, 2), 16)
15648 if (numberIsNaN(parsed)) return i
15649 buf[offset + i] = parsed
15650 }
15651 return i
15652}
15653
15654function utf8Write (buf, string, offset, length) {
15655 return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
15656}
15657
15658function asciiWrite (buf, string, offset, length) {
15659 return blitBuffer(asciiToBytes(string), buf, offset, length)
15660}
15661
15662function latin1Write (buf, string, offset, length) {
15663 return asciiWrite(buf, string, offset, length)
15664}
15665
15666function base64Write (buf, string, offset, length) {
15667 return blitBuffer(base64ToBytes(string), buf, offset, length)
15668}
15669
15670function ucs2Write (buf, string, offset, length) {
15671 return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
15672}
15673
15674Buffer.prototype.write = function write (string, offset, length, encoding) {
15675 // Buffer#write(string)
15676 if (offset === undefined) {
15677 encoding = 'utf8'
15678 length = this.length
15679 offset = 0
15680 // Buffer#write(string, encoding)
15681 } else if (length === undefined && typeof offset === 'string') {
15682 encoding = offset
15683 length = this.length
15684 offset = 0
15685 // Buffer#write(string, offset[, length][, encoding])
15686 } else if (isFinite(offset)) {
15687 offset = offset >>> 0
15688 if (isFinite(length)) {
15689 length = length >>> 0
15690 if (encoding === undefined) encoding = 'utf8'
15691 } else {
15692 encoding = length
15693 length = undefined
15694 }
15695 } else {
15696 throw new Error(
15697 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
15698 )
15699 }
15700
15701 var remaining = this.length - offset
15702 if (length === undefined || length > remaining) length = remaining
15703
15704 if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
15705 throw new RangeError('Attempt to write outside buffer bounds')
15706 }
15707
15708 if (!encoding) encoding = 'utf8'
15709
15710 var loweredCase = false
15711 for (;;) {
15712 switch (encoding) {
15713 case 'hex':
15714 return hexWrite(this, string, offset, length)
15715
15716 case 'utf8':
15717 case 'utf-8':
15718 return utf8Write(this, string, offset, length)
15719
15720 case 'ascii':
15721 return asciiWrite(this, string, offset, length)
15722
15723 case 'latin1':
15724 case 'binary':
15725 return latin1Write(this, string, offset, length)
15726
15727 case 'base64':
15728 // Warning: maxLength not taken into account in base64Write
15729 return base64Write(this, string, offset, length)
15730
15731 case 'ucs2':
15732 case 'ucs-2':
15733 case 'utf16le':
15734 case 'utf-16le':
15735 return ucs2Write(this, string, offset, length)
15736
15737 default:
15738 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
15739 encoding = ('' + encoding).toLowerCase()
15740 loweredCase = true
15741 }
15742 }
15743}
15744
15745Buffer.prototype.toJSON = function toJSON () {
15746 return {
15747 type: 'Buffer',
15748 data: Array.prototype.slice.call(this._arr || this, 0)
15749 }
15750}
15751
15752function base64Slice (buf, start, end) {
15753 if (start === 0 && end === buf.length) {
15754 return base64.fromByteArray(buf)
15755 } else {
15756 return base64.fromByteArray(buf.slice(start, end))
15757 }
15758}
15759
15760function utf8Slice (buf, start, end) {
15761 end = Math.min(buf.length, end)
15762 var res = []
15763
15764 var i = start
15765 while (i < end) {
15766 var firstByte = buf[i]
15767 var codePoint = null
15768 var bytesPerSequence = (firstByte > 0xEF) ? 4
15769 : (firstByte > 0xDF) ? 3
15770 : (firstByte > 0xBF) ? 2
15771 : 1
15772
15773 if (i + bytesPerSequence <= end) {
15774 var secondByte, thirdByte, fourthByte, tempCodePoint
15775
15776 switch (bytesPerSequence) {
15777 case 1:
15778 if (firstByte < 0x80) {
15779 codePoint = firstByte
15780 }
15781 break
15782 case 2:
15783 secondByte = buf[i + 1]
15784 if ((secondByte & 0xC0) === 0x80) {
15785 tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
15786 if (tempCodePoint > 0x7F) {
15787 codePoint = tempCodePoint
15788 }
15789 }
15790 break
15791 case 3:
15792 secondByte = buf[i + 1]
15793 thirdByte = buf[i + 2]
15794 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
15795 tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
15796 if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
15797 codePoint = tempCodePoint
15798 }
15799 }
15800 break
15801 case 4:
15802 secondByte = buf[i + 1]
15803 thirdByte = buf[i + 2]
15804 fourthByte = buf[i + 3]
15805 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
15806 tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
15807 if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
15808 codePoint = tempCodePoint
15809 }
15810 }
15811 }
15812 }
15813
15814 if (codePoint === null) {
15815 // we did not generate a valid codePoint so insert a
15816 // replacement char (U+FFFD) and advance only 1 byte
15817 codePoint = 0xFFFD
15818 bytesPerSequence = 1
15819 } else if (codePoint > 0xFFFF) {
15820 // encode to utf16 (surrogate pair dance)
15821 codePoint -= 0x10000
15822 res.push(codePoint >>> 10 & 0x3FF | 0xD800)
15823 codePoint = 0xDC00 | codePoint & 0x3FF
15824 }
15825
15826 res.push(codePoint)
15827 i += bytesPerSequence
15828 }
15829
15830 return decodeCodePointsArray(res)
15831}
15832
15833// Based on http://stackoverflow.com/a/22747272/680742, the browser with
15834// the lowest limit is Chrome, with 0x10000 args.
15835// We go 1 magnitude less, for safety
15836var MAX_ARGUMENTS_LENGTH = 0x1000
15837
15838function decodeCodePointsArray (codePoints) {
15839 var len = codePoints.length
15840 if (len <= MAX_ARGUMENTS_LENGTH) {
15841 return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
15842 }
15843
15844 // Decode in chunks to avoid "call stack size exceeded".
15845 var res = ''
15846 var i = 0
15847 while (i < len) {
15848 res += String.fromCharCode.apply(
15849 String,
15850 codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
15851 )
15852 }
15853 return res
15854}
15855
15856function asciiSlice (buf, start, end) {
15857 var ret = ''
15858 end = Math.min(buf.length, end)
15859
15860 for (var i = start; i < end; ++i) {
15861 ret += String.fromCharCode(buf[i] & 0x7F)
15862 }
15863 return ret
15864}
15865
15866function latin1Slice (buf, start, end) {
15867 var ret = ''
15868 end = Math.min(buf.length, end)
15869
15870 for (var i = start; i < end; ++i) {
15871 ret += String.fromCharCode(buf[i])
15872 }
15873 return ret
15874}
15875
15876function hexSlice (buf, start, end) {
15877 var len = buf.length
15878
15879 if (!start || start < 0) start = 0
15880 if (!end || end < 0 || end > len) end = len
15881
15882 var out = ''
15883 for (var i = start; i < end; ++i) {
15884 out += toHex(buf[i])
15885 }
15886 return out
15887}
15888
15889function utf16leSlice (buf, start, end) {
15890 var bytes = buf.slice(start, end)
15891 var res = ''
15892 for (var i = 0; i < bytes.length; i += 2) {
15893 res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
15894 }
15895 return res
15896}
15897
15898Buffer.prototype.slice = function slice (start, end) {
15899 var len = this.length
15900 start = ~~start
15901 end = end === undefined ? len : ~~end
15902
15903 if (start < 0) {
15904 start += len
15905 if (start < 0) start = 0
15906 } else if (start > len) {
15907 start = len
15908 }
15909
15910 if (end < 0) {
15911 end += len
15912 if (end < 0) end = 0
15913 } else if (end > len) {
15914 end = len
15915 }
15916
15917 if (end < start) end = start
15918
15919 var newBuf = this.subarray(start, end)
15920 // Return an augmented `Uint8Array` instance
15921 Object.setPrototypeOf(newBuf, Buffer.prototype)
15922
15923 return newBuf
15924}
15925
15926/*
15927 * Need to make sure that buffer isn't trying to write out of bounds.
15928 */
15929function checkOffset (offset, ext, length) {
15930 if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
15931 if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
15932}
15933
15934Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
15935 offset = offset >>> 0
15936 byteLength = byteLength >>> 0
15937 if (!noAssert) checkOffset(offset, byteLength, this.length)
15938
15939 var val = this[offset]
15940 var mul = 1
15941 var i = 0
15942 while (++i < byteLength && (mul *= 0x100)) {
15943 val += this[offset + i] * mul
15944 }
15945
15946 return val
15947}
15948
15949Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
15950 offset = offset >>> 0
15951 byteLength = byteLength >>> 0
15952 if (!noAssert) {
15953 checkOffset(offset, byteLength, this.length)
15954 }
15955
15956 var val = this[offset + --byteLength]
15957 var mul = 1
15958 while (byteLength > 0 && (mul *= 0x100)) {
15959 val += this[offset + --byteLength] * mul
15960 }
15961
15962 return val
15963}
15964
15965Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
15966 offset = offset >>> 0
15967 if (!noAssert) checkOffset(offset, 1, this.length)
15968 return this[offset]
15969}
15970
15971Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
15972 offset = offset >>> 0
15973 if (!noAssert) checkOffset(offset, 2, this.length)
15974 return this[offset] | (this[offset + 1] << 8)
15975}
15976
15977Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
15978 offset = offset >>> 0
15979 if (!noAssert) checkOffset(offset, 2, this.length)
15980 return (this[offset] << 8) | this[offset + 1]
15981}
15982
15983Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
15984 offset = offset >>> 0
15985 if (!noAssert) checkOffset(offset, 4, this.length)
15986
15987 return ((this[offset]) |
15988 (this[offset + 1] << 8) |
15989 (this[offset + 2] << 16)) +
15990 (this[offset + 3] * 0x1000000)
15991}
15992
15993Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
15994 offset = offset >>> 0
15995 if (!noAssert) checkOffset(offset, 4, this.length)
15996
15997 return (this[offset] * 0x1000000) +
15998 ((this[offset + 1] << 16) |
15999 (this[offset + 2] << 8) |
16000 this[offset + 3])
16001}
16002
16003Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
16004 offset = offset >>> 0
16005 byteLength = byteLength >>> 0
16006 if (!noAssert) checkOffset(offset, byteLength, this.length)
16007
16008 var val = this[offset]
16009 var mul = 1
16010 var i = 0
16011 while (++i < byteLength && (mul *= 0x100)) {
16012 val += this[offset + i] * mul
16013 }
16014 mul *= 0x80
16015
16016 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
16017
16018 return val
16019}
16020
16021Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
16022 offset = offset >>> 0
16023 byteLength = byteLength >>> 0
16024 if (!noAssert) checkOffset(offset, byteLength, this.length)
16025
16026 var i = byteLength
16027 var mul = 1
16028 var val = this[offset + --i]
16029 while (i > 0 && (mul *= 0x100)) {
16030 val += this[offset + --i] * mul
16031 }
16032 mul *= 0x80
16033
16034 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
16035
16036 return val
16037}
16038
16039Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
16040 offset = offset >>> 0
16041 if (!noAssert) checkOffset(offset, 1, this.length)
16042 if (!(this[offset] & 0x80)) return (this[offset])
16043 return ((0xff - this[offset] + 1) * -1)
16044}
16045
16046Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
16047 offset = offset >>> 0
16048 if (!noAssert) checkOffset(offset, 2, this.length)
16049 var val = this[offset] | (this[offset + 1] << 8)
16050 return (val & 0x8000) ? val | 0xFFFF0000 : val
16051}
16052
16053Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
16054 offset = offset >>> 0
16055 if (!noAssert) checkOffset(offset, 2, this.length)
16056 var val = this[offset + 1] | (this[offset] << 8)
16057 return (val & 0x8000) ? val | 0xFFFF0000 : val
16058}
16059
16060Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
16061 offset = offset >>> 0
16062 if (!noAssert) checkOffset(offset, 4, this.length)
16063
16064 return (this[offset]) |
16065 (this[offset + 1] << 8) |
16066 (this[offset + 2] << 16) |
16067 (this[offset + 3] << 24)
16068}
16069
16070Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
16071 offset = offset >>> 0
16072 if (!noAssert) checkOffset(offset, 4, this.length)
16073
16074 return (this[offset] << 24) |
16075 (this[offset + 1] << 16) |
16076 (this[offset + 2] << 8) |
16077 (this[offset + 3])
16078}
16079
16080Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
16081 offset = offset >>> 0
16082 if (!noAssert) checkOffset(offset, 4, this.length)
16083 return ieee754.read(this, offset, true, 23, 4)
16084}
16085
16086Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
16087 offset = offset >>> 0
16088 if (!noAssert) checkOffset(offset, 4, this.length)
16089 return ieee754.read(this, offset, false, 23, 4)
16090}
16091
16092Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
16093 offset = offset >>> 0
16094 if (!noAssert) checkOffset(offset, 8, this.length)
16095 return ieee754.read(this, offset, true, 52, 8)
16096}
16097
16098Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
16099 offset = offset >>> 0
16100 if (!noAssert) checkOffset(offset, 8, this.length)
16101 return ieee754.read(this, offset, false, 52, 8)
16102}
16103
16104function checkInt (buf, value, offset, ext, max, min) {
16105 if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
16106 if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
16107 if (offset + ext > buf.length) throw new RangeError('Index out of range')
16108}
16109
16110Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
16111 value = +value
16112 offset = offset >>> 0
16113 byteLength = byteLength >>> 0
16114 if (!noAssert) {
16115 var maxBytes = Math.pow(2, 8 * byteLength) - 1
16116 checkInt(this, value, offset, byteLength, maxBytes, 0)
16117 }
16118
16119 var mul = 1
16120 var i = 0
16121 this[offset] = value & 0xFF
16122 while (++i < byteLength && (mul *= 0x100)) {
16123 this[offset + i] = (value / mul) & 0xFF
16124 }
16125
16126 return offset + byteLength
16127}
16128
16129Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
16130 value = +value
16131 offset = offset >>> 0
16132 byteLength = byteLength >>> 0
16133 if (!noAssert) {
16134 var maxBytes = Math.pow(2, 8 * byteLength) - 1
16135 checkInt(this, value, offset, byteLength, maxBytes, 0)
16136 }
16137
16138 var i = byteLength - 1
16139 var mul = 1
16140 this[offset + i] = value & 0xFF
16141 while (--i >= 0 && (mul *= 0x100)) {
16142 this[offset + i] = (value / mul) & 0xFF
16143 }
16144
16145 return offset + byteLength
16146}
16147
16148Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
16149 value = +value
16150 offset = offset >>> 0
16151 if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
16152 this[offset] = (value & 0xff)
16153 return offset + 1
16154}
16155
16156Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
16157 value = +value
16158 offset = offset >>> 0
16159 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
16160 this[offset] = (value & 0xff)
16161 this[offset + 1] = (value >>> 8)
16162 return offset + 2
16163}
16164
16165Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
16166 value = +value
16167 offset = offset >>> 0
16168 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
16169 this[offset] = (value >>> 8)
16170 this[offset + 1] = (value & 0xff)
16171 return offset + 2
16172}
16173
16174Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
16175 value = +value
16176 offset = offset >>> 0
16177 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
16178 this[offset + 3] = (value >>> 24)
16179 this[offset + 2] = (value >>> 16)
16180 this[offset + 1] = (value >>> 8)
16181 this[offset] = (value & 0xff)
16182 return offset + 4
16183}
16184
16185Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
16186 value = +value
16187 offset = offset >>> 0
16188 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
16189 this[offset] = (value >>> 24)
16190 this[offset + 1] = (value >>> 16)
16191 this[offset + 2] = (value >>> 8)
16192 this[offset + 3] = (value & 0xff)
16193 return offset + 4
16194}
16195
16196Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
16197 value = +value
16198 offset = offset >>> 0
16199 if (!noAssert) {
16200 var limit = Math.pow(2, (8 * byteLength) - 1)
16201
16202 checkInt(this, value, offset, byteLength, limit - 1, -limit)
16203 }
16204
16205 var i = 0
16206 var mul = 1
16207 var sub = 0
16208 this[offset] = value & 0xFF
16209 while (++i < byteLength && (mul *= 0x100)) {
16210 if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
16211 sub = 1
16212 }
16213 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
16214 }
16215
16216 return offset + byteLength
16217}
16218
16219Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
16220 value = +value
16221 offset = offset >>> 0
16222 if (!noAssert) {
16223 var limit = Math.pow(2, (8 * byteLength) - 1)
16224
16225 checkInt(this, value, offset, byteLength, limit - 1, -limit)
16226 }
16227
16228 var i = byteLength - 1
16229 var mul = 1
16230 var sub = 0
16231 this[offset + i] = value & 0xFF
16232 while (--i >= 0 && (mul *= 0x100)) {
16233 if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
16234 sub = 1
16235 }
16236 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
16237 }
16238
16239 return offset + byteLength
16240}
16241
16242Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
16243 value = +value
16244 offset = offset >>> 0
16245 if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
16246 if (value < 0) value = 0xff + value + 1
16247 this[offset] = (value & 0xff)
16248 return offset + 1
16249}
16250
16251Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
16252 value = +value
16253 offset = offset >>> 0
16254 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
16255 this[offset] = (value & 0xff)
16256 this[offset + 1] = (value >>> 8)
16257 return offset + 2
16258}
16259
16260Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
16261 value = +value
16262 offset = offset >>> 0
16263 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
16264 this[offset] = (value >>> 8)
16265 this[offset + 1] = (value & 0xff)
16266 return offset + 2
16267}
16268
16269Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
16270 value = +value
16271 offset = offset >>> 0
16272 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
16273 this[offset] = (value & 0xff)
16274 this[offset + 1] = (value >>> 8)
16275 this[offset + 2] = (value >>> 16)
16276 this[offset + 3] = (value >>> 24)
16277 return offset + 4
16278}
16279
16280Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
16281 value = +value
16282 offset = offset >>> 0
16283 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
16284 if (value < 0) value = 0xffffffff + value + 1
16285 this[offset] = (value >>> 24)
16286 this[offset + 1] = (value >>> 16)
16287 this[offset + 2] = (value >>> 8)
16288 this[offset + 3] = (value & 0xff)
16289 return offset + 4
16290}
16291
16292function checkIEEE754 (buf, value, offset, ext, max, min) {
16293 if (offset + ext > buf.length) throw new RangeError('Index out of range')
16294 if (offset < 0) throw new RangeError('Index out of range')
16295}
16296
16297function writeFloat (buf, value, offset, littleEndian, noAssert) {
16298 value = +value
16299 offset = offset >>> 0
16300 if (!noAssert) {
16301 checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
16302 }
16303 ieee754.write(buf, value, offset, littleEndian, 23, 4)
16304 return offset + 4
16305}
16306
16307Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
16308 return writeFloat(this, value, offset, true, noAssert)
16309}
16310
16311Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
16312 return writeFloat(this, value, offset, false, noAssert)
16313}
16314
16315function writeDouble (buf, value, offset, littleEndian, noAssert) {
16316 value = +value
16317 offset = offset >>> 0
16318 if (!noAssert) {
16319 checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
16320 }
16321 ieee754.write(buf, value, offset, littleEndian, 52, 8)
16322 return offset + 8
16323}
16324
16325Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
16326 return writeDouble(this, value, offset, true, noAssert)
16327}
16328
16329Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
16330 return writeDouble(this, value, offset, false, noAssert)
16331}
16332
16333// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
16334Buffer.prototype.copy = function copy (target, targetStart, start, end) {
16335 if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
16336 if (!start) start = 0
16337 if (!end && end !== 0) end = this.length
16338 if (targetStart >= target.length) targetStart = target.length
16339 if (!targetStart) targetStart = 0
16340 if (end > 0 && end < start) end = start
16341
16342 // Copy 0 bytes; we're done
16343 if (end === start) return 0
16344 if (target.length === 0 || this.length === 0) return 0
16345
16346 // Fatal error conditions
16347 if (targetStart < 0) {
16348 throw new RangeError('targetStart out of bounds')
16349 }
16350 if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
16351 if (end < 0) throw new RangeError('sourceEnd out of bounds')
16352
16353 // Are we oob?
16354 if (end > this.length) end = this.length
16355 if (target.length - targetStart < end - start) {
16356 end = target.length - targetStart + start
16357 }
16358
16359 var len = end - start
16360
16361 if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
16362 // Use built-in when available, missing from IE11
16363 this.copyWithin(targetStart, start, end)
16364 } else if (this === target && start < targetStart && targetStart < end) {
16365 // descending copy from end
16366 for (var i = len - 1; i >= 0; --i) {
16367 target[i + targetStart] = this[i + start]
16368 }
16369 } else {
16370 Uint8Array.prototype.set.call(
16371 target,
16372 this.subarray(start, end),
16373 targetStart
16374 )
16375 }
16376
16377 return len
16378}
16379
16380// Usage:
16381// buffer.fill(number[, offset[, end]])
16382// buffer.fill(buffer[, offset[, end]])
16383// buffer.fill(string[, offset[, end]][, encoding])
16384Buffer.prototype.fill = function fill (val, start, end, encoding) {
16385 // Handle string cases:
16386 if (typeof val === 'string') {
16387 if (typeof start === 'string') {
16388 encoding = start
16389 start = 0
16390 end = this.length
16391 } else if (typeof end === 'string') {
16392 encoding = end
16393 end = this.length
16394 }
16395 if (encoding !== undefined && typeof encoding !== 'string') {
16396 throw new TypeError('encoding must be a string')
16397 }
16398 if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
16399 throw new TypeError('Unknown encoding: ' + encoding)
16400 }
16401 if (val.length === 1) {
16402 var code = val.charCodeAt(0)
16403 if ((encoding === 'utf8' && code < 128) ||
16404 encoding === 'latin1') {
16405 // Fast path: If `val` fits into a single byte, use that numeric value.
16406 val = code
16407 }
16408 }
16409 } else if (typeof val === 'number') {
16410 val = val & 255
16411 } else if (typeof val === 'boolean') {
16412 val = Number(val)
16413 }
16414
16415 // Invalid ranges are not set to a default, so can range check early.
16416 if (start < 0 || this.length < start || this.length < end) {
16417 throw new RangeError('Out of range index')
16418 }
16419
16420 if (end <= start) {
16421 return this
16422 }
16423
16424 start = start >>> 0
16425 end = end === undefined ? this.length : end >>> 0
16426
16427 if (!val) val = 0
16428
16429 var i
16430 if (typeof val === 'number') {
16431 for (i = start; i < end; ++i) {
16432 this[i] = val
16433 }
16434 } else {
16435 var bytes = Buffer.isBuffer(val)
16436 ? val
16437 : Buffer.from(val, encoding)
16438 var len = bytes.length
16439 if (len === 0) {
16440 throw new TypeError('The value "' + val +
16441 '" is invalid for argument "value"')
16442 }
16443 for (i = 0; i < end - start; ++i) {
16444 this[i + start] = bytes[i % len]
16445 }
16446 }
16447
16448 return this
16449}
16450
16451// HELPER FUNCTIONS
16452// ================
16453
16454var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
16455
16456function base64clean (str) {
16457 // Node takes equal signs as end of the Base64 encoding
16458 str = str.split('=')[0]
16459 // Node strips out invalid characters like \n and \t from the string, base64-js does not
16460 str = str.trim().replace(INVALID_BASE64_RE, '')
16461 // Node converts strings with length < 2 to ''
16462 if (str.length < 2) return ''
16463 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
16464 while (str.length % 4 !== 0) {
16465 str = str + '='
16466 }
16467 return str
16468}
16469
16470function toHex (n) {
16471 if (n < 16) return '0' + n.toString(16)
16472 return n.toString(16)
16473}
16474
16475function utf8ToBytes (string, units) {
16476 units = units || Infinity
16477 var codePoint
16478 var length = string.length
16479 var leadSurrogate = null
16480 var bytes = []
16481
16482 for (var i = 0; i < length; ++i) {
16483 codePoint = string.charCodeAt(i)
16484
16485 // is surrogate component
16486 if (codePoint > 0xD7FF && codePoint < 0xE000) {
16487 // last char was a lead
16488 if (!leadSurrogate) {
16489 // no lead yet
16490 if (codePoint > 0xDBFF) {
16491 // unexpected trail
16492 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
16493 continue
16494 } else if (i + 1 === length) {
16495 // unpaired lead
16496 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
16497 continue
16498 }
16499
16500 // valid lead
16501 leadSurrogate = codePoint
16502
16503 continue
16504 }
16505
16506 // 2 leads in a row
16507 if (codePoint < 0xDC00) {
16508 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
16509 leadSurrogate = codePoint
16510 continue
16511 }
16512
16513 // valid surrogate pair
16514 codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
16515 } else if (leadSurrogate) {
16516 // valid bmp char, but last char was a lead
16517 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
16518 }
16519
16520 leadSurrogate = null
16521
16522 // encode utf8
16523 if (codePoint < 0x80) {
16524 if ((units -= 1) < 0) break
16525 bytes.push(codePoint)
16526 } else if (codePoint < 0x800) {
16527 if ((units -= 2) < 0) break
16528 bytes.push(
16529 codePoint >> 0x6 | 0xC0,
16530 codePoint & 0x3F | 0x80
16531 )
16532 } else if (codePoint < 0x10000) {
16533 if ((units -= 3) < 0) break
16534 bytes.push(
16535 codePoint >> 0xC | 0xE0,
16536 codePoint >> 0x6 & 0x3F | 0x80,
16537 codePoint & 0x3F | 0x80
16538 )
16539 } else if (codePoint < 0x110000) {
16540 if ((units -= 4) < 0) break
16541 bytes.push(
16542 codePoint >> 0x12 | 0xF0,
16543 codePoint >> 0xC & 0x3F | 0x80,
16544 codePoint >> 0x6 & 0x3F | 0x80,
16545 codePoint & 0x3F | 0x80
16546 )
16547 } else {
16548 throw new Error('Invalid code point')
16549 }
16550 }
16551
16552 return bytes
16553}
16554
16555function asciiToBytes (str) {
16556 var byteArray = []
16557 for (var i = 0; i < str.length; ++i) {
16558 // Node's code seems to be doing this and not & 0x7F..
16559 byteArray.push(str.charCodeAt(i) & 0xFF)
16560 }
16561 return byteArray
16562}
16563
16564function utf16leToBytes (str, units) {
16565 var c, hi, lo
16566 var byteArray = []
16567 for (var i = 0; i < str.length; ++i) {
16568 if ((units -= 2) < 0) break
16569
16570 c = str.charCodeAt(i)
16571 hi = c >> 8
16572 lo = c % 256
16573 byteArray.push(lo)
16574 byteArray.push(hi)
16575 }
16576
16577 return byteArray
16578}
16579
16580function base64ToBytes (str) {
16581 return base64.toByteArray(base64clean(str))
16582}
16583
16584function blitBuffer (src, dst, offset, length) {
16585 for (var i = 0; i < length; ++i) {
16586 if ((i + offset >= dst.length) || (i >= src.length)) break
16587 dst[i + offset] = src[i]
16588 }
16589 return i
16590}
16591
16592// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
16593// the `instanceof` check but they should be treated as of that type.
16594// See: https://github.com/feross/buffer/issues/166
16595function isInstance (obj, type) {
16596 return obj instanceof type ||
16597 (obj != null && obj.constructor != null && obj.constructor.name != null &&
16598 obj.constructor.name === type.name)
16599}
16600function numberIsNaN (obj) {
16601 // For IE11 support
16602 return obj !== obj // eslint-disable-line no-self-compare
16603}
16604
16605}).call(this,require("buffer").Buffer)
16606},{"base64-js":78,"buffer":110,"ieee754":161}],111:[function(require,module,exports){
16607arguments[4][31][0].apply(exports,arguments)
16608},{"dup":31,"inherits":162,"safe-buffer":206,"stream":215,"string_decoder":216}],112:[function(require,module,exports){
16609(function (Buffer){
16610// Copyright Joyent, Inc. and other Node contributors.
16611//
16612// Permission is hereby granted, free of charge, to any person obtaining a
16613// copy of this software and associated documentation files (the
16614// "Software"), to deal in the Software without restriction, including
16615// without limitation the rights to use, copy, modify, merge, publish,
16616// distribute, sublicense, and/or sell copies of the Software, and to permit
16617// persons to whom the Software is furnished to do so, subject to the
16618// following conditions:
16619//
16620// The above copyright notice and this permission notice shall be included
16621// in all copies or substantial portions of the Software.
16622//
16623// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16624// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16625// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
16626// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
16627// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16628// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
16629// USE OR OTHER DEALINGS IN THE SOFTWARE.
16630
16631// NOTE: These type checking functions intentionally don't use `instanceof`
16632// because it is fragile and can be easily faked with `Object.create()`.
16633
16634function isArray(arg) {
16635 if (Array.isArray) {
16636 return Array.isArray(arg);
16637 }
16638 return objectToString(arg) === '[object Array]';
16639}
16640exports.isArray = isArray;
16641
16642function isBoolean(arg) {
16643 return typeof arg === 'boolean';
16644}
16645exports.isBoolean = isBoolean;
16646
16647function isNull(arg) {
16648 return arg === null;
16649}
16650exports.isNull = isNull;
16651
16652function isNullOrUndefined(arg) {
16653 return arg == null;
16654}
16655exports.isNullOrUndefined = isNullOrUndefined;
16656
16657function isNumber(arg) {
16658 return typeof arg === 'number';
16659}
16660exports.isNumber = isNumber;
16661
16662function isString(arg) {
16663 return typeof arg === 'string';
16664}
16665exports.isString = isString;
16666
16667function isSymbol(arg) {
16668 return typeof arg === 'symbol';
16669}
16670exports.isSymbol = isSymbol;
16671
16672function isUndefined(arg) {
16673 return arg === void 0;
16674}
16675exports.isUndefined = isUndefined;
16676
16677function isRegExp(re) {
16678 return objectToString(re) === '[object RegExp]';
16679}
16680exports.isRegExp = isRegExp;
16681
16682function isObject(arg) {
16683 return typeof arg === 'object' && arg !== null;
16684}
16685exports.isObject = isObject;
16686
16687function isDate(d) {
16688 return objectToString(d) === '[object Date]';
16689}
16690exports.isDate = isDate;
16691
16692function isError(e) {
16693 return (objectToString(e) === '[object Error]' || e instanceof Error);
16694}
16695exports.isError = isError;
16696
16697function isFunction(arg) {
16698 return typeof arg === 'function';
16699}
16700exports.isFunction = isFunction;
16701
16702function isPrimitive(arg) {
16703 return arg === null ||
16704 typeof arg === 'boolean' ||
16705 typeof arg === 'number' ||
16706 typeof arg === 'string' ||
16707 typeof arg === 'symbol' || // ES6 symbol
16708 typeof arg === 'undefined';
16709}
16710exports.isPrimitive = isPrimitive;
16711
16712exports.isBuffer = Buffer.isBuffer;
16713
16714function objectToString(o) {
16715 return Object.prototype.toString.call(o);
16716}
16717
16718}).call(this,{"isBuffer":require("../../is-buffer/index.js")})
16719},{"../../is-buffer/index.js":163}],113:[function(require,module,exports){
16720(function (Buffer){
16721var elliptic = require('elliptic')
16722var BN = require('bn.js')
16723
16724module.exports = function createECDH (curve) {
16725 return new ECDH(curve)
16726}
16727
16728var aliases = {
16729 secp256k1: {
16730 name: 'secp256k1',
16731 byteLength: 32
16732 },
16733 secp224r1: {
16734 name: 'p224',
16735 byteLength: 28
16736 },
16737 prime256v1: {
16738 name: 'p256',
16739 byteLength: 32
16740 },
16741 prime192v1: {
16742 name: 'p192',
16743 byteLength: 24
16744 },
16745 ed25519: {
16746 name: 'ed25519',
16747 byteLength: 32
16748 },
16749 secp384r1: {
16750 name: 'p384',
16751 byteLength: 48
16752 },
16753 secp521r1: {
16754 name: 'p521',
16755 byteLength: 66
16756 }
16757}
16758
16759aliases.p224 = aliases.secp224r1
16760aliases.p256 = aliases.secp256r1 = aliases.prime256v1
16761aliases.p192 = aliases.secp192r1 = aliases.prime192v1
16762aliases.p384 = aliases.secp384r1
16763aliases.p521 = aliases.secp521r1
16764
16765function ECDH (curve) {
16766 this.curveType = aliases[curve]
16767 if (!this.curveType) {
16768 this.curveType = {
16769 name: curve
16770 }
16771 }
16772 this.curve = new elliptic.ec(this.curveType.name) // eslint-disable-line new-cap
16773 this.keys = void 0
16774}
16775
16776ECDH.prototype.generateKeys = function (enc, format) {
16777 this.keys = this.curve.genKeyPair()
16778 return this.getPublicKey(enc, format)
16779}
16780
16781ECDH.prototype.computeSecret = function (other, inenc, enc) {
16782 inenc = inenc || 'utf8'
16783 if (!Buffer.isBuffer(other)) {
16784 other = new Buffer(other, inenc)
16785 }
16786 var otherPub = this.curve.keyFromPublic(other).getPublic()
16787 var out = otherPub.mul(this.keys.getPrivate()).getX()
16788 return formatReturnValue(out, enc, this.curveType.byteLength)
16789}
16790
16791ECDH.prototype.getPublicKey = function (enc, format) {
16792 var key = this.keys.getPublic(format === 'compressed', true)
16793 if (format === 'hybrid') {
16794 if (key[key.length - 1] % 2) {
16795 key[0] = 7
16796 } else {
16797 key[0] = 6
16798 }
16799 }
16800 return formatReturnValue(key, enc)
16801}
16802
16803ECDH.prototype.getPrivateKey = function (enc) {
16804 return formatReturnValue(this.keys.getPrivate(), enc)
16805}
16806
16807ECDH.prototype.setPublicKey = function (pub, enc) {
16808 enc = enc || 'utf8'
16809 if (!Buffer.isBuffer(pub)) {
16810 pub = new Buffer(pub, enc)
16811 }
16812 this.keys._importPublic(pub)
16813 return this
16814}
16815
16816ECDH.prototype.setPrivateKey = function (priv, enc) {
16817 enc = enc || 'utf8'
16818 if (!Buffer.isBuffer(priv)) {
16819 priv = new Buffer(priv, enc)
16820 }
16821
16822 var _priv = new BN(priv)
16823 _priv = _priv.toString(16)
16824 this.keys = this.curve.genKeyPair()
16825 this.keys._importPrivate(_priv)
16826 return this
16827}
16828
16829function formatReturnValue (bn, enc, len) {
16830 if (!Array.isArray(bn)) {
16831 bn = bn.toArray()
16832 }
16833 var buf = new Buffer(bn)
16834 if (len && buf.length < len) {
16835 var zeros = new Buffer(len - buf.length)
16836 zeros.fill(0)
16837 buf = Buffer.concat([zeros, buf])
16838 }
16839 if (!enc) {
16840 return buf
16841 } else {
16842 return buf.toString(enc)
16843 }
16844}
16845
16846}).call(this,require("buffer").Buffer)
16847},{"bn.js":79,"buffer":110,"elliptic":129}],114:[function(require,module,exports){
16848arguments[4][32][0].apply(exports,arguments)
16849},{"cipher-base":111,"dup":32,"inherits":162,"md5.js":165,"ripemd160":205,"sha.js":208}],115:[function(require,module,exports){
16850var MD5 = require('md5.js')
16851
16852module.exports = function (buffer) {
16853 return new MD5().update(buffer).digest()
16854}
16855
16856},{"md5.js":165}],116:[function(require,module,exports){
16857'use strict'
16858var inherits = require('inherits')
16859var Legacy = require('./legacy')
16860var Base = require('cipher-base')
16861var Buffer = require('safe-buffer').Buffer
16862var md5 = require('create-hash/md5')
16863var RIPEMD160 = require('ripemd160')
16864
16865var sha = require('sha.js')
16866
16867var ZEROS = Buffer.alloc(128)
16868
16869function Hmac (alg, key) {
16870 Base.call(this, 'digest')
16871 if (typeof key === 'string') {
16872 key = Buffer.from(key)
16873 }
16874
16875 var blocksize = (alg === 'sha512' || alg === 'sha384') ? 128 : 64
16876
16877 this._alg = alg
16878 this._key = key
16879 if (key.length > blocksize) {
16880 var hash = alg === 'rmd160' ? new RIPEMD160() : sha(alg)
16881 key = hash.update(key).digest()
16882 } else if (key.length < blocksize) {
16883 key = Buffer.concat([key, ZEROS], blocksize)
16884 }
16885
16886 var ipad = this._ipad = Buffer.allocUnsafe(blocksize)
16887 var opad = this._opad = Buffer.allocUnsafe(blocksize)
16888
16889 for (var i = 0; i < blocksize; i++) {
16890 ipad[i] = key[i] ^ 0x36
16891 opad[i] = key[i] ^ 0x5C
16892 }
16893 this._hash = alg === 'rmd160' ? new RIPEMD160() : sha(alg)
16894 this._hash.update(ipad)
16895}
16896
16897inherits(Hmac, Base)
16898
16899Hmac.prototype._update = function (data) {
16900 this._hash.update(data)
16901}
16902
16903Hmac.prototype._final = function () {
16904 var h = this._hash.digest()
16905 var hash = this._alg === 'rmd160' ? new RIPEMD160() : sha(this._alg)
16906 return hash.update(this._opad).update(h).digest()
16907}
16908
16909module.exports = function createHmac (alg, key) {
16910 alg = alg.toLowerCase()
16911 if (alg === 'rmd160' || alg === 'ripemd160') {
16912 return new Hmac('rmd160', key)
16913 }
16914 if (alg === 'md5') {
16915 return new Legacy(md5, key)
16916 }
16917 return new Hmac(alg, key)
16918}
16919
16920},{"./legacy":117,"cipher-base":111,"create-hash/md5":115,"inherits":162,"ripemd160":205,"safe-buffer":206,"sha.js":208}],117:[function(require,module,exports){
16921'use strict'
16922var inherits = require('inherits')
16923var Buffer = require('safe-buffer').Buffer
16924
16925var Base = require('cipher-base')
16926
16927var ZEROS = Buffer.alloc(128)
16928var blocksize = 64
16929
16930function Hmac (alg, key) {
16931 Base.call(this, 'digest')
16932 if (typeof key === 'string') {
16933 key = Buffer.from(key)
16934 }
16935
16936 this._alg = alg
16937 this._key = key
16938
16939 if (key.length > blocksize) {
16940 key = alg(key)
16941 } else if (key.length < blocksize) {
16942 key = Buffer.concat([key, ZEROS], blocksize)
16943 }
16944
16945 var ipad = this._ipad = Buffer.allocUnsafe(blocksize)
16946 var opad = this._opad = Buffer.allocUnsafe(blocksize)
16947
16948 for (var i = 0; i < blocksize; i++) {
16949 ipad[i] = key[i] ^ 0x36
16950 opad[i] = key[i] ^ 0x5C
16951 }
16952
16953 this._hash = [ipad]
16954}
16955
16956inherits(Hmac, Base)
16957
16958Hmac.prototype._update = function (data) {
16959 this._hash.push(data)
16960}
16961
16962Hmac.prototype._final = function () {
16963 var h = this._alg(Buffer.concat(this._hash))
16964 return this._alg(Buffer.concat([this._opad, h]))
16965}
16966module.exports = Hmac
16967
16968},{"cipher-base":111,"inherits":162,"safe-buffer":206}],118:[function(require,module,exports){
16969'use strict'
16970
16971exports.randomBytes = exports.rng = exports.pseudoRandomBytes = exports.prng = require('randombytes')
16972exports.createHash = exports.Hash = require('create-hash')
16973exports.createHmac = exports.Hmac = require('create-hmac')
16974
16975var algos = require('browserify-sign/algos')
16976var algoKeys = Object.keys(algos)
16977var hashes = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160'].concat(algoKeys)
16978exports.getHashes = function () {
16979 return hashes
16980}
16981
16982var p = require('pbkdf2')
16983exports.pbkdf2 = p.pbkdf2
16984exports.pbkdf2Sync = p.pbkdf2Sync
16985
16986var aes = require('browserify-cipher')
16987
16988exports.Cipher = aes.Cipher
16989exports.createCipher = aes.createCipher
16990exports.Cipheriv = aes.Cipheriv
16991exports.createCipheriv = aes.createCipheriv
16992exports.Decipher = aes.Decipher
16993exports.createDecipher = aes.createDecipher
16994exports.Decipheriv = aes.Decipheriv
16995exports.createDecipheriv = aes.createDecipheriv
16996exports.getCiphers = aes.getCiphers
16997exports.listCiphers = aes.listCiphers
16998
16999var dh = require('diffie-hellman')
17000
17001exports.DiffieHellmanGroup = dh.DiffieHellmanGroup
17002exports.createDiffieHellmanGroup = dh.createDiffieHellmanGroup
17003exports.getDiffieHellman = dh.getDiffieHellman
17004exports.createDiffieHellman = dh.createDiffieHellman
17005exports.DiffieHellman = dh.DiffieHellman
17006
17007var sign = require('browserify-sign')
17008
17009exports.createSign = sign.createSign
17010exports.Sign = sign.Sign
17011exports.createVerify = sign.createVerify
17012exports.Verify = sign.Verify
17013
17014exports.createECDH = require('create-ecdh')
17015
17016var publicEncrypt = require('public-encrypt')
17017
17018exports.publicEncrypt = publicEncrypt.publicEncrypt
17019exports.privateEncrypt = publicEncrypt.privateEncrypt
17020exports.publicDecrypt = publicEncrypt.publicDecrypt
17021exports.privateDecrypt = publicEncrypt.privateDecrypt
17022
17023// the least I can do is make error messages for the rest of the node.js/crypto api.
17024// ;[
17025// 'createCredentials'
17026// ].forEach(function (name) {
17027// exports[name] = function () {
17028// throw new Error([
17029// 'sorry, ' + name + ' is not implemented yet',
17030// 'we accept pull requests',
17031// 'https://github.com/crypto-browserify/crypto-browserify'
17032// ].join('\n'))
17033// }
17034// })
17035
17036var rf = require('randomfill')
17037
17038exports.randomFill = rf.randomFill
17039exports.randomFillSync = rf.randomFillSync
17040
17041exports.createCredentials = function () {
17042 throw new Error([
17043 'sorry, createCredentials is not implemented yet',
17044 'we accept pull requests',
17045 'https://github.com/crypto-browserify/crypto-browserify'
17046 ].join('\n'))
17047}
17048
17049exports.constants = {
17050 'DH_CHECK_P_NOT_SAFE_PRIME': 2,
17051 'DH_CHECK_P_NOT_PRIME': 1,
17052 'DH_UNABLE_TO_CHECK_GENERATOR': 4,
17053 'DH_NOT_SUITABLE_GENERATOR': 8,
17054 'NPN_ENABLED': 1,
17055 'ALPN_ENABLED': 1,
17056 'RSA_PKCS1_PADDING': 1,
17057 'RSA_SSLV23_PADDING': 2,
17058 'RSA_NO_PADDING': 3,
17059 'RSA_PKCS1_OAEP_PADDING': 4,
17060 'RSA_X931_PADDING': 5,
17061 'RSA_PKCS1_PSS_PADDING': 6,
17062 'POINT_CONVERSION_COMPRESSED': 2,
17063 'POINT_CONVERSION_UNCOMPRESSED': 4,
17064 'POINT_CONVERSION_HYBRID': 6
17065}
17066
17067},{"browserify-cipher":99,"browserify-sign":106,"browserify-sign/algos":103,"create-ecdh":113,"create-hash":114,"create-hmac":116,"diffie-hellman":125,"pbkdf2":175,"public-encrypt":182,"randombytes":188,"randomfill":189}],119:[function(require,module,exports){
17068'use strict';
17069
17070exports.utils = require('./des/utils');
17071exports.Cipher = require('./des/cipher');
17072exports.DES = require('./des/des');
17073exports.CBC = require('./des/cbc');
17074exports.EDE = require('./des/ede');
17075
17076},{"./des/cbc":120,"./des/cipher":121,"./des/des":122,"./des/ede":123,"./des/utils":124}],120:[function(require,module,exports){
17077'use strict';
17078
17079var assert = require('minimalistic-assert');
17080var inherits = require('inherits');
17081
17082var proto = {};
17083
17084function CBCState(iv) {
17085 assert.equal(iv.length, 8, 'Invalid IV length');
17086
17087 this.iv = new Array(8);
17088 for (var i = 0; i < this.iv.length; i++)
17089 this.iv[i] = iv[i];
17090}
17091
17092function instantiate(Base) {
17093 function CBC(options) {
17094 Base.call(this, options);
17095 this._cbcInit();
17096 }
17097 inherits(CBC, Base);
17098
17099 var keys = Object.keys(proto);
17100 for (var i = 0; i < keys.length; i++) {
17101 var key = keys[i];
17102 CBC.prototype[key] = proto[key];
17103 }
17104
17105 CBC.create = function create(options) {
17106 return new CBC(options);
17107 };
17108
17109 return CBC;
17110}
17111
17112exports.instantiate = instantiate;
17113
17114proto._cbcInit = function _cbcInit() {
17115 var state = new CBCState(this.options.iv);
17116 this._cbcState = state;
17117};
17118
17119proto._update = function _update(inp, inOff, out, outOff) {
17120 var state = this._cbcState;
17121 var superProto = this.constructor.super_.prototype;
17122
17123 var iv = state.iv;
17124 if (this.type === 'encrypt') {
17125 for (var i = 0; i < this.blockSize; i++)
17126 iv[i] ^= inp[inOff + i];
17127
17128 superProto._update.call(this, iv, 0, out, outOff);
17129
17130 for (var i = 0; i < this.blockSize; i++)
17131 iv[i] = out[outOff + i];
17132 } else {
17133 superProto._update.call(this, inp, inOff, out, outOff);
17134
17135 for (var i = 0; i < this.blockSize; i++)
17136 out[outOff + i] ^= iv[i];
17137
17138 for (var i = 0; i < this.blockSize; i++)
17139 iv[i] = inp[inOff + i];
17140 }
17141};
17142
17143},{"inherits":162,"minimalistic-assert":167}],121:[function(require,module,exports){
17144'use strict';
17145
17146var assert = require('minimalistic-assert');
17147
17148function Cipher(options) {
17149 this.options = options;
17150
17151 this.type = this.options.type;
17152 this.blockSize = 8;
17153 this._init();
17154
17155 this.buffer = new Array(this.blockSize);
17156 this.bufferOff = 0;
17157}
17158module.exports = Cipher;
17159
17160Cipher.prototype._init = function _init() {
17161 // Might be overrided
17162};
17163
17164Cipher.prototype.update = function update(data) {
17165 if (data.length === 0)
17166 return [];
17167
17168 if (this.type === 'decrypt')
17169 return this._updateDecrypt(data);
17170 else
17171 return this._updateEncrypt(data);
17172};
17173
17174Cipher.prototype._buffer = function _buffer(data, off) {
17175 // Append data to buffer
17176 var min = Math.min(this.buffer.length - this.bufferOff, data.length - off);
17177 for (var i = 0; i < min; i++)
17178 this.buffer[this.bufferOff + i] = data[off + i];
17179 this.bufferOff += min;
17180
17181 // Shift next
17182 return min;
17183};
17184
17185Cipher.prototype._flushBuffer = function _flushBuffer(out, off) {
17186 this._update(this.buffer, 0, out, off);
17187 this.bufferOff = 0;
17188 return this.blockSize;
17189};
17190
17191Cipher.prototype._updateEncrypt = function _updateEncrypt(data) {
17192 var inputOff = 0;
17193 var outputOff = 0;
17194
17195 var count = ((this.bufferOff + data.length) / this.blockSize) | 0;
17196 var out = new Array(count * this.blockSize);
17197
17198 if (this.bufferOff !== 0) {
17199 inputOff += this._buffer(data, inputOff);
17200
17201 if (this.bufferOff === this.buffer.length)
17202 outputOff += this._flushBuffer(out, outputOff);
17203 }
17204
17205 // Write blocks
17206 var max = data.length - ((data.length - inputOff) % this.blockSize);
17207 for (; inputOff < max; inputOff += this.blockSize) {
17208 this._update(data, inputOff, out, outputOff);
17209 outputOff += this.blockSize;
17210 }
17211
17212 // Queue rest
17213 for (; inputOff < data.length; inputOff++, this.bufferOff++)
17214 this.buffer[this.bufferOff] = data[inputOff];
17215
17216 return out;
17217};
17218
17219Cipher.prototype._updateDecrypt = function _updateDecrypt(data) {
17220 var inputOff = 0;
17221 var outputOff = 0;
17222
17223 var count = Math.ceil((this.bufferOff + data.length) / this.blockSize) - 1;
17224 var out = new Array(count * this.blockSize);
17225
17226 // TODO(indutny): optimize it, this is far from optimal
17227 for (; count > 0; count--) {
17228 inputOff += this._buffer(data, inputOff);
17229 outputOff += this._flushBuffer(out, outputOff);
17230 }
17231
17232 // Buffer rest of the input
17233 inputOff += this._buffer(data, inputOff);
17234
17235 return out;
17236};
17237
17238Cipher.prototype.final = function final(buffer) {
17239 var first;
17240 if (buffer)
17241 first = this.update(buffer);
17242
17243 var last;
17244 if (this.type === 'encrypt')
17245 last = this._finalEncrypt();
17246 else
17247 last = this._finalDecrypt();
17248
17249 if (first)
17250 return first.concat(last);
17251 else
17252 return last;
17253};
17254
17255Cipher.prototype._pad = function _pad(buffer, off) {
17256 if (off === 0)
17257 return false;
17258
17259 while (off < buffer.length)
17260 buffer[off++] = 0;
17261
17262 return true;
17263};
17264
17265Cipher.prototype._finalEncrypt = function _finalEncrypt() {
17266 if (!this._pad(this.buffer, this.bufferOff))
17267 return [];
17268
17269 var out = new Array(this.blockSize);
17270 this._update(this.buffer, 0, out, 0);
17271 return out;
17272};
17273
17274Cipher.prototype._unpad = function _unpad(buffer) {
17275 return buffer;
17276};
17277
17278Cipher.prototype._finalDecrypt = function _finalDecrypt() {
17279 assert.equal(this.bufferOff, this.blockSize, 'Not enough data to decrypt');
17280 var out = new Array(this.blockSize);
17281 this._flushBuffer(out, 0);
17282
17283 return this._unpad(out);
17284};
17285
17286},{"minimalistic-assert":167}],122:[function(require,module,exports){
17287'use strict';
17288
17289var assert = require('minimalistic-assert');
17290var inherits = require('inherits');
17291
17292var des = require('../des');
17293var utils = des.utils;
17294var Cipher = des.Cipher;
17295
17296function DESState() {
17297 this.tmp = new Array(2);
17298 this.keys = null;
17299}
17300
17301function DES(options) {
17302 Cipher.call(this, options);
17303
17304 var state = new DESState();
17305 this._desState = state;
17306
17307 this.deriveKeys(state, options.key);
17308}
17309inherits(DES, Cipher);
17310module.exports = DES;
17311
17312DES.create = function create(options) {
17313 return new DES(options);
17314};
17315
17316var shiftTable = [
17317 1, 1, 2, 2, 2, 2, 2, 2,
17318 1, 2, 2, 2, 2, 2, 2, 1
17319];
17320
17321DES.prototype.deriveKeys = function deriveKeys(state, key) {
17322 state.keys = new Array(16 * 2);
17323
17324 assert.equal(key.length, this.blockSize, 'Invalid key length');
17325
17326 var kL = utils.readUInt32BE(key, 0);
17327 var kR = utils.readUInt32BE(key, 4);
17328
17329 utils.pc1(kL, kR, state.tmp, 0);
17330 kL = state.tmp[0];
17331 kR = state.tmp[1];
17332 for (var i = 0; i < state.keys.length; i += 2) {
17333 var shift = shiftTable[i >>> 1];
17334 kL = utils.r28shl(kL, shift);
17335 kR = utils.r28shl(kR, shift);
17336 utils.pc2(kL, kR, state.keys, i);
17337 }
17338};
17339
17340DES.prototype._update = function _update(inp, inOff, out, outOff) {
17341 var state = this._desState;
17342
17343 var l = utils.readUInt32BE(inp, inOff);
17344 var r = utils.readUInt32BE(inp, inOff + 4);
17345
17346 // Initial Permutation
17347 utils.ip(l, r, state.tmp, 0);
17348 l = state.tmp[0];
17349 r = state.tmp[1];
17350
17351 if (this.type === 'encrypt')
17352 this._encrypt(state, l, r, state.tmp, 0);
17353 else
17354 this._decrypt(state, l, r, state.tmp, 0);
17355
17356 l = state.tmp[0];
17357 r = state.tmp[1];
17358
17359 utils.writeUInt32BE(out, l, outOff);
17360 utils.writeUInt32BE(out, r, outOff + 4);
17361};
17362
17363DES.prototype._pad = function _pad(buffer, off) {
17364 var value = buffer.length - off;
17365 for (var i = off; i < buffer.length; i++)
17366 buffer[i] = value;
17367
17368 return true;
17369};
17370
17371DES.prototype._unpad = function _unpad(buffer) {
17372 var pad = buffer[buffer.length - 1];
17373 for (var i = buffer.length - pad; i < buffer.length; i++)
17374 assert.equal(buffer[i], pad);
17375
17376 return buffer.slice(0, buffer.length - pad);
17377};
17378
17379DES.prototype._encrypt = function _encrypt(state, lStart, rStart, out, off) {
17380 var l = lStart;
17381 var r = rStart;
17382
17383 // Apply f() x16 times
17384 for (var i = 0; i < state.keys.length; i += 2) {
17385 var keyL = state.keys[i];
17386 var keyR = state.keys[i + 1];
17387
17388 // f(r, k)
17389 utils.expand(r, state.tmp, 0);
17390
17391 keyL ^= state.tmp[0];
17392 keyR ^= state.tmp[1];
17393 var s = utils.substitute(keyL, keyR);
17394 var f = utils.permute(s);
17395
17396 var t = r;
17397 r = (l ^ f) >>> 0;
17398 l = t;
17399 }
17400
17401 // Reverse Initial Permutation
17402 utils.rip(r, l, out, off);
17403};
17404
17405DES.prototype._decrypt = function _decrypt(state, lStart, rStart, out, off) {
17406 var l = rStart;
17407 var r = lStart;
17408
17409 // Apply f() x16 times
17410 for (var i = state.keys.length - 2; i >= 0; i -= 2) {
17411 var keyL = state.keys[i];
17412 var keyR = state.keys[i + 1];
17413
17414 // f(r, k)
17415 utils.expand(l, state.tmp, 0);
17416
17417 keyL ^= state.tmp[0];
17418 keyR ^= state.tmp[1];
17419 var s = utils.substitute(keyL, keyR);
17420 var f = utils.permute(s);
17421
17422 var t = l;
17423 l = (r ^ f) >>> 0;
17424 r = t;
17425 }
17426
17427 // Reverse Initial Permutation
17428 utils.rip(l, r, out, off);
17429};
17430
17431},{"../des":119,"inherits":162,"minimalistic-assert":167}],123:[function(require,module,exports){
17432'use strict';
17433
17434var assert = require('minimalistic-assert');
17435var inherits = require('inherits');
17436
17437var des = require('../des');
17438var Cipher = des.Cipher;
17439var DES = des.DES;
17440
17441function EDEState(type, key) {
17442 assert.equal(key.length, 24, 'Invalid key length');
17443
17444 var k1 = key.slice(0, 8);
17445 var k2 = key.slice(8, 16);
17446 var k3 = key.slice(16, 24);
17447
17448 if (type === 'encrypt') {
17449 this.ciphers = [
17450 DES.create({ type: 'encrypt', key: k1 }),
17451 DES.create({ type: 'decrypt', key: k2 }),
17452 DES.create({ type: 'encrypt', key: k3 })
17453 ];
17454 } else {
17455 this.ciphers = [
17456 DES.create({ type: 'decrypt', key: k3 }),
17457 DES.create({ type: 'encrypt', key: k2 }),
17458 DES.create({ type: 'decrypt', key: k1 })
17459 ];
17460 }
17461}
17462
17463function EDE(options) {
17464 Cipher.call(this, options);
17465
17466 var state = new EDEState(this.type, this.options.key);
17467 this._edeState = state;
17468}
17469inherits(EDE, Cipher);
17470
17471module.exports = EDE;
17472
17473EDE.create = function create(options) {
17474 return new EDE(options);
17475};
17476
17477EDE.prototype._update = function _update(inp, inOff, out, outOff) {
17478 var state = this._edeState;
17479
17480 state.ciphers[0]._update(inp, inOff, out, outOff);
17481 state.ciphers[1]._update(out, outOff, out, outOff);
17482 state.ciphers[2]._update(out, outOff, out, outOff);
17483};
17484
17485EDE.prototype._pad = DES.prototype._pad;
17486EDE.prototype._unpad = DES.prototype._unpad;
17487
17488},{"../des":119,"inherits":162,"minimalistic-assert":167}],124:[function(require,module,exports){
17489'use strict';
17490
17491exports.readUInt32BE = function readUInt32BE(bytes, off) {
17492 var res = (bytes[0 + off] << 24) |
17493 (bytes[1 + off] << 16) |
17494 (bytes[2 + off] << 8) |
17495 bytes[3 + off];
17496 return res >>> 0;
17497};
17498
17499exports.writeUInt32BE = function writeUInt32BE(bytes, value, off) {
17500 bytes[0 + off] = value >>> 24;
17501 bytes[1 + off] = (value >>> 16) & 0xff;
17502 bytes[2 + off] = (value >>> 8) & 0xff;
17503 bytes[3 + off] = value & 0xff;
17504};
17505
17506exports.ip = function ip(inL, inR, out, off) {
17507 var outL = 0;
17508 var outR = 0;
17509
17510 for (var i = 6; i >= 0; i -= 2) {
17511 for (var j = 0; j <= 24; j += 8) {
17512 outL <<= 1;
17513 outL |= (inR >>> (j + i)) & 1;
17514 }
17515 for (var j = 0; j <= 24; j += 8) {
17516 outL <<= 1;
17517 outL |= (inL >>> (j + i)) & 1;
17518 }
17519 }
17520
17521 for (var i = 6; i >= 0; i -= 2) {
17522 for (var j = 1; j <= 25; j += 8) {
17523 outR <<= 1;
17524 outR |= (inR >>> (j + i)) & 1;
17525 }
17526 for (var j = 1; j <= 25; j += 8) {
17527 outR <<= 1;
17528 outR |= (inL >>> (j + i)) & 1;
17529 }
17530 }
17531
17532 out[off + 0] = outL >>> 0;
17533 out[off + 1] = outR >>> 0;
17534};
17535
17536exports.rip = function rip(inL, inR, out, off) {
17537 var outL = 0;
17538 var outR = 0;
17539
17540 for (var i = 0; i < 4; i++) {
17541 for (var j = 24; j >= 0; j -= 8) {
17542 outL <<= 1;
17543 outL |= (inR >>> (j + i)) & 1;
17544 outL <<= 1;
17545 outL |= (inL >>> (j + i)) & 1;
17546 }
17547 }
17548 for (var i = 4; i < 8; i++) {
17549 for (var j = 24; j >= 0; j -= 8) {
17550 outR <<= 1;
17551 outR |= (inR >>> (j + i)) & 1;
17552 outR <<= 1;
17553 outR |= (inL >>> (j + i)) & 1;
17554 }
17555 }
17556
17557 out[off + 0] = outL >>> 0;
17558 out[off + 1] = outR >>> 0;
17559};
17560
17561exports.pc1 = function pc1(inL, inR, out, off) {
17562 var outL = 0;
17563 var outR = 0;
17564
17565 // 7, 15, 23, 31, 39, 47, 55, 63
17566 // 6, 14, 22, 30, 39, 47, 55, 63
17567 // 5, 13, 21, 29, 39, 47, 55, 63
17568 // 4, 12, 20, 28
17569 for (var i = 7; i >= 5; i--) {
17570 for (var j = 0; j <= 24; j += 8) {
17571 outL <<= 1;
17572 outL |= (inR >> (j + i)) & 1;
17573 }
17574 for (var j = 0; j <= 24; j += 8) {
17575 outL <<= 1;
17576 outL |= (inL >> (j + i)) & 1;
17577 }
17578 }
17579 for (var j = 0; j <= 24; j += 8) {
17580 outL <<= 1;
17581 outL |= (inR >> (j + i)) & 1;
17582 }
17583
17584 // 1, 9, 17, 25, 33, 41, 49, 57
17585 // 2, 10, 18, 26, 34, 42, 50, 58
17586 // 3, 11, 19, 27, 35, 43, 51, 59
17587 // 36, 44, 52, 60
17588 for (var i = 1; i <= 3; i++) {
17589 for (var j = 0; j <= 24; j += 8) {
17590 outR <<= 1;
17591 outR |= (inR >> (j + i)) & 1;
17592 }
17593 for (var j = 0; j <= 24; j += 8) {
17594 outR <<= 1;
17595 outR |= (inL >> (j + i)) & 1;
17596 }
17597 }
17598 for (var j = 0; j <= 24; j += 8) {
17599 outR <<= 1;
17600 outR |= (inL >> (j + i)) & 1;
17601 }
17602
17603 out[off + 0] = outL >>> 0;
17604 out[off + 1] = outR >>> 0;
17605};
17606
17607exports.r28shl = function r28shl(num, shift) {
17608 return ((num << shift) & 0xfffffff) | (num >>> (28 - shift));
17609};
17610
17611var pc2table = [
17612 // inL => outL
17613 14, 11, 17, 4, 27, 23, 25, 0,
17614 13, 22, 7, 18, 5, 9, 16, 24,
17615 2, 20, 12, 21, 1, 8, 15, 26,
17616
17617 // inR => outR
17618 15, 4, 25, 19, 9, 1, 26, 16,
17619 5, 11, 23, 8, 12, 7, 17, 0,
17620 22, 3, 10, 14, 6, 20, 27, 24
17621];
17622
17623exports.pc2 = function pc2(inL, inR, out, off) {
17624 var outL = 0;
17625 var outR = 0;
17626
17627 var len = pc2table.length >>> 1;
17628 for (var i = 0; i < len; i++) {
17629 outL <<= 1;
17630 outL |= (inL >>> pc2table[i]) & 0x1;
17631 }
17632 for (var i = len; i < pc2table.length; i++) {
17633 outR <<= 1;
17634 outR |= (inR >>> pc2table[i]) & 0x1;
17635 }
17636
17637 out[off + 0] = outL >>> 0;
17638 out[off + 1] = outR >>> 0;
17639};
17640
17641exports.expand = function expand(r, out, off) {
17642 var outL = 0;
17643 var outR = 0;
17644
17645 outL = ((r & 1) << 5) | (r >>> 27);
17646 for (var i = 23; i >= 15; i -= 4) {
17647 outL <<= 6;
17648 outL |= (r >>> i) & 0x3f;
17649 }
17650 for (var i = 11; i >= 3; i -= 4) {
17651 outR |= (r >>> i) & 0x3f;
17652 outR <<= 6;
17653 }
17654 outR |= ((r & 0x1f) << 1) | (r >>> 31);
17655
17656 out[off + 0] = outL >>> 0;
17657 out[off + 1] = outR >>> 0;
17658};
17659
17660var sTable = [
17661 14, 0, 4, 15, 13, 7, 1, 4, 2, 14, 15, 2, 11, 13, 8, 1,
17662 3, 10, 10, 6, 6, 12, 12, 11, 5, 9, 9, 5, 0, 3, 7, 8,
17663 4, 15, 1, 12, 14, 8, 8, 2, 13, 4, 6, 9, 2, 1, 11, 7,
17664 15, 5, 12, 11, 9, 3, 7, 14, 3, 10, 10, 0, 5, 6, 0, 13,
17665
17666 15, 3, 1, 13, 8, 4, 14, 7, 6, 15, 11, 2, 3, 8, 4, 14,
17667 9, 12, 7, 0, 2, 1, 13, 10, 12, 6, 0, 9, 5, 11, 10, 5,
17668 0, 13, 14, 8, 7, 10, 11, 1, 10, 3, 4, 15, 13, 4, 1, 2,
17669 5, 11, 8, 6, 12, 7, 6, 12, 9, 0, 3, 5, 2, 14, 15, 9,
17670
17671 10, 13, 0, 7, 9, 0, 14, 9, 6, 3, 3, 4, 15, 6, 5, 10,
17672 1, 2, 13, 8, 12, 5, 7, 14, 11, 12, 4, 11, 2, 15, 8, 1,
17673 13, 1, 6, 10, 4, 13, 9, 0, 8, 6, 15, 9, 3, 8, 0, 7,
17674 11, 4, 1, 15, 2, 14, 12, 3, 5, 11, 10, 5, 14, 2, 7, 12,
17675
17676 7, 13, 13, 8, 14, 11, 3, 5, 0, 6, 6, 15, 9, 0, 10, 3,
17677 1, 4, 2, 7, 8, 2, 5, 12, 11, 1, 12, 10, 4, 14, 15, 9,
17678 10, 3, 6, 15, 9, 0, 0, 6, 12, 10, 11, 1, 7, 13, 13, 8,
17679 15, 9, 1, 4, 3, 5, 14, 11, 5, 12, 2, 7, 8, 2, 4, 14,
17680
17681 2, 14, 12, 11, 4, 2, 1, 12, 7, 4, 10, 7, 11, 13, 6, 1,
17682 8, 5, 5, 0, 3, 15, 15, 10, 13, 3, 0, 9, 14, 8, 9, 6,
17683 4, 11, 2, 8, 1, 12, 11, 7, 10, 1, 13, 14, 7, 2, 8, 13,
17684 15, 6, 9, 15, 12, 0, 5, 9, 6, 10, 3, 4, 0, 5, 14, 3,
17685
17686 12, 10, 1, 15, 10, 4, 15, 2, 9, 7, 2, 12, 6, 9, 8, 5,
17687 0, 6, 13, 1, 3, 13, 4, 14, 14, 0, 7, 11, 5, 3, 11, 8,
17688 9, 4, 14, 3, 15, 2, 5, 12, 2, 9, 8, 5, 12, 15, 3, 10,
17689 7, 11, 0, 14, 4, 1, 10, 7, 1, 6, 13, 0, 11, 8, 6, 13,
17690
17691 4, 13, 11, 0, 2, 11, 14, 7, 15, 4, 0, 9, 8, 1, 13, 10,
17692 3, 14, 12, 3, 9, 5, 7, 12, 5, 2, 10, 15, 6, 8, 1, 6,
17693 1, 6, 4, 11, 11, 13, 13, 8, 12, 1, 3, 4, 7, 10, 14, 7,
17694 10, 9, 15, 5, 6, 0, 8, 15, 0, 14, 5, 2, 9, 3, 2, 12,
17695
17696 13, 1, 2, 15, 8, 13, 4, 8, 6, 10, 15, 3, 11, 7, 1, 4,
17697 10, 12, 9, 5, 3, 6, 14, 11, 5, 0, 0, 14, 12, 9, 7, 2,
17698 7, 2, 11, 1, 4, 14, 1, 7, 9, 4, 12, 10, 14, 8, 2, 13,
17699 0, 15, 6, 12, 10, 9, 13, 0, 15, 3, 3, 5, 5, 6, 8, 11
17700];
17701
17702exports.substitute = function substitute(inL, inR) {
17703 var out = 0;
17704 for (var i = 0; i < 4; i++) {
17705 var b = (inL >>> (18 - i * 6)) & 0x3f;
17706 var sb = sTable[i * 0x40 + b];
17707
17708 out <<= 4;
17709 out |= sb;
17710 }
17711 for (var i = 0; i < 4; i++) {
17712 var b = (inR >>> (18 - i * 6)) & 0x3f;
17713 var sb = sTable[4 * 0x40 + i * 0x40 + b];
17714
17715 out <<= 4;
17716 out |= sb;
17717 }
17718 return out >>> 0;
17719};
17720
17721var permuteTable = [
17722 16, 25, 12, 11, 3, 20, 4, 15, 31, 17, 9, 6, 27, 14, 1, 22,
17723 30, 24, 8, 18, 0, 5, 29, 23, 13, 19, 2, 26, 10, 21, 28, 7
17724];
17725
17726exports.permute = function permute(num) {
17727 var out = 0;
17728 for (var i = 0; i < permuteTable.length; i++) {
17729 out <<= 1;
17730 out |= (num >>> permuteTable[i]) & 0x1;
17731 }
17732 return out >>> 0;
17733};
17734
17735exports.padSplit = function padSplit(num, size, group) {
17736 var str = num.toString(2);
17737 while (str.length < size)
17738 str = '0' + str;
17739
17740 var out = [];
17741 for (var i = 0; i < size; i += group)
17742 out.push(str.slice(i, i + group));
17743 return out.join(' ');
17744};
17745
17746},{}],125:[function(require,module,exports){
17747(function (Buffer){
17748var generatePrime = require('./lib/generatePrime')
17749var primes = require('./lib/primes.json')
17750
17751var DH = require('./lib/dh')
17752
17753function getDiffieHellman (mod) {
17754 var prime = new Buffer(primes[mod].prime, 'hex')
17755 var gen = new Buffer(primes[mod].gen, 'hex')
17756
17757 return new DH(prime, gen)
17758}
17759
17760var ENCODINGS = {
17761 'binary': true, 'hex': true, 'base64': true
17762}
17763
17764function createDiffieHellman (prime, enc, generator, genc) {
17765 if (Buffer.isBuffer(enc) || ENCODINGS[enc] === undefined) {
17766 return createDiffieHellman(prime, 'binary', enc, generator)
17767 }
17768
17769 enc = enc || 'binary'
17770 genc = genc || 'binary'
17771 generator = generator || new Buffer([2])
17772
17773 if (!Buffer.isBuffer(generator)) {
17774 generator = new Buffer(generator, genc)
17775 }
17776
17777 if (typeof prime === 'number') {
17778 return new DH(generatePrime(prime, generator), generator, true)
17779 }
17780
17781 if (!Buffer.isBuffer(prime)) {
17782 prime = new Buffer(prime, enc)
17783 }
17784
17785 return new DH(prime, generator, true)
17786}
17787
17788exports.DiffieHellmanGroup = exports.createDiffieHellmanGroup = exports.getDiffieHellman = getDiffieHellman
17789exports.createDiffieHellman = exports.DiffieHellman = createDiffieHellman
17790
17791}).call(this,require("buffer").Buffer)
17792},{"./lib/dh":126,"./lib/generatePrime":127,"./lib/primes.json":128,"buffer":110}],126:[function(require,module,exports){
17793(function (Buffer){
17794var BN = require('bn.js');
17795var MillerRabin = require('miller-rabin');
17796var millerRabin = new MillerRabin();
17797var TWENTYFOUR = new BN(24);
17798var ELEVEN = new BN(11);
17799var TEN = new BN(10);
17800var THREE = new BN(3);
17801var SEVEN = new BN(7);
17802var primes = require('./generatePrime');
17803var randomBytes = require('randombytes');
17804module.exports = DH;
17805
17806function setPublicKey(pub, enc) {
17807 enc = enc || 'utf8';
17808 if (!Buffer.isBuffer(pub)) {
17809 pub = new Buffer(pub, enc);
17810 }
17811 this._pub = new BN(pub);
17812 return this;
17813}
17814
17815function setPrivateKey(priv, enc) {
17816 enc = enc || 'utf8';
17817 if (!Buffer.isBuffer(priv)) {
17818 priv = new Buffer(priv, enc);
17819 }
17820 this._priv = new BN(priv);
17821 return this;
17822}
17823
17824var primeCache = {};
17825function checkPrime(prime, generator) {
17826 var gen = generator.toString('hex');
17827 var hex = [gen, prime.toString(16)].join('_');
17828 if (hex in primeCache) {
17829 return primeCache[hex];
17830 }
17831 var error = 0;
17832
17833 if (prime.isEven() ||
17834 !primes.simpleSieve ||
17835 !primes.fermatTest(prime) ||
17836 !millerRabin.test(prime)) {
17837 //not a prime so +1
17838 error += 1;
17839
17840 if (gen === '02' || gen === '05') {
17841 // we'd be able to check the generator
17842 // it would fail so +8
17843 error += 8;
17844 } else {
17845 //we wouldn't be able to test the generator
17846 // so +4
17847 error += 4;
17848 }
17849 primeCache[hex] = error;
17850 return error;
17851 }
17852 if (!millerRabin.test(prime.shrn(1))) {
17853 //not a safe prime
17854 error += 2;
17855 }
17856 var rem;
17857 switch (gen) {
17858 case '02':
17859 if (prime.mod(TWENTYFOUR).cmp(ELEVEN)) {
17860 // unsuidable generator
17861 error += 8;
17862 }
17863 break;
17864 case '05':
17865 rem = prime.mod(TEN);
17866 if (rem.cmp(THREE) && rem.cmp(SEVEN)) {
17867 // prime mod 10 needs to equal 3 or 7
17868 error += 8;
17869 }
17870 break;
17871 default:
17872 error += 4;
17873 }
17874 primeCache[hex] = error;
17875 return error;
17876}
17877
17878function DH(prime, generator, malleable) {
17879 this.setGenerator(generator);
17880 this.__prime = new BN(prime);
17881 this._prime = BN.mont(this.__prime);
17882 this._primeLen = prime.length;
17883 this._pub = undefined;
17884 this._priv = undefined;
17885 this._primeCode = undefined;
17886 if (malleable) {
17887 this.setPublicKey = setPublicKey;
17888 this.setPrivateKey = setPrivateKey;
17889 } else {
17890 this._primeCode = 8;
17891 }
17892}
17893Object.defineProperty(DH.prototype, 'verifyError', {
17894 enumerable: true,
17895 get: function () {
17896 if (typeof this._primeCode !== 'number') {
17897 this._primeCode = checkPrime(this.__prime, this.__gen);
17898 }
17899 return this._primeCode;
17900 }
17901});
17902DH.prototype.generateKeys = function () {
17903 if (!this._priv) {
17904 this._priv = new BN(randomBytes(this._primeLen));
17905 }
17906 this._pub = this._gen.toRed(this._prime).redPow(this._priv).fromRed();
17907 return this.getPublicKey();
17908};
17909
17910DH.prototype.computeSecret = function (other) {
17911 other = new BN(other);
17912 other = other.toRed(this._prime);
17913 var secret = other.redPow(this._priv).fromRed();
17914 var out = new Buffer(secret.toArray());
17915 var prime = this.getPrime();
17916 if (out.length < prime.length) {
17917 var front = new Buffer(prime.length - out.length);
17918 front.fill(0);
17919 out = Buffer.concat([front, out]);
17920 }
17921 return out;
17922};
17923
17924DH.prototype.getPublicKey = function getPublicKey(enc) {
17925 return formatReturnValue(this._pub, enc);
17926};
17927
17928DH.prototype.getPrivateKey = function getPrivateKey(enc) {
17929 return formatReturnValue(this._priv, enc);
17930};
17931
17932DH.prototype.getPrime = function (enc) {
17933 return formatReturnValue(this.__prime, enc);
17934};
17935
17936DH.prototype.getGenerator = function (enc) {
17937 return formatReturnValue(this._gen, enc);
17938};
17939
17940DH.prototype.setGenerator = function (gen, enc) {
17941 enc = enc || 'utf8';
17942 if (!Buffer.isBuffer(gen)) {
17943 gen = new Buffer(gen, enc);
17944 }
17945 this.__gen = gen;
17946 this._gen = new BN(gen);
17947 return this;
17948};
17949
17950function formatReturnValue(bn, enc) {
17951 var buf = new Buffer(bn.toArray());
17952 if (!enc) {
17953 return buf;
17954 } else {
17955 return buf.toString(enc);
17956 }
17957}
17958
17959}).call(this,require("buffer").Buffer)
17960},{"./generatePrime":127,"bn.js":79,"buffer":110,"miller-rabin":166,"randombytes":188}],127:[function(require,module,exports){
17961var randomBytes = require('randombytes');
17962module.exports = findPrime;
17963findPrime.simpleSieve = simpleSieve;
17964findPrime.fermatTest = fermatTest;
17965var BN = require('bn.js');
17966var TWENTYFOUR = new BN(24);
17967var MillerRabin = require('miller-rabin');
17968var millerRabin = new MillerRabin();
17969var ONE = new BN(1);
17970var TWO = new BN(2);
17971var FIVE = new BN(5);
17972var SIXTEEN = new BN(16);
17973var EIGHT = new BN(8);
17974var TEN = new BN(10);
17975var THREE = new BN(3);
17976var SEVEN = new BN(7);
17977var ELEVEN = new BN(11);
17978var FOUR = new BN(4);
17979var TWELVE = new BN(12);
17980var primes = null;
17981
17982function _getPrimes() {
17983 if (primes !== null)
17984 return primes;
17985
17986 var limit = 0x100000;
17987 var res = [];
17988 res[0] = 2;
17989 for (var i = 1, k = 3; k < limit; k += 2) {
17990 var sqrt = Math.ceil(Math.sqrt(k));
17991 for (var j = 0; j < i && res[j] <= sqrt; j++)
17992 if (k % res[j] === 0)
17993 break;
17994
17995 if (i !== j && res[j] <= sqrt)
17996 continue;
17997
17998 res[i++] = k;
17999 }
18000 primes = res;
18001 return res;
18002}
18003
18004function simpleSieve(p) {
18005 var primes = _getPrimes();
18006
18007 for (var i = 0; i < primes.length; i++)
18008 if (p.modn(primes[i]) === 0) {
18009 if (p.cmpn(primes[i]) === 0) {
18010 return true;
18011 } else {
18012 return false;
18013 }
18014 }
18015
18016 return true;
18017}
18018
18019function fermatTest(p) {
18020 var red = BN.mont(p);
18021 return TWO.toRed(red).redPow(p.subn(1)).fromRed().cmpn(1) === 0;
18022}
18023
18024function findPrime(bits, gen) {
18025 if (bits < 16) {
18026 // this is what openssl does
18027 if (gen === 2 || gen === 5) {
18028 return new BN([0x8c, 0x7b]);
18029 } else {
18030 return new BN([0x8c, 0x27]);
18031 }
18032 }
18033 gen = new BN(gen);
18034
18035 var num, n2;
18036
18037 while (true) {
18038 num = new BN(randomBytes(Math.ceil(bits / 8)));
18039 while (num.bitLength() > bits) {
18040 num.ishrn(1);
18041 }
18042 if (num.isEven()) {
18043 num.iadd(ONE);
18044 }
18045 if (!num.testn(1)) {
18046 num.iadd(TWO);
18047 }
18048 if (!gen.cmp(TWO)) {
18049 while (num.mod(TWENTYFOUR).cmp(ELEVEN)) {
18050 num.iadd(FOUR);
18051 }
18052 } else if (!gen.cmp(FIVE)) {
18053 while (num.mod(TEN).cmp(THREE)) {
18054 num.iadd(FOUR);
18055 }
18056 }
18057 n2 = num.shrn(1);
18058 if (simpleSieve(n2) && simpleSieve(num) &&
18059 fermatTest(n2) && fermatTest(num) &&
18060 millerRabin.test(n2) && millerRabin.test(num)) {
18061 return num;
18062 }
18063 }
18064
18065}
18066
18067},{"bn.js":79,"miller-rabin":166,"randombytes":188}],128:[function(require,module,exports){
18068module.exports={
18069 "modp1": {
18070 "gen": "02",
18071 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"
18072 },
18073 "modp2": {
18074 "gen": "02",
18075 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"
18076 },
18077 "modp5": {
18078 "gen": "02",
18079 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"
18080 },
18081 "modp14": {
18082 "gen": "02",
18083 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"
18084 },
18085 "modp15": {
18086 "gen": "02",
18087 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"
18088 },
18089 "modp16": {
18090 "gen": "02",
18091 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"
18092 },
18093 "modp17": {
18094 "gen": "02",
18095 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"
18096 },
18097 "modp18": {
18098 "gen": "02",
18099 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"
18100 }
18101}
18102},{}],129:[function(require,module,exports){
18103'use strict';
18104
18105var elliptic = exports;
18106
18107elliptic.version = require('../package.json').version;
18108elliptic.utils = require('./elliptic/utils');
18109elliptic.rand = require('brorand');
18110elliptic.curve = require('./elliptic/curve');
18111elliptic.curves = require('./elliptic/curves');
18112
18113// Protocols
18114elliptic.ec = require('./elliptic/ec');
18115elliptic.eddsa = require('./elliptic/eddsa');
18116
18117},{"../package.json":144,"./elliptic/curve":132,"./elliptic/curves":135,"./elliptic/ec":136,"./elliptic/eddsa":139,"./elliptic/utils":143,"brorand":80}],130:[function(require,module,exports){
18118'use strict';
18119
18120var BN = require('bn.js');
18121var utils = require('../utils');
18122var getNAF = utils.getNAF;
18123var getJSF = utils.getJSF;
18124var assert = utils.assert;
18125
18126function BaseCurve(type, conf) {
18127 this.type = type;
18128 this.p = new BN(conf.p, 16);
18129
18130 // Use Montgomery, when there is no fast reduction for the prime
18131 this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p);
18132
18133 // Useful for many curves
18134 this.zero = new BN(0).toRed(this.red);
18135 this.one = new BN(1).toRed(this.red);
18136 this.two = new BN(2).toRed(this.red);
18137
18138 // Curve configuration, optional
18139 this.n = conf.n && new BN(conf.n, 16);
18140 this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed);
18141
18142 // Temporary arrays
18143 this._wnafT1 = new Array(4);
18144 this._wnafT2 = new Array(4);
18145 this._wnafT3 = new Array(4);
18146 this._wnafT4 = new Array(4);
18147
18148 // Generalized Greg Maxwell's trick
18149 var adjustCount = this.n && this.p.div(this.n);
18150 if (!adjustCount || adjustCount.cmpn(100) > 0) {
18151 this.redN = null;
18152 } else {
18153 this._maxwellTrick = true;
18154 this.redN = this.n.toRed(this.red);
18155 }
18156}
18157module.exports = BaseCurve;
18158
18159BaseCurve.prototype.point = function point() {
18160 throw new Error('Not implemented');
18161};
18162
18163BaseCurve.prototype.validate = function validate() {
18164 throw new Error('Not implemented');
18165};
18166
18167BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) {
18168 assert(p.precomputed);
18169 var doubles = p._getDoubles();
18170
18171 var naf = getNAF(k, 1);
18172 var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1);
18173 I /= 3;
18174
18175 // Translate into more windowed form
18176 var repr = [];
18177 for (var j = 0; j < naf.length; j += doubles.step) {
18178 var nafW = 0;
18179 for (var k = j + doubles.step - 1; k >= j; k--)
18180 nafW = (nafW << 1) + naf[k];
18181 repr.push(nafW);
18182 }
18183
18184 var a = this.jpoint(null, null, null);
18185 var b = this.jpoint(null, null, null);
18186 for (var i = I; i > 0; i--) {
18187 for (var j = 0; j < repr.length; j++) {
18188 var nafW = repr[j];
18189 if (nafW === i)
18190 b = b.mixedAdd(doubles.points[j]);
18191 else if (nafW === -i)
18192 b = b.mixedAdd(doubles.points[j].neg());
18193 }
18194 a = a.add(b);
18195 }
18196 return a.toP();
18197};
18198
18199BaseCurve.prototype._wnafMul = function _wnafMul(p, k) {
18200 var w = 4;
18201
18202 // Precompute window
18203 var nafPoints = p._getNAFPoints(w);
18204 w = nafPoints.wnd;
18205 var wnd = nafPoints.points;
18206
18207 // Get NAF form
18208 var naf = getNAF(k, w);
18209
18210 // Add `this`*(N+1) for every w-NAF index
18211 var acc = this.jpoint(null, null, null);
18212 for (var i = naf.length - 1; i >= 0; i--) {
18213 // Count zeroes
18214 for (var k = 0; i >= 0 && naf[i] === 0; i--)
18215 k++;
18216 if (i >= 0)
18217 k++;
18218 acc = acc.dblp(k);
18219
18220 if (i < 0)
18221 break;
18222 var z = naf[i];
18223 assert(z !== 0);
18224 if (p.type === 'affine') {
18225 // J +- P
18226 if (z > 0)
18227 acc = acc.mixedAdd(wnd[(z - 1) >> 1]);
18228 else
18229 acc = acc.mixedAdd(wnd[(-z - 1) >> 1].neg());
18230 } else {
18231 // J +- J
18232 if (z > 0)
18233 acc = acc.add(wnd[(z - 1) >> 1]);
18234 else
18235 acc = acc.add(wnd[(-z - 1) >> 1].neg());
18236 }
18237 }
18238 return p.type === 'affine' ? acc.toP() : acc;
18239};
18240
18241BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW,
18242 points,
18243 coeffs,
18244 len,
18245 jacobianResult) {
18246 var wndWidth = this._wnafT1;
18247 var wnd = this._wnafT2;
18248 var naf = this._wnafT3;
18249
18250 // Fill all arrays
18251 var max = 0;
18252 for (var i = 0; i < len; i++) {
18253 var p = points[i];
18254 var nafPoints = p._getNAFPoints(defW);
18255 wndWidth[i] = nafPoints.wnd;
18256 wnd[i] = nafPoints.points;
18257 }
18258
18259 // Comb small window NAFs
18260 for (var i = len - 1; i >= 1; i -= 2) {
18261 var a = i - 1;
18262 var b = i;
18263 if (wndWidth[a] !== 1 || wndWidth[b] !== 1) {
18264 naf[a] = getNAF(coeffs[a], wndWidth[a]);
18265 naf[b] = getNAF(coeffs[b], wndWidth[b]);
18266 max = Math.max(naf[a].length, max);
18267 max = Math.max(naf[b].length, max);
18268 continue;
18269 }
18270
18271 var comb = [
18272 points[a], /* 1 */
18273 null, /* 3 */
18274 null, /* 5 */
18275 points[b] /* 7 */
18276 ];
18277
18278 // Try to avoid Projective points, if possible
18279 if (points[a].y.cmp(points[b].y) === 0) {
18280 comb[1] = points[a].add(points[b]);
18281 comb[2] = points[a].toJ().mixedAdd(points[b].neg());
18282 } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) {
18283 comb[1] = points[a].toJ().mixedAdd(points[b]);
18284 comb[2] = points[a].add(points[b].neg());
18285 } else {
18286 comb[1] = points[a].toJ().mixedAdd(points[b]);
18287 comb[2] = points[a].toJ().mixedAdd(points[b].neg());
18288 }
18289
18290 var index = [
18291 -3, /* -1 -1 */
18292 -1, /* -1 0 */
18293 -5, /* -1 1 */
18294 -7, /* 0 -1 */
18295 0, /* 0 0 */
18296 7, /* 0 1 */
18297 5, /* 1 -1 */
18298 1, /* 1 0 */
18299 3 /* 1 1 */
18300 ];
18301
18302 var jsf = getJSF(coeffs[a], coeffs[b]);
18303 max = Math.max(jsf[0].length, max);
18304 naf[a] = new Array(max);
18305 naf[b] = new Array(max);
18306 for (var j = 0; j < max; j++) {
18307 var ja = jsf[0][j] | 0;
18308 var jb = jsf[1][j] | 0;
18309
18310 naf[a][j] = index[(ja + 1) * 3 + (jb + 1)];
18311 naf[b][j] = 0;
18312 wnd[a] = comb;
18313 }
18314 }
18315
18316 var acc = this.jpoint(null, null, null);
18317 var tmp = this._wnafT4;
18318 for (var i = max; i >= 0; i--) {
18319 var k = 0;
18320
18321 while (i >= 0) {
18322 var zero = true;
18323 for (var j = 0; j < len; j++) {
18324 tmp[j] = naf[j][i] | 0;
18325 if (tmp[j] !== 0)
18326 zero = false;
18327 }
18328 if (!zero)
18329 break;
18330 k++;
18331 i--;
18332 }
18333 if (i >= 0)
18334 k++;
18335 acc = acc.dblp(k);
18336 if (i < 0)
18337 break;
18338
18339 for (var j = 0; j < len; j++) {
18340 var z = tmp[j];
18341 var p;
18342 if (z === 0)
18343 continue;
18344 else if (z > 0)
18345 p = wnd[j][(z - 1) >> 1];
18346 else if (z < 0)
18347 p = wnd[j][(-z - 1) >> 1].neg();
18348
18349 if (p.type === 'affine')
18350 acc = acc.mixedAdd(p);
18351 else
18352 acc = acc.add(p);
18353 }
18354 }
18355 // Zeroify references
18356 for (var i = 0; i < len; i++)
18357 wnd[i] = null;
18358
18359 if (jacobianResult)
18360 return acc;
18361 else
18362 return acc.toP();
18363};
18364
18365function BasePoint(curve, type) {
18366 this.curve = curve;
18367 this.type = type;
18368 this.precomputed = null;
18369}
18370BaseCurve.BasePoint = BasePoint;
18371
18372BasePoint.prototype.eq = function eq(/*other*/) {
18373 throw new Error('Not implemented');
18374};
18375
18376BasePoint.prototype.validate = function validate() {
18377 return this.curve.validate(this);
18378};
18379
18380BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
18381 bytes = utils.toArray(bytes, enc);
18382
18383 var len = this.p.byteLength();
18384
18385 // uncompressed, hybrid-odd, hybrid-even
18386 if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) &&
18387 bytes.length - 1 === 2 * len) {
18388 if (bytes[0] === 0x06)
18389 assert(bytes[bytes.length - 1] % 2 === 0);
18390 else if (bytes[0] === 0x07)
18391 assert(bytes[bytes.length - 1] % 2 === 1);
18392
18393 var res = this.point(bytes.slice(1, 1 + len),
18394 bytes.slice(1 + len, 1 + 2 * len));
18395
18396 return res;
18397 } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) &&
18398 bytes.length - 1 === len) {
18399 return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03);
18400 }
18401 throw new Error('Unknown point format');
18402};
18403
18404BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) {
18405 return this.encode(enc, true);
18406};
18407
18408BasePoint.prototype._encode = function _encode(compact) {
18409 var len = this.curve.p.byteLength();
18410 var x = this.getX().toArray('be', len);
18411
18412 if (compact)
18413 return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x);
18414
18415 return [ 0x04 ].concat(x, this.getY().toArray('be', len)) ;
18416};
18417
18418BasePoint.prototype.encode = function encode(enc, compact) {
18419 return utils.encode(this._encode(compact), enc);
18420};
18421
18422BasePoint.prototype.precompute = function precompute(power) {
18423 if (this.precomputed)
18424 return this;
18425
18426 var precomputed = {
18427 doubles: null,
18428 naf: null,
18429 beta: null
18430 };
18431 precomputed.naf = this._getNAFPoints(8);
18432 precomputed.doubles = this._getDoubles(4, power);
18433 precomputed.beta = this._getBeta();
18434 this.precomputed = precomputed;
18435
18436 return this;
18437};
18438
18439BasePoint.prototype._hasDoubles = function _hasDoubles(k) {
18440 if (!this.precomputed)
18441 return false;
18442
18443 var doubles = this.precomputed.doubles;
18444 if (!doubles)
18445 return false;
18446
18447 return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step);
18448};
18449
18450BasePoint.prototype._getDoubles = function _getDoubles(step, power) {
18451 if (this.precomputed && this.precomputed.doubles)
18452 return this.precomputed.doubles;
18453
18454 var doubles = [ this ];
18455 var acc = this;
18456 for (var i = 0; i < power; i += step) {
18457 for (var j = 0; j < step; j++)
18458 acc = acc.dbl();
18459 doubles.push(acc);
18460 }
18461 return {
18462 step: step,
18463 points: doubles
18464 };
18465};
18466
18467BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) {
18468 if (this.precomputed && this.precomputed.naf)
18469 return this.precomputed.naf;
18470
18471 var res = [ this ];
18472 var max = (1 << wnd) - 1;
18473 var dbl = max === 1 ? null : this.dbl();
18474 for (var i = 1; i < max; i++)
18475 res[i] = res[i - 1].add(dbl);
18476 return {
18477 wnd: wnd,
18478 points: res
18479 };
18480};
18481
18482BasePoint.prototype._getBeta = function _getBeta() {
18483 return null;
18484};
18485
18486BasePoint.prototype.dblp = function dblp(k) {
18487 var r = this;
18488 for (var i = 0; i < k; i++)
18489 r = r.dbl();
18490 return r;
18491};
18492
18493},{"../utils":143,"bn.js":79}],131:[function(require,module,exports){
18494'use strict';
18495
18496var utils = require('../utils');
18497var BN = require('bn.js');
18498var inherits = require('inherits');
18499var Base = require('./base');
18500
18501var assert = utils.assert;
18502
18503function EdwardsCurve(conf) {
18504 // NOTE: Important as we are creating point in Base.call()
18505 this.twisted = (conf.a | 0) !== 1;
18506 this.mOneA = this.twisted && (conf.a | 0) === -1;
18507 this.extended = this.mOneA;
18508
18509 Base.call(this, 'edwards', conf);
18510
18511 this.a = new BN(conf.a, 16).umod(this.red.m);
18512 this.a = this.a.toRed(this.red);
18513 this.c = new BN(conf.c, 16).toRed(this.red);
18514 this.c2 = this.c.redSqr();
18515 this.d = new BN(conf.d, 16).toRed(this.red);
18516 this.dd = this.d.redAdd(this.d);
18517
18518 assert(!this.twisted || this.c.fromRed().cmpn(1) === 0);
18519 this.oneC = (conf.c | 0) === 1;
18520}
18521inherits(EdwardsCurve, Base);
18522module.exports = EdwardsCurve;
18523
18524EdwardsCurve.prototype._mulA = function _mulA(num) {
18525 if (this.mOneA)
18526 return num.redNeg();
18527 else
18528 return this.a.redMul(num);
18529};
18530
18531EdwardsCurve.prototype._mulC = function _mulC(num) {
18532 if (this.oneC)
18533 return num;
18534 else
18535 return this.c.redMul(num);
18536};
18537
18538// Just for compatibility with Short curve
18539EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) {
18540 return this.point(x, y, z, t);
18541};
18542
18543EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) {
18544 x = new BN(x, 16);
18545 if (!x.red)
18546 x = x.toRed(this.red);
18547
18548 var x2 = x.redSqr();
18549 var rhs = this.c2.redSub(this.a.redMul(x2));
18550 var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x2));
18551
18552 var y2 = rhs.redMul(lhs.redInvm());
18553 var y = y2.redSqrt();
18554 if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
18555 throw new Error('invalid point');
18556
18557 var isOdd = y.fromRed().isOdd();
18558 if (odd && !isOdd || !odd && isOdd)
18559 y = y.redNeg();
18560
18561 return this.point(x, y);
18562};
18563
18564EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) {
18565 y = new BN(y, 16);
18566 if (!y.red)
18567 y = y.toRed(this.red);
18568
18569 // x^2 = (y^2 - c^2) / (c^2 d y^2 - a)
18570 var y2 = y.redSqr();
18571 var lhs = y2.redSub(this.c2);
18572 var rhs = y2.redMul(this.d).redMul(this.c2).redSub(this.a);
18573 var x2 = lhs.redMul(rhs.redInvm());
18574
18575 if (x2.cmp(this.zero) === 0) {
18576 if (odd)
18577 throw new Error('invalid point');
18578 else
18579 return this.point(this.zero, y);
18580 }
18581
18582 var x = x2.redSqrt();
18583 if (x.redSqr().redSub(x2).cmp(this.zero) !== 0)
18584 throw new Error('invalid point');
18585
18586 if (x.fromRed().isOdd() !== odd)
18587 x = x.redNeg();
18588
18589 return this.point(x, y);
18590};
18591
18592EdwardsCurve.prototype.validate = function validate(point) {
18593 if (point.isInfinity())
18594 return true;
18595
18596 // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2)
18597 point.normalize();
18598
18599 var x2 = point.x.redSqr();
18600 var y2 = point.y.redSqr();
18601 var lhs = x2.redMul(this.a).redAdd(y2);
18602 var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2)));
18603
18604 return lhs.cmp(rhs) === 0;
18605};
18606
18607function Point(curve, x, y, z, t) {
18608 Base.BasePoint.call(this, curve, 'projective');
18609 if (x === null && y === null && z === null) {
18610 this.x = this.curve.zero;
18611 this.y = this.curve.one;
18612 this.z = this.curve.one;
18613 this.t = this.curve.zero;
18614 this.zOne = true;
18615 } else {
18616 this.x = new BN(x, 16);
18617 this.y = new BN(y, 16);
18618 this.z = z ? new BN(z, 16) : this.curve.one;
18619 this.t = t && new BN(t, 16);
18620 if (!this.x.red)
18621 this.x = this.x.toRed(this.curve.red);
18622 if (!this.y.red)
18623 this.y = this.y.toRed(this.curve.red);
18624 if (!this.z.red)
18625 this.z = this.z.toRed(this.curve.red);
18626 if (this.t && !this.t.red)
18627 this.t = this.t.toRed(this.curve.red);
18628 this.zOne = this.z === this.curve.one;
18629
18630 // Use extended coordinates
18631 if (this.curve.extended && !this.t) {
18632 this.t = this.x.redMul(this.y);
18633 if (!this.zOne)
18634 this.t = this.t.redMul(this.z.redInvm());
18635 }
18636 }
18637}
18638inherits(Point, Base.BasePoint);
18639
18640EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
18641 return Point.fromJSON(this, obj);
18642};
18643
18644EdwardsCurve.prototype.point = function point(x, y, z, t) {
18645 return new Point(this, x, y, z, t);
18646};
18647
18648Point.fromJSON = function fromJSON(curve, obj) {
18649 return new Point(curve, obj[0], obj[1], obj[2]);
18650};
18651
18652Point.prototype.inspect = function inspect() {
18653 if (this.isInfinity())
18654 return '<EC Point Infinity>';
18655 return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
18656 ' y: ' + this.y.fromRed().toString(16, 2) +
18657 ' z: ' + this.z.fromRed().toString(16, 2) + '>';
18658};
18659
18660Point.prototype.isInfinity = function isInfinity() {
18661 // XXX This code assumes that zero is always zero in red
18662 return this.x.cmpn(0) === 0 &&
18663 (this.y.cmp(this.z) === 0 ||
18664 (this.zOne && this.y.cmp(this.curve.c) === 0));
18665};
18666
18667Point.prototype._extDbl = function _extDbl() {
18668 // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
18669 // #doubling-dbl-2008-hwcd
18670 // 4M + 4S
18671
18672 // A = X1^2
18673 var a = this.x.redSqr();
18674 // B = Y1^2
18675 var b = this.y.redSqr();
18676 // C = 2 * Z1^2
18677 var c = this.z.redSqr();
18678 c = c.redIAdd(c);
18679 // D = a * A
18680 var d = this.curve._mulA(a);
18681 // E = (X1 + Y1)^2 - A - B
18682 var e = this.x.redAdd(this.y).redSqr().redISub(a).redISub(b);
18683 // G = D + B
18684 var g = d.redAdd(b);
18685 // F = G - C
18686 var f = g.redSub(c);
18687 // H = D - B
18688 var h = d.redSub(b);
18689 // X3 = E * F
18690 var nx = e.redMul(f);
18691 // Y3 = G * H
18692 var ny = g.redMul(h);
18693 // T3 = E * H
18694 var nt = e.redMul(h);
18695 // Z3 = F * G
18696 var nz = f.redMul(g);
18697 return this.curve.point(nx, ny, nz, nt);
18698};
18699
18700Point.prototype._projDbl = function _projDbl() {
18701 // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
18702 // #doubling-dbl-2008-bbjlp
18703 // #doubling-dbl-2007-bl
18704 // and others
18705 // Generally 3M + 4S or 2M + 4S
18706
18707 // B = (X1 + Y1)^2
18708 var b = this.x.redAdd(this.y).redSqr();
18709 // C = X1^2
18710 var c = this.x.redSqr();
18711 // D = Y1^2
18712 var d = this.y.redSqr();
18713
18714 var nx;
18715 var ny;
18716 var nz;
18717 if (this.curve.twisted) {
18718 // E = a * C
18719 var e = this.curve._mulA(c);
18720 // F = E + D
18721 var f = e.redAdd(d);
18722 if (this.zOne) {
18723 // X3 = (B - C - D) * (F - 2)
18724 nx = b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two));
18725 // Y3 = F * (E - D)
18726 ny = f.redMul(e.redSub(d));
18727 // Z3 = F^2 - 2 * F
18728 nz = f.redSqr().redSub(f).redSub(f);
18729 } else {
18730 // H = Z1^2
18731 var h = this.z.redSqr();
18732 // J = F - 2 * H
18733 var j = f.redSub(h).redISub(h);
18734 // X3 = (B-C-D)*J
18735 nx = b.redSub(c).redISub(d).redMul(j);
18736 // Y3 = F * (E - D)
18737 ny = f.redMul(e.redSub(d));
18738 // Z3 = F * J
18739 nz = f.redMul(j);
18740 }
18741 } else {
18742 // E = C + D
18743 var e = c.redAdd(d);
18744 // H = (c * Z1)^2
18745 var h = this.curve._mulC(this.z).redSqr();
18746 // J = E - 2 * H
18747 var j = e.redSub(h).redSub(h);
18748 // X3 = c * (B - E) * J
18749 nx = this.curve._mulC(b.redISub(e)).redMul(j);
18750 // Y3 = c * E * (C - D)
18751 ny = this.curve._mulC(e).redMul(c.redISub(d));
18752 // Z3 = E * J
18753 nz = e.redMul(j);
18754 }
18755 return this.curve.point(nx, ny, nz);
18756};
18757
18758Point.prototype.dbl = function dbl() {
18759 if (this.isInfinity())
18760 return this;
18761
18762 // Double in extended coordinates
18763 if (this.curve.extended)
18764 return this._extDbl();
18765 else
18766 return this._projDbl();
18767};
18768
18769Point.prototype._extAdd = function _extAdd(p) {
18770 // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
18771 // #addition-add-2008-hwcd-3
18772 // 8M
18773
18774 // A = (Y1 - X1) * (Y2 - X2)
18775 var a = this.y.redSub(this.x).redMul(p.y.redSub(p.x));
18776 // B = (Y1 + X1) * (Y2 + X2)
18777 var b = this.y.redAdd(this.x).redMul(p.y.redAdd(p.x));
18778 // C = T1 * k * T2
18779 var c = this.t.redMul(this.curve.dd).redMul(p.t);
18780 // D = Z1 * 2 * Z2
18781 var d = this.z.redMul(p.z.redAdd(p.z));
18782 // E = B - A
18783 var e = b.redSub(a);
18784 // F = D - C
18785 var f = d.redSub(c);
18786 // G = D + C
18787 var g = d.redAdd(c);
18788 // H = B + A
18789 var h = b.redAdd(a);
18790 // X3 = E * F
18791 var nx = e.redMul(f);
18792 // Y3 = G * H
18793 var ny = g.redMul(h);
18794 // T3 = E * H
18795 var nt = e.redMul(h);
18796 // Z3 = F * G
18797 var nz = f.redMul(g);
18798 return this.curve.point(nx, ny, nz, nt);
18799};
18800
18801Point.prototype._projAdd = function _projAdd(p) {
18802 // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
18803 // #addition-add-2008-bbjlp
18804 // #addition-add-2007-bl
18805 // 10M + 1S
18806
18807 // A = Z1 * Z2
18808 var a = this.z.redMul(p.z);
18809 // B = A^2
18810 var b = a.redSqr();
18811 // C = X1 * X2
18812 var c = this.x.redMul(p.x);
18813 // D = Y1 * Y2
18814 var d = this.y.redMul(p.y);
18815 // E = d * C * D
18816 var e = this.curve.d.redMul(c).redMul(d);
18817 // F = B - E
18818 var f = b.redSub(e);
18819 // G = B + E
18820 var g = b.redAdd(e);
18821 // X3 = A * F * ((X1 + Y1) * (X2 + Y2) - C - D)
18822 var tmp = this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d);
18823 var nx = a.redMul(f).redMul(tmp);
18824 var ny;
18825 var nz;
18826 if (this.curve.twisted) {
18827 // Y3 = A * G * (D - a * C)
18828 ny = a.redMul(g).redMul(d.redSub(this.curve._mulA(c)));
18829 // Z3 = F * G
18830 nz = f.redMul(g);
18831 } else {
18832 // Y3 = A * G * (D - C)
18833 ny = a.redMul(g).redMul(d.redSub(c));
18834 // Z3 = c * F * G
18835 nz = this.curve._mulC(f).redMul(g);
18836 }
18837 return this.curve.point(nx, ny, nz);
18838};
18839
18840Point.prototype.add = function add(p) {
18841 if (this.isInfinity())
18842 return p;
18843 if (p.isInfinity())
18844 return this;
18845
18846 if (this.curve.extended)
18847 return this._extAdd(p);
18848 else
18849 return this._projAdd(p);
18850};
18851
18852Point.prototype.mul = function mul(k) {
18853 if (this._hasDoubles(k))
18854 return this.curve._fixedNafMul(this, k);
18855 else
18856 return this.curve._wnafMul(this, k);
18857};
18858
18859Point.prototype.mulAdd = function mulAdd(k1, p, k2) {
18860 return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false);
18861};
18862
18863Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) {
18864 return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true);
18865};
18866
18867Point.prototype.normalize = function normalize() {
18868 if (this.zOne)
18869 return this;
18870
18871 // Normalize coordinates
18872 var zi = this.z.redInvm();
18873 this.x = this.x.redMul(zi);
18874 this.y = this.y.redMul(zi);
18875 if (this.t)
18876 this.t = this.t.redMul(zi);
18877 this.z = this.curve.one;
18878 this.zOne = true;
18879 return this;
18880};
18881
18882Point.prototype.neg = function neg() {
18883 return this.curve.point(this.x.redNeg(),
18884 this.y,
18885 this.z,
18886 this.t && this.t.redNeg());
18887};
18888
18889Point.prototype.getX = function getX() {
18890 this.normalize();
18891 return this.x.fromRed();
18892};
18893
18894Point.prototype.getY = function getY() {
18895 this.normalize();
18896 return this.y.fromRed();
18897};
18898
18899Point.prototype.eq = function eq(other) {
18900 return this === other ||
18901 this.getX().cmp(other.getX()) === 0 &&
18902 this.getY().cmp(other.getY()) === 0;
18903};
18904
18905Point.prototype.eqXToP = function eqXToP(x) {
18906 var rx = x.toRed(this.curve.red).redMul(this.z);
18907 if (this.x.cmp(rx) === 0)
18908 return true;
18909
18910 var xc = x.clone();
18911 var t = this.curve.redN.redMul(this.z);
18912 for (;;) {
18913 xc.iadd(this.curve.n);
18914 if (xc.cmp(this.curve.p) >= 0)
18915 return false;
18916
18917 rx.redIAdd(t);
18918 if (this.x.cmp(rx) === 0)
18919 return true;
18920 }
18921};
18922
18923// Compatibility with BaseCurve
18924Point.prototype.toP = Point.prototype.normalize;
18925Point.prototype.mixedAdd = Point.prototype.add;
18926
18927},{"../utils":143,"./base":130,"bn.js":79,"inherits":162}],132:[function(require,module,exports){
18928'use strict';
18929
18930var curve = exports;
18931
18932curve.base = require('./base');
18933curve.short = require('./short');
18934curve.mont = require('./mont');
18935curve.edwards = require('./edwards');
18936
18937},{"./base":130,"./edwards":131,"./mont":133,"./short":134}],133:[function(require,module,exports){
18938'use strict';
18939
18940var BN = require('bn.js');
18941var inherits = require('inherits');
18942var Base = require('./base');
18943
18944var utils = require('../utils');
18945
18946function MontCurve(conf) {
18947 Base.call(this, 'mont', conf);
18948
18949 this.a = new BN(conf.a, 16).toRed(this.red);
18950 this.b = new BN(conf.b, 16).toRed(this.red);
18951 this.i4 = new BN(4).toRed(this.red).redInvm();
18952 this.two = new BN(2).toRed(this.red);
18953 this.a24 = this.i4.redMul(this.a.redAdd(this.two));
18954}
18955inherits(MontCurve, Base);
18956module.exports = MontCurve;
18957
18958MontCurve.prototype.validate = function validate(point) {
18959 var x = point.normalize().x;
18960 var x2 = x.redSqr();
18961 var rhs = x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x);
18962 var y = rhs.redSqrt();
18963
18964 return y.redSqr().cmp(rhs) === 0;
18965};
18966
18967function Point(curve, x, z) {
18968 Base.BasePoint.call(this, curve, 'projective');
18969 if (x === null && z === null) {
18970 this.x = this.curve.one;
18971 this.z = this.curve.zero;
18972 } else {
18973 this.x = new BN(x, 16);
18974 this.z = new BN(z, 16);
18975 if (!this.x.red)
18976 this.x = this.x.toRed(this.curve.red);
18977 if (!this.z.red)
18978 this.z = this.z.toRed(this.curve.red);
18979 }
18980}
18981inherits(Point, Base.BasePoint);
18982
18983MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
18984 return this.point(utils.toArray(bytes, enc), 1);
18985};
18986
18987MontCurve.prototype.point = function point(x, z) {
18988 return new Point(this, x, z);
18989};
18990
18991MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
18992 return Point.fromJSON(this, obj);
18993};
18994
18995Point.prototype.precompute = function precompute() {
18996 // No-op
18997};
18998
18999Point.prototype._encode = function _encode() {
19000 return this.getX().toArray('be', this.curve.p.byteLength());
19001};
19002
19003Point.fromJSON = function fromJSON(curve, obj) {
19004 return new Point(curve, obj[0], obj[1] || curve.one);
19005};
19006
19007Point.prototype.inspect = function inspect() {
19008 if (this.isInfinity())
19009 return '<EC Point Infinity>';
19010 return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
19011 ' z: ' + this.z.fromRed().toString(16, 2) + '>';
19012};
19013
19014Point.prototype.isInfinity = function isInfinity() {
19015 // XXX This code assumes that zero is always zero in red
19016 return this.z.cmpn(0) === 0;
19017};
19018
19019Point.prototype.dbl = function dbl() {
19020 // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3
19021 // 2M + 2S + 4A
19022
19023 // A = X1 + Z1
19024 var a = this.x.redAdd(this.z);
19025 // AA = A^2
19026 var aa = a.redSqr();
19027 // B = X1 - Z1
19028 var b = this.x.redSub(this.z);
19029 // BB = B^2
19030 var bb = b.redSqr();
19031 // C = AA - BB
19032 var c = aa.redSub(bb);
19033 // X3 = AA * BB
19034 var nx = aa.redMul(bb);
19035 // Z3 = C * (BB + A24 * C)
19036 var nz = c.redMul(bb.redAdd(this.curve.a24.redMul(c)));
19037 return this.curve.point(nx, nz);
19038};
19039
19040Point.prototype.add = function add() {
19041 throw new Error('Not supported on Montgomery curve');
19042};
19043
19044Point.prototype.diffAdd = function diffAdd(p, diff) {
19045 // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3
19046 // 4M + 2S + 6A
19047
19048 // A = X2 + Z2
19049 var a = this.x.redAdd(this.z);
19050 // B = X2 - Z2
19051 var b = this.x.redSub(this.z);
19052 // C = X3 + Z3
19053 var c = p.x.redAdd(p.z);
19054 // D = X3 - Z3
19055 var d = p.x.redSub(p.z);
19056 // DA = D * A
19057 var da = d.redMul(a);
19058 // CB = C * B
19059 var cb = c.redMul(b);
19060 // X5 = Z1 * (DA + CB)^2
19061 var nx = diff.z.redMul(da.redAdd(cb).redSqr());
19062 // Z5 = X1 * (DA - CB)^2
19063 var nz = diff.x.redMul(da.redISub(cb).redSqr());
19064 return this.curve.point(nx, nz);
19065};
19066
19067Point.prototype.mul = function mul(k) {
19068 var t = k.clone();
19069 var a = this; // (N / 2) * Q + Q
19070 var b = this.curve.point(null, null); // (N / 2) * Q
19071 var c = this; // Q
19072
19073 for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1))
19074 bits.push(t.andln(1));
19075
19076 for (var i = bits.length - 1; i >= 0; i--) {
19077 if (bits[i] === 0) {
19078 // N * Q + Q = ((N / 2) * Q + Q)) + (N / 2) * Q
19079 a = a.diffAdd(b, c);
19080 // N * Q = 2 * ((N / 2) * Q + Q))
19081 b = b.dbl();
19082 } else {
19083 // N * Q = ((N / 2) * Q + Q) + ((N / 2) * Q)
19084 b = a.diffAdd(b, c);
19085 // N * Q + Q = 2 * ((N / 2) * Q + Q)
19086 a = a.dbl();
19087 }
19088 }
19089 return b;
19090};
19091
19092Point.prototype.mulAdd = function mulAdd() {
19093 throw new Error('Not supported on Montgomery curve');
19094};
19095
19096Point.prototype.jumlAdd = function jumlAdd() {
19097 throw new Error('Not supported on Montgomery curve');
19098};
19099
19100Point.prototype.eq = function eq(other) {
19101 return this.getX().cmp(other.getX()) === 0;
19102};
19103
19104Point.prototype.normalize = function normalize() {
19105 this.x = this.x.redMul(this.z.redInvm());
19106 this.z = this.curve.one;
19107 return this;
19108};
19109
19110Point.prototype.getX = function getX() {
19111 // Normalize coordinates
19112 this.normalize();
19113
19114 return this.x.fromRed();
19115};
19116
19117},{"../utils":143,"./base":130,"bn.js":79,"inherits":162}],134:[function(require,module,exports){
19118'use strict';
19119
19120var utils = require('../utils');
19121var BN = require('bn.js');
19122var inherits = require('inherits');
19123var Base = require('./base');
19124
19125var assert = utils.assert;
19126
19127function ShortCurve(conf) {
19128 Base.call(this, 'short', conf);
19129
19130 this.a = new BN(conf.a, 16).toRed(this.red);
19131 this.b = new BN(conf.b, 16).toRed(this.red);
19132 this.tinv = this.two.redInvm();
19133
19134 this.zeroA = this.a.fromRed().cmpn(0) === 0;
19135 this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0;
19136
19137 // If the curve is endomorphic, precalculate beta and lambda
19138 this.endo = this._getEndomorphism(conf);
19139 this._endoWnafT1 = new Array(4);
19140 this._endoWnafT2 = new Array(4);
19141}
19142inherits(ShortCurve, Base);
19143module.exports = ShortCurve;
19144
19145ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) {
19146 // No efficient endomorphism
19147 if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)
19148 return;
19149
19150 // Compute beta and lambda, that lambda * P = (beta * Px; Py)
19151 var beta;
19152 var lambda;
19153 if (conf.beta) {
19154 beta = new BN(conf.beta, 16).toRed(this.red);
19155 } else {
19156 var betas = this._getEndoRoots(this.p);
19157 // Choose the smallest beta
19158 beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1];
19159 beta = beta.toRed(this.red);
19160 }
19161 if (conf.lambda) {
19162 lambda = new BN(conf.lambda, 16);
19163 } else {
19164 // Choose the lambda that is matching selected beta
19165 var lambdas = this._getEndoRoots(this.n);
19166 if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) {
19167 lambda = lambdas[0];
19168 } else {
19169 lambda = lambdas[1];
19170 assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0);
19171 }
19172 }
19173
19174 // Get basis vectors, used for balanced length-two representation
19175 var basis;
19176 if (conf.basis) {
19177 basis = conf.basis.map(function(vec) {
19178 return {
19179 a: new BN(vec.a, 16),
19180 b: new BN(vec.b, 16)
19181 };
19182 });
19183 } else {
19184 basis = this._getEndoBasis(lambda);
19185 }
19186
19187 return {
19188 beta: beta,
19189 lambda: lambda,
19190 basis: basis
19191 };
19192};
19193
19194ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) {
19195 // Find roots of for x^2 + x + 1 in F
19196 // Root = (-1 +- Sqrt(-3)) / 2
19197 //
19198 var red = num === this.p ? this.red : BN.mont(num);
19199 var tinv = new BN(2).toRed(red).redInvm();
19200 var ntinv = tinv.redNeg();
19201
19202 var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv);
19203
19204 var l1 = ntinv.redAdd(s).fromRed();
19205 var l2 = ntinv.redSub(s).fromRed();
19206 return [ l1, l2 ];
19207};
19208
19209ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) {
19210 // aprxSqrt >= sqrt(this.n)
19211 var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2));
19212
19213 // 3.74
19214 // Run EGCD, until r(L + 1) < aprxSqrt
19215 var u = lambda;
19216 var v = this.n.clone();
19217 var x1 = new BN(1);
19218 var y1 = new BN(0);
19219 var x2 = new BN(0);
19220 var y2 = new BN(1);
19221
19222 // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n)
19223 var a0;
19224 var b0;
19225 // First vector
19226 var a1;
19227 var b1;
19228 // Second vector
19229 var a2;
19230 var b2;
19231
19232 var prevR;
19233 var i = 0;
19234 var r;
19235 var x;
19236 while (u.cmpn(0) !== 0) {
19237 var q = v.div(u);
19238 r = v.sub(q.mul(u));
19239 x = x2.sub(q.mul(x1));
19240 var y = y2.sub(q.mul(y1));
19241
19242 if (!a1 && r.cmp(aprxSqrt) < 0) {
19243 a0 = prevR.neg();
19244 b0 = x1;
19245 a1 = r.neg();
19246 b1 = x;
19247 } else if (a1 && ++i === 2) {
19248 break;
19249 }
19250 prevR = r;
19251
19252 v = u;
19253 u = r;
19254 x2 = x1;
19255 x1 = x;
19256 y2 = y1;
19257 y1 = y;
19258 }
19259 a2 = r.neg();
19260 b2 = x;
19261
19262 var len1 = a1.sqr().add(b1.sqr());
19263 var len2 = a2.sqr().add(b2.sqr());
19264 if (len2.cmp(len1) >= 0) {
19265 a2 = a0;
19266 b2 = b0;
19267 }
19268
19269 // Normalize signs
19270 if (a1.negative) {
19271 a1 = a1.neg();
19272 b1 = b1.neg();
19273 }
19274 if (a2.negative) {
19275 a2 = a2.neg();
19276 b2 = b2.neg();
19277 }
19278
19279 return [
19280 { a: a1, b: b1 },
19281 { a: a2, b: b2 }
19282 ];
19283};
19284
19285ShortCurve.prototype._endoSplit = function _endoSplit(k) {
19286 var basis = this.endo.basis;
19287 var v1 = basis[0];
19288 var v2 = basis[1];
19289
19290 var c1 = v2.b.mul(k).divRound(this.n);
19291 var c2 = v1.b.neg().mul(k).divRound(this.n);
19292
19293 var p1 = c1.mul(v1.a);
19294 var p2 = c2.mul(v2.a);
19295 var q1 = c1.mul(v1.b);
19296 var q2 = c2.mul(v2.b);
19297
19298 // Calculate answer
19299 var k1 = k.sub(p1).sub(p2);
19300 var k2 = q1.add(q2).neg();
19301 return { k1: k1, k2: k2 };
19302};
19303
19304ShortCurve.prototype.pointFromX = function pointFromX(x, odd) {
19305 x = new BN(x, 16);
19306 if (!x.red)
19307 x = x.toRed(this.red);
19308
19309 var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b);
19310 var y = y2.redSqrt();
19311 if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
19312 throw new Error('invalid point');
19313
19314 // XXX Is there any way to tell if the number is odd without converting it
19315 // to non-red form?
19316 var isOdd = y.fromRed().isOdd();
19317 if (odd && !isOdd || !odd && isOdd)
19318 y = y.redNeg();
19319
19320 return this.point(x, y);
19321};
19322
19323ShortCurve.prototype.validate = function validate(point) {
19324 if (point.inf)
19325 return true;
19326
19327 var x = point.x;
19328 var y = point.y;
19329
19330 var ax = this.a.redMul(x);
19331 var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b);
19332 return y.redSqr().redISub(rhs).cmpn(0) === 0;
19333};
19334
19335ShortCurve.prototype._endoWnafMulAdd =
19336 function _endoWnafMulAdd(points, coeffs, jacobianResult) {
19337 var npoints = this._endoWnafT1;
19338 var ncoeffs = this._endoWnafT2;
19339 for (var i = 0; i < points.length; i++) {
19340 var split = this._endoSplit(coeffs[i]);
19341 var p = points[i];
19342 var beta = p._getBeta();
19343
19344 if (split.k1.negative) {
19345 split.k1.ineg();
19346 p = p.neg(true);
19347 }
19348 if (split.k2.negative) {
19349 split.k2.ineg();
19350 beta = beta.neg(true);
19351 }
19352
19353 npoints[i * 2] = p;
19354 npoints[i * 2 + 1] = beta;
19355 ncoeffs[i * 2] = split.k1;
19356 ncoeffs[i * 2 + 1] = split.k2;
19357 }
19358 var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult);
19359
19360 // Clean-up references to points and coefficients
19361 for (var j = 0; j < i * 2; j++) {
19362 npoints[j] = null;
19363 ncoeffs[j] = null;
19364 }
19365 return res;
19366};
19367
19368function Point(curve, x, y, isRed) {
19369 Base.BasePoint.call(this, curve, 'affine');
19370 if (x === null && y === null) {
19371 this.x = null;
19372 this.y = null;
19373 this.inf = true;
19374 } else {
19375 this.x = new BN(x, 16);
19376 this.y = new BN(y, 16);
19377 // Force redgomery representation when loading from JSON
19378 if (isRed) {
19379 this.x.forceRed(this.curve.red);
19380 this.y.forceRed(this.curve.red);
19381 }
19382 if (!this.x.red)
19383 this.x = this.x.toRed(this.curve.red);
19384 if (!this.y.red)
19385 this.y = this.y.toRed(this.curve.red);
19386 this.inf = false;
19387 }
19388}
19389inherits(Point, Base.BasePoint);
19390
19391ShortCurve.prototype.point = function point(x, y, isRed) {
19392 return new Point(this, x, y, isRed);
19393};
19394
19395ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) {
19396 return Point.fromJSON(this, obj, red);
19397};
19398
19399Point.prototype._getBeta = function _getBeta() {
19400 if (!this.curve.endo)
19401 return;
19402
19403 var pre = this.precomputed;
19404 if (pre && pre.beta)
19405 return pre.beta;
19406
19407 var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y);
19408 if (pre) {
19409 var curve = this.curve;
19410 var endoMul = function(p) {
19411 return curve.point(p.x.redMul(curve.endo.beta), p.y);
19412 };
19413 pre.beta = beta;
19414 beta.precomputed = {
19415 beta: null,
19416 naf: pre.naf && {
19417 wnd: pre.naf.wnd,
19418 points: pre.naf.points.map(endoMul)
19419 },
19420 doubles: pre.doubles && {
19421 step: pre.doubles.step,
19422 points: pre.doubles.points.map(endoMul)
19423 }
19424 };
19425 }
19426 return beta;
19427};
19428
19429Point.prototype.toJSON = function toJSON() {
19430 if (!this.precomputed)
19431 return [ this.x, this.y ];
19432
19433 return [ this.x, this.y, this.precomputed && {
19434 doubles: this.precomputed.doubles && {
19435 step: this.precomputed.doubles.step,
19436 points: this.precomputed.doubles.points.slice(1)
19437 },
19438 naf: this.precomputed.naf && {
19439 wnd: this.precomputed.naf.wnd,
19440 points: this.precomputed.naf.points.slice(1)
19441 }
19442 } ];
19443};
19444
19445Point.fromJSON = function fromJSON(curve, obj, red) {
19446 if (typeof obj === 'string')
19447 obj = JSON.parse(obj);
19448 var res = curve.point(obj[0], obj[1], red);
19449 if (!obj[2])
19450 return res;
19451
19452 function obj2point(obj) {
19453 return curve.point(obj[0], obj[1], red);
19454 }
19455
19456 var pre = obj[2];
19457 res.precomputed = {
19458 beta: null,
19459 doubles: pre.doubles && {
19460 step: pre.doubles.step,
19461 points: [ res ].concat(pre.doubles.points.map(obj2point))
19462 },
19463 naf: pre.naf && {
19464 wnd: pre.naf.wnd,
19465 points: [ res ].concat(pre.naf.points.map(obj2point))
19466 }
19467 };
19468 return res;
19469};
19470
19471Point.prototype.inspect = function inspect() {
19472 if (this.isInfinity())
19473 return '<EC Point Infinity>';
19474 return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
19475 ' y: ' + this.y.fromRed().toString(16, 2) + '>';
19476};
19477
19478Point.prototype.isInfinity = function isInfinity() {
19479 return this.inf;
19480};
19481
19482Point.prototype.add = function add(p) {
19483 // O + P = P
19484 if (this.inf)
19485 return p;
19486
19487 // P + O = P
19488 if (p.inf)
19489 return this;
19490
19491 // P + P = 2P
19492 if (this.eq(p))
19493 return this.dbl();
19494
19495 // P + (-P) = O
19496 if (this.neg().eq(p))
19497 return this.curve.point(null, null);
19498
19499 // P + Q = O
19500 if (this.x.cmp(p.x) === 0)
19501 return this.curve.point(null, null);
19502
19503 var c = this.y.redSub(p.y);
19504 if (c.cmpn(0) !== 0)
19505 c = c.redMul(this.x.redSub(p.x).redInvm());
19506 var nx = c.redSqr().redISub(this.x).redISub(p.x);
19507 var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
19508 return this.curve.point(nx, ny);
19509};
19510
19511Point.prototype.dbl = function dbl() {
19512 if (this.inf)
19513 return this;
19514
19515 // 2P = O
19516 var ys1 = this.y.redAdd(this.y);
19517 if (ys1.cmpn(0) === 0)
19518 return this.curve.point(null, null);
19519
19520 var a = this.curve.a;
19521
19522 var x2 = this.x.redSqr();
19523 var dyinv = ys1.redInvm();
19524 var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv);
19525
19526 var nx = c.redSqr().redISub(this.x.redAdd(this.x));
19527 var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
19528 return this.curve.point(nx, ny);
19529};
19530
19531Point.prototype.getX = function getX() {
19532 return this.x.fromRed();
19533};
19534
19535Point.prototype.getY = function getY() {
19536 return this.y.fromRed();
19537};
19538
19539Point.prototype.mul = function mul(k) {
19540 k = new BN(k, 16);
19541
19542 if (this._hasDoubles(k))
19543 return this.curve._fixedNafMul(this, k);
19544 else if (this.curve.endo)
19545 return this.curve._endoWnafMulAdd([ this ], [ k ]);
19546 else
19547 return this.curve._wnafMul(this, k);
19548};
19549
19550Point.prototype.mulAdd = function mulAdd(k1, p2, k2) {
19551 var points = [ this, p2 ];
19552 var coeffs = [ k1, k2 ];
19553 if (this.curve.endo)
19554 return this.curve._endoWnafMulAdd(points, coeffs);
19555 else
19556 return this.curve._wnafMulAdd(1, points, coeffs, 2);
19557};
19558
19559Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) {
19560 var points = [ this, p2 ];
19561 var coeffs = [ k1, k2 ];
19562 if (this.curve.endo)
19563 return this.curve._endoWnafMulAdd(points, coeffs, true);
19564 else
19565 return this.curve._wnafMulAdd(1, points, coeffs, 2, true);
19566};
19567
19568Point.prototype.eq = function eq(p) {
19569 return this === p ||
19570 this.inf === p.inf &&
19571 (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0);
19572};
19573
19574Point.prototype.neg = function neg(_precompute) {
19575 if (this.inf)
19576 return this;
19577
19578 var res = this.curve.point(this.x, this.y.redNeg());
19579 if (_precompute && this.precomputed) {
19580 var pre = this.precomputed;
19581 var negate = function(p) {
19582 return p.neg();
19583 };
19584 res.precomputed = {
19585 naf: pre.naf && {
19586 wnd: pre.naf.wnd,
19587 points: pre.naf.points.map(negate)
19588 },
19589 doubles: pre.doubles && {
19590 step: pre.doubles.step,
19591 points: pre.doubles.points.map(negate)
19592 }
19593 };
19594 }
19595 return res;
19596};
19597
19598Point.prototype.toJ = function toJ() {
19599 if (this.inf)
19600 return this.curve.jpoint(null, null, null);
19601
19602 var res = this.curve.jpoint(this.x, this.y, this.curve.one);
19603 return res;
19604};
19605
19606function JPoint(curve, x, y, z) {
19607 Base.BasePoint.call(this, curve, 'jacobian');
19608 if (x === null && y === null && z === null) {
19609 this.x = this.curve.one;
19610 this.y = this.curve.one;
19611 this.z = new BN(0);
19612 } else {
19613 this.x = new BN(x, 16);
19614 this.y = new BN(y, 16);
19615 this.z = new BN(z, 16);
19616 }
19617 if (!this.x.red)
19618 this.x = this.x.toRed(this.curve.red);
19619 if (!this.y.red)
19620 this.y = this.y.toRed(this.curve.red);
19621 if (!this.z.red)
19622 this.z = this.z.toRed(this.curve.red);
19623
19624 this.zOne = this.z === this.curve.one;
19625}
19626inherits(JPoint, Base.BasePoint);
19627
19628ShortCurve.prototype.jpoint = function jpoint(x, y, z) {
19629 return new JPoint(this, x, y, z);
19630};
19631
19632JPoint.prototype.toP = function toP() {
19633 if (this.isInfinity())
19634 return this.curve.point(null, null);
19635
19636 var zinv = this.z.redInvm();
19637 var zinv2 = zinv.redSqr();
19638 var ax = this.x.redMul(zinv2);
19639 var ay = this.y.redMul(zinv2).redMul(zinv);
19640
19641 return this.curve.point(ax, ay);
19642};
19643
19644JPoint.prototype.neg = function neg() {
19645 return this.curve.jpoint(this.x, this.y.redNeg(), this.z);
19646};
19647
19648JPoint.prototype.add = function add(p) {
19649 // O + P = P
19650 if (this.isInfinity())
19651 return p;
19652
19653 // P + O = P
19654 if (p.isInfinity())
19655 return this;
19656
19657 // 12M + 4S + 7A
19658 var pz2 = p.z.redSqr();
19659 var z2 = this.z.redSqr();
19660 var u1 = this.x.redMul(pz2);
19661 var u2 = p.x.redMul(z2);
19662 var s1 = this.y.redMul(pz2.redMul(p.z));
19663 var s2 = p.y.redMul(z2.redMul(this.z));
19664
19665 var h = u1.redSub(u2);
19666 var r = s1.redSub(s2);
19667 if (h.cmpn(0) === 0) {
19668 if (r.cmpn(0) !== 0)
19669 return this.curve.jpoint(null, null, null);
19670 else
19671 return this.dbl();
19672 }
19673
19674 var h2 = h.redSqr();
19675 var h3 = h2.redMul(h);
19676 var v = u1.redMul(h2);
19677
19678 var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
19679 var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
19680 var nz = this.z.redMul(p.z).redMul(h);
19681
19682 return this.curve.jpoint(nx, ny, nz);
19683};
19684
19685JPoint.prototype.mixedAdd = function mixedAdd(p) {
19686 // O + P = P
19687 if (this.isInfinity())
19688 return p.toJ();
19689
19690 // P + O = P
19691 if (p.isInfinity())
19692 return this;
19693
19694 // 8M + 3S + 7A
19695 var z2 = this.z.redSqr();
19696 var u1 = this.x;
19697 var u2 = p.x.redMul(z2);
19698 var s1 = this.y;
19699 var s2 = p.y.redMul(z2).redMul(this.z);
19700
19701 var h = u1.redSub(u2);
19702 var r = s1.redSub(s2);
19703 if (h.cmpn(0) === 0) {
19704 if (r.cmpn(0) !== 0)
19705 return this.curve.jpoint(null, null, null);
19706 else
19707 return this.dbl();
19708 }
19709
19710 var h2 = h.redSqr();
19711 var h3 = h2.redMul(h);
19712 var v = u1.redMul(h2);
19713
19714 var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
19715 var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
19716 var nz = this.z.redMul(h);
19717
19718 return this.curve.jpoint(nx, ny, nz);
19719};
19720
19721JPoint.prototype.dblp = function dblp(pow) {
19722 if (pow === 0)
19723 return this;
19724 if (this.isInfinity())
19725 return this;
19726 if (!pow)
19727 return this.dbl();
19728
19729 if (this.curve.zeroA || this.curve.threeA) {
19730 var r = this;
19731 for (var i = 0; i < pow; i++)
19732 r = r.dbl();
19733 return r;
19734 }
19735
19736 // 1M + 2S + 1A + N * (4S + 5M + 8A)
19737 // N = 1 => 6M + 6S + 9A
19738 var a = this.curve.a;
19739 var tinv = this.curve.tinv;
19740
19741 var jx = this.x;
19742 var jy = this.y;
19743 var jz = this.z;
19744 var jz4 = jz.redSqr().redSqr();
19745
19746 // Reuse results
19747 var jyd = jy.redAdd(jy);
19748 for (var i = 0; i < pow; i++) {
19749 var jx2 = jx.redSqr();
19750 var jyd2 = jyd.redSqr();
19751 var jyd4 = jyd2.redSqr();
19752 var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
19753
19754 var t1 = jx.redMul(jyd2);
19755 var nx = c.redSqr().redISub(t1.redAdd(t1));
19756 var t2 = t1.redISub(nx);
19757 var dny = c.redMul(t2);
19758 dny = dny.redIAdd(dny).redISub(jyd4);
19759 var nz = jyd.redMul(jz);
19760 if (i + 1 < pow)
19761 jz4 = jz4.redMul(jyd4);
19762
19763 jx = nx;
19764 jz = nz;
19765 jyd = dny;
19766 }
19767
19768 return this.curve.jpoint(jx, jyd.redMul(tinv), jz);
19769};
19770
19771JPoint.prototype.dbl = function dbl() {
19772 if (this.isInfinity())
19773 return this;
19774
19775 if (this.curve.zeroA)
19776 return this._zeroDbl();
19777 else if (this.curve.threeA)
19778 return this._threeDbl();
19779 else
19780 return this._dbl();
19781};
19782
19783JPoint.prototype._zeroDbl = function _zeroDbl() {
19784 var nx;
19785 var ny;
19786 var nz;
19787 // Z = 1
19788 if (this.zOne) {
19789 // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
19790 // #doubling-mdbl-2007-bl
19791 // 1M + 5S + 14A
19792
19793 // XX = X1^2
19794 var xx = this.x.redSqr();
19795 // YY = Y1^2
19796 var yy = this.y.redSqr();
19797 // YYYY = YY^2
19798 var yyyy = yy.redSqr();
19799 // S = 2 * ((X1 + YY)^2 - XX - YYYY)
19800 var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
19801 s = s.redIAdd(s);
19802 // M = 3 * XX + a; a = 0
19803 var m = xx.redAdd(xx).redIAdd(xx);
19804 // T = M ^ 2 - 2*S
19805 var t = m.redSqr().redISub(s).redISub(s);
19806
19807 // 8 * YYYY
19808 var yyyy8 = yyyy.redIAdd(yyyy);
19809 yyyy8 = yyyy8.redIAdd(yyyy8);
19810 yyyy8 = yyyy8.redIAdd(yyyy8);
19811
19812 // X3 = T
19813 nx = t;
19814 // Y3 = M * (S - T) - 8 * YYYY
19815 ny = m.redMul(s.redISub(t)).redISub(yyyy8);
19816 // Z3 = 2*Y1
19817 nz = this.y.redAdd(this.y);
19818 } else {
19819 // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
19820 // #doubling-dbl-2009-l
19821 // 2M + 5S + 13A
19822
19823 // A = X1^2
19824 var a = this.x.redSqr();
19825 // B = Y1^2
19826 var b = this.y.redSqr();
19827 // C = B^2
19828 var c = b.redSqr();
19829 // D = 2 * ((X1 + B)^2 - A - C)
19830 var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c);
19831 d = d.redIAdd(d);
19832 // E = 3 * A
19833 var e = a.redAdd(a).redIAdd(a);
19834 // F = E^2
19835 var f = e.redSqr();
19836
19837 // 8 * C
19838 var c8 = c.redIAdd(c);
19839 c8 = c8.redIAdd(c8);
19840 c8 = c8.redIAdd(c8);
19841
19842 // X3 = F - 2 * D
19843 nx = f.redISub(d).redISub(d);
19844 // Y3 = E * (D - X3) - 8 * C
19845 ny = e.redMul(d.redISub(nx)).redISub(c8);
19846 // Z3 = 2 * Y1 * Z1
19847 nz = this.y.redMul(this.z);
19848 nz = nz.redIAdd(nz);
19849 }
19850
19851 return this.curve.jpoint(nx, ny, nz);
19852};
19853
19854JPoint.prototype._threeDbl = function _threeDbl() {
19855 var nx;
19856 var ny;
19857 var nz;
19858 // Z = 1
19859 if (this.zOne) {
19860 // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html
19861 // #doubling-mdbl-2007-bl
19862 // 1M + 5S + 15A
19863
19864 // XX = X1^2
19865 var xx = this.x.redSqr();
19866 // YY = Y1^2
19867 var yy = this.y.redSqr();
19868 // YYYY = YY^2
19869 var yyyy = yy.redSqr();
19870 // S = 2 * ((X1 + YY)^2 - XX - YYYY)
19871 var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
19872 s = s.redIAdd(s);
19873 // M = 3 * XX + a
19874 var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a);
19875 // T = M^2 - 2 * S
19876 var t = m.redSqr().redISub(s).redISub(s);
19877 // X3 = T
19878 nx = t;
19879 // Y3 = M * (S - T) - 8 * YYYY
19880 var yyyy8 = yyyy.redIAdd(yyyy);
19881 yyyy8 = yyyy8.redIAdd(yyyy8);
19882 yyyy8 = yyyy8.redIAdd(yyyy8);
19883 ny = m.redMul(s.redISub(t)).redISub(yyyy8);
19884 // Z3 = 2 * Y1
19885 nz = this.y.redAdd(this.y);
19886 } else {
19887 // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b
19888 // 3M + 5S
19889
19890 // delta = Z1^2
19891 var delta = this.z.redSqr();
19892 // gamma = Y1^2
19893 var gamma = this.y.redSqr();
19894 // beta = X1 * gamma
19895 var beta = this.x.redMul(gamma);
19896 // alpha = 3 * (X1 - delta) * (X1 + delta)
19897 var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta));
19898 alpha = alpha.redAdd(alpha).redIAdd(alpha);
19899 // X3 = alpha^2 - 8 * beta
19900 var beta4 = beta.redIAdd(beta);
19901 beta4 = beta4.redIAdd(beta4);
19902 var beta8 = beta4.redAdd(beta4);
19903 nx = alpha.redSqr().redISub(beta8);
19904 // Z3 = (Y1 + Z1)^2 - gamma - delta
19905 nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta);
19906 // Y3 = alpha * (4 * beta - X3) - 8 * gamma^2
19907 var ggamma8 = gamma.redSqr();
19908 ggamma8 = ggamma8.redIAdd(ggamma8);
19909 ggamma8 = ggamma8.redIAdd(ggamma8);
19910 ggamma8 = ggamma8.redIAdd(ggamma8);
19911 ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8);
19912 }
19913
19914 return this.curve.jpoint(nx, ny, nz);
19915};
19916
19917JPoint.prototype._dbl = function _dbl() {
19918 var a = this.curve.a;
19919
19920 // 4M + 6S + 10A
19921 var jx = this.x;
19922 var jy = this.y;
19923 var jz = this.z;
19924 var jz4 = jz.redSqr().redSqr();
19925
19926 var jx2 = jx.redSqr();
19927 var jy2 = jy.redSqr();
19928
19929 var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
19930
19931 var jxd4 = jx.redAdd(jx);
19932 jxd4 = jxd4.redIAdd(jxd4);
19933 var t1 = jxd4.redMul(jy2);
19934 var nx = c.redSqr().redISub(t1.redAdd(t1));
19935 var t2 = t1.redISub(nx);
19936
19937 var jyd8 = jy2.redSqr();
19938 jyd8 = jyd8.redIAdd(jyd8);
19939 jyd8 = jyd8.redIAdd(jyd8);
19940 jyd8 = jyd8.redIAdd(jyd8);
19941 var ny = c.redMul(t2).redISub(jyd8);
19942 var nz = jy.redAdd(jy).redMul(jz);
19943
19944 return this.curve.jpoint(nx, ny, nz);
19945};
19946
19947JPoint.prototype.trpl = function trpl() {
19948 if (!this.curve.zeroA)
19949 return this.dbl().add(this);
19950
19951 // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl
19952 // 5M + 10S + ...
19953
19954 // XX = X1^2
19955 var xx = this.x.redSqr();
19956 // YY = Y1^2
19957 var yy = this.y.redSqr();
19958 // ZZ = Z1^2
19959 var zz = this.z.redSqr();
19960 // YYYY = YY^2
19961 var yyyy = yy.redSqr();
19962 // M = 3 * XX + a * ZZ2; a = 0
19963 var m = xx.redAdd(xx).redIAdd(xx);
19964 // MM = M^2
19965 var mm = m.redSqr();
19966 // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM
19967 var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
19968 e = e.redIAdd(e);
19969 e = e.redAdd(e).redIAdd(e);
19970 e = e.redISub(mm);
19971 // EE = E^2
19972 var ee = e.redSqr();
19973 // T = 16*YYYY
19974 var t = yyyy.redIAdd(yyyy);
19975 t = t.redIAdd(t);
19976 t = t.redIAdd(t);
19977 t = t.redIAdd(t);
19978 // U = (M + E)^2 - MM - EE - T
19979 var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t);
19980 // X3 = 4 * (X1 * EE - 4 * YY * U)
19981 var yyu4 = yy.redMul(u);
19982 yyu4 = yyu4.redIAdd(yyu4);
19983 yyu4 = yyu4.redIAdd(yyu4);
19984 var nx = this.x.redMul(ee).redISub(yyu4);
19985 nx = nx.redIAdd(nx);
19986 nx = nx.redIAdd(nx);
19987 // Y3 = 8 * Y1 * (U * (T - U) - E * EE)
19988 var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee)));
19989 ny = ny.redIAdd(ny);
19990 ny = ny.redIAdd(ny);
19991 ny = ny.redIAdd(ny);
19992 // Z3 = (Z1 + E)^2 - ZZ - EE
19993 var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee);
19994
19995 return this.curve.jpoint(nx, ny, nz);
19996};
19997
19998JPoint.prototype.mul = function mul(k, kbase) {
19999 k = new BN(k, kbase);
20000
20001 return this.curve._wnafMul(this, k);
20002};
20003
20004JPoint.prototype.eq = function eq(p) {
20005 if (p.type === 'affine')
20006 return this.eq(p.toJ());
20007
20008 if (this === p)
20009 return true;
20010
20011 // x1 * z2^2 == x2 * z1^2
20012 var z2 = this.z.redSqr();
20013 var pz2 = p.z.redSqr();
20014 if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0)
20015 return false;
20016
20017 // y1 * z2^3 == y2 * z1^3
20018 var z3 = z2.redMul(this.z);
20019 var pz3 = pz2.redMul(p.z);
20020 return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0;
20021};
20022
20023JPoint.prototype.eqXToP = function eqXToP(x) {
20024 var zs = this.z.redSqr();
20025 var rx = x.toRed(this.curve.red).redMul(zs);
20026 if (this.x.cmp(rx) === 0)
20027 return true;
20028
20029 var xc = x.clone();
20030 var t = this.curve.redN.redMul(zs);
20031 for (;;) {
20032 xc.iadd(this.curve.n);
20033 if (xc.cmp(this.curve.p) >= 0)
20034 return false;
20035
20036 rx.redIAdd(t);
20037 if (this.x.cmp(rx) === 0)
20038 return true;
20039 }
20040};
20041
20042JPoint.prototype.inspect = function inspect() {
20043 if (this.isInfinity())
20044 return '<EC JPoint Infinity>';
20045 return '<EC JPoint x: ' + this.x.toString(16, 2) +
20046 ' y: ' + this.y.toString(16, 2) +
20047 ' z: ' + this.z.toString(16, 2) + '>';
20048};
20049
20050JPoint.prototype.isInfinity = function isInfinity() {
20051 // XXX This code assumes that zero is always zero in red
20052 return this.z.cmpn(0) === 0;
20053};
20054
20055},{"../utils":143,"./base":130,"bn.js":79,"inherits":162}],135:[function(require,module,exports){
20056'use strict';
20057
20058var curves = exports;
20059
20060var hash = require('hash.js');
20061var curve = require('./curve');
20062var utils = require('./utils');
20063
20064var assert = utils.assert;
20065
20066function PresetCurve(options) {
20067 if (options.type === 'short')
20068 this.curve = new curve.short(options);
20069 else if (options.type === 'edwards')
20070 this.curve = new curve.edwards(options);
20071 else
20072 this.curve = new curve.mont(options);
20073 this.g = this.curve.g;
20074 this.n = this.curve.n;
20075 this.hash = options.hash;
20076
20077 assert(this.g.validate(), 'Invalid curve');
20078 assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O');
20079}
20080curves.PresetCurve = PresetCurve;
20081
20082function defineCurve(name, options) {
20083 Object.defineProperty(curves, name, {
20084 configurable: true,
20085 enumerable: true,
20086 get: function() {
20087 var curve = new PresetCurve(options);
20088 Object.defineProperty(curves, name, {
20089 configurable: true,
20090 enumerable: true,
20091 value: curve
20092 });
20093 return curve;
20094 }
20095 });
20096}
20097
20098defineCurve('p192', {
20099 type: 'short',
20100 prime: 'p192',
20101 p: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff',
20102 a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc',
20103 b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1',
20104 n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831',
20105 hash: hash.sha256,
20106 gRed: false,
20107 g: [
20108 '188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012',
20109 '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811'
20110 ]
20111});
20112
20113defineCurve('p224', {
20114 type: 'short',
20115 prime: 'p224',
20116 p: 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001',
20117 a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe',
20118 b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4',
20119 n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d',
20120 hash: hash.sha256,
20121 gRed: false,
20122 g: [
20123 'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21',
20124 'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34'
20125 ]
20126});
20127
20128defineCurve('p256', {
20129 type: 'short',
20130 prime: null,
20131 p: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff',
20132 a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc',
20133 b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b',
20134 n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551',
20135 hash: hash.sha256,
20136 gRed: false,
20137 g: [
20138 '6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296',
20139 '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5'
20140 ]
20141});
20142
20143defineCurve('p384', {
20144 type: 'short',
20145 prime: null,
20146 p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
20147 'fffffffe ffffffff 00000000 00000000 ffffffff',
20148 a: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
20149 'fffffffe ffffffff 00000000 00000000 fffffffc',
20150 b: 'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f ' +
20151 '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef',
20152 n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' +
20153 'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973',
20154 hash: hash.sha384,
20155 gRed: false,
20156 g: [
20157 'aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' +
20158 '5502f25d bf55296c 3a545e38 72760ab7',
20159 '3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' +
20160 '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f'
20161 ]
20162});
20163
20164defineCurve('p521', {
20165 type: 'short',
20166 prime: null,
20167 p: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
20168 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
20169 'ffffffff ffffffff ffffffff ffffffff ffffffff',
20170 a: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
20171 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
20172 'ffffffff ffffffff ffffffff ffffffff fffffffc',
20173 b: '00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b ' +
20174 '99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd ' +
20175 '3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00',
20176 n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
20177 'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' +
20178 'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409',
20179 hash: hash.sha512,
20180 gRed: false,
20181 g: [
20182 '000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' +
20183 '053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 ' +
20184 'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66',
20185 '00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' +
20186 '579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' +
20187 '3fad0761 353c7086 a272c240 88be9476 9fd16650'
20188 ]
20189});
20190
20191defineCurve('curve25519', {
20192 type: 'mont',
20193 prime: 'p25519',
20194 p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
20195 a: '76d06',
20196 b: '1',
20197 n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
20198 hash: hash.sha256,
20199 gRed: false,
20200 g: [
20201 '9'
20202 ]
20203});
20204
20205defineCurve('ed25519', {
20206 type: 'edwards',
20207 prime: 'p25519',
20208 p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
20209 a: '-1',
20210 c: '1',
20211 // -121665 * (121666^(-1)) (mod P)
20212 d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3',
20213 n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
20214 hash: hash.sha256,
20215 gRed: false,
20216 g: [
20217 '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a',
20218
20219 // 4/5
20220 '6666666666666666666666666666666666666666666666666666666666666658'
20221 ]
20222});
20223
20224var pre;
20225try {
20226 pre = require('./precomputed/secp256k1');
20227} catch (e) {
20228 pre = undefined;
20229}
20230
20231defineCurve('secp256k1', {
20232 type: 'short',
20233 prime: 'k256',
20234 p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f',
20235 a: '0',
20236 b: '7',
20237 n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141',
20238 h: '1',
20239 hash: hash.sha256,
20240
20241 // Precomputed endomorphism
20242 beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee',
20243 lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72',
20244 basis: [
20245 {
20246 a: '3086d221a7d46bcde86c90e49284eb15',
20247 b: '-e4437ed6010e88286f547fa90abfe4c3'
20248 },
20249 {
20250 a: '114ca50f7a8e2f3f657c1108d9d44cfd8',
20251 b: '3086d221a7d46bcde86c90e49284eb15'
20252 }
20253 ],
20254
20255 gRed: false,
20256 g: [
20257 '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
20258 '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8',
20259 pre
20260 ]
20261});
20262
20263},{"./curve":132,"./precomputed/secp256k1":142,"./utils":143,"hash.js":148}],136:[function(require,module,exports){
20264'use strict';
20265
20266var BN = require('bn.js');
20267var HmacDRBG = require('hmac-drbg');
20268var utils = require('../utils');
20269var curves = require('../curves');
20270var rand = require('brorand');
20271var assert = utils.assert;
20272
20273var KeyPair = require('./key');
20274var Signature = require('./signature');
20275
20276function EC(options) {
20277 if (!(this instanceof EC))
20278 return new EC(options);
20279
20280 // Shortcut `elliptic.ec(curve-name)`
20281 if (typeof options === 'string') {
20282 assert(curves.hasOwnProperty(options), 'Unknown curve ' + options);
20283
20284 options = curves[options];
20285 }
20286
20287 // Shortcut for `elliptic.ec(elliptic.curves.curveName)`
20288 if (options instanceof curves.PresetCurve)
20289 options = { curve: options };
20290
20291 this.curve = options.curve.curve;
20292 this.n = this.curve.n;
20293 this.nh = this.n.ushrn(1);
20294 this.g = this.curve.g;
20295
20296 // Point on curve
20297 this.g = options.curve.g;
20298 this.g.precompute(options.curve.n.bitLength() + 1);
20299
20300 // Hash for function for DRBG
20301 this.hash = options.hash || options.curve.hash;
20302}
20303module.exports = EC;
20304
20305EC.prototype.keyPair = function keyPair(options) {
20306 return new KeyPair(this, options);
20307};
20308
20309EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) {
20310 return KeyPair.fromPrivate(this, priv, enc);
20311};
20312
20313EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) {
20314 return KeyPair.fromPublic(this, pub, enc);
20315};
20316
20317EC.prototype.genKeyPair = function genKeyPair(options) {
20318 if (!options)
20319 options = {};
20320
20321 // Instantiate Hmac_DRBG
20322 var drbg = new HmacDRBG({
20323 hash: this.hash,
20324 pers: options.pers,
20325 persEnc: options.persEnc || 'utf8',
20326 entropy: options.entropy || rand(this.hash.hmacStrength),
20327 entropyEnc: options.entropy && options.entropyEnc || 'utf8',
20328 nonce: this.n.toArray()
20329 });
20330
20331 var bytes = this.n.byteLength();
20332 var ns2 = this.n.sub(new BN(2));
20333 do {
20334 var priv = new BN(drbg.generate(bytes));
20335 if (priv.cmp(ns2) > 0)
20336 continue;
20337
20338 priv.iaddn(1);
20339 return this.keyFromPrivate(priv);
20340 } while (true);
20341};
20342
20343EC.prototype._truncateToN = function truncateToN(msg, truncOnly) {
20344 var delta = msg.byteLength() * 8 - this.n.bitLength();
20345 if (delta > 0)
20346 msg = msg.ushrn(delta);
20347 if (!truncOnly && msg.cmp(this.n) >= 0)
20348 return msg.sub(this.n);
20349 else
20350 return msg;
20351};
20352
20353EC.prototype.sign = function sign(msg, key, enc, options) {
20354 if (typeof enc === 'object') {
20355 options = enc;
20356 enc = null;
20357 }
20358 if (!options)
20359 options = {};
20360
20361 key = this.keyFromPrivate(key, enc);
20362 msg = this._truncateToN(new BN(msg, 16));
20363
20364 // Zero-extend key to provide enough entropy
20365 var bytes = this.n.byteLength();
20366 var bkey = key.getPrivate().toArray('be', bytes);
20367
20368 // Zero-extend nonce to have the same byte size as N
20369 var nonce = msg.toArray('be', bytes);
20370
20371 // Instantiate Hmac_DRBG
20372 var drbg = new HmacDRBG({
20373 hash: this.hash,
20374 entropy: bkey,
20375 nonce: nonce,
20376 pers: options.pers,
20377 persEnc: options.persEnc || 'utf8'
20378 });
20379
20380 // Number of bytes to generate
20381 var ns1 = this.n.sub(new BN(1));
20382
20383 for (var iter = 0; true; iter++) {
20384 var k = options.k ?
20385 options.k(iter) :
20386 new BN(drbg.generate(this.n.byteLength()));
20387 k = this._truncateToN(k, true);
20388 if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0)
20389 continue;
20390
20391 var kp = this.g.mul(k);
20392 if (kp.isInfinity())
20393 continue;
20394
20395 var kpX = kp.getX();
20396 var r = kpX.umod(this.n);
20397 if (r.cmpn(0) === 0)
20398 continue;
20399
20400 var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg));
20401 s = s.umod(this.n);
20402 if (s.cmpn(0) === 0)
20403 continue;
20404
20405 var recoveryParam = (kp.getY().isOdd() ? 1 : 0) |
20406 (kpX.cmp(r) !== 0 ? 2 : 0);
20407
20408 // Use complement of `s`, if it is > `n / 2`
20409 if (options.canonical && s.cmp(this.nh) > 0) {
20410 s = this.n.sub(s);
20411 recoveryParam ^= 1;
20412 }
20413
20414 return new Signature({ r: r, s: s, recoveryParam: recoveryParam });
20415 }
20416};
20417
20418EC.prototype.verify = function verify(msg, signature, key, enc) {
20419 msg = this._truncateToN(new BN(msg, 16));
20420 key = this.keyFromPublic(key, enc);
20421 signature = new Signature(signature, 'hex');
20422
20423 // Perform primitive values validation
20424 var r = signature.r;
20425 var s = signature.s;
20426 if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0)
20427 return false;
20428 if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0)
20429 return false;
20430
20431 // Validate signature
20432 var sinv = s.invm(this.n);
20433 var u1 = sinv.mul(msg).umod(this.n);
20434 var u2 = sinv.mul(r).umod(this.n);
20435
20436 if (!this.curve._maxwellTrick) {
20437 var p = this.g.mulAdd(u1, key.getPublic(), u2);
20438 if (p.isInfinity())
20439 return false;
20440
20441 return p.getX().umod(this.n).cmp(r) === 0;
20442 }
20443
20444 // NOTE: Greg Maxwell's trick, inspired by:
20445 // https://git.io/vad3K
20446
20447 var p = this.g.jmulAdd(u1, key.getPublic(), u2);
20448 if (p.isInfinity())
20449 return false;
20450
20451 // Compare `p.x` of Jacobian point with `r`,
20452 // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the
20453 // inverse of `p.z^2`
20454 return p.eqXToP(r);
20455};
20456
20457EC.prototype.recoverPubKey = function(msg, signature, j, enc) {
20458 assert((3 & j) === j, 'The recovery param is more than two bits');
20459 signature = new Signature(signature, enc);
20460
20461 var n = this.n;
20462 var e = new BN(msg);
20463 var r = signature.r;
20464 var s = signature.s;
20465
20466 // A set LSB signifies that the y-coordinate is odd
20467 var isYOdd = j & 1;
20468 var isSecondKey = j >> 1;
20469 if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey)
20470 throw new Error('Unable to find sencond key candinate');
20471
20472 // 1.1. Let x = r + jn.
20473 if (isSecondKey)
20474 r = this.curve.pointFromX(r.add(this.curve.n), isYOdd);
20475 else
20476 r = this.curve.pointFromX(r, isYOdd);
20477
20478 var rInv = signature.r.invm(n);
20479 var s1 = n.sub(e).mul(rInv).umod(n);
20480 var s2 = s.mul(rInv).umod(n);
20481
20482 // 1.6.1 Compute Q = r^-1 (sR - eG)
20483 // Q = r^-1 (sR + -eG)
20484 return this.g.mulAdd(s1, r, s2);
20485};
20486
20487EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) {
20488 signature = new Signature(signature, enc);
20489 if (signature.recoveryParam !== null)
20490 return signature.recoveryParam;
20491
20492 for (var i = 0; i < 4; i++) {
20493 var Qprime;
20494 try {
20495 Qprime = this.recoverPubKey(e, signature, i);
20496 } catch (e) {
20497 continue;
20498 }
20499
20500 if (Qprime.eq(Q))
20501 return i;
20502 }
20503 throw new Error('Unable to find valid recovery factor');
20504};
20505
20506},{"../curves":135,"../utils":143,"./key":137,"./signature":138,"bn.js":79,"brorand":80,"hmac-drbg":160}],137:[function(require,module,exports){
20507'use strict';
20508
20509var BN = require('bn.js');
20510var utils = require('../utils');
20511var assert = utils.assert;
20512
20513function KeyPair(ec, options) {
20514 this.ec = ec;
20515 this.priv = null;
20516 this.pub = null;
20517
20518 // KeyPair(ec, { priv: ..., pub: ... })
20519 if (options.priv)
20520 this._importPrivate(options.priv, options.privEnc);
20521 if (options.pub)
20522 this._importPublic(options.pub, options.pubEnc);
20523}
20524module.exports = KeyPair;
20525
20526KeyPair.fromPublic = function fromPublic(ec, pub, enc) {
20527 if (pub instanceof KeyPair)
20528 return pub;
20529
20530 return new KeyPair(ec, {
20531 pub: pub,
20532 pubEnc: enc
20533 });
20534};
20535
20536KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) {
20537 if (priv instanceof KeyPair)
20538 return priv;
20539
20540 return new KeyPair(ec, {
20541 priv: priv,
20542 privEnc: enc
20543 });
20544};
20545
20546KeyPair.prototype.validate = function validate() {
20547 var pub = this.getPublic();
20548
20549 if (pub.isInfinity())
20550 return { result: false, reason: 'Invalid public key' };
20551 if (!pub.validate())
20552 return { result: false, reason: 'Public key is not a point' };
20553 if (!pub.mul(this.ec.curve.n).isInfinity())
20554 return { result: false, reason: 'Public key * N != O' };
20555
20556 return { result: true, reason: null };
20557};
20558
20559KeyPair.prototype.getPublic = function getPublic(compact, enc) {
20560 // compact is optional argument
20561 if (typeof compact === 'string') {
20562 enc = compact;
20563 compact = null;
20564 }
20565
20566 if (!this.pub)
20567 this.pub = this.ec.g.mul(this.priv);
20568
20569 if (!enc)
20570 return this.pub;
20571
20572 return this.pub.encode(enc, compact);
20573};
20574
20575KeyPair.prototype.getPrivate = function getPrivate(enc) {
20576 if (enc === 'hex')
20577 return this.priv.toString(16, 2);
20578 else
20579 return this.priv;
20580};
20581
20582KeyPair.prototype._importPrivate = function _importPrivate(key, enc) {
20583 this.priv = new BN(key, enc || 16);
20584
20585 // Ensure that the priv won't be bigger than n, otherwise we may fail
20586 // in fixed multiplication method
20587 this.priv = this.priv.umod(this.ec.curve.n);
20588};
20589
20590KeyPair.prototype._importPublic = function _importPublic(key, enc) {
20591 if (key.x || key.y) {
20592 // Montgomery points only have an `x` coordinate.
20593 // Weierstrass/Edwards points on the other hand have both `x` and
20594 // `y` coordinates.
20595 if (this.ec.curve.type === 'mont') {
20596 assert(key.x, 'Need x coordinate');
20597 } else if (this.ec.curve.type === 'short' ||
20598 this.ec.curve.type === 'edwards') {
20599 assert(key.x && key.y, 'Need both x and y coordinate');
20600 }
20601 this.pub = this.ec.curve.point(key.x, key.y);
20602 return;
20603 }
20604 this.pub = this.ec.curve.decodePoint(key, enc);
20605};
20606
20607// ECDH
20608KeyPair.prototype.derive = function derive(pub) {
20609 return pub.mul(this.priv).getX();
20610};
20611
20612// ECDSA
20613KeyPair.prototype.sign = function sign(msg, enc, options) {
20614 return this.ec.sign(msg, this, enc, options);
20615};
20616
20617KeyPair.prototype.verify = function verify(msg, signature) {
20618 return this.ec.verify(msg, signature, this);
20619};
20620
20621KeyPair.prototype.inspect = function inspect() {
20622 return '<Key priv: ' + (this.priv && this.priv.toString(16, 2)) +
20623 ' pub: ' + (this.pub && this.pub.inspect()) + ' >';
20624};
20625
20626},{"../utils":143,"bn.js":79}],138:[function(require,module,exports){
20627'use strict';
20628
20629var BN = require('bn.js');
20630
20631var utils = require('../utils');
20632var assert = utils.assert;
20633
20634function Signature(options, enc) {
20635 if (options instanceof Signature)
20636 return options;
20637
20638 if (this._importDER(options, enc))
20639 return;
20640
20641 assert(options.r && options.s, 'Signature without r or s');
20642 this.r = new BN(options.r, 16);
20643 this.s = new BN(options.s, 16);
20644 if (options.recoveryParam === undefined)
20645 this.recoveryParam = null;
20646 else
20647 this.recoveryParam = options.recoveryParam;
20648}
20649module.exports = Signature;
20650
20651function Position() {
20652 this.place = 0;
20653}
20654
20655function getLength(buf, p) {
20656 var initial = buf[p.place++];
20657 if (!(initial & 0x80)) {
20658 return initial;
20659 }
20660 var octetLen = initial & 0xf;
20661 var val = 0;
20662 for (var i = 0, off = p.place; i < octetLen; i++, off++) {
20663 val <<= 8;
20664 val |= buf[off];
20665 }
20666 p.place = off;
20667 return val;
20668}
20669
20670function rmPadding(buf) {
20671 var i = 0;
20672 var len = buf.length - 1;
20673 while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) {
20674 i++;
20675 }
20676 if (i === 0) {
20677 return buf;
20678 }
20679 return buf.slice(i);
20680}
20681
20682Signature.prototype._importDER = function _importDER(data, enc) {
20683 data = utils.toArray(data, enc);
20684 var p = new Position();
20685 if (data[p.place++] !== 0x30) {
20686 return false;
20687 }
20688 var len = getLength(data, p);
20689 if ((len + p.place) !== data.length) {
20690 return false;
20691 }
20692 if (data[p.place++] !== 0x02) {
20693 return false;
20694 }
20695 var rlen = getLength(data, p);
20696 var r = data.slice(p.place, rlen + p.place);
20697 p.place += rlen;
20698 if (data[p.place++] !== 0x02) {
20699 return false;
20700 }
20701 var slen = getLength(data, p);
20702 if (data.length !== slen + p.place) {
20703 return false;
20704 }
20705 var s = data.slice(p.place, slen + p.place);
20706 if (r[0] === 0 && (r[1] & 0x80)) {
20707 r = r.slice(1);
20708 }
20709 if (s[0] === 0 && (s[1] & 0x80)) {
20710 s = s.slice(1);
20711 }
20712
20713 this.r = new BN(r);
20714 this.s = new BN(s);
20715 this.recoveryParam = null;
20716
20717 return true;
20718};
20719
20720function constructLength(arr, len) {
20721 if (len < 0x80) {
20722 arr.push(len);
20723 return;
20724 }
20725 var octets = 1 + (Math.log(len) / Math.LN2 >>> 3);
20726 arr.push(octets | 0x80);
20727 while (--octets) {
20728 arr.push((len >>> (octets << 3)) & 0xff);
20729 }
20730 arr.push(len);
20731}
20732
20733Signature.prototype.toDER = function toDER(enc) {
20734 var r = this.r.toArray();
20735 var s = this.s.toArray();
20736
20737 // Pad values
20738 if (r[0] & 0x80)
20739 r = [ 0 ].concat(r);
20740 // Pad values
20741 if (s[0] & 0x80)
20742 s = [ 0 ].concat(s);
20743
20744 r = rmPadding(r);
20745 s = rmPadding(s);
20746
20747 while (!s[0] && !(s[1] & 0x80)) {
20748 s = s.slice(1);
20749 }
20750 var arr = [ 0x02 ];
20751 constructLength(arr, r.length);
20752 arr = arr.concat(r);
20753 arr.push(0x02);
20754 constructLength(arr, s.length);
20755 var backHalf = arr.concat(s);
20756 var res = [ 0x30 ];
20757 constructLength(res, backHalf.length);
20758 res = res.concat(backHalf);
20759 return utils.encode(res, enc);
20760};
20761
20762},{"../utils":143,"bn.js":79}],139:[function(require,module,exports){
20763'use strict';
20764
20765var hash = require('hash.js');
20766var curves = require('../curves');
20767var utils = require('../utils');
20768var assert = utils.assert;
20769var parseBytes = utils.parseBytes;
20770var KeyPair = require('./key');
20771var Signature = require('./signature');
20772
20773function EDDSA(curve) {
20774 assert(curve === 'ed25519', 'only tested with ed25519 so far');
20775
20776 if (!(this instanceof EDDSA))
20777 return new EDDSA(curve);
20778
20779 var curve = curves[curve].curve;
20780 this.curve = curve;
20781 this.g = curve.g;
20782 this.g.precompute(curve.n.bitLength() + 1);
20783
20784 this.pointClass = curve.point().constructor;
20785 this.encodingLength = Math.ceil(curve.n.bitLength() / 8);
20786 this.hash = hash.sha512;
20787}
20788
20789module.exports = EDDSA;
20790
20791/**
20792* @param {Array|String} message - message bytes
20793* @param {Array|String|KeyPair} secret - secret bytes or a keypair
20794* @returns {Signature} - signature
20795*/
20796EDDSA.prototype.sign = function sign(message, secret) {
20797 message = parseBytes(message);
20798 var key = this.keyFromSecret(secret);
20799 var r = this.hashInt(key.messagePrefix(), message);
20800 var R = this.g.mul(r);
20801 var Rencoded = this.encodePoint(R);
20802 var s_ = this.hashInt(Rencoded, key.pubBytes(), message)
20803 .mul(key.priv());
20804 var S = r.add(s_).umod(this.curve.n);
20805 return this.makeSignature({ R: R, S: S, Rencoded: Rencoded });
20806};
20807
20808/**
20809* @param {Array} message - message bytes
20810* @param {Array|String|Signature} sig - sig bytes
20811* @param {Array|String|Point|KeyPair} pub - public key
20812* @returns {Boolean} - true if public key matches sig of message
20813*/
20814EDDSA.prototype.verify = function verify(message, sig, pub) {
20815 message = parseBytes(message);
20816 sig = this.makeSignature(sig);
20817 var key = this.keyFromPublic(pub);
20818 var h = this.hashInt(sig.Rencoded(), key.pubBytes(), message);
20819 var SG = this.g.mul(sig.S());
20820 var RplusAh = sig.R().add(key.pub().mul(h));
20821 return RplusAh.eq(SG);
20822};
20823
20824EDDSA.prototype.hashInt = function hashInt() {
20825 var hash = this.hash();
20826 for (var i = 0; i < arguments.length; i++)
20827 hash.update(arguments[i]);
20828 return utils.intFromLE(hash.digest()).umod(this.curve.n);
20829};
20830
20831EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) {
20832 return KeyPair.fromPublic(this, pub);
20833};
20834
20835EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) {
20836 return KeyPair.fromSecret(this, secret);
20837};
20838
20839EDDSA.prototype.makeSignature = function makeSignature(sig) {
20840 if (sig instanceof Signature)
20841 return sig;
20842 return new Signature(this, sig);
20843};
20844
20845/**
20846* * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.2
20847*
20848* EDDSA defines methods for encoding and decoding points and integers. These are
20849* helper convenience methods, that pass along to utility functions implied
20850* parameters.
20851*
20852*/
20853EDDSA.prototype.encodePoint = function encodePoint(point) {
20854 var enc = point.getY().toArray('le', this.encodingLength);
20855 enc[this.encodingLength - 1] |= point.getX().isOdd() ? 0x80 : 0;
20856 return enc;
20857};
20858
20859EDDSA.prototype.decodePoint = function decodePoint(bytes) {
20860 bytes = utils.parseBytes(bytes);
20861
20862 var lastIx = bytes.length - 1;
20863 var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80);
20864 var xIsOdd = (bytes[lastIx] & 0x80) !== 0;
20865
20866 var y = utils.intFromLE(normed);
20867 return this.curve.pointFromY(y, xIsOdd);
20868};
20869
20870EDDSA.prototype.encodeInt = function encodeInt(num) {
20871 return num.toArray('le', this.encodingLength);
20872};
20873
20874EDDSA.prototype.decodeInt = function decodeInt(bytes) {
20875 return utils.intFromLE(bytes);
20876};
20877
20878EDDSA.prototype.isPoint = function isPoint(val) {
20879 return val instanceof this.pointClass;
20880};
20881
20882},{"../curves":135,"../utils":143,"./key":140,"./signature":141,"hash.js":148}],140:[function(require,module,exports){
20883'use strict';
20884
20885var utils = require('../utils');
20886var assert = utils.assert;
20887var parseBytes = utils.parseBytes;
20888var cachedProperty = utils.cachedProperty;
20889
20890/**
20891* @param {EDDSA} eddsa - instance
20892* @param {Object} params - public/private key parameters
20893*
20894* @param {Array<Byte>} [params.secret] - secret seed bytes
20895* @param {Point} [params.pub] - public key point (aka `A` in eddsa terms)
20896* @param {Array<Byte>} [params.pub] - public key point encoded as bytes
20897*
20898*/
20899function KeyPair(eddsa, params) {
20900 this.eddsa = eddsa;
20901 this._secret = parseBytes(params.secret);
20902 if (eddsa.isPoint(params.pub))
20903 this._pub = params.pub;
20904 else
20905 this._pubBytes = parseBytes(params.pub);
20906}
20907
20908KeyPair.fromPublic = function fromPublic(eddsa, pub) {
20909 if (pub instanceof KeyPair)
20910 return pub;
20911 return new KeyPair(eddsa, { pub: pub });
20912};
20913
20914KeyPair.fromSecret = function fromSecret(eddsa, secret) {
20915 if (secret instanceof KeyPair)
20916 return secret;
20917 return new KeyPair(eddsa, { secret: secret });
20918};
20919
20920KeyPair.prototype.secret = function secret() {
20921 return this._secret;
20922};
20923
20924cachedProperty(KeyPair, 'pubBytes', function pubBytes() {
20925 return this.eddsa.encodePoint(this.pub());
20926});
20927
20928cachedProperty(KeyPair, 'pub', function pub() {
20929 if (this._pubBytes)
20930 return this.eddsa.decodePoint(this._pubBytes);
20931 return this.eddsa.g.mul(this.priv());
20932});
20933
20934cachedProperty(KeyPair, 'privBytes', function privBytes() {
20935 var eddsa = this.eddsa;
20936 var hash = this.hash();
20937 var lastIx = eddsa.encodingLength - 1;
20938
20939 var a = hash.slice(0, eddsa.encodingLength);
20940 a[0] &= 248;
20941 a[lastIx] &= 127;
20942 a[lastIx] |= 64;
20943
20944 return a;
20945});
20946
20947cachedProperty(KeyPair, 'priv', function priv() {
20948 return this.eddsa.decodeInt(this.privBytes());
20949});
20950
20951cachedProperty(KeyPair, 'hash', function hash() {
20952 return this.eddsa.hash().update(this.secret()).digest();
20953});
20954
20955cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() {
20956 return this.hash().slice(this.eddsa.encodingLength);
20957});
20958
20959KeyPair.prototype.sign = function sign(message) {
20960 assert(this._secret, 'KeyPair can only verify');
20961 return this.eddsa.sign(message, this);
20962};
20963
20964KeyPair.prototype.verify = function verify(message, sig) {
20965 return this.eddsa.verify(message, sig, this);
20966};
20967
20968KeyPair.prototype.getSecret = function getSecret(enc) {
20969 assert(this._secret, 'KeyPair is public only');
20970 return utils.encode(this.secret(), enc);
20971};
20972
20973KeyPair.prototype.getPublic = function getPublic(enc) {
20974 return utils.encode(this.pubBytes(), enc);
20975};
20976
20977module.exports = KeyPair;
20978
20979},{"../utils":143}],141:[function(require,module,exports){
20980'use strict';
20981
20982var BN = require('bn.js');
20983var utils = require('../utils');
20984var assert = utils.assert;
20985var cachedProperty = utils.cachedProperty;
20986var parseBytes = utils.parseBytes;
20987
20988/**
20989* @param {EDDSA} eddsa - eddsa instance
20990* @param {Array<Bytes>|Object} sig -
20991* @param {Array<Bytes>|Point} [sig.R] - R point as Point or bytes
20992* @param {Array<Bytes>|bn} [sig.S] - S scalar as bn or bytes
20993* @param {Array<Bytes>} [sig.Rencoded] - R point encoded
20994* @param {Array<Bytes>} [sig.Sencoded] - S scalar encoded
20995*/
20996function Signature(eddsa, sig) {
20997 this.eddsa = eddsa;
20998
20999 if (typeof sig !== 'object')
21000 sig = parseBytes(sig);
21001
21002 if (Array.isArray(sig)) {
21003 sig = {
21004 R: sig.slice(0, eddsa.encodingLength),
21005 S: sig.slice(eddsa.encodingLength)
21006 };
21007 }
21008
21009 assert(sig.R && sig.S, 'Signature without R or S');
21010
21011 if (eddsa.isPoint(sig.R))
21012 this._R = sig.R;
21013 if (sig.S instanceof BN)
21014 this._S = sig.S;
21015
21016 this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded;
21017 this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded;
21018}
21019
21020cachedProperty(Signature, 'S', function S() {
21021 return this.eddsa.decodeInt(this.Sencoded());
21022});
21023
21024cachedProperty(Signature, 'R', function R() {
21025 return this.eddsa.decodePoint(this.Rencoded());
21026});
21027
21028cachedProperty(Signature, 'Rencoded', function Rencoded() {
21029 return this.eddsa.encodePoint(this.R());
21030});
21031
21032cachedProperty(Signature, 'Sencoded', function Sencoded() {
21033 return this.eddsa.encodeInt(this.S());
21034});
21035
21036Signature.prototype.toBytes = function toBytes() {
21037 return this.Rencoded().concat(this.Sencoded());
21038};
21039
21040Signature.prototype.toHex = function toHex() {
21041 return utils.encode(this.toBytes(), 'hex').toUpperCase();
21042};
21043
21044module.exports = Signature;
21045
21046},{"../utils":143,"bn.js":79}],142:[function(require,module,exports){
21047module.exports = {
21048 doubles: {
21049 step: 4,
21050 points: [
21051 [
21052 'e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a',
21053 'f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821'
21054 ],
21055 [
21056 '8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508',
21057 '11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf'
21058 ],
21059 [
21060 '175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739',
21061 'd3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695'
21062 ],
21063 [
21064 '363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640',
21065 '4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9'
21066 ],
21067 [
21068 '8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c',
21069 '4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36'
21070 ],
21071 [
21072 '723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda',
21073 '96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f'
21074 ],
21075 [
21076 'eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa',
21077 '5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999'
21078 ],
21079 [
21080 '100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0',
21081 'cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09'
21082 ],
21083 [
21084 'e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d',
21085 '9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d'
21086 ],
21087 [
21088 'feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d',
21089 'e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088'
21090 ],
21091 [
21092 'da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1',
21093 '9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d'
21094 ],
21095 [
21096 '53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0',
21097 '5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8'
21098 ],
21099 [
21100 '8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047',
21101 '10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a'
21102 ],
21103 [
21104 '385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862',
21105 '283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453'
21106 ],
21107 [
21108 '6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7',
21109 '7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160'
21110 ],
21111 [
21112 '3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd',
21113 '56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0'
21114 ],
21115 [
21116 '85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83',
21117 '7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6'
21118 ],
21119 [
21120 '948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a',
21121 '53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589'
21122 ],
21123 [
21124 '6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8',
21125 'bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17'
21126 ],
21127 [
21128 'e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d',
21129 '4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda'
21130 ],
21131 [
21132 'e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725',
21133 '7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd'
21134 ],
21135 [
21136 '213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754',
21137 '4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2'
21138 ],
21139 [
21140 '4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c',
21141 '17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6'
21142 ],
21143 [
21144 'fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6',
21145 '6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f'
21146 ],
21147 [
21148 '76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39',
21149 'c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01'
21150 ],
21151 [
21152 'c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891',
21153 '893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3'
21154 ],
21155 [
21156 'd895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b',
21157 'febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f'
21158 ],
21159 [
21160 'b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03',
21161 '2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7'
21162 ],
21163 [
21164 'e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d',
21165 'eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78'
21166 ],
21167 [
21168 'a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070',
21169 '7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1'
21170 ],
21171 [
21172 '90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4',
21173 'e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150'
21174 ],
21175 [
21176 '8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da',
21177 '662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82'
21178 ],
21179 [
21180 'e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11',
21181 '1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc'
21182 ],
21183 [
21184 '8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e',
21185 'efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b'
21186 ],
21187 [
21188 'e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41',
21189 '2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51'
21190 ],
21191 [
21192 'b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef',
21193 '67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45'
21194 ],
21195 [
21196 'd68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8',
21197 'db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120'
21198 ],
21199 [
21200 '324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d',
21201 '648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84'
21202 ],
21203 [
21204 '4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96',
21205 '35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d'
21206 ],
21207 [
21208 '9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd',
21209 'ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d'
21210 ],
21211 [
21212 '6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5',
21213 '9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8'
21214 ],
21215 [
21216 'a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266',
21217 '40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8'
21218 ],
21219 [
21220 '7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71',
21221 '34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac'
21222 ],
21223 [
21224 '928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac',
21225 'c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f'
21226 ],
21227 [
21228 '85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751',
21229 '1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962'
21230 ],
21231 [
21232 'ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e',
21233 '493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907'
21234 ],
21235 [
21236 '827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241',
21237 'c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec'
21238 ],
21239 [
21240 'eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3',
21241 'be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d'
21242 ],
21243 [
21244 'e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f',
21245 '4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414'
21246 ],
21247 [
21248 '1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19',
21249 'aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd'
21250 ],
21251 [
21252 '146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be',
21253 'b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0'
21254 ],
21255 [
21256 'fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9',
21257 '6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811'
21258 ],
21259 [
21260 'da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2',
21261 '8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1'
21262 ],
21263 [
21264 'a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13',
21265 '7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c'
21266 ],
21267 [
21268 '174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c',
21269 'ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73'
21270 ],
21271 [
21272 '959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba',
21273 '2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd'
21274 ],
21275 [
21276 'd2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151',
21277 'e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405'
21278 ],
21279 [
21280 '64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073',
21281 'd99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589'
21282 ],
21283 [
21284 '8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458',
21285 '38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e'
21286 ],
21287 [
21288 '13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b',
21289 '69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27'
21290 ],
21291 [
21292 'bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366',
21293 'd3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1'
21294 ],
21295 [
21296 '8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa',
21297 '40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482'
21298 ],
21299 [
21300 '8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0',
21301 '620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945'
21302 ],
21303 [
21304 'dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787',
21305 '7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573'
21306 ],
21307 [
21308 'f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e',
21309 'ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82'
21310 ]
21311 ]
21312 },
21313 naf: {
21314 wnd: 7,
21315 points: [
21316 [
21317 'f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9',
21318 '388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672'
21319 ],
21320 [
21321 '2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4',
21322 'd8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6'
21323 ],
21324 [
21325 '5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc',
21326 '6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da'
21327 ],
21328 [
21329 'acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe',
21330 'cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37'
21331 ],
21332 [
21333 '774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb',
21334 'd984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b'
21335 ],
21336 [
21337 'f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8',
21338 'ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81'
21339 ],
21340 [
21341 'd7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e',
21342 '581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58'
21343 ],
21344 [
21345 'defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34',
21346 '4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77'
21347 ],
21348 [
21349 '2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c',
21350 '85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a'
21351 ],
21352 [
21353 '352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5',
21354 '321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c'
21355 ],
21356 [
21357 '2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f',
21358 '2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67'
21359 ],
21360 [
21361 '9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714',
21362 '73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402'
21363 ],
21364 [
21365 'daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729',
21366 'a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55'
21367 ],
21368 [
21369 'c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db',
21370 '2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482'
21371 ],
21372 [
21373 '6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4',
21374 'e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82'
21375 ],
21376 [
21377 '1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5',
21378 'b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396'
21379 ],
21380 [
21381 '605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479',
21382 '2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49'
21383 ],
21384 [
21385 '62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d',
21386 '80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf'
21387 ],
21388 [
21389 '80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f',
21390 '1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a'
21391 ],
21392 [
21393 '7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb',
21394 'd0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7'
21395 ],
21396 [
21397 'd528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9',
21398 'eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933'
21399 ],
21400 [
21401 '49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963',
21402 '758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a'
21403 ],
21404 [
21405 '77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74',
21406 '958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6'
21407 ],
21408 [
21409 'f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530',
21410 'e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37'
21411 ],
21412 [
21413 '463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b',
21414 '5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e'
21415 ],
21416 [
21417 'f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247',
21418 'cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6'
21419 ],
21420 [
21421 'caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1',
21422 'cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476'
21423 ],
21424 [
21425 '2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120',
21426 '4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40'
21427 ],
21428 [
21429 '7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435',
21430 '91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61'
21431 ],
21432 [
21433 '754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18',
21434 '673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683'
21435 ],
21436 [
21437 'e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8',
21438 '59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5'
21439 ],
21440 [
21441 '186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb',
21442 '3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b'
21443 ],
21444 [
21445 'df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f',
21446 '55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417'
21447 ],
21448 [
21449 '5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143',
21450 'efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868'
21451 ],
21452 [
21453 '290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba',
21454 'e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a'
21455 ],
21456 [
21457 'af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45',
21458 'f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6'
21459 ],
21460 [
21461 '766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a',
21462 '744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996'
21463 ],
21464 [
21465 '59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e',
21466 'c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e'
21467 ],
21468 [
21469 'f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8',
21470 'e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d'
21471 ],
21472 [
21473 '7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c',
21474 '30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2'
21475 ],
21476 [
21477 '948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519',
21478 'e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e'
21479 ],
21480 [
21481 '7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab',
21482 '100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437'
21483 ],
21484 [
21485 '3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca',
21486 'ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311'
21487 ],
21488 [
21489 'd3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf',
21490 '8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4'
21491 ],
21492 [
21493 '1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610',
21494 '68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575'
21495 ],
21496 [
21497 '733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4',
21498 'f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d'
21499 ],
21500 [
21501 '15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c',
21502 'd56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d'
21503 ],
21504 [
21505 'a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940',
21506 'edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629'
21507 ],
21508 [
21509 'e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980',
21510 'a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06'
21511 ],
21512 [
21513 '311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3',
21514 '66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374'
21515 ],
21516 [
21517 '34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf',
21518 '9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee'
21519 ],
21520 [
21521 'f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63',
21522 '4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1'
21523 ],
21524 [
21525 'd7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448',
21526 'fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b'
21527 ],
21528 [
21529 '32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf',
21530 '5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661'
21531 ],
21532 [
21533 '7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5',
21534 '8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6'
21535 ],
21536 [
21537 'ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6',
21538 '8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e'
21539 ],
21540 [
21541 '16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5',
21542 '5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d'
21543 ],
21544 [
21545 'eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99',
21546 'f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc'
21547 ],
21548 [
21549 '78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51',
21550 'f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4'
21551 ],
21552 [
21553 '494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5',
21554 '42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c'
21555 ],
21556 [
21557 'a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5',
21558 '204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b'
21559 ],
21560 [
21561 'c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997',
21562 '4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913'
21563 ],
21564 [
21565 '841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881',
21566 '73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154'
21567 ],
21568 [
21569 '5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5',
21570 '39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865'
21571 ],
21572 [
21573 '36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66',
21574 'd2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc'
21575 ],
21576 [
21577 '336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726',
21578 'ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224'
21579 ],
21580 [
21581 '8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede',
21582 '6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e'
21583 ],
21584 [
21585 '1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94',
21586 '60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6'
21587 ],
21588 [
21589 '85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31',
21590 '3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511'
21591 ],
21592 [
21593 '29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51',
21594 'b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b'
21595 ],
21596 [
21597 'a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252',
21598 'ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2'
21599 ],
21600 [
21601 '4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5',
21602 'cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c'
21603 ],
21604 [
21605 'd24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b',
21606 '6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3'
21607 ],
21608 [
21609 'ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4',
21610 '322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d'
21611 ],
21612 [
21613 'af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f',
21614 '6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700'
21615 ],
21616 [
21617 'e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889',
21618 '2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4'
21619 ],
21620 [
21621 '591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246',
21622 'b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196'
21623 ],
21624 [
21625 '11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984',
21626 '998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4'
21627 ],
21628 [
21629 '3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a',
21630 'b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257'
21631 ],
21632 [
21633 'cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030',
21634 'bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13'
21635 ],
21636 [
21637 'c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197',
21638 '6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096'
21639 ],
21640 [
21641 'c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593',
21642 'c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38'
21643 ],
21644 [
21645 'a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef',
21646 '21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f'
21647 ],
21648 [
21649 '347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38',
21650 '60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448'
21651 ],
21652 [
21653 'da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a',
21654 '49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a'
21655 ],
21656 [
21657 'c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111',
21658 '5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4'
21659 ],
21660 [
21661 '4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502',
21662 '7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437'
21663 ],
21664 [
21665 '3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea',
21666 'be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7'
21667 ],
21668 [
21669 'cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26',
21670 '8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d'
21671 ],
21672 [
21673 'b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986',
21674 '39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a'
21675 ],
21676 [
21677 'd4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e',
21678 '62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54'
21679 ],
21680 [
21681 '48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4',
21682 '25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77'
21683 ],
21684 [
21685 'dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda',
21686 'ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517'
21687 ],
21688 [
21689 '6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859',
21690 'cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10'
21691 ],
21692 [
21693 'e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f',
21694 'f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125'
21695 ],
21696 [
21697 'eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c',
21698 '6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e'
21699 ],
21700 [
21701 '13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942',
21702 'fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1'
21703 ],
21704 [
21705 'ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a',
21706 '1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2'
21707 ],
21708 [
21709 'b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80',
21710 '5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423'
21711 ],
21712 [
21713 'ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d',
21714 '438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8'
21715 ],
21716 [
21717 '8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1',
21718 'cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758'
21719 ],
21720 [
21721 '52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63',
21722 'c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375'
21723 ],
21724 [
21725 'e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352',
21726 '6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d'
21727 ],
21728 [
21729 '7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193',
21730 'ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec'
21731 ],
21732 [
21733 '5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00',
21734 '9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0'
21735 ],
21736 [
21737 '32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58',
21738 'ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c'
21739 ],
21740 [
21741 'e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7',
21742 'd3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4'
21743 ],
21744 [
21745 '8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8',
21746 'c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f'
21747 ],
21748 [
21749 '4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e',
21750 '67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649'
21751 ],
21752 [
21753 '3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d',
21754 'cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826'
21755 ],
21756 [
21757 '674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b',
21758 '299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5'
21759 ],
21760 [
21761 'd32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f',
21762 'f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87'
21763 ],
21764 [
21765 '30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6',
21766 '462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b'
21767 ],
21768 [
21769 'be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297',
21770 '62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc'
21771 ],
21772 [
21773 '93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a',
21774 '7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c'
21775 ],
21776 [
21777 'b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c',
21778 'ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f'
21779 ],
21780 [
21781 'd5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52',
21782 '4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a'
21783 ],
21784 [
21785 'd3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb',
21786 'bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46'
21787 ],
21788 [
21789 '463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065',
21790 'bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f'
21791 ],
21792 [
21793 '7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917',
21794 '603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03'
21795 ],
21796 [
21797 '74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9',
21798 'cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08'
21799 ],
21800 [
21801 '30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3',
21802 '553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8'
21803 ],
21804 [
21805 '9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57',
21806 '712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373'
21807 ],
21808 [
21809 '176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66',
21810 'ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3'
21811 ],
21812 [
21813 '75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8',
21814 '9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8'
21815 ],
21816 [
21817 '809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721',
21818 '9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1'
21819 ],
21820 [
21821 '1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180',
21822 '4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9'
21823 ]
21824 ]
21825 }
21826};
21827
21828},{}],143:[function(require,module,exports){
21829'use strict';
21830
21831var utils = exports;
21832var BN = require('bn.js');
21833var minAssert = require('minimalistic-assert');
21834var minUtils = require('minimalistic-crypto-utils');
21835
21836utils.assert = minAssert;
21837utils.toArray = minUtils.toArray;
21838utils.zero2 = minUtils.zero2;
21839utils.toHex = minUtils.toHex;
21840utils.encode = minUtils.encode;
21841
21842// Represent num in a w-NAF form
21843function getNAF(num, w) {
21844 var naf = [];
21845 var ws = 1 << (w + 1);
21846 var k = num.clone();
21847 while (k.cmpn(1) >= 0) {
21848 var z;
21849 if (k.isOdd()) {
21850 var mod = k.andln(ws - 1);
21851 if (mod > (ws >> 1) - 1)
21852 z = (ws >> 1) - mod;
21853 else
21854 z = mod;
21855 k.isubn(z);
21856 } else {
21857 z = 0;
21858 }
21859 naf.push(z);
21860
21861 // Optimization, shift by word if possible
21862 var shift = (k.cmpn(0) !== 0 && k.andln(ws - 1) === 0) ? (w + 1) : 1;
21863 for (var i = 1; i < shift; i++)
21864 naf.push(0);
21865 k.iushrn(shift);
21866 }
21867
21868 return naf;
21869}
21870utils.getNAF = getNAF;
21871
21872// Represent k1, k2 in a Joint Sparse Form
21873function getJSF(k1, k2) {
21874 var jsf = [
21875 [],
21876 []
21877 ];
21878
21879 k1 = k1.clone();
21880 k2 = k2.clone();
21881 var d1 = 0;
21882 var d2 = 0;
21883 while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) {
21884
21885 // First phase
21886 var m14 = (k1.andln(3) + d1) & 3;
21887 var m24 = (k2.andln(3) + d2) & 3;
21888 if (m14 === 3)
21889 m14 = -1;
21890 if (m24 === 3)
21891 m24 = -1;
21892 var u1;
21893 if ((m14 & 1) === 0) {
21894 u1 = 0;
21895 } else {
21896 var m8 = (k1.andln(7) + d1) & 7;
21897 if ((m8 === 3 || m8 === 5) && m24 === 2)
21898 u1 = -m14;
21899 else
21900 u1 = m14;
21901 }
21902 jsf[0].push(u1);
21903
21904 var u2;
21905 if ((m24 & 1) === 0) {
21906 u2 = 0;
21907 } else {
21908 var m8 = (k2.andln(7) + d2) & 7;
21909 if ((m8 === 3 || m8 === 5) && m14 === 2)
21910 u2 = -m24;
21911 else
21912 u2 = m24;
21913 }
21914 jsf[1].push(u2);
21915
21916 // Second phase
21917 if (2 * d1 === u1 + 1)
21918 d1 = 1 - d1;
21919 if (2 * d2 === u2 + 1)
21920 d2 = 1 - d2;
21921 k1.iushrn(1);
21922 k2.iushrn(1);
21923 }
21924
21925 return jsf;
21926}
21927utils.getJSF = getJSF;
21928
21929function cachedProperty(obj, name, computer) {
21930 var key = '_' + name;
21931 obj.prototype[name] = function cachedProperty() {
21932 return this[key] !== undefined ? this[key] :
21933 this[key] = computer.call(this);
21934 };
21935}
21936utils.cachedProperty = cachedProperty;
21937
21938function parseBytes(bytes) {
21939 return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') :
21940 bytes;
21941}
21942utils.parseBytes = parseBytes;
21943
21944function intFromLE(bytes) {
21945 return new BN(bytes, 'hex', 'le');
21946}
21947utils.intFromLE = intFromLE;
21948
21949
21950},{"bn.js":79,"minimalistic-assert":167,"minimalistic-crypto-utils":168}],144:[function(require,module,exports){
21951module.exports={
21952 "_args": [
21953 [
21954 "elliptic@^6.0.0",
21955 "/usr/local/lib/node_modules/browserify/node_modules/browserify-sign"
21956 ]
21957 ],
21958 "_from": "elliptic@>=6.0.0 <7.0.0",
21959 "_hasShrinkwrap": false,
21960 "_id": "elliptic@6.5.0",
21961 "_inCache": true,
21962 "_installable": true,
21963 "_location": "/browserify/elliptic",
21964 "_nodeVersion": "12.2.0",
21965 "_npmOperationalInternal": {
21966 "host": "s3://npm-registry-packages",
21967 "tmp": "tmp/elliptic_6.5.0_1561521826385_0.20848274510512943"
21968 },
21969 "_npmUser": {
21970 "email": "fedor@indutny.com",
21971 "name": "indutny"
21972 },
21973 "_npmVersion": "6.9.0",
21974 "_phantomChildren": {},
21975 "_requested": {
21976 "name": "elliptic",
21977 "raw": "elliptic@^6.0.0",
21978 "rawSpec": "^6.0.0",
21979 "scope": null,
21980 "spec": ">=6.0.0 <7.0.0",
21981 "type": "range"
21982 },
21983 "_requiredBy": [
21984 "/browserify/browserify-sign",
21985 "/browserify/create-ecdh"
21986 ],
21987 "_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.0.tgz",
21988 "_shasum": "2b8ed4c891b7de3200e14412a5b8248c7af505ca",
21989 "_shrinkwrap": null,
21990 "_spec": "elliptic@^6.0.0",
21991 "_where": "/usr/local/lib/node_modules/browserify/node_modules/browserify-sign",
21992 "author": {
21993 "email": "fedor@indutny.com",
21994 "name": "Fedor Indutny"
21995 },
21996 "bugs": {
21997 "url": "https://github.com/indutny/elliptic/issues"
21998 },
21999 "dependencies": {
22000 "bn.js": "^4.4.0",
22001 "brorand": "^1.0.1",
22002 "hash.js": "^1.0.0",
22003 "hmac-drbg": "^1.0.0",
22004 "inherits": "^2.0.1",
22005 "minimalistic-assert": "^1.0.0",
22006 "minimalistic-crypto-utils": "^1.0.0"
22007 },
22008 "description": "EC cryptography",
22009 "devDependencies": {
22010 "brfs": "^1.4.3",
22011 "coveralls": "^2.11.3",
22012 "grunt": "^0.4.5",
22013 "grunt-browserify": "^5.0.0",
22014 "grunt-cli": "^1.2.0",
22015 "grunt-contrib-connect": "^1.0.0",
22016 "grunt-contrib-copy": "^1.0.0",
22017 "grunt-contrib-uglify": "^1.0.1",
22018 "grunt-mocha-istanbul": "^3.0.1",
22019 "grunt-saucelabs": "^8.6.2",
22020 "istanbul": "^0.4.2",
22021 "jscs": "^2.9.0",
22022 "jshint": "^2.6.0",
22023 "mocha": "^2.1.0"
22024 },
22025 "directories": {},
22026 "dist": {
22027 "fileCount": 17,
22028 "integrity": "sha512-eFOJTMyCYb7xtE/caJ6JJu+bhi67WCYNbkGSknu20pmM8Ke/bqOfdnZWxyoGN26JgfxTbXrsCkEw4KheCT/KGg==",
22029 "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdEu6jCRA9TVsSAnZWagAAJh4QAJXJ18MReidNMHrxFJGv\ngSONMB2uz0lWJ7eEUyggaCA/Tr6w4RBA6Ilne0Wou3jTAGou+GClpAde6Hkb\nEq1iq1brx+5gHeY3rGs8GB+T3c1JsVz+2t6934esXGM6IJNmG91TaCMSbuwQ\nTWHD62RxFylLYjffBIWt6KLximZnXcvAES0Qu7VUql1SlfvmGtaHlQAhvtLj\nG+ayBnSnWMcEvDPJdfnKi67PlGMa334spEmWzcqobFySr+y/ufiZRCp+wiSl\ndCwbFNMaH4fue+dhq1m7jGO/euFQvJw2Jf32zT/ToaM768nH8yHrrZ8lMRjs\ngCUymge8kbI5W1WA8wla7+J52Exbo6LbcBqSupVhVw6gXkOdjQCOkywBXa1c\nPiFxwOUSfdFATpkUi3/8serYCgv9NgGzvQ0rjej0//1+he6q7UUyKn9wyrdH\nMntmi18UgyQ8c1NrshKAOCb1oeniCEv7B1adfH2axH9uvMiVP8N5BMfAUNE1\nnkCD3lDXRz/7C+90DiI+h2MS3+az8ciqMTbpKlw3HrmUyCex+KvLq9+wNLGf\nyaJGd/r6NT0pu36v0M2+ul266/RbbY6D1ED/cl8gDZRFTT/SfTCkU+QAn2Mg\nfAlnn9BXogYR1XM1GNrnGUVkY7ngORiAGez5DU7P93jMpdSS9OtwAHHi1Oto\nbZ+X\r\n=LuMF\r\n-----END PGP SIGNATURE-----\r\n",
22030 "shasum": "2b8ed4c891b7de3200e14412a5b8248c7af505ca",
22031 "tarball": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.0.tgz",
22032 "unpackedSize": 118006
22033 },
22034 "gitHead": "475f066aebd14681591f0f0f18a2abc0ded8c390",
22035 "homepage": "https://github.com/indutny/elliptic",
22036 "keywords": [
22037 "Cryptography",
22038 "EC",
22039 "Elliptic",
22040 "curve"
22041 ],
22042 "license": "MIT",
22043 "main": "lib/elliptic.js",
22044 "maintainers": [
22045 {
22046 "name": "indutny",
22047 "email": "fedor@indutny.com"
22048 }
22049 ],
22050 "name": "elliptic",
22051 "optionalDependencies": {},
22052 "readme": "ERROR: No README data found!",
22053 "repository": {
22054 "type": "git",
22055 "url": "git+ssh://git@github.com/indutny/elliptic.git"
22056 },
22057 "scripts": {
22058 "jscs": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",
22059 "jshint": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",
22060 "lint": "npm run jscs && npm run jshint",
22061 "test": "npm run lint && npm run unit",
22062 "unit": "istanbul test _mocha --reporter=spec test/index.js",
22063 "version": "grunt dist && git add dist/"
22064 },
22065 "version": "6.5.0"
22066}
22067
22068},{}],145:[function(require,module,exports){
22069// Copyright Joyent, Inc. and other Node contributors.
22070//
22071// Permission is hereby granted, free of charge, to any person obtaining a
22072// copy of this software and associated documentation files (the
22073// "Software"), to deal in the Software without restriction, including
22074// without limitation the rights to use, copy, modify, merge, publish,
22075// distribute, sublicense, and/or sell copies of the Software, and to permit
22076// persons to whom the Software is furnished to do so, subject to the
22077// following conditions:
22078//
22079// The above copyright notice and this permission notice shall be included
22080// in all copies or substantial portions of the Software.
22081//
22082// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22083// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22084// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
22085// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
22086// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22087// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22088// USE OR OTHER DEALINGS IN THE SOFTWARE.
22089
22090var objectCreate = Object.create || objectCreatePolyfill
22091var objectKeys = Object.keys || objectKeysPolyfill
22092var bind = Function.prototype.bind || functionBindPolyfill
22093
22094function EventEmitter() {
22095 if (!this._events || !Object.prototype.hasOwnProperty.call(this, '_events')) {
22096 this._events = objectCreate(null);
22097 this._eventsCount = 0;
22098 }
22099
22100 this._maxListeners = this._maxListeners || undefined;
22101}
22102module.exports = EventEmitter;
22103
22104// Backwards-compat with node 0.10.x
22105EventEmitter.EventEmitter = EventEmitter;
22106
22107EventEmitter.prototype._events = undefined;
22108EventEmitter.prototype._maxListeners = undefined;
22109
22110// By default EventEmitters will print a warning if more than 10 listeners are
22111// added to it. This is a useful default which helps finding memory leaks.
22112var defaultMaxListeners = 10;
22113
22114var hasDefineProperty;
22115try {
22116 var o = {};
22117 if (Object.defineProperty) Object.defineProperty(o, 'x', { value: 0 });
22118 hasDefineProperty = o.x === 0;
22119} catch (err) { hasDefineProperty = false }
22120if (hasDefineProperty) {
22121 Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
22122 enumerable: true,
22123 get: function() {
22124 return defaultMaxListeners;
22125 },
22126 set: function(arg) {
22127 // check whether the input is a positive number (whose value is zero or
22128 // greater and not a NaN).
22129 if (typeof arg !== 'number' || arg < 0 || arg !== arg)
22130 throw new TypeError('"defaultMaxListeners" must be a positive number');
22131 defaultMaxListeners = arg;
22132 }
22133 });
22134} else {
22135 EventEmitter.defaultMaxListeners = defaultMaxListeners;
22136}
22137
22138// Obviously not all Emitters should be limited to 10. This function allows
22139// that to be increased. Set to zero for unlimited.
22140EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
22141 if (typeof n !== 'number' || n < 0 || isNaN(n))
22142 throw new TypeError('"n" argument must be a positive number');
22143 this._maxListeners = n;
22144 return this;
22145};
22146
22147function $getMaxListeners(that) {
22148 if (that._maxListeners === undefined)
22149 return EventEmitter.defaultMaxListeners;
22150 return that._maxListeners;
22151}
22152
22153EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
22154 return $getMaxListeners(this);
22155};
22156
22157// These standalone emit* functions are used to optimize calling of event
22158// handlers for fast cases because emit() itself often has a variable number of
22159// arguments and can be deoptimized because of that. These functions always have
22160// the same number of arguments and thus do not get deoptimized, so the code
22161// inside them can execute faster.
22162function emitNone(handler, isFn, self) {
22163 if (isFn)
22164 handler.call(self);
22165 else {
22166 var len = handler.length;
22167 var listeners = arrayClone(handler, len);
22168 for (var i = 0; i < len; ++i)
22169 listeners[i].call(self);
22170 }
22171}
22172function emitOne(handler, isFn, self, arg1) {
22173 if (isFn)
22174 handler.call(self, arg1);
22175 else {
22176 var len = handler.length;
22177 var listeners = arrayClone(handler, len);
22178 for (var i = 0; i < len; ++i)
22179 listeners[i].call(self, arg1);
22180 }
22181}
22182function emitTwo(handler, isFn, self, arg1, arg2) {
22183 if (isFn)
22184 handler.call(self, arg1, arg2);
22185 else {
22186 var len = handler.length;
22187 var listeners = arrayClone(handler, len);
22188 for (var i = 0; i < len; ++i)
22189 listeners[i].call(self, arg1, arg2);
22190 }
22191}
22192function emitThree(handler, isFn, self, arg1, arg2, arg3) {
22193 if (isFn)
22194 handler.call(self, arg1, arg2, arg3);
22195 else {
22196 var len = handler.length;
22197 var listeners = arrayClone(handler, len);
22198 for (var i = 0; i < len; ++i)
22199 listeners[i].call(self, arg1, arg2, arg3);
22200 }
22201}
22202
22203function emitMany(handler, isFn, self, args) {
22204 if (isFn)
22205 handler.apply(self, args);
22206 else {
22207 var len = handler.length;
22208 var listeners = arrayClone(handler, len);
22209 for (var i = 0; i < len; ++i)
22210 listeners[i].apply(self, args);
22211 }
22212}
22213
22214EventEmitter.prototype.emit = function emit(type) {
22215 var er, handler, len, args, i, events;
22216 var doError = (type === 'error');
22217
22218 events = this._events;
22219 if (events)
22220 doError = (doError && events.error == null);
22221 else if (!doError)
22222 return false;
22223
22224 // If there is no 'error' event listener then throw.
22225 if (doError) {
22226 if (arguments.length > 1)
22227 er = arguments[1];
22228 if (er instanceof Error) {
22229 throw er; // Unhandled 'error' event
22230 } else {
22231 // At least give some kind of context to the user
22232 var err = new Error('Unhandled "error" event. (' + er + ')');
22233 err.context = er;
22234 throw err;
22235 }
22236 return false;
22237 }
22238
22239 handler = events[type];
22240
22241 if (!handler)
22242 return false;
22243
22244 var isFn = typeof handler === 'function';
22245 len = arguments.length;
22246 switch (len) {
22247 // fast cases
22248 case 1:
22249 emitNone(handler, isFn, this);
22250 break;
22251 case 2:
22252 emitOne(handler, isFn, this, arguments[1]);
22253 break;
22254 case 3:
22255 emitTwo(handler, isFn, this, arguments[1], arguments[2]);
22256 break;
22257 case 4:
22258 emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
22259 break;
22260 // slower
22261 default:
22262 args = new Array(len - 1);
22263 for (i = 1; i < len; i++)
22264 args[i - 1] = arguments[i];
22265 emitMany(handler, isFn, this, args);
22266 }
22267
22268 return true;
22269};
22270
22271function _addListener(target, type, listener, prepend) {
22272 var m;
22273 var events;
22274 var existing;
22275
22276 if (typeof listener !== 'function')
22277 throw new TypeError('"listener" argument must be a function');
22278
22279 events = target._events;
22280 if (!events) {
22281 events = target._events = objectCreate(null);
22282 target._eventsCount = 0;
22283 } else {
22284 // To avoid recursion in the case that type === "newListener"! Before
22285 // adding it to the listeners, first emit "newListener".
22286 if (events.newListener) {
22287 target.emit('newListener', type,
22288 listener.listener ? listener.listener : listener);
22289
22290 // Re-assign `events` because a newListener handler could have caused the
22291 // this._events to be assigned to a new object
22292 events = target._events;
22293 }
22294 existing = events[type];
22295 }
22296
22297 if (!existing) {
22298 // Optimize the case of one listener. Don't need the extra array object.
22299 existing = events[type] = listener;
22300 ++target._eventsCount;
22301 } else {
22302 if (typeof existing === 'function') {
22303 // Adding the second element, need to change to array.
22304 existing = events[type] =
22305 prepend ? [listener, existing] : [existing, listener];
22306 } else {
22307 // If we've already got an array, just append.
22308 if (prepend) {
22309 existing.unshift(listener);
22310 } else {
22311 existing.push(listener);
22312 }
22313 }
22314
22315 // Check for listener leak
22316 if (!existing.warned) {
22317 m = $getMaxListeners(target);
22318 if (m && m > 0 && existing.length > m) {
22319 existing.warned = true;
22320 var w = new Error('Possible EventEmitter memory leak detected. ' +
22321 existing.length + ' "' + String(type) + '" listeners ' +
22322 'added. Use emitter.setMaxListeners() to ' +
22323 'increase limit.');
22324 w.name = 'MaxListenersExceededWarning';
22325 w.emitter = target;
22326 w.type = type;
22327 w.count = existing.length;
22328 if (typeof console === 'object' && console.warn) {
22329 console.warn('%s: %s', w.name, w.message);
22330 }
22331 }
22332 }
22333 }
22334
22335 return target;
22336}
22337
22338EventEmitter.prototype.addListener = function addListener(type, listener) {
22339 return _addListener(this, type, listener, false);
22340};
22341
22342EventEmitter.prototype.on = EventEmitter.prototype.addListener;
22343
22344EventEmitter.prototype.prependListener =
22345 function prependListener(type, listener) {
22346 return _addListener(this, type, listener, true);
22347 };
22348
22349function onceWrapper() {
22350 if (!this.fired) {
22351 this.target.removeListener(this.type, this.wrapFn);
22352 this.fired = true;
22353 switch (arguments.length) {
22354 case 0:
22355 return this.listener.call(this.target);
22356 case 1:
22357 return this.listener.call(this.target, arguments[0]);
22358 case 2:
22359 return this.listener.call(this.target, arguments[0], arguments[1]);
22360 case 3:
22361 return this.listener.call(this.target, arguments[0], arguments[1],
22362 arguments[2]);
22363 default:
22364 var args = new Array(arguments.length);
22365 for (var i = 0; i < args.length; ++i)
22366 args[i] = arguments[i];
22367 this.listener.apply(this.target, args);
22368 }
22369 }
22370}
22371
22372function _onceWrap(target, type, listener) {
22373 var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
22374 var wrapped = bind.call(onceWrapper, state);
22375 wrapped.listener = listener;
22376 state.wrapFn = wrapped;
22377 return wrapped;
22378}
22379
22380EventEmitter.prototype.once = function once(type, listener) {
22381 if (typeof listener !== 'function')
22382 throw new TypeError('"listener" argument must be a function');
22383 this.on(type, _onceWrap(this, type, listener));
22384 return this;
22385};
22386
22387EventEmitter.prototype.prependOnceListener =
22388 function prependOnceListener(type, listener) {
22389 if (typeof listener !== 'function')
22390 throw new TypeError('"listener" argument must be a function');
22391 this.prependListener(type, _onceWrap(this, type, listener));
22392 return this;
22393 };
22394
22395// Emits a 'removeListener' event if and only if the listener was removed.
22396EventEmitter.prototype.removeListener =
22397 function removeListener(type, listener) {
22398 var list, events, position, i, originalListener;
22399
22400 if (typeof listener !== 'function')
22401 throw new TypeError('"listener" argument must be a function');
22402
22403 events = this._events;
22404 if (!events)
22405 return this;
22406
22407 list = events[type];
22408 if (!list)
22409 return this;
22410
22411 if (list === listener || list.listener === listener) {
22412 if (--this._eventsCount === 0)
22413 this._events = objectCreate(null);
22414 else {
22415 delete events[type];
22416 if (events.removeListener)
22417 this.emit('removeListener', type, list.listener || listener);
22418 }
22419 } else if (typeof list !== 'function') {
22420 position = -1;
22421
22422 for (i = list.length - 1; i >= 0; i--) {
22423 if (list[i] === listener || list[i].listener === listener) {
22424 originalListener = list[i].listener;
22425 position = i;
22426 break;
22427 }
22428 }
22429
22430 if (position < 0)
22431 return this;
22432
22433 if (position === 0)
22434 list.shift();
22435 else
22436 spliceOne(list, position);
22437
22438 if (list.length === 1)
22439 events[type] = list[0];
22440
22441 if (events.removeListener)
22442 this.emit('removeListener', type, originalListener || listener);
22443 }
22444
22445 return this;
22446 };
22447
22448EventEmitter.prototype.removeAllListeners =
22449 function removeAllListeners(type) {
22450 var listeners, events, i;
22451
22452 events = this._events;
22453 if (!events)
22454 return this;
22455
22456 // not listening for removeListener, no need to emit
22457 if (!events.removeListener) {
22458 if (arguments.length === 0) {
22459 this._events = objectCreate(null);
22460 this._eventsCount = 0;
22461 } else if (events[type]) {
22462 if (--this._eventsCount === 0)
22463 this._events = objectCreate(null);
22464 else
22465 delete events[type];
22466 }
22467 return this;
22468 }
22469
22470 // emit removeListener for all listeners on all events
22471 if (arguments.length === 0) {
22472 var keys = objectKeys(events);
22473 var key;
22474 for (i = 0; i < keys.length; ++i) {
22475 key = keys[i];
22476 if (key === 'removeListener') continue;
22477 this.removeAllListeners(key);
22478 }
22479 this.removeAllListeners('removeListener');
22480 this._events = objectCreate(null);
22481 this._eventsCount = 0;
22482 return this;
22483 }
22484
22485 listeners = events[type];
22486
22487 if (typeof listeners === 'function') {
22488 this.removeListener(type, listeners);
22489 } else if (listeners) {
22490 // LIFO order
22491 for (i = listeners.length - 1; i >= 0; i--) {
22492 this.removeListener(type, listeners[i]);
22493 }
22494 }
22495
22496 return this;
22497 };
22498
22499function _listeners(target, type, unwrap) {
22500 var events = target._events;
22501
22502 if (!events)
22503 return [];
22504
22505 var evlistener = events[type];
22506 if (!evlistener)
22507 return [];
22508
22509 if (typeof evlistener === 'function')
22510 return unwrap ? [evlistener.listener || evlistener] : [evlistener];
22511
22512 return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
22513}
22514
22515EventEmitter.prototype.listeners = function listeners(type) {
22516 return _listeners(this, type, true);
22517};
22518
22519EventEmitter.prototype.rawListeners = function rawListeners(type) {
22520 return _listeners(this, type, false);
22521};
22522
22523EventEmitter.listenerCount = function(emitter, type) {
22524 if (typeof emitter.listenerCount === 'function') {
22525 return emitter.listenerCount(type);
22526 } else {
22527 return listenerCount.call(emitter, type);
22528 }
22529};
22530
22531EventEmitter.prototype.listenerCount = listenerCount;
22532function listenerCount(type) {
22533 var events = this._events;
22534
22535 if (events) {
22536 var evlistener = events[type];
22537
22538 if (typeof evlistener === 'function') {
22539 return 1;
22540 } else if (evlistener) {
22541 return evlistener.length;
22542 }
22543 }
22544
22545 return 0;
22546}
22547
22548EventEmitter.prototype.eventNames = function eventNames() {
22549 return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
22550};
22551
22552// About 1.5x faster than the two-arg version of Array#splice().
22553function spliceOne(list, index) {
22554 for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1)
22555 list[i] = list[k];
22556 list.pop();
22557}
22558
22559function arrayClone(arr, n) {
22560 var copy = new Array(n);
22561 for (var i = 0; i < n; ++i)
22562 copy[i] = arr[i];
22563 return copy;
22564}
22565
22566function unwrapListeners(arr) {
22567 var ret = new Array(arr.length);
22568 for (var i = 0; i < ret.length; ++i) {
22569 ret[i] = arr[i].listener || arr[i];
22570 }
22571 return ret;
22572}
22573
22574function objectCreatePolyfill(proto) {
22575 var F = function() {};
22576 F.prototype = proto;
22577 return new F;
22578}
22579function objectKeysPolyfill(obj) {
22580 var keys = [];
22581 for (var k in obj) if (Object.prototype.hasOwnProperty.call(obj, k)) {
22582 keys.push(k);
22583 }
22584 return k;
22585}
22586function functionBindPolyfill(context) {
22587 var fn = this;
22588 return function () {
22589 return fn.apply(context, arguments);
22590 };
22591}
22592
22593},{}],146:[function(require,module,exports){
22594arguments[4][38][0].apply(exports,arguments)
22595},{"dup":38,"md5.js":165,"safe-buffer":206}],147:[function(require,module,exports){
22596arguments[4][43][0].apply(exports,arguments)
22597},{"dup":43,"inherits":162,"safe-buffer":206,"stream":215}],148:[function(require,module,exports){
22598var hash = exports;
22599
22600hash.utils = require('./hash/utils');
22601hash.common = require('./hash/common');
22602hash.sha = require('./hash/sha');
22603hash.ripemd = require('./hash/ripemd');
22604hash.hmac = require('./hash/hmac');
22605
22606// Proxy hash functions to the main object
22607hash.sha1 = hash.sha.sha1;
22608hash.sha256 = hash.sha.sha256;
22609hash.sha224 = hash.sha.sha224;
22610hash.sha384 = hash.sha.sha384;
22611hash.sha512 = hash.sha.sha512;
22612hash.ripemd160 = hash.ripemd.ripemd160;
22613
22614},{"./hash/common":149,"./hash/hmac":150,"./hash/ripemd":151,"./hash/sha":152,"./hash/utils":159}],149:[function(require,module,exports){
22615'use strict';
22616
22617var utils = require('./utils');
22618var assert = require('minimalistic-assert');
22619
22620function BlockHash() {
22621 this.pending = null;
22622 this.pendingTotal = 0;
22623 this.blockSize = this.constructor.blockSize;
22624 this.outSize = this.constructor.outSize;
22625 this.hmacStrength = this.constructor.hmacStrength;
22626 this.padLength = this.constructor.padLength / 8;
22627 this.endian = 'big';
22628
22629 this._delta8 = this.blockSize / 8;
22630 this._delta32 = this.blockSize / 32;
22631}
22632exports.BlockHash = BlockHash;
22633
22634BlockHash.prototype.update = function update(msg, enc) {
22635 // Convert message to array, pad it, and join into 32bit blocks
22636 msg = utils.toArray(msg, enc);
22637 if (!this.pending)
22638 this.pending = msg;
22639 else
22640 this.pending = this.pending.concat(msg);
22641 this.pendingTotal += msg.length;
22642
22643 // Enough data, try updating
22644 if (this.pending.length >= this._delta8) {
22645 msg = this.pending;
22646
22647 // Process pending data in blocks
22648 var r = msg.length % this._delta8;
22649 this.pending = msg.slice(msg.length - r, msg.length);
22650 if (this.pending.length === 0)
22651 this.pending = null;
22652
22653 msg = utils.join32(msg, 0, msg.length - r, this.endian);
22654 for (var i = 0; i < msg.length; i += this._delta32)
22655 this._update(msg, i, i + this._delta32);
22656 }
22657
22658 return this;
22659};
22660
22661BlockHash.prototype.digest = function digest(enc) {
22662 this.update(this._pad());
22663 assert(this.pending === null);
22664
22665 return this._digest(enc);
22666};
22667
22668BlockHash.prototype._pad = function pad() {
22669 var len = this.pendingTotal;
22670 var bytes = this._delta8;
22671 var k = bytes - ((len + this.padLength) % bytes);
22672 var res = new Array(k + this.padLength);
22673 res[0] = 0x80;
22674 for (var i = 1; i < k; i++)
22675 res[i] = 0;
22676
22677 // Append length
22678 len <<= 3;
22679 if (this.endian === 'big') {
22680 for (var t = 8; t < this.padLength; t++)
22681 res[i++] = 0;
22682
22683 res[i++] = 0;
22684 res[i++] = 0;
22685 res[i++] = 0;
22686 res[i++] = 0;
22687 res[i++] = (len >>> 24) & 0xff;
22688 res[i++] = (len >>> 16) & 0xff;
22689 res[i++] = (len >>> 8) & 0xff;
22690 res[i++] = len & 0xff;
22691 } else {
22692 res[i++] = len & 0xff;
22693 res[i++] = (len >>> 8) & 0xff;
22694 res[i++] = (len >>> 16) & 0xff;
22695 res[i++] = (len >>> 24) & 0xff;
22696 res[i++] = 0;
22697 res[i++] = 0;
22698 res[i++] = 0;
22699 res[i++] = 0;
22700
22701 for (t = 8; t < this.padLength; t++)
22702 res[i++] = 0;
22703 }
22704
22705 return res;
22706};
22707
22708},{"./utils":159,"minimalistic-assert":167}],150:[function(require,module,exports){
22709'use strict';
22710
22711var utils = require('./utils');
22712var assert = require('minimalistic-assert');
22713
22714function Hmac(hash, key, enc) {
22715 if (!(this instanceof Hmac))
22716 return new Hmac(hash, key, enc);
22717 this.Hash = hash;
22718 this.blockSize = hash.blockSize / 8;
22719 this.outSize = hash.outSize / 8;
22720 this.inner = null;
22721 this.outer = null;
22722
22723 this._init(utils.toArray(key, enc));
22724}
22725module.exports = Hmac;
22726
22727Hmac.prototype._init = function init(key) {
22728 // Shorten key, if needed
22729 if (key.length > this.blockSize)
22730 key = new this.Hash().update(key).digest();
22731 assert(key.length <= this.blockSize);
22732
22733 // Add padding to key
22734 for (var i = key.length; i < this.blockSize; i++)
22735 key.push(0);
22736
22737 for (i = 0; i < key.length; i++)
22738 key[i] ^= 0x36;
22739 this.inner = new this.Hash().update(key);
22740
22741 // 0x36 ^ 0x5c = 0x6a
22742 for (i = 0; i < key.length; i++)
22743 key[i] ^= 0x6a;
22744 this.outer = new this.Hash().update(key);
22745};
22746
22747Hmac.prototype.update = function update(msg, enc) {
22748 this.inner.update(msg, enc);
22749 return this;
22750};
22751
22752Hmac.prototype.digest = function digest(enc) {
22753 this.outer.update(this.inner.digest());
22754 return this.outer.digest(enc);
22755};
22756
22757},{"./utils":159,"minimalistic-assert":167}],151:[function(require,module,exports){
22758'use strict';
22759
22760var utils = require('./utils');
22761var common = require('./common');
22762
22763var rotl32 = utils.rotl32;
22764var sum32 = utils.sum32;
22765var sum32_3 = utils.sum32_3;
22766var sum32_4 = utils.sum32_4;
22767var BlockHash = common.BlockHash;
22768
22769function RIPEMD160() {
22770 if (!(this instanceof RIPEMD160))
22771 return new RIPEMD160();
22772
22773 BlockHash.call(this);
22774
22775 this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ];
22776 this.endian = 'little';
22777}
22778utils.inherits(RIPEMD160, BlockHash);
22779exports.ripemd160 = RIPEMD160;
22780
22781RIPEMD160.blockSize = 512;
22782RIPEMD160.outSize = 160;
22783RIPEMD160.hmacStrength = 192;
22784RIPEMD160.padLength = 64;
22785
22786RIPEMD160.prototype._update = function update(msg, start) {
22787 var A = this.h[0];
22788 var B = this.h[1];
22789 var C = this.h[2];
22790 var D = this.h[3];
22791 var E = this.h[4];
22792 var Ah = A;
22793 var Bh = B;
22794 var Ch = C;
22795 var Dh = D;
22796 var Eh = E;
22797 for (var j = 0; j < 80; j++) {
22798 var T = sum32(
22799 rotl32(
22800 sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)),
22801 s[j]),
22802 E);
22803 A = E;
22804 E = D;
22805 D = rotl32(C, 10);
22806 C = B;
22807 B = T;
22808 T = sum32(
22809 rotl32(
22810 sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)),
22811 sh[j]),
22812 Eh);
22813 Ah = Eh;
22814 Eh = Dh;
22815 Dh = rotl32(Ch, 10);
22816 Ch = Bh;
22817 Bh = T;
22818 }
22819 T = sum32_3(this.h[1], C, Dh);
22820 this.h[1] = sum32_3(this.h[2], D, Eh);
22821 this.h[2] = sum32_3(this.h[3], E, Ah);
22822 this.h[3] = sum32_3(this.h[4], A, Bh);
22823 this.h[4] = sum32_3(this.h[0], B, Ch);
22824 this.h[0] = T;
22825};
22826
22827RIPEMD160.prototype._digest = function digest(enc) {
22828 if (enc === 'hex')
22829 return utils.toHex32(this.h, 'little');
22830 else
22831 return utils.split32(this.h, 'little');
22832};
22833
22834function f(j, x, y, z) {
22835 if (j <= 15)
22836 return x ^ y ^ z;
22837 else if (j <= 31)
22838 return (x & y) | ((~x) & z);
22839 else if (j <= 47)
22840 return (x | (~y)) ^ z;
22841 else if (j <= 63)
22842 return (x & z) | (y & (~z));
22843 else
22844 return x ^ (y | (~z));
22845}
22846
22847function K(j) {
22848 if (j <= 15)
22849 return 0x00000000;
22850 else if (j <= 31)
22851 return 0x5a827999;
22852 else if (j <= 47)
22853 return 0x6ed9eba1;
22854 else if (j <= 63)
22855 return 0x8f1bbcdc;
22856 else
22857 return 0xa953fd4e;
22858}
22859
22860function Kh(j) {
22861 if (j <= 15)
22862 return 0x50a28be6;
22863 else if (j <= 31)
22864 return 0x5c4dd124;
22865 else if (j <= 47)
22866 return 0x6d703ef3;
22867 else if (j <= 63)
22868 return 0x7a6d76e9;
22869 else
22870 return 0x00000000;
22871}
22872
22873var r = [
22874 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
22875 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
22876 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
22877 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
22878 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
22879];
22880
22881var rh = [
22882 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
22883 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
22884 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
22885 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
22886 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
22887];
22888
22889var s = [
22890 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
22891 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
22892 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
22893 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
22894 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
22895];
22896
22897var sh = [
22898 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
22899 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
22900 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
22901 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
22902 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
22903];
22904
22905},{"./common":149,"./utils":159}],152:[function(require,module,exports){
22906'use strict';
22907
22908exports.sha1 = require('./sha/1');
22909exports.sha224 = require('./sha/224');
22910exports.sha256 = require('./sha/256');
22911exports.sha384 = require('./sha/384');
22912exports.sha512 = require('./sha/512');
22913
22914},{"./sha/1":153,"./sha/224":154,"./sha/256":155,"./sha/384":156,"./sha/512":157}],153:[function(require,module,exports){
22915'use strict';
22916
22917var utils = require('../utils');
22918var common = require('../common');
22919var shaCommon = require('./common');
22920
22921var rotl32 = utils.rotl32;
22922var sum32 = utils.sum32;
22923var sum32_5 = utils.sum32_5;
22924var ft_1 = shaCommon.ft_1;
22925var BlockHash = common.BlockHash;
22926
22927var sha1_K = [
22928 0x5A827999, 0x6ED9EBA1,
22929 0x8F1BBCDC, 0xCA62C1D6
22930];
22931
22932function SHA1() {
22933 if (!(this instanceof SHA1))
22934 return new SHA1();
22935
22936 BlockHash.call(this);
22937 this.h = [
22938 0x67452301, 0xefcdab89, 0x98badcfe,
22939 0x10325476, 0xc3d2e1f0 ];
22940 this.W = new Array(80);
22941}
22942
22943utils.inherits(SHA1, BlockHash);
22944module.exports = SHA1;
22945
22946SHA1.blockSize = 512;
22947SHA1.outSize = 160;
22948SHA1.hmacStrength = 80;
22949SHA1.padLength = 64;
22950
22951SHA1.prototype._update = function _update(msg, start) {
22952 var W = this.W;
22953
22954 for (var i = 0; i < 16; i++)
22955 W[i] = msg[start + i];
22956
22957 for(; i < W.length; i++)
22958 W[i] = rotl32(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1);
22959
22960 var a = this.h[0];
22961 var b = this.h[1];
22962 var c = this.h[2];
22963 var d = this.h[3];
22964 var e = this.h[4];
22965
22966 for (i = 0; i < W.length; i++) {
22967 var s = ~~(i / 20);
22968 var t = sum32_5(rotl32(a, 5), ft_1(s, b, c, d), e, W[i], sha1_K[s]);
22969 e = d;
22970 d = c;
22971 c = rotl32(b, 30);
22972 b = a;
22973 a = t;
22974 }
22975
22976 this.h[0] = sum32(this.h[0], a);
22977 this.h[1] = sum32(this.h[1], b);
22978 this.h[2] = sum32(this.h[2], c);
22979 this.h[3] = sum32(this.h[3], d);
22980 this.h[4] = sum32(this.h[4], e);
22981};
22982
22983SHA1.prototype._digest = function digest(enc) {
22984 if (enc === 'hex')
22985 return utils.toHex32(this.h, 'big');
22986 else
22987 return utils.split32(this.h, 'big');
22988};
22989
22990},{"../common":149,"../utils":159,"./common":158}],154:[function(require,module,exports){
22991'use strict';
22992
22993var utils = require('../utils');
22994var SHA256 = require('./256');
22995
22996function SHA224() {
22997 if (!(this instanceof SHA224))
22998 return new SHA224();
22999
23000 SHA256.call(this);
23001 this.h = [
23002 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
23003 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 ];
23004}
23005utils.inherits(SHA224, SHA256);
23006module.exports = SHA224;
23007
23008SHA224.blockSize = 512;
23009SHA224.outSize = 224;
23010SHA224.hmacStrength = 192;
23011SHA224.padLength = 64;
23012
23013SHA224.prototype._digest = function digest(enc) {
23014 // Just truncate output
23015 if (enc === 'hex')
23016 return utils.toHex32(this.h.slice(0, 7), 'big');
23017 else
23018 return utils.split32(this.h.slice(0, 7), 'big');
23019};
23020
23021
23022},{"../utils":159,"./256":155}],155:[function(require,module,exports){
23023'use strict';
23024
23025var utils = require('../utils');
23026var common = require('../common');
23027var shaCommon = require('./common');
23028var assert = require('minimalistic-assert');
23029
23030var sum32 = utils.sum32;
23031var sum32_4 = utils.sum32_4;
23032var sum32_5 = utils.sum32_5;
23033var ch32 = shaCommon.ch32;
23034var maj32 = shaCommon.maj32;
23035var s0_256 = shaCommon.s0_256;
23036var s1_256 = shaCommon.s1_256;
23037var g0_256 = shaCommon.g0_256;
23038var g1_256 = shaCommon.g1_256;
23039
23040var BlockHash = common.BlockHash;
23041
23042var sha256_K = [
23043 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
23044 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
23045 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
23046 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
23047 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
23048 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
23049 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
23050 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
23051 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
23052 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
23053 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
23054 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
23055 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
23056 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
23057 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
23058 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
23059];
23060
23061function SHA256() {
23062 if (!(this instanceof SHA256))
23063 return new SHA256();
23064
23065 BlockHash.call(this);
23066 this.h = [
23067 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
23068 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
23069 ];
23070 this.k = sha256_K;
23071 this.W = new Array(64);
23072}
23073utils.inherits(SHA256, BlockHash);
23074module.exports = SHA256;
23075
23076SHA256.blockSize = 512;
23077SHA256.outSize = 256;
23078SHA256.hmacStrength = 192;
23079SHA256.padLength = 64;
23080
23081SHA256.prototype._update = function _update(msg, start) {
23082 var W = this.W;
23083
23084 for (var i = 0; i < 16; i++)
23085 W[i] = msg[start + i];
23086 for (; i < W.length; i++)
23087 W[i] = sum32_4(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]);
23088
23089 var a = this.h[0];
23090 var b = this.h[1];
23091 var c = this.h[2];
23092 var d = this.h[3];
23093 var e = this.h[4];
23094 var f = this.h[5];
23095 var g = this.h[6];
23096 var h = this.h[7];
23097
23098 assert(this.k.length === W.length);
23099 for (i = 0; i < W.length; i++) {
23100 var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]);
23101 var T2 = sum32(s0_256(a), maj32(a, b, c));
23102 h = g;
23103 g = f;
23104 f = e;
23105 e = sum32(d, T1);
23106 d = c;
23107 c = b;
23108 b = a;
23109 a = sum32(T1, T2);
23110 }
23111
23112 this.h[0] = sum32(this.h[0], a);
23113 this.h[1] = sum32(this.h[1], b);
23114 this.h[2] = sum32(this.h[2], c);
23115 this.h[3] = sum32(this.h[3], d);
23116 this.h[4] = sum32(this.h[4], e);
23117 this.h[5] = sum32(this.h[5], f);
23118 this.h[6] = sum32(this.h[6], g);
23119 this.h[7] = sum32(this.h[7], h);
23120};
23121
23122SHA256.prototype._digest = function digest(enc) {
23123 if (enc === 'hex')
23124 return utils.toHex32(this.h, 'big');
23125 else
23126 return utils.split32(this.h, 'big');
23127};
23128
23129},{"../common":149,"../utils":159,"./common":158,"minimalistic-assert":167}],156:[function(require,module,exports){
23130'use strict';
23131
23132var utils = require('../utils');
23133
23134var SHA512 = require('./512');
23135
23136function SHA384() {
23137 if (!(this instanceof SHA384))
23138 return new SHA384();
23139
23140 SHA512.call(this);
23141 this.h = [
23142 0xcbbb9d5d, 0xc1059ed8,
23143 0x629a292a, 0x367cd507,
23144 0x9159015a, 0x3070dd17,
23145 0x152fecd8, 0xf70e5939,
23146 0x67332667, 0xffc00b31,
23147 0x8eb44a87, 0x68581511,
23148 0xdb0c2e0d, 0x64f98fa7,
23149 0x47b5481d, 0xbefa4fa4 ];
23150}
23151utils.inherits(SHA384, SHA512);
23152module.exports = SHA384;
23153
23154SHA384.blockSize = 1024;
23155SHA384.outSize = 384;
23156SHA384.hmacStrength = 192;
23157SHA384.padLength = 128;
23158
23159SHA384.prototype._digest = function digest(enc) {
23160 if (enc === 'hex')
23161 return utils.toHex32(this.h.slice(0, 12), 'big');
23162 else
23163 return utils.split32(this.h.slice(0, 12), 'big');
23164};
23165
23166},{"../utils":159,"./512":157}],157:[function(require,module,exports){
23167'use strict';
23168
23169var utils = require('../utils');
23170var common = require('../common');
23171var assert = require('minimalistic-assert');
23172
23173var rotr64_hi = utils.rotr64_hi;
23174var rotr64_lo = utils.rotr64_lo;
23175var shr64_hi = utils.shr64_hi;
23176var shr64_lo = utils.shr64_lo;
23177var sum64 = utils.sum64;
23178var sum64_hi = utils.sum64_hi;
23179var sum64_lo = utils.sum64_lo;
23180var sum64_4_hi = utils.sum64_4_hi;
23181var sum64_4_lo = utils.sum64_4_lo;
23182var sum64_5_hi = utils.sum64_5_hi;
23183var sum64_5_lo = utils.sum64_5_lo;
23184
23185var BlockHash = common.BlockHash;
23186
23187var sha512_K = [
23188 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
23189 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
23190 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
23191 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
23192 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
23193 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
23194 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
23195 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
23196 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
23197 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
23198 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
23199 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
23200 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
23201 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
23202 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
23203 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
23204 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
23205 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
23206 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
23207 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
23208 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
23209 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
23210 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
23211 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
23212 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
23213 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
23214 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
23215 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
23216 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
23217 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
23218 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
23219 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
23220 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
23221 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
23222 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
23223 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
23224 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
23225 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
23226 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
23227 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
23228];
23229
23230function SHA512() {
23231 if (!(this instanceof SHA512))
23232 return new SHA512();
23233
23234 BlockHash.call(this);
23235 this.h = [
23236 0x6a09e667, 0xf3bcc908,
23237 0xbb67ae85, 0x84caa73b,
23238 0x3c6ef372, 0xfe94f82b,
23239 0xa54ff53a, 0x5f1d36f1,
23240 0x510e527f, 0xade682d1,
23241 0x9b05688c, 0x2b3e6c1f,
23242 0x1f83d9ab, 0xfb41bd6b,
23243 0x5be0cd19, 0x137e2179 ];
23244 this.k = sha512_K;
23245 this.W = new Array(160);
23246}
23247utils.inherits(SHA512, BlockHash);
23248module.exports = SHA512;
23249
23250SHA512.blockSize = 1024;
23251SHA512.outSize = 512;
23252SHA512.hmacStrength = 192;
23253SHA512.padLength = 128;
23254
23255SHA512.prototype._prepareBlock = function _prepareBlock(msg, start) {
23256 var W = this.W;
23257
23258 // 32 x 32bit words
23259 for (var i = 0; i < 32; i++)
23260 W[i] = msg[start + i];
23261 for (; i < W.length; i += 2) {
23262 var c0_hi = g1_512_hi(W[i - 4], W[i - 3]); // i - 2
23263 var c0_lo = g1_512_lo(W[i - 4], W[i - 3]);
23264 var c1_hi = W[i - 14]; // i - 7
23265 var c1_lo = W[i - 13];
23266 var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); // i - 15
23267 var c2_lo = g0_512_lo(W[i - 30], W[i - 29]);
23268 var c3_hi = W[i - 32]; // i - 16
23269 var c3_lo = W[i - 31];
23270
23271 W[i] = sum64_4_hi(
23272 c0_hi, c0_lo,
23273 c1_hi, c1_lo,
23274 c2_hi, c2_lo,
23275 c3_hi, c3_lo);
23276 W[i + 1] = sum64_4_lo(
23277 c0_hi, c0_lo,
23278 c1_hi, c1_lo,
23279 c2_hi, c2_lo,
23280 c3_hi, c3_lo);
23281 }
23282};
23283
23284SHA512.prototype._update = function _update(msg, start) {
23285 this._prepareBlock(msg, start);
23286
23287 var W = this.W;
23288
23289 var ah = this.h[0];
23290 var al = this.h[1];
23291 var bh = this.h[2];
23292 var bl = this.h[3];
23293 var ch = this.h[4];
23294 var cl = this.h[5];
23295 var dh = this.h[6];
23296 var dl = this.h[7];
23297 var eh = this.h[8];
23298 var el = this.h[9];
23299 var fh = this.h[10];
23300 var fl = this.h[11];
23301 var gh = this.h[12];
23302 var gl = this.h[13];
23303 var hh = this.h[14];
23304 var hl = this.h[15];
23305
23306 assert(this.k.length === W.length);
23307 for (var i = 0; i < W.length; i += 2) {
23308 var c0_hi = hh;
23309 var c0_lo = hl;
23310 var c1_hi = s1_512_hi(eh, el);
23311 var c1_lo = s1_512_lo(eh, el);
23312 var c2_hi = ch64_hi(eh, el, fh, fl, gh, gl);
23313 var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl);
23314 var c3_hi = this.k[i];
23315 var c3_lo = this.k[i + 1];
23316 var c4_hi = W[i];
23317 var c4_lo = W[i + 1];
23318
23319 var T1_hi = sum64_5_hi(
23320 c0_hi, c0_lo,
23321 c1_hi, c1_lo,
23322 c2_hi, c2_lo,
23323 c3_hi, c3_lo,
23324 c4_hi, c4_lo);
23325 var T1_lo = sum64_5_lo(
23326 c0_hi, c0_lo,
23327 c1_hi, c1_lo,
23328 c2_hi, c2_lo,
23329 c3_hi, c3_lo,
23330 c4_hi, c4_lo);
23331
23332 c0_hi = s0_512_hi(ah, al);
23333 c0_lo = s0_512_lo(ah, al);
23334 c1_hi = maj64_hi(ah, al, bh, bl, ch, cl);
23335 c1_lo = maj64_lo(ah, al, bh, bl, ch, cl);
23336
23337 var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo);
23338 var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo);
23339
23340 hh = gh;
23341 hl = gl;
23342
23343 gh = fh;
23344 gl = fl;
23345
23346 fh = eh;
23347 fl = el;
23348
23349 eh = sum64_hi(dh, dl, T1_hi, T1_lo);
23350 el = sum64_lo(dl, dl, T1_hi, T1_lo);
23351
23352 dh = ch;
23353 dl = cl;
23354
23355 ch = bh;
23356 cl = bl;
23357
23358 bh = ah;
23359 bl = al;
23360
23361 ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo);
23362 al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo);
23363 }
23364
23365 sum64(this.h, 0, ah, al);
23366 sum64(this.h, 2, bh, bl);
23367 sum64(this.h, 4, ch, cl);
23368 sum64(this.h, 6, dh, dl);
23369 sum64(this.h, 8, eh, el);
23370 sum64(this.h, 10, fh, fl);
23371 sum64(this.h, 12, gh, gl);
23372 sum64(this.h, 14, hh, hl);
23373};
23374
23375SHA512.prototype._digest = function digest(enc) {
23376 if (enc === 'hex')
23377 return utils.toHex32(this.h, 'big');
23378 else
23379 return utils.split32(this.h, 'big');
23380};
23381
23382function ch64_hi(xh, xl, yh, yl, zh) {
23383 var r = (xh & yh) ^ ((~xh) & zh);
23384 if (r < 0)
23385 r += 0x100000000;
23386 return r;
23387}
23388
23389function ch64_lo(xh, xl, yh, yl, zh, zl) {
23390 var r = (xl & yl) ^ ((~xl) & zl);
23391 if (r < 0)
23392 r += 0x100000000;
23393 return r;
23394}
23395
23396function maj64_hi(xh, xl, yh, yl, zh) {
23397 var r = (xh & yh) ^ (xh & zh) ^ (yh & zh);
23398 if (r < 0)
23399 r += 0x100000000;
23400 return r;
23401}
23402
23403function maj64_lo(xh, xl, yh, yl, zh, zl) {
23404 var r = (xl & yl) ^ (xl & zl) ^ (yl & zl);
23405 if (r < 0)
23406 r += 0x100000000;
23407 return r;
23408}
23409
23410function s0_512_hi(xh, xl) {
23411 var c0_hi = rotr64_hi(xh, xl, 28);
23412 var c1_hi = rotr64_hi(xl, xh, 2); // 34
23413 var c2_hi = rotr64_hi(xl, xh, 7); // 39
23414
23415 var r = c0_hi ^ c1_hi ^ c2_hi;
23416 if (r < 0)
23417 r += 0x100000000;
23418 return r;
23419}
23420
23421function s0_512_lo(xh, xl) {
23422 var c0_lo = rotr64_lo(xh, xl, 28);
23423 var c1_lo = rotr64_lo(xl, xh, 2); // 34
23424 var c2_lo = rotr64_lo(xl, xh, 7); // 39
23425
23426 var r = c0_lo ^ c1_lo ^ c2_lo;
23427 if (r < 0)
23428 r += 0x100000000;
23429 return r;
23430}
23431
23432function s1_512_hi(xh, xl) {
23433 var c0_hi = rotr64_hi(xh, xl, 14);
23434 var c1_hi = rotr64_hi(xh, xl, 18);
23435 var c2_hi = rotr64_hi(xl, xh, 9); // 41
23436
23437 var r = c0_hi ^ c1_hi ^ c2_hi;
23438 if (r < 0)
23439 r += 0x100000000;
23440 return r;
23441}
23442
23443function s1_512_lo(xh, xl) {
23444 var c0_lo = rotr64_lo(xh, xl, 14);
23445 var c1_lo = rotr64_lo(xh, xl, 18);
23446 var c2_lo = rotr64_lo(xl, xh, 9); // 41
23447
23448 var r = c0_lo ^ c1_lo ^ c2_lo;
23449 if (r < 0)
23450 r += 0x100000000;
23451 return r;
23452}
23453
23454function g0_512_hi(xh, xl) {
23455 var c0_hi = rotr64_hi(xh, xl, 1);
23456 var c1_hi = rotr64_hi(xh, xl, 8);
23457 var c2_hi = shr64_hi(xh, xl, 7);
23458
23459 var r = c0_hi ^ c1_hi ^ c2_hi;
23460 if (r < 0)
23461 r += 0x100000000;
23462 return r;
23463}
23464
23465function g0_512_lo(xh, xl) {
23466 var c0_lo = rotr64_lo(xh, xl, 1);
23467 var c1_lo = rotr64_lo(xh, xl, 8);
23468 var c2_lo = shr64_lo(xh, xl, 7);
23469
23470 var r = c0_lo ^ c1_lo ^ c2_lo;
23471 if (r < 0)
23472 r += 0x100000000;
23473 return r;
23474}
23475
23476function g1_512_hi(xh, xl) {
23477 var c0_hi = rotr64_hi(xh, xl, 19);
23478 var c1_hi = rotr64_hi(xl, xh, 29); // 61
23479 var c2_hi = shr64_hi(xh, xl, 6);
23480
23481 var r = c0_hi ^ c1_hi ^ c2_hi;
23482 if (r < 0)
23483 r += 0x100000000;
23484 return r;
23485}
23486
23487function g1_512_lo(xh, xl) {
23488 var c0_lo = rotr64_lo(xh, xl, 19);
23489 var c1_lo = rotr64_lo(xl, xh, 29); // 61
23490 var c2_lo = shr64_lo(xh, xl, 6);
23491
23492 var r = c0_lo ^ c1_lo ^ c2_lo;
23493 if (r < 0)
23494 r += 0x100000000;
23495 return r;
23496}
23497
23498},{"../common":149,"../utils":159,"minimalistic-assert":167}],158:[function(require,module,exports){
23499'use strict';
23500
23501var utils = require('../utils');
23502var rotr32 = utils.rotr32;
23503
23504function ft_1(s, x, y, z) {
23505 if (s === 0)
23506 return ch32(x, y, z);
23507 if (s === 1 || s === 3)
23508 return p32(x, y, z);
23509 if (s === 2)
23510 return maj32(x, y, z);
23511}
23512exports.ft_1 = ft_1;
23513
23514function ch32(x, y, z) {
23515 return (x & y) ^ ((~x) & z);
23516}
23517exports.ch32 = ch32;
23518
23519function maj32(x, y, z) {
23520 return (x & y) ^ (x & z) ^ (y & z);
23521}
23522exports.maj32 = maj32;
23523
23524function p32(x, y, z) {
23525 return x ^ y ^ z;
23526}
23527exports.p32 = p32;
23528
23529function s0_256(x) {
23530 return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22);
23531}
23532exports.s0_256 = s0_256;
23533
23534function s1_256(x) {
23535 return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25);
23536}
23537exports.s1_256 = s1_256;
23538
23539function g0_256(x) {
23540 return rotr32(x, 7) ^ rotr32(x, 18) ^ (x >>> 3);
23541}
23542exports.g0_256 = g0_256;
23543
23544function g1_256(x) {
23545 return rotr32(x, 17) ^ rotr32(x, 19) ^ (x >>> 10);
23546}
23547exports.g1_256 = g1_256;
23548
23549},{"../utils":159}],159:[function(require,module,exports){
23550'use strict';
23551
23552var assert = require('minimalistic-assert');
23553var inherits = require('inherits');
23554
23555exports.inherits = inherits;
23556
23557function isSurrogatePair(msg, i) {
23558 if ((msg.charCodeAt(i) & 0xFC00) !== 0xD800) {
23559 return false;
23560 }
23561 if (i < 0 || i + 1 >= msg.length) {
23562 return false;
23563 }
23564 return (msg.charCodeAt(i + 1) & 0xFC00) === 0xDC00;
23565}
23566
23567function toArray(msg, enc) {
23568 if (Array.isArray(msg))
23569 return msg.slice();
23570 if (!msg)
23571 return [];
23572 var res = [];
23573 if (typeof msg === 'string') {
23574 if (!enc) {
23575 // Inspired by stringToUtf8ByteArray() in closure-library by Google
23576 // https://github.com/google/closure-library/blob/8598d87242af59aac233270742c8984e2b2bdbe0/closure/goog/crypt/crypt.js#L117-L143
23577 // Apache License 2.0
23578 // https://github.com/google/closure-library/blob/master/LICENSE
23579 var p = 0;
23580 for (var i = 0; i < msg.length; i++) {
23581 var c = msg.charCodeAt(i);
23582 if (c < 128) {
23583 res[p++] = c;
23584 } else if (c < 2048) {
23585 res[p++] = (c >> 6) | 192;
23586 res[p++] = (c & 63) | 128;
23587 } else if (isSurrogatePair(msg, i)) {
23588 c = 0x10000 + ((c & 0x03FF) << 10) + (msg.charCodeAt(++i) & 0x03FF);
23589 res[p++] = (c >> 18) | 240;
23590 res[p++] = ((c >> 12) & 63) | 128;
23591 res[p++] = ((c >> 6) & 63) | 128;
23592 res[p++] = (c & 63) | 128;
23593 } else {
23594 res[p++] = (c >> 12) | 224;
23595 res[p++] = ((c >> 6) & 63) | 128;
23596 res[p++] = (c & 63) | 128;
23597 }
23598 }
23599 } else if (enc === 'hex') {
23600 msg = msg.replace(/[^a-z0-9]+/ig, '');
23601 if (msg.length % 2 !== 0)
23602 msg = '0' + msg;
23603 for (i = 0; i < msg.length; i += 2)
23604 res.push(parseInt(msg[i] + msg[i + 1], 16));
23605 }
23606 } else {
23607 for (i = 0; i < msg.length; i++)
23608 res[i] = msg[i] | 0;
23609 }
23610 return res;
23611}
23612exports.toArray = toArray;
23613
23614function toHex(msg) {
23615 var res = '';
23616 for (var i = 0; i < msg.length; i++)
23617 res += zero2(msg[i].toString(16));
23618 return res;
23619}
23620exports.toHex = toHex;
23621
23622function htonl(w) {
23623 var res = (w >>> 24) |
23624 ((w >>> 8) & 0xff00) |
23625 ((w << 8) & 0xff0000) |
23626 ((w & 0xff) << 24);
23627 return res >>> 0;
23628}
23629exports.htonl = htonl;
23630
23631function toHex32(msg, endian) {
23632 var res = '';
23633 for (var i = 0; i < msg.length; i++) {
23634 var w = msg[i];
23635 if (endian === 'little')
23636 w = htonl(w);
23637 res += zero8(w.toString(16));
23638 }
23639 return res;
23640}
23641exports.toHex32 = toHex32;
23642
23643function zero2(word) {
23644 if (word.length === 1)
23645 return '0' + word;
23646 else
23647 return word;
23648}
23649exports.zero2 = zero2;
23650
23651function zero8(word) {
23652 if (word.length === 7)
23653 return '0' + word;
23654 else if (word.length === 6)
23655 return '00' + word;
23656 else if (word.length === 5)
23657 return '000' + word;
23658 else if (word.length === 4)
23659 return '0000' + word;
23660 else if (word.length === 3)
23661 return '00000' + word;
23662 else if (word.length === 2)
23663 return '000000' + word;
23664 else if (word.length === 1)
23665 return '0000000' + word;
23666 else
23667 return word;
23668}
23669exports.zero8 = zero8;
23670
23671function join32(msg, start, end, endian) {
23672 var len = end - start;
23673 assert(len % 4 === 0);
23674 var res = new Array(len / 4);
23675 for (var i = 0, k = start; i < res.length; i++, k += 4) {
23676 var w;
23677 if (endian === 'big')
23678 w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3];
23679 else
23680 w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k];
23681 res[i] = w >>> 0;
23682 }
23683 return res;
23684}
23685exports.join32 = join32;
23686
23687function split32(msg, endian) {
23688 var res = new Array(msg.length * 4);
23689 for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
23690 var m = msg[i];
23691 if (endian === 'big') {
23692 res[k] = m >>> 24;
23693 res[k + 1] = (m >>> 16) & 0xff;
23694 res[k + 2] = (m >>> 8) & 0xff;
23695 res[k + 3] = m & 0xff;
23696 } else {
23697 res[k + 3] = m >>> 24;
23698 res[k + 2] = (m >>> 16) & 0xff;
23699 res[k + 1] = (m >>> 8) & 0xff;
23700 res[k] = m & 0xff;
23701 }
23702 }
23703 return res;
23704}
23705exports.split32 = split32;
23706
23707function rotr32(w, b) {
23708 return (w >>> b) | (w << (32 - b));
23709}
23710exports.rotr32 = rotr32;
23711
23712function rotl32(w, b) {
23713 return (w << b) | (w >>> (32 - b));
23714}
23715exports.rotl32 = rotl32;
23716
23717function sum32(a, b) {
23718 return (a + b) >>> 0;
23719}
23720exports.sum32 = sum32;
23721
23722function sum32_3(a, b, c) {
23723 return (a + b + c) >>> 0;
23724}
23725exports.sum32_3 = sum32_3;
23726
23727function sum32_4(a, b, c, d) {
23728 return (a + b + c + d) >>> 0;
23729}
23730exports.sum32_4 = sum32_4;
23731
23732function sum32_5(a, b, c, d, e) {
23733 return (a + b + c + d + e) >>> 0;
23734}
23735exports.sum32_5 = sum32_5;
23736
23737function sum64(buf, pos, ah, al) {
23738 var bh = buf[pos];
23739 var bl = buf[pos + 1];
23740
23741 var lo = (al + bl) >>> 0;
23742 var hi = (lo < al ? 1 : 0) + ah + bh;
23743 buf[pos] = hi >>> 0;
23744 buf[pos + 1] = lo;
23745}
23746exports.sum64 = sum64;
23747
23748function sum64_hi(ah, al, bh, bl) {
23749 var lo = (al + bl) >>> 0;
23750 var hi = (lo < al ? 1 : 0) + ah + bh;
23751 return hi >>> 0;
23752}
23753exports.sum64_hi = sum64_hi;
23754
23755function sum64_lo(ah, al, bh, bl) {
23756 var lo = al + bl;
23757 return lo >>> 0;
23758}
23759exports.sum64_lo = sum64_lo;
23760
23761function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) {
23762 var carry = 0;
23763 var lo = al;
23764 lo = (lo + bl) >>> 0;
23765 carry += lo < al ? 1 : 0;
23766 lo = (lo + cl) >>> 0;
23767 carry += lo < cl ? 1 : 0;
23768 lo = (lo + dl) >>> 0;
23769 carry += lo < dl ? 1 : 0;
23770
23771 var hi = ah + bh + ch + dh + carry;
23772 return hi >>> 0;
23773}
23774exports.sum64_4_hi = sum64_4_hi;
23775
23776function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) {
23777 var lo = al + bl + cl + dl;
23778 return lo >>> 0;
23779}
23780exports.sum64_4_lo = sum64_4_lo;
23781
23782function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
23783 var carry = 0;
23784 var lo = al;
23785 lo = (lo + bl) >>> 0;
23786 carry += lo < al ? 1 : 0;
23787 lo = (lo + cl) >>> 0;
23788 carry += lo < cl ? 1 : 0;
23789 lo = (lo + dl) >>> 0;
23790 carry += lo < dl ? 1 : 0;
23791 lo = (lo + el) >>> 0;
23792 carry += lo < el ? 1 : 0;
23793
23794 var hi = ah + bh + ch + dh + eh + carry;
23795 return hi >>> 0;
23796}
23797exports.sum64_5_hi = sum64_5_hi;
23798
23799function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
23800 var lo = al + bl + cl + dl + el;
23801
23802 return lo >>> 0;
23803}
23804exports.sum64_5_lo = sum64_5_lo;
23805
23806function rotr64_hi(ah, al, num) {
23807 var r = (al << (32 - num)) | (ah >>> num);
23808 return r >>> 0;
23809}
23810exports.rotr64_hi = rotr64_hi;
23811
23812function rotr64_lo(ah, al, num) {
23813 var r = (ah << (32 - num)) | (al >>> num);
23814 return r >>> 0;
23815}
23816exports.rotr64_lo = rotr64_lo;
23817
23818function shr64_hi(ah, al, num) {
23819 return ah >>> num;
23820}
23821exports.shr64_hi = shr64_hi;
23822
23823function shr64_lo(ah, al, num) {
23824 var r = (ah << (32 - num)) | (al >>> num);
23825 return r >>> 0;
23826}
23827exports.shr64_lo = shr64_lo;
23828
23829},{"inherits":162,"minimalistic-assert":167}],160:[function(require,module,exports){
23830'use strict';
23831
23832var hash = require('hash.js');
23833var utils = require('minimalistic-crypto-utils');
23834var assert = require('minimalistic-assert');
23835
23836function HmacDRBG(options) {
23837 if (!(this instanceof HmacDRBG))
23838 return new HmacDRBG(options);
23839 this.hash = options.hash;
23840 this.predResist = !!options.predResist;
23841
23842 this.outLen = this.hash.outSize;
23843 this.minEntropy = options.minEntropy || this.hash.hmacStrength;
23844
23845 this._reseed = null;
23846 this.reseedInterval = null;
23847 this.K = null;
23848 this.V = null;
23849
23850 var entropy = utils.toArray(options.entropy, options.entropyEnc || 'hex');
23851 var nonce = utils.toArray(options.nonce, options.nonceEnc || 'hex');
23852 var pers = utils.toArray(options.pers, options.persEnc || 'hex');
23853 assert(entropy.length >= (this.minEntropy / 8),
23854 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
23855 this._init(entropy, nonce, pers);
23856}
23857module.exports = HmacDRBG;
23858
23859HmacDRBG.prototype._init = function init(entropy, nonce, pers) {
23860 var seed = entropy.concat(nonce).concat(pers);
23861
23862 this.K = new Array(this.outLen / 8);
23863 this.V = new Array(this.outLen / 8);
23864 for (var i = 0; i < this.V.length; i++) {
23865 this.K[i] = 0x00;
23866 this.V[i] = 0x01;
23867 }
23868
23869 this._update(seed);
23870 this._reseed = 1;
23871 this.reseedInterval = 0x1000000000000; // 2^48
23872};
23873
23874HmacDRBG.prototype._hmac = function hmac() {
23875 return new hash.hmac(this.hash, this.K);
23876};
23877
23878HmacDRBG.prototype._update = function update(seed) {
23879 var kmac = this._hmac()
23880 .update(this.V)
23881 .update([ 0x00 ]);
23882 if (seed)
23883 kmac = kmac.update(seed);
23884 this.K = kmac.digest();
23885 this.V = this._hmac().update(this.V).digest();
23886 if (!seed)
23887 return;
23888
23889 this.K = this._hmac()
23890 .update(this.V)
23891 .update([ 0x01 ])
23892 .update(seed)
23893 .digest();
23894 this.V = this._hmac().update(this.V).digest();
23895};
23896
23897HmacDRBG.prototype.reseed = function reseed(entropy, entropyEnc, add, addEnc) {
23898 // Optional entropy enc
23899 if (typeof entropyEnc !== 'string') {
23900 addEnc = add;
23901 add = entropyEnc;
23902 entropyEnc = null;
23903 }
23904
23905 entropy = utils.toArray(entropy, entropyEnc);
23906 add = utils.toArray(add, addEnc);
23907
23908 assert(entropy.length >= (this.minEntropy / 8),
23909 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
23910
23911 this._update(entropy.concat(add || []));
23912 this._reseed = 1;
23913};
23914
23915HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) {
23916 if (this._reseed > this.reseedInterval)
23917 throw new Error('Reseed is required');
23918
23919 // Optional encoding
23920 if (typeof enc !== 'string') {
23921 addEnc = add;
23922 add = enc;
23923 enc = null;
23924 }
23925
23926 // Optional additional data
23927 if (add) {
23928 add = utils.toArray(add, addEnc || 'hex');
23929 this._update(add);
23930 }
23931
23932 var temp = [];
23933 while (temp.length < len) {
23934 this.V = this._hmac().update(this.V).digest();
23935 temp = temp.concat(this.V);
23936 }
23937
23938 var res = temp.slice(0, len);
23939 this._update(add);
23940 this._reseed++;
23941 return utils.encode(res, enc);
23942};
23943
23944},{"hash.js":148,"minimalistic-assert":167,"minimalistic-crypto-utils":168}],161:[function(require,module,exports){
23945exports.read = function (buffer, offset, isLE, mLen, nBytes) {
23946 var e, m
23947 var eLen = (nBytes * 8) - mLen - 1
23948 var eMax = (1 << eLen) - 1
23949 var eBias = eMax >> 1
23950 var nBits = -7
23951 var i = isLE ? (nBytes - 1) : 0
23952 var d = isLE ? -1 : 1
23953 var s = buffer[offset + i]
23954
23955 i += d
23956
23957 e = s & ((1 << (-nBits)) - 1)
23958 s >>= (-nBits)
23959 nBits += eLen
23960 for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
23961
23962 m = e & ((1 << (-nBits)) - 1)
23963 e >>= (-nBits)
23964 nBits += mLen
23965 for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
23966
23967 if (e === 0) {
23968 e = 1 - eBias
23969 } else if (e === eMax) {
23970 return m ? NaN : ((s ? -1 : 1) * Infinity)
23971 } else {
23972 m = m + Math.pow(2, mLen)
23973 e = e - eBias
23974 }
23975 return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
23976}
23977
23978exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
23979 var e, m, c
23980 var eLen = (nBytes * 8) - mLen - 1
23981 var eMax = (1 << eLen) - 1
23982 var eBias = eMax >> 1
23983 var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
23984 var i = isLE ? 0 : (nBytes - 1)
23985 var d = isLE ? 1 : -1
23986 var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
23987
23988 value = Math.abs(value)
23989
23990 if (isNaN(value) || value === Infinity) {
23991 m = isNaN(value) ? 1 : 0
23992 e = eMax
23993 } else {
23994 e = Math.floor(Math.log(value) / Math.LN2)
23995 if (value * (c = Math.pow(2, -e)) < 1) {
23996 e--
23997 c *= 2
23998 }
23999 if (e + eBias >= 1) {
24000 value += rt / c
24001 } else {
24002 value += rt * Math.pow(2, 1 - eBias)
24003 }
24004 if (value * c >= 2) {
24005 e++
24006 c /= 2
24007 }
24008
24009 if (e + eBias >= eMax) {
24010 m = 0
24011 e = eMax
24012 } else if (e + eBias >= 1) {
24013 m = ((value * c) - 1) * Math.pow(2, mLen)
24014 e = e + eBias
24015 } else {
24016 m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
24017 e = 0
24018 }
24019 }
24020
24021 for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
24022
24023 e = (e << mLen) | m
24024 eLen += mLen
24025 for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
24026
24027 buffer[offset + i - d] |= s * 128
24028}
24029
24030},{}],162:[function(require,module,exports){
24031arguments[4][44][0].apply(exports,arguments)
24032},{"dup":44}],163:[function(require,module,exports){
24033/*!
24034 * Determine if an object is a Buffer
24035 *
24036 * @author Feross Aboukhadijeh <https://feross.org>
24037 * @license MIT
24038 */
24039
24040// The _isBuffer check is for Safari 5-7 support, because it's missing
24041// Object.prototype.constructor. Remove this eventually
24042module.exports = function (obj) {
24043 return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
24044}
24045
24046function isBuffer (obj) {
24047 return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
24048}
24049
24050// For Node v0.10 support. Remove this eventually.
24051function isSlowBuffer (obj) {
24052 return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
24053}
24054
24055},{}],164:[function(require,module,exports){
24056var toString = {}.toString;
24057
24058module.exports = Array.isArray || function (arr) {
24059 return toString.call(arr) == '[object Array]';
24060};
24061
24062},{}],165:[function(require,module,exports){
24063arguments[4][45][0].apply(exports,arguments)
24064},{"dup":45,"hash-base":147,"inherits":162,"safe-buffer":206}],166:[function(require,module,exports){
24065var bn = require('bn.js');
24066var brorand = require('brorand');
24067
24068function MillerRabin(rand) {
24069 this.rand = rand || new brorand.Rand();
24070}
24071module.exports = MillerRabin;
24072
24073MillerRabin.create = function create(rand) {
24074 return new MillerRabin(rand);
24075};
24076
24077MillerRabin.prototype._randbelow = function _randbelow(n) {
24078 var len = n.bitLength();
24079 var min_bytes = Math.ceil(len / 8);
24080
24081 // Generage random bytes until a number less than n is found.
24082 // This ensures that 0..n-1 have an equal probability of being selected.
24083 do
24084 var a = new bn(this.rand.generate(min_bytes));
24085 while (a.cmp(n) >= 0);
24086
24087 return a;
24088};
24089
24090MillerRabin.prototype._randrange = function _randrange(start, stop) {
24091 // Generate a random number greater than or equal to start and less than stop.
24092 var size = stop.sub(start);
24093 return start.add(this._randbelow(size));
24094};
24095
24096MillerRabin.prototype.test = function test(n, k, cb) {
24097 var len = n.bitLength();
24098 var red = bn.mont(n);
24099 var rone = new bn(1).toRed(red);
24100
24101 if (!k)
24102 k = Math.max(1, (len / 48) | 0);
24103
24104 // Find d and s, (n - 1) = (2 ^ s) * d;
24105 var n1 = n.subn(1);
24106 for (var s = 0; !n1.testn(s); s++) {}
24107 var d = n.shrn(s);
24108
24109 var rn1 = n1.toRed(red);
24110
24111 var prime = true;
24112 for (; k > 0; k--) {
24113 var a = this._randrange(new bn(2), n1);
24114 if (cb)
24115 cb(a);
24116
24117 var x = a.toRed(red).redPow(d);
24118 if (x.cmp(rone) === 0 || x.cmp(rn1) === 0)
24119 continue;
24120
24121 for (var i = 1; i < s; i++) {
24122 x = x.redSqr();
24123
24124 if (x.cmp(rone) === 0)
24125 return false;
24126 if (x.cmp(rn1) === 0)
24127 break;
24128 }
24129
24130 if (i === s)
24131 return false;
24132 }
24133
24134 return prime;
24135};
24136
24137MillerRabin.prototype.getDivisor = function getDivisor(n, k) {
24138 var len = n.bitLength();
24139 var red = bn.mont(n);
24140 var rone = new bn(1).toRed(red);
24141
24142 if (!k)
24143 k = Math.max(1, (len / 48) | 0);
24144
24145 // Find d and s, (n - 1) = (2 ^ s) * d;
24146 var n1 = n.subn(1);
24147 for (var s = 0; !n1.testn(s); s++) {}
24148 var d = n.shrn(s);
24149
24150 var rn1 = n1.toRed(red);
24151
24152 for (; k > 0; k--) {
24153 var a = this._randrange(new bn(2), n1);
24154
24155 var g = n.gcd(a);
24156 if (g.cmpn(1) !== 0)
24157 return g;
24158
24159 var x = a.toRed(red).redPow(d);
24160 if (x.cmp(rone) === 0 || x.cmp(rn1) === 0)
24161 continue;
24162
24163 for (var i = 1; i < s; i++) {
24164 x = x.redSqr();
24165
24166 if (x.cmp(rone) === 0)
24167 return x.fromRed().subn(1).gcd(n);
24168 if (x.cmp(rn1) === 0)
24169 break;
24170 }
24171
24172 if (i === s) {
24173 x = x.redSqr();
24174 return x.fromRed().subn(1).gcd(n);
24175 }
24176 }
24177
24178 return false;
24179};
24180
24181},{"bn.js":79,"brorand":80}],167:[function(require,module,exports){
24182module.exports = assert;
24183
24184function assert(val, msg) {
24185 if (!val)
24186 throw new Error(msg || 'Assertion failed');
24187}
24188
24189assert.equal = function assertEqual(l, r, msg) {
24190 if (l != r)
24191 throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r));
24192};
24193
24194},{}],168:[function(require,module,exports){
24195'use strict';
24196
24197var utils = exports;
24198
24199function toArray(msg, enc) {
24200 if (Array.isArray(msg))
24201 return msg.slice();
24202 if (!msg)
24203 return [];
24204 var res = [];
24205 if (typeof msg !== 'string') {
24206 for (var i = 0; i < msg.length; i++)
24207 res[i] = msg[i] | 0;
24208 return res;
24209 }
24210 if (enc === 'hex') {
24211 msg = msg.replace(/[^a-z0-9]+/ig, '');
24212 if (msg.length % 2 !== 0)
24213 msg = '0' + msg;
24214 for (var i = 0; i < msg.length; i += 2)
24215 res.push(parseInt(msg[i] + msg[i + 1], 16));
24216 } else {
24217 for (var i = 0; i < msg.length; i++) {
24218 var c = msg.charCodeAt(i);
24219 var hi = c >> 8;
24220 var lo = c & 0xff;
24221 if (hi)
24222 res.push(hi, lo);
24223 else
24224 res.push(lo);
24225 }
24226 }
24227 return res;
24228}
24229utils.toArray = toArray;
24230
24231function zero2(word) {
24232 if (word.length === 1)
24233 return '0' + word;
24234 else
24235 return word;
24236}
24237utils.zero2 = zero2;
24238
24239function toHex(msg) {
24240 var res = '';
24241 for (var i = 0; i < msg.length; i++)
24242 res += zero2(msg[i].toString(16));
24243 return res;
24244}
24245utils.toHex = toHex;
24246
24247utils.encode = function encode(arr, enc) {
24248 if (enc === 'hex')
24249 return toHex(arr);
24250 else
24251 return arr;
24252};
24253
24254},{}],169:[function(require,module,exports){
24255/*
24256object-assign
24257(c) Sindre Sorhus
24258@license MIT
24259*/
24260
24261'use strict';
24262/* eslint-disable no-unused-vars */
24263var getOwnPropertySymbols = Object.getOwnPropertySymbols;
24264var hasOwnProperty = Object.prototype.hasOwnProperty;
24265var propIsEnumerable = Object.prototype.propertyIsEnumerable;
24266
24267function toObject(val) {
24268 if (val === null || val === undefined) {
24269 throw new TypeError('Object.assign cannot be called with null or undefined');
24270 }
24271
24272 return Object(val);
24273}
24274
24275function shouldUseNative() {
24276 try {
24277 if (!Object.assign) {
24278 return false;
24279 }
24280
24281 // Detect buggy property enumeration order in older V8 versions.
24282
24283 // https://bugs.chromium.org/p/v8/issues/detail?id=4118
24284 var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
24285 test1[5] = 'de';
24286 if (Object.getOwnPropertyNames(test1)[0] === '5') {
24287 return false;
24288 }
24289
24290 // https://bugs.chromium.org/p/v8/issues/detail?id=3056
24291 var test2 = {};
24292 for (var i = 0; i < 10; i++) {
24293 test2['_' + String.fromCharCode(i)] = i;
24294 }
24295 var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
24296 return test2[n];
24297 });
24298 if (order2.join('') !== '0123456789') {
24299 return false;
24300 }
24301
24302 // https://bugs.chromium.org/p/v8/issues/detail?id=3056
24303 var test3 = {};
24304 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
24305 test3[letter] = letter;
24306 });
24307 if (Object.keys(Object.assign({}, test3)).join('') !==
24308 'abcdefghijklmnopqrst') {
24309 return false;
24310 }
24311
24312 return true;
24313 } catch (err) {
24314 // We don't expect any of the above to throw, but better to be safe.
24315 return false;
24316 }
24317}
24318
24319module.exports = shouldUseNative() ? Object.assign : function (target, source) {
24320 var from;
24321 var to = toObject(target);
24322 var symbols;
24323
24324 for (var s = 1; s < arguments.length; s++) {
24325 from = Object(arguments[s]);
24326
24327 for (var key in from) {
24328 if (hasOwnProperty.call(from, key)) {
24329 to[key] = from[key];
24330 }
24331 }
24332
24333 if (getOwnPropertySymbols) {
24334 symbols = getOwnPropertySymbols(from);
24335 for (var i = 0; i < symbols.length; i++) {
24336 if (propIsEnumerable.call(from, symbols[i])) {
24337 to[symbols[i]] = from[symbols[i]];
24338 }
24339 }
24340 }
24341 }
24342
24343 return to;
24344};
24345
24346},{}],170:[function(require,module,exports){
24347module.exports={"2.16.840.1.101.3.4.1.1": "aes-128-ecb",
24348"2.16.840.1.101.3.4.1.2": "aes-128-cbc",
24349"2.16.840.1.101.3.4.1.3": "aes-128-ofb",
24350"2.16.840.1.101.3.4.1.4": "aes-128-cfb",
24351"2.16.840.1.101.3.4.1.21": "aes-192-ecb",
24352"2.16.840.1.101.3.4.1.22": "aes-192-cbc",
24353"2.16.840.1.101.3.4.1.23": "aes-192-ofb",
24354"2.16.840.1.101.3.4.1.24": "aes-192-cfb",
24355"2.16.840.1.101.3.4.1.41": "aes-256-ecb",
24356"2.16.840.1.101.3.4.1.42": "aes-256-cbc",
24357"2.16.840.1.101.3.4.1.43": "aes-256-ofb",
24358"2.16.840.1.101.3.4.1.44": "aes-256-cfb"
24359}
24360},{}],171:[function(require,module,exports){
24361// from https://github.com/indutny/self-signed/blob/gh-pages/lib/asn1.js
24362// Fedor, you are amazing.
24363'use strict'
24364
24365var asn1 = require('asn1.js')
24366
24367exports.certificate = require('./certificate')
24368
24369var RSAPrivateKey = asn1.define('RSAPrivateKey', function () {
24370 this.seq().obj(
24371 this.key('version').int(),
24372 this.key('modulus').int(),
24373 this.key('publicExponent').int(),
24374 this.key('privateExponent').int(),
24375 this.key('prime1').int(),
24376 this.key('prime2').int(),
24377 this.key('exponent1').int(),
24378 this.key('exponent2').int(),
24379 this.key('coefficient').int()
24380 )
24381})
24382exports.RSAPrivateKey = RSAPrivateKey
24383
24384var RSAPublicKey = asn1.define('RSAPublicKey', function () {
24385 this.seq().obj(
24386 this.key('modulus').int(),
24387 this.key('publicExponent').int()
24388 )
24389})
24390exports.RSAPublicKey = RSAPublicKey
24391
24392var PublicKey = asn1.define('SubjectPublicKeyInfo', function () {
24393 this.seq().obj(
24394 this.key('algorithm').use(AlgorithmIdentifier),
24395 this.key('subjectPublicKey').bitstr()
24396 )
24397})
24398exports.PublicKey = PublicKey
24399
24400var AlgorithmIdentifier = asn1.define('AlgorithmIdentifier', function () {
24401 this.seq().obj(
24402 this.key('algorithm').objid(),
24403 this.key('none').null_().optional(),
24404 this.key('curve').objid().optional(),
24405 this.key('params').seq().obj(
24406 this.key('p').int(),
24407 this.key('q').int(),
24408 this.key('g').int()
24409 ).optional()
24410 )
24411})
24412
24413var PrivateKeyInfo = asn1.define('PrivateKeyInfo', function () {
24414 this.seq().obj(
24415 this.key('version').int(),
24416 this.key('algorithm').use(AlgorithmIdentifier),
24417 this.key('subjectPrivateKey').octstr()
24418 )
24419})
24420exports.PrivateKey = PrivateKeyInfo
24421var EncryptedPrivateKeyInfo = asn1.define('EncryptedPrivateKeyInfo', function () {
24422 this.seq().obj(
24423 this.key('algorithm').seq().obj(
24424 this.key('id').objid(),
24425 this.key('decrypt').seq().obj(
24426 this.key('kde').seq().obj(
24427 this.key('id').objid(),
24428 this.key('kdeparams').seq().obj(
24429 this.key('salt').octstr(),
24430 this.key('iters').int()
24431 )
24432 ),
24433 this.key('cipher').seq().obj(
24434 this.key('algo').objid(),
24435 this.key('iv').octstr()
24436 )
24437 )
24438 ),
24439 this.key('subjectPrivateKey').octstr()
24440 )
24441})
24442
24443exports.EncryptedPrivateKey = EncryptedPrivateKeyInfo
24444
24445var DSAPrivateKey = asn1.define('DSAPrivateKey', function () {
24446 this.seq().obj(
24447 this.key('version').int(),
24448 this.key('p').int(),
24449 this.key('q').int(),
24450 this.key('g').int(),
24451 this.key('pub_key').int(),
24452 this.key('priv_key').int()
24453 )
24454})
24455exports.DSAPrivateKey = DSAPrivateKey
24456
24457exports.DSAparam = asn1.define('DSAparam', function () {
24458 this.int()
24459})
24460
24461var ECPrivateKey = asn1.define('ECPrivateKey', function () {
24462 this.seq().obj(
24463 this.key('version').int(),
24464 this.key('privateKey').octstr(),
24465 this.key('parameters').optional().explicit(0).use(ECParameters),
24466 this.key('publicKey').optional().explicit(1).bitstr()
24467 )
24468})
24469exports.ECPrivateKey = ECPrivateKey
24470
24471var ECParameters = asn1.define('ECParameters', function () {
24472 this.choice({
24473 namedCurve: this.objid()
24474 })
24475})
24476
24477exports.signature = asn1.define('signature', function () {
24478 this.seq().obj(
24479 this.key('r').int(),
24480 this.key('s').int()
24481 )
24482})
24483
24484},{"./certificate":172,"asn1.js":60}],172:[function(require,module,exports){
24485// from https://github.com/Rantanen/node-dtls/blob/25a7dc861bda38cfeac93a723500eea4f0ac2e86/Certificate.js
24486// thanks to @Rantanen
24487
24488'use strict'
24489
24490var asn = require('asn1.js')
24491
24492var Time = asn.define('Time', function () {
24493 this.choice({
24494 utcTime: this.utctime(),
24495 generalTime: this.gentime()
24496 })
24497})
24498
24499var AttributeTypeValue = asn.define('AttributeTypeValue', function () {
24500 this.seq().obj(
24501 this.key('type').objid(),
24502 this.key('value').any()
24503 )
24504})
24505
24506var AlgorithmIdentifier = asn.define('AlgorithmIdentifier', function () {
24507 this.seq().obj(
24508 this.key('algorithm').objid(),
24509 this.key('parameters').optional(),
24510 this.key('curve').objid().optional()
24511 )
24512})
24513
24514var SubjectPublicKeyInfo = asn.define('SubjectPublicKeyInfo', function () {
24515 this.seq().obj(
24516 this.key('algorithm').use(AlgorithmIdentifier),
24517 this.key('subjectPublicKey').bitstr()
24518 )
24519})
24520
24521var RelativeDistinguishedName = asn.define('RelativeDistinguishedName', function () {
24522 this.setof(AttributeTypeValue)
24523})
24524
24525var RDNSequence = asn.define('RDNSequence', function () {
24526 this.seqof(RelativeDistinguishedName)
24527})
24528
24529var Name = asn.define('Name', function () {
24530 this.choice({
24531 rdnSequence: this.use(RDNSequence)
24532 })
24533})
24534
24535var Validity = asn.define('Validity', function () {
24536 this.seq().obj(
24537 this.key('notBefore').use(Time),
24538 this.key('notAfter').use(Time)
24539 )
24540})
24541
24542var Extension = asn.define('Extension', function () {
24543 this.seq().obj(
24544 this.key('extnID').objid(),
24545 this.key('critical').bool().def(false),
24546 this.key('extnValue').octstr()
24547 )
24548})
24549
24550var TBSCertificate = asn.define('TBSCertificate', function () {
24551 this.seq().obj(
24552 this.key('version').explicit(0).int().optional(),
24553 this.key('serialNumber').int(),
24554 this.key('signature').use(AlgorithmIdentifier),
24555 this.key('issuer').use(Name),
24556 this.key('validity').use(Validity),
24557 this.key('subject').use(Name),
24558 this.key('subjectPublicKeyInfo').use(SubjectPublicKeyInfo),
24559 this.key('issuerUniqueID').implicit(1).bitstr().optional(),
24560 this.key('subjectUniqueID').implicit(2).bitstr().optional(),
24561 this.key('extensions').explicit(3).seqof(Extension).optional()
24562 )
24563})
24564
24565var X509Certificate = asn.define('X509Certificate', function () {
24566 this.seq().obj(
24567 this.key('tbsCertificate').use(TBSCertificate),
24568 this.key('signatureAlgorithm').use(AlgorithmIdentifier),
24569 this.key('signatureValue').bitstr()
24570 )
24571})
24572
24573module.exports = X509Certificate
24574
24575},{"asn1.js":60}],173:[function(require,module,exports){
24576// adapted from https://github.com/apatil/pemstrip
24577var findProc = /Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r\+\/\=]+)[\n\r]+/m
24578var startRegex = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m
24579var fullRegex = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r\+\/\=]+)-----END \1-----$/m
24580var evp = require('evp_bytestokey')
24581var ciphers = require('browserify-aes')
24582var Buffer = require('safe-buffer').Buffer
24583module.exports = function (okey, password) {
24584 var key = okey.toString()
24585 var match = key.match(findProc)
24586 var decrypted
24587 if (!match) {
24588 var match2 = key.match(fullRegex)
24589 decrypted = new Buffer(match2[2].replace(/[\r\n]/g, ''), 'base64')
24590 } else {
24591 var suite = 'aes' + match[1]
24592 var iv = Buffer.from(match[2], 'hex')
24593 var cipherText = Buffer.from(match[3].replace(/[\r\n]/g, ''), 'base64')
24594 var cipherKey = evp(password, iv.slice(0, 8), parseInt(match[1], 10)).key
24595 var out = []
24596 var cipher = ciphers.createDecipheriv(suite, cipherKey, iv)
24597 out.push(cipher.update(cipherText))
24598 out.push(cipher.final())
24599 decrypted = Buffer.concat(out)
24600 }
24601 var tag = key.match(startRegex)[1]
24602 return {
24603 tag: tag,
24604 data: decrypted
24605 }
24606}
24607
24608},{"browserify-aes":84,"evp_bytestokey":146,"safe-buffer":206}],174:[function(require,module,exports){
24609var asn1 = require('./asn1')
24610var aesid = require('./aesid.json')
24611var fixProc = require('./fixProc')
24612var ciphers = require('browserify-aes')
24613var compat = require('pbkdf2')
24614var Buffer = require('safe-buffer').Buffer
24615module.exports = parseKeys
24616
24617function parseKeys (buffer) {
24618 var password
24619 if (typeof buffer === 'object' && !Buffer.isBuffer(buffer)) {
24620 password = buffer.passphrase
24621 buffer = buffer.key
24622 }
24623 if (typeof buffer === 'string') {
24624 buffer = Buffer.from(buffer)
24625 }
24626
24627 var stripped = fixProc(buffer, password)
24628
24629 var type = stripped.tag
24630 var data = stripped.data
24631 var subtype, ndata
24632 switch (type) {
24633 case 'CERTIFICATE':
24634 ndata = asn1.certificate.decode(data, 'der').tbsCertificate.subjectPublicKeyInfo
24635 // falls through
24636 case 'PUBLIC KEY':
24637 if (!ndata) {
24638 ndata = asn1.PublicKey.decode(data, 'der')
24639 }
24640 subtype = ndata.algorithm.algorithm.join('.')
24641 switch (subtype) {
24642 case '1.2.840.113549.1.1.1':
24643 return asn1.RSAPublicKey.decode(ndata.subjectPublicKey.data, 'der')
24644 case '1.2.840.10045.2.1':
24645 ndata.subjectPrivateKey = ndata.subjectPublicKey
24646 return {
24647 type: 'ec',
24648 data: ndata
24649 }
24650 case '1.2.840.10040.4.1':
24651 ndata.algorithm.params.pub_key = asn1.DSAparam.decode(ndata.subjectPublicKey.data, 'der')
24652 return {
24653 type: 'dsa',
24654 data: ndata.algorithm.params
24655 }
24656 default: throw new Error('unknown key id ' + subtype)
24657 }
24658 throw new Error('unknown key type ' + type)
24659 case 'ENCRYPTED PRIVATE KEY':
24660 data = asn1.EncryptedPrivateKey.decode(data, 'der')
24661 data = decrypt(data, password)
24662 // falls through
24663 case 'PRIVATE KEY':
24664 ndata = asn1.PrivateKey.decode(data, 'der')
24665 subtype = ndata.algorithm.algorithm.join('.')
24666 switch (subtype) {
24667 case '1.2.840.113549.1.1.1':
24668 return asn1.RSAPrivateKey.decode(ndata.subjectPrivateKey, 'der')
24669 case '1.2.840.10045.2.1':
24670 return {
24671 curve: ndata.algorithm.curve,
24672 privateKey: asn1.ECPrivateKey.decode(ndata.subjectPrivateKey, 'der').privateKey
24673 }
24674 case '1.2.840.10040.4.1':
24675 ndata.algorithm.params.priv_key = asn1.DSAparam.decode(ndata.subjectPrivateKey, 'der')
24676 return {
24677 type: 'dsa',
24678 params: ndata.algorithm.params
24679 }
24680 default: throw new Error('unknown key id ' + subtype)
24681 }
24682 throw new Error('unknown key type ' + type)
24683 case 'RSA PUBLIC KEY':
24684 return asn1.RSAPublicKey.decode(data, 'der')
24685 case 'RSA PRIVATE KEY':
24686 return asn1.RSAPrivateKey.decode(data, 'der')
24687 case 'DSA PRIVATE KEY':
24688 return {
24689 type: 'dsa',
24690 params: asn1.DSAPrivateKey.decode(data, 'der')
24691 }
24692 case 'EC PRIVATE KEY':
24693 data = asn1.ECPrivateKey.decode(data, 'der')
24694 return {
24695 curve: data.parameters.value,
24696 privateKey: data.privateKey
24697 }
24698 default: throw new Error('unknown key type ' + type)
24699 }
24700}
24701parseKeys.signature = asn1.signature
24702function decrypt (data, password) {
24703 var salt = data.algorithm.decrypt.kde.kdeparams.salt
24704 var iters = parseInt(data.algorithm.decrypt.kde.kdeparams.iters.toString(), 10)
24705 var algo = aesid[data.algorithm.decrypt.cipher.algo.join('.')]
24706 var iv = data.algorithm.decrypt.cipher.iv
24707 var cipherText = data.subjectPrivateKey
24708 var keylen = parseInt(algo.split('-')[1], 10) / 8
24709 var key = compat.pbkdf2Sync(password, salt, iters, keylen, 'sha1')
24710 var cipher = ciphers.createDecipheriv(algo, key, iv)
24711 var out = []
24712 out.push(cipher.update(cipherText))
24713 out.push(cipher.final())
24714 return Buffer.concat(out)
24715}
24716
24717},{"./aesid.json":170,"./asn1":171,"./fixProc":173,"browserify-aes":84,"pbkdf2":175,"safe-buffer":206}],175:[function(require,module,exports){
24718exports.pbkdf2 = require('./lib/async')
24719exports.pbkdf2Sync = require('./lib/sync')
24720
24721},{"./lib/async":176,"./lib/sync":179}],176:[function(require,module,exports){
24722(function (process,global){
24723var checkParameters = require('./precondition')
24724var defaultEncoding = require('./default-encoding')
24725var sync = require('./sync')
24726var Buffer = require('safe-buffer').Buffer
24727
24728var ZERO_BUF
24729var subtle = global.crypto && global.crypto.subtle
24730var toBrowser = {
24731 'sha': 'SHA-1',
24732 'sha-1': 'SHA-1',
24733 'sha1': 'SHA-1',
24734 'sha256': 'SHA-256',
24735 'sha-256': 'SHA-256',
24736 'sha384': 'SHA-384',
24737 'sha-384': 'SHA-384',
24738 'sha-512': 'SHA-512',
24739 'sha512': 'SHA-512'
24740}
24741var checks = []
24742function checkNative (algo) {
24743 if (global.process && !global.process.browser) {
24744 return Promise.resolve(false)
24745 }
24746 if (!subtle || !subtle.importKey || !subtle.deriveBits) {
24747 return Promise.resolve(false)
24748 }
24749 if (checks[algo] !== undefined) {
24750 return checks[algo]
24751 }
24752 ZERO_BUF = ZERO_BUF || Buffer.alloc(8)
24753 var prom = browserPbkdf2(ZERO_BUF, ZERO_BUF, 10, 128, algo)
24754 .then(function () {
24755 return true
24756 }).catch(function () {
24757 return false
24758 })
24759 checks[algo] = prom
24760 return prom
24761}
24762
24763function browserPbkdf2 (password, salt, iterations, length, algo) {
24764 return subtle.importKey(
24765 'raw', password, {name: 'PBKDF2'}, false, ['deriveBits']
24766 ).then(function (key) {
24767 return subtle.deriveBits({
24768 name: 'PBKDF2',
24769 salt: salt,
24770 iterations: iterations,
24771 hash: {
24772 name: algo
24773 }
24774 }, key, length << 3)
24775 }).then(function (res) {
24776 return Buffer.from(res)
24777 })
24778}
24779
24780function resolvePromise (promise, callback) {
24781 promise.then(function (out) {
24782 process.nextTick(function () {
24783 callback(null, out)
24784 })
24785 }, function (e) {
24786 process.nextTick(function () {
24787 callback(e)
24788 })
24789 })
24790}
24791module.exports = function (password, salt, iterations, keylen, digest, callback) {
24792 if (typeof digest === 'function') {
24793 callback = digest
24794 digest = undefined
24795 }
24796
24797 digest = digest || 'sha1'
24798 var algo = toBrowser[digest.toLowerCase()]
24799
24800 if (!algo || typeof global.Promise !== 'function') {
24801 return process.nextTick(function () {
24802 var out
24803 try {
24804 out = sync(password, salt, iterations, keylen, digest)
24805 } catch (e) {
24806 return callback(e)
24807 }
24808 callback(null, out)
24809 })
24810 }
24811
24812 checkParameters(password, salt, iterations, keylen)
24813 if (typeof callback !== 'function') throw new Error('No callback provided to pbkdf2')
24814 if (!Buffer.isBuffer(password)) password = Buffer.from(password, defaultEncoding)
24815 if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, defaultEncoding)
24816
24817 resolvePromise(checkNative(algo).then(function (resp) {
24818 if (resp) return browserPbkdf2(password, salt, iterations, keylen, algo)
24819
24820 return sync(password, salt, iterations, keylen, digest)
24821 }), callback)
24822}
24823
24824}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
24825},{"./default-encoding":177,"./precondition":178,"./sync":179,"_process":181,"safe-buffer":206}],177:[function(require,module,exports){
24826(function (process){
24827var defaultEncoding
24828/* istanbul ignore next */
24829if (process.browser) {
24830 defaultEncoding = 'utf-8'
24831} else {
24832 var pVersionMajor = parseInt(process.version.split('.')[0].slice(1), 10)
24833
24834 defaultEncoding = pVersionMajor >= 6 ? 'utf-8' : 'binary'
24835}
24836module.exports = defaultEncoding
24837
24838}).call(this,require('_process'))
24839},{"_process":181}],178:[function(require,module,exports){
24840(function (Buffer){
24841var MAX_ALLOC = Math.pow(2, 30) - 1 // default in iojs
24842
24843function checkBuffer (buf, name) {
24844 if (typeof buf !== 'string' && !Buffer.isBuffer(buf)) {
24845 throw new TypeError(name + ' must be a buffer or string')
24846 }
24847}
24848
24849module.exports = function (password, salt, iterations, keylen) {
24850 checkBuffer(password, 'Password')
24851 checkBuffer(salt, 'Salt')
24852
24853 if (typeof iterations !== 'number') {
24854 throw new TypeError('Iterations not a number')
24855 }
24856
24857 if (iterations < 0) {
24858 throw new TypeError('Bad iterations')
24859 }
24860
24861 if (typeof keylen !== 'number') {
24862 throw new TypeError('Key length not a number')
24863 }
24864
24865 if (keylen < 0 || keylen > MAX_ALLOC || keylen !== keylen) { /* eslint no-self-compare: 0 */
24866 throw new TypeError('Bad key length')
24867 }
24868}
24869
24870}).call(this,{"isBuffer":require("../../is-buffer/index.js")})
24871},{"../../is-buffer/index.js":163}],179:[function(require,module,exports){
24872var md5 = require('create-hash/md5')
24873var RIPEMD160 = require('ripemd160')
24874var sha = require('sha.js')
24875
24876var checkParameters = require('./precondition')
24877var defaultEncoding = require('./default-encoding')
24878var Buffer = require('safe-buffer').Buffer
24879var ZEROS = Buffer.alloc(128)
24880var sizes = {
24881 md5: 16,
24882 sha1: 20,
24883 sha224: 28,
24884 sha256: 32,
24885 sha384: 48,
24886 sha512: 64,
24887 rmd160: 20,
24888 ripemd160: 20
24889}
24890
24891function Hmac (alg, key, saltLen) {
24892 var hash = getDigest(alg)
24893 var blocksize = (alg === 'sha512' || alg === 'sha384') ? 128 : 64
24894
24895 if (key.length > blocksize) {
24896 key = hash(key)
24897 } else if (key.length < blocksize) {
24898 key = Buffer.concat([key, ZEROS], blocksize)
24899 }
24900
24901 var ipad = Buffer.allocUnsafe(blocksize + sizes[alg])
24902 var opad = Buffer.allocUnsafe(blocksize + sizes[alg])
24903 for (var i = 0; i < blocksize; i++) {
24904 ipad[i] = key[i] ^ 0x36
24905 opad[i] = key[i] ^ 0x5C
24906 }
24907
24908 var ipad1 = Buffer.allocUnsafe(blocksize + saltLen + 4)
24909 ipad.copy(ipad1, 0, 0, blocksize)
24910 this.ipad1 = ipad1
24911 this.ipad2 = ipad
24912 this.opad = opad
24913 this.alg = alg
24914 this.blocksize = blocksize
24915 this.hash = hash
24916 this.size = sizes[alg]
24917}
24918
24919Hmac.prototype.run = function (data, ipad) {
24920 data.copy(ipad, this.blocksize)
24921 var h = this.hash(ipad)
24922 h.copy(this.opad, this.blocksize)
24923 return this.hash(this.opad)
24924}
24925
24926function getDigest (alg) {
24927 function shaFunc (data) {
24928 return sha(alg).update(data).digest()
24929 }
24930 function rmd160Func (data) {
24931 return new RIPEMD160().update(data).digest()
24932 }
24933
24934 if (alg === 'rmd160' || alg === 'ripemd160') return rmd160Func
24935 if (alg === 'md5') return md5
24936 return shaFunc
24937}
24938
24939function pbkdf2 (password, salt, iterations, keylen, digest) {
24940 checkParameters(password, salt, iterations, keylen)
24941
24942 if (!Buffer.isBuffer(password)) password = Buffer.from(password, defaultEncoding)
24943 if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, defaultEncoding)
24944
24945 digest = digest || 'sha1'
24946
24947 var hmac = new Hmac(digest, password, salt.length)
24948
24949 var DK = Buffer.allocUnsafe(keylen)
24950 var block1 = Buffer.allocUnsafe(salt.length + 4)
24951 salt.copy(block1, 0, 0, salt.length)
24952
24953 var destPos = 0
24954 var hLen = sizes[digest]
24955 var l = Math.ceil(keylen / hLen)
24956
24957 for (var i = 1; i <= l; i++) {
24958 block1.writeUInt32BE(i, salt.length)
24959
24960 var T = hmac.run(block1, hmac.ipad1)
24961 var U = T
24962
24963 for (var j = 1; j < iterations; j++) {
24964 U = hmac.run(U, hmac.ipad2)
24965 for (var k = 0; k < hLen; k++) T[k] ^= U[k]
24966 }
24967
24968 T.copy(DK, destPos)
24969 destPos += hLen
24970 }
24971
24972 return DK
24973}
24974
24975module.exports = pbkdf2
24976
24977},{"./default-encoding":177,"./precondition":178,"create-hash/md5":115,"ripemd160":205,"safe-buffer":206,"sha.js":208}],180:[function(require,module,exports){
24978(function (process){
24979'use strict';
24980
24981if (typeof process === 'undefined' ||
24982 !process.version ||
24983 process.version.indexOf('v0.') === 0 ||
24984 process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
24985 module.exports = { nextTick: nextTick };
24986} else {
24987 module.exports = process
24988}
24989
24990function nextTick(fn, arg1, arg2, arg3) {
24991 if (typeof fn !== 'function') {
24992 throw new TypeError('"callback" argument must be a function');
24993 }
24994 var len = arguments.length;
24995 var args, i;
24996 switch (len) {
24997 case 0:
24998 case 1:
24999 return process.nextTick(fn);
25000 case 2:
25001 return process.nextTick(function afterTickOne() {
25002 fn.call(null, arg1);
25003 });
25004 case 3:
25005 return process.nextTick(function afterTickTwo() {
25006 fn.call(null, arg1, arg2);
25007 });
25008 case 4:
25009 return process.nextTick(function afterTickThree() {
25010 fn.call(null, arg1, arg2, arg3);
25011 });
25012 default:
25013 args = new Array(len - 1);
25014 i = 0;
25015 while (i < args.length) {
25016 args[i++] = arguments[i];
25017 }
25018 return process.nextTick(function afterTick() {
25019 fn.apply(null, args);
25020 });
25021 }
25022}
25023
25024
25025}).call(this,require('_process'))
25026},{"_process":181}],181:[function(require,module,exports){
25027// shim for using process in browser
25028var process = module.exports = {};
25029
25030// cached from whatever global is present so that test runners that stub it
25031// don't break things. But we need to wrap it in a try catch in case it is
25032// wrapped in strict mode code which doesn't define any globals. It's inside a
25033// function because try/catches deoptimize in certain engines.
25034
25035var cachedSetTimeout;
25036var cachedClearTimeout;
25037
25038function defaultSetTimout() {
25039 throw new Error('setTimeout has not been defined');
25040}
25041function defaultClearTimeout () {
25042 throw new Error('clearTimeout has not been defined');
25043}
25044(function () {
25045 try {
25046 if (typeof setTimeout === 'function') {
25047 cachedSetTimeout = setTimeout;
25048 } else {
25049 cachedSetTimeout = defaultSetTimout;
25050 }
25051 } catch (e) {
25052 cachedSetTimeout = defaultSetTimout;
25053 }
25054 try {
25055 if (typeof clearTimeout === 'function') {
25056 cachedClearTimeout = clearTimeout;
25057 } else {
25058 cachedClearTimeout = defaultClearTimeout;
25059 }
25060 } catch (e) {
25061 cachedClearTimeout = defaultClearTimeout;
25062 }
25063} ())
25064function runTimeout(fun) {
25065 if (cachedSetTimeout === setTimeout) {
25066 //normal enviroments in sane situations
25067 return setTimeout(fun, 0);
25068 }
25069 // if setTimeout wasn't available but was latter defined
25070 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
25071 cachedSetTimeout = setTimeout;
25072 return setTimeout(fun, 0);
25073 }
25074 try {
25075 // when when somebody has screwed with setTimeout but no I.E. maddness
25076 return cachedSetTimeout(fun, 0);
25077 } catch(e){
25078 try {
25079 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
25080 return cachedSetTimeout.call(null, fun, 0);
25081 } catch(e){
25082 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
25083 return cachedSetTimeout.call(this, fun, 0);
25084 }
25085 }
25086
25087
25088}
25089function runClearTimeout(marker) {
25090 if (cachedClearTimeout === clearTimeout) {
25091 //normal enviroments in sane situations
25092 return clearTimeout(marker);
25093 }
25094 // if clearTimeout wasn't available but was latter defined
25095 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
25096 cachedClearTimeout = clearTimeout;
25097 return clearTimeout(marker);
25098 }
25099 try {
25100 // when when somebody has screwed with setTimeout but no I.E. maddness
25101 return cachedClearTimeout(marker);
25102 } catch (e){
25103 try {
25104 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
25105 return cachedClearTimeout.call(null, marker);
25106 } catch (e){
25107 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
25108 // Some versions of I.E. have different rules for clearTimeout vs setTimeout
25109 return cachedClearTimeout.call(this, marker);
25110 }
25111 }
25112
25113
25114
25115}
25116var queue = [];
25117var draining = false;
25118var currentQueue;
25119var queueIndex = -1;
25120
25121function cleanUpNextTick() {
25122 if (!draining || !currentQueue) {
25123 return;
25124 }
25125 draining = false;
25126 if (currentQueue.length) {
25127 queue = currentQueue.concat(queue);
25128 } else {
25129 queueIndex = -1;
25130 }
25131 if (queue.length) {
25132 drainQueue();
25133 }
25134}
25135
25136function drainQueue() {
25137 if (draining) {
25138 return;
25139 }
25140 var timeout = runTimeout(cleanUpNextTick);
25141 draining = true;
25142
25143 var len = queue.length;
25144 while(len) {
25145 currentQueue = queue;
25146 queue = [];
25147 while (++queueIndex < len) {
25148 if (currentQueue) {
25149 currentQueue[queueIndex].run();
25150 }
25151 }
25152 queueIndex = -1;
25153 len = queue.length;
25154 }
25155 currentQueue = null;
25156 draining = false;
25157 runClearTimeout(timeout);
25158}
25159
25160process.nextTick = function (fun) {
25161 var args = new Array(arguments.length - 1);
25162 if (arguments.length > 1) {
25163 for (var i = 1; i < arguments.length; i++) {
25164 args[i - 1] = arguments[i];
25165 }
25166 }
25167 queue.push(new Item(fun, args));
25168 if (queue.length === 1 && !draining) {
25169 runTimeout(drainQueue);
25170 }
25171};
25172
25173// v8 likes predictible objects
25174function Item(fun, array) {
25175 this.fun = fun;
25176 this.array = array;
25177}
25178Item.prototype.run = function () {
25179 this.fun.apply(null, this.array);
25180};
25181process.title = 'browser';
25182process.browser = true;
25183process.env = {};
25184process.argv = [];
25185process.version = ''; // empty string to avoid regexp issues
25186process.versions = {};
25187
25188function noop() {}
25189
25190process.on = noop;
25191process.addListener = noop;
25192process.once = noop;
25193process.off = noop;
25194process.removeListener = noop;
25195process.removeAllListeners = noop;
25196process.emit = noop;
25197process.prependListener = noop;
25198process.prependOnceListener = noop;
25199
25200process.listeners = function (name) { return [] }
25201
25202process.binding = function (name) {
25203 throw new Error('process.binding is not supported');
25204};
25205
25206process.cwd = function () { return '/' };
25207process.chdir = function (dir) {
25208 throw new Error('process.chdir is not supported');
25209};
25210process.umask = function() { return 0; };
25211
25212},{}],182:[function(require,module,exports){
25213exports.publicEncrypt = require('./publicEncrypt')
25214exports.privateDecrypt = require('./privateDecrypt')
25215
25216exports.privateEncrypt = function privateEncrypt (key, buf) {
25217 return exports.publicEncrypt(key, buf, true)
25218}
25219
25220exports.publicDecrypt = function publicDecrypt (key, buf) {
25221 return exports.privateDecrypt(key, buf, true)
25222}
25223
25224},{"./privateDecrypt":184,"./publicEncrypt":185}],183:[function(require,module,exports){
25225var createHash = require('create-hash')
25226var Buffer = require('safe-buffer').Buffer
25227
25228module.exports = function (seed, len) {
25229 var t = Buffer.alloc(0)
25230 var i = 0
25231 var c
25232 while (t.length < len) {
25233 c = i2ops(i++)
25234 t = Buffer.concat([t, createHash('sha1').update(seed).update(c).digest()])
25235 }
25236 return t.slice(0, len)
25237}
25238
25239function i2ops (c) {
25240 var out = Buffer.allocUnsafe(4)
25241 out.writeUInt32BE(c, 0)
25242 return out
25243}
25244
25245},{"create-hash":114,"safe-buffer":206}],184:[function(require,module,exports){
25246var parseKeys = require('parse-asn1')
25247var mgf = require('./mgf')
25248var xor = require('./xor')
25249var BN = require('bn.js')
25250var crt = require('browserify-rsa')
25251var createHash = require('create-hash')
25252var withPublic = require('./withPublic')
25253var Buffer = require('safe-buffer').Buffer
25254
25255module.exports = function privateDecrypt (privateKey, enc, reverse) {
25256 var padding
25257 if (privateKey.padding) {
25258 padding = privateKey.padding
25259 } else if (reverse) {
25260 padding = 1
25261 } else {
25262 padding = 4
25263 }
25264
25265 var key = parseKeys(privateKey)
25266 var k = key.modulus.byteLength()
25267 if (enc.length > k || new BN(enc).cmp(key.modulus) >= 0) {
25268 throw new Error('decryption error')
25269 }
25270 var msg
25271 if (reverse) {
25272 msg = withPublic(new BN(enc), key)
25273 } else {
25274 msg = crt(enc, key)
25275 }
25276 var zBuffer = Buffer.alloc(k - msg.length)
25277 msg = Buffer.concat([zBuffer, msg], k)
25278 if (padding === 4) {
25279 return oaep(key, msg)
25280 } else if (padding === 1) {
25281 return pkcs1(key, msg, reverse)
25282 } else if (padding === 3) {
25283 return msg
25284 } else {
25285 throw new Error('unknown padding')
25286 }
25287}
25288
25289function oaep (key, msg) {
25290 var k = key.modulus.byteLength()
25291 var iHash = createHash('sha1').update(Buffer.alloc(0)).digest()
25292 var hLen = iHash.length
25293 if (msg[0] !== 0) {
25294 throw new Error('decryption error')
25295 }
25296 var maskedSeed = msg.slice(1, hLen + 1)
25297 var maskedDb = msg.slice(hLen + 1)
25298 var seed = xor(maskedSeed, mgf(maskedDb, hLen))
25299 var db = xor(maskedDb, mgf(seed, k - hLen - 1))
25300 if (compare(iHash, db.slice(0, hLen))) {
25301 throw new Error('decryption error')
25302 }
25303 var i = hLen
25304 while (db[i] === 0) {
25305 i++
25306 }
25307 if (db[i++] !== 1) {
25308 throw new Error('decryption error')
25309 }
25310 return db.slice(i)
25311}
25312
25313function pkcs1 (key, msg, reverse) {
25314 var p1 = msg.slice(0, 2)
25315 var i = 2
25316 var status = 0
25317 while (msg[i++] !== 0) {
25318 if (i >= msg.length) {
25319 status++
25320 break
25321 }
25322 }
25323 var ps = msg.slice(2, i - 1)
25324
25325 if ((p1.toString('hex') !== '0002' && !reverse) || (p1.toString('hex') !== '0001' && reverse)) {
25326 status++
25327 }
25328 if (ps.length < 8) {
25329 status++
25330 }
25331 if (status) {
25332 throw new Error('decryption error')
25333 }
25334 return msg.slice(i)
25335}
25336function compare (a, b) {
25337 a = Buffer.from(a)
25338 b = Buffer.from(b)
25339 var dif = 0
25340 var len = a.length
25341 if (a.length !== b.length) {
25342 dif++
25343 len = Math.min(a.length, b.length)
25344 }
25345 var i = -1
25346 while (++i < len) {
25347 dif += (a[i] ^ b[i])
25348 }
25349 return dif
25350}
25351
25352},{"./mgf":183,"./withPublic":186,"./xor":187,"bn.js":79,"browserify-rsa":102,"create-hash":114,"parse-asn1":174,"safe-buffer":206}],185:[function(require,module,exports){
25353var parseKeys = require('parse-asn1')
25354var randomBytes = require('randombytes')
25355var createHash = require('create-hash')
25356var mgf = require('./mgf')
25357var xor = require('./xor')
25358var BN = require('bn.js')
25359var withPublic = require('./withPublic')
25360var crt = require('browserify-rsa')
25361var Buffer = require('safe-buffer').Buffer
25362
25363module.exports = function publicEncrypt (publicKey, msg, reverse) {
25364 var padding
25365 if (publicKey.padding) {
25366 padding = publicKey.padding
25367 } else if (reverse) {
25368 padding = 1
25369 } else {
25370 padding = 4
25371 }
25372 var key = parseKeys(publicKey)
25373 var paddedMsg
25374 if (padding === 4) {
25375 paddedMsg = oaep(key, msg)
25376 } else if (padding === 1) {
25377 paddedMsg = pkcs1(key, msg, reverse)
25378 } else if (padding === 3) {
25379 paddedMsg = new BN(msg)
25380 if (paddedMsg.cmp(key.modulus) >= 0) {
25381 throw new Error('data too long for modulus')
25382 }
25383 } else {
25384 throw new Error('unknown padding')
25385 }
25386 if (reverse) {
25387 return crt(paddedMsg, key)
25388 } else {
25389 return withPublic(paddedMsg, key)
25390 }
25391}
25392
25393function oaep (key, msg) {
25394 var k = key.modulus.byteLength()
25395 var mLen = msg.length
25396 var iHash = createHash('sha1').update(Buffer.alloc(0)).digest()
25397 var hLen = iHash.length
25398 var hLen2 = 2 * hLen
25399 if (mLen > k - hLen2 - 2) {
25400 throw new Error('message too long')
25401 }
25402 var ps = Buffer.alloc(k - mLen - hLen2 - 2)
25403 var dblen = k - hLen - 1
25404 var seed = randomBytes(hLen)
25405 var maskedDb = xor(Buffer.concat([iHash, ps, Buffer.alloc(1, 1), msg], dblen), mgf(seed, dblen))
25406 var maskedSeed = xor(seed, mgf(maskedDb, hLen))
25407 return new BN(Buffer.concat([Buffer.alloc(1), maskedSeed, maskedDb], k))
25408}
25409function pkcs1 (key, msg, reverse) {
25410 var mLen = msg.length
25411 var k = key.modulus.byteLength()
25412 if (mLen > k - 11) {
25413 throw new Error('message too long')
25414 }
25415 var ps
25416 if (reverse) {
25417 ps = Buffer.alloc(k - mLen - 3, 0xff)
25418 } else {
25419 ps = nonZero(k - mLen - 3)
25420 }
25421 return new BN(Buffer.concat([Buffer.from([0, reverse ? 1 : 2]), ps, Buffer.alloc(1), msg], k))
25422}
25423function nonZero (len) {
25424 var out = Buffer.allocUnsafe(len)
25425 var i = 0
25426 var cache = randomBytes(len * 2)
25427 var cur = 0
25428 var num
25429 while (i < len) {
25430 if (cur === cache.length) {
25431 cache = randomBytes(len * 2)
25432 cur = 0
25433 }
25434 num = cache[cur++]
25435 if (num) {
25436 out[i++] = num
25437 }
25438 }
25439 return out
25440}
25441
25442},{"./mgf":183,"./withPublic":186,"./xor":187,"bn.js":79,"browserify-rsa":102,"create-hash":114,"parse-asn1":174,"randombytes":188,"safe-buffer":206}],186:[function(require,module,exports){
25443var BN = require('bn.js')
25444var Buffer = require('safe-buffer').Buffer
25445
25446function withPublic (paddedMsg, key) {
25447 return Buffer.from(paddedMsg
25448 .toRed(BN.mont(key.modulus))
25449 .redPow(new BN(key.publicExponent))
25450 .fromRed()
25451 .toArray())
25452}
25453
25454module.exports = withPublic
25455
25456},{"bn.js":79,"safe-buffer":206}],187:[function(require,module,exports){
25457module.exports = function xor (a, b) {
25458 var len = a.length
25459 var i = -1
25460 while (++i < len) {
25461 a[i] ^= b[i]
25462 }
25463 return a
25464}
25465
25466},{}],188:[function(require,module,exports){
25467(function (process,global){
25468'use strict'
25469
25470// limit of Crypto.getRandomValues()
25471// https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues
25472var MAX_BYTES = 65536
25473
25474// Node supports requesting up to this number of bytes
25475// https://github.com/nodejs/node/blob/master/lib/internal/crypto/random.js#L48
25476var MAX_UINT32 = 4294967295
25477
25478function oldBrowser () {
25479 throw new Error('Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11')
25480}
25481
25482var Buffer = require('safe-buffer').Buffer
25483var crypto = global.crypto || global.msCrypto
25484
25485if (crypto && crypto.getRandomValues) {
25486 module.exports = randomBytes
25487} else {
25488 module.exports = oldBrowser
25489}
25490
25491function randomBytes (size, cb) {
25492 // phantomjs needs to throw
25493 if (size > MAX_UINT32) throw new RangeError('requested too many random bytes')
25494
25495 var bytes = Buffer.allocUnsafe(size)
25496
25497 if (size > 0) { // getRandomValues fails on IE if size == 0
25498 if (size > MAX_BYTES) { // this is the max bytes crypto.getRandomValues
25499 // can do at once see https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues
25500 for (var generated = 0; generated < size; generated += MAX_BYTES) {
25501 // buffer.slice automatically checks if the end is past the end of
25502 // the buffer so we don't have to here
25503 crypto.getRandomValues(bytes.slice(generated, generated + MAX_BYTES))
25504 }
25505 } else {
25506 crypto.getRandomValues(bytes)
25507 }
25508 }
25509
25510 if (typeof cb === 'function') {
25511 return process.nextTick(function () {
25512 cb(null, bytes)
25513 })
25514 }
25515
25516 return bytes
25517}
25518
25519}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
25520},{"_process":181,"safe-buffer":206}],189:[function(require,module,exports){
25521(function (process,global){
25522'use strict'
25523
25524function oldBrowser () {
25525 throw new Error('secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11')
25526}
25527var safeBuffer = require('safe-buffer')
25528var randombytes = require('randombytes')
25529var Buffer = safeBuffer.Buffer
25530var kBufferMaxLength = safeBuffer.kMaxLength
25531var crypto = global.crypto || global.msCrypto
25532var kMaxUint32 = Math.pow(2, 32) - 1
25533function assertOffset (offset, length) {
25534 if (typeof offset !== 'number' || offset !== offset) { // eslint-disable-line no-self-compare
25535 throw new TypeError('offset must be a number')
25536 }
25537
25538 if (offset > kMaxUint32 || offset < 0) {
25539 throw new TypeError('offset must be a uint32')
25540 }
25541
25542 if (offset > kBufferMaxLength || offset > length) {
25543 throw new RangeError('offset out of range')
25544 }
25545}
25546
25547function assertSize (size, offset, length) {
25548 if (typeof size !== 'number' || size !== size) { // eslint-disable-line no-self-compare
25549 throw new TypeError('size must be a number')
25550 }
25551
25552 if (size > kMaxUint32 || size < 0) {
25553 throw new TypeError('size must be a uint32')
25554 }
25555
25556 if (size + offset > length || size > kBufferMaxLength) {
25557 throw new RangeError('buffer too small')
25558 }
25559}
25560if ((crypto && crypto.getRandomValues) || !process.browser) {
25561 exports.randomFill = randomFill
25562 exports.randomFillSync = randomFillSync
25563} else {
25564 exports.randomFill = oldBrowser
25565 exports.randomFillSync = oldBrowser
25566}
25567function randomFill (buf, offset, size, cb) {
25568 if (!Buffer.isBuffer(buf) && !(buf instanceof global.Uint8Array)) {
25569 throw new TypeError('"buf" argument must be a Buffer or Uint8Array')
25570 }
25571
25572 if (typeof offset === 'function') {
25573 cb = offset
25574 offset = 0
25575 size = buf.length
25576 } else if (typeof size === 'function') {
25577 cb = size
25578 size = buf.length - offset
25579 } else if (typeof cb !== 'function') {
25580 throw new TypeError('"cb" argument must be a function')
25581 }
25582 assertOffset(offset, buf.length)
25583 assertSize(size, offset, buf.length)
25584 return actualFill(buf, offset, size, cb)
25585}
25586
25587function actualFill (buf, offset, size, cb) {
25588 if (process.browser) {
25589 var ourBuf = buf.buffer
25590 var uint = new Uint8Array(ourBuf, offset, size)
25591 crypto.getRandomValues(uint)
25592 if (cb) {
25593 process.nextTick(function () {
25594 cb(null, buf)
25595 })
25596 return
25597 }
25598 return buf
25599 }
25600 if (cb) {
25601 randombytes(size, function (err, bytes) {
25602 if (err) {
25603 return cb(err)
25604 }
25605 bytes.copy(buf, offset)
25606 cb(null, buf)
25607 })
25608 return
25609 }
25610 var bytes = randombytes(size)
25611 bytes.copy(buf, offset)
25612 return buf
25613}
25614function randomFillSync (buf, offset, size) {
25615 if (typeof offset === 'undefined') {
25616 offset = 0
25617 }
25618 if (!Buffer.isBuffer(buf) && !(buf instanceof global.Uint8Array)) {
25619 throw new TypeError('"buf" argument must be a Buffer or Uint8Array')
25620 }
25621
25622 assertOffset(offset, buf.length)
25623
25624 if (size === undefined) size = buf.length - offset
25625
25626 assertSize(size, offset, buf.length)
25627
25628 return actualFill(buf, offset, size)
25629}
25630
25631}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
25632},{"_process":181,"randombytes":188,"safe-buffer":206}],190:[function(require,module,exports){
25633module.exports = require('./lib/_stream_duplex.js');
25634
25635},{"./lib/_stream_duplex.js":191}],191:[function(require,module,exports){
25636// Copyright Joyent, Inc. and other Node contributors.
25637//
25638// Permission is hereby granted, free of charge, to any person obtaining a
25639// copy of this software and associated documentation files (the
25640// "Software"), to deal in the Software without restriction, including
25641// without limitation the rights to use, copy, modify, merge, publish,
25642// distribute, sublicense, and/or sell copies of the Software, and to permit
25643// persons to whom the Software is furnished to do so, subject to the
25644// following conditions:
25645//
25646// The above copyright notice and this permission notice shall be included
25647// in all copies or substantial portions of the Software.
25648//
25649// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25650// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25651// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
25652// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25653// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
25654// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
25655// USE OR OTHER DEALINGS IN THE SOFTWARE.
25656
25657// a duplex stream is just a stream that is both readable and writable.
25658// Since JS doesn't have multiple prototypal inheritance, this class
25659// prototypally inherits from Readable, and then parasitically from
25660// Writable.
25661
25662'use strict';
25663
25664/*<replacement>*/
25665
25666var pna = require('process-nextick-args');
25667/*</replacement>*/
25668
25669/*<replacement>*/
25670var objectKeys = Object.keys || function (obj) {
25671 var keys = [];
25672 for (var key in obj) {
25673 keys.push(key);
25674 }return keys;
25675};
25676/*</replacement>*/
25677
25678module.exports = Duplex;
25679
25680/*<replacement>*/
25681var util = require('core-util-is');
25682util.inherits = require('inherits');
25683/*</replacement>*/
25684
25685var Readable = require('./_stream_readable');
25686var Writable = require('./_stream_writable');
25687
25688util.inherits(Duplex, Readable);
25689
25690{
25691 // avoid scope creep, the keys array can then be collected
25692 var keys = objectKeys(Writable.prototype);
25693 for (var v = 0; v < keys.length; v++) {
25694 var method = keys[v];
25695 if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
25696 }
25697}
25698
25699function Duplex(options) {
25700 if (!(this instanceof Duplex)) return new Duplex(options);
25701
25702 Readable.call(this, options);
25703 Writable.call(this, options);
25704
25705 if (options && options.readable === false) this.readable = false;
25706
25707 if (options && options.writable === false) this.writable = false;
25708
25709 this.allowHalfOpen = true;
25710 if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
25711
25712 this.once('end', onend);
25713}
25714
25715Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
25716 // making it explicit this property is not enumerable
25717 // because otherwise some prototype manipulation in
25718 // userland will fail
25719 enumerable: false,
25720 get: function () {
25721 return this._writableState.highWaterMark;
25722 }
25723});
25724
25725// the no-half-open enforcer
25726function onend() {
25727 // if we allow half-open state, or if the writable side ended,
25728 // then we're ok.
25729 if (this.allowHalfOpen || this._writableState.ended) return;
25730
25731 // no more data can be written.
25732 // But allow more writes to happen in this tick.
25733 pna.nextTick(onEndNT, this);
25734}
25735
25736function onEndNT(self) {
25737 self.end();
25738}
25739
25740Object.defineProperty(Duplex.prototype, 'destroyed', {
25741 get: function () {
25742 if (this._readableState === undefined || this._writableState === undefined) {
25743 return false;
25744 }
25745 return this._readableState.destroyed && this._writableState.destroyed;
25746 },
25747 set: function (value) {
25748 // we ignore the value if the stream
25749 // has not been initialized yet
25750 if (this._readableState === undefined || this._writableState === undefined) {
25751 return;
25752 }
25753
25754 // backward compatibility, the user is explicitly
25755 // managing destroyed
25756 this._readableState.destroyed = value;
25757 this._writableState.destroyed = value;
25758 }
25759});
25760
25761Duplex.prototype._destroy = function (err, cb) {
25762 this.push(null);
25763 this.end();
25764
25765 pna.nextTick(cb, err);
25766};
25767},{"./_stream_readable":193,"./_stream_writable":195,"core-util-is":112,"inherits":162,"process-nextick-args":180}],192:[function(require,module,exports){
25768// Copyright Joyent, Inc. and other Node contributors.
25769//
25770// Permission is hereby granted, free of charge, to any person obtaining a
25771// copy of this software and associated documentation files (the
25772// "Software"), to deal in the Software without restriction, including
25773// without limitation the rights to use, copy, modify, merge, publish,
25774// distribute, sublicense, and/or sell copies of the Software, and to permit
25775// persons to whom the Software is furnished to do so, subject to the
25776// following conditions:
25777//
25778// The above copyright notice and this permission notice shall be included
25779// in all copies or substantial portions of the Software.
25780//
25781// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25782// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25783// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
25784// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25785// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
25786// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
25787// USE OR OTHER DEALINGS IN THE SOFTWARE.
25788
25789// a passthrough stream.
25790// basically just the most minimal sort of Transform stream.
25791// Every written chunk gets output as-is.
25792
25793'use strict';
25794
25795module.exports = PassThrough;
25796
25797var Transform = require('./_stream_transform');
25798
25799/*<replacement>*/
25800var util = require('core-util-is');
25801util.inherits = require('inherits');
25802/*</replacement>*/
25803
25804util.inherits(PassThrough, Transform);
25805
25806function PassThrough(options) {
25807 if (!(this instanceof PassThrough)) return new PassThrough(options);
25808
25809 Transform.call(this, options);
25810}
25811
25812PassThrough.prototype._transform = function (chunk, encoding, cb) {
25813 cb(null, chunk);
25814};
25815},{"./_stream_transform":194,"core-util-is":112,"inherits":162}],193:[function(require,module,exports){
25816(function (process,global){
25817// Copyright Joyent, Inc. and other Node contributors.
25818//
25819// Permission is hereby granted, free of charge, to any person obtaining a
25820// copy of this software and associated documentation files (the
25821// "Software"), to deal in the Software without restriction, including
25822// without limitation the rights to use, copy, modify, merge, publish,
25823// distribute, sublicense, and/or sell copies of the Software, and to permit
25824// persons to whom the Software is furnished to do so, subject to the
25825// following conditions:
25826//
25827// The above copyright notice and this permission notice shall be included
25828// in all copies or substantial portions of the Software.
25829//
25830// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25831// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25832// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
25833// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25834// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
25835// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
25836// USE OR OTHER DEALINGS IN THE SOFTWARE.
25837
25838'use strict';
25839
25840/*<replacement>*/
25841
25842var pna = require('process-nextick-args');
25843/*</replacement>*/
25844
25845module.exports = Readable;
25846
25847/*<replacement>*/
25848var isArray = require('isarray');
25849/*</replacement>*/
25850
25851/*<replacement>*/
25852var Duplex;
25853/*</replacement>*/
25854
25855Readable.ReadableState = ReadableState;
25856
25857/*<replacement>*/
25858var EE = require('events').EventEmitter;
25859
25860var EElistenerCount = function (emitter, type) {
25861 return emitter.listeners(type).length;
25862};
25863/*</replacement>*/
25864
25865/*<replacement>*/
25866var Stream = require('./internal/streams/stream');
25867/*</replacement>*/
25868
25869/*<replacement>*/
25870
25871var Buffer = require('safe-buffer').Buffer;
25872var OurUint8Array = global.Uint8Array || function () {};
25873function _uint8ArrayToBuffer(chunk) {
25874 return Buffer.from(chunk);
25875}
25876function _isUint8Array(obj) {
25877 return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
25878}
25879
25880/*</replacement>*/
25881
25882/*<replacement>*/
25883var util = require('core-util-is');
25884util.inherits = require('inherits');
25885/*</replacement>*/
25886
25887/*<replacement>*/
25888var debugUtil = require('util');
25889var debug = void 0;
25890if (debugUtil && debugUtil.debuglog) {
25891 debug = debugUtil.debuglog('stream');
25892} else {
25893 debug = function () {};
25894}
25895/*</replacement>*/
25896
25897var BufferList = require('./internal/streams/BufferList');
25898var destroyImpl = require('./internal/streams/destroy');
25899var StringDecoder;
25900
25901util.inherits(Readable, Stream);
25902
25903var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
25904
25905function prependListener(emitter, event, fn) {
25906 // Sadly this is not cacheable as some libraries bundle their own
25907 // event emitter implementation with them.
25908 if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);
25909
25910 // This is a hack to make sure that our error handler is attached before any
25911 // userland ones. NEVER DO THIS. This is here only because this code needs
25912 // to continue to work with older versions of Node.js that do not include
25913 // the prependListener() method. The goal is to eventually remove this hack.
25914 if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
25915}
25916
25917function ReadableState(options, stream) {
25918 Duplex = Duplex || require('./_stream_duplex');
25919
25920 options = options || {};
25921
25922 // Duplex streams are both readable and writable, but share
25923 // the same options object.
25924 // However, some cases require setting options to different
25925 // values for the readable and the writable sides of the duplex stream.
25926 // These options can be provided separately as readableXXX and writableXXX.
25927 var isDuplex = stream instanceof Duplex;
25928
25929 // object stream flag. Used to make read(n) ignore n and to
25930 // make all the buffer merging and length checks go away
25931 this.objectMode = !!options.objectMode;
25932
25933 if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
25934
25935 // the point at which it stops calling _read() to fill the buffer
25936 // Note: 0 is a valid value, means "don't call _read preemptively ever"
25937 var hwm = options.highWaterMark;
25938 var readableHwm = options.readableHighWaterMark;
25939 var defaultHwm = this.objectMode ? 16 : 16 * 1024;
25940
25941 if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;
25942
25943 // cast to ints.
25944 this.highWaterMark = Math.floor(this.highWaterMark);
25945
25946 // A linked list is used to store data chunks instead of an array because the
25947 // linked list can remove elements from the beginning faster than
25948 // array.shift()
25949 this.buffer = new BufferList();
25950 this.length = 0;
25951 this.pipes = null;
25952 this.pipesCount = 0;
25953 this.flowing = null;
25954 this.ended = false;
25955 this.endEmitted = false;
25956 this.reading = false;
25957
25958 // a flag to be able to tell if the event 'readable'/'data' is emitted
25959 // immediately, or on a later tick. We set this to true at first, because
25960 // any actions that shouldn't happen until "later" should generally also
25961 // not happen before the first read call.
25962 this.sync = true;
25963
25964 // whenever we return null, then we set a flag to say
25965 // that we're awaiting a 'readable' event emission.
25966 this.needReadable = false;
25967 this.emittedReadable = false;
25968 this.readableListening = false;
25969 this.resumeScheduled = false;
25970
25971 // has it been destroyed
25972 this.destroyed = false;
25973
25974 // Crypto is kind of old and crusty. Historically, its default string
25975 // encoding is 'binary' so we have to make this configurable.
25976 // Everything else in the universe uses 'utf8', though.
25977 this.defaultEncoding = options.defaultEncoding || 'utf8';
25978
25979 // the number of writers that are awaiting a drain event in .pipe()s
25980 this.awaitDrain = 0;
25981
25982 // if true, a maybeReadMore has been scheduled
25983 this.readingMore = false;
25984
25985 this.decoder = null;
25986 this.encoding = null;
25987 if (options.encoding) {
25988 if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
25989 this.decoder = new StringDecoder(options.encoding);
25990 this.encoding = options.encoding;
25991 }
25992}
25993
25994function Readable(options) {
25995 Duplex = Duplex || require('./_stream_duplex');
25996
25997 if (!(this instanceof Readable)) return new Readable(options);
25998
25999 this._readableState = new ReadableState(options, this);
26000
26001 // legacy
26002 this.readable = true;
26003
26004 if (options) {
26005 if (typeof options.read === 'function') this._read = options.read;
26006
26007 if (typeof options.destroy === 'function') this._destroy = options.destroy;
26008 }
26009
26010 Stream.call(this);
26011}
26012
26013Object.defineProperty(Readable.prototype, 'destroyed', {
26014 get: function () {
26015 if (this._readableState === undefined) {
26016 return false;
26017 }
26018 return this._readableState.destroyed;
26019 },
26020 set: function (value) {
26021 // we ignore the value if the stream
26022 // has not been initialized yet
26023 if (!this._readableState) {
26024 return;
26025 }
26026
26027 // backward compatibility, the user is explicitly
26028 // managing destroyed
26029 this._readableState.destroyed = value;
26030 }
26031});
26032
26033Readable.prototype.destroy = destroyImpl.destroy;
26034Readable.prototype._undestroy = destroyImpl.undestroy;
26035Readable.prototype._destroy = function (err, cb) {
26036 this.push(null);
26037 cb(err);
26038};
26039
26040// Manually shove something into the read() buffer.
26041// This returns true if the highWaterMark has not been hit yet,
26042// similar to how Writable.write() returns true if you should
26043// write() some more.
26044Readable.prototype.push = function (chunk, encoding) {
26045 var state = this._readableState;
26046 var skipChunkCheck;
26047
26048 if (!state.objectMode) {
26049 if (typeof chunk === 'string') {
26050 encoding = encoding || state.defaultEncoding;
26051 if (encoding !== state.encoding) {
26052 chunk = Buffer.from(chunk, encoding);
26053 encoding = '';
26054 }
26055 skipChunkCheck = true;
26056 }
26057 } else {
26058 skipChunkCheck = true;
26059 }
26060
26061 return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
26062};
26063
26064// Unshift should *always* be something directly out of read()
26065Readable.prototype.unshift = function (chunk) {
26066 return readableAddChunk(this, chunk, null, true, false);
26067};
26068
26069function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
26070 var state = stream._readableState;
26071 if (chunk === null) {
26072 state.reading = false;
26073 onEofChunk(stream, state);
26074 } else {
26075 var er;
26076 if (!skipChunkCheck) er = chunkInvalid(state, chunk);
26077 if (er) {
26078 stream.emit('error', er);
26079 } else if (state.objectMode || chunk && chunk.length > 0) {
26080 if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
26081 chunk = _uint8ArrayToBuffer(chunk);
26082 }
26083
26084 if (addToFront) {
26085 if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
26086 } else if (state.ended) {
26087 stream.emit('error', new Error('stream.push() after EOF'));
26088 } else {
26089 state.reading = false;
26090 if (state.decoder && !encoding) {
26091 chunk = state.decoder.write(chunk);
26092 if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
26093 } else {
26094 addChunk(stream, state, chunk, false);
26095 }
26096 }
26097 } else if (!addToFront) {
26098 state.reading = false;
26099 }
26100 }
26101
26102 return needMoreData(state);
26103}
26104
26105function addChunk(stream, state, chunk, addToFront) {
26106 if (state.flowing && state.length === 0 && !state.sync) {
26107 stream.emit('data', chunk);
26108 stream.read(0);
26109 } else {
26110 // update the buffer info.
26111 state.length += state.objectMode ? 1 : chunk.length;
26112 if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
26113
26114 if (state.needReadable) emitReadable(stream);
26115 }
26116 maybeReadMore(stream, state);
26117}
26118
26119function chunkInvalid(state, chunk) {
26120 var er;
26121 if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
26122 er = new TypeError('Invalid non-string/buffer chunk');
26123 }
26124 return er;
26125}
26126
26127// if it's past the high water mark, we can push in some more.
26128// Also, if we have no data yet, we can stand some
26129// more bytes. This is to work around cases where hwm=0,
26130// such as the repl. Also, if the push() triggered a
26131// readable event, and the user called read(largeNumber) such that
26132// needReadable was set, then we ought to push more, so that another
26133// 'readable' event will be triggered.
26134function needMoreData(state) {
26135 return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
26136}
26137
26138Readable.prototype.isPaused = function () {
26139 return this._readableState.flowing === false;
26140};
26141
26142// backwards compatibility.
26143Readable.prototype.setEncoding = function (enc) {
26144 if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
26145 this._readableState.decoder = new StringDecoder(enc);
26146 this._readableState.encoding = enc;
26147 return this;
26148};
26149
26150// Don't raise the hwm > 8MB
26151var MAX_HWM = 0x800000;
26152function computeNewHighWaterMark(n) {
26153 if (n >= MAX_HWM) {
26154 n = MAX_HWM;
26155 } else {
26156 // Get the next highest power of 2 to prevent increasing hwm excessively in
26157 // tiny amounts
26158 n--;
26159 n |= n >>> 1;
26160 n |= n >>> 2;
26161 n |= n >>> 4;
26162 n |= n >>> 8;
26163 n |= n >>> 16;
26164 n++;
26165 }
26166 return n;
26167}
26168
26169// This function is designed to be inlinable, so please take care when making
26170// changes to the function body.
26171function howMuchToRead(n, state) {
26172 if (n <= 0 || state.length === 0 && state.ended) return 0;
26173 if (state.objectMode) return 1;
26174 if (n !== n) {
26175 // Only flow one buffer at a time
26176 if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
26177 }
26178 // If we're asking for more than the current hwm, then raise the hwm.
26179 if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
26180 if (n <= state.length) return n;
26181 // Don't have enough
26182 if (!state.ended) {
26183 state.needReadable = true;
26184 return 0;
26185 }
26186 return state.length;
26187}
26188
26189// you can override either this method, or the async _read(n) below.
26190Readable.prototype.read = function (n) {
26191 debug('read', n);
26192 n = parseInt(n, 10);
26193 var state = this._readableState;
26194 var nOrig = n;
26195
26196 if (n !== 0) state.emittedReadable = false;
26197
26198 // if we're doing read(0) to trigger a readable event, but we
26199 // already have a bunch of data in the buffer, then just trigger
26200 // the 'readable' event and move on.
26201 if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
26202 debug('read: emitReadable', state.length, state.ended);
26203 if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
26204 return null;
26205 }
26206
26207 n = howMuchToRead(n, state);
26208
26209 // if we've ended, and we're now clear, then finish it up.
26210 if (n === 0 && state.ended) {
26211 if (state.length === 0) endReadable(this);
26212 return null;
26213 }
26214
26215 // All the actual chunk generation logic needs to be
26216 // *below* the call to _read. The reason is that in certain
26217 // synthetic stream cases, such as passthrough streams, _read
26218 // may be a completely synchronous operation which may change
26219 // the state of the read buffer, providing enough data when
26220 // before there was *not* enough.
26221 //
26222 // So, the steps are:
26223 // 1. Figure out what the state of things will be after we do
26224 // a read from the buffer.
26225 //
26226 // 2. If that resulting state will trigger a _read, then call _read.
26227 // Note that this may be asynchronous, or synchronous. Yes, it is
26228 // deeply ugly to write APIs this way, but that still doesn't mean
26229 // that the Readable class should behave improperly, as streams are
26230 // designed to be sync/async agnostic.
26231 // Take note if the _read call is sync or async (ie, if the read call
26232 // has returned yet), so that we know whether or not it's safe to emit
26233 // 'readable' etc.
26234 //
26235 // 3. Actually pull the requested chunks out of the buffer and return.
26236
26237 // if we need a readable event, then we need to do some reading.
26238 var doRead = state.needReadable;
26239 debug('need readable', doRead);
26240
26241 // if we currently have less than the highWaterMark, then also read some
26242 if (state.length === 0 || state.length - n < state.highWaterMark) {
26243 doRead = true;
26244 debug('length less than watermark', doRead);
26245 }
26246
26247 // however, if we've ended, then there's no point, and if we're already
26248 // reading, then it's unnecessary.
26249 if (state.ended || state.reading) {
26250 doRead = false;
26251 debug('reading or ended', doRead);
26252 } else if (doRead) {
26253 debug('do read');
26254 state.reading = true;
26255 state.sync = true;
26256 // if the length is currently zero, then we *need* a readable event.
26257 if (state.length === 0) state.needReadable = true;
26258 // call internal read method
26259 this._read(state.highWaterMark);
26260 state.sync = false;
26261 // If _read pushed data synchronously, then `reading` will be false,
26262 // and we need to re-evaluate how much data we can return to the user.
26263 if (!state.reading) n = howMuchToRead(nOrig, state);
26264 }
26265
26266 var ret;
26267 if (n > 0) ret = fromList(n, state);else ret = null;
26268
26269 if (ret === null) {
26270 state.needReadable = true;
26271 n = 0;
26272 } else {
26273 state.length -= n;
26274 }
26275
26276 if (state.length === 0) {
26277 // If we have nothing in the buffer, then we want to know
26278 // as soon as we *do* get something into the buffer.
26279 if (!state.ended) state.needReadable = true;
26280
26281 // If we tried to read() past the EOF, then emit end on the next tick.
26282 if (nOrig !== n && state.ended) endReadable(this);
26283 }
26284
26285 if (ret !== null) this.emit('data', ret);
26286
26287 return ret;
26288};
26289
26290function onEofChunk(stream, state) {
26291 if (state.ended) return;
26292 if (state.decoder) {
26293 var chunk = state.decoder.end();
26294 if (chunk && chunk.length) {
26295 state.buffer.push(chunk);
26296 state.length += state.objectMode ? 1 : chunk.length;
26297 }
26298 }
26299 state.ended = true;
26300
26301 // emit 'readable' now to make sure it gets picked up.
26302 emitReadable(stream);
26303}
26304
26305// Don't emit readable right away in sync mode, because this can trigger
26306// another read() call => stack overflow. This way, it might trigger
26307// a nextTick recursion warning, but that's not so bad.
26308function emitReadable(stream) {
26309 var state = stream._readableState;
26310 state.needReadable = false;
26311 if (!state.emittedReadable) {
26312 debug('emitReadable', state.flowing);
26313 state.emittedReadable = true;
26314 if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);
26315 }
26316}
26317
26318function emitReadable_(stream) {
26319 debug('emit readable');
26320 stream.emit('readable');
26321 flow(stream);
26322}
26323
26324// at this point, the user has presumably seen the 'readable' event,
26325// and called read() to consume some data. that may have triggered
26326// in turn another _read(n) call, in which case reading = true if
26327// it's in progress.
26328// However, if we're not ended, or reading, and the length < hwm,
26329// then go ahead and try to read some more preemptively.
26330function maybeReadMore(stream, state) {
26331 if (!state.readingMore) {
26332 state.readingMore = true;
26333 pna.nextTick(maybeReadMore_, stream, state);
26334 }
26335}
26336
26337function maybeReadMore_(stream, state) {
26338 var len = state.length;
26339 while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
26340 debug('maybeReadMore read 0');
26341 stream.read(0);
26342 if (len === state.length)
26343 // didn't get any data, stop spinning.
26344 break;else len = state.length;
26345 }
26346 state.readingMore = false;
26347}
26348
26349// abstract method. to be overridden in specific implementation classes.
26350// call cb(er, data) where data is <= n in length.
26351// for virtual (non-string, non-buffer) streams, "length" is somewhat
26352// arbitrary, and perhaps not very meaningful.
26353Readable.prototype._read = function (n) {
26354 this.emit('error', new Error('_read() is not implemented'));
26355};
26356
26357Readable.prototype.pipe = function (dest, pipeOpts) {
26358 var src = this;
26359 var state = this._readableState;
26360
26361 switch (state.pipesCount) {
26362 case 0:
26363 state.pipes = dest;
26364 break;
26365 case 1:
26366 state.pipes = [state.pipes, dest];
26367 break;
26368 default:
26369 state.pipes.push(dest);
26370 break;
26371 }
26372 state.pipesCount += 1;
26373 debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
26374
26375 var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
26376
26377 var endFn = doEnd ? onend : unpipe;
26378 if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);
26379
26380 dest.on('unpipe', onunpipe);
26381 function onunpipe(readable, unpipeInfo) {
26382 debug('onunpipe');
26383 if (readable === src) {
26384 if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
26385 unpipeInfo.hasUnpiped = true;
26386 cleanup();
26387 }
26388 }
26389 }
26390
26391 function onend() {
26392 debug('onend');
26393 dest.end();
26394 }
26395
26396 // when the dest drains, it reduces the awaitDrain counter
26397 // on the source. This would be more elegant with a .once()
26398 // handler in flow(), but adding and removing repeatedly is
26399 // too slow.
26400 var ondrain = pipeOnDrain(src);
26401 dest.on('drain', ondrain);
26402
26403 var cleanedUp = false;
26404 function cleanup() {
26405 debug('cleanup');
26406 // cleanup event handlers once the pipe is broken
26407 dest.removeListener('close', onclose);
26408 dest.removeListener('finish', onfinish);
26409 dest.removeListener('drain', ondrain);
26410 dest.removeListener('error', onerror);
26411 dest.removeListener('unpipe', onunpipe);
26412 src.removeListener('end', onend);
26413 src.removeListener('end', unpipe);
26414 src.removeListener('data', ondata);
26415
26416 cleanedUp = true;
26417
26418 // if the reader is waiting for a drain event from this
26419 // specific writer, then it would cause it to never start
26420 // flowing again.
26421 // So, if this is awaiting a drain, then we just call it now.
26422 // If we don't know, then assume that we are waiting for one.
26423 if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
26424 }
26425
26426 // If the user pushes more data while we're writing to dest then we'll end up
26427 // in ondata again. However, we only want to increase awaitDrain once because
26428 // dest will only emit one 'drain' event for the multiple writes.
26429 // => Introduce a guard on increasing awaitDrain.
26430 var increasedAwaitDrain = false;
26431 src.on('data', ondata);
26432 function ondata(chunk) {
26433 debug('ondata');
26434 increasedAwaitDrain = false;
26435 var ret = dest.write(chunk);
26436 if (false === ret && !increasedAwaitDrain) {
26437 // If the user unpiped during `dest.write()`, it is possible
26438 // to get stuck in a permanently paused state if that write
26439 // also returned false.
26440 // => Check whether `dest` is still a piping destination.
26441 if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
26442 debug('false write response, pause', src._readableState.awaitDrain);
26443 src._readableState.awaitDrain++;
26444 increasedAwaitDrain = true;
26445 }
26446 src.pause();
26447 }
26448 }
26449
26450 // if the dest has an error, then stop piping into it.
26451 // however, don't suppress the throwing behavior for this.
26452 function onerror(er) {
26453 debug('onerror', er);
26454 unpipe();
26455 dest.removeListener('error', onerror);
26456 if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
26457 }
26458
26459 // Make sure our error handler is attached before userland ones.
26460 prependListener(dest, 'error', onerror);
26461
26462 // Both close and finish should trigger unpipe, but only once.
26463 function onclose() {
26464 dest.removeListener('finish', onfinish);
26465 unpipe();
26466 }
26467 dest.once('close', onclose);
26468 function onfinish() {
26469 debug('onfinish');
26470 dest.removeListener('close', onclose);
26471 unpipe();
26472 }
26473 dest.once('finish', onfinish);
26474
26475 function unpipe() {
26476 debug('unpipe');
26477 src.unpipe(dest);
26478 }
26479
26480 // tell the dest that it's being piped to
26481 dest.emit('pipe', src);
26482
26483 // start the flow if it hasn't been started already.
26484 if (!state.flowing) {
26485 debug('pipe resume');
26486 src.resume();
26487 }
26488
26489 return dest;
26490};
26491
26492function pipeOnDrain(src) {
26493 return function () {
26494 var state = src._readableState;
26495 debug('pipeOnDrain', state.awaitDrain);
26496 if (state.awaitDrain) state.awaitDrain--;
26497 if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
26498 state.flowing = true;
26499 flow(src);
26500 }
26501 };
26502}
26503
26504Readable.prototype.unpipe = function (dest) {
26505 var state = this._readableState;
26506 var unpipeInfo = { hasUnpiped: false };
26507
26508 // if we're not piping anywhere, then do nothing.
26509 if (state.pipesCount === 0) return this;
26510
26511 // just one destination. most common case.
26512 if (state.pipesCount === 1) {
26513 // passed in one, but it's not the right one.
26514 if (dest && dest !== state.pipes) return this;
26515
26516 if (!dest) dest = state.pipes;
26517
26518 // got a match.
26519 state.pipes = null;
26520 state.pipesCount = 0;
26521 state.flowing = false;
26522 if (dest) dest.emit('unpipe', this, unpipeInfo);
26523 return this;
26524 }
26525
26526 // slow case. multiple pipe destinations.
26527
26528 if (!dest) {
26529 // remove all.
26530 var dests = state.pipes;
26531 var len = state.pipesCount;
26532 state.pipes = null;
26533 state.pipesCount = 0;
26534 state.flowing = false;
26535
26536 for (var i = 0; i < len; i++) {
26537 dests[i].emit('unpipe', this, unpipeInfo);
26538 }return this;
26539 }
26540
26541 // try to find the right one.
26542 var index = indexOf(state.pipes, dest);
26543 if (index === -1) return this;
26544
26545 state.pipes.splice(index, 1);
26546 state.pipesCount -= 1;
26547 if (state.pipesCount === 1) state.pipes = state.pipes[0];
26548
26549 dest.emit('unpipe', this, unpipeInfo);
26550
26551 return this;
26552};
26553
26554// set up data events if they are asked for
26555// Ensure readable listeners eventually get something
26556Readable.prototype.on = function (ev, fn) {
26557 var res = Stream.prototype.on.call(this, ev, fn);
26558
26559 if (ev === 'data') {
26560 // Start flowing on next tick if stream isn't explicitly paused
26561 if (this._readableState.flowing !== false) this.resume();
26562 } else if (ev === 'readable') {
26563 var state = this._readableState;
26564 if (!state.endEmitted && !state.readableListening) {
26565 state.readableListening = state.needReadable = true;
26566 state.emittedReadable = false;
26567 if (!state.reading) {
26568 pna.nextTick(nReadingNextTick, this);
26569 } else if (state.length) {
26570 emitReadable(this);
26571 }
26572 }
26573 }
26574
26575 return res;
26576};
26577Readable.prototype.addListener = Readable.prototype.on;
26578
26579function nReadingNextTick(self) {
26580 debug('readable nexttick read 0');
26581 self.read(0);
26582}
26583
26584// pause() and resume() are remnants of the legacy readable stream API
26585// If the user uses them, then switch into old mode.
26586Readable.prototype.resume = function () {
26587 var state = this._readableState;
26588 if (!state.flowing) {
26589 debug('resume');
26590 state.flowing = true;
26591 resume(this, state);
26592 }
26593 return this;
26594};
26595
26596function resume(stream, state) {
26597 if (!state.resumeScheduled) {
26598 state.resumeScheduled = true;
26599 pna.nextTick(resume_, stream, state);
26600 }
26601}
26602
26603function resume_(stream, state) {
26604 if (!state.reading) {
26605 debug('resume read 0');
26606 stream.read(0);
26607 }
26608
26609 state.resumeScheduled = false;
26610 state.awaitDrain = 0;
26611 stream.emit('resume');
26612 flow(stream);
26613 if (state.flowing && !state.reading) stream.read(0);
26614}
26615
26616Readable.prototype.pause = function () {
26617 debug('call pause flowing=%j', this._readableState.flowing);
26618 if (false !== this._readableState.flowing) {
26619 debug('pause');
26620 this._readableState.flowing = false;
26621 this.emit('pause');
26622 }
26623 return this;
26624};
26625
26626function flow(stream) {
26627 var state = stream._readableState;
26628 debug('flow', state.flowing);
26629 while (state.flowing && stream.read() !== null) {}
26630}
26631
26632// wrap an old-style stream as the async data source.
26633// This is *not* part of the readable stream interface.
26634// It is an ugly unfortunate mess of history.
26635Readable.prototype.wrap = function (stream) {
26636 var _this = this;
26637
26638 var state = this._readableState;
26639 var paused = false;
26640
26641 stream.on('end', function () {
26642 debug('wrapped end');
26643 if (state.decoder && !state.ended) {
26644 var chunk = state.decoder.end();
26645 if (chunk && chunk.length) _this.push(chunk);
26646 }
26647
26648 _this.push(null);
26649 });
26650
26651 stream.on('data', function (chunk) {
26652 debug('wrapped data');
26653 if (state.decoder) chunk = state.decoder.write(chunk);
26654
26655 // don't skip over falsy values in objectMode
26656 if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
26657
26658 var ret = _this.push(chunk);
26659 if (!ret) {
26660 paused = true;
26661 stream.pause();
26662 }
26663 });
26664
26665 // proxy all the other methods.
26666 // important when wrapping filters and duplexes.
26667 for (var i in stream) {
26668 if (this[i] === undefined && typeof stream[i] === 'function') {
26669 this[i] = function (method) {
26670 return function () {
26671 return stream[method].apply(stream, arguments);
26672 };
26673 }(i);
26674 }
26675 }
26676
26677 // proxy certain important events.
26678 for (var n = 0; n < kProxyEvents.length; n++) {
26679 stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
26680 }
26681
26682 // when we try to consume some more bytes, simply unpause the
26683 // underlying stream.
26684 this._read = function (n) {
26685 debug('wrapped _read', n);
26686 if (paused) {
26687 paused = false;
26688 stream.resume();
26689 }
26690 };
26691
26692 return this;
26693};
26694
26695Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
26696 // making it explicit this property is not enumerable
26697 // because otherwise some prototype manipulation in
26698 // userland will fail
26699 enumerable: false,
26700 get: function () {
26701 return this._readableState.highWaterMark;
26702 }
26703});
26704
26705// exposed for testing purposes only.
26706Readable._fromList = fromList;
26707
26708// Pluck off n bytes from an array of buffers.
26709// Length is the combined lengths of all the buffers in the list.
26710// This function is designed to be inlinable, so please take care when making
26711// changes to the function body.
26712function fromList(n, state) {
26713 // nothing buffered
26714 if (state.length === 0) return null;
26715
26716 var ret;
26717 if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
26718 // read it all, truncate the list
26719 if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);
26720 state.buffer.clear();
26721 } else {
26722 // read part of list
26723 ret = fromListPartial(n, state.buffer, state.decoder);
26724 }
26725
26726 return ret;
26727}
26728
26729// Extracts only enough buffered data to satisfy the amount requested.
26730// This function is designed to be inlinable, so please take care when making
26731// changes to the function body.
26732function fromListPartial(n, list, hasStrings) {
26733 var ret;
26734 if (n < list.head.data.length) {
26735 // slice is the same for buffers and strings
26736 ret = list.head.data.slice(0, n);
26737 list.head.data = list.head.data.slice(n);
26738 } else if (n === list.head.data.length) {
26739 // first chunk is a perfect match
26740 ret = list.shift();
26741 } else {
26742 // result spans more than one buffer
26743 ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
26744 }
26745 return ret;
26746}
26747
26748// Copies a specified amount of characters from the list of buffered data
26749// chunks.
26750// This function is designed to be inlinable, so please take care when making
26751// changes to the function body.
26752function copyFromBufferString(n, list) {
26753 var p = list.head;
26754 var c = 1;
26755 var ret = p.data;
26756 n -= ret.length;
26757 while (p = p.next) {
26758 var str = p.data;
26759 var nb = n > str.length ? str.length : n;
26760 if (nb === str.length) ret += str;else ret += str.slice(0, n);
26761 n -= nb;
26762 if (n === 0) {
26763 if (nb === str.length) {
26764 ++c;
26765 if (p.next) list.head = p.next;else list.head = list.tail = null;
26766 } else {
26767 list.head = p;
26768 p.data = str.slice(nb);
26769 }
26770 break;
26771 }
26772 ++c;
26773 }
26774 list.length -= c;
26775 return ret;
26776}
26777
26778// Copies a specified amount of bytes from the list of buffered data chunks.
26779// This function is designed to be inlinable, so please take care when making
26780// changes to the function body.
26781function copyFromBuffer(n, list) {
26782 var ret = Buffer.allocUnsafe(n);
26783 var p = list.head;
26784 var c = 1;
26785 p.data.copy(ret);
26786 n -= p.data.length;
26787 while (p = p.next) {
26788 var buf = p.data;
26789 var nb = n > buf.length ? buf.length : n;
26790 buf.copy(ret, ret.length - n, 0, nb);
26791 n -= nb;
26792 if (n === 0) {
26793 if (nb === buf.length) {
26794 ++c;
26795 if (p.next) list.head = p.next;else list.head = list.tail = null;
26796 } else {
26797 list.head = p;
26798 p.data = buf.slice(nb);
26799 }
26800 break;
26801 }
26802 ++c;
26803 }
26804 list.length -= c;
26805 return ret;
26806}
26807
26808function endReadable(stream) {
26809 var state = stream._readableState;
26810
26811 // If we get here before consuming all the bytes, then that is a
26812 // bug in node. Should never happen.
26813 if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
26814
26815 if (!state.endEmitted) {
26816 state.ended = true;
26817 pna.nextTick(endReadableNT, state, stream);
26818 }
26819}
26820
26821function endReadableNT(state, stream) {
26822 // Check that we didn't get one last unshift.
26823 if (!state.endEmitted && state.length === 0) {
26824 state.endEmitted = true;
26825 stream.readable = false;
26826 stream.emit('end');
26827 }
26828}
26829
26830function indexOf(xs, x) {
26831 for (var i = 0, l = xs.length; i < l; i++) {
26832 if (xs[i] === x) return i;
26833 }
26834 return -1;
26835}
26836}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
26837},{"./_stream_duplex":191,"./internal/streams/BufferList":196,"./internal/streams/destroy":197,"./internal/streams/stream":198,"_process":181,"core-util-is":112,"events":145,"inherits":162,"isarray":164,"process-nextick-args":180,"safe-buffer":199,"string_decoder/":200,"util":81}],194:[function(require,module,exports){
26838// Copyright Joyent, Inc. and other Node contributors.
26839//
26840// Permission is hereby granted, free of charge, to any person obtaining a
26841// copy of this software and associated documentation files (the
26842// "Software"), to deal in the Software without restriction, including
26843// without limitation the rights to use, copy, modify, merge, publish,
26844// distribute, sublicense, and/or sell copies of the Software, and to permit
26845// persons to whom the Software is furnished to do so, subject to the
26846// following conditions:
26847//
26848// The above copyright notice and this permission notice shall be included
26849// in all copies or substantial portions of the Software.
26850//
26851// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
26852// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26853// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
26854// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
26855// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
26856// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
26857// USE OR OTHER DEALINGS IN THE SOFTWARE.
26858
26859// a transform stream is a readable/writable stream where you do
26860// something with the data. Sometimes it's called a "filter",
26861// but that's not a great name for it, since that implies a thing where
26862// some bits pass through, and others are simply ignored. (That would
26863// be a valid example of a transform, of course.)
26864//
26865// While the output is causally related to the input, it's not a
26866// necessarily symmetric or synchronous transformation. For example,
26867// a zlib stream might take multiple plain-text writes(), and then
26868// emit a single compressed chunk some time in the future.
26869//
26870// Here's how this works:
26871//
26872// The Transform stream has all the aspects of the readable and writable
26873// stream classes. When you write(chunk), that calls _write(chunk,cb)
26874// internally, and returns false if there's a lot of pending writes
26875// buffered up. When you call read(), that calls _read(n) until
26876// there's enough pending readable data buffered up.
26877//
26878// In a transform stream, the written data is placed in a buffer. When
26879// _read(n) is called, it transforms the queued up data, calling the
26880// buffered _write cb's as it consumes chunks. If consuming a single
26881// written chunk would result in multiple output chunks, then the first
26882// outputted bit calls the readcb, and subsequent chunks just go into
26883// the read buffer, and will cause it to emit 'readable' if necessary.
26884//
26885// This way, back-pressure is actually determined by the reading side,
26886// since _read has to be called to start processing a new chunk. However,
26887// a pathological inflate type of transform can cause excessive buffering
26888// here. For example, imagine a stream where every byte of input is
26889// interpreted as an integer from 0-255, and then results in that many
26890// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
26891// 1kb of data being output. In this case, you could write a very small
26892// amount of input, and end up with a very large amount of output. In
26893// such a pathological inflating mechanism, there'd be no way to tell
26894// the system to stop doing the transform. A single 4MB write could
26895// cause the system to run out of memory.
26896//
26897// However, even in such a pathological case, only a single written chunk
26898// would be consumed, and then the rest would wait (un-transformed) until
26899// the results of the previous transformed chunk were consumed.
26900
26901'use strict';
26902
26903module.exports = Transform;
26904
26905var Duplex = require('./_stream_duplex');
26906
26907/*<replacement>*/
26908var util = require('core-util-is');
26909util.inherits = require('inherits');
26910/*</replacement>*/
26911
26912util.inherits(Transform, Duplex);
26913
26914function afterTransform(er, data) {
26915 var ts = this._transformState;
26916 ts.transforming = false;
26917
26918 var cb = ts.writecb;
26919
26920 if (!cb) {
26921 return this.emit('error', new Error('write callback called multiple times'));
26922 }
26923
26924 ts.writechunk = null;
26925 ts.writecb = null;
26926
26927 if (data != null) // single equals check for both `null` and `undefined`
26928 this.push(data);
26929
26930 cb(er);
26931
26932 var rs = this._readableState;
26933 rs.reading = false;
26934 if (rs.needReadable || rs.length < rs.highWaterMark) {
26935 this._read(rs.highWaterMark);
26936 }
26937}
26938
26939function Transform(options) {
26940 if (!(this instanceof Transform)) return new Transform(options);
26941
26942 Duplex.call(this, options);
26943
26944 this._transformState = {
26945 afterTransform: afterTransform.bind(this),
26946 needTransform: false,
26947 transforming: false,
26948 writecb: null,
26949 writechunk: null,
26950 writeencoding: null
26951 };
26952
26953 // start out asking for a readable event once data is transformed.
26954 this._readableState.needReadable = true;
26955
26956 // we have implemented the _read method, and done the other things
26957 // that Readable wants before the first _read call, so unset the
26958 // sync guard flag.
26959 this._readableState.sync = false;
26960
26961 if (options) {
26962 if (typeof options.transform === 'function') this._transform = options.transform;
26963
26964 if (typeof options.flush === 'function') this._flush = options.flush;
26965 }
26966
26967 // When the writable side finishes, then flush out anything remaining.
26968 this.on('prefinish', prefinish);
26969}
26970
26971function prefinish() {
26972 var _this = this;
26973
26974 if (typeof this._flush === 'function') {
26975 this._flush(function (er, data) {
26976 done(_this, er, data);
26977 });
26978 } else {
26979 done(this, null, null);
26980 }
26981}
26982
26983Transform.prototype.push = function (chunk, encoding) {
26984 this._transformState.needTransform = false;
26985 return Duplex.prototype.push.call(this, chunk, encoding);
26986};
26987
26988// This is the part where you do stuff!
26989// override this function in implementation classes.
26990// 'chunk' is an input chunk.
26991//
26992// Call `push(newChunk)` to pass along transformed output
26993// to the readable side. You may call 'push' zero or more times.
26994//
26995// Call `cb(err)` when you are done with this chunk. If you pass
26996// an error, then that'll put the hurt on the whole operation. If you
26997// never call cb(), then you'll never get another chunk.
26998Transform.prototype._transform = function (chunk, encoding, cb) {
26999 throw new Error('_transform() is not implemented');
27000};
27001
27002Transform.prototype._write = function (chunk, encoding, cb) {
27003 var ts = this._transformState;
27004 ts.writecb = cb;
27005 ts.writechunk = chunk;
27006 ts.writeencoding = encoding;
27007 if (!ts.transforming) {
27008 var rs = this._readableState;
27009 if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
27010 }
27011};
27012
27013// Doesn't matter what the args are here.
27014// _transform does all the work.
27015// That we got here means that the readable side wants more data.
27016Transform.prototype._read = function (n) {
27017 var ts = this._transformState;
27018
27019 if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
27020 ts.transforming = true;
27021 this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
27022 } else {
27023 // mark that we need a transform, so that any data that comes in
27024 // will get processed, now that we've asked for it.
27025 ts.needTransform = true;
27026 }
27027};
27028
27029Transform.prototype._destroy = function (err, cb) {
27030 var _this2 = this;
27031
27032 Duplex.prototype._destroy.call(this, err, function (err2) {
27033 cb(err2);
27034 _this2.emit('close');
27035 });
27036};
27037
27038function done(stream, er, data) {
27039 if (er) return stream.emit('error', er);
27040
27041 if (data != null) // single equals check for both `null` and `undefined`
27042 stream.push(data);
27043
27044 // if there's nothing in the write buffer, then that means
27045 // that nothing more will ever be provided
27046 if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
27047
27048 if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
27049
27050 return stream.push(null);
27051}
27052},{"./_stream_duplex":191,"core-util-is":112,"inherits":162}],195:[function(require,module,exports){
27053(function (process,global,setImmediate){
27054// Copyright Joyent, Inc. and other Node contributors.
27055//
27056// Permission is hereby granted, free of charge, to any person obtaining a
27057// copy of this software and associated documentation files (the
27058// "Software"), to deal in the Software without restriction, including
27059// without limitation the rights to use, copy, modify, merge, publish,
27060// distribute, sublicense, and/or sell copies of the Software, and to permit
27061// persons to whom the Software is furnished to do so, subject to the
27062// following conditions:
27063//
27064// The above copyright notice and this permission notice shall be included
27065// in all copies or substantial portions of the Software.
27066//
27067// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
27068// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27069// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
27070// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
27071// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
27072// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
27073// USE OR OTHER DEALINGS IN THE SOFTWARE.
27074
27075// A bit simpler than readable streams.
27076// Implement an async ._write(chunk, encoding, cb), and it'll handle all
27077// the drain event emission and buffering.
27078
27079'use strict';
27080
27081/*<replacement>*/
27082
27083var pna = require('process-nextick-args');
27084/*</replacement>*/
27085
27086module.exports = Writable;
27087
27088/* <replacement> */
27089function WriteReq(chunk, encoding, cb) {
27090 this.chunk = chunk;
27091 this.encoding = encoding;
27092 this.callback = cb;
27093 this.next = null;
27094}
27095
27096// It seems a linked list but it is not
27097// there will be only 2 of these for each stream
27098function CorkedRequest(state) {
27099 var _this = this;
27100
27101 this.next = null;
27102 this.entry = null;
27103 this.finish = function () {
27104 onCorkedFinish(_this, state);
27105 };
27106}
27107/* </replacement> */
27108
27109/*<replacement>*/
27110var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
27111/*</replacement>*/
27112
27113/*<replacement>*/
27114var Duplex;
27115/*</replacement>*/
27116
27117Writable.WritableState = WritableState;
27118
27119/*<replacement>*/
27120var util = require('core-util-is');
27121util.inherits = require('inherits');
27122/*</replacement>*/
27123
27124/*<replacement>*/
27125var internalUtil = {
27126 deprecate: require('util-deprecate')
27127};
27128/*</replacement>*/
27129
27130/*<replacement>*/
27131var Stream = require('./internal/streams/stream');
27132/*</replacement>*/
27133
27134/*<replacement>*/
27135
27136var Buffer = require('safe-buffer').Buffer;
27137var OurUint8Array = global.Uint8Array || function () {};
27138function _uint8ArrayToBuffer(chunk) {
27139 return Buffer.from(chunk);
27140}
27141function _isUint8Array(obj) {
27142 return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
27143}
27144
27145/*</replacement>*/
27146
27147var destroyImpl = require('./internal/streams/destroy');
27148
27149util.inherits(Writable, Stream);
27150
27151function nop() {}
27152
27153function WritableState(options, stream) {
27154 Duplex = Duplex || require('./_stream_duplex');
27155
27156 options = options || {};
27157
27158 // Duplex streams are both readable and writable, but share
27159 // the same options object.
27160 // However, some cases require setting options to different
27161 // values for the readable and the writable sides of the duplex stream.
27162 // These options can be provided separately as readableXXX and writableXXX.
27163 var isDuplex = stream instanceof Duplex;
27164
27165 // object stream flag to indicate whether or not this stream
27166 // contains buffers or objects.
27167 this.objectMode = !!options.objectMode;
27168
27169 if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
27170
27171 // the point at which write() starts returning false
27172 // Note: 0 is a valid value, means that we always return false if
27173 // the entire buffer is not flushed immediately on write()
27174 var hwm = options.highWaterMark;
27175 var writableHwm = options.writableHighWaterMark;
27176 var defaultHwm = this.objectMode ? 16 : 16 * 1024;
27177
27178 if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;
27179
27180 // cast to ints.
27181 this.highWaterMark = Math.floor(this.highWaterMark);
27182
27183 // if _final has been called
27184 this.finalCalled = false;
27185
27186 // drain event flag.
27187 this.needDrain = false;
27188 // at the start of calling end()
27189 this.ending = false;
27190 // when end() has been called, and returned
27191 this.ended = false;
27192 // when 'finish' is emitted
27193 this.finished = false;
27194
27195 // has it been destroyed
27196 this.destroyed = false;
27197
27198 // should we decode strings into buffers before passing to _write?
27199 // this is here so that some node-core streams can optimize string
27200 // handling at a lower level.
27201 var noDecode = options.decodeStrings === false;
27202 this.decodeStrings = !noDecode;
27203
27204 // Crypto is kind of old and crusty. Historically, its default string
27205 // encoding is 'binary' so we have to make this configurable.
27206 // Everything else in the universe uses 'utf8', though.
27207 this.defaultEncoding = options.defaultEncoding || 'utf8';
27208
27209 // not an actual buffer we keep track of, but a measurement
27210 // of how much we're waiting to get pushed to some underlying
27211 // socket or file.
27212 this.length = 0;
27213
27214 // a flag to see when we're in the middle of a write.
27215 this.writing = false;
27216
27217 // when true all writes will be buffered until .uncork() call
27218 this.corked = 0;
27219
27220 // a flag to be able to tell if the onwrite cb is called immediately,
27221 // or on a later tick. We set this to true at first, because any
27222 // actions that shouldn't happen until "later" should generally also
27223 // not happen before the first write call.
27224 this.sync = true;
27225
27226 // a flag to know if we're processing previously buffered items, which
27227 // may call the _write() callback in the same tick, so that we don't
27228 // end up in an overlapped onwrite situation.
27229 this.bufferProcessing = false;
27230
27231 // the callback that's passed to _write(chunk,cb)
27232 this.onwrite = function (er) {
27233 onwrite(stream, er);
27234 };
27235
27236 // the callback that the user supplies to write(chunk,encoding,cb)
27237 this.writecb = null;
27238
27239 // the amount that is being written when _write is called.
27240 this.writelen = 0;
27241
27242 this.bufferedRequest = null;
27243 this.lastBufferedRequest = null;
27244
27245 // number of pending user-supplied write callbacks
27246 // this must be 0 before 'finish' can be emitted
27247 this.pendingcb = 0;
27248
27249 // emit prefinish if the only thing we're waiting for is _write cbs
27250 // This is relevant for synchronous Transform streams
27251 this.prefinished = false;
27252
27253 // True if the error was already emitted and should not be thrown again
27254 this.errorEmitted = false;
27255
27256 // count buffered requests
27257 this.bufferedRequestCount = 0;
27258
27259 // allocate the first CorkedRequest, there is always
27260 // one allocated and free to use, and we maintain at most two
27261 this.corkedRequestsFree = new CorkedRequest(this);
27262}
27263
27264WritableState.prototype.getBuffer = function getBuffer() {
27265 var current = this.bufferedRequest;
27266 var out = [];
27267 while (current) {
27268 out.push(current);
27269 current = current.next;
27270 }
27271 return out;
27272};
27273
27274(function () {
27275 try {
27276 Object.defineProperty(WritableState.prototype, 'buffer', {
27277 get: internalUtil.deprecate(function () {
27278 return this.getBuffer();
27279 }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
27280 });
27281 } catch (_) {}
27282})();
27283
27284// Test _writableState for inheritance to account for Duplex streams,
27285// whose prototype chain only points to Readable.
27286var realHasInstance;
27287if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
27288 realHasInstance = Function.prototype[Symbol.hasInstance];
27289 Object.defineProperty(Writable, Symbol.hasInstance, {
27290 value: function (object) {
27291 if (realHasInstance.call(this, object)) return true;
27292 if (this !== Writable) return false;
27293
27294 return object && object._writableState instanceof WritableState;
27295 }
27296 });
27297} else {
27298 realHasInstance = function (object) {
27299 return object instanceof this;
27300 };
27301}
27302
27303function Writable(options) {
27304 Duplex = Duplex || require('./_stream_duplex');
27305
27306 // Writable ctor is applied to Duplexes, too.
27307 // `realHasInstance` is necessary because using plain `instanceof`
27308 // would return false, as no `_writableState` property is attached.
27309
27310 // Trying to use the custom `instanceof` for Writable here will also break the
27311 // Node.js LazyTransform implementation, which has a non-trivial getter for
27312 // `_writableState` that would lead to infinite recursion.
27313 if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
27314 return new Writable(options);
27315 }
27316
27317 this._writableState = new WritableState(options, this);
27318
27319 // legacy.
27320 this.writable = true;
27321
27322 if (options) {
27323 if (typeof options.write === 'function') this._write = options.write;
27324
27325 if (typeof options.writev === 'function') this._writev = options.writev;
27326
27327 if (typeof options.destroy === 'function') this._destroy = options.destroy;
27328
27329 if (typeof options.final === 'function') this._final = options.final;
27330 }
27331
27332 Stream.call(this);
27333}
27334
27335// Otherwise people can pipe Writable streams, which is just wrong.
27336Writable.prototype.pipe = function () {
27337 this.emit('error', new Error('Cannot pipe, not readable'));
27338};
27339
27340function writeAfterEnd(stream, cb) {
27341 var er = new Error('write after end');
27342 // TODO: defer error events consistently everywhere, not just the cb
27343 stream.emit('error', er);
27344 pna.nextTick(cb, er);
27345}
27346
27347// Checks that a user-supplied chunk is valid, especially for the particular
27348// mode the stream is in. Currently this means that `null` is never accepted
27349// and undefined/non-string values are only allowed in object mode.
27350function validChunk(stream, state, chunk, cb) {
27351 var valid = true;
27352 var er = false;
27353
27354 if (chunk === null) {
27355 er = new TypeError('May not write null values to stream');
27356 } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
27357 er = new TypeError('Invalid non-string/buffer chunk');
27358 }
27359 if (er) {
27360 stream.emit('error', er);
27361 pna.nextTick(cb, er);
27362 valid = false;
27363 }
27364 return valid;
27365}
27366
27367Writable.prototype.write = function (chunk, encoding, cb) {
27368 var state = this._writableState;
27369 var ret = false;
27370 var isBuf = !state.objectMode && _isUint8Array(chunk);
27371
27372 if (isBuf && !Buffer.isBuffer(chunk)) {
27373 chunk = _uint8ArrayToBuffer(chunk);
27374 }
27375
27376 if (typeof encoding === 'function') {
27377 cb = encoding;
27378 encoding = null;
27379 }
27380
27381 if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
27382
27383 if (typeof cb !== 'function') cb = nop;
27384
27385 if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
27386 state.pendingcb++;
27387 ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
27388 }
27389
27390 return ret;
27391};
27392
27393Writable.prototype.cork = function () {
27394 var state = this._writableState;
27395
27396 state.corked++;
27397};
27398
27399Writable.prototype.uncork = function () {
27400 var state = this._writableState;
27401
27402 if (state.corked) {
27403 state.corked--;
27404
27405 if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
27406 }
27407};
27408
27409Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
27410 // node::ParseEncoding() requires lower case.
27411 if (typeof encoding === 'string') encoding = encoding.toLowerCase();
27412 if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
27413 this._writableState.defaultEncoding = encoding;
27414 return this;
27415};
27416
27417function decodeChunk(state, chunk, encoding) {
27418 if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
27419 chunk = Buffer.from(chunk, encoding);
27420 }
27421 return chunk;
27422}
27423
27424Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
27425 // making it explicit this property is not enumerable
27426 // because otherwise some prototype manipulation in
27427 // userland will fail
27428 enumerable: false,
27429 get: function () {
27430 return this._writableState.highWaterMark;
27431 }
27432});
27433
27434// if we're already writing something, then just put this
27435// in the queue, and wait our turn. Otherwise, call _write
27436// If we return false, then we need a drain event, so set that flag.
27437function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
27438 if (!isBuf) {
27439 var newChunk = decodeChunk(state, chunk, encoding);
27440 if (chunk !== newChunk) {
27441 isBuf = true;
27442 encoding = 'buffer';
27443 chunk = newChunk;
27444 }
27445 }
27446 var len = state.objectMode ? 1 : chunk.length;
27447
27448 state.length += len;
27449
27450 var ret = state.length < state.highWaterMark;
27451 // we must ensure that previous needDrain will not be reset to false.
27452 if (!ret) state.needDrain = true;
27453
27454 if (state.writing || state.corked) {
27455 var last = state.lastBufferedRequest;
27456 state.lastBufferedRequest = {
27457 chunk: chunk,
27458 encoding: encoding,
27459 isBuf: isBuf,
27460 callback: cb,
27461 next: null
27462 };
27463 if (last) {
27464 last.next = state.lastBufferedRequest;
27465 } else {
27466 state.bufferedRequest = state.lastBufferedRequest;
27467 }
27468 state.bufferedRequestCount += 1;
27469 } else {
27470 doWrite(stream, state, false, len, chunk, encoding, cb);
27471 }
27472
27473 return ret;
27474}
27475
27476function doWrite(stream, state, writev, len, chunk, encoding, cb) {
27477 state.writelen = len;
27478 state.writecb = cb;
27479 state.writing = true;
27480 state.sync = true;
27481 if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
27482 state.sync = false;
27483}
27484
27485function onwriteError(stream, state, sync, er, cb) {
27486 --state.pendingcb;
27487
27488 if (sync) {
27489 // defer the callback if we are being called synchronously
27490 // to avoid piling up things on the stack
27491 pna.nextTick(cb, er);
27492 // this can emit finish, and it will always happen
27493 // after error
27494 pna.nextTick(finishMaybe, stream, state);
27495 stream._writableState.errorEmitted = true;
27496 stream.emit('error', er);
27497 } else {
27498 // the caller expect this to happen before if
27499 // it is async
27500 cb(er);
27501 stream._writableState.errorEmitted = true;
27502 stream.emit('error', er);
27503 // this can emit finish, but finish must
27504 // always follow error
27505 finishMaybe(stream, state);
27506 }
27507}
27508
27509function onwriteStateUpdate(state) {
27510 state.writing = false;
27511 state.writecb = null;
27512 state.length -= state.writelen;
27513 state.writelen = 0;
27514}
27515
27516function onwrite(stream, er) {
27517 var state = stream._writableState;
27518 var sync = state.sync;
27519 var cb = state.writecb;
27520
27521 onwriteStateUpdate(state);
27522
27523 if (er) onwriteError(stream, state, sync, er, cb);else {
27524 // Check if we're actually ready to finish, but don't emit yet
27525 var finished = needFinish(state);
27526
27527 if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
27528 clearBuffer(stream, state);
27529 }
27530
27531 if (sync) {
27532 /*<replacement>*/
27533 asyncWrite(afterWrite, stream, state, finished, cb);
27534 /*</replacement>*/
27535 } else {
27536 afterWrite(stream, state, finished, cb);
27537 }
27538 }
27539}
27540
27541function afterWrite(stream, state, finished, cb) {
27542 if (!finished) onwriteDrain(stream, state);
27543 state.pendingcb--;
27544 cb();
27545 finishMaybe(stream, state);
27546}
27547
27548// Must force callback to be called on nextTick, so that we don't
27549// emit 'drain' before the write() consumer gets the 'false' return
27550// value, and has a chance to attach a 'drain' listener.
27551function onwriteDrain(stream, state) {
27552 if (state.length === 0 && state.needDrain) {
27553 state.needDrain = false;
27554 stream.emit('drain');
27555 }
27556}
27557
27558// if there's something in the buffer waiting, then process it
27559function clearBuffer(stream, state) {
27560 state.bufferProcessing = true;
27561 var entry = state.bufferedRequest;
27562
27563 if (stream._writev && entry && entry.next) {
27564 // Fast case, write everything using _writev()
27565 var l = state.bufferedRequestCount;
27566 var buffer = new Array(l);
27567 var holder = state.corkedRequestsFree;
27568 holder.entry = entry;
27569
27570 var count = 0;
27571 var allBuffers = true;
27572 while (entry) {
27573 buffer[count] = entry;
27574 if (!entry.isBuf) allBuffers = false;
27575 entry = entry.next;
27576 count += 1;
27577 }
27578 buffer.allBuffers = allBuffers;
27579
27580 doWrite(stream, state, true, state.length, buffer, '', holder.finish);
27581
27582 // doWrite is almost always async, defer these to save a bit of time
27583 // as the hot path ends with doWrite
27584 state.pendingcb++;
27585 state.lastBufferedRequest = null;
27586 if (holder.next) {
27587 state.corkedRequestsFree = holder.next;
27588 holder.next = null;
27589 } else {
27590 state.corkedRequestsFree = new CorkedRequest(state);
27591 }
27592 state.bufferedRequestCount = 0;
27593 } else {
27594 // Slow case, write chunks one-by-one
27595 while (entry) {
27596 var chunk = entry.chunk;
27597 var encoding = entry.encoding;
27598 var cb = entry.callback;
27599 var len = state.objectMode ? 1 : chunk.length;
27600
27601 doWrite(stream, state, false, len, chunk, encoding, cb);
27602 entry = entry.next;
27603 state.bufferedRequestCount--;
27604 // if we didn't call the onwrite immediately, then
27605 // it means that we need to wait until it does.
27606 // also, that means that the chunk and cb are currently
27607 // being processed, so move the buffer counter past them.
27608 if (state.writing) {
27609 break;
27610 }
27611 }
27612
27613 if (entry === null) state.lastBufferedRequest = null;
27614 }
27615
27616 state.bufferedRequest = entry;
27617 state.bufferProcessing = false;
27618}
27619
27620Writable.prototype._write = function (chunk, encoding, cb) {
27621 cb(new Error('_write() is not implemented'));
27622};
27623
27624Writable.prototype._writev = null;
27625
27626Writable.prototype.end = function (chunk, encoding, cb) {
27627 var state = this._writableState;
27628
27629 if (typeof chunk === 'function') {
27630 cb = chunk;
27631 chunk = null;
27632 encoding = null;
27633 } else if (typeof encoding === 'function') {
27634 cb = encoding;
27635 encoding = null;
27636 }
27637
27638 if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
27639
27640 // .end() fully uncorks
27641 if (state.corked) {
27642 state.corked = 1;
27643 this.uncork();
27644 }
27645
27646 // ignore unnecessary end() calls.
27647 if (!state.ending && !state.finished) endWritable(this, state, cb);
27648};
27649
27650function needFinish(state) {
27651 return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
27652}
27653function callFinal(stream, state) {
27654 stream._final(function (err) {
27655 state.pendingcb--;
27656 if (err) {
27657 stream.emit('error', err);
27658 }
27659 state.prefinished = true;
27660 stream.emit('prefinish');
27661 finishMaybe(stream, state);
27662 });
27663}
27664function prefinish(stream, state) {
27665 if (!state.prefinished && !state.finalCalled) {
27666 if (typeof stream._final === 'function') {
27667 state.pendingcb++;
27668 state.finalCalled = true;
27669 pna.nextTick(callFinal, stream, state);
27670 } else {
27671 state.prefinished = true;
27672 stream.emit('prefinish');
27673 }
27674 }
27675}
27676
27677function finishMaybe(stream, state) {
27678 var need = needFinish(state);
27679 if (need) {
27680 prefinish(stream, state);
27681 if (state.pendingcb === 0) {
27682 state.finished = true;
27683 stream.emit('finish');
27684 }
27685 }
27686 return need;
27687}
27688
27689function endWritable(stream, state, cb) {
27690 state.ending = true;
27691 finishMaybe(stream, state);
27692 if (cb) {
27693 if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
27694 }
27695 state.ended = true;
27696 stream.writable = false;
27697}
27698
27699function onCorkedFinish(corkReq, state, err) {
27700 var entry = corkReq.entry;
27701 corkReq.entry = null;
27702 while (entry) {
27703 var cb = entry.callback;
27704 state.pendingcb--;
27705 cb(err);
27706 entry = entry.next;
27707 }
27708 if (state.corkedRequestsFree) {
27709 state.corkedRequestsFree.next = corkReq;
27710 } else {
27711 state.corkedRequestsFree = corkReq;
27712 }
27713}
27714
27715Object.defineProperty(Writable.prototype, 'destroyed', {
27716 get: function () {
27717 if (this._writableState === undefined) {
27718 return false;
27719 }
27720 return this._writableState.destroyed;
27721 },
27722 set: function (value) {
27723 // we ignore the value if the stream
27724 // has not been initialized yet
27725 if (!this._writableState) {
27726 return;
27727 }
27728
27729 // backward compatibility, the user is explicitly
27730 // managing destroyed
27731 this._writableState.destroyed = value;
27732 }
27733});
27734
27735Writable.prototype.destroy = destroyImpl.destroy;
27736Writable.prototype._undestroy = destroyImpl.undestroy;
27737Writable.prototype._destroy = function (err, cb) {
27738 this.end();
27739 cb(err);
27740};
27741}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").setImmediate)
27742},{"./_stream_duplex":191,"./internal/streams/destroy":197,"./internal/streams/stream":198,"_process":181,"core-util-is":112,"inherits":162,"process-nextick-args":180,"safe-buffer":199,"timers":217,"util-deprecate":218}],196:[function(require,module,exports){
27743'use strict';
27744
27745function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
27746
27747var Buffer = require('safe-buffer').Buffer;
27748var util = require('util');
27749
27750function copyBuffer(src, target, offset) {
27751 src.copy(target, offset);
27752}
27753
27754module.exports = function () {
27755 function BufferList() {
27756 _classCallCheck(this, BufferList);
27757
27758 this.head = null;
27759 this.tail = null;
27760 this.length = 0;
27761 }
27762
27763 BufferList.prototype.push = function push(v) {
27764 var entry = { data: v, next: null };
27765 if (this.length > 0) this.tail.next = entry;else this.head = entry;
27766 this.tail = entry;
27767 ++this.length;
27768 };
27769
27770 BufferList.prototype.unshift = function unshift(v) {
27771 var entry = { data: v, next: this.head };
27772 if (this.length === 0) this.tail = entry;
27773 this.head = entry;
27774 ++this.length;
27775 };
27776
27777 BufferList.prototype.shift = function shift() {
27778 if (this.length === 0) return;
27779 var ret = this.head.data;
27780 if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
27781 --this.length;
27782 return ret;
27783 };
27784
27785 BufferList.prototype.clear = function clear() {
27786 this.head = this.tail = null;
27787 this.length = 0;
27788 };
27789
27790 BufferList.prototype.join = function join(s) {
27791 if (this.length === 0) return '';
27792 var p = this.head;
27793 var ret = '' + p.data;
27794 while (p = p.next) {
27795 ret += s + p.data;
27796 }return ret;
27797 };
27798
27799 BufferList.prototype.concat = function concat(n) {
27800 if (this.length === 0) return Buffer.alloc(0);
27801 if (this.length === 1) return this.head.data;
27802 var ret = Buffer.allocUnsafe(n >>> 0);
27803 var p = this.head;
27804 var i = 0;
27805 while (p) {
27806 copyBuffer(p.data, ret, i);
27807 i += p.data.length;
27808 p = p.next;
27809 }
27810 return ret;
27811 };
27812
27813 return BufferList;
27814}();
27815
27816if (util && util.inspect && util.inspect.custom) {
27817 module.exports.prototype[util.inspect.custom] = function () {
27818 var obj = util.inspect({ length: this.length });
27819 return this.constructor.name + ' ' + obj;
27820 };
27821}
27822},{"safe-buffer":199,"util":81}],197:[function(require,module,exports){
27823'use strict';
27824
27825/*<replacement>*/
27826
27827var pna = require('process-nextick-args');
27828/*</replacement>*/
27829
27830// undocumented cb() API, needed for core, not for public API
27831function destroy(err, cb) {
27832 var _this = this;
27833
27834 var readableDestroyed = this._readableState && this._readableState.destroyed;
27835 var writableDestroyed = this._writableState && this._writableState.destroyed;
27836
27837 if (readableDestroyed || writableDestroyed) {
27838 if (cb) {
27839 cb(err);
27840 } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
27841 pna.nextTick(emitErrorNT, this, err);
27842 }
27843 return this;
27844 }
27845
27846 // we set destroyed to true before firing error callbacks in order
27847 // to make it re-entrance safe in case destroy() is called within callbacks
27848
27849 if (this._readableState) {
27850 this._readableState.destroyed = true;
27851 }
27852
27853 // if this is a duplex stream mark the writable part as destroyed as well
27854 if (this._writableState) {
27855 this._writableState.destroyed = true;
27856 }
27857
27858 this._destroy(err || null, function (err) {
27859 if (!cb && err) {
27860 pna.nextTick(emitErrorNT, _this, err);
27861 if (_this._writableState) {
27862 _this._writableState.errorEmitted = true;
27863 }
27864 } else if (cb) {
27865 cb(err);
27866 }
27867 });
27868
27869 return this;
27870}
27871
27872function undestroy() {
27873 if (this._readableState) {
27874 this._readableState.destroyed = false;
27875 this._readableState.reading = false;
27876 this._readableState.ended = false;
27877 this._readableState.endEmitted = false;
27878 }
27879
27880 if (this._writableState) {
27881 this._writableState.destroyed = false;
27882 this._writableState.ended = false;
27883 this._writableState.ending = false;
27884 this._writableState.finished = false;
27885 this._writableState.errorEmitted = false;
27886 }
27887}
27888
27889function emitErrorNT(self, err) {
27890 self.emit('error', err);
27891}
27892
27893module.exports = {
27894 destroy: destroy,
27895 undestroy: undestroy
27896};
27897},{"process-nextick-args":180}],198:[function(require,module,exports){
27898module.exports = require('events').EventEmitter;
27899
27900},{"events":145}],199:[function(require,module,exports){
27901/* eslint-disable node/no-deprecated-api */
27902var buffer = require('buffer')
27903var Buffer = buffer.Buffer
27904
27905// alternative to using Object.keys for old browsers
27906function copyProps (src, dst) {
27907 for (var key in src) {
27908 dst[key] = src[key]
27909 }
27910}
27911if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
27912 module.exports = buffer
27913} else {
27914 // Copy properties from require('buffer')
27915 copyProps(buffer, exports)
27916 exports.Buffer = SafeBuffer
27917}
27918
27919function SafeBuffer (arg, encodingOrOffset, length) {
27920 return Buffer(arg, encodingOrOffset, length)
27921}
27922
27923// Copy static methods from Buffer
27924copyProps(Buffer, SafeBuffer)
27925
27926SafeBuffer.from = function (arg, encodingOrOffset, length) {
27927 if (typeof arg === 'number') {
27928 throw new TypeError('Argument must not be a number')
27929 }
27930 return Buffer(arg, encodingOrOffset, length)
27931}
27932
27933SafeBuffer.alloc = function (size, fill, encoding) {
27934 if (typeof size !== 'number') {
27935 throw new TypeError('Argument must be a number')
27936 }
27937 var buf = Buffer(size)
27938 if (fill !== undefined) {
27939 if (typeof encoding === 'string') {
27940 buf.fill(fill, encoding)
27941 } else {
27942 buf.fill(fill)
27943 }
27944 } else {
27945 buf.fill(0)
27946 }
27947 return buf
27948}
27949
27950SafeBuffer.allocUnsafe = function (size) {
27951 if (typeof size !== 'number') {
27952 throw new TypeError('Argument must be a number')
27953 }
27954 return Buffer(size)
27955}
27956
27957SafeBuffer.allocUnsafeSlow = function (size) {
27958 if (typeof size !== 'number') {
27959 throw new TypeError('Argument must be a number')
27960 }
27961 return buffer.SlowBuffer(size)
27962}
27963
27964},{"buffer":110}],200:[function(require,module,exports){
27965// Copyright Joyent, Inc. and other Node contributors.
27966//
27967// Permission is hereby granted, free of charge, to any person obtaining a
27968// copy of this software and associated documentation files (the
27969// "Software"), to deal in the Software without restriction, including
27970// without limitation the rights to use, copy, modify, merge, publish,
27971// distribute, sublicense, and/or sell copies of the Software, and to permit
27972// persons to whom the Software is furnished to do so, subject to the
27973// following conditions:
27974//
27975// The above copyright notice and this permission notice shall be included
27976// in all copies or substantial portions of the Software.
27977//
27978// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
27979// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27980// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
27981// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
27982// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
27983// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
27984// USE OR OTHER DEALINGS IN THE SOFTWARE.
27985
27986'use strict';
27987
27988/*<replacement>*/
27989
27990var Buffer = require('safe-buffer').Buffer;
27991/*</replacement>*/
27992
27993var isEncoding = Buffer.isEncoding || function (encoding) {
27994 encoding = '' + encoding;
27995 switch (encoding && encoding.toLowerCase()) {
27996 case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':
27997 return true;
27998 default:
27999 return false;
28000 }
28001};
28002
28003function _normalizeEncoding(enc) {
28004 if (!enc) return 'utf8';
28005 var retried;
28006 while (true) {
28007 switch (enc) {
28008 case 'utf8':
28009 case 'utf-8':
28010 return 'utf8';
28011 case 'ucs2':
28012 case 'ucs-2':
28013 case 'utf16le':
28014 case 'utf-16le':
28015 return 'utf16le';
28016 case 'latin1':
28017 case 'binary':
28018 return 'latin1';
28019 case 'base64':
28020 case 'ascii':
28021 case 'hex':
28022 return enc;
28023 default:
28024 if (retried) return; // undefined
28025 enc = ('' + enc).toLowerCase();
28026 retried = true;
28027 }
28028 }
28029};
28030
28031// Do not cache `Buffer.isEncoding` when checking encoding names as some
28032// modules monkey-patch it to support additional encodings
28033function normalizeEncoding(enc) {
28034 var nenc = _normalizeEncoding(enc);
28035 if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
28036 return nenc || enc;
28037}
28038
28039// StringDecoder provides an interface for efficiently splitting a series of
28040// buffers into a series of JS strings without breaking apart multi-byte
28041// characters.
28042exports.StringDecoder = StringDecoder;
28043function StringDecoder(encoding) {
28044 this.encoding = normalizeEncoding(encoding);
28045 var nb;
28046 switch (this.encoding) {
28047 case 'utf16le':
28048 this.text = utf16Text;
28049 this.end = utf16End;
28050 nb = 4;
28051 break;
28052 case 'utf8':
28053 this.fillLast = utf8FillLast;
28054 nb = 4;
28055 break;
28056 case 'base64':
28057 this.text = base64Text;
28058 this.end = base64End;
28059 nb = 3;
28060 break;
28061 default:
28062 this.write = simpleWrite;
28063 this.end = simpleEnd;
28064 return;
28065 }
28066 this.lastNeed = 0;
28067 this.lastTotal = 0;
28068 this.lastChar = Buffer.allocUnsafe(nb);
28069}
28070
28071StringDecoder.prototype.write = function (buf) {
28072 if (buf.length === 0) return '';
28073 var r;
28074 var i;
28075 if (this.lastNeed) {
28076 r = this.fillLast(buf);
28077 if (r === undefined) return '';
28078 i = this.lastNeed;
28079 this.lastNeed = 0;
28080 } else {
28081 i = 0;
28082 }
28083 if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
28084 return r || '';
28085};
28086
28087StringDecoder.prototype.end = utf8End;
28088
28089// Returns only complete characters in a Buffer
28090StringDecoder.prototype.text = utf8Text;
28091
28092// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
28093StringDecoder.prototype.fillLast = function (buf) {
28094 if (this.lastNeed <= buf.length) {
28095 buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
28096 return this.lastChar.toString(this.encoding, 0, this.lastTotal);
28097 }
28098 buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
28099 this.lastNeed -= buf.length;
28100};
28101
28102// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
28103// continuation byte. If an invalid byte is detected, -2 is returned.
28104function utf8CheckByte(byte) {
28105 if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
28106 return byte >> 6 === 0x02 ? -1 : -2;
28107}
28108
28109// Checks at most 3 bytes at the end of a Buffer in order to detect an
28110// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
28111// needed to complete the UTF-8 character (if applicable) are returned.
28112function utf8CheckIncomplete(self, buf, i) {
28113 var j = buf.length - 1;
28114 if (j < i) return 0;
28115 var nb = utf8CheckByte(buf[j]);
28116 if (nb >= 0) {
28117 if (nb > 0) self.lastNeed = nb - 1;
28118 return nb;
28119 }
28120 if (--j < i || nb === -2) return 0;
28121 nb = utf8CheckByte(buf[j]);
28122 if (nb >= 0) {
28123 if (nb > 0) self.lastNeed = nb - 2;
28124 return nb;
28125 }
28126 if (--j < i || nb === -2) return 0;
28127 nb = utf8CheckByte(buf[j]);
28128 if (nb >= 0) {
28129 if (nb > 0) {
28130 if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
28131 }
28132 return nb;
28133 }
28134 return 0;
28135}
28136
28137// Validates as many continuation bytes for a multi-byte UTF-8 character as
28138// needed or are available. If we see a non-continuation byte where we expect
28139// one, we "replace" the validated continuation bytes we've seen so far with
28140// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
28141// behavior. The continuation byte check is included three times in the case
28142// where all of the continuation bytes for a character exist in the same buffer.
28143// It is also done this way as a slight performance increase instead of using a
28144// loop.
28145function utf8CheckExtraBytes(self, buf, p) {
28146 if ((buf[0] & 0xC0) !== 0x80) {
28147 self.lastNeed = 0;
28148 return '\ufffd';
28149 }
28150 if (self.lastNeed > 1 && buf.length > 1) {
28151 if ((buf[1] & 0xC0) !== 0x80) {
28152 self.lastNeed = 1;
28153 return '\ufffd';
28154 }
28155 if (self.lastNeed > 2 && buf.length > 2) {
28156 if ((buf[2] & 0xC0) !== 0x80) {
28157 self.lastNeed = 2;
28158 return '\ufffd';
28159 }
28160 }
28161 }
28162}
28163
28164// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
28165function utf8FillLast(buf) {
28166 var p = this.lastTotal - this.lastNeed;
28167 var r = utf8CheckExtraBytes(this, buf, p);
28168 if (r !== undefined) return r;
28169 if (this.lastNeed <= buf.length) {
28170 buf.copy(this.lastChar, p, 0, this.lastNeed);
28171 return this.lastChar.toString(this.encoding, 0, this.lastTotal);
28172 }
28173 buf.copy(this.lastChar, p, 0, buf.length);
28174 this.lastNeed -= buf.length;
28175}
28176
28177// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
28178// partial character, the character's bytes are buffered until the required
28179// number of bytes are available.
28180function utf8Text(buf, i) {
28181 var total = utf8CheckIncomplete(this, buf, i);
28182 if (!this.lastNeed) return buf.toString('utf8', i);
28183 this.lastTotal = total;
28184 var end = buf.length - (total - this.lastNeed);
28185 buf.copy(this.lastChar, 0, end);
28186 return buf.toString('utf8', i, end);
28187}
28188
28189// For UTF-8, a replacement character is added when ending on a partial
28190// character.
28191function utf8End(buf) {
28192 var r = buf && buf.length ? this.write(buf) : '';
28193 if (this.lastNeed) return r + '\ufffd';
28194 return r;
28195}
28196
28197// UTF-16LE typically needs two bytes per character, but even if we have an even
28198// number of bytes available, we need to check if we end on a leading/high
28199// surrogate. In that case, we need to wait for the next two bytes in order to
28200// decode the last character properly.
28201function utf16Text(buf, i) {
28202 if ((buf.length - i) % 2 === 0) {
28203 var r = buf.toString('utf16le', i);
28204 if (r) {
28205 var c = r.charCodeAt(r.length - 1);
28206 if (c >= 0xD800 && c <= 0xDBFF) {
28207 this.lastNeed = 2;
28208 this.lastTotal = 4;
28209 this.lastChar[0] = buf[buf.length - 2];
28210 this.lastChar[1] = buf[buf.length - 1];
28211 return r.slice(0, -1);
28212 }
28213 }
28214 return r;
28215 }
28216 this.lastNeed = 1;
28217 this.lastTotal = 2;
28218 this.lastChar[0] = buf[buf.length - 1];
28219 return buf.toString('utf16le', i, buf.length - 1);
28220}
28221
28222// For UTF-16LE we do not explicitly append special replacement characters if we
28223// end on a partial character, we simply let v8 handle that.
28224function utf16End(buf) {
28225 var r = buf && buf.length ? this.write(buf) : '';
28226 if (this.lastNeed) {
28227 var end = this.lastTotal - this.lastNeed;
28228 return r + this.lastChar.toString('utf16le', 0, end);
28229 }
28230 return r;
28231}
28232
28233function base64Text(buf, i) {
28234 var n = (buf.length - i) % 3;
28235 if (n === 0) return buf.toString('base64', i);
28236 this.lastNeed = 3 - n;
28237 this.lastTotal = 3;
28238 if (n === 1) {
28239 this.lastChar[0] = buf[buf.length - 1];
28240 } else {
28241 this.lastChar[0] = buf[buf.length - 2];
28242 this.lastChar[1] = buf[buf.length - 1];
28243 }
28244 return buf.toString('base64', i, buf.length - n);
28245}
28246
28247function base64End(buf) {
28248 var r = buf && buf.length ? this.write(buf) : '';
28249 if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
28250 return r;
28251}
28252
28253// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
28254function simpleWrite(buf) {
28255 return buf.toString(this.encoding);
28256}
28257
28258function simpleEnd(buf) {
28259 return buf && buf.length ? this.write(buf) : '';
28260}
28261},{"safe-buffer":199}],201:[function(require,module,exports){
28262module.exports = require('./readable').PassThrough
28263
28264},{"./readable":202}],202:[function(require,module,exports){
28265exports = module.exports = require('./lib/_stream_readable.js');
28266exports.Stream = exports;
28267exports.Readable = exports;
28268exports.Writable = require('./lib/_stream_writable.js');
28269exports.Duplex = require('./lib/_stream_duplex.js');
28270exports.Transform = require('./lib/_stream_transform.js');
28271exports.PassThrough = require('./lib/_stream_passthrough.js');
28272
28273},{"./lib/_stream_duplex.js":191,"./lib/_stream_passthrough.js":192,"./lib/_stream_readable.js":193,"./lib/_stream_transform.js":194,"./lib/_stream_writable.js":195}],203:[function(require,module,exports){
28274module.exports = require('./readable').Transform
28275
28276},{"./readable":202}],204:[function(require,module,exports){
28277module.exports = require('./lib/_stream_writable.js');
28278
28279},{"./lib/_stream_writable.js":195}],205:[function(require,module,exports){
28280arguments[4][46][0].apply(exports,arguments)
28281},{"buffer":110,"dup":46,"hash-base":147,"inherits":162}],206:[function(require,module,exports){
28282arguments[4][47][0].apply(exports,arguments)
28283},{"buffer":110,"dup":47}],207:[function(require,module,exports){
28284arguments[4][52][0].apply(exports,arguments)
28285},{"dup":52,"safe-buffer":206}],208:[function(require,module,exports){
28286arguments[4][53][0].apply(exports,arguments)
28287},{"./sha":209,"./sha1":210,"./sha224":211,"./sha256":212,"./sha384":213,"./sha512":214,"dup":53}],209:[function(require,module,exports){
28288arguments[4][54][0].apply(exports,arguments)
28289},{"./hash":207,"dup":54,"inherits":162,"safe-buffer":206}],210:[function(require,module,exports){
28290arguments[4][55][0].apply(exports,arguments)
28291},{"./hash":207,"dup":55,"inherits":162,"safe-buffer":206}],211:[function(require,module,exports){
28292arguments[4][56][0].apply(exports,arguments)
28293},{"./hash":207,"./sha256":212,"dup":56,"inherits":162,"safe-buffer":206}],212:[function(require,module,exports){
28294arguments[4][57][0].apply(exports,arguments)
28295},{"./hash":207,"dup":57,"inherits":162,"safe-buffer":206}],213:[function(require,module,exports){
28296arguments[4][58][0].apply(exports,arguments)
28297},{"./hash":207,"./sha512":214,"dup":58,"inherits":162,"safe-buffer":206}],214:[function(require,module,exports){
28298arguments[4][59][0].apply(exports,arguments)
28299},{"./hash":207,"dup":59,"inherits":162,"safe-buffer":206}],215:[function(require,module,exports){
28300// Copyright Joyent, Inc. and other Node contributors.
28301//
28302// Permission is hereby granted, free of charge, to any person obtaining a
28303// copy of this software and associated documentation files (the
28304// "Software"), to deal in the Software without restriction, including
28305// without limitation the rights to use, copy, modify, merge, publish,
28306// distribute, sublicense, and/or sell copies of the Software, and to permit
28307// persons to whom the Software is furnished to do so, subject to the
28308// following conditions:
28309//
28310// The above copyright notice and this permission notice shall be included
28311// in all copies or substantial portions of the Software.
28312//
28313// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
28314// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28315// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
28316// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
28317// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
28318// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
28319// USE OR OTHER DEALINGS IN THE SOFTWARE.
28320
28321module.exports = Stream;
28322
28323var EE = require('events').EventEmitter;
28324var inherits = require('inherits');
28325
28326inherits(Stream, EE);
28327Stream.Readable = require('readable-stream/readable.js');
28328Stream.Writable = require('readable-stream/writable.js');
28329Stream.Duplex = require('readable-stream/duplex.js');
28330Stream.Transform = require('readable-stream/transform.js');
28331Stream.PassThrough = require('readable-stream/passthrough.js');
28332
28333// Backwards-compat with node 0.4.x
28334Stream.Stream = Stream;
28335
28336
28337
28338// old-style streams. Note that the pipe method (the only relevant
28339// part of this class) is overridden in the Readable class.
28340
28341function Stream() {
28342 EE.call(this);
28343}
28344
28345Stream.prototype.pipe = function(dest, options) {
28346 var source = this;
28347
28348 function ondata(chunk) {
28349 if (dest.writable) {
28350 if (false === dest.write(chunk) && source.pause) {
28351 source.pause();
28352 }
28353 }
28354 }
28355
28356 source.on('data', ondata);
28357
28358 function ondrain() {
28359 if (source.readable && source.resume) {
28360 source.resume();
28361 }
28362 }
28363
28364 dest.on('drain', ondrain);
28365
28366 // If the 'end' option is not supplied, dest.end() will be called when
28367 // source gets the 'end' or 'close' events. Only dest.end() once.
28368 if (!dest._isStdio && (!options || options.end !== false)) {
28369 source.on('end', onend);
28370 source.on('close', onclose);
28371 }
28372
28373 var didOnEnd = false;
28374 function onend() {
28375 if (didOnEnd) return;
28376 didOnEnd = true;
28377
28378 dest.end();
28379 }
28380
28381
28382 function onclose() {
28383 if (didOnEnd) return;
28384 didOnEnd = true;
28385
28386 if (typeof dest.destroy === 'function') dest.destroy();
28387 }
28388
28389 // don't leave dangling pipes when there are errors.
28390 function onerror(er) {
28391 cleanup();
28392 if (EE.listenerCount(this, 'error') === 0) {
28393 throw er; // Unhandled stream error in pipe.
28394 }
28395 }
28396
28397 source.on('error', onerror);
28398 dest.on('error', onerror);
28399
28400 // remove all the event listeners that were added.
28401 function cleanup() {
28402 source.removeListener('data', ondata);
28403 dest.removeListener('drain', ondrain);
28404
28405 source.removeListener('end', onend);
28406 source.removeListener('close', onclose);
28407
28408 source.removeListener('error', onerror);
28409 dest.removeListener('error', onerror);
28410
28411 source.removeListener('end', cleanup);
28412 source.removeListener('close', cleanup);
28413
28414 dest.removeListener('close', cleanup);
28415 }
28416
28417 source.on('end', cleanup);
28418 source.on('close', cleanup);
28419
28420 dest.on('close', cleanup);
28421
28422 dest.emit('pipe', source);
28423
28424 // Allow for unix-like usage: A.pipe(B).pipe(C)
28425 return dest;
28426};
28427
28428},{"events":145,"inherits":162,"readable-stream/duplex.js":190,"readable-stream/passthrough.js":201,"readable-stream/readable.js":202,"readable-stream/transform.js":203,"readable-stream/writable.js":204}],216:[function(require,module,exports){
28429arguments[4][200][0].apply(exports,arguments)
28430},{"dup":200,"safe-buffer":206}],217:[function(require,module,exports){
28431(function (setImmediate,clearImmediate){
28432var nextTick = require('process/browser.js').nextTick;
28433var apply = Function.prototype.apply;
28434var slice = Array.prototype.slice;
28435var immediateIds = {};
28436var nextImmediateId = 0;
28437
28438// DOM APIs, for completeness
28439
28440exports.setTimeout = function() {
28441 return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
28442};
28443exports.setInterval = function() {
28444 return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
28445};
28446exports.clearTimeout =
28447exports.clearInterval = function(timeout) { timeout.close(); };
28448
28449function Timeout(id, clearFn) {
28450 this._id = id;
28451 this._clearFn = clearFn;
28452}
28453Timeout.prototype.unref = Timeout.prototype.ref = function() {};
28454Timeout.prototype.close = function() {
28455 this._clearFn.call(window, this._id);
28456};
28457
28458// Does not start the time, just sets up the members needed.
28459exports.enroll = function(item, msecs) {
28460 clearTimeout(item._idleTimeoutId);
28461 item._idleTimeout = msecs;
28462};
28463
28464exports.unenroll = function(item) {
28465 clearTimeout(item._idleTimeoutId);
28466 item._idleTimeout = -1;
28467};
28468
28469exports._unrefActive = exports.active = function(item) {
28470 clearTimeout(item._idleTimeoutId);
28471
28472 var msecs = item._idleTimeout;
28473 if (msecs >= 0) {
28474 item._idleTimeoutId = setTimeout(function onTimeout() {
28475 if (item._onTimeout)
28476 item._onTimeout();
28477 }, msecs);
28478 }
28479};
28480
28481// That's not how node.js implements it but the exposed api is the same.
28482exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) {
28483 var id = nextImmediateId++;
28484 var args = arguments.length < 2 ? false : slice.call(arguments, 1);
28485
28486 immediateIds[id] = true;
28487
28488 nextTick(function onNextTick() {
28489 if (immediateIds[id]) {
28490 // fn.call() is faster so we optimize for the common use-case
28491 // @see http://jsperf.com/call-apply-segu
28492 if (args) {
28493 fn.apply(null, args);
28494 } else {
28495 fn.call(null);
28496 }
28497 // Prevent ids from leaking
28498 exports.clearImmediate(id);
28499 }
28500 });
28501
28502 return id;
28503};
28504
28505exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) {
28506 delete immediateIds[id];
28507};
28508}).call(this,require("timers").setImmediate,require("timers").clearImmediate)
28509},{"process/browser.js":181,"timers":217}],218:[function(require,module,exports){
28510(function (global){
28511
28512/**
28513 * Module exports.
28514 */
28515
28516module.exports = deprecate;
28517
28518/**
28519 * Mark that a method should not be used.
28520 * Returns a modified function which warns once by default.
28521 *
28522 * If `localStorage.noDeprecation = true` is set, then it is a no-op.
28523 *
28524 * If `localStorage.throwDeprecation = true` is set, then deprecated functions
28525 * will throw an Error when invoked.
28526 *
28527 * If `localStorage.traceDeprecation = true` is set, then deprecated functions
28528 * will invoke `console.trace()` instead of `console.error()`.
28529 *
28530 * @param {Function} fn - the function to deprecate
28531 * @param {String} msg - the string to print to the console when `fn` is invoked
28532 * @returns {Function} a new "deprecated" version of `fn`
28533 * @api public
28534 */
28535
28536function deprecate (fn, msg) {
28537 if (config('noDeprecation')) {
28538 return fn;
28539 }
28540
28541 var warned = false;
28542 function deprecated() {
28543 if (!warned) {
28544 if (config('throwDeprecation')) {
28545 throw new Error(msg);
28546 } else if (config('traceDeprecation')) {
28547 console.trace(msg);
28548 } else {
28549 console.warn(msg);
28550 }
28551 warned = true;
28552 }
28553 return fn.apply(this, arguments);
28554 }
28555
28556 return deprecated;
28557}
28558
28559/**
28560 * Checks `localStorage` for boolean values for the given `name`.
28561 *
28562 * @param {String} name
28563 * @returns {Boolean}
28564 * @api private
28565 */
28566
28567function config (name) {
28568 // accessing global.localStorage can trigger a DOMException in sandboxed iframes
28569 try {
28570 if (!global.localStorage) return false;
28571 } catch (_) {
28572 return false;
28573 }
28574 var val = global.localStorage[name];
28575 if (null == val) return false;
28576 return String(val).toLowerCase() === 'true';
28577}
28578
28579}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
28580},{}],219:[function(require,module,exports){
28581var indexOf = function (xs, item) {
28582 if (xs.indexOf) return xs.indexOf(item);
28583 else for (var i = 0; i < xs.length; i++) {
28584 if (xs[i] === item) return i;
28585 }
28586 return -1;
28587};
28588var Object_keys = function (obj) {
28589 if (Object.keys) return Object.keys(obj)
28590 else {
28591 var res = [];
28592 for (var key in obj) res.push(key)
28593 return res;
28594 }
28595};
28596
28597var forEach = function (xs, fn) {
28598 if (xs.forEach) return xs.forEach(fn)
28599 else for (var i = 0; i < xs.length; i++) {
28600 fn(xs[i], i, xs);
28601 }
28602};
28603
28604var defineProp = (function() {
28605 try {
28606 Object.defineProperty({}, '_', {});
28607 return function(obj, name, value) {
28608 Object.defineProperty(obj, name, {
28609 writable: true,
28610 enumerable: false,
28611 configurable: true,
28612 value: value
28613 })
28614 };
28615 } catch(e) {
28616 return function(obj, name, value) {
28617 obj[name] = value;
28618 };
28619 }
28620}());
28621
28622var globals = ['Array', 'Boolean', 'Date', 'Error', 'EvalError', 'Function',
28623'Infinity', 'JSON', 'Math', 'NaN', 'Number', 'Object', 'RangeError',
28624'ReferenceError', 'RegExp', 'String', 'SyntaxError', 'TypeError', 'URIError',
28625'decodeURI', 'decodeURIComponent', 'encodeURI', 'encodeURIComponent', 'escape',
28626'eval', 'isFinite', 'isNaN', 'parseFloat', 'parseInt', 'undefined', 'unescape'];
28627
28628function Context() {}
28629Context.prototype = {};
28630
28631var Script = exports.Script = function NodeScript (code) {
28632 if (!(this instanceof Script)) return new Script(code);
28633 this.code = code;
28634};
28635
28636Script.prototype.runInContext = function (context) {
28637 if (!(context instanceof Context)) {
28638 throw new TypeError("needs a 'context' argument.");
28639 }
28640
28641 var iframe = document.createElement('iframe');
28642 if (!iframe.style) iframe.style = {};
28643 iframe.style.display = 'none';
28644
28645 document.body.appendChild(iframe);
28646
28647 var win = iframe.contentWindow;
28648 var wEval = win.eval, wExecScript = win.execScript;
28649
28650 if (!wEval && wExecScript) {
28651 // win.eval() magically appears when this is called in IE:
28652 wExecScript.call(win, 'null');
28653 wEval = win.eval;
28654 }
28655
28656 forEach(Object_keys(context), function (key) {
28657 win[key] = context[key];
28658 });
28659 forEach(globals, function (key) {
28660 if (context[key]) {
28661 win[key] = context[key];
28662 }
28663 });
28664
28665 var winKeys = Object_keys(win);
28666
28667 var res = wEval.call(win, this.code);
28668
28669 forEach(Object_keys(win), function (key) {
28670 // Avoid copying circular objects like `top` and `window` by only
28671 // updating existing context properties or new properties in the `win`
28672 // that was only introduced after the eval.
28673 if (key in context || indexOf(winKeys, key) === -1) {
28674 context[key] = win[key];
28675 }
28676 });
28677
28678 forEach(globals, function (key) {
28679 if (!(key in context)) {
28680 defineProp(context, key, win[key]);
28681 }
28682 });
28683
28684 document.body.removeChild(iframe);
28685
28686 return res;
28687};
28688
28689Script.prototype.runInThisContext = function () {
28690 return eval(this.code); // maybe...
28691};
28692
28693Script.prototype.runInNewContext = function (context) {
28694 var ctx = Script.createContext(context);
28695 var res = this.runInContext(ctx);
28696
28697 if (context) {
28698 forEach(Object_keys(ctx), function (key) {
28699 context[key] = ctx[key];
28700 });
28701 }
28702
28703 return res;
28704};
28705
28706forEach(Object_keys(Script.prototype), function (name) {
28707 exports[name] = Script[name] = function (code) {
28708 var s = Script(code);
28709 return s[name].apply(s, [].slice.call(arguments, 1));
28710 };
28711});
28712
28713exports.isContext = function (context) {
28714 return context instanceof Context;
28715};
28716
28717exports.createScript = function (code) {
28718 return exports.Script(code);
28719};
28720
28721exports.createContext = Script.createContext = function (context) {
28722 var copy = new Context();
28723 if(typeof context === 'object') {
28724 forEach(Object_keys(context), function (key) {
28725 copy[key] = context[key];
28726 });
28727 }
28728 return copy;
28729};
28730
28731},{}]},{},[1])(1)
28732});
diff --git a/src/js/index.js b/src/js/index.js
index a778799..035a2b3 100644
--- a/src/js/index.js
+++ b/src/js/index.js
@@ -233,7 +233,14 @@
233 if (phraseChangeTimeoutEvent != null) { 233 if (phraseChangeTimeoutEvent != null) {
234 clearTimeout(phraseChangeTimeoutEvent); 234 clearTimeout(phraseChangeTimeoutEvent);
235 } 235 }
236 phraseChangeTimeoutEvent = setTimeout(phraseChanged, 400); 236 phraseChangeTimeoutEvent = setTimeout(function() {
237 phraseChanged();
238 var entropy = mnemonic.toRawEntropyHex(DOM.phrase.val());
239 if (entropy !== null) {
240 DOM.entropyMnemonicLength.val("raw");
241 DOM.entropy.val(entropy);
242 }
243 }, 400);
237 } 244 }
238 245
239 function phraseChanged() { 246 function phraseChanged() {
@@ -493,9 +500,16 @@
493 function calcBip32RootKeyFromSeed(phrase, passphrase) { 500 function calcBip32RootKeyFromSeed(phrase, passphrase) {
494 seed = mnemonic.toSeed(phrase, passphrase); 501 seed = mnemonic.toSeed(phrase, passphrase);
495 bip32RootKey = bitcoinjs.bitcoin.HDNode.fromSeedHex(seed, network); 502 bip32RootKey = bitcoinjs.bitcoin.HDNode.fromSeedHex(seed, network);
503 if(isGRS())
504 bip32RootKey = groestlcoinjs.HDNode.fromSeedHex(seed, network);
505
496 } 506 }
497 507
498 function calcBip32RootKeyFromBase58(rootKeyBase58) { 508 function calcBip32RootKeyFromBase58(rootKeyBase58) {
509 if(isGRS()) {
510 calcBip32RootKeyFromBase58GRS(rootKeyBase58);
511 return;
512 }
499 // try parsing with various segwit network params since this extended 513 // try parsing with various segwit network params since this extended
500 // key may be from any one of them. 514 // key may be from any one of them.
501 if (networkHasSegwit()) { 515 if (networkHasSegwit()) {
@@ -530,6 +544,41 @@
530 bip32RootKey = bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58, network); 544 bip32RootKey = bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58, network);
531 } 545 }
532 546
547 function calcBip32RootKeyFromBase58GRS(rootKeyBase58) {
548 // try parsing with various segwit network params since this extended
549 // key may be from any one of them.
550 if (networkHasSegwit()) {
551 var n = network;
552 if ("baseNetwork" in n) {
553 n = bitcoinjs.bitcoin.networks[n.baseNetwork];
554 }
555 // try parsing using base network params
556 try {
557 bip32RootKey = groestlcoinjs.HDNode.fromBase58(rootKeyBase58, n);
558 return;
559 }
560 catch (e) {}
561 // try parsing using p2wpkh params
562 if ("p2wpkh" in n) {
563 try {
564 bip32RootKey = groestlcoinjs.HDNode.fromBase58(rootKeyBase58, n.p2wpkh);
565 return;
566 }
567 catch (e) {}
568 }
569 // try parsing using p2wpkh-in-p2sh network params
570 if ("p2wpkhInP2sh" in n) {
571 try {
572 bip32RootKey = groestlcoinjs.HDNode.fromBase58(rootKeyBase58, n.p2wpkhInP2sh);
573 return;
574 }
575 catch (e) {}
576 }
577 }
578 // try the network params as currently specified
579 bip32RootKey = groestlcoinjs.HDNode.fromBase58(rootKeyBase58, network);
580 }
581
533 function calcBip32ExtendedKey(path) { 582 function calcBip32ExtendedKey(path) {
534 // Check there's a root key to derive from 583 // Check there's a root key to derive from
535 if (!bip32RootKey) { 584 if (!bip32RootKey) {
@@ -600,6 +649,9 @@
600 } 649 }
601 650
602 function validateRootKey(rootKeyBase58) { 651 function validateRootKey(rootKeyBase58) {
652 if(isGRS())
653 return validateRootKeyGRS(rootKeyBase58);
654
603 // try various segwit network params since this extended key may be from 655 // try various segwit network params since this extended key may be from
604 // any one of them. 656 // any one of them.
605 if (networkHasSegwit()) { 657 if (networkHasSegwit()) {
@@ -640,6 +692,47 @@
640 return ""; 692 return "";
641 } 693 }
642 694
695 function validateRootKeyGRS(rootKeyBase58) {
696 // try various segwit network params since this extended key may be from
697 // any one of them.
698 if (networkHasSegwit()) {
699 var n = network;
700 if ("baseNetwork" in n) {
701 n = bitcoinjs.bitcoin.networks[n.baseNetwork];
702 }
703 // try parsing using base network params
704 try {
705 groestlcoinjs.HDNode.fromBase58(rootKeyBase58, n);
706 return "";
707 }
708 catch (e) {}
709 // try parsing using p2wpkh params
710 if ("p2wpkh" in n) {
711 try {
712 groestlcoinjs.HDNode.fromBase58(rootKeyBase58, n.p2wpkh);
713 return "";
714 }
715 catch (e) {}
716 }
717 // try parsing using p2wpkh-in-p2sh network params
718 if ("p2wpkhInP2sh" in n) {
719 try {
720 groestlcoinjs.HDNode.fromBase58(rootKeyBase58, n.p2wpkhInP2sh);
721 return "";
722 }
723 catch (e) {}
724 }
725 }
726 // try the network params as currently specified
727 try {
728 groestlcoinjs.HDNode.fromBase58(rootKeyBase58, network);
729 }
730 catch (e) {
731 return "Invalid root key";
732 }
733 return "";
734 }
735
643 function getDerivationPath() { 736 function getDerivationPath() {
644 if (bip44TabSelected()) { 737 if (bip44TabSelected()) {
645 var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44); 738 var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44);
@@ -750,6 +843,10 @@
750 return false; 843 return false;
751 } 844 }
752 845
846 function isGRS() {
847 return networks[DOM.network.val()].name == "GRS - Groestlcoin" || networks[DOM.network.val()].name == "GRS - Groestlcoin Testnet";
848 }
849
753 function displayBip44Info() { 850 function displayBip44Info() {
754 // Get the derivation path for the account 851 // Get the derivation path for the account
755 var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44); 852 var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44);
@@ -893,6 +990,9 @@
893 var useUncompressed = useBip38; 990 var useUncompressed = useBip38;
894 if (useUncompressed) { 991 if (useUncompressed) {
895 keyPair = new bitcoinjs.bitcoin.ECPair(keyPair.d, null, { network: network, compressed: false }); 992 keyPair = new bitcoinjs.bitcoin.ECPair(keyPair.d, null, { network: network, compressed: false });
993 if(isGRS())
994 keyPair = new groestlcoinjs.ECPair(keyPair.d, null, { network: network, compressed: false });
995
896 } 996 }
897 // get address 997 // get address
898 var address = keyPair.getAddress().toString(); 998 var address = keyPair.getAddress().toString();
@@ -903,9 +1003,14 @@
903 privkey = keyPair.toWIF(); 1003 privkey = keyPair.toWIF();
904 // BIP38 encode private key if required 1004 // BIP38 encode private key if required
905 if (useBip38) { 1005 if (useBip38) {
906 privkey = bitcoinjsBip38.encrypt(keyPair.d.toBuffer(), false, bip38password, function(p) { 1006 if(isGRS())
907 console.log("Progressed " + p.percent.toFixed(1) + "% for index " + index); 1007 privkey = groestlcoinjsBip38.encrypt(keyPair.d.toBuffer(), false, bip38password, function(p) {
908 }); 1008 console.log("Progressed " + p.percent.toFixed(1) + "% for index " + index);
1009 }, null, networks[DOM.network.val()].name.includes("Testnet"));
1010 else
1011 privkey = bitcoinjsBip38.encrypt(keyPair.d.toBuffer(), false, bip38password, function(p) {
1012 console.log("Progressed " + p.percent.toFixed(1) + "% for index " + index);
1013 });
909 } 1014 }
910 } 1015 }
911 // get pubkey 1016 // get pubkey
@@ -922,7 +1027,12 @@
922 || (networks[DOM.network.val()].name == "MUSIC - Musicoin") 1027 || (networks[DOM.network.val()].name == "MUSIC - Musicoin")
923 || (networks[DOM.network.val()].name == "POA - Poa") 1028 || (networks[DOM.network.val()].name == "POA - Poa")
924 || (networks[DOM.network.val()].name == "EXP - Expanse") 1029 || (networks[DOM.network.val()].name == "EXP - Expanse")
925 || (networks[DOM.network.val()].name == "CLO - Callisto")) { 1030 || (networks[DOM.network.val()].name == "CLO - Callisto")
1031 || (networks[DOM.network.val()].name == "DXN - DEXON")
1032 || (networks[DOM.network.val()].name == "ELLA - Ellaism")
1033 || (networks[DOM.network.val()].name == "ESN - Ethersocial Network")
1034 || (networks[DOM.network.val()].name == "VET - VeChain")
1035 ) {
926 var privKeyBuffer = keyPair.d.toBuffer(32); 1036 var privKeyBuffer = keyPair.d.toBuffer(32);
927 privkey = privKeyBuffer.toString('hex'); 1037 privkey = privKeyBuffer.toString('hex');
928 var addressBuffer = ethUtil.privateToAddress(privKeyBuffer); 1038 var addressBuffer = ethUtil.privateToAddress(privKeyBuffer);
@@ -932,11 +1042,38 @@
932 privkey = ethUtil.addHexPrefix(privkey); 1042 privkey = ethUtil.addHexPrefix(privkey);
933 pubkey = ethUtil.addHexPrefix(pubkey); 1043 pubkey = ethUtil.addHexPrefix(pubkey);
934 } 1044 }
1045
1046 // Stellar is different
1047 if (networks[DOM.network.val()].name == "XLM - Stellar") {
1048 var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44);
1049 var coin = parseIntNoNaN(DOM.bip44coin.val(), 0);
1050 var path = "m/";
1051 path += purpose + "'/";
1052 path += coin + "'/" + index + "'";
1053 var keypair = stellarUtil.getKeypair(path, seed);
1054 indexText = path;
1055 privkey = keypair.secret();
1056 pubkey = address = keypair.publicKey();
1057 }
1058 if ((networks[DOM.network.val()].name == "NAS - Nebulas")) {
1059 var NasAccount = require("nebulas-account");
1060 var privKeyBuffer = keyPair.d.toBuffer(32);
1061 var nebulasAccount = new NasAccount();
1062 nebulasAccount.setPrivateKey(privKeyBuffer);
1063 address = nebulasAccount.getAddressString();
1064 privkey = nebulasAccount.getPrivateKeyString();
1065 pubkey = nebulasAccount.getPublicKeyString();
1066 }
935 // Ripple values are different 1067 // Ripple values are different
936 if (networks[DOM.network.val()].name == "XRP - Ripple") { 1068 if (networks[DOM.network.val()].name == "XRP - Ripple") {
937 privkey = convertRipplePriv(privkey); 1069 privkey = convertRipplePriv(privkey);
938 address = convertRippleAdrr(address); 1070 address = convertRippleAdrr(address);
939 } 1071 }
1072 // CasinoCoin values are different
1073 if (networks[DOM.network.val()].name == "CSC - CasinoCoin") {
1074 privkey = convertCasinoCoinPriv(privkey);
1075 address = convertCasinoCoinAdrr(address);
1076 }
940 // Bitcoin Cash address format may vary 1077 // Bitcoin Cash address format may vary
941 if (networks[DOM.network.val()].name == "BCH - Bitcoin Cash") { 1078 if (networks[DOM.network.val()].name == "BCH - Bitcoin Cash") {
942 var bchAddrType = DOM.bitcoinCashAddressType.filter(":checked").val(); 1079 var bchAddrType = DOM.bitcoinCashAddressType.filter(":checked").val();
@@ -947,6 +1084,13 @@
947 address = bchaddr.toBitpayAddress(address); 1084 address = bchaddr.toBitpayAddress(address);
948 } 1085 }
949 } 1086 }
1087 // Bitcoin Cash address format may vary
1088 if (networks[DOM.network.val()].name == "SLP - Simple Ledger Protocol") {
1089 var bchAddrType = DOM.bitcoinCashAddressType.filter(":checked").val();
1090 if (bchAddrType == "cashaddr") {
1091 address = bchaddr.toSlpAddress(address);
1092 }
1093 }
950 // Segwit addresses are different 1094 // Segwit addresses are different
951 if (isSegwit) { 1095 if (isSegwit) {
952 if (!segwitAvailable) { 1096 if (!segwitAvailable) {
@@ -965,6 +1109,34 @@
965 address = bitcoinjs.bitcoin.address.fromOutputScript(scriptpubkey, network) 1109 address = bitcoinjs.bitcoin.address.fromOutputScript(scriptpubkey, network)
966 } 1110 }
967 } 1111 }
1112
1113 if ((networks[DOM.network.val()].name == "CRW - Crown")) {
1114 address = bitcoinjs.bitcoin.networks.crown.toNewAddress(address);
1115 }
1116
1117 if (networks[DOM.network.val()].name == "EOS - EOSIO") {
1118 address = ""
1119 pubkey = eosUtil.bufferToPublic(keyPair.getPublicKeyBuffer());
1120 privkey = eosUtil.bufferToPrivate(keyPair.d.toBuffer(32));
1121 }
1122
1123 //Groestlcoin Addresses are different
1124 if(isGRS()) {
1125
1126 if (isSegwit) {
1127 if (!segwitAvailable) {
1128 return;
1129 }
1130 if (isP2wpkh) {
1131 address = groestlcoinjs.address.fromOutputScript(scriptpubkey, network)
1132 }
1133 else if (isP2wpkhInP2sh) {
1134 address = groestlcoinjs.address.fromOutputScript(scriptpubkey, network)
1135 }
1136 }
1137 //non-segwit addresses are handled by using groestlcoinjs for bip32RootKey
1138 }
1139
968 addAddressToList(indexText, address, pubkey, privkey); 1140 addAddressToList(indexText, address, pubkey, privkey);
969 if (isLast) { 1141 if (isLast) {
970 hidePending(); 1142 hidePending();
@@ -1675,6 +1847,13 @@
1675 }, 1847 },
1676 }, 1848 },
1677 { 1849 {
1850 name: "ARYA - Aryacoin",
1851 onSelect: function() {
1852 network = bitcoinjs.bitcoin.networks.aryacoin;
1853 setHdCoin(357);
1854 },
1855 },
1856 {
1678 name: "AUR - Auroracoin", 1857 name: "AUR - Auroracoin",
1679 onSelect: function() { 1858 onSelect: function() {
1680 network = bitcoinjs.bitcoin.networks.auroracoin; 1859 network = bitcoinjs.bitcoin.networks.auroracoin;
@@ -1696,6 +1875,13 @@
1696 }, 1875 },
1697 }, 1876 },
1698 { 1877 {
1878 name: "BOLI - Bolivarcoin",
1879 onSelect: function() {
1880 network = bitcoinjs.bitcoin.networks.bolivarcoin;
1881 setHdCoin(278);
1882 },
1883 },
1884 {
1699 name: "BCA - Bitcoin Atom", 1885 name: "BCA - Bitcoin Atom",
1700 onSelect: function() { 1886 onSelect: function() {
1701 network = bitcoinjs.bitcoin.networks.atom; 1887 network = bitcoinjs.bitcoin.networks.atom;
@@ -1731,6 +1917,20 @@
1731 }, 1917 },
1732 }, 1918 },
1733 { 1919 {
1920 name: "BND - Blocknode",
1921 onSelect: function() {
1922 network = bitcoinjs.bitcoin.networks.blocknode;
1923 setHdCoin(2941);
1924 },
1925 },
1926 {
1927 name: "tBND - Blocknode Testnet",
1928 onSelect: function() {
1929 network = bitcoinjs.bitcoin.networks.blocknode_testnet;
1930 setHdCoin(1);
1931 },
1932 },
1933 {
1734 name: "BRIT - Britcoin", 1934 name: "BRIT - Britcoin",
1735 onSelect: function() { 1935 onSelect: function() {
1736 network = bitcoinjs.bitcoin.networks.britcoin; 1936 network = bitcoinjs.bitcoin.networks.britcoin;
@@ -1744,6 +1944,13 @@
1744 setHdCoin(91); 1944 setHdCoin(91);
1745 }, 1945 },
1746 }, 1946 },
1947 {
1948 name: "BST - BlockStamp",
1949 onSelect: function() {
1950 network = bitcoinjs.bitcoin.networks.blockstamp;
1951 setHdCoin(254);
1952 },
1953 },
1747 { 1954 {
1748 name: "BTA - Bata", 1955 name: "BTA - Bata",
1749 onSelect: function() { 1956 onSelect: function() {
@@ -1780,6 +1987,13 @@
1780 }, 1987 },
1781 }, 1988 },
1782 { 1989 {
1990 name: "BSV - BitcoinSV",
1991 onSelect: function() {
1992 network = bitcoinjs.bitcoin.networks.bitcoinsv;
1993 setHdCoin(236);
1994 },
1995 },
1996 {
1783 name: "BTCZ - Bitcoinz", 1997 name: "BTCZ - Bitcoinz",
1784 onSelect: function() { 1998 onSelect: function() {
1785 network = bitcoinjs.bitcoin.networks.bitcoinz; 1999 network = bitcoinjs.bitcoin.networks.bitcoinz;
@@ -1858,6 +2072,13 @@
1858 }, 2072 },
1859 }, 2073 },
1860 { 2074 {
2075 name: "CPU - CPUchain",
2076 onSelect: function() {
2077 network = bitcoinjs.bitcoin.networks.cpuchain;
2078 setHdCoin(363);
2079 },
2080 },
2081 {
1861 name: "CRAVE - Crave", 2082 name: "CRAVE - Crave",
1862 onSelect: function() { 2083 onSelect: function() {
1863 network = bitcoinjs.bitcoin.networks.crave; 2084 network = bitcoinjs.bitcoin.networks.crave;
@@ -1865,6 +2086,13 @@
1865 }, 2086 },
1866 }, 2087 },
1867 { 2088 {
2089 name: "CRW - Crown (Legacy)",
2090 onSelect: function() {
2091 network = bitcoinjs.bitcoin.networks.crown;
2092 setHdCoin(72);
2093 },
2094 },
2095 {
1868 name: "CRW - Crown", 2096 name: "CRW - Crown",
1869 onSelect: function() { 2097 onSelect: function() {
1870 network = bitcoinjs.bitcoin.networks.crown; 2098 network = bitcoinjs.bitcoin.networks.crown;
@@ -1872,6 +2100,13 @@
1872 }, 2100 },
1873 }, 2101 },
1874 { 2102 {
2103 name: "CSC - CasinoCoin",
2104 onSelect: function() {
2105 network = bitcoinjs.bitcoin.networks.bitcoin;
2106 setHdCoin(359);
2107 },
2108 },
2109 {
1875 name: "DASH - Dash", 2110 name: "DASH - Dash",
1876 onSelect: function() { 2111 onSelect: function() {
1877 network = bitcoinjs.bitcoin.networks.dash; 2112 network = bitcoinjs.bitcoin.networks.dash;
@@ -1928,6 +2163,20 @@
1928 }, 2163 },
1929 }, 2164 },
1930 { 2165 {
2166 name: "DOGEt - Dogecoin Testnet",
2167 onSelect: function() {
2168 network = bitcoinjs.bitcoin.networks.dogecointestnet;
2169 setHdCoin(1);
2170 },
2171 },
2172 {
2173 name: "DXN - DEXON",
2174 onSelect: function() {
2175 network = bitcoinjs.bitcoin.networks.bitcoin;
2176 setHdCoin(237);
2177 },
2178 },
2179 {
1931 name: "ECN - Ecoin", 2180 name: "ECN - Ecoin",
1932 onSelect: function() { 2181 onSelect: function() {
1933 network = bitcoinjs.bitcoin.networks.ecoin; 2182 network = bitcoinjs.bitcoin.networks.ecoin;
@@ -1949,6 +2198,14 @@
1949 }, 2198 },
1950 }, 2199 },
1951 { 2200 {
2201 name: "ELLA - Ellaism",
2202 segwitAvailable: false,
2203 onSelect: function() {
2204 network = bitcoinjs.bitcoin.networks.bitcoin;
2205 setHdCoin(163);
2206 },
2207 },
2208 {
1952 name: "EMC2 - Einsteinium", 2209 name: "EMC2 - Einsteinium",
1953 onSelect: function() { 2210 onSelect: function() {
1954 network = bitcoinjs.bitcoin.networks.einsteinium; 2211 network = bitcoinjs.bitcoin.networks.einsteinium;
@@ -1963,6 +2220,21 @@
1963 }, 2220 },
1964 }, 2221 },
1965 { 2222 {
2223 name: "EOS - EOSIO",
2224 onSelect: function() {
2225 network = bitcoinjs.bitcoin.networks.bitcoin;
2226 setHdCoin(194);
2227 },
2228 },
2229 {
2230 name: "ESN - Ethersocial Network",
2231 segwitAvailable: false,
2232 onSelect: function() {
2233 network = bitcoinjs.bitcoin.networks.bitcoin;
2234 setHdCoin(31102);
2235 },
2236 },
2237 {
1966 name: "ETC - Ethereum Classic", 2238 name: "ETC - Ethereum Classic",
1967 segwitAvailable: false, 2239 segwitAvailable: false,
1968 onSelect: function() { 2240 onSelect: function() {
@@ -2000,6 +2272,20 @@
2000 }, 2272 },
2001 }, 2273 },
2002 { 2274 {
2275 name: "FIX - FIX",
2276 onSelect: function() {
2277 network = bitcoinjs.bitcoin.networks.fix;
2278 setHdCoin(336);
2279 },
2280 },
2281 {
2282 name: "FIX - FIX Testnet",
2283 onSelect: function() {
2284 network = bitcoinjs.bitcoin.networks.fixtestnet;
2285 setHdCoin(1);
2286 },
2287 },
2288 {
2003 name: "FJC - Fujicoin", 2289 name: "FJC - Fujicoin",
2004 onSelect: function() { 2290 onSelect: function() {
2005 network = bitcoinjs.bitcoin.networks.fujicoin; 2291 network = bitcoinjs.bitcoin.networks.fujicoin;
@@ -2056,6 +2342,20 @@
2056 }, 2342 },
2057 }, 2343 },
2058 { 2344 {
2345 name: "GRS - Groestlcoin",
2346 onSelect: function() {
2347 network = bitcoinjs.bitcoin.networks.groestlcoin;
2348 setHdCoin(17);
2349 },
2350 },
2351 {
2352 name: "GRS - Groestlcoin Testnet",
2353 onSelect: function() {
2354 network = bitcoinjs.bitcoin.networks.groestlcointestnet;
2355 setHdCoin(1);
2356 },
2357 },
2358 {
2059 name: "HNC - Helleniccoin", 2359 name: "HNC - Helleniccoin",
2060 onSelect: function() { 2360 onSelect: function() {
2061 network = bitcoinjs.bitcoin.networks.helleniccoin; 2361 network = bitcoinjs.bitcoin.networks.helleniccoin;
@@ -2063,12 +2363,19 @@
2063 }, 2363 },
2064 }, 2364 },
2065 { 2365 {
2066 name: "HUSH - Hush", 2366 name: "HUSH - Hush (Legacy)",
2067 onSelect: function() { 2367 onSelect: function() {
2068 network = bitcoinjs.bitcoin.networks.hush; 2368 network = bitcoinjs.bitcoin.networks.hush;
2069 setHdCoin(197); 2369 setHdCoin(197);
2070 }, 2370 },
2071 }, 2371 },
2372 {
2373 name: "HUSH - Hush3",
2374 onSelect: function() {
2375 network = bitcoinjs.bitcoin.networks.hush3;
2376 setHdCoin(197);
2377 },
2378 },
2072 { 2379 {
2073 name: "INSN - Insane", 2380 name: "INSN - Insane",
2074 onSelect: function() { 2381 onSelect: function() {
@@ -2142,6 +2449,14 @@
2142 }, 2449 },
2143 }, 2450 },
2144 { 2451 {
2452 name: "LKR - Lkrcoin",
2453 segwitAvailable: false,
2454 onSelect: function() {
2455 network = bitcoinjs.bitcoin.networks.lkrcoin;
2456 setHdCoin(557);
2457 },
2458 },
2459 {
2145 name: "LTC - Litecoin", 2460 name: "LTC - Litecoin",
2146 onSelect: function() { 2461 onSelect: function() {
2147 network = bitcoinjs.bitcoin.networks.litecoin; 2462 network = bitcoinjs.bitcoin.networks.litecoin;
@@ -2150,6 +2465,21 @@
2150 }, 2465 },
2151 }, 2466 },
2152 { 2467 {
2468 name: "LTCt - Litecoin Testnet",
2469 onSelect: function() {
2470 network = bitcoinjs.bitcoin.networks.litecointestnet;
2471 setHdCoin(1);
2472 DOM.litecoinLtubContainer.removeClass("hidden");
2473 },
2474 },
2475 {
2476 name: "LTZ - LitecoinZ",
2477 onSelect: function() {
2478 network = bitcoinjs.bitcoin.networks.litecoinz;
2479 setHdCoin(221);
2480 },
2481 },
2482 {
2153 name: "LYNX - Lynx", 2483 name: "LYNX - Lynx",
2154 onSelect: function() { 2484 onSelect: function() {
2155 network = bitcoinjs.bitcoin.networks.lynx; 2485 network = bitcoinjs.bitcoin.networks.lynx;
@@ -2193,6 +2523,13 @@
2193 }, 2523 },
2194 }, 2524 },
2195 { 2525 {
2526 name: "MONK - Monkey Project",
2527 onSelect: function() {
2528 network = bitcoinjs.bitcoin.networks.monkeyproject,
2529 setHdCoin(214);
2530 },
2531 },
2532 {
2196 name: "MUSIC - Musicoin", 2533 name: "MUSIC - Musicoin",
2197 segwitAvailable: false, 2534 segwitAvailable: false,
2198 onSelect: function() { 2535 onSelect: function() {
@@ -2208,6 +2545,13 @@
2208 }, 2545 },
2209 }, 2546 },
2210 { 2547 {
2548 name: "NAS - Nebulas",
2549 onSelect: function() {
2550 network = bitcoinjs.bitcoin.networks.bitcoin;
2551 setHdCoin(2718);
2552 },
2553 },
2554 {
2211 name: "NEBL - Neblio", 2555 name: "NEBL - Neblio",
2212 onSelect: function() { 2556 onSelect: function() {
2213 network = bitcoinjs.bitcoin.networks.neblio; 2557 network = bitcoinjs.bitcoin.networks.neblio;
@@ -2222,6 +2566,13 @@
2222 }, 2566 },
2223 }, 2567 },
2224 { 2568 {
2569 name: "NIX - NIX Platform",
2570 onSelect: function() {
2571 network = bitcoinjs.bitcoin.networks.nix;
2572 setHdCoin(400);
2573 },
2574 },
2575 {
2225 name: "NLG - Gulden", 2576 name: "NLG - Gulden",
2226 onSelect: function() { 2577 onSelect: function() {
2227 network = bitcoinjs.bitcoin.networks.gulden; 2578 network = bitcoinjs.bitcoin.networks.gulden;
@@ -2285,6 +2636,13 @@
2285 }, 2636 },
2286 }, 2637 },
2287 { 2638 {
2639 name: "ONION - DeepOnion",
2640 onSelect: function() {
2641 network = bitcoinjs.bitcoin.networks.deeponion;
2642 setHdCoin(305);
2643 },
2644 },
2645 {
2288 name: "ONX - Onixcoin", 2646 name: "ONX - Onixcoin",
2289 onSelect: function() { 2647 onSelect: function() {
2290 network = bitcoinjs.bitcoin.networks.onixcoin; 2648 network = bitcoinjs.bitcoin.networks.onixcoin;
@@ -2378,6 +2736,13 @@
2378 }, 2736 },
2379 }, 2737 },
2380 { 2738 {
2739 name: "RPD - Rapids",
2740 onSelect: function() {
2741 network = bitcoinjs.bitcoin.networks.rapids;
2742 setHdCoin(320);
2743 },
2744 },
2745 {
2381 name: "RVN - Ravencoin", 2746 name: "RVN - Ravencoin",
2382 onSelect: function() { 2747 onSelect: function() {
2383 network = bitcoinjs.bitcoin.networks.ravencoin; 2748 network = bitcoinjs.bitcoin.networks.ravencoin;
@@ -2406,6 +2771,13 @@
2406 }, 2771 },
2407 }, 2772 },
2408 { 2773 {
2774 name: "SAFE - Safecoin",
2775 onSelect: function() {
2776 network = bitcoinjs.bitcoin.networks.safecoin;
2777 setHdCoin(19165);
2778 },
2779 },
2780 {
2409 name: "SLS - Salus", 2781 name: "SLS - Salus",
2410 onSelect: function() { 2782 onSelect: function() {
2411 network = bitcoinjs.bitcoin.networks.salus; 2783 network = bitcoinjs.bitcoin.networks.salus;
@@ -2441,6 +2813,13 @@
2441 }, 2813 },
2442 }, 2814 },
2443 { 2815 {
2816 name: "SLP - Simple Ledger Protocol",
2817 onSelect: function() {
2818 DOM.bitcoinCashAddressTypeContainer.removeClass("hidden");
2819 setHdCoin(245);
2820 },
2821 },
2822 {
2444 name: "SLR - Solarcoin", 2823 name: "SLR - Solarcoin",
2445 onSelect: function() { 2824 onSelect: function() {
2446 network = bitcoinjs.bitcoin.networks.solarcoin; 2825 network = bitcoinjs.bitcoin.networks.solarcoin;
@@ -2504,6 +2883,20 @@
2504 }, 2883 },
2505 }, 2884 },
2506 { 2885 {
2886 name: "TWINS - TWINS",
2887 onSelect: function() {
2888 network = bitcoinjs.bitcoin.networks.twins;
2889 setHdCoin(970);
2890 },
2891 },
2892 {
2893 name: "TWINS - TWINS Testnet",
2894 onSelect: function() {
2895 network = bitcoinjs.bitcoin.networks.twinstestnet;
2896 setHdCoin(1);
2897 },
2898 },
2899 {
2507 name: "USC - Ultimatesecurecash", 2900 name: "USC - Ultimatesecurecash",
2508 onSelect: function() { 2901 onSelect: function() {
2509 network = bitcoinjs.bitcoin.networks.ultimatesecurecash; 2902 network = bitcoinjs.bitcoin.networks.ultimatesecurecash;
@@ -2532,6 +2925,13 @@
2532 }, 2925 },
2533 }, 2926 },
2534 { 2927 {
2928 name: "VET - VeChain",
2929 onSelect: function() {
2930 network = bitcoinjs.bitcoin.networks.bitcoin;
2931 setHdCoin(818);
2932 },
2933 },
2934 {
2535 name: "VIA - Viacoin", 2935 name: "VIA - Viacoin",
2536 onSelect: function() { 2936 onSelect: function() {
2537 network = bitcoinjs.bitcoin.networks.viacoin; 2937 network = bitcoinjs.bitcoin.networks.viacoin;
@@ -2560,6 +2960,13 @@
2560 }, 2960 },
2561 }, 2961 },
2562 { 2962 {
2963 name: "WGR - Wagerr",
2964 onSelect: function() {
2965 network = bitcoinjs.bitcoin.networks.wagerr;
2966 setHdCoin(7825266);
2967 },
2968 },
2969 {
2563 name: "WC - Wincoin", 2970 name: "WC - Wincoin",
2564 onSelect: function() { 2971 onSelect: function() {
2565 network = bitcoinjs.bitcoin.networks.wincoin; 2972 network = bitcoinjs.bitcoin.networks.wincoin;
@@ -2581,6 +2988,13 @@
2581 }, 2988 },
2582 }, 2989 },
2583 { 2990 {
2991 name: "XLM - Stellar",
2992 onSelect: function() {
2993 network = stellarUtil.dummyNetwork;
2994 setHdCoin(148);
2995 },
2996 },
2997 {
2584 name: "XMY - Myriadcoin", 2998 name: "XMY - Myriadcoin",
2585 onSelect: function() { 2999 onSelect: function() {
2586 network = bitcoinjs.bitcoin.networks.myriadcoin; 3000 network = bitcoinjs.bitcoin.networks.myriadcoin;
@@ -2645,7 +3059,7 @@
2645 }, 3059 },
2646 }, 3060 },
2647 { 3061 {
2648 name: "ZEN - Zencash", 3062 name: "ZEN - Horizen",
2649 onSelect: function() { 3063 onSelect: function() {
2650 network = bitcoinjs.bitcoin.networks.zencash; 3064 network = bitcoinjs.bitcoin.networks.zencash;
2651 setHdCoin(121); 3065 setHdCoin(121);
diff --git a/src/js/jsbip39.js b/src/js/jsbip39.js
index 3230e3b..9a6e7ec 100644
--- a/src/js/jsbip39.js
+++ b/src/js/jsbip39.js
@@ -97,22 +97,10 @@ var Mnemonic = function(language) {
97 } 97 }
98 98
99 self.check = function(mnemonic) { 99 self.check = function(mnemonic) {
100 var mnemonic = self.splitWords(mnemonic); 100 var b = mnemonicToBinaryString(mnemonic);
101 if (mnemonic.length == 0 || mnemonic.length % 3 > 0) { 101 if (b === null) {
102 return false 102 return false;
103 }
104 // idx = map(lambda x: bin(self.wordlist.index(x))[2:].zfill(11), mnemonic)
105 var idx = [];
106 for (var i=0; i<mnemonic.length; i++) {
107 var word = mnemonic[i];
108 var wordIndex = wordlist.indexOf(word);
109 if (wordIndex == -1) {
110 return false;
111 }
112 var binaryIndex = zfill(wordIndex.toString(2), 11);
113 idx.push(binaryIndex);
114 } 103 }
115 var b = idx.join('');
116 var l = b.length; 104 var l = b.length;
117 //d = b[:l / 33 * 32] 105 //d = b[:l / 33 * 32]
118 //h = b[-l / 33:] 106 //h = b[-l / 33:]
@@ -128,6 +116,20 @@ var Mnemonic = function(language) {
128 return h == nh; 116 return h == nh;
129 } 117 }
130 118
119 self.toRawEntropyHex = function(mnemonic) {
120 var b = mnemonicToBinaryString(mnemonic);
121 if (b === null)
122 return null;
123 var d = b.substring(0, b.length / 33 * 32);
124 var nd = binaryStringToWordArray(d);
125
126 var h = "";
127 for (var i=0; i<nd.length; i++) {
128 h += ('0000000' + nd[i].toString(16)).slice(-8);
129 }
130 return h;
131 }
132
131 self.toSeed = function(mnemonic, passphrase) { 133 self.toSeed = function(mnemonic, passphrase) {
132 passphrase = passphrase || ''; 134 passphrase = passphrase || '';
133 mnemonic = self.joinWords(self.splitWords(mnemonic)); // removes duplicate blanks 135 mnemonic = self.joinWords(self.splitWords(mnemonic)); // removes duplicate blanks
@@ -200,6 +202,25 @@ var Mnemonic = function(language) {
200 return a; 202 return a;
201 } 203 }
202 204
205 function mnemonicToBinaryString(mnemonic) {
206 var mnemonic = self.splitWords(mnemonic);
207 if (mnemonic.length == 0 || mnemonic.length % 3 > 0) {
208 return null;
209 }
210 // idx = map(lambda x: bin(self.wordlist.index(x))[2:].zfill(11), mnemonic)
211 var idx = [];
212 for (var i=0; i<mnemonic.length; i++) {
213 var word = mnemonic[i];
214 var wordIndex = wordlist.indexOf(word);
215 if (wordIndex == -1) {
216 return null;
217 }
218 var binaryIndex = zfill(wordIndex.toString(2), 11);
219 idx.push(binaryIndex);
220 }
221 return idx.join('');
222 }
223
203 // Pad a numeric string on the left with zero digits until the given width 224 // Pad a numeric string on the left with zero digits until the given width
204 // is reached. 225 // is reached.
205 // Note this differs to the python implementation because it does not 226 // Note this differs to the python implementation because it does not
diff --git a/src/js/levenshtein.js b/src/js/levenshtein.js
index 3051ec5..a57b8fb 100644
--- a/src/js/levenshtein.js
+++ b/src/js/levenshtein.js
@@ -1,38 +1,17 @@
1// source
2// https://github.com/hiddentao/fast-levenshtein/blob/2.0.6/levenshtein.js
1(function() { 3(function() {
2 'use strict'; 4 'use strict';
3 5
4 /** 6 var collator;
5 * Extend an Object with another Object's properties. 7 try {
6 * 8 collator = (typeof Intl !== "undefined" && typeof Intl.Collator !== "undefined") ? Intl.Collator("generic", { sensitivity: "base" }) : null;
7 * The source objects are specified as additional arguments. 9 } catch (err){
8 * 10 console.log("Collator could not be initialized and wouldn't be used");
9 * @param dst Object the object to extend. 11 }
10 * 12 // arrays to re-use
11 * @return Object the final object. 13 var prevRow = [],
12 */ 14 str2Char = [];
13 var _extend = function(dst) {
14 var sources = Array.prototype.slice.call(arguments, 1);
15 for (var i=0; i<sources.length; ++i) {
16 var src = sources[i];
17 for (var p in src) {
18 if (src.hasOwnProperty(p)) dst[p] = src[p];
19 }
20 }
21 return dst;
22 };
23
24
25 /**
26 * Defer execution of given function.
27 * @param {Function} func
28 */
29 var _defer = function(func) {
30 if (typeof setImmediate === 'function') {
31 return setImmediate(func);
32 } else {
33 return setTimeout(func, 0);
34 }
35 };
36 15
37 /** 16 /**
38 * Based on the algorithm at http://en.wikipedia.org/wiki/Levenshtein_distance. 17 * Based on the algorithm at http://en.wikipedia.org/wiki/Levenshtein_distance.
@@ -43,148 +22,96 @@
43 * 22 *
44 * @param str1 String the first string. 23 * @param str1 String the first string.
45 * @param str2 String the second string. 24 * @param str2 String the second string.
25 * @param [options] Additional options.
26 * @param [options.useCollator] Use `Intl.Collator` for locale-sensitive string comparison.
46 * @return Integer the levenshtein distance (0 and above). 27 * @return Integer the levenshtein distance (0 and above).
47 */ 28 */
48 get: function(str1, str2) { 29 get: function(str1, str2, options) {
30 var useCollator = (options && collator && options.useCollator);
31
32 var str1Len = str1.length,
33 str2Len = str2.length;
34
49 // base cases 35 // base cases
50 if (str1 === str2) return 0; 36 if (str1Len === 0) return str2Len;
51 if (str1.length === 0) return str2.length; 37 if (str2Len === 0) return str1Len;
52 if (str2.length === 0) return str1.length;
53 38
54 // two rows 39 // two rows
55 var prevRow = new Array(str2.length + 1), 40 var curCol, nextCol, i, j, tmp;
56 curCol, nextCol, i, j, tmp;
57 41
58 // initialise previous row 42 // initialise previous row
59 for (i=0; i<prevRow.length; ++i) { 43 for (i=0; i<str2Len; ++i) {
60 prevRow[i] = i; 44 prevRow[i] = i;
45 str2Char[i] = str2.charCodeAt(i);
61 } 46 }
47 prevRow[str2Len] = str2Len;
62 48
63 // calculate current row distance from previous row 49 var strCmp;
64 for (i=0; i<str1.length; ++i) { 50 if (useCollator) {
65 nextCol = i + 1; 51 // calculate current row distance from previous row using collator
52 for (i = 0; i < str1Len; ++i) {
53 nextCol = i + 1;
66 54
67 for (j=0; j<str2.length; ++j) { 55 for (j = 0; j < str2Len; ++j) {
68 curCol = nextCol; 56 curCol = nextCol;
69 57
70 // substution 58 // substution
71 nextCol = prevRow[j] + ( (str1.charAt(i) === str2.charAt(j)) ? 0 : 1 ); 59 strCmp = 0 === collator.compare(str1.charAt(i), String.fromCharCode(str2Char[j]));
72 // insertion
73 tmp = curCol + 1;
74 if (nextCol > tmp) {
75 nextCol = tmp;
76 }
77 // deletion
78 tmp = prevRow[j + 1] + 1;
79 if (nextCol > tmp) {
80 nextCol = tmp;
81 }
82 60
83 // copy current col value into previous (in preparation for next iteration) 61 nextCol = prevRow[j] + (strCmp ? 0 : 1);
84 prevRow[j] = curCol;
85 }
86 62
87 // copy last col value into previous (in preparation for next iteration) 63 // insertion
88 prevRow[j] = nextCol; 64 tmp = curCol + 1;
89 } 65 if (nextCol > tmp) {
66 nextCol = tmp;
67 }
68 // deletion
69 tmp = prevRow[j + 1] + 1;
70 if (nextCol > tmp) {
71 nextCol = tmp;
72 }
90 73
91 return nextCol; 74 // copy current col value into previous (in preparation for next iteration)
92 }, 75 prevRow[j] = curCol;
76 }
93 77
94 /** 78 // copy last col value into previous (in preparation for next iteration)
95 * Asynchronously calculate levenshtein distance of the two strings. 79 prevRow[j] = nextCol;
96 * 80 }
97 * @param str1 String the first string. 81 }
98 * @param str2 String the second string. 82 else {
99 * @param cb Function callback function with signature: function(Error err, int distance) 83 // calculate current row distance from previous row without collator
100 * @param [options] Object additional options. 84 for (i = 0; i < str1Len; ++i) {
101 * @param [options.progress] Function progress callback with signature: function(percentComplete) 85 nextCol = i + 1;
102 */
103 getAsync: function(str1, str2, cb, options) {
104 options = _extend({}, {
105 progress: null
106 }, options);
107 86
108 // base cases 87 for (j = 0; j < str2Len; ++j) {
109 if (str1 === str2) return cb(null, 0); 88 curCol = nextCol;
110 if (str1.length === 0) return cb(null, str2.length);
111 if (str2.length === 0) return cb(null, str1.length);
112 89
113 // two rows 90 // substution
114 var prevRow = new Array(str2.length + 1), 91 strCmp = str1.charCodeAt(i) === str2Char[j];
115 curCol, nextCol,
116 i, j, tmp,
117 startTime, currentTime;
118 92
119 // initialise previous row 93 nextCol = prevRow[j] + (strCmp ? 0 : 1);
120 for (i=0; i<prevRow.length; ++i) {
121 prevRow[i] = i;
122 }
123 94
124 nextCol = 1; 95 // insertion
125 i = 0; 96 tmp = curCol + 1;
126 j = -1; 97 if (nextCol > tmp) {
127 98 nextCol = tmp;
128 var __calculate = function() {
129 // reset timer
130 startTime = new Date().valueOf();
131 currentTime = startTime;
132
133 // keep going until one second has elapsed
134 while (currentTime - startTime < 1000) {
135 // reached end of current row?
136 if (str2.length <= (++j)) {
137 // copy current into previous (in preparation for next iteration)
138 prevRow[j] = nextCol;
139
140 // if already done all chars
141 if (str1.length <= (++i)) {
142 return cb(null, nextCol);
143 } 99 }
144 // else if we have more left to do 100 // deletion
145 else { 101 tmp = prevRow[j + 1] + 1;
146 nextCol = i + 1; 102 if (nextCol > tmp) {
147 j = 0; 103 nextCol = tmp;
148 } 104 }
149 }
150
151 // calculation
152 curCol = nextCol;
153 105
154 // substution 106 // copy current col value into previous (in preparation for next iteration)
155 nextCol = prevRow[j] + ( (str1.charAt(i) === str2.charAt(j)) ? 0 : 1 ); 107 prevRow[j] = curCol;
156 // insertion
157 tmp = curCol + 1;
158 if (nextCol > tmp) {
159 nextCol = tmp;
160 }
161 // deletion
162 tmp = prevRow[j + 1] + 1;
163 if (nextCol > tmp) {
164 nextCol = tmp;
165 } 108 }
166 109
167 // copy current into previous (in preparation for next iteration) 110 // copy last col value into previous (in preparation for next iteration)
168 prevRow[j] = curCol; 111 prevRow[j] = nextCol;
169
170 // get current time
171 currentTime = new Date().valueOf();
172 } 112 }
173 113 }
174 // send a progress update? 114 return nextCol;
175 if (null !== options.progress) {
176 try {
177 options.progress.call(null, (i * 100.0/ str1.length));
178 } catch (err) {
179 return cb('Progress callback: ' + err.toString());
180 }
181 }
182
183 // next iteration
184 _defer(__calculate);
185 };
186
187 __calculate();
188 } 115 }
189 116
190 }; 117 };
diff --git a/src/js/nebulas-account.js b/src/js/nebulas-account.js
new file mode 100644
index 0000000..bded3e9
--- /dev/null
+++ b/src/js/nebulas-account.js
@@ -0,0 +1,27697 @@
1require=(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){
2
3"use strict";
4
5var Buffer = require('safe-buffer').Buffer;
6
7var jsSHA = require('jssha');
8var createKeccakHash = require('keccak');
9var secp256k1 = require('secp256k1');
10var crypto = require('crypto');
11var scrypt = require('scryptsy');
12var RIPEMD160 = require('ripemd160');
13
14var uuid = require('uuid');
15
16var utils = require('./utils.js');
17
18var keccak = function (a, bits) {
19 a = toBuffer(a);
20 if (!bits) bits = 256;
21
22 return createKeccakHash('keccak' + bits).update(a).digest();
23};
24
25var sha3 = function () {
26 var shaObj = new jsSHA("SHA3-256", "HEX");
27 for (var i = 0; i < arguments.length; i++) {
28 var v = toBuffer(arguments[i]);
29 shaObj.update(v.toString("hex"));
30 }
31 return Buffer.from(shaObj.getHash("HEX"), "hex");
32};
33
34var ripemd160 = function () {
35 var ripemd160stream = new RIPEMD160();
36 for (var i = 0; i < arguments.length; i++) {
37 var v = toBuffer(arguments[i]);
38 ripemd160stream.update(v);
39 }
40 return ripemd160stream.digest();
41};
42
43// check if hex string
44var isHexPrefixed = function (str) {
45 if (typeof str !== 'string') {
46 throw new Error("[is-hex-prefixed] value must be type 'string', is currently type " + typeof str + ", while checking isHexPrefixed.");
47 }
48
49 return str.slice(0, 2) === '0x';
50};
51
52// returns hex string without 0x
53var stripHexPrefix = function (str) {
54 if (typeof str !== 'string') {
55 return str;
56 }
57 return isHexPrefixed(str) ? str.slice(2) : str;
58};
59
60function isHexString(value, length) {
61 if (typeof value !== 'string' || !value.match(/^0x[0-9A-Fa-f]*$/)) {
62 return false;
63 }
64
65 if (length && value.length !== 2 + 2 * length) {
66 return false;
67 }
68
69 return true;
70}
71
72// returns hex string from int
73function intToHex(i) {
74 var hex = i.toString(16); // eslint-disable-line
75
76 return '0x' + padToEven(hex);
77}
78
79// returns buffer from int
80function intToBuffer(i) {
81 var hex = intToHex(i);
82
83 return new Buffer(hex.slice(2), 'hex');
84}
85
86// returns a buffer filled with 0
87var zeros = function (bytes) {
88 return Buffer.allocUnsafe(bytes).fill(0);
89};
90
91var padToEven = function (value) {
92 var a = value; // eslint-disable-line
93
94 if (typeof a !== 'string') {
95 throw new Error('padToEven only support string');
96 }
97
98 if (a.length % 2) {
99 a = '0' + a;
100 }
101
102 return a;
103};
104
105// convert value to digit/8 buffer with BigEndian.
106var padToBigEndian = function (value, digit) {
107 value = toBuffer(value);
108 var buff = Buffer.alloc(digit / 8);
109 for (var i = 0; i < value.length; i++) {
110 var start = buff.length - value.length + i;
111 if (start >= 0) {
112 buff[start] = value[i];
113 }
114 }
115 return buff;
116};
117
118// attempts to turn a value to buffer, the input can be buffer, string,number
119var toBuffer = function (v) {
120 /*jshint maxcomplexity:13 */
121 if (!Buffer.isBuffer(v)) {
122 if (Array.isArray(v)) {
123 v = Buffer.from(v);
124 } else if (typeof v === 'string') {
125 if (isHexString(v)) {
126 v = Buffer.from(padToEven(stripHexPrefix(v)), 'hex');
127 } else {
128 v = Buffer.from(v);
129 }
130 } else if (typeof v === 'number') {
131 v = intToBuffer(v);
132 } else if (v === null || v === undefined) {
133 v = Buffer.allocUnsafe(0);
134 } else if (utils.isBigNumber(v)) {
135 // TODO: neb number is a big int, not support if v is decimal, later fix it.
136 v = Buffer.from(padToEven(v.toString(16)), 'hex');
137 } else if (v.toArray) {
138 v = Buffer.from(v.toArray());
139 } else if (v.subarray) {
140 v = Buffer.from(v);
141 } else if (v === null || typeof v === "undefined") {
142 v = Buffer.allocUnsafe(0);
143 } else {
144 throw new Error('invalid type');
145 }
146 }
147 return v;
148};
149
150var bufferToHex = function (buf) {
151 buf = toBuffer(buf);
152 return '0x' + buf.toString('hex');
153};
154
155// convert secp256k1 private key to public key
156var privateToPublic = function (privateKey) {
157 privateKey = toBuffer(privateKey);
158 // skip the type flag and use the X, Y points
159 return secp256k1.publicKeyCreate(privateKey, false).slice(1);
160};
161
162var isValidPublic = function (publicKey, sanitize) {
163 if (publicKey.length === 64) {
164 // Convert to SEC1 for secp256k1
165 return secp256k1.publicKeyVerify(Buffer.concat([Buffer.from([4]), publicKey]));
166 }
167
168 if (!sanitize) {
169 return false;
170 }
171
172 return secp256k1.publicKeyVerify(publicKey);
173};
174
175// sign transaction hash
176var sign = function (msgHash, privateKey) {
177
178 var sig = secp256k1.sign(toBuffer(msgHash), toBuffer(privateKey));
179 // var ret = {}
180 // ret.r = sig.signature.slice(0, 32)
181 // ret.s = sig.signature.slice(32, 64)
182 // ret.v = sig.recovery
183 return Buffer.concat([toBuffer(sig.signature), toBuffer(sig.recovery)]);
184};
185
186var verify = function (message, signature, publicKey) {
187 signature = signature.slice(0, -1); //remove the sig.recovery byte
188 publicKey = Buffer.concat([toBuffer([0x04]), toBuffer(publicKey)]); //add 0x04 before publicKey
189 return secp256k1.verify(toBuffer(message), toBuffer(signature), toBuffer(publicKey));
190};
191
192var recover = function (message, signature, recovery, compressed) {
193 return secp256k1.recover(toBuffer(message), toBuffer(signature), recovery, compressed);
194};
195
196module.exports = {
197 secp256k1: secp256k1,
198 keccak: keccak,
199 sha3: sha3,
200 ripemd160: ripemd160,
201 crypto: crypto,
202 scrypt: scrypt,
203 uuid: uuid,
204
205 zeros: zeros,
206 isHexPrefixed: isHexPrefixed,
207 padToBigEndian: padToBigEndian,
208 toBuffer: toBuffer,
209 bufferToHex: bufferToHex,
210 privateToPublic: privateToPublic,
211 isValidPublic: isValidPublic,
212 sign: sign,
213 verify: verify,
214 recover: recover
215};
216
217},{"./utils.js":2,"crypto":62,"jssha":110,"keccak":111,"ripemd160":155,"safe-buffer":156,"scryptsy":157,"secp256k1":158,"uuid":175}],2:[function(require,module,exports){
218
219"use strict";
220
221var BigNumber = require('bignumber.js');
222
223var isNull = function (v) {
224 return v === null || typeof v === "undefined";
225};
226
227var isBrowser = function () {
228 return typeof window !== "undefined";
229};
230
231var isBigNumber = function (obj) {
232 return obj instanceof BigNumber || obj && obj.constructor && obj.constructor.name === 'BigNumber';
233};
234
235var isString = function (obj) {
236 return typeof obj === 'string' && obj.constructor === String;
237};
238
239var isObject = function (obj) {
240 return obj !== null && typeof obj === 'object';
241};
242
243var isFunction = function (object) {
244 return typeof object === 'function';
245};
246
247var isNumber = function (object) {
248 return typeof object === 'number';
249};
250
251var toBigNumber = function (number) {
252 number = number || 0;
253 if (isBigNumber(number)) {
254 return number;
255 }
256 if (isString(number) && number.indexOf('0x') === 0) {
257 return new BigNumber(number.replace('0x', ''), 16);
258 }
259 return new BigNumber(number.toString(10), 10);
260};
261
262var toString = function (obj) {
263 if (isString(obj)) {
264 return obj;
265 } else if (isBigNumber(obj)) {
266 return obj.toString(10);
267 } else if (isObject(obj)) {
268 return JSON.stringify(obj);
269 } else {
270 return obj + "";
271 }
272};
273
274// Transform Array-like arguments object to common array.
275var argumentsToArray = function (args) {
276 var len = args.length,
277 resultArray = new Array(len);
278
279 for (var i = 0; i < len; i += 1) {
280 resultArray[i] = args[i];
281 }
282 return resultArray;
283};
284
285// Create object based on provided arrays
286var zipArraysToObject = function (keysArr, valuesArr) {
287 var resultObject = {};
288
289 for (var i = 0; i < keysArr.length; i += 1) {
290 resultObject[keysArr[i]] = valuesArr[i];
291 }
292 return resultObject;
293};
294
295// Function what make overall view for arguments.
296// If arguments was provided separated by commas like "func(arg1 ,arg2)" we create
297// ArgumentsObject and write keys from argsNames and value from args.
298// in case wheare we provide args in object like "func({arg1: value})"
299// we just return that object
300var argumentsToObject = function (keys, args) {
301 var ArgumentsObject = {};
302
303 args = argumentsToArray(args);
304 if (isObject(args[0])) {
305 ArgumentsObject = args[0];
306 } else {
307 ArgumentsObject = zipArraysToObject(keys, args);
308 }
309
310 return ArgumentsObject;
311};
312
313module.exports = {
314 isNull: isNull,
315 isBrowser: isBrowser,
316 isBigNumber: isBigNumber,
317 isString: isString,
318 isObject: isObject,
319 isFunction: isFunction,
320 isNumber: isNumber,
321 toBigNumber: toBigNumber,
322 toString: toString,
323 argumentsToObject: argumentsToObject,
324 zipArraysToObject: zipArraysToObject
325};
326
327},{"bignumber.js":19}],3:[function(require,module,exports){
328var asn1 = exports;
329
330asn1.bignum = require('bn.js');
331
332asn1.define = require('./asn1/api').define;
333asn1.base = require('./asn1/base');
334asn1.constants = require('./asn1/constants');
335asn1.decoders = require('./asn1/decoders');
336asn1.encoders = require('./asn1/encoders');
337
338},{"./asn1/api":4,"./asn1/base":6,"./asn1/constants":10,"./asn1/decoders":12,"./asn1/encoders":15,"bn.js":21}],4:[function(require,module,exports){
339var asn1 = require('../asn1');
340var inherits = require('inherits');
341
342var api = exports;
343
344api.define = function define(name, body) {
345 return new Entity(name, body);
346};
347
348function Entity(name, body) {
349 this.name = name;
350 this.body = body;
351
352 this.decoders = {};
353 this.encoders = {};
354};
355
356Entity.prototype._createNamed = function createNamed(base) {
357 var named;
358 try {
359 named = require('vm').runInThisContext(
360 '(function ' + this.name + '(entity) {\n' +
361 ' this._initNamed(entity);\n' +
362 '})'
363 );
364 } catch (e) {
365 named = function (entity) {
366 this._initNamed(entity);
367 };
368 }
369 inherits(named, base);
370 named.prototype._initNamed = function initnamed(entity) {
371 base.call(this, entity);
372 };
373
374 return new named(this);
375};
376
377Entity.prototype._getDecoder = function _getDecoder(enc) {
378 enc = enc || 'der';
379 // Lazily create decoder
380 if (!this.decoders.hasOwnProperty(enc))
381 this.decoders[enc] = this._createNamed(asn1.decoders[enc]);
382 return this.decoders[enc];
383};
384
385Entity.prototype.decode = function decode(data, enc, options) {
386 return this._getDecoder(enc).decode(data, options);
387};
388
389Entity.prototype._getEncoder = function _getEncoder(enc) {
390 enc = enc || 'der';
391 // Lazily create encoder
392 if (!this.encoders.hasOwnProperty(enc))
393 this.encoders[enc] = this._createNamed(asn1.encoders[enc]);
394 return this.encoders[enc];
395};
396
397Entity.prototype.encode = function encode(data, enc, /* internal */ reporter) {
398 return this._getEncoder(enc).encode(data, reporter);
399};
400
401},{"../asn1":3,"inherits":107,"vm":180}],5:[function(require,module,exports){
402var inherits = require('inherits');
403var Reporter = require('../base').Reporter;
404var Buffer = require('buffer').Buffer;
405
406function DecoderBuffer(base, options) {
407 Reporter.call(this, options);
408 if (!Buffer.isBuffer(base)) {
409 this.error('Input not Buffer');
410 return;
411 }
412
413 this.base = base;
414 this.offset = 0;
415 this.length = base.length;
416}
417inherits(DecoderBuffer, Reporter);
418exports.DecoderBuffer = DecoderBuffer;
419
420DecoderBuffer.prototype.save = function save() {
421 return { offset: this.offset, reporter: Reporter.prototype.save.call(this) };
422};
423
424DecoderBuffer.prototype.restore = function restore(save) {
425 // Return skipped data
426 var res = new DecoderBuffer(this.base);
427 res.offset = save.offset;
428 res.length = this.offset;
429
430 this.offset = save.offset;
431 Reporter.prototype.restore.call(this, save.reporter);
432
433 return res;
434};
435
436DecoderBuffer.prototype.isEmpty = function isEmpty() {
437 return this.offset === this.length;
438};
439
440DecoderBuffer.prototype.readUInt8 = function readUInt8(fail) {
441 if (this.offset + 1 <= this.length)
442 return this.base.readUInt8(this.offset++, true);
443 else
444 return this.error(fail || 'DecoderBuffer overrun');
445}
446
447DecoderBuffer.prototype.skip = function skip(bytes, fail) {
448 if (!(this.offset + bytes <= this.length))
449 return this.error(fail || 'DecoderBuffer overrun');
450
451 var res = new DecoderBuffer(this.base);
452
453 // Share reporter state
454 res._reporterState = this._reporterState;
455
456 res.offset = this.offset;
457 res.length = this.offset + bytes;
458 this.offset += bytes;
459 return res;
460}
461
462DecoderBuffer.prototype.raw = function raw(save) {
463 return this.base.slice(save ? save.offset : this.offset, this.length);
464}
465
466function EncoderBuffer(value, reporter) {
467 if (Array.isArray(value)) {
468 this.length = 0;
469 this.value = value.map(function(item) {
470 if (!(item instanceof EncoderBuffer))
471 item = new EncoderBuffer(item, reporter);
472 this.length += item.length;
473 return item;
474 }, this);
475 } else if (typeof value === 'number') {
476 if (!(0 <= value && value <= 0xff))
477 return reporter.error('non-byte EncoderBuffer value');
478 this.value = value;
479 this.length = 1;
480 } else if (typeof value === 'string') {
481 this.value = value;
482 this.length = Buffer.byteLength(value);
483 } else if (Buffer.isBuffer(value)) {
484 this.value = value;
485 this.length = value.length;
486 } else {
487 return reporter.error('Unsupported type: ' + typeof value);
488 }
489}
490exports.EncoderBuffer = EncoderBuffer;
491
492EncoderBuffer.prototype.join = function join(out, offset) {
493 if (!out)
494 out = new Buffer(this.length);
495 if (!offset)
496 offset = 0;
497
498 if (this.length === 0)
499 return out;
500
501 if (Array.isArray(this.value)) {
502 this.value.forEach(function(item) {
503 item.join(out, offset);
504 offset += item.length;
505 });
506 } else {
507 if (typeof this.value === 'number')
508 out[offset] = this.value;
509 else if (typeof this.value === 'string')
510 out.write(this.value, offset);
511 else if (Buffer.isBuffer(this.value))
512 this.value.copy(out, offset);
513 offset += this.length;
514 }
515
516 return out;
517};
518
519},{"../base":6,"buffer":53,"inherits":107}],6:[function(require,module,exports){
520var base = exports;
521
522base.Reporter = require('./reporter').Reporter;
523base.DecoderBuffer = require('./buffer').DecoderBuffer;
524base.EncoderBuffer = require('./buffer').EncoderBuffer;
525base.Node = require('./node');
526
527},{"./buffer":5,"./node":7,"./reporter":8}],7:[function(require,module,exports){
528var Reporter = require('../base').Reporter;
529var EncoderBuffer = require('../base').EncoderBuffer;
530var DecoderBuffer = require('../base').DecoderBuffer;
531var assert = require('minimalistic-assert');
532
533// Supported tags
534var tags = [
535 'seq', 'seqof', 'set', 'setof', 'objid', 'bool',
536 'gentime', 'utctime', 'null_', 'enum', 'int', 'objDesc',
537 'bitstr', 'bmpstr', 'charstr', 'genstr', 'graphstr', 'ia5str', 'iso646str',
538 'numstr', 'octstr', 'printstr', 't61str', 'unistr', 'utf8str', 'videostr'
539];
540
541// Public methods list
542var methods = [
543 'key', 'obj', 'use', 'optional', 'explicit', 'implicit', 'def', 'choice',
544 'any', 'contains'
545].concat(tags);
546
547// Overrided methods list
548var overrided = [
549 '_peekTag', '_decodeTag', '_use',
550 '_decodeStr', '_decodeObjid', '_decodeTime',
551 '_decodeNull', '_decodeInt', '_decodeBool', '_decodeList',
552
553 '_encodeComposite', '_encodeStr', '_encodeObjid', '_encodeTime',
554 '_encodeNull', '_encodeInt', '_encodeBool'
555];
556
557function Node(enc, parent) {
558 var state = {};
559 this._baseState = state;
560
561 state.enc = enc;
562
563 state.parent = parent || null;
564 state.children = null;
565
566 // State
567 state.tag = null;
568 state.args = null;
569 state.reverseArgs = null;
570 state.choice = null;
571 state.optional = false;
572 state.any = false;
573 state.obj = false;
574 state.use = null;
575 state.useDecoder = null;
576 state.key = null;
577 state['default'] = null;
578 state.explicit = null;
579 state.implicit = null;
580 state.contains = null;
581
582 // Should create new instance on each method
583 if (!state.parent) {
584 state.children = [];
585 this._wrap();
586 }
587}
588module.exports = Node;
589
590var stateProps = [
591 'enc', 'parent', 'children', 'tag', 'args', 'reverseArgs', 'choice',
592 'optional', 'any', 'obj', 'use', 'alteredUse', 'key', 'default', 'explicit',
593 'implicit', 'contains'
594];
595
596Node.prototype.clone = function clone() {
597 var state = this._baseState;
598 var cstate = {};
599 stateProps.forEach(function(prop) {
600 cstate[prop] = state[prop];
601 });
602 var res = new this.constructor(cstate.parent);
603 res._baseState = cstate;
604 return res;
605};
606
607Node.prototype._wrap = function wrap() {
608 var state = this._baseState;
609 methods.forEach(function(method) {
610 this[method] = function _wrappedMethod() {
611 var clone = new this.constructor(this);
612 state.children.push(clone);
613 return clone[method].apply(clone, arguments);
614 };
615 }, this);
616};
617
618Node.prototype._init = function init(body) {
619 var state = this._baseState;
620
621 assert(state.parent === null);
622 body.call(this);
623
624 // Filter children
625 state.children = state.children.filter(function(child) {
626 return child._baseState.parent === this;
627 }, this);
628 assert.equal(state.children.length, 1, 'Root node can have only one child');
629};
630
631Node.prototype._useArgs = function useArgs(args) {
632 var state = this._baseState;
633
634 // Filter children and args
635 var children = args.filter(function(arg) {
636 return arg instanceof this.constructor;
637 }, this);
638 args = args.filter(function(arg) {
639 return !(arg instanceof this.constructor);
640 }, this);
641
642 if (children.length !== 0) {
643 assert(state.children === null);
644 state.children = children;
645
646 // Replace parent to maintain backward link
647 children.forEach(function(child) {
648 child._baseState.parent = this;
649 }, this);
650 }
651 if (args.length !== 0) {
652 assert(state.args === null);
653 state.args = args;
654 state.reverseArgs = args.map(function(arg) {
655 if (typeof arg !== 'object' || arg.constructor !== Object)
656 return arg;
657
658 var res = {};
659 Object.keys(arg).forEach(function(key) {
660 if (key == (key | 0))
661 key |= 0;
662 var value = arg[key];
663 res[value] = key;
664 });
665 return res;
666 });
667 }
668};
669
670//
671// Overrided methods
672//
673
674overrided.forEach(function(method) {
675 Node.prototype[method] = function _overrided() {
676 var state = this._baseState;
677 throw new Error(method + ' not implemented for encoding: ' + state.enc);
678 };
679});
680
681//
682// Public methods
683//
684
685tags.forEach(function(tag) {
686 Node.prototype[tag] = function _tagMethod() {
687 var state = this._baseState;
688 var args = Array.prototype.slice.call(arguments);
689
690 assert(state.tag === null);
691 state.tag = tag;
692
693 this._useArgs(args);
694
695 return this;
696 };
697});
698
699Node.prototype.use = function use(item) {
700 assert(item);
701 var state = this._baseState;
702
703 assert(state.use === null);
704 state.use = item;
705
706 return this;
707};
708
709Node.prototype.optional = function optional() {
710 var state = this._baseState;
711
712 state.optional = true;
713
714 return this;
715};
716
717Node.prototype.def = function def(val) {
718 var state = this._baseState;
719
720 assert(state['default'] === null);
721 state['default'] = val;
722 state.optional = true;
723
724 return this;
725};
726
727Node.prototype.explicit = function explicit(num) {
728 var state = this._baseState;
729
730 assert(state.explicit === null && state.implicit === null);
731 state.explicit = num;
732
733 return this;
734};
735
736Node.prototype.implicit = function implicit(num) {
737 var state = this._baseState;
738
739 assert(state.explicit === null && state.implicit === null);
740 state.implicit = num;
741
742 return this;
743};
744
745Node.prototype.obj = function obj() {
746 var state = this._baseState;
747 var args = Array.prototype.slice.call(arguments);
748
749 state.obj = true;
750
751 if (args.length !== 0)
752 this._useArgs(args);
753
754 return this;
755};
756
757Node.prototype.key = function key(newKey) {
758 var state = this._baseState;
759
760 assert(state.key === null);
761 state.key = newKey;
762
763 return this;
764};
765
766Node.prototype.any = function any() {
767 var state = this._baseState;
768
769 state.any = true;
770
771 return this;
772};
773
774Node.prototype.choice = function choice(obj) {
775 var state = this._baseState;
776
777 assert(state.choice === null);
778 state.choice = obj;
779 this._useArgs(Object.keys(obj).map(function(key) {
780 return obj[key];
781 }));
782
783 return this;
784};
785
786Node.prototype.contains = function contains(item) {
787 var state = this._baseState;
788
789 assert(state.use === null);
790 state.contains = item;
791
792 return this;
793};
794
795//
796// Decoding
797//
798
799Node.prototype._decode = function decode(input, options) {
800 var state = this._baseState;
801
802 // Decode root node
803 if (state.parent === null)
804 return input.wrapResult(state.children[0]._decode(input, options));
805
806 var result = state['default'];
807 var present = true;
808
809 var prevKey = null;
810 if (state.key !== null)
811 prevKey = input.enterKey(state.key);
812
813 // Check if tag is there
814 if (state.optional) {
815 var tag = null;
816 if (state.explicit !== null)
817 tag = state.explicit;
818 else if (state.implicit !== null)
819 tag = state.implicit;
820 else if (state.tag !== null)
821 tag = state.tag;
822
823 if (tag === null && !state.any) {
824 // Trial and Error
825 var save = input.save();
826 try {
827 if (state.choice === null)
828 this._decodeGeneric(state.tag, input, options);
829 else
830 this._decodeChoice(input, options);
831 present = true;
832 } catch (e) {
833 present = false;
834 }
835 input.restore(save);
836 } else {
837 present = this._peekTag(input, tag, state.any);
838
839 if (input.isError(present))
840 return present;
841 }
842 }
843
844 // Push object on stack
845 var prevObj;
846 if (state.obj && present)
847 prevObj = input.enterObject();
848
849 if (present) {
850 // Unwrap explicit values
851 if (state.explicit !== null) {
852 var explicit = this._decodeTag(input, state.explicit);
853 if (input.isError(explicit))
854 return explicit;
855 input = explicit;
856 }
857
858 var start = input.offset;
859
860 // Unwrap implicit and normal values
861 if (state.use === null && state.choice === null) {
862 if (state.any)
863 var save = input.save();
864 var body = this._decodeTag(
865 input,
866 state.implicit !== null ? state.implicit : state.tag,
867 state.any
868 );
869 if (input.isError(body))
870 return body;
871
872 if (state.any)
873 result = input.raw(save);
874 else
875 input = body;
876 }
877
878 if (options && options.track && state.tag !== null)
879 options.track(input.path(), start, input.length, 'tagged');
880
881 if (options && options.track && state.tag !== null)
882 options.track(input.path(), input.offset, input.length, 'content');
883
884 // Select proper method for tag
885 if (state.any)
886 result = result;
887 else if (state.choice === null)
888 result = this._decodeGeneric(state.tag, input, options);
889 else
890 result = this._decodeChoice(input, options);
891
892 if (input.isError(result))
893 return result;
894
895 // Decode children
896 if (!state.any && state.choice === null && state.children !== null) {
897 state.children.forEach(function decodeChildren(child) {
898 // NOTE: We are ignoring errors here, to let parser continue with other
899 // parts of encoded data
900 child._decode(input, options);
901 });
902 }
903
904 // Decode contained/encoded by schema, only in bit or octet strings
905 if (state.contains && (state.tag === 'octstr' || state.tag === 'bitstr')) {
906 var data = new DecoderBuffer(result);
907 result = this._getUse(state.contains, input._reporterState.obj)
908 ._decode(data, options);
909 }
910 }
911
912 // Pop object
913 if (state.obj && present)
914 result = input.leaveObject(prevObj);
915
916 // Set key
917 if (state.key !== null && (result !== null || present === true))
918 input.leaveKey(prevKey, state.key, result);
919 else if (prevKey !== null)
920 input.exitKey(prevKey);
921
922 return result;
923};
924
925Node.prototype._decodeGeneric = function decodeGeneric(tag, input, options) {
926 var state = this._baseState;
927
928 if (tag === 'seq' || tag === 'set')
929 return null;
930 if (tag === 'seqof' || tag === 'setof')
931 return this._decodeList(input, tag, state.args[0], options);
932 else if (/str$/.test(tag))
933 return this._decodeStr(input, tag, options);
934 else if (tag === 'objid' && state.args)
935 return this._decodeObjid(input, state.args[0], state.args[1], options);
936 else if (tag === 'objid')
937 return this._decodeObjid(input, null, null, options);
938 else if (tag === 'gentime' || tag === 'utctime')
939 return this._decodeTime(input, tag, options);
940 else if (tag === 'null_')
941 return this._decodeNull(input, options);
942 else if (tag === 'bool')
943 return this._decodeBool(input, options);
944 else if (tag === 'objDesc')
945 return this._decodeStr(input, tag, options);
946 else if (tag === 'int' || tag === 'enum')
947 return this._decodeInt(input, state.args && state.args[0], options);
948
949 if (state.use !== null) {
950 return this._getUse(state.use, input._reporterState.obj)
951 ._decode(input, options);
952 } else {
953 return input.error('unknown tag: ' + tag);
954 }
955};
956
957Node.prototype._getUse = function _getUse(entity, obj) {
958
959 var state = this._baseState;
960 // Create altered use decoder if implicit is set
961 state.useDecoder = this._use(entity, obj);
962 assert(state.useDecoder._baseState.parent === null);
963 state.useDecoder = state.useDecoder._baseState.children[0];
964 if (state.implicit !== state.useDecoder._baseState.implicit) {
965 state.useDecoder = state.useDecoder.clone();
966 state.useDecoder._baseState.implicit = state.implicit;
967 }
968 return state.useDecoder;
969};
970
971Node.prototype._decodeChoice = function decodeChoice(input, options) {
972 var state = this._baseState;
973 var result = null;
974 var match = false;
975
976 Object.keys(state.choice).some(function(key) {
977 var save = input.save();
978 var node = state.choice[key];
979 try {
980 var value = node._decode(input, options);
981 if (input.isError(value))
982 return false;
983
984 result = { type: key, value: value };
985 match = true;
986 } catch (e) {
987 input.restore(save);
988 return false;
989 }
990 return true;
991 }, this);
992
993 if (!match)
994 return input.error('Choice not matched');
995
996 return result;
997};
998
999//
1000// Encoding
1001//
1002
1003Node.prototype._createEncoderBuffer = function createEncoderBuffer(data) {
1004 return new EncoderBuffer(data, this.reporter);
1005};
1006
1007Node.prototype._encode = function encode(data, reporter, parent) {
1008 var state = this._baseState;
1009 if (state['default'] !== null && state['default'] === data)
1010 return;
1011
1012 var result = this._encodeValue(data, reporter, parent);
1013 if (result === undefined)
1014 return;
1015
1016 if (this._skipDefault(result, reporter, parent))
1017 return;
1018
1019 return result;
1020};
1021
1022Node.prototype._encodeValue = function encode(data, reporter, parent) {
1023 var state = this._baseState;
1024
1025 // Decode root node
1026 if (state.parent === null)
1027 return state.children[0]._encode(data, reporter || new Reporter());
1028
1029 var result = null;
1030
1031 // Set reporter to share it with a child class
1032 this.reporter = reporter;
1033
1034 // Check if data is there
1035 if (state.optional && data === undefined) {
1036 if (state['default'] !== null)
1037 data = state['default']
1038 else
1039 return;
1040 }
1041
1042 // Encode children first
1043 var content = null;
1044 var primitive = false;
1045 if (state.any) {
1046 // Anything that was given is translated to buffer
1047 result = this._createEncoderBuffer(data);
1048 } else if (state.choice) {
1049 result = this._encodeChoice(data, reporter);
1050 } else if (state.contains) {
1051 content = this._getUse(state.contains, parent)._encode(data, reporter);
1052 primitive = true;
1053 } else if (state.children) {
1054 content = state.children.map(function(child) {
1055 if (child._baseState.tag === 'null_')
1056 return child._encode(null, reporter, data);
1057
1058 if (child._baseState.key === null)
1059 return reporter.error('Child should have a key');
1060 var prevKey = reporter.enterKey(child._baseState.key);
1061
1062 if (typeof data !== 'object')
1063 return reporter.error('Child expected, but input is not object');
1064
1065 var res = child._encode(data[child._baseState.key], reporter, data);
1066 reporter.leaveKey(prevKey);
1067
1068 return res;
1069 }, this).filter(function(child) {
1070 return child;
1071 });
1072 content = this._createEncoderBuffer(content);
1073 } else {
1074 if (state.tag === 'seqof' || state.tag === 'setof') {
1075 // TODO(indutny): this should be thrown on DSL level
1076 if (!(state.args && state.args.length === 1))
1077 return reporter.error('Too many args for : ' + state.tag);
1078
1079 if (!Array.isArray(data))
1080 return reporter.error('seqof/setof, but data is not Array');
1081
1082 var child = this.clone();
1083 child._baseState.implicit = null;
1084 content = this._createEncoderBuffer(data.map(function(item) {
1085 var state = this._baseState;
1086
1087 return this._getUse(state.args[0], data)._encode(item, reporter);
1088 }, child));
1089 } else if (state.use !== null) {
1090 result = this._getUse(state.use, parent)._encode(data, reporter);
1091 } else {
1092 content = this._encodePrimitive(state.tag, data);
1093 primitive = true;
1094 }
1095 }
1096
1097 // Encode data itself
1098 var result;
1099 if (!state.any && state.choice === null) {
1100 var tag = state.implicit !== null ? state.implicit : state.tag;
1101 var cls = state.implicit === null ? 'universal' : 'context';
1102
1103 if (tag === null) {
1104 if (state.use === null)
1105 reporter.error('Tag could be omitted only for .use()');
1106 } else {
1107 if (state.use === null)
1108 result = this._encodeComposite(tag, primitive, cls, content);
1109 }
1110 }
1111
1112 // Wrap in explicit
1113 if (state.explicit !== null)
1114 result = this._encodeComposite(state.explicit, false, 'context', result);
1115
1116 return result;
1117};
1118
1119Node.prototype._encodeChoice = function encodeChoice(data, reporter) {
1120 var state = this._baseState;
1121
1122 var node = state.choice[data.type];
1123 if (!node) {
1124 assert(
1125 false,
1126 data.type + ' not found in ' +
1127 JSON.stringify(Object.keys(state.choice)));
1128 }
1129 return node._encode(data.value, reporter);
1130};
1131
1132Node.prototype._encodePrimitive = function encodePrimitive(tag, data) {
1133 var state = this._baseState;
1134
1135 if (/str$/.test(tag))
1136 return this._encodeStr(data, tag);
1137 else if (tag === 'objid' && state.args)
1138 return this._encodeObjid(data, state.reverseArgs[0], state.args[1]);
1139 else if (tag === 'objid')
1140 return this._encodeObjid(data, null, null);
1141 else if (tag === 'gentime' || tag === 'utctime')
1142 return this._encodeTime(data, tag);
1143 else if (tag === 'null_')
1144 return this._encodeNull();
1145 else if (tag === 'int' || tag === 'enum')
1146 return this._encodeInt(data, state.args && state.reverseArgs[0]);
1147 else if (tag === 'bool')
1148 return this._encodeBool(data);
1149 else if (tag === 'objDesc')
1150 return this._encodeStr(data, tag);
1151 else
1152 throw new Error('Unsupported tag: ' + tag);
1153};
1154
1155Node.prototype._isNumstr = function isNumstr(str) {
1156 return /^[0-9 ]*$/.test(str);
1157};
1158
1159Node.prototype._isPrintstr = function isPrintstr(str) {
1160 return /^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(str);
1161};
1162
1163},{"../base":6,"minimalistic-assert":120}],8:[function(require,module,exports){
1164var inherits = require('inherits');
1165
1166function Reporter(options) {
1167 this._reporterState = {
1168 obj: null,
1169 path: [],
1170 options: options || {},
1171 errors: []
1172 };
1173}
1174exports.Reporter = Reporter;
1175
1176Reporter.prototype.isError = function isError(obj) {
1177 return obj instanceof ReporterError;
1178};
1179
1180Reporter.prototype.save = function save() {
1181 var state = this._reporterState;
1182
1183 return { obj: state.obj, pathLen: state.path.length };
1184};
1185
1186Reporter.prototype.restore = function restore(data) {
1187 var state = this._reporterState;
1188
1189 state.obj = data.obj;
1190 state.path = state.path.slice(0, data.pathLen);
1191};
1192
1193Reporter.prototype.enterKey = function enterKey(key) {
1194 return this._reporterState.path.push(key);
1195};
1196
1197Reporter.prototype.exitKey = function exitKey(index) {
1198 var state = this._reporterState;
1199
1200 state.path = state.path.slice(0, index - 1);
1201};
1202
1203Reporter.prototype.leaveKey = function leaveKey(index, key, value) {
1204 var state = this._reporterState;
1205
1206 this.exitKey(index);
1207 if (state.obj !== null)
1208 state.obj[key] = value;
1209};
1210
1211Reporter.prototype.path = function path() {
1212 return this._reporterState.path.join('/');
1213};
1214
1215Reporter.prototype.enterObject = function enterObject() {
1216 var state = this._reporterState;
1217
1218 var prev = state.obj;
1219 state.obj = {};
1220 return prev;
1221};
1222
1223Reporter.prototype.leaveObject = function leaveObject(prev) {
1224 var state = this._reporterState;
1225
1226 var now = state.obj;
1227 state.obj = prev;
1228 return now;
1229};
1230
1231Reporter.prototype.error = function error(msg) {
1232 var err;
1233 var state = this._reporterState;
1234
1235 var inherited = msg instanceof ReporterError;
1236 if (inherited) {
1237 err = msg;
1238 } else {
1239 err = new ReporterError(state.path.map(function(elem) {
1240 return '[' + JSON.stringify(elem) + ']';
1241 }).join(''), msg.message || msg, msg.stack);
1242 }
1243
1244 if (!state.options.partial)
1245 throw err;
1246
1247 if (!inherited)
1248 state.errors.push(err);
1249
1250 return err;
1251};
1252
1253Reporter.prototype.wrapResult = function wrapResult(result) {
1254 var state = this._reporterState;
1255 if (!state.options.partial)
1256 return result;
1257
1258 return {
1259 result: this.isError(result) ? null : result,
1260 errors: state.errors
1261 };
1262};
1263
1264function ReporterError(path, msg) {
1265 this.path = path;
1266 this.rethrow(msg);
1267};
1268inherits(ReporterError, Error);
1269
1270ReporterError.prototype.rethrow = function rethrow(msg) {
1271 this.message = msg + ' at: ' + (this.path || '(shallow)');
1272 if (Error.captureStackTrace)
1273 Error.captureStackTrace(this, ReporterError);
1274
1275 if (!this.stack) {
1276 try {
1277 // IE only adds stack when thrown
1278 throw new Error(this.message);
1279 } catch (e) {
1280 this.stack = e.stack;
1281 }
1282 }
1283 return this;
1284};
1285
1286},{"inherits":107}],9:[function(require,module,exports){
1287var constants = require('../constants');
1288
1289exports.tagClass = {
1290 0: 'universal',
1291 1: 'application',
1292 2: 'context',
1293 3: 'private'
1294};
1295exports.tagClassByName = constants._reverse(exports.tagClass);
1296
1297exports.tag = {
1298 0x00: 'end',
1299 0x01: 'bool',
1300 0x02: 'int',
1301 0x03: 'bitstr',
1302 0x04: 'octstr',
1303 0x05: 'null_',
1304 0x06: 'objid',
1305 0x07: 'objDesc',
1306 0x08: 'external',
1307 0x09: 'real',
1308 0x0a: 'enum',
1309 0x0b: 'embed',
1310 0x0c: 'utf8str',
1311 0x0d: 'relativeOid',
1312 0x10: 'seq',
1313 0x11: 'set',
1314 0x12: 'numstr',
1315 0x13: 'printstr',
1316 0x14: 't61str',
1317 0x15: 'videostr',
1318 0x16: 'ia5str',
1319 0x17: 'utctime',
1320 0x18: 'gentime',
1321 0x19: 'graphstr',
1322 0x1a: 'iso646str',
1323 0x1b: 'genstr',
1324 0x1c: 'unistr',
1325 0x1d: 'charstr',
1326 0x1e: 'bmpstr'
1327};
1328exports.tagByName = constants._reverse(exports.tag);
1329
1330},{"../constants":10}],10:[function(require,module,exports){
1331var constants = exports;
1332
1333// Helper
1334constants._reverse = function reverse(map) {
1335 var res = {};
1336
1337 Object.keys(map).forEach(function(key) {
1338 // Convert key to integer if it is stringified
1339 if ((key | 0) == key)
1340 key = key | 0;
1341
1342 var value = map[key];
1343 res[value] = key;
1344 });
1345
1346 return res;
1347};
1348
1349constants.der = require('./der');
1350
1351},{"./der":9}],11:[function(require,module,exports){
1352var inherits = require('inherits');
1353
1354var asn1 = require('../../asn1');
1355var base = asn1.base;
1356var bignum = asn1.bignum;
1357
1358// Import DER constants
1359var der = asn1.constants.der;
1360
1361function DERDecoder(entity) {
1362 this.enc = 'der';
1363 this.name = entity.name;
1364 this.entity = entity;
1365
1366 // Construct base tree
1367 this.tree = new DERNode();
1368 this.tree._init(entity.body);
1369};
1370module.exports = DERDecoder;
1371
1372DERDecoder.prototype.decode = function decode(data, options) {
1373 if (!(data instanceof base.DecoderBuffer))
1374 data = new base.DecoderBuffer(data, options);
1375
1376 return this.tree._decode(data, options);
1377};
1378
1379// Tree methods
1380
1381function DERNode(parent) {
1382 base.Node.call(this, 'der', parent);
1383}
1384inherits(DERNode, base.Node);
1385
1386DERNode.prototype._peekTag = function peekTag(buffer, tag, any) {
1387 if (buffer.isEmpty())
1388 return false;
1389
1390 var state = buffer.save();
1391 var decodedTag = derDecodeTag(buffer, 'Failed to peek tag: "' + tag + '"');
1392 if (buffer.isError(decodedTag))
1393 return decodedTag;
1394
1395 buffer.restore(state);
1396
1397 return decodedTag.tag === tag || decodedTag.tagStr === tag ||
1398 (decodedTag.tagStr + 'of') === tag || any;
1399};
1400
1401DERNode.prototype._decodeTag = function decodeTag(buffer, tag, any) {
1402 var decodedTag = derDecodeTag(buffer,
1403 'Failed to decode tag of "' + tag + '"');
1404 if (buffer.isError(decodedTag))
1405 return decodedTag;
1406
1407 var len = derDecodeLen(buffer,
1408 decodedTag.primitive,
1409 'Failed to get length of "' + tag + '"');
1410
1411 // Failure
1412 if (buffer.isError(len))
1413 return len;
1414
1415 if (!any &&
1416 decodedTag.tag !== tag &&
1417 decodedTag.tagStr !== tag &&
1418 decodedTag.tagStr + 'of' !== tag) {
1419 return buffer.error('Failed to match tag: "' + tag + '"');
1420 }
1421
1422 if (decodedTag.primitive || len !== null)
1423 return buffer.skip(len, 'Failed to match body of: "' + tag + '"');
1424
1425 // Indefinite length... find END tag
1426 var state = buffer.save();
1427 var res = this._skipUntilEnd(
1428 buffer,
1429 'Failed to skip indefinite length body: "' + this.tag + '"');
1430 if (buffer.isError(res))
1431 return res;
1432
1433 len = buffer.offset - state.offset;
1434 buffer.restore(state);
1435 return buffer.skip(len, 'Failed to match body of: "' + tag + '"');
1436};
1437
1438DERNode.prototype._skipUntilEnd = function skipUntilEnd(buffer, fail) {
1439 while (true) {
1440 var tag = derDecodeTag(buffer, fail);
1441 if (buffer.isError(tag))
1442 return tag;
1443 var len = derDecodeLen(buffer, tag.primitive, fail);
1444 if (buffer.isError(len))
1445 return len;
1446
1447 var res;
1448 if (tag.primitive || len !== null)
1449 res = buffer.skip(len)
1450 else
1451 res = this._skipUntilEnd(buffer, fail);
1452
1453 // Failure
1454 if (buffer.isError(res))
1455 return res;
1456
1457 if (tag.tagStr === 'end')
1458 break;
1459 }
1460};
1461
1462DERNode.prototype._decodeList = function decodeList(buffer, tag, decoder,
1463 options) {
1464 var result = [];
1465 while (!buffer.isEmpty()) {
1466 var possibleEnd = this._peekTag(buffer, 'end');
1467 if (buffer.isError(possibleEnd))
1468 return possibleEnd;
1469
1470 var res = decoder.decode(buffer, 'der', options);
1471 if (buffer.isError(res) && possibleEnd)
1472 break;
1473 result.push(res);
1474 }
1475 return result;
1476};
1477
1478DERNode.prototype._decodeStr = function decodeStr(buffer, tag) {
1479 if (tag === 'bitstr') {
1480 var unused = buffer.readUInt8();
1481 if (buffer.isError(unused))
1482 return unused;
1483 return { unused: unused, data: buffer.raw() };
1484 } else if (tag === 'bmpstr') {
1485 var raw = buffer.raw();
1486 if (raw.length % 2 === 1)
1487 return buffer.error('Decoding of string type: bmpstr length mismatch');
1488
1489 var str = '';
1490 for (var i = 0; i < raw.length / 2; i++) {
1491 str += String.fromCharCode(raw.readUInt16BE(i * 2));
1492 }
1493 return str;
1494 } else if (tag === 'numstr') {
1495 var numstr = buffer.raw().toString('ascii');
1496 if (!this._isNumstr(numstr)) {
1497 return buffer.error('Decoding of string type: ' +
1498 'numstr unsupported characters');
1499 }
1500 return numstr;
1501 } else if (tag === 'octstr') {
1502 return buffer.raw();
1503 } else if (tag === 'objDesc') {
1504 return buffer.raw();
1505 } else if (tag === 'printstr') {
1506 var printstr = buffer.raw().toString('ascii');
1507 if (!this._isPrintstr(printstr)) {
1508 return buffer.error('Decoding of string type: ' +
1509 'printstr unsupported characters');
1510 }
1511 return printstr;
1512 } else if (/str$/.test(tag)) {
1513 return buffer.raw().toString();
1514 } else {
1515 return buffer.error('Decoding of string type: ' + tag + ' unsupported');
1516 }
1517};
1518
1519DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) {
1520 var result;
1521 var identifiers = [];
1522 var ident = 0;
1523 while (!buffer.isEmpty()) {
1524 var subident = buffer.readUInt8();
1525 ident <<= 7;
1526 ident |= subident & 0x7f;
1527 if ((subident & 0x80) === 0) {
1528 identifiers.push(ident);
1529 ident = 0;
1530 }
1531 }
1532 if (subident & 0x80)
1533 identifiers.push(ident);
1534
1535 var first = (identifiers[0] / 40) | 0;
1536 var second = identifiers[0] % 40;
1537
1538 if (relative)
1539 result = identifiers;
1540 else
1541 result = [first, second].concat(identifiers.slice(1));
1542
1543 if (values) {
1544 var tmp = values[result.join(' ')];
1545 if (tmp === undefined)
1546 tmp = values[result.join('.')];
1547 if (tmp !== undefined)
1548 result = tmp;
1549 }
1550
1551 return result;
1552};
1553
1554DERNode.prototype._decodeTime = function decodeTime(buffer, tag) {
1555 var str = buffer.raw().toString();
1556 if (tag === 'gentime') {
1557 var year = str.slice(0, 4) | 0;
1558 var mon = str.slice(4, 6) | 0;
1559 var day = str.slice(6, 8) | 0;
1560 var hour = str.slice(8, 10) | 0;
1561 var min = str.slice(10, 12) | 0;
1562 var sec = str.slice(12, 14) | 0;
1563 } else if (tag === 'utctime') {
1564 var year = str.slice(0, 2) | 0;
1565 var mon = str.slice(2, 4) | 0;
1566 var day = str.slice(4, 6) | 0;
1567 var hour = str.slice(6, 8) | 0;
1568 var min = str.slice(8, 10) | 0;
1569 var sec = str.slice(10, 12) | 0;
1570 if (year < 70)
1571 year = 2000 + year;
1572 else
1573 year = 1900 + year;
1574 } else {
1575 return buffer.error('Decoding ' + tag + ' time is not supported yet');
1576 }
1577
1578 return Date.UTC(year, mon - 1, day, hour, min, sec, 0);
1579};
1580
1581DERNode.prototype._decodeNull = function decodeNull(buffer) {
1582 return null;
1583};
1584
1585DERNode.prototype._decodeBool = function decodeBool(buffer) {
1586 var res = buffer.readUInt8();
1587 if (buffer.isError(res))
1588 return res;
1589 else
1590 return res !== 0;
1591};
1592
1593DERNode.prototype._decodeInt = function decodeInt(buffer, values) {
1594 // Bigint, return as it is (assume big endian)
1595 var raw = buffer.raw();
1596 var res = new bignum(raw);
1597
1598 if (values)
1599 res = values[res.toString(10)] || res;
1600
1601 return res;
1602};
1603
1604DERNode.prototype._use = function use(entity, obj) {
1605 if (typeof entity === 'function')
1606 entity = entity(obj);
1607 return entity._getDecoder('der').tree;
1608};
1609
1610// Utility methods
1611
1612function derDecodeTag(buf, fail) {
1613 var tag = buf.readUInt8(fail);
1614 if (buf.isError(tag))
1615 return tag;
1616
1617 var cls = der.tagClass[tag >> 6];
1618 var primitive = (tag & 0x20) === 0;
1619
1620 // Multi-octet tag - load
1621 if ((tag & 0x1f) === 0x1f) {
1622 var oct = tag;
1623 tag = 0;
1624 while ((oct & 0x80) === 0x80) {
1625 oct = buf.readUInt8(fail);
1626 if (buf.isError(oct))
1627 return oct;
1628
1629 tag <<= 7;
1630 tag |= oct & 0x7f;
1631 }
1632 } else {
1633 tag &= 0x1f;
1634 }
1635 var tagStr = der.tag[tag];
1636
1637 return {
1638 cls: cls,
1639 primitive: primitive,
1640 tag: tag,
1641 tagStr: tagStr
1642 };
1643}
1644
1645function derDecodeLen(buf, primitive, fail) {
1646 var len = buf.readUInt8(fail);
1647 if (buf.isError(len))
1648 return len;
1649
1650 // Indefinite form
1651 if (!primitive && len === 0x80)
1652 return null;
1653
1654 // Definite form
1655 if ((len & 0x80) === 0) {
1656 // Short form
1657 return len;
1658 }
1659
1660 // Long form
1661 var num = len & 0x7f;
1662 if (num > 4)
1663 return buf.error('length octect is too long');
1664
1665 len = 0;
1666 for (var i = 0; i < num; i++) {
1667 len <<= 8;
1668 var j = buf.readUInt8(fail);
1669 if (buf.isError(j))
1670 return j;
1671 len |= j;
1672 }
1673
1674 return len;
1675}
1676
1677},{"../../asn1":3,"inherits":107}],12:[function(require,module,exports){
1678var decoders = exports;
1679
1680decoders.der = require('./der');
1681decoders.pem = require('./pem');
1682
1683},{"./der":11,"./pem":13}],13:[function(require,module,exports){
1684var inherits = require('inherits');
1685var Buffer = require('buffer').Buffer;
1686
1687var DERDecoder = require('./der');
1688
1689function PEMDecoder(entity) {
1690 DERDecoder.call(this, entity);
1691 this.enc = 'pem';
1692};
1693inherits(PEMDecoder, DERDecoder);
1694module.exports = PEMDecoder;
1695
1696PEMDecoder.prototype.decode = function decode(data, options) {
1697 var lines = data.toString().split(/[\r\n]+/g);
1698
1699 var label = options.label.toUpperCase();
1700
1701 var re = /^-----(BEGIN|END) ([^-]+)-----$/;
1702 var start = -1;
1703 var end = -1;
1704 for (var i = 0; i < lines.length; i++) {
1705 var match = lines[i].match(re);
1706 if (match === null)
1707 continue;
1708
1709 if (match[2] !== label)
1710 continue;
1711
1712 if (start === -1) {
1713 if (match[1] !== 'BEGIN')
1714 break;
1715 start = i;
1716 } else {
1717 if (match[1] !== 'END')
1718 break;
1719 end = i;
1720 break;
1721 }
1722 }
1723 if (start === -1 || end === -1)
1724 throw new Error('PEM section not found for: ' + label);
1725
1726 var base64 = lines.slice(start + 1, end).join('');
1727 // Remove excessive symbols
1728 base64.replace(/[^a-z0-9\+\/=]+/gi, '');
1729
1730 var input = new Buffer(base64, 'base64');
1731 return DERDecoder.prototype.decode.call(this, input, options);
1732};
1733
1734},{"./der":11,"buffer":53,"inherits":107}],14:[function(require,module,exports){
1735var inherits = require('inherits');
1736var Buffer = require('buffer').Buffer;
1737
1738var asn1 = require('../../asn1');
1739var base = asn1.base;
1740
1741// Import DER constants
1742var der = asn1.constants.der;
1743
1744function DEREncoder(entity) {
1745 this.enc = 'der';
1746 this.name = entity.name;
1747 this.entity = entity;
1748
1749 // Construct base tree
1750 this.tree = new DERNode();
1751 this.tree._init(entity.body);
1752};
1753module.exports = DEREncoder;
1754
1755DEREncoder.prototype.encode = function encode(data, reporter) {
1756 return this.tree._encode(data, reporter).join();
1757};
1758
1759// Tree methods
1760
1761function DERNode(parent) {
1762 base.Node.call(this, 'der', parent);
1763}
1764inherits(DERNode, base.Node);
1765
1766DERNode.prototype._encodeComposite = function encodeComposite(tag,
1767 primitive,
1768 cls,
1769 content) {
1770 var encodedTag = encodeTag(tag, primitive, cls, this.reporter);
1771
1772 // Short form
1773 if (content.length < 0x80) {
1774 var header = new Buffer(2);
1775 header[0] = encodedTag;
1776 header[1] = content.length;
1777 return this._createEncoderBuffer([ header, content ]);
1778 }
1779
1780 // Long form
1781 // Count octets required to store length
1782 var lenOctets = 1;
1783 for (var i = content.length; i >= 0x100; i >>= 8)
1784 lenOctets++;
1785
1786 var header = new Buffer(1 + 1 + lenOctets);
1787 header[0] = encodedTag;
1788 header[1] = 0x80 | lenOctets;
1789
1790 for (var i = 1 + lenOctets, j = content.length; j > 0; i--, j >>= 8)
1791 header[i] = j & 0xff;
1792
1793 return this._createEncoderBuffer([ header, content ]);
1794};
1795
1796DERNode.prototype._encodeStr = function encodeStr(str, tag) {
1797 if (tag === 'bitstr') {
1798 return this._createEncoderBuffer([ str.unused | 0, str.data ]);
1799 } else if (tag === 'bmpstr') {
1800 var buf = new Buffer(str.length * 2);
1801 for (var i = 0; i < str.length; i++) {
1802 buf.writeUInt16BE(str.charCodeAt(i), i * 2);
1803 }
1804 return this._createEncoderBuffer(buf);
1805 } else if (tag === 'numstr') {
1806 if (!this._isNumstr(str)) {
1807 return this.reporter.error('Encoding of string type: numstr supports ' +
1808 'only digits and space');
1809 }
1810 return this._createEncoderBuffer(str);
1811 } else if (tag === 'printstr') {
1812 if (!this._isPrintstr(str)) {
1813 return this.reporter.error('Encoding of string type: printstr supports ' +
1814 'only latin upper and lower case letters, ' +
1815 'digits, space, apostrophe, left and rigth ' +
1816 'parenthesis, plus sign, comma, hyphen, ' +
1817 'dot, slash, colon, equal sign, ' +
1818 'question mark');
1819 }
1820 return this._createEncoderBuffer(str);
1821 } else if (/str$/.test(tag)) {
1822 return this._createEncoderBuffer(str);
1823 } else if (tag === 'objDesc') {
1824 return this._createEncoderBuffer(str);
1825 } else {
1826 return this.reporter.error('Encoding of string type: ' + tag +
1827 ' unsupported');
1828 }
1829};
1830
1831DERNode.prototype._encodeObjid = function encodeObjid(id, values, relative) {
1832 if (typeof id === 'string') {
1833 if (!values)
1834 return this.reporter.error('string objid given, but no values map found');
1835 if (!values.hasOwnProperty(id))
1836 return this.reporter.error('objid not found in values map');
1837 id = values[id].split(/[\s\.]+/g);
1838 for (var i = 0; i < id.length; i++)
1839 id[i] |= 0;
1840 } else if (Array.isArray(id)) {
1841 id = id.slice();
1842 for (var i = 0; i < id.length; i++)
1843 id[i] |= 0;
1844 }
1845
1846 if (!Array.isArray(id)) {
1847 return this.reporter.error('objid() should be either array or string, ' +
1848 'got: ' + JSON.stringify(id));
1849 }
1850
1851 if (!relative) {
1852 if (id[1] >= 40)
1853 return this.reporter.error('Second objid identifier OOB');
1854 id.splice(0, 2, id[0] * 40 + id[1]);
1855 }
1856
1857 // Count number of octets
1858 var size = 0;
1859 for (var i = 0; i < id.length; i++) {
1860 var ident = id[i];
1861 for (size++; ident >= 0x80; ident >>= 7)
1862 size++;
1863 }
1864
1865 var objid = new Buffer(size);
1866 var offset = objid.length - 1;
1867 for (var i = id.length - 1; i >= 0; i--) {
1868 var ident = id[i];
1869 objid[offset--] = ident & 0x7f;
1870 while ((ident >>= 7) > 0)
1871 objid[offset--] = 0x80 | (ident & 0x7f);
1872 }
1873
1874 return this._createEncoderBuffer(objid);
1875};
1876
1877function two(num) {
1878 if (num < 10)
1879 return '0' + num;
1880 else
1881 return num;
1882}
1883
1884DERNode.prototype._encodeTime = function encodeTime(time, tag) {
1885 var str;
1886 var date = new Date(time);
1887
1888 if (tag === 'gentime') {
1889 str = [
1890 two(date.getFullYear()),
1891 two(date.getUTCMonth() + 1),
1892 two(date.getUTCDate()),
1893 two(date.getUTCHours()),
1894 two(date.getUTCMinutes()),
1895 two(date.getUTCSeconds()),
1896 'Z'
1897 ].join('');
1898 } else if (tag === 'utctime') {
1899 str = [
1900 two(date.getFullYear() % 100),
1901 two(date.getUTCMonth() + 1),
1902 two(date.getUTCDate()),
1903 two(date.getUTCHours()),
1904 two(date.getUTCMinutes()),
1905 two(date.getUTCSeconds()),
1906 'Z'
1907 ].join('');
1908 } else {
1909 this.reporter.error('Encoding ' + tag + ' time is not supported yet');
1910 }
1911
1912 return this._encodeStr(str, 'octstr');
1913};
1914
1915DERNode.prototype._encodeNull = function encodeNull() {
1916 return this._createEncoderBuffer('');
1917};
1918
1919DERNode.prototype._encodeInt = function encodeInt(num, values) {
1920 if (typeof num === 'string') {
1921 if (!values)
1922 return this.reporter.error('String int or enum given, but no values map');
1923 if (!values.hasOwnProperty(num)) {
1924 return this.reporter.error('Values map doesn\'t contain: ' +
1925 JSON.stringify(num));
1926 }
1927 num = values[num];
1928 }
1929
1930 // Bignum, assume big endian
1931 if (typeof num !== 'number' && !Buffer.isBuffer(num)) {
1932 var numArray = num.toArray();
1933 if (!num.sign && numArray[0] & 0x80) {
1934 numArray.unshift(0);
1935 }
1936 num = new Buffer(numArray);
1937 }
1938
1939 if (Buffer.isBuffer(num)) {
1940 var size = num.length;
1941 if (num.length === 0)
1942 size++;
1943
1944 var out = new Buffer(size);
1945 num.copy(out);
1946 if (num.length === 0)
1947 out[0] = 0
1948 return this._createEncoderBuffer(out);
1949 }
1950
1951 if (num < 0x80)
1952 return this._createEncoderBuffer(num);
1953
1954 if (num < 0x100)
1955 return this._createEncoderBuffer([0, num]);
1956
1957 var size = 1;
1958 for (var i = num; i >= 0x100; i >>= 8)
1959 size++;
1960
1961 var out = new Array(size);
1962 for (var i = out.length - 1; i >= 0; i--) {
1963 out[i] = num & 0xff;
1964 num >>= 8;
1965 }
1966 if(out[0] & 0x80) {
1967 out.unshift(0);
1968 }
1969
1970 return this._createEncoderBuffer(new Buffer(out));
1971};
1972
1973DERNode.prototype._encodeBool = function encodeBool(value) {
1974 return this._createEncoderBuffer(value ? 0xff : 0);
1975};
1976
1977DERNode.prototype._use = function use(entity, obj) {
1978 if (typeof entity === 'function')
1979 entity = entity(obj);
1980 return entity._getEncoder('der').tree;
1981};
1982
1983DERNode.prototype._skipDefault = function skipDefault(dataBuffer, reporter, parent) {
1984 var state = this._baseState;
1985 var i;
1986 if (state['default'] === null)
1987 return false;
1988
1989 var data = dataBuffer.join();
1990 if (state.defaultBuffer === undefined)
1991 state.defaultBuffer = this._encodeValue(state['default'], reporter, parent).join();
1992
1993 if (data.length !== state.defaultBuffer.length)
1994 return false;
1995
1996 for (i=0; i < data.length; i++)
1997 if (data[i] !== state.defaultBuffer[i])
1998 return false;
1999
2000 return true;
2001};
2002
2003// Utility methods
2004
2005function encodeTag(tag, primitive, cls, reporter) {
2006 var res;
2007
2008 if (tag === 'seqof')
2009 tag = 'seq';
2010 else if (tag === 'setof')
2011 tag = 'set';
2012
2013 if (der.tagByName.hasOwnProperty(tag))
2014 res = der.tagByName[tag];
2015 else if (typeof tag === 'number' && (tag | 0) === tag)
2016 res = tag;
2017 else
2018 return reporter.error('Unknown tag: ' + tag);
2019
2020 if (res >= 0x1f)
2021 return reporter.error('Multi-octet tag encoding unsupported');
2022
2023 if (!primitive)
2024 res |= 0x20;
2025
2026 res |= (der.tagClassByName[cls || 'universal'] << 6);
2027
2028 return res;
2029}
2030
2031},{"../../asn1":3,"buffer":53,"inherits":107}],15:[function(require,module,exports){
2032var encoders = exports;
2033
2034encoders.der = require('./der');
2035encoders.pem = require('./pem');
2036
2037},{"./der":14,"./pem":16}],16:[function(require,module,exports){
2038var inherits = require('inherits');
2039
2040var DEREncoder = require('./der');
2041
2042function PEMEncoder(entity) {
2043 DEREncoder.call(this, entity);
2044 this.enc = 'pem';
2045};
2046inherits(PEMEncoder, DEREncoder);
2047module.exports = PEMEncoder;
2048
2049PEMEncoder.prototype.encode = function encode(data, options) {
2050 var buf = DEREncoder.prototype.encode.call(this, data);
2051
2052 var p = buf.toString('base64');
2053 var out = [ '-----BEGIN ' + options.label + '-----' ];
2054 for (var i = 0; i < p.length; i += 64)
2055 out.push(p.slice(i, i + 64));
2056 out.push('-----END ' + options.label + '-----');
2057 return out.join('\n');
2058};
2059
2060},{"./der":14,"inherits":107}],17:[function(require,module,exports){
2061// base-x encoding
2062// Forked from https://github.com/cryptocoinjs/bs58
2063// Originally written by Mike Hearn for BitcoinJ
2064// Copyright (c) 2011 Google Inc
2065// Ported to JavaScript by Stefan Thomas
2066// Merged Buffer refactorings from base58-native by Stephen Pair
2067// Copyright (c) 2013 BitPay Inc
2068
2069var Buffer = require('safe-buffer').Buffer
2070
2071module.exports = function base (ALPHABET) {
2072 var ALPHABET_MAP = {}
2073 var BASE = ALPHABET.length
2074 var LEADER = ALPHABET.charAt(0)
2075
2076 // pre-compute lookup table
2077 for (var z = 0; z < ALPHABET.length; z++) {
2078 var x = ALPHABET.charAt(z)
2079
2080 if (ALPHABET_MAP[x] !== undefined) throw new TypeError(x + ' is ambiguous')
2081 ALPHABET_MAP[x] = z
2082 }
2083
2084 function encode (source) {
2085 if (source.length === 0) return ''
2086
2087 var digits = [0]
2088 for (var i = 0; i < source.length; ++i) {
2089 for (var j = 0, carry = source[i]; j < digits.length; ++j) {
2090 carry += digits[j] << 8
2091 digits[j] = carry % BASE
2092 carry = (carry / BASE) | 0
2093 }
2094
2095 while (carry > 0) {
2096 digits.push(carry % BASE)
2097 carry = (carry / BASE) | 0
2098 }
2099 }
2100
2101 var string = ''
2102
2103 // deal with leading zeros
2104 for (var k = 0; source[k] === 0 && k < source.length - 1; ++k) string += LEADER
2105 // convert digits to a string
2106 for (var q = digits.length - 1; q >= 0; --q) string += ALPHABET[digits[q]]
2107
2108 return string
2109 }
2110
2111 function decodeUnsafe (string) {
2112 if (typeof string !== 'string') throw new TypeError('Expected String')
2113 if (string.length === 0) return Buffer.allocUnsafe(0)
2114
2115 var bytes = [0]
2116 for (var i = 0; i < string.length; i++) {
2117 var value = ALPHABET_MAP[string[i]]
2118 if (value === undefined) return
2119
2120 for (var j = 0, carry = value; j < bytes.length; ++j) {
2121 carry += bytes[j] * BASE
2122 bytes[j] = carry & 0xff
2123 carry >>= 8
2124 }
2125
2126 while (carry > 0) {
2127 bytes.push(carry & 0xff)
2128 carry >>= 8
2129 }
2130 }
2131
2132 // deal with leading zeros
2133 for (var k = 0; string[k] === LEADER && k < string.length - 1; ++k) {
2134 bytes.push(0)
2135 }
2136
2137 return Buffer.from(bytes.reverse())
2138 }
2139
2140 function decode (string) {
2141 var buffer = decodeUnsafe(string)
2142 if (buffer) return buffer
2143
2144 throw new Error('Non-base' + BASE + ' character')
2145 }
2146
2147 return {
2148 encode: encode,
2149 decodeUnsafe: decodeUnsafe,
2150 decode: decode
2151 }
2152}
2153
2154},{"safe-buffer":156}],18:[function(require,module,exports){
2155'use strict'
2156
2157exports.byteLength = byteLength
2158exports.toByteArray = toByteArray
2159exports.fromByteArray = fromByteArray
2160
2161var lookup = []
2162var revLookup = []
2163var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
2164
2165var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
2166for (var i = 0, len = code.length; i < len; ++i) {
2167 lookup[i] = code[i]
2168 revLookup[code.charCodeAt(i)] = i
2169}
2170
2171revLookup['-'.charCodeAt(0)] = 62
2172revLookup['_'.charCodeAt(0)] = 63
2173
2174function placeHoldersCount (b64) {
2175 var len = b64.length
2176 if (len % 4 > 0) {
2177 throw new Error('Invalid string. Length must be a multiple of 4')
2178 }
2179
2180 // the number of equal signs (place holders)
2181 // if there are two placeholders, than the two characters before it
2182 // represent one byte
2183 // if there is only one, then the three characters before it represent 2 bytes
2184 // this is just a cheap hack to not do indexOf twice
2185 return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0
2186}
2187
2188function byteLength (b64) {
2189 // base64 is 4/3 + up to two characters of the original data
2190 return (b64.length * 3 / 4) - placeHoldersCount(b64)
2191}
2192
2193function toByteArray (b64) {
2194 var i, l, tmp, placeHolders, arr
2195 var len = b64.length
2196 placeHolders = placeHoldersCount(b64)
2197
2198 arr = new Arr((len * 3 / 4) - placeHolders)
2199
2200 // if there are placeholders, only get up to the last complete 4 chars
2201 l = placeHolders > 0 ? len - 4 : len
2202
2203 var L = 0
2204
2205 for (i = 0; i < l; i += 4) {
2206 tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]
2207 arr[L++] = (tmp >> 16) & 0xFF
2208 arr[L++] = (tmp >> 8) & 0xFF
2209 arr[L++] = tmp & 0xFF
2210 }
2211
2212 if (placeHolders === 2) {
2213 tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)
2214 arr[L++] = tmp & 0xFF
2215 } else if (placeHolders === 1) {
2216 tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)
2217 arr[L++] = (tmp >> 8) & 0xFF
2218 arr[L++] = tmp & 0xFF
2219 }
2220
2221 return arr
2222}
2223
2224function tripletToBase64 (num) {
2225 return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
2226}
2227
2228function encodeChunk (uint8, start, end) {
2229 var tmp
2230 var output = []
2231 for (var i = start; i < end; i += 3) {
2232 tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
2233 output.push(tripletToBase64(tmp))
2234 }
2235 return output.join('')
2236}
2237
2238function fromByteArray (uint8) {
2239 var tmp
2240 var len = uint8.length
2241 var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
2242 var output = ''
2243 var parts = []
2244 var maxChunkLength = 16383 // must be multiple of 3
2245
2246 // go through the array every three bytes, we'll deal with trailing stuff later
2247 for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
2248 parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
2249 }
2250
2251 // pad the end with zeros, but make sure to not forget the extra bytes
2252 if (extraBytes === 1) {
2253 tmp = uint8[len - 1]
2254 output += lookup[tmp >> 2]
2255 output += lookup[(tmp << 4) & 0x3F]
2256 output += '=='
2257 } else if (extraBytes === 2) {
2258 tmp = (uint8[len - 2] << 8) + (uint8[len - 1])
2259 output += lookup[tmp >> 10]
2260 output += lookup[(tmp >> 4) & 0x3F]
2261 output += lookup[(tmp << 2) & 0x3F]
2262 output += '='
2263 }
2264
2265 parts.push(output)
2266
2267 return parts.join('')
2268}
2269
2270},{}],19:[function(require,module,exports){
2271/*! bignumber.js v5.0.0 https://github.com/MikeMcl/bignumber.js/LICENCE */
2272
2273;(function (globalObj) {
2274 'use strict';
2275
2276 /*
2277 bignumber.js v5.0.0
2278 A JavaScript library for arbitrary-precision arithmetic.
2279 https://github.com/MikeMcl/bignumber.js
2280 Copyright (c) 2017 Michael Mclaughlin <M8ch88l@gmail.com>
2281 MIT Expat Licence
2282 */
2283
2284
2285 var BigNumber,
2286 isNumeric = /^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,
2287 mathceil = Math.ceil,
2288 mathfloor = Math.floor,
2289 notBool = ' not a boolean or binary digit',
2290 roundingMode = 'rounding mode',
2291 tooManyDigits = 'number type has more than 15 significant digits',
2292 ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_',
2293 BASE = 1e14,
2294 LOG_BASE = 14,
2295 MAX_SAFE_INTEGER = 0x1fffffffffffff, // 2^53 - 1
2296 // MAX_INT32 = 0x7fffffff, // 2^31 - 1
2297 POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13],
2298 SQRT_BASE = 1e7,
2299
2300 /*
2301 * The limit on the value of DECIMAL_PLACES, TO_EXP_NEG, TO_EXP_POS, MIN_EXP, MAX_EXP, and
2302 * the arguments to toExponential, toFixed, toFormat, and toPrecision, beyond which an
2303 * exception is thrown (if ERRORS is true).
2304 */
2305 MAX = 1E9; // 0 to MAX_INT32
2306
2307
2308 /*
2309 * Create and return a BigNumber constructor.
2310 */
2311 function constructorFactory(config) {
2312 var div, parseNumeric,
2313
2314 // id tracks the caller function, so its name can be included in error messages.
2315 id = 0,
2316 P = BigNumber.prototype,
2317 ONE = new BigNumber(1),
2318
2319
2320 /********************************* EDITABLE DEFAULTS **********************************/
2321
2322
2323 /*
2324 * The default values below must be integers within the inclusive ranges stated.
2325 * The values can also be changed at run-time using BigNumber.config.
2326 */
2327
2328 // The maximum number of decimal places for operations involving division.
2329 DECIMAL_PLACES = 20, // 0 to MAX
2330
2331 /*
2332 * The rounding mode used when rounding to the above decimal places, and when using
2333 * toExponential, toFixed, toFormat and toPrecision, and round (default value).
2334 * UP 0 Away from zero.
2335 * DOWN 1 Towards zero.
2336 * CEIL 2 Towards +Infinity.
2337 * FLOOR 3 Towards -Infinity.
2338 * HALF_UP 4 Towards nearest neighbour. If equidistant, up.
2339 * HALF_DOWN 5 Towards nearest neighbour. If equidistant, down.
2340 * HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour.
2341 * HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity.
2342 * HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.
2343 */
2344 ROUNDING_MODE = 4, // 0 to 8
2345
2346 // EXPONENTIAL_AT : [TO_EXP_NEG , TO_EXP_POS]
2347
2348 // The exponent value at and beneath which toString returns exponential notation.
2349 // Number type: -7
2350 TO_EXP_NEG = -7, // 0 to -MAX
2351
2352 // The exponent value at and above which toString returns exponential notation.
2353 // Number type: 21
2354 TO_EXP_POS = 21, // 0 to MAX
2355
2356 // RANGE : [MIN_EXP, MAX_EXP]
2357
2358 // The minimum exponent value, beneath which underflow to zero occurs.
2359 // Number type: -324 (5e-324)
2360 MIN_EXP = -1e7, // -1 to -MAX
2361
2362 // The maximum exponent value, above which overflow to Infinity occurs.
2363 // Number type: 308 (1.7976931348623157e+308)
2364 // For MAX_EXP > 1e7, e.g. new BigNumber('1e100000000').plus(1) may be slow.
2365 MAX_EXP = 1e7, // 1 to MAX
2366
2367 // Whether BigNumber Errors are ever thrown.
2368 ERRORS = true, // true or false
2369
2370 // Change to intValidatorNoErrors if ERRORS is false.
2371 isValidInt = intValidatorWithErrors, // intValidatorWithErrors/intValidatorNoErrors
2372
2373 // Whether to use cryptographically-secure random number generation, if available.
2374 CRYPTO = false, // true or false
2375
2376 /*
2377 * The modulo mode used when calculating the modulus: a mod n.
2378 * The quotient (q = a / n) is calculated according to the corresponding rounding mode.
2379 * The remainder (r) is calculated as: r = a - n * q.
2380 *
2381 * UP 0 The remainder is positive if the dividend is negative, else is negative.
2382 * DOWN 1 The remainder has the same sign as the dividend.
2383 * This modulo mode is commonly known as 'truncated division' and is
2384 * equivalent to (a % n) in JavaScript.
2385 * FLOOR 3 The remainder has the same sign as the divisor (Python %).
2386 * HALF_EVEN 6 This modulo mode implements the IEEE 754 remainder function.
2387 * EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)).
2388 * The remainder is always positive.
2389 *
2390 * The truncated division, floored division, Euclidian division and IEEE 754 remainder
2391 * modes are commonly used for the modulus operation.
2392 * Although the other rounding modes can also be used, they may not give useful results.
2393 */
2394 MODULO_MODE = 1, // 0 to 9
2395
2396 // The maximum number of significant digits of the result of the toPower operation.
2397 // If POW_PRECISION is 0, there will be unlimited significant digits.
2398 POW_PRECISION = 0, // 0 to MAX
2399
2400 // The format specification used by the BigNumber.prototype.toFormat method.
2401 FORMAT = {
2402 decimalSeparator: '.',
2403 groupSeparator: ',',
2404 groupSize: 3,
2405 secondaryGroupSize: 0,
2406 fractionGroupSeparator: '\xA0', // non-breaking space
2407 fractionGroupSize: 0
2408 };
2409
2410
2411 /******************************************************************************************/
2412
2413
2414 // CONSTRUCTOR
2415
2416
2417 /*
2418 * The BigNumber constructor and exported function.
2419 * Create and return a new instance of a BigNumber object.
2420 *
2421 * n {number|string|BigNumber} A numeric value.
2422 * [b] {number} The base of n. Integer, 2 to 64 inclusive.
2423 */
2424 function BigNumber( n, b ) {
2425 var c, e, i, num, len, str,
2426 x = this;
2427
2428 // Enable constructor usage without new.
2429 if ( !( x instanceof BigNumber ) ) {
2430
2431 // 'BigNumber() constructor call without new: {n}'
2432 // See GitHub issue: #81.
2433 //if (ERRORS) raise( 26, 'constructor call without new', n );
2434 return new BigNumber( n, b );
2435 }
2436
2437 // 'new BigNumber() base not an integer: {b}'
2438 // 'new BigNumber() base out of range: {b}'
2439 if ( b == null || !isValidInt( b, 2, 64, id, 'base' ) ) {
2440
2441 // Duplicate.
2442 if ( n instanceof BigNumber ) {
2443 x.s = n.s;
2444 x.e = n.e;
2445 x.c = ( n = n.c ) ? n.slice() : n;
2446 id = 0;
2447 return;
2448 }
2449
2450 if ( ( num = typeof n == 'number' ) && n * 0 == 0 ) {
2451 x.s = 1 / n < 0 ? ( n = -n, -1 ) : 1;
2452
2453 // Fast path for integers.
2454 if ( n === ~~n ) {
2455 for ( e = 0, i = n; i >= 10; i /= 10, e++ );
2456 x.e = e;
2457 x.c = [n];
2458 id = 0;
2459 return;
2460 }
2461
2462 str = n + '';
2463 } else {
2464 if ( !isNumeric.test( str = n + '' ) ) return parseNumeric( x, str, num );
2465 x.s = str.charCodeAt(0) === 45 ? ( str = str.slice(1), -1 ) : 1;
2466 }
2467 } else {
2468 b = b | 0;
2469 str = n + '';
2470
2471 // Ensure return value is rounded to DECIMAL_PLACES as with other bases.
2472 // Allow exponential notation to be used with base 10 argument.
2473 if ( b == 10 ) {
2474 x = new BigNumber( n instanceof BigNumber ? n : str );
2475 return round( x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE );
2476 }
2477
2478 // Avoid potential interpretation of Infinity and NaN as base 44+ values.
2479 // Any number in exponential form will fail due to the [Ee][+-].
2480 if ( ( num = typeof n == 'number' ) && n * 0 != 0 ||
2481 !( new RegExp( '^-?' + ( c = '[' + ALPHABET.slice( 0, b ) + ']+' ) +
2482 '(?:\\.' + c + ')?$',b < 37 ? 'i' : '' ) ).test(str) ) {
2483 return parseNumeric( x, str, num, b );
2484 }
2485
2486 if (num) {
2487 x.s = 1 / n < 0 ? ( str = str.slice(1), -1 ) : 1;
2488
2489 if ( ERRORS && str.replace( /^0\.0*|\./, '' ).length > 15 ) {
2490
2491 // 'new BigNumber() number type has more than 15 significant digits: {n}'
2492 raise( id, tooManyDigits, n );
2493 }
2494
2495 // Prevent later check for length on converted number.
2496 num = false;
2497 } else {
2498 x.s = str.charCodeAt(0) === 45 ? ( str = str.slice(1), -1 ) : 1;
2499 }
2500
2501 str = convertBase( str, 10, b, x.s );
2502 }
2503
2504 // Decimal point?
2505 if ( ( e = str.indexOf('.') ) > -1 ) str = str.replace( '.', '' );
2506
2507 // Exponential form?
2508 if ( ( i = str.search( /e/i ) ) > 0 ) {
2509
2510 // Determine exponent.
2511 if ( e < 0 ) e = i;
2512 e += +str.slice( i + 1 );
2513 str = str.substring( 0, i );
2514 } else if ( e < 0 ) {
2515
2516 // Integer.
2517 e = str.length;
2518 }
2519
2520 // Determine leading zeros.
2521 for ( i = 0; str.charCodeAt(i) === 48; i++ );
2522
2523 // Determine trailing zeros.
2524 for ( len = str.length; str.charCodeAt(--len) === 48; );
2525 str = str.slice( i, len + 1 );
2526
2527 if (str) {
2528 len = str.length;
2529
2530 // Disallow numbers with over 15 significant digits if number type.
2531 // 'new BigNumber() number type has more than 15 significant digits: {n}'
2532 if ( num && ERRORS && len > 15 && ( n > MAX_SAFE_INTEGER || n !== mathfloor(n) ) ) {
2533 raise( id, tooManyDigits, x.s * n );
2534 }
2535
2536 e = e - i - 1;
2537
2538 // Overflow?
2539 if ( e > MAX_EXP ) {
2540
2541 // Infinity.
2542 x.c = x.e = null;
2543
2544 // Underflow?
2545 } else if ( e < MIN_EXP ) {
2546
2547 // Zero.
2548 x.c = [ x.e = 0 ];
2549 } else {
2550 x.e = e;
2551 x.c = [];
2552
2553 // Transform base
2554
2555 // e is the base 10 exponent.
2556 // i is where to slice str to get the first element of the coefficient array.
2557 i = ( e + 1 ) % LOG_BASE;
2558 if ( e < 0 ) i += LOG_BASE;
2559
2560 if ( i < len ) {
2561 if (i) x.c.push( +str.slice( 0, i ) );
2562
2563 for ( len -= LOG_BASE; i < len; ) {
2564 x.c.push( +str.slice( i, i += LOG_BASE ) );
2565 }
2566
2567 str = str.slice(i);
2568 i = LOG_BASE - str.length;
2569 } else {
2570 i -= len;
2571 }
2572
2573 for ( ; i--; str += '0' );
2574 x.c.push( +str );
2575 }
2576 } else {
2577
2578 // Zero.
2579 x.c = [ x.e = 0 ];
2580 }
2581
2582 id = 0;
2583 }
2584
2585
2586 // CONSTRUCTOR PROPERTIES
2587
2588
2589 BigNumber.another = constructorFactory;
2590
2591 BigNumber.ROUND_UP = 0;
2592 BigNumber.ROUND_DOWN = 1;
2593 BigNumber.ROUND_CEIL = 2;
2594 BigNumber.ROUND_FLOOR = 3;
2595 BigNumber.ROUND_HALF_UP = 4;
2596 BigNumber.ROUND_HALF_DOWN = 5;
2597 BigNumber.ROUND_HALF_EVEN = 6;
2598 BigNumber.ROUND_HALF_CEIL = 7;
2599 BigNumber.ROUND_HALF_FLOOR = 8;
2600 BigNumber.EUCLID = 9;
2601
2602
2603 /*
2604 * Configure infrequently-changing library-wide settings.
2605 *
2606 * Accept an object or an argument list, with one or many of the following properties or
2607 * parameters respectively:
2608 *
2609 * DECIMAL_PLACES {number} Integer, 0 to MAX inclusive
2610 * ROUNDING_MODE {number} Integer, 0 to 8 inclusive
2611 * EXPONENTIAL_AT {number|number[]} Integer, -MAX to MAX inclusive or
2612 * [integer -MAX to 0 incl., 0 to MAX incl.]
2613 * RANGE {number|number[]} Non-zero integer, -MAX to MAX inclusive or
2614 * [integer -MAX to -1 incl., integer 1 to MAX incl.]
2615 * ERRORS {boolean|number} true, false, 1 or 0
2616 * CRYPTO {boolean|number} true, false, 1 or 0
2617 * MODULO_MODE {number} 0 to 9 inclusive
2618 * POW_PRECISION {number} 0 to MAX inclusive
2619 * FORMAT {object} See BigNumber.prototype.toFormat
2620 * decimalSeparator {string}
2621 * groupSeparator {string}
2622 * groupSize {number}
2623 * secondaryGroupSize {number}
2624 * fractionGroupSeparator {string}
2625 * fractionGroupSize {number}
2626 *
2627 * (The values assigned to the above FORMAT object properties are not checked for validity.)
2628 *
2629 * E.g.
2630 * BigNumber.config(20, 4) is equivalent to
2631 * BigNumber.config({ DECIMAL_PLACES : 20, ROUNDING_MODE : 4 })
2632 *
2633 * Ignore properties/parameters set to null or undefined.
2634 * Return an object with the properties current values.
2635 */
2636 BigNumber.config = BigNumber.set = function () {
2637 var v, p,
2638 i = 0,
2639 r = {},
2640 a = arguments,
2641 o = a[0],
2642 has = o && typeof o == 'object'
2643 ? function () { if ( o.hasOwnProperty(p) ) return ( v = o[p] ) != null; }
2644 : function () { if ( a.length > i ) return ( v = a[i++] ) != null; };
2645
2646 // DECIMAL_PLACES {number} Integer, 0 to MAX inclusive.
2647 // 'config() DECIMAL_PLACES not an integer: {v}'
2648 // 'config() DECIMAL_PLACES out of range: {v}'
2649 if ( has( p = 'DECIMAL_PLACES' ) && isValidInt( v, 0, MAX, 2, p ) ) {
2650 DECIMAL_PLACES = v | 0;
2651 }
2652 r[p] = DECIMAL_PLACES;
2653
2654 // ROUNDING_MODE {number} Integer, 0 to 8 inclusive.
2655 // 'config() ROUNDING_MODE not an integer: {v}'
2656 // 'config() ROUNDING_MODE out of range: {v}'
2657 if ( has( p = 'ROUNDING_MODE' ) && isValidInt( v, 0, 8, 2, p ) ) {
2658 ROUNDING_MODE = v | 0;
2659 }
2660 r[p] = ROUNDING_MODE;
2661
2662 // EXPONENTIAL_AT {number|number[]}
2663 // Integer, -MAX to MAX inclusive or [integer -MAX to 0 inclusive, 0 to MAX inclusive].
2664 // 'config() EXPONENTIAL_AT not an integer: {v}'
2665 // 'config() EXPONENTIAL_AT out of range: {v}'
2666 if ( has( p = 'EXPONENTIAL_AT' ) ) {
2667
2668 if ( isArray(v) ) {
2669 if ( isValidInt( v[0], -MAX, 0, 2, p ) && isValidInt( v[1], 0, MAX, 2, p ) ) {
2670 TO_EXP_NEG = v[0] | 0;
2671 TO_EXP_POS = v[1] | 0;
2672 }
2673 } else if ( isValidInt( v, -MAX, MAX, 2, p ) ) {
2674 TO_EXP_NEG = -( TO_EXP_POS = ( v < 0 ? -v : v ) | 0 );
2675 }
2676 }
2677 r[p] = [ TO_EXP_NEG, TO_EXP_POS ];
2678
2679 // RANGE {number|number[]} Non-zero integer, -MAX to MAX inclusive or
2680 // [integer -MAX to -1 inclusive, integer 1 to MAX inclusive].
2681 // 'config() RANGE not an integer: {v}'
2682 // 'config() RANGE cannot be zero: {v}'
2683 // 'config() RANGE out of range: {v}'
2684 if ( has( p = 'RANGE' ) ) {
2685
2686 if ( isArray(v) ) {
2687 if ( isValidInt( v[0], -MAX, -1, 2, p ) && isValidInt( v[1], 1, MAX, 2, p ) ) {
2688 MIN_EXP = v[0] | 0;
2689 MAX_EXP = v[1] | 0;
2690 }
2691 } else if ( isValidInt( v, -MAX, MAX, 2, p ) ) {
2692 if ( v | 0 ) MIN_EXP = -( MAX_EXP = ( v < 0 ? -v : v ) | 0 );
2693 else if (ERRORS) raise( 2, p + ' cannot be zero', v );
2694 }
2695 }
2696 r[p] = [ MIN_EXP, MAX_EXP ];
2697
2698 // ERRORS {boolean|number} true, false, 1 or 0.
2699 // 'config() ERRORS not a boolean or binary digit: {v}'
2700 if ( has( p = 'ERRORS' ) ) {
2701
2702 if ( v === !!v || v === 1 || v === 0 ) {
2703 id = 0;
2704 isValidInt = ( ERRORS = !!v ) ? intValidatorWithErrors : intValidatorNoErrors;
2705 } else if (ERRORS) {
2706 raise( 2, p + notBool, v );
2707 }
2708 }
2709 r[p] = ERRORS;
2710
2711 // CRYPTO {boolean|number} true, false, 1 or 0.
2712 // 'config() CRYPTO not a boolean or binary digit: {v}'
2713 // 'config() crypto unavailable: {crypto}'
2714 if ( has( p = 'CRYPTO' ) ) {
2715
2716 if ( v === true || v === false || v === 1 || v === 0 ) {
2717 if (v) {
2718 v = typeof crypto == 'undefined';
2719 if ( !v && crypto && (crypto.getRandomValues || crypto.randomBytes)) {
2720 CRYPTO = true;
2721 } else if (ERRORS) {
2722 raise( 2, 'crypto unavailable', v ? void 0 : crypto );
2723 } else {
2724 CRYPTO = false;
2725 }
2726 } else {
2727 CRYPTO = false;
2728 }
2729 } else if (ERRORS) {
2730 raise( 2, p + notBool, v );
2731 }
2732 }
2733 r[p] = CRYPTO;
2734
2735 // MODULO_MODE {number} Integer, 0 to 9 inclusive.
2736 // 'config() MODULO_MODE not an integer: {v}'
2737 // 'config() MODULO_MODE out of range: {v}'
2738 if ( has( p = 'MODULO_MODE' ) && isValidInt( v, 0, 9, 2, p ) ) {
2739 MODULO_MODE = v | 0;
2740 }
2741 r[p] = MODULO_MODE;
2742
2743 // POW_PRECISION {number} Integer, 0 to MAX inclusive.
2744 // 'config() POW_PRECISION not an integer: {v}'
2745 // 'config() POW_PRECISION out of range: {v}'
2746 if ( has( p = 'POW_PRECISION' ) && isValidInt( v, 0, MAX, 2, p ) ) {
2747 POW_PRECISION = v | 0;
2748 }
2749 r[p] = POW_PRECISION;
2750
2751 // FORMAT {object}
2752 // 'config() FORMAT not an object: {v}'
2753 if ( has( p = 'FORMAT' ) ) {
2754
2755 if ( typeof v == 'object' ) {
2756 FORMAT = v;
2757 } else if (ERRORS) {
2758 raise( 2, p + ' not an object', v );
2759 }
2760 }
2761 r[p] = FORMAT;
2762
2763 return r;
2764 };
2765
2766
2767 /*
2768 * Return a new BigNumber whose value is the maximum of the arguments.
2769 *
2770 * arguments {number|string|BigNumber}
2771 */
2772 BigNumber.max = function () { return maxOrMin( arguments, P.lt ); };
2773
2774
2775 /*
2776 * Return a new BigNumber whose value is the minimum of the arguments.
2777 *
2778 * arguments {number|string|BigNumber}
2779 */
2780 BigNumber.min = function () { return maxOrMin( arguments, P.gt ); };
2781
2782
2783 /*
2784 * Return a new BigNumber with a random value equal to or greater than 0 and less than 1,
2785 * and with dp, or DECIMAL_PLACES if dp is omitted, decimal places (or less if trailing
2786 * zeros are produced).
2787 *
2788 * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
2789 *
2790 * 'random() decimal places not an integer: {dp}'
2791 * 'random() decimal places out of range: {dp}'
2792 * 'random() crypto unavailable: {crypto}'
2793 */
2794 BigNumber.random = (function () {
2795 var pow2_53 = 0x20000000000000;
2796
2797 // Return a 53 bit integer n, where 0 <= n < 9007199254740992.
2798 // Check if Math.random() produces more than 32 bits of randomness.
2799 // If it does, assume at least 53 bits are produced, otherwise assume at least 30 bits.
2800 // 0x40000000 is 2^30, 0x800000 is 2^23, 0x1fffff is 2^21 - 1.
2801 var random53bitInt = (Math.random() * pow2_53) & 0x1fffff
2802 ? function () { return mathfloor( Math.random() * pow2_53 ); }
2803 : function () { return ((Math.random() * 0x40000000 | 0) * 0x800000) +
2804 (Math.random() * 0x800000 | 0); };
2805
2806 return function (dp) {
2807 var a, b, e, k, v,
2808 i = 0,
2809 c = [],
2810 rand = new BigNumber(ONE);
2811
2812 dp = dp == null || !isValidInt( dp, 0, MAX, 14 ) ? DECIMAL_PLACES : dp | 0;
2813 k = mathceil( dp / LOG_BASE );
2814
2815 if (CRYPTO) {
2816
2817 // Browsers supporting crypto.getRandomValues.
2818 if (crypto.getRandomValues) {
2819
2820 a = crypto.getRandomValues( new Uint32Array( k *= 2 ) );
2821
2822 for ( ; i < k; ) {
2823
2824 // 53 bits:
2825 // ((Math.pow(2, 32) - 1) * Math.pow(2, 21)).toString(2)
2826 // 11111 11111111 11111111 11111111 11100000 00000000 00000000
2827 // ((Math.pow(2, 32) - 1) >>> 11).toString(2)
2828 // 11111 11111111 11111111
2829 // 0x20000 is 2^21.
2830 v = a[i] * 0x20000 + (a[i + 1] >>> 11);
2831
2832 // Rejection sampling:
2833 // 0 <= v < 9007199254740992
2834 // Probability that v >= 9e15, is
2835 // 7199254740992 / 9007199254740992 ~= 0.0008, i.e. 1 in 1251
2836 if ( v >= 9e15 ) {
2837 b = crypto.getRandomValues( new Uint32Array(2) );
2838 a[i] = b[0];
2839 a[i + 1] = b[1];
2840 } else {
2841
2842 // 0 <= v <= 8999999999999999
2843 // 0 <= (v % 1e14) <= 99999999999999
2844 c.push( v % 1e14 );
2845 i += 2;
2846 }
2847 }
2848 i = k / 2;
2849
2850 // Node.js supporting crypto.randomBytes.
2851 } else if (crypto.randomBytes) {
2852
2853 // buffer
2854 a = crypto.randomBytes( k *= 7 );
2855
2856 for ( ; i < k; ) {
2857
2858 // 0x1000000000000 is 2^48, 0x10000000000 is 2^40
2859 // 0x100000000 is 2^32, 0x1000000 is 2^24
2860 // 11111 11111111 11111111 11111111 11111111 11111111 11111111
2861 // 0 <= v < 9007199254740992
2862 v = ( ( a[i] & 31 ) * 0x1000000000000 ) + ( a[i + 1] * 0x10000000000 ) +
2863 ( a[i + 2] * 0x100000000 ) + ( a[i + 3] * 0x1000000 ) +
2864 ( a[i + 4] << 16 ) + ( a[i + 5] << 8 ) + a[i + 6];
2865
2866 if ( v >= 9e15 ) {
2867 crypto.randomBytes(7).copy( a, i );
2868 } else {
2869
2870 // 0 <= (v % 1e14) <= 99999999999999
2871 c.push( v % 1e14 );
2872 i += 7;
2873 }
2874 }
2875 i = k / 7;
2876 } else {
2877 CRYPTO = false;
2878 if (ERRORS) raise( 14, 'crypto unavailable', crypto );
2879 }
2880 }
2881
2882 // Use Math.random.
2883 if (!CRYPTO) {
2884
2885 for ( ; i < k; ) {
2886 v = random53bitInt();
2887 if ( v < 9e15 ) c[i++] = v % 1e14;
2888 }
2889 }
2890
2891 k = c[--i];
2892 dp %= LOG_BASE;
2893
2894 // Convert trailing digits to zeros according to dp.
2895 if ( k && dp ) {
2896 v = POWS_TEN[LOG_BASE - dp];
2897 c[i] = mathfloor( k / v ) * v;
2898 }
2899
2900 // Remove trailing elements which are zero.
2901 for ( ; c[i] === 0; c.pop(), i-- );
2902
2903 // Zero?
2904 if ( i < 0 ) {
2905 c = [ e = 0 ];
2906 } else {
2907
2908 // Remove leading elements which are zero and adjust exponent accordingly.
2909 for ( e = -1 ; c[0] === 0; c.splice(0, 1), e -= LOG_BASE);
2910
2911 // Count the digits of the first element of c to determine leading zeros, and...
2912 for ( i = 1, v = c[0]; v >= 10; v /= 10, i++);
2913
2914 // adjust the exponent accordingly.
2915 if ( i < LOG_BASE ) e -= LOG_BASE - i;
2916 }
2917
2918 rand.e = e;
2919 rand.c = c;
2920 return rand;
2921 };
2922 })();
2923
2924
2925 // PRIVATE FUNCTIONS
2926
2927
2928 // Convert a numeric string of baseIn to a numeric string of baseOut.
2929 function convertBase( str, baseOut, baseIn, sign ) {
2930 var d, e, k, r, x, xc, y,
2931 i = str.indexOf( '.' ),
2932 dp = DECIMAL_PLACES,
2933 rm = ROUNDING_MODE;
2934
2935 if ( baseIn < 37 ) str = str.toLowerCase();
2936
2937 // Non-integer.
2938 if ( i >= 0 ) {
2939 k = POW_PRECISION;
2940
2941 // Unlimited precision.
2942 POW_PRECISION = 0;
2943 str = str.replace( '.', '' );
2944 y = new BigNumber(baseIn);
2945 x = y.pow( str.length - i );
2946 POW_PRECISION = k;
2947
2948 // Convert str as if an integer, then restore the fraction part by dividing the
2949 // result by its base raised to a power.
2950 y.c = toBaseOut( toFixedPoint( coeffToString( x.c ), x.e ), 10, baseOut );
2951 y.e = y.c.length;
2952 }
2953
2954 // Convert the number as integer.
2955 xc = toBaseOut( str, baseIn, baseOut );
2956 e = k = xc.length;
2957
2958 // Remove trailing zeros.
2959 for ( ; xc[--k] == 0; xc.pop() );
2960 if ( !xc[0] ) return '0';
2961
2962 if ( i < 0 ) {
2963 --e;
2964 } else {
2965 x.c = xc;
2966 x.e = e;
2967
2968 // sign is needed for correct rounding.
2969 x.s = sign;
2970 x = div( x, y, dp, rm, baseOut );
2971 xc = x.c;
2972 r = x.r;
2973 e = x.e;
2974 }
2975
2976 d = e + dp + 1;
2977
2978 // The rounding digit, i.e. the digit to the right of the digit that may be rounded up.
2979 i = xc[d];
2980 k = baseOut / 2;
2981 r = r || d < 0 || xc[d + 1] != null;
2982
2983 r = rm < 4 ? ( i != null || r ) && ( rm == 0 || rm == ( x.s < 0 ? 3 : 2 ) )
2984 : i > k || i == k &&( rm == 4 || r || rm == 6 && xc[d - 1] & 1 ||
2985 rm == ( x.s < 0 ? 8 : 7 ) );
2986
2987 if ( d < 1 || !xc[0] ) {
2988
2989 // 1^-dp or 0.
2990 str = r ? toFixedPoint( '1', -dp ) : '0';
2991 } else {
2992 xc.length = d;
2993
2994 if (r) {
2995
2996 // Rounding up may mean the previous digit has to be rounded up and so on.
2997 for ( --baseOut; ++xc[--d] > baseOut; ) {
2998 xc[d] = 0;
2999
3000 if ( !d ) {
3001 ++e;
3002 xc = [1].concat(xc);
3003 }
3004 }
3005 }
3006
3007 // Determine trailing zeros.
3008 for ( k = xc.length; !xc[--k]; );
3009
3010 // E.g. [4, 11, 15] becomes 4bf.
3011 for ( i = 0, str = ''; i <= k; str += ALPHABET.charAt( xc[i++] ) );
3012 str = toFixedPoint( str, e );
3013 }
3014
3015 // The caller will add the sign.
3016 return str;
3017 }
3018
3019
3020 // Perform division in the specified base. Called by div and convertBase.
3021 div = (function () {
3022
3023 // Assume non-zero x and k.
3024 function multiply( x, k, base ) {
3025 var m, temp, xlo, xhi,
3026 carry = 0,
3027 i = x.length,
3028 klo = k % SQRT_BASE,
3029 khi = k / SQRT_BASE | 0;
3030
3031 for ( x = x.slice(); i--; ) {
3032 xlo = x[i] % SQRT_BASE;
3033 xhi = x[i] / SQRT_BASE | 0;
3034 m = khi * xlo + xhi * klo;
3035 temp = klo * xlo + ( ( m % SQRT_BASE ) * SQRT_BASE ) + carry;
3036 carry = ( temp / base | 0 ) + ( m / SQRT_BASE | 0 ) + khi * xhi;
3037 x[i] = temp % base;
3038 }
3039
3040 if (carry) x = [carry].concat(x);
3041
3042 return x;
3043 }
3044
3045 function compare( a, b, aL, bL ) {
3046 var i, cmp;
3047
3048 if ( aL != bL ) {
3049 cmp = aL > bL ? 1 : -1;
3050 } else {
3051
3052 for ( i = cmp = 0; i < aL; i++ ) {
3053
3054 if ( a[i] != b[i] ) {
3055 cmp = a[i] > b[i] ? 1 : -1;
3056 break;
3057 }
3058 }
3059 }
3060 return cmp;
3061 }
3062
3063 function subtract( a, b, aL, base ) {
3064 var i = 0;
3065
3066 // Subtract b from a.
3067 for ( ; aL--; ) {
3068 a[aL] -= i;
3069 i = a[aL] < b[aL] ? 1 : 0;
3070 a[aL] = i * base + a[aL] - b[aL];
3071 }
3072
3073 // Remove leading zeros.
3074 for ( ; !a[0] && a.length > 1; a.splice(0, 1) );
3075 }
3076
3077 // x: dividend, y: divisor.
3078 return function ( x, y, dp, rm, base ) {
3079 var cmp, e, i, more, n, prod, prodL, q, qc, rem, remL, rem0, xi, xL, yc0,
3080 yL, yz,
3081 s = x.s == y.s ? 1 : -1,
3082 xc = x.c,
3083 yc = y.c;
3084
3085 // Either NaN, Infinity or 0?
3086 if ( !xc || !xc[0] || !yc || !yc[0] ) {
3087
3088 return new BigNumber(
3089
3090 // Return NaN if either NaN, or both Infinity or 0.
3091 !x.s || !y.s || ( xc ? yc && xc[0] == yc[0] : !yc ) ? NaN :
3092
3093 // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0.
3094 xc && xc[0] == 0 || !yc ? s * 0 : s / 0
3095 );
3096 }
3097
3098 q = new BigNumber(s);
3099 qc = q.c = [];
3100 e = x.e - y.e;
3101 s = dp + e + 1;
3102
3103 if ( !base ) {
3104 base = BASE;
3105 e = bitFloor( x.e / LOG_BASE ) - bitFloor( y.e / LOG_BASE );
3106 s = s / LOG_BASE | 0;
3107 }
3108
3109 // Result exponent may be one less then the current value of e.
3110 // The coefficients of the BigNumbers from convertBase may have trailing zeros.
3111 for ( i = 0; yc[i] == ( xc[i] || 0 ); i++ );
3112 if ( yc[i] > ( xc[i] || 0 ) ) e--;
3113
3114 if ( s < 0 ) {
3115 qc.push(1);
3116 more = true;
3117 } else {
3118 xL = xc.length;
3119 yL = yc.length;
3120 i = 0;
3121 s += 2;
3122
3123 // Normalise xc and yc so highest order digit of yc is >= base / 2.
3124
3125 n = mathfloor( base / ( yc[0] + 1 ) );
3126
3127 // Not necessary, but to handle odd bases where yc[0] == ( base / 2 ) - 1.
3128 // if ( n > 1 || n++ == 1 && yc[0] < base / 2 ) {
3129 if ( n > 1 ) {
3130 yc = multiply( yc, n, base );
3131 xc = multiply( xc, n, base );
3132 yL = yc.length;
3133 xL = xc.length;
3134 }
3135
3136 xi = yL;
3137 rem = xc.slice( 0, yL );
3138 remL = rem.length;
3139
3140 // Add zeros to make remainder as long as divisor.
3141 for ( ; remL < yL; rem[remL++] = 0 );
3142 yz = yc.slice();
3143 yz = [0].concat(yz);
3144 yc0 = yc[0];
3145 if ( yc[1] >= base / 2 ) yc0++;
3146 // Not necessary, but to prevent trial digit n > base, when using base 3.
3147 // else if ( base == 3 && yc0 == 1 ) yc0 = 1 + 1e-15;
3148
3149 do {
3150 n = 0;
3151
3152 // Compare divisor and remainder.
3153 cmp = compare( yc, rem, yL, remL );
3154
3155 // If divisor < remainder.
3156 if ( cmp < 0 ) {
3157
3158 // Calculate trial digit, n.
3159
3160 rem0 = rem[0];
3161 if ( yL != remL ) rem0 = rem0 * base + ( rem[1] || 0 );
3162
3163 // n is how many times the divisor goes into the current remainder.
3164 n = mathfloor( rem0 / yc0 );
3165
3166 // Algorithm:
3167 // 1. product = divisor * trial digit (n)
3168 // 2. if product > remainder: product -= divisor, n--
3169 // 3. remainder -= product
3170 // 4. if product was < remainder at 2:
3171 // 5. compare new remainder and divisor
3172 // 6. If remainder > divisor: remainder -= divisor, n++
3173
3174 if ( n > 1 ) {
3175
3176 // n may be > base only when base is 3.
3177 if (n >= base) n = base - 1;
3178
3179 // product = divisor * trial digit.
3180 prod = multiply( yc, n, base );
3181 prodL = prod.length;
3182 remL = rem.length;
3183
3184 // Compare product and remainder.
3185 // If product > remainder.
3186 // Trial digit n too high.
3187 // n is 1 too high about 5% of the time, and is not known to have
3188 // ever been more than 1 too high.
3189 while ( compare( prod, rem, prodL, remL ) == 1 ) {
3190 n--;
3191
3192 // Subtract divisor from product.
3193 subtract( prod, yL < prodL ? yz : yc, prodL, base );
3194 prodL = prod.length;
3195 cmp = 1;
3196 }
3197 } else {
3198
3199 // n is 0 or 1, cmp is -1.
3200 // If n is 0, there is no need to compare yc and rem again below,
3201 // so change cmp to 1 to avoid it.
3202 // If n is 1, leave cmp as -1, so yc and rem are compared again.
3203 if ( n == 0 ) {
3204
3205 // divisor < remainder, so n must be at least 1.
3206 cmp = n = 1;
3207 }
3208
3209 // product = divisor
3210 prod = yc.slice();
3211 prodL = prod.length;
3212 }
3213
3214 if ( prodL < remL ) prod = [0].concat(prod);
3215
3216 // Subtract product from remainder.
3217 subtract( rem, prod, remL, base );
3218 remL = rem.length;
3219
3220 // If product was < remainder.
3221 if ( cmp == -1 ) {
3222
3223 // Compare divisor and new remainder.
3224 // If divisor < new remainder, subtract divisor from remainder.
3225 // Trial digit n too low.
3226 // n is 1 too low about 5% of the time, and very rarely 2 too low.
3227 while ( compare( yc, rem, yL, remL ) < 1 ) {
3228 n++;
3229
3230 // Subtract divisor from remainder.
3231 subtract( rem, yL < remL ? yz : yc, remL, base );
3232 remL = rem.length;
3233 }
3234 }
3235 } else if ( cmp === 0 ) {
3236 n++;
3237 rem = [0];
3238 } // else cmp === 1 and n will be 0
3239
3240 // Add the next digit, n, to the result array.
3241 qc[i++] = n;
3242
3243 // Update the remainder.
3244 if ( rem[0] ) {
3245 rem[remL++] = xc[xi] || 0;
3246 } else {
3247 rem = [ xc[xi] ];
3248 remL = 1;
3249 }
3250 } while ( ( xi++ < xL || rem[0] != null ) && s-- );
3251
3252 more = rem[0] != null;
3253
3254 // Leading zero?
3255 if ( !qc[0] ) qc.splice(0, 1);
3256 }
3257
3258 if ( base == BASE ) {
3259
3260 // To calculate q.e, first get the number of digits of qc[0].
3261 for ( i = 1, s = qc[0]; s >= 10; s /= 10, i++ );
3262 round( q, dp + ( q.e = i + e * LOG_BASE - 1 ) + 1, rm, more );
3263
3264 // Caller is convertBase.
3265 } else {
3266 q.e = e;
3267 q.r = +more;
3268 }
3269
3270 return q;
3271 };
3272 })();
3273
3274
3275 /*
3276 * Return a string representing the value of BigNumber n in fixed-point or exponential
3277 * notation rounded to the specified decimal places or significant digits.
3278 *
3279 * n is a BigNumber.
3280 * i is the index of the last digit required (i.e. the digit that may be rounded up).
3281 * rm is the rounding mode.
3282 * caller is caller id: toExponential 19, toFixed 20, toFormat 21, toPrecision 24.
3283 */
3284 function format( n, i, rm, caller ) {
3285 var c0, e, ne, len, str;
3286
3287 rm = rm != null && isValidInt( rm, 0, 8, caller, roundingMode )
3288 ? rm | 0 : ROUNDING_MODE;
3289
3290 if ( !n.c ) return n.toString();
3291 c0 = n.c[0];
3292 ne = n.e;
3293
3294 if ( i == null ) {
3295 str = coeffToString( n.c );
3296 str = caller == 19 || caller == 24 && ne <= TO_EXP_NEG
3297 ? toExponential( str, ne )
3298 : toFixedPoint( str, ne );
3299 } else {
3300 n = round( new BigNumber(n), i, rm );
3301
3302 // n.e may have changed if the value was rounded up.
3303 e = n.e;
3304
3305 str = coeffToString( n.c );
3306 len = str.length;
3307
3308 // toPrecision returns exponential notation if the number of significant digits
3309 // specified is less than the number of digits necessary to represent the integer
3310 // part of the value in fixed-point notation.
3311
3312 // Exponential notation.
3313 if ( caller == 19 || caller == 24 && ( i <= e || e <= TO_EXP_NEG ) ) {
3314
3315 // Append zeros?
3316 for ( ; len < i; str += '0', len++ );
3317 str = toExponential( str, e );
3318
3319 // Fixed-point notation.
3320 } else {
3321 i -= ne;
3322 str = toFixedPoint( str, e );
3323
3324 // Append zeros?
3325 if ( e + 1 > len ) {
3326 if ( --i > 0 ) for ( str += '.'; i--; str += '0' );
3327 } else {
3328 i += e - len;
3329 if ( i > 0 ) {
3330 if ( e + 1 == len ) str += '.';
3331 for ( ; i--; str += '0' );
3332 }
3333 }
3334 }
3335 }
3336
3337 return n.s < 0 && c0 ? '-' + str : str;
3338 }
3339
3340
3341 // Handle BigNumber.max and BigNumber.min.
3342 function maxOrMin( args, method ) {
3343 var m, n,
3344 i = 0;
3345
3346 if ( isArray( args[0] ) ) args = args[0];
3347 m = new BigNumber( args[0] );
3348
3349 for ( ; ++i < args.length; ) {
3350 n = new BigNumber( args[i] );
3351
3352 // If any number is NaN, return NaN.
3353 if ( !n.s ) {
3354 m = n;
3355 break;
3356 } else if ( method.call( m, n ) ) {
3357 m = n;
3358 }
3359 }
3360
3361 return m;
3362 }
3363
3364
3365 /*
3366 * Return true if n is an integer in range, otherwise throw.
3367 * Use for argument validation when ERRORS is true.
3368 */
3369 function intValidatorWithErrors( n, min, max, caller, name ) {
3370 if ( n < min || n > max || n != truncate(n) ) {
3371 raise( caller, ( name || 'decimal places' ) +
3372 ( n < min || n > max ? ' out of range' : ' not an integer' ), n );
3373 }
3374
3375 return true;
3376 }
3377
3378
3379 /*
3380 * Strip trailing zeros, calculate base 10 exponent and check against MIN_EXP and MAX_EXP.
3381 * Called by minus, plus and times.
3382 */
3383 function normalise( n, c, e ) {
3384 var i = 1,
3385 j = c.length;
3386
3387 // Remove trailing zeros.
3388 for ( ; !c[--j]; c.pop() );
3389
3390 // Calculate the base 10 exponent. First get the number of digits of c[0].
3391 for ( j = c[0]; j >= 10; j /= 10, i++ );
3392
3393 // Overflow?
3394 if ( ( e = i + e * LOG_BASE - 1 ) > MAX_EXP ) {
3395
3396 // Infinity.
3397 n.c = n.e = null;
3398
3399 // Underflow?
3400 } else if ( e < MIN_EXP ) {
3401
3402 // Zero.
3403 n.c = [ n.e = 0 ];
3404 } else {
3405 n.e = e;
3406 n.c = c;
3407 }
3408
3409 return n;
3410 }
3411
3412
3413 // Handle values that fail the validity test in BigNumber.
3414 parseNumeric = (function () {
3415 var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i,
3416 dotAfter = /^([^.]+)\.$/,
3417 dotBefore = /^\.([^.]+)$/,
3418 isInfinityOrNaN = /^-?(Infinity|NaN)$/,
3419 whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
3420
3421 return function ( x, str, num, b ) {
3422 var base,
3423 s = num ? str : str.replace( whitespaceOrPlus, '' );
3424
3425 // No exception on ±Infinity or NaN.
3426 if ( isInfinityOrNaN.test(s) ) {
3427 x.s = isNaN(s) ? null : s < 0 ? -1 : 1;
3428 } else {
3429 if ( !num ) {
3430
3431 // basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i
3432 s = s.replace( basePrefix, function ( m, p1, p2 ) {
3433 base = ( p2 = p2.toLowerCase() ) == 'x' ? 16 : p2 == 'b' ? 2 : 8;
3434 return !b || b == base ? p1 : m;
3435 });
3436
3437 if (b) {
3438 base = b;
3439
3440 // E.g. '1.' to '1', '.1' to '0.1'
3441 s = s.replace( dotAfter, '$1' ).replace( dotBefore, '0.$1' );
3442 }
3443
3444 if ( str != s ) return new BigNumber( s, base );
3445 }
3446
3447 // 'new BigNumber() not a number: {n}'
3448 // 'new BigNumber() not a base {b} number: {n}'
3449 if (ERRORS) raise( id, 'not a' + ( b ? ' base ' + b : '' ) + ' number', str );
3450 x.s = null;
3451 }
3452
3453 x.c = x.e = null;
3454 id = 0;
3455 }
3456 })();
3457
3458
3459 // Throw a BigNumber Error.
3460 function raise( caller, msg, val ) {
3461 var error = new Error( [
3462 'new BigNumber', // 0
3463 'cmp', // 1
3464 'config', // 2
3465 'div', // 3
3466 'divToInt', // 4
3467 'eq', // 5
3468 'gt', // 6
3469 'gte', // 7
3470 'lt', // 8
3471 'lte', // 9
3472 'minus', // 10
3473 'mod', // 11
3474 'plus', // 12
3475 'precision', // 13
3476 'random', // 14
3477 'round', // 15
3478 'shift', // 16
3479 'times', // 17
3480 'toDigits', // 18
3481 'toExponential', // 19
3482 'toFixed', // 20
3483 'toFormat', // 21
3484 'toFraction', // 22
3485 'pow', // 23
3486 'toPrecision', // 24
3487 'toString', // 25
3488 'BigNumber' // 26
3489 ][caller] + '() ' + msg + ': ' + val );
3490
3491 error.name = 'BigNumber Error';
3492 id = 0;
3493 throw error;
3494 }
3495
3496
3497 /*
3498 * Round x to sd significant digits using rounding mode rm. Check for over/under-flow.
3499 * If r is truthy, it is known that there are more digits after the rounding digit.
3500 */
3501 function round( x, sd, rm, r ) {
3502 var d, i, j, k, n, ni, rd,
3503 xc = x.c,
3504 pows10 = POWS_TEN;
3505
3506 // if x is not Infinity or NaN...
3507 if (xc) {
3508
3509 // rd is the rounding digit, i.e. the digit after the digit that may be rounded up.
3510 // n is a base 1e14 number, the value of the element of array x.c containing rd.
3511 // ni is the index of n within x.c.
3512 // d is the number of digits of n.
3513 // i is the index of rd within n including leading zeros.
3514 // j is the actual index of rd within n (if < 0, rd is a leading zero).
3515 out: {
3516
3517 // Get the number of digits of the first element of xc.
3518 for ( d = 1, k = xc[0]; k >= 10; k /= 10, d++ );
3519 i = sd - d;
3520
3521 // If the rounding digit is in the first element of xc...
3522 if ( i < 0 ) {
3523 i += LOG_BASE;
3524 j = sd;
3525 n = xc[ ni = 0 ];
3526
3527 // Get the rounding digit at index j of n.
3528 rd = n / pows10[ d - j - 1 ] % 10 | 0;
3529 } else {
3530 ni = mathceil( ( i + 1 ) / LOG_BASE );
3531
3532 if ( ni >= xc.length ) {
3533
3534 if (r) {
3535
3536 // Needed by sqrt.
3537 for ( ; xc.length <= ni; xc.push(0) );
3538 n = rd = 0;
3539 d = 1;
3540 i %= LOG_BASE;
3541 j = i - LOG_BASE + 1;
3542 } else {
3543 break out;
3544 }
3545 } else {
3546 n = k = xc[ni];
3547
3548 // Get the number of digits of n.
3549 for ( d = 1; k >= 10; k /= 10, d++ );
3550
3551 // Get the index of rd within n.
3552 i %= LOG_BASE;
3553
3554 // Get the index of rd within n, adjusted for leading zeros.
3555 // The number of leading zeros of n is given by LOG_BASE - d.
3556 j = i - LOG_BASE + d;
3557
3558 // Get the rounding digit at index j of n.
3559 rd = j < 0 ? 0 : n / pows10[ d - j - 1 ] % 10 | 0;
3560 }
3561 }
3562
3563 r = r || sd < 0 ||
3564
3565 // Are there any non-zero digits after the rounding digit?
3566 // The expression n % pows10[ d - j - 1 ] returns all digits of n to the right
3567 // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.
3568 xc[ni + 1] != null || ( j < 0 ? n : n % pows10[ d - j - 1 ] );
3569
3570 r = rm < 4
3571 ? ( rd || r ) && ( rm == 0 || rm == ( x.s < 0 ? 3 : 2 ) )
3572 : rd > 5 || rd == 5 && ( rm == 4 || r || rm == 6 &&
3573
3574 // Check whether the digit to the left of the rounding digit is odd.
3575 ( ( i > 0 ? j > 0 ? n / pows10[ d - j ] : 0 : xc[ni - 1] ) % 10 ) & 1 ||
3576 rm == ( x.s < 0 ? 8 : 7 ) );
3577
3578 if ( sd < 1 || !xc[0] ) {
3579 xc.length = 0;
3580
3581 if (r) {
3582
3583 // Convert sd to decimal places.
3584 sd -= x.e + 1;
3585
3586 // 1, 0.1, 0.01, 0.001, 0.0001 etc.
3587 xc[0] = pows10[ ( LOG_BASE - sd % LOG_BASE ) % LOG_BASE ];
3588 x.e = -sd || 0;
3589 } else {
3590
3591 // Zero.
3592 xc[0] = x.e = 0;
3593 }
3594
3595 return x;
3596 }
3597
3598 // Remove excess digits.
3599 if ( i == 0 ) {
3600 xc.length = ni;
3601 k = 1;
3602 ni--;
3603 } else {
3604 xc.length = ni + 1;
3605 k = pows10[ LOG_BASE - i ];
3606
3607 // E.g. 56700 becomes 56000 if 7 is the rounding digit.
3608 // j > 0 means i > number of leading zeros of n.
3609 xc[ni] = j > 0 ? mathfloor( n / pows10[ d - j ] % pows10[j] ) * k : 0;
3610 }
3611
3612 // Round up?
3613 if (r) {
3614
3615 for ( ; ; ) {
3616
3617 // If the digit to be rounded up is in the first element of xc...
3618 if ( ni == 0 ) {
3619
3620 // i will be the length of xc[0] before k is added.
3621 for ( i = 1, j = xc[0]; j >= 10; j /= 10, i++ );
3622 j = xc[0] += k;
3623 for ( k = 1; j >= 10; j /= 10, k++ );
3624
3625 // if i != k the length has increased.
3626 if ( i != k ) {
3627 x.e++;
3628 if ( xc[0] == BASE ) xc[0] = 1;
3629 }
3630
3631 break;
3632 } else {
3633 xc[ni] += k;
3634 if ( xc[ni] != BASE ) break;
3635 xc[ni--] = 0;
3636 k = 1;
3637 }
3638 }
3639 }
3640
3641 // Remove trailing zeros.
3642 for ( i = xc.length; xc[--i] === 0; xc.pop() );
3643 }
3644
3645 // Overflow? Infinity.
3646 if ( x.e > MAX_EXP ) {
3647 x.c = x.e = null;
3648
3649 // Underflow? Zero.
3650 } else if ( x.e < MIN_EXP ) {
3651 x.c = [ x.e = 0 ];
3652 }
3653 }
3654
3655 return x;
3656 }
3657
3658
3659 // PROTOTYPE/INSTANCE METHODS
3660
3661
3662 /*
3663 * Return a new BigNumber whose value is the absolute value of this BigNumber.
3664 */
3665 P.absoluteValue = P.abs = function () {
3666 var x = new BigNumber(this);
3667 if ( x.s < 0 ) x.s = 1;
3668 return x;
3669 };
3670
3671
3672 /*
3673 * Return a new BigNumber whose value is the value of this BigNumber rounded to a whole
3674 * number in the direction of Infinity.
3675 */
3676 P.ceil = function () {
3677 return round( new BigNumber(this), this.e + 1, 2 );
3678 };
3679
3680
3681 /*
3682 * Return
3683 * 1 if the value of this BigNumber is greater than the value of BigNumber(y, b),
3684 * -1 if the value of this BigNumber is less than the value of BigNumber(y, b),
3685 * 0 if they have the same value,
3686 * or null if the value of either is NaN.
3687 */
3688 P.comparedTo = P.cmp = function ( y, b ) {
3689 id = 1;
3690 return compare( this, new BigNumber( y, b ) );
3691 };
3692
3693
3694 /*
3695 * Return the number of decimal places of the value of this BigNumber, or null if the value
3696 * of this BigNumber is ±Infinity or NaN.
3697 */
3698 P.decimalPlaces = P.dp = function () {
3699 var n, v,
3700 c = this.c;
3701
3702 if ( !c ) return null;
3703 n = ( ( v = c.length - 1 ) - bitFloor( this.e / LOG_BASE ) ) * LOG_BASE;
3704
3705 // Subtract the number of trailing zeros of the last number.
3706 if ( v = c[v] ) for ( ; v % 10 == 0; v /= 10, n-- );
3707 if ( n < 0 ) n = 0;
3708
3709 return n;
3710 };
3711
3712
3713 /*
3714 * n / 0 = I
3715 * n / N = N
3716 * n / I = 0
3717 * 0 / n = 0
3718 * 0 / 0 = N
3719 * 0 / N = N
3720 * 0 / I = 0
3721 * N / n = N
3722 * N / 0 = N
3723 * N / N = N
3724 * N / I = N
3725 * I / n = I
3726 * I / 0 = I
3727 * I / N = N
3728 * I / I = N
3729 *
3730 * Return a new BigNumber whose value is the value of this BigNumber divided by the value of
3731 * BigNumber(y, b), rounded according to DECIMAL_PLACES and ROUNDING_MODE.
3732 */
3733 P.dividedBy = P.div = function ( y, b ) {
3734 id = 3;
3735 return div( this, new BigNumber( y, b ), DECIMAL_PLACES, ROUNDING_MODE );
3736 };
3737
3738
3739 /*
3740 * Return a new BigNumber whose value is the integer part of dividing the value of this
3741 * BigNumber by the value of BigNumber(y, b).
3742 */
3743 P.dividedToIntegerBy = P.divToInt = function ( y, b ) {
3744 id = 4;
3745 return div( this, new BigNumber( y, b ), 0, 1 );
3746 };
3747
3748
3749 /*
3750 * Return true if the value of this BigNumber is equal to the value of BigNumber(y, b),
3751 * otherwise returns false.
3752 */
3753 P.equals = P.eq = function ( y, b ) {
3754 id = 5;
3755 return compare( this, new BigNumber( y, b ) ) === 0;
3756 };
3757
3758
3759 /*
3760 * Return a new BigNumber whose value is the value of this BigNumber rounded to a whole
3761 * number in the direction of -Infinity.
3762 */
3763 P.floor = function () {
3764 return round( new BigNumber(this), this.e + 1, 3 );
3765 };
3766
3767
3768 /*
3769 * Return true if the value of this BigNumber is greater than the value of BigNumber(y, b),
3770 * otherwise returns false.
3771 */
3772 P.greaterThan = P.gt = function ( y, b ) {
3773 id = 6;
3774 return compare( this, new BigNumber( y, b ) ) > 0;
3775 };
3776
3777
3778 /*
3779 * Return true if the value of this BigNumber is greater than or equal to the value of
3780 * BigNumber(y, b), otherwise returns false.
3781 */
3782 P.greaterThanOrEqualTo = P.gte = function ( y, b ) {
3783 id = 7;
3784 return ( b = compare( this, new BigNumber( y, b ) ) ) === 1 || b === 0;
3785
3786 };
3787
3788
3789 /*
3790 * Return true if the value of this BigNumber is a finite number, otherwise returns false.
3791 */
3792 P.isFinite = function () {
3793 return !!this.c;
3794 };
3795
3796
3797 /*
3798 * Return true if the value of this BigNumber is an integer, otherwise return false.
3799 */
3800 P.isInteger = P.isInt = function () {
3801 return !!this.c && bitFloor( this.e / LOG_BASE ) > this.c.length - 2;
3802 };
3803
3804
3805 /*
3806 * Return true if the value of this BigNumber is NaN, otherwise returns false.
3807 */
3808 P.isNaN = function () {
3809 return !this.s;
3810 };
3811
3812
3813 /*
3814 * Return true if the value of this BigNumber is negative, otherwise returns false.
3815 */
3816 P.isNegative = P.isNeg = function () {
3817 return this.s < 0;
3818 };
3819
3820
3821 /*
3822 * Return true if the value of this BigNumber is 0 or -0, otherwise returns false.
3823 */
3824 P.isZero = function () {
3825 return !!this.c && this.c[0] == 0;
3826 };
3827
3828
3829 /*
3830 * Return true if the value of this BigNumber is less than the value of BigNumber(y, b),
3831 * otherwise returns false.
3832 */
3833 P.lessThan = P.lt = function ( y, b ) {
3834 id = 8;
3835 return compare( this, new BigNumber( y, b ) ) < 0;
3836 };
3837
3838
3839 /*
3840 * Return true if the value of this BigNumber is less than or equal to the value of
3841 * BigNumber(y, b), otherwise returns false.
3842 */
3843 P.lessThanOrEqualTo = P.lte = function ( y, b ) {
3844 id = 9;
3845 return ( b = compare( this, new BigNumber( y, b ) ) ) === -1 || b === 0;
3846 };
3847
3848
3849 /*
3850 * n - 0 = n
3851 * n - N = N
3852 * n - I = -I
3853 * 0 - n = -n
3854 * 0 - 0 = 0
3855 * 0 - N = N
3856 * 0 - I = -I
3857 * N - n = N
3858 * N - 0 = N
3859 * N - N = N
3860 * N - I = N
3861 * I - n = I
3862 * I - 0 = I
3863 * I - N = N
3864 * I - I = N
3865 *
3866 * Return a new BigNumber whose value is the value of this BigNumber minus the value of
3867 * BigNumber(y, b).
3868 */
3869 P.minus = P.sub = function ( y, b ) {
3870 var i, j, t, xLTy,
3871 x = this,
3872 a = x.s;
3873
3874 id = 10;
3875 y = new BigNumber( y, b );
3876 b = y.s;
3877
3878 // Either NaN?
3879 if ( !a || !b ) return new BigNumber(NaN);
3880
3881 // Signs differ?
3882 if ( a != b ) {
3883 y.s = -b;
3884 return x.plus(y);
3885 }
3886
3887 var xe = x.e / LOG_BASE,
3888 ye = y.e / LOG_BASE,
3889 xc = x.c,
3890 yc = y.c;
3891
3892 if ( !xe || !ye ) {
3893
3894 // Either Infinity?
3895 if ( !xc || !yc ) return xc ? ( y.s = -b, y ) : new BigNumber( yc ? x : NaN );
3896
3897 // Either zero?
3898 if ( !xc[0] || !yc[0] ) {
3899
3900 // Return y if y is non-zero, x if x is non-zero, or zero if both are zero.
3901 return yc[0] ? ( y.s = -b, y ) : new BigNumber( xc[0] ? x :
3902
3903 // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
3904 ROUNDING_MODE == 3 ? -0 : 0 );
3905 }
3906 }
3907
3908 xe = bitFloor(xe);
3909 ye = bitFloor(ye);
3910 xc = xc.slice();
3911
3912 // Determine which is the bigger number.
3913 if ( a = xe - ye ) {
3914
3915 if ( xLTy = a < 0 ) {
3916 a = -a;
3917 t = xc;
3918 } else {
3919 ye = xe;
3920 t = yc;
3921 }
3922
3923 t.reverse();
3924
3925 // Prepend zeros to equalise exponents.
3926 for ( b = a; b--; t.push(0) );
3927 t.reverse();
3928 } else {
3929
3930 // Exponents equal. Check digit by digit.
3931 j = ( xLTy = ( a = xc.length ) < ( b = yc.length ) ) ? a : b;
3932
3933 for ( a = b = 0; b < j; b++ ) {
3934
3935 if ( xc[b] != yc[b] ) {
3936 xLTy = xc[b] < yc[b];
3937 break;
3938 }
3939 }
3940 }
3941
3942 // x < y? Point xc to the array of the bigger number.
3943 if (xLTy) t = xc, xc = yc, yc = t, y.s = -y.s;
3944
3945 b = ( j = yc.length ) - ( i = xc.length );
3946
3947 // Append zeros to xc if shorter.
3948 // No need to add zeros to yc if shorter as subtract only needs to start at yc.length.
3949 if ( b > 0 ) for ( ; b--; xc[i++] = 0 );
3950 b = BASE - 1;
3951
3952 // Subtract yc from xc.
3953 for ( ; j > a; ) {
3954
3955 if ( xc[--j] < yc[j] ) {
3956 for ( i = j; i && !xc[--i]; xc[i] = b );
3957 --xc[i];
3958 xc[j] += BASE;
3959 }
3960
3961 xc[j] -= yc[j];
3962 }
3963
3964 // Remove leading zeros and adjust exponent accordingly.
3965 for ( ; xc[0] == 0; xc.splice(0, 1), --ye );
3966
3967 // Zero?
3968 if ( !xc[0] ) {
3969
3970 // Following IEEE 754 (2008) 6.3,
3971 // n - n = +0 but n - n = -0 when rounding towards -Infinity.
3972 y.s = ROUNDING_MODE == 3 ? -1 : 1;
3973 y.c = [ y.e = 0 ];
3974 return y;
3975 }
3976
3977 // No need to check for Infinity as +x - +y != Infinity && -x - -y != Infinity
3978 // for finite x and y.
3979 return normalise( y, xc, ye );
3980 };
3981
3982
3983 /*
3984 * n % 0 = N
3985 * n % N = N
3986 * n % I = n
3987 * 0 % n = 0
3988 * -0 % n = -0
3989 * 0 % 0 = N
3990 * 0 % N = N
3991 * 0 % I = 0
3992 * N % n = N
3993 * N % 0 = N
3994 * N % N = N
3995 * N % I = N
3996 * I % n = N
3997 * I % 0 = N
3998 * I % N = N
3999 * I % I = N
4000 *
4001 * Return a new BigNumber whose value is the value of this BigNumber modulo the value of
4002 * BigNumber(y, b). The result depends on the value of MODULO_MODE.
4003 */
4004 P.modulo = P.mod = function ( y, b ) {
4005 var q, s,
4006 x = this;
4007
4008 id = 11;
4009 y = new BigNumber( y, b );
4010
4011 // Return NaN if x is Infinity or NaN, or y is NaN or zero.
4012 if ( !x.c || !y.s || y.c && !y.c[0] ) {
4013 return new BigNumber(NaN);
4014
4015 // Return x if y is Infinity or x is zero.
4016 } else if ( !y.c || x.c && !x.c[0] ) {
4017 return new BigNumber(x);
4018 }
4019
4020 if ( MODULO_MODE == 9 ) {
4021
4022 // Euclidian division: q = sign(y) * floor(x / abs(y))
4023 // r = x - qy where 0 <= r < abs(y)
4024 s = y.s;
4025 y.s = 1;
4026 q = div( x, y, 0, 3 );
4027 y.s = s;
4028 q.s *= s;
4029 } else {
4030 q = div( x, y, 0, MODULO_MODE );
4031 }
4032
4033 return x.minus( q.times(y) );
4034 };
4035
4036
4037 /*
4038 * Return a new BigNumber whose value is the value of this BigNumber negated,
4039 * i.e. multiplied by -1.
4040 */
4041 P.negated = P.neg = function () {
4042 var x = new BigNumber(this);
4043 x.s = -x.s || null;
4044 return x;
4045 };
4046
4047
4048 /*
4049 * n + 0 = n
4050 * n + N = N
4051 * n + I = I
4052 * 0 + n = n
4053 * 0 + 0 = 0
4054 * 0 + N = N
4055 * 0 + I = I
4056 * N + n = N
4057 * N + 0 = N
4058 * N + N = N
4059 * N + I = N
4060 * I + n = I
4061 * I + 0 = I
4062 * I + N = N
4063 * I + I = I
4064 *
4065 * Return a new BigNumber whose value is the value of this BigNumber plus the value of
4066 * BigNumber(y, b).
4067 */
4068 P.plus = P.add = function ( y, b ) {
4069 var t,
4070 x = this,
4071 a = x.s;
4072
4073 id = 12;
4074 y = new BigNumber( y, b );
4075 b = y.s;
4076
4077 // Either NaN?
4078 if ( !a || !b ) return new BigNumber(NaN);
4079
4080 // Signs differ?
4081 if ( a != b ) {
4082 y.s = -b;
4083 return x.minus(y);
4084 }
4085
4086 var xe = x.e / LOG_BASE,
4087 ye = y.e / LOG_BASE,
4088 xc = x.c,
4089 yc = y.c;
4090
4091 if ( !xe || !ye ) {
4092
4093 // Return ±Infinity if either ±Infinity.
4094 if ( !xc || !yc ) return new BigNumber( a / 0 );
4095
4096 // Either zero?
4097 // Return y if y is non-zero, x if x is non-zero, or zero if both are zero.
4098 if ( !xc[0] || !yc[0] ) return yc[0] ? y : new BigNumber( xc[0] ? x : a * 0 );
4099 }
4100
4101 xe = bitFloor(xe);
4102 ye = bitFloor(ye);
4103 xc = xc.slice();
4104
4105 // Prepend zeros to equalise exponents. Faster to use reverse then do unshifts.
4106 if ( a = xe - ye ) {
4107 if ( a > 0 ) {
4108 ye = xe;
4109 t = yc;
4110 } else {
4111 a = -a;
4112 t = xc;
4113 }
4114
4115 t.reverse();
4116 for ( ; a--; t.push(0) );
4117 t.reverse();
4118 }
4119
4120 a = xc.length;
4121 b = yc.length;
4122
4123 // Point xc to the longer array, and b to the shorter length.
4124 if ( a - b < 0 ) t = yc, yc = xc, xc = t, b = a;
4125
4126 // Only start adding at yc.length - 1 as the further digits of xc can be ignored.
4127 for ( a = 0; b; ) {
4128 a = ( xc[--b] = xc[b] + yc[b] + a ) / BASE | 0;
4129 xc[b] = BASE === xc[b] ? 0 : xc[b] % BASE;
4130 }
4131
4132 if (a) {
4133 xc = [a].concat(xc);
4134 ++ye;
4135 }
4136
4137 // No need to check for zero, as +x + +y != 0 && -x + -y != 0
4138 // ye = MAX_EXP + 1 possible
4139 return normalise( y, xc, ye );
4140 };
4141
4142
4143 /*
4144 * Return the number of significant digits of the value of this BigNumber.
4145 *
4146 * [z] {boolean|number} Whether to count integer-part trailing zeros: true, false, 1 or 0.
4147 */
4148 P.precision = P.sd = function (z) {
4149 var n, v,
4150 x = this,
4151 c = x.c;
4152
4153 // 'precision() argument not a boolean or binary digit: {z}'
4154 if ( z != null && z !== !!z && z !== 1 && z !== 0 ) {
4155 if (ERRORS) raise( 13, 'argument' + notBool, z );
4156 if ( z != !!z ) z = null;
4157 }
4158
4159 if ( !c ) return null;
4160 v = c.length - 1;
4161 n = v * LOG_BASE + 1;
4162
4163 if ( v = c[v] ) {
4164
4165 // Subtract the number of trailing zeros of the last element.
4166 for ( ; v % 10 == 0; v /= 10, n-- );
4167
4168 // Add the number of digits of the first element.
4169 for ( v = c[0]; v >= 10; v /= 10, n++ );
4170 }
4171
4172 if ( z && x.e + 1 > n ) n = x.e + 1;
4173
4174 return n;
4175 };
4176
4177
4178 /*
4179 * Return a new BigNumber whose value is the value of this BigNumber rounded to a maximum of
4180 * dp decimal places using rounding mode rm, or to 0 and ROUNDING_MODE respectively if
4181 * omitted.
4182 *
4183 * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
4184 * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
4185 *
4186 * 'round() decimal places out of range: {dp}'
4187 * 'round() decimal places not an integer: {dp}'
4188 * 'round() rounding mode not an integer: {rm}'
4189 * 'round() rounding mode out of range: {rm}'
4190 */
4191 P.round = function ( dp, rm ) {
4192 var n = new BigNumber(this);
4193
4194 if ( dp == null || isValidInt( dp, 0, MAX, 15 ) ) {
4195 round( n, ~~dp + this.e + 1, rm == null ||
4196 !isValidInt( rm, 0, 8, 15, roundingMode ) ? ROUNDING_MODE : rm | 0 );
4197 }
4198
4199 return n;
4200 };
4201
4202
4203 /*
4204 * Return a new BigNumber whose value is the value of this BigNumber shifted by k places
4205 * (powers of 10). Shift to the right if n > 0, and to the left if n < 0.
4206 *
4207 * k {number} Integer, -MAX_SAFE_INTEGER to MAX_SAFE_INTEGER inclusive.
4208 *
4209 * If k is out of range and ERRORS is false, the result will be ±0 if k < 0, or ±Infinity
4210 * otherwise.
4211 *
4212 * 'shift() argument not an integer: {k}'
4213 * 'shift() argument out of range: {k}'
4214 */
4215 P.shift = function (k) {
4216 var n = this;
4217 return isValidInt( k, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER, 16, 'argument' )
4218
4219 // k < 1e+21, or truncate(k) will produce exponential notation.
4220 ? n.times( '1e' + truncate(k) )
4221 : new BigNumber( n.c && n.c[0] && ( k < -MAX_SAFE_INTEGER || k > MAX_SAFE_INTEGER )
4222 ? n.s * ( k < 0 ? 0 : 1 / 0 )
4223 : n );
4224 };
4225
4226
4227 /*
4228 * sqrt(-n) = N
4229 * sqrt( N) = N
4230 * sqrt(-I) = N
4231 * sqrt( I) = I
4232 * sqrt( 0) = 0
4233 * sqrt(-0) = -0
4234 *
4235 * Return a new BigNumber whose value is the square root of the value of this BigNumber,
4236 * rounded according to DECIMAL_PLACES and ROUNDING_MODE.
4237 */
4238 P.squareRoot = P.sqrt = function () {
4239 var m, n, r, rep, t,
4240 x = this,
4241 c = x.c,
4242 s = x.s,
4243 e = x.e,
4244 dp = DECIMAL_PLACES + 4,
4245 half = new BigNumber('0.5');
4246
4247 // Negative/NaN/Infinity/zero?
4248 if ( s !== 1 || !c || !c[0] ) {
4249 return new BigNumber( !s || s < 0 && ( !c || c[0] ) ? NaN : c ? x : 1 / 0 );
4250 }
4251
4252 // Initial estimate.
4253 s = Math.sqrt( +x );
4254
4255 // Math.sqrt underflow/overflow?
4256 // Pass x to Math.sqrt as integer, then adjust the exponent of the result.
4257 if ( s == 0 || s == 1 / 0 ) {
4258 n = coeffToString(c);
4259 if ( ( n.length + e ) % 2 == 0 ) n += '0';
4260 s = Math.sqrt(n);
4261 e = bitFloor( ( e + 1 ) / 2 ) - ( e < 0 || e % 2 );
4262
4263 if ( s == 1 / 0 ) {
4264 n = '1e' + e;
4265 } else {
4266 n = s.toExponential();
4267 n = n.slice( 0, n.indexOf('e') + 1 ) + e;
4268 }
4269
4270 r = new BigNumber(n);
4271 } else {
4272 r = new BigNumber( s + '' );
4273 }
4274
4275 // Check for zero.
4276 // r could be zero if MIN_EXP is changed after the this value was created.
4277 // This would cause a division by zero (x/t) and hence Infinity below, which would cause
4278 // coeffToString to throw.
4279 if ( r.c[0] ) {
4280 e = r.e;
4281 s = e + dp;
4282 if ( s < 3 ) s = 0;
4283
4284 // Newton-Raphson iteration.
4285 for ( ; ; ) {
4286 t = r;
4287 r = half.times( t.plus( div( x, t, dp, 1 ) ) );
4288
4289 if ( coeffToString( t.c ).slice( 0, s ) === ( n =
4290 coeffToString( r.c ) ).slice( 0, s ) ) {
4291
4292 // The exponent of r may here be one less than the final result exponent,
4293 // e.g 0.0009999 (e-4) --> 0.001 (e-3), so adjust s so the rounding digits
4294 // are indexed correctly.
4295 if ( r.e < e ) --s;
4296 n = n.slice( s - 3, s + 1 );
4297
4298 // The 4th rounding digit may be in error by -1 so if the 4 rounding digits
4299 // are 9999 or 4999 (i.e. approaching a rounding boundary) continue the
4300 // iteration.
4301 if ( n == '9999' || !rep && n == '4999' ) {
4302
4303 // On the first iteration only, check to see if rounding up gives the
4304 // exact result as the nines may infinitely repeat.
4305 if ( !rep ) {
4306 round( t, t.e + DECIMAL_PLACES + 2, 0 );
4307
4308 if ( t.times(t).eq(x) ) {
4309 r = t;
4310 break;
4311 }
4312 }
4313
4314 dp += 4;
4315 s += 4;
4316 rep = 1;
4317 } else {
4318
4319 // If rounding digits are null, 0{0,4} or 50{0,3}, check for exact
4320 // result. If not, then there are further digits and m will be truthy.
4321 if ( !+n || !+n.slice(1) && n.charAt(0) == '5' ) {
4322
4323 // Truncate to the first rounding digit.
4324 round( r, r.e + DECIMAL_PLACES + 2, 1 );
4325 m = !r.times(r).eq(x);
4326 }
4327
4328 break;
4329 }
4330 }
4331 }
4332 }
4333
4334 return round( r, r.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m );
4335 };
4336
4337
4338 /*
4339 * n * 0 = 0
4340 * n * N = N
4341 * n * I = I
4342 * 0 * n = 0
4343 * 0 * 0 = 0
4344 * 0 * N = N
4345 * 0 * I = N
4346 * N * n = N
4347 * N * 0 = N
4348 * N * N = N
4349 * N * I = N
4350 * I * n = I
4351 * I * 0 = N
4352 * I * N = N
4353 * I * I = I
4354 *
4355 * Return a new BigNumber whose value is the value of this BigNumber times the value of
4356 * BigNumber(y, b).
4357 */
4358 P.times = P.mul = function ( y, b ) {
4359 var c, e, i, j, k, m, xcL, xlo, xhi, ycL, ylo, yhi, zc,
4360 base, sqrtBase,
4361 x = this,
4362 xc = x.c,
4363 yc = ( id = 17, y = new BigNumber( y, b ) ).c;
4364
4365 // Either NaN, ±Infinity or ±0?
4366 if ( !xc || !yc || !xc[0] || !yc[0] ) {
4367
4368 // Return NaN if either is NaN, or one is 0 and the other is Infinity.
4369 if ( !x.s || !y.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc ) {
4370 y.c = y.e = y.s = null;
4371 } else {
4372 y.s *= x.s;
4373
4374 // Return ±Infinity if either is ±Infinity.
4375 if ( !xc || !yc ) {
4376 y.c = y.e = null;
4377
4378 // Return ±0 if either is ±0.
4379 } else {
4380 y.c = [0];
4381 y.e = 0;
4382 }
4383 }
4384
4385 return y;
4386 }
4387
4388 e = bitFloor( x.e / LOG_BASE ) + bitFloor( y.e / LOG_BASE );
4389 y.s *= x.s;
4390 xcL = xc.length;
4391 ycL = yc.length;
4392
4393 // Ensure xc points to longer array and xcL to its length.
4394 if ( xcL < ycL ) zc = xc, xc = yc, yc = zc, i = xcL, xcL = ycL, ycL = i;
4395
4396 // Initialise the result array with zeros.
4397 for ( i = xcL + ycL, zc = []; i--; zc.push(0) );
4398
4399 base = BASE;
4400 sqrtBase = SQRT_BASE;
4401
4402 for ( i = ycL; --i >= 0; ) {
4403 c = 0;
4404 ylo = yc[i] % sqrtBase;
4405 yhi = yc[i] / sqrtBase | 0;
4406
4407 for ( k = xcL, j = i + k; j > i; ) {
4408 xlo = xc[--k] % sqrtBase;
4409 xhi = xc[k] / sqrtBase | 0;
4410 m = yhi * xlo + xhi * ylo;
4411 xlo = ylo * xlo + ( ( m % sqrtBase ) * sqrtBase ) + zc[j] + c;
4412 c = ( xlo / base | 0 ) + ( m / sqrtBase | 0 ) + yhi * xhi;
4413 zc[j--] = xlo % base;
4414 }
4415
4416 zc[j] = c;
4417 }
4418
4419 if (c) {
4420 ++e;
4421 } else {
4422 zc.splice(0, 1);
4423 }
4424
4425 return normalise( y, zc, e );
4426 };
4427
4428
4429 /*
4430 * Return a new BigNumber whose value is the value of this BigNumber rounded to a maximum of
4431 * sd significant digits using rounding mode rm, or ROUNDING_MODE if rm is omitted.
4432 *
4433 * [sd] {number} Significant digits. Integer, 1 to MAX inclusive.
4434 * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
4435 *
4436 * 'toDigits() precision out of range: {sd}'
4437 * 'toDigits() precision not an integer: {sd}'
4438 * 'toDigits() rounding mode not an integer: {rm}'
4439 * 'toDigits() rounding mode out of range: {rm}'
4440 */
4441 P.toDigits = function ( sd, rm ) {
4442 var n = new BigNumber(this);
4443 sd = sd == null || !isValidInt( sd, 1, MAX, 18, 'precision' ) ? null : sd | 0;
4444 rm = rm == null || !isValidInt( rm, 0, 8, 18, roundingMode ) ? ROUNDING_MODE : rm | 0;
4445 return sd ? round( n, sd, rm ) : n;
4446 };
4447
4448
4449 /*
4450 * Return a string representing the value of this BigNumber in exponential notation and
4451 * rounded using ROUNDING_MODE to dp fixed decimal places.
4452 *
4453 * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
4454 * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
4455 *
4456 * 'toExponential() decimal places not an integer: {dp}'
4457 * 'toExponential() decimal places out of range: {dp}'
4458 * 'toExponential() rounding mode not an integer: {rm}'
4459 * 'toExponential() rounding mode out of range: {rm}'
4460 */
4461 P.toExponential = function ( dp, rm ) {
4462 return format( this,
4463 dp != null && isValidInt( dp, 0, MAX, 19 ) ? ~~dp + 1 : null, rm, 19 );
4464 };
4465
4466
4467 /*
4468 * Return a string representing the value of this BigNumber in fixed-point notation rounding
4469 * to dp fixed decimal places using rounding mode rm, or ROUNDING_MODE if rm is omitted.
4470 *
4471 * Note: as with JavaScript's number type, (-0).toFixed(0) is '0',
4472 * but e.g. (-0.00001).toFixed(0) is '-0'.
4473 *
4474 * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
4475 * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
4476 *
4477 * 'toFixed() decimal places not an integer: {dp}'
4478 * 'toFixed() decimal places out of range: {dp}'
4479 * 'toFixed() rounding mode not an integer: {rm}'
4480 * 'toFixed() rounding mode out of range: {rm}'
4481 */
4482 P.toFixed = function ( dp, rm ) {
4483 return format( this, dp != null && isValidInt( dp, 0, MAX, 20 )
4484 ? ~~dp + this.e + 1 : null, rm, 20 );
4485 };
4486
4487
4488 /*
4489 * Return a string representing the value of this BigNumber in fixed-point notation rounded
4490 * using rm or ROUNDING_MODE to dp decimal places, and formatted according to the properties
4491 * of the FORMAT object (see BigNumber.config).
4492 *
4493 * FORMAT = {
4494 * decimalSeparator : '.',
4495 * groupSeparator : ',',
4496 * groupSize : 3,
4497 * secondaryGroupSize : 0,
4498 * fractionGroupSeparator : '\xA0', // non-breaking space
4499 * fractionGroupSize : 0
4500 * };
4501 *
4502 * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
4503 * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
4504 *
4505 * 'toFormat() decimal places not an integer: {dp}'
4506 * 'toFormat() decimal places out of range: {dp}'
4507 * 'toFormat() rounding mode not an integer: {rm}'
4508 * 'toFormat() rounding mode out of range: {rm}'
4509 */
4510 P.toFormat = function ( dp, rm ) {
4511 var str = format( this, dp != null && isValidInt( dp, 0, MAX, 21 )
4512 ? ~~dp + this.e + 1 : null, rm, 21 );
4513
4514 if ( this.c ) {
4515 var i,
4516 arr = str.split('.'),
4517 g1 = +FORMAT.groupSize,
4518 g2 = +FORMAT.secondaryGroupSize,
4519 groupSeparator = FORMAT.groupSeparator,
4520 intPart = arr[0],
4521 fractionPart = arr[1],
4522 isNeg = this.s < 0,
4523 intDigits = isNeg ? intPart.slice(1) : intPart,
4524 len = intDigits.length;
4525
4526 if (g2) i = g1, g1 = g2, g2 = i, len -= i;
4527
4528 if ( g1 > 0 && len > 0 ) {
4529 i = len % g1 || g1;
4530 intPart = intDigits.substr( 0, i );
4531
4532 for ( ; i < len; i += g1 ) {
4533 intPart += groupSeparator + intDigits.substr( i, g1 );
4534 }
4535
4536 if ( g2 > 0 ) intPart += groupSeparator + intDigits.slice(i);
4537 if (isNeg) intPart = '-' + intPart;
4538 }
4539
4540 str = fractionPart
4541 ? intPart + FORMAT.decimalSeparator + ( ( g2 = +FORMAT.fractionGroupSize )
4542 ? fractionPart.replace( new RegExp( '\\d{' + g2 + '}\\B', 'g' ),
4543 '$&' + FORMAT.fractionGroupSeparator )
4544 : fractionPart )
4545 : intPart;
4546 }
4547
4548 return str;
4549 };
4550
4551
4552 /*
4553 * Return a string array representing the value of this BigNumber as a simple fraction with
4554 * an integer numerator and an integer denominator. The denominator will be a positive
4555 * non-zero value less than or equal to the specified maximum denominator. If a maximum
4556 * denominator is not specified, the denominator will be the lowest value necessary to
4557 * represent the number exactly.
4558 *
4559 * [md] {number|string|BigNumber} Integer >= 1 and < Infinity. The maximum denominator.
4560 *
4561 * 'toFraction() max denominator not an integer: {md}'
4562 * 'toFraction() max denominator out of range: {md}'
4563 */
4564 P.toFraction = function (md) {
4565 var arr, d0, d2, e, exp, n, n0, q, s,
4566 k = ERRORS,
4567 x = this,
4568 xc = x.c,
4569 d = new BigNumber(ONE),
4570 n1 = d0 = new BigNumber(ONE),
4571 d1 = n0 = new BigNumber(ONE);
4572
4573 if ( md != null ) {
4574 ERRORS = false;
4575 n = new BigNumber(md);
4576 ERRORS = k;
4577
4578 if ( !( k = n.isInt() ) || n.lt(ONE) ) {
4579
4580 if (ERRORS) {
4581 raise( 22,
4582 'max denominator ' + ( k ? 'out of range' : 'not an integer' ), md );
4583 }
4584
4585 // ERRORS is false:
4586 // If md is a finite non-integer >= 1, round it to an integer and use it.
4587 md = !k && n.c && round( n, n.e + 1, 1 ).gte(ONE) ? n : null;
4588 }
4589 }
4590
4591 if ( !xc ) return x.toString();
4592 s = coeffToString(xc);
4593
4594 // Determine initial denominator.
4595 // d is a power of 10 and the minimum max denominator that specifies the value exactly.
4596 e = d.e = s.length - x.e - 1;
4597 d.c[0] = POWS_TEN[ ( exp = e % LOG_BASE ) < 0 ? LOG_BASE + exp : exp ];
4598 md = !md || n.cmp(d) > 0 ? ( e > 0 ? d : n1 ) : n;
4599
4600 exp = MAX_EXP;
4601 MAX_EXP = 1 / 0;
4602 n = new BigNumber(s);
4603
4604 // n0 = d1 = 0
4605 n0.c[0] = 0;
4606
4607 for ( ; ; ) {
4608 q = div( n, d, 0, 1 );
4609 d2 = d0.plus( q.times(d1) );
4610 if ( d2.cmp(md) == 1 ) break;
4611 d0 = d1;
4612 d1 = d2;
4613 n1 = n0.plus( q.times( d2 = n1 ) );
4614 n0 = d2;
4615 d = n.minus( q.times( d2 = d ) );
4616 n = d2;
4617 }
4618
4619 d2 = div( md.minus(d0), d1, 0, 1 );
4620 n0 = n0.plus( d2.times(n1) );
4621 d0 = d0.plus( d2.times(d1) );
4622 n0.s = n1.s = x.s;
4623 e *= 2;
4624
4625 // Determine which fraction is closer to x, n0/d0 or n1/d1
4626 arr = div( n1, d1, e, ROUNDING_MODE ).minus(x).abs().cmp(
4627 div( n0, d0, e, ROUNDING_MODE ).minus(x).abs() ) < 1
4628 ? [ n1.toString(), d1.toString() ]
4629 : [ n0.toString(), d0.toString() ];
4630
4631 MAX_EXP = exp;
4632 return arr;
4633 };
4634
4635
4636 /*
4637 * Return the value of this BigNumber converted to a number primitive.
4638 */
4639 P.toNumber = function () {
4640 return +this;
4641 };
4642
4643
4644 /*
4645 * Return a BigNumber whose value is the value of this BigNumber raised to the power n.
4646 * If m is present, return the result modulo m.
4647 * If n is negative round according to DECIMAL_PLACES and ROUNDING_MODE.
4648 * If POW_PRECISION is non-zero and m is not present, round to POW_PRECISION using
4649 * ROUNDING_MODE.
4650 *
4651 * The modular power operation works efficiently when x, n, and m are positive integers,
4652 * otherwise it is equivalent to calculating x.toPower(n).modulo(m) (with POW_PRECISION 0).
4653 *
4654 * n {number} Integer, -MAX_SAFE_INTEGER to MAX_SAFE_INTEGER inclusive.
4655 * [m] {number|string|BigNumber} The modulus.
4656 *
4657 * 'pow() exponent not an integer: {n}'
4658 * 'pow() exponent out of range: {n}'
4659 *
4660 * Performs 54 loop iterations for n of 9007199254740991.
4661 */
4662 P.toPower = P.pow = function ( n, m ) {
4663 var k, y, z,
4664 i = mathfloor( n < 0 ? -n : +n ),
4665 x = this;
4666
4667 if ( m != null ) {
4668 id = 23;
4669 m = new BigNumber(m);
4670 }
4671
4672 // Pass ±Infinity to Math.pow if exponent is out of range.
4673 if ( !isValidInt( n, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER, 23, 'exponent' ) &&
4674 ( !isFinite(n) || i > MAX_SAFE_INTEGER && ( n /= 0 ) ||
4675 parseFloat(n) != n && !( n = NaN ) ) || n == 0 ) {
4676 k = Math.pow( +x, n );
4677 return new BigNumber( m ? k % m : k );
4678 }
4679
4680 if (m) {
4681 if ( n > 1 && x.gt(ONE) && x.isInt() && m.gt(ONE) && m.isInt() ) {
4682 x = x.mod(m);
4683 } else {
4684 z = m;
4685
4686 // Nullify m so only a single mod operation is performed at the end.
4687 m = null;
4688 }
4689 } else if (POW_PRECISION) {
4690
4691 // Truncating each coefficient array to a length of k after each multiplication
4692 // equates to truncating significant digits to POW_PRECISION + [28, 41],
4693 // i.e. there will be a minimum of 28 guard digits retained.
4694 // (Using + 1.5 would give [9, 21] guard digits.)
4695 k = mathceil( POW_PRECISION / LOG_BASE + 2 );
4696 }
4697
4698 y = new BigNumber(ONE);
4699
4700 for ( ; ; ) {
4701 if ( i % 2 ) {
4702 y = y.times(x);
4703 if ( !y.c ) break;
4704 if (k) {
4705 if ( y.c.length > k ) y.c.length = k;
4706 } else if (m) {
4707 y = y.mod(m);
4708 }
4709 }
4710
4711 i = mathfloor( i / 2 );
4712 if ( !i ) break;
4713 x = x.times(x);
4714 if (k) {
4715 if ( x.c && x.c.length > k ) x.c.length = k;
4716 } else if (m) {
4717 x = x.mod(m);
4718 }
4719 }
4720
4721 if (m) return y;
4722 if ( n < 0 ) y = ONE.div(y);
4723
4724 return z ? y.mod(z) : k ? round( y, POW_PRECISION, ROUNDING_MODE ) : y;
4725 };
4726
4727
4728 /*
4729 * Return a string representing the value of this BigNumber rounded to sd significant digits
4730 * using rounding mode rm or ROUNDING_MODE. If sd is less than the number of digits
4731 * necessary to represent the integer part of the value in fixed-point notation, then use
4732 * exponential notation.
4733 *
4734 * [sd] {number} Significant digits. Integer, 1 to MAX inclusive.
4735 * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
4736 *
4737 * 'toPrecision() precision not an integer: {sd}'
4738 * 'toPrecision() precision out of range: {sd}'
4739 * 'toPrecision() rounding mode not an integer: {rm}'
4740 * 'toPrecision() rounding mode out of range: {rm}'
4741 */
4742 P.toPrecision = function ( sd, rm ) {
4743 return format( this, sd != null && isValidInt( sd, 1, MAX, 24, 'precision' )
4744 ? sd | 0 : null, rm, 24 );
4745 };
4746
4747
4748 /*
4749 * Return a string representing the value of this BigNumber in base b, or base 10 if b is
4750 * omitted. If a base is specified, including base 10, round according to DECIMAL_PLACES and
4751 * ROUNDING_MODE. If a base is not specified, and this BigNumber has a positive exponent
4752 * that is equal to or greater than TO_EXP_POS, or a negative exponent equal to or less than
4753 * TO_EXP_NEG, return exponential notation.
4754 *
4755 * [b] {number} Integer, 2 to 64 inclusive.
4756 *
4757 * 'toString() base not an integer: {b}'
4758 * 'toString() base out of range: {b}'
4759 */
4760 P.toString = function (b) {
4761 var str,
4762 n = this,
4763 s = n.s,
4764 e = n.e;
4765
4766 // Infinity or NaN?
4767 if ( e === null ) {
4768
4769 if (s) {
4770 str = 'Infinity';
4771 if ( s < 0 ) str = '-' + str;
4772 } else {
4773 str = 'NaN';
4774 }
4775 } else {
4776 str = coeffToString( n.c );
4777
4778 if ( b == null || !isValidInt( b, 2, 64, 25, 'base' ) ) {
4779 str = e <= TO_EXP_NEG || e >= TO_EXP_POS
4780 ? toExponential( str, e )
4781 : toFixedPoint( str, e );
4782 } else {
4783 str = convertBase( toFixedPoint( str, e ), b | 0, 10, s );
4784 }
4785
4786 if ( s < 0 && n.c[0] ) str = '-' + str;
4787 }
4788
4789 return str;
4790 };
4791
4792
4793 /*
4794 * Return a new BigNumber whose value is the value of this BigNumber truncated to a whole
4795 * number.
4796 */
4797 P.truncated = P.trunc = function () {
4798 return round( new BigNumber(this), this.e + 1, 1 );
4799 };
4800
4801
4802 /*
4803 * Return as toString, but do not accept a base argument, and include the minus sign for
4804 * negative zero.
4805 */
4806 P.valueOf = P.toJSON = function () {
4807 var str,
4808 n = this,
4809 e = n.e;
4810
4811 if ( e === null ) return n.toString();
4812
4813 str = coeffToString( n.c );
4814
4815 str = e <= TO_EXP_NEG || e >= TO_EXP_POS
4816 ? toExponential( str, e )
4817 : toFixedPoint( str, e );
4818
4819 return n.s < 0 ? '-' + str : str;
4820 };
4821
4822
4823 P.isBigNumber = true;
4824
4825 if ( config != null ) BigNumber.config(config);
4826
4827 return BigNumber;
4828 }
4829
4830
4831 // PRIVATE HELPER FUNCTIONS
4832
4833
4834 function bitFloor(n) {
4835 var i = n | 0;
4836 return n > 0 || n === i ? i : i - 1;
4837 }
4838
4839
4840 // Return a coefficient array as a string of base 10 digits.
4841 function coeffToString(a) {
4842 var s, z,
4843 i = 1,
4844 j = a.length,
4845 r = a[0] + '';
4846
4847 for ( ; i < j; ) {
4848 s = a[i++] + '';
4849 z = LOG_BASE - s.length;
4850 for ( ; z--; s = '0' + s );
4851 r += s;
4852 }
4853
4854 // Determine trailing zeros.
4855 for ( j = r.length; r.charCodeAt(--j) === 48; );
4856 return r.slice( 0, j + 1 || 1 );
4857 }
4858
4859
4860 // Compare the value of BigNumbers x and y.
4861 function compare( x, y ) {
4862 var a, b,
4863 xc = x.c,
4864 yc = y.c,
4865 i = x.s,
4866 j = y.s,
4867 k = x.e,
4868 l = y.e;
4869
4870 // Either NaN?
4871 if ( !i || !j ) return null;
4872
4873 a = xc && !xc[0];
4874 b = yc && !yc[0];
4875
4876 // Either zero?
4877 if ( a || b ) return a ? b ? 0 : -j : i;
4878
4879 // Signs differ?
4880 if ( i != j ) return i;
4881
4882 a = i < 0;
4883 b = k == l;
4884
4885 // Either Infinity?
4886 if ( !xc || !yc ) return b ? 0 : !xc ^ a ? 1 : -1;
4887
4888 // Compare exponents.
4889 if ( !b ) return k > l ^ a ? 1 : -1;
4890
4891 j = ( k = xc.length ) < ( l = yc.length ) ? k : l;
4892
4893 // Compare digit by digit.
4894 for ( i = 0; i < j; i++ ) if ( xc[i] != yc[i] ) return xc[i] > yc[i] ^ a ? 1 : -1;
4895
4896 // Compare lengths.
4897 return k == l ? 0 : k > l ^ a ? 1 : -1;
4898 }
4899
4900
4901 /*
4902 * Return true if n is a valid number in range, otherwise false.
4903 * Use for argument validation when ERRORS is false.
4904 * Note: parseInt('1e+1') == 1 but parseFloat('1e+1') == 10.
4905 */
4906 function intValidatorNoErrors( n, min, max ) {
4907 return ( n = truncate(n) ) >= min && n <= max;
4908 }
4909
4910
4911 function isArray(obj) {
4912 return Object.prototype.toString.call(obj) == '[object Array]';
4913 }
4914
4915
4916 /*
4917 * Convert string of baseIn to an array of numbers of baseOut.
4918 * Eg. convertBase('255', 10, 16) returns [15, 15].
4919 * Eg. convertBase('ff', 16, 10) returns [2, 5, 5].
4920 */
4921 function toBaseOut( str, baseIn, baseOut ) {
4922 var j,
4923 arr = [0],
4924 arrL,
4925 i = 0,
4926 len = str.length;
4927
4928 for ( ; i < len; ) {
4929 for ( arrL = arr.length; arrL--; arr[arrL] *= baseIn );
4930 arr[ j = 0 ] += ALPHABET.indexOf( str.charAt( i++ ) );
4931
4932 for ( ; j < arr.length; j++ ) {
4933
4934 if ( arr[j] > baseOut - 1 ) {
4935 if ( arr[j + 1] == null ) arr[j + 1] = 0;
4936 arr[j + 1] += arr[j] / baseOut | 0;
4937 arr[j] %= baseOut;
4938 }
4939 }
4940 }
4941
4942 return arr.reverse();
4943 }
4944
4945
4946 function toExponential( str, e ) {
4947 return ( str.length > 1 ? str.charAt(0) + '.' + str.slice(1) : str ) +
4948 ( e < 0 ? 'e' : 'e+' ) + e;
4949 }
4950
4951
4952 function toFixedPoint( str, e ) {
4953 var len, z;
4954
4955 // Negative exponent?
4956 if ( e < 0 ) {
4957
4958 // Prepend zeros.
4959 for ( z = '0.'; ++e; z += '0' );
4960 str = z + str;
4961
4962 // Positive exponent
4963 } else {
4964 len = str.length;
4965
4966 // Append zeros.
4967 if ( ++e > len ) {
4968 for ( z = '0', e -= len; --e; z += '0' );
4969 str += z;
4970 } else if ( e < len ) {
4971 str = str.slice( 0, e ) + '.' + str.slice(e);
4972 }
4973 }
4974
4975 return str;
4976 }
4977
4978
4979 function truncate(n) {
4980 n = parseFloat(n);
4981 return n < 0 ? mathceil(n) : mathfloor(n);
4982 }
4983
4984
4985 // EXPORT
4986
4987
4988 BigNumber = constructorFactory();
4989 BigNumber['default'] = BigNumber.BigNumber = BigNumber;
4990
4991
4992 // AMD.
4993 if ( typeof define == 'function' && define.amd ) {
4994 define( function () { return BigNumber; } );
4995
4996 // Node.js and other environments that support module.exports.
4997 } else if ( typeof module != 'undefined' && module.exports ) {
4998 module.exports = BigNumber;
4999
5000 // Browser.
5001 } else {
5002 if ( !globalObj ) globalObj = typeof self != 'undefined' ? self : Function('return this')();
5003 globalObj.BigNumber = BigNumber;
5004 }
5005})(this);
5006
5007},{}],20:[function(require,module,exports){
5008// Reference https://github.com/bitcoin/bips/blob/master/bip-0066.mediawiki
5009// Format: 0x30 [total-length] 0x02 [R-length] [R] 0x02 [S-length] [S]
5010// NOTE: SIGHASH byte ignored AND restricted, truncate before use
5011
5012var Buffer = require('safe-buffer').Buffer
5013
5014function check (buffer) {
5015 if (buffer.length < 8) return false
5016 if (buffer.length > 72) return false
5017 if (buffer[0] !== 0x30) return false
5018 if (buffer[1] !== buffer.length - 2) return false
5019 if (buffer[2] !== 0x02) return false
5020
5021 var lenR = buffer[3]
5022 if (lenR === 0) return false
5023 if (5 + lenR >= buffer.length) return false
5024 if (buffer[4 + lenR] !== 0x02) return false
5025
5026 var lenS = buffer[5 + lenR]
5027 if (lenS === 0) return false
5028 if ((6 + lenR + lenS) !== buffer.length) return false
5029
5030 if (buffer[4] & 0x80) return false
5031 if (lenR > 1 && (buffer[4] === 0x00) && !(buffer[5] & 0x80)) return false
5032
5033 if (buffer[lenR + 6] & 0x80) return false
5034 if (lenS > 1 && (buffer[lenR + 6] === 0x00) && !(buffer[lenR + 7] & 0x80)) return false
5035 return true
5036}
5037
5038function decode (buffer) {
5039 if (buffer.length < 8) throw new Error('DER sequence length is too short')
5040 if (buffer.length > 72) throw new Error('DER sequence length is too long')
5041 if (buffer[0] !== 0x30) throw new Error('Expected DER sequence')
5042 if (buffer[1] !== buffer.length - 2) throw new Error('DER sequence length is invalid')
5043 if (buffer[2] !== 0x02) throw new Error('Expected DER integer')
5044
5045 var lenR = buffer[3]
5046 if (lenR === 0) throw new Error('R length is zero')
5047 if (5 + lenR >= buffer.length) throw new Error('R length is too long')
5048 if (buffer[4 + lenR] !== 0x02) throw new Error('Expected DER integer (2)')
5049
5050 var lenS = buffer[5 + lenR]
5051 if (lenS === 0) throw new Error('S length is zero')
5052 if ((6 + lenR + lenS) !== buffer.length) throw new Error('S length is invalid')
5053
5054 if (buffer[4] & 0x80) throw new Error('R value is negative')
5055 if (lenR > 1 && (buffer[4] === 0x00) && !(buffer[5] & 0x80)) throw new Error('R value excessively padded')
5056
5057 if (buffer[lenR + 6] & 0x80) throw new Error('S value is negative')
5058 if (lenS > 1 && (buffer[lenR + 6] === 0x00) && !(buffer[lenR + 7] & 0x80)) throw new Error('S value excessively padded')
5059
5060 // non-BIP66 - extract R, S values
5061 return {
5062 r: buffer.slice(4, 4 + lenR),
5063 s: buffer.slice(6 + lenR)
5064 }
5065}
5066
5067/*
5068 * Expects r and s to be positive DER integers.
5069 *
5070 * The DER format uses the most significant bit as a sign bit (& 0x80).
5071 * If the significant bit is set AND the integer is positive, a 0x00 is prepended.
5072 *
5073 * Examples:
5074 *
5075 * 0 => 0x00
5076 * 1 => 0x01
5077 * -1 => 0xff
5078 * 127 => 0x7f
5079 * -127 => 0x81
5080 * 128 => 0x0080
5081 * -128 => 0x80
5082 * 255 => 0x00ff
5083 * -255 => 0xff01
5084 * 16300 => 0x3fac
5085 * -16300 => 0xc054
5086 * 62300 => 0x00f35c
5087 * -62300 => 0xff0ca4
5088*/
5089function encode (r, s) {
5090 var lenR = r.length
5091 var lenS = s.length
5092 if (lenR === 0) throw new Error('R length is zero')
5093 if (lenS === 0) throw new Error('S length is zero')
5094 if (lenR > 33) throw new Error('R length is too long')
5095 if (lenS > 33) throw new Error('S length is too long')
5096 if (r[0] & 0x80) throw new Error('R value is negative')
5097 if (s[0] & 0x80) throw new Error('S value is negative')
5098 if (lenR > 1 && (r[0] === 0x00) && !(r[1] & 0x80)) throw new Error('R value excessively padded')
5099 if (lenS > 1 && (s[0] === 0x00) && !(s[1] & 0x80)) throw new Error('S value excessively padded')
5100
5101 var signature = Buffer.allocUnsafe(6 + lenR + lenS)
5102
5103 // 0x30 [total-length] 0x02 [R-length] [R] 0x02 [S-length] [S]
5104 signature[0] = 0x30
5105 signature[1] = signature.length - 2
5106 signature[2] = 0x02
5107 signature[3] = r.length
5108 r.copy(signature, 4)
5109 signature[4 + lenR] = 0x02
5110 signature[5 + lenR] = s.length
5111 s.copy(signature, 6 + lenR)
5112
5113 return signature
5114}
5115
5116module.exports = {
5117 check: check,
5118 decode: decode,
5119 encode: encode
5120}
5121
5122},{"safe-buffer":156}],21:[function(require,module,exports){
5123(function (module, exports) {
5124 'use strict';
5125
5126 // Utils
5127 function assert (val, msg) {
5128 if (!val) throw new Error(msg || 'Assertion failed');
5129 }
5130
5131 // Could use `inherits` module, but don't want to move from single file
5132 // architecture yet.
5133 function inherits (ctor, superCtor) {
5134 ctor.super_ = superCtor;
5135 var TempCtor = function () {};
5136 TempCtor.prototype = superCtor.prototype;
5137 ctor.prototype = new TempCtor();
5138 ctor.prototype.constructor = ctor;
5139 }
5140
5141 // BN
5142
5143 function BN (number, base, endian) {
5144 if (BN.isBN(number)) {
5145 return number;
5146 }
5147
5148 this.negative = 0;
5149 this.words = null;
5150 this.length = 0;
5151
5152 // Reduction context
5153 this.red = null;
5154
5155 if (number !== null) {
5156 if (base === 'le' || base === 'be') {
5157 endian = base;
5158 base = 10;
5159 }
5160
5161 this._init(number || 0, base || 10, endian || 'be');
5162 }
5163 }
5164 if (typeof module === 'object') {
5165 module.exports = BN;
5166 } else {
5167 exports.BN = BN;
5168 }
5169
5170 BN.BN = BN;
5171 BN.wordSize = 26;
5172
5173 var Buffer;
5174 try {
5175 Buffer = require('buffer').Buffer;
5176 } catch (e) {
5177 }
5178
5179 BN.isBN = function isBN (num) {
5180 if (num instanceof BN) {
5181 return true;
5182 }
5183
5184 return num !== null && typeof num === 'object' &&
5185 num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);
5186 };
5187
5188 BN.max = function max (left, right) {
5189 if (left.cmp(right) > 0) return left;
5190 return right;
5191 };
5192
5193 BN.min = function min (left, right) {
5194 if (left.cmp(right) < 0) return left;
5195 return right;
5196 };
5197
5198 BN.prototype._init = function init (number, base, endian) {
5199 if (typeof number === 'number') {
5200 return this._initNumber(number, base, endian);
5201 }
5202
5203 if (typeof number === 'object') {
5204 return this._initArray(number, base, endian);
5205 }
5206
5207 if (base === 'hex') {
5208 base = 16;
5209 }
5210 assert(base === (base | 0) && base >= 2 && base <= 36);
5211
5212 number = number.toString().replace(/\s+/g, '');
5213 var start = 0;
5214 if (number[0] === '-') {
5215 start++;
5216 }
5217
5218 if (base === 16) {
5219 this._parseHex(number, start);
5220 } else {
5221 this._parseBase(number, base, start);
5222 }
5223
5224 if (number[0] === '-') {
5225 this.negative = 1;
5226 }
5227
5228 this.strip();
5229
5230 if (endian !== 'le') return;
5231
5232 this._initArray(this.toArray(), base, endian);
5233 };
5234
5235 BN.prototype._initNumber = function _initNumber (number, base, endian) {
5236 if (number < 0) {
5237 this.negative = 1;
5238 number = -number;
5239 }
5240 if (number < 0x4000000) {
5241 this.words = [ number & 0x3ffffff ];
5242 this.length = 1;
5243 } else if (number < 0x10000000000000) {
5244 this.words = [
5245 number & 0x3ffffff,
5246 (number / 0x4000000) & 0x3ffffff
5247 ];
5248 this.length = 2;
5249 } else {
5250 assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)
5251 this.words = [
5252 number & 0x3ffffff,
5253 (number / 0x4000000) & 0x3ffffff,
5254 1
5255 ];
5256 this.length = 3;
5257 }
5258
5259 if (endian !== 'le') return;
5260
5261 // Reverse the bytes
5262 this._initArray(this.toArray(), base, endian);
5263 };
5264
5265 BN.prototype._initArray = function _initArray (number, base, endian) {
5266 // Perhaps a Uint8Array
5267 assert(typeof number.length === 'number');
5268 if (number.length <= 0) {
5269 this.words = [ 0 ];
5270 this.length = 1;
5271 return this;
5272 }
5273
5274 this.length = Math.ceil(number.length / 3);
5275 this.words = new Array(this.length);
5276 for (var i = 0; i < this.length; i++) {
5277 this.words[i] = 0;
5278 }
5279
5280 var j, w;
5281 var off = 0;
5282 if (endian === 'be') {
5283 for (i = number.length - 1, j = 0; i >= 0; i -= 3) {
5284 w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16);
5285 this.words[j] |= (w << off) & 0x3ffffff;
5286 this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
5287 off += 24;
5288 if (off >= 26) {
5289 off -= 26;
5290 j++;
5291 }
5292 }
5293 } else if (endian === 'le') {
5294 for (i = 0, j = 0; i < number.length; i += 3) {
5295 w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16);
5296 this.words[j] |= (w << off) & 0x3ffffff;
5297 this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
5298 off += 24;
5299 if (off >= 26) {
5300 off -= 26;
5301 j++;
5302 }
5303 }
5304 }
5305 return this.strip();
5306 };
5307
5308 function parseHex (str, start, end) {
5309 var r = 0;
5310 var len = Math.min(str.length, end);
5311 for (var i = start; i < len; i++) {
5312 var c = str.charCodeAt(i) - 48;
5313
5314 r <<= 4;
5315
5316 // 'a' - 'f'
5317 if (c >= 49 && c <= 54) {
5318 r |= c - 49 + 0xa;
5319
5320 // 'A' - 'F'
5321 } else if (c >= 17 && c <= 22) {
5322 r |= c - 17 + 0xa;
5323
5324 // '0' - '9'
5325 } else {
5326 r |= c & 0xf;
5327 }
5328 }
5329 return r;
5330 }
5331
5332 BN.prototype._parseHex = function _parseHex (number, start) {
5333 // Create possibly bigger array to ensure that it fits the number
5334 this.length = Math.ceil((number.length - start) / 6);
5335 this.words = new Array(this.length);
5336 for (var i = 0; i < this.length; i++) {
5337 this.words[i] = 0;
5338 }
5339
5340 var j, w;
5341 // Scan 24-bit chunks and add them to the number
5342 var off = 0;
5343 for (i = number.length - 6, j = 0; i >= start; i -= 6) {
5344 w = parseHex(number, i, i + 6);
5345 this.words[j] |= (w << off) & 0x3ffffff;
5346 // NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb
5347 this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;
5348 off += 24;
5349 if (off >= 26) {
5350 off -= 26;
5351 j++;
5352 }
5353 }
5354 if (i + 6 !== start) {
5355 w = parseHex(number, start, i + 6);
5356 this.words[j] |= (w << off) & 0x3ffffff;
5357 this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;
5358 }
5359 this.strip();
5360 };
5361
5362 function parseBase (str, start, end, mul) {
5363 var r = 0;
5364 var len = Math.min(str.length, end);
5365 for (var i = start; i < len; i++) {
5366 var c = str.charCodeAt(i) - 48;
5367
5368 r *= mul;
5369
5370 // 'a'
5371 if (c >= 49) {
5372 r += c - 49 + 0xa;
5373
5374 // 'A'
5375 } else if (c >= 17) {
5376 r += c - 17 + 0xa;
5377
5378 // '0' - '9'
5379 } else {
5380 r += c;
5381 }
5382 }
5383 return r;
5384 }
5385
5386 BN.prototype._parseBase = function _parseBase (number, base, start) {
5387 // Initialize as zero
5388 this.words = [ 0 ];
5389 this.length = 1;
5390
5391 // Find length of limb in base
5392 for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {
5393 limbLen++;
5394 }
5395 limbLen--;
5396 limbPow = (limbPow / base) | 0;
5397
5398 var total = number.length - start;
5399 var mod = total % limbLen;
5400 var end = Math.min(total, total - mod) + start;
5401
5402 var word = 0;
5403 for (var i = start; i < end; i += limbLen) {
5404 word = parseBase(number, i, i + limbLen, base);
5405
5406 this.imuln(limbPow);
5407 if (this.words[0] + word < 0x4000000) {
5408 this.words[0] += word;
5409 } else {
5410 this._iaddn(word);
5411 }
5412 }
5413
5414 if (mod !== 0) {
5415 var pow = 1;
5416 word = parseBase(number, i, number.length, base);
5417
5418 for (i = 0; i < mod; i++) {
5419 pow *= base;
5420 }
5421
5422 this.imuln(pow);
5423 if (this.words[0] + word < 0x4000000) {
5424 this.words[0] += word;
5425 } else {
5426 this._iaddn(word);
5427 }
5428 }
5429 };
5430
5431 BN.prototype.copy = function copy (dest) {
5432 dest.words = new Array(this.length);
5433 for (var i = 0; i < this.length; i++) {
5434 dest.words[i] = this.words[i];
5435 }
5436 dest.length = this.length;
5437 dest.negative = this.negative;
5438 dest.red = this.red;
5439 };
5440
5441 BN.prototype.clone = function clone () {
5442 var r = new BN(null);
5443 this.copy(r);
5444 return r;
5445 };
5446
5447 BN.prototype._expand = function _expand (size) {
5448 while (this.length < size) {
5449 this.words[this.length++] = 0;
5450 }
5451 return this;
5452 };
5453
5454 // Remove leading `0` from `this`
5455 BN.prototype.strip = function strip () {
5456 while (this.length > 1 && this.words[this.length - 1] === 0) {
5457 this.length--;
5458 }
5459 return this._normSign();
5460 };
5461
5462 BN.prototype._normSign = function _normSign () {
5463 // -0 = 0
5464 if (this.length === 1 && this.words[0] === 0) {
5465 this.negative = 0;
5466 }
5467 return this;
5468 };
5469
5470 BN.prototype.inspect = function inspect () {
5471 return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';
5472 };
5473
5474 /*
5475
5476 var zeros = [];
5477 var groupSizes = [];
5478 var groupBases = [];
5479
5480 var s = '';
5481 var i = -1;
5482 while (++i < BN.wordSize) {
5483 zeros[i] = s;
5484 s += '0';
5485 }
5486 groupSizes[0] = 0;
5487 groupSizes[1] = 0;
5488 groupBases[0] = 0;
5489 groupBases[1] = 0;
5490 var base = 2 - 1;
5491 while (++base < 36 + 1) {
5492 var groupSize = 0;
5493 var groupBase = 1;
5494 while (groupBase < (1 << BN.wordSize) / base) {
5495 groupBase *= base;
5496 groupSize += 1;
5497 }
5498 groupSizes[base] = groupSize;
5499 groupBases[base] = groupBase;
5500 }
5501
5502 */
5503
5504 var zeros = [
5505 '',
5506 '0',
5507 '00',
5508 '000',
5509 '0000',
5510 '00000',
5511 '000000',
5512 '0000000',
5513 '00000000',
5514 '000000000',
5515 '0000000000',
5516 '00000000000',
5517 '000000000000',
5518 '0000000000000',
5519 '00000000000000',
5520 '000000000000000',
5521 '0000000000000000',
5522 '00000000000000000',
5523 '000000000000000000',
5524 '0000000000000000000',
5525 '00000000000000000000',
5526 '000000000000000000000',
5527 '0000000000000000000000',
5528 '00000000000000000000000',
5529 '000000000000000000000000',
5530 '0000000000000000000000000'
5531 ];
5532
5533 var groupSizes = [
5534 0, 0,
5535 25, 16, 12, 11, 10, 9, 8,
5536 8, 7, 7, 7, 7, 6, 6,
5537 6, 6, 6, 6, 6, 5, 5,
5538 5, 5, 5, 5, 5, 5, 5,
5539 5, 5, 5, 5, 5, 5, 5
5540 ];
5541
5542 var groupBases = [
5543 0, 0,
5544 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216,
5545 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625,
5546 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632,
5547 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149,
5548 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176
5549 ];
5550
5551 BN.prototype.toString = function toString (base, padding) {
5552 base = base || 10;
5553 padding = padding | 0 || 1;
5554
5555 var out;
5556 if (base === 16 || base === 'hex') {
5557 out = '';
5558 var off = 0;
5559 var carry = 0;
5560 for (var i = 0; i < this.length; i++) {
5561 var w = this.words[i];
5562 var word = (((w << off) | carry) & 0xffffff).toString(16);
5563 carry = (w >>> (24 - off)) & 0xffffff;
5564 if (carry !== 0 || i !== this.length - 1) {
5565 out = zeros[6 - word.length] + word + out;
5566 } else {
5567 out = word + out;
5568 }
5569 off += 2;
5570 if (off >= 26) {
5571 off -= 26;
5572 i--;
5573 }
5574 }
5575 if (carry !== 0) {
5576 out = carry.toString(16) + out;
5577 }
5578 while (out.length % padding !== 0) {
5579 out = '0' + out;
5580 }
5581 if (this.negative !== 0) {
5582 out = '-' + out;
5583 }
5584 return out;
5585 }
5586
5587 if (base === (base | 0) && base >= 2 && base <= 36) {
5588 // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));
5589 var groupSize = groupSizes[base];
5590 // var groupBase = Math.pow(base, groupSize);
5591 var groupBase = groupBases[base];
5592 out = '';
5593 var c = this.clone();
5594 c.negative = 0;
5595 while (!c.isZero()) {
5596 var r = c.modn(groupBase).toString(base);
5597 c = c.idivn(groupBase);
5598
5599 if (!c.isZero()) {
5600 out = zeros[groupSize - r.length] + r + out;
5601 } else {
5602 out = r + out;
5603 }
5604 }
5605 if (this.isZero()) {
5606 out = '0' + out;
5607 }
5608 while (out.length % padding !== 0) {
5609 out = '0' + out;
5610 }
5611 if (this.negative !== 0) {
5612 out = '-' + out;
5613 }
5614 return out;
5615 }
5616
5617 assert(false, 'Base should be between 2 and 36');
5618 };
5619
5620 BN.prototype.toNumber = function toNumber () {
5621 var ret = this.words[0];
5622 if (this.length === 2) {
5623 ret += this.words[1] * 0x4000000;
5624 } else if (this.length === 3 && this.words[2] === 0x01) {
5625 // NOTE: at this stage it is known that the top bit is set
5626 ret += 0x10000000000000 + (this.words[1] * 0x4000000);
5627 } else if (this.length > 2) {
5628 assert(false, 'Number can only safely store up to 53 bits');
5629 }
5630 return (this.negative !== 0) ? -ret : ret;
5631 };
5632
5633 BN.prototype.toJSON = function toJSON () {
5634 return this.toString(16);
5635 };
5636
5637 BN.prototype.toBuffer = function toBuffer (endian, length) {
5638 assert(typeof Buffer !== 'undefined');
5639 return this.toArrayLike(Buffer, endian, length);
5640 };
5641
5642 BN.prototype.toArray = function toArray (endian, length) {
5643 return this.toArrayLike(Array, endian, length);
5644 };
5645
5646 BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) {
5647 var byteLength = this.byteLength();
5648 var reqLength = length || Math.max(1, byteLength);
5649 assert(byteLength <= reqLength, 'byte array longer than desired length');
5650 assert(reqLength > 0, 'Requested array length <= 0');
5651
5652 this.strip();
5653 var littleEndian = endian === 'le';
5654 var res = new ArrayType(reqLength);
5655
5656 var b, i;
5657 var q = this.clone();
5658 if (!littleEndian) {
5659 // Assume big-endian
5660 for (i = 0; i < reqLength - byteLength; i++) {
5661 res[i] = 0;
5662 }
5663
5664 for (i = 0; !q.isZero(); i++) {
5665 b = q.andln(0xff);
5666 q.iushrn(8);
5667
5668 res[reqLength - i - 1] = b;
5669 }
5670 } else {
5671 for (i = 0; !q.isZero(); i++) {
5672 b = q.andln(0xff);
5673 q.iushrn(8);
5674
5675 res[i] = b;
5676 }
5677
5678 for (; i < reqLength; i++) {
5679 res[i] = 0;
5680 }
5681 }
5682
5683 return res;
5684 };
5685
5686 if (Math.clz32) {
5687 BN.prototype._countBits = function _countBits (w) {
5688 return 32 - Math.clz32(w);
5689 };
5690 } else {
5691 BN.prototype._countBits = function _countBits (w) {
5692 var t = w;
5693 var r = 0;
5694 if (t >= 0x1000) {
5695 r += 13;
5696 t >>>= 13;
5697 }
5698 if (t >= 0x40) {
5699 r += 7;
5700 t >>>= 7;
5701 }
5702 if (t >= 0x8) {
5703 r += 4;
5704 t >>>= 4;
5705 }
5706 if (t >= 0x02) {
5707 r += 2;
5708 t >>>= 2;
5709 }
5710 return r + t;
5711 };
5712 }
5713
5714 BN.prototype._zeroBits = function _zeroBits (w) {
5715 // Short-cut
5716 if (w === 0) return 26;
5717
5718 var t = w;
5719 var r = 0;
5720 if ((t & 0x1fff) === 0) {
5721 r += 13;
5722 t >>>= 13;
5723 }
5724 if ((t & 0x7f) === 0) {
5725 r += 7;
5726 t >>>= 7;
5727 }
5728 if ((t & 0xf) === 0) {
5729 r += 4;
5730 t >>>= 4;
5731 }
5732 if ((t & 0x3) === 0) {
5733 r += 2;
5734 t >>>= 2;
5735 }
5736 if ((t & 0x1) === 0) {
5737 r++;
5738 }
5739 return r;
5740 };
5741
5742 // Return number of used bits in a BN
5743 BN.prototype.bitLength = function bitLength () {
5744 var w = this.words[this.length - 1];
5745 var hi = this._countBits(w);
5746 return (this.length - 1) * 26 + hi;
5747 };
5748
5749 function toBitArray (num) {
5750 var w = new Array(num.bitLength());
5751
5752 for (var bit = 0; bit < w.length; bit++) {
5753 var off = (bit / 26) | 0;
5754 var wbit = bit % 26;
5755
5756 w[bit] = (num.words[off] & (1 << wbit)) >>> wbit;
5757 }
5758
5759 return w;
5760 }
5761
5762 // Number of trailing zero bits
5763 BN.prototype.zeroBits = function zeroBits () {
5764 if (this.isZero()) return 0;
5765
5766 var r = 0;
5767 for (var i = 0; i < this.length; i++) {
5768 var b = this._zeroBits(this.words[i]);
5769 r += b;
5770 if (b !== 26) break;
5771 }
5772 return r;
5773 };
5774
5775 BN.prototype.byteLength = function byteLength () {
5776 return Math.ceil(this.bitLength() / 8);
5777 };
5778
5779 BN.prototype.toTwos = function toTwos (width) {
5780 if (this.negative !== 0) {
5781 return this.abs().inotn(width).iaddn(1);
5782 }
5783 return this.clone();
5784 };
5785
5786 BN.prototype.fromTwos = function fromTwos (width) {
5787 if (this.testn(width - 1)) {
5788 return this.notn(width).iaddn(1).ineg();
5789 }
5790 return this.clone();
5791 };
5792
5793 BN.prototype.isNeg = function isNeg () {
5794 return this.negative !== 0;
5795 };
5796
5797 // Return negative clone of `this`
5798 BN.prototype.neg = function neg () {
5799 return this.clone().ineg();
5800 };
5801
5802 BN.prototype.ineg = function ineg () {
5803 if (!this.isZero()) {
5804 this.negative ^= 1;
5805 }
5806
5807 return this;
5808 };
5809
5810 // Or `num` with `this` in-place
5811 BN.prototype.iuor = function iuor (num) {
5812 while (this.length < num.length) {
5813 this.words[this.length++] = 0;
5814 }
5815
5816 for (var i = 0; i < num.length; i++) {
5817 this.words[i] = this.words[i] | num.words[i];
5818 }
5819
5820 return this.strip();
5821 };
5822
5823 BN.prototype.ior = function ior (num) {
5824 assert((this.negative | num.negative) === 0);
5825 return this.iuor(num);
5826 };
5827
5828 // Or `num` with `this`
5829 BN.prototype.or = function or (num) {
5830 if (this.length > num.length) return this.clone().ior(num);
5831 return num.clone().ior(this);
5832 };
5833
5834 BN.prototype.uor = function uor (num) {
5835 if (this.length > num.length) return this.clone().iuor(num);
5836 return num.clone().iuor(this);
5837 };
5838
5839 // And `num` with `this` in-place
5840 BN.prototype.iuand = function iuand (num) {
5841 // b = min-length(num, this)
5842 var b;
5843 if (this.length > num.length) {
5844 b = num;
5845 } else {
5846 b = this;
5847 }
5848
5849 for (var i = 0; i < b.length; i++) {
5850 this.words[i] = this.words[i] & num.words[i];
5851 }
5852
5853 this.length = b.length;
5854
5855 return this.strip();
5856 };
5857
5858 BN.prototype.iand = function iand (num) {
5859 assert((this.negative | num.negative) === 0);
5860 return this.iuand(num);
5861 };
5862
5863 // And `num` with `this`
5864 BN.prototype.and = function and (num) {
5865 if (this.length > num.length) return this.clone().iand(num);
5866 return num.clone().iand(this);
5867 };
5868
5869 BN.prototype.uand = function uand (num) {
5870 if (this.length > num.length) return this.clone().iuand(num);
5871 return num.clone().iuand(this);
5872 };
5873
5874 // Xor `num` with `this` in-place
5875 BN.prototype.iuxor = function iuxor (num) {
5876 // a.length > b.length
5877 var a;
5878 var b;
5879 if (this.length > num.length) {
5880 a = this;
5881 b = num;
5882 } else {
5883 a = num;
5884 b = this;
5885 }
5886
5887 for (var i = 0; i < b.length; i++) {
5888 this.words[i] = a.words[i] ^ b.words[i];
5889 }
5890
5891 if (this !== a) {
5892 for (; i < a.length; i++) {
5893 this.words[i] = a.words[i];
5894 }
5895 }
5896
5897 this.length = a.length;
5898
5899 return this.strip();
5900 };
5901
5902 BN.prototype.ixor = function ixor (num) {
5903 assert((this.negative | num.negative) === 0);
5904 return this.iuxor(num);
5905 };
5906
5907 // Xor `num` with `this`
5908 BN.prototype.xor = function xor (num) {
5909 if (this.length > num.length) return this.clone().ixor(num);
5910 return num.clone().ixor(this);
5911 };
5912
5913 BN.prototype.uxor = function uxor (num) {
5914 if (this.length > num.length) return this.clone().iuxor(num);
5915 return num.clone().iuxor(this);
5916 };
5917
5918 // Not ``this`` with ``width`` bitwidth
5919 BN.prototype.inotn = function inotn (width) {
5920 assert(typeof width === 'number' && width >= 0);
5921
5922 var bytesNeeded = Math.ceil(width / 26) | 0;
5923 var bitsLeft = width % 26;
5924
5925 // Extend the buffer with leading zeroes
5926 this._expand(bytesNeeded);
5927
5928 if (bitsLeft > 0) {
5929 bytesNeeded--;
5930 }
5931
5932 // Handle complete words
5933 for (var i = 0; i < bytesNeeded; i++) {
5934 this.words[i] = ~this.words[i] & 0x3ffffff;
5935 }
5936
5937 // Handle the residue
5938 if (bitsLeft > 0) {
5939 this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft));
5940 }
5941
5942 // And remove leading zeroes
5943 return this.strip();
5944 };
5945
5946 BN.prototype.notn = function notn (width) {
5947 return this.clone().inotn(width);
5948 };
5949
5950 // Set `bit` of `this`
5951 BN.prototype.setn = function setn (bit, val) {
5952 assert(typeof bit === 'number' && bit >= 0);
5953
5954 var off = (bit / 26) | 0;
5955 var wbit = bit % 26;
5956
5957 this._expand(off + 1);
5958
5959 if (val) {
5960 this.words[off] = this.words[off] | (1 << wbit);
5961 } else {
5962 this.words[off] = this.words[off] & ~(1 << wbit);
5963 }
5964
5965 return this.strip();
5966 };
5967
5968 // Add `num` to `this` in-place
5969 BN.prototype.iadd = function iadd (num) {
5970 var r;
5971
5972 // negative + positive
5973 if (this.negative !== 0 && num.negative === 0) {
5974 this.negative = 0;
5975 r = this.isub(num);
5976 this.negative ^= 1;
5977 return this._normSign();
5978
5979 // positive + negative
5980 } else if (this.negative === 0 && num.negative !== 0) {
5981 num.negative = 0;
5982 r = this.isub(num);
5983 num.negative = 1;
5984 return r._normSign();
5985 }
5986
5987 // a.length > b.length
5988 var a, b;
5989 if (this.length > num.length) {
5990 a = this;
5991 b = num;
5992 } else {
5993 a = num;
5994 b = this;
5995 }
5996
5997 var carry = 0;
5998 for (var i = 0; i < b.length; i++) {
5999 r = (a.words[i] | 0) + (b.words[i] | 0) + carry;
6000 this.words[i] = r & 0x3ffffff;
6001 carry = r >>> 26;
6002 }
6003 for (; carry !== 0 && i < a.length; i++) {
6004 r = (a.words[i] | 0) + carry;
6005 this.words[i] = r & 0x3ffffff;
6006 carry = r >>> 26;
6007 }
6008
6009 this.length = a.length;
6010 if (carry !== 0) {
6011 this.words[this.length] = carry;
6012 this.length++;
6013 // Copy the rest of the words
6014 } else if (a !== this) {
6015 for (; i < a.length; i++) {
6016 this.words[i] = a.words[i];
6017 }
6018 }
6019
6020 return this;
6021 };
6022
6023 // Add `num` to `this`
6024 BN.prototype.add = function add (num) {
6025 var res;
6026 if (num.negative !== 0 && this.negative === 0) {
6027 num.negative = 0;
6028 res = this.sub(num);
6029 num.negative ^= 1;
6030 return res;
6031 } else if (num.negative === 0 && this.negative !== 0) {
6032 this.negative = 0;
6033 res = num.sub(this);
6034 this.negative = 1;
6035 return res;
6036 }
6037
6038 if (this.length > num.length) return this.clone().iadd(num);
6039
6040 return num.clone().iadd(this);
6041 };
6042
6043 // Subtract `num` from `this` in-place
6044 BN.prototype.isub = function isub (num) {
6045 // this - (-num) = this + num
6046 if (num.negative !== 0) {
6047 num.negative = 0;
6048 var r = this.iadd(num);
6049 num.negative = 1;
6050 return r._normSign();
6051
6052 // -this - num = -(this + num)
6053 } else if (this.negative !== 0) {
6054 this.negative = 0;
6055 this.iadd(num);
6056 this.negative = 1;
6057 return this._normSign();
6058 }
6059
6060 // At this point both numbers are positive
6061 var cmp = this.cmp(num);
6062
6063 // Optimization - zeroify
6064 if (cmp === 0) {
6065 this.negative = 0;
6066 this.length = 1;
6067 this.words[0] = 0;
6068 return this;
6069 }
6070
6071 // a > b
6072 var a, b;
6073 if (cmp > 0) {
6074 a = this;
6075 b = num;
6076 } else {
6077 a = num;
6078 b = this;
6079 }
6080
6081 var carry = 0;
6082 for (var i = 0; i < b.length; i++) {
6083 r = (a.words[i] | 0) - (b.words[i] | 0) + carry;
6084 carry = r >> 26;
6085 this.words[i] = r & 0x3ffffff;
6086 }
6087 for (; carry !== 0 && i < a.length; i++) {
6088 r = (a.words[i] | 0) + carry;
6089 carry = r >> 26;
6090 this.words[i] = r & 0x3ffffff;
6091 }
6092
6093 // Copy rest of the words
6094 if (carry === 0 && i < a.length && a !== this) {
6095 for (; i < a.length; i++) {
6096 this.words[i] = a.words[i];
6097 }
6098 }
6099
6100 this.length = Math.max(this.length, i);
6101
6102 if (a !== this) {
6103 this.negative = 1;
6104 }
6105
6106 return this.strip();
6107 };
6108
6109 // Subtract `num` from `this`
6110 BN.prototype.sub = function sub (num) {
6111 return this.clone().isub(num);
6112 };
6113
6114 function smallMulTo (self, num, out) {
6115 out.negative = num.negative ^ self.negative;
6116 var len = (self.length + num.length) | 0;
6117 out.length = len;
6118 len = (len - 1) | 0;
6119
6120 // Peel one iteration (compiler can't do it, because of code complexity)
6121 var a = self.words[0] | 0;
6122 var b = num.words[0] | 0;
6123 var r = a * b;
6124
6125 var lo = r & 0x3ffffff;
6126 var carry = (r / 0x4000000) | 0;
6127 out.words[0] = lo;
6128
6129 for (var k = 1; k < len; k++) {
6130 // Sum all words with the same `i + j = k` and accumulate `ncarry`,
6131 // note that ncarry could be >= 0x3ffffff
6132 var ncarry = carry >>> 26;
6133 var rword = carry & 0x3ffffff;
6134 var maxJ = Math.min(k, num.length - 1);
6135 for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
6136 var i = (k - j) | 0;
6137 a = self.words[i] | 0;
6138 b = num.words[j] | 0;
6139 r = a * b + rword;
6140 ncarry += (r / 0x4000000) | 0;
6141 rword = r & 0x3ffffff;
6142 }
6143 out.words[k] = rword | 0;
6144 carry = ncarry | 0;
6145 }
6146 if (carry !== 0) {
6147 out.words[k] = carry | 0;
6148 } else {
6149 out.length--;
6150 }
6151
6152 return out.strip();
6153 }
6154
6155 // TODO(indutny): it may be reasonable to omit it for users who don't need
6156 // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit
6157 // multiplication (like elliptic secp256k1).
6158 var comb10MulTo = function comb10MulTo (self, num, out) {
6159 var a = self.words;
6160 var b = num.words;
6161 var o = out.words;
6162 var c = 0;
6163 var lo;
6164 var mid;
6165 var hi;
6166 var a0 = a[0] | 0;
6167 var al0 = a0 & 0x1fff;
6168 var ah0 = a0 >>> 13;
6169 var a1 = a[1] | 0;
6170 var al1 = a1 & 0x1fff;
6171 var ah1 = a1 >>> 13;
6172 var a2 = a[2] | 0;
6173 var al2 = a2 & 0x1fff;
6174 var ah2 = a2 >>> 13;
6175 var a3 = a[3] | 0;
6176 var al3 = a3 & 0x1fff;
6177 var ah3 = a3 >>> 13;
6178 var a4 = a[4] | 0;
6179 var al4 = a4 & 0x1fff;
6180 var ah4 = a4 >>> 13;
6181 var a5 = a[5] | 0;
6182 var al5 = a5 & 0x1fff;
6183 var ah5 = a5 >>> 13;
6184 var a6 = a[6] | 0;
6185 var al6 = a6 & 0x1fff;
6186 var ah6 = a6 >>> 13;
6187 var a7 = a[7] | 0;
6188 var al7 = a7 & 0x1fff;
6189 var ah7 = a7 >>> 13;
6190 var a8 = a[8] | 0;
6191 var al8 = a8 & 0x1fff;
6192 var ah8 = a8 >>> 13;
6193 var a9 = a[9] | 0;
6194 var al9 = a9 & 0x1fff;
6195 var ah9 = a9 >>> 13;
6196 var b0 = b[0] | 0;
6197 var bl0 = b0 & 0x1fff;
6198 var bh0 = b0 >>> 13;
6199 var b1 = b[1] | 0;
6200 var bl1 = b1 & 0x1fff;
6201 var bh1 = b1 >>> 13;
6202 var b2 = b[2] | 0;
6203 var bl2 = b2 & 0x1fff;
6204 var bh2 = b2 >>> 13;
6205 var b3 = b[3] | 0;
6206 var bl3 = b3 & 0x1fff;
6207 var bh3 = b3 >>> 13;
6208 var b4 = b[4] | 0;
6209 var bl4 = b4 & 0x1fff;
6210 var bh4 = b4 >>> 13;
6211 var b5 = b[5] | 0;
6212 var bl5 = b5 & 0x1fff;
6213 var bh5 = b5 >>> 13;
6214 var b6 = b[6] | 0;
6215 var bl6 = b6 & 0x1fff;
6216 var bh6 = b6 >>> 13;
6217 var b7 = b[7] | 0;
6218 var bl7 = b7 & 0x1fff;
6219 var bh7 = b7 >>> 13;
6220 var b8 = b[8] | 0;
6221 var bl8 = b8 & 0x1fff;
6222 var bh8 = b8 >>> 13;
6223 var b9 = b[9] | 0;
6224 var bl9 = b9 & 0x1fff;
6225 var bh9 = b9 >>> 13;
6226
6227 out.negative = self.negative ^ num.negative;
6228 out.length = 19;
6229 /* k = 0 */
6230 lo = Math.imul(al0, bl0);
6231 mid = Math.imul(al0, bh0);
6232 mid = (mid + Math.imul(ah0, bl0)) | 0;
6233 hi = Math.imul(ah0, bh0);
6234 var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6235 c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0;
6236 w0 &= 0x3ffffff;
6237 /* k = 1 */
6238 lo = Math.imul(al1, bl0);
6239 mid = Math.imul(al1, bh0);
6240 mid = (mid + Math.imul(ah1, bl0)) | 0;
6241 hi = Math.imul(ah1, bh0);
6242 lo = (lo + Math.imul(al0, bl1)) | 0;
6243 mid = (mid + Math.imul(al0, bh1)) | 0;
6244 mid = (mid + Math.imul(ah0, bl1)) | 0;
6245 hi = (hi + Math.imul(ah0, bh1)) | 0;
6246 var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6247 c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0;
6248 w1 &= 0x3ffffff;
6249 /* k = 2 */
6250 lo = Math.imul(al2, bl0);
6251 mid = Math.imul(al2, bh0);
6252 mid = (mid + Math.imul(ah2, bl0)) | 0;
6253 hi = Math.imul(ah2, bh0);
6254 lo = (lo + Math.imul(al1, bl1)) | 0;
6255 mid = (mid + Math.imul(al1, bh1)) | 0;
6256 mid = (mid + Math.imul(ah1, bl1)) | 0;
6257 hi = (hi + Math.imul(ah1, bh1)) | 0;
6258 lo = (lo + Math.imul(al0, bl2)) | 0;
6259 mid = (mid + Math.imul(al0, bh2)) | 0;
6260 mid = (mid + Math.imul(ah0, bl2)) | 0;
6261 hi = (hi + Math.imul(ah0, bh2)) | 0;
6262 var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6263 c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0;
6264 w2 &= 0x3ffffff;
6265 /* k = 3 */
6266 lo = Math.imul(al3, bl0);
6267 mid = Math.imul(al3, bh0);
6268 mid = (mid + Math.imul(ah3, bl0)) | 0;
6269 hi = Math.imul(ah3, bh0);
6270 lo = (lo + Math.imul(al2, bl1)) | 0;
6271 mid = (mid + Math.imul(al2, bh1)) | 0;
6272 mid = (mid + Math.imul(ah2, bl1)) | 0;
6273 hi = (hi + Math.imul(ah2, bh1)) | 0;
6274 lo = (lo + Math.imul(al1, bl2)) | 0;
6275 mid = (mid + Math.imul(al1, bh2)) | 0;
6276 mid = (mid + Math.imul(ah1, bl2)) | 0;
6277 hi = (hi + Math.imul(ah1, bh2)) | 0;
6278 lo = (lo + Math.imul(al0, bl3)) | 0;
6279 mid = (mid + Math.imul(al0, bh3)) | 0;
6280 mid = (mid + Math.imul(ah0, bl3)) | 0;
6281 hi = (hi + Math.imul(ah0, bh3)) | 0;
6282 var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6283 c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0;
6284 w3 &= 0x3ffffff;
6285 /* k = 4 */
6286 lo = Math.imul(al4, bl0);
6287 mid = Math.imul(al4, bh0);
6288 mid = (mid + Math.imul(ah4, bl0)) | 0;
6289 hi = Math.imul(ah4, bh0);
6290 lo = (lo + Math.imul(al3, bl1)) | 0;
6291 mid = (mid + Math.imul(al3, bh1)) | 0;
6292 mid = (mid + Math.imul(ah3, bl1)) | 0;
6293 hi = (hi + Math.imul(ah3, bh1)) | 0;
6294 lo = (lo + Math.imul(al2, bl2)) | 0;
6295 mid = (mid + Math.imul(al2, bh2)) | 0;
6296 mid = (mid + Math.imul(ah2, bl2)) | 0;
6297 hi = (hi + Math.imul(ah2, bh2)) | 0;
6298 lo = (lo + Math.imul(al1, bl3)) | 0;
6299 mid = (mid + Math.imul(al1, bh3)) | 0;
6300 mid = (mid + Math.imul(ah1, bl3)) | 0;
6301 hi = (hi + Math.imul(ah1, bh3)) | 0;
6302 lo = (lo + Math.imul(al0, bl4)) | 0;
6303 mid = (mid + Math.imul(al0, bh4)) | 0;
6304 mid = (mid + Math.imul(ah0, bl4)) | 0;
6305 hi = (hi + Math.imul(ah0, bh4)) | 0;
6306 var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6307 c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0;
6308 w4 &= 0x3ffffff;
6309 /* k = 5 */
6310 lo = Math.imul(al5, bl0);
6311 mid = Math.imul(al5, bh0);
6312 mid = (mid + Math.imul(ah5, bl0)) | 0;
6313 hi = Math.imul(ah5, bh0);
6314 lo = (lo + Math.imul(al4, bl1)) | 0;
6315 mid = (mid + Math.imul(al4, bh1)) | 0;
6316 mid = (mid + Math.imul(ah4, bl1)) | 0;
6317 hi = (hi + Math.imul(ah4, bh1)) | 0;
6318 lo = (lo + Math.imul(al3, bl2)) | 0;
6319 mid = (mid + Math.imul(al3, bh2)) | 0;
6320 mid = (mid + Math.imul(ah3, bl2)) | 0;
6321 hi = (hi + Math.imul(ah3, bh2)) | 0;
6322 lo = (lo + Math.imul(al2, bl3)) | 0;
6323 mid = (mid + Math.imul(al2, bh3)) | 0;
6324 mid = (mid + Math.imul(ah2, bl3)) | 0;
6325 hi = (hi + Math.imul(ah2, bh3)) | 0;
6326 lo = (lo + Math.imul(al1, bl4)) | 0;
6327 mid = (mid + Math.imul(al1, bh4)) | 0;
6328 mid = (mid + Math.imul(ah1, bl4)) | 0;
6329 hi = (hi + Math.imul(ah1, bh4)) | 0;
6330 lo = (lo + Math.imul(al0, bl5)) | 0;
6331 mid = (mid + Math.imul(al0, bh5)) | 0;
6332 mid = (mid + Math.imul(ah0, bl5)) | 0;
6333 hi = (hi + Math.imul(ah0, bh5)) | 0;
6334 var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6335 c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0;
6336 w5 &= 0x3ffffff;
6337 /* k = 6 */
6338 lo = Math.imul(al6, bl0);
6339 mid = Math.imul(al6, bh0);
6340 mid = (mid + Math.imul(ah6, bl0)) | 0;
6341 hi = Math.imul(ah6, bh0);
6342 lo = (lo + Math.imul(al5, bl1)) | 0;
6343 mid = (mid + Math.imul(al5, bh1)) | 0;
6344 mid = (mid + Math.imul(ah5, bl1)) | 0;
6345 hi = (hi + Math.imul(ah5, bh1)) | 0;
6346 lo = (lo + Math.imul(al4, bl2)) | 0;
6347 mid = (mid + Math.imul(al4, bh2)) | 0;
6348 mid = (mid + Math.imul(ah4, bl2)) | 0;
6349 hi = (hi + Math.imul(ah4, bh2)) | 0;
6350 lo = (lo + Math.imul(al3, bl3)) | 0;
6351 mid = (mid + Math.imul(al3, bh3)) | 0;
6352 mid = (mid + Math.imul(ah3, bl3)) | 0;
6353 hi = (hi + Math.imul(ah3, bh3)) | 0;
6354 lo = (lo + Math.imul(al2, bl4)) | 0;
6355 mid = (mid + Math.imul(al2, bh4)) | 0;
6356 mid = (mid + Math.imul(ah2, bl4)) | 0;
6357 hi = (hi + Math.imul(ah2, bh4)) | 0;
6358 lo = (lo + Math.imul(al1, bl5)) | 0;
6359 mid = (mid + Math.imul(al1, bh5)) | 0;
6360 mid = (mid + Math.imul(ah1, bl5)) | 0;
6361 hi = (hi + Math.imul(ah1, bh5)) | 0;
6362 lo = (lo + Math.imul(al0, bl6)) | 0;
6363 mid = (mid + Math.imul(al0, bh6)) | 0;
6364 mid = (mid + Math.imul(ah0, bl6)) | 0;
6365 hi = (hi + Math.imul(ah0, bh6)) | 0;
6366 var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6367 c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0;
6368 w6 &= 0x3ffffff;
6369 /* k = 7 */
6370 lo = Math.imul(al7, bl0);
6371 mid = Math.imul(al7, bh0);
6372 mid = (mid + Math.imul(ah7, bl0)) | 0;
6373 hi = Math.imul(ah7, bh0);
6374 lo = (lo + Math.imul(al6, bl1)) | 0;
6375 mid = (mid + Math.imul(al6, bh1)) | 0;
6376 mid = (mid + Math.imul(ah6, bl1)) | 0;
6377 hi = (hi + Math.imul(ah6, bh1)) | 0;
6378 lo = (lo + Math.imul(al5, bl2)) | 0;
6379 mid = (mid + Math.imul(al5, bh2)) | 0;
6380 mid = (mid + Math.imul(ah5, bl2)) | 0;
6381 hi = (hi + Math.imul(ah5, bh2)) | 0;
6382 lo = (lo + Math.imul(al4, bl3)) | 0;
6383 mid = (mid + Math.imul(al4, bh3)) | 0;
6384 mid = (mid + Math.imul(ah4, bl3)) | 0;
6385 hi = (hi + Math.imul(ah4, bh3)) | 0;
6386 lo = (lo + Math.imul(al3, bl4)) | 0;
6387 mid = (mid + Math.imul(al3, bh4)) | 0;
6388 mid = (mid + Math.imul(ah3, bl4)) | 0;
6389 hi = (hi + Math.imul(ah3, bh4)) | 0;
6390 lo = (lo + Math.imul(al2, bl5)) | 0;
6391 mid = (mid + Math.imul(al2, bh5)) | 0;
6392 mid = (mid + Math.imul(ah2, bl5)) | 0;
6393 hi = (hi + Math.imul(ah2, bh5)) | 0;
6394 lo = (lo + Math.imul(al1, bl6)) | 0;
6395 mid = (mid + Math.imul(al1, bh6)) | 0;
6396 mid = (mid + Math.imul(ah1, bl6)) | 0;
6397 hi = (hi + Math.imul(ah1, bh6)) | 0;
6398 lo = (lo + Math.imul(al0, bl7)) | 0;
6399 mid = (mid + Math.imul(al0, bh7)) | 0;
6400 mid = (mid + Math.imul(ah0, bl7)) | 0;
6401 hi = (hi + Math.imul(ah0, bh7)) | 0;
6402 var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6403 c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0;
6404 w7 &= 0x3ffffff;
6405 /* k = 8 */
6406 lo = Math.imul(al8, bl0);
6407 mid = Math.imul(al8, bh0);
6408 mid = (mid + Math.imul(ah8, bl0)) | 0;
6409 hi = Math.imul(ah8, bh0);
6410 lo = (lo + Math.imul(al7, bl1)) | 0;
6411 mid = (mid + Math.imul(al7, bh1)) | 0;
6412 mid = (mid + Math.imul(ah7, bl1)) | 0;
6413 hi = (hi + Math.imul(ah7, bh1)) | 0;
6414 lo = (lo + Math.imul(al6, bl2)) | 0;
6415 mid = (mid + Math.imul(al6, bh2)) | 0;
6416 mid = (mid + Math.imul(ah6, bl2)) | 0;
6417 hi = (hi + Math.imul(ah6, bh2)) | 0;
6418 lo = (lo + Math.imul(al5, bl3)) | 0;
6419 mid = (mid + Math.imul(al5, bh3)) | 0;
6420 mid = (mid + Math.imul(ah5, bl3)) | 0;
6421 hi = (hi + Math.imul(ah5, bh3)) | 0;
6422 lo = (lo + Math.imul(al4, bl4)) | 0;
6423 mid = (mid + Math.imul(al4, bh4)) | 0;
6424 mid = (mid + Math.imul(ah4, bl4)) | 0;
6425 hi = (hi + Math.imul(ah4, bh4)) | 0;
6426 lo = (lo + Math.imul(al3, bl5)) | 0;
6427 mid = (mid + Math.imul(al3, bh5)) | 0;
6428 mid = (mid + Math.imul(ah3, bl5)) | 0;
6429 hi = (hi + Math.imul(ah3, bh5)) | 0;
6430 lo = (lo + Math.imul(al2, bl6)) | 0;
6431 mid = (mid + Math.imul(al2, bh6)) | 0;
6432 mid = (mid + Math.imul(ah2, bl6)) | 0;
6433 hi = (hi + Math.imul(ah2, bh6)) | 0;
6434 lo = (lo + Math.imul(al1, bl7)) | 0;
6435 mid = (mid + Math.imul(al1, bh7)) | 0;
6436 mid = (mid + Math.imul(ah1, bl7)) | 0;
6437 hi = (hi + Math.imul(ah1, bh7)) | 0;
6438 lo = (lo + Math.imul(al0, bl8)) | 0;
6439 mid = (mid + Math.imul(al0, bh8)) | 0;
6440 mid = (mid + Math.imul(ah0, bl8)) | 0;
6441 hi = (hi + Math.imul(ah0, bh8)) | 0;
6442 var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6443 c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0;
6444 w8 &= 0x3ffffff;
6445 /* k = 9 */
6446 lo = Math.imul(al9, bl0);
6447 mid = Math.imul(al9, bh0);
6448 mid = (mid + Math.imul(ah9, bl0)) | 0;
6449 hi = Math.imul(ah9, bh0);
6450 lo = (lo + Math.imul(al8, bl1)) | 0;
6451 mid = (mid + Math.imul(al8, bh1)) | 0;
6452 mid = (mid + Math.imul(ah8, bl1)) | 0;
6453 hi = (hi + Math.imul(ah8, bh1)) | 0;
6454 lo = (lo + Math.imul(al7, bl2)) | 0;
6455 mid = (mid + Math.imul(al7, bh2)) | 0;
6456 mid = (mid + Math.imul(ah7, bl2)) | 0;
6457 hi = (hi + Math.imul(ah7, bh2)) | 0;
6458 lo = (lo + Math.imul(al6, bl3)) | 0;
6459 mid = (mid + Math.imul(al6, bh3)) | 0;
6460 mid = (mid + Math.imul(ah6, bl3)) | 0;
6461 hi = (hi + Math.imul(ah6, bh3)) | 0;
6462 lo = (lo + Math.imul(al5, bl4)) | 0;
6463 mid = (mid + Math.imul(al5, bh4)) | 0;
6464 mid = (mid + Math.imul(ah5, bl4)) | 0;
6465 hi = (hi + Math.imul(ah5, bh4)) | 0;
6466 lo = (lo + Math.imul(al4, bl5)) | 0;
6467 mid = (mid + Math.imul(al4, bh5)) | 0;
6468 mid = (mid + Math.imul(ah4, bl5)) | 0;
6469 hi = (hi + Math.imul(ah4, bh5)) | 0;
6470 lo = (lo + Math.imul(al3, bl6)) | 0;
6471 mid = (mid + Math.imul(al3, bh6)) | 0;
6472 mid = (mid + Math.imul(ah3, bl6)) | 0;
6473 hi = (hi + Math.imul(ah3, bh6)) | 0;
6474 lo = (lo + Math.imul(al2, bl7)) | 0;
6475 mid = (mid + Math.imul(al2, bh7)) | 0;
6476 mid = (mid + Math.imul(ah2, bl7)) | 0;
6477 hi = (hi + Math.imul(ah2, bh7)) | 0;
6478 lo = (lo + Math.imul(al1, bl8)) | 0;
6479 mid = (mid + Math.imul(al1, bh8)) | 0;
6480 mid = (mid + Math.imul(ah1, bl8)) | 0;
6481 hi = (hi + Math.imul(ah1, bh8)) | 0;
6482 lo = (lo + Math.imul(al0, bl9)) | 0;
6483 mid = (mid + Math.imul(al0, bh9)) | 0;
6484 mid = (mid + Math.imul(ah0, bl9)) | 0;
6485 hi = (hi + Math.imul(ah0, bh9)) | 0;
6486 var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6487 c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0;
6488 w9 &= 0x3ffffff;
6489 /* k = 10 */
6490 lo = Math.imul(al9, bl1);
6491 mid = Math.imul(al9, bh1);
6492 mid = (mid + Math.imul(ah9, bl1)) | 0;
6493 hi = Math.imul(ah9, bh1);
6494 lo = (lo + Math.imul(al8, bl2)) | 0;
6495 mid = (mid + Math.imul(al8, bh2)) | 0;
6496 mid = (mid + Math.imul(ah8, bl2)) | 0;
6497 hi = (hi + Math.imul(ah8, bh2)) | 0;
6498 lo = (lo + Math.imul(al7, bl3)) | 0;
6499 mid = (mid + Math.imul(al7, bh3)) | 0;
6500 mid = (mid + Math.imul(ah7, bl3)) | 0;
6501 hi = (hi + Math.imul(ah7, bh3)) | 0;
6502 lo = (lo + Math.imul(al6, bl4)) | 0;
6503 mid = (mid + Math.imul(al6, bh4)) | 0;
6504 mid = (mid + Math.imul(ah6, bl4)) | 0;
6505 hi = (hi + Math.imul(ah6, bh4)) | 0;
6506 lo = (lo + Math.imul(al5, bl5)) | 0;
6507 mid = (mid + Math.imul(al5, bh5)) | 0;
6508 mid = (mid + Math.imul(ah5, bl5)) | 0;
6509 hi = (hi + Math.imul(ah5, bh5)) | 0;
6510 lo = (lo + Math.imul(al4, bl6)) | 0;
6511 mid = (mid + Math.imul(al4, bh6)) | 0;
6512 mid = (mid + Math.imul(ah4, bl6)) | 0;
6513 hi = (hi + Math.imul(ah4, bh6)) | 0;
6514 lo = (lo + Math.imul(al3, bl7)) | 0;
6515 mid = (mid + Math.imul(al3, bh7)) | 0;
6516 mid = (mid + Math.imul(ah3, bl7)) | 0;
6517 hi = (hi + Math.imul(ah3, bh7)) | 0;
6518 lo = (lo + Math.imul(al2, bl8)) | 0;
6519 mid = (mid + Math.imul(al2, bh8)) | 0;
6520 mid = (mid + Math.imul(ah2, bl8)) | 0;
6521 hi = (hi + Math.imul(ah2, bh8)) | 0;
6522 lo = (lo + Math.imul(al1, bl9)) | 0;
6523 mid = (mid + Math.imul(al1, bh9)) | 0;
6524 mid = (mid + Math.imul(ah1, bl9)) | 0;
6525 hi = (hi + Math.imul(ah1, bh9)) | 0;
6526 var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6527 c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0;
6528 w10 &= 0x3ffffff;
6529 /* k = 11 */
6530 lo = Math.imul(al9, bl2);
6531 mid = Math.imul(al9, bh2);
6532 mid = (mid + Math.imul(ah9, bl2)) | 0;
6533 hi = Math.imul(ah9, bh2);
6534 lo = (lo + Math.imul(al8, bl3)) | 0;
6535 mid = (mid + Math.imul(al8, bh3)) | 0;
6536 mid = (mid + Math.imul(ah8, bl3)) | 0;
6537 hi = (hi + Math.imul(ah8, bh3)) | 0;
6538 lo = (lo + Math.imul(al7, bl4)) | 0;
6539 mid = (mid + Math.imul(al7, bh4)) | 0;
6540 mid = (mid + Math.imul(ah7, bl4)) | 0;
6541 hi = (hi + Math.imul(ah7, bh4)) | 0;
6542 lo = (lo + Math.imul(al6, bl5)) | 0;
6543 mid = (mid + Math.imul(al6, bh5)) | 0;
6544 mid = (mid + Math.imul(ah6, bl5)) | 0;
6545 hi = (hi + Math.imul(ah6, bh5)) | 0;
6546 lo = (lo + Math.imul(al5, bl6)) | 0;
6547 mid = (mid + Math.imul(al5, bh6)) | 0;
6548 mid = (mid + Math.imul(ah5, bl6)) | 0;
6549 hi = (hi + Math.imul(ah5, bh6)) | 0;
6550 lo = (lo + Math.imul(al4, bl7)) | 0;
6551 mid = (mid + Math.imul(al4, bh7)) | 0;
6552 mid = (mid + Math.imul(ah4, bl7)) | 0;
6553 hi = (hi + Math.imul(ah4, bh7)) | 0;
6554 lo = (lo + Math.imul(al3, bl8)) | 0;
6555 mid = (mid + Math.imul(al3, bh8)) | 0;
6556 mid = (mid + Math.imul(ah3, bl8)) | 0;
6557 hi = (hi + Math.imul(ah3, bh8)) | 0;
6558 lo = (lo + Math.imul(al2, bl9)) | 0;
6559 mid = (mid + Math.imul(al2, bh9)) | 0;
6560 mid = (mid + Math.imul(ah2, bl9)) | 0;
6561 hi = (hi + Math.imul(ah2, bh9)) | 0;
6562 var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6563 c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0;
6564 w11 &= 0x3ffffff;
6565 /* k = 12 */
6566 lo = Math.imul(al9, bl3);
6567 mid = Math.imul(al9, bh3);
6568 mid = (mid + Math.imul(ah9, bl3)) | 0;
6569 hi = Math.imul(ah9, bh3);
6570 lo = (lo + Math.imul(al8, bl4)) | 0;
6571 mid = (mid + Math.imul(al8, bh4)) | 0;
6572 mid = (mid + Math.imul(ah8, bl4)) | 0;
6573 hi = (hi + Math.imul(ah8, bh4)) | 0;
6574 lo = (lo + Math.imul(al7, bl5)) | 0;
6575 mid = (mid + Math.imul(al7, bh5)) | 0;
6576 mid = (mid + Math.imul(ah7, bl5)) | 0;
6577 hi = (hi + Math.imul(ah7, bh5)) | 0;
6578 lo = (lo + Math.imul(al6, bl6)) | 0;
6579 mid = (mid + Math.imul(al6, bh6)) | 0;
6580 mid = (mid + Math.imul(ah6, bl6)) | 0;
6581 hi = (hi + Math.imul(ah6, bh6)) | 0;
6582 lo = (lo + Math.imul(al5, bl7)) | 0;
6583 mid = (mid + Math.imul(al5, bh7)) | 0;
6584 mid = (mid + Math.imul(ah5, bl7)) | 0;
6585 hi = (hi + Math.imul(ah5, bh7)) | 0;
6586 lo = (lo + Math.imul(al4, bl8)) | 0;
6587 mid = (mid + Math.imul(al4, bh8)) | 0;
6588 mid = (mid + Math.imul(ah4, bl8)) | 0;
6589 hi = (hi + Math.imul(ah4, bh8)) | 0;
6590 lo = (lo + Math.imul(al3, bl9)) | 0;
6591 mid = (mid + Math.imul(al3, bh9)) | 0;
6592 mid = (mid + Math.imul(ah3, bl9)) | 0;
6593 hi = (hi + Math.imul(ah3, bh9)) | 0;
6594 var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6595 c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0;
6596 w12 &= 0x3ffffff;
6597 /* k = 13 */
6598 lo = Math.imul(al9, bl4);
6599 mid = Math.imul(al9, bh4);
6600 mid = (mid + Math.imul(ah9, bl4)) | 0;
6601 hi = Math.imul(ah9, bh4);
6602 lo = (lo + Math.imul(al8, bl5)) | 0;
6603 mid = (mid + Math.imul(al8, bh5)) | 0;
6604 mid = (mid + Math.imul(ah8, bl5)) | 0;
6605 hi = (hi + Math.imul(ah8, bh5)) | 0;
6606 lo = (lo + Math.imul(al7, bl6)) | 0;
6607 mid = (mid + Math.imul(al7, bh6)) | 0;
6608 mid = (mid + Math.imul(ah7, bl6)) | 0;
6609 hi = (hi + Math.imul(ah7, bh6)) | 0;
6610 lo = (lo + Math.imul(al6, bl7)) | 0;
6611 mid = (mid + Math.imul(al6, bh7)) | 0;
6612 mid = (mid + Math.imul(ah6, bl7)) | 0;
6613 hi = (hi + Math.imul(ah6, bh7)) | 0;
6614 lo = (lo + Math.imul(al5, bl8)) | 0;
6615 mid = (mid + Math.imul(al5, bh8)) | 0;
6616 mid = (mid + Math.imul(ah5, bl8)) | 0;
6617 hi = (hi + Math.imul(ah5, bh8)) | 0;
6618 lo = (lo + Math.imul(al4, bl9)) | 0;
6619 mid = (mid + Math.imul(al4, bh9)) | 0;
6620 mid = (mid + Math.imul(ah4, bl9)) | 0;
6621 hi = (hi + Math.imul(ah4, bh9)) | 0;
6622 var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6623 c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0;
6624 w13 &= 0x3ffffff;
6625 /* k = 14 */
6626 lo = Math.imul(al9, bl5);
6627 mid = Math.imul(al9, bh5);
6628 mid = (mid + Math.imul(ah9, bl5)) | 0;
6629 hi = Math.imul(ah9, bh5);
6630 lo = (lo + Math.imul(al8, bl6)) | 0;
6631 mid = (mid + Math.imul(al8, bh6)) | 0;
6632 mid = (mid + Math.imul(ah8, bl6)) | 0;
6633 hi = (hi + Math.imul(ah8, bh6)) | 0;
6634 lo = (lo + Math.imul(al7, bl7)) | 0;
6635 mid = (mid + Math.imul(al7, bh7)) | 0;
6636 mid = (mid + Math.imul(ah7, bl7)) | 0;
6637 hi = (hi + Math.imul(ah7, bh7)) | 0;
6638 lo = (lo + Math.imul(al6, bl8)) | 0;
6639 mid = (mid + Math.imul(al6, bh8)) | 0;
6640 mid = (mid + Math.imul(ah6, bl8)) | 0;
6641 hi = (hi + Math.imul(ah6, bh8)) | 0;
6642 lo = (lo + Math.imul(al5, bl9)) | 0;
6643 mid = (mid + Math.imul(al5, bh9)) | 0;
6644 mid = (mid + Math.imul(ah5, bl9)) | 0;
6645 hi = (hi + Math.imul(ah5, bh9)) | 0;
6646 var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6647 c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0;
6648 w14 &= 0x3ffffff;
6649 /* k = 15 */
6650 lo = Math.imul(al9, bl6);
6651 mid = Math.imul(al9, bh6);
6652 mid = (mid + Math.imul(ah9, bl6)) | 0;
6653 hi = Math.imul(ah9, bh6);
6654 lo = (lo + Math.imul(al8, bl7)) | 0;
6655 mid = (mid + Math.imul(al8, bh7)) | 0;
6656 mid = (mid + Math.imul(ah8, bl7)) | 0;
6657 hi = (hi + Math.imul(ah8, bh7)) | 0;
6658 lo = (lo + Math.imul(al7, bl8)) | 0;
6659 mid = (mid + Math.imul(al7, bh8)) | 0;
6660 mid = (mid + Math.imul(ah7, bl8)) | 0;
6661 hi = (hi + Math.imul(ah7, bh8)) | 0;
6662 lo = (lo + Math.imul(al6, bl9)) | 0;
6663 mid = (mid + Math.imul(al6, bh9)) | 0;
6664 mid = (mid + Math.imul(ah6, bl9)) | 0;
6665 hi = (hi + Math.imul(ah6, bh9)) | 0;
6666 var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6667 c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0;
6668 w15 &= 0x3ffffff;
6669 /* k = 16 */
6670 lo = Math.imul(al9, bl7);
6671 mid = Math.imul(al9, bh7);
6672 mid = (mid + Math.imul(ah9, bl7)) | 0;
6673 hi = Math.imul(ah9, bh7);
6674 lo = (lo + Math.imul(al8, bl8)) | 0;
6675 mid = (mid + Math.imul(al8, bh8)) | 0;
6676 mid = (mid + Math.imul(ah8, bl8)) | 0;
6677 hi = (hi + Math.imul(ah8, bh8)) | 0;
6678 lo = (lo + Math.imul(al7, bl9)) | 0;
6679 mid = (mid + Math.imul(al7, bh9)) | 0;
6680 mid = (mid + Math.imul(ah7, bl9)) | 0;
6681 hi = (hi + Math.imul(ah7, bh9)) | 0;
6682 var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6683 c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0;
6684 w16 &= 0x3ffffff;
6685 /* k = 17 */
6686 lo = Math.imul(al9, bl8);
6687 mid = Math.imul(al9, bh8);
6688 mid = (mid + Math.imul(ah9, bl8)) | 0;
6689 hi = Math.imul(ah9, bh8);
6690 lo = (lo + Math.imul(al8, bl9)) | 0;
6691 mid = (mid + Math.imul(al8, bh9)) | 0;
6692 mid = (mid + Math.imul(ah8, bl9)) | 0;
6693 hi = (hi + Math.imul(ah8, bh9)) | 0;
6694 var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6695 c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0;
6696 w17 &= 0x3ffffff;
6697 /* k = 18 */
6698 lo = Math.imul(al9, bl9);
6699 mid = Math.imul(al9, bh9);
6700 mid = (mid + Math.imul(ah9, bl9)) | 0;
6701 hi = Math.imul(ah9, bh9);
6702 var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6703 c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0;
6704 w18 &= 0x3ffffff;
6705 o[0] = w0;
6706 o[1] = w1;
6707 o[2] = w2;
6708 o[3] = w3;
6709 o[4] = w4;
6710 o[5] = w5;
6711 o[6] = w6;
6712 o[7] = w7;
6713 o[8] = w8;
6714 o[9] = w9;
6715 o[10] = w10;
6716 o[11] = w11;
6717 o[12] = w12;
6718 o[13] = w13;
6719 o[14] = w14;
6720 o[15] = w15;
6721 o[16] = w16;
6722 o[17] = w17;
6723 o[18] = w18;
6724 if (c !== 0) {
6725 o[19] = c;
6726 out.length++;
6727 }
6728 return out;
6729 };
6730
6731 // Polyfill comb
6732 if (!Math.imul) {
6733 comb10MulTo = smallMulTo;
6734 }
6735
6736 function bigMulTo (self, num, out) {
6737 out.negative = num.negative ^ self.negative;
6738 out.length = self.length + num.length;
6739
6740 var carry = 0;
6741 var hncarry = 0;
6742 for (var k = 0; k < out.length - 1; k++) {
6743 // Sum all words with the same `i + j = k` and accumulate `ncarry`,
6744 // note that ncarry could be >= 0x3ffffff
6745 var ncarry = hncarry;
6746 hncarry = 0;
6747 var rword = carry & 0x3ffffff;
6748 var maxJ = Math.min(k, num.length - 1);
6749 for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
6750 var i = k - j;
6751 var a = self.words[i] | 0;
6752 var b = num.words[j] | 0;
6753 var r = a * b;
6754
6755 var lo = r & 0x3ffffff;
6756 ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0;
6757 lo = (lo + rword) | 0;
6758 rword = lo & 0x3ffffff;
6759 ncarry = (ncarry + (lo >>> 26)) | 0;
6760
6761 hncarry += ncarry >>> 26;
6762 ncarry &= 0x3ffffff;
6763 }
6764 out.words[k] = rword;
6765 carry = ncarry;
6766 ncarry = hncarry;
6767 }
6768 if (carry !== 0) {
6769 out.words[k] = carry;
6770 } else {
6771 out.length--;
6772 }
6773
6774 return out.strip();
6775 }
6776
6777 function jumboMulTo (self, num, out) {
6778 var fftm = new FFTM();
6779 return fftm.mulp(self, num, out);
6780 }
6781
6782 BN.prototype.mulTo = function mulTo (num, out) {
6783 var res;
6784 var len = this.length + num.length;
6785 if (this.length === 10 && num.length === 10) {
6786 res = comb10MulTo(this, num, out);
6787 } else if (len < 63) {
6788 res = smallMulTo(this, num, out);
6789 } else if (len < 1024) {
6790 res = bigMulTo(this, num, out);
6791 } else {
6792 res = jumboMulTo(this, num, out);
6793 }
6794
6795 return res;
6796 };
6797
6798 // Cooley-Tukey algorithm for FFT
6799 // slightly revisited to rely on looping instead of recursion
6800
6801 function FFTM (x, y) {
6802 this.x = x;
6803 this.y = y;
6804 }
6805
6806 FFTM.prototype.makeRBT = function makeRBT (N) {
6807 var t = new Array(N);
6808 var l = BN.prototype._countBits(N) - 1;
6809 for (var i = 0; i < N; i++) {
6810 t[i] = this.revBin(i, l, N);
6811 }
6812
6813 return t;
6814 };
6815
6816 // Returns binary-reversed representation of `x`
6817 FFTM.prototype.revBin = function revBin (x, l, N) {
6818 if (x === 0 || x === N - 1) return x;
6819
6820 var rb = 0;
6821 for (var i = 0; i < l; i++) {
6822 rb |= (x & 1) << (l - i - 1);
6823 x >>= 1;
6824 }
6825
6826 return rb;
6827 };
6828
6829 // Performs "tweedling" phase, therefore 'emulating'
6830 // behaviour of the recursive algorithm
6831 FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) {
6832 for (var i = 0; i < N; i++) {
6833 rtws[i] = rws[rbt[i]];
6834 itws[i] = iws[rbt[i]];
6835 }
6836 };
6837
6838 FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) {
6839 this.permute(rbt, rws, iws, rtws, itws, N);
6840
6841 for (var s = 1; s < N; s <<= 1) {
6842 var l = s << 1;
6843
6844 var rtwdf = Math.cos(2 * Math.PI / l);
6845 var itwdf = Math.sin(2 * Math.PI / l);
6846
6847 for (var p = 0; p < N; p += l) {
6848 var rtwdf_ = rtwdf;
6849 var itwdf_ = itwdf;
6850
6851 for (var j = 0; j < s; j++) {
6852 var re = rtws[p + j];
6853 var ie = itws[p + j];
6854
6855 var ro = rtws[p + j + s];
6856 var io = itws[p + j + s];
6857
6858 var rx = rtwdf_ * ro - itwdf_ * io;
6859
6860 io = rtwdf_ * io + itwdf_ * ro;
6861 ro = rx;
6862
6863 rtws[p + j] = re + ro;
6864 itws[p + j] = ie + io;
6865
6866 rtws[p + j + s] = re - ro;
6867 itws[p + j + s] = ie - io;
6868
6869 /* jshint maxdepth : false */
6870 if (j !== l) {
6871 rx = rtwdf * rtwdf_ - itwdf * itwdf_;
6872
6873 itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;
6874 rtwdf_ = rx;
6875 }
6876 }
6877 }
6878 }
6879 };
6880
6881 FFTM.prototype.guessLen13b = function guessLen13b (n, m) {
6882 var N = Math.max(m, n) | 1;
6883 var odd = N & 1;
6884 var i = 0;
6885 for (N = N / 2 | 0; N; N = N >>> 1) {
6886 i++;
6887 }
6888
6889 return 1 << i + 1 + odd;
6890 };
6891
6892 FFTM.prototype.conjugate = function conjugate (rws, iws, N) {
6893 if (N <= 1) return;
6894
6895 for (var i = 0; i < N / 2; i++) {
6896 var t = rws[i];
6897
6898 rws[i] = rws[N - i - 1];
6899 rws[N - i - 1] = t;
6900
6901 t = iws[i];
6902
6903 iws[i] = -iws[N - i - 1];
6904 iws[N - i - 1] = -t;
6905 }
6906 };
6907
6908 FFTM.prototype.normalize13b = function normalize13b (ws, N) {
6909 var carry = 0;
6910 for (var i = 0; i < N / 2; i++) {
6911 var w = Math.round(ws[2 * i + 1] / N) * 0x2000 +
6912 Math.round(ws[2 * i] / N) +
6913 carry;
6914
6915 ws[i] = w & 0x3ffffff;
6916
6917 if (w < 0x4000000) {
6918 carry = 0;
6919 } else {
6920 carry = w / 0x4000000 | 0;
6921 }
6922 }
6923
6924 return ws;
6925 };
6926
6927 FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) {
6928 var carry = 0;
6929 for (var i = 0; i < len; i++) {
6930 carry = carry + (ws[i] | 0);
6931
6932 rws[2 * i] = carry & 0x1fff; carry = carry >>> 13;
6933 rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13;
6934 }
6935
6936 // Pad with zeroes
6937 for (i = 2 * len; i < N; ++i) {
6938 rws[i] = 0;
6939 }
6940
6941 assert(carry === 0);
6942 assert((carry & ~0x1fff) === 0);
6943 };
6944
6945 FFTM.prototype.stub = function stub (N) {
6946 var ph = new Array(N);
6947 for (var i = 0; i < N; i++) {
6948 ph[i] = 0;
6949 }
6950
6951 return ph;
6952 };
6953
6954 FFTM.prototype.mulp = function mulp (x, y, out) {
6955 var N = 2 * this.guessLen13b(x.length, y.length);
6956
6957 var rbt = this.makeRBT(N);
6958
6959 var _ = this.stub(N);
6960
6961 var rws = new Array(N);
6962 var rwst = new Array(N);
6963 var iwst = new Array(N);
6964
6965 var nrws = new Array(N);
6966 var nrwst = new Array(N);
6967 var niwst = new Array(N);
6968
6969 var rmws = out.words;
6970 rmws.length = N;
6971
6972 this.convert13b(x.words, x.length, rws, N);
6973 this.convert13b(y.words, y.length, nrws, N);
6974
6975 this.transform(rws, _, rwst, iwst, N, rbt);
6976 this.transform(nrws, _, nrwst, niwst, N, rbt);
6977
6978 for (var i = 0; i < N; i++) {
6979 var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];
6980 iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];
6981 rwst[i] = rx;
6982 }
6983
6984 this.conjugate(rwst, iwst, N);
6985 this.transform(rwst, iwst, rmws, _, N, rbt);
6986 this.conjugate(rmws, _, N);
6987 this.normalize13b(rmws, N);
6988
6989 out.negative = x.negative ^ y.negative;
6990 out.length = x.length + y.length;
6991 return out.strip();
6992 };
6993
6994 // Multiply `this` by `num`
6995 BN.prototype.mul = function mul (num) {
6996 var out = new BN(null);
6997 out.words = new Array(this.length + num.length);
6998 return this.mulTo(num, out);
6999 };
7000
7001 // Multiply employing FFT
7002 BN.prototype.mulf = function mulf (num) {
7003 var out = new BN(null);
7004 out.words = new Array(this.length + num.length);
7005 return jumboMulTo(this, num, out);
7006 };
7007
7008 // In-place Multiplication
7009 BN.prototype.imul = function imul (num) {
7010 return this.clone().mulTo(num, this);
7011 };
7012
7013 BN.prototype.imuln = function imuln (num) {
7014 assert(typeof num === 'number');
7015 assert(num < 0x4000000);
7016
7017 // Carry
7018 var carry = 0;
7019 for (var i = 0; i < this.length; i++) {
7020 var w = (this.words[i] | 0) * num;
7021 var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);
7022 carry >>= 26;
7023 carry += (w / 0x4000000) | 0;
7024 // NOTE: lo is 27bit maximum
7025 carry += lo >>> 26;
7026 this.words[i] = lo & 0x3ffffff;
7027 }
7028
7029 if (carry !== 0) {
7030 this.words[i] = carry;
7031 this.length++;
7032 }
7033
7034 return this;
7035 };
7036
7037 BN.prototype.muln = function muln (num) {
7038 return this.clone().imuln(num);
7039 };
7040
7041 // `this` * `this`
7042 BN.prototype.sqr = function sqr () {
7043 return this.mul(this);
7044 };
7045
7046 // `this` * `this` in-place
7047 BN.prototype.isqr = function isqr () {
7048 return this.imul(this.clone());
7049 };
7050
7051 // Math.pow(`this`, `num`)
7052 BN.prototype.pow = function pow (num) {
7053 var w = toBitArray(num);
7054 if (w.length === 0) return new BN(1);
7055
7056 // Skip leading zeroes
7057 var res = this;
7058 for (var i = 0; i < w.length; i++, res = res.sqr()) {
7059 if (w[i] !== 0) break;
7060 }
7061
7062 if (++i < w.length) {
7063 for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {
7064 if (w[i] === 0) continue;
7065
7066 res = res.mul(q);
7067 }
7068 }
7069
7070 return res;
7071 };
7072
7073 // Shift-left in-place
7074 BN.prototype.iushln = function iushln (bits) {
7075 assert(typeof bits === 'number' && bits >= 0);
7076 var r = bits % 26;
7077 var s = (bits - r) / 26;
7078 var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r);
7079 var i;
7080
7081 if (r !== 0) {
7082 var carry = 0;
7083
7084 for (i = 0; i < this.length; i++) {
7085 var newCarry = this.words[i] & carryMask;
7086 var c = ((this.words[i] | 0) - newCarry) << r;
7087 this.words[i] = c | carry;
7088 carry = newCarry >>> (26 - r);
7089 }
7090
7091 if (carry) {
7092 this.words[i] = carry;
7093 this.length++;
7094 }
7095 }
7096
7097 if (s !== 0) {
7098 for (i = this.length - 1; i >= 0; i--) {
7099 this.words[i + s] = this.words[i];
7100 }
7101
7102 for (i = 0; i < s; i++) {
7103 this.words[i] = 0;
7104 }
7105
7106 this.length += s;
7107 }
7108
7109 return this.strip();
7110 };
7111
7112 BN.prototype.ishln = function ishln (bits) {
7113 // TODO(indutny): implement me
7114 assert(this.negative === 0);
7115 return this.iushln(bits);
7116 };
7117
7118 // Shift-right in-place
7119 // NOTE: `hint` is a lowest bit before trailing zeroes
7120 // NOTE: if `extended` is present - it will be filled with destroyed bits
7121 BN.prototype.iushrn = function iushrn (bits, hint, extended) {
7122 assert(typeof bits === 'number' && bits >= 0);
7123 var h;
7124 if (hint) {
7125 h = (hint - (hint % 26)) / 26;
7126 } else {
7127 h = 0;
7128 }
7129
7130 var r = bits % 26;
7131 var s = Math.min((bits - r) / 26, this.length);
7132 var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
7133 var maskedWords = extended;
7134
7135 h -= s;
7136 h = Math.max(0, h);
7137
7138 // Extended mode, copy masked part
7139 if (maskedWords) {
7140 for (var i = 0; i < s; i++) {
7141 maskedWords.words[i] = this.words[i];
7142 }
7143 maskedWords.length = s;
7144 }
7145
7146 if (s === 0) {
7147 // No-op, we should not move anything at all
7148 } else if (this.length > s) {
7149 this.length -= s;
7150 for (i = 0; i < this.length; i++) {
7151 this.words[i] = this.words[i + s];
7152 }
7153 } else {
7154 this.words[0] = 0;
7155 this.length = 1;
7156 }
7157
7158 var carry = 0;
7159 for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {
7160 var word = this.words[i] | 0;
7161 this.words[i] = (carry << (26 - r)) | (word >>> r);
7162 carry = word & mask;
7163 }
7164
7165 // Push carried bits as a mask
7166 if (maskedWords && carry !== 0) {
7167 maskedWords.words[maskedWords.length++] = carry;
7168 }
7169
7170 if (this.length === 0) {
7171 this.words[0] = 0;
7172 this.length = 1;
7173 }
7174
7175 return this.strip();
7176 };
7177
7178 BN.prototype.ishrn = function ishrn (bits, hint, extended) {
7179 // TODO(indutny): implement me
7180 assert(this.negative === 0);
7181 return this.iushrn(bits, hint, extended);
7182 };
7183
7184 // Shift-left
7185 BN.prototype.shln = function shln (bits) {
7186 return this.clone().ishln(bits);
7187 };
7188
7189 BN.prototype.ushln = function ushln (bits) {
7190 return this.clone().iushln(bits);
7191 };
7192
7193 // Shift-right
7194 BN.prototype.shrn = function shrn (bits) {
7195 return this.clone().ishrn(bits);
7196 };
7197
7198 BN.prototype.ushrn = function ushrn (bits) {
7199 return this.clone().iushrn(bits);
7200 };
7201
7202 // Test if n bit is set
7203 BN.prototype.testn = function testn (bit) {
7204 assert(typeof bit === 'number' && bit >= 0);
7205 var r = bit % 26;
7206 var s = (bit - r) / 26;
7207 var q = 1 << r;
7208
7209 // Fast case: bit is much higher than all existing words
7210 if (this.length <= s) return false;
7211
7212 // Check bit and return
7213 var w = this.words[s];
7214
7215 return !!(w & q);
7216 };
7217
7218 // Return only lowers bits of number (in-place)
7219 BN.prototype.imaskn = function imaskn (bits) {
7220 assert(typeof bits === 'number' && bits >= 0);
7221 var r = bits % 26;
7222 var s = (bits - r) / 26;
7223
7224 assert(this.negative === 0, 'imaskn works only with positive numbers');
7225
7226 if (this.length <= s) {
7227 return this;
7228 }
7229
7230 if (r !== 0) {
7231 s++;
7232 }
7233 this.length = Math.min(s, this.length);
7234
7235 if (r !== 0) {
7236 var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
7237 this.words[this.length - 1] &= mask;
7238 }
7239
7240 return this.strip();
7241 };
7242
7243 // Return only lowers bits of number
7244 BN.prototype.maskn = function maskn (bits) {
7245 return this.clone().imaskn(bits);
7246 };
7247
7248 // Add plain number `num` to `this`
7249 BN.prototype.iaddn = function iaddn (num) {
7250 assert(typeof num === 'number');
7251 assert(num < 0x4000000);
7252 if (num < 0) return this.isubn(-num);
7253
7254 // Possible sign change
7255 if (this.negative !== 0) {
7256 if (this.length === 1 && (this.words[0] | 0) < num) {
7257 this.words[0] = num - (this.words[0] | 0);
7258 this.negative = 0;
7259 return this;
7260 }
7261
7262 this.negative = 0;
7263 this.isubn(num);
7264 this.negative = 1;
7265 return this;
7266 }
7267
7268 // Add without checks
7269 return this._iaddn(num);
7270 };
7271
7272 BN.prototype._iaddn = function _iaddn (num) {
7273 this.words[0] += num;
7274
7275 // Carry
7276 for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {
7277 this.words[i] -= 0x4000000;
7278 if (i === this.length - 1) {
7279 this.words[i + 1] = 1;
7280 } else {
7281 this.words[i + 1]++;
7282 }
7283 }
7284 this.length = Math.max(this.length, i + 1);
7285
7286 return this;
7287 };
7288
7289 // Subtract plain number `num` from `this`
7290 BN.prototype.isubn = function isubn (num) {
7291 assert(typeof num === 'number');
7292 assert(num < 0x4000000);
7293 if (num < 0) return this.iaddn(-num);
7294
7295 if (this.negative !== 0) {
7296 this.negative = 0;
7297 this.iaddn(num);
7298 this.negative = 1;
7299 return this;
7300 }
7301
7302 this.words[0] -= num;
7303
7304 if (this.length === 1 && this.words[0] < 0) {
7305 this.words[0] = -this.words[0];
7306 this.negative = 1;
7307 } else {
7308 // Carry
7309 for (var i = 0; i < this.length && this.words[i] < 0; i++) {
7310 this.words[i] += 0x4000000;
7311 this.words[i + 1] -= 1;
7312 }
7313 }
7314
7315 return this.strip();
7316 };
7317
7318 BN.prototype.addn = function addn (num) {
7319 return this.clone().iaddn(num);
7320 };
7321
7322 BN.prototype.subn = function subn (num) {
7323 return this.clone().isubn(num);
7324 };
7325
7326 BN.prototype.iabs = function iabs () {
7327 this.negative = 0;
7328
7329 return this;
7330 };
7331
7332 BN.prototype.abs = function abs () {
7333 return this.clone().iabs();
7334 };
7335
7336 BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) {
7337 var len = num.length + shift;
7338 var i;
7339
7340 this._expand(len);
7341
7342 var w;
7343 var carry = 0;
7344 for (i = 0; i < num.length; i++) {
7345 w = (this.words[i + shift] | 0) + carry;
7346 var right = (num.words[i] | 0) * mul;
7347 w -= right & 0x3ffffff;
7348 carry = (w >> 26) - ((right / 0x4000000) | 0);
7349 this.words[i + shift] = w & 0x3ffffff;
7350 }
7351 for (; i < this.length - shift; i++) {
7352 w = (this.words[i + shift] | 0) + carry;
7353 carry = w >> 26;
7354 this.words[i + shift] = w & 0x3ffffff;
7355 }
7356
7357 if (carry === 0) return this.strip();
7358
7359 // Subtraction overflow
7360 assert(carry === -1);
7361 carry = 0;
7362 for (i = 0; i < this.length; i++) {
7363 w = -(this.words[i] | 0) + carry;
7364 carry = w >> 26;
7365 this.words[i] = w & 0x3ffffff;
7366 }
7367 this.negative = 1;
7368
7369 return this.strip();
7370 };
7371
7372 BN.prototype._wordDiv = function _wordDiv (num, mode) {
7373 var shift = this.length - num.length;
7374
7375 var a = this.clone();
7376 var b = num;
7377
7378 // Normalize
7379 var bhi = b.words[b.length - 1] | 0;
7380 var bhiBits = this._countBits(bhi);
7381 shift = 26 - bhiBits;
7382 if (shift !== 0) {
7383 b = b.ushln(shift);
7384 a.iushln(shift);
7385 bhi = b.words[b.length - 1] | 0;
7386 }
7387
7388 // Initialize quotient
7389 var m = a.length - b.length;
7390 var q;
7391
7392 if (mode !== 'mod') {
7393 q = new BN(null);
7394 q.length = m + 1;
7395 q.words = new Array(q.length);
7396 for (var i = 0; i < q.length; i++) {
7397 q.words[i] = 0;
7398 }
7399 }
7400
7401 var diff = a.clone()._ishlnsubmul(b, 1, m);
7402 if (diff.negative === 0) {
7403 a = diff;
7404 if (q) {
7405 q.words[m] = 1;
7406 }
7407 }
7408
7409 for (var j = m - 1; j >= 0; j--) {
7410 var qj = (a.words[b.length + j] | 0) * 0x4000000 +
7411 (a.words[b.length + j - 1] | 0);
7412
7413 // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max
7414 // (0x7ffffff)
7415 qj = Math.min((qj / bhi) | 0, 0x3ffffff);
7416
7417 a._ishlnsubmul(b, qj, j);
7418 while (a.negative !== 0) {
7419 qj--;
7420 a.negative = 0;
7421 a._ishlnsubmul(b, 1, j);
7422 if (!a.isZero()) {
7423 a.negative ^= 1;
7424 }
7425 }
7426 if (q) {
7427 q.words[j] = qj;
7428 }
7429 }
7430 if (q) {
7431 q.strip();
7432 }
7433 a.strip();
7434
7435 // Denormalize
7436 if (mode !== 'div' && shift !== 0) {
7437 a.iushrn(shift);
7438 }
7439
7440 return {
7441 div: q || null,
7442 mod: a
7443 };
7444 };
7445
7446 // NOTE: 1) `mode` can be set to `mod` to request mod only,
7447 // to `div` to request div only, or be absent to
7448 // request both div & mod
7449 // 2) `positive` is true if unsigned mod is requested
7450 BN.prototype.divmod = function divmod (num, mode, positive) {
7451 assert(!num.isZero());
7452
7453 if (this.isZero()) {
7454 return {
7455 div: new BN(0),
7456 mod: new BN(0)
7457 };
7458 }
7459
7460 var div, mod, res;
7461 if (this.negative !== 0 && num.negative === 0) {
7462 res = this.neg().divmod(num, mode);
7463
7464 if (mode !== 'mod') {
7465 div = res.div.neg();
7466 }
7467
7468 if (mode !== 'div') {
7469 mod = res.mod.neg();
7470 if (positive && mod.negative !== 0) {
7471 mod.iadd(num);
7472 }
7473 }
7474
7475 return {
7476 div: div,
7477 mod: mod
7478 };
7479 }
7480
7481 if (this.negative === 0 && num.negative !== 0) {
7482 res = this.divmod(num.neg(), mode);
7483
7484 if (mode !== 'mod') {
7485 div = res.div.neg();
7486 }
7487
7488 return {
7489 div: div,
7490 mod: res.mod
7491 };
7492 }
7493
7494 if ((this.negative & num.negative) !== 0) {
7495 res = this.neg().divmod(num.neg(), mode);
7496
7497 if (mode !== 'div') {
7498 mod = res.mod.neg();
7499 if (positive && mod.negative !== 0) {
7500 mod.isub(num);
7501 }
7502 }
7503
7504 return {
7505 div: res.div,
7506 mod: mod
7507 };
7508 }
7509
7510 // Both numbers are positive at this point
7511
7512 // Strip both numbers to approximate shift value
7513 if (num.length > this.length || this.cmp(num) < 0) {
7514 return {
7515 div: new BN(0),
7516 mod: this
7517 };
7518 }
7519
7520 // Very short reduction
7521 if (num.length === 1) {
7522 if (mode === 'div') {
7523 return {
7524 div: this.divn(num.words[0]),
7525 mod: null
7526 };
7527 }
7528
7529 if (mode === 'mod') {
7530 return {
7531 div: null,
7532 mod: new BN(this.modn(num.words[0]))
7533 };
7534 }
7535
7536 return {
7537 div: this.divn(num.words[0]),
7538 mod: new BN(this.modn(num.words[0]))
7539 };
7540 }
7541
7542 return this._wordDiv(num, mode);
7543 };
7544
7545 // Find `this` / `num`
7546 BN.prototype.div = function div (num) {
7547 return this.divmod(num, 'div', false).div;
7548 };
7549
7550 // Find `this` % `num`
7551 BN.prototype.mod = function mod (num) {
7552 return this.divmod(num, 'mod', false).mod;
7553 };
7554
7555 BN.prototype.umod = function umod (num) {
7556 return this.divmod(num, 'mod', true).mod;
7557 };
7558
7559 // Find Round(`this` / `num`)
7560 BN.prototype.divRound = function divRound (num) {
7561 var dm = this.divmod(num);
7562
7563 // Fast case - exact division
7564 if (dm.mod.isZero()) return dm.div;
7565
7566 var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
7567
7568 var half = num.ushrn(1);
7569 var r2 = num.andln(1);
7570 var cmp = mod.cmp(half);
7571
7572 // Round down
7573 if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;
7574
7575 // Round up
7576 return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
7577 };
7578
7579 BN.prototype.modn = function modn (num) {
7580 assert(num <= 0x3ffffff);
7581 var p = (1 << 26) % num;
7582
7583 var acc = 0;
7584 for (var i = this.length - 1; i >= 0; i--) {
7585 acc = (p * acc + (this.words[i] | 0)) % num;
7586 }
7587
7588 return acc;
7589 };
7590
7591 // In-place division by number
7592 BN.prototype.idivn = function idivn (num) {
7593 assert(num <= 0x3ffffff);
7594
7595 var carry = 0;
7596 for (var i = this.length - 1; i >= 0; i--) {
7597 var w = (this.words[i] | 0) + carry * 0x4000000;
7598 this.words[i] = (w / num) | 0;
7599 carry = w % num;
7600 }
7601
7602 return this.strip();
7603 };
7604
7605 BN.prototype.divn = function divn (num) {
7606 return this.clone().idivn(num);
7607 };
7608
7609 BN.prototype.egcd = function egcd (p) {
7610 assert(p.negative === 0);
7611 assert(!p.isZero());
7612
7613 var x = this;
7614 var y = p.clone();
7615
7616 if (x.negative !== 0) {
7617 x = x.umod(p);
7618 } else {
7619 x = x.clone();
7620 }
7621
7622 // A * x + B * y = x
7623 var A = new BN(1);
7624 var B = new BN(0);
7625
7626 // C * x + D * y = y
7627 var C = new BN(0);
7628 var D = new BN(1);
7629
7630 var g = 0;
7631
7632 while (x.isEven() && y.isEven()) {
7633 x.iushrn(1);
7634 y.iushrn(1);
7635 ++g;
7636 }
7637
7638 var yp = y.clone();
7639 var xp = x.clone();
7640
7641 while (!x.isZero()) {
7642 for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
7643 if (i > 0) {
7644 x.iushrn(i);
7645 while (i-- > 0) {
7646 if (A.isOdd() || B.isOdd()) {
7647 A.iadd(yp);
7648 B.isub(xp);
7649 }
7650
7651 A.iushrn(1);
7652 B.iushrn(1);
7653 }
7654 }
7655
7656 for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
7657 if (j > 0) {
7658 y.iushrn(j);
7659 while (j-- > 0) {
7660 if (C.isOdd() || D.isOdd()) {
7661 C.iadd(yp);
7662 D.isub(xp);
7663 }
7664
7665 C.iushrn(1);
7666 D.iushrn(1);
7667 }
7668 }
7669
7670 if (x.cmp(y) >= 0) {
7671 x.isub(y);
7672 A.isub(C);
7673 B.isub(D);
7674 } else {
7675 y.isub(x);
7676 C.isub(A);
7677 D.isub(B);
7678 }
7679 }
7680
7681 return {
7682 a: C,
7683 b: D,
7684 gcd: y.iushln(g)
7685 };
7686 };
7687
7688 // This is reduced incarnation of the binary EEA
7689 // above, designated to invert members of the
7690 // _prime_ fields F(p) at a maximal speed
7691 BN.prototype._invmp = function _invmp (p) {
7692 assert(p.negative === 0);
7693 assert(!p.isZero());
7694
7695 var a = this;
7696 var b = p.clone();
7697
7698 if (a.negative !== 0) {
7699 a = a.umod(p);
7700 } else {
7701 a = a.clone();
7702 }
7703
7704 var x1 = new BN(1);
7705 var x2 = new BN(0);
7706
7707 var delta = b.clone();
7708
7709 while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
7710 for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
7711 if (i > 0) {
7712 a.iushrn(i);
7713 while (i-- > 0) {
7714 if (x1.isOdd()) {
7715 x1.iadd(delta);
7716 }
7717
7718 x1.iushrn(1);
7719 }
7720 }
7721
7722 for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
7723 if (j > 0) {
7724 b.iushrn(j);
7725 while (j-- > 0) {
7726 if (x2.isOdd()) {
7727 x2.iadd(delta);
7728 }
7729
7730 x2.iushrn(1);
7731 }
7732 }
7733
7734 if (a.cmp(b) >= 0) {
7735 a.isub(b);
7736 x1.isub(x2);
7737 } else {
7738 b.isub(a);
7739 x2.isub(x1);
7740 }
7741 }
7742
7743 var res;
7744 if (a.cmpn(1) === 0) {
7745 res = x1;
7746 } else {
7747 res = x2;
7748 }
7749
7750 if (res.cmpn(0) < 0) {
7751 res.iadd(p);
7752 }
7753
7754 return res;
7755 };
7756
7757 BN.prototype.gcd = function gcd (num) {
7758 if (this.isZero()) return num.abs();
7759 if (num.isZero()) return this.abs();
7760
7761 var a = this.clone();
7762 var b = num.clone();
7763 a.negative = 0;
7764 b.negative = 0;
7765
7766 // Remove common factor of two
7767 for (var shift = 0; a.isEven() && b.isEven(); shift++) {
7768 a.iushrn(1);
7769 b.iushrn(1);
7770 }
7771
7772 do {
7773 while (a.isEven()) {
7774 a.iushrn(1);
7775 }
7776 while (b.isEven()) {
7777 b.iushrn(1);
7778 }
7779
7780 var r = a.cmp(b);
7781 if (r < 0) {
7782 // Swap `a` and `b` to make `a` always bigger than `b`
7783 var t = a;
7784 a = b;
7785 b = t;
7786 } else if (r === 0 || b.cmpn(1) === 0) {
7787 break;
7788 }
7789
7790 a.isub(b);
7791 } while (true);
7792
7793 return b.iushln(shift);
7794 };
7795
7796 // Invert number in the field F(num)
7797 BN.prototype.invm = function invm (num) {
7798 return this.egcd(num).a.umod(num);
7799 };
7800
7801 BN.prototype.isEven = function isEven () {
7802 return (this.words[0] & 1) === 0;
7803 };
7804
7805 BN.prototype.isOdd = function isOdd () {
7806 return (this.words[0] & 1) === 1;
7807 };
7808
7809 // And first word and num
7810 BN.prototype.andln = function andln (num) {
7811 return this.words[0] & num;
7812 };
7813
7814 // Increment at the bit position in-line
7815 BN.prototype.bincn = function bincn (bit) {
7816 assert(typeof bit === 'number');
7817 var r = bit % 26;
7818 var s = (bit - r) / 26;
7819 var q = 1 << r;
7820
7821 // Fast case: bit is much higher than all existing words
7822 if (this.length <= s) {
7823 this._expand(s + 1);
7824 this.words[s] |= q;
7825 return this;
7826 }
7827
7828 // Add bit and propagate, if needed
7829 var carry = q;
7830 for (var i = s; carry !== 0 && i < this.length; i++) {
7831 var w = this.words[i] | 0;
7832 w += carry;
7833 carry = w >>> 26;
7834 w &= 0x3ffffff;
7835 this.words[i] = w;
7836 }
7837 if (carry !== 0) {
7838 this.words[i] = carry;
7839 this.length++;
7840 }
7841 return this;
7842 };
7843
7844 BN.prototype.isZero = function isZero () {
7845 return this.length === 1 && this.words[0] === 0;
7846 };
7847
7848 BN.prototype.cmpn = function cmpn (num) {
7849 var negative = num < 0;
7850
7851 if (this.negative !== 0 && !negative) return -1;
7852 if (this.negative === 0 && negative) return 1;
7853
7854 this.strip();
7855
7856 var res;
7857 if (this.length > 1) {
7858 res = 1;
7859 } else {
7860 if (negative) {
7861 num = -num;
7862 }
7863
7864 assert(num <= 0x3ffffff, 'Number is too big');
7865
7866 var w = this.words[0] | 0;
7867 res = w === num ? 0 : w < num ? -1 : 1;
7868 }
7869 if (this.negative !== 0) return -res | 0;
7870 return res;
7871 };
7872
7873 // Compare two numbers and return:
7874 // 1 - if `this` > `num`
7875 // 0 - if `this` == `num`
7876 // -1 - if `this` < `num`
7877 BN.prototype.cmp = function cmp (num) {
7878 if (this.negative !== 0 && num.negative === 0) return -1;
7879 if (this.negative === 0 && num.negative !== 0) return 1;
7880
7881 var res = this.ucmp(num);
7882 if (this.negative !== 0) return -res | 0;
7883 return res;
7884 };
7885
7886 // Unsigned comparison
7887 BN.prototype.ucmp = function ucmp (num) {
7888 // At this point both numbers have the same sign
7889 if (this.length > num.length) return 1;
7890 if (this.length < num.length) return -1;
7891
7892 var res = 0;
7893 for (var i = this.length - 1; i >= 0; i--) {
7894 var a = this.words[i] | 0;
7895 var b = num.words[i] | 0;
7896
7897 if (a === b) continue;
7898 if (a < b) {
7899 res = -1;
7900 } else if (a > b) {
7901 res = 1;
7902 }
7903 break;
7904 }
7905 return res;
7906 };
7907
7908 BN.prototype.gtn = function gtn (num) {
7909 return this.cmpn(num) === 1;
7910 };
7911
7912 BN.prototype.gt = function gt (num) {
7913 return this.cmp(num) === 1;
7914 };
7915
7916 BN.prototype.gten = function gten (num) {
7917 return this.cmpn(num) >= 0;
7918 };
7919
7920 BN.prototype.gte = function gte (num) {
7921 return this.cmp(num) >= 0;
7922 };
7923
7924 BN.prototype.ltn = function ltn (num) {
7925 return this.cmpn(num) === -1;
7926 };
7927
7928 BN.prototype.lt = function lt (num) {
7929 return this.cmp(num) === -1;
7930 };
7931
7932 BN.prototype.lten = function lten (num) {
7933 return this.cmpn(num) <= 0;
7934 };
7935
7936 BN.prototype.lte = function lte (num) {
7937 return this.cmp(num) <= 0;
7938 };
7939
7940 BN.prototype.eqn = function eqn (num) {
7941 return this.cmpn(num) === 0;
7942 };
7943
7944 BN.prototype.eq = function eq (num) {
7945 return this.cmp(num) === 0;
7946 };
7947
7948 //
7949 // A reduce context, could be using montgomery or something better, depending
7950 // on the `m` itself.
7951 //
7952 BN.red = function red (num) {
7953 return new Red(num);
7954 };
7955
7956 BN.prototype.toRed = function toRed (ctx) {
7957 assert(!this.red, 'Already a number in reduction context');
7958 assert(this.negative === 0, 'red works only with positives');
7959 return ctx.convertTo(this)._forceRed(ctx);
7960 };
7961
7962 BN.prototype.fromRed = function fromRed () {
7963 assert(this.red, 'fromRed works only with numbers in reduction context');
7964 return this.red.convertFrom(this);
7965 };
7966
7967 BN.prototype._forceRed = function _forceRed (ctx) {
7968 this.red = ctx;
7969 return this;
7970 };
7971
7972 BN.prototype.forceRed = function forceRed (ctx) {
7973 assert(!this.red, 'Already a number in reduction context');
7974 return this._forceRed(ctx);
7975 };
7976
7977 BN.prototype.redAdd = function redAdd (num) {
7978 assert(this.red, 'redAdd works only with red numbers');
7979 return this.red.add(this, num);
7980 };
7981
7982 BN.prototype.redIAdd = function redIAdd (num) {
7983 assert(this.red, 'redIAdd works only with red numbers');
7984 return this.red.iadd(this, num);
7985 };
7986
7987 BN.prototype.redSub = function redSub (num) {
7988 assert(this.red, 'redSub works only with red numbers');
7989 return this.red.sub(this, num);
7990 };
7991
7992 BN.prototype.redISub = function redISub (num) {
7993 assert(this.red, 'redISub works only with red numbers');
7994 return this.red.isub(this, num);
7995 };
7996
7997 BN.prototype.redShl = function redShl (num) {
7998 assert(this.red, 'redShl works only with red numbers');
7999 return this.red.shl(this, num);
8000 };
8001
8002 BN.prototype.redMul = function redMul (num) {
8003 assert(this.red, 'redMul works only with red numbers');
8004 this.red._verify2(this, num);
8005 return this.red.mul(this, num);
8006 };
8007
8008 BN.prototype.redIMul = function redIMul (num) {
8009 assert(this.red, 'redMul works only with red numbers');
8010 this.red._verify2(this, num);
8011 return this.red.imul(this, num);
8012 };
8013
8014 BN.prototype.redSqr = function redSqr () {
8015 assert(this.red, 'redSqr works only with red numbers');
8016 this.red._verify1(this);
8017 return this.red.sqr(this);
8018 };
8019
8020 BN.prototype.redISqr = function redISqr () {
8021 assert(this.red, 'redISqr works only with red numbers');
8022 this.red._verify1(this);
8023 return this.red.isqr(this);
8024 };
8025
8026 // Square root over p
8027 BN.prototype.redSqrt = function redSqrt () {
8028 assert(this.red, 'redSqrt works only with red numbers');
8029 this.red._verify1(this);
8030 return this.red.sqrt(this);
8031 };
8032
8033 BN.prototype.redInvm = function redInvm () {
8034 assert(this.red, 'redInvm works only with red numbers');
8035 this.red._verify1(this);
8036 return this.red.invm(this);
8037 };
8038
8039 // Return negative clone of `this` % `red modulo`
8040 BN.prototype.redNeg = function redNeg () {
8041 assert(this.red, 'redNeg works only with red numbers');
8042 this.red._verify1(this);
8043 return this.red.neg(this);
8044 };
8045
8046 BN.prototype.redPow = function redPow (num) {
8047 assert(this.red && !num.red, 'redPow(normalNum)');
8048 this.red._verify1(this);
8049 return this.red.pow(this, num);
8050 };
8051
8052 // Prime numbers with efficient reduction
8053 var primes = {
8054 k256: null,
8055 p224: null,
8056 p192: null,
8057 p25519: null
8058 };
8059
8060 // Pseudo-Mersenne prime
8061 function MPrime (name, p) {
8062 // P = 2 ^ N - K
8063 this.name = name;
8064 this.p = new BN(p, 16);
8065 this.n = this.p.bitLength();
8066 this.k = new BN(1).iushln(this.n).isub(this.p);
8067
8068 this.tmp = this._tmp();
8069 }
8070
8071 MPrime.prototype._tmp = function _tmp () {
8072 var tmp = new BN(null);
8073 tmp.words = new Array(Math.ceil(this.n / 13));
8074 return tmp;
8075 };
8076
8077 MPrime.prototype.ireduce = function ireduce (num) {
8078 // Assumes that `num` is less than `P^2`
8079 // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)
8080 var r = num;
8081 var rlen;
8082
8083 do {
8084 this.split(r, this.tmp);
8085 r = this.imulK(r);
8086 r = r.iadd(this.tmp);
8087 rlen = r.bitLength();
8088 } while (rlen > this.n);
8089
8090 var cmp = rlen < this.n ? -1 : r.ucmp(this.p);
8091 if (cmp === 0) {
8092 r.words[0] = 0;
8093 r.length = 1;
8094 } else if (cmp > 0) {
8095 r.isub(this.p);
8096 } else {
8097 r.strip();
8098 }
8099
8100 return r;
8101 };
8102
8103 MPrime.prototype.split = function split (input, out) {
8104 input.iushrn(this.n, 0, out);
8105 };
8106
8107 MPrime.prototype.imulK = function imulK (num) {
8108 return num.imul(this.k);
8109 };
8110
8111 function K256 () {
8112 MPrime.call(
8113 this,
8114 'k256',
8115 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');
8116 }
8117 inherits(K256, MPrime);
8118
8119 K256.prototype.split = function split (input, output) {
8120 // 256 = 9 * 26 + 22
8121 var mask = 0x3fffff;
8122
8123 var outLen = Math.min(input.length, 9);
8124 for (var i = 0; i < outLen; i++) {
8125 output.words[i] = input.words[i];
8126 }
8127 output.length = outLen;
8128
8129 if (input.length <= 9) {
8130 input.words[0] = 0;
8131 input.length = 1;
8132 return;
8133 }
8134
8135 // Shift by 9 limbs
8136 var prev = input.words[9];
8137 output.words[output.length++] = prev & mask;
8138
8139 for (i = 10; i < input.length; i++) {
8140 var next = input.words[i] | 0;
8141 input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22);
8142 prev = next;
8143 }
8144 prev >>>= 22;
8145 input.words[i - 10] = prev;
8146 if (prev === 0 && input.length > 10) {
8147 input.length -= 10;
8148 } else {
8149 input.length -= 9;
8150 }
8151 };
8152
8153 K256.prototype.imulK = function imulK (num) {
8154 // K = 0x1000003d1 = [ 0x40, 0x3d1 ]
8155 num.words[num.length] = 0;
8156 num.words[num.length + 1] = 0;
8157 num.length += 2;
8158
8159 // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390
8160 var lo = 0;
8161 for (var i = 0; i < num.length; i++) {
8162 var w = num.words[i] | 0;
8163 lo += w * 0x3d1;
8164 num.words[i] = lo & 0x3ffffff;
8165 lo = w * 0x40 + ((lo / 0x4000000) | 0);
8166 }
8167
8168 // Fast length reduction
8169 if (num.words[num.length - 1] === 0) {
8170 num.length--;
8171 if (num.words[num.length - 1] === 0) {
8172 num.length--;
8173 }
8174 }
8175 return num;
8176 };
8177
8178 function P224 () {
8179 MPrime.call(
8180 this,
8181 'p224',
8182 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');
8183 }
8184 inherits(P224, MPrime);
8185
8186 function P192 () {
8187 MPrime.call(
8188 this,
8189 'p192',
8190 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');
8191 }
8192 inherits(P192, MPrime);
8193
8194 function P25519 () {
8195 // 2 ^ 255 - 19
8196 MPrime.call(
8197 this,
8198 '25519',
8199 '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');
8200 }
8201 inherits(P25519, MPrime);
8202
8203 P25519.prototype.imulK = function imulK (num) {
8204 // K = 0x13
8205 var carry = 0;
8206 for (var i = 0; i < num.length; i++) {
8207 var hi = (num.words[i] | 0) * 0x13 + carry;
8208 var lo = hi & 0x3ffffff;
8209 hi >>>= 26;
8210
8211 num.words[i] = lo;
8212 carry = hi;
8213 }
8214 if (carry !== 0) {
8215 num.words[num.length++] = carry;
8216 }
8217 return num;
8218 };
8219
8220 // Exported mostly for testing purposes, use plain name instead
8221 BN._prime = function prime (name) {
8222 // Cached version of prime
8223 if (primes[name]) return primes[name];
8224
8225 var prime;
8226 if (name === 'k256') {
8227 prime = new K256();
8228 } else if (name === 'p224') {
8229 prime = new P224();
8230 } else if (name === 'p192') {
8231 prime = new P192();
8232 } else if (name === 'p25519') {
8233 prime = new P25519();
8234 } else {
8235 throw new Error('Unknown prime ' + name);
8236 }
8237 primes[name] = prime;
8238
8239 return prime;
8240 };
8241
8242 //
8243 // Base reduction engine
8244 //
8245 function Red (m) {
8246 if (typeof m === 'string') {
8247 var prime = BN._prime(m);
8248 this.m = prime.p;
8249 this.prime = prime;
8250 } else {
8251 assert(m.gtn(1), 'modulus must be greater than 1');
8252 this.m = m;
8253 this.prime = null;
8254 }
8255 }
8256
8257 Red.prototype._verify1 = function _verify1 (a) {
8258 assert(a.negative === 0, 'red works only with positives');
8259 assert(a.red, 'red works only with red numbers');
8260 };
8261
8262 Red.prototype._verify2 = function _verify2 (a, b) {
8263 assert((a.negative | b.negative) === 0, 'red works only with positives');
8264 assert(a.red && a.red === b.red,
8265 'red works only with red numbers');
8266 };
8267
8268 Red.prototype.imod = function imod (a) {
8269 if (this.prime) return this.prime.ireduce(a)._forceRed(this);
8270 return a.umod(this.m)._forceRed(this);
8271 };
8272
8273 Red.prototype.neg = function neg (a) {
8274 if (a.isZero()) {
8275 return a.clone();
8276 }
8277
8278 return this.m.sub(a)._forceRed(this);
8279 };
8280
8281 Red.prototype.add = function add (a, b) {
8282 this._verify2(a, b);
8283
8284 var res = a.add(b);
8285 if (res.cmp(this.m) >= 0) {
8286 res.isub(this.m);
8287 }
8288 return res._forceRed(this);
8289 };
8290
8291 Red.prototype.iadd = function iadd (a, b) {
8292 this._verify2(a, b);
8293
8294 var res = a.iadd(b);
8295 if (res.cmp(this.m) >= 0) {
8296 res.isub(this.m);
8297 }
8298 return res;
8299 };
8300
8301 Red.prototype.sub = function sub (a, b) {
8302 this._verify2(a, b);
8303
8304 var res = a.sub(b);
8305 if (res.cmpn(0) < 0) {
8306 res.iadd(this.m);
8307 }
8308 return res._forceRed(this);
8309 };
8310
8311 Red.prototype.isub = function isub (a, b) {
8312 this._verify2(a, b);
8313
8314 var res = a.isub(b);
8315 if (res.cmpn(0) < 0) {
8316 res.iadd(this.m);
8317 }
8318 return res;
8319 };
8320
8321 Red.prototype.shl = function shl (a, num) {
8322 this._verify1(a);
8323 return this.imod(a.ushln(num));
8324 };
8325
8326 Red.prototype.imul = function imul (a, b) {
8327 this._verify2(a, b);
8328 return this.imod(a.imul(b));
8329 };
8330
8331 Red.prototype.mul = function mul (a, b) {
8332 this._verify2(a, b);
8333 return this.imod(a.mul(b));
8334 };
8335
8336 Red.prototype.isqr = function isqr (a) {
8337 return this.imul(a, a.clone());
8338 };
8339
8340 Red.prototype.sqr = function sqr (a) {
8341 return this.mul(a, a);
8342 };
8343
8344 Red.prototype.sqrt = function sqrt (a) {
8345 if (a.isZero()) return a.clone();
8346
8347 var mod3 = this.m.andln(3);
8348 assert(mod3 % 2 === 1);
8349
8350 // Fast case
8351 if (mod3 === 3) {
8352 var pow = this.m.add(new BN(1)).iushrn(2);
8353 return this.pow(a, pow);
8354 }
8355
8356 // Tonelli-Shanks algorithm (Totally unoptimized and slow)
8357 //
8358 // Find Q and S, that Q * 2 ^ S = (P - 1)
8359 var q = this.m.subn(1);
8360 var s = 0;
8361 while (!q.isZero() && q.andln(1) === 0) {
8362 s++;
8363 q.iushrn(1);
8364 }
8365 assert(!q.isZero());
8366
8367 var one = new BN(1).toRed(this);
8368 var nOne = one.redNeg();
8369
8370 // Find quadratic non-residue
8371 // NOTE: Max is such because of generalized Riemann hypothesis.
8372 var lpow = this.m.subn(1).iushrn(1);
8373 var z = this.m.bitLength();
8374 z = new BN(2 * z * z).toRed(this);
8375
8376 while (this.pow(z, lpow).cmp(nOne) !== 0) {
8377 z.redIAdd(nOne);
8378 }
8379
8380 var c = this.pow(z, q);
8381 var r = this.pow(a, q.addn(1).iushrn(1));
8382 var t = this.pow(a, q);
8383 var m = s;
8384 while (t.cmp(one) !== 0) {
8385 var tmp = t;
8386 for (var i = 0; tmp.cmp(one) !== 0; i++) {
8387 tmp = tmp.redSqr();
8388 }
8389 assert(i < m);
8390 var b = this.pow(c, new BN(1).iushln(m - i - 1));
8391
8392 r = r.redMul(b);
8393 c = b.redSqr();
8394 t = t.redMul(c);
8395 m = i;
8396 }
8397
8398 return r;
8399 };
8400
8401 Red.prototype.invm = function invm (a) {
8402 var inv = a._invmp(this.m);
8403 if (inv.negative !== 0) {
8404 inv.negative = 0;
8405 return this.imod(inv).redNeg();
8406 } else {
8407 return this.imod(inv);
8408 }
8409 };
8410
8411 Red.prototype.pow = function pow (a, num) {
8412 if (num.isZero()) return new BN(1).toRed(this);
8413 if (num.cmpn(1) === 0) return a.clone();
8414
8415 var windowSize = 4;
8416 var wnd = new Array(1 << windowSize);
8417 wnd[0] = new BN(1).toRed(this);
8418 wnd[1] = a;
8419 for (var i = 2; i < wnd.length; i++) {
8420 wnd[i] = this.mul(wnd[i - 1], a);
8421 }
8422
8423 var res = wnd[0];
8424 var current = 0;
8425 var currentLen = 0;
8426 var start = num.bitLength() % 26;
8427 if (start === 0) {
8428 start = 26;
8429 }
8430
8431 for (i = num.length - 1; i >= 0; i--) {
8432 var word = num.words[i];
8433 for (var j = start - 1; j >= 0; j--) {
8434 var bit = (word >> j) & 1;
8435 if (res !== wnd[0]) {
8436 res = this.sqr(res);
8437 }
8438
8439 if (bit === 0 && current === 0) {
8440 currentLen = 0;
8441 continue;
8442 }
8443
8444 current <<= 1;
8445 current |= bit;
8446 currentLen++;
8447 if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;
8448
8449 res = this.mul(res, wnd[current]);
8450 currentLen = 0;
8451 current = 0;
8452 }
8453 start = 26;
8454 }
8455
8456 return res;
8457 };
8458
8459 Red.prototype.convertTo = function convertTo (num) {
8460 var r = num.umod(this.m);
8461
8462 return r === num ? r.clone() : r;
8463 };
8464
8465 Red.prototype.convertFrom = function convertFrom (num) {
8466 var res = num.clone();
8467 res.red = null;
8468 return res;
8469 };
8470
8471 //
8472 // Montgomery method engine
8473 //
8474
8475 BN.mont = function mont (num) {
8476 return new Mont(num);
8477 };
8478
8479 function Mont (m) {
8480 Red.call(this, m);
8481
8482 this.shift = this.m.bitLength();
8483 if (this.shift % 26 !== 0) {
8484 this.shift += 26 - (this.shift % 26);
8485 }
8486
8487 this.r = new BN(1).iushln(this.shift);
8488 this.r2 = this.imod(this.r.sqr());
8489 this.rinv = this.r._invmp(this.m);
8490
8491 this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
8492 this.minv = this.minv.umod(this.r);
8493 this.minv = this.r.sub(this.minv);
8494 }
8495 inherits(Mont, Red);
8496
8497 Mont.prototype.convertTo = function convertTo (num) {
8498 return this.imod(num.ushln(this.shift));
8499 };
8500
8501 Mont.prototype.convertFrom = function convertFrom (num) {
8502 var r = this.imod(num.mul(this.rinv));
8503 r.red = null;
8504 return r;
8505 };
8506
8507 Mont.prototype.imul = function imul (a, b) {
8508 if (a.isZero() || b.isZero()) {
8509 a.words[0] = 0;
8510 a.length = 1;
8511 return a;
8512 }
8513
8514 var t = a.imul(b);
8515 var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
8516 var u = t.isub(c).iushrn(this.shift);
8517 var res = u;
8518
8519 if (u.cmp(this.m) >= 0) {
8520 res = u.isub(this.m);
8521 } else if (u.cmpn(0) < 0) {
8522 res = u.iadd(this.m);
8523 }
8524
8525 return res._forceRed(this);
8526 };
8527
8528 Mont.prototype.mul = function mul (a, b) {
8529 if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);
8530
8531 var t = a.mul(b);
8532 var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
8533 var u = t.isub(c).iushrn(this.shift);
8534 var res = u;
8535 if (u.cmp(this.m) >= 0) {
8536 res = u.isub(this.m);
8537 } else if (u.cmpn(0) < 0) {
8538 res = u.iadd(this.m);
8539 }
8540
8541 return res._forceRed(this);
8542 };
8543
8544 Mont.prototype.invm = function invm (a) {
8545 // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R
8546 var res = this.imod(a._invmp(this.m).mul(this.r2));
8547 return res._forceRed(this);
8548 };
8549})(typeof module === 'undefined' || module, this);
8550
8551},{"buffer":23}],22:[function(require,module,exports){
8552var r;
8553
8554module.exports = function rand(len) {
8555 if (!r)
8556 r = new Rand(null);
8557
8558 return r.generate(len);
8559};
8560
8561function Rand(rand) {
8562 this.rand = rand;
8563}
8564module.exports.Rand = Rand;
8565
8566Rand.prototype.generate = function generate(len) {
8567 return this._rand(len);
8568};
8569
8570// Emulate crypto API using randy
8571Rand.prototype._rand = function _rand(n) {
8572 if (this.rand.getBytes)
8573 return this.rand.getBytes(n);
8574
8575 var res = new Uint8Array(n);
8576 for (var i = 0; i < res.length; i++)
8577 res[i] = this.rand.getByte();
8578 return res;
8579};
8580
8581if (typeof self === 'object') {
8582 if (self.crypto && self.crypto.getRandomValues) {
8583 // Modern browsers
8584 Rand.prototype._rand = function _rand(n) {
8585 var arr = new Uint8Array(n);
8586 self.crypto.getRandomValues(arr);
8587 return arr;
8588 };
8589 } else if (self.msCrypto && self.msCrypto.getRandomValues) {
8590 // IE
8591 Rand.prototype._rand = function _rand(n) {
8592 var arr = new Uint8Array(n);
8593 self.msCrypto.getRandomValues(arr);
8594 return arr;
8595 };
8596
8597 // Safari's WebWorkers do not have `crypto`
8598 } else if (typeof window === 'object') {
8599 // Old junk
8600 Rand.prototype._rand = function() {
8601 throw new Error('Not implemented yet');
8602 };
8603 }
8604} else {
8605 // Node.js or Web worker with no crypto support
8606 try {
8607 var crypto = require('crypto');
8608 if (typeof crypto.randomBytes !== 'function')
8609 throw new Error('Not supported');
8610
8611 Rand.prototype._rand = function _rand(n) {
8612 return crypto.randomBytes(n);
8613 };
8614 } catch (e) {
8615 }
8616}
8617
8618},{"crypto":23}],23:[function(require,module,exports){
8619
8620},{}],24:[function(require,module,exports){
8621// based on the aes implimentation in triple sec
8622// https://github.com/keybase/triplesec
8623// which is in turn based on the one from crypto-js
8624// https://code.google.com/p/crypto-js/
8625
8626var Buffer = require('safe-buffer').Buffer
8627
8628function asUInt32Array (buf) {
8629 if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf)
8630
8631 var len = (buf.length / 4) | 0
8632 var out = new Array(len)
8633
8634 for (var i = 0; i < len; i++) {
8635 out[i] = buf.readUInt32BE(i * 4)
8636 }
8637
8638 return out
8639}
8640
8641function scrubVec (v) {
8642 for (var i = 0; i < v.length; v++) {
8643 v[i] = 0
8644 }
8645}
8646
8647function cryptBlock (M, keySchedule, SUB_MIX, SBOX, nRounds) {
8648 var SUB_MIX0 = SUB_MIX[0]
8649 var SUB_MIX1 = SUB_MIX[1]
8650 var SUB_MIX2 = SUB_MIX[2]
8651 var SUB_MIX3 = SUB_MIX[3]
8652
8653 var s0 = M[0] ^ keySchedule[0]
8654 var s1 = M[1] ^ keySchedule[1]
8655 var s2 = M[2] ^ keySchedule[2]
8656 var s3 = M[3] ^ keySchedule[3]
8657 var t0, t1, t2, t3
8658 var ksRow = 4
8659
8660 for (var round = 1; round < nRounds; round++) {
8661 t0 = SUB_MIX0[s0 >>> 24] ^ SUB_MIX1[(s1 >>> 16) & 0xff] ^ SUB_MIX2[(s2 >>> 8) & 0xff] ^ SUB_MIX3[s3 & 0xff] ^ keySchedule[ksRow++]
8662 t1 = SUB_MIX0[s1 >>> 24] ^ SUB_MIX1[(s2 >>> 16) & 0xff] ^ SUB_MIX2[(s3 >>> 8) & 0xff] ^ SUB_MIX3[s0 & 0xff] ^ keySchedule[ksRow++]
8663 t2 = SUB_MIX0[s2 >>> 24] ^ SUB_MIX1[(s3 >>> 16) & 0xff] ^ SUB_MIX2[(s0 >>> 8) & 0xff] ^ SUB_MIX3[s1 & 0xff] ^ keySchedule[ksRow++]
8664 t3 = SUB_MIX0[s3 >>> 24] ^ SUB_MIX1[(s0 >>> 16) & 0xff] ^ SUB_MIX2[(s1 >>> 8) & 0xff] ^ SUB_MIX3[s2 & 0xff] ^ keySchedule[ksRow++]
8665 s0 = t0
8666 s1 = t1
8667 s2 = t2
8668 s3 = t3
8669 }
8670
8671 t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++]
8672 t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++]
8673 t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++]
8674 t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++]
8675 t0 = t0 >>> 0
8676 t1 = t1 >>> 0
8677 t2 = t2 >>> 0
8678 t3 = t3 >>> 0
8679
8680 return [t0, t1, t2, t3]
8681}
8682
8683// AES constants
8684var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36]
8685var G = (function () {
8686 // Compute double table
8687 var d = new Array(256)
8688 for (var j = 0; j < 256; j++) {
8689 if (j < 128) {
8690 d[j] = j << 1
8691 } else {
8692 d[j] = (j << 1) ^ 0x11b
8693 }
8694 }
8695
8696 var SBOX = []
8697 var INV_SBOX = []
8698 var SUB_MIX = [[], [], [], []]
8699 var INV_SUB_MIX = [[], [], [], []]
8700
8701 // Walk GF(2^8)
8702 var x = 0
8703 var xi = 0
8704 for (var i = 0; i < 256; ++i) {
8705 // Compute sbox
8706 var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4)
8707 sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63
8708 SBOX[x] = sx
8709 INV_SBOX[sx] = x
8710
8711 // Compute multiplication
8712 var x2 = d[x]
8713 var x4 = d[x2]
8714 var x8 = d[x4]
8715
8716 // Compute sub bytes, mix columns tables
8717 var t = (d[sx] * 0x101) ^ (sx * 0x1010100)
8718 SUB_MIX[0][x] = (t << 24) | (t >>> 8)
8719 SUB_MIX[1][x] = (t << 16) | (t >>> 16)
8720 SUB_MIX[2][x] = (t << 8) | (t >>> 24)
8721 SUB_MIX[3][x] = t
8722
8723 // Compute inv sub bytes, inv mix columns tables
8724 t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100)
8725 INV_SUB_MIX[0][sx] = (t << 24) | (t >>> 8)
8726 INV_SUB_MIX[1][sx] = (t << 16) | (t >>> 16)
8727 INV_SUB_MIX[2][sx] = (t << 8) | (t >>> 24)
8728 INV_SUB_MIX[3][sx] = t
8729
8730 if (x === 0) {
8731 x = xi = 1
8732 } else {
8733 x = x2 ^ d[d[d[x8 ^ x2]]]
8734 xi ^= d[d[xi]]
8735 }
8736 }
8737
8738 return {
8739 SBOX: SBOX,
8740 INV_SBOX: INV_SBOX,
8741 SUB_MIX: SUB_MIX,
8742 INV_SUB_MIX: INV_SUB_MIX
8743 }
8744})()
8745
8746function AES (key) {
8747 this._key = asUInt32Array(key)
8748 this._reset()
8749}
8750
8751AES.blockSize = 4 * 4
8752AES.keySize = 256 / 8
8753AES.prototype.blockSize = AES.blockSize
8754AES.prototype.keySize = AES.keySize
8755AES.prototype._reset = function () {
8756 var keyWords = this._key
8757 var keySize = keyWords.length
8758 var nRounds = keySize + 6
8759 var ksRows = (nRounds + 1) * 4
8760
8761 var keySchedule = []
8762 for (var k = 0; k < keySize; k++) {
8763 keySchedule[k] = keyWords[k]
8764 }
8765
8766 for (k = keySize; k < ksRows; k++) {
8767 var t = keySchedule[k - 1]
8768
8769 if (k % keySize === 0) {
8770 t = (t << 8) | (t >>> 24)
8771 t =
8772 (G.SBOX[t >>> 24] << 24) |
8773 (G.SBOX[(t >>> 16) & 0xff] << 16) |
8774 (G.SBOX[(t >>> 8) & 0xff] << 8) |
8775 (G.SBOX[t & 0xff])
8776
8777 t ^= RCON[(k / keySize) | 0] << 24
8778 } else if (keySize > 6 && k % keySize === 4) {
8779 t =
8780 (G.SBOX[t >>> 24] << 24) |
8781 (G.SBOX[(t >>> 16) & 0xff] << 16) |
8782 (G.SBOX[(t >>> 8) & 0xff] << 8) |
8783 (G.SBOX[t & 0xff])
8784 }
8785
8786 keySchedule[k] = keySchedule[k - keySize] ^ t
8787 }
8788
8789 var invKeySchedule = []
8790 for (var ik = 0; ik < ksRows; ik++) {
8791 var ksR = ksRows - ik
8792 var tt = keySchedule[ksR - (ik % 4 ? 0 : 4)]
8793
8794 if (ik < 4 || ksR <= 4) {
8795 invKeySchedule[ik] = tt
8796 } else {
8797 invKeySchedule[ik] =
8798 G.INV_SUB_MIX[0][G.SBOX[tt >>> 24]] ^
8799 G.INV_SUB_MIX[1][G.SBOX[(tt >>> 16) & 0xff]] ^
8800 G.INV_SUB_MIX[2][G.SBOX[(tt >>> 8) & 0xff]] ^
8801 G.INV_SUB_MIX[3][G.SBOX[tt & 0xff]]
8802 }
8803 }
8804
8805 this._nRounds = nRounds
8806 this._keySchedule = keySchedule
8807 this._invKeySchedule = invKeySchedule
8808}
8809
8810AES.prototype.encryptBlockRaw = function (M) {
8811 M = asUInt32Array(M)
8812 return cryptBlock(M, this._keySchedule, G.SUB_MIX, G.SBOX, this._nRounds)
8813}
8814
8815AES.prototype.encryptBlock = function (M) {
8816 var out = this.encryptBlockRaw(M)
8817 var buf = Buffer.allocUnsafe(16)
8818 buf.writeUInt32BE(out[0], 0)
8819 buf.writeUInt32BE(out[1], 4)
8820 buf.writeUInt32BE(out[2], 8)
8821 buf.writeUInt32BE(out[3], 12)
8822 return buf
8823}
8824
8825AES.prototype.decryptBlock = function (M) {
8826 M = asUInt32Array(M)
8827
8828 // swap
8829 var m1 = M[1]
8830 M[1] = M[3]
8831 M[3] = m1
8832
8833 var out = cryptBlock(M, this._invKeySchedule, G.INV_SUB_MIX, G.INV_SBOX, this._nRounds)
8834 var buf = Buffer.allocUnsafe(16)
8835 buf.writeUInt32BE(out[0], 0)
8836 buf.writeUInt32BE(out[3], 4)
8837 buf.writeUInt32BE(out[2], 8)
8838 buf.writeUInt32BE(out[1], 12)
8839 return buf
8840}
8841
8842AES.prototype.scrub = function () {
8843 scrubVec(this._keySchedule)
8844 scrubVec(this._invKeySchedule)
8845 scrubVec(this._key)
8846}
8847
8848module.exports.AES = AES
8849
8850},{"safe-buffer":156}],25:[function(require,module,exports){
8851var aes = require('./aes')
8852var Buffer = require('safe-buffer').Buffer
8853var Transform = require('cipher-base')
8854var inherits = require('inherits')
8855var GHASH = require('./ghash')
8856var xor = require('buffer-xor')
8857var incr32 = require('./incr32')
8858
8859function xorTest (a, b) {
8860 var out = 0
8861 if (a.length !== b.length) out++
8862
8863 var len = Math.min(a.length, b.length)
8864 for (var i = 0; i < len; ++i) {
8865 out += (a[i] ^ b[i])
8866 }
8867
8868 return out
8869}
8870
8871function calcIv (self, iv, ck) {
8872 if (iv.length === 12) {
8873 self._finID = Buffer.concat([iv, Buffer.from([0, 0, 0, 1])])
8874 return Buffer.concat([iv, Buffer.from([0, 0, 0, 2])])
8875 }
8876 var ghash = new GHASH(ck)
8877 var len = iv.length
8878 var toPad = len % 16
8879 ghash.update(iv)
8880 if (toPad) {
8881 toPad = 16 - toPad
8882 ghash.update(Buffer.alloc(toPad, 0))
8883 }
8884 ghash.update(Buffer.alloc(8, 0))
8885 var ivBits = len * 8
8886 var tail = Buffer.alloc(8)
8887 tail.writeUIntBE(ivBits, 0, 8)
8888 ghash.update(tail)
8889 self._finID = ghash.state
8890 var out = Buffer.from(self._finID)
8891 incr32(out)
8892 return out
8893}
8894function StreamCipher (mode, key, iv, decrypt) {
8895 Transform.call(this)
8896
8897 var h = Buffer.alloc(4, 0)
8898
8899 this._cipher = new aes.AES(key)
8900 var ck = this._cipher.encryptBlock(h)
8901 this._ghash = new GHASH(ck)
8902 iv = calcIv(this, iv, ck)
8903
8904 this._prev = Buffer.from(iv)
8905 this._cache = Buffer.allocUnsafe(0)
8906 this._secCache = Buffer.allocUnsafe(0)
8907 this._decrypt = decrypt
8908 this._alen = 0
8909 this._len = 0
8910 this._mode = mode
8911
8912 this._authTag = null
8913 this._called = false
8914}
8915
8916inherits(StreamCipher, Transform)
8917
8918StreamCipher.prototype._update = function (chunk) {
8919 if (!this._called && this._alen) {
8920 var rump = 16 - (this._alen % 16)
8921 if (rump < 16) {
8922 rump = Buffer.alloc(rump, 0)
8923 this._ghash.update(rump)
8924 }
8925 }
8926
8927 this._called = true
8928 var out = this._mode.encrypt(this, chunk)
8929 if (this._decrypt) {
8930 this._ghash.update(chunk)
8931 } else {
8932 this._ghash.update(out)
8933 }
8934 this._len += chunk.length
8935 return out
8936}
8937
8938StreamCipher.prototype._final = function () {
8939 if (this._decrypt && !this._authTag) throw new Error('Unsupported state or unable to authenticate data')
8940
8941 var tag = xor(this._ghash.final(this._alen * 8, this._len * 8), this._cipher.encryptBlock(this._finID))
8942 if (this._decrypt && xorTest(tag, this._authTag)) throw new Error('Unsupported state or unable to authenticate data')
8943
8944 this._authTag = tag
8945 this._cipher.scrub()
8946}
8947
8948StreamCipher.prototype.getAuthTag = function getAuthTag () {
8949 if (this._decrypt || !Buffer.isBuffer(this._authTag)) throw new Error('Attempting to get auth tag in unsupported state')
8950
8951 return this._authTag
8952}
8953
8954StreamCipher.prototype.setAuthTag = function setAuthTag (tag) {
8955 if (!this._decrypt) throw new Error('Attempting to set auth tag in unsupported state')
8956
8957 this._authTag = tag
8958}
8959
8960StreamCipher.prototype.setAAD = function setAAD (buf) {
8961 if (this._called) throw new Error('Attempting to set AAD in unsupported state')
8962
8963 this._ghash.update(buf)
8964 this._alen += buf.length
8965}
8966
8967module.exports = StreamCipher
8968
8969},{"./aes":24,"./ghash":29,"./incr32":30,"buffer-xor":52,"cipher-base":54,"inherits":107,"safe-buffer":156}],26:[function(require,module,exports){
8970var ciphers = require('./encrypter')
8971var deciphers = require('./decrypter')
8972var modes = require('./modes/list.json')
8973
8974function getCiphers () {
8975 return Object.keys(modes)
8976}
8977
8978exports.createCipher = exports.Cipher = ciphers.createCipher
8979exports.createCipheriv = exports.Cipheriv = ciphers.createCipheriv
8980exports.createDecipher = exports.Decipher = deciphers.createDecipher
8981exports.createDecipheriv = exports.Decipheriv = deciphers.createDecipheriv
8982exports.listCiphers = exports.getCiphers = getCiphers
8983
8984},{"./decrypter":27,"./encrypter":28,"./modes/list.json":38}],27:[function(require,module,exports){
8985var AuthCipher = require('./authCipher')
8986var Buffer = require('safe-buffer').Buffer
8987var MODES = require('./modes')
8988var StreamCipher = require('./streamCipher')
8989var Transform = require('cipher-base')
8990var aes = require('./aes')
8991var ebtk = require('evp_bytestokey')
8992var inherits = require('inherits')
8993
8994function Decipher (mode, key, iv) {
8995 Transform.call(this)
8996
8997 this._cache = new Splitter()
8998 this._last = void 0
8999 this._cipher = new aes.AES(key)
9000 this._prev = Buffer.from(iv)
9001 this._mode = mode
9002 this._autopadding = true
9003}
9004
9005inherits(Decipher, Transform)
9006
9007Decipher.prototype._update = function (data) {
9008 this._cache.add(data)
9009 var chunk
9010 var thing
9011 var out = []
9012 while ((chunk = this._cache.get(this._autopadding))) {
9013 thing = this._mode.decrypt(this, chunk)
9014 out.push(thing)
9015 }
9016 return Buffer.concat(out)
9017}
9018
9019Decipher.prototype._final = function () {
9020 var chunk = this._cache.flush()
9021 if (this._autopadding) {
9022 return unpad(this._mode.decrypt(this, chunk))
9023 } else if (chunk) {
9024 throw new Error('data not multiple of block length')
9025 }
9026}
9027
9028Decipher.prototype.setAutoPadding = function (setTo) {
9029 this._autopadding = !!setTo
9030 return this
9031}
9032
9033function Splitter () {
9034 this.cache = Buffer.allocUnsafe(0)
9035}
9036
9037Splitter.prototype.add = function (data) {
9038 this.cache = Buffer.concat([this.cache, data])
9039}
9040
9041Splitter.prototype.get = function (autoPadding) {
9042 var out
9043 if (autoPadding) {
9044 if (this.cache.length > 16) {
9045 out = this.cache.slice(0, 16)
9046 this.cache = this.cache.slice(16)
9047 return out
9048 }
9049 } else {
9050 if (this.cache.length >= 16) {
9051 out = this.cache.slice(0, 16)
9052 this.cache = this.cache.slice(16)
9053 return out
9054 }
9055 }
9056
9057 return null
9058}
9059
9060Splitter.prototype.flush = function () {
9061 if (this.cache.length) return this.cache
9062}
9063
9064function unpad (last) {
9065 var padded = last[15]
9066 var i = -1
9067 while (++i < padded) {
9068 if (last[(i + (16 - padded))] !== padded) {
9069 throw new Error('unable to decrypt data')
9070 }
9071 }
9072 if (padded === 16) return
9073
9074 return last.slice(0, 16 - padded)
9075}
9076
9077function createDecipheriv (suite, password, iv) {
9078 var config = MODES[suite.toLowerCase()]
9079 if (!config) throw new TypeError('invalid suite type')
9080
9081 if (typeof iv === 'string') iv = Buffer.from(iv)
9082 if (config.mode !== 'GCM' && iv.length !== config.iv) throw new TypeError('invalid iv length ' + iv.length)
9083
9084 if (typeof password === 'string') password = Buffer.from(password)
9085 if (password.length !== config.key / 8) throw new TypeError('invalid key length ' + password.length)
9086
9087 if (config.type === 'stream') {
9088 return new StreamCipher(config.module, password, iv, true)
9089 } else if (config.type === 'auth') {
9090 return new AuthCipher(config.module, password, iv, true)
9091 }
9092
9093 return new Decipher(config.module, password, iv)
9094}
9095
9096function createDecipher (suite, password) {
9097 var config = MODES[suite.toLowerCase()]
9098 if (!config) throw new TypeError('invalid suite type')
9099
9100 var keys = ebtk(password, false, config.key, config.iv)
9101 return createDecipheriv(suite, keys.key, keys.iv)
9102}
9103
9104exports.createDecipher = createDecipher
9105exports.createDecipheriv = createDecipheriv
9106
9107},{"./aes":24,"./authCipher":25,"./modes":37,"./streamCipher":40,"cipher-base":54,"evp_bytestokey":90,"inherits":107,"safe-buffer":156}],28:[function(require,module,exports){
9108var MODES = require('./modes')
9109var AuthCipher = require('./authCipher')
9110var Buffer = require('safe-buffer').Buffer
9111var StreamCipher = require('./streamCipher')
9112var Transform = require('cipher-base')
9113var aes = require('./aes')
9114var ebtk = require('evp_bytestokey')
9115var inherits = require('inherits')
9116
9117function Cipher (mode, key, iv) {
9118 Transform.call(this)
9119
9120 this._cache = new Splitter()
9121 this._cipher = new aes.AES(key)
9122 this._prev = Buffer.from(iv)
9123 this._mode = mode
9124 this._autopadding = true
9125}
9126
9127inherits(Cipher, Transform)
9128
9129Cipher.prototype._update = function (data) {
9130 this._cache.add(data)
9131 var chunk
9132 var thing
9133 var out = []
9134
9135 while ((chunk = this._cache.get())) {
9136 thing = this._mode.encrypt(this, chunk)
9137 out.push(thing)
9138 }
9139
9140 return Buffer.concat(out)
9141}
9142
9143var PADDING = Buffer.alloc(16, 0x10)
9144
9145Cipher.prototype._final = function () {
9146 var chunk = this._cache.flush()
9147 if (this._autopadding) {
9148 chunk = this._mode.encrypt(this, chunk)
9149 this._cipher.scrub()
9150 return chunk
9151 }
9152
9153 if (!chunk.equals(PADDING)) {
9154 this._cipher.scrub()
9155 throw new Error('data not multiple of block length')
9156 }
9157}
9158
9159Cipher.prototype.setAutoPadding = function (setTo) {
9160 this._autopadding = !!setTo
9161 return this
9162}
9163
9164function Splitter () {
9165 this.cache = Buffer.allocUnsafe(0)
9166}
9167
9168Splitter.prototype.add = function (data) {
9169 this.cache = Buffer.concat([this.cache, data])
9170}
9171
9172Splitter.prototype.get = function () {
9173 if (this.cache.length > 15) {
9174 var out = this.cache.slice(0, 16)
9175 this.cache = this.cache.slice(16)
9176 return out
9177 }
9178 return null
9179}
9180
9181Splitter.prototype.flush = function () {
9182 var len = 16 - this.cache.length
9183 var padBuff = Buffer.allocUnsafe(len)
9184
9185 var i = -1
9186 while (++i < len) {
9187 padBuff.writeUInt8(len, i)
9188 }
9189
9190 return Buffer.concat([this.cache, padBuff])
9191}
9192
9193function createCipheriv (suite, password, iv) {
9194 var config = MODES[suite.toLowerCase()]
9195 if (!config) throw new TypeError('invalid suite type')
9196
9197 if (typeof password === 'string') password = Buffer.from(password)
9198 if (password.length !== config.key / 8) throw new TypeError('invalid key length ' + password.length)
9199
9200 if (typeof iv === 'string') iv = Buffer.from(iv)
9201 if (config.mode !== 'GCM' && iv.length !== config.iv) throw new TypeError('invalid iv length ' + iv.length)
9202
9203 if (config.type === 'stream') {
9204 return new StreamCipher(config.module, password, iv)
9205 } else if (config.type === 'auth') {
9206 return new AuthCipher(config.module, password, iv)
9207 }
9208
9209 return new Cipher(config.module, password, iv)
9210}
9211
9212function createCipher (suite, password) {
9213 var config = MODES[suite.toLowerCase()]
9214 if (!config) throw new TypeError('invalid suite type')
9215
9216 var keys = ebtk(password, false, config.key, config.iv)
9217 return createCipheriv(suite, keys.key, keys.iv)
9218}
9219
9220exports.createCipheriv = createCipheriv
9221exports.createCipher = createCipher
9222
9223},{"./aes":24,"./authCipher":25,"./modes":37,"./streamCipher":40,"cipher-base":54,"evp_bytestokey":90,"inherits":107,"safe-buffer":156}],29:[function(require,module,exports){
9224var Buffer = require('safe-buffer').Buffer
9225var ZEROES = Buffer.alloc(16, 0)
9226
9227function toArray (buf) {
9228 return [
9229 buf.readUInt32BE(0),
9230 buf.readUInt32BE(4),
9231 buf.readUInt32BE(8),
9232 buf.readUInt32BE(12)
9233 ]
9234}
9235
9236function fromArray (out) {
9237 var buf = Buffer.allocUnsafe(16)
9238 buf.writeUInt32BE(out[0] >>> 0, 0)
9239 buf.writeUInt32BE(out[1] >>> 0, 4)
9240 buf.writeUInt32BE(out[2] >>> 0, 8)
9241 buf.writeUInt32BE(out[3] >>> 0, 12)
9242 return buf
9243}
9244
9245function GHASH (key) {
9246 this.h = key
9247 this.state = Buffer.alloc(16, 0)
9248 this.cache = Buffer.allocUnsafe(0)
9249}
9250
9251// from http://bitwiseshiftleft.github.io/sjcl/doc/symbols/src/core_gcm.js.html
9252// by Juho Vähä-Herttua
9253GHASH.prototype.ghash = function (block) {
9254 var i = -1
9255 while (++i < block.length) {
9256 this.state[i] ^= block[i]
9257 }
9258 this._multiply()
9259}
9260
9261GHASH.prototype._multiply = function () {
9262 var Vi = toArray(this.h)
9263 var Zi = [0, 0, 0, 0]
9264 var j, xi, lsbVi
9265 var i = -1
9266 while (++i < 128) {
9267 xi = (this.state[~~(i / 8)] & (1 << (7 - (i % 8)))) !== 0
9268 if (xi) {
9269 // Z_i+1 = Z_i ^ V_i
9270 Zi[0] ^= Vi[0]
9271 Zi[1] ^= Vi[1]
9272 Zi[2] ^= Vi[2]
9273 Zi[3] ^= Vi[3]
9274 }
9275
9276 // Store the value of LSB(V_i)
9277 lsbVi = (Vi[3] & 1) !== 0
9278
9279 // V_i+1 = V_i >> 1
9280 for (j = 3; j > 0; j--) {
9281 Vi[j] = (Vi[j] >>> 1) | ((Vi[j - 1] & 1) << 31)
9282 }
9283 Vi[0] = Vi[0] >>> 1
9284
9285 // If LSB(V_i) is 1, V_i+1 = (V_i >> 1) ^ R
9286 if (lsbVi) {
9287 Vi[0] = Vi[0] ^ (0xe1 << 24)
9288 }
9289 }
9290 this.state = fromArray(Zi)
9291}
9292
9293GHASH.prototype.update = function (buf) {
9294 this.cache = Buffer.concat([this.cache, buf])
9295 var chunk
9296 while (this.cache.length >= 16) {
9297 chunk = this.cache.slice(0, 16)
9298 this.cache = this.cache.slice(16)
9299 this.ghash(chunk)
9300 }
9301}
9302
9303GHASH.prototype.final = function (abl, bl) {
9304 if (this.cache.length) {
9305 this.ghash(Buffer.concat([this.cache, ZEROES], 16))
9306 }
9307
9308 this.ghash(fromArray([0, abl, 0, bl]))
9309 return this.state
9310}
9311
9312module.exports = GHASH
9313
9314},{"safe-buffer":156}],30:[function(require,module,exports){
9315function incr32 (iv) {
9316 var len = iv.length
9317 var item
9318 while (len--) {
9319 item = iv.readUInt8(len)
9320 if (item === 255) {
9321 iv.writeUInt8(0, len)
9322 } else {
9323 item++
9324 iv.writeUInt8(item, len)
9325 break
9326 }
9327 }
9328}
9329module.exports = incr32
9330
9331},{}],31:[function(require,module,exports){
9332var xor = require('buffer-xor')
9333
9334exports.encrypt = function (self, block) {
9335 var data = xor(block, self._prev)
9336
9337 self._prev = self._cipher.encryptBlock(data)
9338 return self._prev
9339}
9340
9341exports.decrypt = function (self, block) {
9342 var pad = self._prev
9343
9344 self._prev = block
9345 var out = self._cipher.decryptBlock(block)
9346
9347 return xor(out, pad)
9348}
9349
9350},{"buffer-xor":52}],32:[function(require,module,exports){
9351var Buffer = require('safe-buffer').Buffer
9352var xor = require('buffer-xor')
9353
9354function encryptStart (self, data, decrypt) {
9355 var len = data.length
9356 var out = xor(data, self._cache)
9357 self._cache = self._cache.slice(len)
9358 self._prev = Buffer.concat([self._prev, decrypt ? data : out])
9359 return out
9360}
9361
9362exports.encrypt = function (self, data, decrypt) {
9363 var out = Buffer.allocUnsafe(0)
9364 var len
9365
9366 while (data.length) {
9367 if (self._cache.length === 0) {
9368 self._cache = self._cipher.encryptBlock(self._prev)
9369 self._prev = Buffer.allocUnsafe(0)
9370 }
9371
9372 if (self._cache.length <= data.length) {
9373 len = self._cache.length
9374 out = Buffer.concat([out, encryptStart(self, data.slice(0, len), decrypt)])
9375 data = data.slice(len)
9376 } else {
9377 out = Buffer.concat([out, encryptStart(self, data, decrypt)])
9378 break
9379 }
9380 }
9381
9382 return out
9383}
9384
9385},{"buffer-xor":52,"safe-buffer":156}],33:[function(require,module,exports){
9386var Buffer = require('safe-buffer').Buffer
9387
9388function encryptByte (self, byteParam, decrypt) {
9389 var pad
9390 var i = -1
9391 var len = 8
9392 var out = 0
9393 var bit, value
9394 while (++i < len) {
9395 pad = self._cipher.encryptBlock(self._prev)
9396 bit = (byteParam & (1 << (7 - i))) ? 0x80 : 0
9397 value = pad[0] ^ bit
9398 out += ((value & 0x80) >> (i % 8))
9399 self._prev = shiftIn(self._prev, decrypt ? bit : value)
9400 }
9401 return out
9402}
9403
9404function shiftIn (buffer, value) {
9405 var len = buffer.length
9406 var i = -1
9407 var out = Buffer.allocUnsafe(buffer.length)
9408 buffer = Buffer.concat([buffer, Buffer.from([value])])
9409
9410 while (++i < len) {
9411 out[i] = buffer[i] << 1 | buffer[i + 1] >> (7)
9412 }
9413
9414 return out
9415}
9416
9417exports.encrypt = function (self, chunk, decrypt) {
9418 var len = chunk.length
9419 var out = Buffer.allocUnsafe(len)
9420 var i = -1
9421
9422 while (++i < len) {
9423 out[i] = encryptByte(self, chunk[i], decrypt)
9424 }
9425
9426 return out
9427}
9428
9429},{"safe-buffer":156}],34:[function(require,module,exports){
9430var Buffer = require('safe-buffer').Buffer
9431
9432function encryptByte (self, byteParam, decrypt) {
9433 var pad = self._cipher.encryptBlock(self._prev)
9434 var out = pad[0] ^ byteParam
9435
9436 self._prev = Buffer.concat([
9437 self._prev.slice(1),
9438 Buffer.from([decrypt ? byteParam : out])
9439 ])
9440
9441 return out
9442}
9443
9444exports.encrypt = function (self, chunk, decrypt) {
9445 var len = chunk.length
9446 var out = Buffer.allocUnsafe(len)
9447 var i = -1
9448
9449 while (++i < len) {
9450 out[i] = encryptByte(self, chunk[i], decrypt)
9451 }
9452
9453 return out
9454}
9455
9456},{"safe-buffer":156}],35:[function(require,module,exports){
9457var xor = require('buffer-xor')
9458var Buffer = require('safe-buffer').Buffer
9459var incr32 = require('../incr32')
9460
9461function getBlock (self) {
9462 var out = self._cipher.encryptBlockRaw(self._prev)
9463 incr32(self._prev)
9464 return out
9465}
9466
9467var blockSize = 16
9468exports.encrypt = function (self, chunk) {
9469 var chunkNum = Math.ceil(chunk.length / blockSize)
9470 var start = self._cache.length
9471 self._cache = Buffer.concat([
9472 self._cache,
9473 Buffer.allocUnsafe(chunkNum * blockSize)
9474 ])
9475 for (var i = 0; i < chunkNum; i++) {
9476 var out = getBlock(self)
9477 var offset = start + i * blockSize
9478 self._cache.writeUInt32BE(out[0], offset + 0)
9479 self._cache.writeUInt32BE(out[1], offset + 4)
9480 self._cache.writeUInt32BE(out[2], offset + 8)
9481 self._cache.writeUInt32BE(out[3], offset + 12)
9482 }
9483 var pad = self._cache.slice(0, chunk.length)
9484 self._cache = self._cache.slice(chunk.length)
9485 return xor(chunk, pad)
9486}
9487
9488},{"../incr32":30,"buffer-xor":52,"safe-buffer":156}],36:[function(require,module,exports){
9489exports.encrypt = function (self, block) {
9490 return self._cipher.encryptBlock(block)
9491}
9492
9493exports.decrypt = function (self, block) {
9494 return self._cipher.decryptBlock(block)
9495}
9496
9497},{}],37:[function(require,module,exports){
9498var modeModules = {
9499 ECB: require('./ecb'),
9500 CBC: require('./cbc'),
9501 CFB: require('./cfb'),
9502 CFB8: require('./cfb8'),
9503 CFB1: require('./cfb1'),
9504 OFB: require('./ofb'),
9505 CTR: require('./ctr'),
9506 GCM: require('./ctr')
9507}
9508
9509var modes = require('./list.json')
9510
9511for (var key in modes) {
9512 modes[key].module = modeModules[modes[key].mode]
9513}
9514
9515module.exports = modes
9516
9517},{"./cbc":31,"./cfb":32,"./cfb1":33,"./cfb8":34,"./ctr":35,"./ecb":36,"./list.json":38,"./ofb":39}],38:[function(require,module,exports){
9518module.exports={
9519 "aes-128-ecb": {
9520 "cipher": "AES",
9521 "key": 128,
9522 "iv": 0,
9523 "mode": "ECB",
9524 "type": "block"
9525 },
9526 "aes-192-ecb": {
9527 "cipher": "AES",
9528 "key": 192,
9529 "iv": 0,
9530 "mode": "ECB",
9531 "type": "block"
9532 },
9533 "aes-256-ecb": {
9534 "cipher": "AES",
9535 "key": 256,
9536 "iv": 0,
9537 "mode": "ECB",
9538 "type": "block"
9539 },
9540 "aes-128-cbc": {
9541 "cipher": "AES",
9542 "key": 128,
9543 "iv": 16,
9544 "mode": "CBC",
9545 "type": "block"
9546 },
9547 "aes-192-cbc": {
9548 "cipher": "AES",
9549 "key": 192,
9550 "iv": 16,
9551 "mode": "CBC",
9552 "type": "block"
9553 },
9554 "aes-256-cbc": {
9555 "cipher": "AES",
9556 "key": 256,
9557 "iv": 16,
9558 "mode": "CBC",
9559 "type": "block"
9560 },
9561 "aes128": {
9562 "cipher": "AES",
9563 "key": 128,
9564 "iv": 16,
9565 "mode": "CBC",
9566 "type": "block"
9567 },
9568 "aes192": {
9569 "cipher": "AES",
9570 "key": 192,
9571 "iv": 16,
9572 "mode": "CBC",
9573 "type": "block"
9574 },
9575 "aes256": {
9576 "cipher": "AES",
9577 "key": 256,
9578 "iv": 16,
9579 "mode": "CBC",
9580 "type": "block"
9581 },
9582 "aes-128-cfb": {
9583 "cipher": "AES",
9584 "key": 128,
9585 "iv": 16,
9586 "mode": "CFB",
9587 "type": "stream"
9588 },
9589 "aes-192-cfb": {
9590 "cipher": "AES",
9591 "key": 192,
9592 "iv": 16,
9593 "mode": "CFB",
9594 "type": "stream"
9595 },
9596 "aes-256-cfb": {
9597 "cipher": "AES",
9598 "key": 256,
9599 "iv": 16,
9600 "mode": "CFB",
9601 "type": "stream"
9602 },
9603 "aes-128-cfb8": {
9604 "cipher": "AES",
9605 "key": 128,
9606 "iv": 16,
9607 "mode": "CFB8",
9608 "type": "stream"
9609 },
9610 "aes-192-cfb8": {
9611 "cipher": "AES",
9612 "key": 192,
9613 "iv": 16,
9614 "mode": "CFB8",
9615 "type": "stream"
9616 },
9617 "aes-256-cfb8": {
9618 "cipher": "AES",
9619 "key": 256,
9620 "iv": 16,
9621 "mode": "CFB8",
9622 "type": "stream"
9623 },
9624 "aes-128-cfb1": {
9625 "cipher": "AES",
9626 "key": 128,
9627 "iv": 16,
9628 "mode": "CFB1",
9629 "type": "stream"
9630 },
9631 "aes-192-cfb1": {
9632 "cipher": "AES",
9633 "key": 192,
9634 "iv": 16,
9635 "mode": "CFB1",
9636 "type": "stream"
9637 },
9638 "aes-256-cfb1": {
9639 "cipher": "AES",
9640 "key": 256,
9641 "iv": 16,
9642 "mode": "CFB1",
9643 "type": "stream"
9644 },
9645 "aes-128-ofb": {
9646 "cipher": "AES",
9647 "key": 128,
9648 "iv": 16,
9649 "mode": "OFB",
9650 "type": "stream"
9651 },
9652 "aes-192-ofb": {
9653 "cipher": "AES",
9654 "key": 192,
9655 "iv": 16,
9656 "mode": "OFB",
9657 "type": "stream"
9658 },
9659 "aes-256-ofb": {
9660 "cipher": "AES",
9661 "key": 256,
9662 "iv": 16,
9663 "mode": "OFB",
9664 "type": "stream"
9665 },
9666 "aes-128-ctr": {
9667 "cipher": "AES",
9668 "key": 128,
9669 "iv": 16,
9670 "mode": "CTR",
9671 "type": "stream"
9672 },
9673 "aes-192-ctr": {
9674 "cipher": "AES",
9675 "key": 192,
9676 "iv": 16,
9677 "mode": "CTR",
9678 "type": "stream"
9679 },
9680 "aes-256-ctr": {
9681 "cipher": "AES",
9682 "key": 256,
9683 "iv": 16,
9684 "mode": "CTR",
9685 "type": "stream"
9686 },
9687 "aes-128-gcm": {
9688 "cipher": "AES",
9689 "key": 128,
9690 "iv": 12,
9691 "mode": "GCM",
9692 "type": "auth"
9693 },
9694 "aes-192-gcm": {
9695 "cipher": "AES",
9696 "key": 192,
9697 "iv": 12,
9698 "mode": "GCM",
9699 "type": "auth"
9700 },
9701 "aes-256-gcm": {
9702 "cipher": "AES",
9703 "key": 256,
9704 "iv": 12,
9705 "mode": "GCM",
9706 "type": "auth"
9707 }
9708}
9709
9710},{}],39:[function(require,module,exports){
9711(function (Buffer){
9712var xor = require('buffer-xor')
9713
9714function getBlock (self) {
9715 self._prev = self._cipher.encryptBlock(self._prev)
9716 return self._prev
9717}
9718
9719exports.encrypt = function (self, chunk) {
9720 while (self._cache.length < chunk.length) {
9721 self._cache = Buffer.concat([self._cache, getBlock(self)])
9722 }
9723
9724 var pad = self._cache.slice(0, chunk.length)
9725 self._cache = self._cache.slice(chunk.length)
9726 return xor(chunk, pad)
9727}
9728
9729}).call(this,require("buffer").Buffer)
9730},{"buffer":53,"buffer-xor":52}],40:[function(require,module,exports){
9731var aes = require('./aes')
9732var Buffer = require('safe-buffer').Buffer
9733var Transform = require('cipher-base')
9734var inherits = require('inherits')
9735
9736function StreamCipher (mode, key, iv, decrypt) {
9737 Transform.call(this)
9738
9739 this._cipher = new aes.AES(key)
9740 this._prev = Buffer.from(iv)
9741 this._cache = Buffer.allocUnsafe(0)
9742 this._secCache = Buffer.allocUnsafe(0)
9743 this._decrypt = decrypt
9744 this._mode = mode
9745}
9746
9747inherits(StreamCipher, Transform)
9748
9749StreamCipher.prototype._update = function (chunk) {
9750 return this._mode.encrypt(this, chunk, this._decrypt)
9751}
9752
9753StreamCipher.prototype._final = function () {
9754 this._cipher.scrub()
9755}
9756
9757module.exports = StreamCipher
9758
9759},{"./aes":24,"cipher-base":54,"inherits":107,"safe-buffer":156}],41:[function(require,module,exports){
9760var ebtk = require('evp_bytestokey')
9761var aes = require('browserify-aes/browser')
9762var DES = require('browserify-des')
9763var desModes = require('browserify-des/modes')
9764var aesModes = require('browserify-aes/modes')
9765function createCipher (suite, password) {
9766 var keyLen, ivLen
9767 suite = suite.toLowerCase()
9768 if (aesModes[suite]) {
9769 keyLen = aesModes[suite].key
9770 ivLen = aesModes[suite].iv
9771 } else if (desModes[suite]) {
9772 keyLen = desModes[suite].key * 8
9773 ivLen = desModes[suite].iv
9774 } else {
9775 throw new TypeError('invalid suite type')
9776 }
9777 var keys = ebtk(password, false, keyLen, ivLen)
9778 return createCipheriv(suite, keys.key, keys.iv)
9779}
9780function createDecipher (suite, password) {
9781 var keyLen, ivLen
9782 suite = suite.toLowerCase()
9783 if (aesModes[suite]) {
9784 keyLen = aesModes[suite].key
9785 ivLen = aesModes[suite].iv
9786 } else if (desModes[suite]) {
9787 keyLen = desModes[suite].key * 8
9788 ivLen = desModes[suite].iv
9789 } else {
9790 throw new TypeError('invalid suite type')
9791 }
9792 var keys = ebtk(password, false, keyLen, ivLen)
9793 return createDecipheriv(suite, keys.key, keys.iv)
9794}
9795
9796function createCipheriv (suite, key, iv) {
9797 suite = suite.toLowerCase()
9798 if (aesModes[suite]) {
9799 return aes.createCipheriv(suite, key, iv)
9800 } else if (desModes[suite]) {
9801 return new DES({
9802 key: key,
9803 iv: iv,
9804 mode: suite
9805 })
9806 } else {
9807 throw new TypeError('invalid suite type')
9808 }
9809}
9810function createDecipheriv (suite, key, iv) {
9811 suite = suite.toLowerCase()
9812 if (aesModes[suite]) {
9813 return aes.createDecipheriv(suite, key, iv)
9814 } else if (desModes[suite]) {
9815 return new DES({
9816 key: key,
9817 iv: iv,
9818 mode: suite,
9819 decrypt: true
9820 })
9821 } else {
9822 throw new TypeError('invalid suite type')
9823 }
9824}
9825exports.createCipher = exports.Cipher = createCipher
9826exports.createCipheriv = exports.Cipheriv = createCipheriv
9827exports.createDecipher = exports.Decipher = createDecipher
9828exports.createDecipheriv = exports.Decipheriv = createDecipheriv
9829function getCiphers () {
9830 return Object.keys(desModes).concat(aes.getCiphers())
9831}
9832exports.listCiphers = exports.getCiphers = getCiphers
9833
9834},{"browserify-aes/browser":26,"browserify-aes/modes":37,"browserify-des":42,"browserify-des/modes":43,"evp_bytestokey":90}],42:[function(require,module,exports){
9835(function (Buffer){
9836var CipherBase = require('cipher-base')
9837var des = require('des.js')
9838var inherits = require('inherits')
9839
9840var modes = {
9841 'des-ede3-cbc': des.CBC.instantiate(des.EDE),
9842 'des-ede3': des.EDE,
9843 'des-ede-cbc': des.CBC.instantiate(des.EDE),
9844 'des-ede': des.EDE,
9845 'des-cbc': des.CBC.instantiate(des.DES),
9846 'des-ecb': des.DES
9847}
9848modes.des = modes['des-cbc']
9849modes.des3 = modes['des-ede3-cbc']
9850module.exports = DES
9851inherits(DES, CipherBase)
9852function DES (opts) {
9853 CipherBase.call(this)
9854 var modeName = opts.mode.toLowerCase()
9855 var mode = modes[modeName]
9856 var type
9857 if (opts.decrypt) {
9858 type = 'decrypt'
9859 } else {
9860 type = 'encrypt'
9861 }
9862 var key = opts.key
9863 if (modeName === 'des-ede' || modeName === 'des-ede-cbc') {
9864 key = Buffer.concat([key, key.slice(0, 8)])
9865 }
9866 var iv = opts.iv
9867 this._des = mode.create({
9868 key: key,
9869 iv: iv,
9870 type: type
9871 })
9872}
9873DES.prototype._update = function (data) {
9874 return new Buffer(this._des.update(data))
9875}
9876DES.prototype._final = function () {
9877 return new Buffer(this._des.final())
9878}
9879
9880}).call(this,require("buffer").Buffer)
9881},{"buffer":53,"cipher-base":54,"des.js":63,"inherits":107}],43:[function(require,module,exports){
9882exports['des-ecb'] = {
9883 key: 8,
9884 iv: 0
9885}
9886exports['des-cbc'] = exports.des = {
9887 key: 8,
9888 iv: 8
9889}
9890exports['des-ede3-cbc'] = exports.des3 = {
9891 key: 24,
9892 iv: 8
9893}
9894exports['des-ede3'] = {
9895 key: 24,
9896 iv: 0
9897}
9898exports['des-ede-cbc'] = {
9899 key: 16,
9900 iv: 8
9901}
9902exports['des-ede'] = {
9903 key: 16,
9904 iv: 0
9905}
9906
9907},{}],44:[function(require,module,exports){
9908(function (Buffer){
9909var bn = require('bn.js');
9910var randomBytes = require('randombytes');
9911module.exports = crt;
9912function blind(priv) {
9913 var r = getr(priv);
9914 var blinder = r.toRed(bn.mont(priv.modulus))
9915 .redPow(new bn(priv.publicExponent)).fromRed();
9916 return {
9917 blinder: blinder,
9918 unblinder:r.invm(priv.modulus)
9919 };
9920}
9921function crt(msg, priv) {
9922 var blinds = blind(priv);
9923 var len = priv.modulus.byteLength();
9924 var mod = bn.mont(priv.modulus);
9925 var blinded = new bn(msg).mul(blinds.blinder).umod(priv.modulus);
9926 var c1 = blinded.toRed(bn.mont(priv.prime1));
9927 var c2 = blinded.toRed(bn.mont(priv.prime2));
9928 var qinv = priv.coefficient;
9929 var p = priv.prime1;
9930 var q = priv.prime2;
9931 var m1 = c1.redPow(priv.exponent1);
9932 var m2 = c2.redPow(priv.exponent2);
9933 m1 = m1.fromRed();
9934 m2 = m2.fromRed();
9935 var h = m1.isub(m2).imul(qinv).umod(p);
9936 h.imul(q);
9937 m2.iadd(h);
9938 return new Buffer(m2.imul(blinds.unblinder).umod(priv.modulus).toArray(false, len));
9939}
9940crt.getr = getr;
9941function getr(priv) {
9942 var len = priv.modulus.byteLength();
9943 var r = new bn(randomBytes(len));
9944 while (r.cmp(priv.modulus) >= 0 || !r.umod(priv.prime1) || !r.umod(priv.prime2)) {
9945 r = new bn(randomBytes(len));
9946 }
9947 return r;
9948}
9949
9950}).call(this,require("buffer").Buffer)
9951},{"bn.js":21,"buffer":53,"randombytes":140}],45:[function(require,module,exports){
9952module.exports = require('./browser/algorithms.json')
9953
9954},{"./browser/algorithms.json":46}],46:[function(require,module,exports){
9955module.exports={
9956 "sha224WithRSAEncryption": {
9957 "sign": "rsa",
9958 "hash": "sha224",
9959 "id": "302d300d06096086480165030402040500041c"
9960 },
9961 "RSA-SHA224": {
9962 "sign": "ecdsa/rsa",
9963 "hash": "sha224",
9964 "id": "302d300d06096086480165030402040500041c"
9965 },
9966 "sha256WithRSAEncryption": {
9967 "sign": "rsa",
9968 "hash": "sha256",
9969 "id": "3031300d060960864801650304020105000420"
9970 },
9971 "RSA-SHA256": {
9972 "sign": "ecdsa/rsa",
9973 "hash": "sha256",
9974 "id": "3031300d060960864801650304020105000420"
9975 },
9976 "sha384WithRSAEncryption": {
9977 "sign": "rsa",
9978 "hash": "sha384",
9979 "id": "3041300d060960864801650304020205000430"
9980 },
9981 "RSA-SHA384": {
9982 "sign": "ecdsa/rsa",
9983 "hash": "sha384",
9984 "id": "3041300d060960864801650304020205000430"
9985 },
9986 "sha512WithRSAEncryption": {
9987 "sign": "rsa",
9988 "hash": "sha512",
9989 "id": "3051300d060960864801650304020305000440"
9990 },
9991 "RSA-SHA512": {
9992 "sign": "ecdsa/rsa",
9993 "hash": "sha512",
9994 "id": "3051300d060960864801650304020305000440"
9995 },
9996 "RSA-SHA1": {
9997 "sign": "rsa",
9998 "hash": "sha1",
9999 "id": "3021300906052b0e03021a05000414"
10000 },
10001 "ecdsa-with-SHA1": {
10002 "sign": "ecdsa",
10003 "hash": "sha1",
10004 "id": ""
10005 },
10006 "sha256": {
10007 "sign": "ecdsa",
10008 "hash": "sha256",
10009 "id": ""
10010 },
10011 "sha224": {
10012 "sign": "ecdsa",
10013 "hash": "sha224",
10014 "id": ""
10015 },
10016 "sha384": {
10017 "sign": "ecdsa",
10018 "hash": "sha384",
10019 "id": ""
10020 },
10021 "sha512": {
10022 "sign": "ecdsa",
10023 "hash": "sha512",
10024 "id": ""
10025 },
10026 "DSA-SHA": {
10027 "sign": "dsa",
10028 "hash": "sha1",
10029 "id": ""
10030 },
10031 "DSA-SHA1": {
10032 "sign": "dsa",
10033 "hash": "sha1",
10034 "id": ""
10035 },
10036 "DSA": {
10037 "sign": "dsa",
10038 "hash": "sha1",
10039 "id": ""
10040 },
10041 "DSA-WITH-SHA224": {
10042 "sign": "dsa",
10043 "hash": "sha224",
10044 "id": ""
10045 },
10046 "DSA-SHA224": {
10047 "sign": "dsa",
10048 "hash": "sha224",
10049 "id": ""
10050 },
10051 "DSA-WITH-SHA256": {
10052 "sign": "dsa",
10053 "hash": "sha256",
10054 "id": ""
10055 },
10056 "DSA-SHA256": {
10057 "sign": "dsa",
10058 "hash": "sha256",
10059 "id": ""
10060 },
10061 "DSA-WITH-SHA384": {
10062 "sign": "dsa",
10063 "hash": "sha384",
10064 "id": ""
10065 },
10066 "DSA-SHA384": {
10067 "sign": "dsa",
10068 "hash": "sha384",
10069 "id": ""
10070 },
10071 "DSA-WITH-SHA512": {
10072 "sign": "dsa",
10073 "hash": "sha512",
10074 "id": ""
10075 },
10076 "DSA-SHA512": {
10077 "sign": "dsa",
10078 "hash": "sha512",
10079 "id": ""
10080 },
10081 "DSA-RIPEMD160": {
10082 "sign": "dsa",
10083 "hash": "rmd160",
10084 "id": ""
10085 },
10086 "ripemd160WithRSA": {
10087 "sign": "rsa",
10088 "hash": "rmd160",
10089 "id": "3021300906052b2403020105000414"
10090 },
10091 "RSA-RIPEMD160": {
10092 "sign": "rsa",
10093 "hash": "rmd160",
10094 "id": "3021300906052b2403020105000414"
10095 },
10096 "md5WithRSAEncryption": {
10097 "sign": "rsa",
10098 "hash": "md5",
10099 "id": "3020300c06082a864886f70d020505000410"
10100 },
10101 "RSA-MD5": {
10102 "sign": "rsa",
10103 "hash": "md5",
10104 "id": "3020300c06082a864886f70d020505000410"
10105 }
10106}
10107
10108},{}],47:[function(require,module,exports){
10109module.exports={
10110 "1.3.132.0.10": "secp256k1",
10111 "1.3.132.0.33": "p224",
10112 "1.2.840.10045.3.1.1": "p192",
10113 "1.2.840.10045.3.1.7": "p256",
10114 "1.3.132.0.34": "p384",
10115 "1.3.132.0.35": "p521"
10116}
10117
10118},{}],48:[function(require,module,exports){
10119(function (Buffer){
10120var createHash = require('create-hash')
10121var stream = require('stream')
10122var inherits = require('inherits')
10123var sign = require('./sign')
10124var verify = require('./verify')
10125
10126var algorithms = require('./algorithms.json')
10127Object.keys(algorithms).forEach(function (key) {
10128 algorithms[key].id = new Buffer(algorithms[key].id, 'hex')
10129 algorithms[key.toLowerCase()] = algorithms[key]
10130})
10131
10132function Sign (algorithm) {
10133 stream.Writable.call(this)
10134
10135 var data = algorithms[algorithm]
10136 if (!data) throw new Error('Unknown message digest')
10137
10138 this._hashType = data.hash
10139 this._hash = createHash(data.hash)
10140 this._tag = data.id
10141 this._signType = data.sign
10142}
10143inherits(Sign, stream.Writable)
10144
10145Sign.prototype._write = function _write (data, _, done) {
10146 this._hash.update(data)
10147 done()
10148}
10149
10150Sign.prototype.update = function update (data, enc) {
10151 if (typeof data === 'string') data = new Buffer(data, enc)
10152
10153 this._hash.update(data)
10154 return this
10155}
10156
10157Sign.prototype.sign = function signMethod (key, enc) {
10158 this.end()
10159 var hash = this._hash.digest()
10160 var sig = sign(hash, key, this._hashType, this._signType, this._tag)
10161
10162 return enc ? sig.toString(enc) : sig
10163}
10164
10165function Verify (algorithm) {
10166 stream.Writable.call(this)
10167
10168 var data = algorithms[algorithm]
10169 if (!data) throw new Error('Unknown message digest')
10170
10171 this._hash = createHash(data.hash)
10172 this._tag = data.id
10173 this._signType = data.sign
10174}
10175inherits(Verify, stream.Writable)
10176
10177Verify.prototype._write = function _write (data, _, done) {
10178 this._hash.update(data)
10179 done()
10180}
10181
10182Verify.prototype.update = function update (data, enc) {
10183 if (typeof data === 'string') data = new Buffer(data, enc)
10184
10185 this._hash.update(data)
10186 return this
10187}
10188
10189Verify.prototype.verify = function verifyMethod (key, sig, enc) {
10190 if (typeof sig === 'string') sig = new Buffer(sig, enc)
10191
10192 this.end()
10193 var hash = this._hash.digest()
10194 return verify(sig, hash, key, this._signType, this._tag)
10195}
10196
10197function createSign (algorithm) {
10198 return new Sign(algorithm)
10199}
10200
10201function createVerify (algorithm) {
10202 return new Verify(algorithm)
10203}
10204
10205module.exports = {
10206 Sign: createSign,
10207 Verify: createVerify,
10208 createSign: createSign,
10209 createVerify: createVerify
10210}
10211
10212}).call(this,require("buffer").Buffer)
10213},{"./algorithms.json":46,"./sign":49,"./verify":50,"buffer":53,"create-hash":57,"inherits":107,"stream":172}],49:[function(require,module,exports){
10214(function (Buffer){
10215// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js
10216var createHmac = require('create-hmac')
10217var crt = require('browserify-rsa')
10218var EC = require('elliptic').ec
10219var BN = require('bn.js')
10220var parseKeys = require('parse-asn1')
10221var curves = require('./curves.json')
10222
10223function sign (hash, key, hashType, signType, tag) {
10224 var priv = parseKeys(key)
10225 if (priv.curve) {
10226 // rsa keys can be interpreted as ecdsa ones in openssl
10227 if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type')
10228 return ecSign(hash, priv)
10229 } else if (priv.type === 'dsa') {
10230 if (signType !== 'dsa') throw new Error('wrong private key type')
10231 return dsaSign(hash, priv, hashType)
10232 } else {
10233 if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type')
10234 }
10235 hash = Buffer.concat([tag, hash])
10236 var len = priv.modulus.byteLength()
10237 var pad = [ 0, 1 ]
10238 while (hash.length + pad.length + 1 < len) pad.push(0xff)
10239 pad.push(0x00)
10240 var i = -1
10241 while (++i < hash.length) pad.push(hash[i])
10242
10243 var out = crt(pad, priv)
10244 return out
10245}
10246
10247function ecSign (hash, priv) {
10248 var curveId = curves[priv.curve.join('.')]
10249 if (!curveId) throw new Error('unknown curve ' + priv.curve.join('.'))
10250
10251 var curve = new EC(curveId)
10252 var key = curve.keyFromPrivate(priv.privateKey)
10253 var out = key.sign(hash)
10254
10255 return new Buffer(out.toDER())
10256}
10257
10258function dsaSign (hash, priv, algo) {
10259 var x = priv.params.priv_key
10260 var p = priv.params.p
10261 var q = priv.params.q
10262 var g = priv.params.g
10263 var r = new BN(0)
10264 var k
10265 var H = bits2int(hash, q).mod(q)
10266 var s = false
10267 var kv = getKey(x, q, hash, algo)
10268 while (s === false) {
10269 k = makeKey(q, kv, algo)
10270 r = makeR(g, k, p, q)
10271 s = k.invm(q).imul(H.add(x.mul(r))).mod(q)
10272 if (s.cmpn(0) === 0) {
10273 s = false
10274 r = new BN(0)
10275 }
10276 }
10277 return toDER(r, s)
10278}
10279
10280function toDER (r, s) {
10281 r = r.toArray()
10282 s = s.toArray()
10283
10284 // Pad values
10285 if (r[0] & 0x80) r = [ 0 ].concat(r)
10286 if (s[0] & 0x80) s = [ 0 ].concat(s)
10287
10288 var total = r.length + s.length + 4
10289 var res = [ 0x30, total, 0x02, r.length ]
10290 res = res.concat(r, [ 0x02, s.length ], s)
10291 return new Buffer(res)
10292}
10293
10294function getKey (x, q, hash, algo) {
10295 x = new Buffer(x.toArray())
10296 if (x.length < q.byteLength()) {
10297 var zeros = new Buffer(q.byteLength() - x.length)
10298 zeros.fill(0)
10299 x = Buffer.concat([ zeros, x ])
10300 }
10301 var hlen = hash.length
10302 var hbits = bits2octets(hash, q)
10303 var v = new Buffer(hlen)
10304 v.fill(1)
10305 var k = new Buffer(hlen)
10306 k.fill(0)
10307 k = createHmac(algo, k).update(v).update(new Buffer([ 0 ])).update(x).update(hbits).digest()
10308 v = createHmac(algo, k).update(v).digest()
10309 k = createHmac(algo, k).update(v).update(new Buffer([ 1 ])).update(x).update(hbits).digest()
10310 v = createHmac(algo, k).update(v).digest()
10311 return { k: k, v: v }
10312}
10313
10314function bits2int (obits, q) {
10315 var bits = new BN(obits)
10316 var shift = (obits.length << 3) - q.bitLength()
10317 if (shift > 0) bits.ishrn(shift)
10318 return bits
10319}
10320
10321function bits2octets (bits, q) {
10322 bits = bits2int(bits, q)
10323 bits = bits.mod(q)
10324 var out = new Buffer(bits.toArray())
10325 if (out.length < q.byteLength()) {
10326 var zeros = new Buffer(q.byteLength() - out.length)
10327 zeros.fill(0)
10328 out = Buffer.concat([ zeros, out ])
10329 }
10330 return out
10331}
10332
10333function makeKey (q, kv, algo) {
10334 var t
10335 var k
10336
10337 do {
10338 t = new Buffer(0)
10339
10340 while (t.length * 8 < q.bitLength()) {
10341 kv.v = createHmac(algo, kv.k).update(kv.v).digest()
10342 t = Buffer.concat([ t, kv.v ])
10343 }
10344
10345 k = bits2int(t, q)
10346 kv.k = createHmac(algo, kv.k).update(kv.v).update(new Buffer([ 0 ])).digest()
10347 kv.v = createHmac(algo, kv.k).update(kv.v).digest()
10348 } while (k.cmp(q) !== -1)
10349
10350 return k
10351}
10352
10353function makeR (g, k, p, q) {
10354 return g.toRed(BN.mont(p)).redPow(k).fromRed().mod(q)
10355}
10356
10357module.exports = sign
10358module.exports.getKey = getKey
10359module.exports.makeKey = makeKey
10360
10361}).call(this,require("buffer").Buffer)
10362},{"./curves.json":47,"bn.js":21,"browserify-rsa":44,"buffer":53,"create-hmac":60,"elliptic":73,"parse-asn1":126}],50:[function(require,module,exports){
10363(function (Buffer){
10364// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js
10365var BN = require('bn.js')
10366var EC = require('elliptic').ec
10367var parseKeys = require('parse-asn1')
10368var curves = require('./curves.json')
10369
10370function verify (sig, hash, key, signType, tag) {
10371 var pub = parseKeys(key)
10372 if (pub.type === 'ec') {
10373 // rsa keys can be interpreted as ecdsa ones in openssl
10374 if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type')
10375 return ecVerify(sig, hash, pub)
10376 } else if (pub.type === 'dsa') {
10377 if (signType !== 'dsa') throw new Error('wrong public key type')
10378 return dsaVerify(sig, hash, pub)
10379 } else {
10380 if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type')
10381 }
10382 hash = Buffer.concat([tag, hash])
10383 var len = pub.modulus.byteLength()
10384 var pad = [ 1 ]
10385 var padNum = 0
10386 while (hash.length + pad.length + 2 < len) {
10387 pad.push(0xff)
10388 padNum++
10389 }
10390 pad.push(0x00)
10391 var i = -1
10392 while (++i < hash.length) {
10393 pad.push(hash[i])
10394 }
10395 pad = new Buffer(pad)
10396 var red = BN.mont(pub.modulus)
10397 sig = new BN(sig).toRed(red)
10398
10399 sig = sig.redPow(new BN(pub.publicExponent))
10400 sig = new Buffer(sig.fromRed().toArray())
10401 var out = padNum < 8 ? 1 : 0
10402 len = Math.min(sig.length, pad.length)
10403 if (sig.length !== pad.length) out = 1
10404
10405 i = -1
10406 while (++i < len) out |= sig[i] ^ pad[i]
10407 return out === 0
10408}
10409
10410function ecVerify (sig, hash, pub) {
10411 var curveId = curves[pub.data.algorithm.curve.join('.')]
10412 if (!curveId) throw new Error('unknown curve ' + pub.data.algorithm.curve.join('.'))
10413
10414 var curve = new EC(curveId)
10415 var pubkey = pub.data.subjectPrivateKey.data
10416
10417 return curve.verify(hash, sig, pubkey)
10418}
10419
10420function dsaVerify (sig, hash, pub) {
10421 var p = pub.data.p
10422 var q = pub.data.q
10423 var g = pub.data.g
10424 var y = pub.data.pub_key
10425 var unpacked = parseKeys.signature.decode(sig, 'der')
10426 var s = unpacked.s
10427 var r = unpacked.r
10428 checkValue(s, q)
10429 checkValue(r, q)
10430 var montp = BN.mont(p)
10431 var w = s.invm(q)
10432 var v = g.toRed(montp)
10433 .redPow(new BN(hash).mul(w).mod(q))
10434 .fromRed()
10435 .mul(y.toRed(montp).redPow(r.mul(w).mod(q)).fromRed())
10436 .mod(p)
10437 .mod(q)
10438 return v.cmp(r) === 0
10439}
10440
10441function checkValue (b, q) {
10442 if (b.cmpn(0) <= 0) throw new Error('invalid sig')
10443 if (b.cmp(q) >= q) throw new Error('invalid sig')
10444}
10445
10446module.exports = verify
10447
10448}).call(this,require("buffer").Buffer)
10449},{"./curves.json":47,"bn.js":21,"buffer":53,"elliptic":73,"parse-asn1":126}],51:[function(require,module,exports){
10450var basex = require('base-x')
10451var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
10452
10453module.exports = basex(ALPHABET)
10454
10455},{"base-x":17}],52:[function(require,module,exports){
10456(function (Buffer){
10457module.exports = function xor (a, b) {
10458 var length = Math.min(a.length, b.length)
10459 var buffer = new Buffer(length)
10460
10461 for (var i = 0; i < length; ++i) {
10462 buffer[i] = a[i] ^ b[i]
10463 }
10464
10465 return buffer
10466}
10467
10468}).call(this,require("buffer").Buffer)
10469},{"buffer":53}],53:[function(require,module,exports){
10470/*!
10471 * The buffer module from node.js, for the browser.
10472 *
10473 * @author Feross Aboukhadijeh <https://feross.org>
10474 * @license MIT
10475 */
10476/* eslint-disable no-proto */
10477
10478'use strict'
10479
10480var base64 = require('base64-js')
10481var ieee754 = require('ieee754')
10482
10483exports.Buffer = Buffer
10484exports.SlowBuffer = SlowBuffer
10485exports.INSPECT_MAX_BYTES = 50
10486
10487var K_MAX_LENGTH = 0x7fffffff
10488exports.kMaxLength = K_MAX_LENGTH
10489
10490/**
10491 * If `Buffer.TYPED_ARRAY_SUPPORT`:
10492 * === true Use Uint8Array implementation (fastest)
10493 * === false Print warning and recommend using `buffer` v4.x which has an Object
10494 * implementation (most compatible, even IE6)
10495 *
10496 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
10497 * Opera 11.6+, iOS 4.2+.
10498 *
10499 * We report that the browser does not support typed arrays if the are not subclassable
10500 * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
10501 * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
10502 * for __proto__ and has a buggy typed array implementation.
10503 */
10504Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
10505
10506if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
10507 typeof console.error === 'function') {
10508 console.error(
10509 'This browser lacks typed array (Uint8Array) support which is required by ' +
10510 '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
10511 )
10512}
10513
10514function typedArraySupport () {
10515 // Can typed array instances can be augmented?
10516 try {
10517 var arr = new Uint8Array(1)
10518 arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
10519 return arr.foo() === 42
10520 } catch (e) {
10521 return false
10522 }
10523}
10524
10525function createBuffer (length) {
10526 if (length > K_MAX_LENGTH) {
10527 throw new RangeError('Invalid typed array length')
10528 }
10529 // Return an augmented `Uint8Array` instance
10530 var buf = new Uint8Array(length)
10531 buf.__proto__ = Buffer.prototype
10532 return buf
10533}
10534
10535/**
10536 * The Buffer constructor returns instances of `Uint8Array` that have their
10537 * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
10538 * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
10539 * and the `Uint8Array` methods. Square bracket notation works as expected -- it
10540 * returns a single octet.
10541 *
10542 * The `Uint8Array` prototype remains unmodified.
10543 */
10544
10545function Buffer (arg, encodingOrOffset, length) {
10546 // Common case.
10547 if (typeof arg === 'number') {
10548 if (typeof encodingOrOffset === 'string') {
10549 throw new Error(
10550 'If encoding is specified then the first argument must be a string'
10551 )
10552 }
10553 return allocUnsafe(arg)
10554 }
10555 return from(arg, encodingOrOffset, length)
10556}
10557
10558// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
10559if (typeof Symbol !== 'undefined' && Symbol.species &&
10560 Buffer[Symbol.species] === Buffer) {
10561 Object.defineProperty(Buffer, Symbol.species, {
10562 value: null,
10563 configurable: true,
10564 enumerable: false,
10565 writable: false
10566 })
10567}
10568
10569Buffer.poolSize = 8192 // not used by this implementation
10570
10571function from (value, encodingOrOffset, length) {
10572 if (typeof value === 'number') {
10573 throw new TypeError('"value" argument must not be a number')
10574 }
10575
10576 if (isArrayBuffer(value)) {
10577 return fromArrayBuffer(value, encodingOrOffset, length)
10578 }
10579
10580 if (typeof value === 'string') {
10581 return fromString(value, encodingOrOffset)
10582 }
10583
10584 return fromObject(value)
10585}
10586
10587/**
10588 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
10589 * if value is a number.
10590 * Buffer.from(str[, encoding])
10591 * Buffer.from(array)
10592 * Buffer.from(buffer)
10593 * Buffer.from(arrayBuffer[, byteOffset[, length]])
10594 **/
10595Buffer.from = function (value, encodingOrOffset, length) {
10596 return from(value, encodingOrOffset, length)
10597}
10598
10599// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
10600// https://github.com/feross/buffer/pull/148
10601Buffer.prototype.__proto__ = Uint8Array.prototype
10602Buffer.__proto__ = Uint8Array
10603
10604function assertSize (size) {
10605 if (typeof size !== 'number') {
10606 throw new TypeError('"size" argument must be a number')
10607 } else if (size < 0) {
10608 throw new RangeError('"size" argument must not be negative')
10609 }
10610}
10611
10612function alloc (size, fill, encoding) {
10613 assertSize(size)
10614 if (size <= 0) {
10615 return createBuffer(size)
10616 }
10617 if (fill !== undefined) {
10618 // Only pay attention to encoding if it's a string. This
10619 // prevents accidentally sending in a number that would
10620 // be interpretted as a start offset.
10621 return typeof encoding === 'string'
10622 ? createBuffer(size).fill(fill, encoding)
10623 : createBuffer(size).fill(fill)
10624 }
10625 return createBuffer(size)
10626}
10627
10628/**
10629 * Creates a new filled Buffer instance.
10630 * alloc(size[, fill[, encoding]])
10631 **/
10632Buffer.alloc = function (size, fill, encoding) {
10633 return alloc(size, fill, encoding)
10634}
10635
10636function allocUnsafe (size) {
10637 assertSize(size)
10638 return createBuffer(size < 0 ? 0 : checked(size) | 0)
10639}
10640
10641/**
10642 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
10643 * */
10644Buffer.allocUnsafe = function (size) {
10645 return allocUnsafe(size)
10646}
10647/**
10648 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
10649 */
10650Buffer.allocUnsafeSlow = function (size) {
10651 return allocUnsafe(size)
10652}
10653
10654function fromString (string, encoding) {
10655 if (typeof encoding !== 'string' || encoding === '') {
10656 encoding = 'utf8'
10657 }
10658
10659 if (!Buffer.isEncoding(encoding)) {
10660 throw new TypeError('"encoding" must be a valid string encoding')
10661 }
10662
10663 var length = byteLength(string, encoding) | 0
10664 var buf = createBuffer(length)
10665
10666 var actual = buf.write(string, encoding)
10667
10668 if (actual !== length) {
10669 // Writing a hex string, for example, that contains invalid characters will
10670 // cause everything after the first invalid character to be ignored. (e.g.
10671 // 'abxxcd' will be treated as 'ab')
10672 buf = buf.slice(0, actual)
10673 }
10674
10675 return buf
10676}
10677
10678function fromArrayLike (array) {
10679 var length = array.length < 0 ? 0 : checked(array.length) | 0
10680 var buf = createBuffer(length)
10681 for (var i = 0; i < length; i += 1) {
10682 buf[i] = array[i] & 255
10683 }
10684 return buf
10685}
10686
10687function fromArrayBuffer (array, byteOffset, length) {
10688 if (byteOffset < 0 || array.byteLength < byteOffset) {
10689 throw new RangeError('\'offset\' is out of bounds')
10690 }
10691
10692 if (array.byteLength < byteOffset + (length || 0)) {
10693 throw new RangeError('\'length\' is out of bounds')
10694 }
10695
10696 var buf
10697 if (byteOffset === undefined && length === undefined) {
10698 buf = new Uint8Array(array)
10699 } else if (length === undefined) {
10700 buf = new Uint8Array(array, byteOffset)
10701 } else {
10702 buf = new Uint8Array(array, byteOffset, length)
10703 }
10704
10705 // Return an augmented `Uint8Array` instance
10706 buf.__proto__ = Buffer.prototype
10707 return buf
10708}
10709
10710function fromObject (obj) {
10711 if (Buffer.isBuffer(obj)) {
10712 var len = checked(obj.length) | 0
10713 var buf = createBuffer(len)
10714
10715 if (buf.length === 0) {
10716 return buf
10717 }
10718
10719 obj.copy(buf, 0, 0, len)
10720 return buf
10721 }
10722
10723 if (obj) {
10724 if (isArrayBufferView(obj) || 'length' in obj) {
10725 if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
10726 return createBuffer(0)
10727 }
10728 return fromArrayLike(obj)
10729 }
10730
10731 if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
10732 return fromArrayLike(obj.data)
10733 }
10734 }
10735
10736 throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
10737}
10738
10739function checked (length) {
10740 // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
10741 // length is NaN (which is otherwise coerced to zero.)
10742 if (length >= K_MAX_LENGTH) {
10743 throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
10744 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
10745 }
10746 return length | 0
10747}
10748
10749function SlowBuffer (length) {
10750 if (+length != length) { // eslint-disable-line eqeqeq
10751 length = 0
10752 }
10753 return Buffer.alloc(+length)
10754}
10755
10756Buffer.isBuffer = function isBuffer (b) {
10757 return b != null && b._isBuffer === true
10758}
10759
10760Buffer.compare = function compare (a, b) {
10761 if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
10762 throw new TypeError('Arguments must be Buffers')
10763 }
10764
10765 if (a === b) return 0
10766
10767 var x = a.length
10768 var y = b.length
10769
10770 for (var i = 0, len = Math.min(x, y); i < len; ++i) {
10771 if (a[i] !== b[i]) {
10772 x = a[i]
10773 y = b[i]
10774 break
10775 }
10776 }
10777
10778 if (x < y) return -1
10779 if (y < x) return 1
10780 return 0
10781}
10782
10783Buffer.isEncoding = function isEncoding (encoding) {
10784 switch (String(encoding).toLowerCase()) {
10785 case 'hex':
10786 case 'utf8':
10787 case 'utf-8':
10788 case 'ascii':
10789 case 'latin1':
10790 case 'binary':
10791 case 'base64':
10792 case 'ucs2':
10793 case 'ucs-2':
10794 case 'utf16le':
10795 case 'utf-16le':
10796 return true
10797 default:
10798 return false
10799 }
10800}
10801
10802Buffer.concat = function concat (list, length) {
10803 if (!Array.isArray(list)) {
10804 throw new TypeError('"list" argument must be an Array of Buffers')
10805 }
10806
10807 if (list.length === 0) {
10808 return Buffer.alloc(0)
10809 }
10810
10811 var i
10812 if (length === undefined) {
10813 length = 0
10814 for (i = 0; i < list.length; ++i) {
10815 length += list[i].length
10816 }
10817 }
10818
10819 var buffer = Buffer.allocUnsafe(length)
10820 var pos = 0
10821 for (i = 0; i < list.length; ++i) {
10822 var buf = list[i]
10823 if (!Buffer.isBuffer(buf)) {
10824 throw new TypeError('"list" argument must be an Array of Buffers')
10825 }
10826 buf.copy(buffer, pos)
10827 pos += buf.length
10828 }
10829 return buffer
10830}
10831
10832function byteLength (string, encoding) {
10833 if (Buffer.isBuffer(string)) {
10834 return string.length
10835 }
10836 if (isArrayBufferView(string) || isArrayBuffer(string)) {
10837 return string.byteLength
10838 }
10839 if (typeof string !== 'string') {
10840 string = '' + string
10841 }
10842
10843 var len = string.length
10844 if (len === 0) return 0
10845
10846 // Use a for loop to avoid recursion
10847 var loweredCase = false
10848 for (;;) {
10849 switch (encoding) {
10850 case 'ascii':
10851 case 'latin1':
10852 case 'binary':
10853 return len
10854 case 'utf8':
10855 case 'utf-8':
10856 case undefined:
10857 return utf8ToBytes(string).length
10858 case 'ucs2':
10859 case 'ucs-2':
10860 case 'utf16le':
10861 case 'utf-16le':
10862 return len * 2
10863 case 'hex':
10864 return len >>> 1
10865 case 'base64':
10866 return base64ToBytes(string).length
10867 default:
10868 if (loweredCase) return utf8ToBytes(string).length // assume utf8
10869 encoding = ('' + encoding).toLowerCase()
10870 loweredCase = true
10871 }
10872 }
10873}
10874Buffer.byteLength = byteLength
10875
10876function slowToString (encoding, start, end) {
10877 var loweredCase = false
10878
10879 // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
10880 // property of a typed array.
10881
10882 // This behaves neither like String nor Uint8Array in that we set start/end
10883 // to their upper/lower bounds if the value passed is out of range.
10884 // undefined is handled specially as per ECMA-262 6th Edition,
10885 // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
10886 if (start === undefined || start < 0) {
10887 start = 0
10888 }
10889 // Return early if start > this.length. Done here to prevent potential uint32
10890 // coercion fail below.
10891 if (start > this.length) {
10892 return ''
10893 }
10894
10895 if (end === undefined || end > this.length) {
10896 end = this.length
10897 }
10898
10899 if (end <= 0) {
10900 return ''
10901 }
10902
10903 // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
10904 end >>>= 0
10905 start >>>= 0
10906
10907 if (end <= start) {
10908 return ''
10909 }
10910
10911 if (!encoding) encoding = 'utf8'
10912
10913 while (true) {
10914 switch (encoding) {
10915 case 'hex':
10916 return hexSlice(this, start, end)
10917
10918 case 'utf8':
10919 case 'utf-8':
10920 return utf8Slice(this, start, end)
10921
10922 case 'ascii':
10923 return asciiSlice(this, start, end)
10924
10925 case 'latin1':
10926 case 'binary':
10927 return latin1Slice(this, start, end)
10928
10929 case 'base64':
10930 return base64Slice(this, start, end)
10931
10932 case 'ucs2':
10933 case 'ucs-2':
10934 case 'utf16le':
10935 case 'utf-16le':
10936 return utf16leSlice(this, start, end)
10937
10938 default:
10939 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
10940 encoding = (encoding + '').toLowerCase()
10941 loweredCase = true
10942 }
10943 }
10944}
10945
10946// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
10947// to detect a Buffer instance. It's not possible to use `instanceof Buffer`
10948// reliably in a browserify context because there could be multiple different
10949// copies of the 'buffer' package in use. This method works even for Buffer
10950// instances that were created from another copy of the `buffer` package.
10951// See: https://github.com/feross/buffer/issues/154
10952Buffer.prototype._isBuffer = true
10953
10954function swap (b, n, m) {
10955 var i = b[n]
10956 b[n] = b[m]
10957 b[m] = i
10958}
10959
10960Buffer.prototype.swap16 = function swap16 () {
10961 var len = this.length
10962 if (len % 2 !== 0) {
10963 throw new RangeError('Buffer size must be a multiple of 16-bits')
10964 }
10965 for (var i = 0; i < len; i += 2) {
10966 swap(this, i, i + 1)
10967 }
10968 return this
10969}
10970
10971Buffer.prototype.swap32 = function swap32 () {
10972 var len = this.length
10973 if (len % 4 !== 0) {
10974 throw new RangeError('Buffer size must be a multiple of 32-bits')
10975 }
10976 for (var i = 0; i < len; i += 4) {
10977 swap(this, i, i + 3)
10978 swap(this, i + 1, i + 2)
10979 }
10980 return this
10981}
10982
10983Buffer.prototype.swap64 = function swap64 () {
10984 var len = this.length
10985 if (len % 8 !== 0) {
10986 throw new RangeError('Buffer size must be a multiple of 64-bits')
10987 }
10988 for (var i = 0; i < len; i += 8) {
10989 swap(this, i, i + 7)
10990 swap(this, i + 1, i + 6)
10991 swap(this, i + 2, i + 5)
10992 swap(this, i + 3, i + 4)
10993 }
10994 return this
10995}
10996
10997Buffer.prototype.toString = function toString () {
10998 var length = this.length
10999 if (length === 0) return ''
11000 if (arguments.length === 0) return utf8Slice(this, 0, length)
11001 return slowToString.apply(this, arguments)
11002}
11003
11004Buffer.prototype.equals = function equals (b) {
11005 if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
11006 if (this === b) return true
11007 return Buffer.compare(this, b) === 0
11008}
11009
11010Buffer.prototype.inspect = function inspect () {
11011 var str = ''
11012 var max = exports.INSPECT_MAX_BYTES
11013 if (this.length > 0) {
11014 str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
11015 if (this.length > max) str += ' ... '
11016 }
11017 return '<Buffer ' + str + '>'
11018}
11019
11020Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
11021 if (!Buffer.isBuffer(target)) {
11022 throw new TypeError('Argument must be a Buffer')
11023 }
11024
11025 if (start === undefined) {
11026 start = 0
11027 }
11028 if (end === undefined) {
11029 end = target ? target.length : 0
11030 }
11031 if (thisStart === undefined) {
11032 thisStart = 0
11033 }
11034 if (thisEnd === undefined) {
11035 thisEnd = this.length
11036 }
11037
11038 if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
11039 throw new RangeError('out of range index')
11040 }
11041
11042 if (thisStart >= thisEnd && start >= end) {
11043 return 0
11044 }
11045 if (thisStart >= thisEnd) {
11046 return -1
11047 }
11048 if (start >= end) {
11049 return 1
11050 }
11051
11052 start >>>= 0
11053 end >>>= 0
11054 thisStart >>>= 0
11055 thisEnd >>>= 0
11056
11057 if (this === target) return 0
11058
11059 var x = thisEnd - thisStart
11060 var y = end - start
11061 var len = Math.min(x, y)
11062
11063 var thisCopy = this.slice(thisStart, thisEnd)
11064 var targetCopy = target.slice(start, end)
11065
11066 for (var i = 0; i < len; ++i) {
11067 if (thisCopy[i] !== targetCopy[i]) {
11068 x = thisCopy[i]
11069 y = targetCopy[i]
11070 break
11071 }
11072 }
11073
11074 if (x < y) return -1
11075 if (y < x) return 1
11076 return 0
11077}
11078
11079// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
11080// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
11081//
11082// Arguments:
11083// - buffer - a Buffer to search
11084// - val - a string, Buffer, or number
11085// - byteOffset - an index into `buffer`; will be clamped to an int32
11086// - encoding - an optional encoding, relevant is val is a string
11087// - dir - true for indexOf, false for lastIndexOf
11088function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
11089 // Empty buffer means no match
11090 if (buffer.length === 0) return -1
11091
11092 // Normalize byteOffset
11093 if (typeof byteOffset === 'string') {
11094 encoding = byteOffset
11095 byteOffset = 0
11096 } else if (byteOffset > 0x7fffffff) {
11097 byteOffset = 0x7fffffff
11098 } else if (byteOffset < -0x80000000) {
11099 byteOffset = -0x80000000
11100 }
11101 byteOffset = +byteOffset // Coerce to Number.
11102 if (numberIsNaN(byteOffset)) {
11103 // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
11104 byteOffset = dir ? 0 : (buffer.length - 1)
11105 }
11106
11107 // Normalize byteOffset: negative offsets start from the end of the buffer
11108 if (byteOffset < 0) byteOffset = buffer.length + byteOffset
11109 if (byteOffset >= buffer.length) {
11110 if (dir) return -1
11111 else byteOffset = buffer.length - 1
11112 } else if (byteOffset < 0) {
11113 if (dir) byteOffset = 0
11114 else return -1
11115 }
11116
11117 // Normalize val
11118 if (typeof val === 'string') {
11119 val = Buffer.from(val, encoding)
11120 }
11121
11122 // Finally, search either indexOf (if dir is true) or lastIndexOf
11123 if (Buffer.isBuffer(val)) {
11124 // Special case: looking for empty string/buffer always fails
11125 if (val.length === 0) {
11126 return -1
11127 }
11128 return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
11129 } else if (typeof val === 'number') {
11130 val = val & 0xFF // Search for a byte value [0-255]
11131 if (typeof Uint8Array.prototype.indexOf === 'function') {
11132 if (dir) {
11133 return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
11134 } else {
11135 return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
11136 }
11137 }
11138 return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
11139 }
11140
11141 throw new TypeError('val must be string, number or Buffer')
11142}
11143
11144function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
11145 var indexSize = 1
11146 var arrLength = arr.length
11147 var valLength = val.length
11148
11149 if (encoding !== undefined) {
11150 encoding = String(encoding).toLowerCase()
11151 if (encoding === 'ucs2' || encoding === 'ucs-2' ||
11152 encoding === 'utf16le' || encoding === 'utf-16le') {
11153 if (arr.length < 2 || val.length < 2) {
11154 return -1
11155 }
11156 indexSize = 2
11157 arrLength /= 2
11158 valLength /= 2
11159 byteOffset /= 2
11160 }
11161 }
11162
11163 function read (buf, i) {
11164 if (indexSize === 1) {
11165 return buf[i]
11166 } else {
11167 return buf.readUInt16BE(i * indexSize)
11168 }
11169 }
11170
11171 var i
11172 if (dir) {
11173 var foundIndex = -1
11174 for (i = byteOffset; i < arrLength; i++) {
11175 if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
11176 if (foundIndex === -1) foundIndex = i
11177 if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
11178 } else {
11179 if (foundIndex !== -1) i -= i - foundIndex
11180 foundIndex = -1
11181 }
11182 }
11183 } else {
11184 if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
11185 for (i = byteOffset; i >= 0; i--) {
11186 var found = true
11187 for (var j = 0; j < valLength; j++) {
11188 if (read(arr, i + j) !== read(val, j)) {
11189 found = false
11190 break
11191 }
11192 }
11193 if (found) return i
11194 }
11195 }
11196
11197 return -1
11198}
11199
11200Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
11201 return this.indexOf(val, byteOffset, encoding) !== -1
11202}
11203
11204Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
11205 return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
11206}
11207
11208Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
11209 return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
11210}
11211
11212function hexWrite (buf, string, offset, length) {
11213 offset = Number(offset) || 0
11214 var remaining = buf.length - offset
11215 if (!length) {
11216 length = remaining
11217 } else {
11218 length = Number(length)
11219 if (length > remaining) {
11220 length = remaining
11221 }
11222 }
11223
11224 // must be an even number of digits
11225 var strLen = string.length
11226 if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
11227
11228 if (length > strLen / 2) {
11229 length = strLen / 2
11230 }
11231 for (var i = 0; i < length; ++i) {
11232 var parsed = parseInt(string.substr(i * 2, 2), 16)
11233 if (numberIsNaN(parsed)) return i
11234 buf[offset + i] = parsed
11235 }
11236 return i
11237}
11238
11239function utf8Write (buf, string, offset, length) {
11240 return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
11241}
11242
11243function asciiWrite (buf, string, offset, length) {
11244 return blitBuffer(asciiToBytes(string), buf, offset, length)
11245}
11246
11247function latin1Write (buf, string, offset, length) {
11248 return asciiWrite(buf, string, offset, length)
11249}
11250
11251function base64Write (buf, string, offset, length) {
11252 return blitBuffer(base64ToBytes(string), buf, offset, length)
11253}
11254
11255function ucs2Write (buf, string, offset, length) {
11256 return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
11257}
11258
11259Buffer.prototype.write = function write (string, offset, length, encoding) {
11260 // Buffer#write(string)
11261 if (offset === undefined) {
11262 encoding = 'utf8'
11263 length = this.length
11264 offset = 0
11265 // Buffer#write(string, encoding)
11266 } else if (length === undefined && typeof offset === 'string') {
11267 encoding = offset
11268 length = this.length
11269 offset = 0
11270 // Buffer#write(string, offset[, length][, encoding])
11271 } else if (isFinite(offset)) {
11272 offset = offset >>> 0
11273 if (isFinite(length)) {
11274 length = length >>> 0
11275 if (encoding === undefined) encoding = 'utf8'
11276 } else {
11277 encoding = length
11278 length = undefined
11279 }
11280 } else {
11281 throw new Error(
11282 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
11283 )
11284 }
11285
11286 var remaining = this.length - offset
11287 if (length === undefined || length > remaining) length = remaining
11288
11289 if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
11290 throw new RangeError('Attempt to write outside buffer bounds')
11291 }
11292
11293 if (!encoding) encoding = 'utf8'
11294
11295 var loweredCase = false
11296 for (;;) {
11297 switch (encoding) {
11298 case 'hex':
11299 return hexWrite(this, string, offset, length)
11300
11301 case 'utf8':
11302 case 'utf-8':
11303 return utf8Write(this, string, offset, length)
11304
11305 case 'ascii':
11306 return asciiWrite(this, string, offset, length)
11307
11308 case 'latin1':
11309 case 'binary':
11310 return latin1Write(this, string, offset, length)
11311
11312 case 'base64':
11313 // Warning: maxLength not taken into account in base64Write
11314 return base64Write(this, string, offset, length)
11315
11316 case 'ucs2':
11317 case 'ucs-2':
11318 case 'utf16le':
11319 case 'utf-16le':
11320 return ucs2Write(this, string, offset, length)
11321
11322 default:
11323 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
11324 encoding = ('' + encoding).toLowerCase()
11325 loweredCase = true
11326 }
11327 }
11328}
11329
11330Buffer.prototype.toJSON = function toJSON () {
11331 return {
11332 type: 'Buffer',
11333 data: Array.prototype.slice.call(this._arr || this, 0)
11334 }
11335}
11336
11337function base64Slice (buf, start, end) {
11338 if (start === 0 && end === buf.length) {
11339 return base64.fromByteArray(buf)
11340 } else {
11341 return base64.fromByteArray(buf.slice(start, end))
11342 }
11343}
11344
11345function utf8Slice (buf, start, end) {
11346 end = Math.min(buf.length, end)
11347 var res = []
11348
11349 var i = start
11350 while (i < end) {
11351 var firstByte = buf[i]
11352 var codePoint = null
11353 var bytesPerSequence = (firstByte > 0xEF) ? 4
11354 : (firstByte > 0xDF) ? 3
11355 : (firstByte > 0xBF) ? 2
11356 : 1
11357
11358 if (i + bytesPerSequence <= end) {
11359 var secondByte, thirdByte, fourthByte, tempCodePoint
11360
11361 switch (bytesPerSequence) {
11362 case 1:
11363 if (firstByte < 0x80) {
11364 codePoint = firstByte
11365 }
11366 break
11367 case 2:
11368 secondByte = buf[i + 1]
11369 if ((secondByte & 0xC0) === 0x80) {
11370 tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
11371 if (tempCodePoint > 0x7F) {
11372 codePoint = tempCodePoint
11373 }
11374 }
11375 break
11376 case 3:
11377 secondByte = buf[i + 1]
11378 thirdByte = buf[i + 2]
11379 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
11380 tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
11381 if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
11382 codePoint = tempCodePoint
11383 }
11384 }
11385 break
11386 case 4:
11387 secondByte = buf[i + 1]
11388 thirdByte = buf[i + 2]
11389 fourthByte = buf[i + 3]
11390 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
11391 tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
11392 if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
11393 codePoint = tempCodePoint
11394 }
11395 }
11396 }
11397 }
11398
11399 if (codePoint === null) {
11400 // we did not generate a valid codePoint so insert a
11401 // replacement char (U+FFFD) and advance only 1 byte
11402 codePoint = 0xFFFD
11403 bytesPerSequence = 1
11404 } else if (codePoint > 0xFFFF) {
11405 // encode to utf16 (surrogate pair dance)
11406 codePoint -= 0x10000
11407 res.push(codePoint >>> 10 & 0x3FF | 0xD800)
11408 codePoint = 0xDC00 | codePoint & 0x3FF
11409 }
11410
11411 res.push(codePoint)
11412 i += bytesPerSequence
11413 }
11414
11415 return decodeCodePointsArray(res)
11416}
11417
11418// Based on http://stackoverflow.com/a/22747272/680742, the browser with
11419// the lowest limit is Chrome, with 0x10000 args.
11420// We go 1 magnitude less, for safety
11421var MAX_ARGUMENTS_LENGTH = 0x1000
11422
11423function decodeCodePointsArray (codePoints) {
11424 var len = codePoints.length
11425 if (len <= MAX_ARGUMENTS_LENGTH) {
11426 return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
11427 }
11428
11429 // Decode in chunks to avoid "call stack size exceeded".
11430 var res = ''
11431 var i = 0
11432 while (i < len) {
11433 res += String.fromCharCode.apply(
11434 String,
11435 codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
11436 )
11437 }
11438 return res
11439}
11440
11441function asciiSlice (buf, start, end) {
11442 var ret = ''
11443 end = Math.min(buf.length, end)
11444
11445 for (var i = start; i < end; ++i) {
11446 ret += String.fromCharCode(buf[i] & 0x7F)
11447 }
11448 return ret
11449}
11450
11451function latin1Slice (buf, start, end) {
11452 var ret = ''
11453 end = Math.min(buf.length, end)
11454
11455 for (var i = start; i < end; ++i) {
11456 ret += String.fromCharCode(buf[i])
11457 }
11458 return ret
11459}
11460
11461function hexSlice (buf, start, end) {
11462 var len = buf.length
11463
11464 if (!start || start < 0) start = 0
11465 if (!end || end < 0 || end > len) end = len
11466
11467 var out = ''
11468 for (var i = start; i < end; ++i) {
11469 out += toHex(buf[i])
11470 }
11471 return out
11472}
11473
11474function utf16leSlice (buf, start, end) {
11475 var bytes = buf.slice(start, end)
11476 var res = ''
11477 for (var i = 0; i < bytes.length; i += 2) {
11478 res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
11479 }
11480 return res
11481}
11482
11483Buffer.prototype.slice = function slice (start, end) {
11484 var len = this.length
11485 start = ~~start
11486 end = end === undefined ? len : ~~end
11487
11488 if (start < 0) {
11489 start += len
11490 if (start < 0) start = 0
11491 } else if (start > len) {
11492 start = len
11493 }
11494
11495 if (end < 0) {
11496 end += len
11497 if (end < 0) end = 0
11498 } else if (end > len) {
11499 end = len
11500 }
11501
11502 if (end < start) end = start
11503
11504 var newBuf = this.subarray(start, end)
11505 // Return an augmented `Uint8Array` instance
11506 newBuf.__proto__ = Buffer.prototype
11507 return newBuf
11508}
11509
11510/*
11511 * Need to make sure that buffer isn't trying to write out of bounds.
11512 */
11513function checkOffset (offset, ext, length) {
11514 if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
11515 if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
11516}
11517
11518Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
11519 offset = offset >>> 0
11520 byteLength = byteLength >>> 0
11521 if (!noAssert) checkOffset(offset, byteLength, this.length)
11522
11523 var val = this[offset]
11524 var mul = 1
11525 var i = 0
11526 while (++i < byteLength && (mul *= 0x100)) {
11527 val += this[offset + i] * mul
11528 }
11529
11530 return val
11531}
11532
11533Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
11534 offset = offset >>> 0
11535 byteLength = byteLength >>> 0
11536 if (!noAssert) {
11537 checkOffset(offset, byteLength, this.length)
11538 }
11539
11540 var val = this[offset + --byteLength]
11541 var mul = 1
11542 while (byteLength > 0 && (mul *= 0x100)) {
11543 val += this[offset + --byteLength] * mul
11544 }
11545
11546 return val
11547}
11548
11549Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
11550 offset = offset >>> 0
11551 if (!noAssert) checkOffset(offset, 1, this.length)
11552 return this[offset]
11553}
11554
11555Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
11556 offset = offset >>> 0
11557 if (!noAssert) checkOffset(offset, 2, this.length)
11558 return this[offset] | (this[offset + 1] << 8)
11559}
11560
11561Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
11562 offset = offset >>> 0
11563 if (!noAssert) checkOffset(offset, 2, this.length)
11564 return (this[offset] << 8) | this[offset + 1]
11565}
11566
11567Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
11568 offset = offset >>> 0
11569 if (!noAssert) checkOffset(offset, 4, this.length)
11570
11571 return ((this[offset]) |
11572 (this[offset + 1] << 8) |
11573 (this[offset + 2] << 16)) +
11574 (this[offset + 3] * 0x1000000)
11575}
11576
11577Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
11578 offset = offset >>> 0
11579 if (!noAssert) checkOffset(offset, 4, this.length)
11580
11581 return (this[offset] * 0x1000000) +
11582 ((this[offset + 1] << 16) |
11583 (this[offset + 2] << 8) |
11584 this[offset + 3])
11585}
11586
11587Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
11588 offset = offset >>> 0
11589 byteLength = byteLength >>> 0
11590 if (!noAssert) checkOffset(offset, byteLength, this.length)
11591
11592 var val = this[offset]
11593 var mul = 1
11594 var i = 0
11595 while (++i < byteLength && (mul *= 0x100)) {
11596 val += this[offset + i] * mul
11597 }
11598 mul *= 0x80
11599
11600 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
11601
11602 return val
11603}
11604
11605Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
11606 offset = offset >>> 0
11607 byteLength = byteLength >>> 0
11608 if (!noAssert) checkOffset(offset, byteLength, this.length)
11609
11610 var i = byteLength
11611 var mul = 1
11612 var val = this[offset + --i]
11613 while (i > 0 && (mul *= 0x100)) {
11614 val += this[offset + --i] * mul
11615 }
11616 mul *= 0x80
11617
11618 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
11619
11620 return val
11621}
11622
11623Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
11624 offset = offset >>> 0
11625 if (!noAssert) checkOffset(offset, 1, this.length)
11626 if (!(this[offset] & 0x80)) return (this[offset])
11627 return ((0xff - this[offset] + 1) * -1)
11628}
11629
11630Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
11631 offset = offset >>> 0
11632 if (!noAssert) checkOffset(offset, 2, this.length)
11633 var val = this[offset] | (this[offset + 1] << 8)
11634 return (val & 0x8000) ? val | 0xFFFF0000 : val
11635}
11636
11637Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
11638 offset = offset >>> 0
11639 if (!noAssert) checkOffset(offset, 2, this.length)
11640 var val = this[offset + 1] | (this[offset] << 8)
11641 return (val & 0x8000) ? val | 0xFFFF0000 : val
11642}
11643
11644Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
11645 offset = offset >>> 0
11646 if (!noAssert) checkOffset(offset, 4, this.length)
11647
11648 return (this[offset]) |
11649 (this[offset + 1] << 8) |
11650 (this[offset + 2] << 16) |
11651 (this[offset + 3] << 24)
11652}
11653
11654Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
11655 offset = offset >>> 0
11656 if (!noAssert) checkOffset(offset, 4, this.length)
11657
11658 return (this[offset] << 24) |
11659 (this[offset + 1] << 16) |
11660 (this[offset + 2] << 8) |
11661 (this[offset + 3])
11662}
11663
11664Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
11665 offset = offset >>> 0
11666 if (!noAssert) checkOffset(offset, 4, this.length)
11667 return ieee754.read(this, offset, true, 23, 4)
11668}
11669
11670Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
11671 offset = offset >>> 0
11672 if (!noAssert) checkOffset(offset, 4, this.length)
11673 return ieee754.read(this, offset, false, 23, 4)
11674}
11675
11676Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
11677 offset = offset >>> 0
11678 if (!noAssert) checkOffset(offset, 8, this.length)
11679 return ieee754.read(this, offset, true, 52, 8)
11680}
11681
11682Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
11683 offset = offset >>> 0
11684 if (!noAssert) checkOffset(offset, 8, this.length)
11685 return ieee754.read(this, offset, false, 52, 8)
11686}
11687
11688function checkInt (buf, value, offset, ext, max, min) {
11689 if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
11690 if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
11691 if (offset + ext > buf.length) throw new RangeError('Index out of range')
11692}
11693
11694Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
11695 value = +value
11696 offset = offset >>> 0
11697 byteLength = byteLength >>> 0
11698 if (!noAssert) {
11699 var maxBytes = Math.pow(2, 8 * byteLength) - 1
11700 checkInt(this, value, offset, byteLength, maxBytes, 0)
11701 }
11702
11703 var mul = 1
11704 var i = 0
11705 this[offset] = value & 0xFF
11706 while (++i < byteLength && (mul *= 0x100)) {
11707 this[offset + i] = (value / mul) & 0xFF
11708 }
11709
11710 return offset + byteLength
11711}
11712
11713Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
11714 value = +value
11715 offset = offset >>> 0
11716 byteLength = byteLength >>> 0
11717 if (!noAssert) {
11718 var maxBytes = Math.pow(2, 8 * byteLength) - 1
11719 checkInt(this, value, offset, byteLength, maxBytes, 0)
11720 }
11721
11722 var i = byteLength - 1
11723 var mul = 1
11724 this[offset + i] = value & 0xFF
11725 while (--i >= 0 && (mul *= 0x100)) {
11726 this[offset + i] = (value / mul) & 0xFF
11727 }
11728
11729 return offset + byteLength
11730}
11731
11732Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
11733 value = +value
11734 offset = offset >>> 0
11735 if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
11736 this[offset] = (value & 0xff)
11737 return offset + 1
11738}
11739
11740Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
11741 value = +value
11742 offset = offset >>> 0
11743 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
11744 this[offset] = (value & 0xff)
11745 this[offset + 1] = (value >>> 8)
11746 return offset + 2
11747}
11748
11749Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
11750 value = +value
11751 offset = offset >>> 0
11752 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
11753 this[offset] = (value >>> 8)
11754 this[offset + 1] = (value & 0xff)
11755 return offset + 2
11756}
11757
11758Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
11759 value = +value
11760 offset = offset >>> 0
11761 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
11762 this[offset + 3] = (value >>> 24)
11763 this[offset + 2] = (value >>> 16)
11764 this[offset + 1] = (value >>> 8)
11765 this[offset] = (value & 0xff)
11766 return offset + 4
11767}
11768
11769Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
11770 value = +value
11771 offset = offset >>> 0
11772 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
11773 this[offset] = (value >>> 24)
11774 this[offset + 1] = (value >>> 16)
11775 this[offset + 2] = (value >>> 8)
11776 this[offset + 3] = (value & 0xff)
11777 return offset + 4
11778}
11779
11780Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
11781 value = +value
11782 offset = offset >>> 0
11783 if (!noAssert) {
11784 var limit = Math.pow(2, (8 * byteLength) - 1)
11785
11786 checkInt(this, value, offset, byteLength, limit - 1, -limit)
11787 }
11788
11789 var i = 0
11790 var mul = 1
11791 var sub = 0
11792 this[offset] = value & 0xFF
11793 while (++i < byteLength && (mul *= 0x100)) {
11794 if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
11795 sub = 1
11796 }
11797 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
11798 }
11799
11800 return offset + byteLength
11801}
11802
11803Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
11804 value = +value
11805 offset = offset >>> 0
11806 if (!noAssert) {
11807 var limit = Math.pow(2, (8 * byteLength) - 1)
11808
11809 checkInt(this, value, offset, byteLength, limit - 1, -limit)
11810 }
11811
11812 var i = byteLength - 1
11813 var mul = 1
11814 var sub = 0
11815 this[offset + i] = value & 0xFF
11816 while (--i >= 0 && (mul *= 0x100)) {
11817 if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
11818 sub = 1
11819 }
11820 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
11821 }
11822
11823 return offset + byteLength
11824}
11825
11826Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
11827 value = +value
11828 offset = offset >>> 0
11829 if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
11830 if (value < 0) value = 0xff + value + 1
11831 this[offset] = (value & 0xff)
11832 return offset + 1
11833}
11834
11835Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
11836 value = +value
11837 offset = offset >>> 0
11838 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
11839 this[offset] = (value & 0xff)
11840 this[offset + 1] = (value >>> 8)
11841 return offset + 2
11842}
11843
11844Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
11845 value = +value
11846 offset = offset >>> 0
11847 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
11848 this[offset] = (value >>> 8)
11849 this[offset + 1] = (value & 0xff)
11850 return offset + 2
11851}
11852
11853Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
11854 value = +value
11855 offset = offset >>> 0
11856 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
11857 this[offset] = (value & 0xff)
11858 this[offset + 1] = (value >>> 8)
11859 this[offset + 2] = (value >>> 16)
11860 this[offset + 3] = (value >>> 24)
11861 return offset + 4
11862}
11863
11864Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
11865 value = +value
11866 offset = offset >>> 0
11867 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
11868 if (value < 0) value = 0xffffffff + value + 1
11869 this[offset] = (value >>> 24)
11870 this[offset + 1] = (value >>> 16)
11871 this[offset + 2] = (value >>> 8)
11872 this[offset + 3] = (value & 0xff)
11873 return offset + 4
11874}
11875
11876function checkIEEE754 (buf, value, offset, ext, max, min) {
11877 if (offset + ext > buf.length) throw new RangeError('Index out of range')
11878 if (offset < 0) throw new RangeError('Index out of range')
11879}
11880
11881function writeFloat (buf, value, offset, littleEndian, noAssert) {
11882 value = +value
11883 offset = offset >>> 0
11884 if (!noAssert) {
11885 checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
11886 }
11887 ieee754.write(buf, value, offset, littleEndian, 23, 4)
11888 return offset + 4
11889}
11890
11891Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
11892 return writeFloat(this, value, offset, true, noAssert)
11893}
11894
11895Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
11896 return writeFloat(this, value, offset, false, noAssert)
11897}
11898
11899function writeDouble (buf, value, offset, littleEndian, noAssert) {
11900 value = +value
11901 offset = offset >>> 0
11902 if (!noAssert) {
11903 checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
11904 }
11905 ieee754.write(buf, value, offset, littleEndian, 52, 8)
11906 return offset + 8
11907}
11908
11909Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
11910 return writeDouble(this, value, offset, true, noAssert)
11911}
11912
11913Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
11914 return writeDouble(this, value, offset, false, noAssert)
11915}
11916
11917// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
11918Buffer.prototype.copy = function copy (target, targetStart, start, end) {
11919 if (!start) start = 0
11920 if (!end && end !== 0) end = this.length
11921 if (targetStart >= target.length) targetStart = target.length
11922 if (!targetStart) targetStart = 0
11923 if (end > 0 && end < start) end = start
11924
11925 // Copy 0 bytes; we're done
11926 if (end === start) return 0
11927 if (target.length === 0 || this.length === 0) return 0
11928
11929 // Fatal error conditions
11930 if (targetStart < 0) {
11931 throw new RangeError('targetStart out of bounds')
11932 }
11933 if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
11934 if (end < 0) throw new RangeError('sourceEnd out of bounds')
11935
11936 // Are we oob?
11937 if (end > this.length) end = this.length
11938 if (target.length - targetStart < end - start) {
11939 end = target.length - targetStart + start
11940 }
11941
11942 var len = end - start
11943 var i
11944
11945 if (this === target && start < targetStart && targetStart < end) {
11946 // descending copy from end
11947 for (i = len - 1; i >= 0; --i) {
11948 target[i + targetStart] = this[i + start]
11949 }
11950 } else if (len < 1000) {
11951 // ascending copy from start
11952 for (i = 0; i < len; ++i) {
11953 target[i + targetStart] = this[i + start]
11954 }
11955 } else {
11956 Uint8Array.prototype.set.call(
11957 target,
11958 this.subarray(start, start + len),
11959 targetStart
11960 )
11961 }
11962
11963 return len
11964}
11965
11966// Usage:
11967// buffer.fill(number[, offset[, end]])
11968// buffer.fill(buffer[, offset[, end]])
11969// buffer.fill(string[, offset[, end]][, encoding])
11970Buffer.prototype.fill = function fill (val, start, end, encoding) {
11971 // Handle string cases:
11972 if (typeof val === 'string') {
11973 if (typeof start === 'string') {
11974 encoding = start
11975 start = 0
11976 end = this.length
11977 } else if (typeof end === 'string') {
11978 encoding = end
11979 end = this.length
11980 }
11981 if (val.length === 1) {
11982 var code = val.charCodeAt(0)
11983 if (code < 256) {
11984 val = code
11985 }
11986 }
11987 if (encoding !== undefined && typeof encoding !== 'string') {
11988 throw new TypeError('encoding must be a string')
11989 }
11990 if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
11991 throw new TypeError('Unknown encoding: ' + encoding)
11992 }
11993 } else if (typeof val === 'number') {
11994 val = val & 255
11995 }
11996
11997 // Invalid ranges are not set to a default, so can range check early.
11998 if (start < 0 || this.length < start || this.length < end) {
11999 throw new RangeError('Out of range index')
12000 }
12001
12002 if (end <= start) {
12003 return this
12004 }
12005
12006 start = start >>> 0
12007 end = end === undefined ? this.length : end >>> 0
12008
12009 if (!val) val = 0
12010
12011 var i
12012 if (typeof val === 'number') {
12013 for (i = start; i < end; ++i) {
12014 this[i] = val
12015 }
12016 } else {
12017 var bytes = Buffer.isBuffer(val)
12018 ? val
12019 : new Buffer(val, encoding)
12020 var len = bytes.length
12021 for (i = 0; i < end - start; ++i) {
12022 this[i + start] = bytes[i % len]
12023 }
12024 }
12025
12026 return this
12027}
12028
12029// HELPER FUNCTIONS
12030// ================
12031
12032var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
12033
12034function base64clean (str) {
12035 // Node strips out invalid characters like \n and \t from the string, base64-js does not
12036 str = str.trim().replace(INVALID_BASE64_RE, '')
12037 // Node converts strings with length < 2 to ''
12038 if (str.length < 2) return ''
12039 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
12040 while (str.length % 4 !== 0) {
12041 str = str + '='
12042 }
12043 return str
12044}
12045
12046function toHex (n) {
12047 if (n < 16) return '0' + n.toString(16)
12048 return n.toString(16)
12049}
12050
12051function utf8ToBytes (string, units) {
12052 units = units || Infinity
12053 var codePoint
12054 var length = string.length
12055 var leadSurrogate = null
12056 var bytes = []
12057
12058 for (var i = 0; i < length; ++i) {
12059 codePoint = string.charCodeAt(i)
12060
12061 // is surrogate component
12062 if (codePoint > 0xD7FF && codePoint < 0xE000) {
12063 // last char was a lead
12064 if (!leadSurrogate) {
12065 // no lead yet
12066 if (codePoint > 0xDBFF) {
12067 // unexpected trail
12068 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
12069 continue
12070 } else if (i + 1 === length) {
12071 // unpaired lead
12072 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
12073 continue
12074 }
12075
12076 // valid lead
12077 leadSurrogate = codePoint
12078
12079 continue
12080 }
12081
12082 // 2 leads in a row
12083 if (codePoint < 0xDC00) {
12084 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
12085 leadSurrogate = codePoint
12086 continue
12087 }
12088
12089 // valid surrogate pair
12090 codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
12091 } else if (leadSurrogate) {
12092 // valid bmp char, but last char was a lead
12093 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
12094 }
12095
12096 leadSurrogate = null
12097
12098 // encode utf8
12099 if (codePoint < 0x80) {
12100 if ((units -= 1) < 0) break
12101 bytes.push(codePoint)
12102 } else if (codePoint < 0x800) {
12103 if ((units -= 2) < 0) break
12104 bytes.push(
12105 codePoint >> 0x6 | 0xC0,
12106 codePoint & 0x3F | 0x80
12107 )
12108 } else if (codePoint < 0x10000) {
12109 if ((units -= 3) < 0) break
12110 bytes.push(
12111 codePoint >> 0xC | 0xE0,
12112 codePoint >> 0x6 & 0x3F | 0x80,
12113 codePoint & 0x3F | 0x80
12114 )
12115 } else if (codePoint < 0x110000) {
12116 if ((units -= 4) < 0) break
12117 bytes.push(
12118 codePoint >> 0x12 | 0xF0,
12119 codePoint >> 0xC & 0x3F | 0x80,
12120 codePoint >> 0x6 & 0x3F | 0x80,
12121 codePoint & 0x3F | 0x80
12122 )
12123 } else {
12124 throw new Error('Invalid code point')
12125 }
12126 }
12127
12128 return bytes
12129}
12130
12131function asciiToBytes (str) {
12132 var byteArray = []
12133 for (var i = 0; i < str.length; ++i) {
12134 // Node's code seems to be doing this and not & 0x7F..
12135 byteArray.push(str.charCodeAt(i) & 0xFF)
12136 }
12137 return byteArray
12138}
12139
12140function utf16leToBytes (str, units) {
12141 var c, hi, lo
12142 var byteArray = []
12143 for (var i = 0; i < str.length; ++i) {
12144 if ((units -= 2) < 0) break
12145
12146 c = str.charCodeAt(i)
12147 hi = c >> 8
12148 lo = c % 256
12149 byteArray.push(lo)
12150 byteArray.push(hi)
12151 }
12152
12153 return byteArray
12154}
12155
12156function base64ToBytes (str) {
12157 return base64.toByteArray(base64clean(str))
12158}
12159
12160function blitBuffer (src, dst, offset, length) {
12161 for (var i = 0; i < length; ++i) {
12162 if ((i + offset >= dst.length) || (i >= src.length)) break
12163 dst[i + offset] = src[i]
12164 }
12165 return i
12166}
12167
12168// ArrayBuffers from another context (i.e. an iframe) do not pass the `instanceof` check
12169// but they should be treated as valid. See: https://github.com/feross/buffer/issues/166
12170function isArrayBuffer (obj) {
12171 return obj instanceof ArrayBuffer ||
12172 (obj != null && obj.constructor != null && obj.constructor.name === 'ArrayBuffer' &&
12173 typeof obj.byteLength === 'number')
12174}
12175
12176// Node 0.10 supports `ArrayBuffer` but lacks `ArrayBuffer.isView`
12177function isArrayBufferView (obj) {
12178 return (typeof ArrayBuffer.isView === 'function') && ArrayBuffer.isView(obj)
12179}
12180
12181function numberIsNaN (obj) {
12182 return obj !== obj // eslint-disable-line no-self-compare
12183}
12184
12185},{"base64-js":18,"ieee754":105}],54:[function(require,module,exports){
12186var Buffer = require('safe-buffer').Buffer
12187var Transform = require('stream').Transform
12188var StringDecoder = require('string_decoder').StringDecoder
12189var inherits = require('inherits')
12190
12191function CipherBase (hashMode) {
12192 Transform.call(this)
12193 this.hashMode = typeof hashMode === 'string'
12194 if (this.hashMode) {
12195 this[hashMode] = this._finalOrDigest
12196 } else {
12197 this.final = this._finalOrDigest
12198 }
12199 if (this._final) {
12200 this.__final = this._final
12201 this._final = null
12202 }
12203 this._decoder = null
12204 this._encoding = null
12205}
12206inherits(CipherBase, Transform)
12207
12208CipherBase.prototype.update = function (data, inputEnc, outputEnc) {
12209 if (typeof data === 'string') {
12210 data = Buffer.from(data, inputEnc)
12211 }
12212
12213 var outData = this._update(data)
12214 if (this.hashMode) return this
12215
12216 if (outputEnc) {
12217 outData = this._toString(outData, outputEnc)
12218 }
12219
12220 return outData
12221}
12222
12223CipherBase.prototype.setAutoPadding = function () {}
12224CipherBase.prototype.getAuthTag = function () {
12225 throw new Error('trying to get auth tag in unsupported state')
12226}
12227
12228CipherBase.prototype.setAuthTag = function () {
12229 throw new Error('trying to set auth tag in unsupported state')
12230}
12231
12232CipherBase.prototype.setAAD = function () {
12233 throw new Error('trying to set aad in unsupported state')
12234}
12235
12236CipherBase.prototype._transform = function (data, _, next) {
12237 var err
12238 try {
12239 if (this.hashMode) {
12240 this._update(data)
12241 } else {
12242 this.push(this._update(data))
12243 }
12244 } catch (e) {
12245 err = e
12246 } finally {
12247 next(err)
12248 }
12249}
12250CipherBase.prototype._flush = function (done) {
12251 var err
12252 try {
12253 this.push(this.__final())
12254 } catch (e) {
12255 err = e
12256 }
12257
12258 done(err)
12259}
12260CipherBase.prototype._finalOrDigest = function (outputEnc) {
12261 var outData = this.__final() || Buffer.alloc(0)
12262 if (outputEnc) {
12263 outData = this._toString(outData, outputEnc, true)
12264 }
12265 return outData
12266}
12267
12268CipherBase.prototype._toString = function (value, enc, fin) {
12269 if (!this._decoder) {
12270 this._decoder = new StringDecoder(enc)
12271 this._encoding = enc
12272 }
12273
12274 if (this._encoding !== enc) throw new Error('can\'t switch encodings')
12275
12276 var out = this._decoder.write(value)
12277 if (fin) {
12278 out += this._decoder.end()
12279 }
12280
12281 return out
12282}
12283
12284module.exports = CipherBase
12285
12286},{"inherits":107,"safe-buffer":156,"stream":172,"string_decoder":173}],55:[function(require,module,exports){
12287(function (Buffer){
12288// Copyright Joyent, Inc. and other Node contributors.
12289//
12290// Permission is hereby granted, free of charge, to any person obtaining a
12291// copy of this software and associated documentation files (the
12292// "Software"), to deal in the Software without restriction, including
12293// without limitation the rights to use, copy, modify, merge, publish,
12294// distribute, sublicense, and/or sell copies of the Software, and to permit
12295// persons to whom the Software is furnished to do so, subject to the
12296// following conditions:
12297//
12298// The above copyright notice and this permission notice shall be included
12299// in all copies or substantial portions of the Software.
12300//
12301// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
12302// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
12303// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
12304// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
12305// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
12306// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
12307// USE OR OTHER DEALINGS IN THE SOFTWARE.
12308
12309// NOTE: These type checking functions intentionally don't use `instanceof`
12310// because it is fragile and can be easily faked with `Object.create()`.
12311
12312function isArray(arg) {
12313 if (Array.isArray) {
12314 return Array.isArray(arg);
12315 }
12316 return objectToString(arg) === '[object Array]';
12317}
12318exports.isArray = isArray;
12319
12320function isBoolean(arg) {
12321 return typeof arg === 'boolean';
12322}
12323exports.isBoolean = isBoolean;
12324
12325function isNull(arg) {
12326 return arg === null;
12327}
12328exports.isNull = isNull;
12329
12330function isNullOrUndefined(arg) {
12331 return arg == null;
12332}
12333exports.isNullOrUndefined = isNullOrUndefined;
12334
12335function isNumber(arg) {
12336 return typeof arg === 'number';
12337}
12338exports.isNumber = isNumber;
12339
12340function isString(arg) {
12341 return typeof arg === 'string';
12342}
12343exports.isString = isString;
12344
12345function isSymbol(arg) {
12346 return typeof arg === 'symbol';
12347}
12348exports.isSymbol = isSymbol;
12349
12350function isUndefined(arg) {
12351 return arg === void 0;
12352}
12353exports.isUndefined = isUndefined;
12354
12355function isRegExp(re) {
12356 return objectToString(re) === '[object RegExp]';
12357}
12358exports.isRegExp = isRegExp;
12359
12360function isObject(arg) {
12361 return typeof arg === 'object' && arg !== null;
12362}
12363exports.isObject = isObject;
12364
12365function isDate(d) {
12366 return objectToString(d) === '[object Date]';
12367}
12368exports.isDate = isDate;
12369
12370function isError(e) {
12371 return (objectToString(e) === '[object Error]' || e instanceof Error);
12372}
12373exports.isError = isError;
12374
12375function isFunction(arg) {
12376 return typeof arg === 'function';
12377}
12378exports.isFunction = isFunction;
12379
12380function isPrimitive(arg) {
12381 return arg === null ||
12382 typeof arg === 'boolean' ||
12383 typeof arg === 'number' ||
12384 typeof arg === 'string' ||
12385 typeof arg === 'symbol' || // ES6 symbol
12386 typeof arg === 'undefined';
12387}
12388exports.isPrimitive = isPrimitive;
12389
12390exports.isBuffer = Buffer.isBuffer;
12391
12392function objectToString(o) {
12393 return Object.prototype.toString.call(o);
12394}
12395
12396}).call(this,{"isBuffer":require("../../is-buffer/index.js")})
12397},{"../../is-buffer/index.js":108}],56:[function(require,module,exports){
12398(function (Buffer){
12399var elliptic = require('elliptic');
12400var BN = require('bn.js');
12401
12402module.exports = function createECDH(curve) {
12403 return new ECDH(curve);
12404};
12405
12406var aliases = {
12407 secp256k1: {
12408 name: 'secp256k1',
12409 byteLength: 32
12410 },
12411 secp224r1: {
12412 name: 'p224',
12413 byteLength: 28
12414 },
12415 prime256v1: {
12416 name: 'p256',
12417 byteLength: 32
12418 },
12419 prime192v1: {
12420 name: 'p192',
12421 byteLength: 24
12422 },
12423 ed25519: {
12424 name: 'ed25519',
12425 byteLength: 32
12426 },
12427 secp384r1: {
12428 name: 'p384',
12429 byteLength: 48
12430 },
12431 secp521r1: {
12432 name: 'p521',
12433 byteLength: 66
12434 }
12435};
12436
12437aliases.p224 = aliases.secp224r1;
12438aliases.p256 = aliases.secp256r1 = aliases.prime256v1;
12439aliases.p192 = aliases.secp192r1 = aliases.prime192v1;
12440aliases.p384 = aliases.secp384r1;
12441aliases.p521 = aliases.secp521r1;
12442
12443function ECDH(curve) {
12444 this.curveType = aliases[curve];
12445 if (!this.curveType ) {
12446 this.curveType = {
12447 name: curve
12448 };
12449 }
12450 this.curve = new elliptic.ec(this.curveType.name);
12451 this.keys = void 0;
12452}
12453
12454ECDH.prototype.generateKeys = function (enc, format) {
12455 this.keys = this.curve.genKeyPair();
12456 return this.getPublicKey(enc, format);
12457};
12458
12459ECDH.prototype.computeSecret = function (other, inenc, enc) {
12460 inenc = inenc || 'utf8';
12461 if (!Buffer.isBuffer(other)) {
12462 other = new Buffer(other, inenc);
12463 }
12464 var otherPub = this.curve.keyFromPublic(other).getPublic();
12465 var out = otherPub.mul(this.keys.getPrivate()).getX();
12466 return formatReturnValue(out, enc, this.curveType.byteLength);
12467};
12468
12469ECDH.prototype.getPublicKey = function (enc, format) {
12470 var key = this.keys.getPublic(format === 'compressed', true);
12471 if (format === 'hybrid') {
12472 if (key[key.length - 1] % 2) {
12473 key[0] = 7;
12474 } else {
12475 key [0] = 6;
12476 }
12477 }
12478 return formatReturnValue(key, enc);
12479};
12480
12481ECDH.prototype.getPrivateKey = function (enc) {
12482 return formatReturnValue(this.keys.getPrivate(), enc);
12483};
12484
12485ECDH.prototype.setPublicKey = function (pub, enc) {
12486 enc = enc || 'utf8';
12487 if (!Buffer.isBuffer(pub)) {
12488 pub = new Buffer(pub, enc);
12489 }
12490 this.keys._importPublic(pub);
12491 return this;
12492};
12493
12494ECDH.prototype.setPrivateKey = function (priv, enc) {
12495 enc = enc || 'utf8';
12496 if (!Buffer.isBuffer(priv)) {
12497 priv = new Buffer(priv, enc);
12498 }
12499 var _priv = new BN(priv);
12500 _priv = _priv.toString(16);
12501 this.keys._importPrivate(_priv);
12502 return this;
12503};
12504
12505function formatReturnValue(bn, enc, len) {
12506 if (!Array.isArray(bn)) {
12507 bn = bn.toArray();
12508 }
12509 var buf = new Buffer(bn);
12510 if (len && buf.length < len) {
12511 var zeros = new Buffer(len - buf.length);
12512 zeros.fill(0);
12513 buf = Buffer.concat([zeros, buf]);
12514 }
12515 if (!enc) {
12516 return buf;
12517 } else {
12518 return buf.toString(enc);
12519 }
12520}
12521
12522}).call(this,require("buffer").Buffer)
12523},{"bn.js":21,"buffer":53,"elliptic":73}],57:[function(require,module,exports){
12524(function (Buffer){
12525'use strict'
12526var inherits = require('inherits')
12527var md5 = require('./md5')
12528var RIPEMD160 = require('ripemd160')
12529var sha = require('sha.js')
12530
12531var Base = require('cipher-base')
12532
12533function HashNoConstructor (hash) {
12534 Base.call(this, 'digest')
12535
12536 this._hash = hash
12537 this.buffers = []
12538}
12539
12540inherits(HashNoConstructor, Base)
12541
12542HashNoConstructor.prototype._update = function (data) {
12543 this.buffers.push(data)
12544}
12545
12546HashNoConstructor.prototype._final = function () {
12547 var buf = Buffer.concat(this.buffers)
12548 var r = this._hash(buf)
12549 this.buffers = null
12550
12551 return r
12552}
12553
12554function Hash (hash) {
12555 Base.call(this, 'digest')
12556
12557 this._hash = hash
12558}
12559
12560inherits(Hash, Base)
12561
12562Hash.prototype._update = function (data) {
12563 this._hash.update(data)
12564}
12565
12566Hash.prototype._final = function () {
12567 return this._hash.digest()
12568}
12569
12570module.exports = function createHash (alg) {
12571 alg = alg.toLowerCase()
12572 if (alg === 'md5') return new HashNoConstructor(md5)
12573 if (alg === 'rmd160' || alg === 'ripemd160') return new Hash(new RIPEMD160())
12574
12575 return new Hash(sha(alg))
12576}
12577
12578}).call(this,require("buffer").Buffer)
12579},{"./md5":59,"buffer":53,"cipher-base":54,"inherits":107,"ripemd160":155,"sha.js":165}],58:[function(require,module,exports){
12580(function (Buffer){
12581'use strict'
12582var intSize = 4
12583var zeroBuffer = new Buffer(intSize)
12584zeroBuffer.fill(0)
12585
12586var charSize = 8
12587var hashSize = 16
12588
12589function toArray (buf) {
12590 if ((buf.length % intSize) !== 0) {
12591 var len = buf.length + (intSize - (buf.length % intSize))
12592 buf = Buffer.concat([buf, zeroBuffer], len)
12593 }
12594
12595 var arr = new Array(buf.length >>> 2)
12596 for (var i = 0, j = 0; i < buf.length; i += intSize, j++) {
12597 arr[j] = buf.readInt32LE(i)
12598 }
12599
12600 return arr
12601}
12602
12603module.exports = function hash (buf, fn) {
12604 var arr = fn(toArray(buf), buf.length * charSize)
12605 buf = new Buffer(hashSize)
12606 for (var i = 0; i < arr.length; i++) {
12607 buf.writeInt32LE(arr[i], i << 2, true)
12608 }
12609 return buf
12610}
12611
12612}).call(this,require("buffer").Buffer)
12613},{"buffer":53}],59:[function(require,module,exports){
12614'use strict'
12615/*
12616 * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
12617 * Digest Algorithm, as defined in RFC 1321.
12618 * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
12619 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
12620 * Distributed under the BSD License
12621 * See http://pajhome.org.uk/crypt/md5 for more info.
12622 */
12623
12624var makeHash = require('./make-hash')
12625
12626/*
12627 * Calculate the MD5 of an array of little-endian words, and a bit length
12628 */
12629function core_md5 (x, len) {
12630 /* append padding */
12631 x[len >> 5] |= 0x80 << ((len) % 32)
12632 x[(((len + 64) >>> 9) << 4) + 14] = len
12633
12634 var a = 1732584193
12635 var b = -271733879
12636 var c = -1732584194
12637 var d = 271733878
12638
12639 for (var i = 0; i < x.length; i += 16) {
12640 var olda = a
12641 var oldb = b
12642 var oldc = c
12643 var oldd = d
12644
12645 a = md5_ff(a, b, c, d, x[i + 0], 7, -680876936)
12646 d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586)
12647 c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819)
12648 b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330)
12649 a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897)
12650 d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426)
12651 c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341)
12652 b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983)
12653 a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416)
12654 d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417)
12655 c = md5_ff(c, d, a, b, x[i + 10], 17, -42063)
12656 b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162)
12657 a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682)
12658 d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101)
12659 c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290)
12660 b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329)
12661
12662 a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510)
12663 d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632)
12664 c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713)
12665 b = md5_gg(b, c, d, a, x[i + 0], 20, -373897302)
12666 a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691)
12667 d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083)
12668 c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335)
12669 b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848)
12670 a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438)
12671 d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690)
12672 c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961)
12673 b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501)
12674 a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467)
12675 d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784)
12676 c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473)
12677 b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734)
12678
12679 a = md5_hh(a, b, c, d, x[i + 5], 4, -378558)
12680 d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463)
12681 c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562)
12682 b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556)
12683 a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060)
12684 d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353)
12685 c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632)
12686 b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640)
12687 a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174)
12688 d = md5_hh(d, a, b, c, x[i + 0], 11, -358537222)
12689 c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979)
12690 b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189)
12691 a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487)
12692 d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835)
12693 c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520)
12694 b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651)
12695
12696 a = md5_ii(a, b, c, d, x[i + 0], 6, -198630844)
12697 d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415)
12698 c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905)
12699 b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055)
12700 a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571)
12701 d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606)
12702 c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523)
12703 b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799)
12704 a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359)
12705 d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744)
12706 c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380)
12707 b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649)
12708 a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070)
12709 d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379)
12710 c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259)
12711 b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551)
12712
12713 a = safe_add(a, olda)
12714 b = safe_add(b, oldb)
12715 c = safe_add(c, oldc)
12716 d = safe_add(d, oldd)
12717 }
12718
12719 return [a, b, c, d]
12720}
12721
12722/*
12723 * These functions implement the four basic operations the algorithm uses.
12724 */
12725function md5_cmn (q, a, b, x, s, t) {
12726 return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b)
12727}
12728
12729function md5_ff (a, b, c, d, x, s, t) {
12730 return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t)
12731}
12732
12733function md5_gg (a, b, c, d, x, s, t) {
12734 return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t)
12735}
12736
12737function md5_hh (a, b, c, d, x, s, t) {
12738 return md5_cmn(b ^ c ^ d, a, b, x, s, t)
12739}
12740
12741function md5_ii (a, b, c, d, x, s, t) {
12742 return md5_cmn(c ^ (b | (~d)), a, b, x, s, t)
12743}
12744
12745/*
12746 * Add integers, wrapping at 2^32. This uses 16-bit operations internally
12747 * to work around bugs in some JS interpreters.
12748 */
12749function safe_add (x, y) {
12750 var lsw = (x & 0xFFFF) + (y & 0xFFFF)
12751 var msw = (x >> 16) + (y >> 16) + (lsw >> 16)
12752 return (msw << 16) | (lsw & 0xFFFF)
12753}
12754
12755/*
12756 * Bitwise rotate a 32-bit number to the left.
12757 */
12758function bit_rol (num, cnt) {
12759 return (num << cnt) | (num >>> (32 - cnt))
12760}
12761
12762module.exports = function md5 (buf) {
12763 return makeHash(buf, core_md5)
12764}
12765
12766},{"./make-hash":58}],60:[function(require,module,exports){
12767'use strict'
12768var inherits = require('inherits')
12769var Legacy = require('./legacy')
12770var Base = require('cipher-base')
12771var Buffer = require('safe-buffer').Buffer
12772var md5 = require('create-hash/md5')
12773var RIPEMD160 = require('ripemd160')
12774
12775var sha = require('sha.js')
12776
12777var ZEROS = Buffer.alloc(128)
12778
12779function Hmac (alg, key) {
12780 Base.call(this, 'digest')
12781 if (typeof key === 'string') {
12782 key = Buffer.from(key)
12783 }
12784
12785 var blocksize = (alg === 'sha512' || alg === 'sha384') ? 128 : 64
12786
12787 this._alg = alg
12788 this._key = key
12789 if (key.length > blocksize) {
12790 var hash = alg === 'rmd160' ? new RIPEMD160() : sha(alg)
12791 key = hash.update(key).digest()
12792 } else if (key.length < blocksize) {
12793 key = Buffer.concat([key, ZEROS], blocksize)
12794 }
12795
12796 var ipad = this._ipad = Buffer.allocUnsafe(blocksize)
12797 var opad = this._opad = Buffer.allocUnsafe(blocksize)
12798
12799 for (var i = 0; i < blocksize; i++) {
12800 ipad[i] = key[i] ^ 0x36
12801 opad[i] = key[i] ^ 0x5C
12802 }
12803 this._hash = alg === 'rmd160' ? new RIPEMD160() : sha(alg)
12804 this._hash.update(ipad)
12805}
12806
12807inherits(Hmac, Base)
12808
12809Hmac.prototype._update = function (data) {
12810 this._hash.update(data)
12811}
12812
12813Hmac.prototype._final = function () {
12814 var h = this._hash.digest()
12815 var hash = this._alg === 'rmd160' ? new RIPEMD160() : sha(this._alg)
12816 return hash.update(this._opad).update(h).digest()
12817}
12818
12819module.exports = function createHmac (alg, key) {
12820 alg = alg.toLowerCase()
12821 if (alg === 'rmd160' || alg === 'ripemd160') {
12822 return new Hmac('rmd160', key)
12823 }
12824 if (alg === 'md5') {
12825 return new Legacy(md5, key)
12826 }
12827 return new Hmac(alg, key)
12828}
12829
12830},{"./legacy":61,"cipher-base":54,"create-hash/md5":59,"inherits":107,"ripemd160":155,"safe-buffer":156,"sha.js":165}],61:[function(require,module,exports){
12831'use strict'
12832var inherits = require('inherits')
12833var Buffer = require('safe-buffer').Buffer
12834
12835var Base = require('cipher-base')
12836
12837var ZEROS = Buffer.alloc(128)
12838var blocksize = 64
12839
12840function Hmac (alg, key) {
12841 Base.call(this, 'digest')
12842 if (typeof key === 'string') {
12843 key = Buffer.from(key)
12844 }
12845
12846 this._alg = alg
12847 this._key = key
12848
12849 if (key.length > blocksize) {
12850 key = alg(key)
12851 } else if (key.length < blocksize) {
12852 key = Buffer.concat([key, ZEROS], blocksize)
12853 }
12854
12855 var ipad = this._ipad = Buffer.allocUnsafe(blocksize)
12856 var opad = this._opad = Buffer.allocUnsafe(blocksize)
12857
12858 for (var i = 0; i < blocksize; i++) {
12859 ipad[i] = key[i] ^ 0x36
12860 opad[i] = key[i] ^ 0x5C
12861 }
12862
12863 this._hash = [ipad]
12864}
12865
12866inherits(Hmac, Base)
12867
12868Hmac.prototype._update = function (data) {
12869 this._hash.push(data)
12870}
12871
12872Hmac.prototype._final = function () {
12873 var h = this._alg(Buffer.concat(this._hash))
12874 return this._alg(Buffer.concat([this._opad, h]))
12875}
12876module.exports = Hmac
12877
12878},{"cipher-base":54,"inherits":107,"safe-buffer":156}],62:[function(require,module,exports){
12879'use strict'
12880
12881exports.randomBytes = exports.rng = exports.pseudoRandomBytes = exports.prng = require('randombytes')
12882exports.createHash = exports.Hash = require('create-hash')
12883exports.createHmac = exports.Hmac = require('create-hmac')
12884
12885var algos = require('browserify-sign/algos')
12886var algoKeys = Object.keys(algos)
12887var hashes = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160'].concat(algoKeys)
12888exports.getHashes = function () {
12889 return hashes
12890}
12891
12892var p = require('pbkdf2')
12893exports.pbkdf2 = p.pbkdf2
12894exports.pbkdf2Sync = p.pbkdf2Sync
12895
12896var aes = require('browserify-cipher')
12897
12898exports.Cipher = aes.Cipher
12899exports.createCipher = aes.createCipher
12900exports.Cipheriv = aes.Cipheriv
12901exports.createCipheriv = aes.createCipheriv
12902exports.Decipher = aes.Decipher
12903exports.createDecipher = aes.createDecipher
12904exports.Decipheriv = aes.Decipheriv
12905exports.createDecipheriv = aes.createDecipheriv
12906exports.getCiphers = aes.getCiphers
12907exports.listCiphers = aes.listCiphers
12908
12909var dh = require('diffie-hellman')
12910
12911exports.DiffieHellmanGroup = dh.DiffieHellmanGroup
12912exports.createDiffieHellmanGroup = dh.createDiffieHellmanGroup
12913exports.getDiffieHellman = dh.getDiffieHellman
12914exports.createDiffieHellman = dh.createDiffieHellman
12915exports.DiffieHellman = dh.DiffieHellman
12916
12917var sign = require('browserify-sign')
12918
12919exports.createSign = sign.createSign
12920exports.Sign = sign.Sign
12921exports.createVerify = sign.createVerify
12922exports.Verify = sign.Verify
12923
12924exports.createECDH = require('create-ecdh')
12925
12926var publicEncrypt = require('public-encrypt')
12927
12928exports.publicEncrypt = publicEncrypt.publicEncrypt
12929exports.privateEncrypt = publicEncrypt.privateEncrypt
12930exports.publicDecrypt = publicEncrypt.publicDecrypt
12931exports.privateDecrypt = publicEncrypt.privateDecrypt
12932
12933// the least I can do is make error messages for the rest of the node.js/crypto api.
12934// ;[
12935// 'createCredentials'
12936// ].forEach(function (name) {
12937// exports[name] = function () {
12938// throw new Error([
12939// 'sorry, ' + name + ' is not implemented yet',
12940// 'we accept pull requests',
12941// 'https://github.com/crypto-browserify/crypto-browserify'
12942// ].join('\n'))
12943// }
12944// })
12945
12946var rf = require('randomfill')
12947
12948exports.randomFill = rf.randomFill
12949exports.randomFillSync = rf.randomFillSync
12950
12951exports.createCredentials = function () {
12952 throw new Error([
12953 'sorry, createCredentials is not implemented yet',
12954 'we accept pull requests',
12955 'https://github.com/crypto-browserify/crypto-browserify'
12956 ].join('\n'))
12957}
12958
12959exports.constants = {
12960 'DH_CHECK_P_NOT_SAFE_PRIME': 2,
12961 'DH_CHECK_P_NOT_PRIME': 1,
12962 'DH_UNABLE_TO_CHECK_GENERATOR': 4,
12963 'DH_NOT_SUITABLE_GENERATOR': 8,
12964 'NPN_ENABLED': 1,
12965 'ALPN_ENABLED': 1,
12966 'RSA_PKCS1_PADDING': 1,
12967 'RSA_SSLV23_PADDING': 2,
12968 'RSA_NO_PADDING': 3,
12969 'RSA_PKCS1_OAEP_PADDING': 4,
12970 'RSA_X931_PADDING': 5,
12971 'RSA_PKCS1_PSS_PADDING': 6,
12972 'POINT_CONVERSION_COMPRESSED': 2,
12973 'POINT_CONVERSION_UNCOMPRESSED': 4,
12974 'POINT_CONVERSION_HYBRID': 6
12975}
12976
12977},{"browserify-cipher":41,"browserify-sign":48,"browserify-sign/algos":45,"create-ecdh":56,"create-hash":57,"create-hmac":60,"diffie-hellman":69,"pbkdf2":127,"public-encrypt":134,"randombytes":140,"randomfill":141}],63:[function(require,module,exports){
12978'use strict';
12979
12980exports.utils = require('./des/utils');
12981exports.Cipher = require('./des/cipher');
12982exports.DES = require('./des/des');
12983exports.CBC = require('./des/cbc');
12984exports.EDE = require('./des/ede');
12985
12986},{"./des/cbc":64,"./des/cipher":65,"./des/des":66,"./des/ede":67,"./des/utils":68}],64:[function(require,module,exports){
12987'use strict';
12988
12989var assert = require('minimalistic-assert');
12990var inherits = require('inherits');
12991
12992var proto = {};
12993
12994function CBCState(iv) {
12995 assert.equal(iv.length, 8, 'Invalid IV length');
12996
12997 this.iv = new Array(8);
12998 for (var i = 0; i < this.iv.length; i++)
12999 this.iv[i] = iv[i];
13000}
13001
13002function instantiate(Base) {
13003 function CBC(options) {
13004 Base.call(this, options);
13005 this._cbcInit();
13006 }
13007 inherits(CBC, Base);
13008
13009 var keys = Object.keys(proto);
13010 for (var i = 0; i < keys.length; i++) {
13011 var key = keys[i];
13012 CBC.prototype[key] = proto[key];
13013 }
13014
13015 CBC.create = function create(options) {
13016 return new CBC(options);
13017 };
13018
13019 return CBC;
13020}
13021
13022exports.instantiate = instantiate;
13023
13024proto._cbcInit = function _cbcInit() {
13025 var state = new CBCState(this.options.iv);
13026 this._cbcState = state;
13027};
13028
13029proto._update = function _update(inp, inOff, out, outOff) {
13030 var state = this._cbcState;
13031 var superProto = this.constructor.super_.prototype;
13032
13033 var iv = state.iv;
13034 if (this.type === 'encrypt') {
13035 for (var i = 0; i < this.blockSize; i++)
13036 iv[i] ^= inp[inOff + i];
13037
13038 superProto._update.call(this, iv, 0, out, outOff);
13039
13040 for (var i = 0; i < this.blockSize; i++)
13041 iv[i] = out[outOff + i];
13042 } else {
13043 superProto._update.call(this, inp, inOff, out, outOff);
13044
13045 for (var i = 0; i < this.blockSize; i++)
13046 out[outOff + i] ^= iv[i];
13047
13048 for (var i = 0; i < this.blockSize; i++)
13049 iv[i] = inp[inOff + i];
13050 }
13051};
13052
13053},{"inherits":107,"minimalistic-assert":120}],65:[function(require,module,exports){
13054'use strict';
13055
13056var assert = require('minimalistic-assert');
13057
13058function Cipher(options) {
13059 this.options = options;
13060
13061 this.type = this.options.type;
13062 this.blockSize = 8;
13063 this._init();
13064
13065 this.buffer = new Array(this.blockSize);
13066 this.bufferOff = 0;
13067}
13068module.exports = Cipher;
13069
13070Cipher.prototype._init = function _init() {
13071 // Might be overrided
13072};
13073
13074Cipher.prototype.update = function update(data) {
13075 if (data.length === 0)
13076 return [];
13077
13078 if (this.type === 'decrypt')
13079 return this._updateDecrypt(data);
13080 else
13081 return this._updateEncrypt(data);
13082};
13083
13084Cipher.prototype._buffer = function _buffer(data, off) {
13085 // Append data to buffer
13086 var min = Math.min(this.buffer.length - this.bufferOff, data.length - off);
13087 for (var i = 0; i < min; i++)
13088 this.buffer[this.bufferOff + i] = data[off + i];
13089 this.bufferOff += min;
13090
13091 // Shift next
13092 return min;
13093};
13094
13095Cipher.prototype._flushBuffer = function _flushBuffer(out, off) {
13096 this._update(this.buffer, 0, out, off);
13097 this.bufferOff = 0;
13098 return this.blockSize;
13099};
13100
13101Cipher.prototype._updateEncrypt = function _updateEncrypt(data) {
13102 var inputOff = 0;
13103 var outputOff = 0;
13104
13105 var count = ((this.bufferOff + data.length) / this.blockSize) | 0;
13106 var out = new Array(count * this.blockSize);
13107
13108 if (this.bufferOff !== 0) {
13109 inputOff += this._buffer(data, inputOff);
13110
13111 if (this.bufferOff === this.buffer.length)
13112 outputOff += this._flushBuffer(out, outputOff);
13113 }
13114
13115 // Write blocks
13116 var max = data.length - ((data.length - inputOff) % this.blockSize);
13117 for (; inputOff < max; inputOff += this.blockSize) {
13118 this._update(data, inputOff, out, outputOff);
13119 outputOff += this.blockSize;
13120 }
13121
13122 // Queue rest
13123 for (; inputOff < data.length; inputOff++, this.bufferOff++)
13124 this.buffer[this.bufferOff] = data[inputOff];
13125
13126 return out;
13127};
13128
13129Cipher.prototype._updateDecrypt = function _updateDecrypt(data) {
13130 var inputOff = 0;
13131 var outputOff = 0;
13132
13133 var count = Math.ceil((this.bufferOff + data.length) / this.blockSize) - 1;
13134 var out = new Array(count * this.blockSize);
13135
13136 // TODO(indutny): optimize it, this is far from optimal
13137 for (; count > 0; count--) {
13138 inputOff += this._buffer(data, inputOff);
13139 outputOff += this._flushBuffer(out, outputOff);
13140 }
13141
13142 // Buffer rest of the input
13143 inputOff += this._buffer(data, inputOff);
13144
13145 return out;
13146};
13147
13148Cipher.prototype.final = function final(buffer) {
13149 var first;
13150 if (buffer)
13151 first = this.update(buffer);
13152
13153 var last;
13154 if (this.type === 'encrypt')
13155 last = this._finalEncrypt();
13156 else
13157 last = this._finalDecrypt();
13158
13159 if (first)
13160 return first.concat(last);
13161 else
13162 return last;
13163};
13164
13165Cipher.prototype._pad = function _pad(buffer, off) {
13166 if (off === 0)
13167 return false;
13168
13169 while (off < buffer.length)
13170 buffer[off++] = 0;
13171
13172 return true;
13173};
13174
13175Cipher.prototype._finalEncrypt = function _finalEncrypt() {
13176 if (!this._pad(this.buffer, this.bufferOff))
13177 return [];
13178
13179 var out = new Array(this.blockSize);
13180 this._update(this.buffer, 0, out, 0);
13181 return out;
13182};
13183
13184Cipher.prototype._unpad = function _unpad(buffer) {
13185 return buffer;
13186};
13187
13188Cipher.prototype._finalDecrypt = function _finalDecrypt() {
13189 assert.equal(this.bufferOff, this.blockSize, 'Not enough data to decrypt');
13190 var out = new Array(this.blockSize);
13191 this._flushBuffer(out, 0);
13192
13193 return this._unpad(out);
13194};
13195
13196},{"minimalistic-assert":120}],66:[function(require,module,exports){
13197'use strict';
13198
13199var assert = require('minimalistic-assert');
13200var inherits = require('inherits');
13201
13202var des = require('../des');
13203var utils = des.utils;
13204var Cipher = des.Cipher;
13205
13206function DESState() {
13207 this.tmp = new Array(2);
13208 this.keys = null;
13209}
13210
13211function DES(options) {
13212 Cipher.call(this, options);
13213
13214 var state = new DESState();
13215 this._desState = state;
13216
13217 this.deriveKeys(state, options.key);
13218}
13219inherits(DES, Cipher);
13220module.exports = DES;
13221
13222DES.create = function create(options) {
13223 return new DES(options);
13224};
13225
13226var shiftTable = [
13227 1, 1, 2, 2, 2, 2, 2, 2,
13228 1, 2, 2, 2, 2, 2, 2, 1
13229];
13230
13231DES.prototype.deriveKeys = function deriveKeys(state, key) {
13232 state.keys = new Array(16 * 2);
13233
13234 assert.equal(key.length, this.blockSize, 'Invalid key length');
13235
13236 var kL = utils.readUInt32BE(key, 0);
13237 var kR = utils.readUInt32BE(key, 4);
13238
13239 utils.pc1(kL, kR, state.tmp, 0);
13240 kL = state.tmp[0];
13241 kR = state.tmp[1];
13242 for (var i = 0; i < state.keys.length; i += 2) {
13243 var shift = shiftTable[i >>> 1];
13244 kL = utils.r28shl(kL, shift);
13245 kR = utils.r28shl(kR, shift);
13246 utils.pc2(kL, kR, state.keys, i);
13247 }
13248};
13249
13250DES.prototype._update = function _update(inp, inOff, out, outOff) {
13251 var state = this._desState;
13252
13253 var l = utils.readUInt32BE(inp, inOff);
13254 var r = utils.readUInt32BE(inp, inOff + 4);
13255
13256 // Initial Permutation
13257 utils.ip(l, r, state.tmp, 0);
13258 l = state.tmp[0];
13259 r = state.tmp[1];
13260
13261 if (this.type === 'encrypt')
13262 this._encrypt(state, l, r, state.tmp, 0);
13263 else
13264 this._decrypt(state, l, r, state.tmp, 0);
13265
13266 l = state.tmp[0];
13267 r = state.tmp[1];
13268
13269 utils.writeUInt32BE(out, l, outOff);
13270 utils.writeUInt32BE(out, r, outOff + 4);
13271};
13272
13273DES.prototype._pad = function _pad(buffer, off) {
13274 var value = buffer.length - off;
13275 for (var i = off; i < buffer.length; i++)
13276 buffer[i] = value;
13277
13278 return true;
13279};
13280
13281DES.prototype._unpad = function _unpad(buffer) {
13282 var pad = buffer[buffer.length - 1];
13283 for (var i = buffer.length - pad; i < buffer.length; i++)
13284 assert.equal(buffer[i], pad);
13285
13286 return buffer.slice(0, buffer.length - pad);
13287};
13288
13289DES.prototype._encrypt = function _encrypt(state, lStart, rStart, out, off) {
13290 var l = lStart;
13291 var r = rStart;
13292
13293 // Apply f() x16 times
13294 for (var i = 0; i < state.keys.length; i += 2) {
13295 var keyL = state.keys[i];
13296 var keyR = state.keys[i + 1];
13297
13298 // f(r, k)
13299 utils.expand(r, state.tmp, 0);
13300
13301 keyL ^= state.tmp[0];
13302 keyR ^= state.tmp[1];
13303 var s = utils.substitute(keyL, keyR);
13304 var f = utils.permute(s);
13305
13306 var t = r;
13307 r = (l ^ f) >>> 0;
13308 l = t;
13309 }
13310
13311 // Reverse Initial Permutation
13312 utils.rip(r, l, out, off);
13313};
13314
13315DES.prototype._decrypt = function _decrypt(state, lStart, rStart, out, off) {
13316 var l = rStart;
13317 var r = lStart;
13318
13319 // Apply f() x16 times
13320 for (var i = state.keys.length - 2; i >= 0; i -= 2) {
13321 var keyL = state.keys[i];
13322 var keyR = state.keys[i + 1];
13323
13324 // f(r, k)
13325 utils.expand(l, state.tmp, 0);
13326
13327 keyL ^= state.tmp[0];
13328 keyR ^= state.tmp[1];
13329 var s = utils.substitute(keyL, keyR);
13330 var f = utils.permute(s);
13331
13332 var t = l;
13333 l = (r ^ f) >>> 0;
13334 r = t;
13335 }
13336
13337 // Reverse Initial Permutation
13338 utils.rip(l, r, out, off);
13339};
13340
13341},{"../des":63,"inherits":107,"minimalistic-assert":120}],67:[function(require,module,exports){
13342'use strict';
13343
13344var assert = require('minimalistic-assert');
13345var inherits = require('inherits');
13346
13347var des = require('../des');
13348var Cipher = des.Cipher;
13349var DES = des.DES;
13350
13351function EDEState(type, key) {
13352 assert.equal(key.length, 24, 'Invalid key length');
13353
13354 var k1 = key.slice(0, 8);
13355 var k2 = key.slice(8, 16);
13356 var k3 = key.slice(16, 24);
13357
13358 if (type === 'encrypt') {
13359 this.ciphers = [
13360 DES.create({ type: 'encrypt', key: k1 }),
13361 DES.create({ type: 'decrypt', key: k2 }),
13362 DES.create({ type: 'encrypt', key: k3 })
13363 ];
13364 } else {
13365 this.ciphers = [
13366 DES.create({ type: 'decrypt', key: k3 }),
13367 DES.create({ type: 'encrypt', key: k2 }),
13368 DES.create({ type: 'decrypt', key: k1 })
13369 ];
13370 }
13371}
13372
13373function EDE(options) {
13374 Cipher.call(this, options);
13375
13376 var state = new EDEState(this.type, this.options.key);
13377 this._edeState = state;
13378}
13379inherits(EDE, Cipher);
13380
13381module.exports = EDE;
13382
13383EDE.create = function create(options) {
13384 return new EDE(options);
13385};
13386
13387EDE.prototype._update = function _update(inp, inOff, out, outOff) {
13388 var state = this._edeState;
13389
13390 state.ciphers[0]._update(inp, inOff, out, outOff);
13391 state.ciphers[1]._update(out, outOff, out, outOff);
13392 state.ciphers[2]._update(out, outOff, out, outOff);
13393};
13394
13395EDE.prototype._pad = DES.prototype._pad;
13396EDE.prototype._unpad = DES.prototype._unpad;
13397
13398},{"../des":63,"inherits":107,"minimalistic-assert":120}],68:[function(require,module,exports){
13399'use strict';
13400
13401exports.readUInt32BE = function readUInt32BE(bytes, off) {
13402 var res = (bytes[0 + off] << 24) |
13403 (bytes[1 + off] << 16) |
13404 (bytes[2 + off] << 8) |
13405 bytes[3 + off];
13406 return res >>> 0;
13407};
13408
13409exports.writeUInt32BE = function writeUInt32BE(bytes, value, off) {
13410 bytes[0 + off] = value >>> 24;
13411 bytes[1 + off] = (value >>> 16) & 0xff;
13412 bytes[2 + off] = (value >>> 8) & 0xff;
13413 bytes[3 + off] = value & 0xff;
13414};
13415
13416exports.ip = function ip(inL, inR, out, off) {
13417 var outL = 0;
13418 var outR = 0;
13419
13420 for (var i = 6; i >= 0; i -= 2) {
13421 for (var j = 0; j <= 24; j += 8) {
13422 outL <<= 1;
13423 outL |= (inR >>> (j + i)) & 1;
13424 }
13425 for (var j = 0; j <= 24; j += 8) {
13426 outL <<= 1;
13427 outL |= (inL >>> (j + i)) & 1;
13428 }
13429 }
13430
13431 for (var i = 6; i >= 0; i -= 2) {
13432 for (var j = 1; j <= 25; j += 8) {
13433 outR <<= 1;
13434 outR |= (inR >>> (j + i)) & 1;
13435 }
13436 for (var j = 1; j <= 25; j += 8) {
13437 outR <<= 1;
13438 outR |= (inL >>> (j + i)) & 1;
13439 }
13440 }
13441
13442 out[off + 0] = outL >>> 0;
13443 out[off + 1] = outR >>> 0;
13444};
13445
13446exports.rip = function rip(inL, inR, out, off) {
13447 var outL = 0;
13448 var outR = 0;
13449
13450 for (var i = 0; i < 4; i++) {
13451 for (var j = 24; j >= 0; j -= 8) {
13452 outL <<= 1;
13453 outL |= (inR >>> (j + i)) & 1;
13454 outL <<= 1;
13455 outL |= (inL >>> (j + i)) & 1;
13456 }
13457 }
13458 for (var i = 4; i < 8; i++) {
13459 for (var j = 24; j >= 0; j -= 8) {
13460 outR <<= 1;
13461 outR |= (inR >>> (j + i)) & 1;
13462 outR <<= 1;
13463 outR |= (inL >>> (j + i)) & 1;
13464 }
13465 }
13466
13467 out[off + 0] = outL >>> 0;
13468 out[off + 1] = outR >>> 0;
13469};
13470
13471exports.pc1 = function pc1(inL, inR, out, off) {
13472 var outL = 0;
13473 var outR = 0;
13474
13475 // 7, 15, 23, 31, 39, 47, 55, 63
13476 // 6, 14, 22, 30, 39, 47, 55, 63
13477 // 5, 13, 21, 29, 39, 47, 55, 63
13478 // 4, 12, 20, 28
13479 for (var i = 7; i >= 5; i--) {
13480 for (var j = 0; j <= 24; j += 8) {
13481 outL <<= 1;
13482 outL |= (inR >> (j + i)) & 1;
13483 }
13484 for (var j = 0; j <= 24; j += 8) {
13485 outL <<= 1;
13486 outL |= (inL >> (j + i)) & 1;
13487 }
13488 }
13489 for (var j = 0; j <= 24; j += 8) {
13490 outL <<= 1;
13491 outL |= (inR >> (j + i)) & 1;
13492 }
13493
13494 // 1, 9, 17, 25, 33, 41, 49, 57
13495 // 2, 10, 18, 26, 34, 42, 50, 58
13496 // 3, 11, 19, 27, 35, 43, 51, 59
13497 // 36, 44, 52, 60
13498 for (var i = 1; i <= 3; i++) {
13499 for (var j = 0; j <= 24; j += 8) {
13500 outR <<= 1;
13501 outR |= (inR >> (j + i)) & 1;
13502 }
13503 for (var j = 0; j <= 24; j += 8) {
13504 outR <<= 1;
13505 outR |= (inL >> (j + i)) & 1;
13506 }
13507 }
13508 for (var j = 0; j <= 24; j += 8) {
13509 outR <<= 1;
13510 outR |= (inL >> (j + i)) & 1;
13511 }
13512
13513 out[off + 0] = outL >>> 0;
13514 out[off + 1] = outR >>> 0;
13515};
13516
13517exports.r28shl = function r28shl(num, shift) {
13518 return ((num << shift) & 0xfffffff) | (num >>> (28 - shift));
13519};
13520
13521var pc2table = [
13522 // inL => outL
13523 14, 11, 17, 4, 27, 23, 25, 0,
13524 13, 22, 7, 18, 5, 9, 16, 24,
13525 2, 20, 12, 21, 1, 8, 15, 26,
13526
13527 // inR => outR
13528 15, 4, 25, 19, 9, 1, 26, 16,
13529 5, 11, 23, 8, 12, 7, 17, 0,
13530 22, 3, 10, 14, 6, 20, 27, 24
13531];
13532
13533exports.pc2 = function pc2(inL, inR, out, off) {
13534 var outL = 0;
13535 var outR = 0;
13536
13537 var len = pc2table.length >>> 1;
13538 for (var i = 0; i < len; i++) {
13539 outL <<= 1;
13540 outL |= (inL >>> pc2table[i]) & 0x1;
13541 }
13542 for (var i = len; i < pc2table.length; i++) {
13543 outR <<= 1;
13544 outR |= (inR >>> pc2table[i]) & 0x1;
13545 }
13546
13547 out[off + 0] = outL >>> 0;
13548 out[off + 1] = outR >>> 0;
13549};
13550
13551exports.expand = function expand(r, out, off) {
13552 var outL = 0;
13553 var outR = 0;
13554
13555 outL = ((r & 1) << 5) | (r >>> 27);
13556 for (var i = 23; i >= 15; i -= 4) {
13557 outL <<= 6;
13558 outL |= (r >>> i) & 0x3f;
13559 }
13560 for (var i = 11; i >= 3; i -= 4) {
13561 outR |= (r >>> i) & 0x3f;
13562 outR <<= 6;
13563 }
13564 outR |= ((r & 0x1f) << 1) | (r >>> 31);
13565
13566 out[off + 0] = outL >>> 0;
13567 out[off + 1] = outR >>> 0;
13568};
13569
13570var sTable = [
13571 14, 0, 4, 15, 13, 7, 1, 4, 2, 14, 15, 2, 11, 13, 8, 1,
13572 3, 10, 10, 6, 6, 12, 12, 11, 5, 9, 9, 5, 0, 3, 7, 8,
13573 4, 15, 1, 12, 14, 8, 8, 2, 13, 4, 6, 9, 2, 1, 11, 7,
13574 15, 5, 12, 11, 9, 3, 7, 14, 3, 10, 10, 0, 5, 6, 0, 13,
13575
13576 15, 3, 1, 13, 8, 4, 14, 7, 6, 15, 11, 2, 3, 8, 4, 14,
13577 9, 12, 7, 0, 2, 1, 13, 10, 12, 6, 0, 9, 5, 11, 10, 5,
13578 0, 13, 14, 8, 7, 10, 11, 1, 10, 3, 4, 15, 13, 4, 1, 2,
13579 5, 11, 8, 6, 12, 7, 6, 12, 9, 0, 3, 5, 2, 14, 15, 9,
13580
13581 10, 13, 0, 7, 9, 0, 14, 9, 6, 3, 3, 4, 15, 6, 5, 10,
13582 1, 2, 13, 8, 12, 5, 7, 14, 11, 12, 4, 11, 2, 15, 8, 1,
13583 13, 1, 6, 10, 4, 13, 9, 0, 8, 6, 15, 9, 3, 8, 0, 7,
13584 11, 4, 1, 15, 2, 14, 12, 3, 5, 11, 10, 5, 14, 2, 7, 12,
13585
13586 7, 13, 13, 8, 14, 11, 3, 5, 0, 6, 6, 15, 9, 0, 10, 3,
13587 1, 4, 2, 7, 8, 2, 5, 12, 11, 1, 12, 10, 4, 14, 15, 9,
13588 10, 3, 6, 15, 9, 0, 0, 6, 12, 10, 11, 1, 7, 13, 13, 8,
13589 15, 9, 1, 4, 3, 5, 14, 11, 5, 12, 2, 7, 8, 2, 4, 14,
13590
13591 2, 14, 12, 11, 4, 2, 1, 12, 7, 4, 10, 7, 11, 13, 6, 1,
13592 8, 5, 5, 0, 3, 15, 15, 10, 13, 3, 0, 9, 14, 8, 9, 6,
13593 4, 11, 2, 8, 1, 12, 11, 7, 10, 1, 13, 14, 7, 2, 8, 13,
13594 15, 6, 9, 15, 12, 0, 5, 9, 6, 10, 3, 4, 0, 5, 14, 3,
13595
13596 12, 10, 1, 15, 10, 4, 15, 2, 9, 7, 2, 12, 6, 9, 8, 5,
13597 0, 6, 13, 1, 3, 13, 4, 14, 14, 0, 7, 11, 5, 3, 11, 8,
13598 9, 4, 14, 3, 15, 2, 5, 12, 2, 9, 8, 5, 12, 15, 3, 10,
13599 7, 11, 0, 14, 4, 1, 10, 7, 1, 6, 13, 0, 11, 8, 6, 13,
13600
13601 4, 13, 11, 0, 2, 11, 14, 7, 15, 4, 0, 9, 8, 1, 13, 10,
13602 3, 14, 12, 3, 9, 5, 7, 12, 5, 2, 10, 15, 6, 8, 1, 6,
13603 1, 6, 4, 11, 11, 13, 13, 8, 12, 1, 3, 4, 7, 10, 14, 7,
13604 10, 9, 15, 5, 6, 0, 8, 15, 0, 14, 5, 2, 9, 3, 2, 12,
13605
13606 13, 1, 2, 15, 8, 13, 4, 8, 6, 10, 15, 3, 11, 7, 1, 4,
13607 10, 12, 9, 5, 3, 6, 14, 11, 5, 0, 0, 14, 12, 9, 7, 2,
13608 7, 2, 11, 1, 4, 14, 1, 7, 9, 4, 12, 10, 14, 8, 2, 13,
13609 0, 15, 6, 12, 10, 9, 13, 0, 15, 3, 3, 5, 5, 6, 8, 11
13610];
13611
13612exports.substitute = function substitute(inL, inR) {
13613 var out = 0;
13614 for (var i = 0; i < 4; i++) {
13615 var b = (inL >>> (18 - i * 6)) & 0x3f;
13616 var sb = sTable[i * 0x40 + b];
13617
13618 out <<= 4;
13619 out |= sb;
13620 }
13621 for (var i = 0; i < 4; i++) {
13622 var b = (inR >>> (18 - i * 6)) & 0x3f;
13623 var sb = sTable[4 * 0x40 + i * 0x40 + b];
13624
13625 out <<= 4;
13626 out |= sb;
13627 }
13628 return out >>> 0;
13629};
13630
13631var permuteTable = [
13632 16, 25, 12, 11, 3, 20, 4, 15, 31, 17, 9, 6, 27, 14, 1, 22,
13633 30, 24, 8, 18, 0, 5, 29, 23, 13, 19, 2, 26, 10, 21, 28, 7
13634];
13635
13636exports.permute = function permute(num) {
13637 var out = 0;
13638 for (var i = 0; i < permuteTable.length; i++) {
13639 out <<= 1;
13640 out |= (num >>> permuteTable[i]) & 0x1;
13641 }
13642 return out >>> 0;
13643};
13644
13645exports.padSplit = function padSplit(num, size, group) {
13646 var str = num.toString(2);
13647 while (str.length < size)
13648 str = '0' + str;
13649
13650 var out = [];
13651 for (var i = 0; i < size; i += group)
13652 out.push(str.slice(i, i + group));
13653 return out.join(' ');
13654};
13655
13656},{}],69:[function(require,module,exports){
13657(function (Buffer){
13658var generatePrime = require('./lib/generatePrime')
13659var primes = require('./lib/primes.json')
13660
13661var DH = require('./lib/dh')
13662
13663function getDiffieHellman (mod) {
13664 var prime = new Buffer(primes[mod].prime, 'hex')
13665 var gen = new Buffer(primes[mod].gen, 'hex')
13666
13667 return new DH(prime, gen)
13668}
13669
13670var ENCODINGS = {
13671 'binary': true, 'hex': true, 'base64': true
13672}
13673
13674function createDiffieHellman (prime, enc, generator, genc) {
13675 if (Buffer.isBuffer(enc) || ENCODINGS[enc] === undefined) {
13676 return createDiffieHellman(prime, 'binary', enc, generator)
13677 }
13678
13679 enc = enc || 'binary'
13680 genc = genc || 'binary'
13681 generator = generator || new Buffer([2])
13682
13683 if (!Buffer.isBuffer(generator)) {
13684 generator = new Buffer(generator, genc)
13685 }
13686
13687 if (typeof prime === 'number') {
13688 return new DH(generatePrime(prime, generator), generator, true)
13689 }
13690
13691 if (!Buffer.isBuffer(prime)) {
13692 prime = new Buffer(prime, enc)
13693 }
13694
13695 return new DH(prime, generator, true)
13696}
13697
13698exports.DiffieHellmanGroup = exports.createDiffieHellmanGroup = exports.getDiffieHellman = getDiffieHellman
13699exports.createDiffieHellman = exports.DiffieHellman = createDiffieHellman
13700
13701}).call(this,require("buffer").Buffer)
13702},{"./lib/dh":70,"./lib/generatePrime":71,"./lib/primes.json":72,"buffer":53}],70:[function(require,module,exports){
13703(function (Buffer){
13704var BN = require('bn.js');
13705var MillerRabin = require('miller-rabin');
13706var millerRabin = new MillerRabin();
13707var TWENTYFOUR = new BN(24);
13708var ELEVEN = new BN(11);
13709var TEN = new BN(10);
13710var THREE = new BN(3);
13711var SEVEN = new BN(7);
13712var primes = require('./generatePrime');
13713var randomBytes = require('randombytes');
13714module.exports = DH;
13715
13716function setPublicKey(pub, enc) {
13717 enc = enc || 'utf8';
13718 if (!Buffer.isBuffer(pub)) {
13719 pub = new Buffer(pub, enc);
13720 }
13721 this._pub = new BN(pub);
13722 return this;
13723}
13724
13725function setPrivateKey(priv, enc) {
13726 enc = enc || 'utf8';
13727 if (!Buffer.isBuffer(priv)) {
13728 priv = new Buffer(priv, enc);
13729 }
13730 this._priv = new BN(priv);
13731 return this;
13732}
13733
13734var primeCache = {};
13735function checkPrime(prime, generator) {
13736 var gen = generator.toString('hex');
13737 var hex = [gen, prime.toString(16)].join('_');
13738 if (hex in primeCache) {
13739 return primeCache[hex];
13740 }
13741 var error = 0;
13742
13743 if (prime.isEven() ||
13744 !primes.simpleSieve ||
13745 !primes.fermatTest(prime) ||
13746 !millerRabin.test(prime)) {
13747 //not a prime so +1
13748 error += 1;
13749
13750 if (gen === '02' || gen === '05') {
13751 // we'd be able to check the generator
13752 // it would fail so +8
13753 error += 8;
13754 } else {
13755 //we wouldn't be able to test the generator
13756 // so +4
13757 error += 4;
13758 }
13759 primeCache[hex] = error;
13760 return error;
13761 }
13762 if (!millerRabin.test(prime.shrn(1))) {
13763 //not a safe prime
13764 error += 2;
13765 }
13766 var rem;
13767 switch (gen) {
13768 case '02':
13769 if (prime.mod(TWENTYFOUR).cmp(ELEVEN)) {
13770 // unsuidable generator
13771 error += 8;
13772 }
13773 break;
13774 case '05':
13775 rem = prime.mod(TEN);
13776 if (rem.cmp(THREE) && rem.cmp(SEVEN)) {
13777 // prime mod 10 needs to equal 3 or 7
13778 error += 8;
13779 }
13780 break;
13781 default:
13782 error += 4;
13783 }
13784 primeCache[hex] = error;
13785 return error;
13786}
13787
13788function DH(prime, generator, malleable) {
13789 this.setGenerator(generator);
13790 this.__prime = new BN(prime);
13791 this._prime = BN.mont(this.__prime);
13792 this._primeLen = prime.length;
13793 this._pub = undefined;
13794 this._priv = undefined;
13795 this._primeCode = undefined;
13796 if (malleable) {
13797 this.setPublicKey = setPublicKey;
13798 this.setPrivateKey = setPrivateKey;
13799 } else {
13800 this._primeCode = 8;
13801 }
13802}
13803Object.defineProperty(DH.prototype, 'verifyError', {
13804 enumerable: true,
13805 get: function () {
13806 if (typeof this._primeCode !== 'number') {
13807 this._primeCode = checkPrime(this.__prime, this.__gen);
13808 }
13809 return this._primeCode;
13810 }
13811});
13812DH.prototype.generateKeys = function () {
13813 if (!this._priv) {
13814 this._priv = new BN(randomBytes(this._primeLen));
13815 }
13816 this._pub = this._gen.toRed(this._prime).redPow(this._priv).fromRed();
13817 return this.getPublicKey();
13818};
13819
13820DH.prototype.computeSecret = function (other) {
13821 other = new BN(other);
13822 other = other.toRed(this._prime);
13823 var secret = other.redPow(this._priv).fromRed();
13824 var out = new Buffer(secret.toArray());
13825 var prime = this.getPrime();
13826 if (out.length < prime.length) {
13827 var front = new Buffer(prime.length - out.length);
13828 front.fill(0);
13829 out = Buffer.concat([front, out]);
13830 }
13831 return out;
13832};
13833
13834DH.prototype.getPublicKey = function getPublicKey(enc) {
13835 return formatReturnValue(this._pub, enc);
13836};
13837
13838DH.prototype.getPrivateKey = function getPrivateKey(enc) {
13839 return formatReturnValue(this._priv, enc);
13840};
13841
13842DH.prototype.getPrime = function (enc) {
13843 return formatReturnValue(this.__prime, enc);
13844};
13845
13846DH.prototype.getGenerator = function (enc) {
13847 return formatReturnValue(this._gen, enc);
13848};
13849
13850DH.prototype.setGenerator = function (gen, enc) {
13851 enc = enc || 'utf8';
13852 if (!Buffer.isBuffer(gen)) {
13853 gen = new Buffer(gen, enc);
13854 }
13855 this.__gen = gen;
13856 this._gen = new BN(gen);
13857 return this;
13858};
13859
13860function formatReturnValue(bn, enc) {
13861 var buf = new Buffer(bn.toArray());
13862 if (!enc) {
13863 return buf;
13864 } else {
13865 return buf.toString(enc);
13866 }
13867}
13868
13869}).call(this,require("buffer").Buffer)
13870},{"./generatePrime":71,"bn.js":21,"buffer":53,"miller-rabin":119,"randombytes":140}],71:[function(require,module,exports){
13871var randomBytes = require('randombytes');
13872module.exports = findPrime;
13873findPrime.simpleSieve = simpleSieve;
13874findPrime.fermatTest = fermatTest;
13875var BN = require('bn.js');
13876var TWENTYFOUR = new BN(24);
13877var MillerRabin = require('miller-rabin');
13878var millerRabin = new MillerRabin();
13879var ONE = new BN(1);
13880var TWO = new BN(2);
13881var FIVE = new BN(5);
13882var SIXTEEN = new BN(16);
13883var EIGHT = new BN(8);
13884var TEN = new BN(10);
13885var THREE = new BN(3);
13886var SEVEN = new BN(7);
13887var ELEVEN = new BN(11);
13888var FOUR = new BN(4);
13889var TWELVE = new BN(12);
13890var primes = null;
13891
13892function _getPrimes() {
13893 if (primes !== null)
13894 return primes;
13895
13896 var limit = 0x100000;
13897 var res = [];
13898 res[0] = 2;
13899 for (var i = 1, k = 3; k < limit; k += 2) {
13900 var sqrt = Math.ceil(Math.sqrt(k));
13901 for (var j = 0; j < i && res[j] <= sqrt; j++)
13902 if (k % res[j] === 0)
13903 break;
13904
13905 if (i !== j && res[j] <= sqrt)
13906 continue;
13907
13908 res[i++] = k;
13909 }
13910 primes = res;
13911 return res;
13912}
13913
13914function simpleSieve(p) {
13915 var primes = _getPrimes();
13916
13917 for (var i = 0; i < primes.length; i++)
13918 if (p.modn(primes[i]) === 0) {
13919 if (p.cmpn(primes[i]) === 0) {
13920 return true;
13921 } else {
13922 return false;
13923 }
13924 }
13925
13926 return true;
13927}
13928
13929function fermatTest(p) {
13930 var red = BN.mont(p);
13931 return TWO.toRed(red).redPow(p.subn(1)).fromRed().cmpn(1) === 0;
13932}
13933
13934function findPrime(bits, gen) {
13935 if (bits < 16) {
13936 // this is what openssl does
13937 if (gen === 2 || gen === 5) {
13938 return new BN([0x8c, 0x7b]);
13939 } else {
13940 return new BN([0x8c, 0x27]);
13941 }
13942 }
13943 gen = new BN(gen);
13944
13945 var num, n2;
13946
13947 while (true) {
13948 num = new BN(randomBytes(Math.ceil(bits / 8)));
13949 while (num.bitLength() > bits) {
13950 num.ishrn(1);
13951 }
13952 if (num.isEven()) {
13953 num.iadd(ONE);
13954 }
13955 if (!num.testn(1)) {
13956 num.iadd(TWO);
13957 }
13958 if (!gen.cmp(TWO)) {
13959 while (num.mod(TWENTYFOUR).cmp(ELEVEN)) {
13960 num.iadd(FOUR);
13961 }
13962 } else if (!gen.cmp(FIVE)) {
13963 while (num.mod(TEN).cmp(THREE)) {
13964 num.iadd(FOUR);
13965 }
13966 }
13967 n2 = num.shrn(1);
13968 if (simpleSieve(n2) && simpleSieve(num) &&
13969 fermatTest(n2) && fermatTest(num) &&
13970 millerRabin.test(n2) && millerRabin.test(num)) {
13971 return num;
13972 }
13973 }
13974
13975}
13976
13977},{"bn.js":21,"miller-rabin":119,"randombytes":140}],72:[function(require,module,exports){
13978module.exports={
13979 "modp1": {
13980 "gen": "02",
13981 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"
13982 },
13983 "modp2": {
13984 "gen": "02",
13985 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"
13986 },
13987 "modp5": {
13988 "gen": "02",
13989 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"
13990 },
13991 "modp14": {
13992 "gen": "02",
13993 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"
13994 },
13995 "modp15": {
13996 "gen": "02",
13997 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"
13998 },
13999 "modp16": {
14000 "gen": "02",
14001 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"
14002 },
14003 "modp17": {
14004 "gen": "02",
14005 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"
14006 },
14007 "modp18": {
14008 "gen": "02",
14009 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"
14010 }
14011}
14012},{}],73:[function(require,module,exports){
14013'use strict';
14014
14015var elliptic = exports;
14016
14017elliptic.version = require('../package.json').version;
14018elliptic.utils = require('./elliptic/utils');
14019elliptic.rand = require('brorand');
14020elliptic.curve = require('./elliptic/curve');
14021elliptic.curves = require('./elliptic/curves');
14022
14023// Protocols
14024elliptic.ec = require('./elliptic/ec');
14025elliptic.eddsa = require('./elliptic/eddsa');
14026
14027},{"../package.json":88,"./elliptic/curve":76,"./elliptic/curves":79,"./elliptic/ec":80,"./elliptic/eddsa":83,"./elliptic/utils":87,"brorand":22}],74:[function(require,module,exports){
14028'use strict';
14029
14030var BN = require('bn.js');
14031var elliptic = require('../../elliptic');
14032var utils = elliptic.utils;
14033var getNAF = utils.getNAF;
14034var getJSF = utils.getJSF;
14035var assert = utils.assert;
14036
14037function BaseCurve(type, conf) {
14038 this.type = type;
14039 this.p = new BN(conf.p, 16);
14040
14041 // Use Montgomery, when there is no fast reduction for the prime
14042 this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p);
14043
14044 // Useful for many curves
14045 this.zero = new BN(0).toRed(this.red);
14046 this.one = new BN(1).toRed(this.red);
14047 this.two = new BN(2).toRed(this.red);
14048
14049 // Curve configuration, optional
14050 this.n = conf.n && new BN(conf.n, 16);
14051 this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed);
14052
14053 // Temporary arrays
14054 this._wnafT1 = new Array(4);
14055 this._wnafT2 = new Array(4);
14056 this._wnafT3 = new Array(4);
14057 this._wnafT4 = new Array(4);
14058
14059 // Generalized Greg Maxwell's trick
14060 var adjustCount = this.n && this.p.div(this.n);
14061 if (!adjustCount || adjustCount.cmpn(100) > 0) {
14062 this.redN = null;
14063 } else {
14064 this._maxwellTrick = true;
14065 this.redN = this.n.toRed(this.red);
14066 }
14067}
14068module.exports = BaseCurve;
14069
14070BaseCurve.prototype.point = function point() {
14071 throw new Error('Not implemented');
14072};
14073
14074BaseCurve.prototype.validate = function validate() {
14075 throw new Error('Not implemented');
14076};
14077
14078BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) {
14079 assert(p.precomputed);
14080 var doubles = p._getDoubles();
14081
14082 var naf = getNAF(k, 1);
14083 var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1);
14084 I /= 3;
14085
14086 // Translate into more windowed form
14087 var repr = [];
14088 for (var j = 0; j < naf.length; j += doubles.step) {
14089 var nafW = 0;
14090 for (var k = j + doubles.step - 1; k >= j; k--)
14091 nafW = (nafW << 1) + naf[k];
14092 repr.push(nafW);
14093 }
14094
14095 var a = this.jpoint(null, null, null);
14096 var b = this.jpoint(null, null, null);
14097 for (var i = I; i > 0; i--) {
14098 for (var j = 0; j < repr.length; j++) {
14099 var nafW = repr[j];
14100 if (nafW === i)
14101 b = b.mixedAdd(doubles.points[j]);
14102 else if (nafW === -i)
14103 b = b.mixedAdd(doubles.points[j].neg());
14104 }
14105 a = a.add(b);
14106 }
14107 return a.toP();
14108};
14109
14110BaseCurve.prototype._wnafMul = function _wnafMul(p, k) {
14111 var w = 4;
14112
14113 // Precompute window
14114 var nafPoints = p._getNAFPoints(w);
14115 w = nafPoints.wnd;
14116 var wnd = nafPoints.points;
14117
14118 // Get NAF form
14119 var naf = getNAF(k, w);
14120
14121 // Add `this`*(N+1) for every w-NAF index
14122 var acc = this.jpoint(null, null, null);
14123 for (var i = naf.length - 1; i >= 0; i--) {
14124 // Count zeroes
14125 for (var k = 0; i >= 0 && naf[i] === 0; i--)
14126 k++;
14127 if (i >= 0)
14128 k++;
14129 acc = acc.dblp(k);
14130
14131 if (i < 0)
14132 break;
14133 var z = naf[i];
14134 assert(z !== 0);
14135 if (p.type === 'affine') {
14136 // J +- P
14137 if (z > 0)
14138 acc = acc.mixedAdd(wnd[(z - 1) >> 1]);
14139 else
14140 acc = acc.mixedAdd(wnd[(-z - 1) >> 1].neg());
14141 } else {
14142 // J +- J
14143 if (z > 0)
14144 acc = acc.add(wnd[(z - 1) >> 1]);
14145 else
14146 acc = acc.add(wnd[(-z - 1) >> 1].neg());
14147 }
14148 }
14149 return p.type === 'affine' ? acc.toP() : acc;
14150};
14151
14152BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW,
14153 points,
14154 coeffs,
14155 len,
14156 jacobianResult) {
14157 var wndWidth = this._wnafT1;
14158 var wnd = this._wnafT2;
14159 var naf = this._wnafT3;
14160
14161 // Fill all arrays
14162 var max = 0;
14163 for (var i = 0; i < len; i++) {
14164 var p = points[i];
14165 var nafPoints = p._getNAFPoints(defW);
14166 wndWidth[i] = nafPoints.wnd;
14167 wnd[i] = nafPoints.points;
14168 }
14169
14170 // Comb small window NAFs
14171 for (var i = len - 1; i >= 1; i -= 2) {
14172 var a = i - 1;
14173 var b = i;
14174 if (wndWidth[a] !== 1 || wndWidth[b] !== 1) {
14175 naf[a] = getNAF(coeffs[a], wndWidth[a]);
14176 naf[b] = getNAF(coeffs[b], wndWidth[b]);
14177 max = Math.max(naf[a].length, max);
14178 max = Math.max(naf[b].length, max);
14179 continue;
14180 }
14181
14182 var comb = [
14183 points[a], /* 1 */
14184 null, /* 3 */
14185 null, /* 5 */
14186 points[b] /* 7 */
14187 ];
14188
14189 // Try to avoid Projective points, if possible
14190 if (points[a].y.cmp(points[b].y) === 0) {
14191 comb[1] = points[a].add(points[b]);
14192 comb[2] = points[a].toJ().mixedAdd(points[b].neg());
14193 } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) {
14194 comb[1] = points[a].toJ().mixedAdd(points[b]);
14195 comb[2] = points[a].add(points[b].neg());
14196 } else {
14197 comb[1] = points[a].toJ().mixedAdd(points[b]);
14198 comb[2] = points[a].toJ().mixedAdd(points[b].neg());
14199 }
14200
14201 var index = [
14202 -3, /* -1 -1 */
14203 -1, /* -1 0 */
14204 -5, /* -1 1 */
14205 -7, /* 0 -1 */
14206 0, /* 0 0 */
14207 7, /* 0 1 */
14208 5, /* 1 -1 */
14209 1, /* 1 0 */
14210 3 /* 1 1 */
14211 ];
14212
14213 var jsf = getJSF(coeffs[a], coeffs[b]);
14214 max = Math.max(jsf[0].length, max);
14215 naf[a] = new Array(max);
14216 naf[b] = new Array(max);
14217 for (var j = 0; j < max; j++) {
14218 var ja = jsf[0][j] | 0;
14219 var jb = jsf[1][j] | 0;
14220
14221 naf[a][j] = index[(ja + 1) * 3 + (jb + 1)];
14222 naf[b][j] = 0;
14223 wnd[a] = comb;
14224 }
14225 }
14226
14227 var acc = this.jpoint(null, null, null);
14228 var tmp = this._wnafT4;
14229 for (var i = max; i >= 0; i--) {
14230 var k = 0;
14231
14232 while (i >= 0) {
14233 var zero = true;
14234 for (var j = 0; j < len; j++) {
14235 tmp[j] = naf[j][i] | 0;
14236 if (tmp[j] !== 0)
14237 zero = false;
14238 }
14239 if (!zero)
14240 break;
14241 k++;
14242 i--;
14243 }
14244 if (i >= 0)
14245 k++;
14246 acc = acc.dblp(k);
14247 if (i < 0)
14248 break;
14249
14250 for (var j = 0; j < len; j++) {
14251 var z = tmp[j];
14252 var p;
14253 if (z === 0)
14254 continue;
14255 else if (z > 0)
14256 p = wnd[j][(z - 1) >> 1];
14257 else if (z < 0)
14258 p = wnd[j][(-z - 1) >> 1].neg();
14259
14260 if (p.type === 'affine')
14261 acc = acc.mixedAdd(p);
14262 else
14263 acc = acc.add(p);
14264 }
14265 }
14266 // Zeroify references
14267 for (var i = 0; i < len; i++)
14268 wnd[i] = null;
14269
14270 if (jacobianResult)
14271 return acc;
14272 else
14273 return acc.toP();
14274};
14275
14276function BasePoint(curve, type) {
14277 this.curve = curve;
14278 this.type = type;
14279 this.precomputed = null;
14280}
14281BaseCurve.BasePoint = BasePoint;
14282
14283BasePoint.prototype.eq = function eq(/*other*/) {
14284 throw new Error('Not implemented');
14285};
14286
14287BasePoint.prototype.validate = function validate() {
14288 return this.curve.validate(this);
14289};
14290
14291BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
14292 bytes = utils.toArray(bytes, enc);
14293
14294 var len = this.p.byteLength();
14295
14296 // uncompressed, hybrid-odd, hybrid-even
14297 if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) &&
14298 bytes.length - 1 === 2 * len) {
14299 if (bytes[0] === 0x06)
14300 assert(bytes[bytes.length - 1] % 2 === 0);
14301 else if (bytes[0] === 0x07)
14302 assert(bytes[bytes.length - 1] % 2 === 1);
14303
14304 var res = this.point(bytes.slice(1, 1 + len),
14305 bytes.slice(1 + len, 1 + 2 * len));
14306
14307 return res;
14308 } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) &&
14309 bytes.length - 1 === len) {
14310 return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03);
14311 }
14312 throw new Error('Unknown point format');
14313};
14314
14315BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) {
14316 return this.encode(enc, true);
14317};
14318
14319BasePoint.prototype._encode = function _encode(compact) {
14320 var len = this.curve.p.byteLength();
14321 var x = this.getX().toArray('be', len);
14322
14323 if (compact)
14324 return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x);
14325
14326 return [ 0x04 ].concat(x, this.getY().toArray('be', len)) ;
14327};
14328
14329BasePoint.prototype.encode = function encode(enc, compact) {
14330 return utils.encode(this._encode(compact), enc);
14331};
14332
14333BasePoint.prototype.precompute = function precompute(power) {
14334 if (this.precomputed)
14335 return this;
14336
14337 var precomputed = {
14338 doubles: null,
14339 naf: null,
14340 beta: null
14341 };
14342 precomputed.naf = this._getNAFPoints(8);
14343 precomputed.doubles = this._getDoubles(4, power);
14344 precomputed.beta = this._getBeta();
14345 this.precomputed = precomputed;
14346
14347 return this;
14348};
14349
14350BasePoint.prototype._hasDoubles = function _hasDoubles(k) {
14351 if (!this.precomputed)
14352 return false;
14353
14354 var doubles = this.precomputed.doubles;
14355 if (!doubles)
14356 return false;
14357
14358 return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step);
14359};
14360
14361BasePoint.prototype._getDoubles = function _getDoubles(step, power) {
14362 if (this.precomputed && this.precomputed.doubles)
14363 return this.precomputed.doubles;
14364
14365 var doubles = [ this ];
14366 var acc = this;
14367 for (var i = 0; i < power; i += step) {
14368 for (var j = 0; j < step; j++)
14369 acc = acc.dbl();
14370 doubles.push(acc);
14371 }
14372 return {
14373 step: step,
14374 points: doubles
14375 };
14376};
14377
14378BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) {
14379 if (this.precomputed && this.precomputed.naf)
14380 return this.precomputed.naf;
14381
14382 var res = [ this ];
14383 var max = (1 << wnd) - 1;
14384 var dbl = max === 1 ? null : this.dbl();
14385 for (var i = 1; i < max; i++)
14386 res[i] = res[i - 1].add(dbl);
14387 return {
14388 wnd: wnd,
14389 points: res
14390 };
14391};
14392
14393BasePoint.prototype._getBeta = function _getBeta() {
14394 return null;
14395};
14396
14397BasePoint.prototype.dblp = function dblp(k) {
14398 var r = this;
14399 for (var i = 0; i < k; i++)
14400 r = r.dbl();
14401 return r;
14402};
14403
14404},{"../../elliptic":73,"bn.js":21}],75:[function(require,module,exports){
14405'use strict';
14406
14407var curve = require('../curve');
14408var elliptic = require('../../elliptic');
14409var BN = require('bn.js');
14410var inherits = require('inherits');
14411var Base = curve.base;
14412
14413var assert = elliptic.utils.assert;
14414
14415function EdwardsCurve(conf) {
14416 // NOTE: Important as we are creating point in Base.call()
14417 this.twisted = (conf.a | 0) !== 1;
14418 this.mOneA = this.twisted && (conf.a | 0) === -1;
14419 this.extended = this.mOneA;
14420
14421 Base.call(this, 'edwards', conf);
14422
14423 this.a = new BN(conf.a, 16).umod(this.red.m);
14424 this.a = this.a.toRed(this.red);
14425 this.c = new BN(conf.c, 16).toRed(this.red);
14426 this.c2 = this.c.redSqr();
14427 this.d = new BN(conf.d, 16).toRed(this.red);
14428 this.dd = this.d.redAdd(this.d);
14429
14430 assert(!this.twisted || this.c.fromRed().cmpn(1) === 0);
14431 this.oneC = (conf.c | 0) === 1;
14432}
14433inherits(EdwardsCurve, Base);
14434module.exports = EdwardsCurve;
14435
14436EdwardsCurve.prototype._mulA = function _mulA(num) {
14437 if (this.mOneA)
14438 return num.redNeg();
14439 else
14440 return this.a.redMul(num);
14441};
14442
14443EdwardsCurve.prototype._mulC = function _mulC(num) {
14444 if (this.oneC)
14445 return num;
14446 else
14447 return this.c.redMul(num);
14448};
14449
14450// Just for compatibility with Short curve
14451EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) {
14452 return this.point(x, y, z, t);
14453};
14454
14455EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) {
14456 x = new BN(x, 16);
14457 if (!x.red)
14458 x = x.toRed(this.red);
14459
14460 var x2 = x.redSqr();
14461 var rhs = this.c2.redSub(this.a.redMul(x2));
14462 var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x2));
14463
14464 var y2 = rhs.redMul(lhs.redInvm());
14465 var y = y2.redSqrt();
14466 if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
14467 throw new Error('invalid point');
14468
14469 var isOdd = y.fromRed().isOdd();
14470 if (odd && !isOdd || !odd && isOdd)
14471 y = y.redNeg();
14472
14473 return this.point(x, y);
14474};
14475
14476EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) {
14477 y = new BN(y, 16);
14478 if (!y.red)
14479 y = y.toRed(this.red);
14480
14481 // x^2 = (y^2 - 1) / (d y^2 + 1)
14482 var y2 = y.redSqr();
14483 var lhs = y2.redSub(this.one);
14484 var rhs = y2.redMul(this.d).redAdd(this.one);
14485 var x2 = lhs.redMul(rhs.redInvm());
14486
14487 if (x2.cmp(this.zero) === 0) {
14488 if (odd)
14489 throw new Error('invalid point');
14490 else
14491 return this.point(this.zero, y);
14492 }
14493
14494 var x = x2.redSqrt();
14495 if (x.redSqr().redSub(x2).cmp(this.zero) !== 0)
14496 throw new Error('invalid point');
14497
14498 if (x.isOdd() !== odd)
14499 x = x.redNeg();
14500
14501 return this.point(x, y);
14502};
14503
14504EdwardsCurve.prototype.validate = function validate(point) {
14505 if (point.isInfinity())
14506 return true;
14507
14508 // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2)
14509 point.normalize();
14510
14511 var x2 = point.x.redSqr();
14512 var y2 = point.y.redSqr();
14513 var lhs = x2.redMul(this.a).redAdd(y2);
14514 var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2)));
14515
14516 return lhs.cmp(rhs) === 0;
14517};
14518
14519function Point(curve, x, y, z, t) {
14520 Base.BasePoint.call(this, curve, 'projective');
14521 if (x === null && y === null && z === null) {
14522 this.x = this.curve.zero;
14523 this.y = this.curve.one;
14524 this.z = this.curve.one;
14525 this.t = this.curve.zero;
14526 this.zOne = true;
14527 } else {
14528 this.x = new BN(x, 16);
14529 this.y = new BN(y, 16);
14530 this.z = z ? new BN(z, 16) : this.curve.one;
14531 this.t = t && new BN(t, 16);
14532 if (!this.x.red)
14533 this.x = this.x.toRed(this.curve.red);
14534 if (!this.y.red)
14535 this.y = this.y.toRed(this.curve.red);
14536 if (!this.z.red)
14537 this.z = this.z.toRed(this.curve.red);
14538 if (this.t && !this.t.red)
14539 this.t = this.t.toRed(this.curve.red);
14540 this.zOne = this.z === this.curve.one;
14541
14542 // Use extended coordinates
14543 if (this.curve.extended && !this.t) {
14544 this.t = this.x.redMul(this.y);
14545 if (!this.zOne)
14546 this.t = this.t.redMul(this.z.redInvm());
14547 }
14548 }
14549}
14550inherits(Point, Base.BasePoint);
14551
14552EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
14553 return Point.fromJSON(this, obj);
14554};
14555
14556EdwardsCurve.prototype.point = function point(x, y, z, t) {
14557 return new Point(this, x, y, z, t);
14558};
14559
14560Point.fromJSON = function fromJSON(curve, obj) {
14561 return new Point(curve, obj[0], obj[1], obj[2]);
14562};
14563
14564Point.prototype.inspect = function inspect() {
14565 if (this.isInfinity())
14566 return '<EC Point Infinity>';
14567 return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
14568 ' y: ' + this.y.fromRed().toString(16, 2) +
14569 ' z: ' + this.z.fromRed().toString(16, 2) + '>';
14570};
14571
14572Point.prototype.isInfinity = function isInfinity() {
14573 // XXX This code assumes that zero is always zero in red
14574 return this.x.cmpn(0) === 0 &&
14575 this.y.cmp(this.z) === 0;
14576};
14577
14578Point.prototype._extDbl = function _extDbl() {
14579 // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
14580 // #doubling-dbl-2008-hwcd
14581 // 4M + 4S
14582
14583 // A = X1^2
14584 var a = this.x.redSqr();
14585 // B = Y1^2
14586 var b = this.y.redSqr();
14587 // C = 2 * Z1^2
14588 var c = this.z.redSqr();
14589 c = c.redIAdd(c);
14590 // D = a * A
14591 var d = this.curve._mulA(a);
14592 // E = (X1 + Y1)^2 - A - B
14593 var e = this.x.redAdd(this.y).redSqr().redISub(a).redISub(b);
14594 // G = D + B
14595 var g = d.redAdd(b);
14596 // F = G - C
14597 var f = g.redSub(c);
14598 // H = D - B
14599 var h = d.redSub(b);
14600 // X3 = E * F
14601 var nx = e.redMul(f);
14602 // Y3 = G * H
14603 var ny = g.redMul(h);
14604 // T3 = E * H
14605 var nt = e.redMul(h);
14606 // Z3 = F * G
14607 var nz = f.redMul(g);
14608 return this.curve.point(nx, ny, nz, nt);
14609};
14610
14611Point.prototype._projDbl = function _projDbl() {
14612 // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
14613 // #doubling-dbl-2008-bbjlp
14614 // #doubling-dbl-2007-bl
14615 // and others
14616 // Generally 3M + 4S or 2M + 4S
14617
14618 // B = (X1 + Y1)^2
14619 var b = this.x.redAdd(this.y).redSqr();
14620 // C = X1^2
14621 var c = this.x.redSqr();
14622 // D = Y1^2
14623 var d = this.y.redSqr();
14624
14625 var nx;
14626 var ny;
14627 var nz;
14628 if (this.curve.twisted) {
14629 // E = a * C
14630 var e = this.curve._mulA(c);
14631 // F = E + D
14632 var f = e.redAdd(d);
14633 if (this.zOne) {
14634 // X3 = (B - C - D) * (F - 2)
14635 nx = b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two));
14636 // Y3 = F * (E - D)
14637 ny = f.redMul(e.redSub(d));
14638 // Z3 = F^2 - 2 * F
14639 nz = f.redSqr().redSub(f).redSub(f);
14640 } else {
14641 // H = Z1^2
14642 var h = this.z.redSqr();
14643 // J = F - 2 * H
14644 var j = f.redSub(h).redISub(h);
14645 // X3 = (B-C-D)*J
14646 nx = b.redSub(c).redISub(d).redMul(j);
14647 // Y3 = F * (E - D)
14648 ny = f.redMul(e.redSub(d));
14649 // Z3 = F * J
14650 nz = f.redMul(j);
14651 }
14652 } else {
14653 // E = C + D
14654 var e = c.redAdd(d);
14655 // H = (c * Z1)^2
14656 var h = this.curve._mulC(this.c.redMul(this.z)).redSqr();
14657 // J = E - 2 * H
14658 var j = e.redSub(h).redSub(h);
14659 // X3 = c * (B - E) * J
14660 nx = this.curve._mulC(b.redISub(e)).redMul(j);
14661 // Y3 = c * E * (C - D)
14662 ny = this.curve._mulC(e).redMul(c.redISub(d));
14663 // Z3 = E * J
14664 nz = e.redMul(j);
14665 }
14666 return this.curve.point(nx, ny, nz);
14667};
14668
14669Point.prototype.dbl = function dbl() {
14670 if (this.isInfinity())
14671 return this;
14672
14673 // Double in extended coordinates
14674 if (this.curve.extended)
14675 return this._extDbl();
14676 else
14677 return this._projDbl();
14678};
14679
14680Point.prototype._extAdd = function _extAdd(p) {
14681 // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
14682 // #addition-add-2008-hwcd-3
14683 // 8M
14684
14685 // A = (Y1 - X1) * (Y2 - X2)
14686 var a = this.y.redSub(this.x).redMul(p.y.redSub(p.x));
14687 // B = (Y1 + X1) * (Y2 + X2)
14688 var b = this.y.redAdd(this.x).redMul(p.y.redAdd(p.x));
14689 // C = T1 * k * T2
14690 var c = this.t.redMul(this.curve.dd).redMul(p.t);
14691 // D = Z1 * 2 * Z2
14692 var d = this.z.redMul(p.z.redAdd(p.z));
14693 // E = B - A
14694 var e = b.redSub(a);
14695 // F = D - C
14696 var f = d.redSub(c);
14697 // G = D + C
14698 var g = d.redAdd(c);
14699 // H = B + A
14700 var h = b.redAdd(a);
14701 // X3 = E * F
14702 var nx = e.redMul(f);
14703 // Y3 = G * H
14704 var ny = g.redMul(h);
14705 // T3 = E * H
14706 var nt = e.redMul(h);
14707 // Z3 = F * G
14708 var nz = f.redMul(g);
14709 return this.curve.point(nx, ny, nz, nt);
14710};
14711
14712Point.prototype._projAdd = function _projAdd(p) {
14713 // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
14714 // #addition-add-2008-bbjlp
14715 // #addition-add-2007-bl
14716 // 10M + 1S
14717
14718 // A = Z1 * Z2
14719 var a = this.z.redMul(p.z);
14720 // B = A^2
14721 var b = a.redSqr();
14722 // C = X1 * X2
14723 var c = this.x.redMul(p.x);
14724 // D = Y1 * Y2
14725 var d = this.y.redMul(p.y);
14726 // E = d * C * D
14727 var e = this.curve.d.redMul(c).redMul(d);
14728 // F = B - E
14729 var f = b.redSub(e);
14730 // G = B + E
14731 var g = b.redAdd(e);
14732 // X3 = A * F * ((X1 + Y1) * (X2 + Y2) - C - D)
14733 var tmp = this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d);
14734 var nx = a.redMul(f).redMul(tmp);
14735 var ny;
14736 var nz;
14737 if (this.curve.twisted) {
14738 // Y3 = A * G * (D - a * C)
14739 ny = a.redMul(g).redMul(d.redSub(this.curve._mulA(c)));
14740 // Z3 = F * G
14741 nz = f.redMul(g);
14742 } else {
14743 // Y3 = A * G * (D - C)
14744 ny = a.redMul(g).redMul(d.redSub(c));
14745 // Z3 = c * F * G
14746 nz = this.curve._mulC(f).redMul(g);
14747 }
14748 return this.curve.point(nx, ny, nz);
14749};
14750
14751Point.prototype.add = function add(p) {
14752 if (this.isInfinity())
14753 return p;
14754 if (p.isInfinity())
14755 return this;
14756
14757 if (this.curve.extended)
14758 return this._extAdd(p);
14759 else
14760 return this._projAdd(p);
14761};
14762
14763Point.prototype.mul = function mul(k) {
14764 if (this._hasDoubles(k))
14765 return this.curve._fixedNafMul(this, k);
14766 else
14767 return this.curve._wnafMul(this, k);
14768};
14769
14770Point.prototype.mulAdd = function mulAdd(k1, p, k2) {
14771 return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false);
14772};
14773
14774Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) {
14775 return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true);
14776};
14777
14778Point.prototype.normalize = function normalize() {
14779 if (this.zOne)
14780 return this;
14781
14782 // Normalize coordinates
14783 var zi = this.z.redInvm();
14784 this.x = this.x.redMul(zi);
14785 this.y = this.y.redMul(zi);
14786 if (this.t)
14787 this.t = this.t.redMul(zi);
14788 this.z = this.curve.one;
14789 this.zOne = true;
14790 return this;
14791};
14792
14793Point.prototype.neg = function neg() {
14794 return this.curve.point(this.x.redNeg(),
14795 this.y,
14796 this.z,
14797 this.t && this.t.redNeg());
14798};
14799
14800Point.prototype.getX = function getX() {
14801 this.normalize();
14802 return this.x.fromRed();
14803};
14804
14805Point.prototype.getY = function getY() {
14806 this.normalize();
14807 return this.y.fromRed();
14808};
14809
14810Point.prototype.eq = function eq(other) {
14811 return this === other ||
14812 this.getX().cmp(other.getX()) === 0 &&
14813 this.getY().cmp(other.getY()) === 0;
14814};
14815
14816Point.prototype.eqXToP = function eqXToP(x) {
14817 var rx = x.toRed(this.curve.red).redMul(this.z);
14818 if (this.x.cmp(rx) === 0)
14819 return true;
14820
14821 var xc = x.clone();
14822 var t = this.curve.redN.redMul(this.z);
14823 for (;;) {
14824 xc.iadd(this.curve.n);
14825 if (xc.cmp(this.curve.p) >= 0)
14826 return false;
14827
14828 rx.redIAdd(t);
14829 if (this.x.cmp(rx) === 0)
14830 return true;
14831 }
14832 return false;
14833};
14834
14835// Compatibility with BaseCurve
14836Point.prototype.toP = Point.prototype.normalize;
14837Point.prototype.mixedAdd = Point.prototype.add;
14838
14839},{"../../elliptic":73,"../curve":76,"bn.js":21,"inherits":107}],76:[function(require,module,exports){
14840'use strict';
14841
14842var curve = exports;
14843
14844curve.base = require('./base');
14845curve.short = require('./short');
14846curve.mont = require('./mont');
14847curve.edwards = require('./edwards');
14848
14849},{"./base":74,"./edwards":75,"./mont":77,"./short":78}],77:[function(require,module,exports){
14850'use strict';
14851
14852var curve = require('../curve');
14853var BN = require('bn.js');
14854var inherits = require('inherits');
14855var Base = curve.base;
14856
14857var elliptic = require('../../elliptic');
14858var utils = elliptic.utils;
14859
14860function MontCurve(conf) {
14861 Base.call(this, 'mont', conf);
14862
14863 this.a = new BN(conf.a, 16).toRed(this.red);
14864 this.b = new BN(conf.b, 16).toRed(this.red);
14865 this.i4 = new BN(4).toRed(this.red).redInvm();
14866 this.two = new BN(2).toRed(this.red);
14867 this.a24 = this.i4.redMul(this.a.redAdd(this.two));
14868}
14869inherits(MontCurve, Base);
14870module.exports = MontCurve;
14871
14872MontCurve.prototype.validate = function validate(point) {
14873 var x = point.normalize().x;
14874 var x2 = x.redSqr();
14875 var rhs = x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x);
14876 var y = rhs.redSqrt();
14877
14878 return y.redSqr().cmp(rhs) === 0;
14879};
14880
14881function Point(curve, x, z) {
14882 Base.BasePoint.call(this, curve, 'projective');
14883 if (x === null && z === null) {
14884 this.x = this.curve.one;
14885 this.z = this.curve.zero;
14886 } else {
14887 this.x = new BN(x, 16);
14888 this.z = new BN(z, 16);
14889 if (!this.x.red)
14890 this.x = this.x.toRed(this.curve.red);
14891 if (!this.z.red)
14892 this.z = this.z.toRed(this.curve.red);
14893 }
14894}
14895inherits(Point, Base.BasePoint);
14896
14897MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
14898 return this.point(utils.toArray(bytes, enc), 1);
14899};
14900
14901MontCurve.prototype.point = function point(x, z) {
14902 return new Point(this, x, z);
14903};
14904
14905MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
14906 return Point.fromJSON(this, obj);
14907};
14908
14909Point.prototype.precompute = function precompute() {
14910 // No-op
14911};
14912
14913Point.prototype._encode = function _encode() {
14914 return this.getX().toArray('be', this.curve.p.byteLength());
14915};
14916
14917Point.fromJSON = function fromJSON(curve, obj) {
14918 return new Point(curve, obj[0], obj[1] || curve.one);
14919};
14920
14921Point.prototype.inspect = function inspect() {
14922 if (this.isInfinity())
14923 return '<EC Point Infinity>';
14924 return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
14925 ' z: ' + this.z.fromRed().toString(16, 2) + '>';
14926};
14927
14928Point.prototype.isInfinity = function isInfinity() {
14929 // XXX This code assumes that zero is always zero in red
14930 return this.z.cmpn(0) === 0;
14931};
14932
14933Point.prototype.dbl = function dbl() {
14934 // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3
14935 // 2M + 2S + 4A
14936
14937 // A = X1 + Z1
14938 var a = this.x.redAdd(this.z);
14939 // AA = A^2
14940 var aa = a.redSqr();
14941 // B = X1 - Z1
14942 var b = this.x.redSub(this.z);
14943 // BB = B^2
14944 var bb = b.redSqr();
14945 // C = AA - BB
14946 var c = aa.redSub(bb);
14947 // X3 = AA * BB
14948 var nx = aa.redMul(bb);
14949 // Z3 = C * (BB + A24 * C)
14950 var nz = c.redMul(bb.redAdd(this.curve.a24.redMul(c)));
14951 return this.curve.point(nx, nz);
14952};
14953
14954Point.prototype.add = function add() {
14955 throw new Error('Not supported on Montgomery curve');
14956};
14957
14958Point.prototype.diffAdd = function diffAdd(p, diff) {
14959 // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3
14960 // 4M + 2S + 6A
14961
14962 // A = X2 + Z2
14963 var a = this.x.redAdd(this.z);
14964 // B = X2 - Z2
14965 var b = this.x.redSub(this.z);
14966 // C = X3 + Z3
14967 var c = p.x.redAdd(p.z);
14968 // D = X3 - Z3
14969 var d = p.x.redSub(p.z);
14970 // DA = D * A
14971 var da = d.redMul(a);
14972 // CB = C * B
14973 var cb = c.redMul(b);
14974 // X5 = Z1 * (DA + CB)^2
14975 var nx = diff.z.redMul(da.redAdd(cb).redSqr());
14976 // Z5 = X1 * (DA - CB)^2
14977 var nz = diff.x.redMul(da.redISub(cb).redSqr());
14978 return this.curve.point(nx, nz);
14979};
14980
14981Point.prototype.mul = function mul(k) {
14982 var t = k.clone();
14983 var a = this; // (N / 2) * Q + Q
14984 var b = this.curve.point(null, null); // (N / 2) * Q
14985 var c = this; // Q
14986
14987 for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1))
14988 bits.push(t.andln(1));
14989
14990 for (var i = bits.length - 1; i >= 0; i--) {
14991 if (bits[i] === 0) {
14992 // N * Q + Q = ((N / 2) * Q + Q)) + (N / 2) * Q
14993 a = a.diffAdd(b, c);
14994 // N * Q = 2 * ((N / 2) * Q + Q))
14995 b = b.dbl();
14996 } else {
14997 // N * Q = ((N / 2) * Q + Q) + ((N / 2) * Q)
14998 b = a.diffAdd(b, c);
14999 // N * Q + Q = 2 * ((N / 2) * Q + Q)
15000 a = a.dbl();
15001 }
15002 }
15003 return b;
15004};
15005
15006Point.prototype.mulAdd = function mulAdd() {
15007 throw new Error('Not supported on Montgomery curve');
15008};
15009
15010Point.prototype.jumlAdd = function jumlAdd() {
15011 throw new Error('Not supported on Montgomery curve');
15012};
15013
15014Point.prototype.eq = function eq(other) {
15015 return this.getX().cmp(other.getX()) === 0;
15016};
15017
15018Point.prototype.normalize = function normalize() {
15019 this.x = this.x.redMul(this.z.redInvm());
15020 this.z = this.curve.one;
15021 return this;
15022};
15023
15024Point.prototype.getX = function getX() {
15025 // Normalize coordinates
15026 this.normalize();
15027
15028 return this.x.fromRed();
15029};
15030
15031},{"../../elliptic":73,"../curve":76,"bn.js":21,"inherits":107}],78:[function(require,module,exports){
15032'use strict';
15033
15034var curve = require('../curve');
15035var elliptic = require('../../elliptic');
15036var BN = require('bn.js');
15037var inherits = require('inherits');
15038var Base = curve.base;
15039
15040var assert = elliptic.utils.assert;
15041
15042function ShortCurve(conf) {
15043 Base.call(this, 'short', conf);
15044
15045 this.a = new BN(conf.a, 16).toRed(this.red);
15046 this.b = new BN(conf.b, 16).toRed(this.red);
15047 this.tinv = this.two.redInvm();
15048
15049 this.zeroA = this.a.fromRed().cmpn(0) === 0;
15050 this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0;
15051
15052 // If the curve is endomorphic, precalculate beta and lambda
15053 this.endo = this._getEndomorphism(conf);
15054 this._endoWnafT1 = new Array(4);
15055 this._endoWnafT2 = new Array(4);
15056}
15057inherits(ShortCurve, Base);
15058module.exports = ShortCurve;
15059
15060ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) {
15061 // No efficient endomorphism
15062 if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)
15063 return;
15064
15065 // Compute beta and lambda, that lambda * P = (beta * Px; Py)
15066 var beta;
15067 var lambda;
15068 if (conf.beta) {
15069 beta = new BN(conf.beta, 16).toRed(this.red);
15070 } else {
15071 var betas = this._getEndoRoots(this.p);
15072 // Choose the smallest beta
15073 beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1];
15074 beta = beta.toRed(this.red);
15075 }
15076 if (conf.lambda) {
15077 lambda = new BN(conf.lambda, 16);
15078 } else {
15079 // Choose the lambda that is matching selected beta
15080 var lambdas = this._getEndoRoots(this.n);
15081 if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) {
15082 lambda = lambdas[0];
15083 } else {
15084 lambda = lambdas[1];
15085 assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0);
15086 }
15087 }
15088
15089 // Get basis vectors, used for balanced length-two representation
15090 var basis;
15091 if (conf.basis) {
15092 basis = conf.basis.map(function(vec) {
15093 return {
15094 a: new BN(vec.a, 16),
15095 b: new BN(vec.b, 16)
15096 };
15097 });
15098 } else {
15099 basis = this._getEndoBasis(lambda);
15100 }
15101
15102 return {
15103 beta: beta,
15104 lambda: lambda,
15105 basis: basis
15106 };
15107};
15108
15109ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) {
15110 // Find roots of for x^2 + x + 1 in F
15111 // Root = (-1 +- Sqrt(-3)) / 2
15112 //
15113 var red = num === this.p ? this.red : BN.mont(num);
15114 var tinv = new BN(2).toRed(red).redInvm();
15115 var ntinv = tinv.redNeg();
15116
15117 var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv);
15118
15119 var l1 = ntinv.redAdd(s).fromRed();
15120 var l2 = ntinv.redSub(s).fromRed();
15121 return [ l1, l2 ];
15122};
15123
15124ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) {
15125 // aprxSqrt >= sqrt(this.n)
15126 var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2));
15127
15128 // 3.74
15129 // Run EGCD, until r(L + 1) < aprxSqrt
15130 var u = lambda;
15131 var v = this.n.clone();
15132 var x1 = new BN(1);
15133 var y1 = new BN(0);
15134 var x2 = new BN(0);
15135 var y2 = new BN(1);
15136
15137 // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n)
15138 var a0;
15139 var b0;
15140 // First vector
15141 var a1;
15142 var b1;
15143 // Second vector
15144 var a2;
15145 var b2;
15146
15147 var prevR;
15148 var i = 0;
15149 var r;
15150 var x;
15151 while (u.cmpn(0) !== 0) {
15152 var q = v.div(u);
15153 r = v.sub(q.mul(u));
15154 x = x2.sub(q.mul(x1));
15155 var y = y2.sub(q.mul(y1));
15156
15157 if (!a1 && r.cmp(aprxSqrt) < 0) {
15158 a0 = prevR.neg();
15159 b0 = x1;
15160 a1 = r.neg();
15161 b1 = x;
15162 } else if (a1 && ++i === 2) {
15163 break;
15164 }
15165 prevR = r;
15166
15167 v = u;
15168 u = r;
15169 x2 = x1;
15170 x1 = x;
15171 y2 = y1;
15172 y1 = y;
15173 }
15174 a2 = r.neg();
15175 b2 = x;
15176
15177 var len1 = a1.sqr().add(b1.sqr());
15178 var len2 = a2.sqr().add(b2.sqr());
15179 if (len2.cmp(len1) >= 0) {
15180 a2 = a0;
15181 b2 = b0;
15182 }
15183
15184 // Normalize signs
15185 if (a1.negative) {
15186 a1 = a1.neg();
15187 b1 = b1.neg();
15188 }
15189 if (a2.negative) {
15190 a2 = a2.neg();
15191 b2 = b2.neg();
15192 }
15193
15194 return [
15195 { a: a1, b: b1 },
15196 { a: a2, b: b2 }
15197 ];
15198};
15199
15200ShortCurve.prototype._endoSplit = function _endoSplit(k) {
15201 var basis = this.endo.basis;
15202 var v1 = basis[0];
15203 var v2 = basis[1];
15204
15205 var c1 = v2.b.mul(k).divRound(this.n);
15206 var c2 = v1.b.neg().mul(k).divRound(this.n);
15207
15208 var p1 = c1.mul(v1.a);
15209 var p2 = c2.mul(v2.a);
15210 var q1 = c1.mul(v1.b);
15211 var q2 = c2.mul(v2.b);
15212
15213 // Calculate answer
15214 var k1 = k.sub(p1).sub(p2);
15215 var k2 = q1.add(q2).neg();
15216 return { k1: k1, k2: k2 };
15217};
15218
15219ShortCurve.prototype.pointFromX = function pointFromX(x, odd) {
15220 x = new BN(x, 16);
15221 if (!x.red)
15222 x = x.toRed(this.red);
15223
15224 var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b);
15225 var y = y2.redSqrt();
15226 if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
15227 throw new Error('invalid point');
15228
15229 // XXX Is there any way to tell if the number is odd without converting it
15230 // to non-red form?
15231 var isOdd = y.fromRed().isOdd();
15232 if (odd && !isOdd || !odd && isOdd)
15233 y = y.redNeg();
15234
15235 return this.point(x, y);
15236};
15237
15238ShortCurve.prototype.validate = function validate(point) {
15239 if (point.inf)
15240 return true;
15241
15242 var x = point.x;
15243 var y = point.y;
15244
15245 var ax = this.a.redMul(x);
15246 var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b);
15247 return y.redSqr().redISub(rhs).cmpn(0) === 0;
15248};
15249
15250ShortCurve.prototype._endoWnafMulAdd =
15251 function _endoWnafMulAdd(points, coeffs, jacobianResult) {
15252 var npoints = this._endoWnafT1;
15253 var ncoeffs = this._endoWnafT2;
15254 for (var i = 0; i < points.length; i++) {
15255 var split = this._endoSplit(coeffs[i]);
15256 var p = points[i];
15257 var beta = p._getBeta();
15258
15259 if (split.k1.negative) {
15260 split.k1.ineg();
15261 p = p.neg(true);
15262 }
15263 if (split.k2.negative) {
15264 split.k2.ineg();
15265 beta = beta.neg(true);
15266 }
15267
15268 npoints[i * 2] = p;
15269 npoints[i * 2 + 1] = beta;
15270 ncoeffs[i * 2] = split.k1;
15271 ncoeffs[i * 2 + 1] = split.k2;
15272 }
15273 var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult);
15274
15275 // Clean-up references to points and coefficients
15276 for (var j = 0; j < i * 2; j++) {
15277 npoints[j] = null;
15278 ncoeffs[j] = null;
15279 }
15280 return res;
15281};
15282
15283function Point(curve, x, y, isRed) {
15284 Base.BasePoint.call(this, curve, 'affine');
15285 if (x === null && y === null) {
15286 this.x = null;
15287 this.y = null;
15288 this.inf = true;
15289 } else {
15290 this.x = new BN(x, 16);
15291 this.y = new BN(y, 16);
15292 // Force redgomery representation when loading from JSON
15293 if (isRed) {
15294 this.x.forceRed(this.curve.red);
15295 this.y.forceRed(this.curve.red);
15296 }
15297 if (!this.x.red)
15298 this.x = this.x.toRed(this.curve.red);
15299 if (!this.y.red)
15300 this.y = this.y.toRed(this.curve.red);
15301 this.inf = false;
15302 }
15303}
15304inherits(Point, Base.BasePoint);
15305
15306ShortCurve.prototype.point = function point(x, y, isRed) {
15307 return new Point(this, x, y, isRed);
15308};
15309
15310ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) {
15311 return Point.fromJSON(this, obj, red);
15312};
15313
15314Point.prototype._getBeta = function _getBeta() {
15315 if (!this.curve.endo)
15316 return;
15317
15318 var pre = this.precomputed;
15319 if (pre && pre.beta)
15320 return pre.beta;
15321
15322 var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y);
15323 if (pre) {
15324 var curve = this.curve;
15325 var endoMul = function(p) {
15326 return curve.point(p.x.redMul(curve.endo.beta), p.y);
15327 };
15328 pre.beta = beta;
15329 beta.precomputed = {
15330 beta: null,
15331 naf: pre.naf && {
15332 wnd: pre.naf.wnd,
15333 points: pre.naf.points.map(endoMul)
15334 },
15335 doubles: pre.doubles && {
15336 step: pre.doubles.step,
15337 points: pre.doubles.points.map(endoMul)
15338 }
15339 };
15340 }
15341 return beta;
15342};
15343
15344Point.prototype.toJSON = function toJSON() {
15345 if (!this.precomputed)
15346 return [ this.x, this.y ];
15347
15348 return [ this.x, this.y, this.precomputed && {
15349 doubles: this.precomputed.doubles && {
15350 step: this.precomputed.doubles.step,
15351 points: this.precomputed.doubles.points.slice(1)
15352 },
15353 naf: this.precomputed.naf && {
15354 wnd: this.precomputed.naf.wnd,
15355 points: this.precomputed.naf.points.slice(1)
15356 }
15357 } ];
15358};
15359
15360Point.fromJSON = function fromJSON(curve, obj, red) {
15361 if (typeof obj === 'string')
15362 obj = JSON.parse(obj);
15363 var res = curve.point(obj[0], obj[1], red);
15364 if (!obj[2])
15365 return res;
15366
15367 function obj2point(obj) {
15368 return curve.point(obj[0], obj[1], red);
15369 }
15370
15371 var pre = obj[2];
15372 res.precomputed = {
15373 beta: null,
15374 doubles: pre.doubles && {
15375 step: pre.doubles.step,
15376 points: [ res ].concat(pre.doubles.points.map(obj2point))
15377 },
15378 naf: pre.naf && {
15379 wnd: pre.naf.wnd,
15380 points: [ res ].concat(pre.naf.points.map(obj2point))
15381 }
15382 };
15383 return res;
15384};
15385
15386Point.prototype.inspect = function inspect() {
15387 if (this.isInfinity())
15388 return '<EC Point Infinity>';
15389 return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
15390 ' y: ' + this.y.fromRed().toString(16, 2) + '>';
15391};
15392
15393Point.prototype.isInfinity = function isInfinity() {
15394 return this.inf;
15395};
15396
15397Point.prototype.add = function add(p) {
15398 // O + P = P
15399 if (this.inf)
15400 return p;
15401
15402 // P + O = P
15403 if (p.inf)
15404 return this;
15405
15406 // P + P = 2P
15407 if (this.eq(p))
15408 return this.dbl();
15409
15410 // P + (-P) = O
15411 if (this.neg().eq(p))
15412 return this.curve.point(null, null);
15413
15414 // P + Q = O
15415 if (this.x.cmp(p.x) === 0)
15416 return this.curve.point(null, null);
15417
15418 var c = this.y.redSub(p.y);
15419 if (c.cmpn(0) !== 0)
15420 c = c.redMul(this.x.redSub(p.x).redInvm());
15421 var nx = c.redSqr().redISub(this.x).redISub(p.x);
15422 var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
15423 return this.curve.point(nx, ny);
15424};
15425
15426Point.prototype.dbl = function dbl() {
15427 if (this.inf)
15428 return this;
15429
15430 // 2P = O
15431 var ys1 = this.y.redAdd(this.y);
15432 if (ys1.cmpn(0) === 0)
15433 return this.curve.point(null, null);
15434
15435 var a = this.curve.a;
15436
15437 var x2 = this.x.redSqr();
15438 var dyinv = ys1.redInvm();
15439 var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv);
15440
15441 var nx = c.redSqr().redISub(this.x.redAdd(this.x));
15442 var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
15443 return this.curve.point(nx, ny);
15444};
15445
15446Point.prototype.getX = function getX() {
15447 return this.x.fromRed();
15448};
15449
15450Point.prototype.getY = function getY() {
15451 return this.y.fromRed();
15452};
15453
15454Point.prototype.mul = function mul(k) {
15455 k = new BN(k, 16);
15456
15457 if (this._hasDoubles(k))
15458 return this.curve._fixedNafMul(this, k);
15459 else if (this.curve.endo)
15460 return this.curve._endoWnafMulAdd([ this ], [ k ]);
15461 else
15462 return this.curve._wnafMul(this, k);
15463};
15464
15465Point.prototype.mulAdd = function mulAdd(k1, p2, k2) {
15466 var points = [ this, p2 ];
15467 var coeffs = [ k1, k2 ];
15468 if (this.curve.endo)
15469 return this.curve._endoWnafMulAdd(points, coeffs);
15470 else
15471 return this.curve._wnafMulAdd(1, points, coeffs, 2);
15472};
15473
15474Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) {
15475 var points = [ this, p2 ];
15476 var coeffs = [ k1, k2 ];
15477 if (this.curve.endo)
15478 return this.curve._endoWnafMulAdd(points, coeffs, true);
15479 else
15480 return this.curve._wnafMulAdd(1, points, coeffs, 2, true);
15481};
15482
15483Point.prototype.eq = function eq(p) {
15484 return this === p ||
15485 this.inf === p.inf &&
15486 (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0);
15487};
15488
15489Point.prototype.neg = function neg(_precompute) {
15490 if (this.inf)
15491 return this;
15492
15493 var res = this.curve.point(this.x, this.y.redNeg());
15494 if (_precompute && this.precomputed) {
15495 var pre = this.precomputed;
15496 var negate = function(p) {
15497 return p.neg();
15498 };
15499 res.precomputed = {
15500 naf: pre.naf && {
15501 wnd: pre.naf.wnd,
15502 points: pre.naf.points.map(negate)
15503 },
15504 doubles: pre.doubles && {
15505 step: pre.doubles.step,
15506 points: pre.doubles.points.map(negate)
15507 }
15508 };
15509 }
15510 return res;
15511};
15512
15513Point.prototype.toJ = function toJ() {
15514 if (this.inf)
15515 return this.curve.jpoint(null, null, null);
15516
15517 var res = this.curve.jpoint(this.x, this.y, this.curve.one);
15518 return res;
15519};
15520
15521function JPoint(curve, x, y, z) {
15522 Base.BasePoint.call(this, curve, 'jacobian');
15523 if (x === null && y === null && z === null) {
15524 this.x = this.curve.one;
15525 this.y = this.curve.one;
15526 this.z = new BN(0);
15527 } else {
15528 this.x = new BN(x, 16);
15529 this.y = new BN(y, 16);
15530 this.z = new BN(z, 16);
15531 }
15532 if (!this.x.red)
15533 this.x = this.x.toRed(this.curve.red);
15534 if (!this.y.red)
15535 this.y = this.y.toRed(this.curve.red);
15536 if (!this.z.red)
15537 this.z = this.z.toRed(this.curve.red);
15538
15539 this.zOne = this.z === this.curve.one;
15540}
15541inherits(JPoint, Base.BasePoint);
15542
15543ShortCurve.prototype.jpoint = function jpoint(x, y, z) {
15544 return new JPoint(this, x, y, z);
15545};
15546
15547JPoint.prototype.toP = function toP() {
15548 if (this.isInfinity())
15549 return this.curve.point(null, null);
15550
15551 var zinv = this.z.redInvm();
15552 var zinv2 = zinv.redSqr();
15553 var ax = this.x.redMul(zinv2);
15554 var ay = this.y.redMul(zinv2).redMul(zinv);
15555
15556 return this.curve.point(ax, ay);
15557};
15558
15559JPoint.prototype.neg = function neg() {
15560 return this.curve.jpoint(this.x, this.y.redNeg(), this.z);
15561};
15562
15563JPoint.prototype.add = function add(p) {
15564 // O + P = P
15565 if (this.isInfinity())
15566 return p;
15567
15568 // P + O = P
15569 if (p.isInfinity())
15570 return this;
15571
15572 // 12M + 4S + 7A
15573 var pz2 = p.z.redSqr();
15574 var z2 = this.z.redSqr();
15575 var u1 = this.x.redMul(pz2);
15576 var u2 = p.x.redMul(z2);
15577 var s1 = this.y.redMul(pz2.redMul(p.z));
15578 var s2 = p.y.redMul(z2.redMul(this.z));
15579
15580 var h = u1.redSub(u2);
15581 var r = s1.redSub(s2);
15582 if (h.cmpn(0) === 0) {
15583 if (r.cmpn(0) !== 0)
15584 return this.curve.jpoint(null, null, null);
15585 else
15586 return this.dbl();
15587 }
15588
15589 var h2 = h.redSqr();
15590 var h3 = h2.redMul(h);
15591 var v = u1.redMul(h2);
15592
15593 var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
15594 var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
15595 var nz = this.z.redMul(p.z).redMul(h);
15596
15597 return this.curve.jpoint(nx, ny, nz);
15598};
15599
15600JPoint.prototype.mixedAdd = function mixedAdd(p) {
15601 // O + P = P
15602 if (this.isInfinity())
15603 return p.toJ();
15604
15605 // P + O = P
15606 if (p.isInfinity())
15607 return this;
15608
15609 // 8M + 3S + 7A
15610 var z2 = this.z.redSqr();
15611 var u1 = this.x;
15612 var u2 = p.x.redMul(z2);
15613 var s1 = this.y;
15614 var s2 = p.y.redMul(z2).redMul(this.z);
15615
15616 var h = u1.redSub(u2);
15617 var r = s1.redSub(s2);
15618 if (h.cmpn(0) === 0) {
15619 if (r.cmpn(0) !== 0)
15620 return this.curve.jpoint(null, null, null);
15621 else
15622 return this.dbl();
15623 }
15624
15625 var h2 = h.redSqr();
15626 var h3 = h2.redMul(h);
15627 var v = u1.redMul(h2);
15628
15629 var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
15630 var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
15631 var nz = this.z.redMul(h);
15632
15633 return this.curve.jpoint(nx, ny, nz);
15634};
15635
15636JPoint.prototype.dblp = function dblp(pow) {
15637 if (pow === 0)
15638 return this;
15639 if (this.isInfinity())
15640 return this;
15641 if (!pow)
15642 return this.dbl();
15643
15644 if (this.curve.zeroA || this.curve.threeA) {
15645 var r = this;
15646 for (var i = 0; i < pow; i++)
15647 r = r.dbl();
15648 return r;
15649 }
15650
15651 // 1M + 2S + 1A + N * (4S + 5M + 8A)
15652 // N = 1 => 6M + 6S + 9A
15653 var a = this.curve.a;
15654 var tinv = this.curve.tinv;
15655
15656 var jx = this.x;
15657 var jy = this.y;
15658 var jz = this.z;
15659 var jz4 = jz.redSqr().redSqr();
15660
15661 // Reuse results
15662 var jyd = jy.redAdd(jy);
15663 for (var i = 0; i < pow; i++) {
15664 var jx2 = jx.redSqr();
15665 var jyd2 = jyd.redSqr();
15666 var jyd4 = jyd2.redSqr();
15667 var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
15668
15669 var t1 = jx.redMul(jyd2);
15670 var nx = c.redSqr().redISub(t1.redAdd(t1));
15671 var t2 = t1.redISub(nx);
15672 var dny = c.redMul(t2);
15673 dny = dny.redIAdd(dny).redISub(jyd4);
15674 var nz = jyd.redMul(jz);
15675 if (i + 1 < pow)
15676 jz4 = jz4.redMul(jyd4);
15677
15678 jx = nx;
15679 jz = nz;
15680 jyd = dny;
15681 }
15682
15683 return this.curve.jpoint(jx, jyd.redMul(tinv), jz);
15684};
15685
15686JPoint.prototype.dbl = function dbl() {
15687 if (this.isInfinity())
15688 return this;
15689
15690 if (this.curve.zeroA)
15691 return this._zeroDbl();
15692 else if (this.curve.threeA)
15693 return this._threeDbl();
15694 else
15695 return this._dbl();
15696};
15697
15698JPoint.prototype._zeroDbl = function _zeroDbl() {
15699 var nx;
15700 var ny;
15701 var nz;
15702 // Z = 1
15703 if (this.zOne) {
15704 // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
15705 // #doubling-mdbl-2007-bl
15706 // 1M + 5S + 14A
15707
15708 // XX = X1^2
15709 var xx = this.x.redSqr();
15710 // YY = Y1^2
15711 var yy = this.y.redSqr();
15712 // YYYY = YY^2
15713 var yyyy = yy.redSqr();
15714 // S = 2 * ((X1 + YY)^2 - XX - YYYY)
15715 var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
15716 s = s.redIAdd(s);
15717 // M = 3 * XX + a; a = 0
15718 var m = xx.redAdd(xx).redIAdd(xx);
15719 // T = M ^ 2 - 2*S
15720 var t = m.redSqr().redISub(s).redISub(s);
15721
15722 // 8 * YYYY
15723 var yyyy8 = yyyy.redIAdd(yyyy);
15724 yyyy8 = yyyy8.redIAdd(yyyy8);
15725 yyyy8 = yyyy8.redIAdd(yyyy8);
15726
15727 // X3 = T
15728 nx = t;
15729 // Y3 = M * (S - T) - 8 * YYYY
15730 ny = m.redMul(s.redISub(t)).redISub(yyyy8);
15731 // Z3 = 2*Y1
15732 nz = this.y.redAdd(this.y);
15733 } else {
15734 // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
15735 // #doubling-dbl-2009-l
15736 // 2M + 5S + 13A
15737
15738 // A = X1^2
15739 var a = this.x.redSqr();
15740 // B = Y1^2
15741 var b = this.y.redSqr();
15742 // C = B^2
15743 var c = b.redSqr();
15744 // D = 2 * ((X1 + B)^2 - A - C)
15745 var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c);
15746 d = d.redIAdd(d);
15747 // E = 3 * A
15748 var e = a.redAdd(a).redIAdd(a);
15749 // F = E^2
15750 var f = e.redSqr();
15751
15752 // 8 * C
15753 var c8 = c.redIAdd(c);
15754 c8 = c8.redIAdd(c8);
15755 c8 = c8.redIAdd(c8);
15756
15757 // X3 = F - 2 * D
15758 nx = f.redISub(d).redISub(d);
15759 // Y3 = E * (D - X3) - 8 * C
15760 ny = e.redMul(d.redISub(nx)).redISub(c8);
15761 // Z3 = 2 * Y1 * Z1
15762 nz = this.y.redMul(this.z);
15763 nz = nz.redIAdd(nz);
15764 }
15765
15766 return this.curve.jpoint(nx, ny, nz);
15767};
15768
15769JPoint.prototype._threeDbl = function _threeDbl() {
15770 var nx;
15771 var ny;
15772 var nz;
15773 // Z = 1
15774 if (this.zOne) {
15775 // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html
15776 // #doubling-mdbl-2007-bl
15777 // 1M + 5S + 15A
15778
15779 // XX = X1^2
15780 var xx = this.x.redSqr();
15781 // YY = Y1^2
15782 var yy = this.y.redSqr();
15783 // YYYY = YY^2
15784 var yyyy = yy.redSqr();
15785 // S = 2 * ((X1 + YY)^2 - XX - YYYY)
15786 var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
15787 s = s.redIAdd(s);
15788 // M = 3 * XX + a
15789 var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a);
15790 // T = M^2 - 2 * S
15791 var t = m.redSqr().redISub(s).redISub(s);
15792 // X3 = T
15793 nx = t;
15794 // Y3 = M * (S - T) - 8 * YYYY
15795 var yyyy8 = yyyy.redIAdd(yyyy);
15796 yyyy8 = yyyy8.redIAdd(yyyy8);
15797 yyyy8 = yyyy8.redIAdd(yyyy8);
15798 ny = m.redMul(s.redISub(t)).redISub(yyyy8);
15799 // Z3 = 2 * Y1
15800 nz = this.y.redAdd(this.y);
15801 } else {
15802 // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b
15803 // 3M + 5S
15804
15805 // delta = Z1^2
15806 var delta = this.z.redSqr();
15807 // gamma = Y1^2
15808 var gamma = this.y.redSqr();
15809 // beta = X1 * gamma
15810 var beta = this.x.redMul(gamma);
15811 // alpha = 3 * (X1 - delta) * (X1 + delta)
15812 var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta));
15813 alpha = alpha.redAdd(alpha).redIAdd(alpha);
15814 // X3 = alpha^2 - 8 * beta
15815 var beta4 = beta.redIAdd(beta);
15816 beta4 = beta4.redIAdd(beta4);
15817 var beta8 = beta4.redAdd(beta4);
15818 nx = alpha.redSqr().redISub(beta8);
15819 // Z3 = (Y1 + Z1)^2 - gamma - delta
15820 nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta);
15821 // Y3 = alpha * (4 * beta - X3) - 8 * gamma^2
15822 var ggamma8 = gamma.redSqr();
15823 ggamma8 = ggamma8.redIAdd(ggamma8);
15824 ggamma8 = ggamma8.redIAdd(ggamma8);
15825 ggamma8 = ggamma8.redIAdd(ggamma8);
15826 ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8);
15827 }
15828
15829 return this.curve.jpoint(nx, ny, nz);
15830};
15831
15832JPoint.prototype._dbl = function _dbl() {
15833 var a = this.curve.a;
15834
15835 // 4M + 6S + 10A
15836 var jx = this.x;
15837 var jy = this.y;
15838 var jz = this.z;
15839 var jz4 = jz.redSqr().redSqr();
15840
15841 var jx2 = jx.redSqr();
15842 var jy2 = jy.redSqr();
15843
15844 var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
15845
15846 var jxd4 = jx.redAdd(jx);
15847 jxd4 = jxd4.redIAdd(jxd4);
15848 var t1 = jxd4.redMul(jy2);
15849 var nx = c.redSqr().redISub(t1.redAdd(t1));
15850 var t2 = t1.redISub(nx);
15851
15852 var jyd8 = jy2.redSqr();
15853 jyd8 = jyd8.redIAdd(jyd8);
15854 jyd8 = jyd8.redIAdd(jyd8);
15855 jyd8 = jyd8.redIAdd(jyd8);
15856 var ny = c.redMul(t2).redISub(jyd8);
15857 var nz = jy.redAdd(jy).redMul(jz);
15858
15859 return this.curve.jpoint(nx, ny, nz);
15860};
15861
15862JPoint.prototype.trpl = function trpl() {
15863 if (!this.curve.zeroA)
15864 return this.dbl().add(this);
15865
15866 // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl
15867 // 5M + 10S + ...
15868
15869 // XX = X1^2
15870 var xx = this.x.redSqr();
15871 // YY = Y1^2
15872 var yy = this.y.redSqr();
15873 // ZZ = Z1^2
15874 var zz = this.z.redSqr();
15875 // YYYY = YY^2
15876 var yyyy = yy.redSqr();
15877 // M = 3 * XX + a * ZZ2; a = 0
15878 var m = xx.redAdd(xx).redIAdd(xx);
15879 // MM = M^2
15880 var mm = m.redSqr();
15881 // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM
15882 var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
15883 e = e.redIAdd(e);
15884 e = e.redAdd(e).redIAdd(e);
15885 e = e.redISub(mm);
15886 // EE = E^2
15887 var ee = e.redSqr();
15888 // T = 16*YYYY
15889 var t = yyyy.redIAdd(yyyy);
15890 t = t.redIAdd(t);
15891 t = t.redIAdd(t);
15892 t = t.redIAdd(t);
15893 // U = (M + E)^2 - MM - EE - T
15894 var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t);
15895 // X3 = 4 * (X1 * EE - 4 * YY * U)
15896 var yyu4 = yy.redMul(u);
15897 yyu4 = yyu4.redIAdd(yyu4);
15898 yyu4 = yyu4.redIAdd(yyu4);
15899 var nx = this.x.redMul(ee).redISub(yyu4);
15900 nx = nx.redIAdd(nx);
15901 nx = nx.redIAdd(nx);
15902 // Y3 = 8 * Y1 * (U * (T - U) - E * EE)
15903 var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee)));
15904 ny = ny.redIAdd(ny);
15905 ny = ny.redIAdd(ny);
15906 ny = ny.redIAdd(ny);
15907 // Z3 = (Z1 + E)^2 - ZZ - EE
15908 var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee);
15909
15910 return this.curve.jpoint(nx, ny, nz);
15911};
15912
15913JPoint.prototype.mul = function mul(k, kbase) {
15914 k = new BN(k, kbase);
15915
15916 return this.curve._wnafMul(this, k);
15917};
15918
15919JPoint.prototype.eq = function eq(p) {
15920 if (p.type === 'affine')
15921 return this.eq(p.toJ());
15922
15923 if (this === p)
15924 return true;
15925
15926 // x1 * z2^2 == x2 * z1^2
15927 var z2 = this.z.redSqr();
15928 var pz2 = p.z.redSqr();
15929 if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0)
15930 return false;
15931
15932 // y1 * z2^3 == y2 * z1^3
15933 var z3 = z2.redMul(this.z);
15934 var pz3 = pz2.redMul(p.z);
15935 return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0;
15936};
15937
15938JPoint.prototype.eqXToP = function eqXToP(x) {
15939 var zs = this.z.redSqr();
15940 var rx = x.toRed(this.curve.red).redMul(zs);
15941 if (this.x.cmp(rx) === 0)
15942 return true;
15943
15944 var xc = x.clone();
15945 var t = this.curve.redN.redMul(zs);
15946 for (;;) {
15947 xc.iadd(this.curve.n);
15948 if (xc.cmp(this.curve.p) >= 0)
15949 return false;
15950
15951 rx.redIAdd(t);
15952 if (this.x.cmp(rx) === 0)
15953 return true;
15954 }
15955 return false;
15956};
15957
15958JPoint.prototype.inspect = function inspect() {
15959 if (this.isInfinity())
15960 return '<EC JPoint Infinity>';
15961 return '<EC JPoint x: ' + this.x.toString(16, 2) +
15962 ' y: ' + this.y.toString(16, 2) +
15963 ' z: ' + this.z.toString(16, 2) + '>';
15964};
15965
15966JPoint.prototype.isInfinity = function isInfinity() {
15967 // XXX This code assumes that zero is always zero in red
15968 return this.z.cmpn(0) === 0;
15969};
15970
15971},{"../../elliptic":73,"../curve":76,"bn.js":21,"inherits":107}],79:[function(require,module,exports){
15972'use strict';
15973
15974var curves = exports;
15975
15976var hash = require('hash.js');
15977var elliptic = require('../elliptic');
15978
15979var assert = elliptic.utils.assert;
15980
15981function PresetCurve(options) {
15982 if (options.type === 'short')
15983 this.curve = new elliptic.curve.short(options);
15984 else if (options.type === 'edwards')
15985 this.curve = new elliptic.curve.edwards(options);
15986 else
15987 this.curve = new elliptic.curve.mont(options);
15988 this.g = this.curve.g;
15989 this.n = this.curve.n;
15990 this.hash = options.hash;
15991
15992 assert(this.g.validate(), 'Invalid curve');
15993 assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O');
15994}
15995curves.PresetCurve = PresetCurve;
15996
15997function defineCurve(name, options) {
15998 Object.defineProperty(curves, name, {
15999 configurable: true,
16000 enumerable: true,
16001 get: function() {
16002 var curve = new PresetCurve(options);
16003 Object.defineProperty(curves, name, {
16004 configurable: true,
16005 enumerable: true,
16006 value: curve
16007 });
16008 return curve;
16009 }
16010 });
16011}
16012
16013defineCurve('p192', {
16014 type: 'short',
16015 prime: 'p192',
16016 p: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff',
16017 a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc',
16018 b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1',
16019 n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831',
16020 hash: hash.sha256,
16021 gRed: false,
16022 g: [
16023 '188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012',
16024 '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811'
16025 ]
16026});
16027
16028defineCurve('p224', {
16029 type: 'short',
16030 prime: 'p224',
16031 p: 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001',
16032 a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe',
16033 b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4',
16034 n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d',
16035 hash: hash.sha256,
16036 gRed: false,
16037 g: [
16038 'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21',
16039 'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34'
16040 ]
16041});
16042
16043defineCurve('p256', {
16044 type: 'short',
16045 prime: null,
16046 p: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff',
16047 a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc',
16048 b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b',
16049 n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551',
16050 hash: hash.sha256,
16051 gRed: false,
16052 g: [
16053 '6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296',
16054 '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5'
16055 ]
16056});
16057
16058defineCurve('p384', {
16059 type: 'short',
16060 prime: null,
16061 p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
16062 'fffffffe ffffffff 00000000 00000000 ffffffff',
16063 a: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
16064 'fffffffe ffffffff 00000000 00000000 fffffffc',
16065 b: 'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f ' +
16066 '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef',
16067 n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' +
16068 'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973',
16069 hash: hash.sha384,
16070 gRed: false,
16071 g: [
16072 'aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' +
16073 '5502f25d bf55296c 3a545e38 72760ab7',
16074 '3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' +
16075 '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f'
16076 ]
16077});
16078
16079defineCurve('p521', {
16080 type: 'short',
16081 prime: null,
16082 p: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
16083 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
16084 'ffffffff ffffffff ffffffff ffffffff ffffffff',
16085 a: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
16086 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
16087 'ffffffff ffffffff ffffffff ffffffff fffffffc',
16088 b: '00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b ' +
16089 '99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd ' +
16090 '3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00',
16091 n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
16092 'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' +
16093 'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409',
16094 hash: hash.sha512,
16095 gRed: false,
16096 g: [
16097 '000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' +
16098 '053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 ' +
16099 'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66',
16100 '00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' +
16101 '579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' +
16102 '3fad0761 353c7086 a272c240 88be9476 9fd16650'
16103 ]
16104});
16105
16106defineCurve('curve25519', {
16107 type: 'mont',
16108 prime: 'p25519',
16109 p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
16110 a: '76d06',
16111 b: '1',
16112 n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
16113 hash: hash.sha256,
16114 gRed: false,
16115 g: [
16116 '9'
16117 ]
16118});
16119
16120defineCurve('ed25519', {
16121 type: 'edwards',
16122 prime: 'p25519',
16123 p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
16124 a: '-1',
16125 c: '1',
16126 // -121665 * (121666^(-1)) (mod P)
16127 d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3',
16128 n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
16129 hash: hash.sha256,
16130 gRed: false,
16131 g: [
16132 '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a',
16133
16134 // 4/5
16135 '6666666666666666666666666666666666666666666666666666666666666658'
16136 ]
16137});
16138
16139var pre;
16140try {
16141 pre = require('./precomputed/secp256k1');
16142} catch (e) {
16143 pre = undefined;
16144}
16145
16146defineCurve('secp256k1', {
16147 type: 'short',
16148 prime: 'k256',
16149 p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f',
16150 a: '0',
16151 b: '7',
16152 n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141',
16153 h: '1',
16154 hash: hash.sha256,
16155
16156 // Precomputed endomorphism
16157 beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee',
16158 lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72',
16159 basis: [
16160 {
16161 a: '3086d221a7d46bcde86c90e49284eb15',
16162 b: '-e4437ed6010e88286f547fa90abfe4c3'
16163 },
16164 {
16165 a: '114ca50f7a8e2f3f657c1108d9d44cfd8',
16166 b: '3086d221a7d46bcde86c90e49284eb15'
16167 }
16168 ],
16169
16170 gRed: false,
16171 g: [
16172 '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
16173 '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8',
16174 pre
16175 ]
16176});
16177
16178},{"../elliptic":73,"./precomputed/secp256k1":86,"hash.js":92}],80:[function(require,module,exports){
16179'use strict';
16180
16181var BN = require('bn.js');
16182var HmacDRBG = require('hmac-drbg');
16183var elliptic = require('../../elliptic');
16184var utils = elliptic.utils;
16185var assert = utils.assert;
16186
16187var KeyPair = require('./key');
16188var Signature = require('./signature');
16189
16190function EC(options) {
16191 if (!(this instanceof EC))
16192 return new EC(options);
16193
16194 // Shortcut `elliptic.ec(curve-name)`
16195 if (typeof options === 'string') {
16196 assert(elliptic.curves.hasOwnProperty(options), 'Unknown curve ' + options);
16197
16198 options = elliptic.curves[options];
16199 }
16200
16201 // Shortcut for `elliptic.ec(elliptic.curves.curveName)`
16202 if (options instanceof elliptic.curves.PresetCurve)
16203 options = { curve: options };
16204
16205 this.curve = options.curve.curve;
16206 this.n = this.curve.n;
16207 this.nh = this.n.ushrn(1);
16208 this.g = this.curve.g;
16209
16210 // Point on curve
16211 this.g = options.curve.g;
16212 this.g.precompute(options.curve.n.bitLength() + 1);
16213
16214 // Hash for function for DRBG
16215 this.hash = options.hash || options.curve.hash;
16216}
16217module.exports = EC;
16218
16219EC.prototype.keyPair = function keyPair(options) {
16220 return new KeyPair(this, options);
16221};
16222
16223EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) {
16224 return KeyPair.fromPrivate(this, priv, enc);
16225};
16226
16227EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) {
16228 return KeyPair.fromPublic(this, pub, enc);
16229};
16230
16231EC.prototype.genKeyPair = function genKeyPair(options) {
16232 if (!options)
16233 options = {};
16234
16235 // Instantiate Hmac_DRBG
16236 var drbg = new HmacDRBG({
16237 hash: this.hash,
16238 pers: options.pers,
16239 persEnc: options.persEnc || 'utf8',
16240 entropy: options.entropy || elliptic.rand(this.hash.hmacStrength),
16241 entropyEnc: options.entropy && options.entropyEnc || 'utf8',
16242 nonce: this.n.toArray()
16243 });
16244
16245 var bytes = this.n.byteLength();
16246 var ns2 = this.n.sub(new BN(2));
16247 do {
16248 var priv = new BN(drbg.generate(bytes));
16249 if (priv.cmp(ns2) > 0)
16250 continue;
16251
16252 priv.iaddn(1);
16253 return this.keyFromPrivate(priv);
16254 } while (true);
16255};
16256
16257EC.prototype._truncateToN = function truncateToN(msg, truncOnly) {
16258 var delta = msg.byteLength() * 8 - this.n.bitLength();
16259 if (delta > 0)
16260 msg = msg.ushrn(delta);
16261 if (!truncOnly && msg.cmp(this.n) >= 0)
16262 return msg.sub(this.n);
16263 else
16264 return msg;
16265};
16266
16267EC.prototype.sign = function sign(msg, key, enc, options) {
16268 if (typeof enc === 'object') {
16269 options = enc;
16270 enc = null;
16271 }
16272 if (!options)
16273 options = {};
16274
16275 key = this.keyFromPrivate(key, enc);
16276 msg = this._truncateToN(new BN(msg, 16));
16277
16278 // Zero-extend key to provide enough entropy
16279 var bytes = this.n.byteLength();
16280 var bkey = key.getPrivate().toArray('be', bytes);
16281
16282 // Zero-extend nonce to have the same byte size as N
16283 var nonce = msg.toArray('be', bytes);
16284
16285 // Instantiate Hmac_DRBG
16286 var drbg = new HmacDRBG({
16287 hash: this.hash,
16288 entropy: bkey,
16289 nonce: nonce,
16290 pers: options.pers,
16291 persEnc: options.persEnc || 'utf8'
16292 });
16293
16294 // Number of bytes to generate
16295 var ns1 = this.n.sub(new BN(1));
16296
16297 for (var iter = 0; true; iter++) {
16298 var k = options.k ?
16299 options.k(iter) :
16300 new BN(drbg.generate(this.n.byteLength()));
16301 k = this._truncateToN(k, true);
16302 if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0)
16303 continue;
16304
16305 var kp = this.g.mul(k);
16306 if (kp.isInfinity())
16307 continue;
16308
16309 var kpX = kp.getX();
16310 var r = kpX.umod(this.n);
16311 if (r.cmpn(0) === 0)
16312 continue;
16313
16314 var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg));
16315 s = s.umod(this.n);
16316 if (s.cmpn(0) === 0)
16317 continue;
16318
16319 var recoveryParam = (kp.getY().isOdd() ? 1 : 0) |
16320 (kpX.cmp(r) !== 0 ? 2 : 0);
16321
16322 // Use complement of `s`, if it is > `n / 2`
16323 if (options.canonical && s.cmp(this.nh) > 0) {
16324 s = this.n.sub(s);
16325 recoveryParam ^= 1;
16326 }
16327
16328 return new Signature({ r: r, s: s, recoveryParam: recoveryParam });
16329 }
16330};
16331
16332EC.prototype.verify = function verify(msg, signature, key, enc) {
16333 msg = this._truncateToN(new BN(msg, 16));
16334 key = this.keyFromPublic(key, enc);
16335 signature = new Signature(signature, 'hex');
16336
16337 // Perform primitive values validation
16338 var r = signature.r;
16339 var s = signature.s;
16340 if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0)
16341 return false;
16342 if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0)
16343 return false;
16344
16345 // Validate signature
16346 var sinv = s.invm(this.n);
16347 var u1 = sinv.mul(msg).umod(this.n);
16348 var u2 = sinv.mul(r).umod(this.n);
16349
16350 if (!this.curve._maxwellTrick) {
16351 var p = this.g.mulAdd(u1, key.getPublic(), u2);
16352 if (p.isInfinity())
16353 return false;
16354
16355 return p.getX().umod(this.n).cmp(r) === 0;
16356 }
16357
16358 // NOTE: Greg Maxwell's trick, inspired by:
16359 // https://git.io/vad3K
16360
16361 var p = this.g.jmulAdd(u1, key.getPublic(), u2);
16362 if (p.isInfinity())
16363 return false;
16364
16365 // Compare `p.x` of Jacobian point with `r`,
16366 // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the
16367 // inverse of `p.z^2`
16368 return p.eqXToP(r);
16369};
16370
16371EC.prototype.recoverPubKey = function(msg, signature, j, enc) {
16372 assert((3 & j) === j, 'The recovery param is more than two bits');
16373 signature = new Signature(signature, enc);
16374
16375 var n = this.n;
16376 var e = new BN(msg);
16377 var r = signature.r;
16378 var s = signature.s;
16379
16380 // A set LSB signifies that the y-coordinate is odd
16381 var isYOdd = j & 1;
16382 var isSecondKey = j >> 1;
16383 if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey)
16384 throw new Error('Unable to find sencond key candinate');
16385
16386 // 1.1. Let x = r + jn.
16387 if (isSecondKey)
16388 r = this.curve.pointFromX(r.add(this.curve.n), isYOdd);
16389 else
16390 r = this.curve.pointFromX(r, isYOdd);
16391
16392 var rInv = signature.r.invm(n);
16393 var s1 = n.sub(e).mul(rInv).umod(n);
16394 var s2 = s.mul(rInv).umod(n);
16395
16396 // 1.6.1 Compute Q = r^-1 (sR - eG)
16397 // Q = r^-1 (sR + -eG)
16398 return this.g.mulAdd(s1, r, s2);
16399};
16400
16401EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) {
16402 signature = new Signature(signature, enc);
16403 if (signature.recoveryParam !== null)
16404 return signature.recoveryParam;
16405
16406 for (var i = 0; i < 4; i++) {
16407 var Qprime;
16408 try {
16409 Qprime = this.recoverPubKey(e, signature, i);
16410 } catch (e) {
16411 continue;
16412 }
16413
16414 if (Qprime.eq(Q))
16415 return i;
16416 }
16417 throw new Error('Unable to find valid recovery factor');
16418};
16419
16420},{"../../elliptic":73,"./key":81,"./signature":82,"bn.js":21,"hmac-drbg":104}],81:[function(require,module,exports){
16421'use strict';
16422
16423var BN = require('bn.js');
16424var elliptic = require('../../elliptic');
16425var utils = elliptic.utils;
16426var assert = utils.assert;
16427
16428function KeyPair(ec, options) {
16429 this.ec = ec;
16430 this.priv = null;
16431 this.pub = null;
16432
16433 // KeyPair(ec, { priv: ..., pub: ... })
16434 if (options.priv)
16435 this._importPrivate(options.priv, options.privEnc);
16436 if (options.pub)
16437 this._importPublic(options.pub, options.pubEnc);
16438}
16439module.exports = KeyPair;
16440
16441KeyPair.fromPublic = function fromPublic(ec, pub, enc) {
16442 if (pub instanceof KeyPair)
16443 return pub;
16444
16445 return new KeyPair(ec, {
16446 pub: pub,
16447 pubEnc: enc
16448 });
16449};
16450
16451KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) {
16452 if (priv instanceof KeyPair)
16453 return priv;
16454
16455 return new KeyPair(ec, {
16456 priv: priv,
16457 privEnc: enc
16458 });
16459};
16460
16461KeyPair.prototype.validate = function validate() {
16462 var pub = this.getPublic();
16463
16464 if (pub.isInfinity())
16465 return { result: false, reason: 'Invalid public key' };
16466 if (!pub.validate())
16467 return { result: false, reason: 'Public key is not a point' };
16468 if (!pub.mul(this.ec.curve.n).isInfinity())
16469 return { result: false, reason: 'Public key * N != O' };
16470
16471 return { result: true, reason: null };
16472};
16473
16474KeyPair.prototype.getPublic = function getPublic(compact, enc) {
16475 // compact is optional argument
16476 if (typeof compact === 'string') {
16477 enc = compact;
16478 compact = null;
16479 }
16480
16481 if (!this.pub)
16482 this.pub = this.ec.g.mul(this.priv);
16483
16484 if (!enc)
16485 return this.pub;
16486
16487 return this.pub.encode(enc, compact);
16488};
16489
16490KeyPair.prototype.getPrivate = function getPrivate(enc) {
16491 if (enc === 'hex')
16492 return this.priv.toString(16, 2);
16493 else
16494 return this.priv;
16495};
16496
16497KeyPair.prototype._importPrivate = function _importPrivate(key, enc) {
16498 this.priv = new BN(key, enc || 16);
16499
16500 // Ensure that the priv won't be bigger than n, otherwise we may fail
16501 // in fixed multiplication method
16502 this.priv = this.priv.umod(this.ec.curve.n);
16503};
16504
16505KeyPair.prototype._importPublic = function _importPublic(key, enc) {
16506 if (key.x || key.y) {
16507 // Montgomery points only have an `x` coordinate.
16508 // Weierstrass/Edwards points on the other hand have both `x` and
16509 // `y` coordinates.
16510 if (this.ec.curve.type === 'mont') {
16511 assert(key.x, 'Need x coordinate');
16512 } else if (this.ec.curve.type === 'short' ||
16513 this.ec.curve.type === 'edwards') {
16514 assert(key.x && key.y, 'Need both x and y coordinate');
16515 }
16516 this.pub = this.ec.curve.point(key.x, key.y);
16517 return;
16518 }
16519 this.pub = this.ec.curve.decodePoint(key, enc);
16520};
16521
16522// ECDH
16523KeyPair.prototype.derive = function derive(pub) {
16524 return pub.mul(this.priv).getX();
16525};
16526
16527// ECDSA
16528KeyPair.prototype.sign = function sign(msg, enc, options) {
16529 return this.ec.sign(msg, this, enc, options);
16530};
16531
16532KeyPair.prototype.verify = function verify(msg, signature) {
16533 return this.ec.verify(msg, signature, this);
16534};
16535
16536KeyPair.prototype.inspect = function inspect() {
16537 return '<Key priv: ' + (this.priv && this.priv.toString(16, 2)) +
16538 ' pub: ' + (this.pub && this.pub.inspect()) + ' >';
16539};
16540
16541},{"../../elliptic":73,"bn.js":21}],82:[function(require,module,exports){
16542'use strict';
16543
16544var BN = require('bn.js');
16545
16546var elliptic = require('../../elliptic');
16547var utils = elliptic.utils;
16548var assert = utils.assert;
16549
16550function Signature(options, enc) {
16551 if (options instanceof Signature)
16552 return options;
16553
16554 if (this._importDER(options, enc))
16555 return;
16556
16557 assert(options.r && options.s, 'Signature without r or s');
16558 this.r = new BN(options.r, 16);
16559 this.s = new BN(options.s, 16);
16560 if (options.recoveryParam === undefined)
16561 this.recoveryParam = null;
16562 else
16563 this.recoveryParam = options.recoveryParam;
16564}
16565module.exports = Signature;
16566
16567function Position() {
16568 this.place = 0;
16569}
16570
16571function getLength(buf, p) {
16572 var initial = buf[p.place++];
16573 if (!(initial & 0x80)) {
16574 return initial;
16575 }
16576 var octetLen = initial & 0xf;
16577 var val = 0;
16578 for (var i = 0, off = p.place; i < octetLen; i++, off++) {
16579 val <<= 8;
16580 val |= buf[off];
16581 }
16582 p.place = off;
16583 return val;
16584}
16585
16586function rmPadding(buf) {
16587 var i = 0;
16588 var len = buf.length - 1;
16589 while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) {
16590 i++;
16591 }
16592 if (i === 0) {
16593 return buf;
16594 }
16595 return buf.slice(i);
16596}
16597
16598Signature.prototype._importDER = function _importDER(data, enc) {
16599 data = utils.toArray(data, enc);
16600 var p = new Position();
16601 if (data[p.place++] !== 0x30) {
16602 return false;
16603 }
16604 var len = getLength(data, p);
16605 if ((len + p.place) !== data.length) {
16606 return false;
16607 }
16608 if (data[p.place++] !== 0x02) {
16609 return false;
16610 }
16611 var rlen = getLength(data, p);
16612 var r = data.slice(p.place, rlen + p.place);
16613 p.place += rlen;
16614 if (data[p.place++] !== 0x02) {
16615 return false;
16616 }
16617 var slen = getLength(data, p);
16618 if (data.length !== slen + p.place) {
16619 return false;
16620 }
16621 var s = data.slice(p.place, slen + p.place);
16622 if (r[0] === 0 && (r[1] & 0x80)) {
16623 r = r.slice(1);
16624 }
16625 if (s[0] === 0 && (s[1] & 0x80)) {
16626 s = s.slice(1);
16627 }
16628
16629 this.r = new BN(r);
16630 this.s = new BN(s);
16631 this.recoveryParam = null;
16632
16633 return true;
16634};
16635
16636function constructLength(arr, len) {
16637 if (len < 0x80) {
16638 arr.push(len);
16639 return;
16640 }
16641 var octets = 1 + (Math.log(len) / Math.LN2 >>> 3);
16642 arr.push(octets | 0x80);
16643 while (--octets) {
16644 arr.push((len >>> (octets << 3)) & 0xff);
16645 }
16646 arr.push(len);
16647}
16648
16649Signature.prototype.toDER = function toDER(enc) {
16650 var r = this.r.toArray();
16651 var s = this.s.toArray();
16652
16653 // Pad values
16654 if (r[0] & 0x80)
16655 r = [ 0 ].concat(r);
16656 // Pad values
16657 if (s[0] & 0x80)
16658 s = [ 0 ].concat(s);
16659
16660 r = rmPadding(r);
16661 s = rmPadding(s);
16662
16663 while (!s[0] && !(s[1] & 0x80)) {
16664 s = s.slice(1);
16665 }
16666 var arr = [ 0x02 ];
16667 constructLength(arr, r.length);
16668 arr = arr.concat(r);
16669 arr.push(0x02);
16670 constructLength(arr, s.length);
16671 var backHalf = arr.concat(s);
16672 var res = [ 0x30 ];
16673 constructLength(res, backHalf.length);
16674 res = res.concat(backHalf);
16675 return utils.encode(res, enc);
16676};
16677
16678},{"../../elliptic":73,"bn.js":21}],83:[function(require,module,exports){
16679'use strict';
16680
16681var hash = require('hash.js');
16682var elliptic = require('../../elliptic');
16683var utils = elliptic.utils;
16684var assert = utils.assert;
16685var parseBytes = utils.parseBytes;
16686var KeyPair = require('./key');
16687var Signature = require('./signature');
16688
16689function EDDSA(curve) {
16690 assert(curve === 'ed25519', 'only tested with ed25519 so far');
16691
16692 if (!(this instanceof EDDSA))
16693 return new EDDSA(curve);
16694
16695 var curve = elliptic.curves[curve].curve;
16696 this.curve = curve;
16697 this.g = curve.g;
16698 this.g.precompute(curve.n.bitLength() + 1);
16699
16700 this.pointClass = curve.point().constructor;
16701 this.encodingLength = Math.ceil(curve.n.bitLength() / 8);
16702 this.hash = hash.sha512;
16703}
16704
16705module.exports = EDDSA;
16706
16707/**
16708* @param {Array|String} message - message bytes
16709* @param {Array|String|KeyPair} secret - secret bytes or a keypair
16710* @returns {Signature} - signature
16711*/
16712EDDSA.prototype.sign = function sign(message, secret) {
16713 message = parseBytes(message);
16714 var key = this.keyFromSecret(secret);
16715 var r = this.hashInt(key.messagePrefix(), message);
16716 var R = this.g.mul(r);
16717 var Rencoded = this.encodePoint(R);
16718 var s_ = this.hashInt(Rencoded, key.pubBytes(), message)
16719 .mul(key.priv());
16720 var S = r.add(s_).umod(this.curve.n);
16721 return this.makeSignature({ R: R, S: S, Rencoded: Rencoded });
16722};
16723
16724/**
16725* @param {Array} message - message bytes
16726* @param {Array|String|Signature} sig - sig bytes
16727* @param {Array|String|Point|KeyPair} pub - public key
16728* @returns {Boolean} - true if public key matches sig of message
16729*/
16730EDDSA.prototype.verify = function verify(message, sig, pub) {
16731 message = parseBytes(message);
16732 sig = this.makeSignature(sig);
16733 var key = this.keyFromPublic(pub);
16734 var h = this.hashInt(sig.Rencoded(), key.pubBytes(), message);
16735 var SG = this.g.mul(sig.S());
16736 var RplusAh = sig.R().add(key.pub().mul(h));
16737 return RplusAh.eq(SG);
16738};
16739
16740EDDSA.prototype.hashInt = function hashInt() {
16741 var hash = this.hash();
16742 for (var i = 0; i < arguments.length; i++)
16743 hash.update(arguments[i]);
16744 return utils.intFromLE(hash.digest()).umod(this.curve.n);
16745};
16746
16747EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) {
16748 return KeyPair.fromPublic(this, pub);
16749};
16750
16751EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) {
16752 return KeyPair.fromSecret(this, secret);
16753};
16754
16755EDDSA.prototype.makeSignature = function makeSignature(sig) {
16756 if (sig instanceof Signature)
16757 return sig;
16758 return new Signature(this, sig);
16759};
16760
16761/**
16762* * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.2
16763*
16764* EDDSA defines methods for encoding and decoding points and integers. These are
16765* helper convenience methods, that pass along to utility functions implied
16766* parameters.
16767*
16768*/
16769EDDSA.prototype.encodePoint = function encodePoint(point) {
16770 var enc = point.getY().toArray('le', this.encodingLength);
16771 enc[this.encodingLength - 1] |= point.getX().isOdd() ? 0x80 : 0;
16772 return enc;
16773};
16774
16775EDDSA.prototype.decodePoint = function decodePoint(bytes) {
16776 bytes = utils.parseBytes(bytes);
16777
16778 var lastIx = bytes.length - 1;
16779 var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80);
16780 var xIsOdd = (bytes[lastIx] & 0x80) !== 0;
16781
16782 var y = utils.intFromLE(normed);
16783 return this.curve.pointFromY(y, xIsOdd);
16784};
16785
16786EDDSA.prototype.encodeInt = function encodeInt(num) {
16787 return num.toArray('le', this.encodingLength);
16788};
16789
16790EDDSA.prototype.decodeInt = function decodeInt(bytes) {
16791 return utils.intFromLE(bytes);
16792};
16793
16794EDDSA.prototype.isPoint = function isPoint(val) {
16795 return val instanceof this.pointClass;
16796};
16797
16798},{"../../elliptic":73,"./key":84,"./signature":85,"hash.js":92}],84:[function(require,module,exports){
16799'use strict';
16800
16801var elliptic = require('../../elliptic');
16802var utils = elliptic.utils;
16803var assert = utils.assert;
16804var parseBytes = utils.parseBytes;
16805var cachedProperty = utils.cachedProperty;
16806
16807/**
16808* @param {EDDSA} eddsa - instance
16809* @param {Object} params - public/private key parameters
16810*
16811* @param {Array<Byte>} [params.secret] - secret seed bytes
16812* @param {Point} [params.pub] - public key point (aka `A` in eddsa terms)
16813* @param {Array<Byte>} [params.pub] - public key point encoded as bytes
16814*
16815*/
16816function KeyPair(eddsa, params) {
16817 this.eddsa = eddsa;
16818 this._secret = parseBytes(params.secret);
16819 if (eddsa.isPoint(params.pub))
16820 this._pub = params.pub;
16821 else
16822 this._pubBytes = parseBytes(params.pub);
16823}
16824
16825KeyPair.fromPublic = function fromPublic(eddsa, pub) {
16826 if (pub instanceof KeyPair)
16827 return pub;
16828 return new KeyPair(eddsa, { pub: pub });
16829};
16830
16831KeyPair.fromSecret = function fromSecret(eddsa, secret) {
16832 if (secret instanceof KeyPair)
16833 return secret;
16834 return new KeyPair(eddsa, { secret: secret });
16835};
16836
16837KeyPair.prototype.secret = function secret() {
16838 return this._secret;
16839};
16840
16841cachedProperty(KeyPair, 'pubBytes', function pubBytes() {
16842 return this.eddsa.encodePoint(this.pub());
16843});
16844
16845cachedProperty(KeyPair, 'pub', function pub() {
16846 if (this._pubBytes)
16847 return this.eddsa.decodePoint(this._pubBytes);
16848 return this.eddsa.g.mul(this.priv());
16849});
16850
16851cachedProperty(KeyPair, 'privBytes', function privBytes() {
16852 var eddsa = this.eddsa;
16853 var hash = this.hash();
16854 var lastIx = eddsa.encodingLength - 1;
16855
16856 var a = hash.slice(0, eddsa.encodingLength);
16857 a[0] &= 248;
16858 a[lastIx] &= 127;
16859 a[lastIx] |= 64;
16860
16861 return a;
16862});
16863
16864cachedProperty(KeyPair, 'priv', function priv() {
16865 return this.eddsa.decodeInt(this.privBytes());
16866});
16867
16868cachedProperty(KeyPair, 'hash', function hash() {
16869 return this.eddsa.hash().update(this.secret()).digest();
16870});
16871
16872cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() {
16873 return this.hash().slice(this.eddsa.encodingLength);
16874});
16875
16876KeyPair.prototype.sign = function sign(message) {
16877 assert(this._secret, 'KeyPair can only verify');
16878 return this.eddsa.sign(message, this);
16879};
16880
16881KeyPair.prototype.verify = function verify(message, sig) {
16882 return this.eddsa.verify(message, sig, this);
16883};
16884
16885KeyPair.prototype.getSecret = function getSecret(enc) {
16886 assert(this._secret, 'KeyPair is public only');
16887 return utils.encode(this.secret(), enc);
16888};
16889
16890KeyPair.prototype.getPublic = function getPublic(enc) {
16891 return utils.encode(this.pubBytes(), enc);
16892};
16893
16894module.exports = KeyPair;
16895
16896},{"../../elliptic":73}],85:[function(require,module,exports){
16897'use strict';
16898
16899var BN = require('bn.js');
16900var elliptic = require('../../elliptic');
16901var utils = elliptic.utils;
16902var assert = utils.assert;
16903var cachedProperty = utils.cachedProperty;
16904var parseBytes = utils.parseBytes;
16905
16906/**
16907* @param {EDDSA} eddsa - eddsa instance
16908* @param {Array<Bytes>|Object} sig -
16909* @param {Array<Bytes>|Point} [sig.R] - R point as Point or bytes
16910* @param {Array<Bytes>|bn} [sig.S] - S scalar as bn or bytes
16911* @param {Array<Bytes>} [sig.Rencoded] - R point encoded
16912* @param {Array<Bytes>} [sig.Sencoded] - S scalar encoded
16913*/
16914function Signature(eddsa, sig) {
16915 this.eddsa = eddsa;
16916
16917 if (typeof sig !== 'object')
16918 sig = parseBytes(sig);
16919
16920 if (Array.isArray(sig)) {
16921 sig = {
16922 R: sig.slice(0, eddsa.encodingLength),
16923 S: sig.slice(eddsa.encodingLength)
16924 };
16925 }
16926
16927 assert(sig.R && sig.S, 'Signature without R or S');
16928
16929 if (eddsa.isPoint(sig.R))
16930 this._R = sig.R;
16931 if (sig.S instanceof BN)
16932 this._S = sig.S;
16933
16934 this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded;
16935 this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded;
16936}
16937
16938cachedProperty(Signature, 'S', function S() {
16939 return this.eddsa.decodeInt(this.Sencoded());
16940});
16941
16942cachedProperty(Signature, 'R', function R() {
16943 return this.eddsa.decodePoint(this.Rencoded());
16944});
16945
16946cachedProperty(Signature, 'Rencoded', function Rencoded() {
16947 return this.eddsa.encodePoint(this.R());
16948});
16949
16950cachedProperty(Signature, 'Sencoded', function Sencoded() {
16951 return this.eddsa.encodeInt(this.S());
16952});
16953
16954Signature.prototype.toBytes = function toBytes() {
16955 return this.Rencoded().concat(this.Sencoded());
16956};
16957
16958Signature.prototype.toHex = function toHex() {
16959 return utils.encode(this.toBytes(), 'hex').toUpperCase();
16960};
16961
16962module.exports = Signature;
16963
16964},{"../../elliptic":73,"bn.js":21}],86:[function(require,module,exports){
16965module.exports = {
16966 doubles: {
16967 step: 4,
16968 points: [
16969 [
16970 'e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a',
16971 'f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821'
16972 ],
16973 [
16974 '8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508',
16975 '11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf'
16976 ],
16977 [
16978 '175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739',
16979 'd3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695'
16980 ],
16981 [
16982 '363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640',
16983 '4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9'
16984 ],
16985 [
16986 '8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c',
16987 '4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36'
16988 ],
16989 [
16990 '723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda',
16991 '96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f'
16992 ],
16993 [
16994 'eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa',
16995 '5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999'
16996 ],
16997 [
16998 '100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0',
16999 'cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09'
17000 ],
17001 [
17002 'e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d',
17003 '9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d'
17004 ],
17005 [
17006 'feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d',
17007 'e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088'
17008 ],
17009 [
17010 'da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1',
17011 '9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d'
17012 ],
17013 [
17014 '53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0',
17015 '5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8'
17016 ],
17017 [
17018 '8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047',
17019 '10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a'
17020 ],
17021 [
17022 '385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862',
17023 '283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453'
17024 ],
17025 [
17026 '6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7',
17027 '7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160'
17028 ],
17029 [
17030 '3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd',
17031 '56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0'
17032 ],
17033 [
17034 '85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83',
17035 '7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6'
17036 ],
17037 [
17038 '948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a',
17039 '53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589'
17040 ],
17041 [
17042 '6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8',
17043 'bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17'
17044 ],
17045 [
17046 'e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d',
17047 '4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda'
17048 ],
17049 [
17050 'e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725',
17051 '7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd'
17052 ],
17053 [
17054 '213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754',
17055 '4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2'
17056 ],
17057 [
17058 '4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c',
17059 '17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6'
17060 ],
17061 [
17062 'fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6',
17063 '6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f'
17064 ],
17065 [
17066 '76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39',
17067 'c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01'
17068 ],
17069 [
17070 'c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891',
17071 '893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3'
17072 ],
17073 [
17074 'd895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b',
17075 'febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f'
17076 ],
17077 [
17078 'b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03',
17079 '2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7'
17080 ],
17081 [
17082 'e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d',
17083 'eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78'
17084 ],
17085 [
17086 'a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070',
17087 '7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1'
17088 ],
17089 [
17090 '90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4',
17091 'e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150'
17092 ],
17093 [
17094 '8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da',
17095 '662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82'
17096 ],
17097 [
17098 'e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11',
17099 '1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc'
17100 ],
17101 [
17102 '8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e',
17103 'efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b'
17104 ],
17105 [
17106 'e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41',
17107 '2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51'
17108 ],
17109 [
17110 'b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef',
17111 '67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45'
17112 ],
17113 [
17114 'd68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8',
17115 'db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120'
17116 ],
17117 [
17118 '324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d',
17119 '648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84'
17120 ],
17121 [
17122 '4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96',
17123 '35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d'
17124 ],
17125 [
17126 '9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd',
17127 'ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d'
17128 ],
17129 [
17130 '6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5',
17131 '9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8'
17132 ],
17133 [
17134 'a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266',
17135 '40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8'
17136 ],
17137 [
17138 '7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71',
17139 '34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac'
17140 ],
17141 [
17142 '928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac',
17143 'c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f'
17144 ],
17145 [
17146 '85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751',
17147 '1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962'
17148 ],
17149 [
17150 'ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e',
17151 '493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907'
17152 ],
17153 [
17154 '827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241',
17155 'c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec'
17156 ],
17157 [
17158 'eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3',
17159 'be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d'
17160 ],
17161 [
17162 'e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f',
17163 '4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414'
17164 ],
17165 [
17166 '1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19',
17167 'aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd'
17168 ],
17169 [
17170 '146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be',
17171 'b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0'
17172 ],
17173 [
17174 'fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9',
17175 '6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811'
17176 ],
17177 [
17178 'da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2',
17179 '8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1'
17180 ],
17181 [
17182 'a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13',
17183 '7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c'
17184 ],
17185 [
17186 '174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c',
17187 'ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73'
17188 ],
17189 [
17190 '959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba',
17191 '2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd'
17192 ],
17193 [
17194 'd2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151',
17195 'e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405'
17196 ],
17197 [
17198 '64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073',
17199 'd99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589'
17200 ],
17201 [
17202 '8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458',
17203 '38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e'
17204 ],
17205 [
17206 '13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b',
17207 '69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27'
17208 ],
17209 [
17210 'bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366',
17211 'd3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1'
17212 ],
17213 [
17214 '8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa',
17215 '40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482'
17216 ],
17217 [
17218 '8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0',
17219 '620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945'
17220 ],
17221 [
17222 'dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787',
17223 '7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573'
17224 ],
17225 [
17226 'f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e',
17227 'ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82'
17228 ]
17229 ]
17230 },
17231 naf: {
17232 wnd: 7,
17233 points: [
17234 [
17235 'f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9',
17236 '388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672'
17237 ],
17238 [
17239 '2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4',
17240 'd8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6'
17241 ],
17242 [
17243 '5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc',
17244 '6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da'
17245 ],
17246 [
17247 'acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe',
17248 'cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37'
17249 ],
17250 [
17251 '774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb',
17252 'd984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b'
17253 ],
17254 [
17255 'f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8',
17256 'ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81'
17257 ],
17258 [
17259 'd7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e',
17260 '581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58'
17261 ],
17262 [
17263 'defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34',
17264 '4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77'
17265 ],
17266 [
17267 '2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c',
17268 '85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a'
17269 ],
17270 [
17271 '352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5',
17272 '321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c'
17273 ],
17274 [
17275 '2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f',
17276 '2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67'
17277 ],
17278 [
17279 '9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714',
17280 '73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402'
17281 ],
17282 [
17283 'daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729',
17284 'a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55'
17285 ],
17286 [
17287 'c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db',
17288 '2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482'
17289 ],
17290 [
17291 '6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4',
17292 'e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82'
17293 ],
17294 [
17295 '1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5',
17296 'b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396'
17297 ],
17298 [
17299 '605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479',
17300 '2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49'
17301 ],
17302 [
17303 '62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d',
17304 '80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf'
17305 ],
17306 [
17307 '80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f',
17308 '1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a'
17309 ],
17310 [
17311 '7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb',
17312 'd0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7'
17313 ],
17314 [
17315 'd528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9',
17316 'eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933'
17317 ],
17318 [
17319 '49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963',
17320 '758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a'
17321 ],
17322 [
17323 '77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74',
17324 '958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6'
17325 ],
17326 [
17327 'f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530',
17328 'e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37'
17329 ],
17330 [
17331 '463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b',
17332 '5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e'
17333 ],
17334 [
17335 'f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247',
17336 'cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6'
17337 ],
17338 [
17339 'caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1',
17340 'cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476'
17341 ],
17342 [
17343 '2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120',
17344 '4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40'
17345 ],
17346 [
17347 '7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435',
17348 '91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61'
17349 ],
17350 [
17351 '754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18',
17352 '673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683'
17353 ],
17354 [
17355 'e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8',
17356 '59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5'
17357 ],
17358 [
17359 '186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb',
17360 '3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b'
17361 ],
17362 [
17363 'df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f',
17364 '55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417'
17365 ],
17366 [
17367 '5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143',
17368 'efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868'
17369 ],
17370 [
17371 '290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba',
17372 'e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a'
17373 ],
17374 [
17375 'af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45',
17376 'f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6'
17377 ],
17378 [
17379 '766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a',
17380 '744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996'
17381 ],
17382 [
17383 '59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e',
17384 'c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e'
17385 ],
17386 [
17387 'f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8',
17388 'e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d'
17389 ],
17390 [
17391 '7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c',
17392 '30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2'
17393 ],
17394 [
17395 '948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519',
17396 'e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e'
17397 ],
17398 [
17399 '7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab',
17400 '100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437'
17401 ],
17402 [
17403 '3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca',
17404 'ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311'
17405 ],
17406 [
17407 'd3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf',
17408 '8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4'
17409 ],
17410 [
17411 '1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610',
17412 '68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575'
17413 ],
17414 [
17415 '733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4',
17416 'f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d'
17417 ],
17418 [
17419 '15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c',
17420 'd56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d'
17421 ],
17422 [
17423 'a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940',
17424 'edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629'
17425 ],
17426 [
17427 'e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980',
17428 'a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06'
17429 ],
17430 [
17431 '311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3',
17432 '66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374'
17433 ],
17434 [
17435 '34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf',
17436 '9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee'
17437 ],
17438 [
17439 'f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63',
17440 '4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1'
17441 ],
17442 [
17443 'd7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448',
17444 'fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b'
17445 ],
17446 [
17447 '32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf',
17448 '5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661'
17449 ],
17450 [
17451 '7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5',
17452 '8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6'
17453 ],
17454 [
17455 'ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6',
17456 '8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e'
17457 ],
17458 [
17459 '16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5',
17460 '5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d'
17461 ],
17462 [
17463 'eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99',
17464 'f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc'
17465 ],
17466 [
17467 '78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51',
17468 'f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4'
17469 ],
17470 [
17471 '494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5',
17472 '42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c'
17473 ],
17474 [
17475 'a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5',
17476 '204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b'
17477 ],
17478 [
17479 'c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997',
17480 '4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913'
17481 ],
17482 [
17483 '841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881',
17484 '73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154'
17485 ],
17486 [
17487 '5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5',
17488 '39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865'
17489 ],
17490 [
17491 '36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66',
17492 'd2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc'
17493 ],
17494 [
17495 '336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726',
17496 'ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224'
17497 ],
17498 [
17499 '8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede',
17500 '6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e'
17501 ],
17502 [
17503 '1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94',
17504 '60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6'
17505 ],
17506 [
17507 '85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31',
17508 '3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511'
17509 ],
17510 [
17511 '29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51',
17512 'b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b'
17513 ],
17514 [
17515 'a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252',
17516 'ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2'
17517 ],
17518 [
17519 '4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5',
17520 'cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c'
17521 ],
17522 [
17523 'd24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b',
17524 '6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3'
17525 ],
17526 [
17527 'ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4',
17528 '322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d'
17529 ],
17530 [
17531 'af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f',
17532 '6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700'
17533 ],
17534 [
17535 'e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889',
17536 '2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4'
17537 ],
17538 [
17539 '591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246',
17540 'b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196'
17541 ],
17542 [
17543 '11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984',
17544 '998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4'
17545 ],
17546 [
17547 '3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a',
17548 'b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257'
17549 ],
17550 [
17551 'cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030',
17552 'bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13'
17553 ],
17554 [
17555 'c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197',
17556 '6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096'
17557 ],
17558 [
17559 'c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593',
17560 'c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38'
17561 ],
17562 [
17563 'a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef',
17564 '21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f'
17565 ],
17566 [
17567 '347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38',
17568 '60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448'
17569 ],
17570 [
17571 'da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a',
17572 '49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a'
17573 ],
17574 [
17575 'c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111',
17576 '5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4'
17577 ],
17578 [
17579 '4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502',
17580 '7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437'
17581 ],
17582 [
17583 '3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea',
17584 'be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7'
17585 ],
17586 [
17587 'cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26',
17588 '8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d'
17589 ],
17590 [
17591 'b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986',
17592 '39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a'
17593 ],
17594 [
17595 'd4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e',
17596 '62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54'
17597 ],
17598 [
17599 '48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4',
17600 '25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77'
17601 ],
17602 [
17603 'dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda',
17604 'ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517'
17605 ],
17606 [
17607 '6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859',
17608 'cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10'
17609 ],
17610 [
17611 'e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f',
17612 'f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125'
17613 ],
17614 [
17615 'eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c',
17616 '6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e'
17617 ],
17618 [
17619 '13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942',
17620 'fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1'
17621 ],
17622 [
17623 'ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a',
17624 '1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2'
17625 ],
17626 [
17627 'b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80',
17628 '5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423'
17629 ],
17630 [
17631 'ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d',
17632 '438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8'
17633 ],
17634 [
17635 '8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1',
17636 'cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758'
17637 ],
17638 [
17639 '52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63',
17640 'c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375'
17641 ],
17642 [
17643 'e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352',
17644 '6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d'
17645 ],
17646 [
17647 '7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193',
17648 'ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec'
17649 ],
17650 [
17651 '5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00',
17652 '9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0'
17653 ],
17654 [
17655 '32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58',
17656 'ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c'
17657 ],
17658 [
17659 'e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7',
17660 'd3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4'
17661 ],
17662 [
17663 '8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8',
17664 'c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f'
17665 ],
17666 [
17667 '4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e',
17668 '67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649'
17669 ],
17670 [
17671 '3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d',
17672 'cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826'
17673 ],
17674 [
17675 '674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b',
17676 '299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5'
17677 ],
17678 [
17679 'd32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f',
17680 'f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87'
17681 ],
17682 [
17683 '30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6',
17684 '462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b'
17685 ],
17686 [
17687 'be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297',
17688 '62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc'
17689 ],
17690 [
17691 '93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a',
17692 '7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c'
17693 ],
17694 [
17695 'b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c',
17696 'ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f'
17697 ],
17698 [
17699 'd5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52',
17700 '4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a'
17701 ],
17702 [
17703 'd3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb',
17704 'bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46'
17705 ],
17706 [
17707 '463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065',
17708 'bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f'
17709 ],
17710 [
17711 '7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917',
17712 '603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03'
17713 ],
17714 [
17715 '74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9',
17716 'cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08'
17717 ],
17718 [
17719 '30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3',
17720 '553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8'
17721 ],
17722 [
17723 '9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57',
17724 '712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373'
17725 ],
17726 [
17727 '176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66',
17728 'ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3'
17729 ],
17730 [
17731 '75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8',
17732 '9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8'
17733 ],
17734 [
17735 '809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721',
17736 '9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1'
17737 ],
17738 [
17739 '1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180',
17740 '4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9'
17741 ]
17742 ]
17743 }
17744};
17745
17746},{}],87:[function(require,module,exports){
17747'use strict';
17748
17749var utils = exports;
17750var BN = require('bn.js');
17751var minAssert = require('minimalistic-assert');
17752var minUtils = require('minimalistic-crypto-utils');
17753
17754utils.assert = minAssert;
17755utils.toArray = minUtils.toArray;
17756utils.zero2 = minUtils.zero2;
17757utils.toHex = minUtils.toHex;
17758utils.encode = minUtils.encode;
17759
17760// Represent num in a w-NAF form
17761function getNAF(num, w) {
17762 var naf = [];
17763 var ws = 1 << (w + 1);
17764 var k = num.clone();
17765 while (k.cmpn(1) >= 0) {
17766 var z;
17767 if (k.isOdd()) {
17768 var mod = k.andln(ws - 1);
17769 if (mod > (ws >> 1) - 1)
17770 z = (ws >> 1) - mod;
17771 else
17772 z = mod;
17773 k.isubn(z);
17774 } else {
17775 z = 0;
17776 }
17777 naf.push(z);
17778
17779 // Optimization, shift by word if possible
17780 var shift = (k.cmpn(0) !== 0 && k.andln(ws - 1) === 0) ? (w + 1) : 1;
17781 for (var i = 1; i < shift; i++)
17782 naf.push(0);
17783 k.iushrn(shift);
17784 }
17785
17786 return naf;
17787}
17788utils.getNAF = getNAF;
17789
17790// Represent k1, k2 in a Joint Sparse Form
17791function getJSF(k1, k2) {
17792 var jsf = [
17793 [],
17794 []
17795 ];
17796
17797 k1 = k1.clone();
17798 k2 = k2.clone();
17799 var d1 = 0;
17800 var d2 = 0;
17801 while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) {
17802
17803 // First phase
17804 var m14 = (k1.andln(3) + d1) & 3;
17805 var m24 = (k2.andln(3) + d2) & 3;
17806 if (m14 === 3)
17807 m14 = -1;
17808 if (m24 === 3)
17809 m24 = -1;
17810 var u1;
17811 if ((m14 & 1) === 0) {
17812 u1 = 0;
17813 } else {
17814 var m8 = (k1.andln(7) + d1) & 7;
17815 if ((m8 === 3 || m8 === 5) && m24 === 2)
17816 u1 = -m14;
17817 else
17818 u1 = m14;
17819 }
17820 jsf[0].push(u1);
17821
17822 var u2;
17823 if ((m24 & 1) === 0) {
17824 u2 = 0;
17825 } else {
17826 var m8 = (k2.andln(7) + d2) & 7;
17827 if ((m8 === 3 || m8 === 5) && m14 === 2)
17828 u2 = -m24;
17829 else
17830 u2 = m24;
17831 }
17832 jsf[1].push(u2);
17833
17834 // Second phase
17835 if (2 * d1 === u1 + 1)
17836 d1 = 1 - d1;
17837 if (2 * d2 === u2 + 1)
17838 d2 = 1 - d2;
17839 k1.iushrn(1);
17840 k2.iushrn(1);
17841 }
17842
17843 return jsf;
17844}
17845utils.getJSF = getJSF;
17846
17847function cachedProperty(obj, name, computer) {
17848 var key = '_' + name;
17849 obj.prototype[name] = function cachedProperty() {
17850 return this[key] !== undefined ? this[key] :
17851 this[key] = computer.call(this);
17852 };
17853}
17854utils.cachedProperty = cachedProperty;
17855
17856function parseBytes(bytes) {
17857 return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') :
17858 bytes;
17859}
17860utils.parseBytes = parseBytes;
17861
17862function intFromLE(bytes) {
17863 return new BN(bytes, 'hex', 'le');
17864}
17865utils.intFromLE = intFromLE;
17866
17867
17868},{"bn.js":21,"minimalistic-assert":120,"minimalistic-crypto-utils":121}],88:[function(require,module,exports){
17869module.exports={
17870 "_args": [
17871 [
17872 "elliptic@6.4.0",
17873 "/home/gleb/work/cryptocurrencies/nas-hardwallet/neb.js"
17874 ]
17875 ],
17876 "_from": "elliptic@6.4.0",
17877 "_id": "elliptic@6.4.0",
17878 "_inBundle": false,
17879 "_integrity": "sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=",
17880 "_location": "/elliptic",
17881 "_phantomChildren": {},
17882 "_requested": {
17883 "type": "version",
17884 "registry": true,
17885 "raw": "elliptic@6.4.0",
17886 "name": "elliptic",
17887 "escapedName": "elliptic",
17888 "rawSpec": "6.4.0",
17889 "saveSpec": null,
17890 "fetchSpec": "6.4.0"
17891 },
17892 "_requiredBy": [
17893 "/browserify-sign",
17894 "/create-ecdh",
17895 "/secp256k1"
17896 ],
17897 "_resolved": "http://registry.npm.taobao.org/elliptic/download/elliptic-6.4.0.tgz",
17898 "_spec": "6.4.0",
17899 "_where": "/home/gleb/work/cryptocurrencies/nas-hardwallet/neb.js",
17900 "author": {
17901 "name": "Fedor Indutny",
17902 "email": "fedor@indutny.com"
17903 },
17904 "bugs": {
17905 "url": "https://github.com/indutny/elliptic/issues"
17906 },
17907 "dependencies": {
17908 "bn.js": "^4.4.0",
17909 "brorand": "^1.0.1",
17910 "hash.js": "^1.0.0",
17911 "hmac-drbg": "^1.0.0",
17912 "inherits": "^2.0.1",
17913 "minimalistic-assert": "^1.0.0",
17914 "minimalistic-crypto-utils": "^1.0.0"
17915 },
17916 "description": "EC cryptography",
17917 "devDependencies": {
17918 "brfs": "^1.4.3",
17919 "coveralls": "^2.11.3",
17920 "grunt": "^0.4.5",
17921 "grunt-browserify": "^5.0.0",
17922 "grunt-cli": "^1.2.0",
17923 "grunt-contrib-connect": "^1.0.0",
17924 "grunt-contrib-copy": "^1.0.0",
17925 "grunt-contrib-uglify": "^1.0.1",
17926 "grunt-mocha-istanbul": "^3.0.1",
17927 "grunt-saucelabs": "^8.6.2",
17928 "istanbul": "^0.4.2",
17929 "jscs": "^2.9.0",
17930 "jshint": "^2.6.0",
17931 "mocha": "^2.1.0"
17932 },
17933 "files": [
17934 "lib"
17935 ],
17936 "homepage": "https://github.com/indutny/elliptic",
17937 "keywords": [
17938 "EC",
17939 "Elliptic",
17940 "curve",
17941 "Cryptography"
17942 ],
17943 "license": "MIT",
17944 "main": "lib/elliptic.js",
17945 "name": "elliptic",
17946 "repository": {
17947 "type": "git",
17948 "url": "git+ssh://git@github.com/indutny/elliptic.git"
17949 },
17950 "scripts": {
17951 "jscs": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",
17952 "jshint": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",
17953 "lint": "npm run jscs && npm run jshint",
17954 "test": "npm run lint && npm run unit",
17955 "unit": "istanbul test _mocha --reporter=spec test/index.js",
17956 "version": "grunt dist && git add dist/"
17957 },
17958 "version": "6.4.0"
17959}
17960
17961},{}],89:[function(require,module,exports){
17962// Copyright Joyent, Inc. and other Node contributors.
17963//
17964// Permission is hereby granted, free of charge, to any person obtaining a
17965// copy of this software and associated documentation files (the
17966// "Software"), to deal in the Software without restriction, including
17967// without limitation the rights to use, copy, modify, merge, publish,
17968// distribute, sublicense, and/or sell copies of the Software, and to permit
17969// persons to whom the Software is furnished to do so, subject to the
17970// following conditions:
17971//
17972// The above copyright notice and this permission notice shall be included
17973// in all copies or substantial portions of the Software.
17974//
17975// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17976// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17977// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17978// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17979// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
17980// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
17981// USE OR OTHER DEALINGS IN THE SOFTWARE.
17982
17983function EventEmitter() {
17984 this._events = this._events || {};
17985 this._maxListeners = this._maxListeners || undefined;
17986}
17987module.exports = EventEmitter;
17988
17989// Backwards-compat with node 0.10.x
17990EventEmitter.EventEmitter = EventEmitter;
17991
17992EventEmitter.prototype._events = undefined;
17993EventEmitter.prototype._maxListeners = undefined;
17994
17995// By default EventEmitters will print a warning if more than 10 listeners are
17996// added to it. This is a useful default which helps finding memory leaks.
17997EventEmitter.defaultMaxListeners = 10;
17998
17999// Obviously not all Emitters should be limited to 10. This function allows
18000// that to be increased. Set to zero for unlimited.
18001EventEmitter.prototype.setMaxListeners = function(n) {
18002 if (!isNumber(n) || n < 0 || isNaN(n))
18003 throw TypeError('n must be a positive number');
18004 this._maxListeners = n;
18005 return this;
18006};
18007
18008EventEmitter.prototype.emit = function(type) {
18009 var er, handler, len, args, i, listeners;
18010
18011 if (!this._events)
18012 this._events = {};
18013
18014 // If there is no 'error' event listener then throw.
18015 if (type === 'error') {
18016 if (!this._events.error ||
18017 (isObject(this._events.error) && !this._events.error.length)) {
18018 er = arguments[1];
18019 if (er instanceof Error) {
18020 throw er; // Unhandled 'error' event
18021 } else {
18022 // At least give some kind of context to the user
18023 var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
18024 err.context = er;
18025 throw err;
18026 }
18027 }
18028 }
18029
18030 handler = this._events[type];
18031
18032 if (isUndefined(handler))
18033 return false;
18034
18035 if (isFunction(handler)) {
18036 switch (arguments.length) {
18037 // fast cases
18038 case 1:
18039 handler.call(this);
18040 break;
18041 case 2:
18042 handler.call(this, arguments[1]);
18043 break;
18044 case 3:
18045 handler.call(this, arguments[1], arguments[2]);
18046 break;
18047 // slower
18048 default:
18049 args = Array.prototype.slice.call(arguments, 1);
18050 handler.apply(this, args);
18051 }
18052 } else if (isObject(handler)) {
18053 args = Array.prototype.slice.call(arguments, 1);
18054 listeners = handler.slice();
18055 len = listeners.length;
18056 for (i = 0; i < len; i++)
18057 listeners[i].apply(this, args);
18058 }
18059
18060 return true;
18061};
18062
18063EventEmitter.prototype.addListener = function(type, listener) {
18064 var m;
18065
18066 if (!isFunction(listener))
18067 throw TypeError('listener must be a function');
18068
18069 if (!this._events)
18070 this._events = {};
18071
18072 // To avoid recursion in the case that type === "newListener"! Before
18073 // adding it to the listeners, first emit "newListener".
18074 if (this._events.newListener)
18075 this.emit('newListener', type,
18076 isFunction(listener.listener) ?
18077 listener.listener : listener);
18078
18079 if (!this._events[type])
18080 // Optimize the case of one listener. Don't need the extra array object.
18081 this._events[type] = listener;
18082 else if (isObject(this._events[type]))
18083 // If we've already got an array, just append.
18084 this._events[type].push(listener);
18085 else
18086 // Adding the second element, need to change to array.
18087 this._events[type] = [this._events[type], listener];
18088
18089 // Check for listener leak
18090 if (isObject(this._events[type]) && !this._events[type].warned) {
18091 if (!isUndefined(this._maxListeners)) {
18092 m = this._maxListeners;
18093 } else {
18094 m = EventEmitter.defaultMaxListeners;
18095 }
18096
18097 if (m && m > 0 && this._events[type].length > m) {
18098 this._events[type].warned = true;
18099 console.error('(node) warning: possible EventEmitter memory ' +
18100 'leak detected. %d listeners added. ' +
18101 'Use emitter.setMaxListeners() to increase limit.',
18102 this._events[type].length);
18103 if (typeof console.trace === 'function') {
18104 // not supported in IE 10
18105 console.trace();
18106 }
18107 }
18108 }
18109
18110 return this;
18111};
18112
18113EventEmitter.prototype.on = EventEmitter.prototype.addListener;
18114
18115EventEmitter.prototype.once = function(type, listener) {
18116 if (!isFunction(listener))
18117 throw TypeError('listener must be a function');
18118
18119 var fired = false;
18120
18121 function g() {
18122 this.removeListener(type, g);
18123
18124 if (!fired) {
18125 fired = true;
18126 listener.apply(this, arguments);
18127 }
18128 }
18129
18130 g.listener = listener;
18131 this.on(type, g);
18132
18133 return this;
18134};
18135
18136// emits a 'removeListener' event iff the listener was removed
18137EventEmitter.prototype.removeListener = function(type, listener) {
18138 var list, position, length, i;
18139
18140 if (!isFunction(listener))
18141 throw TypeError('listener must be a function');
18142
18143 if (!this._events || !this._events[type])
18144 return this;
18145
18146 list = this._events[type];
18147 length = list.length;
18148 position = -1;
18149
18150 if (list === listener ||
18151 (isFunction(list.listener) && list.listener === listener)) {
18152 delete this._events[type];
18153 if (this._events.removeListener)
18154 this.emit('removeListener', type, listener);
18155
18156 } else if (isObject(list)) {
18157 for (i = length; i-- > 0;) {
18158 if (list[i] === listener ||
18159 (list[i].listener && list[i].listener === listener)) {
18160 position = i;
18161 break;
18162 }
18163 }
18164
18165 if (position < 0)
18166 return this;
18167
18168 if (list.length === 1) {
18169 list.length = 0;
18170 delete this._events[type];
18171 } else {
18172 list.splice(position, 1);
18173 }
18174
18175 if (this._events.removeListener)
18176 this.emit('removeListener', type, listener);
18177 }
18178
18179 return this;
18180};
18181
18182EventEmitter.prototype.removeAllListeners = function(type) {
18183 var key, listeners;
18184
18185 if (!this._events)
18186 return this;
18187
18188 // not listening for removeListener, no need to emit
18189 if (!this._events.removeListener) {
18190 if (arguments.length === 0)
18191 this._events = {};
18192 else if (this._events[type])
18193 delete this._events[type];
18194 return this;
18195 }
18196
18197 // emit removeListener for all listeners on all events
18198 if (arguments.length === 0) {
18199 for (key in this._events) {
18200 if (key === 'removeListener') continue;
18201 this.removeAllListeners(key);
18202 }
18203 this.removeAllListeners('removeListener');
18204 this._events = {};
18205 return this;
18206 }
18207
18208 listeners = this._events[type];
18209
18210 if (isFunction(listeners)) {
18211 this.removeListener(type, listeners);
18212 } else if (listeners) {
18213 // LIFO order
18214 while (listeners.length)
18215 this.removeListener(type, listeners[listeners.length - 1]);
18216 }
18217 delete this._events[type];
18218
18219 return this;
18220};
18221
18222EventEmitter.prototype.listeners = function(type) {
18223 var ret;
18224 if (!this._events || !this._events[type])
18225 ret = [];
18226 else if (isFunction(this._events[type]))
18227 ret = [this._events[type]];
18228 else
18229 ret = this._events[type].slice();
18230 return ret;
18231};
18232
18233EventEmitter.prototype.listenerCount = function(type) {
18234 if (this._events) {
18235 var evlistener = this._events[type];
18236
18237 if (isFunction(evlistener))
18238 return 1;
18239 else if (evlistener)
18240 return evlistener.length;
18241 }
18242 return 0;
18243};
18244
18245EventEmitter.listenerCount = function(emitter, type) {
18246 return emitter.listenerCount(type);
18247};
18248
18249function isFunction(arg) {
18250 return typeof arg === 'function';
18251}
18252
18253function isNumber(arg) {
18254 return typeof arg === 'number';
18255}
18256
18257function isObject(arg) {
18258 return typeof arg === 'object' && arg !== null;
18259}
18260
18261function isUndefined(arg) {
18262 return arg === void 0;
18263}
18264
18265},{}],90:[function(require,module,exports){
18266var Buffer = require('safe-buffer').Buffer
18267var MD5 = require('md5.js')
18268
18269/* eslint-disable camelcase */
18270function EVP_BytesToKey (password, salt, keyBits, ivLen) {
18271 if (!Buffer.isBuffer(password)) password = Buffer.from(password, 'binary')
18272 if (salt) {
18273 if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, 'binary')
18274 if (salt.length !== 8) throw new RangeError('salt should be Buffer with 8 byte length')
18275 }
18276
18277 var keyLen = keyBits / 8
18278 var key = Buffer.alloc(keyLen)
18279 var iv = Buffer.alloc(ivLen || 0)
18280 var tmp = Buffer.alloc(0)
18281
18282 while (keyLen > 0 || ivLen > 0) {
18283 var hash = new MD5()
18284 hash.update(tmp)
18285 hash.update(password)
18286 if (salt) hash.update(salt)
18287 tmp = hash.digest()
18288
18289 var used = 0
18290
18291 if (keyLen > 0) {
18292 var keyStart = key.length - keyLen
18293 used = Math.min(keyLen, tmp.length)
18294 tmp.copy(key, keyStart, 0, used)
18295 keyLen -= used
18296 }
18297
18298 if (used < tmp.length && ivLen > 0) {
18299 var ivStart = iv.length - ivLen
18300 var length = Math.min(ivLen, tmp.length - used)
18301 tmp.copy(iv, ivStart, used, used + length)
18302 ivLen -= length
18303 }
18304 }
18305
18306 tmp.fill(0)
18307 return { key: key, iv: iv }
18308}
18309
18310module.exports = EVP_BytesToKey
18311
18312},{"md5.js":117,"safe-buffer":156}],91:[function(require,module,exports){
18313(function (Buffer){
18314'use strict'
18315var Transform = require('stream').Transform
18316var inherits = require('inherits')
18317
18318function HashBase (blockSize) {
18319 Transform.call(this)
18320
18321 this._block = new Buffer(blockSize)
18322 this._blockSize = blockSize
18323 this._blockOffset = 0
18324 this._length = [0, 0, 0, 0]
18325
18326 this._finalized = false
18327}
18328
18329inherits(HashBase, Transform)
18330
18331HashBase.prototype._transform = function (chunk, encoding, callback) {
18332 var error = null
18333 try {
18334 if (encoding !== 'buffer') chunk = new Buffer(chunk, encoding)
18335 this.update(chunk)
18336 } catch (err) {
18337 error = err
18338 }
18339
18340 callback(error)
18341}
18342
18343HashBase.prototype._flush = function (callback) {
18344 var error = null
18345 try {
18346 this.push(this._digest())
18347 } catch (err) {
18348 error = err
18349 }
18350
18351 callback(error)
18352}
18353
18354HashBase.prototype.update = function (data, encoding) {
18355 if (!Buffer.isBuffer(data) && typeof data !== 'string') throw new TypeError('Data must be a string or a buffer')
18356 if (this._finalized) throw new Error('Digest already called')
18357 if (!Buffer.isBuffer(data)) data = new Buffer(data, encoding || 'binary')
18358
18359 // consume data
18360 var block = this._block
18361 var offset = 0
18362 while (this._blockOffset + data.length - offset >= this._blockSize) {
18363 for (var i = this._blockOffset; i < this._blockSize;) block[i++] = data[offset++]
18364 this._update()
18365 this._blockOffset = 0
18366 }
18367 while (offset < data.length) block[this._blockOffset++] = data[offset++]
18368
18369 // update length
18370 for (var j = 0, carry = data.length * 8; carry > 0; ++j) {
18371 this._length[j] += carry
18372 carry = (this._length[j] / 0x0100000000) | 0
18373 if (carry > 0) this._length[j] -= 0x0100000000 * carry
18374 }
18375
18376 return this
18377}
18378
18379HashBase.prototype._update = function (data) {
18380 throw new Error('_update is not implemented')
18381}
18382
18383HashBase.prototype.digest = function (encoding) {
18384 if (this._finalized) throw new Error('Digest already called')
18385 this._finalized = true
18386
18387 var digest = this._digest()
18388 if (encoding !== undefined) digest = digest.toString(encoding)
18389 return digest
18390}
18391
18392HashBase.prototype._digest = function () {
18393 throw new Error('_digest is not implemented')
18394}
18395
18396module.exports = HashBase
18397
18398}).call(this,require("buffer").Buffer)
18399},{"buffer":53,"inherits":107,"stream":172}],92:[function(require,module,exports){
18400var hash = exports;
18401
18402hash.utils = require('./hash/utils');
18403hash.common = require('./hash/common');
18404hash.sha = require('./hash/sha');
18405hash.ripemd = require('./hash/ripemd');
18406hash.hmac = require('./hash/hmac');
18407
18408// Proxy hash functions to the main object
18409hash.sha1 = hash.sha.sha1;
18410hash.sha256 = hash.sha.sha256;
18411hash.sha224 = hash.sha.sha224;
18412hash.sha384 = hash.sha.sha384;
18413hash.sha512 = hash.sha.sha512;
18414hash.ripemd160 = hash.ripemd.ripemd160;
18415
18416},{"./hash/common":93,"./hash/hmac":94,"./hash/ripemd":95,"./hash/sha":96,"./hash/utils":103}],93:[function(require,module,exports){
18417'use strict';
18418
18419var utils = require('./utils');
18420var assert = require('minimalistic-assert');
18421
18422function BlockHash() {
18423 this.pending = null;
18424 this.pendingTotal = 0;
18425 this.blockSize = this.constructor.blockSize;
18426 this.outSize = this.constructor.outSize;
18427 this.hmacStrength = this.constructor.hmacStrength;
18428 this.padLength = this.constructor.padLength / 8;
18429 this.endian = 'big';
18430
18431 this._delta8 = this.blockSize / 8;
18432 this._delta32 = this.blockSize / 32;
18433}
18434exports.BlockHash = BlockHash;
18435
18436BlockHash.prototype.update = function update(msg, enc) {
18437 // Convert message to array, pad it, and join into 32bit blocks
18438 msg = utils.toArray(msg, enc);
18439 if (!this.pending)
18440 this.pending = msg;
18441 else
18442 this.pending = this.pending.concat(msg);
18443 this.pendingTotal += msg.length;
18444
18445 // Enough data, try updating
18446 if (this.pending.length >= this._delta8) {
18447 msg = this.pending;
18448
18449 // Process pending data in blocks
18450 var r = msg.length % this._delta8;
18451 this.pending = msg.slice(msg.length - r, msg.length);
18452 if (this.pending.length === 0)
18453 this.pending = null;
18454
18455 msg = utils.join32(msg, 0, msg.length - r, this.endian);
18456 for (var i = 0; i < msg.length; i += this._delta32)
18457 this._update(msg, i, i + this._delta32);
18458 }
18459
18460 return this;
18461};
18462
18463BlockHash.prototype.digest = function digest(enc) {
18464 this.update(this._pad());
18465 assert(this.pending === null);
18466
18467 return this._digest(enc);
18468};
18469
18470BlockHash.prototype._pad = function pad() {
18471 var len = this.pendingTotal;
18472 var bytes = this._delta8;
18473 var k = bytes - ((len + this.padLength) % bytes);
18474 var res = new Array(k + this.padLength);
18475 res[0] = 0x80;
18476 for (var i = 1; i < k; i++)
18477 res[i] = 0;
18478
18479 // Append length
18480 len <<= 3;
18481 if (this.endian === 'big') {
18482 for (var t = 8; t < this.padLength; t++)
18483 res[i++] = 0;
18484
18485 res[i++] = 0;
18486 res[i++] = 0;
18487 res[i++] = 0;
18488 res[i++] = 0;
18489 res[i++] = (len >>> 24) & 0xff;
18490 res[i++] = (len >>> 16) & 0xff;
18491 res[i++] = (len >>> 8) & 0xff;
18492 res[i++] = len & 0xff;
18493 } else {
18494 res[i++] = len & 0xff;
18495 res[i++] = (len >>> 8) & 0xff;
18496 res[i++] = (len >>> 16) & 0xff;
18497 res[i++] = (len >>> 24) & 0xff;
18498 res[i++] = 0;
18499 res[i++] = 0;
18500 res[i++] = 0;
18501 res[i++] = 0;
18502
18503 for (t = 8; t < this.padLength; t++)
18504 res[i++] = 0;
18505 }
18506
18507 return res;
18508};
18509
18510},{"./utils":103,"minimalistic-assert":120}],94:[function(require,module,exports){
18511'use strict';
18512
18513var utils = require('./utils');
18514var assert = require('minimalistic-assert');
18515
18516function Hmac(hash, key, enc) {
18517 if (!(this instanceof Hmac))
18518 return new Hmac(hash, key, enc);
18519 this.Hash = hash;
18520 this.blockSize = hash.blockSize / 8;
18521 this.outSize = hash.outSize / 8;
18522 this.inner = null;
18523 this.outer = null;
18524
18525 this._init(utils.toArray(key, enc));
18526}
18527module.exports = Hmac;
18528
18529Hmac.prototype._init = function init(key) {
18530 // Shorten key, if needed
18531 if (key.length > this.blockSize)
18532 key = new this.Hash().update(key).digest();
18533 assert(key.length <= this.blockSize);
18534
18535 // Add padding to key
18536 for (var i = key.length; i < this.blockSize; i++)
18537 key.push(0);
18538
18539 for (i = 0; i < key.length; i++)
18540 key[i] ^= 0x36;
18541 this.inner = new this.Hash().update(key);
18542
18543 // 0x36 ^ 0x5c = 0x6a
18544 for (i = 0; i < key.length; i++)
18545 key[i] ^= 0x6a;
18546 this.outer = new this.Hash().update(key);
18547};
18548
18549Hmac.prototype.update = function update(msg, enc) {
18550 this.inner.update(msg, enc);
18551 return this;
18552};
18553
18554Hmac.prototype.digest = function digest(enc) {
18555 this.outer.update(this.inner.digest());
18556 return this.outer.digest(enc);
18557};
18558
18559},{"./utils":103,"minimalistic-assert":120}],95:[function(require,module,exports){
18560'use strict';
18561
18562var utils = require('./utils');
18563var common = require('./common');
18564
18565var rotl32 = utils.rotl32;
18566var sum32 = utils.sum32;
18567var sum32_3 = utils.sum32_3;
18568var sum32_4 = utils.sum32_4;
18569var BlockHash = common.BlockHash;
18570
18571function RIPEMD160() {
18572 if (!(this instanceof RIPEMD160))
18573 return new RIPEMD160();
18574
18575 BlockHash.call(this);
18576
18577 this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ];
18578 this.endian = 'little';
18579}
18580utils.inherits(RIPEMD160, BlockHash);
18581exports.ripemd160 = RIPEMD160;
18582
18583RIPEMD160.blockSize = 512;
18584RIPEMD160.outSize = 160;
18585RIPEMD160.hmacStrength = 192;
18586RIPEMD160.padLength = 64;
18587
18588RIPEMD160.prototype._update = function update(msg, start) {
18589 var A = this.h[0];
18590 var B = this.h[1];
18591 var C = this.h[2];
18592 var D = this.h[3];
18593 var E = this.h[4];
18594 var Ah = A;
18595 var Bh = B;
18596 var Ch = C;
18597 var Dh = D;
18598 var Eh = E;
18599 for (var j = 0; j < 80; j++) {
18600 var T = sum32(
18601 rotl32(
18602 sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)),
18603 s[j]),
18604 E);
18605 A = E;
18606 E = D;
18607 D = rotl32(C, 10);
18608 C = B;
18609 B = T;
18610 T = sum32(
18611 rotl32(
18612 sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)),
18613 sh[j]),
18614 Eh);
18615 Ah = Eh;
18616 Eh = Dh;
18617 Dh = rotl32(Ch, 10);
18618 Ch = Bh;
18619 Bh = T;
18620 }
18621 T = sum32_3(this.h[1], C, Dh);
18622 this.h[1] = sum32_3(this.h[2], D, Eh);
18623 this.h[2] = sum32_3(this.h[3], E, Ah);
18624 this.h[3] = sum32_3(this.h[4], A, Bh);
18625 this.h[4] = sum32_3(this.h[0], B, Ch);
18626 this.h[0] = T;
18627};
18628
18629RIPEMD160.prototype._digest = function digest(enc) {
18630 if (enc === 'hex')
18631 return utils.toHex32(this.h, 'little');
18632 else
18633 return utils.split32(this.h, 'little');
18634};
18635
18636function f(j, x, y, z) {
18637 if (j <= 15)
18638 return x ^ y ^ z;
18639 else if (j <= 31)
18640 return (x & y) | ((~x) & z);
18641 else if (j <= 47)
18642 return (x | (~y)) ^ z;
18643 else if (j <= 63)
18644 return (x & z) | (y & (~z));
18645 else
18646 return x ^ (y | (~z));
18647}
18648
18649function K(j) {
18650 if (j <= 15)
18651 return 0x00000000;
18652 else if (j <= 31)
18653 return 0x5a827999;
18654 else if (j <= 47)
18655 return 0x6ed9eba1;
18656 else if (j <= 63)
18657 return 0x8f1bbcdc;
18658 else
18659 return 0xa953fd4e;
18660}
18661
18662function Kh(j) {
18663 if (j <= 15)
18664 return 0x50a28be6;
18665 else if (j <= 31)
18666 return 0x5c4dd124;
18667 else if (j <= 47)
18668 return 0x6d703ef3;
18669 else if (j <= 63)
18670 return 0x7a6d76e9;
18671 else
18672 return 0x00000000;
18673}
18674
18675var r = [
18676 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
18677 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
18678 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
18679 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
18680 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
18681];
18682
18683var rh = [
18684 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
18685 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
18686 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
18687 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
18688 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
18689];
18690
18691var s = [
18692 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
18693 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
18694 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
18695 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
18696 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
18697];
18698
18699var sh = [
18700 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
18701 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
18702 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
18703 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
18704 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
18705];
18706
18707},{"./common":93,"./utils":103}],96:[function(require,module,exports){
18708'use strict';
18709
18710exports.sha1 = require('./sha/1');
18711exports.sha224 = require('./sha/224');
18712exports.sha256 = require('./sha/256');
18713exports.sha384 = require('./sha/384');
18714exports.sha512 = require('./sha/512');
18715
18716},{"./sha/1":97,"./sha/224":98,"./sha/256":99,"./sha/384":100,"./sha/512":101}],97:[function(require,module,exports){
18717'use strict';
18718
18719var utils = require('../utils');
18720var common = require('../common');
18721var shaCommon = require('./common');
18722
18723var rotl32 = utils.rotl32;
18724var sum32 = utils.sum32;
18725var sum32_5 = utils.sum32_5;
18726var ft_1 = shaCommon.ft_1;
18727var BlockHash = common.BlockHash;
18728
18729var sha1_K = [
18730 0x5A827999, 0x6ED9EBA1,
18731 0x8F1BBCDC, 0xCA62C1D6
18732];
18733
18734function SHA1() {
18735 if (!(this instanceof SHA1))
18736 return new SHA1();
18737
18738 BlockHash.call(this);
18739 this.h = [
18740 0x67452301, 0xefcdab89, 0x98badcfe,
18741 0x10325476, 0xc3d2e1f0 ];
18742 this.W = new Array(80);
18743}
18744
18745utils.inherits(SHA1, BlockHash);
18746module.exports = SHA1;
18747
18748SHA1.blockSize = 512;
18749SHA1.outSize = 160;
18750SHA1.hmacStrength = 80;
18751SHA1.padLength = 64;
18752
18753SHA1.prototype._update = function _update(msg, start) {
18754 var W = this.W;
18755
18756 for (var i = 0; i < 16; i++)
18757 W[i] = msg[start + i];
18758
18759 for(; i < W.length; i++)
18760 W[i] = rotl32(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1);
18761
18762 var a = this.h[0];
18763 var b = this.h[1];
18764 var c = this.h[2];
18765 var d = this.h[3];
18766 var e = this.h[4];
18767
18768 for (i = 0; i < W.length; i++) {
18769 var s = ~~(i / 20);
18770 var t = sum32_5(rotl32(a, 5), ft_1(s, b, c, d), e, W[i], sha1_K[s]);
18771 e = d;
18772 d = c;
18773 c = rotl32(b, 30);
18774 b = a;
18775 a = t;
18776 }
18777
18778 this.h[0] = sum32(this.h[0], a);
18779 this.h[1] = sum32(this.h[1], b);
18780 this.h[2] = sum32(this.h[2], c);
18781 this.h[3] = sum32(this.h[3], d);
18782 this.h[4] = sum32(this.h[4], e);
18783};
18784
18785SHA1.prototype._digest = function digest(enc) {
18786 if (enc === 'hex')
18787 return utils.toHex32(this.h, 'big');
18788 else
18789 return utils.split32(this.h, 'big');
18790};
18791
18792},{"../common":93,"../utils":103,"./common":102}],98:[function(require,module,exports){
18793'use strict';
18794
18795var utils = require('../utils');
18796var SHA256 = require('./256');
18797
18798function SHA224() {
18799 if (!(this instanceof SHA224))
18800 return new SHA224();
18801
18802 SHA256.call(this);
18803 this.h = [
18804 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
18805 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 ];
18806}
18807utils.inherits(SHA224, SHA256);
18808module.exports = SHA224;
18809
18810SHA224.blockSize = 512;
18811SHA224.outSize = 224;
18812SHA224.hmacStrength = 192;
18813SHA224.padLength = 64;
18814
18815SHA224.prototype._digest = function digest(enc) {
18816 // Just truncate output
18817 if (enc === 'hex')
18818 return utils.toHex32(this.h.slice(0, 7), 'big');
18819 else
18820 return utils.split32(this.h.slice(0, 7), 'big');
18821};
18822
18823
18824},{"../utils":103,"./256":99}],99:[function(require,module,exports){
18825'use strict';
18826
18827var utils = require('../utils');
18828var common = require('../common');
18829var shaCommon = require('./common');
18830var assert = require('minimalistic-assert');
18831
18832var sum32 = utils.sum32;
18833var sum32_4 = utils.sum32_4;
18834var sum32_5 = utils.sum32_5;
18835var ch32 = shaCommon.ch32;
18836var maj32 = shaCommon.maj32;
18837var s0_256 = shaCommon.s0_256;
18838var s1_256 = shaCommon.s1_256;
18839var g0_256 = shaCommon.g0_256;
18840var g1_256 = shaCommon.g1_256;
18841
18842var BlockHash = common.BlockHash;
18843
18844var sha256_K = [
18845 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
18846 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
18847 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
18848 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
18849 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
18850 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
18851 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
18852 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
18853 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
18854 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
18855 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
18856 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
18857 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
18858 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
18859 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
18860 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
18861];
18862
18863function SHA256() {
18864 if (!(this instanceof SHA256))
18865 return new SHA256();
18866
18867 BlockHash.call(this);
18868 this.h = [
18869 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
18870 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
18871 ];
18872 this.k = sha256_K;
18873 this.W = new Array(64);
18874}
18875utils.inherits(SHA256, BlockHash);
18876module.exports = SHA256;
18877
18878SHA256.blockSize = 512;
18879SHA256.outSize = 256;
18880SHA256.hmacStrength = 192;
18881SHA256.padLength = 64;
18882
18883SHA256.prototype._update = function _update(msg, start) {
18884 var W = this.W;
18885
18886 for (var i = 0; i < 16; i++)
18887 W[i] = msg[start + i];
18888 for (; i < W.length; i++)
18889 W[i] = sum32_4(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]);
18890
18891 var a = this.h[0];
18892 var b = this.h[1];
18893 var c = this.h[2];
18894 var d = this.h[3];
18895 var e = this.h[4];
18896 var f = this.h[5];
18897 var g = this.h[6];
18898 var h = this.h[7];
18899
18900 assert(this.k.length === W.length);
18901 for (i = 0; i < W.length; i++) {
18902 var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]);
18903 var T2 = sum32(s0_256(a), maj32(a, b, c));
18904 h = g;
18905 g = f;
18906 f = e;
18907 e = sum32(d, T1);
18908 d = c;
18909 c = b;
18910 b = a;
18911 a = sum32(T1, T2);
18912 }
18913
18914 this.h[0] = sum32(this.h[0], a);
18915 this.h[1] = sum32(this.h[1], b);
18916 this.h[2] = sum32(this.h[2], c);
18917 this.h[3] = sum32(this.h[3], d);
18918 this.h[4] = sum32(this.h[4], e);
18919 this.h[5] = sum32(this.h[5], f);
18920 this.h[6] = sum32(this.h[6], g);
18921 this.h[7] = sum32(this.h[7], h);
18922};
18923
18924SHA256.prototype._digest = function digest(enc) {
18925 if (enc === 'hex')
18926 return utils.toHex32(this.h, 'big');
18927 else
18928 return utils.split32(this.h, 'big');
18929};
18930
18931},{"../common":93,"../utils":103,"./common":102,"minimalistic-assert":120}],100:[function(require,module,exports){
18932'use strict';
18933
18934var utils = require('../utils');
18935
18936var SHA512 = require('./512');
18937
18938function SHA384() {
18939 if (!(this instanceof SHA384))
18940 return new SHA384();
18941
18942 SHA512.call(this);
18943 this.h = [
18944 0xcbbb9d5d, 0xc1059ed8,
18945 0x629a292a, 0x367cd507,
18946 0x9159015a, 0x3070dd17,
18947 0x152fecd8, 0xf70e5939,
18948 0x67332667, 0xffc00b31,
18949 0x8eb44a87, 0x68581511,
18950 0xdb0c2e0d, 0x64f98fa7,
18951 0x47b5481d, 0xbefa4fa4 ];
18952}
18953utils.inherits(SHA384, SHA512);
18954module.exports = SHA384;
18955
18956SHA384.blockSize = 1024;
18957SHA384.outSize = 384;
18958SHA384.hmacStrength = 192;
18959SHA384.padLength = 128;
18960
18961SHA384.prototype._digest = function digest(enc) {
18962 if (enc === 'hex')
18963 return utils.toHex32(this.h.slice(0, 12), 'big');
18964 else
18965 return utils.split32(this.h.slice(0, 12), 'big');
18966};
18967
18968},{"../utils":103,"./512":101}],101:[function(require,module,exports){
18969'use strict';
18970
18971var utils = require('../utils');
18972var common = require('../common');
18973var assert = require('minimalistic-assert');
18974
18975var rotr64_hi = utils.rotr64_hi;
18976var rotr64_lo = utils.rotr64_lo;
18977var shr64_hi = utils.shr64_hi;
18978var shr64_lo = utils.shr64_lo;
18979var sum64 = utils.sum64;
18980var sum64_hi = utils.sum64_hi;
18981var sum64_lo = utils.sum64_lo;
18982var sum64_4_hi = utils.sum64_4_hi;
18983var sum64_4_lo = utils.sum64_4_lo;
18984var sum64_5_hi = utils.sum64_5_hi;
18985var sum64_5_lo = utils.sum64_5_lo;
18986
18987var BlockHash = common.BlockHash;
18988
18989var sha512_K = [
18990 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
18991 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
18992 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
18993 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
18994 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
18995 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
18996 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
18997 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
18998 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
18999 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
19000 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
19001 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
19002 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
19003 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
19004 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
19005 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
19006 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
19007 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
19008 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
19009 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
19010 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
19011 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
19012 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
19013 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
19014 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
19015 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
19016 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
19017 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
19018 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
19019 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
19020 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
19021 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
19022 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
19023 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
19024 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
19025 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
19026 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
19027 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
19028 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
19029 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
19030];
19031
19032function SHA512() {
19033 if (!(this instanceof SHA512))
19034 return new SHA512();
19035
19036 BlockHash.call(this);
19037 this.h = [
19038 0x6a09e667, 0xf3bcc908,
19039 0xbb67ae85, 0x84caa73b,
19040 0x3c6ef372, 0xfe94f82b,
19041 0xa54ff53a, 0x5f1d36f1,
19042 0x510e527f, 0xade682d1,
19043 0x9b05688c, 0x2b3e6c1f,
19044 0x1f83d9ab, 0xfb41bd6b,
19045 0x5be0cd19, 0x137e2179 ];
19046 this.k = sha512_K;
19047 this.W = new Array(160);
19048}
19049utils.inherits(SHA512, BlockHash);
19050module.exports = SHA512;
19051
19052SHA512.blockSize = 1024;
19053SHA512.outSize = 512;
19054SHA512.hmacStrength = 192;
19055SHA512.padLength = 128;
19056
19057SHA512.prototype._prepareBlock = function _prepareBlock(msg, start) {
19058 var W = this.W;
19059
19060 // 32 x 32bit words
19061 for (var i = 0; i < 32; i++)
19062 W[i] = msg[start + i];
19063 for (; i < W.length; i += 2) {
19064 var c0_hi = g1_512_hi(W[i - 4], W[i - 3]); // i - 2
19065 var c0_lo = g1_512_lo(W[i - 4], W[i - 3]);
19066 var c1_hi = W[i - 14]; // i - 7
19067 var c1_lo = W[i - 13];
19068 var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); // i - 15
19069 var c2_lo = g0_512_lo(W[i - 30], W[i - 29]);
19070 var c3_hi = W[i - 32]; // i - 16
19071 var c3_lo = W[i - 31];
19072
19073 W[i] = sum64_4_hi(
19074 c0_hi, c0_lo,
19075 c1_hi, c1_lo,
19076 c2_hi, c2_lo,
19077 c3_hi, c3_lo);
19078 W[i + 1] = sum64_4_lo(
19079 c0_hi, c0_lo,
19080 c1_hi, c1_lo,
19081 c2_hi, c2_lo,
19082 c3_hi, c3_lo);
19083 }
19084};
19085
19086SHA512.prototype._update = function _update(msg, start) {
19087 this._prepareBlock(msg, start);
19088
19089 var W = this.W;
19090
19091 var ah = this.h[0];
19092 var al = this.h[1];
19093 var bh = this.h[2];
19094 var bl = this.h[3];
19095 var ch = this.h[4];
19096 var cl = this.h[5];
19097 var dh = this.h[6];
19098 var dl = this.h[7];
19099 var eh = this.h[8];
19100 var el = this.h[9];
19101 var fh = this.h[10];
19102 var fl = this.h[11];
19103 var gh = this.h[12];
19104 var gl = this.h[13];
19105 var hh = this.h[14];
19106 var hl = this.h[15];
19107
19108 assert(this.k.length === W.length);
19109 for (var i = 0; i < W.length; i += 2) {
19110 var c0_hi = hh;
19111 var c0_lo = hl;
19112 var c1_hi = s1_512_hi(eh, el);
19113 var c1_lo = s1_512_lo(eh, el);
19114 var c2_hi = ch64_hi(eh, el, fh, fl, gh, gl);
19115 var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl);
19116 var c3_hi = this.k[i];
19117 var c3_lo = this.k[i + 1];
19118 var c4_hi = W[i];
19119 var c4_lo = W[i + 1];
19120
19121 var T1_hi = sum64_5_hi(
19122 c0_hi, c0_lo,
19123 c1_hi, c1_lo,
19124 c2_hi, c2_lo,
19125 c3_hi, c3_lo,
19126 c4_hi, c4_lo);
19127 var T1_lo = sum64_5_lo(
19128 c0_hi, c0_lo,
19129 c1_hi, c1_lo,
19130 c2_hi, c2_lo,
19131 c3_hi, c3_lo,
19132 c4_hi, c4_lo);
19133
19134 c0_hi = s0_512_hi(ah, al);
19135 c0_lo = s0_512_lo(ah, al);
19136 c1_hi = maj64_hi(ah, al, bh, bl, ch, cl);
19137 c1_lo = maj64_lo(ah, al, bh, bl, ch, cl);
19138
19139 var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo);
19140 var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo);
19141
19142 hh = gh;
19143 hl = gl;
19144
19145 gh = fh;
19146 gl = fl;
19147
19148 fh = eh;
19149 fl = el;
19150
19151 eh = sum64_hi(dh, dl, T1_hi, T1_lo);
19152 el = sum64_lo(dl, dl, T1_hi, T1_lo);
19153
19154 dh = ch;
19155 dl = cl;
19156
19157 ch = bh;
19158 cl = bl;
19159
19160 bh = ah;
19161 bl = al;
19162
19163 ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo);
19164 al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo);
19165 }
19166
19167 sum64(this.h, 0, ah, al);
19168 sum64(this.h, 2, bh, bl);
19169 sum64(this.h, 4, ch, cl);
19170 sum64(this.h, 6, dh, dl);
19171 sum64(this.h, 8, eh, el);
19172 sum64(this.h, 10, fh, fl);
19173 sum64(this.h, 12, gh, gl);
19174 sum64(this.h, 14, hh, hl);
19175};
19176
19177SHA512.prototype._digest = function digest(enc) {
19178 if (enc === 'hex')
19179 return utils.toHex32(this.h, 'big');
19180 else
19181 return utils.split32(this.h, 'big');
19182};
19183
19184function ch64_hi(xh, xl, yh, yl, zh) {
19185 var r = (xh & yh) ^ ((~xh) & zh);
19186 if (r < 0)
19187 r += 0x100000000;
19188 return r;
19189}
19190
19191function ch64_lo(xh, xl, yh, yl, zh, zl) {
19192 var r = (xl & yl) ^ ((~xl) & zl);
19193 if (r < 0)
19194 r += 0x100000000;
19195 return r;
19196}
19197
19198function maj64_hi(xh, xl, yh, yl, zh) {
19199 var r = (xh & yh) ^ (xh & zh) ^ (yh & zh);
19200 if (r < 0)
19201 r += 0x100000000;
19202 return r;
19203}
19204
19205function maj64_lo(xh, xl, yh, yl, zh, zl) {
19206 var r = (xl & yl) ^ (xl & zl) ^ (yl & zl);
19207 if (r < 0)
19208 r += 0x100000000;
19209 return r;
19210}
19211
19212function s0_512_hi(xh, xl) {
19213 var c0_hi = rotr64_hi(xh, xl, 28);
19214 var c1_hi = rotr64_hi(xl, xh, 2); // 34
19215 var c2_hi = rotr64_hi(xl, xh, 7); // 39
19216
19217 var r = c0_hi ^ c1_hi ^ c2_hi;
19218 if (r < 0)
19219 r += 0x100000000;
19220 return r;
19221}
19222
19223function s0_512_lo(xh, xl) {
19224 var c0_lo = rotr64_lo(xh, xl, 28);
19225 var c1_lo = rotr64_lo(xl, xh, 2); // 34
19226 var c2_lo = rotr64_lo(xl, xh, 7); // 39
19227
19228 var r = c0_lo ^ c1_lo ^ c2_lo;
19229 if (r < 0)
19230 r += 0x100000000;
19231 return r;
19232}
19233
19234function s1_512_hi(xh, xl) {
19235 var c0_hi = rotr64_hi(xh, xl, 14);
19236 var c1_hi = rotr64_hi(xh, xl, 18);
19237 var c2_hi = rotr64_hi(xl, xh, 9); // 41
19238
19239 var r = c0_hi ^ c1_hi ^ c2_hi;
19240 if (r < 0)
19241 r += 0x100000000;
19242 return r;
19243}
19244
19245function s1_512_lo(xh, xl) {
19246 var c0_lo = rotr64_lo(xh, xl, 14);
19247 var c1_lo = rotr64_lo(xh, xl, 18);
19248 var c2_lo = rotr64_lo(xl, xh, 9); // 41
19249
19250 var r = c0_lo ^ c1_lo ^ c2_lo;
19251 if (r < 0)
19252 r += 0x100000000;
19253 return r;
19254}
19255
19256function g0_512_hi(xh, xl) {
19257 var c0_hi = rotr64_hi(xh, xl, 1);
19258 var c1_hi = rotr64_hi(xh, xl, 8);
19259 var c2_hi = shr64_hi(xh, xl, 7);
19260
19261 var r = c0_hi ^ c1_hi ^ c2_hi;
19262 if (r < 0)
19263 r += 0x100000000;
19264 return r;
19265}
19266
19267function g0_512_lo(xh, xl) {
19268 var c0_lo = rotr64_lo(xh, xl, 1);
19269 var c1_lo = rotr64_lo(xh, xl, 8);
19270 var c2_lo = shr64_lo(xh, xl, 7);
19271
19272 var r = c0_lo ^ c1_lo ^ c2_lo;
19273 if (r < 0)
19274 r += 0x100000000;
19275 return r;
19276}
19277
19278function g1_512_hi(xh, xl) {
19279 var c0_hi = rotr64_hi(xh, xl, 19);
19280 var c1_hi = rotr64_hi(xl, xh, 29); // 61
19281 var c2_hi = shr64_hi(xh, xl, 6);
19282
19283 var r = c0_hi ^ c1_hi ^ c2_hi;
19284 if (r < 0)
19285 r += 0x100000000;
19286 return r;
19287}
19288
19289function g1_512_lo(xh, xl) {
19290 var c0_lo = rotr64_lo(xh, xl, 19);
19291 var c1_lo = rotr64_lo(xl, xh, 29); // 61
19292 var c2_lo = shr64_lo(xh, xl, 6);
19293
19294 var r = c0_lo ^ c1_lo ^ c2_lo;
19295 if (r < 0)
19296 r += 0x100000000;
19297 return r;
19298}
19299
19300},{"../common":93,"../utils":103,"minimalistic-assert":120}],102:[function(require,module,exports){
19301'use strict';
19302
19303var utils = require('../utils');
19304var rotr32 = utils.rotr32;
19305
19306function ft_1(s, x, y, z) {
19307 if (s === 0)
19308 return ch32(x, y, z);
19309 if (s === 1 || s === 3)
19310 return p32(x, y, z);
19311 if (s === 2)
19312 return maj32(x, y, z);
19313}
19314exports.ft_1 = ft_1;
19315
19316function ch32(x, y, z) {
19317 return (x & y) ^ ((~x) & z);
19318}
19319exports.ch32 = ch32;
19320
19321function maj32(x, y, z) {
19322 return (x & y) ^ (x & z) ^ (y & z);
19323}
19324exports.maj32 = maj32;
19325
19326function p32(x, y, z) {
19327 return x ^ y ^ z;
19328}
19329exports.p32 = p32;
19330
19331function s0_256(x) {
19332 return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22);
19333}
19334exports.s0_256 = s0_256;
19335
19336function s1_256(x) {
19337 return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25);
19338}
19339exports.s1_256 = s1_256;
19340
19341function g0_256(x) {
19342 return rotr32(x, 7) ^ rotr32(x, 18) ^ (x >>> 3);
19343}
19344exports.g0_256 = g0_256;
19345
19346function g1_256(x) {
19347 return rotr32(x, 17) ^ rotr32(x, 19) ^ (x >>> 10);
19348}
19349exports.g1_256 = g1_256;
19350
19351},{"../utils":103}],103:[function(require,module,exports){
19352'use strict';
19353
19354var assert = require('minimalistic-assert');
19355var inherits = require('inherits');
19356
19357exports.inherits = inherits;
19358
19359function toArray(msg, enc) {
19360 if (Array.isArray(msg))
19361 return msg.slice();
19362 if (!msg)
19363 return [];
19364 var res = [];
19365 if (typeof msg === 'string') {
19366 if (!enc) {
19367 for (var i = 0; i < msg.length; i++) {
19368 var c = msg.charCodeAt(i);
19369 var hi = c >> 8;
19370 var lo = c & 0xff;
19371 if (hi)
19372 res.push(hi, lo);
19373 else
19374 res.push(lo);
19375 }
19376 } else if (enc === 'hex') {
19377 msg = msg.replace(/[^a-z0-9]+/ig, '');
19378 if (msg.length % 2 !== 0)
19379 msg = '0' + msg;
19380 for (i = 0; i < msg.length; i += 2)
19381 res.push(parseInt(msg[i] + msg[i + 1], 16));
19382 }
19383 } else {
19384 for (i = 0; i < msg.length; i++)
19385 res[i] = msg[i] | 0;
19386 }
19387 return res;
19388}
19389exports.toArray = toArray;
19390
19391function toHex(msg) {
19392 var res = '';
19393 for (var i = 0; i < msg.length; i++)
19394 res += zero2(msg[i].toString(16));
19395 return res;
19396}
19397exports.toHex = toHex;
19398
19399function htonl(w) {
19400 var res = (w >>> 24) |
19401 ((w >>> 8) & 0xff00) |
19402 ((w << 8) & 0xff0000) |
19403 ((w & 0xff) << 24);
19404 return res >>> 0;
19405}
19406exports.htonl = htonl;
19407
19408function toHex32(msg, endian) {
19409 var res = '';
19410 for (var i = 0; i < msg.length; i++) {
19411 var w = msg[i];
19412 if (endian === 'little')
19413 w = htonl(w);
19414 res += zero8(w.toString(16));
19415 }
19416 return res;
19417}
19418exports.toHex32 = toHex32;
19419
19420function zero2(word) {
19421 if (word.length === 1)
19422 return '0' + word;
19423 else
19424 return word;
19425}
19426exports.zero2 = zero2;
19427
19428function zero8(word) {
19429 if (word.length === 7)
19430 return '0' + word;
19431 else if (word.length === 6)
19432 return '00' + word;
19433 else if (word.length === 5)
19434 return '000' + word;
19435 else if (word.length === 4)
19436 return '0000' + word;
19437 else if (word.length === 3)
19438 return '00000' + word;
19439 else if (word.length === 2)
19440 return '000000' + word;
19441 else if (word.length === 1)
19442 return '0000000' + word;
19443 else
19444 return word;
19445}
19446exports.zero8 = zero8;
19447
19448function join32(msg, start, end, endian) {
19449 var len = end - start;
19450 assert(len % 4 === 0);
19451 var res = new Array(len / 4);
19452 for (var i = 0, k = start; i < res.length; i++, k += 4) {
19453 var w;
19454 if (endian === 'big')
19455 w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3];
19456 else
19457 w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k];
19458 res[i] = w >>> 0;
19459 }
19460 return res;
19461}
19462exports.join32 = join32;
19463
19464function split32(msg, endian) {
19465 var res = new Array(msg.length * 4);
19466 for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
19467 var m = msg[i];
19468 if (endian === 'big') {
19469 res[k] = m >>> 24;
19470 res[k + 1] = (m >>> 16) & 0xff;
19471 res[k + 2] = (m >>> 8) & 0xff;
19472 res[k + 3] = m & 0xff;
19473 } else {
19474 res[k + 3] = m >>> 24;
19475 res[k + 2] = (m >>> 16) & 0xff;
19476 res[k + 1] = (m >>> 8) & 0xff;
19477 res[k] = m & 0xff;
19478 }
19479 }
19480 return res;
19481}
19482exports.split32 = split32;
19483
19484function rotr32(w, b) {
19485 return (w >>> b) | (w << (32 - b));
19486}
19487exports.rotr32 = rotr32;
19488
19489function rotl32(w, b) {
19490 return (w << b) | (w >>> (32 - b));
19491}
19492exports.rotl32 = rotl32;
19493
19494function sum32(a, b) {
19495 return (a + b) >>> 0;
19496}
19497exports.sum32 = sum32;
19498
19499function sum32_3(a, b, c) {
19500 return (a + b + c) >>> 0;
19501}
19502exports.sum32_3 = sum32_3;
19503
19504function sum32_4(a, b, c, d) {
19505 return (a + b + c + d) >>> 0;
19506}
19507exports.sum32_4 = sum32_4;
19508
19509function sum32_5(a, b, c, d, e) {
19510 return (a + b + c + d + e) >>> 0;
19511}
19512exports.sum32_5 = sum32_5;
19513
19514function sum64(buf, pos, ah, al) {
19515 var bh = buf[pos];
19516 var bl = buf[pos + 1];
19517
19518 var lo = (al + bl) >>> 0;
19519 var hi = (lo < al ? 1 : 0) + ah + bh;
19520 buf[pos] = hi >>> 0;
19521 buf[pos + 1] = lo;
19522}
19523exports.sum64 = sum64;
19524
19525function sum64_hi(ah, al, bh, bl) {
19526 var lo = (al + bl) >>> 0;
19527 var hi = (lo < al ? 1 : 0) + ah + bh;
19528 return hi >>> 0;
19529}
19530exports.sum64_hi = sum64_hi;
19531
19532function sum64_lo(ah, al, bh, bl) {
19533 var lo = al + bl;
19534 return lo >>> 0;
19535}
19536exports.sum64_lo = sum64_lo;
19537
19538function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) {
19539 var carry = 0;
19540 var lo = al;
19541 lo = (lo + bl) >>> 0;
19542 carry += lo < al ? 1 : 0;
19543 lo = (lo + cl) >>> 0;
19544 carry += lo < cl ? 1 : 0;
19545 lo = (lo + dl) >>> 0;
19546 carry += lo < dl ? 1 : 0;
19547
19548 var hi = ah + bh + ch + dh + carry;
19549 return hi >>> 0;
19550}
19551exports.sum64_4_hi = sum64_4_hi;
19552
19553function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) {
19554 var lo = al + bl + cl + dl;
19555 return lo >>> 0;
19556}
19557exports.sum64_4_lo = sum64_4_lo;
19558
19559function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
19560 var carry = 0;
19561 var lo = al;
19562 lo = (lo + bl) >>> 0;
19563 carry += lo < al ? 1 : 0;
19564 lo = (lo + cl) >>> 0;
19565 carry += lo < cl ? 1 : 0;
19566 lo = (lo + dl) >>> 0;
19567 carry += lo < dl ? 1 : 0;
19568 lo = (lo + el) >>> 0;
19569 carry += lo < el ? 1 : 0;
19570
19571 var hi = ah + bh + ch + dh + eh + carry;
19572 return hi >>> 0;
19573}
19574exports.sum64_5_hi = sum64_5_hi;
19575
19576function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
19577 var lo = al + bl + cl + dl + el;
19578
19579 return lo >>> 0;
19580}
19581exports.sum64_5_lo = sum64_5_lo;
19582
19583function rotr64_hi(ah, al, num) {
19584 var r = (al << (32 - num)) | (ah >>> num);
19585 return r >>> 0;
19586}
19587exports.rotr64_hi = rotr64_hi;
19588
19589function rotr64_lo(ah, al, num) {
19590 var r = (ah << (32 - num)) | (al >>> num);
19591 return r >>> 0;
19592}
19593exports.rotr64_lo = rotr64_lo;
19594
19595function shr64_hi(ah, al, num) {
19596 return ah >>> num;
19597}
19598exports.shr64_hi = shr64_hi;
19599
19600function shr64_lo(ah, al, num) {
19601 var r = (ah << (32 - num)) | (al >>> num);
19602 return r >>> 0;
19603}
19604exports.shr64_lo = shr64_lo;
19605
19606},{"inherits":107,"minimalistic-assert":120}],104:[function(require,module,exports){
19607'use strict';
19608
19609var hash = require('hash.js');
19610var utils = require('minimalistic-crypto-utils');
19611var assert = require('minimalistic-assert');
19612
19613function HmacDRBG(options) {
19614 if (!(this instanceof HmacDRBG))
19615 return new HmacDRBG(options);
19616 this.hash = options.hash;
19617 this.predResist = !!options.predResist;
19618
19619 this.outLen = this.hash.outSize;
19620 this.minEntropy = options.minEntropy || this.hash.hmacStrength;
19621
19622 this._reseed = null;
19623 this.reseedInterval = null;
19624 this.K = null;
19625 this.V = null;
19626
19627 var entropy = utils.toArray(options.entropy, options.entropyEnc || 'hex');
19628 var nonce = utils.toArray(options.nonce, options.nonceEnc || 'hex');
19629 var pers = utils.toArray(options.pers, options.persEnc || 'hex');
19630 assert(entropy.length >= (this.minEntropy / 8),
19631 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
19632 this._init(entropy, nonce, pers);
19633}
19634module.exports = HmacDRBG;
19635
19636HmacDRBG.prototype._init = function init(entropy, nonce, pers) {
19637 var seed = entropy.concat(nonce).concat(pers);
19638
19639 this.K = new Array(this.outLen / 8);
19640 this.V = new Array(this.outLen / 8);
19641 for (var i = 0; i < this.V.length; i++) {
19642 this.K[i] = 0x00;
19643 this.V[i] = 0x01;
19644 }
19645
19646 this._update(seed);
19647 this._reseed = 1;
19648 this.reseedInterval = 0x1000000000000; // 2^48
19649};
19650
19651HmacDRBG.prototype._hmac = function hmac() {
19652 return new hash.hmac(this.hash, this.K);
19653};
19654
19655HmacDRBG.prototype._update = function update(seed) {
19656 var kmac = this._hmac()
19657 .update(this.V)
19658 .update([ 0x00 ]);
19659 if (seed)
19660 kmac = kmac.update(seed);
19661 this.K = kmac.digest();
19662 this.V = this._hmac().update(this.V).digest();
19663 if (!seed)
19664 return;
19665
19666 this.K = this._hmac()
19667 .update(this.V)
19668 .update([ 0x01 ])
19669 .update(seed)
19670 .digest();
19671 this.V = this._hmac().update(this.V).digest();
19672};
19673
19674HmacDRBG.prototype.reseed = function reseed(entropy, entropyEnc, add, addEnc) {
19675 // Optional entropy enc
19676 if (typeof entropyEnc !== 'string') {
19677 addEnc = add;
19678 add = entropyEnc;
19679 entropyEnc = null;
19680 }
19681
19682 entropy = utils.toArray(entropy, entropyEnc);
19683 add = utils.toArray(add, addEnc);
19684
19685 assert(entropy.length >= (this.minEntropy / 8),
19686 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
19687
19688 this._update(entropy.concat(add || []));
19689 this._reseed = 1;
19690};
19691
19692HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) {
19693 if (this._reseed > this.reseedInterval)
19694 throw new Error('Reseed is required');
19695
19696 // Optional encoding
19697 if (typeof enc !== 'string') {
19698 addEnc = add;
19699 add = enc;
19700 enc = null;
19701 }
19702
19703 // Optional additional data
19704 if (add) {
19705 add = utils.toArray(add, addEnc || 'hex');
19706 this._update(add);
19707 }
19708
19709 var temp = [];
19710 while (temp.length < len) {
19711 this.V = this._hmac().update(this.V).digest();
19712 temp = temp.concat(this.V);
19713 }
19714
19715 var res = temp.slice(0, len);
19716 this._update(add);
19717 this._reseed++;
19718 return utils.encode(res, enc);
19719};
19720
19721},{"hash.js":92,"minimalistic-assert":120,"minimalistic-crypto-utils":121}],105:[function(require,module,exports){
19722exports.read = function (buffer, offset, isLE, mLen, nBytes) {
19723 var e, m
19724 var eLen = nBytes * 8 - mLen - 1
19725 var eMax = (1 << eLen) - 1
19726 var eBias = eMax >> 1
19727 var nBits = -7
19728 var i = isLE ? (nBytes - 1) : 0
19729 var d = isLE ? -1 : 1
19730 var s = buffer[offset + i]
19731
19732 i += d
19733
19734 e = s & ((1 << (-nBits)) - 1)
19735 s >>= (-nBits)
19736 nBits += eLen
19737 for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
19738
19739 m = e & ((1 << (-nBits)) - 1)
19740 e >>= (-nBits)
19741 nBits += mLen
19742 for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
19743
19744 if (e === 0) {
19745 e = 1 - eBias
19746 } else if (e === eMax) {
19747 return m ? NaN : ((s ? -1 : 1) * Infinity)
19748 } else {
19749 m = m + Math.pow(2, mLen)
19750 e = e - eBias
19751 }
19752 return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
19753}
19754
19755exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
19756 var e, m, c
19757 var eLen = nBytes * 8 - mLen - 1
19758 var eMax = (1 << eLen) - 1
19759 var eBias = eMax >> 1
19760 var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
19761 var i = isLE ? 0 : (nBytes - 1)
19762 var d = isLE ? 1 : -1
19763 var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
19764
19765 value = Math.abs(value)
19766
19767 if (isNaN(value) || value === Infinity) {
19768 m = isNaN(value) ? 1 : 0
19769 e = eMax
19770 } else {
19771 e = Math.floor(Math.log(value) / Math.LN2)
19772 if (value * (c = Math.pow(2, -e)) < 1) {
19773 e--
19774 c *= 2
19775 }
19776 if (e + eBias >= 1) {
19777 value += rt / c
19778 } else {
19779 value += rt * Math.pow(2, 1 - eBias)
19780 }
19781 if (value * c >= 2) {
19782 e++
19783 c /= 2
19784 }
19785
19786 if (e + eBias >= eMax) {
19787 m = 0
19788 e = eMax
19789 } else if (e + eBias >= 1) {
19790 m = (value * c - 1) * Math.pow(2, mLen)
19791 e = e + eBias
19792 } else {
19793 m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
19794 e = 0
19795 }
19796 }
19797
19798 for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
19799
19800 e = (e << mLen) | m
19801 eLen += mLen
19802 for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
19803
19804 buffer[offset + i - d] |= s * 128
19805}
19806
19807},{}],106:[function(require,module,exports){
19808
19809var indexOf = [].indexOf;
19810
19811module.exports = function(arr, obj){
19812 if (indexOf) return arr.indexOf(obj);
19813 for (var i = 0; i < arr.length; ++i) {
19814 if (arr[i] === obj) return i;
19815 }
19816 return -1;
19817};
19818},{}],107:[function(require,module,exports){
19819if (typeof Object.create === 'function') {
19820 // implementation from standard node.js 'util' module
19821 module.exports = function inherits(ctor, superCtor) {
19822 ctor.super_ = superCtor
19823 ctor.prototype = Object.create(superCtor.prototype, {
19824 constructor: {
19825 value: ctor,
19826 enumerable: false,
19827 writable: true,
19828 configurable: true
19829 }
19830 });
19831 };
19832} else {
19833 // old school shim for old browsers
19834 module.exports = function inherits(ctor, superCtor) {
19835 ctor.super_ = superCtor
19836 var TempCtor = function () {}
19837 TempCtor.prototype = superCtor.prototype
19838 ctor.prototype = new TempCtor()
19839 ctor.prototype.constructor = ctor
19840 }
19841}
19842
19843},{}],108:[function(require,module,exports){
19844/*!
19845 * Determine if an object is a Buffer
19846 *
19847 * @author Feross Aboukhadijeh <https://feross.org>
19848 * @license MIT
19849 */
19850
19851// The _isBuffer check is for Safari 5-7 support, because it's missing
19852// Object.prototype.constructor. Remove this eventually
19853module.exports = function (obj) {
19854 return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
19855}
19856
19857function isBuffer (obj) {
19858 return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
19859}
19860
19861// For Node v0.10 support. Remove this eventually.
19862function isSlowBuffer (obj) {
19863 return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
19864}
19865
19866},{}],109:[function(require,module,exports){
19867var toString = {}.toString;
19868
19869module.exports = Array.isArray || function (arr) {
19870 return toString.call(arr) == '[object Array]';
19871};
19872
19873},{}],110:[function(require,module,exports){
19874/*
19875 A JavaScript implementation of the SHA family of hashes, as
19876 defined in FIPS PUB 180-4 and FIPS PUB 202, as well as the corresponding
19877 HMAC implementation as defined in FIPS PUB 198a
19878
19879 Copyright Brian Turek 2008-2017
19880 Distributed under the BSD License
19881 See http://caligatio.github.com/jsSHA/ for more information
19882
19883 Several functions taken from Paul Johnston
19884*/
19885'use strict';(function(Y){function C(c,a,b){var e=0,h=[],n=0,g,l,d,f,m,q,u,r,I=!1,v=[],w=[],t,y=!1,z=!1,x=-1;b=b||{};g=b.encoding||"UTF8";t=b.numRounds||1;if(t!==parseInt(t,10)||1>t)throw Error("numRounds must a integer >= 1");if("SHA-1"===c)m=512,q=K,u=Z,f=160,r=function(a){return a.slice()};else if(0===c.lastIndexOf("SHA-",0))if(q=function(a,b){return L(a,b,c)},u=function(a,b,h,e){var k,f;if("SHA-224"===c||"SHA-256"===c)k=(b+65>>>9<<4)+15,f=16;else if("SHA-384"===c||"SHA-512"===c)k=(b+129>>>10<<
198865)+31,f=32;else throw Error("Unexpected error in SHA-2 implementation");for(;a.length<=k;)a.push(0);a[b>>>5]|=128<<24-b%32;b=b+h;a[k]=b&4294967295;a[k-1]=b/4294967296|0;h=a.length;for(b=0;b<h;b+=f)e=L(a.slice(b,b+f),e,c);if("SHA-224"===c)a=[e[0],e[1],e[2],e[3],e[4],e[5],e[6]];else if("SHA-256"===c)a=e;else if("SHA-384"===c)a=[e[0].a,e[0].b,e[1].a,e[1].b,e[2].a,e[2].b,e[3].a,e[3].b,e[4].a,e[4].b,e[5].a,e[5].b];else if("SHA-512"===c)a=[e[0].a,e[0].b,e[1].a,e[1].b,e[2].a,e[2].b,e[3].a,e[3].b,e[4].a,
19887e[4].b,e[5].a,e[5].b,e[6].a,e[6].b,e[7].a,e[7].b];else throw Error("Unexpected error in SHA-2 implementation");return a},r=function(a){return a.slice()},"SHA-224"===c)m=512,f=224;else if("SHA-256"===c)m=512,f=256;else if("SHA-384"===c)m=1024,f=384;else if("SHA-512"===c)m=1024,f=512;else throw Error("Chosen SHA variant is not supported");else if(0===c.lastIndexOf("SHA3-",0)||0===c.lastIndexOf("SHAKE",0)){var F=6;q=D;r=function(a){var c=[],e;for(e=0;5>e;e+=1)c[e]=a[e].slice();return c};x=1;if("SHA3-224"===
19888c)m=1152,f=224;else if("SHA3-256"===c)m=1088,f=256;else if("SHA3-384"===c)m=832,f=384;else if("SHA3-512"===c)m=576,f=512;else if("SHAKE128"===c)m=1344,f=-1,F=31,z=!0;else if("SHAKE256"===c)m=1088,f=-1,F=31,z=!0;else throw Error("Chosen SHA variant is not supported");u=function(a,c,e,b,h){e=m;var k=F,f,g=[],n=e>>>5,l=0,d=c>>>5;for(f=0;f<d&&c>=e;f+=n)b=D(a.slice(f,f+n),b),c-=e;a=a.slice(f);for(c%=e;a.length<n;)a.push(0);f=c>>>3;a[f>>2]^=k<<f%4*8;a[n-1]^=2147483648;for(b=D(a,b);32*g.length<h;){a=b[l%
198895][l/5|0];g.push(a.b);if(32*g.length>=h)break;g.push(a.a);l+=1;0===64*l%e&&D(null,b)}return g}}else throw Error("Chosen SHA variant is not supported");d=M(a,g,x);l=A(c);this.setHMACKey=function(a,b,h){var k;if(!0===I)throw Error("HMAC key already set");if(!0===y)throw Error("Cannot set HMAC key after calling update");if(!0===z)throw Error("SHAKE is not supported for HMAC");g=(h||{}).encoding||"UTF8";b=M(b,g,x)(a);a=b.binLen;b=b.value;k=m>>>3;h=k/4-1;if(k<a/8){for(b=u(b,a,0,A(c),f);b.length<=h;)b.push(0);
19890b[h]&=4294967040}else if(k>a/8){for(;b.length<=h;)b.push(0);b[h]&=4294967040}for(a=0;a<=h;a+=1)v[a]=b[a]^909522486,w[a]=b[a]^1549556828;l=q(v,l);e=m;I=!0};this.update=function(a){var c,b,k,f=0,g=m>>>5;c=d(a,h,n);a=c.binLen;b=c.value;c=a>>>5;for(k=0;k<c;k+=g)f+m<=a&&(l=q(b.slice(k,k+g),l),f+=m);e+=f;h=b.slice(f>>>5);n=a%m;y=!0};this.getHash=function(a,b){var k,g,d,m;if(!0===I)throw Error("Cannot call getHash after setting HMAC key");d=N(b);if(!0===z){if(-1===d.shakeLen)throw Error("shakeLen must be specified in options");
19891f=d.shakeLen}switch(a){case "HEX":k=function(a){return O(a,f,x,d)};break;case "B64":k=function(a){return P(a,f,x,d)};break;case "BYTES":k=function(a){return Q(a,f,x)};break;case "ARRAYBUFFER":try{g=new ArrayBuffer(0)}catch(p){throw Error("ARRAYBUFFER not supported by this environment");}k=function(a){return R(a,f,x)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER");}m=u(h.slice(),n,e,r(l),f);for(g=1;g<t;g+=1)!0===z&&0!==f%32&&(m[m.length-1]&=16777215>>>24-f%32),m=u(m,f,
198920,A(c),f);return k(m)};this.getHMAC=function(a,b){var k,g,d,p;if(!1===I)throw Error("Cannot call getHMAC without first setting HMAC key");d=N(b);switch(a){case "HEX":k=function(a){return O(a,f,x,d)};break;case "B64":k=function(a){return P(a,f,x,d)};break;case "BYTES":k=function(a){return Q(a,f,x)};break;case "ARRAYBUFFER":try{k=new ArrayBuffer(0)}catch(v){throw Error("ARRAYBUFFER not supported by this environment");}k=function(a){return R(a,f,x)};break;default:throw Error("outputFormat must be HEX, B64, BYTES, or ARRAYBUFFER");
19893}g=u(h.slice(),n,e,r(l),f);p=q(w,A(c));p=u(g,f,m,p,f);return k(p)}}function b(c,a){this.a=c;this.b=a}function O(c,a,b,e){var h="";a/=8;var n,g,d;d=-1===b?3:0;for(n=0;n<a;n+=1)g=c[n>>>2]>>>8*(d+n%4*b),h+="0123456789abcdef".charAt(g>>>4&15)+"0123456789abcdef".charAt(g&15);return e.outputUpper?h.toUpperCase():h}function P(c,a,b,e){var h="",n=a/8,g,d,p,f;f=-1===b?3:0;for(g=0;g<n;g+=3)for(d=g+1<n?c[g+1>>>2]:0,p=g+2<n?c[g+2>>>2]:0,p=(c[g>>>2]>>>8*(f+g%4*b)&255)<<16|(d>>>8*(f+(g+1)%4*b)&255)<<8|p>>>8*(f+
19894(g+2)%4*b)&255,d=0;4>d;d+=1)8*g+6*d<=a?h+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(p>>>6*(3-d)&63):h+=e.b64Pad;return h}function Q(c,a,b){var e="";a/=8;var h,d,g;g=-1===b?3:0;for(h=0;h<a;h+=1)d=c[h>>>2]>>>8*(g+h%4*b)&255,e+=String.fromCharCode(d);return e}function R(c,a,b){a/=8;var e,h=new ArrayBuffer(a),d,g;g=new Uint8Array(h);d=-1===b?3:0;for(e=0;e<a;e+=1)g[e]=c[e>>>2]>>>8*(d+e%4*b)&255;return h}function N(c){var a={outputUpper:!1,b64Pad:"=",shakeLen:-1};c=c||{};
19895a.outputUpper=c.outputUpper||!1;!0===c.hasOwnProperty("b64Pad")&&(a.b64Pad=c.b64Pad);if(!0===c.hasOwnProperty("shakeLen")){if(0!==c.shakeLen%8)throw Error("shakeLen must be a multiple of 8");a.shakeLen=c.shakeLen}if("boolean"!==typeof a.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!==typeof a.b64Pad)throw Error("Invalid b64Pad formatting option");return a}function M(c,a,b){switch(a){case "UTF8":case "UTF16BE":case "UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE");
19896}switch(c){case "HEX":c=function(a,c,d){var g=a.length,l,p,f,m,q,u;if(0!==g%2)throw Error("String of HEX type must be in byte increments");c=c||[0];d=d||0;q=d>>>3;u=-1===b?3:0;for(l=0;l<g;l+=2){p=parseInt(a.substr(l,2),16);if(isNaN(p))throw Error("String of HEX type contains invalid characters");m=(l>>>1)+q;for(f=m>>>2;c.length<=f;)c.push(0);c[f]|=p<<8*(u+m%4*b)}return{value:c,binLen:4*g+d}};break;case "TEXT":c=function(c,h,d){var g,l,p=0,f,m,q,u,r,t;h=h||[0];d=d||0;q=d>>>3;if("UTF8"===a)for(t=-1===
19897b?3:0,f=0;f<c.length;f+=1)for(g=c.charCodeAt(f),l=[],128>g?l.push(g):2048>g?(l.push(192|g>>>6),l.push(128|g&63)):55296>g||57344<=g?l.push(224|g>>>12,128|g>>>6&63,128|g&63):(f+=1,g=65536+((g&1023)<<10|c.charCodeAt(f)&1023),l.push(240|g>>>18,128|g>>>12&63,128|g>>>6&63,128|g&63)),m=0;m<l.length;m+=1){r=p+q;for(u=r>>>2;h.length<=u;)h.push(0);h[u]|=l[m]<<8*(t+r%4*b);p+=1}else if("UTF16BE"===a||"UTF16LE"===a)for(t=-1===b?2:0,l="UTF16LE"===a&&1!==b||"UTF16LE"!==a&&1===b,f=0;f<c.length;f+=1){g=c.charCodeAt(f);
19898!0===l&&(m=g&255,g=m<<8|g>>>8);r=p+q;for(u=r>>>2;h.length<=u;)h.push(0);h[u]|=g<<8*(t+r%4*b);p+=2}return{value:h,binLen:8*p+d}};break;case "B64":c=function(a,c,d){var g=0,l,p,f,m,q,u,r,t;if(-1===a.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");p=a.indexOf("=");a=a.replace(/\=/g,"");if(-1!==p&&p<a.length)throw Error("Invalid '=' found in base-64 string");c=c||[0];d=d||0;u=d>>>3;t=-1===b?3:0;for(p=0;p<a.length;p+=4){q=a.substr(p,4);for(f=m=0;f<q.length;f+=1)l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(q[f]),
19899m|=l<<18-6*f;for(f=0;f<q.length-1;f+=1){r=g+u;for(l=r>>>2;c.length<=l;)c.push(0);c[l]|=(m>>>16-8*f&255)<<8*(t+r%4*b);g+=1}}return{value:c,binLen:8*g+d}};break;case "BYTES":c=function(a,c,d){var g,l,p,f,m,q;c=c||[0];d=d||0;p=d>>>3;q=-1===b?3:0;for(l=0;l<a.length;l+=1)g=a.charCodeAt(l),m=l+p,f=m>>>2,c.length<=f&&c.push(0),c[f]|=g<<8*(q+m%4*b);return{value:c,binLen:8*a.length+d}};break;case "ARRAYBUFFER":try{c=new ArrayBuffer(0)}catch(e){throw Error("ARRAYBUFFER not supported by this environment");}c=
19900function(a,c,d){var g,l,p,f,m,q;c=c||[0];d=d||0;l=d>>>3;m=-1===b?3:0;q=new Uint8Array(a);for(g=0;g<a.byteLength;g+=1)f=g+l,p=f>>>2,c.length<=p&&c.push(0),c[p]|=q[g]<<8*(m+f%4*b);return{value:c,binLen:8*a.byteLength+d}};break;default:throw Error("format must be HEX, TEXT, B64, BYTES, or ARRAYBUFFER");}return c}function y(c,a){return c<<a|c>>>32-a}function S(c,a){return 32<a?(a-=32,new b(c.b<<a|c.a>>>32-a,c.a<<a|c.b>>>32-a)):0!==a?new b(c.a<<a|c.b>>>32-a,c.b<<a|c.a>>>32-a):c}function w(c,a){return c>>>
19901a|c<<32-a}function t(c,a){var k=null,k=new b(c.a,c.b);return k=32>=a?new b(k.a>>>a|k.b<<32-a&4294967295,k.b>>>a|k.a<<32-a&4294967295):new b(k.b>>>a-32|k.a<<64-a&4294967295,k.a>>>a-32|k.b<<64-a&4294967295)}function T(c,a){var k=null;return k=32>=a?new b(c.a>>>a,c.b>>>a|c.a<<32-a&4294967295):new b(0,c.a>>>a-32)}function aa(c,a,b){return c&a^~c&b}function ba(c,a,k){return new b(c.a&a.a^~c.a&k.a,c.b&a.b^~c.b&k.b)}function U(c,a,b){return c&a^c&b^a&b}function ca(c,a,k){return new b(c.a&a.a^c.a&k.a^a.a&
19902k.a,c.b&a.b^c.b&k.b^a.b&k.b)}function da(c){return w(c,2)^w(c,13)^w(c,22)}function ea(c){var a=t(c,28),k=t(c,34);c=t(c,39);return new b(a.a^k.a^c.a,a.b^k.b^c.b)}function fa(c){return w(c,6)^w(c,11)^w(c,25)}function ga(c){var a=t(c,14),k=t(c,18);c=t(c,41);return new b(a.a^k.a^c.a,a.b^k.b^c.b)}function ha(c){return w(c,7)^w(c,18)^c>>>3}function ia(c){var a=t(c,1),k=t(c,8);c=T(c,7);return new b(a.a^k.a^c.a,a.b^k.b^c.b)}function ja(c){return w(c,17)^w(c,19)^c>>>10}function ka(c){var a=t(c,19),k=t(c,61);
19903c=T(c,6);return new b(a.a^k.a^c.a,a.b^k.b^c.b)}function G(c,a){var b=(c&65535)+(a&65535);return((c>>>16)+(a>>>16)+(b>>>16)&65535)<<16|b&65535}function la(c,a,b,e){var h=(c&65535)+(a&65535)+(b&65535)+(e&65535);return((c>>>16)+(a>>>16)+(b>>>16)+(e>>>16)+(h>>>16)&65535)<<16|h&65535}function H(c,a,b,e,h){var d=(c&65535)+(a&65535)+(b&65535)+(e&65535)+(h&65535);return((c>>>16)+(a>>>16)+(b>>>16)+(e>>>16)+(h>>>16)+(d>>>16)&65535)<<16|d&65535}function ma(c,a){var d,e,h;d=(c.b&65535)+(a.b&65535);e=(c.b>>>16)+
19904(a.b>>>16)+(d>>>16);h=(e&65535)<<16|d&65535;d=(c.a&65535)+(a.a&65535)+(e>>>16);e=(c.a>>>16)+(a.a>>>16)+(d>>>16);return new b((e&65535)<<16|d&65535,h)}function na(c,a,d,e){var h,n,g;h=(c.b&65535)+(a.b&65535)+(d.b&65535)+(e.b&65535);n=(c.b>>>16)+(a.b>>>16)+(d.b>>>16)+(e.b>>>16)+(h>>>16);g=(n&65535)<<16|h&65535;h=(c.a&65535)+(a.a&65535)+(d.a&65535)+(e.a&65535)+(n>>>16);n=(c.a>>>16)+(a.a>>>16)+(d.a>>>16)+(e.a>>>16)+(h>>>16);return new b((n&65535)<<16|h&65535,g)}function oa(c,a,d,e,h){var n,g,l;n=(c.b&
1990565535)+(a.b&65535)+(d.b&65535)+(e.b&65535)+(h.b&65535);g=(c.b>>>16)+(a.b>>>16)+(d.b>>>16)+(e.b>>>16)+(h.b>>>16)+(n>>>16);l=(g&65535)<<16|n&65535;n=(c.a&65535)+(a.a&65535)+(d.a&65535)+(e.a&65535)+(h.a&65535)+(g>>>16);g=(c.a>>>16)+(a.a>>>16)+(d.a>>>16)+(e.a>>>16)+(h.a>>>16)+(n>>>16);return new b((g&65535)<<16|n&65535,l)}function B(c,a){return new b(c.a^a.a,c.b^a.b)}function A(c){var a=[],d;if("SHA-1"===c)a=[1732584193,4023233417,2562383102,271733878,3285377520];else if(0===c.lastIndexOf("SHA-",0))switch(a=
19906[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],d=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],c){case "SHA-224":break;case "SHA-256":a=d;break;case "SHA-384":a=[new b(3418070365,a[0]),new b(1654270250,a[1]),new b(2438529370,a[2]),new b(355462360,a[3]),new b(1731405415,a[4]),new b(41048885895,a[5]),new b(3675008525,a[6]),new b(1203062813,a[7])];break;case "SHA-512":a=[new b(d[0],4089235720),new b(d[1],2227873595),
19907new b(d[2],4271175723),new b(d[3],1595750129),new b(d[4],2917565137),new b(d[5],725511199),new b(d[6],4215389547),new b(d[7],327033209)];break;default:throw Error("Unknown SHA variant");}else if(0===c.lastIndexOf("SHA3-",0)||0===c.lastIndexOf("SHAKE",0))for(c=0;5>c;c+=1)a[c]=[new b(0,0),new b(0,0),new b(0,0),new b(0,0),new b(0,0)];else throw Error("No SHA variants supported");return a}function K(c,a){var b=[],e,d,n,g,l,p,f;e=a[0];d=a[1];n=a[2];g=a[3];l=a[4];for(f=0;80>f;f+=1)b[f]=16>f?c[f]:y(b[f-
199083]^b[f-8]^b[f-14]^b[f-16],1),p=20>f?H(y(e,5),d&n^~d&g,l,1518500249,b[f]):40>f?H(y(e,5),d^n^g,l,1859775393,b[f]):60>f?H(y(e,5),U(d,n,g),l,2400959708,b[f]):H(y(e,5),d^n^g,l,3395469782,b[f]),l=g,g=n,n=y(d,30),d=e,e=p;a[0]=G(e,a[0]);a[1]=G(d,a[1]);a[2]=G(n,a[2]);a[3]=G(g,a[3]);a[4]=G(l,a[4]);return a}function Z(c,a,b,e){var d;for(d=(a+65>>>9<<4)+15;c.length<=d;)c.push(0);c[a>>>5]|=128<<24-a%32;a+=b;c[d]=a&4294967295;c[d-1]=a/4294967296|0;a=c.length;for(d=0;d<a;d+=16)e=K(c.slice(d,d+16),e);return e}function L(c,
19909a,k){var e,h,n,g,l,p,f,m,q,u,r,t,v,w,y,A,z,x,F,B,C,D,E=[],J;if("SHA-224"===k||"SHA-256"===k)u=64,t=1,D=Number,v=G,w=la,y=H,A=ha,z=ja,x=da,F=fa,C=U,B=aa,J=d;else if("SHA-384"===k||"SHA-512"===k)u=80,t=2,D=b,v=ma,w=na,y=oa,A=ia,z=ka,x=ea,F=ga,C=ca,B=ba,J=V;else throw Error("Unexpected error in SHA-2 implementation");k=a[0];e=a[1];h=a[2];n=a[3];g=a[4];l=a[5];p=a[6];f=a[7];for(r=0;r<u;r+=1)16>r?(q=r*t,m=c.length<=q?0:c[q],q=c.length<=q+1?0:c[q+1],E[r]=new D(m,q)):E[r]=w(z(E[r-2]),E[r-7],A(E[r-15]),E[r-
1991016]),m=y(f,F(g),B(g,l,p),J[r],E[r]),q=v(x(k),C(k,e,h)),f=p,p=l,l=g,g=v(n,m),n=h,h=e,e=k,k=v(m,q);a[0]=v(k,a[0]);a[1]=v(e,a[1]);a[2]=v(h,a[2]);a[3]=v(n,a[3]);a[4]=v(g,a[4]);a[5]=v(l,a[5]);a[6]=v(p,a[6]);a[7]=v(f,a[7]);return a}function D(c,a){var d,e,h,n,g=[],l=[];if(null!==c)for(e=0;e<c.length;e+=2)a[(e>>>1)%5][(e>>>1)/5|0]=B(a[(e>>>1)%5][(e>>>1)/5|0],new b(c[e+1],c[e]));for(d=0;24>d;d+=1){n=A("SHA3-");for(e=0;5>e;e+=1){h=a[e][0];var p=a[e][1],f=a[e][2],m=a[e][3],q=a[e][4];g[e]=new b(h.a^p.a^f.a^
19911m.a^q.a,h.b^p.b^f.b^m.b^q.b)}for(e=0;5>e;e+=1)l[e]=B(g[(e+4)%5],S(g[(e+1)%5],1));for(e=0;5>e;e+=1)for(h=0;5>h;h+=1)a[e][h]=B(a[e][h],l[e]);for(e=0;5>e;e+=1)for(h=0;5>h;h+=1)n[h][(2*e+3*h)%5]=S(a[e][h],W[e][h]);for(e=0;5>e;e+=1)for(h=0;5>h;h+=1)a[e][h]=B(n[e][h],new b(~n[(e+1)%5][h].a&n[(e+2)%5][h].a,~n[(e+1)%5][h].b&n[(e+2)%5][h].b));a[0][0]=B(a[0][0],X[d])}return a}var d,V,W,X;d=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,
199121426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,
199132227730452,2361852424,2428436474,2756734187,3204031479,3329325298];V=[new b(d[0],3609767458),new b(d[1],602891725),new b(d[2],3964484399),new b(d[3],2173295548),new b(d[4],4081628472),new b(d[5],3053834265),new b(d[6],2937671579),new b(d[7],3664609560),new b(d[8],2734883394),new b(d[9],1164996542),new b(d[10],1323610764),new b(d[11],3590304994),new b(d[12],4068182383),new b(d[13],991336113),new b(d[14],633803317),new b(d[15],3479774868),new b(d[16],2666613458),new b(d[17],944711139),new b(d[18],2341262773),
19914new b(d[19],2007800933),new b(d[20],1495990901),new b(d[21],1856431235),new b(d[22],3175218132),new b(d[23],2198950837),new b(d[24],3999719339),new b(d[25],766784016),new b(d[26],2566594879),new b(d[27],3203337956),new b(d[28],1034457026),new b(d[29],2466948901),new b(d[30],3758326383),new b(d[31],168717936),new b(d[32],1188179964),new b(d[33],1546045734),new b(d[34],1522805485),new b(d[35],2643833823),new b(d[36],2343527390),new b(d[37],1014477480),new b(d[38],1206759142),new b(d[39],344077627),
19915new b(d[40],1290863460),new b(d[41],3158454273),new b(d[42],3505952657),new b(d[43],106217008),new b(d[44],3606008344),new b(d[45],1432725776),new b(d[46],1467031594),new b(d[47],851169720),new b(d[48],3100823752),new b(d[49],1363258195),new b(d[50],3750685593),new b(d[51],3785050280),new b(d[52],3318307427),new b(d[53],3812723403),new b(d[54],2003034995),new b(d[55],3602036899),new b(d[56],1575990012),new b(d[57],1125592928),new b(d[58],2716904306),new b(d[59],442776044),new b(d[60],593698344),new b(d[61],
199163733110249),new b(d[62],2999351573),new b(d[63],3815920427),new b(3391569614,3928383900),new b(3515267271,566280711),new b(3940187606,3454069534),new b(4118630271,4000239992),new b(116418474,1914138554),new b(174292421,2731055270),new b(289380356,3203993006),new b(460393269,320620315),new b(685471733,587496836),new b(852142971,1086792851),new b(1017036298,365543100),new b(1126000580,2618297676),new b(1288033470,3409855158),new b(1501505948,4234509866),new b(1607167915,987167468),new b(1816402316,
199171246189591)];X=[new b(0,1),new b(0,32898),new b(2147483648,32906),new b(2147483648,2147516416),new b(0,32907),new b(0,2147483649),new b(2147483648,2147516545),new b(2147483648,32777),new b(0,138),new b(0,136),new b(0,2147516425),new b(0,2147483658),new b(0,2147516555),new b(2147483648,139),new b(2147483648,32905),new b(2147483648,32771),new b(2147483648,32770),new b(2147483648,128),new b(0,32778),new b(2147483648,2147483658),new b(2147483648,2147516545),new b(2147483648,32896),new b(0,2147483649),
19918new b(2147483648,2147516424)];W=[[0,36,3,41,18],[1,44,10,45,2],[62,6,43,15,61],[28,55,25,21,56],[27,20,39,8,14]];"function"===typeof define&&define.amd?define(function(){return C}):"undefined"!==typeof exports?("undefined"!==typeof module&&module.exports&&(module.exports=C),exports=C):Y.jsSHA=C})(this);
19919
19920},{}],111:[function(require,module,exports){
19921'use strict'
19922module.exports = require('./lib/api')(require('./lib/keccak'))
19923
19924},{"./lib/api":112,"./lib/keccak":116}],112:[function(require,module,exports){
19925'use strict'
19926var createKeccak = require('./keccak')
19927var createShake = require('./shake')
19928
19929module.exports = function (KeccakState) {
19930 var Keccak = createKeccak(KeccakState)
19931 var Shake = createShake(KeccakState)
19932
19933 return function (algorithm, options) {
19934 var hash = typeof algorithm === 'string' ? algorithm.toLowerCase() : algorithm
19935 switch (hash) {
19936 case 'keccak224': return new Keccak(1152, 448, null, 224, options)
19937 case 'keccak256': return new Keccak(1088, 512, null, 256, options)
19938 case 'keccak384': return new Keccak(832, 768, null, 384, options)
19939 case 'keccak512': return new Keccak(576, 1024, null, 512, options)
19940
19941 case 'sha3-224': return new Keccak(1152, 448, 0x06, 224, options)
19942 case 'sha3-256': return new Keccak(1088, 512, 0x06, 256, options)
19943 case 'sha3-384': return new Keccak(832, 768, 0x06, 384, options)
19944 case 'sha3-512': return new Keccak(576, 1024, 0x06, 512, options)
19945
19946 case 'shake128': return new Shake(1344, 256, 0x1f, options)
19947 case 'shake256': return new Shake(1088, 512, 0x1f, options)
19948
19949 default: throw new Error('Invald algorithm: ' + algorithm)
19950 }
19951 }
19952}
19953
19954},{"./keccak":113,"./shake":114}],113:[function(require,module,exports){
19955'use strict'
19956var Buffer = require('safe-buffer').Buffer
19957var Transform = require('stream').Transform
19958var inherits = require('inherits')
19959
19960module.exports = function (KeccakState) {
19961 function Keccak (rate, capacity, delimitedSuffix, hashBitLength, options) {
19962 Transform.call(this, options)
19963
19964 this._rate = rate
19965 this._capacity = capacity
19966 this._delimitedSuffix = delimitedSuffix
19967 this._hashBitLength = hashBitLength
19968 this._options = options
19969
19970 this._state = new KeccakState()
19971 this._state.initialize(rate, capacity)
19972 this._finalized = false
19973 }
19974
19975 inherits(Keccak, Transform)
19976
19977 Keccak.prototype._transform = function (chunk, encoding, callback) {
19978 var error = null
19979 try {
19980 this.update(chunk, encoding)
19981 } catch (err) {
19982 error = err
19983 }
19984
19985 callback(error)
19986 }
19987
19988 Keccak.prototype._flush = function (callback) {
19989 var error = null
19990 try {
19991 this.push(this.digest())
19992 } catch (err) {
19993 error = err
19994 }
19995
19996 callback(error)
19997 }
19998
19999 Keccak.prototype.update = function (data, encoding) {
20000 if (!Buffer.isBuffer(data) && typeof data !== 'string') throw new TypeError('Data must be a string or a buffer')
20001 if (this._finalized) throw new Error('Digest already called')
20002 if (!Buffer.isBuffer(data)) data = Buffer.from(data, encoding)
20003
20004 this._state.absorb(data)
20005
20006 return this
20007 }
20008
20009 Keccak.prototype.digest = function (encoding) {
20010 if (this._finalized) throw new Error('Digest already called')
20011 this._finalized = true
20012
20013 if (this._delimitedSuffix) this._state.absorbLastFewBits(this._delimitedSuffix)
20014 var digest = this._state.squeeze(this._hashBitLength / 8)
20015 if (encoding !== undefined) digest = digest.toString(encoding)
20016
20017 this._resetState()
20018
20019 return digest
20020 }
20021
20022 // remove result from memory
20023 Keccak.prototype._resetState = function () {
20024 this._state.initialize(this._rate, this._capacity)
20025 return this
20026 }
20027
20028 // because sometimes we need hash right now and little later
20029 Keccak.prototype._clone = function () {
20030 var clone = new Keccak(this._rate, this._capacity, this._delimitedSuffix, this._hashBitLength, this._options)
20031 this._state.copy(clone._state)
20032 clone._finalized = this._finalized
20033
20034 return clone
20035 }
20036
20037 return Keccak
20038}
20039
20040},{"inherits":107,"safe-buffer":156,"stream":172}],114:[function(require,module,exports){
20041'use strict'
20042var Buffer = require('safe-buffer').Buffer
20043var Transform = require('stream').Transform
20044var inherits = require('inherits')
20045
20046module.exports = function (KeccakState) {
20047 function Shake (rate, capacity, delimitedSuffix, options) {
20048 Transform.call(this, options)
20049
20050 this._rate = rate
20051 this._capacity = capacity
20052 this._delimitedSuffix = delimitedSuffix
20053 this._options = options
20054
20055 this._state = new KeccakState()
20056 this._state.initialize(rate, capacity)
20057 this._finalized = false
20058 }
20059
20060 inherits(Shake, Transform)
20061
20062 Shake.prototype._transform = function (chunk, encoding, callback) {
20063 var error = null
20064 try {
20065 this.update(chunk, encoding)
20066 } catch (err) {
20067 error = err
20068 }
20069
20070 callback(error)
20071 }
20072
20073 Shake.prototype._flush = function () {}
20074
20075 Shake.prototype._read = function (size) {
20076 this.push(this.squeeze(size))
20077 }
20078
20079 Shake.prototype.update = function (data, encoding) {
20080 if (!Buffer.isBuffer(data) && typeof data !== 'string') throw new TypeError('Data must be a string or a buffer')
20081 if (this._finalized) throw new Error('Squeeze already called')
20082 if (!Buffer.isBuffer(data)) data = Buffer.from(data, encoding)
20083
20084 this._state.absorb(data)
20085
20086 return this
20087 }
20088
20089 Shake.prototype.squeeze = function (dataByteLength, encoding) {
20090 if (!this._finalized) {
20091 this._finalized = true
20092 this._state.absorbLastFewBits(this._delimitedSuffix)
20093 }
20094
20095 var data = this._state.squeeze(dataByteLength)
20096 if (encoding !== undefined) data = data.toString(encoding)
20097
20098 return data
20099 }
20100
20101 Shake.prototype._resetState = function () {
20102 this._state.initialize(this._rate, this._capacity)
20103 return this
20104 }
20105
20106 Shake.prototype._clone = function () {
20107 var clone = new Shake(this._rate, this._capacity, this._delimitedSuffix, this._options)
20108 this._state.copy(clone._state)
20109 clone._finalized = this._finalized
20110
20111 return clone
20112 }
20113
20114 return Shake
20115}
20116
20117},{"inherits":107,"safe-buffer":156,"stream":172}],115:[function(require,module,exports){
20118'use strict'
20119var P1600_ROUND_CONSTANTS = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649, 0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0, 2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771, 2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648, 2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648]
20120
20121exports.p1600 = function (s) {
20122 for (var round = 0; round < 24; ++round) {
20123 // theta
20124 var lo0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40]
20125 var hi0 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41]
20126 var lo1 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42]
20127 var hi1 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43]
20128 var lo2 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44]
20129 var hi2 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45]
20130 var lo3 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46]
20131 var hi3 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47]
20132 var lo4 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48]
20133 var hi4 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49]
20134
20135 var lo = lo4 ^ (lo1 << 1 | hi1 >>> 31)
20136 var hi = hi4 ^ (hi1 << 1 | lo1 >>> 31)
20137 var t1slo0 = s[0] ^ lo
20138 var t1shi0 = s[1] ^ hi
20139 var t1slo5 = s[10] ^ lo
20140 var t1shi5 = s[11] ^ hi
20141 var t1slo10 = s[20] ^ lo
20142 var t1shi10 = s[21] ^ hi
20143 var t1slo15 = s[30] ^ lo
20144 var t1shi15 = s[31] ^ hi
20145 var t1slo20 = s[40] ^ lo
20146 var t1shi20 = s[41] ^ hi
20147 lo = lo0 ^ (lo2 << 1 | hi2 >>> 31)
20148 hi = hi0 ^ (hi2 << 1 | lo2 >>> 31)
20149 var t1slo1 = s[2] ^ lo
20150 var t1shi1 = s[3] ^ hi
20151 var t1slo6 = s[12] ^ lo
20152 var t1shi6 = s[13] ^ hi
20153 var t1slo11 = s[22] ^ lo
20154 var t1shi11 = s[23] ^ hi
20155 var t1slo16 = s[32] ^ lo
20156 var t1shi16 = s[33] ^ hi
20157 var t1slo21 = s[42] ^ lo
20158 var t1shi21 = s[43] ^ hi
20159 lo = lo1 ^ (lo3 << 1 | hi3 >>> 31)
20160 hi = hi1 ^ (hi3 << 1 | lo3 >>> 31)
20161 var t1slo2 = s[4] ^ lo
20162 var t1shi2 = s[5] ^ hi
20163 var t1slo7 = s[14] ^ lo
20164 var t1shi7 = s[15] ^ hi
20165 var t1slo12 = s[24] ^ lo
20166 var t1shi12 = s[25] ^ hi
20167 var t1slo17 = s[34] ^ lo
20168 var t1shi17 = s[35] ^ hi
20169 var t1slo22 = s[44] ^ lo
20170 var t1shi22 = s[45] ^ hi
20171 lo = lo2 ^ (lo4 << 1 | hi4 >>> 31)
20172 hi = hi2 ^ (hi4 << 1 | lo4 >>> 31)
20173 var t1slo3 = s[6] ^ lo
20174 var t1shi3 = s[7] ^ hi
20175 var t1slo8 = s[16] ^ lo
20176 var t1shi8 = s[17] ^ hi
20177 var t1slo13 = s[26] ^ lo
20178 var t1shi13 = s[27] ^ hi
20179 var t1slo18 = s[36] ^ lo
20180 var t1shi18 = s[37] ^ hi
20181 var t1slo23 = s[46] ^ lo
20182 var t1shi23 = s[47] ^ hi
20183 lo = lo3 ^ (lo0 << 1 | hi0 >>> 31)
20184 hi = hi3 ^ (hi0 << 1 | lo0 >>> 31)
20185 var t1slo4 = s[8] ^ lo
20186 var t1shi4 = s[9] ^ hi
20187 var t1slo9 = s[18] ^ lo
20188 var t1shi9 = s[19] ^ hi
20189 var t1slo14 = s[28] ^ lo
20190 var t1shi14 = s[29] ^ hi
20191 var t1slo19 = s[38] ^ lo
20192 var t1shi19 = s[39] ^ hi
20193 var t1slo24 = s[48] ^ lo
20194 var t1shi24 = s[49] ^ hi
20195
20196 // rho & pi
20197 var t2slo0 = t1slo0
20198 var t2shi0 = t1shi0
20199 var t2slo16 = (t1shi5 << 4 | t1slo5 >>> 28)
20200 var t2shi16 = (t1slo5 << 4 | t1shi5 >>> 28)
20201 var t2slo7 = (t1slo10 << 3 | t1shi10 >>> 29)
20202 var t2shi7 = (t1shi10 << 3 | t1slo10 >>> 29)
20203 var t2slo23 = (t1shi15 << 9 | t1slo15 >>> 23)
20204 var t2shi23 = (t1slo15 << 9 | t1shi15 >>> 23)
20205 var t2slo14 = (t1slo20 << 18 | t1shi20 >>> 14)
20206 var t2shi14 = (t1shi20 << 18 | t1slo20 >>> 14)
20207 var t2slo10 = (t1slo1 << 1 | t1shi1 >>> 31)
20208 var t2shi10 = (t1shi1 << 1 | t1slo1 >>> 31)
20209 var t2slo1 = (t1shi6 << 12 | t1slo6 >>> 20)
20210 var t2shi1 = (t1slo6 << 12 | t1shi6 >>> 20)
20211 var t2slo17 = (t1slo11 << 10 | t1shi11 >>> 22)
20212 var t2shi17 = (t1shi11 << 10 | t1slo11 >>> 22)
20213 var t2slo8 = (t1shi16 << 13 | t1slo16 >>> 19)
20214 var t2shi8 = (t1slo16 << 13 | t1shi16 >>> 19)
20215 var t2slo24 = (t1slo21 << 2 | t1shi21 >>> 30)
20216 var t2shi24 = (t1shi21 << 2 | t1slo21 >>> 30)
20217 var t2slo20 = (t1shi2 << 30 | t1slo2 >>> 2)
20218 var t2shi20 = (t1slo2 << 30 | t1shi2 >>> 2)
20219 var t2slo11 = (t1slo7 << 6 | t1shi7 >>> 26)
20220 var t2shi11 = (t1shi7 << 6 | t1slo7 >>> 26)
20221 var t2slo2 = (t1shi12 << 11 | t1slo12 >>> 21)
20222 var t2shi2 = (t1slo12 << 11 | t1shi12 >>> 21)
20223 var t2slo18 = (t1slo17 << 15 | t1shi17 >>> 17)
20224 var t2shi18 = (t1shi17 << 15 | t1slo17 >>> 17)
20225 var t2slo9 = (t1shi22 << 29 | t1slo22 >>> 3)
20226 var t2shi9 = (t1slo22 << 29 | t1shi22 >>> 3)
20227 var t2slo5 = (t1slo3 << 28 | t1shi3 >>> 4)
20228 var t2shi5 = (t1shi3 << 28 | t1slo3 >>> 4)
20229 var t2slo21 = (t1shi8 << 23 | t1slo8 >>> 9)
20230 var t2shi21 = (t1slo8 << 23 | t1shi8 >>> 9)
20231 var t2slo12 = (t1slo13 << 25 | t1shi13 >>> 7)
20232 var t2shi12 = (t1shi13 << 25 | t1slo13 >>> 7)
20233 var t2slo3 = (t1slo18 << 21 | t1shi18 >>> 11)
20234 var t2shi3 = (t1shi18 << 21 | t1slo18 >>> 11)
20235 var t2slo19 = (t1shi23 << 24 | t1slo23 >>> 8)
20236 var t2shi19 = (t1slo23 << 24 | t1shi23 >>> 8)
20237 var t2slo15 = (t1slo4 << 27 | t1shi4 >>> 5)
20238 var t2shi15 = (t1shi4 << 27 | t1slo4 >>> 5)
20239 var t2slo6 = (t1slo9 << 20 | t1shi9 >>> 12)
20240 var t2shi6 = (t1shi9 << 20 | t1slo9 >>> 12)
20241 var t2slo22 = (t1shi14 << 7 | t1slo14 >>> 25)
20242 var t2shi22 = (t1slo14 << 7 | t1shi14 >>> 25)
20243 var t2slo13 = (t1slo19 << 8 | t1shi19 >>> 24)
20244 var t2shi13 = (t1shi19 << 8 | t1slo19 >>> 24)
20245 var t2slo4 = (t1slo24 << 14 | t1shi24 >>> 18)
20246 var t2shi4 = (t1shi24 << 14 | t1slo24 >>> 18)
20247
20248 // chi
20249 s[0] = t2slo0 ^ (~t2slo1 & t2slo2)
20250 s[1] = t2shi0 ^ (~t2shi1 & t2shi2)
20251 s[10] = t2slo5 ^ (~t2slo6 & t2slo7)
20252 s[11] = t2shi5 ^ (~t2shi6 & t2shi7)
20253 s[20] = t2slo10 ^ (~t2slo11 & t2slo12)
20254 s[21] = t2shi10 ^ (~t2shi11 & t2shi12)
20255 s[30] = t2slo15 ^ (~t2slo16 & t2slo17)
20256 s[31] = t2shi15 ^ (~t2shi16 & t2shi17)
20257 s[40] = t2slo20 ^ (~t2slo21 & t2slo22)
20258 s[41] = t2shi20 ^ (~t2shi21 & t2shi22)
20259 s[2] = t2slo1 ^ (~t2slo2 & t2slo3)
20260 s[3] = t2shi1 ^ (~t2shi2 & t2shi3)
20261 s[12] = t2slo6 ^ (~t2slo7 & t2slo8)
20262 s[13] = t2shi6 ^ (~t2shi7 & t2shi8)
20263 s[22] = t2slo11 ^ (~t2slo12 & t2slo13)
20264 s[23] = t2shi11 ^ (~t2shi12 & t2shi13)
20265 s[32] = t2slo16 ^ (~t2slo17 & t2slo18)
20266 s[33] = t2shi16 ^ (~t2shi17 & t2shi18)
20267 s[42] = t2slo21 ^ (~t2slo22 & t2slo23)
20268 s[43] = t2shi21 ^ (~t2shi22 & t2shi23)
20269 s[4] = t2slo2 ^ (~t2slo3 & t2slo4)
20270 s[5] = t2shi2 ^ (~t2shi3 & t2shi4)
20271 s[14] = t2slo7 ^ (~t2slo8 & t2slo9)
20272 s[15] = t2shi7 ^ (~t2shi8 & t2shi9)
20273 s[24] = t2slo12 ^ (~t2slo13 & t2slo14)
20274 s[25] = t2shi12 ^ (~t2shi13 & t2shi14)
20275 s[34] = t2slo17 ^ (~t2slo18 & t2slo19)
20276 s[35] = t2shi17 ^ (~t2shi18 & t2shi19)
20277 s[44] = t2slo22 ^ (~t2slo23 & t2slo24)
20278 s[45] = t2shi22 ^ (~t2shi23 & t2shi24)
20279 s[6] = t2slo3 ^ (~t2slo4 & t2slo0)
20280 s[7] = t2shi3 ^ (~t2shi4 & t2shi0)
20281 s[16] = t2slo8 ^ (~t2slo9 & t2slo5)
20282 s[17] = t2shi8 ^ (~t2shi9 & t2shi5)
20283 s[26] = t2slo13 ^ (~t2slo14 & t2slo10)
20284 s[27] = t2shi13 ^ (~t2shi14 & t2shi10)
20285 s[36] = t2slo18 ^ (~t2slo19 & t2slo15)
20286 s[37] = t2shi18 ^ (~t2shi19 & t2shi15)
20287 s[46] = t2slo23 ^ (~t2slo24 & t2slo20)
20288 s[47] = t2shi23 ^ (~t2shi24 & t2shi20)
20289 s[8] = t2slo4 ^ (~t2slo0 & t2slo1)
20290 s[9] = t2shi4 ^ (~t2shi0 & t2shi1)
20291 s[18] = t2slo9 ^ (~t2slo5 & t2slo6)
20292 s[19] = t2shi9 ^ (~t2shi5 & t2shi6)
20293 s[28] = t2slo14 ^ (~t2slo10 & t2slo11)
20294 s[29] = t2shi14 ^ (~t2shi10 & t2shi11)
20295 s[38] = t2slo19 ^ (~t2slo15 & t2slo16)
20296 s[39] = t2shi19 ^ (~t2shi15 & t2shi16)
20297 s[48] = t2slo24 ^ (~t2slo20 & t2slo21)
20298 s[49] = t2shi24 ^ (~t2shi20 & t2shi21)
20299
20300 // iota
20301 s[0] ^= P1600_ROUND_CONSTANTS[round * 2]
20302 s[1] ^= P1600_ROUND_CONSTANTS[round * 2 + 1]
20303 }
20304}
20305
20306},{}],116:[function(require,module,exports){
20307'use strict'
20308var Buffer = require('safe-buffer').Buffer
20309var keccakState = require('./keccak-state-unroll')
20310
20311function Keccak () {
20312 // much faster than `new Array(50)`
20313 this.state = [
20314 0, 0, 0, 0, 0,
20315 0, 0, 0, 0, 0,
20316 0, 0, 0, 0, 0,
20317 0, 0, 0, 0, 0,
20318 0, 0, 0, 0, 0
20319 ]
20320
20321 this.blockSize = null
20322 this.count = 0
20323 this.squeezing = false
20324}
20325
20326Keccak.prototype.initialize = function (rate, capacity) {
20327 for (var i = 0; i < 50; ++i) this.state[i] = 0
20328 this.blockSize = rate / 8
20329 this.count = 0
20330 this.squeezing = false
20331}
20332
20333Keccak.prototype.absorb = function (data) {
20334 for (var i = 0; i < data.length; ++i) {
20335 this.state[~~(this.count / 4)] ^= data[i] << (8 * (this.count % 4))
20336 this.count += 1
20337 if (this.count === this.blockSize) {
20338 keccakState.p1600(this.state)
20339 this.count = 0
20340 }
20341 }
20342}
20343
20344Keccak.prototype.absorbLastFewBits = function (bits) {
20345 this.state[~~(this.count / 4)] ^= bits << (8 * (this.count % 4))
20346 if ((bits & 0x80) !== 0 && this.count === (this.blockSize - 1)) keccakState.p1600(this.state)
20347 this.state[~~((this.blockSize - 1) / 4)] ^= 0x80 << (8 * ((this.blockSize - 1) % 4))
20348 keccakState.p1600(this.state)
20349 this.count = 0
20350 this.squeezing = true
20351}
20352
20353Keccak.prototype.squeeze = function (length) {
20354 if (!this.squeezing) this.absorbLastFewBits(0x01)
20355
20356 var output = Buffer.alloc(length)
20357 for (var i = 0; i < length; ++i) {
20358 output[i] = (this.state[~~(this.count / 4)] >>> (8 * (this.count % 4))) & 0xff
20359 this.count += 1
20360 if (this.count === this.blockSize) {
20361 keccakState.p1600(this.state)
20362 this.count = 0
20363 }
20364 }
20365
20366 return output
20367}
20368
20369Keccak.prototype.copy = function (dest) {
20370 for (var i = 0; i < 50; ++i) dest.state[i] = this.state[i]
20371 dest.blockSize = this.blockSize
20372 dest.count = this.count
20373 dest.squeezing = this.squeezing
20374}
20375
20376module.exports = Keccak
20377
20378},{"./keccak-state-unroll":115,"safe-buffer":156}],117:[function(require,module,exports){
20379(function (Buffer){
20380'use strict'
20381var inherits = require('inherits')
20382var HashBase = require('hash-base')
20383
20384var ARRAY16 = new Array(16)
20385
20386function MD5 () {
20387 HashBase.call(this, 64)
20388
20389 // state
20390 this._a = 0x67452301
20391 this._b = 0xefcdab89
20392 this._c = 0x98badcfe
20393 this._d = 0x10325476
20394}
20395
20396inherits(MD5, HashBase)
20397
20398MD5.prototype._update = function () {
20399 var M = ARRAY16
20400 for (var i = 0; i < 16; ++i) M[i] = this._block.readInt32LE(i * 4)
20401
20402 var a = this._a
20403 var b = this._b
20404 var c = this._c
20405 var d = this._d
20406
20407 a = fnF(a, b, c, d, M[0], 0xd76aa478, 7)
20408 d = fnF(d, a, b, c, M[1], 0xe8c7b756, 12)
20409 c = fnF(c, d, a, b, M[2], 0x242070db, 17)
20410 b = fnF(b, c, d, a, M[3], 0xc1bdceee, 22)
20411 a = fnF(a, b, c, d, M[4], 0xf57c0faf, 7)
20412 d = fnF(d, a, b, c, M[5], 0x4787c62a, 12)
20413 c = fnF(c, d, a, b, M[6], 0xa8304613, 17)
20414 b = fnF(b, c, d, a, M[7], 0xfd469501, 22)
20415 a = fnF(a, b, c, d, M[8], 0x698098d8, 7)
20416 d = fnF(d, a, b, c, M[9], 0x8b44f7af, 12)
20417 c = fnF(c, d, a, b, M[10], 0xffff5bb1, 17)
20418 b = fnF(b, c, d, a, M[11], 0x895cd7be, 22)
20419 a = fnF(a, b, c, d, M[12], 0x6b901122, 7)
20420 d = fnF(d, a, b, c, M[13], 0xfd987193, 12)
20421 c = fnF(c, d, a, b, M[14], 0xa679438e, 17)
20422 b = fnF(b, c, d, a, M[15], 0x49b40821, 22)
20423
20424 a = fnG(a, b, c, d, M[1], 0xf61e2562, 5)
20425 d = fnG(d, a, b, c, M[6], 0xc040b340, 9)
20426 c = fnG(c, d, a, b, M[11], 0x265e5a51, 14)
20427 b = fnG(b, c, d, a, M[0], 0xe9b6c7aa, 20)
20428 a = fnG(a, b, c, d, M[5], 0xd62f105d, 5)
20429 d = fnG(d, a, b, c, M[10], 0x02441453, 9)
20430 c = fnG(c, d, a, b, M[15], 0xd8a1e681, 14)
20431 b = fnG(b, c, d, a, M[4], 0xe7d3fbc8, 20)
20432 a = fnG(a, b, c, d, M[9], 0x21e1cde6, 5)
20433 d = fnG(d, a, b, c, M[14], 0xc33707d6, 9)
20434 c = fnG(c, d, a, b, M[3], 0xf4d50d87, 14)
20435 b = fnG(b, c, d, a, M[8], 0x455a14ed, 20)
20436 a = fnG(a, b, c, d, M[13], 0xa9e3e905, 5)
20437 d = fnG(d, a, b, c, M[2], 0xfcefa3f8, 9)
20438 c = fnG(c, d, a, b, M[7], 0x676f02d9, 14)
20439 b = fnG(b, c, d, a, M[12], 0x8d2a4c8a, 20)
20440
20441 a = fnH(a, b, c, d, M[5], 0xfffa3942, 4)
20442 d = fnH(d, a, b, c, M[8], 0x8771f681, 11)
20443 c = fnH(c, d, a, b, M[11], 0x6d9d6122, 16)
20444 b = fnH(b, c, d, a, M[14], 0xfde5380c, 23)
20445 a = fnH(a, b, c, d, M[1], 0xa4beea44, 4)
20446 d = fnH(d, a, b, c, M[4], 0x4bdecfa9, 11)
20447 c = fnH(c, d, a, b, M[7], 0xf6bb4b60, 16)
20448 b = fnH(b, c, d, a, M[10], 0xbebfbc70, 23)
20449 a = fnH(a, b, c, d, M[13], 0x289b7ec6, 4)
20450 d = fnH(d, a, b, c, M[0], 0xeaa127fa, 11)
20451 c = fnH(c, d, a, b, M[3], 0xd4ef3085, 16)
20452 b = fnH(b, c, d, a, M[6], 0x04881d05, 23)
20453 a = fnH(a, b, c, d, M[9], 0xd9d4d039, 4)
20454 d = fnH(d, a, b, c, M[12], 0xe6db99e5, 11)
20455 c = fnH(c, d, a, b, M[15], 0x1fa27cf8, 16)
20456 b = fnH(b, c, d, a, M[2], 0xc4ac5665, 23)
20457
20458 a = fnI(a, b, c, d, M[0], 0xf4292244, 6)
20459 d = fnI(d, a, b, c, M[7], 0x432aff97, 10)
20460 c = fnI(c, d, a, b, M[14], 0xab9423a7, 15)
20461 b = fnI(b, c, d, a, M[5], 0xfc93a039, 21)
20462 a = fnI(a, b, c, d, M[12], 0x655b59c3, 6)
20463 d = fnI(d, a, b, c, M[3], 0x8f0ccc92, 10)
20464 c = fnI(c, d, a, b, M[10], 0xffeff47d, 15)
20465 b = fnI(b, c, d, a, M[1], 0x85845dd1, 21)
20466 a = fnI(a, b, c, d, M[8], 0x6fa87e4f, 6)
20467 d = fnI(d, a, b, c, M[15], 0xfe2ce6e0, 10)
20468 c = fnI(c, d, a, b, M[6], 0xa3014314, 15)
20469 b = fnI(b, c, d, a, M[13], 0x4e0811a1, 21)
20470 a = fnI(a, b, c, d, M[4], 0xf7537e82, 6)
20471 d = fnI(d, a, b, c, M[11], 0xbd3af235, 10)
20472 c = fnI(c, d, a, b, M[2], 0x2ad7d2bb, 15)
20473 b = fnI(b, c, d, a, M[9], 0xeb86d391, 21)
20474
20475 this._a = (this._a + a) | 0
20476 this._b = (this._b + b) | 0
20477 this._c = (this._c + c) | 0
20478 this._d = (this._d + d) | 0
20479}
20480
20481MD5.prototype._digest = function () {
20482 // create padding and handle blocks
20483 this._block[this._blockOffset++] = 0x80
20484 if (this._blockOffset > 56) {
20485 this._block.fill(0, this._blockOffset, 64)
20486 this._update()
20487 this._blockOffset = 0
20488 }
20489
20490 this._block.fill(0, this._blockOffset, 56)
20491 this._block.writeUInt32LE(this._length[0], 56)
20492 this._block.writeUInt32LE(this._length[1], 60)
20493 this._update()
20494
20495 // produce result
20496 var buffer = new Buffer(16)
20497 buffer.writeInt32LE(this._a, 0)
20498 buffer.writeInt32LE(this._b, 4)
20499 buffer.writeInt32LE(this._c, 8)
20500 buffer.writeInt32LE(this._d, 12)
20501 return buffer
20502}
20503
20504function rotl (x, n) {
20505 return (x << n) | (x >>> (32 - n))
20506}
20507
20508function fnF (a, b, c, d, m, k, s) {
20509 return (rotl((a + ((b & c) | ((~b) & d)) + m + k) | 0, s) + b) | 0
20510}
20511
20512function fnG (a, b, c, d, m, k, s) {
20513 return (rotl((a + ((b & d) | (c & (~d))) + m + k) | 0, s) + b) | 0
20514}
20515
20516function fnH (a, b, c, d, m, k, s) {
20517 return (rotl((a + (b ^ c ^ d) + m + k) | 0, s) + b) | 0
20518}
20519
20520function fnI (a, b, c, d, m, k, s) {
20521 return (rotl((a + ((c ^ (b | (~d)))) + m + k) | 0, s) + b) | 0
20522}
20523
20524module.exports = MD5
20525
20526}).call(this,require("buffer").Buffer)
20527},{"buffer":53,"hash-base":118,"inherits":107}],118:[function(require,module,exports){
20528'use strict'
20529var Buffer = require('safe-buffer').Buffer
20530var Transform = require('stream').Transform
20531var inherits = require('inherits')
20532
20533function throwIfNotStringOrBuffer (val, prefix) {
20534 if (!Buffer.isBuffer(val) && typeof val !== 'string') {
20535 throw new TypeError(prefix + ' must be a string or a buffer')
20536 }
20537}
20538
20539function HashBase (blockSize) {
20540 Transform.call(this)
20541
20542 this._block = Buffer.allocUnsafe(blockSize)
20543 this._blockSize = blockSize
20544 this._blockOffset = 0
20545 this._length = [0, 0, 0, 0]
20546
20547 this._finalized = false
20548}
20549
20550inherits(HashBase, Transform)
20551
20552HashBase.prototype._transform = function (chunk, encoding, callback) {
20553 var error = null
20554 try {
20555 this.update(chunk, encoding)
20556 } catch (err) {
20557 error = err
20558 }
20559
20560 callback(error)
20561}
20562
20563HashBase.prototype._flush = function (callback) {
20564 var error = null
20565 try {
20566 this.push(this.digest())
20567 } catch (err) {
20568 error = err
20569 }
20570
20571 callback(error)
20572}
20573
20574HashBase.prototype.update = function (data, encoding) {
20575 throwIfNotStringOrBuffer(data, 'Data')
20576 if (this._finalized) throw new Error('Digest already called')
20577 if (!Buffer.isBuffer(data)) data = Buffer.from(data, encoding)
20578
20579 // consume data
20580 var block = this._block
20581 var offset = 0
20582 while (this._blockOffset + data.length - offset >= this._blockSize) {
20583 for (var i = this._blockOffset; i < this._blockSize;) block[i++] = data[offset++]
20584 this._update()
20585 this._blockOffset = 0
20586 }
20587 while (offset < data.length) block[this._blockOffset++] = data[offset++]
20588
20589 // update length
20590 for (var j = 0, carry = data.length * 8; carry > 0; ++j) {
20591 this._length[j] += carry
20592 carry = (this._length[j] / 0x0100000000) | 0
20593 if (carry > 0) this._length[j] -= 0x0100000000 * carry
20594 }
20595
20596 return this
20597}
20598
20599HashBase.prototype._update = function () {
20600 throw new Error('_update is not implemented')
20601}
20602
20603HashBase.prototype.digest = function (encoding) {
20604 if (this._finalized) throw new Error('Digest already called')
20605 this._finalized = true
20606
20607 var digest = this._digest()
20608 if (encoding !== undefined) digest = digest.toString(encoding)
20609
20610 // reset state
20611 this._block.fill(0)
20612 this._blockOffset = 0
20613 for (var i = 0; i < 4; ++i) this._length[i] = 0
20614
20615 return digest
20616}
20617
20618HashBase.prototype._digest = function () {
20619 throw new Error('_digest is not implemented')
20620}
20621
20622module.exports = HashBase
20623
20624},{"inherits":107,"safe-buffer":156,"stream":172}],119:[function(require,module,exports){
20625var bn = require('bn.js');
20626var brorand = require('brorand');
20627
20628function MillerRabin(rand) {
20629 this.rand = rand || new brorand.Rand();
20630}
20631module.exports = MillerRabin;
20632
20633MillerRabin.create = function create(rand) {
20634 return new MillerRabin(rand);
20635};
20636
20637MillerRabin.prototype._randbelow = function _randbelow(n) {
20638 var len = n.bitLength();
20639 var min_bytes = Math.ceil(len / 8);
20640
20641 // Generage random bytes until a number less than n is found.
20642 // This ensures that 0..n-1 have an equal probability of being selected.
20643 do
20644 var a = new bn(this.rand.generate(min_bytes));
20645 while (a.cmp(n) >= 0);
20646
20647 return a;
20648};
20649
20650MillerRabin.prototype._randrange = function _randrange(start, stop) {
20651 // Generate a random number greater than or equal to start and less than stop.
20652 var size = stop.sub(start);
20653 return start.add(this._randbelow(size));
20654};
20655
20656MillerRabin.prototype.test = function test(n, k, cb) {
20657 var len = n.bitLength();
20658 var red = bn.mont(n);
20659 var rone = new bn(1).toRed(red);
20660
20661 if (!k)
20662 k = Math.max(1, (len / 48) | 0);
20663
20664 // Find d and s, (n - 1) = (2 ^ s) * d;
20665 var n1 = n.subn(1);
20666 for (var s = 0; !n1.testn(s); s++) {}
20667 var d = n.shrn(s);
20668
20669 var rn1 = n1.toRed(red);
20670
20671 var prime = true;
20672 for (; k > 0; k--) {
20673 var a = this._randrange(new bn(2), n1);
20674 if (cb)
20675 cb(a);
20676
20677 var x = a.toRed(red).redPow(d);
20678 if (x.cmp(rone) === 0 || x.cmp(rn1) === 0)
20679 continue;
20680
20681 for (var i = 1; i < s; i++) {
20682 x = x.redSqr();
20683
20684 if (x.cmp(rone) === 0)
20685 return false;
20686 if (x.cmp(rn1) === 0)
20687 break;
20688 }
20689
20690 if (i === s)
20691 return false;
20692 }
20693
20694 return prime;
20695};
20696
20697MillerRabin.prototype.getDivisor = function getDivisor(n, k) {
20698 var len = n.bitLength();
20699 var red = bn.mont(n);
20700 var rone = new bn(1).toRed(red);
20701
20702 if (!k)
20703 k = Math.max(1, (len / 48) | 0);
20704
20705 // Find d and s, (n - 1) = (2 ^ s) * d;
20706 var n1 = n.subn(1);
20707 for (var s = 0; !n1.testn(s); s++) {}
20708 var d = n.shrn(s);
20709
20710 var rn1 = n1.toRed(red);
20711
20712 for (; k > 0; k--) {
20713 var a = this._randrange(new bn(2), n1);
20714
20715 var g = n.gcd(a);
20716 if (g.cmpn(1) !== 0)
20717 return g;
20718
20719 var x = a.toRed(red).redPow(d);
20720 if (x.cmp(rone) === 0 || x.cmp(rn1) === 0)
20721 continue;
20722
20723 for (var i = 1; i < s; i++) {
20724 x = x.redSqr();
20725
20726 if (x.cmp(rone) === 0)
20727 return x.fromRed().subn(1).gcd(n);
20728 if (x.cmp(rn1) === 0)
20729 break;
20730 }
20731
20732 if (i === s) {
20733 x = x.redSqr();
20734 return x.fromRed().subn(1).gcd(n);
20735 }
20736 }
20737
20738 return false;
20739};
20740
20741},{"bn.js":21,"brorand":22}],120:[function(require,module,exports){
20742module.exports = assert;
20743
20744function assert(val, msg) {
20745 if (!val)
20746 throw new Error(msg || 'Assertion failed');
20747}
20748
20749assert.equal = function assertEqual(l, r, msg) {
20750 if (l != r)
20751 throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r));
20752};
20753
20754},{}],121:[function(require,module,exports){
20755'use strict';
20756
20757var utils = exports;
20758
20759function toArray(msg, enc) {
20760 if (Array.isArray(msg))
20761 return msg.slice();
20762 if (!msg)
20763 return [];
20764 var res = [];
20765 if (typeof msg !== 'string') {
20766 for (var i = 0; i < msg.length; i++)
20767 res[i] = msg[i] | 0;
20768 return res;
20769 }
20770 if (enc === 'hex') {
20771 msg = msg.replace(/[^a-z0-9]+/ig, '');
20772 if (msg.length % 2 !== 0)
20773 msg = '0' + msg;
20774 for (var i = 0; i < msg.length; i += 2)
20775 res.push(parseInt(msg[i] + msg[i + 1], 16));
20776 } else {
20777 for (var i = 0; i < msg.length; i++) {
20778 var c = msg.charCodeAt(i);
20779 var hi = c >> 8;
20780 var lo = c & 0xff;
20781 if (hi)
20782 res.push(hi, lo);
20783 else
20784 res.push(lo);
20785 }
20786 }
20787 return res;
20788}
20789utils.toArray = toArray;
20790
20791function zero2(word) {
20792 if (word.length === 1)
20793 return '0' + word;
20794 else
20795 return word;
20796}
20797utils.zero2 = zero2;
20798
20799function toHex(msg) {
20800 var res = '';
20801 for (var i = 0; i < msg.length; i++)
20802 res += zero2(msg[i].toString(16));
20803 return res;
20804}
20805utils.toHex = toHex;
20806
20807utils.encode = function encode(arr, enc) {
20808 if (enc === 'hex')
20809 return toHex(arr);
20810 else
20811 return arr;
20812};
20813
20814},{}],122:[function(require,module,exports){
20815module.exports={"2.16.840.1.101.3.4.1.1": "aes-128-ecb",
20816"2.16.840.1.101.3.4.1.2": "aes-128-cbc",
20817"2.16.840.1.101.3.4.1.3": "aes-128-ofb",
20818"2.16.840.1.101.3.4.1.4": "aes-128-cfb",
20819"2.16.840.1.101.3.4.1.21": "aes-192-ecb",
20820"2.16.840.1.101.3.4.1.22": "aes-192-cbc",
20821"2.16.840.1.101.3.4.1.23": "aes-192-ofb",
20822"2.16.840.1.101.3.4.1.24": "aes-192-cfb",
20823"2.16.840.1.101.3.4.1.41": "aes-256-ecb",
20824"2.16.840.1.101.3.4.1.42": "aes-256-cbc",
20825"2.16.840.1.101.3.4.1.43": "aes-256-ofb",
20826"2.16.840.1.101.3.4.1.44": "aes-256-cfb"
20827}
20828},{}],123:[function(require,module,exports){
20829// from https://github.com/indutny/self-signed/blob/gh-pages/lib/asn1.js
20830// Fedor, you are amazing.
20831'use strict'
20832
20833var asn1 = require('asn1.js')
20834
20835exports.certificate = require('./certificate')
20836
20837var RSAPrivateKey = asn1.define('RSAPrivateKey', function () {
20838 this.seq().obj(
20839 this.key('version').int(),
20840 this.key('modulus').int(),
20841 this.key('publicExponent').int(),
20842 this.key('privateExponent').int(),
20843 this.key('prime1').int(),
20844 this.key('prime2').int(),
20845 this.key('exponent1').int(),
20846 this.key('exponent2').int(),
20847 this.key('coefficient').int()
20848 )
20849})
20850exports.RSAPrivateKey = RSAPrivateKey
20851
20852var RSAPublicKey = asn1.define('RSAPublicKey', function () {
20853 this.seq().obj(
20854 this.key('modulus').int(),
20855 this.key('publicExponent').int()
20856 )
20857})
20858exports.RSAPublicKey = RSAPublicKey
20859
20860var PublicKey = asn1.define('SubjectPublicKeyInfo', function () {
20861 this.seq().obj(
20862 this.key('algorithm').use(AlgorithmIdentifier),
20863 this.key('subjectPublicKey').bitstr()
20864 )
20865})
20866exports.PublicKey = PublicKey
20867
20868var AlgorithmIdentifier = asn1.define('AlgorithmIdentifier', function () {
20869 this.seq().obj(
20870 this.key('algorithm').objid(),
20871 this.key('none').null_().optional(),
20872 this.key('curve').objid().optional(),
20873 this.key('params').seq().obj(
20874 this.key('p').int(),
20875 this.key('q').int(),
20876 this.key('g').int()
20877 ).optional()
20878 )
20879})
20880
20881var PrivateKeyInfo = asn1.define('PrivateKeyInfo', function () {
20882 this.seq().obj(
20883 this.key('version').int(),
20884 this.key('algorithm').use(AlgorithmIdentifier),
20885 this.key('subjectPrivateKey').octstr()
20886 )
20887})
20888exports.PrivateKey = PrivateKeyInfo
20889var EncryptedPrivateKeyInfo = asn1.define('EncryptedPrivateKeyInfo', function () {
20890 this.seq().obj(
20891 this.key('algorithm').seq().obj(
20892 this.key('id').objid(),
20893 this.key('decrypt').seq().obj(
20894 this.key('kde').seq().obj(
20895 this.key('id').objid(),
20896 this.key('kdeparams').seq().obj(
20897 this.key('salt').octstr(),
20898 this.key('iters').int()
20899 )
20900 ),
20901 this.key('cipher').seq().obj(
20902 this.key('algo').objid(),
20903 this.key('iv').octstr()
20904 )
20905 )
20906 ),
20907 this.key('subjectPrivateKey').octstr()
20908 )
20909})
20910
20911exports.EncryptedPrivateKey = EncryptedPrivateKeyInfo
20912
20913var DSAPrivateKey = asn1.define('DSAPrivateKey', function () {
20914 this.seq().obj(
20915 this.key('version').int(),
20916 this.key('p').int(),
20917 this.key('q').int(),
20918 this.key('g').int(),
20919 this.key('pub_key').int(),
20920 this.key('priv_key').int()
20921 )
20922})
20923exports.DSAPrivateKey = DSAPrivateKey
20924
20925exports.DSAparam = asn1.define('DSAparam', function () {
20926 this.int()
20927})
20928
20929var ECPrivateKey = asn1.define('ECPrivateKey', function () {
20930 this.seq().obj(
20931 this.key('version').int(),
20932 this.key('privateKey').octstr(),
20933 this.key('parameters').optional().explicit(0).use(ECParameters),
20934 this.key('publicKey').optional().explicit(1).bitstr()
20935 )
20936})
20937exports.ECPrivateKey = ECPrivateKey
20938
20939var ECParameters = asn1.define('ECParameters', function () {
20940 this.choice({
20941 namedCurve: this.objid()
20942 })
20943})
20944
20945exports.signature = asn1.define('signature', function () {
20946 this.seq().obj(
20947 this.key('r').int(),
20948 this.key('s').int()
20949 )
20950})
20951
20952},{"./certificate":124,"asn1.js":3}],124:[function(require,module,exports){
20953// from https://github.com/Rantanen/node-dtls/blob/25a7dc861bda38cfeac93a723500eea4f0ac2e86/Certificate.js
20954// thanks to @Rantanen
20955
20956'use strict'
20957
20958var asn = require('asn1.js')
20959
20960var Time = asn.define('Time', function () {
20961 this.choice({
20962 utcTime: this.utctime(),
20963 generalTime: this.gentime()
20964 })
20965})
20966
20967var AttributeTypeValue = asn.define('AttributeTypeValue', function () {
20968 this.seq().obj(
20969 this.key('type').objid(),
20970 this.key('value').any()
20971 )
20972})
20973
20974var AlgorithmIdentifier = asn.define('AlgorithmIdentifier', function () {
20975 this.seq().obj(
20976 this.key('algorithm').objid(),
20977 this.key('parameters').optional()
20978 )
20979})
20980
20981var SubjectPublicKeyInfo = asn.define('SubjectPublicKeyInfo', function () {
20982 this.seq().obj(
20983 this.key('algorithm').use(AlgorithmIdentifier),
20984 this.key('subjectPublicKey').bitstr()
20985 )
20986})
20987
20988var RelativeDistinguishedName = asn.define('RelativeDistinguishedName', function () {
20989 this.setof(AttributeTypeValue)
20990})
20991
20992var RDNSequence = asn.define('RDNSequence', function () {
20993 this.seqof(RelativeDistinguishedName)
20994})
20995
20996var Name = asn.define('Name', function () {
20997 this.choice({
20998 rdnSequence: this.use(RDNSequence)
20999 })
21000})
21001
21002var Validity = asn.define('Validity', function () {
21003 this.seq().obj(
21004 this.key('notBefore').use(Time),
21005 this.key('notAfter').use(Time)
21006 )
21007})
21008
21009var Extension = asn.define('Extension', function () {
21010 this.seq().obj(
21011 this.key('extnID').objid(),
21012 this.key('critical').bool().def(false),
21013 this.key('extnValue').octstr()
21014 )
21015})
21016
21017var TBSCertificate = asn.define('TBSCertificate', function () {
21018 this.seq().obj(
21019 this.key('version').explicit(0).int(),
21020 this.key('serialNumber').int(),
21021 this.key('signature').use(AlgorithmIdentifier),
21022 this.key('issuer').use(Name),
21023 this.key('validity').use(Validity),
21024 this.key('subject').use(Name),
21025 this.key('subjectPublicKeyInfo').use(SubjectPublicKeyInfo),
21026 this.key('issuerUniqueID').implicit(1).bitstr().optional(),
21027 this.key('subjectUniqueID').implicit(2).bitstr().optional(),
21028 this.key('extensions').explicit(3).seqof(Extension).optional()
21029 )
21030})
21031
21032var X509Certificate = asn.define('X509Certificate', function () {
21033 this.seq().obj(
21034 this.key('tbsCertificate').use(TBSCertificate),
21035 this.key('signatureAlgorithm').use(AlgorithmIdentifier),
21036 this.key('signatureValue').bitstr()
21037 )
21038})
21039
21040module.exports = X509Certificate
21041
21042},{"asn1.js":3}],125:[function(require,module,exports){
21043(function (Buffer){
21044// adapted from https://github.com/apatil/pemstrip
21045var findProc = /Proc-Type: 4,ENCRYPTED\n\r?DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)\n\r?\n\r?([0-9A-z\n\r\+\/\=]+)\n\r?/m
21046var startRegex = /^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----\n/m
21047var fullRegex = /^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----\n\r?([0-9A-z\n\r\+\/\=]+)\n\r?-----END \1-----$/m
21048var evp = require('evp_bytestokey')
21049var ciphers = require('browserify-aes')
21050module.exports = function (okey, password) {
21051 var key = okey.toString()
21052 var match = key.match(findProc)
21053 var decrypted
21054 if (!match) {
21055 var match2 = key.match(fullRegex)
21056 decrypted = new Buffer(match2[2].replace(/\r?\n/g, ''), 'base64')
21057 } else {
21058 var suite = 'aes' + match[1]
21059 var iv = new Buffer(match[2], 'hex')
21060 var cipherText = new Buffer(match[3].replace(/\r?\n/g, ''), 'base64')
21061 var cipherKey = evp(password, iv.slice(0, 8), parseInt(match[1], 10)).key
21062 var out = []
21063 var cipher = ciphers.createDecipheriv(suite, cipherKey, iv)
21064 out.push(cipher.update(cipherText))
21065 out.push(cipher.final())
21066 decrypted = Buffer.concat(out)
21067 }
21068 var tag = key.match(startRegex)[1]
21069 return {
21070 tag: tag,
21071 data: decrypted
21072 }
21073}
21074
21075}).call(this,require("buffer").Buffer)
21076},{"browserify-aes":26,"buffer":53,"evp_bytestokey":90}],126:[function(require,module,exports){
21077(function (Buffer){
21078var asn1 = require('./asn1')
21079var aesid = require('./aesid.json')
21080var fixProc = require('./fixProc')
21081var ciphers = require('browserify-aes')
21082var compat = require('pbkdf2')
21083module.exports = parseKeys
21084
21085function parseKeys (buffer) {
21086 var password
21087 if (typeof buffer === 'object' && !Buffer.isBuffer(buffer)) {
21088 password = buffer.passphrase
21089 buffer = buffer.key
21090 }
21091 if (typeof buffer === 'string') {
21092 buffer = new Buffer(buffer)
21093 }
21094
21095 var stripped = fixProc(buffer, password)
21096
21097 var type = stripped.tag
21098 var data = stripped.data
21099 var subtype, ndata
21100 switch (type) {
21101 case 'CERTIFICATE':
21102 ndata = asn1.certificate.decode(data, 'der').tbsCertificate.subjectPublicKeyInfo
21103 // falls through
21104 case 'PUBLIC KEY':
21105 if (!ndata) {
21106 ndata = asn1.PublicKey.decode(data, 'der')
21107 }
21108 subtype = ndata.algorithm.algorithm.join('.')
21109 switch (subtype) {
21110 case '1.2.840.113549.1.1.1':
21111 return asn1.RSAPublicKey.decode(ndata.subjectPublicKey.data, 'der')
21112 case '1.2.840.10045.2.1':
21113 ndata.subjectPrivateKey = ndata.subjectPublicKey
21114 return {
21115 type: 'ec',
21116 data: ndata
21117 }
21118 case '1.2.840.10040.4.1':
21119 ndata.algorithm.params.pub_key = asn1.DSAparam.decode(ndata.subjectPublicKey.data, 'der')
21120 return {
21121 type: 'dsa',
21122 data: ndata.algorithm.params
21123 }
21124 default: throw new Error('unknown key id ' + subtype)
21125 }
21126 throw new Error('unknown key type ' + type)
21127 case 'ENCRYPTED PRIVATE KEY':
21128 data = asn1.EncryptedPrivateKey.decode(data, 'der')
21129 data = decrypt(data, password)
21130 // falls through
21131 case 'PRIVATE KEY':
21132 ndata = asn1.PrivateKey.decode(data, 'der')
21133 subtype = ndata.algorithm.algorithm.join('.')
21134 switch (subtype) {
21135 case '1.2.840.113549.1.1.1':
21136 return asn1.RSAPrivateKey.decode(ndata.subjectPrivateKey, 'der')
21137 case '1.2.840.10045.2.1':
21138 return {
21139 curve: ndata.algorithm.curve,
21140 privateKey: asn1.ECPrivateKey.decode(ndata.subjectPrivateKey, 'der').privateKey
21141 }
21142 case '1.2.840.10040.4.1':
21143 ndata.algorithm.params.priv_key = asn1.DSAparam.decode(ndata.subjectPrivateKey, 'der')
21144 return {
21145 type: 'dsa',
21146 params: ndata.algorithm.params
21147 }
21148 default: throw new Error('unknown key id ' + subtype)
21149 }
21150 throw new Error('unknown key type ' + type)
21151 case 'RSA PUBLIC KEY':
21152 return asn1.RSAPublicKey.decode(data, 'der')
21153 case 'RSA PRIVATE KEY':
21154 return asn1.RSAPrivateKey.decode(data, 'der')
21155 case 'DSA PRIVATE KEY':
21156 return {
21157 type: 'dsa',
21158 params: asn1.DSAPrivateKey.decode(data, 'der')
21159 }
21160 case 'EC PRIVATE KEY':
21161 data = asn1.ECPrivateKey.decode(data, 'der')
21162 return {
21163 curve: data.parameters.value,
21164 privateKey: data.privateKey
21165 }
21166 default: throw new Error('unknown key type ' + type)
21167 }
21168}
21169parseKeys.signature = asn1.signature
21170function decrypt (data, password) {
21171 var salt = data.algorithm.decrypt.kde.kdeparams.salt
21172 var iters = parseInt(data.algorithm.decrypt.kde.kdeparams.iters.toString(), 10)
21173 var algo = aesid[data.algorithm.decrypt.cipher.algo.join('.')]
21174 var iv = data.algorithm.decrypt.cipher.iv
21175 var cipherText = data.subjectPrivateKey
21176 var keylen = parseInt(algo.split('-')[1], 10) / 8
21177 var key = compat.pbkdf2Sync(password, salt, iters, keylen)
21178 var cipher = ciphers.createDecipheriv(algo, key, iv)
21179 var out = []
21180 out.push(cipher.update(cipherText))
21181 out.push(cipher.final())
21182 return Buffer.concat(out)
21183}
21184
21185}).call(this,require("buffer").Buffer)
21186},{"./aesid.json":122,"./asn1":123,"./fixProc":125,"browserify-aes":26,"buffer":53,"pbkdf2":127}],127:[function(require,module,exports){
21187
21188exports.pbkdf2 = require('./lib/async')
21189
21190exports.pbkdf2Sync = require('./lib/sync')
21191
21192},{"./lib/async":128,"./lib/sync":131}],128:[function(require,module,exports){
21193(function (process,global){
21194var checkParameters = require('./precondition')
21195var defaultEncoding = require('./default-encoding')
21196var sync = require('./sync')
21197var Buffer = require('safe-buffer').Buffer
21198
21199var ZERO_BUF
21200var subtle = global.crypto && global.crypto.subtle
21201var toBrowser = {
21202 'sha': 'SHA-1',
21203 'sha-1': 'SHA-1',
21204 'sha1': 'SHA-1',
21205 'sha256': 'SHA-256',
21206 'sha-256': 'SHA-256',
21207 'sha384': 'SHA-384',
21208 'sha-384': 'SHA-384',
21209 'sha-512': 'SHA-512',
21210 'sha512': 'SHA-512'
21211}
21212var checks = []
21213function checkNative (algo) {
21214 if (global.process && !global.process.browser) {
21215 return Promise.resolve(false)
21216 }
21217 if (!subtle || !subtle.importKey || !subtle.deriveBits) {
21218 return Promise.resolve(false)
21219 }
21220 if (checks[algo] !== undefined) {
21221 return checks[algo]
21222 }
21223 ZERO_BUF = ZERO_BUF || Buffer.alloc(8)
21224 var prom = browserPbkdf2(ZERO_BUF, ZERO_BUF, 10, 128, algo)
21225 .then(function () {
21226 return true
21227 }).catch(function () {
21228 return false
21229 })
21230 checks[algo] = prom
21231 return prom
21232}
21233function browserPbkdf2 (password, salt, iterations, length, algo) {
21234 return subtle.importKey(
21235 'raw', password, {name: 'PBKDF2'}, false, ['deriveBits']
21236 ).then(function (key) {
21237 return subtle.deriveBits({
21238 name: 'PBKDF2',
21239 salt: salt,
21240 iterations: iterations,
21241 hash: {
21242 name: algo
21243 }
21244 }, key, length << 3)
21245 }).then(function (res) {
21246 return Buffer.from(res)
21247 })
21248}
21249function resolvePromise (promise, callback) {
21250 promise.then(function (out) {
21251 process.nextTick(function () {
21252 callback(null, out)
21253 })
21254 }, function (e) {
21255 process.nextTick(function () {
21256 callback(e)
21257 })
21258 })
21259}
21260module.exports = function (password, salt, iterations, keylen, digest, callback) {
21261 if (!Buffer.isBuffer(password)) password = Buffer.from(password, defaultEncoding)
21262 if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, defaultEncoding)
21263
21264 checkParameters(iterations, keylen)
21265 if (typeof digest === 'function') {
21266 callback = digest
21267 digest = undefined
21268 }
21269 if (typeof callback !== 'function') throw new Error('No callback provided to pbkdf2')
21270
21271 digest = digest || 'sha1'
21272 var algo = toBrowser[digest.toLowerCase()]
21273 if (!algo || typeof global.Promise !== 'function') {
21274 return process.nextTick(function () {
21275 var out
21276 try {
21277 out = sync(password, salt, iterations, keylen, digest)
21278 } catch (e) {
21279 return callback(e)
21280 }
21281 callback(null, out)
21282 })
21283 }
21284 resolvePromise(checkNative(algo).then(function (resp) {
21285 if (resp) {
21286 return browserPbkdf2(password, salt, iterations, keylen, algo)
21287 } else {
21288 return sync(password, salt, iterations, keylen, digest)
21289 }
21290 }), callback)
21291}
21292
21293}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
21294},{"./default-encoding":129,"./precondition":130,"./sync":131,"_process":133,"safe-buffer":156}],129:[function(require,module,exports){
21295(function (process){
21296var defaultEncoding
21297/* istanbul ignore next */
21298if (process.browser) {
21299 defaultEncoding = 'utf-8'
21300} else {
21301 var pVersionMajor = parseInt(process.version.split('.')[0].slice(1), 10)
21302
21303 defaultEncoding = pVersionMajor >= 6 ? 'utf-8' : 'binary'
21304}
21305module.exports = defaultEncoding
21306
21307}).call(this,require('_process'))
21308},{"_process":133}],130:[function(require,module,exports){
21309var MAX_ALLOC = Math.pow(2, 30) - 1 // default in iojs
21310module.exports = function (iterations, keylen) {
21311 if (typeof iterations !== 'number') {
21312 throw new TypeError('Iterations not a number')
21313 }
21314
21315 if (iterations < 0) {
21316 throw new TypeError('Bad iterations')
21317 }
21318
21319 if (typeof keylen !== 'number') {
21320 throw new TypeError('Key length not a number')
21321 }
21322
21323 if (keylen < 0 || keylen > MAX_ALLOC || keylen !== keylen) { /* eslint no-self-compare: 0 */
21324 throw new TypeError('Bad key length')
21325 }
21326}
21327
21328},{}],131:[function(require,module,exports){
21329var md5 = require('create-hash/md5')
21330var rmd160 = require('ripemd160')
21331var sha = require('sha.js')
21332
21333var checkParameters = require('./precondition')
21334var defaultEncoding = require('./default-encoding')
21335var Buffer = require('safe-buffer').Buffer
21336var ZEROS = Buffer.alloc(128)
21337var sizes = {
21338 md5: 16,
21339 sha1: 20,
21340 sha224: 28,
21341 sha256: 32,
21342 sha384: 48,
21343 sha512: 64,
21344 rmd160: 20,
21345 ripemd160: 20
21346}
21347
21348function Hmac (alg, key, saltLen) {
21349 var hash = getDigest(alg)
21350 var blocksize = (alg === 'sha512' || alg === 'sha384') ? 128 : 64
21351
21352 if (key.length > blocksize) {
21353 key = hash(key)
21354 } else if (key.length < blocksize) {
21355 key = Buffer.concat([key, ZEROS], blocksize)
21356 }
21357
21358 var ipad = Buffer.allocUnsafe(blocksize + sizes[alg])
21359 var opad = Buffer.allocUnsafe(blocksize + sizes[alg])
21360 for (var i = 0; i < blocksize; i++) {
21361 ipad[i] = key[i] ^ 0x36
21362 opad[i] = key[i] ^ 0x5C
21363 }
21364
21365 var ipad1 = Buffer.allocUnsafe(blocksize + saltLen + 4)
21366 ipad.copy(ipad1, 0, 0, blocksize)
21367 this.ipad1 = ipad1
21368 this.ipad2 = ipad
21369 this.opad = opad
21370 this.alg = alg
21371 this.blocksize = blocksize
21372 this.hash = hash
21373 this.size = sizes[alg]
21374}
21375
21376Hmac.prototype.run = function (data, ipad) {
21377 data.copy(ipad, this.blocksize)
21378 var h = this.hash(ipad)
21379 h.copy(this.opad, this.blocksize)
21380 return this.hash(this.opad)
21381}
21382
21383function getDigest (alg) {
21384 function shaFunc (data) {
21385 return sha(alg).update(data).digest()
21386 }
21387
21388 if (alg === 'rmd160' || alg === 'ripemd160') return rmd160
21389 if (alg === 'md5') return md5
21390 return shaFunc
21391}
21392
21393function pbkdf2 (password, salt, iterations, keylen, digest) {
21394 if (!Buffer.isBuffer(password)) password = Buffer.from(password, defaultEncoding)
21395 if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, defaultEncoding)
21396
21397 checkParameters(iterations, keylen)
21398
21399 digest = digest || 'sha1'
21400
21401 var hmac = new Hmac(digest, password, salt.length)
21402
21403 var DK = Buffer.allocUnsafe(keylen)
21404 var block1 = Buffer.allocUnsafe(salt.length + 4)
21405 salt.copy(block1, 0, 0, salt.length)
21406
21407 var destPos = 0
21408 var hLen = sizes[digest]
21409 var l = Math.ceil(keylen / hLen)
21410
21411 for (var i = 1; i <= l; i++) {
21412 block1.writeUInt32BE(i, salt.length)
21413
21414 var T = hmac.run(block1, hmac.ipad1)
21415 var U = T
21416
21417 for (var j = 1; j < iterations; j++) {
21418 U = hmac.run(U, hmac.ipad2)
21419 for (var k = 0; k < hLen; k++) T[k] ^= U[k]
21420 }
21421
21422 T.copy(DK, destPos)
21423 destPos += hLen
21424 }
21425
21426 return DK
21427}
21428
21429module.exports = pbkdf2
21430
21431},{"./default-encoding":129,"./precondition":130,"create-hash/md5":59,"ripemd160":155,"safe-buffer":156,"sha.js":165}],132:[function(require,module,exports){
21432(function (process){
21433'use strict';
21434
21435if (!process.version ||
21436 process.version.indexOf('v0.') === 0 ||
21437 process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
21438 module.exports = nextTick;
21439} else {
21440 module.exports = process.nextTick;
21441}
21442
21443function nextTick(fn, arg1, arg2, arg3) {
21444 if (typeof fn !== 'function') {
21445 throw new TypeError('"callback" argument must be a function');
21446 }
21447 var len = arguments.length;
21448 var args, i;
21449 switch (len) {
21450 case 0:
21451 case 1:
21452 return process.nextTick(fn);
21453 case 2:
21454 return process.nextTick(function afterTickOne() {
21455 fn.call(null, arg1);
21456 });
21457 case 3:
21458 return process.nextTick(function afterTickTwo() {
21459 fn.call(null, arg1, arg2);
21460 });
21461 case 4:
21462 return process.nextTick(function afterTickThree() {
21463 fn.call(null, arg1, arg2, arg3);
21464 });
21465 default:
21466 args = new Array(len - 1);
21467 i = 0;
21468 while (i < args.length) {
21469 args[i++] = arguments[i];
21470 }
21471 return process.nextTick(function afterTick() {
21472 fn.apply(null, args);
21473 });
21474 }
21475}
21476
21477}).call(this,require('_process'))
21478},{"_process":133}],133:[function(require,module,exports){
21479// shim for using process in browser
21480var process = module.exports = {};
21481
21482// cached from whatever global is present so that test runners that stub it
21483// don't break things. But we need to wrap it in a try catch in case it is
21484// wrapped in strict mode code which doesn't define any globals. It's inside a
21485// function because try/catches deoptimize in certain engines.
21486
21487var cachedSetTimeout;
21488var cachedClearTimeout;
21489
21490function defaultSetTimout() {
21491 throw new Error('setTimeout has not been defined');
21492}
21493function defaultClearTimeout () {
21494 throw new Error('clearTimeout has not been defined');
21495}
21496(function () {
21497 try {
21498 if (typeof setTimeout === 'function') {
21499 cachedSetTimeout = setTimeout;
21500 } else {
21501 cachedSetTimeout = defaultSetTimout;
21502 }
21503 } catch (e) {
21504 cachedSetTimeout = defaultSetTimout;
21505 }
21506 try {
21507 if (typeof clearTimeout === 'function') {
21508 cachedClearTimeout = clearTimeout;
21509 } else {
21510 cachedClearTimeout = defaultClearTimeout;
21511 }
21512 } catch (e) {
21513 cachedClearTimeout = defaultClearTimeout;
21514 }
21515} ())
21516function runTimeout(fun) {
21517 if (cachedSetTimeout === setTimeout) {
21518 //normal enviroments in sane situations
21519 return setTimeout(fun, 0);
21520 }
21521 // if setTimeout wasn't available but was latter defined
21522 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
21523 cachedSetTimeout = setTimeout;
21524 return setTimeout(fun, 0);
21525 }
21526 try {
21527 // when when somebody has screwed with setTimeout but no I.E. maddness
21528 return cachedSetTimeout(fun, 0);
21529 } catch(e){
21530 try {
21531 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
21532 return cachedSetTimeout.call(null, fun, 0);
21533 } catch(e){
21534 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
21535 return cachedSetTimeout.call(this, fun, 0);
21536 }
21537 }
21538
21539
21540}
21541function runClearTimeout(marker) {
21542 if (cachedClearTimeout === clearTimeout) {
21543 //normal enviroments in sane situations
21544 return clearTimeout(marker);
21545 }
21546 // if clearTimeout wasn't available but was latter defined
21547 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
21548 cachedClearTimeout = clearTimeout;
21549 return clearTimeout(marker);
21550 }
21551 try {
21552 // when when somebody has screwed with setTimeout but no I.E. maddness
21553 return cachedClearTimeout(marker);
21554 } catch (e){
21555 try {
21556 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
21557 return cachedClearTimeout.call(null, marker);
21558 } catch (e){
21559 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
21560 // Some versions of I.E. have different rules for clearTimeout vs setTimeout
21561 return cachedClearTimeout.call(this, marker);
21562 }
21563 }
21564
21565
21566
21567}
21568var queue = [];
21569var draining = false;
21570var currentQueue;
21571var queueIndex = -1;
21572
21573function cleanUpNextTick() {
21574 if (!draining || !currentQueue) {
21575 return;
21576 }
21577 draining = false;
21578 if (currentQueue.length) {
21579 queue = currentQueue.concat(queue);
21580 } else {
21581 queueIndex = -1;
21582 }
21583 if (queue.length) {
21584 drainQueue();
21585 }
21586}
21587
21588function drainQueue() {
21589 if (draining) {
21590 return;
21591 }
21592 var timeout = runTimeout(cleanUpNextTick);
21593 draining = true;
21594
21595 var len = queue.length;
21596 while(len) {
21597 currentQueue = queue;
21598 queue = [];
21599 while (++queueIndex < len) {
21600 if (currentQueue) {
21601 currentQueue[queueIndex].run();
21602 }
21603 }
21604 queueIndex = -1;
21605 len = queue.length;
21606 }
21607 currentQueue = null;
21608 draining = false;
21609 runClearTimeout(timeout);
21610}
21611
21612process.nextTick = function (fun) {
21613 var args = new Array(arguments.length - 1);
21614 if (arguments.length > 1) {
21615 for (var i = 1; i < arguments.length; i++) {
21616 args[i - 1] = arguments[i];
21617 }
21618 }
21619 queue.push(new Item(fun, args));
21620 if (queue.length === 1 && !draining) {
21621 runTimeout(drainQueue);
21622 }
21623};
21624
21625// v8 likes predictible objects
21626function Item(fun, array) {
21627 this.fun = fun;
21628 this.array = array;
21629}
21630Item.prototype.run = function () {
21631 this.fun.apply(null, this.array);
21632};
21633process.title = 'browser';
21634process.browser = true;
21635process.env = {};
21636process.argv = [];
21637process.version = ''; // empty string to avoid regexp issues
21638process.versions = {};
21639
21640function noop() {}
21641
21642process.on = noop;
21643process.addListener = noop;
21644process.once = noop;
21645process.off = noop;
21646process.removeListener = noop;
21647process.removeAllListeners = noop;
21648process.emit = noop;
21649process.prependListener = noop;
21650process.prependOnceListener = noop;
21651
21652process.listeners = function (name) { return [] }
21653
21654process.binding = function (name) {
21655 throw new Error('process.binding is not supported');
21656};
21657
21658process.cwd = function () { return '/' };
21659process.chdir = function (dir) {
21660 throw new Error('process.chdir is not supported');
21661};
21662process.umask = function() { return 0; };
21663
21664},{}],134:[function(require,module,exports){
21665exports.publicEncrypt = require('./publicEncrypt');
21666exports.privateDecrypt = require('./privateDecrypt');
21667
21668exports.privateEncrypt = function privateEncrypt(key, buf) {
21669 return exports.publicEncrypt(key, buf, true);
21670};
21671
21672exports.publicDecrypt = function publicDecrypt(key, buf) {
21673 return exports.privateDecrypt(key, buf, true);
21674};
21675},{"./privateDecrypt":136,"./publicEncrypt":137}],135:[function(require,module,exports){
21676(function (Buffer){
21677var createHash = require('create-hash');
21678module.exports = function (seed, len) {
21679 var t = new Buffer('');
21680 var i = 0, c;
21681 while (t.length < len) {
21682 c = i2ops(i++);
21683 t = Buffer.concat([t, createHash('sha1').update(seed).update(c).digest()]);
21684 }
21685 return t.slice(0, len);
21686};
21687
21688function i2ops(c) {
21689 var out = new Buffer(4);
21690 out.writeUInt32BE(c,0);
21691 return out;
21692}
21693}).call(this,require("buffer").Buffer)
21694},{"buffer":53,"create-hash":57}],136:[function(require,module,exports){
21695(function (Buffer){
21696var parseKeys = require('parse-asn1');
21697var mgf = require('./mgf');
21698var xor = require('./xor');
21699var bn = require('bn.js');
21700var crt = require('browserify-rsa');
21701var createHash = require('create-hash');
21702var withPublic = require('./withPublic');
21703module.exports = function privateDecrypt(private_key, enc, reverse) {
21704 var padding;
21705 if (private_key.padding) {
21706 padding = private_key.padding;
21707 } else if (reverse) {
21708 padding = 1;
21709 } else {
21710 padding = 4;
21711 }
21712
21713 var key = parseKeys(private_key);
21714 var k = key.modulus.byteLength();
21715 if (enc.length > k || new bn(enc).cmp(key.modulus) >= 0) {
21716 throw new Error('decryption error');
21717 }
21718 var msg;
21719 if (reverse) {
21720 msg = withPublic(new bn(enc), key);
21721 } else {
21722 msg = crt(enc, key);
21723 }
21724 var zBuffer = new Buffer(k - msg.length);
21725 zBuffer.fill(0);
21726 msg = Buffer.concat([zBuffer, msg], k);
21727 if (padding === 4) {
21728 return oaep(key, msg);
21729 } else if (padding === 1) {
21730 return pkcs1(key, msg, reverse);
21731 } else if (padding === 3) {
21732 return msg;
21733 } else {
21734 throw new Error('unknown padding');
21735 }
21736};
21737
21738function oaep(key, msg){
21739 var n = key.modulus;
21740 var k = key.modulus.byteLength();
21741 var mLen = msg.length;
21742 var iHash = createHash('sha1').update(new Buffer('')).digest();
21743 var hLen = iHash.length;
21744 var hLen2 = 2 * hLen;
21745 if (msg[0] !== 0) {
21746 throw new Error('decryption error');
21747 }
21748 var maskedSeed = msg.slice(1, hLen + 1);
21749 var maskedDb = msg.slice(hLen + 1);
21750 var seed = xor(maskedSeed, mgf(maskedDb, hLen));
21751 var db = xor(maskedDb, mgf(seed, k - hLen - 1));
21752 if (compare(iHash, db.slice(0, hLen))) {
21753 throw new Error('decryption error');
21754 }
21755 var i = hLen;
21756 while (db[i] === 0) {
21757 i++;
21758 }
21759 if (db[i++] !== 1) {
21760 throw new Error('decryption error');
21761 }
21762 return db.slice(i);
21763}
21764
21765function pkcs1(key, msg, reverse){
21766 var p1 = msg.slice(0, 2);
21767 var i = 2;
21768 var status = 0;
21769 while (msg[i++] !== 0) {
21770 if (i >= msg.length) {
21771 status++;
21772 break;
21773 }
21774 }
21775 var ps = msg.slice(2, i - 1);
21776 var p2 = msg.slice(i - 1, i);
21777
21778 if ((p1.toString('hex') !== '0002' && !reverse) || (p1.toString('hex') !== '0001' && reverse)){
21779 status++;
21780 }
21781 if (ps.length < 8) {
21782 status++;
21783 }
21784 if (status) {
21785 throw new Error('decryption error');
21786 }
21787 return msg.slice(i);
21788}
21789function compare(a, b){
21790 a = new Buffer(a);
21791 b = new Buffer(b);
21792 var dif = 0;
21793 var len = a.length;
21794 if (a.length !== b.length) {
21795 dif++;
21796 len = Math.min(a.length, b.length);
21797 }
21798 var i = -1;
21799 while (++i < len) {
21800 dif += (a[i] ^ b[i]);
21801 }
21802 return dif;
21803}
21804}).call(this,require("buffer").Buffer)
21805},{"./mgf":135,"./withPublic":138,"./xor":139,"bn.js":21,"browserify-rsa":44,"buffer":53,"create-hash":57,"parse-asn1":126}],137:[function(require,module,exports){
21806(function (Buffer){
21807var parseKeys = require('parse-asn1');
21808var randomBytes = require('randombytes');
21809var createHash = require('create-hash');
21810var mgf = require('./mgf');
21811var xor = require('./xor');
21812var bn = require('bn.js');
21813var withPublic = require('./withPublic');
21814var crt = require('browserify-rsa');
21815
21816var constants = {
21817 RSA_PKCS1_OAEP_PADDING: 4,
21818 RSA_PKCS1_PADDIN: 1,
21819 RSA_NO_PADDING: 3
21820};
21821
21822module.exports = function publicEncrypt(public_key, msg, reverse) {
21823 var padding;
21824 if (public_key.padding) {
21825 padding = public_key.padding;
21826 } else if (reverse) {
21827 padding = 1;
21828 } else {
21829 padding = 4;
21830 }
21831 var key = parseKeys(public_key);
21832 var paddedMsg;
21833 if (padding === 4) {
21834 paddedMsg = oaep(key, msg);
21835 } else if (padding === 1) {
21836 paddedMsg = pkcs1(key, msg, reverse);
21837 } else if (padding === 3) {
21838 paddedMsg = new bn(msg);
21839 if (paddedMsg.cmp(key.modulus) >= 0) {
21840 throw new Error('data too long for modulus');
21841 }
21842 } else {
21843 throw new Error('unknown padding');
21844 }
21845 if (reverse) {
21846 return crt(paddedMsg, key);
21847 } else {
21848 return withPublic(paddedMsg, key);
21849 }
21850};
21851
21852function oaep(key, msg){
21853 var k = key.modulus.byteLength();
21854 var mLen = msg.length;
21855 var iHash = createHash('sha1').update(new Buffer('')).digest();
21856 var hLen = iHash.length;
21857 var hLen2 = 2 * hLen;
21858 if (mLen > k - hLen2 - 2) {
21859 throw new Error('message too long');
21860 }
21861 var ps = new Buffer(k - mLen - hLen2 - 2);
21862 ps.fill(0);
21863 var dblen = k - hLen - 1;
21864 var seed = randomBytes(hLen);
21865 var maskedDb = xor(Buffer.concat([iHash, ps, new Buffer([1]), msg], dblen), mgf(seed, dblen));
21866 var maskedSeed = xor(seed, mgf(maskedDb, hLen));
21867 return new bn(Buffer.concat([new Buffer([0]), maskedSeed, maskedDb], k));
21868}
21869function pkcs1(key, msg, reverse){
21870 var mLen = msg.length;
21871 var k = key.modulus.byteLength();
21872 if (mLen > k - 11) {
21873 throw new Error('message too long');
21874 }
21875 var ps;
21876 if (reverse) {
21877 ps = new Buffer(k - mLen - 3);
21878 ps.fill(0xff);
21879 } else {
21880 ps = nonZero(k - mLen - 3);
21881 }
21882 return new bn(Buffer.concat([new Buffer([0, reverse?1:2]), ps, new Buffer([0]), msg], k));
21883}
21884function nonZero(len, crypto) {
21885 var out = new Buffer(len);
21886 var i = 0;
21887 var cache = randomBytes(len*2);
21888 var cur = 0;
21889 var num;
21890 while (i < len) {
21891 if (cur === cache.length) {
21892 cache = randomBytes(len*2);
21893 cur = 0;
21894 }
21895 num = cache[cur++];
21896 if (num) {
21897 out[i++] = num;
21898 }
21899 }
21900 return out;
21901}
21902}).call(this,require("buffer").Buffer)
21903},{"./mgf":135,"./withPublic":138,"./xor":139,"bn.js":21,"browserify-rsa":44,"buffer":53,"create-hash":57,"parse-asn1":126,"randombytes":140}],138:[function(require,module,exports){
21904(function (Buffer){
21905var bn = require('bn.js');
21906function withPublic(paddedMsg, key) {
21907 return new Buffer(paddedMsg
21908 .toRed(bn.mont(key.modulus))
21909 .redPow(new bn(key.publicExponent))
21910 .fromRed()
21911 .toArray());
21912}
21913
21914module.exports = withPublic;
21915}).call(this,require("buffer").Buffer)
21916},{"bn.js":21,"buffer":53}],139:[function(require,module,exports){
21917module.exports = function xor(a, b) {
21918 var len = a.length;
21919 var i = -1;
21920 while (++i < len) {
21921 a[i] ^= b[i];
21922 }
21923 return a
21924};
21925},{}],140:[function(require,module,exports){
21926(function (process,global){
21927'use strict'
21928
21929function oldBrowser () {
21930 throw new Error('secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11')
21931}
21932
21933var Buffer = require('safe-buffer').Buffer
21934var crypto = global.crypto || global.msCrypto
21935
21936if (crypto && crypto.getRandomValues) {
21937 module.exports = randomBytes
21938} else {
21939 module.exports = oldBrowser
21940}
21941
21942function randomBytes (size, cb) {
21943 // phantomjs needs to throw
21944 if (size > 65536) throw new Error('requested too many random bytes')
21945 // in case browserify isn't using the Uint8Array version
21946 var rawBytes = new global.Uint8Array(size)
21947
21948 // This will not work in older browsers.
21949 // See https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues
21950 if (size > 0) { // getRandomValues fails on IE if size == 0
21951 crypto.getRandomValues(rawBytes)
21952 }
21953
21954 // XXX: phantomjs doesn't like a buffer being passed here
21955 var bytes = Buffer.from(rawBytes.buffer)
21956
21957 if (typeof cb === 'function') {
21958 return process.nextTick(function () {
21959 cb(null, bytes)
21960 })
21961 }
21962
21963 return bytes
21964}
21965
21966}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
21967},{"_process":133,"safe-buffer":156}],141:[function(require,module,exports){
21968(function (process,global){
21969'use strict'
21970
21971function oldBrowser () {
21972 throw new Error('secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11')
21973}
21974var safeBuffer = require('safe-buffer')
21975var randombytes = require('randombytes')
21976var Buffer = safeBuffer.Buffer
21977var kBufferMaxLength = safeBuffer.kMaxLength
21978var crypto = global.crypto || global.msCrypto
21979var kMaxUint32 = Math.pow(2, 32) - 1
21980function assertOffset (offset, length) {
21981 if (typeof offset !== 'number' || offset !== offset) { // eslint-disable-line no-self-compare
21982 throw new TypeError('offset must be a number')
21983 }
21984
21985 if (offset > kMaxUint32 || offset < 0) {
21986 throw new TypeError('offset must be a uint32')
21987 }
21988
21989 if (offset > kBufferMaxLength || offset > length) {
21990 throw new RangeError('offset out of range')
21991 }
21992}
21993
21994function assertSize (size, offset, length) {
21995 if (typeof size !== 'number' || size !== size) { // eslint-disable-line no-self-compare
21996 throw new TypeError('size must be a number')
21997 }
21998
21999 if (size > kMaxUint32 || size < 0) {
22000 throw new TypeError('size must be a uint32')
22001 }
22002
22003 if (size + offset > length || size > kBufferMaxLength) {
22004 throw new RangeError('buffer too small')
22005 }
22006}
22007if ((crypto && crypto.getRandomValues) || !process.browser) {
22008 exports.randomFill = randomFill
22009 exports.randomFillSync = randomFillSync
22010} else {
22011 exports.randomFill = oldBrowser
22012 exports.randomFillSync = oldBrowser
22013}
22014function randomFill (buf, offset, size, cb) {
22015 if (!Buffer.isBuffer(buf) && !(buf instanceof global.Uint8Array)) {
22016 throw new TypeError('"buf" argument must be a Buffer or Uint8Array')
22017 }
22018
22019 if (typeof offset === 'function') {
22020 cb = offset
22021 offset = 0
22022 size = buf.length
22023 } else if (typeof size === 'function') {
22024 cb = size
22025 size = buf.length - offset
22026 } else if (typeof cb !== 'function') {
22027 throw new TypeError('"cb" argument must be a function')
22028 }
22029 assertOffset(offset, buf.length)
22030 assertSize(size, offset, buf.length)
22031 return actualFill(buf, offset, size, cb)
22032}
22033
22034function actualFill (buf, offset, size, cb) {
22035 if (process.browser) {
22036 var ourBuf = buf.buffer
22037 var uint = new Uint8Array(ourBuf, offset, size)
22038 crypto.getRandomValues(uint)
22039 if (cb) {
22040 process.nextTick(function () {
22041 cb(null, buf)
22042 })
22043 return
22044 }
22045 return buf
22046 }
22047 if (cb) {
22048 randombytes(size, function (err, bytes) {
22049 if (err) {
22050 return cb(err)
22051 }
22052 bytes.copy(buf, offset)
22053 cb(null, buf)
22054 })
22055 return
22056 }
22057 var bytes = randombytes(size)
22058 bytes.copy(buf, offset)
22059 return buf
22060}
22061function randomFillSync (buf, offset, size) {
22062 if (typeof offset === 'undefined') {
22063 offset = 0
22064 }
22065 if (!Buffer.isBuffer(buf) && !(buf instanceof global.Uint8Array)) {
22066 throw new TypeError('"buf" argument must be a Buffer or Uint8Array')
22067 }
22068
22069 assertOffset(offset, buf.length)
22070
22071 if (size === undefined) size = buf.length - offset
22072
22073 assertSize(size, offset, buf.length)
22074
22075 return actualFill(buf, offset, size)
22076}
22077
22078}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
22079},{"_process":133,"randombytes":140,"safe-buffer":156}],142:[function(require,module,exports){
22080module.exports = require('./lib/_stream_duplex.js');
22081
22082},{"./lib/_stream_duplex.js":143}],143:[function(require,module,exports){
22083// Copyright Joyent, Inc. and other Node contributors.
22084//
22085// Permission is hereby granted, free of charge, to any person obtaining a
22086// copy of this software and associated documentation files (the
22087// "Software"), to deal in the Software without restriction, including
22088// without limitation the rights to use, copy, modify, merge, publish,
22089// distribute, sublicense, and/or sell copies of the Software, and to permit
22090// persons to whom the Software is furnished to do so, subject to the
22091// following conditions:
22092//
22093// The above copyright notice and this permission notice shall be included
22094// in all copies or substantial portions of the Software.
22095//
22096// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22097// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22098// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
22099// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
22100// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22101// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22102// USE OR OTHER DEALINGS IN THE SOFTWARE.
22103
22104// a duplex stream is just a stream that is both readable and writable.
22105// Since JS doesn't have multiple prototypal inheritance, this class
22106// prototypally inherits from Readable, and then parasitically from
22107// Writable.
22108
22109'use strict';
22110
22111/*<replacement>*/
22112
22113var processNextTick = require('process-nextick-args');
22114/*</replacement>*/
22115
22116/*<replacement>*/
22117var objectKeys = Object.keys || function (obj) {
22118 var keys = [];
22119 for (var key in obj) {
22120 keys.push(key);
22121 }return keys;
22122};
22123/*</replacement>*/
22124
22125module.exports = Duplex;
22126
22127/*<replacement>*/
22128var util = require('core-util-is');
22129util.inherits = require('inherits');
22130/*</replacement>*/
22131
22132var Readable = require('./_stream_readable');
22133var Writable = require('./_stream_writable');
22134
22135util.inherits(Duplex, Readable);
22136
22137var keys = objectKeys(Writable.prototype);
22138for (var v = 0; v < keys.length; v++) {
22139 var method = keys[v];
22140 if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
22141}
22142
22143function Duplex(options) {
22144 if (!(this instanceof Duplex)) return new Duplex(options);
22145
22146 Readable.call(this, options);
22147 Writable.call(this, options);
22148
22149 if (options && options.readable === false) this.readable = false;
22150
22151 if (options && options.writable === false) this.writable = false;
22152
22153 this.allowHalfOpen = true;
22154 if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
22155
22156 this.once('end', onend);
22157}
22158
22159// the no-half-open enforcer
22160function onend() {
22161 // if we allow half-open state, or if the writable side ended,
22162 // then we're ok.
22163 if (this.allowHalfOpen || this._writableState.ended) return;
22164
22165 // no more data can be written.
22166 // But allow more writes to happen in this tick.
22167 processNextTick(onEndNT, this);
22168}
22169
22170function onEndNT(self) {
22171 self.end();
22172}
22173
22174Object.defineProperty(Duplex.prototype, 'destroyed', {
22175 get: function () {
22176 if (this._readableState === undefined || this._writableState === undefined) {
22177 return false;
22178 }
22179 return this._readableState.destroyed && this._writableState.destroyed;
22180 },
22181 set: function (value) {
22182 // we ignore the value if the stream
22183 // has not been initialized yet
22184 if (this._readableState === undefined || this._writableState === undefined) {
22185 return;
22186 }
22187
22188 // backward compatibility, the user is explicitly
22189 // managing destroyed
22190 this._readableState.destroyed = value;
22191 this._writableState.destroyed = value;
22192 }
22193});
22194
22195Duplex.prototype._destroy = function (err, cb) {
22196 this.push(null);
22197 this.end();
22198
22199 processNextTick(cb, err);
22200};
22201
22202function forEach(xs, f) {
22203 for (var i = 0, l = xs.length; i < l; i++) {
22204 f(xs[i], i);
22205 }
22206}
22207},{"./_stream_readable":145,"./_stream_writable":147,"core-util-is":55,"inherits":107,"process-nextick-args":132}],144:[function(require,module,exports){
22208// Copyright Joyent, Inc. and other Node contributors.
22209//
22210// Permission is hereby granted, free of charge, to any person obtaining a
22211// copy of this software and associated documentation files (the
22212// "Software"), to deal in the Software without restriction, including
22213// without limitation the rights to use, copy, modify, merge, publish,
22214// distribute, sublicense, and/or sell copies of the Software, and to permit
22215// persons to whom the Software is furnished to do so, subject to the
22216// following conditions:
22217//
22218// The above copyright notice and this permission notice shall be included
22219// in all copies or substantial portions of the Software.
22220//
22221// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22222// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22223// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
22224// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
22225// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22226// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22227// USE OR OTHER DEALINGS IN THE SOFTWARE.
22228
22229// a passthrough stream.
22230// basically just the most minimal sort of Transform stream.
22231// Every written chunk gets output as-is.
22232
22233'use strict';
22234
22235module.exports = PassThrough;
22236
22237var Transform = require('./_stream_transform');
22238
22239/*<replacement>*/
22240var util = require('core-util-is');
22241util.inherits = require('inherits');
22242/*</replacement>*/
22243
22244util.inherits(PassThrough, Transform);
22245
22246function PassThrough(options) {
22247 if (!(this instanceof PassThrough)) return new PassThrough(options);
22248
22249 Transform.call(this, options);
22250}
22251
22252PassThrough.prototype._transform = function (chunk, encoding, cb) {
22253 cb(null, chunk);
22254};
22255},{"./_stream_transform":146,"core-util-is":55,"inherits":107}],145:[function(require,module,exports){
22256(function (process,global){
22257// Copyright Joyent, Inc. and other Node contributors.
22258//
22259// Permission is hereby granted, free of charge, to any person obtaining a
22260// copy of this software and associated documentation files (the
22261// "Software"), to deal in the Software without restriction, including
22262// without limitation the rights to use, copy, modify, merge, publish,
22263// distribute, sublicense, and/or sell copies of the Software, and to permit
22264// persons to whom the Software is furnished to do so, subject to the
22265// following conditions:
22266//
22267// The above copyright notice and this permission notice shall be included
22268// in all copies or substantial portions of the Software.
22269//
22270// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22271// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22272// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
22273// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
22274// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22275// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22276// USE OR OTHER DEALINGS IN THE SOFTWARE.
22277
22278'use strict';
22279
22280/*<replacement>*/
22281
22282var processNextTick = require('process-nextick-args');
22283/*</replacement>*/
22284
22285module.exports = Readable;
22286
22287/*<replacement>*/
22288var isArray = require('isarray');
22289/*</replacement>*/
22290
22291/*<replacement>*/
22292var Duplex;
22293/*</replacement>*/
22294
22295Readable.ReadableState = ReadableState;
22296
22297/*<replacement>*/
22298var EE = require('events').EventEmitter;
22299
22300var EElistenerCount = function (emitter, type) {
22301 return emitter.listeners(type).length;
22302};
22303/*</replacement>*/
22304
22305/*<replacement>*/
22306var Stream = require('./internal/streams/stream');
22307/*</replacement>*/
22308
22309// TODO(bmeurer): Change this back to const once hole checks are
22310// properly optimized away early in Ignition+TurboFan.
22311/*<replacement>*/
22312var Buffer = require('safe-buffer').Buffer;
22313var OurUint8Array = global.Uint8Array || function () {};
22314function _uint8ArrayToBuffer(chunk) {
22315 return Buffer.from(chunk);
22316}
22317function _isUint8Array(obj) {
22318 return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
22319}
22320/*</replacement>*/
22321
22322/*<replacement>*/
22323var util = require('core-util-is');
22324util.inherits = require('inherits');
22325/*</replacement>*/
22326
22327/*<replacement>*/
22328var debugUtil = require('util');
22329var debug = void 0;
22330if (debugUtil && debugUtil.debuglog) {
22331 debug = debugUtil.debuglog('stream');
22332} else {
22333 debug = function () {};
22334}
22335/*</replacement>*/
22336
22337var BufferList = require('./internal/streams/BufferList');
22338var destroyImpl = require('./internal/streams/destroy');
22339var StringDecoder;
22340
22341util.inherits(Readable, Stream);
22342
22343var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
22344
22345function prependListener(emitter, event, fn) {
22346 // Sadly this is not cacheable as some libraries bundle their own
22347 // event emitter implementation with them.
22348 if (typeof emitter.prependListener === 'function') {
22349 return emitter.prependListener(event, fn);
22350 } else {
22351 // This is a hack to make sure that our error handler is attached before any
22352 // userland ones. NEVER DO THIS. This is here only because this code needs
22353 // to continue to work with older versions of Node.js that do not include
22354 // the prependListener() method. The goal is to eventually remove this hack.
22355 if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
22356 }
22357}
22358
22359function ReadableState(options, stream) {
22360 Duplex = Duplex || require('./_stream_duplex');
22361
22362 options = options || {};
22363
22364 // object stream flag. Used to make read(n) ignore n and to
22365 // make all the buffer merging and length checks go away
22366 this.objectMode = !!options.objectMode;
22367
22368 if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
22369
22370 // the point at which it stops calling _read() to fill the buffer
22371 // Note: 0 is a valid value, means "don't call _read preemptively ever"
22372 var hwm = options.highWaterMark;
22373 var defaultHwm = this.objectMode ? 16 : 16 * 1024;
22374 this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
22375
22376 // cast to ints.
22377 this.highWaterMark = Math.floor(this.highWaterMark);
22378
22379 // A linked list is used to store data chunks instead of an array because the
22380 // linked list can remove elements from the beginning faster than
22381 // array.shift()
22382 this.buffer = new BufferList();
22383 this.length = 0;
22384 this.pipes = null;
22385 this.pipesCount = 0;
22386 this.flowing = null;
22387 this.ended = false;
22388 this.endEmitted = false;
22389 this.reading = false;
22390
22391 // a flag to be able to tell if the event 'readable'/'data' is emitted
22392 // immediately, or on a later tick. We set this to true at first, because
22393 // any actions that shouldn't happen until "later" should generally also
22394 // not happen before the first read call.
22395 this.sync = true;
22396
22397 // whenever we return null, then we set a flag to say
22398 // that we're awaiting a 'readable' event emission.
22399 this.needReadable = false;
22400 this.emittedReadable = false;
22401 this.readableListening = false;
22402 this.resumeScheduled = false;
22403
22404 // has it been destroyed
22405 this.destroyed = false;
22406
22407 // Crypto is kind of old and crusty. Historically, its default string
22408 // encoding is 'binary' so we have to make this configurable.
22409 // Everything else in the universe uses 'utf8', though.
22410 this.defaultEncoding = options.defaultEncoding || 'utf8';
22411
22412 // the number of writers that are awaiting a drain event in .pipe()s
22413 this.awaitDrain = 0;
22414
22415 // if true, a maybeReadMore has been scheduled
22416 this.readingMore = false;
22417
22418 this.decoder = null;
22419 this.encoding = null;
22420 if (options.encoding) {
22421 if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
22422 this.decoder = new StringDecoder(options.encoding);
22423 this.encoding = options.encoding;
22424 }
22425}
22426
22427function Readable(options) {
22428 Duplex = Duplex || require('./_stream_duplex');
22429
22430 if (!(this instanceof Readable)) return new Readable(options);
22431
22432 this._readableState = new ReadableState(options, this);
22433
22434 // legacy
22435 this.readable = true;
22436
22437 if (options) {
22438 if (typeof options.read === 'function') this._read = options.read;
22439
22440 if (typeof options.destroy === 'function') this._destroy = options.destroy;
22441 }
22442
22443 Stream.call(this);
22444}
22445
22446Object.defineProperty(Readable.prototype, 'destroyed', {
22447 get: function () {
22448 if (this._readableState === undefined) {
22449 return false;
22450 }
22451 return this._readableState.destroyed;
22452 },
22453 set: function (value) {
22454 // we ignore the value if the stream
22455 // has not been initialized yet
22456 if (!this._readableState) {
22457 return;
22458 }
22459
22460 // backward compatibility, the user is explicitly
22461 // managing destroyed
22462 this._readableState.destroyed = value;
22463 }
22464});
22465
22466Readable.prototype.destroy = destroyImpl.destroy;
22467Readable.prototype._undestroy = destroyImpl.undestroy;
22468Readable.prototype._destroy = function (err, cb) {
22469 this.push(null);
22470 cb(err);
22471};
22472
22473// Manually shove something into the read() buffer.
22474// This returns true if the highWaterMark has not been hit yet,
22475// similar to how Writable.write() returns true if you should
22476// write() some more.
22477Readable.prototype.push = function (chunk, encoding) {
22478 var state = this._readableState;
22479 var skipChunkCheck;
22480
22481 if (!state.objectMode) {
22482 if (typeof chunk === 'string') {
22483 encoding = encoding || state.defaultEncoding;
22484 if (encoding !== state.encoding) {
22485 chunk = Buffer.from(chunk, encoding);
22486 encoding = '';
22487 }
22488 skipChunkCheck = true;
22489 }
22490 } else {
22491 skipChunkCheck = true;
22492 }
22493
22494 return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
22495};
22496
22497// Unshift should *always* be something directly out of read()
22498Readable.prototype.unshift = function (chunk) {
22499 return readableAddChunk(this, chunk, null, true, false);
22500};
22501
22502function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
22503 var state = stream._readableState;
22504 if (chunk === null) {
22505 state.reading = false;
22506 onEofChunk(stream, state);
22507 } else {
22508 var er;
22509 if (!skipChunkCheck) er = chunkInvalid(state, chunk);
22510 if (er) {
22511 stream.emit('error', er);
22512 } else if (state.objectMode || chunk && chunk.length > 0) {
22513 if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
22514 chunk = _uint8ArrayToBuffer(chunk);
22515 }
22516
22517 if (addToFront) {
22518 if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
22519 } else if (state.ended) {
22520 stream.emit('error', new Error('stream.push() after EOF'));
22521 } else {
22522 state.reading = false;
22523 if (state.decoder && !encoding) {
22524 chunk = state.decoder.write(chunk);
22525 if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
22526 } else {
22527 addChunk(stream, state, chunk, false);
22528 }
22529 }
22530 } else if (!addToFront) {
22531 state.reading = false;
22532 }
22533 }
22534
22535 return needMoreData(state);
22536}
22537
22538function addChunk(stream, state, chunk, addToFront) {
22539 if (state.flowing && state.length === 0 && !state.sync) {
22540 stream.emit('data', chunk);
22541 stream.read(0);
22542 } else {
22543 // update the buffer info.
22544 state.length += state.objectMode ? 1 : chunk.length;
22545 if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
22546
22547 if (state.needReadable) emitReadable(stream);
22548 }
22549 maybeReadMore(stream, state);
22550}
22551
22552function chunkInvalid(state, chunk) {
22553 var er;
22554 if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
22555 er = new TypeError('Invalid non-string/buffer chunk');
22556 }
22557 return er;
22558}
22559
22560// if it's past the high water mark, we can push in some more.
22561// Also, if we have no data yet, we can stand some
22562// more bytes. This is to work around cases where hwm=0,
22563// such as the repl. Also, if the push() triggered a
22564// readable event, and the user called read(largeNumber) such that
22565// needReadable was set, then we ought to push more, so that another
22566// 'readable' event will be triggered.
22567function needMoreData(state) {
22568 return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
22569}
22570
22571Readable.prototype.isPaused = function () {
22572 return this._readableState.flowing === false;
22573};
22574
22575// backwards compatibility.
22576Readable.prototype.setEncoding = function (enc) {
22577 if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
22578 this._readableState.decoder = new StringDecoder(enc);
22579 this._readableState.encoding = enc;
22580 return this;
22581};
22582
22583// Don't raise the hwm > 8MB
22584var MAX_HWM = 0x800000;
22585function computeNewHighWaterMark(n) {
22586 if (n >= MAX_HWM) {
22587 n = MAX_HWM;
22588 } else {
22589 // Get the next highest power of 2 to prevent increasing hwm excessively in
22590 // tiny amounts
22591 n--;
22592 n |= n >>> 1;
22593 n |= n >>> 2;
22594 n |= n >>> 4;
22595 n |= n >>> 8;
22596 n |= n >>> 16;
22597 n++;
22598 }
22599 return n;
22600}
22601
22602// This function is designed to be inlinable, so please take care when making
22603// changes to the function body.
22604function howMuchToRead(n, state) {
22605 if (n <= 0 || state.length === 0 && state.ended) return 0;
22606 if (state.objectMode) return 1;
22607 if (n !== n) {
22608 // Only flow one buffer at a time
22609 if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
22610 }
22611 // If we're asking for more than the current hwm, then raise the hwm.
22612 if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
22613 if (n <= state.length) return n;
22614 // Don't have enough
22615 if (!state.ended) {
22616 state.needReadable = true;
22617 return 0;
22618 }
22619 return state.length;
22620}
22621
22622// you can override either this method, or the async _read(n) below.
22623Readable.prototype.read = function (n) {
22624 debug('read', n);
22625 n = parseInt(n, 10);
22626 var state = this._readableState;
22627 var nOrig = n;
22628
22629 if (n !== 0) state.emittedReadable = false;
22630
22631 // if we're doing read(0) to trigger a readable event, but we
22632 // already have a bunch of data in the buffer, then just trigger
22633 // the 'readable' event and move on.
22634 if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
22635 debug('read: emitReadable', state.length, state.ended);
22636 if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
22637 return null;
22638 }
22639
22640 n = howMuchToRead(n, state);
22641
22642 // if we've ended, and we're now clear, then finish it up.
22643 if (n === 0 && state.ended) {
22644 if (state.length === 0) endReadable(this);
22645 return null;
22646 }
22647
22648 // All the actual chunk generation logic needs to be
22649 // *below* the call to _read. The reason is that in certain
22650 // synthetic stream cases, such as passthrough streams, _read
22651 // may be a completely synchronous operation which may change
22652 // the state of the read buffer, providing enough data when
22653 // before there was *not* enough.
22654 //
22655 // So, the steps are:
22656 // 1. Figure out what the state of things will be after we do
22657 // a read from the buffer.
22658 //
22659 // 2. If that resulting state will trigger a _read, then call _read.
22660 // Note that this may be asynchronous, or synchronous. Yes, it is
22661 // deeply ugly to write APIs this way, but that still doesn't mean
22662 // that the Readable class should behave improperly, as streams are
22663 // designed to be sync/async agnostic.
22664 // Take note if the _read call is sync or async (ie, if the read call
22665 // has returned yet), so that we know whether or not it's safe to emit
22666 // 'readable' etc.
22667 //
22668 // 3. Actually pull the requested chunks out of the buffer and return.
22669
22670 // if we need a readable event, then we need to do some reading.
22671 var doRead = state.needReadable;
22672 debug('need readable', doRead);
22673
22674 // if we currently have less than the highWaterMark, then also read some
22675 if (state.length === 0 || state.length - n < state.highWaterMark) {
22676 doRead = true;
22677 debug('length less than watermark', doRead);
22678 }
22679
22680 // however, if we've ended, then there's no point, and if we're already
22681 // reading, then it's unnecessary.
22682 if (state.ended || state.reading) {
22683 doRead = false;
22684 debug('reading or ended', doRead);
22685 } else if (doRead) {
22686 debug('do read');
22687 state.reading = true;
22688 state.sync = true;
22689 // if the length is currently zero, then we *need* a readable event.
22690 if (state.length === 0) state.needReadable = true;
22691 // call internal read method
22692 this._read(state.highWaterMark);
22693 state.sync = false;
22694 // If _read pushed data synchronously, then `reading` will be false,
22695 // and we need to re-evaluate how much data we can return to the user.
22696 if (!state.reading) n = howMuchToRead(nOrig, state);
22697 }
22698
22699 var ret;
22700 if (n > 0) ret = fromList(n, state);else ret = null;
22701
22702 if (ret === null) {
22703 state.needReadable = true;
22704 n = 0;
22705 } else {
22706 state.length -= n;
22707 }
22708
22709 if (state.length === 0) {
22710 // If we have nothing in the buffer, then we want to know
22711 // as soon as we *do* get something into the buffer.
22712 if (!state.ended) state.needReadable = true;
22713
22714 // If we tried to read() past the EOF, then emit end on the next tick.
22715 if (nOrig !== n && state.ended) endReadable(this);
22716 }
22717
22718 if (ret !== null) this.emit('data', ret);
22719
22720 return ret;
22721};
22722
22723function onEofChunk(stream, state) {
22724 if (state.ended) return;
22725 if (state.decoder) {
22726 var chunk = state.decoder.end();
22727 if (chunk && chunk.length) {
22728 state.buffer.push(chunk);
22729 state.length += state.objectMode ? 1 : chunk.length;
22730 }
22731 }
22732 state.ended = true;
22733
22734 // emit 'readable' now to make sure it gets picked up.
22735 emitReadable(stream);
22736}
22737
22738// Don't emit readable right away in sync mode, because this can trigger
22739// another read() call => stack overflow. This way, it might trigger
22740// a nextTick recursion warning, but that's not so bad.
22741function emitReadable(stream) {
22742 var state = stream._readableState;
22743 state.needReadable = false;
22744 if (!state.emittedReadable) {
22745 debug('emitReadable', state.flowing);
22746 state.emittedReadable = true;
22747 if (state.sync) processNextTick(emitReadable_, stream);else emitReadable_(stream);
22748 }
22749}
22750
22751function emitReadable_(stream) {
22752 debug('emit readable');
22753 stream.emit('readable');
22754 flow(stream);
22755}
22756
22757// at this point, the user has presumably seen the 'readable' event,
22758// and called read() to consume some data. that may have triggered
22759// in turn another _read(n) call, in which case reading = true if
22760// it's in progress.
22761// However, if we're not ended, or reading, and the length < hwm,
22762// then go ahead and try to read some more preemptively.
22763function maybeReadMore(stream, state) {
22764 if (!state.readingMore) {
22765 state.readingMore = true;
22766 processNextTick(maybeReadMore_, stream, state);
22767 }
22768}
22769
22770function maybeReadMore_(stream, state) {
22771 var len = state.length;
22772 while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
22773 debug('maybeReadMore read 0');
22774 stream.read(0);
22775 if (len === state.length)
22776 // didn't get any data, stop spinning.
22777 break;else len = state.length;
22778 }
22779 state.readingMore = false;
22780}
22781
22782// abstract method. to be overridden in specific implementation classes.
22783// call cb(er, data) where data is <= n in length.
22784// for virtual (non-string, non-buffer) streams, "length" is somewhat
22785// arbitrary, and perhaps not very meaningful.
22786Readable.prototype._read = function (n) {
22787 this.emit('error', new Error('_read() is not implemented'));
22788};
22789
22790Readable.prototype.pipe = function (dest, pipeOpts) {
22791 var src = this;
22792 var state = this._readableState;
22793
22794 switch (state.pipesCount) {
22795 case 0:
22796 state.pipes = dest;
22797 break;
22798 case 1:
22799 state.pipes = [state.pipes, dest];
22800 break;
22801 default:
22802 state.pipes.push(dest);
22803 break;
22804 }
22805 state.pipesCount += 1;
22806 debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
22807
22808 var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
22809
22810 var endFn = doEnd ? onend : unpipe;
22811 if (state.endEmitted) processNextTick(endFn);else src.once('end', endFn);
22812
22813 dest.on('unpipe', onunpipe);
22814 function onunpipe(readable, unpipeInfo) {
22815 debug('onunpipe');
22816 if (readable === src) {
22817 if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
22818 unpipeInfo.hasUnpiped = true;
22819 cleanup();
22820 }
22821 }
22822 }
22823
22824 function onend() {
22825 debug('onend');
22826 dest.end();
22827 }
22828
22829 // when the dest drains, it reduces the awaitDrain counter
22830 // on the source. This would be more elegant with a .once()
22831 // handler in flow(), but adding and removing repeatedly is
22832 // too slow.
22833 var ondrain = pipeOnDrain(src);
22834 dest.on('drain', ondrain);
22835
22836 var cleanedUp = false;
22837 function cleanup() {
22838 debug('cleanup');
22839 // cleanup event handlers once the pipe is broken
22840 dest.removeListener('close', onclose);
22841 dest.removeListener('finish', onfinish);
22842 dest.removeListener('drain', ondrain);
22843 dest.removeListener('error', onerror);
22844 dest.removeListener('unpipe', onunpipe);
22845 src.removeListener('end', onend);
22846 src.removeListener('end', unpipe);
22847 src.removeListener('data', ondata);
22848
22849 cleanedUp = true;
22850
22851 // if the reader is waiting for a drain event from this
22852 // specific writer, then it would cause it to never start
22853 // flowing again.
22854 // So, if this is awaiting a drain, then we just call it now.
22855 // If we don't know, then assume that we are waiting for one.
22856 if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
22857 }
22858
22859 // If the user pushes more data while we're writing to dest then we'll end up
22860 // in ondata again. However, we only want to increase awaitDrain once because
22861 // dest will only emit one 'drain' event for the multiple writes.
22862 // => Introduce a guard on increasing awaitDrain.
22863 var increasedAwaitDrain = false;
22864 src.on('data', ondata);
22865 function ondata(chunk) {
22866 debug('ondata');
22867 increasedAwaitDrain = false;
22868 var ret = dest.write(chunk);
22869 if (false === ret && !increasedAwaitDrain) {
22870 // If the user unpiped during `dest.write()`, it is possible
22871 // to get stuck in a permanently paused state if that write
22872 // also returned false.
22873 // => Check whether `dest` is still a piping destination.
22874 if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
22875 debug('false write response, pause', src._readableState.awaitDrain);
22876 src._readableState.awaitDrain++;
22877 increasedAwaitDrain = true;
22878 }
22879 src.pause();
22880 }
22881 }
22882
22883 // if the dest has an error, then stop piping into it.
22884 // however, don't suppress the throwing behavior for this.
22885 function onerror(er) {
22886 debug('onerror', er);
22887 unpipe();
22888 dest.removeListener('error', onerror);
22889 if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
22890 }
22891
22892 // Make sure our error handler is attached before userland ones.
22893 prependListener(dest, 'error', onerror);
22894
22895 // Both close and finish should trigger unpipe, but only once.
22896 function onclose() {
22897 dest.removeListener('finish', onfinish);
22898 unpipe();
22899 }
22900 dest.once('close', onclose);
22901 function onfinish() {
22902 debug('onfinish');
22903 dest.removeListener('close', onclose);
22904 unpipe();
22905 }
22906 dest.once('finish', onfinish);
22907
22908 function unpipe() {
22909 debug('unpipe');
22910 src.unpipe(dest);
22911 }
22912
22913 // tell the dest that it's being piped to
22914 dest.emit('pipe', src);
22915
22916 // start the flow if it hasn't been started already.
22917 if (!state.flowing) {
22918 debug('pipe resume');
22919 src.resume();
22920 }
22921
22922 return dest;
22923};
22924
22925function pipeOnDrain(src) {
22926 return function () {
22927 var state = src._readableState;
22928 debug('pipeOnDrain', state.awaitDrain);
22929 if (state.awaitDrain) state.awaitDrain--;
22930 if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
22931 state.flowing = true;
22932 flow(src);
22933 }
22934 };
22935}
22936
22937Readable.prototype.unpipe = function (dest) {
22938 var state = this._readableState;
22939 var unpipeInfo = { hasUnpiped: false };
22940
22941 // if we're not piping anywhere, then do nothing.
22942 if (state.pipesCount === 0) return this;
22943
22944 // just one destination. most common case.
22945 if (state.pipesCount === 1) {
22946 // passed in one, but it's not the right one.
22947 if (dest && dest !== state.pipes) return this;
22948
22949 if (!dest) dest = state.pipes;
22950
22951 // got a match.
22952 state.pipes = null;
22953 state.pipesCount = 0;
22954 state.flowing = false;
22955 if (dest) dest.emit('unpipe', this, unpipeInfo);
22956 return this;
22957 }
22958
22959 // slow case. multiple pipe destinations.
22960
22961 if (!dest) {
22962 // remove all.
22963 var dests = state.pipes;
22964 var len = state.pipesCount;
22965 state.pipes = null;
22966 state.pipesCount = 0;
22967 state.flowing = false;
22968
22969 for (var i = 0; i < len; i++) {
22970 dests[i].emit('unpipe', this, unpipeInfo);
22971 }return this;
22972 }
22973
22974 // try to find the right one.
22975 var index = indexOf(state.pipes, dest);
22976 if (index === -1) return this;
22977
22978 state.pipes.splice(index, 1);
22979 state.pipesCount -= 1;
22980 if (state.pipesCount === 1) state.pipes = state.pipes[0];
22981
22982 dest.emit('unpipe', this, unpipeInfo);
22983
22984 return this;
22985};
22986
22987// set up data events if they are asked for
22988// Ensure readable listeners eventually get something
22989Readable.prototype.on = function (ev, fn) {
22990 var res = Stream.prototype.on.call(this, ev, fn);
22991
22992 if (ev === 'data') {
22993 // Start flowing on next tick if stream isn't explicitly paused
22994 if (this._readableState.flowing !== false) this.resume();
22995 } else if (ev === 'readable') {
22996 var state = this._readableState;
22997 if (!state.endEmitted && !state.readableListening) {
22998 state.readableListening = state.needReadable = true;
22999 state.emittedReadable = false;
23000 if (!state.reading) {
23001 processNextTick(nReadingNextTick, this);
23002 } else if (state.length) {
23003 emitReadable(this);
23004 }
23005 }
23006 }
23007
23008 return res;
23009};
23010Readable.prototype.addListener = Readable.prototype.on;
23011
23012function nReadingNextTick(self) {
23013 debug('readable nexttick read 0');
23014 self.read(0);
23015}
23016
23017// pause() and resume() are remnants of the legacy readable stream API
23018// If the user uses them, then switch into old mode.
23019Readable.prototype.resume = function () {
23020 var state = this._readableState;
23021 if (!state.flowing) {
23022 debug('resume');
23023 state.flowing = true;
23024 resume(this, state);
23025 }
23026 return this;
23027};
23028
23029function resume(stream, state) {
23030 if (!state.resumeScheduled) {
23031 state.resumeScheduled = true;
23032 processNextTick(resume_, stream, state);
23033 }
23034}
23035
23036function resume_(stream, state) {
23037 if (!state.reading) {
23038 debug('resume read 0');
23039 stream.read(0);
23040 }
23041
23042 state.resumeScheduled = false;
23043 state.awaitDrain = 0;
23044 stream.emit('resume');
23045 flow(stream);
23046 if (state.flowing && !state.reading) stream.read(0);
23047}
23048
23049Readable.prototype.pause = function () {
23050 debug('call pause flowing=%j', this._readableState.flowing);
23051 if (false !== this._readableState.flowing) {
23052 debug('pause');
23053 this._readableState.flowing = false;
23054 this.emit('pause');
23055 }
23056 return this;
23057};
23058
23059function flow(stream) {
23060 var state = stream._readableState;
23061 debug('flow', state.flowing);
23062 while (state.flowing && stream.read() !== null) {}
23063}
23064
23065// wrap an old-style stream as the async data source.
23066// This is *not* part of the readable stream interface.
23067// It is an ugly unfortunate mess of history.
23068Readable.prototype.wrap = function (stream) {
23069 var state = this._readableState;
23070 var paused = false;
23071
23072 var self = this;
23073 stream.on('end', function () {
23074 debug('wrapped end');
23075 if (state.decoder && !state.ended) {
23076 var chunk = state.decoder.end();
23077 if (chunk && chunk.length) self.push(chunk);
23078 }
23079
23080 self.push(null);
23081 });
23082
23083 stream.on('data', function (chunk) {
23084 debug('wrapped data');
23085 if (state.decoder) chunk = state.decoder.write(chunk);
23086
23087 // don't skip over falsy values in objectMode
23088 if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
23089
23090 var ret = self.push(chunk);
23091 if (!ret) {
23092 paused = true;
23093 stream.pause();
23094 }
23095 });
23096
23097 // proxy all the other methods.
23098 // important when wrapping filters and duplexes.
23099 for (var i in stream) {
23100 if (this[i] === undefined && typeof stream[i] === 'function') {
23101 this[i] = function (method) {
23102 return function () {
23103 return stream[method].apply(stream, arguments);
23104 };
23105 }(i);
23106 }
23107 }
23108
23109 // proxy certain important events.
23110 for (var n = 0; n < kProxyEvents.length; n++) {
23111 stream.on(kProxyEvents[n], self.emit.bind(self, kProxyEvents[n]));
23112 }
23113
23114 // when we try to consume some more bytes, simply unpause the
23115 // underlying stream.
23116 self._read = function (n) {
23117 debug('wrapped _read', n);
23118 if (paused) {
23119 paused = false;
23120 stream.resume();
23121 }
23122 };
23123
23124 return self;
23125};
23126
23127// exposed for testing purposes only.
23128Readable._fromList = fromList;
23129
23130// Pluck off n bytes from an array of buffers.
23131// Length is the combined lengths of all the buffers in the list.
23132// This function is designed to be inlinable, so please take care when making
23133// changes to the function body.
23134function fromList(n, state) {
23135 // nothing buffered
23136 if (state.length === 0) return null;
23137
23138 var ret;
23139 if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
23140 // read it all, truncate the list
23141 if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);
23142 state.buffer.clear();
23143 } else {
23144 // read part of list
23145 ret = fromListPartial(n, state.buffer, state.decoder);
23146 }
23147
23148 return ret;
23149}
23150
23151// Extracts only enough buffered data to satisfy the amount requested.
23152// This function is designed to be inlinable, so please take care when making
23153// changes to the function body.
23154function fromListPartial(n, list, hasStrings) {
23155 var ret;
23156 if (n < list.head.data.length) {
23157 // slice is the same for buffers and strings
23158 ret = list.head.data.slice(0, n);
23159 list.head.data = list.head.data.slice(n);
23160 } else if (n === list.head.data.length) {
23161 // first chunk is a perfect match
23162 ret = list.shift();
23163 } else {
23164 // result spans more than one buffer
23165 ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
23166 }
23167 return ret;
23168}
23169
23170// Copies a specified amount of characters from the list of buffered data
23171// chunks.
23172// This function is designed to be inlinable, so please take care when making
23173// changes to the function body.
23174function copyFromBufferString(n, list) {
23175 var p = list.head;
23176 var c = 1;
23177 var ret = p.data;
23178 n -= ret.length;
23179 while (p = p.next) {
23180 var str = p.data;
23181 var nb = n > str.length ? str.length : n;
23182 if (nb === str.length) ret += str;else ret += str.slice(0, n);
23183 n -= nb;
23184 if (n === 0) {
23185 if (nb === str.length) {
23186 ++c;
23187 if (p.next) list.head = p.next;else list.head = list.tail = null;
23188 } else {
23189 list.head = p;
23190 p.data = str.slice(nb);
23191 }
23192 break;
23193 }
23194 ++c;
23195 }
23196 list.length -= c;
23197 return ret;
23198}
23199
23200// Copies a specified amount of bytes from the list of buffered data chunks.
23201// This function is designed to be inlinable, so please take care when making
23202// changes to the function body.
23203function copyFromBuffer(n, list) {
23204 var ret = Buffer.allocUnsafe(n);
23205 var p = list.head;
23206 var c = 1;
23207 p.data.copy(ret);
23208 n -= p.data.length;
23209 while (p = p.next) {
23210 var buf = p.data;
23211 var nb = n > buf.length ? buf.length : n;
23212 buf.copy(ret, ret.length - n, 0, nb);
23213 n -= nb;
23214 if (n === 0) {
23215 if (nb === buf.length) {
23216 ++c;
23217 if (p.next) list.head = p.next;else list.head = list.tail = null;
23218 } else {
23219 list.head = p;
23220 p.data = buf.slice(nb);
23221 }
23222 break;
23223 }
23224 ++c;
23225 }
23226 list.length -= c;
23227 return ret;
23228}
23229
23230function endReadable(stream) {
23231 var state = stream._readableState;
23232
23233 // If we get here before consuming all the bytes, then that is a
23234 // bug in node. Should never happen.
23235 if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
23236
23237 if (!state.endEmitted) {
23238 state.ended = true;
23239 processNextTick(endReadableNT, state, stream);
23240 }
23241}
23242
23243function endReadableNT(state, stream) {
23244 // Check that we didn't get one last unshift.
23245 if (!state.endEmitted && state.length === 0) {
23246 state.endEmitted = true;
23247 stream.readable = false;
23248 stream.emit('end');
23249 }
23250}
23251
23252function forEach(xs, f) {
23253 for (var i = 0, l = xs.length; i < l; i++) {
23254 f(xs[i], i);
23255 }
23256}
23257
23258function indexOf(xs, x) {
23259 for (var i = 0, l = xs.length; i < l; i++) {
23260 if (xs[i] === x) return i;
23261 }
23262 return -1;
23263}
23264}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
23265},{"./_stream_duplex":143,"./internal/streams/BufferList":148,"./internal/streams/destroy":149,"./internal/streams/stream":150,"_process":133,"core-util-is":55,"events":89,"inherits":107,"isarray":109,"process-nextick-args":132,"safe-buffer":156,"string_decoder/":173,"util":23}],146:[function(require,module,exports){
23266// Copyright Joyent, Inc. and other Node contributors.
23267//
23268// Permission is hereby granted, free of charge, to any person obtaining a
23269// copy of this software and associated documentation files (the
23270// "Software"), to deal in the Software without restriction, including
23271// without limitation the rights to use, copy, modify, merge, publish,
23272// distribute, sublicense, and/or sell copies of the Software, and to permit
23273// persons to whom the Software is furnished to do so, subject to the
23274// following conditions:
23275//
23276// The above copyright notice and this permission notice shall be included
23277// in all copies or substantial portions of the Software.
23278//
23279// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23280// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23281// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
23282// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
23283// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23284// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
23285// USE OR OTHER DEALINGS IN THE SOFTWARE.
23286
23287// a transform stream is a readable/writable stream where you do
23288// something with the data. Sometimes it's called a "filter",
23289// but that's not a great name for it, since that implies a thing where
23290// some bits pass through, and others are simply ignored. (That would
23291// be a valid example of a transform, of course.)
23292//
23293// While the output is causally related to the input, it's not a
23294// necessarily symmetric or synchronous transformation. For example,
23295// a zlib stream might take multiple plain-text writes(), and then
23296// emit a single compressed chunk some time in the future.
23297//
23298// Here's how this works:
23299//
23300// The Transform stream has all the aspects of the readable and writable
23301// stream classes. When you write(chunk), that calls _write(chunk,cb)
23302// internally, and returns false if there's a lot of pending writes
23303// buffered up. When you call read(), that calls _read(n) until
23304// there's enough pending readable data buffered up.
23305//
23306// In a transform stream, the written data is placed in a buffer. When
23307// _read(n) is called, it transforms the queued up data, calling the
23308// buffered _write cb's as it consumes chunks. If consuming a single
23309// written chunk would result in multiple output chunks, then the first
23310// outputted bit calls the readcb, and subsequent chunks just go into
23311// the read buffer, and will cause it to emit 'readable' if necessary.
23312//
23313// This way, back-pressure is actually determined by the reading side,
23314// since _read has to be called to start processing a new chunk. However,
23315// a pathological inflate type of transform can cause excessive buffering
23316// here. For example, imagine a stream where every byte of input is
23317// interpreted as an integer from 0-255, and then results in that many
23318// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
23319// 1kb of data being output. In this case, you could write a very small
23320// amount of input, and end up with a very large amount of output. In
23321// such a pathological inflating mechanism, there'd be no way to tell
23322// the system to stop doing the transform. A single 4MB write could
23323// cause the system to run out of memory.
23324//
23325// However, even in such a pathological case, only a single written chunk
23326// would be consumed, and then the rest would wait (un-transformed) until
23327// the results of the previous transformed chunk were consumed.
23328
23329'use strict';
23330
23331module.exports = Transform;
23332
23333var Duplex = require('./_stream_duplex');
23334
23335/*<replacement>*/
23336var util = require('core-util-is');
23337util.inherits = require('inherits');
23338/*</replacement>*/
23339
23340util.inherits(Transform, Duplex);
23341
23342function TransformState(stream) {
23343 this.afterTransform = function (er, data) {
23344 return afterTransform(stream, er, data);
23345 };
23346
23347 this.needTransform = false;
23348 this.transforming = false;
23349 this.writecb = null;
23350 this.writechunk = null;
23351 this.writeencoding = null;
23352}
23353
23354function afterTransform(stream, er, data) {
23355 var ts = stream._transformState;
23356 ts.transforming = false;
23357
23358 var cb = ts.writecb;
23359
23360 if (!cb) {
23361 return stream.emit('error', new Error('write callback called multiple times'));
23362 }
23363
23364 ts.writechunk = null;
23365 ts.writecb = null;
23366
23367 if (data !== null && data !== undefined) stream.push(data);
23368
23369 cb(er);
23370
23371 var rs = stream._readableState;
23372 rs.reading = false;
23373 if (rs.needReadable || rs.length < rs.highWaterMark) {
23374 stream._read(rs.highWaterMark);
23375 }
23376}
23377
23378function Transform(options) {
23379 if (!(this instanceof Transform)) return new Transform(options);
23380
23381 Duplex.call(this, options);
23382
23383 this._transformState = new TransformState(this);
23384
23385 var stream = this;
23386
23387 // start out asking for a readable event once data is transformed.
23388 this._readableState.needReadable = true;
23389
23390 // we have implemented the _read method, and done the other things
23391 // that Readable wants before the first _read call, so unset the
23392 // sync guard flag.
23393 this._readableState.sync = false;
23394
23395 if (options) {
23396 if (typeof options.transform === 'function') this._transform = options.transform;
23397
23398 if (typeof options.flush === 'function') this._flush = options.flush;
23399 }
23400
23401 // When the writable side finishes, then flush out anything remaining.
23402 this.once('prefinish', function () {
23403 if (typeof this._flush === 'function') this._flush(function (er, data) {
23404 done(stream, er, data);
23405 });else done(stream);
23406 });
23407}
23408
23409Transform.prototype.push = function (chunk, encoding) {
23410 this._transformState.needTransform = false;
23411 return Duplex.prototype.push.call(this, chunk, encoding);
23412};
23413
23414// This is the part where you do stuff!
23415// override this function in implementation classes.
23416// 'chunk' is an input chunk.
23417//
23418// Call `push(newChunk)` to pass along transformed output
23419// to the readable side. You may call 'push' zero or more times.
23420//
23421// Call `cb(err)` when you are done with this chunk. If you pass
23422// an error, then that'll put the hurt on the whole operation. If you
23423// never call cb(), then you'll never get another chunk.
23424Transform.prototype._transform = function (chunk, encoding, cb) {
23425 throw new Error('_transform() is not implemented');
23426};
23427
23428Transform.prototype._write = function (chunk, encoding, cb) {
23429 var ts = this._transformState;
23430 ts.writecb = cb;
23431 ts.writechunk = chunk;
23432 ts.writeencoding = encoding;
23433 if (!ts.transforming) {
23434 var rs = this._readableState;
23435 if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
23436 }
23437};
23438
23439// Doesn't matter what the args are here.
23440// _transform does all the work.
23441// That we got here means that the readable side wants more data.
23442Transform.prototype._read = function (n) {
23443 var ts = this._transformState;
23444
23445 if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
23446 ts.transforming = true;
23447 this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
23448 } else {
23449 // mark that we need a transform, so that any data that comes in
23450 // will get processed, now that we've asked for it.
23451 ts.needTransform = true;
23452 }
23453};
23454
23455Transform.prototype._destroy = function (err, cb) {
23456 var _this = this;
23457
23458 Duplex.prototype._destroy.call(this, err, function (err2) {
23459 cb(err2);
23460 _this.emit('close');
23461 });
23462};
23463
23464function done(stream, er, data) {
23465 if (er) return stream.emit('error', er);
23466
23467 if (data !== null && data !== undefined) stream.push(data);
23468
23469 // if there's nothing in the write buffer, then that means
23470 // that nothing more will ever be provided
23471 var ws = stream._writableState;
23472 var ts = stream._transformState;
23473
23474 if (ws.length) throw new Error('Calling transform done when ws.length != 0');
23475
23476 if (ts.transforming) throw new Error('Calling transform done when still transforming');
23477
23478 return stream.push(null);
23479}
23480},{"./_stream_duplex":143,"core-util-is":55,"inherits":107}],147:[function(require,module,exports){
23481(function (process,global){
23482// Copyright Joyent, Inc. and other Node contributors.
23483//
23484// Permission is hereby granted, free of charge, to any person obtaining a
23485// copy of this software and associated documentation files (the
23486// "Software"), to deal in the Software without restriction, including
23487// without limitation the rights to use, copy, modify, merge, publish,
23488// distribute, sublicense, and/or sell copies of the Software, and to permit
23489// persons to whom the Software is furnished to do so, subject to the
23490// following conditions:
23491//
23492// The above copyright notice and this permission notice shall be included
23493// in all copies or substantial portions of the Software.
23494//
23495// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23496// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23497// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
23498// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
23499// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23500// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
23501// USE OR OTHER DEALINGS IN THE SOFTWARE.
23502
23503// A bit simpler than readable streams.
23504// Implement an async ._write(chunk, encoding, cb), and it'll handle all
23505// the drain event emission and buffering.
23506
23507'use strict';
23508
23509/*<replacement>*/
23510
23511var processNextTick = require('process-nextick-args');
23512/*</replacement>*/
23513
23514module.exports = Writable;
23515
23516/* <replacement> */
23517function WriteReq(chunk, encoding, cb) {
23518 this.chunk = chunk;
23519 this.encoding = encoding;
23520 this.callback = cb;
23521 this.next = null;
23522}
23523
23524// It seems a linked list but it is not
23525// there will be only 2 of these for each stream
23526function CorkedRequest(state) {
23527 var _this = this;
23528
23529 this.next = null;
23530 this.entry = null;
23531 this.finish = function () {
23532 onCorkedFinish(_this, state);
23533 };
23534}
23535/* </replacement> */
23536
23537/*<replacement>*/
23538var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : processNextTick;
23539/*</replacement>*/
23540
23541/*<replacement>*/
23542var Duplex;
23543/*</replacement>*/
23544
23545Writable.WritableState = WritableState;
23546
23547/*<replacement>*/
23548var util = require('core-util-is');
23549util.inherits = require('inherits');
23550/*</replacement>*/
23551
23552/*<replacement>*/
23553var internalUtil = {
23554 deprecate: require('util-deprecate')
23555};
23556/*</replacement>*/
23557
23558/*<replacement>*/
23559var Stream = require('./internal/streams/stream');
23560/*</replacement>*/
23561
23562/*<replacement>*/
23563var Buffer = require('safe-buffer').Buffer;
23564var OurUint8Array = global.Uint8Array || function () {};
23565function _uint8ArrayToBuffer(chunk) {
23566 return Buffer.from(chunk);
23567}
23568function _isUint8Array(obj) {
23569 return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
23570}
23571/*</replacement>*/
23572
23573var destroyImpl = require('./internal/streams/destroy');
23574
23575util.inherits(Writable, Stream);
23576
23577function nop() {}
23578
23579function WritableState(options, stream) {
23580 Duplex = Duplex || require('./_stream_duplex');
23581
23582 options = options || {};
23583
23584 // object stream flag to indicate whether or not this stream
23585 // contains buffers or objects.
23586 this.objectMode = !!options.objectMode;
23587
23588 if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
23589
23590 // the point at which write() starts returning false
23591 // Note: 0 is a valid value, means that we always return false if
23592 // the entire buffer is not flushed immediately on write()
23593 var hwm = options.highWaterMark;
23594 var defaultHwm = this.objectMode ? 16 : 16 * 1024;
23595 this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
23596
23597 // cast to ints.
23598 this.highWaterMark = Math.floor(this.highWaterMark);
23599
23600 // if _final has been called
23601 this.finalCalled = false;
23602
23603 // drain event flag.
23604 this.needDrain = false;
23605 // at the start of calling end()
23606 this.ending = false;
23607 // when end() has been called, and returned
23608 this.ended = false;
23609 // when 'finish' is emitted
23610 this.finished = false;
23611
23612 // has it been destroyed
23613 this.destroyed = false;
23614
23615 // should we decode strings into buffers before passing to _write?
23616 // this is here so that some node-core streams can optimize string
23617 // handling at a lower level.
23618 var noDecode = options.decodeStrings === false;
23619 this.decodeStrings = !noDecode;
23620
23621 // Crypto is kind of old and crusty. Historically, its default string
23622 // encoding is 'binary' so we have to make this configurable.
23623 // Everything else in the universe uses 'utf8', though.
23624 this.defaultEncoding = options.defaultEncoding || 'utf8';
23625
23626 // not an actual buffer we keep track of, but a measurement
23627 // of how much we're waiting to get pushed to some underlying
23628 // socket or file.
23629 this.length = 0;
23630
23631 // a flag to see when we're in the middle of a write.
23632 this.writing = false;
23633
23634 // when true all writes will be buffered until .uncork() call
23635 this.corked = 0;
23636
23637 // a flag to be able to tell if the onwrite cb is called immediately,
23638 // or on a later tick. We set this to true at first, because any
23639 // actions that shouldn't happen until "later" should generally also
23640 // not happen before the first write call.
23641 this.sync = true;
23642
23643 // a flag to know if we're processing previously buffered items, which
23644 // may call the _write() callback in the same tick, so that we don't
23645 // end up in an overlapped onwrite situation.
23646 this.bufferProcessing = false;
23647
23648 // the callback that's passed to _write(chunk,cb)
23649 this.onwrite = function (er) {
23650 onwrite(stream, er);
23651 };
23652
23653 // the callback that the user supplies to write(chunk,encoding,cb)
23654 this.writecb = null;
23655
23656 // the amount that is being written when _write is called.
23657 this.writelen = 0;
23658
23659 this.bufferedRequest = null;
23660 this.lastBufferedRequest = null;
23661
23662 // number of pending user-supplied write callbacks
23663 // this must be 0 before 'finish' can be emitted
23664 this.pendingcb = 0;
23665
23666 // emit prefinish if the only thing we're waiting for is _write cbs
23667 // This is relevant for synchronous Transform streams
23668 this.prefinished = false;
23669
23670 // True if the error was already emitted and should not be thrown again
23671 this.errorEmitted = false;
23672
23673 // count buffered requests
23674 this.bufferedRequestCount = 0;
23675
23676 // allocate the first CorkedRequest, there is always
23677 // one allocated and free to use, and we maintain at most two
23678 this.corkedRequestsFree = new CorkedRequest(this);
23679}
23680
23681WritableState.prototype.getBuffer = function getBuffer() {
23682 var current = this.bufferedRequest;
23683 var out = [];
23684 while (current) {
23685 out.push(current);
23686 current = current.next;
23687 }
23688 return out;
23689};
23690
23691(function () {
23692 try {
23693 Object.defineProperty(WritableState.prototype, 'buffer', {
23694 get: internalUtil.deprecate(function () {
23695 return this.getBuffer();
23696 }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
23697 });
23698 } catch (_) {}
23699})();
23700
23701// Test _writableState for inheritance to account for Duplex streams,
23702// whose prototype chain only points to Readable.
23703var realHasInstance;
23704if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
23705 realHasInstance = Function.prototype[Symbol.hasInstance];
23706 Object.defineProperty(Writable, Symbol.hasInstance, {
23707 value: function (object) {
23708 if (realHasInstance.call(this, object)) return true;
23709
23710 return object && object._writableState instanceof WritableState;
23711 }
23712 });
23713} else {
23714 realHasInstance = function (object) {
23715 return object instanceof this;
23716 };
23717}
23718
23719function Writable(options) {
23720 Duplex = Duplex || require('./_stream_duplex');
23721
23722 // Writable ctor is applied to Duplexes, too.
23723 // `realHasInstance` is necessary because using plain `instanceof`
23724 // would return false, as no `_writableState` property is attached.
23725
23726 // Trying to use the custom `instanceof` for Writable here will also break the
23727 // Node.js LazyTransform implementation, which has a non-trivial getter for
23728 // `_writableState` that would lead to infinite recursion.
23729 if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
23730 return new Writable(options);
23731 }
23732
23733 this._writableState = new WritableState(options, this);
23734
23735 // legacy.
23736 this.writable = true;
23737
23738 if (options) {
23739 if (typeof options.write === 'function') this._write = options.write;
23740
23741 if (typeof options.writev === 'function') this._writev = options.writev;
23742
23743 if (typeof options.destroy === 'function') this._destroy = options.destroy;
23744
23745 if (typeof options.final === 'function') this._final = options.final;
23746 }
23747
23748 Stream.call(this);
23749}
23750
23751// Otherwise people can pipe Writable streams, which is just wrong.
23752Writable.prototype.pipe = function () {
23753 this.emit('error', new Error('Cannot pipe, not readable'));
23754};
23755
23756function writeAfterEnd(stream, cb) {
23757 var er = new Error('write after end');
23758 // TODO: defer error events consistently everywhere, not just the cb
23759 stream.emit('error', er);
23760 processNextTick(cb, er);
23761}
23762
23763// Checks that a user-supplied chunk is valid, especially for the particular
23764// mode the stream is in. Currently this means that `null` is never accepted
23765// and undefined/non-string values are only allowed in object mode.
23766function validChunk(stream, state, chunk, cb) {
23767 var valid = true;
23768 var er = false;
23769
23770 if (chunk === null) {
23771 er = new TypeError('May not write null values to stream');
23772 } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
23773 er = new TypeError('Invalid non-string/buffer chunk');
23774 }
23775 if (er) {
23776 stream.emit('error', er);
23777 processNextTick(cb, er);
23778 valid = false;
23779 }
23780 return valid;
23781}
23782
23783Writable.prototype.write = function (chunk, encoding, cb) {
23784 var state = this._writableState;
23785 var ret = false;
23786 var isBuf = _isUint8Array(chunk) && !state.objectMode;
23787
23788 if (isBuf && !Buffer.isBuffer(chunk)) {
23789 chunk = _uint8ArrayToBuffer(chunk);
23790 }
23791
23792 if (typeof encoding === 'function') {
23793 cb = encoding;
23794 encoding = null;
23795 }
23796
23797 if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
23798
23799 if (typeof cb !== 'function') cb = nop;
23800
23801 if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
23802 state.pendingcb++;
23803 ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
23804 }
23805
23806 return ret;
23807};
23808
23809Writable.prototype.cork = function () {
23810 var state = this._writableState;
23811
23812 state.corked++;
23813};
23814
23815Writable.prototype.uncork = function () {
23816 var state = this._writableState;
23817
23818 if (state.corked) {
23819 state.corked--;
23820
23821 if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
23822 }
23823};
23824
23825Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
23826 // node::ParseEncoding() requires lower case.
23827 if (typeof encoding === 'string') encoding = encoding.toLowerCase();
23828 if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
23829 this._writableState.defaultEncoding = encoding;
23830 return this;
23831};
23832
23833function decodeChunk(state, chunk, encoding) {
23834 if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
23835 chunk = Buffer.from(chunk, encoding);
23836 }
23837 return chunk;
23838}
23839
23840// if we're already writing something, then just put this
23841// in the queue, and wait our turn. Otherwise, call _write
23842// If we return false, then we need a drain event, so set that flag.
23843function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
23844 if (!isBuf) {
23845 var newChunk = decodeChunk(state, chunk, encoding);
23846 if (chunk !== newChunk) {
23847 isBuf = true;
23848 encoding = 'buffer';
23849 chunk = newChunk;
23850 }
23851 }
23852 var len = state.objectMode ? 1 : chunk.length;
23853
23854 state.length += len;
23855
23856 var ret = state.length < state.highWaterMark;
23857 // we must ensure that previous needDrain will not be reset to false.
23858 if (!ret) state.needDrain = true;
23859
23860 if (state.writing || state.corked) {
23861 var last = state.lastBufferedRequest;
23862 state.lastBufferedRequest = {
23863 chunk: chunk,
23864 encoding: encoding,
23865 isBuf: isBuf,
23866 callback: cb,
23867 next: null
23868 };
23869 if (last) {
23870 last.next = state.lastBufferedRequest;
23871 } else {
23872 state.bufferedRequest = state.lastBufferedRequest;
23873 }
23874 state.bufferedRequestCount += 1;
23875 } else {
23876 doWrite(stream, state, false, len, chunk, encoding, cb);
23877 }
23878
23879 return ret;
23880}
23881
23882function doWrite(stream, state, writev, len, chunk, encoding, cb) {
23883 state.writelen = len;
23884 state.writecb = cb;
23885 state.writing = true;
23886 state.sync = true;
23887 if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
23888 state.sync = false;
23889}
23890
23891function onwriteError(stream, state, sync, er, cb) {
23892 --state.pendingcb;
23893
23894 if (sync) {
23895 // defer the callback if we are being called synchronously
23896 // to avoid piling up things on the stack
23897 processNextTick(cb, er);
23898 // this can emit finish, and it will always happen
23899 // after error
23900 processNextTick(finishMaybe, stream, state);
23901 stream._writableState.errorEmitted = true;
23902 stream.emit('error', er);
23903 } else {
23904 // the caller expect this to happen before if
23905 // it is async
23906 cb(er);
23907 stream._writableState.errorEmitted = true;
23908 stream.emit('error', er);
23909 // this can emit finish, but finish must
23910 // always follow error
23911 finishMaybe(stream, state);
23912 }
23913}
23914
23915function onwriteStateUpdate(state) {
23916 state.writing = false;
23917 state.writecb = null;
23918 state.length -= state.writelen;
23919 state.writelen = 0;
23920}
23921
23922function onwrite(stream, er) {
23923 var state = stream._writableState;
23924 var sync = state.sync;
23925 var cb = state.writecb;
23926
23927 onwriteStateUpdate(state);
23928
23929 if (er) onwriteError(stream, state, sync, er, cb);else {
23930 // Check if we're actually ready to finish, but don't emit yet
23931 var finished = needFinish(state);
23932
23933 if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
23934 clearBuffer(stream, state);
23935 }
23936
23937 if (sync) {
23938 /*<replacement>*/
23939 asyncWrite(afterWrite, stream, state, finished, cb);
23940 /*</replacement>*/
23941 } else {
23942 afterWrite(stream, state, finished, cb);
23943 }
23944 }
23945}
23946
23947function afterWrite(stream, state, finished, cb) {
23948 if (!finished) onwriteDrain(stream, state);
23949 state.pendingcb--;
23950 cb();
23951 finishMaybe(stream, state);
23952}
23953
23954// Must force callback to be called on nextTick, so that we don't
23955// emit 'drain' before the write() consumer gets the 'false' return
23956// value, and has a chance to attach a 'drain' listener.
23957function onwriteDrain(stream, state) {
23958 if (state.length === 0 && state.needDrain) {
23959 state.needDrain = false;
23960 stream.emit('drain');
23961 }
23962}
23963
23964// if there's something in the buffer waiting, then process it
23965function clearBuffer(stream, state) {
23966 state.bufferProcessing = true;
23967 var entry = state.bufferedRequest;
23968
23969 if (stream._writev && entry && entry.next) {
23970 // Fast case, write everything using _writev()
23971 var l = state.bufferedRequestCount;
23972 var buffer = new Array(l);
23973 var holder = state.corkedRequestsFree;
23974 holder.entry = entry;
23975
23976 var count = 0;
23977 var allBuffers = true;
23978 while (entry) {
23979 buffer[count] = entry;
23980 if (!entry.isBuf) allBuffers = false;
23981 entry = entry.next;
23982 count += 1;
23983 }
23984 buffer.allBuffers = allBuffers;
23985
23986 doWrite(stream, state, true, state.length, buffer, '', holder.finish);
23987
23988 // doWrite is almost always async, defer these to save a bit of time
23989 // as the hot path ends with doWrite
23990 state.pendingcb++;
23991 state.lastBufferedRequest = null;
23992 if (holder.next) {
23993 state.corkedRequestsFree = holder.next;
23994 holder.next = null;
23995 } else {
23996 state.corkedRequestsFree = new CorkedRequest(state);
23997 }
23998 } else {
23999 // Slow case, write chunks one-by-one
24000 while (entry) {
24001 var chunk = entry.chunk;
24002 var encoding = entry.encoding;
24003 var cb = entry.callback;
24004 var len = state.objectMode ? 1 : chunk.length;
24005
24006 doWrite(stream, state, false, len, chunk, encoding, cb);
24007 entry = entry.next;
24008 // if we didn't call the onwrite immediately, then
24009 // it means that we need to wait until it does.
24010 // also, that means that the chunk and cb are currently
24011 // being processed, so move the buffer counter past them.
24012 if (state.writing) {
24013 break;
24014 }
24015 }
24016
24017 if (entry === null) state.lastBufferedRequest = null;
24018 }
24019
24020 state.bufferedRequestCount = 0;
24021 state.bufferedRequest = entry;
24022 state.bufferProcessing = false;
24023}
24024
24025Writable.prototype._write = function (chunk, encoding, cb) {
24026 cb(new Error('_write() is not implemented'));
24027};
24028
24029Writable.prototype._writev = null;
24030
24031Writable.prototype.end = function (chunk, encoding, cb) {
24032 var state = this._writableState;
24033
24034 if (typeof chunk === 'function') {
24035 cb = chunk;
24036 chunk = null;
24037 encoding = null;
24038 } else if (typeof encoding === 'function') {
24039 cb = encoding;
24040 encoding = null;
24041 }
24042
24043 if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
24044
24045 // .end() fully uncorks
24046 if (state.corked) {
24047 state.corked = 1;
24048 this.uncork();
24049 }
24050
24051 // ignore unnecessary end() calls.
24052 if (!state.ending && !state.finished) endWritable(this, state, cb);
24053};
24054
24055function needFinish(state) {
24056 return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
24057}
24058function callFinal(stream, state) {
24059 stream._final(function (err) {
24060 state.pendingcb--;
24061 if (err) {
24062 stream.emit('error', err);
24063 }
24064 state.prefinished = true;
24065 stream.emit('prefinish');
24066 finishMaybe(stream, state);
24067 });
24068}
24069function prefinish(stream, state) {
24070 if (!state.prefinished && !state.finalCalled) {
24071 if (typeof stream._final === 'function') {
24072 state.pendingcb++;
24073 state.finalCalled = true;
24074 processNextTick(callFinal, stream, state);
24075 } else {
24076 state.prefinished = true;
24077 stream.emit('prefinish');
24078 }
24079 }
24080}
24081
24082function finishMaybe(stream, state) {
24083 var need = needFinish(state);
24084 if (need) {
24085 prefinish(stream, state);
24086 if (state.pendingcb === 0) {
24087 state.finished = true;
24088 stream.emit('finish');
24089 }
24090 }
24091 return need;
24092}
24093
24094function endWritable(stream, state, cb) {
24095 state.ending = true;
24096 finishMaybe(stream, state);
24097 if (cb) {
24098 if (state.finished) processNextTick(cb);else stream.once('finish', cb);
24099 }
24100 state.ended = true;
24101 stream.writable = false;
24102}
24103
24104function onCorkedFinish(corkReq, state, err) {
24105 var entry = corkReq.entry;
24106 corkReq.entry = null;
24107 while (entry) {
24108 var cb = entry.callback;
24109 state.pendingcb--;
24110 cb(err);
24111 entry = entry.next;
24112 }
24113 if (state.corkedRequestsFree) {
24114 state.corkedRequestsFree.next = corkReq;
24115 } else {
24116 state.corkedRequestsFree = corkReq;
24117 }
24118}
24119
24120Object.defineProperty(Writable.prototype, 'destroyed', {
24121 get: function () {
24122 if (this._writableState === undefined) {
24123 return false;
24124 }
24125 return this._writableState.destroyed;
24126 },
24127 set: function (value) {
24128 // we ignore the value if the stream
24129 // has not been initialized yet
24130 if (!this._writableState) {
24131 return;
24132 }
24133
24134 // backward compatibility, the user is explicitly
24135 // managing destroyed
24136 this._writableState.destroyed = value;
24137 }
24138});
24139
24140Writable.prototype.destroy = destroyImpl.destroy;
24141Writable.prototype._undestroy = destroyImpl.undestroy;
24142Writable.prototype._destroy = function (err, cb) {
24143 this.end();
24144 cb(err);
24145};
24146}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
24147},{"./_stream_duplex":143,"./internal/streams/destroy":149,"./internal/streams/stream":150,"_process":133,"core-util-is":55,"inherits":107,"process-nextick-args":132,"safe-buffer":156,"util-deprecate":174}],148:[function(require,module,exports){
24148'use strict';
24149
24150/*<replacement>*/
24151
24152function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
24153
24154var Buffer = require('safe-buffer').Buffer;
24155/*</replacement>*/
24156
24157function copyBuffer(src, target, offset) {
24158 src.copy(target, offset);
24159}
24160
24161module.exports = function () {
24162 function BufferList() {
24163 _classCallCheck(this, BufferList);
24164
24165 this.head = null;
24166 this.tail = null;
24167 this.length = 0;
24168 }
24169
24170 BufferList.prototype.push = function push(v) {
24171 var entry = { data: v, next: null };
24172 if (this.length > 0) this.tail.next = entry;else this.head = entry;
24173 this.tail = entry;
24174 ++this.length;
24175 };
24176
24177 BufferList.prototype.unshift = function unshift(v) {
24178 var entry = { data: v, next: this.head };
24179 if (this.length === 0) this.tail = entry;
24180 this.head = entry;
24181 ++this.length;
24182 };
24183
24184 BufferList.prototype.shift = function shift() {
24185 if (this.length === 0) return;
24186 var ret = this.head.data;
24187 if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
24188 --this.length;
24189 return ret;
24190 };
24191
24192 BufferList.prototype.clear = function clear() {
24193 this.head = this.tail = null;
24194 this.length = 0;
24195 };
24196
24197 BufferList.prototype.join = function join(s) {
24198 if (this.length === 0) return '';
24199 var p = this.head;
24200 var ret = '' + p.data;
24201 while (p = p.next) {
24202 ret += s + p.data;
24203 }return ret;
24204 };
24205
24206 BufferList.prototype.concat = function concat(n) {
24207 if (this.length === 0) return Buffer.alloc(0);
24208 if (this.length === 1) return this.head.data;
24209 var ret = Buffer.allocUnsafe(n >>> 0);
24210 var p = this.head;
24211 var i = 0;
24212 while (p) {
24213 copyBuffer(p.data, ret, i);
24214 i += p.data.length;
24215 p = p.next;
24216 }
24217 return ret;
24218 };
24219
24220 return BufferList;
24221}();
24222},{"safe-buffer":156}],149:[function(require,module,exports){
24223'use strict';
24224
24225/*<replacement>*/
24226
24227var processNextTick = require('process-nextick-args');
24228/*</replacement>*/
24229
24230// undocumented cb() API, needed for core, not for public API
24231function destroy(err, cb) {
24232 var _this = this;
24233
24234 var readableDestroyed = this._readableState && this._readableState.destroyed;
24235 var writableDestroyed = this._writableState && this._writableState.destroyed;
24236
24237 if (readableDestroyed || writableDestroyed) {
24238 if (cb) {
24239 cb(err);
24240 } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
24241 processNextTick(emitErrorNT, this, err);
24242 }
24243 return;
24244 }
24245
24246 // we set destroyed to true before firing error callbacks in order
24247 // to make it re-entrance safe in case destroy() is called within callbacks
24248
24249 if (this._readableState) {
24250 this._readableState.destroyed = true;
24251 }
24252
24253 // if this is a duplex stream mark the writable part as destroyed as well
24254 if (this._writableState) {
24255 this._writableState.destroyed = true;
24256 }
24257
24258 this._destroy(err || null, function (err) {
24259 if (!cb && err) {
24260 processNextTick(emitErrorNT, _this, err);
24261 if (_this._writableState) {
24262 _this._writableState.errorEmitted = true;
24263 }
24264 } else if (cb) {
24265 cb(err);
24266 }
24267 });
24268}
24269
24270function undestroy() {
24271 if (this._readableState) {
24272 this._readableState.destroyed = false;
24273 this._readableState.reading = false;
24274 this._readableState.ended = false;
24275 this._readableState.endEmitted = false;
24276 }
24277
24278 if (this._writableState) {
24279 this._writableState.destroyed = false;
24280 this._writableState.ended = false;
24281 this._writableState.ending = false;
24282 this._writableState.finished = false;
24283 this._writableState.errorEmitted = false;
24284 }
24285}
24286
24287function emitErrorNT(self, err) {
24288 self.emit('error', err);
24289}
24290
24291module.exports = {
24292 destroy: destroy,
24293 undestroy: undestroy
24294};
24295},{"process-nextick-args":132}],150:[function(require,module,exports){
24296module.exports = require('events').EventEmitter;
24297
24298},{"events":89}],151:[function(require,module,exports){
24299module.exports = require('./readable').PassThrough
24300
24301},{"./readable":152}],152:[function(require,module,exports){
24302exports = module.exports = require('./lib/_stream_readable.js');
24303exports.Stream = exports;
24304exports.Readable = exports;
24305exports.Writable = require('./lib/_stream_writable.js');
24306exports.Duplex = require('./lib/_stream_duplex.js');
24307exports.Transform = require('./lib/_stream_transform.js');
24308exports.PassThrough = require('./lib/_stream_passthrough.js');
24309
24310},{"./lib/_stream_duplex.js":143,"./lib/_stream_passthrough.js":144,"./lib/_stream_readable.js":145,"./lib/_stream_transform.js":146,"./lib/_stream_writable.js":147}],153:[function(require,module,exports){
24311module.exports = require('./readable').Transform
24312
24313},{"./readable":152}],154:[function(require,module,exports){
24314module.exports = require('./lib/_stream_writable.js');
24315
24316},{"./lib/_stream_writable.js":147}],155:[function(require,module,exports){
24317(function (Buffer){
24318'use strict'
24319var inherits = require('inherits')
24320var HashBase = require('hash-base')
24321
24322function RIPEMD160 () {
24323 HashBase.call(this, 64)
24324
24325 // state
24326 this._a = 0x67452301
24327 this._b = 0xefcdab89
24328 this._c = 0x98badcfe
24329 this._d = 0x10325476
24330 this._e = 0xc3d2e1f0
24331}
24332
24333inherits(RIPEMD160, HashBase)
24334
24335RIPEMD160.prototype._update = function () {
24336 var m = new Array(16)
24337 for (var i = 0; i < 16; ++i) m[i] = this._block.readInt32LE(i * 4)
24338
24339 var al = this._a
24340 var bl = this._b
24341 var cl = this._c
24342 var dl = this._d
24343 var el = this._e
24344
24345 // Mj = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
24346 // K = 0x00000000
24347 // Sj = 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8
24348 al = fn1(al, bl, cl, dl, el, m[0], 0x00000000, 11); cl = rotl(cl, 10)
24349 el = fn1(el, al, bl, cl, dl, m[1], 0x00000000, 14); bl = rotl(bl, 10)
24350 dl = fn1(dl, el, al, bl, cl, m[2], 0x00000000, 15); al = rotl(al, 10)
24351 cl = fn1(cl, dl, el, al, bl, m[3], 0x00000000, 12); el = rotl(el, 10)
24352 bl = fn1(bl, cl, dl, el, al, m[4], 0x00000000, 5); dl = rotl(dl, 10)
24353 al = fn1(al, bl, cl, dl, el, m[5], 0x00000000, 8); cl = rotl(cl, 10)
24354 el = fn1(el, al, bl, cl, dl, m[6], 0x00000000, 7); bl = rotl(bl, 10)
24355 dl = fn1(dl, el, al, bl, cl, m[7], 0x00000000, 9); al = rotl(al, 10)
24356 cl = fn1(cl, dl, el, al, bl, m[8], 0x00000000, 11); el = rotl(el, 10)
24357 bl = fn1(bl, cl, dl, el, al, m[9], 0x00000000, 13); dl = rotl(dl, 10)
24358 al = fn1(al, bl, cl, dl, el, m[10], 0x00000000, 14); cl = rotl(cl, 10)
24359 el = fn1(el, al, bl, cl, dl, m[11], 0x00000000, 15); bl = rotl(bl, 10)
24360 dl = fn1(dl, el, al, bl, cl, m[12], 0x00000000, 6); al = rotl(al, 10)
24361 cl = fn1(cl, dl, el, al, bl, m[13], 0x00000000, 7); el = rotl(el, 10)
24362 bl = fn1(bl, cl, dl, el, al, m[14], 0x00000000, 9); dl = rotl(dl, 10)
24363 al = fn1(al, bl, cl, dl, el, m[15], 0x00000000, 8); cl = rotl(cl, 10)
24364
24365 // Mj = 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8
24366 // K = 0x5a827999
24367 // Sj = 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12
24368 el = fn2(el, al, bl, cl, dl, m[7], 0x5a827999, 7); bl = rotl(bl, 10)
24369 dl = fn2(dl, el, al, bl, cl, m[4], 0x5a827999, 6); al = rotl(al, 10)
24370 cl = fn2(cl, dl, el, al, bl, m[13], 0x5a827999, 8); el = rotl(el, 10)
24371 bl = fn2(bl, cl, dl, el, al, m[1], 0x5a827999, 13); dl = rotl(dl, 10)
24372 al = fn2(al, bl, cl, dl, el, m[10], 0x5a827999, 11); cl = rotl(cl, 10)
24373 el = fn2(el, al, bl, cl, dl, m[6], 0x5a827999, 9); bl = rotl(bl, 10)
24374 dl = fn2(dl, el, al, bl, cl, m[15], 0x5a827999, 7); al = rotl(al, 10)
24375 cl = fn2(cl, dl, el, al, bl, m[3], 0x5a827999, 15); el = rotl(el, 10)
24376 bl = fn2(bl, cl, dl, el, al, m[12], 0x5a827999, 7); dl = rotl(dl, 10)
24377 al = fn2(al, bl, cl, dl, el, m[0], 0x5a827999, 12); cl = rotl(cl, 10)
24378 el = fn2(el, al, bl, cl, dl, m[9], 0x5a827999, 15); bl = rotl(bl, 10)
24379 dl = fn2(dl, el, al, bl, cl, m[5], 0x5a827999, 9); al = rotl(al, 10)
24380 cl = fn2(cl, dl, el, al, bl, m[2], 0x5a827999, 11); el = rotl(el, 10)
24381 bl = fn2(bl, cl, dl, el, al, m[14], 0x5a827999, 7); dl = rotl(dl, 10)
24382 al = fn2(al, bl, cl, dl, el, m[11], 0x5a827999, 13); cl = rotl(cl, 10)
24383 el = fn2(el, al, bl, cl, dl, m[8], 0x5a827999, 12); bl = rotl(bl, 10)
24384
24385 // Mj = 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12
24386 // K = 0x6ed9eba1
24387 // Sj = 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5
24388 dl = fn3(dl, el, al, bl, cl, m[3], 0x6ed9eba1, 11); al = rotl(al, 10)
24389 cl = fn3(cl, dl, el, al, bl, m[10], 0x6ed9eba1, 13); el = rotl(el, 10)
24390 bl = fn3(bl, cl, dl, el, al, m[14], 0x6ed9eba1, 6); dl = rotl(dl, 10)
24391 al = fn3(al, bl, cl, dl, el, m[4], 0x6ed9eba1, 7); cl = rotl(cl, 10)
24392 el = fn3(el, al, bl, cl, dl, m[9], 0x6ed9eba1, 14); bl = rotl(bl, 10)
24393 dl = fn3(dl, el, al, bl, cl, m[15], 0x6ed9eba1, 9); al = rotl(al, 10)
24394 cl = fn3(cl, dl, el, al, bl, m[8], 0x6ed9eba1, 13); el = rotl(el, 10)
24395 bl = fn3(bl, cl, dl, el, al, m[1], 0x6ed9eba1, 15); dl = rotl(dl, 10)
24396 al = fn3(al, bl, cl, dl, el, m[2], 0x6ed9eba1, 14); cl = rotl(cl, 10)
24397 el = fn3(el, al, bl, cl, dl, m[7], 0x6ed9eba1, 8); bl = rotl(bl, 10)
24398 dl = fn3(dl, el, al, bl, cl, m[0], 0x6ed9eba1, 13); al = rotl(al, 10)
24399 cl = fn3(cl, dl, el, al, bl, m[6], 0x6ed9eba1, 6); el = rotl(el, 10)
24400 bl = fn3(bl, cl, dl, el, al, m[13], 0x6ed9eba1, 5); dl = rotl(dl, 10)
24401 al = fn3(al, bl, cl, dl, el, m[11], 0x6ed9eba1, 12); cl = rotl(cl, 10)
24402 el = fn3(el, al, bl, cl, dl, m[5], 0x6ed9eba1, 7); bl = rotl(bl, 10)
24403 dl = fn3(dl, el, al, bl, cl, m[12], 0x6ed9eba1, 5); al = rotl(al, 10)
24404
24405 // Mj = 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2
24406 // K = 0x8f1bbcdc
24407 // Sj = 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12
24408 cl = fn4(cl, dl, el, al, bl, m[1], 0x8f1bbcdc, 11); el = rotl(el, 10)
24409 bl = fn4(bl, cl, dl, el, al, m[9], 0x8f1bbcdc, 12); dl = rotl(dl, 10)
24410 al = fn4(al, bl, cl, dl, el, m[11], 0x8f1bbcdc, 14); cl = rotl(cl, 10)
24411 el = fn4(el, al, bl, cl, dl, m[10], 0x8f1bbcdc, 15); bl = rotl(bl, 10)
24412 dl = fn4(dl, el, al, bl, cl, m[0], 0x8f1bbcdc, 14); al = rotl(al, 10)
24413 cl = fn4(cl, dl, el, al, bl, m[8], 0x8f1bbcdc, 15); el = rotl(el, 10)
24414 bl = fn4(bl, cl, dl, el, al, m[12], 0x8f1bbcdc, 9); dl = rotl(dl, 10)
24415 al = fn4(al, bl, cl, dl, el, m[4], 0x8f1bbcdc, 8); cl = rotl(cl, 10)
24416 el = fn4(el, al, bl, cl, dl, m[13], 0x8f1bbcdc, 9); bl = rotl(bl, 10)
24417 dl = fn4(dl, el, al, bl, cl, m[3], 0x8f1bbcdc, 14); al = rotl(al, 10)
24418 cl = fn4(cl, dl, el, al, bl, m[7], 0x8f1bbcdc, 5); el = rotl(el, 10)
24419 bl = fn4(bl, cl, dl, el, al, m[15], 0x8f1bbcdc, 6); dl = rotl(dl, 10)
24420 al = fn4(al, bl, cl, dl, el, m[14], 0x8f1bbcdc, 8); cl = rotl(cl, 10)
24421 el = fn4(el, al, bl, cl, dl, m[5], 0x8f1bbcdc, 6); bl = rotl(bl, 10)
24422 dl = fn4(dl, el, al, bl, cl, m[6], 0x8f1bbcdc, 5); al = rotl(al, 10)
24423 cl = fn4(cl, dl, el, al, bl, m[2], 0x8f1bbcdc, 12); el = rotl(el, 10)
24424
24425 // Mj = 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
24426 // K = 0xa953fd4e
24427 // Sj = 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
24428 bl = fn5(bl, cl, dl, el, al, m[4], 0xa953fd4e, 9); dl = rotl(dl, 10)
24429 al = fn5(al, bl, cl, dl, el, m[0], 0xa953fd4e, 15); cl = rotl(cl, 10)
24430 el = fn5(el, al, bl, cl, dl, m[5], 0xa953fd4e, 5); bl = rotl(bl, 10)
24431 dl = fn5(dl, el, al, bl, cl, m[9], 0xa953fd4e, 11); al = rotl(al, 10)
24432 cl = fn5(cl, dl, el, al, bl, m[7], 0xa953fd4e, 6); el = rotl(el, 10)
24433 bl = fn5(bl, cl, dl, el, al, m[12], 0xa953fd4e, 8); dl = rotl(dl, 10)
24434 al = fn5(al, bl, cl, dl, el, m[2], 0xa953fd4e, 13); cl = rotl(cl, 10)
24435 el = fn5(el, al, bl, cl, dl, m[10], 0xa953fd4e, 12); bl = rotl(bl, 10)
24436 dl = fn5(dl, el, al, bl, cl, m[14], 0xa953fd4e, 5); al = rotl(al, 10)
24437 cl = fn5(cl, dl, el, al, bl, m[1], 0xa953fd4e, 12); el = rotl(el, 10)
24438 bl = fn5(bl, cl, dl, el, al, m[3], 0xa953fd4e, 13); dl = rotl(dl, 10)
24439 al = fn5(al, bl, cl, dl, el, m[8], 0xa953fd4e, 14); cl = rotl(cl, 10)
24440 el = fn5(el, al, bl, cl, dl, m[11], 0xa953fd4e, 11); bl = rotl(bl, 10)
24441 dl = fn5(dl, el, al, bl, cl, m[6], 0xa953fd4e, 8); al = rotl(al, 10)
24442 cl = fn5(cl, dl, el, al, bl, m[15], 0xa953fd4e, 5); el = rotl(el, 10)
24443 bl = fn5(bl, cl, dl, el, al, m[13], 0xa953fd4e, 6); dl = rotl(dl, 10)
24444
24445 var ar = this._a
24446 var br = this._b
24447 var cr = this._c
24448 var dr = this._d
24449 var er = this._e
24450
24451 // M'j = 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12
24452 // K' = 0x50a28be6
24453 // S'j = 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6
24454 ar = fn5(ar, br, cr, dr, er, m[5], 0x50a28be6, 8); cr = rotl(cr, 10)
24455 er = fn5(er, ar, br, cr, dr, m[14], 0x50a28be6, 9); br = rotl(br, 10)
24456 dr = fn5(dr, er, ar, br, cr, m[7], 0x50a28be6, 9); ar = rotl(ar, 10)
24457 cr = fn5(cr, dr, er, ar, br, m[0], 0x50a28be6, 11); er = rotl(er, 10)
24458 br = fn5(br, cr, dr, er, ar, m[9], 0x50a28be6, 13); dr = rotl(dr, 10)
24459 ar = fn5(ar, br, cr, dr, er, m[2], 0x50a28be6, 15); cr = rotl(cr, 10)
24460 er = fn5(er, ar, br, cr, dr, m[11], 0x50a28be6, 15); br = rotl(br, 10)
24461 dr = fn5(dr, er, ar, br, cr, m[4], 0x50a28be6, 5); ar = rotl(ar, 10)
24462 cr = fn5(cr, dr, er, ar, br, m[13], 0x50a28be6, 7); er = rotl(er, 10)
24463 br = fn5(br, cr, dr, er, ar, m[6], 0x50a28be6, 7); dr = rotl(dr, 10)
24464 ar = fn5(ar, br, cr, dr, er, m[15], 0x50a28be6, 8); cr = rotl(cr, 10)
24465 er = fn5(er, ar, br, cr, dr, m[8], 0x50a28be6, 11); br = rotl(br, 10)
24466 dr = fn5(dr, er, ar, br, cr, m[1], 0x50a28be6, 14); ar = rotl(ar, 10)
24467 cr = fn5(cr, dr, er, ar, br, m[10], 0x50a28be6, 14); er = rotl(er, 10)
24468 br = fn5(br, cr, dr, er, ar, m[3], 0x50a28be6, 12); dr = rotl(dr, 10)
24469 ar = fn5(ar, br, cr, dr, er, m[12], 0x50a28be6, 6); cr = rotl(cr, 10)
24470
24471 // M'j = 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2
24472 // K' = 0x5c4dd124
24473 // S'j = 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11
24474 er = fn4(er, ar, br, cr, dr, m[6], 0x5c4dd124, 9); br = rotl(br, 10)
24475 dr = fn4(dr, er, ar, br, cr, m[11], 0x5c4dd124, 13); ar = rotl(ar, 10)
24476 cr = fn4(cr, dr, er, ar, br, m[3], 0x5c4dd124, 15); er = rotl(er, 10)
24477 br = fn4(br, cr, dr, er, ar, m[7], 0x5c4dd124, 7); dr = rotl(dr, 10)
24478 ar = fn4(ar, br, cr, dr, er, m[0], 0x5c4dd124, 12); cr = rotl(cr, 10)
24479 er = fn4(er, ar, br, cr, dr, m[13], 0x5c4dd124, 8); br = rotl(br, 10)
24480 dr = fn4(dr, er, ar, br, cr, m[5], 0x5c4dd124, 9); ar = rotl(ar, 10)
24481 cr = fn4(cr, dr, er, ar, br, m[10], 0x5c4dd124, 11); er = rotl(er, 10)
24482 br = fn4(br, cr, dr, er, ar, m[14], 0x5c4dd124, 7); dr = rotl(dr, 10)
24483 ar = fn4(ar, br, cr, dr, er, m[15], 0x5c4dd124, 7); cr = rotl(cr, 10)
24484 er = fn4(er, ar, br, cr, dr, m[8], 0x5c4dd124, 12); br = rotl(br, 10)
24485 dr = fn4(dr, er, ar, br, cr, m[12], 0x5c4dd124, 7); ar = rotl(ar, 10)
24486 cr = fn4(cr, dr, er, ar, br, m[4], 0x5c4dd124, 6); er = rotl(er, 10)
24487 br = fn4(br, cr, dr, er, ar, m[9], 0x5c4dd124, 15); dr = rotl(dr, 10)
24488 ar = fn4(ar, br, cr, dr, er, m[1], 0x5c4dd124, 13); cr = rotl(cr, 10)
24489 er = fn4(er, ar, br, cr, dr, m[2], 0x5c4dd124, 11); br = rotl(br, 10)
24490
24491 // M'j = 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13
24492 // K' = 0x6d703ef3
24493 // S'j = 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5
24494 dr = fn3(dr, er, ar, br, cr, m[15], 0x6d703ef3, 9); ar = rotl(ar, 10)
24495 cr = fn3(cr, dr, er, ar, br, m[5], 0x6d703ef3, 7); er = rotl(er, 10)
24496 br = fn3(br, cr, dr, er, ar, m[1], 0x6d703ef3, 15); dr = rotl(dr, 10)
24497 ar = fn3(ar, br, cr, dr, er, m[3], 0x6d703ef3, 11); cr = rotl(cr, 10)
24498 er = fn3(er, ar, br, cr, dr, m[7], 0x6d703ef3, 8); br = rotl(br, 10)
24499 dr = fn3(dr, er, ar, br, cr, m[14], 0x6d703ef3, 6); ar = rotl(ar, 10)
24500 cr = fn3(cr, dr, er, ar, br, m[6], 0x6d703ef3, 6); er = rotl(er, 10)
24501 br = fn3(br, cr, dr, er, ar, m[9], 0x6d703ef3, 14); dr = rotl(dr, 10)
24502 ar = fn3(ar, br, cr, dr, er, m[11], 0x6d703ef3, 12); cr = rotl(cr, 10)
24503 er = fn3(er, ar, br, cr, dr, m[8], 0x6d703ef3, 13); br = rotl(br, 10)
24504 dr = fn3(dr, er, ar, br, cr, m[12], 0x6d703ef3, 5); ar = rotl(ar, 10)
24505 cr = fn3(cr, dr, er, ar, br, m[2], 0x6d703ef3, 14); er = rotl(er, 10)
24506 br = fn3(br, cr, dr, er, ar, m[10], 0x6d703ef3, 13); dr = rotl(dr, 10)
24507 ar = fn3(ar, br, cr, dr, er, m[0], 0x6d703ef3, 13); cr = rotl(cr, 10)
24508 er = fn3(er, ar, br, cr, dr, m[4], 0x6d703ef3, 7); br = rotl(br, 10)
24509 dr = fn3(dr, er, ar, br, cr, m[13], 0x6d703ef3, 5); ar = rotl(ar, 10)
24510
24511 // M'j = 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14
24512 // K' = 0x7a6d76e9
24513 // S'j = 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8
24514 cr = fn2(cr, dr, er, ar, br, m[8], 0x7a6d76e9, 15); er = rotl(er, 10)
24515 br = fn2(br, cr, dr, er, ar, m[6], 0x7a6d76e9, 5); dr = rotl(dr, 10)
24516 ar = fn2(ar, br, cr, dr, er, m[4], 0x7a6d76e9, 8); cr = rotl(cr, 10)
24517 er = fn2(er, ar, br, cr, dr, m[1], 0x7a6d76e9, 11); br = rotl(br, 10)
24518 dr = fn2(dr, er, ar, br, cr, m[3], 0x7a6d76e9, 14); ar = rotl(ar, 10)
24519 cr = fn2(cr, dr, er, ar, br, m[11], 0x7a6d76e9, 14); er = rotl(er, 10)
24520 br = fn2(br, cr, dr, er, ar, m[15], 0x7a6d76e9, 6); dr = rotl(dr, 10)
24521 ar = fn2(ar, br, cr, dr, er, m[0], 0x7a6d76e9, 14); cr = rotl(cr, 10)
24522 er = fn2(er, ar, br, cr, dr, m[5], 0x7a6d76e9, 6); br = rotl(br, 10)
24523 dr = fn2(dr, er, ar, br, cr, m[12], 0x7a6d76e9, 9); ar = rotl(ar, 10)
24524 cr = fn2(cr, dr, er, ar, br, m[2], 0x7a6d76e9, 12); er = rotl(er, 10)
24525 br = fn2(br, cr, dr, er, ar, m[13], 0x7a6d76e9, 9); dr = rotl(dr, 10)
24526 ar = fn2(ar, br, cr, dr, er, m[9], 0x7a6d76e9, 12); cr = rotl(cr, 10)
24527 er = fn2(er, ar, br, cr, dr, m[7], 0x7a6d76e9, 5); br = rotl(br, 10)
24528 dr = fn2(dr, er, ar, br, cr, m[10], 0x7a6d76e9, 15); ar = rotl(ar, 10)
24529 cr = fn2(cr, dr, er, ar, br, m[14], 0x7a6d76e9, 8); er = rotl(er, 10)
24530
24531 // M'j = 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
24532 // K' = 0x00000000
24533 // S'j = 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
24534 br = fn1(br, cr, dr, er, ar, m[12], 0x00000000, 8); dr = rotl(dr, 10)
24535 ar = fn1(ar, br, cr, dr, er, m[15], 0x00000000, 5); cr = rotl(cr, 10)
24536 er = fn1(er, ar, br, cr, dr, m[10], 0x00000000, 12); br = rotl(br, 10)
24537 dr = fn1(dr, er, ar, br, cr, m[4], 0x00000000, 9); ar = rotl(ar, 10)
24538 cr = fn1(cr, dr, er, ar, br, m[1], 0x00000000, 12); er = rotl(er, 10)
24539 br = fn1(br, cr, dr, er, ar, m[5], 0x00000000, 5); dr = rotl(dr, 10)
24540 ar = fn1(ar, br, cr, dr, er, m[8], 0x00000000, 14); cr = rotl(cr, 10)
24541 er = fn1(er, ar, br, cr, dr, m[7], 0x00000000, 6); br = rotl(br, 10)
24542 dr = fn1(dr, er, ar, br, cr, m[6], 0x00000000, 8); ar = rotl(ar, 10)
24543 cr = fn1(cr, dr, er, ar, br, m[2], 0x00000000, 13); er = rotl(er, 10)
24544 br = fn1(br, cr, dr, er, ar, m[13], 0x00000000, 6); dr = rotl(dr, 10)
24545 ar = fn1(ar, br, cr, dr, er, m[14], 0x00000000, 5); cr = rotl(cr, 10)
24546 er = fn1(er, ar, br, cr, dr, m[0], 0x00000000, 15); br = rotl(br, 10)
24547 dr = fn1(dr, er, ar, br, cr, m[3], 0x00000000, 13); ar = rotl(ar, 10)
24548 cr = fn1(cr, dr, er, ar, br, m[9], 0x00000000, 11); er = rotl(er, 10)
24549 br = fn1(br, cr, dr, er, ar, m[11], 0x00000000, 11); dr = rotl(dr, 10)
24550
24551 // change state
24552 var t = (this._b + cl + dr) | 0
24553 this._b = (this._c + dl + er) | 0
24554 this._c = (this._d + el + ar) | 0
24555 this._d = (this._e + al + br) | 0
24556 this._e = (this._a + bl + cr) | 0
24557 this._a = t
24558}
24559
24560RIPEMD160.prototype._digest = function () {
24561 // create padding and handle blocks
24562 this._block[this._blockOffset++] = 0x80
24563 if (this._blockOffset > 56) {
24564 this._block.fill(0, this._blockOffset, 64)
24565 this._update()
24566 this._blockOffset = 0
24567 }
24568
24569 this._block.fill(0, this._blockOffset, 56)
24570 this._block.writeUInt32LE(this._length[0], 56)
24571 this._block.writeUInt32LE(this._length[1], 60)
24572 this._update()
24573
24574 // produce result
24575 var buffer = new Buffer(20)
24576 buffer.writeInt32LE(this._a, 0)
24577 buffer.writeInt32LE(this._b, 4)
24578 buffer.writeInt32LE(this._c, 8)
24579 buffer.writeInt32LE(this._d, 12)
24580 buffer.writeInt32LE(this._e, 16)
24581 return buffer
24582}
24583
24584function rotl (x, n) {
24585 return (x << n) | (x >>> (32 - n))
24586}
24587
24588function fn1 (a, b, c, d, e, m, k, s) {
24589 return (rotl((a + (b ^ c ^ d) + m + k) | 0, s) + e) | 0
24590}
24591
24592function fn2 (a, b, c, d, e, m, k, s) {
24593 return (rotl((a + ((b & c) | ((~b) & d)) + m + k) | 0, s) + e) | 0
24594}
24595
24596function fn3 (a, b, c, d, e, m, k, s) {
24597 return (rotl((a + ((b | (~c)) ^ d) + m + k) | 0, s) + e) | 0
24598}
24599
24600function fn4 (a, b, c, d, e, m, k, s) {
24601 return (rotl((a + ((b & d) | (c & (~d))) + m + k) | 0, s) + e) | 0
24602}
24603
24604function fn5 (a, b, c, d, e, m, k, s) {
24605 return (rotl((a + (b ^ (c | (~d))) + m + k) | 0, s) + e) | 0
24606}
24607
24608module.exports = RIPEMD160
24609
24610}).call(this,require("buffer").Buffer)
24611},{"buffer":53,"hash-base":91,"inherits":107}],156:[function(require,module,exports){
24612/* eslint-disable node/no-deprecated-api */
24613var buffer = require('buffer')
24614var Buffer = buffer.Buffer
24615
24616// alternative to using Object.keys for old browsers
24617function copyProps (src, dst) {
24618 for (var key in src) {
24619 dst[key] = src[key]
24620 }
24621}
24622if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
24623 module.exports = buffer
24624} else {
24625 // Copy properties from require('buffer')
24626 copyProps(buffer, exports)
24627 exports.Buffer = SafeBuffer
24628}
24629
24630function SafeBuffer (arg, encodingOrOffset, length) {
24631 return Buffer(arg, encodingOrOffset, length)
24632}
24633
24634// Copy static methods from Buffer
24635copyProps(Buffer, SafeBuffer)
24636
24637SafeBuffer.from = function (arg, encodingOrOffset, length) {
24638 if (typeof arg === 'number') {
24639 throw new TypeError('Argument must not be a number')
24640 }
24641 return Buffer(arg, encodingOrOffset, length)
24642}
24643
24644SafeBuffer.alloc = function (size, fill, encoding) {
24645 if (typeof size !== 'number') {
24646 throw new TypeError('Argument must be a number')
24647 }
24648 var buf = Buffer(size)
24649 if (fill !== undefined) {
24650 if (typeof encoding === 'string') {
24651 buf.fill(fill, encoding)
24652 } else {
24653 buf.fill(fill)
24654 }
24655 } else {
24656 buf.fill(0)
24657 }
24658 return buf
24659}
24660
24661SafeBuffer.allocUnsafe = function (size) {
24662 if (typeof size !== 'number') {
24663 throw new TypeError('Argument must be a number')
24664 }
24665 return Buffer(size)
24666}
24667
24668SafeBuffer.allocUnsafeSlow = function (size) {
24669 if (typeof size !== 'number') {
24670 throw new TypeError('Argument must be a number')
24671 }
24672 return buffer.SlowBuffer(size)
24673}
24674
24675},{"buffer":53}],157:[function(require,module,exports){
24676(function (Buffer){
24677var crypto = require('crypto')
24678/* eslint-disable camelcase */
24679
24680var MAX_VALUE = 0x7fffffff
24681
24682// N = Cpu cost, r = Memory cost, p = parallelization cost
24683function scrypt (key, salt, N, r, p, dkLen, progressCallback) {
24684 if (N === 0 || (N & (N - 1)) !== 0) throw Error('N must be > 0 and a power of 2')
24685
24686 if (N > MAX_VALUE / 128 / r) throw Error('Parameter N is too large')
24687 if (r > MAX_VALUE / 128 / p) throw Error('Parameter r is too large')
24688
24689 var XY = new Buffer(256 * r)
24690 var V = new Buffer(128 * r * N)
24691
24692 // pseudo global
24693 var B32 = new Int32Array(16) // salsa20_8
24694 var x = new Int32Array(16) // salsa20_8
24695 var _X = new Buffer(64) // blockmix_salsa8
24696
24697 // pseudo global
24698 var B = crypto.pbkdf2Sync(key, salt, 1, p * 128 * r, 'sha256')
24699
24700 var tickCallback
24701 if (progressCallback) {
24702 var totalOps = p * N * 2
24703 var currentOp = 0
24704
24705 tickCallback = function () {
24706 ++currentOp
24707
24708 // send progress notifications once every 1,000 ops
24709 if (currentOp % 1000 === 0) {
24710 progressCallback({
24711 current: currentOp,
24712 total: totalOps,
24713 percent: (currentOp / totalOps) * 100.0
24714 })
24715 }
24716 }
24717 }
24718
24719 for (var i = 0; i < p; i++) {
24720 smix(B, i * 128 * r, r, N, V, XY)
24721 }
24722
24723 return crypto.pbkdf2Sync(key, B, 1, dkLen, 'sha256')
24724
24725 // all of these functions are actually moved to the top
24726 // due to function hoisting
24727
24728 function smix (B, Bi, r, N, V, XY) {
24729 var Xi = 0
24730 var Yi = 128 * r
24731 var i
24732
24733 B.copy(XY, Xi, Bi, Bi + Yi)
24734
24735 for (i = 0; i < N; i++) {
24736 XY.copy(V, i * Yi, Xi, Xi + Yi)
24737 blockmix_salsa8(XY, Xi, Yi, r)
24738
24739 if (tickCallback) tickCallback()
24740 }
24741
24742 for (i = 0; i < N; i++) {
24743 var offset = Xi + (2 * r - 1) * 64
24744 var j = XY.readUInt32LE(offset) & (N - 1)
24745 blockxor(V, j * Yi, XY, Xi, Yi)
24746 blockmix_salsa8(XY, Xi, Yi, r)
24747
24748 if (tickCallback) tickCallback()
24749 }
24750
24751 XY.copy(B, Bi, Xi, Xi + Yi)
24752 }
24753
24754 function blockmix_salsa8 (BY, Bi, Yi, r) {
24755 var i
24756
24757 arraycopy(BY, Bi + (2 * r - 1) * 64, _X, 0, 64)
24758
24759 for (i = 0; i < 2 * r; i++) {
24760 blockxor(BY, i * 64, _X, 0, 64)
24761 salsa20_8(_X)
24762 arraycopy(_X, 0, BY, Yi + (i * 64), 64)
24763 }
24764
24765 for (i = 0; i < r; i++) {
24766 arraycopy(BY, Yi + (i * 2) * 64, BY, Bi + (i * 64), 64)
24767 }
24768
24769 for (i = 0; i < r; i++) {
24770 arraycopy(BY, Yi + (i * 2 + 1) * 64, BY, Bi + (i + r) * 64, 64)
24771 }
24772 }
24773
24774 function R (a, b) {
24775 return (a << b) | (a >>> (32 - b))
24776 }
24777
24778 function salsa20_8 (B) {
24779 var i
24780
24781 for (i = 0; i < 16; i++) {
24782 B32[i] = (B[i * 4 + 0] & 0xff) << 0
24783 B32[i] |= (B[i * 4 + 1] & 0xff) << 8
24784 B32[i] |= (B[i * 4 + 2] & 0xff) << 16
24785 B32[i] |= (B[i * 4 + 3] & 0xff) << 24
24786 // B32[i] = B.readUInt32LE(i*4) <--- this is signficantly slower even in Node.js
24787 }
24788
24789 arraycopy(B32, 0, x, 0, 16)
24790
24791 for (i = 8; i > 0; i -= 2) {
24792 x[4] ^= R(x[0] + x[12], 7)
24793 x[8] ^= R(x[4] + x[0], 9)
24794 x[12] ^= R(x[8] + x[4], 13)
24795 x[0] ^= R(x[12] + x[8], 18)
24796 x[9] ^= R(x[5] + x[1], 7)
24797 x[13] ^= R(x[9] + x[5], 9)
24798 x[1] ^= R(x[13] + x[9], 13)
24799 x[5] ^= R(x[1] + x[13], 18)
24800 x[14] ^= R(x[10] + x[6], 7)
24801 x[2] ^= R(x[14] + x[10], 9)
24802 x[6] ^= R(x[2] + x[14], 13)
24803 x[10] ^= R(x[6] + x[2], 18)
24804 x[3] ^= R(x[15] + x[11], 7)
24805 x[7] ^= R(x[3] + x[15], 9)
24806 x[11] ^= R(x[7] + x[3], 13)
24807 x[15] ^= R(x[11] + x[7], 18)
24808 x[1] ^= R(x[0] + x[3], 7)
24809 x[2] ^= R(x[1] + x[0], 9)
24810 x[3] ^= R(x[2] + x[1], 13)
24811 x[0] ^= R(x[3] + x[2], 18)
24812 x[6] ^= R(x[5] + x[4], 7)
24813 x[7] ^= R(x[6] + x[5], 9)
24814 x[4] ^= R(x[7] + x[6], 13)
24815 x[5] ^= R(x[4] + x[7], 18)
24816 x[11] ^= R(x[10] + x[9], 7)
24817 x[8] ^= R(x[11] + x[10], 9)
24818 x[9] ^= R(x[8] + x[11], 13)
24819 x[10] ^= R(x[9] + x[8], 18)
24820 x[12] ^= R(x[15] + x[14], 7)
24821 x[13] ^= R(x[12] + x[15], 9)
24822 x[14] ^= R(x[13] + x[12], 13)
24823 x[15] ^= R(x[14] + x[13], 18)
24824 }
24825
24826 for (i = 0; i < 16; ++i) B32[i] = x[i] + B32[i]
24827
24828 for (i = 0; i < 16; i++) {
24829 var bi = i * 4
24830 B[bi + 0] = (B32[i] >> 0 & 0xff)
24831 B[bi + 1] = (B32[i] >> 8 & 0xff)
24832 B[bi + 2] = (B32[i] >> 16 & 0xff)
24833 B[bi + 3] = (B32[i] >> 24 & 0xff)
24834 // B.writeInt32LE(B32[i], i*4) //<--- this is signficantly slower even in Node.js
24835 }
24836 }
24837
24838 // naive approach... going back to loop unrolling may yield additional performance
24839 function blockxor (S, Si, D, Di, len) {
24840 for (var i = 0; i < len; i++) {
24841 D[Di + i] ^= S[Si + i]
24842 }
24843 }
24844}
24845
24846function arraycopy (src, srcPos, dest, destPos, length) {
24847 if (Buffer.isBuffer(src) && Buffer.isBuffer(dest)) {
24848 src.copy(dest, destPos, srcPos, srcPos + length)
24849 } else {
24850 while (length--) {
24851 dest[destPos++] = src[srcPos++]
24852 }
24853 }
24854}
24855
24856module.exports = scrypt
24857
24858}).call(this,require("buffer").Buffer)
24859},{"buffer":53,"crypto":62}],158:[function(require,module,exports){
24860'use strict'
24861module.exports = require('./lib')(require('./lib/elliptic'))
24862
24863},{"./lib":162,"./lib/elliptic":161}],159:[function(require,module,exports){
24864(function (Buffer){
24865'use strict'
24866var toString = Object.prototype.toString
24867
24868// TypeError
24869exports.isArray = function (value, message) {
24870 if (!Array.isArray(value)) throw TypeError(message)
24871}
24872
24873exports.isBoolean = function (value, message) {
24874 if (toString.call(value) !== '[object Boolean]') throw TypeError(message)
24875}
24876
24877exports.isBuffer = function (value, message) {
24878 if (!Buffer.isBuffer(value)) throw TypeError(message)
24879}
24880
24881exports.isFunction = function (value, message) {
24882 if (toString.call(value) !== '[object Function]') throw TypeError(message)
24883}
24884
24885exports.isNumber = function (value, message) {
24886 if (toString.call(value) !== '[object Number]') throw TypeError(message)
24887}
24888
24889exports.isObject = function (value, message) {
24890 if (toString.call(value) !== '[object Object]') throw TypeError(message)
24891}
24892
24893// RangeError
24894exports.isBufferLength = function (buffer, length, message) {
24895 if (buffer.length !== length) throw RangeError(message)
24896}
24897
24898exports.isBufferLength2 = function (buffer, length1, length2, message) {
24899 if (buffer.length !== length1 && buffer.length !== length2) throw RangeError(message)
24900}
24901
24902exports.isLengthGTZero = function (value, message) {
24903 if (value.length === 0) throw RangeError(message)
24904}
24905
24906exports.isNumberInInterval = function (number, x, y, message) {
24907 if (number <= x || number >= y) throw RangeError(message)
24908}
24909
24910}).call(this,{"isBuffer":require("../../is-buffer/index.js")})
24911},{"../../is-buffer/index.js":108}],160:[function(require,module,exports){
24912'use strict'
24913var Buffer = require('safe-buffer').Buffer
24914var bip66 = require('bip66')
24915
24916var EC_PRIVKEY_EXPORT_DER_COMPRESSED = Buffer.from([
24917 // begin
24918 0x30, 0x81, 0xd3, 0x02, 0x01, 0x01, 0x04, 0x20,
24919 // private key
24920 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24921 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24922 // middle
24923 0xa0, 0x81, 0x85, 0x30, 0x81, 0x82, 0x02, 0x01, 0x01, 0x30, 0x2c, 0x06, 0x07, 0x2a, 0x86, 0x48,
24924 0xcE, 0x3d, 0x01, 0x01, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
24925 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
24926 0xff, 0xff, 0xfE, 0xff, 0xff, 0xfc, 0x2f, 0x30, 0x06, 0x04, 0x01, 0x00, 0x04, 0x01, 0x07, 0x04,
24927 0x21, 0x02, 0x79, 0xbE, 0x66, 0x7E, 0xf9, 0xdc, 0xbb, 0xac, 0x55, 0xa0, 0x62, 0x95, 0xcE, 0x87,
24928 0x0b, 0x07, 0x02, 0x9b, 0xfc, 0xdb, 0x2d, 0xcE, 0x28, 0xd9, 0x59, 0xf2, 0x81, 0x5b, 0x16, 0xf8,
24929 0x17, 0x98, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
24930 0xff, 0xff, 0xff, 0xff, 0xfE, 0xba, 0xaE, 0xdc, 0xE6, 0xaf, 0x48, 0xa0, 0x3b, 0xbf, 0xd2, 0x5E,
24931 0x8c, 0xd0, 0x36, 0x41, 0x41, 0x02, 0x01, 0x01, 0xa1, 0x24, 0x03, 0x22, 0x00,
24932 // public key
24933 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24934 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24935 0x00
24936])
24937
24938var EC_PRIVKEY_EXPORT_DER_UNCOMPRESSED = Buffer.from([
24939 // begin
24940 0x30, 0x82, 0x01, 0x13, 0x02, 0x01, 0x01, 0x04, 0x20,
24941 // private key
24942 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24943 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24944 // middle
24945 0xa0, 0x81, 0xa5, 0x30, 0x81, 0xa2, 0x02, 0x01, 0x01, 0x30, 0x2c, 0x06, 0x07, 0x2a, 0x86, 0x48,
24946 0xcE, 0x3d, 0x01, 0x01, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
24947 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
24948 0xff, 0xff, 0xfE, 0xff, 0xff, 0xfc, 0x2f, 0x30, 0x06, 0x04, 0x01, 0x00, 0x04, 0x01, 0x07, 0x04,
24949 0x41, 0x04, 0x79, 0xbE, 0x66, 0x7E, 0xf9, 0xdc, 0xbb, 0xac, 0x55, 0xa0, 0x62, 0x95, 0xcE, 0x87,
24950 0x0b, 0x07, 0x02, 0x9b, 0xfc, 0xdb, 0x2d, 0xcE, 0x28, 0xd9, 0x59, 0xf2, 0x81, 0x5b, 0x16, 0xf8,
24951 0x17, 0x98, 0x48, 0x3a, 0xda, 0x77, 0x26, 0xa3, 0xc4, 0x65, 0x5d, 0xa4, 0xfb, 0xfc, 0x0E, 0x11,
24952 0x08, 0xa8, 0xfd, 0x17, 0xb4, 0x48, 0xa6, 0x85, 0x54, 0x19, 0x9c, 0x47, 0xd0, 0x8f, 0xfb, 0x10,
24953 0xd4, 0xb8, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
24954 0xff, 0xff, 0xff, 0xff, 0xfE, 0xba, 0xaE, 0xdc, 0xE6, 0xaf, 0x48, 0xa0, 0x3b, 0xbf, 0xd2, 0x5E,
24955 0x8c, 0xd0, 0x36, 0x41, 0x41, 0x02, 0x01, 0x01, 0xa1, 0x44, 0x03, 0x42, 0x00,
24956 // public key
24957 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24958 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24959 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24960 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24961 0x00
24962])
24963
24964exports.privateKeyExport = function (privateKey, publicKey, compressed) {
24965 var result = Buffer.from(compressed ? EC_PRIVKEY_EXPORT_DER_COMPRESSED : EC_PRIVKEY_EXPORT_DER_UNCOMPRESSED)
24966 privateKey.copy(result, compressed ? 8 : 9)
24967 publicKey.copy(result, compressed ? 181 : 214)
24968 return result
24969}
24970
24971exports.privateKeyImport = function (privateKey) {
24972 var length = privateKey.length
24973
24974 // sequence header
24975 var index = 0
24976 if (length < index + 1 || privateKey[index] !== 0x30) return
24977 index += 1
24978
24979 // sequence length constructor
24980 if (length < index + 1 || !(privateKey[index] & 0x80)) return
24981
24982 var lenb = privateKey[index] & 0x7f
24983 index += 1
24984 if (lenb < 1 || lenb > 2) return
24985 if (length < index + lenb) return
24986
24987 // sequence length
24988 var len = privateKey[index + lenb - 1] | (lenb > 1 ? privateKey[index + lenb - 2] << 8 : 0)
24989 index += lenb
24990 if (length < index + len) return
24991
24992 // sequence element 0: version number (=1)
24993 if (length < index + 3 ||
24994 privateKey[index] !== 0x02 ||
24995 privateKey[index + 1] !== 0x01 ||
24996 privateKey[index + 2] !== 0x01) {
24997 return
24998 }
24999 index += 3
25000
25001 // sequence element 1: octet string, up to 32 bytes
25002 if (length < index + 2 ||
25003 privateKey[index] !== 0x04 ||
25004 privateKey[index + 1] > 0x20 ||
25005 length < index + 2 + privateKey[index + 1]) {
25006 return
25007 }
25008
25009 return privateKey.slice(index + 2, index + 2 + privateKey[index + 1])
25010}
25011
25012exports.signatureExport = function (sigObj) {
25013 var r = Buffer.concat([Buffer.from([0]), sigObj.r])
25014 for (var lenR = 33, posR = 0; lenR > 1 && r[posR] === 0x00 && !(r[posR + 1] & 0x80); --lenR, ++posR);
25015
25016 var s = Buffer.concat([Buffer.from([0]), sigObj.s])
25017 for (var lenS = 33, posS = 0; lenS > 1 && s[posS] === 0x00 && !(s[posS + 1] & 0x80); --lenS, ++posS);
25018
25019 return bip66.encode(r.slice(posR), s.slice(posS))
25020}
25021
25022exports.signatureImport = function (sig) {
25023 var r = Buffer.alloc(32, 0)
25024 var s = Buffer.alloc(32, 0)
25025
25026 try {
25027 var sigObj = bip66.decode(sig)
25028 if (sigObj.r.length === 33 && sigObj.r[0] === 0x00) sigObj.r = sigObj.r.slice(1)
25029 if (sigObj.r.length > 32) throw new Error('R length is too long')
25030 if (sigObj.s.length === 33 && sigObj.s[0] === 0x00) sigObj.s = sigObj.s.slice(1)
25031 if (sigObj.s.length > 32) throw new Error('S length is too long')
25032 } catch (err) {
25033 return
25034 }
25035
25036 sigObj.r.copy(r, 32 - sigObj.r.length)
25037 sigObj.s.copy(s, 32 - sigObj.s.length)
25038
25039 return { r: r, s: s }
25040}
25041
25042exports.signatureImportLax = function (sig) {
25043 var r = Buffer.alloc(32, 0)
25044 var s = Buffer.alloc(32, 0)
25045
25046 var length = sig.length
25047 var index = 0
25048
25049 // sequence tag byte
25050 if (sig[index++] !== 0x30) return
25051
25052 // sequence length byte
25053 var lenbyte = sig[index++]
25054 if (lenbyte & 0x80) {
25055 index += lenbyte - 0x80
25056 if (index > length) return
25057 }
25058
25059 // sequence tag byte for r
25060 if (sig[index++] !== 0x02) return
25061
25062 // length for r
25063 var rlen = sig[index++]
25064 if (rlen & 0x80) {
25065 lenbyte = rlen - 0x80
25066 if (index + lenbyte > length) return
25067 for (; lenbyte > 0 && sig[index] === 0x00; index += 1, lenbyte -= 1);
25068 for (rlen = 0; lenbyte > 0; index += 1, lenbyte -= 1) rlen = (rlen << 8) + sig[index]
25069 }
25070 if (rlen > length - index) return
25071 var rindex = index
25072 index += rlen
25073
25074 // sequence tag byte for s
25075 if (sig[index++] !== 0x02) return
25076
25077 // length for s
25078 var slen = sig[index++]
25079 if (slen & 0x80) {
25080 lenbyte = slen - 0x80
25081 if (index + lenbyte > length) return
25082 for (; lenbyte > 0 && sig[index] === 0x00; index += 1, lenbyte -= 1);
25083 for (slen = 0; lenbyte > 0; index += 1, lenbyte -= 1) slen = (slen << 8) + sig[index]
25084 }
25085 if (slen > length - index) return
25086 var sindex = index
25087 index += slen
25088
25089 // ignore leading zeros in r
25090 for (; rlen > 0 && sig[rindex] === 0x00; rlen -= 1, rindex += 1);
25091 // copy r value
25092 if (rlen > 32) return
25093 var rvalue = sig.slice(rindex, rindex + rlen)
25094 rvalue.copy(r, 32 - rvalue.length)
25095
25096 // ignore leading zeros in s
25097 for (; slen > 0 && sig[sindex] === 0x00; slen -= 1, sindex += 1);
25098 // copy s value
25099 if (slen > 32) return
25100 var svalue = sig.slice(sindex, sindex + slen)
25101 svalue.copy(s, 32 - svalue.length)
25102
25103 return { r: r, s: s }
25104}
25105
25106},{"bip66":20,"safe-buffer":156}],161:[function(require,module,exports){
25107'use strict'
25108var Buffer = require('safe-buffer').Buffer
25109var createHash = require('create-hash')
25110var BN = require('bn.js')
25111var EC = require('elliptic').ec
25112
25113var messages = require('../messages.json')
25114
25115var ec = new EC('secp256k1')
25116var ecparams = ec.curve
25117
25118function loadCompressedPublicKey (first, xBuffer) {
25119 var x = new BN(xBuffer)
25120
25121 // overflow
25122 if (x.cmp(ecparams.p) >= 0) return null
25123 x = x.toRed(ecparams.red)
25124
25125 // compute corresponding Y
25126 var y = x.redSqr().redIMul(x).redIAdd(ecparams.b).redSqrt()
25127 if ((first === 0x03) !== y.isOdd()) y = y.redNeg()
25128
25129 return ec.keyPair({ pub: { x: x, y: y } })
25130}
25131
25132function loadUncompressedPublicKey (first, xBuffer, yBuffer) {
25133 var x = new BN(xBuffer)
25134 var y = new BN(yBuffer)
25135
25136 // overflow
25137 if (x.cmp(ecparams.p) >= 0 || y.cmp(ecparams.p) >= 0) return null
25138
25139 x = x.toRed(ecparams.red)
25140 y = y.toRed(ecparams.red)
25141
25142 // is odd flag
25143 if ((first === 0x06 || first === 0x07) && y.isOdd() !== (first === 0x07)) return null
25144
25145 // x*x*x + b = y*y
25146 var x3 = x.redSqr().redIMul(x)
25147 if (!y.redSqr().redISub(x3.redIAdd(ecparams.b)).isZero()) return null
25148
25149 return ec.keyPair({ pub: { x: x, y: y } })
25150}
25151
25152function loadPublicKey (publicKey) {
25153 var first = publicKey[0]
25154 switch (first) {
25155 case 0x02:
25156 case 0x03:
25157 if (publicKey.length !== 33) return null
25158 return loadCompressedPublicKey(first, publicKey.slice(1, 33))
25159 case 0x04:
25160 case 0x06:
25161 case 0x07:
25162 if (publicKey.length !== 65) return null
25163 return loadUncompressedPublicKey(first, publicKey.slice(1, 33), publicKey.slice(33, 65))
25164 default:
25165 return null
25166 }
25167}
25168
25169exports.privateKeyVerify = function (privateKey) {
25170 var bn = new BN(privateKey)
25171 return bn.cmp(ecparams.n) < 0 && !bn.isZero()
25172}
25173
25174exports.privateKeyExport = function (privateKey, compressed) {
25175 var d = new BN(privateKey)
25176 if (d.cmp(ecparams.n) >= 0 || d.isZero()) throw new Error(messages.EC_PRIVATE_KEY_EXPORT_DER_FAIL)
25177
25178 return Buffer.from(ec.keyFromPrivate(privateKey).getPublic(compressed, true))
25179}
25180
25181exports.privateKeyNegate = function (privateKey) {
25182 var bn = new BN(privateKey)
25183 return bn.isZero() ? Buffer.alloc(32) : ecparams.n.sub(bn).umod(ecparams.n).toArrayLike(Buffer, 'be', 32)
25184}
25185
25186exports.privateKeyModInverse = function (privateKey) {
25187 var bn = new BN(privateKey)
25188 if (bn.cmp(ecparams.n) >= 0 || bn.isZero()) throw new Error(messages.EC_PRIVATE_KEY_RANGE_INVALID)
25189
25190 return bn.invm(ecparams.n).toArrayLike(Buffer, 'be', 32)
25191}
25192
25193exports.privateKeyTweakAdd = function (privateKey, tweak) {
25194 var bn = new BN(tweak)
25195 if (bn.cmp(ecparams.n) >= 0) throw new Error(messages.EC_PRIVATE_KEY_TWEAK_ADD_FAIL)
25196
25197 bn.iadd(new BN(privateKey))
25198 if (bn.cmp(ecparams.n) >= 0) bn.isub(ecparams.n)
25199 if (bn.isZero()) throw new Error(messages.EC_PRIVATE_KEY_TWEAK_ADD_FAIL)
25200
25201 return bn.toArrayLike(Buffer, 'be', 32)
25202}
25203
25204exports.privateKeyTweakMul = function (privateKey, tweak) {
25205 var bn = new BN(tweak)
25206 if (bn.cmp(ecparams.n) >= 0 || bn.isZero()) throw new Error(messages.EC_PRIVATE_KEY_TWEAK_MUL_FAIL)
25207
25208 bn.imul(new BN(privateKey))
25209 if (bn.cmp(ecparams.n)) bn = bn.umod(ecparams.n)
25210
25211 return bn.toArrayLike(Buffer, 'be', 32)
25212}
25213
25214exports.publicKeyCreate = function (privateKey, compressed) {
25215 var d = new BN(privateKey)
25216 if (d.cmp(ecparams.n) >= 0 || d.isZero()) throw new Error(messages.EC_PUBLIC_KEY_CREATE_FAIL)
25217
25218 return Buffer.from(ec.keyFromPrivate(privateKey).getPublic(compressed, true))
25219}
25220
25221exports.publicKeyConvert = function (publicKey, compressed) {
25222 var pair = loadPublicKey(publicKey)
25223 if (pair === null) throw new Error(messages.EC_PUBLIC_KEY_PARSE_FAIL)
25224
25225 return Buffer.from(pair.getPublic(compressed, true))
25226}
25227
25228exports.publicKeyVerify = function (publicKey) {
25229 return loadPublicKey(publicKey) !== null
25230}
25231
25232exports.publicKeyTweakAdd = function (publicKey, tweak, compressed) {
25233 var pair = loadPublicKey(publicKey)
25234 if (pair === null) throw new Error(messages.EC_PUBLIC_KEY_PARSE_FAIL)
25235
25236 tweak = new BN(tweak)
25237 if (tweak.cmp(ecparams.n) >= 0) throw new Error(messages.EC_PUBLIC_KEY_TWEAK_ADD_FAIL)
25238
25239 return Buffer.from(ecparams.g.mul(tweak).add(pair.pub).encode(true, compressed))
25240}
25241
25242exports.publicKeyTweakMul = function (publicKey, tweak, compressed) {
25243 var pair = loadPublicKey(publicKey)
25244 if (pair === null) throw new Error(messages.EC_PUBLIC_KEY_PARSE_FAIL)
25245
25246 tweak = new BN(tweak)
25247 if (tweak.cmp(ecparams.n) >= 0 || tweak.isZero()) throw new Error(messages.EC_PUBLIC_KEY_TWEAK_MUL_FAIL)
25248
25249 return Buffer.from(pair.pub.mul(tweak).encode(true, compressed))
25250}
25251
25252exports.publicKeyCombine = function (publicKeys, compressed) {
25253 var pairs = new Array(publicKeys.length)
25254 for (var i = 0; i < publicKeys.length; ++i) {
25255 pairs[i] = loadPublicKey(publicKeys[i])
25256 if (pairs[i] === null) throw new Error(messages.EC_PUBLIC_KEY_PARSE_FAIL)
25257 }
25258
25259 var point = pairs[0].pub
25260 for (var j = 1; j < pairs.length; ++j) point = point.add(pairs[j].pub)
25261 if (point.isInfinity()) throw new Error(messages.EC_PUBLIC_KEY_COMBINE_FAIL)
25262
25263 return Buffer.from(point.encode(true, compressed))
25264}
25265
25266exports.signatureNormalize = function (signature) {
25267 var r = new BN(signature.slice(0, 32))
25268 var s = new BN(signature.slice(32, 64))
25269 if (r.cmp(ecparams.n) >= 0 || s.cmp(ecparams.n) >= 0) throw new Error(messages.ECDSA_SIGNATURE_PARSE_FAIL)
25270
25271 var result = Buffer.from(signature)
25272 if (s.cmp(ec.nh) === 1) ecparams.n.sub(s).toArrayLike(Buffer, 'be', 32).copy(result, 32)
25273
25274 return result
25275}
25276
25277exports.signatureExport = function (signature) {
25278 var r = signature.slice(0, 32)
25279 var s = signature.slice(32, 64)
25280 if (new BN(r).cmp(ecparams.n) >= 0 || new BN(s).cmp(ecparams.n) >= 0) throw new Error(messages.ECDSA_SIGNATURE_PARSE_FAIL)
25281
25282 return { r: r, s: s }
25283}
25284
25285exports.signatureImport = function (sigObj) {
25286 var r = new BN(sigObj.r)
25287 if (r.cmp(ecparams.n) >= 0) r = new BN(0)
25288
25289 var s = new BN(sigObj.s)
25290 if (s.cmp(ecparams.n) >= 0) s = new BN(0)
25291
25292 return Buffer.concat([
25293 r.toArrayLike(Buffer, 'be', 32),
25294 s.toArrayLike(Buffer, 'be', 32)
25295 ])
25296}
25297
25298exports.sign = function (message, privateKey, noncefn, data) {
25299 if (typeof noncefn === 'function') {
25300 var getNonce = noncefn
25301 noncefn = function (counter) {
25302 var nonce = getNonce(message, privateKey, null, data, counter)
25303 if (!Buffer.isBuffer(nonce) || nonce.length !== 32) throw new Error(messages.ECDSA_SIGN_FAIL)
25304
25305 return new BN(nonce)
25306 }
25307 }
25308
25309 var d = new BN(privateKey)
25310 if (d.cmp(ecparams.n) >= 0 || d.isZero()) throw new Error(messages.ECDSA_SIGN_FAIL)
25311
25312 var result = ec.sign(message, privateKey, { canonical: true, k: noncefn, pers: data })
25313 return {
25314 signature: Buffer.concat([
25315 result.r.toArrayLike(Buffer, 'be', 32),
25316 result.s.toArrayLike(Buffer, 'be', 32)
25317 ]),
25318 recovery: result.recoveryParam
25319 }
25320}
25321
25322exports.verify = function (message, signature, publicKey) {
25323 var sigObj = {r: signature.slice(0, 32), s: signature.slice(32, 64)}
25324
25325 var sigr = new BN(sigObj.r)
25326 var sigs = new BN(sigObj.s)
25327 if (sigr.cmp(ecparams.n) >= 0 || sigs.cmp(ecparams.n) >= 0) throw new Error(messages.ECDSA_SIGNATURE_PARSE_FAIL)
25328 if (sigs.cmp(ec.nh) === 1 || sigr.isZero() || sigs.isZero()) return false
25329
25330 var pair = loadPublicKey(publicKey)
25331 if (pair === null) throw new Error(messages.EC_PUBLIC_KEY_PARSE_FAIL)
25332
25333 return ec.verify(message, sigObj, {x: pair.pub.x, y: pair.pub.y})
25334}
25335
25336exports.recover = function (message, signature, recovery, compressed) {
25337 var sigObj = {r: signature.slice(0, 32), s: signature.slice(32, 64)}
25338
25339 var sigr = new BN(sigObj.r)
25340 var sigs = new BN(sigObj.s)
25341 if (sigr.cmp(ecparams.n) >= 0 || sigs.cmp(ecparams.n) >= 0) throw new Error(messages.ECDSA_SIGNATURE_PARSE_FAIL)
25342
25343 try {
25344 if (sigr.isZero() || sigs.isZero()) throw new Error()
25345
25346 var point = ec.recoverPubKey(message, sigObj, recovery)
25347 return Buffer.from(point.encode(true, compressed))
25348 } catch (err) {
25349 throw new Error(messages.ECDSA_RECOVER_FAIL)
25350 }
25351}
25352
25353exports.ecdh = function (publicKey, privateKey) {
25354 var shared = exports.ecdhUnsafe(publicKey, privateKey, true)
25355 return createHash('sha256').update(shared).digest()
25356}
25357
25358exports.ecdhUnsafe = function (publicKey, privateKey, compressed) {
25359 var pair = loadPublicKey(publicKey)
25360 if (pair === null) throw new Error(messages.EC_PUBLIC_KEY_PARSE_FAIL)
25361
25362 var scalar = new BN(privateKey)
25363 if (scalar.cmp(ecparams.n) >= 0 || scalar.isZero()) throw new Error(messages.ECDH_FAIL)
25364
25365 return Buffer.from(pair.pub.mul(scalar).encode(true, compressed))
25366}
25367
25368},{"../messages.json":163,"bn.js":21,"create-hash":57,"elliptic":73,"safe-buffer":156}],162:[function(require,module,exports){
25369'use strict'
25370var assert = require('./assert')
25371var der = require('./der')
25372var messages = require('./messages.json')
25373
25374function initCompressedValue (value, defaultValue) {
25375 if (value === undefined) return defaultValue
25376
25377 assert.isBoolean(value, messages.COMPRESSED_TYPE_INVALID)
25378 return value
25379}
25380
25381module.exports = function (secp256k1) {
25382 return {
25383 privateKeyVerify: function (privateKey) {
25384 assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID)
25385 return privateKey.length === 32 && secp256k1.privateKeyVerify(privateKey)
25386 },
25387
25388 privateKeyExport: function (privateKey, compressed) {
25389 assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID)
25390 assert.isBufferLength(privateKey, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID)
25391
25392 compressed = initCompressedValue(compressed, true)
25393 var publicKey = secp256k1.privateKeyExport(privateKey, compressed)
25394
25395 return der.privateKeyExport(privateKey, publicKey, compressed)
25396 },
25397
25398 privateKeyImport: function (privateKey) {
25399 assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID)
25400
25401 privateKey = der.privateKeyImport(privateKey)
25402 if (privateKey && privateKey.length === 32 && secp256k1.privateKeyVerify(privateKey)) return privateKey
25403
25404 throw new Error(messages.EC_PRIVATE_KEY_IMPORT_DER_FAIL)
25405 },
25406
25407 privateKeyNegate: function (privateKey) {
25408 assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID)
25409 assert.isBufferLength(privateKey, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID)
25410
25411 return secp256k1.privateKeyNegate(privateKey)
25412 },
25413
25414 privateKeyModInverse: function (privateKey) {
25415 assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID)
25416 assert.isBufferLength(privateKey, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID)
25417
25418 return secp256k1.privateKeyModInverse(privateKey)
25419 },
25420
25421 privateKeyTweakAdd: function (privateKey, tweak) {
25422 assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID)
25423 assert.isBufferLength(privateKey, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID)
25424
25425 assert.isBuffer(tweak, messages.TWEAK_TYPE_INVALID)
25426 assert.isBufferLength(tweak, 32, messages.TWEAK_LENGTH_INVALID)
25427
25428 return secp256k1.privateKeyTweakAdd(privateKey, tweak)
25429 },
25430
25431 privateKeyTweakMul: function (privateKey, tweak) {
25432 assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID)
25433 assert.isBufferLength(privateKey, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID)
25434
25435 assert.isBuffer(tweak, messages.TWEAK_TYPE_INVALID)
25436 assert.isBufferLength(tweak, 32, messages.TWEAK_LENGTH_INVALID)
25437
25438 return secp256k1.privateKeyTweakMul(privateKey, tweak)
25439 },
25440
25441 publicKeyCreate: function (privateKey, compressed) {
25442 assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID)
25443 assert.isBufferLength(privateKey, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID)
25444
25445 compressed = initCompressedValue(compressed, true)
25446
25447 return secp256k1.publicKeyCreate(privateKey, compressed)
25448 },
25449
25450 publicKeyConvert: function (publicKey, compressed) {
25451 assert.isBuffer(publicKey, messages.EC_PUBLIC_KEY_TYPE_INVALID)
25452 assert.isBufferLength2(publicKey, 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID)
25453
25454 compressed = initCompressedValue(compressed, true)
25455
25456 return secp256k1.publicKeyConvert(publicKey, compressed)
25457 },
25458
25459 publicKeyVerify: function (publicKey) {
25460 assert.isBuffer(publicKey, messages.EC_PUBLIC_KEY_TYPE_INVALID)
25461 return secp256k1.publicKeyVerify(publicKey)
25462 },
25463
25464 publicKeyTweakAdd: function (publicKey, tweak, compressed) {
25465 assert.isBuffer(publicKey, messages.EC_PUBLIC_KEY_TYPE_INVALID)
25466 assert.isBufferLength2(publicKey, 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID)
25467
25468 assert.isBuffer(tweak, messages.TWEAK_TYPE_INVALID)
25469 assert.isBufferLength(tweak, 32, messages.TWEAK_LENGTH_INVALID)
25470
25471 compressed = initCompressedValue(compressed, true)
25472
25473 return secp256k1.publicKeyTweakAdd(publicKey, tweak, compressed)
25474 },
25475
25476 publicKeyTweakMul: function (publicKey, tweak, compressed) {
25477 assert.isBuffer(publicKey, messages.EC_PUBLIC_KEY_TYPE_INVALID)
25478 assert.isBufferLength2(publicKey, 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID)
25479
25480 assert.isBuffer(tweak, messages.TWEAK_TYPE_INVALID)
25481 assert.isBufferLength(tweak, 32, messages.TWEAK_LENGTH_INVALID)
25482
25483 compressed = initCompressedValue(compressed, true)
25484
25485 return secp256k1.publicKeyTweakMul(publicKey, tweak, compressed)
25486 },
25487
25488 publicKeyCombine: function (publicKeys, compressed) {
25489 assert.isArray(publicKeys, messages.EC_PUBLIC_KEYS_TYPE_INVALID)
25490 assert.isLengthGTZero(publicKeys, messages.EC_PUBLIC_KEYS_LENGTH_INVALID)
25491 for (var i = 0; i < publicKeys.length; ++i) {
25492 assert.isBuffer(publicKeys[i], messages.EC_PUBLIC_KEY_TYPE_INVALID)
25493 assert.isBufferLength2(publicKeys[i], 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID)
25494 }
25495
25496 compressed = initCompressedValue(compressed, true)
25497
25498 return secp256k1.publicKeyCombine(publicKeys, compressed)
25499 },
25500
25501 signatureNormalize: function (signature) {
25502 assert.isBuffer(signature, messages.ECDSA_SIGNATURE_TYPE_INVALID)
25503 assert.isBufferLength(signature, 64, messages.ECDSA_SIGNATURE_LENGTH_INVALID)
25504
25505 return secp256k1.signatureNormalize(signature)
25506 },
25507
25508 signatureExport: function (signature) {
25509 assert.isBuffer(signature, messages.ECDSA_SIGNATURE_TYPE_INVALID)
25510 assert.isBufferLength(signature, 64, messages.ECDSA_SIGNATURE_LENGTH_INVALID)
25511
25512 var sigObj = secp256k1.signatureExport(signature)
25513 return der.signatureExport(sigObj)
25514 },
25515
25516 signatureImport: function (sig) {
25517 assert.isBuffer(sig, messages.ECDSA_SIGNATURE_TYPE_INVALID)
25518 assert.isLengthGTZero(sig, messages.ECDSA_SIGNATURE_LENGTH_INVALID)
25519
25520 var sigObj = der.signatureImport(sig)
25521 if (sigObj) return secp256k1.signatureImport(sigObj)
25522
25523 throw new Error(messages.ECDSA_SIGNATURE_PARSE_DER_FAIL)
25524 },
25525
25526 signatureImportLax: function (sig) {
25527 assert.isBuffer(sig, messages.ECDSA_SIGNATURE_TYPE_INVALID)
25528 assert.isLengthGTZero(sig, messages.ECDSA_SIGNATURE_LENGTH_INVALID)
25529
25530 var sigObj = der.signatureImportLax(sig)
25531 if (sigObj) return secp256k1.signatureImport(sigObj)
25532
25533 throw new Error(messages.ECDSA_SIGNATURE_PARSE_DER_FAIL)
25534 },
25535
25536 sign: function (message, privateKey, options) {
25537 assert.isBuffer(message, messages.MSG32_TYPE_INVALID)
25538 assert.isBufferLength(message, 32, messages.MSG32_LENGTH_INVALID)
25539
25540 assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID)
25541 assert.isBufferLength(privateKey, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID)
25542
25543 var data = null
25544 var noncefn = null
25545 if (options !== undefined) {
25546 assert.isObject(options, messages.OPTIONS_TYPE_INVALID)
25547
25548 if (options.data !== undefined) {
25549 assert.isBuffer(options.data, messages.OPTIONS_DATA_TYPE_INVALID)
25550 assert.isBufferLength(options.data, 32, messages.OPTIONS_DATA_LENGTH_INVALID)
25551 data = options.data
25552 }
25553
25554 if (options.noncefn !== undefined) {
25555 assert.isFunction(options.noncefn, messages.OPTIONS_NONCEFN_TYPE_INVALID)
25556 noncefn = options.noncefn
25557 }
25558 }
25559
25560 return secp256k1.sign(message, privateKey, noncefn, data)
25561 },
25562
25563 verify: function (message, signature, publicKey) {
25564 assert.isBuffer(message, messages.MSG32_TYPE_INVALID)
25565 assert.isBufferLength(message, 32, messages.MSG32_LENGTH_INVALID)
25566
25567 assert.isBuffer(signature, messages.ECDSA_SIGNATURE_TYPE_INVALID)
25568 assert.isBufferLength(signature, 64, messages.ECDSA_SIGNATURE_LENGTH_INVALID)
25569
25570 assert.isBuffer(publicKey, messages.EC_PUBLIC_KEY_TYPE_INVALID)
25571 assert.isBufferLength2(publicKey, 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID)
25572
25573 return secp256k1.verify(message, signature, publicKey)
25574 },
25575
25576 recover: function (message, signature, recovery, compressed) {
25577 assert.isBuffer(message, messages.MSG32_TYPE_INVALID)
25578 assert.isBufferLength(message, 32, messages.MSG32_LENGTH_INVALID)
25579
25580 assert.isBuffer(signature, messages.ECDSA_SIGNATURE_TYPE_INVALID)
25581 assert.isBufferLength(signature, 64, messages.ECDSA_SIGNATURE_LENGTH_INVALID)
25582
25583 assert.isNumber(recovery, messages.RECOVERY_ID_TYPE_INVALID)
25584 assert.isNumberInInterval(recovery, -1, 4, messages.RECOVERY_ID_VALUE_INVALID)
25585
25586 compressed = initCompressedValue(compressed, true)
25587
25588 return secp256k1.recover(message, signature, recovery, compressed)
25589 },
25590
25591 ecdh: function (publicKey, privateKey) {
25592 assert.isBuffer(publicKey, messages.EC_PUBLIC_KEY_TYPE_INVALID)
25593 assert.isBufferLength2(publicKey, 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID)
25594
25595 assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID)
25596 assert.isBufferLength(privateKey, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID)
25597
25598 return secp256k1.ecdh(publicKey, privateKey)
25599 },
25600
25601 ecdhUnsafe: function (publicKey, privateKey, compressed) {
25602 assert.isBuffer(publicKey, messages.EC_PUBLIC_KEY_TYPE_INVALID)
25603 assert.isBufferLength2(publicKey, 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID)
25604
25605 assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID)
25606 assert.isBufferLength(privateKey, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID)
25607
25608 compressed = initCompressedValue(compressed, true)
25609
25610 return secp256k1.ecdhUnsafe(publicKey, privateKey, compressed)
25611 }
25612 }
25613}
25614
25615},{"./assert":159,"./der":160,"./messages.json":163}],163:[function(require,module,exports){
25616module.exports={
25617 "COMPRESSED_TYPE_INVALID": "compressed should be a boolean",
25618 "EC_PRIVATE_KEY_TYPE_INVALID": "private key should be a Buffer",
25619 "EC_PRIVATE_KEY_LENGTH_INVALID": "private key length is invalid",
25620 "EC_PRIVATE_KEY_RANGE_INVALID": "private key range is invalid",
25621 "EC_PRIVATE_KEY_TWEAK_ADD_FAIL": "tweak out of range or resulting private key is invalid",
25622 "EC_PRIVATE_KEY_TWEAK_MUL_FAIL": "tweak out of range",
25623 "EC_PRIVATE_KEY_EXPORT_DER_FAIL": "couldn't export to DER format",
25624 "EC_PRIVATE_KEY_IMPORT_DER_FAIL": "couldn't import from DER format",
25625 "EC_PUBLIC_KEYS_TYPE_INVALID": "public keys should be an Array",
25626 "EC_PUBLIC_KEYS_LENGTH_INVALID": "public keys Array should have at least 1 element",
25627 "EC_PUBLIC_KEY_TYPE_INVALID": "public key should be a Buffer",
25628 "EC_PUBLIC_KEY_LENGTH_INVALID": "public key length is invalid",
25629 "EC_PUBLIC_KEY_PARSE_FAIL": "the public key could not be parsed or is invalid",
25630 "EC_PUBLIC_KEY_CREATE_FAIL": "private was invalid, try again",
25631 "EC_PUBLIC_KEY_TWEAK_ADD_FAIL": "tweak out of range or resulting public key is invalid",
25632 "EC_PUBLIC_KEY_TWEAK_MUL_FAIL": "tweak out of range",
25633 "EC_PUBLIC_KEY_COMBINE_FAIL": "the sum of the public keys is not valid",
25634 "ECDH_FAIL": "scalar was invalid (zero or overflow)",
25635 "ECDSA_SIGNATURE_TYPE_INVALID": "signature should be a Buffer",
25636 "ECDSA_SIGNATURE_LENGTH_INVALID": "signature length is invalid",
25637 "ECDSA_SIGNATURE_PARSE_FAIL": "couldn't parse signature",
25638 "ECDSA_SIGNATURE_PARSE_DER_FAIL": "couldn't parse DER signature",
25639 "ECDSA_SIGNATURE_SERIALIZE_DER_FAIL": "couldn't serialize signature to DER format",
25640 "ECDSA_SIGN_FAIL": "nonce generation function failed or private key is invalid",
25641 "ECDSA_RECOVER_FAIL": "couldn't recover public key from signature",
25642 "MSG32_TYPE_INVALID": "message should be a Buffer",
25643 "MSG32_LENGTH_INVALID": "message length is invalid",
25644 "OPTIONS_TYPE_INVALID": "options should be an Object",
25645 "OPTIONS_DATA_TYPE_INVALID": "options.data should be a Buffer",
25646 "OPTIONS_DATA_LENGTH_INVALID": "options.data length is invalid",
25647 "OPTIONS_NONCEFN_TYPE_INVALID": "options.noncefn should be a Function",
25648 "RECOVERY_ID_TYPE_INVALID": "recovery should be a Number",
25649 "RECOVERY_ID_VALUE_INVALID": "recovery should have value between -1 and 4",
25650 "TWEAK_TYPE_INVALID": "tweak should be a Buffer",
25651 "TWEAK_LENGTH_INVALID": "tweak length is invalid"
25652}
25653
25654},{}],164:[function(require,module,exports){
25655var Buffer = require('safe-buffer').Buffer
25656
25657// prototype class for hash functions
25658function Hash (blockSize, finalSize) {
25659 this._block = Buffer.alloc(blockSize)
25660 this._finalSize = finalSize
25661 this._blockSize = blockSize
25662 this._len = 0
25663}
25664
25665Hash.prototype.update = function (data, enc) {
25666 if (typeof data === 'string') {
25667 enc = enc || 'utf8'
25668 data = Buffer.from(data, enc)
25669 }
25670
25671 var block = this._block
25672 var blockSize = this._blockSize
25673 var length = data.length
25674 var accum = this._len
25675
25676 for (var offset = 0; offset < length;) {
25677 var assigned = accum % blockSize
25678 var remainder = Math.min(length - offset, blockSize - assigned)
25679
25680 for (var i = 0; i < remainder; i++) {
25681 block[assigned + i] = data[offset + i]
25682 }
25683
25684 accum += remainder
25685 offset += remainder
25686
25687 if ((accum % blockSize) === 0) {
25688 this._update(block)
25689 }
25690 }
25691
25692 this._len += length
25693 return this
25694}
25695
25696Hash.prototype.digest = function (enc) {
25697 var rem = this._len % this._blockSize
25698
25699 this._block[rem] = 0x80
25700
25701 // zero (rem + 1) trailing bits, where (rem + 1) is the smallest
25702 // non-negative solution to the equation (length + 1 + (rem + 1)) === finalSize mod blockSize
25703 this._block.fill(0, rem + 1)
25704
25705 if (rem >= this._finalSize) {
25706 this._update(this._block)
25707 this._block.fill(0)
25708 }
25709
25710 var bits = this._len * 8
25711
25712 // uint32
25713 if (bits <= 0xffffffff) {
25714 this._block.writeUInt32BE(bits, this._blockSize - 4)
25715
25716 // uint64
25717 } else {
25718 var lowBits = bits & 0xffffffff
25719 var highBits = (bits - lowBits) / 0x100000000
25720
25721 this._block.writeUInt32BE(highBits, this._blockSize - 8)
25722 this._block.writeUInt32BE(lowBits, this._blockSize - 4)
25723 }
25724
25725 this._update(this._block)
25726 var hash = this._hash()
25727
25728 return enc ? hash.toString(enc) : hash
25729}
25730
25731Hash.prototype._update = function () {
25732 throw new Error('_update must be implemented by subclass')
25733}
25734
25735module.exports = Hash
25736
25737},{"safe-buffer":156}],165:[function(require,module,exports){
25738var exports = module.exports = function SHA (algorithm) {
25739 algorithm = algorithm.toLowerCase()
25740
25741 var Algorithm = exports[algorithm]
25742 if (!Algorithm) throw new Error(algorithm + ' is not supported (we accept pull requests)')
25743
25744 return new Algorithm()
25745}
25746
25747exports.sha = require('./sha')
25748exports.sha1 = require('./sha1')
25749exports.sha224 = require('./sha224')
25750exports.sha256 = require('./sha256')
25751exports.sha384 = require('./sha384')
25752exports.sha512 = require('./sha512')
25753
25754},{"./sha":166,"./sha1":167,"./sha224":168,"./sha256":169,"./sha384":170,"./sha512":171}],166:[function(require,module,exports){
25755/*
25756 * A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined
25757 * in FIPS PUB 180-1
25758 * This source code is derived from sha1.js of the same repository.
25759 * The difference between SHA-0 and SHA-1 is just a bitwise rotate left
25760 * operation was added.
25761 */
25762
25763var inherits = require('inherits')
25764var Hash = require('./hash')
25765var Buffer = require('safe-buffer').Buffer
25766
25767var K = [
25768 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
25769]
25770
25771var W = new Array(80)
25772
25773function Sha () {
25774 this.init()
25775 this._w = W
25776
25777 Hash.call(this, 64, 56)
25778}
25779
25780inherits(Sha, Hash)
25781
25782Sha.prototype.init = function () {
25783 this._a = 0x67452301
25784 this._b = 0xefcdab89
25785 this._c = 0x98badcfe
25786 this._d = 0x10325476
25787 this._e = 0xc3d2e1f0
25788
25789 return this
25790}
25791
25792function rotl5 (num) {
25793 return (num << 5) | (num >>> 27)
25794}
25795
25796function rotl30 (num) {
25797 return (num << 30) | (num >>> 2)
25798}
25799
25800function ft (s, b, c, d) {
25801 if (s === 0) return (b & c) | ((~b) & d)
25802 if (s === 2) return (b & c) | (b & d) | (c & d)
25803 return b ^ c ^ d
25804}
25805
25806Sha.prototype._update = function (M) {
25807 var W = this._w
25808
25809 var a = this._a | 0
25810 var b = this._b | 0
25811 var c = this._c | 0
25812 var d = this._d | 0
25813 var e = this._e | 0
25814
25815 for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
25816 for (; i < 80; ++i) W[i] = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]
25817
25818 for (var j = 0; j < 80; ++j) {
25819 var s = ~~(j / 20)
25820 var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0
25821
25822 e = d
25823 d = c
25824 c = rotl30(b)
25825 b = a
25826 a = t
25827 }
25828
25829 this._a = (a + this._a) | 0
25830 this._b = (b + this._b) | 0
25831 this._c = (c + this._c) | 0
25832 this._d = (d + this._d) | 0
25833 this._e = (e + this._e) | 0
25834}
25835
25836Sha.prototype._hash = function () {
25837 var H = Buffer.allocUnsafe(20)
25838
25839 H.writeInt32BE(this._a | 0, 0)
25840 H.writeInt32BE(this._b | 0, 4)
25841 H.writeInt32BE(this._c | 0, 8)
25842 H.writeInt32BE(this._d | 0, 12)
25843 H.writeInt32BE(this._e | 0, 16)
25844
25845 return H
25846}
25847
25848module.exports = Sha
25849
25850},{"./hash":164,"inherits":107,"safe-buffer":156}],167:[function(require,module,exports){
25851/*
25852 * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
25853 * in FIPS PUB 180-1
25854 * Version 2.1a Copyright Paul Johnston 2000 - 2002.
25855 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
25856 * Distributed under the BSD License
25857 * See http://pajhome.org.uk/crypt/md5 for details.
25858 */
25859
25860var inherits = require('inherits')
25861var Hash = require('./hash')
25862var Buffer = require('safe-buffer').Buffer
25863
25864var K = [
25865 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
25866]
25867
25868var W = new Array(80)
25869
25870function Sha1 () {
25871 this.init()
25872 this._w = W
25873
25874 Hash.call(this, 64, 56)
25875}
25876
25877inherits(Sha1, Hash)
25878
25879Sha1.prototype.init = function () {
25880 this._a = 0x67452301
25881 this._b = 0xefcdab89
25882 this._c = 0x98badcfe
25883 this._d = 0x10325476
25884 this._e = 0xc3d2e1f0
25885
25886 return this
25887}
25888
25889function rotl1 (num) {
25890 return (num << 1) | (num >>> 31)
25891}
25892
25893function rotl5 (num) {
25894 return (num << 5) | (num >>> 27)
25895}
25896
25897function rotl30 (num) {
25898 return (num << 30) | (num >>> 2)
25899}
25900
25901function ft (s, b, c, d) {
25902 if (s === 0) return (b & c) | ((~b) & d)
25903 if (s === 2) return (b & c) | (b & d) | (c & d)
25904 return b ^ c ^ d
25905}
25906
25907Sha1.prototype._update = function (M) {
25908 var W = this._w
25909
25910 var a = this._a | 0
25911 var b = this._b | 0
25912 var c = this._c | 0
25913 var d = this._d | 0
25914 var e = this._e | 0
25915
25916 for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
25917 for (; i < 80; ++i) W[i] = rotl1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16])
25918
25919 for (var j = 0; j < 80; ++j) {
25920 var s = ~~(j / 20)
25921 var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0
25922
25923 e = d
25924 d = c
25925 c = rotl30(b)
25926 b = a
25927 a = t
25928 }
25929
25930 this._a = (a + this._a) | 0
25931 this._b = (b + this._b) | 0
25932 this._c = (c + this._c) | 0
25933 this._d = (d + this._d) | 0
25934 this._e = (e + this._e) | 0
25935}
25936
25937Sha1.prototype._hash = function () {
25938 var H = Buffer.allocUnsafe(20)
25939
25940 H.writeInt32BE(this._a | 0, 0)
25941 H.writeInt32BE(this._b | 0, 4)
25942 H.writeInt32BE(this._c | 0, 8)
25943 H.writeInt32BE(this._d | 0, 12)
25944 H.writeInt32BE(this._e | 0, 16)
25945
25946 return H
25947}
25948
25949module.exports = Sha1
25950
25951},{"./hash":164,"inherits":107,"safe-buffer":156}],168:[function(require,module,exports){
25952/**
25953 * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
25954 * in FIPS 180-2
25955 * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
25956 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
25957 *
25958 */
25959
25960var inherits = require('inherits')
25961var Sha256 = require('./sha256')
25962var Hash = require('./hash')
25963var Buffer = require('safe-buffer').Buffer
25964
25965var W = new Array(64)
25966
25967function Sha224 () {
25968 this.init()
25969
25970 this._w = W // new Array(64)
25971
25972 Hash.call(this, 64, 56)
25973}
25974
25975inherits(Sha224, Sha256)
25976
25977Sha224.prototype.init = function () {
25978 this._a = 0xc1059ed8
25979 this._b = 0x367cd507
25980 this._c = 0x3070dd17
25981 this._d = 0xf70e5939
25982 this._e = 0xffc00b31
25983 this._f = 0x68581511
25984 this._g = 0x64f98fa7
25985 this._h = 0xbefa4fa4
25986
25987 return this
25988}
25989
25990Sha224.prototype._hash = function () {
25991 var H = Buffer.allocUnsafe(28)
25992
25993 H.writeInt32BE(this._a, 0)
25994 H.writeInt32BE(this._b, 4)
25995 H.writeInt32BE(this._c, 8)
25996 H.writeInt32BE(this._d, 12)
25997 H.writeInt32BE(this._e, 16)
25998 H.writeInt32BE(this._f, 20)
25999 H.writeInt32BE(this._g, 24)
26000
26001 return H
26002}
26003
26004module.exports = Sha224
26005
26006},{"./hash":164,"./sha256":169,"inherits":107,"safe-buffer":156}],169:[function(require,module,exports){
26007/**
26008 * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
26009 * in FIPS 180-2
26010 * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
26011 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
26012 *
26013 */
26014
26015var inherits = require('inherits')
26016var Hash = require('./hash')
26017var Buffer = require('safe-buffer').Buffer
26018
26019var K = [
26020 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,
26021 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,
26022 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,
26023 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174,
26024 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC,
26025 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,
26026 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7,
26027 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967,
26028 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,
26029 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85,
26030 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3,
26031 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,
26032 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5,
26033 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3,
26034 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,
26035 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2
26036]
26037
26038var W = new Array(64)
26039
26040function Sha256 () {
26041 this.init()
26042
26043 this._w = W // new Array(64)
26044
26045 Hash.call(this, 64, 56)
26046}
26047
26048inherits(Sha256, Hash)
26049
26050Sha256.prototype.init = function () {
26051 this._a = 0x6a09e667
26052 this._b = 0xbb67ae85
26053 this._c = 0x3c6ef372
26054 this._d = 0xa54ff53a
26055 this._e = 0x510e527f
26056 this._f = 0x9b05688c
26057 this._g = 0x1f83d9ab
26058 this._h = 0x5be0cd19
26059
26060 return this
26061}
26062
26063function ch (x, y, z) {
26064 return z ^ (x & (y ^ z))
26065}
26066
26067function maj (x, y, z) {
26068 return (x & y) | (z & (x | y))
26069}
26070
26071function sigma0 (x) {
26072 return (x >>> 2 | x << 30) ^ (x >>> 13 | x << 19) ^ (x >>> 22 | x << 10)
26073}
26074
26075function sigma1 (x) {
26076 return (x >>> 6 | x << 26) ^ (x >>> 11 | x << 21) ^ (x >>> 25 | x << 7)
26077}
26078
26079function gamma0 (x) {
26080 return (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ (x >>> 3)
26081}
26082
26083function gamma1 (x) {
26084 return (x >>> 17 | x << 15) ^ (x >>> 19 | x << 13) ^ (x >>> 10)
26085}
26086
26087Sha256.prototype._update = function (M) {
26088 var W = this._w
26089
26090 var a = this._a | 0
26091 var b = this._b | 0
26092 var c = this._c | 0
26093 var d = this._d | 0
26094 var e = this._e | 0
26095 var f = this._f | 0
26096 var g = this._g | 0
26097 var h = this._h | 0
26098
26099 for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
26100 for (; i < 64; ++i) W[i] = (gamma1(W[i - 2]) + W[i - 7] + gamma0(W[i - 15]) + W[i - 16]) | 0
26101
26102 for (var j = 0; j < 64; ++j) {
26103 var T1 = (h + sigma1(e) + ch(e, f, g) + K[j] + W[j]) | 0
26104 var T2 = (sigma0(a) + maj(a, b, c)) | 0
26105
26106 h = g
26107 g = f
26108 f = e
26109 e = (d + T1) | 0
26110 d = c
26111 c = b
26112 b = a
26113 a = (T1 + T2) | 0
26114 }
26115
26116 this._a = (a + this._a) | 0
26117 this._b = (b + this._b) | 0
26118 this._c = (c + this._c) | 0
26119 this._d = (d + this._d) | 0
26120 this._e = (e + this._e) | 0
26121 this._f = (f + this._f) | 0
26122 this._g = (g + this._g) | 0
26123 this._h = (h + this._h) | 0
26124}
26125
26126Sha256.prototype._hash = function () {
26127 var H = Buffer.allocUnsafe(32)
26128
26129 H.writeInt32BE(this._a, 0)
26130 H.writeInt32BE(this._b, 4)
26131 H.writeInt32BE(this._c, 8)
26132 H.writeInt32BE(this._d, 12)
26133 H.writeInt32BE(this._e, 16)
26134 H.writeInt32BE(this._f, 20)
26135 H.writeInt32BE(this._g, 24)
26136 H.writeInt32BE(this._h, 28)
26137
26138 return H
26139}
26140
26141module.exports = Sha256
26142
26143},{"./hash":164,"inherits":107,"safe-buffer":156}],170:[function(require,module,exports){
26144var inherits = require('inherits')
26145var SHA512 = require('./sha512')
26146var Hash = require('./hash')
26147var Buffer = require('safe-buffer').Buffer
26148
26149var W = new Array(160)
26150
26151function Sha384 () {
26152 this.init()
26153 this._w = W
26154
26155 Hash.call(this, 128, 112)
26156}
26157
26158inherits(Sha384, SHA512)
26159
26160Sha384.prototype.init = function () {
26161 this._ah = 0xcbbb9d5d
26162 this._bh = 0x629a292a
26163 this._ch = 0x9159015a
26164 this._dh = 0x152fecd8
26165 this._eh = 0x67332667
26166 this._fh = 0x8eb44a87
26167 this._gh = 0xdb0c2e0d
26168 this._hh = 0x47b5481d
26169
26170 this._al = 0xc1059ed8
26171 this._bl = 0x367cd507
26172 this._cl = 0x3070dd17
26173 this._dl = 0xf70e5939
26174 this._el = 0xffc00b31
26175 this._fl = 0x68581511
26176 this._gl = 0x64f98fa7
26177 this._hl = 0xbefa4fa4
26178
26179 return this
26180}
26181
26182Sha384.prototype._hash = function () {
26183 var H = Buffer.allocUnsafe(48)
26184
26185 function writeInt64BE (h, l, offset) {
26186 H.writeInt32BE(h, offset)
26187 H.writeInt32BE(l, offset + 4)
26188 }
26189
26190 writeInt64BE(this._ah, this._al, 0)
26191 writeInt64BE(this._bh, this._bl, 8)
26192 writeInt64BE(this._ch, this._cl, 16)
26193 writeInt64BE(this._dh, this._dl, 24)
26194 writeInt64BE(this._eh, this._el, 32)
26195 writeInt64BE(this._fh, this._fl, 40)
26196
26197 return H
26198}
26199
26200module.exports = Sha384
26201
26202},{"./hash":164,"./sha512":171,"inherits":107,"safe-buffer":156}],171:[function(require,module,exports){
26203var inherits = require('inherits')
26204var Hash = require('./hash')
26205var Buffer = require('safe-buffer').Buffer
26206
26207var K = [
26208 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
26209 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
26210 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
26211 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
26212 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
26213 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
26214 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
26215 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
26216 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
26217 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
26218 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
26219 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
26220 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
26221 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
26222 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
26223 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
26224 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
26225 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
26226 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
26227 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
26228 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
26229 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
26230 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
26231 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
26232 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
26233 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
26234 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
26235 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
26236 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
26237 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
26238 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
26239 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
26240 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
26241 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
26242 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
26243 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
26244 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
26245 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
26246 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
26247 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
26248]
26249
26250var W = new Array(160)
26251
26252function Sha512 () {
26253 this.init()
26254 this._w = W
26255
26256 Hash.call(this, 128, 112)
26257}
26258
26259inherits(Sha512, Hash)
26260
26261Sha512.prototype.init = function () {
26262 this._ah = 0x6a09e667
26263 this._bh = 0xbb67ae85
26264 this._ch = 0x3c6ef372
26265 this._dh = 0xa54ff53a
26266 this._eh = 0x510e527f
26267 this._fh = 0x9b05688c
26268 this._gh = 0x1f83d9ab
26269 this._hh = 0x5be0cd19
26270
26271 this._al = 0xf3bcc908
26272 this._bl = 0x84caa73b
26273 this._cl = 0xfe94f82b
26274 this._dl = 0x5f1d36f1
26275 this._el = 0xade682d1
26276 this._fl = 0x2b3e6c1f
26277 this._gl = 0xfb41bd6b
26278 this._hl = 0x137e2179
26279
26280 return this
26281}
26282
26283function Ch (x, y, z) {
26284 return z ^ (x & (y ^ z))
26285}
26286
26287function maj (x, y, z) {
26288 return (x & y) | (z & (x | y))
26289}
26290
26291function sigma0 (x, xl) {
26292 return (x >>> 28 | xl << 4) ^ (xl >>> 2 | x << 30) ^ (xl >>> 7 | x << 25)
26293}
26294
26295function sigma1 (x, xl) {
26296 return (x >>> 14 | xl << 18) ^ (x >>> 18 | xl << 14) ^ (xl >>> 9 | x << 23)
26297}
26298
26299function Gamma0 (x, xl) {
26300 return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7)
26301}
26302
26303function Gamma0l (x, xl) {
26304 return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7 | xl << 25)
26305}
26306
26307function Gamma1 (x, xl) {
26308 return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6)
26309}
26310
26311function Gamma1l (x, xl) {
26312 return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6 | xl << 26)
26313}
26314
26315function getCarry (a, b) {
26316 return (a >>> 0) < (b >>> 0) ? 1 : 0
26317}
26318
26319Sha512.prototype._update = function (M) {
26320 var W = this._w
26321
26322 var ah = this._ah | 0
26323 var bh = this._bh | 0
26324 var ch = this._ch | 0
26325 var dh = this._dh | 0
26326 var eh = this._eh | 0
26327 var fh = this._fh | 0
26328 var gh = this._gh | 0
26329 var hh = this._hh | 0
26330
26331 var al = this._al | 0
26332 var bl = this._bl | 0
26333 var cl = this._cl | 0
26334 var dl = this._dl | 0
26335 var el = this._el | 0
26336 var fl = this._fl | 0
26337 var gl = this._gl | 0
26338 var hl = this._hl | 0
26339
26340 for (var i = 0; i < 32; i += 2) {
26341 W[i] = M.readInt32BE(i * 4)
26342 W[i + 1] = M.readInt32BE(i * 4 + 4)
26343 }
26344 for (; i < 160; i += 2) {
26345 var xh = W[i - 15 * 2]
26346 var xl = W[i - 15 * 2 + 1]
26347 var gamma0 = Gamma0(xh, xl)
26348 var gamma0l = Gamma0l(xl, xh)
26349
26350 xh = W[i - 2 * 2]
26351 xl = W[i - 2 * 2 + 1]
26352 var gamma1 = Gamma1(xh, xl)
26353 var gamma1l = Gamma1l(xl, xh)
26354
26355 // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
26356 var Wi7h = W[i - 7 * 2]
26357 var Wi7l = W[i - 7 * 2 + 1]
26358
26359 var Wi16h = W[i - 16 * 2]
26360 var Wi16l = W[i - 16 * 2 + 1]
26361
26362 var Wil = (gamma0l + Wi7l) | 0
26363 var Wih = (gamma0 + Wi7h + getCarry(Wil, gamma0l)) | 0
26364 Wil = (Wil + gamma1l) | 0
26365 Wih = (Wih + gamma1 + getCarry(Wil, gamma1l)) | 0
26366 Wil = (Wil + Wi16l) | 0
26367 Wih = (Wih + Wi16h + getCarry(Wil, Wi16l)) | 0
26368
26369 W[i] = Wih
26370 W[i + 1] = Wil
26371 }
26372
26373 for (var j = 0; j < 160; j += 2) {
26374 Wih = W[j]
26375 Wil = W[j + 1]
26376
26377 var majh = maj(ah, bh, ch)
26378 var majl = maj(al, bl, cl)
26379
26380 var sigma0h = sigma0(ah, al)
26381 var sigma0l = sigma0(al, ah)
26382 var sigma1h = sigma1(eh, el)
26383 var sigma1l = sigma1(el, eh)
26384
26385 // t1 = h + sigma1 + ch + K[j] + W[j]
26386 var Kih = K[j]
26387 var Kil = K[j + 1]
26388
26389 var chh = Ch(eh, fh, gh)
26390 var chl = Ch(el, fl, gl)
26391
26392 var t1l = (hl + sigma1l) | 0
26393 var t1h = (hh + sigma1h + getCarry(t1l, hl)) | 0
26394 t1l = (t1l + chl) | 0
26395 t1h = (t1h + chh + getCarry(t1l, chl)) | 0
26396 t1l = (t1l + Kil) | 0
26397 t1h = (t1h + Kih + getCarry(t1l, Kil)) | 0
26398 t1l = (t1l + Wil) | 0
26399 t1h = (t1h + Wih + getCarry(t1l, Wil)) | 0
26400
26401 // t2 = sigma0 + maj
26402 var t2l = (sigma0l + majl) | 0
26403 var t2h = (sigma0h + majh + getCarry(t2l, sigma0l)) | 0
26404
26405 hh = gh
26406 hl = gl
26407 gh = fh
26408 gl = fl
26409 fh = eh
26410 fl = el
26411 el = (dl + t1l) | 0
26412 eh = (dh + t1h + getCarry(el, dl)) | 0
26413 dh = ch
26414 dl = cl
26415 ch = bh
26416 cl = bl
26417 bh = ah
26418 bl = al
26419 al = (t1l + t2l) | 0
26420 ah = (t1h + t2h + getCarry(al, t1l)) | 0
26421 }
26422
26423 this._al = (this._al + al) | 0
26424 this._bl = (this._bl + bl) | 0
26425 this._cl = (this._cl + cl) | 0
26426 this._dl = (this._dl + dl) | 0
26427 this._el = (this._el + el) | 0
26428 this._fl = (this._fl + fl) | 0
26429 this._gl = (this._gl + gl) | 0
26430 this._hl = (this._hl + hl) | 0
26431
26432 this._ah = (this._ah + ah + getCarry(this._al, al)) | 0
26433 this._bh = (this._bh + bh + getCarry(this._bl, bl)) | 0
26434 this._ch = (this._ch + ch + getCarry(this._cl, cl)) | 0
26435 this._dh = (this._dh + dh + getCarry(this._dl, dl)) | 0
26436 this._eh = (this._eh + eh + getCarry(this._el, el)) | 0
26437 this._fh = (this._fh + fh + getCarry(this._fl, fl)) | 0
26438 this._gh = (this._gh + gh + getCarry(this._gl, gl)) | 0
26439 this._hh = (this._hh + hh + getCarry(this._hl, hl)) | 0
26440}
26441
26442Sha512.prototype._hash = function () {
26443 var H = Buffer.allocUnsafe(64)
26444
26445 function writeInt64BE (h, l, offset) {
26446 H.writeInt32BE(h, offset)
26447 H.writeInt32BE(l, offset + 4)
26448 }
26449
26450 writeInt64BE(this._ah, this._al, 0)
26451 writeInt64BE(this._bh, this._bl, 8)
26452 writeInt64BE(this._ch, this._cl, 16)
26453 writeInt64BE(this._dh, this._dl, 24)
26454 writeInt64BE(this._eh, this._el, 32)
26455 writeInt64BE(this._fh, this._fl, 40)
26456 writeInt64BE(this._gh, this._gl, 48)
26457 writeInt64BE(this._hh, this._hl, 56)
26458
26459 return H
26460}
26461
26462module.exports = Sha512
26463
26464},{"./hash":164,"inherits":107,"safe-buffer":156}],172:[function(require,module,exports){
26465// Copyright Joyent, Inc. and other Node contributors.
26466//
26467// Permission is hereby granted, free of charge, to any person obtaining a
26468// copy of this software and associated documentation files (the
26469// "Software"), to deal in the Software without restriction, including
26470// without limitation the rights to use, copy, modify, merge, publish,
26471// distribute, sublicense, and/or sell copies of the Software, and to permit
26472// persons to whom the Software is furnished to do so, subject to the
26473// following conditions:
26474//
26475// The above copyright notice and this permission notice shall be included
26476// in all copies or substantial portions of the Software.
26477//
26478// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
26479// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26480// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
26481// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
26482// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
26483// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
26484// USE OR OTHER DEALINGS IN THE SOFTWARE.
26485
26486module.exports = Stream;
26487
26488var EE = require('events').EventEmitter;
26489var inherits = require('inherits');
26490
26491inherits(Stream, EE);
26492Stream.Readable = require('readable-stream/readable.js');
26493Stream.Writable = require('readable-stream/writable.js');
26494Stream.Duplex = require('readable-stream/duplex.js');
26495Stream.Transform = require('readable-stream/transform.js');
26496Stream.PassThrough = require('readable-stream/passthrough.js');
26497
26498// Backwards-compat with node 0.4.x
26499Stream.Stream = Stream;
26500
26501
26502
26503// old-style streams. Note that the pipe method (the only relevant
26504// part of this class) is overridden in the Readable class.
26505
26506function Stream() {
26507 EE.call(this);
26508}
26509
26510Stream.prototype.pipe = function(dest, options) {
26511 var source = this;
26512
26513 function ondata(chunk) {
26514 if (dest.writable) {
26515 if (false === dest.write(chunk) && source.pause) {
26516 source.pause();
26517 }
26518 }
26519 }
26520
26521 source.on('data', ondata);
26522
26523 function ondrain() {
26524 if (source.readable && source.resume) {
26525 source.resume();
26526 }
26527 }
26528
26529 dest.on('drain', ondrain);
26530
26531 // If the 'end' option is not supplied, dest.end() will be called when
26532 // source gets the 'end' or 'close' events. Only dest.end() once.
26533 if (!dest._isStdio && (!options || options.end !== false)) {
26534 source.on('end', onend);
26535 source.on('close', onclose);
26536 }
26537
26538 var didOnEnd = false;
26539 function onend() {
26540 if (didOnEnd) return;
26541 didOnEnd = true;
26542
26543 dest.end();
26544 }
26545
26546
26547 function onclose() {
26548 if (didOnEnd) return;
26549 didOnEnd = true;
26550
26551 if (typeof dest.destroy === 'function') dest.destroy();
26552 }
26553
26554 // don't leave dangling pipes when there are errors.
26555 function onerror(er) {
26556 cleanup();
26557 if (EE.listenerCount(this, 'error') === 0) {
26558 throw er; // Unhandled stream error in pipe.
26559 }
26560 }
26561
26562 source.on('error', onerror);
26563 dest.on('error', onerror);
26564
26565 // remove all the event listeners that were added.
26566 function cleanup() {
26567 source.removeListener('data', ondata);
26568 dest.removeListener('drain', ondrain);
26569
26570 source.removeListener('end', onend);
26571 source.removeListener('close', onclose);
26572
26573 source.removeListener('error', onerror);
26574 dest.removeListener('error', onerror);
26575
26576 source.removeListener('end', cleanup);
26577 source.removeListener('close', cleanup);
26578
26579 dest.removeListener('close', cleanup);
26580 }
26581
26582 source.on('end', cleanup);
26583 source.on('close', cleanup);
26584
26585 dest.on('close', cleanup);
26586
26587 dest.emit('pipe', source);
26588
26589 // Allow for unix-like usage: A.pipe(B).pipe(C)
26590 return dest;
26591};
26592
26593},{"events":89,"inherits":107,"readable-stream/duplex.js":142,"readable-stream/passthrough.js":151,"readable-stream/readable.js":152,"readable-stream/transform.js":153,"readable-stream/writable.js":154}],173:[function(require,module,exports){
26594'use strict';
26595
26596var Buffer = require('safe-buffer').Buffer;
26597
26598var isEncoding = Buffer.isEncoding || function (encoding) {
26599 encoding = '' + encoding;
26600 switch (encoding && encoding.toLowerCase()) {
26601 case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':
26602 return true;
26603 default:
26604 return false;
26605 }
26606};
26607
26608function _normalizeEncoding(enc) {
26609 if (!enc) return 'utf8';
26610 var retried;
26611 while (true) {
26612 switch (enc) {
26613 case 'utf8':
26614 case 'utf-8':
26615 return 'utf8';
26616 case 'ucs2':
26617 case 'ucs-2':
26618 case 'utf16le':
26619 case 'utf-16le':
26620 return 'utf16le';
26621 case 'latin1':
26622 case 'binary':
26623 return 'latin1';
26624 case 'base64':
26625 case 'ascii':
26626 case 'hex':
26627 return enc;
26628 default:
26629 if (retried) return; // undefined
26630 enc = ('' + enc).toLowerCase();
26631 retried = true;
26632 }
26633 }
26634};
26635
26636// Do not cache `Buffer.isEncoding` when checking encoding names as some
26637// modules monkey-patch it to support additional encodings
26638function normalizeEncoding(enc) {
26639 var nenc = _normalizeEncoding(enc);
26640 if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
26641 return nenc || enc;
26642}
26643
26644// StringDecoder provides an interface for efficiently splitting a series of
26645// buffers into a series of JS strings without breaking apart multi-byte
26646// characters.
26647exports.StringDecoder = StringDecoder;
26648function StringDecoder(encoding) {
26649 this.encoding = normalizeEncoding(encoding);
26650 var nb;
26651 switch (this.encoding) {
26652 case 'utf16le':
26653 this.text = utf16Text;
26654 this.end = utf16End;
26655 nb = 4;
26656 break;
26657 case 'utf8':
26658 this.fillLast = utf8FillLast;
26659 nb = 4;
26660 break;
26661 case 'base64':
26662 this.text = base64Text;
26663 this.end = base64End;
26664 nb = 3;
26665 break;
26666 default:
26667 this.write = simpleWrite;
26668 this.end = simpleEnd;
26669 return;
26670 }
26671 this.lastNeed = 0;
26672 this.lastTotal = 0;
26673 this.lastChar = Buffer.allocUnsafe(nb);
26674}
26675
26676StringDecoder.prototype.write = function (buf) {
26677 if (buf.length === 0) return '';
26678 var r;
26679 var i;
26680 if (this.lastNeed) {
26681 r = this.fillLast(buf);
26682 if (r === undefined) return '';
26683 i = this.lastNeed;
26684 this.lastNeed = 0;
26685 } else {
26686 i = 0;
26687 }
26688 if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
26689 return r || '';
26690};
26691
26692StringDecoder.prototype.end = utf8End;
26693
26694// Returns only complete characters in a Buffer
26695StringDecoder.prototype.text = utf8Text;
26696
26697// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
26698StringDecoder.prototype.fillLast = function (buf) {
26699 if (this.lastNeed <= buf.length) {
26700 buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
26701 return this.lastChar.toString(this.encoding, 0, this.lastTotal);
26702 }
26703 buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
26704 this.lastNeed -= buf.length;
26705};
26706
26707// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
26708// continuation byte.
26709function utf8CheckByte(byte) {
26710 if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
26711 return -1;
26712}
26713
26714// Checks at most 3 bytes at the end of a Buffer in order to detect an
26715// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
26716// needed to complete the UTF-8 character (if applicable) are returned.
26717function utf8CheckIncomplete(self, buf, i) {
26718 var j = buf.length - 1;
26719 if (j < i) return 0;
26720 var nb = utf8CheckByte(buf[j]);
26721 if (nb >= 0) {
26722 if (nb > 0) self.lastNeed = nb - 1;
26723 return nb;
26724 }
26725 if (--j < i) return 0;
26726 nb = utf8CheckByte(buf[j]);
26727 if (nb >= 0) {
26728 if (nb > 0) self.lastNeed = nb - 2;
26729 return nb;
26730 }
26731 if (--j < i) return 0;
26732 nb = utf8CheckByte(buf[j]);
26733 if (nb >= 0) {
26734 if (nb > 0) {
26735 if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
26736 }
26737 return nb;
26738 }
26739 return 0;
26740}
26741
26742// Validates as many continuation bytes for a multi-byte UTF-8 character as
26743// needed or are available. If we see a non-continuation byte where we expect
26744// one, we "replace" the validated continuation bytes we've seen so far with
26745// UTF-8 replacement characters ('\ufffd'), to match v8's UTF-8 decoding
26746// behavior. The continuation byte check is included three times in the case
26747// where all of the continuation bytes for a character exist in the same buffer.
26748// It is also done this way as a slight performance increase instead of using a
26749// loop.
26750function utf8CheckExtraBytes(self, buf, p) {
26751 if ((buf[0] & 0xC0) !== 0x80) {
26752 self.lastNeed = 0;
26753 return '\ufffd'.repeat(p);
26754 }
26755 if (self.lastNeed > 1 && buf.length > 1) {
26756 if ((buf[1] & 0xC0) !== 0x80) {
26757 self.lastNeed = 1;
26758 return '\ufffd'.repeat(p + 1);
26759 }
26760 if (self.lastNeed > 2 && buf.length > 2) {
26761 if ((buf[2] & 0xC0) !== 0x80) {
26762 self.lastNeed = 2;
26763 return '\ufffd'.repeat(p + 2);
26764 }
26765 }
26766 }
26767}
26768
26769// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
26770function utf8FillLast(buf) {
26771 var p = this.lastTotal - this.lastNeed;
26772 var r = utf8CheckExtraBytes(this, buf, p);
26773 if (r !== undefined) return r;
26774 if (this.lastNeed <= buf.length) {
26775 buf.copy(this.lastChar, p, 0, this.lastNeed);
26776 return this.lastChar.toString(this.encoding, 0, this.lastTotal);
26777 }
26778 buf.copy(this.lastChar, p, 0, buf.length);
26779 this.lastNeed -= buf.length;
26780}
26781
26782// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
26783// partial character, the character's bytes are buffered until the required
26784// number of bytes are available.
26785function utf8Text(buf, i) {
26786 var total = utf8CheckIncomplete(this, buf, i);
26787 if (!this.lastNeed) return buf.toString('utf8', i);
26788 this.lastTotal = total;
26789 var end = buf.length - (total - this.lastNeed);
26790 buf.copy(this.lastChar, 0, end);
26791 return buf.toString('utf8', i, end);
26792}
26793
26794// For UTF-8, a replacement character for each buffered byte of a (partial)
26795// character needs to be added to the output.
26796function utf8End(buf) {
26797 var r = buf && buf.length ? this.write(buf) : '';
26798 if (this.lastNeed) return r + '\ufffd'.repeat(this.lastTotal - this.lastNeed);
26799 return r;
26800}
26801
26802// UTF-16LE typically needs two bytes per character, but even if we have an even
26803// number of bytes available, we need to check if we end on a leading/high
26804// surrogate. In that case, we need to wait for the next two bytes in order to
26805// decode the last character properly.
26806function utf16Text(buf, i) {
26807 if ((buf.length - i) % 2 === 0) {
26808 var r = buf.toString('utf16le', i);
26809 if (r) {
26810 var c = r.charCodeAt(r.length - 1);
26811 if (c >= 0xD800 && c <= 0xDBFF) {
26812 this.lastNeed = 2;
26813 this.lastTotal = 4;
26814 this.lastChar[0] = buf[buf.length - 2];
26815 this.lastChar[1] = buf[buf.length - 1];
26816 return r.slice(0, -1);
26817 }
26818 }
26819 return r;
26820 }
26821 this.lastNeed = 1;
26822 this.lastTotal = 2;
26823 this.lastChar[0] = buf[buf.length - 1];
26824 return buf.toString('utf16le', i, buf.length - 1);
26825}
26826
26827// For UTF-16LE we do not explicitly append special replacement characters if we
26828// end on a partial character, we simply let v8 handle that.
26829function utf16End(buf) {
26830 var r = buf && buf.length ? this.write(buf) : '';
26831 if (this.lastNeed) {
26832 var end = this.lastTotal - this.lastNeed;
26833 return r + this.lastChar.toString('utf16le', 0, end);
26834 }
26835 return r;
26836}
26837
26838function base64Text(buf, i) {
26839 var n = (buf.length - i) % 3;
26840 if (n === 0) return buf.toString('base64', i);
26841 this.lastNeed = 3 - n;
26842 this.lastTotal = 3;
26843 if (n === 1) {
26844 this.lastChar[0] = buf[buf.length - 1];
26845 } else {
26846 this.lastChar[0] = buf[buf.length - 2];
26847 this.lastChar[1] = buf[buf.length - 1];
26848 }
26849 return buf.toString('base64', i, buf.length - n);
26850}
26851
26852function base64End(buf) {
26853 var r = buf && buf.length ? this.write(buf) : '';
26854 if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
26855 return r;
26856}
26857
26858// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
26859function simpleWrite(buf) {
26860 return buf.toString(this.encoding);
26861}
26862
26863function simpleEnd(buf) {
26864 return buf && buf.length ? this.write(buf) : '';
26865}
26866},{"safe-buffer":156}],174:[function(require,module,exports){
26867(function (global){
26868
26869/**
26870 * Module exports.
26871 */
26872
26873module.exports = deprecate;
26874
26875/**
26876 * Mark that a method should not be used.
26877 * Returns a modified function which warns once by default.
26878 *
26879 * If `localStorage.noDeprecation = true` is set, then it is a no-op.
26880 *
26881 * If `localStorage.throwDeprecation = true` is set, then deprecated functions
26882 * will throw an Error when invoked.
26883 *
26884 * If `localStorage.traceDeprecation = true` is set, then deprecated functions
26885 * will invoke `console.trace()` instead of `console.error()`.
26886 *
26887 * @param {Function} fn - the function to deprecate
26888 * @param {String} msg - the string to print to the console when `fn` is invoked
26889 * @returns {Function} a new "deprecated" version of `fn`
26890 * @api public
26891 */
26892
26893function deprecate (fn, msg) {
26894 if (config('noDeprecation')) {
26895 return fn;
26896 }
26897
26898 var warned = false;
26899 function deprecated() {
26900 if (!warned) {
26901 if (config('throwDeprecation')) {
26902 throw new Error(msg);
26903 } else if (config('traceDeprecation')) {
26904 console.trace(msg);
26905 } else {
26906 console.warn(msg);
26907 }
26908 warned = true;
26909 }
26910 return fn.apply(this, arguments);
26911 }
26912
26913 return deprecated;
26914}
26915
26916/**
26917 * Checks `localStorage` for boolean values for the given `name`.
26918 *
26919 * @param {String} name
26920 * @returns {Boolean}
26921 * @api private
26922 */
26923
26924function config (name) {
26925 // accessing global.localStorage can trigger a DOMException in sandboxed iframes
26926 try {
26927 if (!global.localStorage) return false;
26928 } catch (_) {
26929 return false;
26930 }
26931 var val = global.localStorage[name];
26932 if (null == val) return false;
26933 return String(val).toLowerCase() === 'true';
26934}
26935
26936}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
26937},{}],175:[function(require,module,exports){
26938var v1 = require('./v1');
26939var v4 = require('./v4');
26940
26941var uuid = v4;
26942uuid.v1 = v1;
26943uuid.v4 = v4;
26944
26945module.exports = uuid;
26946
26947},{"./v1":178,"./v4":179}],176:[function(require,module,exports){
26948/**
26949 * Convert array of 16 byte values to UUID string format of the form:
26950 * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
26951 */
26952var byteToHex = [];
26953for (var i = 0; i < 256; ++i) {
26954 byteToHex[i] = (i + 0x100).toString(16).substr(1);
26955}
26956
26957function bytesToUuid(buf, offset) {
26958 var i = offset || 0;
26959 var bth = byteToHex;
26960 return bth[buf[i++]] + bth[buf[i++]] +
26961 bth[buf[i++]] + bth[buf[i++]] + '-' +
26962 bth[buf[i++]] + bth[buf[i++]] + '-' +
26963 bth[buf[i++]] + bth[buf[i++]] + '-' +
26964 bth[buf[i++]] + bth[buf[i++]] + '-' +
26965 bth[buf[i++]] + bth[buf[i++]] +
26966 bth[buf[i++]] + bth[buf[i++]] +
26967 bth[buf[i++]] + bth[buf[i++]];
26968}
26969
26970module.exports = bytesToUuid;
26971
26972},{}],177:[function(require,module,exports){
26973(function (global){
26974// Unique ID creation requires a high quality random # generator. In the
26975// browser this is a little complicated due to unknown quality of Math.random()
26976// and inconsistent support for the `crypto` API. We do the best we can via
26977// feature-detection
26978var rng;
26979
26980var crypto = global.crypto || global.msCrypto; // for IE 11
26981if (crypto && crypto.getRandomValues) {
26982 // WHATWG crypto RNG - http://wiki.whatwg.org/wiki/Crypto
26983 var rnds8 = new Uint8Array(16); // eslint-disable-line no-undef
26984 rng = function whatwgRNG() {
26985 crypto.getRandomValues(rnds8);
26986 return rnds8;
26987 };
26988}
26989
26990if (!rng) {
26991 // Math.random()-based (RNG)
26992 //
26993 // If all else fails, use Math.random(). It's fast, but is of unspecified
26994 // quality.
26995 var rnds = new Array(16);
26996 rng = function() {
26997 for (var i = 0, r; i < 16; i++) {
26998 if ((i & 0x03) === 0) r = Math.random() * 0x100000000;
26999 rnds[i] = r >>> ((i & 0x03) << 3) & 0xff;
27000 }
27001
27002 return rnds;
27003 };
27004}
27005
27006module.exports = rng;
27007
27008}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
27009},{}],178:[function(require,module,exports){
27010var rng = require('./lib/rng');
27011var bytesToUuid = require('./lib/bytesToUuid');
27012
27013// **`v1()` - Generate time-based UUID**
27014//
27015// Inspired by https://github.com/LiosK/UUID.js
27016// and http://docs.python.org/library/uuid.html
27017
27018// random #'s we need to init node and clockseq
27019var _seedBytes = rng();
27020
27021// Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
27022var _nodeId = [
27023 _seedBytes[0] | 0x01,
27024 _seedBytes[1], _seedBytes[2], _seedBytes[3], _seedBytes[4], _seedBytes[5]
27025];
27026
27027// Per 4.2.2, randomize (14 bit) clockseq
27028var _clockseq = (_seedBytes[6] << 8 | _seedBytes[7]) & 0x3fff;
27029
27030// Previous uuid creation time
27031var _lastMSecs = 0, _lastNSecs = 0;
27032
27033// See https://github.com/broofa/node-uuid for API details
27034function v1(options, buf, offset) {
27035 var i = buf && offset || 0;
27036 var b = buf || [];
27037
27038 options = options || {};
27039
27040 var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq;
27041
27042 // UUID timestamps are 100 nano-second units since the Gregorian epoch,
27043 // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
27044 // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
27045 // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
27046 var msecs = options.msecs !== undefined ? options.msecs : new Date().getTime();
27047
27048 // Per 4.2.1.2, use count of uuid's generated during the current clock
27049 // cycle to simulate higher resolution clock
27050 var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1;
27051
27052 // Time since last uuid creation (in msecs)
27053 var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs)/10000;
27054
27055 // Per 4.2.1.2, Bump clockseq on clock regression
27056 if (dt < 0 && options.clockseq === undefined) {
27057 clockseq = clockseq + 1 & 0x3fff;
27058 }
27059
27060 // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
27061 // time interval
27062 if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
27063 nsecs = 0;
27064 }
27065
27066 // Per 4.2.1.2 Throw error if too many uuids are requested
27067 if (nsecs >= 10000) {
27068 throw new Error('uuid.v1(): Can\'t create more than 10M uuids/sec');
27069 }
27070
27071 _lastMSecs = msecs;
27072 _lastNSecs = nsecs;
27073 _clockseq = clockseq;
27074
27075 // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
27076 msecs += 12219292800000;
27077
27078 // `time_low`
27079 var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
27080 b[i++] = tl >>> 24 & 0xff;
27081 b[i++] = tl >>> 16 & 0xff;
27082 b[i++] = tl >>> 8 & 0xff;
27083 b[i++] = tl & 0xff;
27084
27085 // `time_mid`
27086 var tmh = (msecs / 0x100000000 * 10000) & 0xfffffff;
27087 b[i++] = tmh >>> 8 & 0xff;
27088 b[i++] = tmh & 0xff;
27089
27090 // `time_high_and_version`
27091 b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
27092 b[i++] = tmh >>> 16 & 0xff;
27093
27094 // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
27095 b[i++] = clockseq >>> 8 | 0x80;
27096
27097 // `clock_seq_low`
27098 b[i++] = clockseq & 0xff;
27099
27100 // `node`
27101 var node = options.node || _nodeId;
27102 for (var n = 0; n < 6; ++n) {
27103 b[i + n] = node[n];
27104 }
27105
27106 return buf ? buf : bytesToUuid(b);
27107}
27108
27109module.exports = v1;
27110
27111},{"./lib/bytesToUuid":176,"./lib/rng":177}],179:[function(require,module,exports){
27112var rng = require('./lib/rng');
27113var bytesToUuid = require('./lib/bytesToUuid');
27114
27115function v4(options, buf, offset) {
27116 var i = buf && offset || 0;
27117
27118 if (typeof(options) == 'string') {
27119 buf = options == 'binary' ? new Array(16) : null;
27120 options = null;
27121 }
27122 options = options || {};
27123
27124 var rnds = options.random || (options.rng || rng)();
27125
27126 // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
27127 rnds[6] = (rnds[6] & 0x0f) | 0x40;
27128 rnds[8] = (rnds[8] & 0x3f) | 0x80;
27129
27130 // Copy bytes to buffer, if provided
27131 if (buf) {
27132 for (var ii = 0; ii < 16; ++ii) {
27133 buf[i + ii] = rnds[ii];
27134 }
27135 }
27136
27137 return buf || bytesToUuid(rnds);
27138}
27139
27140module.exports = v4;
27141
27142},{"./lib/bytesToUuid":176,"./lib/rng":177}],180:[function(require,module,exports){
27143var indexOf = require('indexof');
27144
27145var Object_keys = function (obj) {
27146 if (Object.keys) return Object.keys(obj)
27147 else {
27148 var res = [];
27149 for (var key in obj) res.push(key)
27150 return res;
27151 }
27152};
27153
27154var forEach = function (xs, fn) {
27155 if (xs.forEach) return xs.forEach(fn)
27156 else for (var i = 0; i < xs.length; i++) {
27157 fn(xs[i], i, xs);
27158 }
27159};
27160
27161var defineProp = (function() {
27162 try {
27163 Object.defineProperty({}, '_', {});
27164 return function(obj, name, value) {
27165 Object.defineProperty(obj, name, {
27166 writable: true,
27167 enumerable: false,
27168 configurable: true,
27169 value: value
27170 })
27171 };
27172 } catch(e) {
27173 return function(obj, name, value) {
27174 obj[name] = value;
27175 };
27176 }
27177}());
27178
27179var globals = ['Array', 'Boolean', 'Date', 'Error', 'EvalError', 'Function',
27180'Infinity', 'JSON', 'Math', 'NaN', 'Number', 'Object', 'RangeError',
27181'ReferenceError', 'RegExp', 'String', 'SyntaxError', 'TypeError', 'URIError',
27182'decodeURI', 'decodeURIComponent', 'encodeURI', 'encodeURIComponent', 'escape',
27183'eval', 'isFinite', 'isNaN', 'parseFloat', 'parseInt', 'undefined', 'unescape'];
27184
27185function Context() {}
27186Context.prototype = {};
27187
27188var Script = exports.Script = function NodeScript (code) {
27189 if (!(this instanceof Script)) return new Script(code);
27190 this.code = code;
27191};
27192
27193Script.prototype.runInContext = function (context) {
27194 if (!(context instanceof Context)) {
27195 throw new TypeError("needs a 'context' argument.");
27196 }
27197
27198 var iframe = document.createElement('iframe');
27199 if (!iframe.style) iframe.style = {};
27200 iframe.style.display = 'none';
27201
27202 document.body.appendChild(iframe);
27203
27204 var win = iframe.contentWindow;
27205 var wEval = win.eval, wExecScript = win.execScript;
27206
27207 if (!wEval && wExecScript) {
27208 // win.eval() magically appears when this is called in IE:
27209 wExecScript.call(win, 'null');
27210 wEval = win.eval;
27211 }
27212
27213 forEach(Object_keys(context), function (key) {
27214 win[key] = context[key];
27215 });
27216 forEach(globals, function (key) {
27217 if (context[key]) {
27218 win[key] = context[key];
27219 }
27220 });
27221
27222 var winKeys = Object_keys(win);
27223
27224 var res = wEval.call(win, this.code);
27225
27226 forEach(Object_keys(win), function (key) {
27227 // Avoid copying circular objects like `top` and `window` by only
27228 // updating existing context properties or new properties in the `win`
27229 // that was only introduced after the eval.
27230 if (key in context || indexOf(winKeys, key) === -1) {
27231 context[key] = win[key];
27232 }
27233 });
27234
27235 forEach(globals, function (key) {
27236 if (!(key in context)) {
27237 defineProp(context, key, win[key]);
27238 }
27239 });
27240
27241 document.body.removeChild(iframe);
27242
27243 return res;
27244};
27245
27246Script.prototype.runInThisContext = function () {
27247 return eval(this.code); // maybe...
27248};
27249
27250Script.prototype.runInNewContext = function (context) {
27251 var ctx = Script.createContext(context);
27252 var res = this.runInContext(ctx);
27253
27254 forEach(Object_keys(ctx), function (key) {
27255 context[key] = ctx[key];
27256 });
27257
27258 return res;
27259};
27260
27261forEach(Object_keys(Script.prototype), function (name) {
27262 exports[name] = Script[name] = function (code) {
27263 var s = Script(code);
27264 return s[name].apply(s, [].slice.call(arguments, 1));
27265 };
27266});
27267
27268exports.createScript = function (code) {
27269 return exports.Script(code);
27270};
27271
27272exports.createContext = Script.createContext = function (context) {
27273 var copy = new Context();
27274 if(typeof context === 'object') {
27275 forEach(Object_keys(context), function (key) {
27276 copy[key] = context[key];
27277 });
27278 }
27279 return copy;
27280};
27281
27282},{"indexof":106}],"nebulas-account":[function(require,module,exports){
27283"use strict";
27284
27285var Buffer = require('safe-buffer').Buffer;
27286var Base58 = require('bs58');
27287var cryptoUtils = require('./utils/crypto-utils.js');
27288var utils = require('./utils/utils.js');
27289
27290var AddressLength = 26;
27291var AddressPrefix = 25;
27292var NormalType = 87;
27293var ContractType = 88;
27294
27295var KeyVersion3 = 3;
27296var KeyCurrentVersion = 4;
27297
27298/**
27299 * @typedef {Object} KeyOptions
27300 * @property {Buffer} salt
27301 * @property {Buffer} iv
27302 * @property {String} kdf
27303 * @property {Number} dklen
27304 * @property {Number} c
27305 * @property {Number} n
27306 * @property {Number} r
27307 * @property {Number} p
27308 * @property {String} cipher
27309 * @property {Buffer} uuid
27310 * @global
27311 */
27312
27313/**
27314 * Key Object.
27315 * @typedef {Object} Key
27316 * @property {Number} version
27317 * @property {Buffer} id
27318 * @property {HexString} address
27319 * @property {Object} crypto
27320 * @global
27321 */
27322
27323/**
27324 * Account constructor.
27325 * Class encapsulate main operation with account entity.
27326 * @constructor
27327 *
27328 * @param {Hash} priv Account private key.
27329 * @param {String} path
27330 *
27331 * @example var account = new Account(new Buffer("ac3773e06ae74c0fa566b0e421d4e391333f31aef90b383f0c0e83e4873609d6", "hex") );
27332 *
27333 */
27334var Account = function (priv, path) {
27335 priv = priv || cryptoUtils.crypto.randomBytes(32);
27336 this.setPrivateKey(priv);
27337 this.path = path;
27338};
27339
27340/**
27341 * Account factory method.
27342 * Create random account.
27343 * @static
27344 *
27345 * @return {Account} Instance of Account constructor.
27346 *
27347 * @example var account = Account.NewAccount();
27348 */
27349Account.NewAccount = function () {
27350 return new Account(cryptoUtils.crypto.randomBytes(32));
27351};
27352
27353/**
27354 * Address validation method.
27355 *
27356 * @static
27357 * @param {String/Hash} addr - Account address.
27358 * @param {Number} type - NormalType / ContractType
27359 *
27360 * @return {Boolean} Is address has correct format.
27361 *
27362 * @example
27363 * if ( Account.isValidAddress("n1QZMXSZtW7BUerroSms4axNfyBGyFGkrh5") ) {
27364 * // some code
27365 * };
27366 */
27367Account.isValidAddress = function (addr, type) {
27368 /*jshint maxcomplexity:10 */
27369
27370 if (utils.isString(addr)) {
27371 try {
27372 addr = Base58.decode(addr);
27373 } catch (e) {
27374 console.log("invalid address.");
27375 // if address can't be base58 decode, return false.
27376 return false;
27377 }
27378 } else if (!Buffer.isBuffer(addr)) {
27379 return false;
27380 }
27381 // address not equal to 26
27382 if (addr.length !== AddressLength) {
27383 return false;
27384 }
27385
27386 // check if address start with AddressPrefix
27387 var buff = Buffer.from(addr);
27388 if (buff.readUIntBE(0, 1) !== AddressPrefix) {
27389 return false;
27390 }
27391
27392 // check if address type is NormalType or ContractType
27393 var t = buff.readUIntBE(1, 1);
27394 if (utils.isNumber(type) && (type === NormalType || type === ContractType)) {
27395 if (t !== type) {
27396 return false;
27397 }
27398 } else if (t !== NormalType && t !== ContractType) {
27399 return false;
27400 }
27401 var content = addr.slice(0, 22);
27402 var checksum = addr.slice(-4);
27403 return Buffer.compare(cryptoUtils.sha3(content).slice(0, 4), checksum) === 0;
27404};
27405
27406/**
27407 * Restore account from address.
27408 * Receive addr or Account instance.
27409 * If addr is Account instance return new Account instance with same PrivateKey.
27410 *
27411 * @static
27412 * @param {(Hash|Object)} - Client address or Account instance.
27413 *
27414 * @return {Account} Instance of Account restored from address.
27415 *
27416 * @example var account = Account.fromAddress("n1QZMXSZtW7BUerroSms4axNfyBGyFGkrh5");
27417 */
27418Account.fromAddress = function (addr) {
27419 var acc = new Account();
27420 if (addr instanceof Account) {
27421 acc.setPrivateKey(addr.getPrivateKey());
27422 return acc;
27423 }
27424 if (utils.isString(addr) && this.isValidAddress(addr)) {
27425 acc.address = Base58.decode(addr);
27426 return acc;
27427 }
27428
27429 var buf = cryptoUtils.toBuffer(addr);
27430 if (this.isValidAddress(buf)) {
27431 acc.address = buf;
27432 return acc;
27433 }
27434 throw new Error("invalid address");
27435};
27436
27437/**
27438 * Restore account from public key.
27439 *
27440 * @static
27441 * @param {(String/Hash)} - Public key.
27442 *
27443 * @return {Account} Instance of Account restored from address.
27444 *
27445 * @example var account = Account.fromPubKey("f18ec04019dd131bbcfada4020b001d547244d768f144ef947577ce53a13ad690eb43e4b02a8daa3c168045cd122c0685f083e1656756ba7982721322ebe4da7");
27446 */
27447Account.fromPubKey = function (publicKey) {
27448 var acc = new Account();
27449 acc.pubKey = cryptoUtils.toBuffer(publicKey);
27450 return acc;
27451};
27452
27453Account.getNormalType = function () {
27454 return NormalType;
27455};
27456
27457Account.getContractType = function () {
27458 return ContractType;
27459};
27460
27461Account.prototype = {
27462 /**
27463 * Private Key setter.
27464 *
27465 * @param {Hash} priv - Account private key.
27466 *
27467 * @example account.setPrivateKey("ac3773e06ae74c0fa566b0e421d4e391333f31aef90b383f0c0e83e4873609d6");
27468 */
27469 setPrivateKey: function (priv) {
27470 if (utils.isString(priv) || Buffer.isBuffer(priv)) {
27471 this.privKey = priv.length === 32 ? priv : Buffer(priv, 'hex');
27472 this.pubKey = null;
27473 this.address = null;
27474 }
27475 },
27476 /**
27477 * Private Key getter.
27478 *
27479 * @return {Buffer} Account private key.
27480 *
27481 * @example var privKey = account.getPrivateKey();
27482 * //<Buffer 5b ed 67 f9 9c b3 31 9e 0c 6f 6a 03 54 8b e3 c8 c5 2a 83 64 46 4f 88 6f> 24
27483 */
27484 getPrivateKey: function () {
27485 return this.privKey;
27486 },
27487 /**
27488 * Get Private Key in hex string format.
27489 *
27490 * @return {HexString} Account private key in String format.
27491 *
27492 * @example var privKey = account.getPrivateKeyString();
27493 * //"ac3773e06ae74c0fa566b0e421d4e391333f31aef90b383f0c0e83e4873609d6"
27494 */
27495 getPrivateKeyString: function () {
27496 return this.getPrivateKey().toString('hex');
27497 },
27498 /**
27499 * Public Key getter.
27500 *
27501 * @return {Buffer} Account public key.
27502 *
27503 * @example var publicKey = account.getPublicKey();
27504 * //<Buffer c0 96 aa 4e 66 c7 4a 9a c7 18 31 f1 24 72 2a c1 3e b5 df 7f 97 1b 13 1d 46 a2 8a e6 81 c6 1d 96 f7 07 d0 aa e9 a7 67 436b 68 af a8 f0 96 65 17 24 29 ... >
27505 */
27506 getPublicKey: function () {
27507 if (utils.isNull(this.pubKey)) {
27508 this.pubKey = cryptoUtils.privateToPublic(this.privKey);
27509 }
27510 return this.pubKey;
27511 },
27512 /**
27513 * Get Public Key in hex string format.
27514 *
27515 * @return {HexString} Account public key in String format.
27516 *
27517 * @example var publicKey = account.getPublicKey();
27518 * //"f18ec04019dd131bbcfada4020b001d547244d768f144ef947577ce53a13ad690eb43e4b02a8daa3c168045cd122c0685f083e1656756ba7982721322ebe4da7"
27519 */
27520 getPublicKeyString: function () {
27521 return this.getPublicKey().toString('hex');
27522 },
27523 /**
27524 * Accaunt address getter.
27525 *
27526 * @return {Buffer} Account address.
27527 *
27528 * @example var publicKey = account.getAddress();
27529 * //<Buffer 7f 87 83 58 46 96 12 7d 1a c0 57 1a 42 87 c6 25 36 08 ff 32 61 36 51 7c>
27530 */
27531 getAddress: function () {
27532 if (utils.isNull(this.address)) {
27533
27534 var pubKey = this.getPublicKey();
27535 if (pubKey.length !== 64) {
27536 pubKey = cryptoUtils.secp256k1.publicKeyConvert(pubKey, false).slice(1);
27537 }
27538
27539 // The uncompressed form consists of a 0x04 (in analogy to the DER OCTET STRING tag) plus
27540 // the concatenation of the binary representation of the X coordinate plus the binary
27541 // representation of the y coordinate of the public point.
27542 pubKey = Buffer.concat([cryptoUtils.toBuffer(4), pubKey]);
27543
27544 // Only take the lower 160bits of the hash
27545 var content = cryptoUtils.sha3(pubKey);
27546 content = cryptoUtils.ripemd160(content);
27547 // content = AddressPrefix + NormalType + content(local address only use normal type)
27548 content = Buffer.concat([cryptoUtils.toBuffer(AddressPrefix), cryptoUtils.toBuffer(NormalType), content]);
27549 var checksum = cryptoUtils.sha3(content).slice(0, 4);
27550 this.address = Buffer.concat([content, checksum]);
27551 }
27552 return this.address;
27553 },
27554 /**
27555 * Get account address in hex string format.
27556 *
27557 * @return {HexString} Account address in String format.
27558 *
27559 * @example var publicKey = account.getAddressString();
27560 * //"802d529bf55d6693b3ac72c59b4a7d159da53cae5a7bf99c"
27561 */
27562 getAddressString: function () {
27563 var addr = this.getAddress();
27564 return Base58.encode(addr);
27565 },
27566 /**
27567 * Generate key buy passphrase and options.
27568 *
27569 * @param {Password} password - Provided password.
27570 * @param {KeyOptions} opts - Key options.
27571 *
27572 * @return {Key} Key Object.
27573 *
27574 * @example var key = account.toKey("passphrase");
27575 */
27576 toKey: function (password, opts) {
27577 /*jshint maxcomplexity:17 */
27578
27579 opts = opts || {};
27580 var salt = opts.salt || cryptoUtils.crypto.randomBytes(32);
27581 var iv = opts.iv || cryptoUtils.crypto.randomBytes(16);
27582 var derivedKey;
27583 var kdf = opts.kdf || 'scrypt';
27584 var kdfparams = {
27585 dklen: opts.dklen || 32,
27586 salt: salt.toString('hex')
27587 };
27588 if (kdf === 'pbkdf2') {
27589 kdfparams.c = opts.c || 262144;
27590 kdfparams.prf = 'hmac-sha256';
27591 derivedKey = cryptoUtils.crypto.pbkdf2Sync(new Buffer(password), salt, kdfparams.c, kdfparams.dklen, 'sha256');
27592 } else if (kdf === 'scrypt') {
27593 kdfparams.n = opts.n || 4096;
27594 kdfparams.r = opts.r || 8;
27595 kdfparams.p = opts.p || 1;
27596 derivedKey = cryptoUtils.scrypt(new Buffer(password), salt, kdfparams.n, kdfparams.r, kdfparams.p, kdfparams.dklen);
27597 } else {
27598 throw new Error('Unsupported kdf');
27599 }
27600 var cipher = cryptoUtils.crypto.createCipheriv(opts.cipher || 'aes-128-ctr', derivedKey.slice(0, 16), iv);
27601 if (!cipher) {
27602 throw new Error('Unsupported cipher');
27603 }
27604 var ciphertext = Buffer.concat([cipher.update(this.privKey), cipher.final()]);
27605 // var mac = cryptoUtils.sha3(Buffer.concat([derivedKey.slice(16, 32), new Buffer(ciphertext, 'hex')])); // KeyVersion3 deprecated
27606 var mac = cryptoUtils.sha3(Buffer.concat([derivedKey.slice(16, 32), new Buffer(ciphertext, 'hex'), iv, new Buffer(opts.cipher || 'aes-128-ctr')]));
27607 return {
27608 version: KeyCurrentVersion,
27609 id: cryptoUtils.uuid.v4({
27610 random: opts.uuid || cryptoUtils.crypto.randomBytes(16)
27611 }),
27612 address: this.getAddressString(),
27613 crypto: {
27614 ciphertext: ciphertext.toString('hex'),
27615 cipherparams: {
27616 iv: iv.toString('hex')
27617 },
27618 cipher: opts.cipher || 'aes-128-ctr',
27619 kdf: kdf,
27620 kdfparams: kdfparams,
27621 mac: mac.toString('hex'),
27622 machash: "sha3256"
27623 }
27624 };
27625 },
27626 /**
27627 * Generate key buy passphrase and options.
27628 * Return in JSON format.
27629 *
27630 * @param {Password} password - Provided password.
27631 * @param {KeyOptions} opts - Key options.
27632 *
27633 * @return {String} JSON stringify Key.
27634 *
27635 * @example var key = account.toKeyString("passphrase");
27636 */
27637 toKeyString: function (password, opts) {
27638 return JSON.stringify(this.toKey(password, opts));
27639 },
27640 /**
27641 * Restore account from key and passphrase.
27642 *
27643 * @param {Key} input - Key Object.
27644 * @param {Password} password - Provided password.
27645 * @param {Boolean} nonStrict - Strict сase sensitivity flag.
27646 *
27647 * @return {@link Account} - Instance of Account restored from key and passphrase.
27648 */
27649 fromKey: function (input, password, nonStrict) {
27650 /*jshint maxcomplexity:10 */
27651
27652 var json = typeof input === 'object' ? input : JSON.parse(nonStrict ? input.toLowerCase() : input);
27653 if (json.version !== KeyVersion3 && json.version !== KeyCurrentVersion) {
27654 throw new Error('Not supported wallet version');
27655 }
27656 var derivedKey;
27657 var kdfparams;
27658 if (json.crypto.kdf === 'scrypt') {
27659 kdfparams = json.crypto.kdfparams;
27660 derivedKey = cryptoUtils.scrypt(new Buffer(password), new Buffer(kdfparams.salt, 'hex'), kdfparams.n, kdfparams.r, kdfparams.p, kdfparams.dklen);
27661 } else if (json.crypto.kdf === 'pbkdf2') {
27662 kdfparams = json.crypto.kdfparams;
27663 if (kdfparams.prf !== 'hmac-sha256') {
27664 throw new Error('Unsupported parameters to PBKDF2');
27665 }
27666 derivedKey = cryptoUtils.crypto.pbkdf2Sync(new Buffer(password), new Buffer(kdfparams.salt, 'hex'), kdfparams.c, kdfparams.dklen, 'sha256');
27667 } else {
27668 throw new Error('Unsupported key derivation scheme');
27669 }
27670 var ciphertext = new Buffer(json.crypto.ciphertext, 'hex');
27671 var mac;
27672
27673 if (json.version === KeyCurrentVersion) {
27674 mac = cryptoUtils.sha3(Buffer.concat([derivedKey.slice(16, 32), ciphertext, new Buffer(json.crypto.cipherparams.iv, 'hex'), new Buffer(json.crypto.cipher)]));
27675 } else {
27676 // KeyVersion3
27677 mac = cryptoUtils.sha3(Buffer.concat([derivedKey.slice(16, 32), ciphertext]));
27678 }
27679
27680 if (mac.toString('hex') !== json.crypto.mac) {
27681 throw new Error('Key derivation failed - possibly wrong passphrase');
27682 }
27683 var decipher = cryptoUtils.crypto.createDecipheriv(json.crypto.cipher, derivedKey.slice(0, 16), new Buffer(json.crypto.cipherparams.iv, 'hex'));
27684 var seed = Buffer.concat([decipher.update(ciphertext), decipher.final()]);
27685 while (seed.length < 32) {
27686 var nullBuff = new Buffer([0x00]);
27687 seed = Buffer.concat([nullBuff, seed]);
27688 }
27689 this.setPrivateKey(seed);
27690 return this;
27691 }
27692
27693};
27694
27695module.exports = Account;
27696
27697},{"./utils/crypto-utils.js":1,"./utils/utils.js":2,"bs58":51,"safe-buffer":156}]},{},[]);
diff --git a/src/js/ripple-util.js b/src/js/ripple-util.js
index 8184a76..f26a93a 100644
--- a/src/js/ripple-util.js
+++ b/src/js/ripple-util.js
@@ -6,5 +6,5 @@ function convertRippleAdrr(address) {
6 6
7function convertRipplePriv(priv) { 7function convertRipplePriv(priv) {
8 return window.basex('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz').decode(priv).toString("hex").slice(2,66) 8 return window.basex('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz').decode(priv).toString("hex").slice(2,66)
9} 9}
10 10
diff --git a/src/js/segwit-parameters.js b/src/js/segwit-parameters.js
index dbb7572..58c9f95 100644
--- a/src/js/segwit-parameters.js
+++ b/src/js/segwit-parameters.js
@@ -161,11 +161,11 @@ bitcoinjs.bitcoin.networks.bgold.p2wpkhInP2sh = {
161 161
162bitcoinjs.bitcoin.networks.digibyte.p2wpkh = { 162bitcoinjs.bitcoin.networks.digibyte.p2wpkh = {
163 baseNetwork: "digibyte", 163 baseNetwork: "digibyte",
164 messagePrefix: '\x18DigiByte Signed Message:\n', 164 messagePrefix: 'x19DigiByte Signed Message:\n',
165 bech32: 'dgb', 165 bech32: 'dgb',
166 bip32: { 166 bip32: {
167 public: 0x0488B21E, 167 public: 0x04b24746,
168 private: 0x0488ADE4 168 private: 0x04b2430c
169 }, 169 },
170 pubKeyHash: 0x1e, 170 pubKeyHash: 0x1e,
171 scriptHash: 0x3f, 171 scriptHash: 0x3f,
@@ -173,15 +173,146 @@ bitcoinjs.bitcoin.networks.digibyte.p2wpkh = {
173}; 173};
174 174
175bitcoinjs.bitcoin.networks.digibyte.p2wpkhInP2sh = { 175bitcoinjs.bitcoin.networks.digibyte.p2wpkhInP2sh = {
176 baseNetwork: "digibyte", 176 baseNetwork: "digibyte",
177 messagePrefix: '\x18DigiByte Signed Message:\n', 177 messagePrefix: '\x19DigiByte Signed Message:\n',
178 bech32: 'dgb', 178 bech32: 'dgb',
179 bip32: { 179 bip32: {
180 public: 0x0488B21E, 180 public: 0x049d7cb2,
181 private: 0x0488ADE4 181 private: 0x049d7878
182 }, 182 },
183 pubKeyHash: 0x1e, 183 pubKeyHash: 0x1e,
184 scriptHash: 0x3f, 184 scriptHash: 0x3f,
185 wif: 0x80 185 wif: 0x80
186}; 186};
187
188bitcoinjs.bitcoin.networks.blockstamp.p2wpkh = {
189 baseNetwork: "blockstamp",
190 messagePrefix: '\x18BlockStamp Signed Message:\n',
191 bech32: 'bc',
192 bip32: {
193 public: 0x0488B21E,
194 private: 0x0488ADE4,
195 },
196 pubKeyHash: 0x00,
197 scriptHash: 0x05,
198 wif: 0x80,
199};
200
201bitcoinjs.bitcoin.networks.blockstamp.p2wpkhInP2sh = {
202 baseNetwork: "blockstamp",
203 messagePrefix: '\x18BlockStamp Signed Message:\n',
204 bech32: 'bc',
205 bip32: {
206 public: 0x0488B21E,
207 private: 0x0488ADE4,
208 },
209 pubKeyHash: 0x00,
210 scriptHash: 0x05,
211 wif: 0x80,
212};
213
214bitcoinjs.bitcoin.networks.nix.p2wpkh = {
215 baseNetwork: "nix",
216 messagePrefix: '\x18Nix Signed Message:\n',
217 bech32: 'nix',
218 bip32: {
219 public: 0x0488b21e,
220 private: 0x0488ade4,
221 },
222 pubKeyHash: 0x26,
223 scriptHash: 0x35,
224 wif: 0x80,
225};
226
227bitcoinjs.bitcoin.networks.nix.p2wpkhInP2sh = {
228 baseNetwork: "nix",
229 messagePrefix: '\x18Nix Signed Message:\n',
230 bech32: 'nix',
231 bip32: {
232 public: 0x0488b21e,
233 private: 0x0488ade4,
234 },
235 pubKeyHash: 0x26,
236 scriptHash: 0x35,
237 wif: 0x80,
238};
239
240bitcoinjs.bitcoin.networks.cpuchain.p2wpkh = {
241 baseNetwork: "cpuchain",
242 messagePrefix: '\x1DCPUchain Signed Message:\n',
243 bech32: 'cpu',
244 bip32: {
245 public: 0x04b24746,
246 private: 0x04b2430c
247 },
248 pubKeyHash: 0x1c,
249 scriptHash: 0x1e,
250 wif: 0x80,
251};
252
253bitcoinjs.bitcoin.networks.cpuchain.p2wpkhInP2sh = {
254 baseNetwork: "cpuchain",
255 messagePrefix: '\x1DCPUchain Signed Message:\n',
256 bech32: 'cpu',
257 bip32: {
258 public: 0x049d7cb2,
259 private: 0x049d7878
260 },
261 pubKeyHash: 0x1c,
262 scriptHash: 0x1e,
263 wif: 0x80,
264};
265
266bitcoinjs.bitcoin.networks.groestlcoin.p2wpkh = {
267 baseNetwork: "groestlcoin",
268 messagePrefix: '\x19GroestlCoin Signed Message:\n',
269 bech32: 'grs',
270 bip32: {
271 public: 0x04b24746,
272 private: 0x04b2430c
273 },
274 pubKeyHash: 0x24,
275 scriptHash: 0x05,
276 wif: 0x80,
277};
278
279bitcoinjs.bitcoin.networks.groestlcointestnet.p2wpkh = {
280 baseNetwork: "groestlcointestnet",
281 messagePrefix: '\x19GroestlCoin Signed Message:\n',
282 bech32: 'tgrs',
283 bip32: {
284 public: 0x045f1cf6,
285 private: 0x045f18bc
286 },
287 pubKeyHash: 0x6f,
288 scriptHash: 0xc4,
289 wif: 0xef
290};
291
292bitcoinjs.bitcoin.networks.groestlcoin.p2wpkhInP2sh = {
293 baseNetwork: "groestlcoin",
294 messagePrefix: '\x19GroestlCoin Signed Message:\n',
295 bech32: 'grs',
296 bip32: {
297 public: 0x049d7cb2,
298 private: 0x049d7878
299 },
300 pubKeyHash: 0x24,
301 scriptHash: 0x05,
302 wif: 0x80,
303};
304
305bitcoinjs.bitcoin.networks.groestlcointestnet.p2wpkhInP2sh = {
306 baseNetwork: "groestlcointestnet",
307 messagePrefix: '\x19GroestlCoin Signed Message:\n',
308 bech32: 'tgrs',
309 bip32: {
310 public: 0x044a5262,
311 private: 0x044a4e28
312 },
313 pubKeyHash: 0x6f,
314 scriptHash: 0xc4,
315 wif: 0xef
316};
317
187})(); 318})();
diff --git a/src/js/sjcl-bip39.js b/src/js/sjcl-bip39.js
index 537e3b8..447b565 100644
--- a/src/js/sjcl-bip39.js
+++ b/src/js/sjcl-bip39.js
@@ -26,13 +26,13 @@ var sjcl = {
26 26
27 /** @namespace Key exchange functions. Right now only SRP is implemented. */ 27 /** @namespace Key exchange functions. Right now only SRP is implemented. */
28 keyexchange: {}, 28 keyexchange: {},
29 29
30 /** @namespace Block cipher modes of operation. */ 30 /** @namespace Block cipher modes of operation. */
31 mode: {}, 31 mode: {},
32 32
33 /** @namespace Miscellaneous. HMAC and PBKDF2. */ 33 /** @namespace Miscellaneous. HMAC and PBKDF2. */
34 misc: {}, 34 misc: {},
35 35
36 /** 36 /**
37 * @namespace Bit array encoders and decoders. 37 * @namespace Bit array encoders and decoders.
38 * 38 *
@@ -43,7 +43,7 @@ var sjcl = {
43 * the method names are "fromBits" and "toBits". 43 * the method names are "fromBits" and "toBits".
44 */ 44 */
45 codec: {}, 45 codec: {},
46 46
47 /** @namespace Exceptions. */ 47 /** @namespace Exceptions. */
48 exception: { 48 exception: {
49 /** @constructor Ciphertext is corrupt. */ 49 /** @constructor Ciphertext is corrupt. */
@@ -51,13 +51,13 @@ var sjcl = {
51 this.toString = function() { return "CORRUPT: "+this.message; }; 51 this.toString = function() { return "CORRUPT: "+this.message; };
52 this.message = message; 52 this.message = message;
53 }, 53 },
54 54
55 /** @constructor Invalid parameter. */ 55 /** @constructor Invalid parameter. */
56 invalid: function(message) { 56 invalid: function(message) {
57 this.toString = function() { return "INVALID: "+this.message; }; 57 this.toString = function() { return "INVALID: "+this.message; };
58 this.message = message; 58 this.message = message;
59 }, 59 },
60 60
61 /** @constructor Bug or missing feature in SJCL. @constructor */ 61 /** @constructor Bug or missing feature in SJCL. @constructor */
62 bug: function(message) { 62 bug: function(message) {
63 this.toString = function() { return "BUG: "+this.message; }; 63 this.toString = function() { return "BUG: "+this.message; };
@@ -159,7 +159,7 @@ sjcl.bitArray = {
159 if (a1.length === 0 || a2.length === 0) { 159 if (a1.length === 0 || a2.length === 0) {
160 return a1.concat(a2); 160 return a1.concat(a2);
161 } 161 }
162 162
163 var last = a1[a1.length-1], shift = sjcl.bitArray.getPartial(last); 163 var last = a1[a1.length-1], shift = sjcl.bitArray.getPartial(last);
164 if (shift === 32) { 164 if (shift === 32) {
165 return a1.concat(a2); 165 return a1.concat(a2);
@@ -245,7 +245,7 @@ sjcl.bitArray = {
245 _shiftRight: function (a, shift, carry, out) { 245 _shiftRight: function (a, shift, carry, out) {
246 var i, last2=0, shift2; 246 var i, last2=0, shift2;
247 if (out === undefined) { out = []; } 247 if (out === undefined) { out = []; }
248 248
249 for (; shift >= 32; shift -= 32) { 249 for (; shift >= 32; shift -= 32) {
250 out.push(carry); 250 out.push(carry);
251 carry = 0; 251 carry = 0;
@@ -253,7 +253,7 @@ sjcl.bitArray = {
253 if (shift === 0) { 253 if (shift === 0) {
254 return out.concat(a); 254 return out.concat(a);
255 } 255 }
256 256
257 for (i=0; i<a.length; i++) { 257 for (i=0; i<a.length; i++) {
258 out.push(carry | a[i]>>>shift); 258 out.push(carry | a[i]>>>shift);
259 carry = a[i] << (32-shift); 259 carry = a[i] << (32-shift);
@@ -263,7 +263,7 @@ sjcl.bitArray = {
263 out.push(sjcl.bitArray.partial(shift+shift2 & 31, (shift + shift2 > 32) ? carry : out.pop(),1)); 263 out.push(sjcl.bitArray.partial(shift+shift2 & 31, (shift + shift2 > 32) ? carry : out.pop(),1));
264 return out; 264 return out;
265 }, 265 },
266 266
267 /** xor a block of 4 words together. 267 /** xor a block of 4 words together.
268 * @private 268 * @private
269 */ 269 */
@@ -295,7 +295,7 @@ sjcl.bitArray = {
295 * @author Mike Hamburg 295 * @author Mike Hamburg
296 * @author Dan Boneh 296 * @author Dan Boneh
297 */ 297 */
298 298
299/** @namespace UTF-8 strings */ 299/** @namespace UTF-8 strings */
300sjcl.codec.utf8String = { 300sjcl.codec.utf8String = {
301 /** Convert from a bitArray to a UTF-8 string. */ 301 /** Convert from a bitArray to a UTF-8 string. */
@@ -310,7 +310,7 @@ sjcl.codec.utf8String = {
310 } 310 }
311 return decodeURIComponent(escape(out)); 311 return decodeURIComponent(escape(out));
312 }, 312 },
313 313
314 /** Convert from a UTF-8 string to a bitArray. */ 314 /** Convert from a UTF-8 string to a bitArray. */
315 toBits: function (str) { 315 toBits: function (str) {
316 str = unescape(encodeURIComponent(str)); 316 str = unescape(encodeURIComponent(str));
@@ -412,7 +412,7 @@ sjcl.hash.sha512.prototype = {
412 * @constant 412 * @constant
413 */ 413 */
414 blockSize: 1024, 414 blockSize: 1024,
415 415
416 /** 416 /**
417 * Reset the hash state. 417 * Reset the hash state.
418 * @return this 418 * @return this
@@ -423,7 +423,7 @@ sjcl.hash.sha512.prototype = {
423 this._length = 0; 423 this._length = 0;
424 return this; 424 return this;
425 }, 425 },
426 426
427 /** 427 /**
428 * Input several words to the hash. 428 * Input several words to the hash.
429 * @param {bitArray|String} data the data to hash. 429 * @param {bitArray|String} data the data to hash.
@@ -441,7 +441,7 @@ sjcl.hash.sha512.prototype = {
441 } 441 }
442 return this; 442 return this;
443 }, 443 },
444 444
445 /** 445 /**
446 * Complete hashing and output the hash value. 446 * Complete hashing and output the hash value.
447 * @return {bitArray} The hash value, an array of 16 big-endian words. 447 * @return {bitArray} The hash value, an array of 16 big-endian words.
@@ -736,12 +736,12 @@ sjcl.misc.hmac = function (key, Hash) {
736 if (key.length > bs) { 736 if (key.length > bs) {
737 key = Hash.hash(key); 737 key = Hash.hash(key);
738 } 738 }
739 739
740 for (i=0; i<bs; i++) { 740 for (i=0; i<bs; i++) {
741 exKey[0][i] = key[i]^0x36363636; 741 exKey[0][i] = key[i]^0x36363636;
742 exKey[1][i] = key[i]^0x5C5C5C5C; 742 exKey[1][i] = key[i]^0x5C5C5C5C;
743 } 743 }
744 744
745 this._baseHash[0].update(exKey[0]); 745 this._baseHash[0].update(exKey[0]);
746 this._baseHash[1].update(exKey[1]); 746 this._baseHash[1].update(exKey[1]);
747 this._resultHash = new Hash(this._baseHash[0]); 747 this._resultHash = new Hash(this._baseHash[0]);
@@ -804,34 +804,34 @@ sjcl.misc.hmac.prototype.digest = function () {
804 */ 804 */
805sjcl.misc.pbkdf2 = function (password, salt, count, length, Prff) { 805sjcl.misc.pbkdf2 = function (password, salt, count, length, Prff) {
806 count = count || 1000; 806 count = count || 1000;
807 807
808 if (length < 0 || count < 0) { 808 if (length < 0 || count < 0) {
809 throw sjcl.exception.invalid("invalid params to pbkdf2"); 809 throw sjcl.exception.invalid("invalid params to pbkdf2");
810 } 810 }
811 811
812 if (typeof password === "string") { 812 if (typeof password === "string") {
813 password = sjcl.codec.utf8String.toBits(password); 813 password = sjcl.codec.utf8String.toBits(password);
814 } 814 }
815 815
816 if (typeof salt === "string") { 816 if (typeof salt === "string") {
817 salt = sjcl.codec.utf8String.toBits(salt); 817 salt = sjcl.codec.utf8String.toBits(salt);
818 } 818 }
819 819
820 Prff = Prff || sjcl.misc.hmac; 820 Prff = Prff || sjcl.misc.hmac;
821 821
822 var prf = new Prff(password), 822 var prf = new Prff(password),
823 u, ui, i, j, k, out = [], b = sjcl.bitArray; 823 u, ui, i, j, k, out = [], b = sjcl.bitArray;
824 824
825 for (k = 1; 32 * out.length < (length || 1); k++) { 825 for (k = 1; 32 * out.length < (length || 1); k++) {
826 u = ui = prf.encrypt(b.concat(salt,[k])); 826 u = ui = prf.encrypt(b.concat(salt,[k]));
827 827
828 for (i=1; i<count; i++) { 828 for (i=1; i<count; i++) {
829 ui = prf.encrypt(ui); 829 ui = prf.encrypt(ui);
830 for (j=0; j<ui.length; j++) { 830 for (j=0; j<ui.length; j++) {
831 u[j] ^= ui[j]; 831 u[j] ^= ui[j];
832 } 832 }
833 } 833 }
834 834
835 out = out.concat(u); 835 out = out.concat(u);
836 } 836 }
837 837
@@ -890,7 +890,7 @@ sjcl.hash.sha256.prototype = {
890 * @constant 890 * @constant
891 */ 891 */
892 blockSize: 512, 892 blockSize: 512,
893 893
894 /** 894 /**
895 * Reset the hash state. 895 * Reset the hash state.
896 * @return this 896 * @return this
@@ -901,7 +901,7 @@ sjcl.hash.sha256.prototype = {
901 this._length = 0; 901 this._length = 0;
902 return this; 902 return this;
903 }, 903 },
904 904
905 /** 905 /**
906 * Input several words to the hash. 906 * Input several words to the hash.
907 * @param {bitArray|String} data the data to hash. 907 * @param {bitArray|String} data the data to hash.
@@ -919,7 +919,7 @@ sjcl.hash.sha256.prototype = {
919 } 919 }
920 return this; 920 return this;
921 }, 921 },
922 922
923 /** 923 /**
924 * Complete hashing and output the hash value. 924 * Complete hashing and output the hash value.
925 * @return {bitArray} The hash value, an array of 8 big-endian words. 925 * @return {bitArray} The hash value, an array of 8 big-endian words.
@@ -929,12 +929,12 @@ sjcl.hash.sha256.prototype = {
929 929
930 // Round out and push the buffer 930 // Round out and push the buffer
931 b = sjcl.bitArray.concat(b, [sjcl.bitArray.partial(1,1)]); 931 b = sjcl.bitArray.concat(b, [sjcl.bitArray.partial(1,1)]);
932 932
933 // Round out the buffer to a multiple of 16 words, less the 2 length words. 933 // Round out the buffer to a multiple of 16 words, less the 2 length words.
934 for (i = b.length + 2; i & 15; i++) { 934 for (i = b.length + 2; i & 15; i++) {
935 b.push(0); 935 b.push(0);
936 } 936 }
937 937
938 // append the length 938 // append the length
939 b.push(Math.floor(this._length / 0x100000000)); 939 b.push(Math.floor(this._length / 0x100000000));
940 b.push(this._length | 0); 940 b.push(this._length | 0);
@@ -955,7 +955,7 @@ sjcl.hash.sha256.prototype = {
955 /* 955 /*
956 _init:[0x6a09e667,0xbb67ae85,0x3c6ef372,0xa54ff53a,0x510e527f,0x9b05688c,0x1f83d9ab,0x5be0cd19], 956 _init:[0x6a09e667,0xbb67ae85,0x3c6ef372,0xa54ff53a,0x510e527f,0x9b05688c,0x1f83d9ab,0x5be0cd19],
957 */ 957 */
958 958
959 /** 959 /**
960 * The SHA-256 hash key, to be precomputed. 960 * The SHA-256 hash key, to be precomputed.
961 * @private 961 * @private
@@ -990,7 +990,7 @@ sjcl.hash.sha256.prototype = {
990 continue outer; 990 continue outer;
991 } 991 }
992 } 992 }
993 993
994 if (i<8) { 994 if (i<8) {
995 this._init[i] = frac(Math.pow(prime, 1/2)); 995 this._init[i] = frac(Math.pow(prime, 1/2));
996 } 996 }
@@ -998,13 +998,13 @@ sjcl.hash.sha256.prototype = {
998 i++; 998 i++;
999 } 999 }
1000 }, 1000 },
1001 1001
1002 /** 1002 /**
1003 * Perform one cycle of SHA-256. 1003 * Perform one cycle of SHA-256.
1004 * @param {bitArray} words one block of words. 1004 * @param {bitArray} words one block of words.
1005 * @private 1005 * @private
1006 */ 1006 */
1007 _block:function (words) { 1007 _block:function (words) {
1008 var i, tmp, a, b, 1008 var i, tmp, a, b,
1009 w = words.slice(0), 1009 w = words.slice(0),
1010 h = this._h, 1010 h = this._h,
@@ -1032,13 +1032,13 @@ sjcl.hash.sha256.prototype = {
1032 } else { 1032 } else {
1033 a = w[(i+1 ) & 15]; 1033 a = w[(i+1 ) & 15];
1034 b = w[(i+14) & 15]; 1034 b = w[(i+14) & 15];
1035 tmp = w[i&15] = ((a>>>7 ^ a>>>18 ^ a>>>3 ^ a<<25 ^ a<<14) + 1035 tmp = w[i&15] = ((a>>>7 ^ a>>>18 ^ a>>>3 ^ a<<25 ^ a<<14) +
1036 (b>>>17 ^ b>>>19 ^ b>>>10 ^ b<<15 ^ b<<13) + 1036 (b>>>17 ^ b>>>19 ^ b>>>10 ^ b<<15 ^ b<<13) +
1037 w[i&15] + w[(i+9) & 15]) | 0; 1037 w[i&15] + w[(i+9) & 15]) | 0;
1038 } 1038 }
1039 1039
1040 tmp = (tmp + h7 + (h4>>>6 ^ h4>>>11 ^ h4>>>25 ^ h4<<26 ^ h4<<21 ^ h4<<7) + (h6 ^ h4&(h5^h6)) + k[i]); // | 0; 1040 tmp = (tmp + h7 + (h4>>>6 ^ h4>>>11 ^ h4>>>25 ^ h4<<26 ^ h4<<21 ^ h4<<7) + (h6 ^ h4&(h5^h6)) + k[i]); // | 0;
1041 1041
1042 // shift register 1042 // shift register
1043 h7 = h6; h6 = h5; h5 = h4; 1043 h7 = h6; h6 = h5; h5 = h4;
1044 h4 = h3 + tmp | 0; 1044 h4 = h3 + tmp | 0;
diff --git a/src/js/stellar-util.js b/src/js/stellar-util.js
new file mode 100644
index 0000000..d576a36
--- /dev/null
+++ b/src/js/stellar-util.js
@@ -0,0 +1,42516 @@
1(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
2var asn1 = exports;
3
4asn1.bignum = require('bn.js');
5
6asn1.define = require('./asn1/api').define;
7asn1.base = require('./asn1/base');
8asn1.constants = require('./asn1/constants');
9asn1.decoders = require('./asn1/decoders');
10asn1.encoders = require('./asn1/encoders');
11
12},{"./asn1/api":2,"./asn1/base":4,"./asn1/constants":8,"./asn1/decoders":10,"./asn1/encoders":13,"bn.js":18}],2:[function(require,module,exports){
13var asn1 = require('../asn1');
14var inherits = require('inherits');
15
16var api = exports;
17
18api.define = function define(name, body) {
19 return new Entity(name, body);
20};
21
22function Entity(name, body) {
23 this.name = name;
24 this.body = body;
25
26 this.decoders = {};
27 this.encoders = {};
28};
29
30Entity.prototype._createNamed = function createNamed(base) {
31 var named;
32 try {
33 named = require('vm').runInThisContext(
34 '(function ' + this.name + '(entity) {\n' +
35 ' this._initNamed(entity);\n' +
36 '})'
37 );
38 } catch (e) {
39 named = function (entity) {
40 this._initNamed(entity);
41 };
42 }
43 inherits(named, base);
44 named.prototype._initNamed = function initnamed(entity) {
45 base.call(this, entity);
46 };
47
48 return new named(this);
49};
50
51Entity.prototype._getDecoder = function _getDecoder(enc) {
52 enc = enc || 'der';
53 // Lazily create decoder
54 if (!this.decoders.hasOwnProperty(enc))
55 this.decoders[enc] = this._createNamed(asn1.decoders[enc]);
56 return this.decoders[enc];
57};
58
59Entity.prototype.decode = function decode(data, enc, options) {
60 return this._getDecoder(enc).decode(data, options);
61};
62
63Entity.prototype._getEncoder = function _getEncoder(enc) {
64 enc = enc || 'der';
65 // Lazily create encoder
66 if (!this.encoders.hasOwnProperty(enc))
67 this.encoders[enc] = this._createNamed(asn1.encoders[enc]);
68 return this.encoders[enc];
69};
70
71Entity.prototype.encode = function encode(data, enc, /* internal */ reporter) {
72 return this._getEncoder(enc).encode(data, reporter);
73};
74
75},{"../asn1":1,"inherits":119,"vm":444}],3:[function(require,module,exports){
76var inherits = require('inherits');
77var Reporter = require('../base').Reporter;
78var Buffer = require('buffer').Buffer;
79
80function DecoderBuffer(base, options) {
81 Reporter.call(this, options);
82 if (!Buffer.isBuffer(base)) {
83 this.error('Input not Buffer');
84 return;
85 }
86
87 this.base = base;
88 this.offset = 0;
89 this.length = base.length;
90}
91inherits(DecoderBuffer, Reporter);
92exports.DecoderBuffer = DecoderBuffer;
93
94DecoderBuffer.prototype.save = function save() {
95 return { offset: this.offset, reporter: Reporter.prototype.save.call(this) };
96};
97
98DecoderBuffer.prototype.restore = function restore(save) {
99 // Return skipped data
100 var res = new DecoderBuffer(this.base);
101 res.offset = save.offset;
102 res.length = this.offset;
103
104 this.offset = save.offset;
105 Reporter.prototype.restore.call(this, save.reporter);
106
107 return res;
108};
109
110DecoderBuffer.prototype.isEmpty = function isEmpty() {
111 return this.offset === this.length;
112};
113
114DecoderBuffer.prototype.readUInt8 = function readUInt8(fail) {
115 if (this.offset + 1 <= this.length)
116 return this.base.readUInt8(this.offset++, true);
117 else
118 return this.error(fail || 'DecoderBuffer overrun');
119}
120
121DecoderBuffer.prototype.skip = function skip(bytes, fail) {
122 if (!(this.offset + bytes <= this.length))
123 return this.error(fail || 'DecoderBuffer overrun');
124
125 var res = new DecoderBuffer(this.base);
126
127 // Share reporter state
128 res._reporterState = this._reporterState;
129
130 res.offset = this.offset;
131 res.length = this.offset + bytes;
132 this.offset += bytes;
133 return res;
134}
135
136DecoderBuffer.prototype.raw = function raw(save) {
137 return this.base.slice(save ? save.offset : this.offset, this.length);
138}
139
140function EncoderBuffer(value, reporter) {
141 if (Array.isArray(value)) {
142 this.length = 0;
143 this.value = value.map(function(item) {
144 if (!(item instanceof EncoderBuffer))
145 item = new EncoderBuffer(item, reporter);
146 this.length += item.length;
147 return item;
148 }, this);
149 } else if (typeof value === 'number') {
150 if (!(0 <= value && value <= 0xff))
151 return reporter.error('non-byte EncoderBuffer value');
152 this.value = value;
153 this.length = 1;
154 } else if (typeof value === 'string') {
155 this.value = value;
156 this.length = Buffer.byteLength(value);
157 } else if (Buffer.isBuffer(value)) {
158 this.value = value;
159 this.length = value.length;
160 } else {
161 return reporter.error('Unsupported type: ' + typeof value);
162 }
163}
164exports.EncoderBuffer = EncoderBuffer;
165
166EncoderBuffer.prototype.join = function join(out, offset) {
167 if (!out)
168 out = new Buffer(this.length);
169 if (!offset)
170 offset = 0;
171
172 if (this.length === 0)
173 return out;
174
175 if (Array.isArray(this.value)) {
176 this.value.forEach(function(item) {
177 item.join(out, offset);
178 offset += item.length;
179 });
180 } else {
181 if (typeof this.value === 'number')
182 out[offset] = this.value;
183 else if (typeof this.value === 'string')
184 out.write(this.value, offset);
185 else if (Buffer.isBuffer(this.value))
186 this.value.copy(out, offset);
187 offset += this.length;
188 }
189
190 return out;
191};
192
193},{"../base":4,"buffer":50,"inherits":119}],4:[function(require,module,exports){
194var base = exports;
195
196base.Reporter = require('./reporter').Reporter;
197base.DecoderBuffer = require('./buffer').DecoderBuffer;
198base.EncoderBuffer = require('./buffer').EncoderBuffer;
199base.Node = require('./node');
200
201},{"./buffer":3,"./node":5,"./reporter":6}],5:[function(require,module,exports){
202var Reporter = require('../base').Reporter;
203var EncoderBuffer = require('../base').EncoderBuffer;
204var DecoderBuffer = require('../base').DecoderBuffer;
205var assert = require('minimalistic-assert');
206
207// Supported tags
208var tags = [
209 'seq', 'seqof', 'set', 'setof', 'objid', 'bool',
210 'gentime', 'utctime', 'null_', 'enum', 'int', 'objDesc',
211 'bitstr', 'bmpstr', 'charstr', 'genstr', 'graphstr', 'ia5str', 'iso646str',
212 'numstr', 'octstr', 'printstr', 't61str', 'unistr', 'utf8str', 'videostr'
213];
214
215// Public methods list
216var methods = [
217 'key', 'obj', 'use', 'optional', 'explicit', 'implicit', 'def', 'choice',
218 'any', 'contains'
219].concat(tags);
220
221// Overrided methods list
222var overrided = [
223 '_peekTag', '_decodeTag', '_use',
224 '_decodeStr', '_decodeObjid', '_decodeTime',
225 '_decodeNull', '_decodeInt', '_decodeBool', '_decodeList',
226
227 '_encodeComposite', '_encodeStr', '_encodeObjid', '_encodeTime',
228 '_encodeNull', '_encodeInt', '_encodeBool'
229];
230
231function Node(enc, parent) {
232 var state = {};
233 this._baseState = state;
234
235 state.enc = enc;
236
237 state.parent = parent || null;
238 state.children = null;
239
240 // State
241 state.tag = null;
242 state.args = null;
243 state.reverseArgs = null;
244 state.choice = null;
245 state.optional = false;
246 state.any = false;
247 state.obj = false;
248 state.use = null;
249 state.useDecoder = null;
250 state.key = null;
251 state['default'] = null;
252 state.explicit = null;
253 state.implicit = null;
254 state.contains = null;
255
256 // Should create new instance on each method
257 if (!state.parent) {
258 state.children = [];
259 this._wrap();
260 }
261}
262module.exports = Node;
263
264var stateProps = [
265 'enc', 'parent', 'children', 'tag', 'args', 'reverseArgs', 'choice',
266 'optional', 'any', 'obj', 'use', 'alteredUse', 'key', 'default', 'explicit',
267 'implicit', 'contains'
268];
269
270Node.prototype.clone = function clone() {
271 var state = this._baseState;
272 var cstate = {};
273 stateProps.forEach(function(prop) {
274 cstate[prop] = state[prop];
275 });
276 var res = new this.constructor(cstate.parent);
277 res._baseState = cstate;
278 return res;
279};
280
281Node.prototype._wrap = function wrap() {
282 var state = this._baseState;
283 methods.forEach(function(method) {
284 this[method] = function _wrappedMethod() {
285 var clone = new this.constructor(this);
286 state.children.push(clone);
287 return clone[method].apply(clone, arguments);
288 };
289 }, this);
290};
291
292Node.prototype._init = function init(body) {
293 var state = this._baseState;
294
295 assert(state.parent === null);
296 body.call(this);
297
298 // Filter children
299 state.children = state.children.filter(function(child) {
300 return child._baseState.parent === this;
301 }, this);
302 assert.equal(state.children.length, 1, 'Root node can have only one child');
303};
304
305Node.prototype._useArgs = function useArgs(args) {
306 var state = this._baseState;
307
308 // Filter children and args
309 var children = args.filter(function(arg) {
310 return arg instanceof this.constructor;
311 }, this);
312 args = args.filter(function(arg) {
313 return !(arg instanceof this.constructor);
314 }, this);
315
316 if (children.length !== 0) {
317 assert(state.children === null);
318 state.children = children;
319
320 // Replace parent to maintain backward link
321 children.forEach(function(child) {
322 child._baseState.parent = this;
323 }, this);
324 }
325 if (args.length !== 0) {
326 assert(state.args === null);
327 state.args = args;
328 state.reverseArgs = args.map(function(arg) {
329 if (typeof arg !== 'object' || arg.constructor !== Object)
330 return arg;
331
332 var res = {};
333 Object.keys(arg).forEach(function(key) {
334 if (key == (key | 0))
335 key |= 0;
336 var value = arg[key];
337 res[value] = key;
338 });
339 return res;
340 });
341 }
342};
343
344//
345// Overrided methods
346//
347
348overrided.forEach(function(method) {
349 Node.prototype[method] = function _overrided() {
350 var state = this._baseState;
351 throw new Error(method + ' not implemented for encoding: ' + state.enc);
352 };
353});
354
355//
356// Public methods
357//
358
359tags.forEach(function(tag) {
360 Node.prototype[tag] = function _tagMethod() {
361 var state = this._baseState;
362 var args = Array.prototype.slice.call(arguments);
363
364 assert(state.tag === null);
365 state.tag = tag;
366
367 this._useArgs(args);
368
369 return this;
370 };
371});
372
373Node.prototype.use = function use(item) {
374 assert(item);
375 var state = this._baseState;
376
377 assert(state.use === null);
378 state.use = item;
379
380 return this;
381};
382
383Node.prototype.optional = function optional() {
384 var state = this._baseState;
385
386 state.optional = true;
387
388 return this;
389};
390
391Node.prototype.def = function def(val) {
392 var state = this._baseState;
393
394 assert(state['default'] === null);
395 state['default'] = val;
396 state.optional = true;
397
398 return this;
399};
400
401Node.prototype.explicit = function explicit(num) {
402 var state = this._baseState;
403
404 assert(state.explicit === null && state.implicit === null);
405 state.explicit = num;
406
407 return this;
408};
409
410Node.prototype.implicit = function implicit(num) {
411 var state = this._baseState;
412
413 assert(state.explicit === null && state.implicit === null);
414 state.implicit = num;
415
416 return this;
417};
418
419Node.prototype.obj = function obj() {
420 var state = this._baseState;
421 var args = Array.prototype.slice.call(arguments);
422
423 state.obj = true;
424
425 if (args.length !== 0)
426 this._useArgs(args);
427
428 return this;
429};
430
431Node.prototype.key = function key(newKey) {
432 var state = this._baseState;
433
434 assert(state.key === null);
435 state.key = newKey;
436
437 return this;
438};
439
440Node.prototype.any = function any() {
441 var state = this._baseState;
442
443 state.any = true;
444
445 return this;
446};
447
448Node.prototype.choice = function choice(obj) {
449 var state = this._baseState;
450
451 assert(state.choice === null);
452 state.choice = obj;
453 this._useArgs(Object.keys(obj).map(function(key) {
454 return obj[key];
455 }));
456
457 return this;
458};
459
460Node.prototype.contains = function contains(item) {
461 var state = this._baseState;
462
463 assert(state.use === null);
464 state.contains = item;
465
466 return this;
467};
468
469//
470// Decoding
471//
472
473Node.prototype._decode = function decode(input, options) {
474 var state = this._baseState;
475
476 // Decode root node
477 if (state.parent === null)
478 return input.wrapResult(state.children[0]._decode(input, options));
479
480 var result = state['default'];
481 var present = true;
482
483 var prevKey = null;
484 if (state.key !== null)
485 prevKey = input.enterKey(state.key);
486
487 // Check if tag is there
488 if (state.optional) {
489 var tag = null;
490 if (state.explicit !== null)
491 tag = state.explicit;
492 else if (state.implicit !== null)
493 tag = state.implicit;
494 else if (state.tag !== null)
495 tag = state.tag;
496
497 if (tag === null && !state.any) {
498 // Trial and Error
499 var save = input.save();
500 try {
501 if (state.choice === null)
502 this._decodeGeneric(state.tag, input, options);
503 else
504 this._decodeChoice(input, options);
505 present = true;
506 } catch (e) {
507 present = false;
508 }
509 input.restore(save);
510 } else {
511 present = this._peekTag(input, tag, state.any);
512
513 if (input.isError(present))
514 return present;
515 }
516 }
517
518 // Push object on stack
519 var prevObj;
520 if (state.obj && present)
521 prevObj = input.enterObject();
522
523 if (present) {
524 // Unwrap explicit values
525 if (state.explicit !== null) {
526 var explicit = this._decodeTag(input, state.explicit);
527 if (input.isError(explicit))
528 return explicit;
529 input = explicit;
530 }
531
532 var start = input.offset;
533
534 // Unwrap implicit and normal values
535 if (state.use === null && state.choice === null) {
536 if (state.any)
537 var save = input.save();
538 var body = this._decodeTag(
539 input,
540 state.implicit !== null ? state.implicit : state.tag,
541 state.any
542 );
543 if (input.isError(body))
544 return body;
545
546 if (state.any)
547 result = input.raw(save);
548 else
549 input = body;
550 }
551
552 if (options && options.track && state.tag !== null)
553 options.track(input.path(), start, input.length, 'tagged');
554
555 if (options && options.track && state.tag !== null)
556 options.track(input.path(), input.offset, input.length, 'content');
557
558 // Select proper method for tag
559 if (state.any)
560 result = result;
561 else if (state.choice === null)
562 result = this._decodeGeneric(state.tag, input, options);
563 else
564 result = this._decodeChoice(input, options);
565
566 if (input.isError(result))
567 return result;
568
569 // Decode children
570 if (!state.any && state.choice === null && state.children !== null) {
571 state.children.forEach(function decodeChildren(child) {
572 // NOTE: We are ignoring errors here, to let parser continue with other
573 // parts of encoded data
574 child._decode(input, options);
575 });
576 }
577
578 // Decode contained/encoded by schema, only in bit or octet strings
579 if (state.contains && (state.tag === 'octstr' || state.tag === 'bitstr')) {
580 var data = new DecoderBuffer(result);
581 result = this._getUse(state.contains, input._reporterState.obj)
582 ._decode(data, options);
583 }
584 }
585
586 // Pop object
587 if (state.obj && present)
588 result = input.leaveObject(prevObj);
589
590 // Set key
591 if (state.key !== null && (result !== null || present === true))
592 input.leaveKey(prevKey, state.key, result);
593 else if (prevKey !== null)
594 input.exitKey(prevKey);
595
596 return result;
597};
598
599Node.prototype._decodeGeneric = function decodeGeneric(tag, input, options) {
600 var state = this._baseState;
601
602 if (tag === 'seq' || tag === 'set')
603 return null;
604 if (tag === 'seqof' || tag === 'setof')
605 return this._decodeList(input, tag, state.args[0], options);
606 else if (/str$/.test(tag))
607 return this._decodeStr(input, tag, options);
608 else if (tag === 'objid' && state.args)
609 return this._decodeObjid(input, state.args[0], state.args[1], options);
610 else if (tag === 'objid')
611 return this._decodeObjid(input, null, null, options);
612 else if (tag === 'gentime' || tag === 'utctime')
613 return this._decodeTime(input, tag, options);
614 else if (tag === 'null_')
615 return this._decodeNull(input, options);
616 else if (tag === 'bool')
617 return this._decodeBool(input, options);
618 else if (tag === 'objDesc')
619 return this._decodeStr(input, tag, options);
620 else if (tag === 'int' || tag === 'enum')
621 return this._decodeInt(input, state.args && state.args[0], options);
622
623 if (state.use !== null) {
624 return this._getUse(state.use, input._reporterState.obj)
625 ._decode(input, options);
626 } else {
627 return input.error('unknown tag: ' + tag);
628 }
629};
630
631Node.prototype._getUse = function _getUse(entity, obj) {
632
633 var state = this._baseState;
634 // Create altered use decoder if implicit is set
635 state.useDecoder = this._use(entity, obj);
636 assert(state.useDecoder._baseState.parent === null);
637 state.useDecoder = state.useDecoder._baseState.children[0];
638 if (state.implicit !== state.useDecoder._baseState.implicit) {
639 state.useDecoder = state.useDecoder.clone();
640 state.useDecoder._baseState.implicit = state.implicit;
641 }
642 return state.useDecoder;
643};
644
645Node.prototype._decodeChoice = function decodeChoice(input, options) {
646 var state = this._baseState;
647 var result = null;
648 var match = false;
649
650 Object.keys(state.choice).some(function(key) {
651 var save = input.save();
652 var node = state.choice[key];
653 try {
654 var value = node._decode(input, options);
655 if (input.isError(value))
656 return false;
657
658 result = { type: key, value: value };
659 match = true;
660 } catch (e) {
661 input.restore(save);
662 return false;
663 }
664 return true;
665 }, this);
666
667 if (!match)
668 return input.error('Choice not matched');
669
670 return result;
671};
672
673//
674// Encoding
675//
676
677Node.prototype._createEncoderBuffer = function createEncoderBuffer(data) {
678 return new EncoderBuffer(data, this.reporter);
679};
680
681Node.prototype._encode = function encode(data, reporter, parent) {
682 var state = this._baseState;
683 if (state['default'] !== null && state['default'] === data)
684 return;
685
686 var result = this._encodeValue(data, reporter, parent);
687 if (result === undefined)
688 return;
689
690 if (this._skipDefault(result, reporter, parent))
691 return;
692
693 return result;
694};
695
696Node.prototype._encodeValue = function encode(data, reporter, parent) {
697 var state = this._baseState;
698
699 // Decode root node
700 if (state.parent === null)
701 return state.children[0]._encode(data, reporter || new Reporter());
702
703 var result = null;
704
705 // Set reporter to share it with a child class
706 this.reporter = reporter;
707
708 // Check if data is there
709 if (state.optional && data === undefined) {
710 if (state['default'] !== null)
711 data = state['default']
712 else
713 return;
714 }
715
716 // Encode children first
717 var content = null;
718 var primitive = false;
719 if (state.any) {
720 // Anything that was given is translated to buffer
721 result = this._createEncoderBuffer(data);
722 } else if (state.choice) {
723 result = this._encodeChoice(data, reporter);
724 } else if (state.contains) {
725 content = this._getUse(state.contains, parent)._encode(data, reporter);
726 primitive = true;
727 } else if (state.children) {
728 content = state.children.map(function(child) {
729 if (child._baseState.tag === 'null_')
730 return child._encode(null, reporter, data);
731
732 if (child._baseState.key === null)
733 return reporter.error('Child should have a key');
734 var prevKey = reporter.enterKey(child._baseState.key);
735
736 if (typeof data !== 'object')
737 return reporter.error('Child expected, but input is not object');
738
739 var res = child._encode(data[child._baseState.key], reporter, data);
740 reporter.leaveKey(prevKey);
741
742 return res;
743 }, this).filter(function(child) {
744 return child;
745 });
746 content = this._createEncoderBuffer(content);
747 } else {
748 if (state.tag === 'seqof' || state.tag === 'setof') {
749 // TODO(indutny): this should be thrown on DSL level
750 if (!(state.args && state.args.length === 1))
751 return reporter.error('Too many args for : ' + state.tag);
752
753 if (!Array.isArray(data))
754 return reporter.error('seqof/setof, but data is not Array');
755
756 var child = this.clone();
757 child._baseState.implicit = null;
758 content = this._createEncoderBuffer(data.map(function(item) {
759 var state = this._baseState;
760
761 return this._getUse(state.args[0], data)._encode(item, reporter);
762 }, child));
763 } else if (state.use !== null) {
764 result = this._getUse(state.use, parent)._encode(data, reporter);
765 } else {
766 content = this._encodePrimitive(state.tag, data);
767 primitive = true;
768 }
769 }
770
771 // Encode data itself
772 var result;
773 if (!state.any && state.choice === null) {
774 var tag = state.implicit !== null ? state.implicit : state.tag;
775 var cls = state.implicit === null ? 'universal' : 'context';
776
777 if (tag === null) {
778 if (state.use === null)
779 reporter.error('Tag could be omitted only for .use()');
780 } else {
781 if (state.use === null)
782 result = this._encodeComposite(tag, primitive, cls, content);
783 }
784 }
785
786 // Wrap in explicit
787 if (state.explicit !== null)
788 result = this._encodeComposite(state.explicit, false, 'context', result);
789
790 return result;
791};
792
793Node.prototype._encodeChoice = function encodeChoice(data, reporter) {
794 var state = this._baseState;
795
796 var node = state.choice[data.type];
797 if (!node) {
798 assert(
799 false,
800 data.type + ' not found in ' +
801 JSON.stringify(Object.keys(state.choice)));
802 }
803 return node._encode(data.value, reporter);
804};
805
806Node.prototype._encodePrimitive = function encodePrimitive(tag, data) {
807 var state = this._baseState;
808
809 if (/str$/.test(tag))
810 return this._encodeStr(data, tag);
811 else if (tag === 'objid' && state.args)
812 return this._encodeObjid(data, state.reverseArgs[0], state.args[1]);
813 else if (tag === 'objid')
814 return this._encodeObjid(data, null, null);
815 else if (tag === 'gentime' || tag === 'utctime')
816 return this._encodeTime(data, tag);
817 else if (tag === 'null_')
818 return this._encodeNull();
819 else if (tag === 'int' || tag === 'enum')
820 return this._encodeInt(data, state.args && state.reverseArgs[0]);
821 else if (tag === 'bool')
822 return this._encodeBool(data);
823 else if (tag === 'objDesc')
824 return this._encodeStr(data, tag);
825 else
826 throw new Error('Unsupported tag: ' + tag);
827};
828
829Node.prototype._isNumstr = function isNumstr(str) {
830 return /^[0-9 ]*$/.test(str);
831};
832
833Node.prototype._isPrintstr = function isPrintstr(str) {
834 return /^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(str);
835};
836
837},{"../base":4,"minimalistic-assert":360}],6:[function(require,module,exports){
838var inherits = require('inherits');
839
840function Reporter(options) {
841 this._reporterState = {
842 obj: null,
843 path: [],
844 options: options || {},
845 errors: []
846 };
847}
848exports.Reporter = Reporter;
849
850Reporter.prototype.isError = function isError(obj) {
851 return obj instanceof ReporterError;
852};
853
854Reporter.prototype.save = function save() {
855 var state = this._reporterState;
856
857 return { obj: state.obj, pathLen: state.path.length };
858};
859
860Reporter.prototype.restore = function restore(data) {
861 var state = this._reporterState;
862
863 state.obj = data.obj;
864 state.path = state.path.slice(0, data.pathLen);
865};
866
867Reporter.prototype.enterKey = function enterKey(key) {
868 return this._reporterState.path.push(key);
869};
870
871Reporter.prototype.exitKey = function exitKey(index) {
872 var state = this._reporterState;
873
874 state.path = state.path.slice(0, index - 1);
875};
876
877Reporter.prototype.leaveKey = function leaveKey(index, key, value) {
878 var state = this._reporterState;
879
880 this.exitKey(index);
881 if (state.obj !== null)
882 state.obj[key] = value;
883};
884
885Reporter.prototype.path = function path() {
886 return this._reporterState.path.join('/');
887};
888
889Reporter.prototype.enterObject = function enterObject() {
890 var state = this._reporterState;
891
892 var prev = state.obj;
893 state.obj = {};
894 return prev;
895};
896
897Reporter.prototype.leaveObject = function leaveObject(prev) {
898 var state = this._reporterState;
899
900 var now = state.obj;
901 state.obj = prev;
902 return now;
903};
904
905Reporter.prototype.error = function error(msg) {
906 var err;
907 var state = this._reporterState;
908
909 var inherited = msg instanceof ReporterError;
910 if (inherited) {
911 err = msg;
912 } else {
913 err = new ReporterError(state.path.map(function(elem) {
914 return '[' + JSON.stringify(elem) + ']';
915 }).join(''), msg.message || msg, msg.stack);
916 }
917
918 if (!state.options.partial)
919 throw err;
920
921 if (!inherited)
922 state.errors.push(err);
923
924 return err;
925};
926
927Reporter.prototype.wrapResult = function wrapResult(result) {
928 var state = this._reporterState;
929 if (!state.options.partial)
930 return result;
931
932 return {
933 result: this.isError(result) ? null : result,
934 errors: state.errors
935 };
936};
937
938function ReporterError(path, msg) {
939 this.path = path;
940 this.rethrow(msg);
941};
942inherits(ReporterError, Error);
943
944ReporterError.prototype.rethrow = function rethrow(msg) {
945 this.message = msg + ' at: ' + (this.path || '(shallow)');
946 if (Error.captureStackTrace)
947 Error.captureStackTrace(this, ReporterError);
948
949 if (!this.stack) {
950 try {
951 // IE only adds stack when thrown
952 throw new Error(this.message);
953 } catch (e) {
954 this.stack = e.stack;
955 }
956 }
957 return this;
958};
959
960},{"inherits":119}],7:[function(require,module,exports){
961var constants = require('../constants');
962
963exports.tagClass = {
964 0: 'universal',
965 1: 'application',
966 2: 'context',
967 3: 'private'
968};
969exports.tagClassByName = constants._reverse(exports.tagClass);
970
971exports.tag = {
972 0x00: 'end',
973 0x01: 'bool',
974 0x02: 'int',
975 0x03: 'bitstr',
976 0x04: 'octstr',
977 0x05: 'null_',
978 0x06: 'objid',
979 0x07: 'objDesc',
980 0x08: 'external',
981 0x09: 'real',
982 0x0a: 'enum',
983 0x0b: 'embed',
984 0x0c: 'utf8str',
985 0x0d: 'relativeOid',
986 0x10: 'seq',
987 0x11: 'set',
988 0x12: 'numstr',
989 0x13: 'printstr',
990 0x14: 't61str',
991 0x15: 'videostr',
992 0x16: 'ia5str',
993 0x17: 'utctime',
994 0x18: 'gentime',
995 0x19: 'graphstr',
996 0x1a: 'iso646str',
997 0x1b: 'genstr',
998 0x1c: 'unistr',
999 0x1d: 'charstr',
1000 0x1e: 'bmpstr'
1001};
1002exports.tagByName = constants._reverse(exports.tag);
1003
1004},{"../constants":8}],8:[function(require,module,exports){
1005var constants = exports;
1006
1007// Helper
1008constants._reverse = function reverse(map) {
1009 var res = {};
1010
1011 Object.keys(map).forEach(function(key) {
1012 // Convert key to integer if it is stringified
1013 if ((key | 0) == key)
1014 key = key | 0;
1015
1016 var value = map[key];
1017 res[value] = key;
1018 });
1019
1020 return res;
1021};
1022
1023constants.der = require('./der');
1024
1025},{"./der":7}],9:[function(require,module,exports){
1026var inherits = require('inherits');
1027
1028var asn1 = require('../../asn1');
1029var base = asn1.base;
1030var bignum = asn1.bignum;
1031
1032// Import DER constants
1033var der = asn1.constants.der;
1034
1035function DERDecoder(entity) {
1036 this.enc = 'der';
1037 this.name = entity.name;
1038 this.entity = entity;
1039
1040 // Construct base tree
1041 this.tree = new DERNode();
1042 this.tree._init(entity.body);
1043};
1044module.exports = DERDecoder;
1045
1046DERDecoder.prototype.decode = function decode(data, options) {
1047 if (!(data instanceof base.DecoderBuffer))
1048 data = new base.DecoderBuffer(data, options);
1049
1050 return this.tree._decode(data, options);
1051};
1052
1053// Tree methods
1054
1055function DERNode(parent) {
1056 base.Node.call(this, 'der', parent);
1057}
1058inherits(DERNode, base.Node);
1059
1060DERNode.prototype._peekTag = function peekTag(buffer, tag, any) {
1061 if (buffer.isEmpty())
1062 return false;
1063
1064 var state = buffer.save();
1065 var decodedTag = derDecodeTag(buffer, 'Failed to peek tag: "' + tag + '"');
1066 if (buffer.isError(decodedTag))
1067 return decodedTag;
1068
1069 buffer.restore(state);
1070
1071 return decodedTag.tag === tag || decodedTag.tagStr === tag ||
1072 (decodedTag.tagStr + 'of') === tag || any;
1073};
1074
1075DERNode.prototype._decodeTag = function decodeTag(buffer, tag, any) {
1076 var decodedTag = derDecodeTag(buffer,
1077 'Failed to decode tag of "' + tag + '"');
1078 if (buffer.isError(decodedTag))
1079 return decodedTag;
1080
1081 var len = derDecodeLen(buffer,
1082 decodedTag.primitive,
1083 'Failed to get length of "' + tag + '"');
1084
1085 // Failure
1086 if (buffer.isError(len))
1087 return len;
1088
1089 if (!any &&
1090 decodedTag.tag !== tag &&
1091 decodedTag.tagStr !== tag &&
1092 decodedTag.tagStr + 'of' !== tag) {
1093 return buffer.error('Failed to match tag: "' + tag + '"');
1094 }
1095
1096 if (decodedTag.primitive || len !== null)
1097 return buffer.skip(len, 'Failed to match body of: "' + tag + '"');
1098
1099 // Indefinite length... find END tag
1100 var state = buffer.save();
1101 var res = this._skipUntilEnd(
1102 buffer,
1103 'Failed to skip indefinite length body: "' + this.tag + '"');
1104 if (buffer.isError(res))
1105 return res;
1106
1107 len = buffer.offset - state.offset;
1108 buffer.restore(state);
1109 return buffer.skip(len, 'Failed to match body of: "' + tag + '"');
1110};
1111
1112DERNode.prototype._skipUntilEnd = function skipUntilEnd(buffer, fail) {
1113 while (true) {
1114 var tag = derDecodeTag(buffer, fail);
1115 if (buffer.isError(tag))
1116 return tag;
1117 var len = derDecodeLen(buffer, tag.primitive, fail);
1118 if (buffer.isError(len))
1119 return len;
1120
1121 var res;
1122 if (tag.primitive || len !== null)
1123 res = buffer.skip(len)
1124 else
1125 res = this._skipUntilEnd(buffer, fail);
1126
1127 // Failure
1128 if (buffer.isError(res))
1129 return res;
1130
1131 if (tag.tagStr === 'end')
1132 break;
1133 }
1134};
1135
1136DERNode.prototype._decodeList = function decodeList(buffer, tag, decoder,
1137 options) {
1138 var result = [];
1139 while (!buffer.isEmpty()) {
1140 var possibleEnd = this._peekTag(buffer, 'end');
1141 if (buffer.isError(possibleEnd))
1142 return possibleEnd;
1143
1144 var res = decoder.decode(buffer, 'der', options);
1145 if (buffer.isError(res) && possibleEnd)
1146 break;
1147 result.push(res);
1148 }
1149 return result;
1150};
1151
1152DERNode.prototype._decodeStr = function decodeStr(buffer, tag) {
1153 if (tag === 'bitstr') {
1154 var unused = buffer.readUInt8();
1155 if (buffer.isError(unused))
1156 return unused;
1157 return { unused: unused, data: buffer.raw() };
1158 } else if (tag === 'bmpstr') {
1159 var raw = buffer.raw();
1160 if (raw.length % 2 === 1)
1161 return buffer.error('Decoding of string type: bmpstr length mismatch');
1162
1163 var str = '';
1164 for (var i = 0; i < raw.length / 2; i++) {
1165 str += String.fromCharCode(raw.readUInt16BE(i * 2));
1166 }
1167 return str;
1168 } else if (tag === 'numstr') {
1169 var numstr = buffer.raw().toString('ascii');
1170 if (!this._isNumstr(numstr)) {
1171 return buffer.error('Decoding of string type: ' +
1172 'numstr unsupported characters');
1173 }
1174 return numstr;
1175 } else if (tag === 'octstr') {
1176 return buffer.raw();
1177 } else if (tag === 'objDesc') {
1178 return buffer.raw();
1179 } else if (tag === 'printstr') {
1180 var printstr = buffer.raw().toString('ascii');
1181 if (!this._isPrintstr(printstr)) {
1182 return buffer.error('Decoding of string type: ' +
1183 'printstr unsupported characters');
1184 }
1185 return printstr;
1186 } else if (/str$/.test(tag)) {
1187 return buffer.raw().toString();
1188 } else {
1189 return buffer.error('Decoding of string type: ' + tag + ' unsupported');
1190 }
1191};
1192
1193DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) {
1194 var result;
1195 var identifiers = [];
1196 var ident = 0;
1197 while (!buffer.isEmpty()) {
1198 var subident = buffer.readUInt8();
1199 ident <<= 7;
1200 ident |= subident & 0x7f;
1201 if ((subident & 0x80) === 0) {
1202 identifiers.push(ident);
1203 ident = 0;
1204 }
1205 }
1206 if (subident & 0x80)
1207 identifiers.push(ident);
1208
1209 var first = (identifiers[0] / 40) | 0;
1210 var second = identifiers[0] % 40;
1211
1212 if (relative)
1213 result = identifiers;
1214 else
1215 result = [first, second].concat(identifiers.slice(1));
1216
1217 if (values) {
1218 var tmp = values[result.join(' ')];
1219 if (tmp === undefined)
1220 tmp = values[result.join('.')];
1221 if (tmp !== undefined)
1222 result = tmp;
1223 }
1224
1225 return result;
1226};
1227
1228DERNode.prototype._decodeTime = function decodeTime(buffer, tag) {
1229 var str = buffer.raw().toString();
1230 if (tag === 'gentime') {
1231 var year = str.slice(0, 4) | 0;
1232 var mon = str.slice(4, 6) | 0;
1233 var day = str.slice(6, 8) | 0;
1234 var hour = str.slice(8, 10) | 0;
1235 var min = str.slice(10, 12) | 0;
1236 var sec = str.slice(12, 14) | 0;
1237 } else if (tag === 'utctime') {
1238 var year = str.slice(0, 2) | 0;
1239 var mon = str.slice(2, 4) | 0;
1240 var day = str.slice(4, 6) | 0;
1241 var hour = str.slice(6, 8) | 0;
1242 var min = str.slice(8, 10) | 0;
1243 var sec = str.slice(10, 12) | 0;
1244 if (year < 70)
1245 year = 2000 + year;
1246 else
1247 year = 1900 + year;
1248 } else {
1249 return buffer.error('Decoding ' + tag + ' time is not supported yet');
1250 }
1251
1252 return Date.UTC(year, mon - 1, day, hour, min, sec, 0);
1253};
1254
1255DERNode.prototype._decodeNull = function decodeNull(buffer) {
1256 return null;
1257};
1258
1259DERNode.prototype._decodeBool = function decodeBool(buffer) {
1260 var res = buffer.readUInt8();
1261 if (buffer.isError(res))
1262 return res;
1263 else
1264 return res !== 0;
1265};
1266
1267DERNode.prototype._decodeInt = function decodeInt(buffer, values) {
1268 // Bigint, return as it is (assume big endian)
1269 var raw = buffer.raw();
1270 var res = new bignum(raw);
1271
1272 if (values)
1273 res = values[res.toString(10)] || res;
1274
1275 return res;
1276};
1277
1278DERNode.prototype._use = function use(entity, obj) {
1279 if (typeof entity === 'function')
1280 entity = entity(obj);
1281 return entity._getDecoder('der').tree;
1282};
1283
1284// Utility methods
1285
1286function derDecodeTag(buf, fail) {
1287 var tag = buf.readUInt8(fail);
1288 if (buf.isError(tag))
1289 return tag;
1290
1291 var cls = der.tagClass[tag >> 6];
1292 var primitive = (tag & 0x20) === 0;
1293
1294 // Multi-octet tag - load
1295 if ((tag & 0x1f) === 0x1f) {
1296 var oct = tag;
1297 tag = 0;
1298 while ((oct & 0x80) === 0x80) {
1299 oct = buf.readUInt8(fail);
1300 if (buf.isError(oct))
1301 return oct;
1302
1303 tag <<= 7;
1304 tag |= oct & 0x7f;
1305 }
1306 } else {
1307 tag &= 0x1f;
1308 }
1309 var tagStr = der.tag[tag];
1310
1311 return {
1312 cls: cls,
1313 primitive: primitive,
1314 tag: tag,
1315 tagStr: tagStr
1316 };
1317}
1318
1319function derDecodeLen(buf, primitive, fail) {
1320 var len = buf.readUInt8(fail);
1321 if (buf.isError(len))
1322 return len;
1323
1324 // Indefinite form
1325 if (!primitive && len === 0x80)
1326 return null;
1327
1328 // Definite form
1329 if ((len & 0x80) === 0) {
1330 // Short form
1331 return len;
1332 }
1333
1334 // Long form
1335 var num = len & 0x7f;
1336 if (num > 4)
1337 return buf.error('length octect is too long');
1338
1339 len = 0;
1340 for (var i = 0; i < num; i++) {
1341 len <<= 8;
1342 var j = buf.readUInt8(fail);
1343 if (buf.isError(j))
1344 return j;
1345 len |= j;
1346 }
1347
1348 return len;
1349}
1350
1351},{"../../asn1":1,"inherits":119}],10:[function(require,module,exports){
1352var decoders = exports;
1353
1354decoders.der = require('./der');
1355decoders.pem = require('./pem');
1356
1357},{"./der":9,"./pem":11}],11:[function(require,module,exports){
1358var inherits = require('inherits');
1359var Buffer = require('buffer').Buffer;
1360
1361var DERDecoder = require('./der');
1362
1363function PEMDecoder(entity) {
1364 DERDecoder.call(this, entity);
1365 this.enc = 'pem';
1366};
1367inherits(PEMDecoder, DERDecoder);
1368module.exports = PEMDecoder;
1369
1370PEMDecoder.prototype.decode = function decode(data, options) {
1371 var lines = data.toString().split(/[\r\n]+/g);
1372
1373 var label = options.label.toUpperCase();
1374
1375 var re = /^-----(BEGIN|END) ([^-]+)-----$/;
1376 var start = -1;
1377 var end = -1;
1378 for (var i = 0; i < lines.length; i++) {
1379 var match = lines[i].match(re);
1380 if (match === null)
1381 continue;
1382
1383 if (match[2] !== label)
1384 continue;
1385
1386 if (start === -1) {
1387 if (match[1] !== 'BEGIN')
1388 break;
1389 start = i;
1390 } else {
1391 if (match[1] !== 'END')
1392 break;
1393 end = i;
1394 break;
1395 }
1396 }
1397 if (start === -1 || end === -1)
1398 throw new Error('PEM section not found for: ' + label);
1399
1400 var base64 = lines.slice(start + 1, end).join('');
1401 // Remove excessive symbols
1402 base64.replace(/[^a-z0-9\+\/=]+/gi, '');
1403
1404 var input = new Buffer(base64, 'base64');
1405 return DERDecoder.prototype.decode.call(this, input, options);
1406};
1407
1408},{"./der":9,"buffer":50,"inherits":119}],12:[function(require,module,exports){
1409var inherits = require('inherits');
1410var Buffer = require('buffer').Buffer;
1411
1412var asn1 = require('../../asn1');
1413var base = asn1.base;
1414
1415// Import DER constants
1416var der = asn1.constants.der;
1417
1418function DEREncoder(entity) {
1419 this.enc = 'der';
1420 this.name = entity.name;
1421 this.entity = entity;
1422
1423 // Construct base tree
1424 this.tree = new DERNode();
1425 this.tree._init(entity.body);
1426};
1427module.exports = DEREncoder;
1428
1429DEREncoder.prototype.encode = function encode(data, reporter) {
1430 return this.tree._encode(data, reporter).join();
1431};
1432
1433// Tree methods
1434
1435function DERNode(parent) {
1436 base.Node.call(this, 'der', parent);
1437}
1438inherits(DERNode, base.Node);
1439
1440DERNode.prototype._encodeComposite = function encodeComposite(tag,
1441 primitive,
1442 cls,
1443 content) {
1444 var encodedTag = encodeTag(tag, primitive, cls, this.reporter);
1445
1446 // Short form
1447 if (content.length < 0x80) {
1448 var header = new Buffer(2);
1449 header[0] = encodedTag;
1450 header[1] = content.length;
1451 return this._createEncoderBuffer([ header, content ]);
1452 }
1453
1454 // Long form
1455 // Count octets required to store length
1456 var lenOctets = 1;
1457 for (var i = content.length; i >= 0x100; i >>= 8)
1458 lenOctets++;
1459
1460 var header = new Buffer(1 + 1 + lenOctets);
1461 header[0] = encodedTag;
1462 header[1] = 0x80 | lenOctets;
1463
1464 for (var i = 1 + lenOctets, j = content.length; j > 0; i--, j >>= 8)
1465 header[i] = j & 0xff;
1466
1467 return this._createEncoderBuffer([ header, content ]);
1468};
1469
1470DERNode.prototype._encodeStr = function encodeStr(str, tag) {
1471 if (tag === 'bitstr') {
1472 return this._createEncoderBuffer([ str.unused | 0, str.data ]);
1473 } else if (tag === 'bmpstr') {
1474 var buf = new Buffer(str.length * 2);
1475 for (var i = 0; i < str.length; i++) {
1476 buf.writeUInt16BE(str.charCodeAt(i), i * 2);
1477 }
1478 return this._createEncoderBuffer(buf);
1479 } else if (tag === 'numstr') {
1480 if (!this._isNumstr(str)) {
1481 return this.reporter.error('Encoding of string type: numstr supports ' +
1482 'only digits and space');
1483 }
1484 return this._createEncoderBuffer(str);
1485 } else if (tag === 'printstr') {
1486 if (!this._isPrintstr(str)) {
1487 return this.reporter.error('Encoding of string type: printstr supports ' +
1488 'only latin upper and lower case letters, ' +
1489 'digits, space, apostrophe, left and rigth ' +
1490 'parenthesis, plus sign, comma, hyphen, ' +
1491 'dot, slash, colon, equal sign, ' +
1492 'question mark');
1493 }
1494 return this._createEncoderBuffer(str);
1495 } else if (/str$/.test(tag)) {
1496 return this._createEncoderBuffer(str);
1497 } else if (tag === 'objDesc') {
1498 return this._createEncoderBuffer(str);
1499 } else {
1500 return this.reporter.error('Encoding of string type: ' + tag +
1501 ' unsupported');
1502 }
1503};
1504
1505DERNode.prototype._encodeObjid = function encodeObjid(id, values, relative) {
1506 if (typeof id === 'string') {
1507 if (!values)
1508 return this.reporter.error('string objid given, but no values map found');
1509 if (!values.hasOwnProperty(id))
1510 return this.reporter.error('objid not found in values map');
1511 id = values[id].split(/[\s\.]+/g);
1512 for (var i = 0; i < id.length; i++)
1513 id[i] |= 0;
1514 } else if (Array.isArray(id)) {
1515 id = id.slice();
1516 for (var i = 0; i < id.length; i++)
1517 id[i] |= 0;
1518 }
1519
1520 if (!Array.isArray(id)) {
1521 return this.reporter.error('objid() should be either array or string, ' +
1522 'got: ' + JSON.stringify(id));
1523 }
1524
1525 if (!relative) {
1526 if (id[1] >= 40)
1527 return this.reporter.error('Second objid identifier OOB');
1528 id.splice(0, 2, id[0] * 40 + id[1]);
1529 }
1530
1531 // Count number of octets
1532 var size = 0;
1533 for (var i = 0; i < id.length; i++) {
1534 var ident = id[i];
1535 for (size++; ident >= 0x80; ident >>= 7)
1536 size++;
1537 }
1538
1539 var objid = new Buffer(size);
1540 var offset = objid.length - 1;
1541 for (var i = id.length - 1; i >= 0; i--) {
1542 var ident = id[i];
1543 objid[offset--] = ident & 0x7f;
1544 while ((ident >>= 7) > 0)
1545 objid[offset--] = 0x80 | (ident & 0x7f);
1546 }
1547
1548 return this._createEncoderBuffer(objid);
1549};
1550
1551function two(num) {
1552 if (num < 10)
1553 return '0' + num;
1554 else
1555 return num;
1556}
1557
1558DERNode.prototype._encodeTime = function encodeTime(time, tag) {
1559 var str;
1560 var date = new Date(time);
1561
1562 if (tag === 'gentime') {
1563 str = [
1564 two(date.getFullYear()),
1565 two(date.getUTCMonth() + 1),
1566 two(date.getUTCDate()),
1567 two(date.getUTCHours()),
1568 two(date.getUTCMinutes()),
1569 two(date.getUTCSeconds()),
1570 'Z'
1571 ].join('');
1572 } else if (tag === 'utctime') {
1573 str = [
1574 two(date.getFullYear() % 100),
1575 two(date.getUTCMonth() + 1),
1576 two(date.getUTCDate()),
1577 two(date.getUTCHours()),
1578 two(date.getUTCMinutes()),
1579 two(date.getUTCSeconds()),
1580 'Z'
1581 ].join('');
1582 } else {
1583 this.reporter.error('Encoding ' + tag + ' time is not supported yet');
1584 }
1585
1586 return this._encodeStr(str, 'octstr');
1587};
1588
1589DERNode.prototype._encodeNull = function encodeNull() {
1590 return this._createEncoderBuffer('');
1591};
1592
1593DERNode.prototype._encodeInt = function encodeInt(num, values) {
1594 if (typeof num === 'string') {
1595 if (!values)
1596 return this.reporter.error('String int or enum given, but no values map');
1597 if (!values.hasOwnProperty(num)) {
1598 return this.reporter.error('Values map doesn\'t contain: ' +
1599 JSON.stringify(num));
1600 }
1601 num = values[num];
1602 }
1603
1604 // Bignum, assume big endian
1605 if (typeof num !== 'number' && !Buffer.isBuffer(num)) {
1606 var numArray = num.toArray();
1607 if (!num.sign && numArray[0] & 0x80) {
1608 numArray.unshift(0);
1609 }
1610 num = new Buffer(numArray);
1611 }
1612
1613 if (Buffer.isBuffer(num)) {
1614 var size = num.length;
1615 if (num.length === 0)
1616 size++;
1617
1618 var out = new Buffer(size);
1619 num.copy(out);
1620 if (num.length === 0)
1621 out[0] = 0
1622 return this._createEncoderBuffer(out);
1623 }
1624
1625 if (num < 0x80)
1626 return this._createEncoderBuffer(num);
1627
1628 if (num < 0x100)
1629 return this._createEncoderBuffer([0, num]);
1630
1631 var size = 1;
1632 for (var i = num; i >= 0x100; i >>= 8)
1633 size++;
1634
1635 var out = new Array(size);
1636 for (var i = out.length - 1; i >= 0; i--) {
1637 out[i] = num & 0xff;
1638 num >>= 8;
1639 }
1640 if(out[0] & 0x80) {
1641 out.unshift(0);
1642 }
1643
1644 return this._createEncoderBuffer(new Buffer(out));
1645};
1646
1647DERNode.prototype._encodeBool = function encodeBool(value) {
1648 return this._createEncoderBuffer(value ? 0xff : 0);
1649};
1650
1651DERNode.prototype._use = function use(entity, obj) {
1652 if (typeof entity === 'function')
1653 entity = entity(obj);
1654 return entity._getEncoder('der').tree;
1655};
1656
1657DERNode.prototype._skipDefault = function skipDefault(dataBuffer, reporter, parent) {
1658 var state = this._baseState;
1659 var i;
1660 if (state['default'] === null)
1661 return false;
1662
1663 var data = dataBuffer.join();
1664 if (state.defaultBuffer === undefined)
1665 state.defaultBuffer = this._encodeValue(state['default'], reporter, parent).join();
1666
1667 if (data.length !== state.defaultBuffer.length)
1668 return false;
1669
1670 for (i=0; i < data.length; i++)
1671 if (data[i] !== state.defaultBuffer[i])
1672 return false;
1673
1674 return true;
1675};
1676
1677// Utility methods
1678
1679function encodeTag(tag, primitive, cls, reporter) {
1680 var res;
1681
1682 if (tag === 'seqof')
1683 tag = 'seq';
1684 else if (tag === 'setof')
1685 tag = 'set';
1686
1687 if (der.tagByName.hasOwnProperty(tag))
1688 res = der.tagByName[tag];
1689 else if (typeof tag === 'number' && (tag | 0) === tag)
1690 res = tag;
1691 else
1692 return reporter.error('Unknown tag: ' + tag);
1693
1694 if (res >= 0x1f)
1695 return reporter.error('Multi-octet tag encoding unsupported');
1696
1697 if (!primitive)
1698 res |= 0x20;
1699
1700 res |= (der.tagClassByName[cls || 'universal'] << 6);
1701
1702 return res;
1703}
1704
1705},{"../../asn1":1,"buffer":50,"inherits":119}],13:[function(require,module,exports){
1706var encoders = exports;
1707
1708encoders.der = require('./der');
1709encoders.pem = require('./pem');
1710
1711},{"./der":12,"./pem":14}],14:[function(require,module,exports){
1712var inherits = require('inherits');
1713
1714var DEREncoder = require('./der');
1715
1716function PEMEncoder(entity) {
1717 DEREncoder.call(this, entity);
1718 this.enc = 'pem';
1719};
1720inherits(PEMEncoder, DEREncoder);
1721module.exports = PEMEncoder;
1722
1723PEMEncoder.prototype.encode = function encode(data, options) {
1724 var buf = DEREncoder.prototype.encode.call(this, data);
1725
1726 var p = buf.toString('base64');
1727 var out = [ '-----BEGIN ' + options.label + '-----' ];
1728 for (var i = 0; i < p.length; i += 64)
1729 out.push(p.slice(i, i + 64));
1730 out.push('-----END ' + options.label + '-----');
1731 return out.join('\n');
1732};
1733
1734},{"./der":12,"inherits":119}],15:[function(require,module,exports){
1735"use strict";
1736
1737/**
1738 * Generate a character map.
1739 * @param {string} alphabet e.g. "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"
1740 * @param {object} mappings map overrides from key to value
1741 * @method
1742 */
1743
1744var charmap = function (alphabet, mappings) {
1745 mappings || (mappings = {});
1746 alphabet.split("").forEach(function (c, i) {
1747 if (!(c in mappings)) mappings[c] = i;
1748 });
1749 return mappings;
1750}
1751
1752/**
1753 * The RFC 4648 base 32 alphabet and character map.
1754 * @see {@link https://tools.ietf.org/html/rfc4648}
1755 */
1756
1757var rfc4648 = {
1758 alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",
1759 charmap: {
1760 0: 14,
1761 1: 8
1762 }
1763};
1764
1765rfc4648.charmap = charmap(rfc4648.alphabet, rfc4648.charmap);
1766
1767/**
1768 * The Crockford base 32 alphabet and character map.
1769 * @see {@link http://www.crockford.com/wrmg/base32.html}
1770 */
1771
1772var crockford = {
1773 alphabet: "0123456789ABCDEFGHJKMNPQRSTVWXYZ",
1774 charmap: {
1775 O: 0,
1776 I: 1,
1777 L: 1
1778 }
1779};
1780
1781crockford.charmap = charmap(crockford.alphabet, crockford.charmap);
1782
1783/**
1784 * base32hex
1785 * @see {@link https://en.wikipedia.org/wiki/Base32#base32hex}
1786 */
1787
1788var base32hex = {
1789 alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV",
1790 charmap: {}
1791};
1792
1793base32hex.charmap = charmap(base32hex.alphabet, base32hex.charmap);
1794
1795/**
1796 * Create a new `Decoder` with the given options.
1797 *
1798 * @param {object} [options]
1799 * @param {string} [type] Supported Base-32 variants are "rfc4648" and
1800 * "crockford".
1801 * @param {object} [charmap] Override the character map used in decoding.
1802 * @constructor
1803 */
1804
1805function Decoder (options) {
1806 this.buf = [];
1807 this.shift = 8;
1808 this.carry = 0;
1809
1810 if (options) {
1811
1812 switch (options.type) {
1813 case "rfc4648":
1814 this.charmap = exports.rfc4648.charmap;
1815 break;
1816 case "crockford":
1817 this.charmap = exports.crockford.charmap;
1818 break;
1819 case "base32hex":
1820 this.charmap = exports.base32hex.charmap;
1821 break;
1822 default:
1823 throw new Error("invalid type");
1824 }
1825
1826 if (options.charmap) this.charmap = options.charmap;
1827 }
1828}
1829
1830/**
1831 * The default character map coresponds to RFC4648.
1832 */
1833
1834Decoder.prototype.charmap = rfc4648.charmap;
1835
1836/**
1837 * Decode a string, continuing from the previous state.
1838 *
1839 * @param {string} str
1840 * @return {Decoder} this
1841 */
1842
1843Decoder.prototype.write = function (str) {
1844 var charmap = this.charmap;
1845 var buf = this.buf;
1846 var shift = this.shift;
1847 var carry = this.carry;
1848
1849 // decode string
1850 str.toUpperCase().split("").forEach(function (char) {
1851
1852 // ignore padding
1853 if (char == "=") return;
1854
1855 // lookup symbol
1856 var symbol = charmap[char] & 0xff;
1857
1858 // 1: 00000 000
1859 // 2: 00 00000 0
1860 // 3: 0000 0000
1861 // 4: 0 00000 00
1862 // 5: 000 00000
1863 // 6: 00000 000
1864 // 7: 00 00000 0
1865
1866 shift -= 5;
1867 if (shift > 0) {
1868 carry |= symbol << shift;
1869 } else if (shift < 0) {
1870 buf.push(carry | (symbol >> -shift));
1871 shift += 8;
1872 carry = (symbol << shift) & 0xff;
1873 } else {
1874 buf.push(carry | symbol);
1875 shift = 8;
1876 carry = 0;
1877 }
1878 });
1879
1880 // save state
1881 this.shift = shift;
1882 this.carry = carry;
1883
1884 // for chaining
1885 return this;
1886};
1887
1888/**
1889 * Finish decoding.
1890 *
1891 * @param {string} [str] The final string to decode.
1892 * @return {Array} Decoded byte array.
1893 */
1894
1895Decoder.prototype.finalize = function (str) {
1896 if (str) {
1897 this.write(str);
1898 }
1899 if (this.shift !== 8 && this.carry !== 0) {
1900 this.buf.push(this.carry);
1901 this.shift = 8;
1902 this.carry = 0;
1903 }
1904 return this.buf;
1905};
1906
1907/**
1908 * Create a new `Encoder` with the given options.
1909 *
1910 * @param {object} [options]
1911 * @param {string} [type] Supported Base-32 variants are "rfc4648" and
1912 * "crockford".
1913 * @param {object} [alphabet] Override the alphabet used in encoding.
1914 * @constructor
1915 */
1916
1917function Encoder (options) {
1918 this.buf = "";
1919 this.shift = 3;
1920 this.carry = 0;
1921
1922 if (options) {
1923
1924 switch (options.type) {
1925 case "rfc4648":
1926 this.alphabet = exports.rfc4648.alphabet;
1927 break;
1928 case "crockford":
1929 this.alphabet = exports.crockford.alphabet;
1930 break;
1931 case "base32hex":
1932 this.alphabet = exports.base32hex.alphabet;
1933 break;
1934 default:
1935 throw new Error("invalid type");
1936 }
1937
1938 if (options.alphabet) this.alphabet = options.alphabet;
1939 else if (options.lc) this.alphabet = this.alphabet.toLowerCase();
1940 }
1941}
1942
1943/**
1944 * The default alphabet coresponds to RFC4648.
1945 */
1946
1947Encoder.prototype.alphabet = rfc4648.alphabet;
1948
1949/**
1950 * Encode a byte array, continuing from the previous state.
1951 *
1952 * @param {byte[]} buf The byte array to encode.
1953 * @return {Encoder} this
1954 */
1955
1956Encoder.prototype.write = function (buf) {
1957 var shift = this.shift;
1958 var carry = this.carry;
1959 var symbol;
1960 var byte;
1961 var i;
1962
1963 // encode each byte in buf
1964 for (i = 0; i < buf.length; i++) {
1965 byte = buf[i];
1966
1967 // 1: 00000 000
1968 // 2: 00 00000 0
1969 // 3: 0000 0000
1970 // 4: 0 00000 00
1971 // 5: 000 00000
1972 // 6: 00000 000
1973 // 7: 00 00000 0
1974
1975 symbol = carry | (byte >> shift);
1976 this.buf += this.alphabet[symbol & 0x1f];
1977
1978 if (shift > 5) {
1979 shift -= 5;
1980 symbol = byte >> shift;
1981 this.buf += this.alphabet[symbol & 0x1f];
1982 }
1983
1984 shift = 5 - shift;
1985 carry = byte << shift;
1986 shift = 8 - shift;
1987 }
1988
1989 // save state
1990 this.shift = shift;
1991 this.carry = carry;
1992
1993 // for chaining
1994 return this;
1995};
1996
1997/**
1998 * Finish encoding.
1999 *
2000 * @param {byte[]} [buf] The final byte array to encode.
2001 * @return {string} The encoded byte array.
2002 */
2003
2004Encoder.prototype.finalize = function (buf) {
2005 if (buf) {
2006 this.write(buf);
2007 }
2008 if (this.shift !== 3) {
2009 this.buf += this.alphabet[this.carry & 0x1f];
2010 this.shift = 3;
2011 this.carry = 0;
2012 }
2013 return this.buf;
2014};
2015
2016/**
2017 * Convenience encoder.
2018 *
2019 * @param {byte[]} buf The byte array to encode.
2020 * @param {object} [options] Options to pass to the encoder.
2021 * @return {string} The encoded string.
2022 */
2023
2024exports.encode = function (buf, options) {
2025 return new Encoder(options).finalize(buf);
2026};
2027
2028/**
2029 * Convenience decoder.
2030 *
2031 * @param {string} str The string to decode.
2032 * @param {object} [options] Options to pass to the decoder.
2033 * @return {byte[]} The decoded byte array.
2034 */
2035
2036exports.decode = function (str, options) {
2037 return new Decoder(options).finalize(str);
2038};
2039
2040// Exports.
2041exports.Decoder = Decoder;
2042exports.Encoder = Encoder;
2043exports.charmap = charmap;
2044exports.crockford = crockford;
2045exports.rfc4648 = rfc4648;
2046exports.base32hex = base32hex;
2047
2048},{}],16:[function(require,module,exports){
2049'use strict'
2050
2051exports.byteLength = byteLength
2052exports.toByteArray = toByteArray
2053exports.fromByteArray = fromByteArray
2054
2055var lookup = []
2056var revLookup = []
2057var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
2058
2059var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
2060for (var i = 0, len = code.length; i < len; ++i) {
2061 lookup[i] = code[i]
2062 revLookup[code.charCodeAt(i)] = i
2063}
2064
2065// Support decoding URL-safe base64 strings, as Node.js does.
2066// See: https://en.wikipedia.org/wiki/Base64#URL_applications
2067revLookup['-'.charCodeAt(0)] = 62
2068revLookup['_'.charCodeAt(0)] = 63
2069
2070function getLens (b64) {
2071 var len = b64.length
2072
2073 if (len % 4 > 0) {
2074 throw new Error('Invalid string. Length must be a multiple of 4')
2075 }
2076
2077 // Trim off extra bytes after placeholder bytes are found
2078 // See: https://github.com/beatgammit/base64-js/issues/42
2079 var validLen = b64.indexOf('=')
2080 if (validLen === -1) validLen = len
2081
2082 var placeHoldersLen = validLen === len
2083 ? 0
2084 : 4 - (validLen % 4)
2085
2086 return [validLen, placeHoldersLen]
2087}
2088
2089// base64 is 4/3 + up to two characters of the original data
2090function byteLength (b64) {
2091 var lens = getLens(b64)
2092 var validLen = lens[0]
2093 var placeHoldersLen = lens[1]
2094 return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
2095}
2096
2097function _byteLength (b64, validLen, placeHoldersLen) {
2098 return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
2099}
2100
2101function toByteArray (b64) {
2102 var tmp
2103 var lens = getLens(b64)
2104 var validLen = lens[0]
2105 var placeHoldersLen = lens[1]
2106
2107 var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
2108
2109 var curByte = 0
2110
2111 // if there are placeholders, only get up to the last complete 4 chars
2112 var len = placeHoldersLen > 0
2113 ? validLen - 4
2114 : validLen
2115
2116 for (var i = 0; i < len; i += 4) {
2117 tmp =
2118 (revLookup[b64.charCodeAt(i)] << 18) |
2119 (revLookup[b64.charCodeAt(i + 1)] << 12) |
2120 (revLookup[b64.charCodeAt(i + 2)] << 6) |
2121 revLookup[b64.charCodeAt(i + 3)]
2122 arr[curByte++] = (tmp >> 16) & 0xFF
2123 arr[curByte++] = (tmp >> 8) & 0xFF
2124 arr[curByte++] = tmp & 0xFF
2125 }
2126
2127 if (placeHoldersLen === 2) {
2128 tmp =
2129 (revLookup[b64.charCodeAt(i)] << 2) |
2130 (revLookup[b64.charCodeAt(i + 1)] >> 4)
2131 arr[curByte++] = tmp & 0xFF
2132 }
2133
2134 if (placeHoldersLen === 1) {
2135 tmp =
2136 (revLookup[b64.charCodeAt(i)] << 10) |
2137 (revLookup[b64.charCodeAt(i + 1)] << 4) |
2138 (revLookup[b64.charCodeAt(i + 2)] >> 2)
2139 arr[curByte++] = (tmp >> 8) & 0xFF
2140 arr[curByte++] = tmp & 0xFF
2141 }
2142
2143 return arr
2144}
2145
2146function tripletToBase64 (num) {
2147 return lookup[num >> 18 & 0x3F] +
2148 lookup[num >> 12 & 0x3F] +
2149 lookup[num >> 6 & 0x3F] +
2150 lookup[num & 0x3F]
2151}
2152
2153function encodeChunk (uint8, start, end) {
2154 var tmp
2155 var output = []
2156 for (var i = start; i < end; i += 3) {
2157 tmp =
2158 ((uint8[i] << 16) & 0xFF0000) +
2159 ((uint8[i + 1] << 8) & 0xFF00) +
2160 (uint8[i + 2] & 0xFF)
2161 output.push(tripletToBase64(tmp))
2162 }
2163 return output.join('')
2164}
2165
2166function fromByteArray (uint8) {
2167 var tmp
2168 var len = uint8.length
2169 var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
2170 var parts = []
2171 var maxChunkLength = 16383 // must be multiple of 3
2172
2173 // go through the array every three bytes, we'll deal with trailing stuff later
2174 for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
2175 parts.push(encodeChunk(
2176 uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
2177 ))
2178 }
2179
2180 // pad the end with zeros, but make sure to not forget the extra bytes
2181 if (extraBytes === 1) {
2182 tmp = uint8[len - 1]
2183 parts.push(
2184 lookup[tmp >> 2] +
2185 lookup[(tmp << 4) & 0x3F] +
2186 '=='
2187 )
2188 } else if (extraBytes === 2) {
2189 tmp = (uint8[len - 2] << 8) + uint8[len - 1]
2190 parts.push(
2191 lookup[tmp >> 10] +
2192 lookup[(tmp >> 4) & 0x3F] +
2193 lookup[(tmp << 2) & 0x3F] +
2194 '='
2195 )
2196 }
2197
2198 return parts.join('')
2199}
2200
2201},{}],17:[function(require,module,exports){
2202/*! bignumber.js v4.1.0 https://github.com/MikeMcl/bignumber.js/LICENCE */
2203
2204;(function (globalObj) {
2205 'use strict';
2206
2207 /*
2208 bignumber.js v4.1.0
2209 A JavaScript library for arbitrary-precision arithmetic.
2210 https://github.com/MikeMcl/bignumber.js
2211 Copyright (c) 2017 Michael Mclaughlin <M8ch88l@gmail.com>
2212 MIT Expat Licence
2213 */
2214
2215
2216 var BigNumber,
2217 isNumeric = /^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,
2218 mathceil = Math.ceil,
2219 mathfloor = Math.floor,
2220 notBool = ' not a boolean or binary digit',
2221 roundingMode = 'rounding mode',
2222 tooManyDigits = 'number type has more than 15 significant digits',
2223 ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_',
2224 BASE = 1e14,
2225 LOG_BASE = 14,
2226 MAX_SAFE_INTEGER = 0x1fffffffffffff, // 2^53 - 1
2227 // MAX_INT32 = 0x7fffffff, // 2^31 - 1
2228 POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13],
2229 SQRT_BASE = 1e7,
2230
2231 /*
2232 * The limit on the value of DECIMAL_PLACES, TO_EXP_NEG, TO_EXP_POS, MIN_EXP, MAX_EXP, and
2233 * the arguments to toExponential, toFixed, toFormat, and toPrecision, beyond which an
2234 * exception is thrown (if ERRORS is true).
2235 */
2236 MAX = 1E9; // 0 to MAX_INT32
2237
2238
2239 /*
2240 * Create and return a BigNumber constructor.
2241 */
2242 function constructorFactory(config) {
2243 var div, parseNumeric,
2244
2245 // id tracks the caller function, so its name can be included in error messages.
2246 id = 0,
2247 P = BigNumber.prototype,
2248 ONE = new BigNumber(1),
2249
2250
2251 /********************************* EDITABLE DEFAULTS **********************************/
2252
2253
2254 /*
2255 * The default values below must be integers within the inclusive ranges stated.
2256 * The values can also be changed at run-time using BigNumber.config.
2257 */
2258
2259 // The maximum number of decimal places for operations involving division.
2260 DECIMAL_PLACES = 20, // 0 to MAX
2261
2262 /*
2263 * The rounding mode used when rounding to the above decimal places, and when using
2264 * toExponential, toFixed, toFormat and toPrecision, and round (default value).
2265 * UP 0 Away from zero.
2266 * DOWN 1 Towards zero.
2267 * CEIL 2 Towards +Infinity.
2268 * FLOOR 3 Towards -Infinity.
2269 * HALF_UP 4 Towards nearest neighbour. If equidistant, up.
2270 * HALF_DOWN 5 Towards nearest neighbour. If equidistant, down.
2271 * HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour.
2272 * HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity.
2273 * HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.
2274 */
2275 ROUNDING_MODE = 4, // 0 to 8
2276
2277 // EXPONENTIAL_AT : [TO_EXP_NEG , TO_EXP_POS]
2278
2279 // The exponent value at and beneath which toString returns exponential notation.
2280 // Number type: -7
2281 TO_EXP_NEG = -7, // 0 to -MAX
2282
2283 // The exponent value at and above which toString returns exponential notation.
2284 // Number type: 21
2285 TO_EXP_POS = 21, // 0 to MAX
2286
2287 // RANGE : [MIN_EXP, MAX_EXP]
2288
2289 // The minimum exponent value, beneath which underflow to zero occurs.
2290 // Number type: -324 (5e-324)
2291 MIN_EXP = -1e7, // -1 to -MAX
2292
2293 // The maximum exponent value, above which overflow to Infinity occurs.
2294 // Number type: 308 (1.7976931348623157e+308)
2295 // For MAX_EXP > 1e7, e.g. new BigNumber('1e100000000').plus(1) may be slow.
2296 MAX_EXP = 1e7, // 1 to MAX
2297
2298 // Whether BigNumber Errors are ever thrown.
2299 ERRORS = true, // true or false
2300
2301 // Change to intValidatorNoErrors if ERRORS is false.
2302 isValidInt = intValidatorWithErrors, // intValidatorWithErrors/intValidatorNoErrors
2303
2304 // Whether to use cryptographically-secure random number generation, if available.
2305 CRYPTO = false, // true or false
2306
2307 /*
2308 * The modulo mode used when calculating the modulus: a mod n.
2309 * The quotient (q = a / n) is calculated according to the corresponding rounding mode.
2310 * The remainder (r) is calculated as: r = a - n * q.
2311 *
2312 * UP 0 The remainder is positive if the dividend is negative, else is negative.
2313 * DOWN 1 The remainder has the same sign as the dividend.
2314 * This modulo mode is commonly known as 'truncated division' and is
2315 * equivalent to (a % n) in JavaScript.
2316 * FLOOR 3 The remainder has the same sign as the divisor (Python %).
2317 * HALF_EVEN 6 This modulo mode implements the IEEE 754 remainder function.
2318 * EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)).
2319 * The remainder is always positive.
2320 *
2321 * The truncated division, floored division, Euclidian division and IEEE 754 remainder
2322 * modes are commonly used for the modulus operation.
2323 * Although the other rounding modes can also be used, they may not give useful results.
2324 */
2325 MODULO_MODE = 1, // 0 to 9
2326
2327 // The maximum number of significant digits of the result of the toPower operation.
2328 // If POW_PRECISION is 0, there will be unlimited significant digits.
2329 POW_PRECISION = 0, // 0 to MAX
2330
2331 // The format specification used by the BigNumber.prototype.toFormat method.
2332 FORMAT = {
2333 decimalSeparator: '.',
2334 groupSeparator: ',',
2335 groupSize: 3,
2336 secondaryGroupSize: 0,
2337 fractionGroupSeparator: '\xA0', // non-breaking space
2338 fractionGroupSize: 0
2339 };
2340
2341
2342 /******************************************************************************************/
2343
2344
2345 // CONSTRUCTOR
2346
2347
2348 /*
2349 * The BigNumber constructor and exported function.
2350 * Create and return a new instance of a BigNumber object.
2351 *
2352 * n {number|string|BigNumber} A numeric value.
2353 * [b] {number} The base of n. Integer, 2 to 64 inclusive.
2354 */
2355 function BigNumber( n, b ) {
2356 var c, e, i, num, len, str,
2357 x = this;
2358
2359 // Enable constructor usage without new.
2360 if ( !( x instanceof BigNumber ) ) {
2361
2362 // 'BigNumber() constructor call without new: {n}'
2363 if (ERRORS) raise( 26, 'constructor call without new', n );
2364 return new BigNumber( n, b );
2365 }
2366
2367 // 'new BigNumber() base not an integer: {b}'
2368 // 'new BigNumber() base out of range: {b}'
2369 if ( b == null || !isValidInt( b, 2, 64, id, 'base' ) ) {
2370
2371 // Duplicate.
2372 if ( n instanceof BigNumber ) {
2373 x.s = n.s;
2374 x.e = n.e;
2375 x.c = ( n = n.c ) ? n.slice() : n;
2376 id = 0;
2377 return;
2378 }
2379
2380 if ( ( num = typeof n == 'number' ) && n * 0 == 0 ) {
2381 x.s = 1 / n < 0 ? ( n = -n, -1 ) : 1;
2382
2383 // Fast path for integers.
2384 if ( n === ~~n ) {
2385 for ( e = 0, i = n; i >= 10; i /= 10, e++ );
2386 x.e = e;
2387 x.c = [n];
2388 id = 0;
2389 return;
2390 }
2391
2392 str = n + '';
2393 } else {
2394 if ( !isNumeric.test( str = n + '' ) ) return parseNumeric( x, str, num );
2395 x.s = str.charCodeAt(0) === 45 ? ( str = str.slice(1), -1 ) : 1;
2396 }
2397 } else {
2398 b = b | 0;
2399 str = n + '';
2400
2401 // Ensure return value is rounded to DECIMAL_PLACES as with other bases.
2402 // Allow exponential notation to be used with base 10 argument.
2403 if ( b == 10 ) {
2404 x = new BigNumber( n instanceof BigNumber ? n : str );
2405 return round( x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE );
2406 }
2407
2408 // Avoid potential interpretation of Infinity and NaN as base 44+ values.
2409 // Any number in exponential form will fail due to the [Ee][+-].
2410 if ( ( num = typeof n == 'number' ) && n * 0 != 0 ||
2411 !( new RegExp( '^-?' + ( c = '[' + ALPHABET.slice( 0, b ) + ']+' ) +
2412 '(?:\\.' + c + ')?$',b < 37 ? 'i' : '' ) ).test(str) ) {
2413 return parseNumeric( x, str, num, b );
2414 }
2415
2416 if (num) {
2417 x.s = 1 / n < 0 ? ( str = str.slice(1), -1 ) : 1;
2418
2419 if ( ERRORS && str.replace( /^0\.0*|\./, '' ).length > 15 ) {
2420
2421 // 'new BigNumber() number type has more than 15 significant digits: {n}'
2422 raise( id, tooManyDigits, n );
2423 }
2424
2425 // Prevent later check for length on converted number.
2426 num = false;
2427 } else {
2428 x.s = str.charCodeAt(0) === 45 ? ( str = str.slice(1), -1 ) : 1;
2429 }
2430
2431 str = convertBase( str, 10, b, x.s );
2432 }
2433
2434 // Decimal point?
2435 if ( ( e = str.indexOf('.') ) > -1 ) str = str.replace( '.', '' );
2436
2437 // Exponential form?
2438 if ( ( i = str.search( /e/i ) ) > 0 ) {
2439
2440 // Determine exponent.
2441 if ( e < 0 ) e = i;
2442 e += +str.slice( i + 1 );
2443 str = str.substring( 0, i );
2444 } else if ( e < 0 ) {
2445
2446 // Integer.
2447 e = str.length;
2448 }
2449
2450 // Determine leading zeros.
2451 for ( i = 0; str.charCodeAt(i) === 48; i++ );
2452
2453 // Determine trailing zeros.
2454 for ( len = str.length; str.charCodeAt(--len) === 48; );
2455 str = str.slice( i, len + 1 );
2456
2457 if (str) {
2458 len = str.length;
2459
2460 // Disallow numbers with over 15 significant digits if number type.
2461 // 'new BigNumber() number type has more than 15 significant digits: {n}'
2462 if ( num && ERRORS && len > 15 && ( n > MAX_SAFE_INTEGER || n !== mathfloor(n) ) ) {
2463 raise( id, tooManyDigits, x.s * n );
2464 }
2465
2466 e = e - i - 1;
2467
2468 // Overflow?
2469 if ( e > MAX_EXP ) {
2470
2471 // Infinity.
2472 x.c = x.e = null;
2473
2474 // Underflow?
2475 } else if ( e < MIN_EXP ) {
2476
2477 // Zero.
2478 x.c = [ x.e = 0 ];
2479 } else {
2480 x.e = e;
2481 x.c = [];
2482
2483 // Transform base
2484
2485 // e is the base 10 exponent.
2486 // i is where to slice str to get the first element of the coefficient array.
2487 i = ( e + 1 ) % LOG_BASE;
2488 if ( e < 0 ) i += LOG_BASE;
2489
2490 if ( i < len ) {
2491 if (i) x.c.push( +str.slice( 0, i ) );
2492
2493 for ( len -= LOG_BASE; i < len; ) {
2494 x.c.push( +str.slice( i, i += LOG_BASE ) );
2495 }
2496
2497 str = str.slice(i);
2498 i = LOG_BASE - str.length;
2499 } else {
2500 i -= len;
2501 }
2502
2503 for ( ; i--; str += '0' );
2504 x.c.push( +str );
2505 }
2506 } else {
2507
2508 // Zero.
2509 x.c = [ x.e = 0 ];
2510 }
2511
2512 id = 0;
2513 }
2514
2515
2516 // CONSTRUCTOR PROPERTIES
2517
2518
2519 BigNumber.another = constructorFactory;
2520
2521 BigNumber.ROUND_UP = 0;
2522 BigNumber.ROUND_DOWN = 1;
2523 BigNumber.ROUND_CEIL = 2;
2524 BigNumber.ROUND_FLOOR = 3;
2525 BigNumber.ROUND_HALF_UP = 4;
2526 BigNumber.ROUND_HALF_DOWN = 5;
2527 BigNumber.ROUND_HALF_EVEN = 6;
2528 BigNumber.ROUND_HALF_CEIL = 7;
2529 BigNumber.ROUND_HALF_FLOOR = 8;
2530 BigNumber.EUCLID = 9;
2531
2532
2533 /*
2534 * Configure infrequently-changing library-wide settings.
2535 *
2536 * Accept an object or an argument list, with one or many of the following properties or
2537 * parameters respectively:
2538 *
2539 * DECIMAL_PLACES {number} Integer, 0 to MAX inclusive
2540 * ROUNDING_MODE {number} Integer, 0 to 8 inclusive
2541 * EXPONENTIAL_AT {number|number[]} Integer, -MAX to MAX inclusive or
2542 * [integer -MAX to 0 incl., 0 to MAX incl.]
2543 * RANGE {number|number[]} Non-zero integer, -MAX to MAX inclusive or
2544 * [integer -MAX to -1 incl., integer 1 to MAX incl.]
2545 * ERRORS {boolean|number} true, false, 1 or 0
2546 * CRYPTO {boolean|number} true, false, 1 or 0
2547 * MODULO_MODE {number} 0 to 9 inclusive
2548 * POW_PRECISION {number} 0 to MAX inclusive
2549 * FORMAT {object} See BigNumber.prototype.toFormat
2550 * decimalSeparator {string}
2551 * groupSeparator {string}
2552 * groupSize {number}
2553 * secondaryGroupSize {number}
2554 * fractionGroupSeparator {string}
2555 * fractionGroupSize {number}
2556 *
2557 * (The values assigned to the above FORMAT object properties are not checked for validity.)
2558 *
2559 * E.g.
2560 * BigNumber.config(20, 4) is equivalent to
2561 * BigNumber.config({ DECIMAL_PLACES : 20, ROUNDING_MODE : 4 })
2562 *
2563 * Ignore properties/parameters set to null or undefined.
2564 * Return an object with the properties current values.
2565 */
2566 BigNumber.config = BigNumber.set = function () {
2567 var v, p,
2568 i = 0,
2569 r = {},
2570 a = arguments,
2571 o = a[0],
2572 has = o && typeof o == 'object'
2573 ? function () { if ( o.hasOwnProperty(p) ) return ( v = o[p] ) != null; }
2574 : function () { if ( a.length > i ) return ( v = a[i++] ) != null; };
2575
2576 // DECIMAL_PLACES {number} Integer, 0 to MAX inclusive.
2577 // 'config() DECIMAL_PLACES not an integer: {v}'
2578 // 'config() DECIMAL_PLACES out of range: {v}'
2579 if ( has( p = 'DECIMAL_PLACES' ) && isValidInt( v, 0, MAX, 2, p ) ) {
2580 DECIMAL_PLACES = v | 0;
2581 }
2582 r[p] = DECIMAL_PLACES;
2583
2584 // ROUNDING_MODE {number} Integer, 0 to 8 inclusive.
2585 // 'config() ROUNDING_MODE not an integer: {v}'
2586 // 'config() ROUNDING_MODE out of range: {v}'
2587 if ( has( p = 'ROUNDING_MODE' ) && isValidInt( v, 0, 8, 2, p ) ) {
2588 ROUNDING_MODE = v | 0;
2589 }
2590 r[p] = ROUNDING_MODE;
2591
2592 // EXPONENTIAL_AT {number|number[]}
2593 // Integer, -MAX to MAX inclusive or [integer -MAX to 0 inclusive, 0 to MAX inclusive].
2594 // 'config() EXPONENTIAL_AT not an integer: {v}'
2595 // 'config() EXPONENTIAL_AT out of range: {v}'
2596 if ( has( p = 'EXPONENTIAL_AT' ) ) {
2597
2598 if ( isArray(v) ) {
2599 if ( isValidInt( v[0], -MAX, 0, 2, p ) && isValidInt( v[1], 0, MAX, 2, p ) ) {
2600 TO_EXP_NEG = v[0] | 0;
2601 TO_EXP_POS = v[1] | 0;
2602 }
2603 } else if ( isValidInt( v, -MAX, MAX, 2, p ) ) {
2604 TO_EXP_NEG = -( TO_EXP_POS = ( v < 0 ? -v : v ) | 0 );
2605 }
2606 }
2607 r[p] = [ TO_EXP_NEG, TO_EXP_POS ];
2608
2609 // RANGE {number|number[]} Non-zero integer, -MAX to MAX inclusive or
2610 // [integer -MAX to -1 inclusive, integer 1 to MAX inclusive].
2611 // 'config() RANGE not an integer: {v}'
2612 // 'config() RANGE cannot be zero: {v}'
2613 // 'config() RANGE out of range: {v}'
2614 if ( has( p = 'RANGE' ) ) {
2615
2616 if ( isArray(v) ) {
2617 if ( isValidInt( v[0], -MAX, -1, 2, p ) && isValidInt( v[1], 1, MAX, 2, p ) ) {
2618 MIN_EXP = v[0] | 0;
2619 MAX_EXP = v[1] | 0;
2620 }
2621 } else if ( isValidInt( v, -MAX, MAX, 2, p ) ) {
2622 if ( v | 0 ) MIN_EXP = -( MAX_EXP = ( v < 0 ? -v : v ) | 0 );
2623 else if (ERRORS) raise( 2, p + ' cannot be zero', v );
2624 }
2625 }
2626 r[p] = [ MIN_EXP, MAX_EXP ];
2627
2628 // ERRORS {boolean|number} true, false, 1 or 0.
2629 // 'config() ERRORS not a boolean or binary digit: {v}'
2630 if ( has( p = 'ERRORS' ) ) {
2631
2632 if ( v === !!v || v === 1 || v === 0 ) {
2633 id = 0;
2634 isValidInt = ( ERRORS = !!v ) ? intValidatorWithErrors : intValidatorNoErrors;
2635 } else if (ERRORS) {
2636 raise( 2, p + notBool, v );
2637 }
2638 }
2639 r[p] = ERRORS;
2640
2641 // CRYPTO {boolean|number} true, false, 1 or 0.
2642 // 'config() CRYPTO not a boolean or binary digit: {v}'
2643 // 'config() crypto unavailable: {crypto}'
2644 if ( has( p = 'CRYPTO' ) ) {
2645
2646 if ( v === true || v === false || v === 1 || v === 0 ) {
2647 if (v) {
2648 v = typeof crypto == 'undefined';
2649 if ( !v && crypto && (crypto.getRandomValues || crypto.randomBytes)) {
2650 CRYPTO = true;
2651 } else if (ERRORS) {
2652 raise( 2, 'crypto unavailable', v ? void 0 : crypto );
2653 } else {
2654 CRYPTO = false;
2655 }
2656 } else {
2657 CRYPTO = false;
2658 }
2659 } else if (ERRORS) {
2660 raise( 2, p + notBool, v );
2661 }
2662 }
2663 r[p] = CRYPTO;
2664
2665 // MODULO_MODE {number} Integer, 0 to 9 inclusive.
2666 // 'config() MODULO_MODE not an integer: {v}'
2667 // 'config() MODULO_MODE out of range: {v}'
2668 if ( has( p = 'MODULO_MODE' ) && isValidInt( v, 0, 9, 2, p ) ) {
2669 MODULO_MODE = v | 0;
2670 }
2671 r[p] = MODULO_MODE;
2672
2673 // POW_PRECISION {number} Integer, 0 to MAX inclusive.
2674 // 'config() POW_PRECISION not an integer: {v}'
2675 // 'config() POW_PRECISION out of range: {v}'
2676 if ( has( p = 'POW_PRECISION' ) && isValidInt( v, 0, MAX, 2, p ) ) {
2677 POW_PRECISION = v | 0;
2678 }
2679 r[p] = POW_PRECISION;
2680
2681 // FORMAT {object}
2682 // 'config() FORMAT not an object: {v}'
2683 if ( has( p = 'FORMAT' ) ) {
2684
2685 if ( typeof v == 'object' ) {
2686 FORMAT = v;
2687 } else if (ERRORS) {
2688 raise( 2, p + ' not an object', v );
2689 }
2690 }
2691 r[p] = FORMAT;
2692
2693 return r;
2694 };
2695
2696
2697 /*
2698 * Return a new BigNumber whose value is the maximum of the arguments.
2699 *
2700 * arguments {number|string|BigNumber}
2701 */
2702 BigNumber.max = function () { return maxOrMin( arguments, P.lt ); };
2703
2704
2705 /*
2706 * Return a new BigNumber whose value is the minimum of the arguments.
2707 *
2708 * arguments {number|string|BigNumber}
2709 */
2710 BigNumber.min = function () { return maxOrMin( arguments, P.gt ); };
2711
2712
2713 /*
2714 * Return a new BigNumber with a random value equal to or greater than 0 and less than 1,
2715 * and with dp, or DECIMAL_PLACES if dp is omitted, decimal places (or less if trailing
2716 * zeros are produced).
2717 *
2718 * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
2719 *
2720 * 'random() decimal places not an integer: {dp}'
2721 * 'random() decimal places out of range: {dp}'
2722 * 'random() crypto unavailable: {crypto}'
2723 */
2724 BigNumber.random = (function () {
2725 var pow2_53 = 0x20000000000000;
2726
2727 // Return a 53 bit integer n, where 0 <= n < 9007199254740992.
2728 // Check if Math.random() produces more than 32 bits of randomness.
2729 // If it does, assume at least 53 bits are produced, otherwise assume at least 30 bits.
2730 // 0x40000000 is 2^30, 0x800000 is 2^23, 0x1fffff is 2^21 - 1.
2731 var random53bitInt = (Math.random() * pow2_53) & 0x1fffff
2732 ? function () { return mathfloor( Math.random() * pow2_53 ); }
2733 : function () { return ((Math.random() * 0x40000000 | 0) * 0x800000) +
2734 (Math.random() * 0x800000 | 0); };
2735
2736 return function (dp) {
2737 var a, b, e, k, v,
2738 i = 0,
2739 c = [],
2740 rand = new BigNumber(ONE);
2741
2742 dp = dp == null || !isValidInt( dp, 0, MAX, 14 ) ? DECIMAL_PLACES : dp | 0;
2743 k = mathceil( dp / LOG_BASE );
2744
2745 if (CRYPTO) {
2746
2747 // Browsers supporting crypto.getRandomValues.
2748 if (crypto.getRandomValues) {
2749
2750 a = crypto.getRandomValues( new Uint32Array( k *= 2 ) );
2751
2752 for ( ; i < k; ) {
2753
2754 // 53 bits:
2755 // ((Math.pow(2, 32) - 1) * Math.pow(2, 21)).toString(2)
2756 // 11111 11111111 11111111 11111111 11100000 00000000 00000000
2757 // ((Math.pow(2, 32) - 1) >>> 11).toString(2)
2758 // 11111 11111111 11111111
2759 // 0x20000 is 2^21.
2760 v = a[i] * 0x20000 + (a[i + 1] >>> 11);
2761
2762 // Rejection sampling:
2763 // 0 <= v < 9007199254740992
2764 // Probability that v >= 9e15, is
2765 // 7199254740992 / 9007199254740992 ~= 0.0008, i.e. 1 in 1251
2766 if ( v >= 9e15 ) {
2767 b = crypto.getRandomValues( new Uint32Array(2) );
2768 a[i] = b[0];
2769 a[i + 1] = b[1];
2770 } else {
2771
2772 // 0 <= v <= 8999999999999999
2773 // 0 <= (v % 1e14) <= 99999999999999
2774 c.push( v % 1e14 );
2775 i += 2;
2776 }
2777 }
2778 i = k / 2;
2779
2780 // Node.js supporting crypto.randomBytes.
2781 } else if (crypto.randomBytes) {
2782
2783 // buffer
2784 a = crypto.randomBytes( k *= 7 );
2785
2786 for ( ; i < k; ) {
2787
2788 // 0x1000000000000 is 2^48, 0x10000000000 is 2^40
2789 // 0x100000000 is 2^32, 0x1000000 is 2^24
2790 // 11111 11111111 11111111 11111111 11111111 11111111 11111111
2791 // 0 <= v < 9007199254740992
2792 v = ( ( a[i] & 31 ) * 0x1000000000000 ) + ( a[i + 1] * 0x10000000000 ) +
2793 ( a[i + 2] * 0x100000000 ) + ( a[i + 3] * 0x1000000 ) +
2794 ( a[i + 4] << 16 ) + ( a[i + 5] << 8 ) + a[i + 6];
2795
2796 if ( v >= 9e15 ) {
2797 crypto.randomBytes(7).copy( a, i );
2798 } else {
2799
2800 // 0 <= (v % 1e14) <= 99999999999999
2801 c.push( v % 1e14 );
2802 i += 7;
2803 }
2804 }
2805 i = k / 7;
2806 } else {
2807 CRYPTO = false;
2808 if (ERRORS) raise( 14, 'crypto unavailable', crypto );
2809 }
2810 }
2811
2812 // Use Math.random.
2813 if (!CRYPTO) {
2814
2815 for ( ; i < k; ) {
2816 v = random53bitInt();
2817 if ( v < 9e15 ) c[i++] = v % 1e14;
2818 }
2819 }
2820
2821 k = c[--i];
2822 dp %= LOG_BASE;
2823
2824 // Convert trailing digits to zeros according to dp.
2825 if ( k && dp ) {
2826 v = POWS_TEN[LOG_BASE - dp];
2827 c[i] = mathfloor( k / v ) * v;
2828 }
2829
2830 // Remove trailing elements which are zero.
2831 for ( ; c[i] === 0; c.pop(), i-- );
2832
2833 // Zero?
2834 if ( i < 0 ) {
2835 c = [ e = 0 ];
2836 } else {
2837
2838 // Remove leading elements which are zero and adjust exponent accordingly.
2839 for ( e = -1 ; c[0] === 0; c.splice(0, 1), e -= LOG_BASE);
2840
2841 // Count the digits of the first element of c to determine leading zeros, and...
2842 for ( i = 1, v = c[0]; v >= 10; v /= 10, i++);
2843
2844 // adjust the exponent accordingly.
2845 if ( i < LOG_BASE ) e -= LOG_BASE - i;
2846 }
2847
2848 rand.e = e;
2849 rand.c = c;
2850 return rand;
2851 };
2852 })();
2853
2854
2855 // PRIVATE FUNCTIONS
2856
2857
2858 // Convert a numeric string of baseIn to a numeric string of baseOut.
2859 function convertBase( str, baseOut, baseIn, sign ) {
2860 var d, e, k, r, x, xc, y,
2861 i = str.indexOf( '.' ),
2862 dp = DECIMAL_PLACES,
2863 rm = ROUNDING_MODE;
2864
2865 if ( baseIn < 37 ) str = str.toLowerCase();
2866
2867 // Non-integer.
2868 if ( i >= 0 ) {
2869 k = POW_PRECISION;
2870
2871 // Unlimited precision.
2872 POW_PRECISION = 0;
2873 str = str.replace( '.', '' );
2874 y = new BigNumber(baseIn);
2875 x = y.pow( str.length - i );
2876 POW_PRECISION = k;
2877
2878 // Convert str as if an integer, then restore the fraction part by dividing the
2879 // result by its base raised to a power.
2880 y.c = toBaseOut( toFixedPoint( coeffToString( x.c ), x.e ), 10, baseOut );
2881 y.e = y.c.length;
2882 }
2883
2884 // Convert the number as integer.
2885 xc = toBaseOut( str, baseIn, baseOut );
2886 e = k = xc.length;
2887
2888 // Remove trailing zeros.
2889 for ( ; xc[--k] == 0; xc.pop() );
2890 if ( !xc[0] ) return '0';
2891
2892 if ( i < 0 ) {
2893 --e;
2894 } else {
2895 x.c = xc;
2896 x.e = e;
2897
2898 // sign is needed for correct rounding.
2899 x.s = sign;
2900 x = div( x, y, dp, rm, baseOut );
2901 xc = x.c;
2902 r = x.r;
2903 e = x.e;
2904 }
2905
2906 d = e + dp + 1;
2907
2908 // The rounding digit, i.e. the digit to the right of the digit that may be rounded up.
2909 i = xc[d];
2910 k = baseOut / 2;
2911 r = r || d < 0 || xc[d + 1] != null;
2912
2913 r = rm < 4 ? ( i != null || r ) && ( rm == 0 || rm == ( x.s < 0 ? 3 : 2 ) )
2914 : i > k || i == k &&( rm == 4 || r || rm == 6 && xc[d - 1] & 1 ||
2915 rm == ( x.s < 0 ? 8 : 7 ) );
2916
2917 if ( d < 1 || !xc[0] ) {
2918
2919 // 1^-dp or 0.
2920 str = r ? toFixedPoint( '1', -dp ) : '0';
2921 } else {
2922 xc.length = d;
2923
2924 if (r) {
2925
2926 // Rounding up may mean the previous digit has to be rounded up and so on.
2927 for ( --baseOut; ++xc[--d] > baseOut; ) {
2928 xc[d] = 0;
2929
2930 if ( !d ) {
2931 ++e;
2932 xc = [1].concat(xc);
2933 }
2934 }
2935 }
2936
2937 // Determine trailing zeros.
2938 for ( k = xc.length; !xc[--k]; );
2939
2940 // E.g. [4, 11, 15] becomes 4bf.
2941 for ( i = 0, str = ''; i <= k; str += ALPHABET.charAt( xc[i++] ) );
2942 str = toFixedPoint( str, e );
2943 }
2944
2945 // The caller will add the sign.
2946 return str;
2947 }
2948
2949
2950 // Perform division in the specified base. Called by div and convertBase.
2951 div = (function () {
2952
2953 // Assume non-zero x and k.
2954 function multiply( x, k, base ) {
2955 var m, temp, xlo, xhi,
2956 carry = 0,
2957 i = x.length,
2958 klo = k % SQRT_BASE,
2959 khi = k / SQRT_BASE | 0;
2960
2961 for ( x = x.slice(); i--; ) {
2962 xlo = x[i] % SQRT_BASE;
2963 xhi = x[i] / SQRT_BASE | 0;
2964 m = khi * xlo + xhi * klo;
2965 temp = klo * xlo + ( ( m % SQRT_BASE ) * SQRT_BASE ) + carry;
2966 carry = ( temp / base | 0 ) + ( m / SQRT_BASE | 0 ) + khi * xhi;
2967 x[i] = temp % base;
2968 }
2969
2970 if (carry) x = [carry].concat(x);
2971
2972 return x;
2973 }
2974
2975 function compare( a, b, aL, bL ) {
2976 var i, cmp;
2977
2978 if ( aL != bL ) {
2979 cmp = aL > bL ? 1 : -1;
2980 } else {
2981
2982 for ( i = cmp = 0; i < aL; i++ ) {
2983
2984 if ( a[i] != b[i] ) {
2985 cmp = a[i] > b[i] ? 1 : -1;
2986 break;
2987 }
2988 }
2989 }
2990 return cmp;
2991 }
2992
2993 function subtract( a, b, aL, base ) {
2994 var i = 0;
2995
2996 // Subtract b from a.
2997 for ( ; aL--; ) {
2998 a[aL] -= i;
2999 i = a[aL] < b[aL] ? 1 : 0;
3000 a[aL] = i * base + a[aL] - b[aL];
3001 }
3002
3003 // Remove leading zeros.
3004 for ( ; !a[0] && a.length > 1; a.splice(0, 1) );
3005 }
3006
3007 // x: dividend, y: divisor.
3008 return function ( x, y, dp, rm, base ) {
3009 var cmp, e, i, more, n, prod, prodL, q, qc, rem, remL, rem0, xi, xL, yc0,
3010 yL, yz,
3011 s = x.s == y.s ? 1 : -1,
3012 xc = x.c,
3013 yc = y.c;
3014
3015 // Either NaN, Infinity or 0?
3016 if ( !xc || !xc[0] || !yc || !yc[0] ) {
3017
3018 return new BigNumber(
3019
3020 // Return NaN if either NaN, or both Infinity or 0.
3021 !x.s || !y.s || ( xc ? yc && xc[0] == yc[0] : !yc ) ? NaN :
3022
3023 // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0.
3024 xc && xc[0] == 0 || !yc ? s * 0 : s / 0
3025 );
3026 }
3027
3028 q = new BigNumber(s);
3029 qc = q.c = [];
3030 e = x.e - y.e;
3031 s = dp + e + 1;
3032
3033 if ( !base ) {
3034 base = BASE;
3035 e = bitFloor( x.e / LOG_BASE ) - bitFloor( y.e / LOG_BASE );
3036 s = s / LOG_BASE | 0;
3037 }
3038
3039 // Result exponent may be one less then the current value of e.
3040 // The coefficients of the BigNumbers from convertBase may have trailing zeros.
3041 for ( i = 0; yc[i] == ( xc[i] || 0 ); i++ );
3042 if ( yc[i] > ( xc[i] || 0 ) ) e--;
3043
3044 if ( s < 0 ) {
3045 qc.push(1);
3046 more = true;
3047 } else {
3048 xL = xc.length;
3049 yL = yc.length;
3050 i = 0;
3051 s += 2;
3052
3053 // Normalise xc and yc so highest order digit of yc is >= base / 2.
3054
3055 n = mathfloor( base / ( yc[0] + 1 ) );
3056
3057 // Not necessary, but to handle odd bases where yc[0] == ( base / 2 ) - 1.
3058 // if ( n > 1 || n++ == 1 && yc[0] < base / 2 ) {
3059 if ( n > 1 ) {
3060 yc = multiply( yc, n, base );
3061 xc = multiply( xc, n, base );
3062 yL = yc.length;
3063 xL = xc.length;
3064 }
3065
3066 xi = yL;
3067 rem = xc.slice( 0, yL );
3068 remL = rem.length;
3069
3070 // Add zeros to make remainder as long as divisor.
3071 for ( ; remL < yL; rem[remL++] = 0 );
3072 yz = yc.slice();
3073 yz = [0].concat(yz);
3074 yc0 = yc[0];
3075 if ( yc[1] >= base / 2 ) yc0++;
3076 // Not necessary, but to prevent trial digit n > base, when using base 3.
3077 // else if ( base == 3 && yc0 == 1 ) yc0 = 1 + 1e-15;
3078
3079 do {
3080 n = 0;
3081
3082 // Compare divisor and remainder.
3083 cmp = compare( yc, rem, yL, remL );
3084
3085 // If divisor < remainder.
3086 if ( cmp < 0 ) {
3087
3088 // Calculate trial digit, n.
3089
3090 rem0 = rem[0];
3091 if ( yL != remL ) rem0 = rem0 * base + ( rem[1] || 0 );
3092
3093 // n is how many times the divisor goes into the current remainder.
3094 n = mathfloor( rem0 / yc0 );
3095
3096 // Algorithm:
3097 // 1. product = divisor * trial digit (n)
3098 // 2. if product > remainder: product -= divisor, n--
3099 // 3. remainder -= product
3100 // 4. if product was < remainder at 2:
3101 // 5. compare new remainder and divisor
3102 // 6. If remainder > divisor: remainder -= divisor, n++
3103
3104 if ( n > 1 ) {
3105
3106 // n may be > base only when base is 3.
3107 if (n >= base) n = base - 1;
3108
3109 // product = divisor * trial digit.
3110 prod = multiply( yc, n, base );
3111 prodL = prod.length;
3112 remL = rem.length;
3113
3114 // Compare product and remainder.
3115 // If product > remainder.
3116 // Trial digit n too high.
3117 // n is 1 too high about 5% of the time, and is not known to have
3118 // ever been more than 1 too high.
3119 while ( compare( prod, rem, prodL, remL ) == 1 ) {
3120 n--;
3121
3122 // Subtract divisor from product.
3123 subtract( prod, yL < prodL ? yz : yc, prodL, base );
3124 prodL = prod.length;
3125 cmp = 1;
3126 }
3127 } else {
3128
3129 // n is 0 or 1, cmp is -1.
3130 // If n is 0, there is no need to compare yc and rem again below,
3131 // so change cmp to 1 to avoid it.
3132 // If n is 1, leave cmp as -1, so yc and rem are compared again.
3133 if ( n == 0 ) {
3134
3135 // divisor < remainder, so n must be at least 1.
3136 cmp = n = 1;
3137 }
3138
3139 // product = divisor
3140 prod = yc.slice();
3141 prodL = prod.length;
3142 }
3143
3144 if ( prodL < remL ) prod = [0].concat(prod);
3145
3146 // Subtract product from remainder.
3147 subtract( rem, prod, remL, base );
3148 remL = rem.length;
3149
3150 // If product was < remainder.
3151 if ( cmp == -1 ) {
3152
3153 // Compare divisor and new remainder.
3154 // If divisor < new remainder, subtract divisor from remainder.
3155 // Trial digit n too low.
3156 // n is 1 too low about 5% of the time, and very rarely 2 too low.
3157 while ( compare( yc, rem, yL, remL ) < 1 ) {
3158 n++;
3159
3160 // Subtract divisor from remainder.
3161 subtract( rem, yL < remL ? yz : yc, remL, base );
3162 remL = rem.length;
3163 }
3164 }
3165 } else if ( cmp === 0 ) {
3166 n++;
3167 rem = [0];
3168 } // else cmp === 1 and n will be 0
3169
3170 // Add the next digit, n, to the result array.
3171 qc[i++] = n;
3172
3173 // Update the remainder.
3174 if ( rem[0] ) {
3175 rem[remL++] = xc[xi] || 0;
3176 } else {
3177 rem = [ xc[xi] ];
3178 remL = 1;
3179 }
3180 } while ( ( xi++ < xL || rem[0] != null ) && s-- );
3181
3182 more = rem[0] != null;
3183
3184 // Leading zero?
3185 if ( !qc[0] ) qc.splice(0, 1);
3186 }
3187
3188 if ( base == BASE ) {
3189
3190 // To calculate q.e, first get the number of digits of qc[0].
3191 for ( i = 1, s = qc[0]; s >= 10; s /= 10, i++ );
3192 round( q, dp + ( q.e = i + e * LOG_BASE - 1 ) + 1, rm, more );
3193
3194 // Caller is convertBase.
3195 } else {
3196 q.e = e;
3197 q.r = +more;
3198 }
3199
3200 return q;
3201 };
3202 })();
3203
3204
3205 /*
3206 * Return a string representing the value of BigNumber n in fixed-point or exponential
3207 * notation rounded to the specified decimal places or significant digits.
3208 *
3209 * n is a BigNumber.
3210 * i is the index of the last digit required (i.e. the digit that may be rounded up).
3211 * rm is the rounding mode.
3212 * caller is caller id: toExponential 19, toFixed 20, toFormat 21, toPrecision 24.
3213 */
3214 function format( n, i, rm, caller ) {
3215 var c0, e, ne, len, str;
3216
3217 rm = rm != null && isValidInt( rm, 0, 8, caller, roundingMode )
3218 ? rm | 0 : ROUNDING_MODE;
3219
3220 if ( !n.c ) return n.toString();
3221 c0 = n.c[0];
3222 ne = n.e;
3223
3224 if ( i == null ) {
3225 str = coeffToString( n.c );
3226 str = caller == 19 || caller == 24 && ne <= TO_EXP_NEG
3227 ? toExponential( str, ne )
3228 : toFixedPoint( str, ne );
3229 } else {
3230 n = round( new BigNumber(n), i, rm );
3231
3232 // n.e may have changed if the value was rounded up.
3233 e = n.e;
3234
3235 str = coeffToString( n.c );
3236 len = str.length;
3237
3238 // toPrecision returns exponential notation if the number of significant digits
3239 // specified is less than the number of digits necessary to represent the integer
3240 // part of the value in fixed-point notation.
3241
3242 // Exponential notation.
3243 if ( caller == 19 || caller == 24 && ( i <= e || e <= TO_EXP_NEG ) ) {
3244
3245 // Append zeros?
3246 for ( ; len < i; str += '0', len++ );
3247 str = toExponential( str, e );
3248
3249 // Fixed-point notation.
3250 } else {
3251 i -= ne;
3252 str = toFixedPoint( str, e );
3253
3254 // Append zeros?
3255 if ( e + 1 > len ) {
3256 if ( --i > 0 ) for ( str += '.'; i--; str += '0' );
3257 } else {
3258 i += e - len;
3259 if ( i > 0 ) {
3260 if ( e + 1 == len ) str += '.';
3261 for ( ; i--; str += '0' );
3262 }
3263 }
3264 }
3265 }
3266
3267 return n.s < 0 && c0 ? '-' + str : str;
3268 }
3269
3270
3271 // Handle BigNumber.max and BigNumber.min.
3272 function maxOrMin( args, method ) {
3273 var m, n,
3274 i = 0;
3275
3276 if ( isArray( args[0] ) ) args = args[0];
3277 m = new BigNumber( args[0] );
3278
3279 for ( ; ++i < args.length; ) {
3280 n = new BigNumber( args[i] );
3281
3282 // If any number is NaN, return NaN.
3283 if ( !n.s ) {
3284 m = n;
3285 break;
3286 } else if ( method.call( m, n ) ) {
3287 m = n;
3288 }
3289 }
3290
3291 return m;
3292 }
3293
3294
3295 /*
3296 * Return true if n is an integer in range, otherwise throw.
3297 * Use for argument validation when ERRORS is true.
3298 */
3299 function intValidatorWithErrors( n, min, max, caller, name ) {
3300 if ( n < min || n > max || n != truncate(n) ) {
3301 raise( caller, ( name || 'decimal places' ) +
3302 ( n < min || n > max ? ' out of range' : ' not an integer' ), n );
3303 }
3304
3305 return true;
3306 }
3307
3308
3309 /*
3310 * Strip trailing zeros, calculate base 10 exponent and check against MIN_EXP and MAX_EXP.
3311 * Called by minus, plus and times.
3312 */
3313 function normalise( n, c, e ) {
3314 var i = 1,
3315 j = c.length;
3316
3317 // Remove trailing zeros.
3318 for ( ; !c[--j]; c.pop() );
3319
3320 // Calculate the base 10 exponent. First get the number of digits of c[0].
3321 for ( j = c[0]; j >= 10; j /= 10, i++ );
3322
3323 // Overflow?
3324 if ( ( e = i + e * LOG_BASE - 1 ) > MAX_EXP ) {
3325
3326 // Infinity.
3327 n.c = n.e = null;
3328
3329 // Underflow?
3330 } else if ( e < MIN_EXP ) {
3331
3332 // Zero.
3333 n.c = [ n.e = 0 ];
3334 } else {
3335 n.e = e;
3336 n.c = c;
3337 }
3338
3339 return n;
3340 }
3341
3342
3343 // Handle values that fail the validity test in BigNumber.
3344 parseNumeric = (function () {
3345 var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i,
3346 dotAfter = /^([^.]+)\.$/,
3347 dotBefore = /^\.([^.]+)$/,
3348 isInfinityOrNaN = /^-?(Infinity|NaN)$/,
3349 whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
3350
3351 return function ( x, str, num, b ) {
3352 var base,
3353 s = num ? str : str.replace( whitespaceOrPlus, '' );
3354
3355 // No exception on ±Infinity or NaN.
3356 if ( isInfinityOrNaN.test(s) ) {
3357 x.s = isNaN(s) ? null : s < 0 ? -1 : 1;
3358 } else {
3359 if ( !num ) {
3360
3361 // basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i
3362 s = s.replace( basePrefix, function ( m, p1, p2 ) {
3363 base = ( p2 = p2.toLowerCase() ) == 'x' ? 16 : p2 == 'b' ? 2 : 8;
3364 return !b || b == base ? p1 : m;
3365 });
3366
3367 if (b) {
3368 base = b;
3369
3370 // E.g. '1.' to '1', '.1' to '0.1'
3371 s = s.replace( dotAfter, '$1' ).replace( dotBefore, '0.$1' );
3372 }
3373
3374 if ( str != s ) return new BigNumber( s, base );
3375 }
3376
3377 // 'new BigNumber() not a number: {n}'
3378 // 'new BigNumber() not a base {b} number: {n}'
3379 if (ERRORS) raise( id, 'not a' + ( b ? ' base ' + b : '' ) + ' number', str );
3380 x.s = null;
3381 }
3382
3383 x.c = x.e = null;
3384 id = 0;
3385 }
3386 })();
3387
3388
3389 // Throw a BigNumber Error.
3390 function raise( caller, msg, val ) {
3391 var error = new Error( [
3392 'new BigNumber', // 0
3393 'cmp', // 1
3394 'config', // 2
3395 'div', // 3
3396 'divToInt', // 4
3397 'eq', // 5
3398 'gt', // 6
3399 'gte', // 7
3400 'lt', // 8
3401 'lte', // 9
3402 'minus', // 10
3403 'mod', // 11
3404 'plus', // 12
3405 'precision', // 13
3406 'random', // 14
3407 'round', // 15
3408 'shift', // 16
3409 'times', // 17
3410 'toDigits', // 18
3411 'toExponential', // 19
3412 'toFixed', // 20
3413 'toFormat', // 21
3414 'toFraction', // 22
3415 'pow', // 23
3416 'toPrecision', // 24
3417 'toString', // 25
3418 'BigNumber' // 26
3419 ][caller] + '() ' + msg + ': ' + val );
3420
3421 error.name = 'BigNumber Error';
3422 id = 0;
3423 throw error;
3424 }
3425
3426
3427 /*
3428 * Round x to sd significant digits using rounding mode rm. Check for over/under-flow.
3429 * If r is truthy, it is known that there are more digits after the rounding digit.
3430 */
3431 function round( x, sd, rm, r ) {
3432 var d, i, j, k, n, ni, rd,
3433 xc = x.c,
3434 pows10 = POWS_TEN;
3435
3436 // if x is not Infinity or NaN...
3437 if (xc) {
3438
3439 // rd is the rounding digit, i.e. the digit after the digit that may be rounded up.
3440 // n is a base 1e14 number, the value of the element of array x.c containing rd.
3441 // ni is the index of n within x.c.
3442 // d is the number of digits of n.
3443 // i is the index of rd within n including leading zeros.
3444 // j is the actual index of rd within n (if < 0, rd is a leading zero).
3445 out: {
3446
3447 // Get the number of digits of the first element of xc.
3448 for ( d = 1, k = xc[0]; k >= 10; k /= 10, d++ );
3449 i = sd - d;
3450
3451 // If the rounding digit is in the first element of xc...
3452 if ( i < 0 ) {
3453 i += LOG_BASE;
3454 j = sd;
3455 n = xc[ ni = 0 ];
3456
3457 // Get the rounding digit at index j of n.
3458 rd = n / pows10[ d - j - 1 ] % 10 | 0;
3459 } else {
3460 ni = mathceil( ( i + 1 ) / LOG_BASE );
3461
3462 if ( ni >= xc.length ) {
3463
3464 if (r) {
3465
3466 // Needed by sqrt.
3467 for ( ; xc.length <= ni; xc.push(0) );
3468 n = rd = 0;
3469 d = 1;
3470 i %= LOG_BASE;
3471 j = i - LOG_BASE + 1;
3472 } else {
3473 break out;
3474 }
3475 } else {
3476 n = k = xc[ni];
3477
3478 // Get the number of digits of n.
3479 for ( d = 1; k >= 10; k /= 10, d++ );
3480
3481 // Get the index of rd within n.
3482 i %= LOG_BASE;
3483
3484 // Get the index of rd within n, adjusted for leading zeros.
3485 // The number of leading zeros of n is given by LOG_BASE - d.
3486 j = i - LOG_BASE + d;
3487
3488 // Get the rounding digit at index j of n.
3489 rd = j < 0 ? 0 : n / pows10[ d - j - 1 ] % 10 | 0;
3490 }
3491 }
3492
3493 r = r || sd < 0 ||
3494
3495 // Are there any non-zero digits after the rounding digit?
3496 // The expression n % pows10[ d - j - 1 ] returns all digits of n to the right
3497 // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.
3498 xc[ni + 1] != null || ( j < 0 ? n : n % pows10[ d - j - 1 ] );
3499
3500 r = rm < 4
3501 ? ( rd || r ) && ( rm == 0 || rm == ( x.s < 0 ? 3 : 2 ) )
3502 : rd > 5 || rd == 5 && ( rm == 4 || r || rm == 6 &&
3503
3504 // Check whether the digit to the left of the rounding digit is odd.
3505 ( ( i > 0 ? j > 0 ? n / pows10[ d - j ] : 0 : xc[ni - 1] ) % 10 ) & 1 ||
3506 rm == ( x.s < 0 ? 8 : 7 ) );
3507
3508 if ( sd < 1 || !xc[0] ) {
3509 xc.length = 0;
3510
3511 if (r) {
3512
3513 // Convert sd to decimal places.
3514 sd -= x.e + 1;
3515
3516 // 1, 0.1, 0.01, 0.001, 0.0001 etc.
3517 xc[0] = pows10[ ( LOG_BASE - sd % LOG_BASE ) % LOG_BASE ];
3518 x.e = -sd || 0;
3519 } else {
3520
3521 // Zero.
3522 xc[0] = x.e = 0;
3523 }
3524
3525 return x;
3526 }
3527
3528 // Remove excess digits.
3529 if ( i == 0 ) {
3530 xc.length = ni;
3531 k = 1;
3532 ni--;
3533 } else {
3534 xc.length = ni + 1;
3535 k = pows10[ LOG_BASE - i ];
3536
3537 // E.g. 56700 becomes 56000 if 7 is the rounding digit.
3538 // j > 0 means i > number of leading zeros of n.
3539 xc[ni] = j > 0 ? mathfloor( n / pows10[ d - j ] % pows10[j] ) * k : 0;
3540 }
3541
3542 // Round up?
3543 if (r) {
3544
3545 for ( ; ; ) {
3546
3547 // If the digit to be rounded up is in the first element of xc...
3548 if ( ni == 0 ) {
3549
3550 // i will be the length of xc[0] before k is added.
3551 for ( i = 1, j = xc[0]; j >= 10; j /= 10, i++ );
3552 j = xc[0] += k;
3553 for ( k = 1; j >= 10; j /= 10, k++ );
3554
3555 // if i != k the length has increased.
3556 if ( i != k ) {
3557 x.e++;
3558 if ( xc[0] == BASE ) xc[0] = 1;
3559 }
3560
3561 break;
3562 } else {
3563 xc[ni] += k;
3564 if ( xc[ni] != BASE ) break;
3565 xc[ni--] = 0;
3566 k = 1;
3567 }
3568 }
3569 }
3570
3571 // Remove trailing zeros.
3572 for ( i = xc.length; xc[--i] === 0; xc.pop() );
3573 }
3574
3575 // Overflow? Infinity.
3576 if ( x.e > MAX_EXP ) {
3577 x.c = x.e = null;
3578
3579 // Underflow? Zero.
3580 } else if ( x.e < MIN_EXP ) {
3581 x.c = [ x.e = 0 ];
3582 }
3583 }
3584
3585 return x;
3586 }
3587
3588
3589 // PROTOTYPE/INSTANCE METHODS
3590
3591
3592 /*
3593 * Return a new BigNumber whose value is the absolute value of this BigNumber.
3594 */
3595 P.absoluteValue = P.abs = function () {
3596 var x = new BigNumber(this);
3597 if ( x.s < 0 ) x.s = 1;
3598 return x;
3599 };
3600
3601
3602 /*
3603 * Return a new BigNumber whose value is the value of this BigNumber rounded to a whole
3604 * number in the direction of Infinity.
3605 */
3606 P.ceil = function () {
3607 return round( new BigNumber(this), this.e + 1, 2 );
3608 };
3609
3610
3611 /*
3612 * Return
3613 * 1 if the value of this BigNumber is greater than the value of BigNumber(y, b),
3614 * -1 if the value of this BigNumber is less than the value of BigNumber(y, b),
3615 * 0 if they have the same value,
3616 * or null if the value of either is NaN.
3617 */
3618 P.comparedTo = P.cmp = function ( y, b ) {
3619 id = 1;
3620 return compare( this, new BigNumber( y, b ) );
3621 };
3622
3623
3624 /*
3625 * Return the number of decimal places of the value of this BigNumber, or null if the value
3626 * of this BigNumber is ±Infinity or NaN.
3627 */
3628 P.decimalPlaces = P.dp = function () {
3629 var n, v,
3630 c = this.c;
3631
3632 if ( !c ) return null;
3633 n = ( ( v = c.length - 1 ) - bitFloor( this.e / LOG_BASE ) ) * LOG_BASE;
3634
3635 // Subtract the number of trailing zeros of the last number.
3636 if ( v = c[v] ) for ( ; v % 10 == 0; v /= 10, n-- );
3637 if ( n < 0 ) n = 0;
3638
3639 return n;
3640 };
3641
3642
3643 /*
3644 * n / 0 = I
3645 * n / N = N
3646 * n / I = 0
3647 * 0 / n = 0
3648 * 0 / 0 = N
3649 * 0 / N = N
3650 * 0 / I = 0
3651 * N / n = N
3652 * N / 0 = N
3653 * N / N = N
3654 * N / I = N
3655 * I / n = I
3656 * I / 0 = I
3657 * I / N = N
3658 * I / I = N
3659 *
3660 * Return a new BigNumber whose value is the value of this BigNumber divided by the value of
3661 * BigNumber(y, b), rounded according to DECIMAL_PLACES and ROUNDING_MODE.
3662 */
3663 P.dividedBy = P.div = function ( y, b ) {
3664 id = 3;
3665 return div( this, new BigNumber( y, b ), DECIMAL_PLACES, ROUNDING_MODE );
3666 };
3667
3668
3669 /*
3670 * Return a new BigNumber whose value is the integer part of dividing the value of this
3671 * BigNumber by the value of BigNumber(y, b).
3672 */
3673 P.dividedToIntegerBy = P.divToInt = function ( y, b ) {
3674 id = 4;
3675 return div( this, new BigNumber( y, b ), 0, 1 );
3676 };
3677
3678
3679 /*
3680 * Return true if the value of this BigNumber is equal to the value of BigNumber(y, b),
3681 * otherwise returns false.
3682 */
3683 P.equals = P.eq = function ( y, b ) {
3684 id = 5;
3685 return compare( this, new BigNumber( y, b ) ) === 0;
3686 };
3687
3688
3689 /*
3690 * Return a new BigNumber whose value is the value of this BigNumber rounded to a whole
3691 * number in the direction of -Infinity.
3692 */
3693 P.floor = function () {
3694 return round( new BigNumber(this), this.e + 1, 3 );
3695 };
3696
3697
3698 /*
3699 * Return true if the value of this BigNumber is greater than the value of BigNumber(y, b),
3700 * otherwise returns false.
3701 */
3702 P.greaterThan = P.gt = function ( y, b ) {
3703 id = 6;
3704 return compare( this, new BigNumber( y, b ) ) > 0;
3705 };
3706
3707
3708 /*
3709 * Return true if the value of this BigNumber is greater than or equal to the value of
3710 * BigNumber(y, b), otherwise returns false.
3711 */
3712 P.greaterThanOrEqualTo = P.gte = function ( y, b ) {
3713 id = 7;
3714 return ( b = compare( this, new BigNumber( y, b ) ) ) === 1 || b === 0;
3715
3716 };
3717
3718
3719 /*
3720 * Return true if the value of this BigNumber is a finite number, otherwise returns false.
3721 */
3722 P.isFinite = function () {
3723 return !!this.c;
3724 };
3725
3726
3727 /*
3728 * Return true if the value of this BigNumber is an integer, otherwise return false.
3729 */
3730 P.isInteger = P.isInt = function () {
3731 return !!this.c && bitFloor( this.e / LOG_BASE ) > this.c.length - 2;
3732 };
3733
3734
3735 /*
3736 * Return true if the value of this BigNumber is NaN, otherwise returns false.
3737 */
3738 P.isNaN = function () {
3739 return !this.s;
3740 };
3741
3742
3743 /*
3744 * Return true if the value of this BigNumber is negative, otherwise returns false.
3745 */
3746 P.isNegative = P.isNeg = function () {
3747 return this.s < 0;
3748 };
3749
3750
3751 /*
3752 * Return true if the value of this BigNumber is 0 or -0, otherwise returns false.
3753 */
3754 P.isZero = function () {
3755 return !!this.c && this.c[0] == 0;
3756 };
3757
3758
3759 /*
3760 * Return true if the value of this BigNumber is less than the value of BigNumber(y, b),
3761 * otherwise returns false.
3762 */
3763 P.lessThan = P.lt = function ( y, b ) {
3764 id = 8;
3765 return compare( this, new BigNumber( y, b ) ) < 0;
3766 };
3767
3768
3769 /*
3770 * Return true if the value of this BigNumber is less than or equal to the value of
3771 * BigNumber(y, b), otherwise returns false.
3772 */
3773 P.lessThanOrEqualTo = P.lte = function ( y, b ) {
3774 id = 9;
3775 return ( b = compare( this, new BigNumber( y, b ) ) ) === -1 || b === 0;
3776 };
3777
3778
3779 /*
3780 * n - 0 = n
3781 * n - N = N
3782 * n - I = -I
3783 * 0 - n = -n
3784 * 0 - 0 = 0
3785 * 0 - N = N
3786 * 0 - I = -I
3787 * N - n = N
3788 * N - 0 = N
3789 * N - N = N
3790 * N - I = N
3791 * I - n = I
3792 * I - 0 = I
3793 * I - N = N
3794 * I - I = N
3795 *
3796 * Return a new BigNumber whose value is the value of this BigNumber minus the value of
3797 * BigNumber(y, b).
3798 */
3799 P.minus = P.sub = function ( y, b ) {
3800 var i, j, t, xLTy,
3801 x = this,
3802 a = x.s;
3803
3804 id = 10;
3805 y = new BigNumber( y, b );
3806 b = y.s;
3807
3808 // Either NaN?
3809 if ( !a || !b ) return new BigNumber(NaN);
3810
3811 // Signs differ?
3812 if ( a != b ) {
3813 y.s = -b;
3814 return x.plus(y);
3815 }
3816
3817 var xe = x.e / LOG_BASE,
3818 ye = y.e / LOG_BASE,
3819 xc = x.c,
3820 yc = y.c;
3821
3822 if ( !xe || !ye ) {
3823
3824 // Either Infinity?
3825 if ( !xc || !yc ) return xc ? ( y.s = -b, y ) : new BigNumber( yc ? x : NaN );
3826
3827 // Either zero?
3828 if ( !xc[0] || !yc[0] ) {
3829
3830 // Return y if y is non-zero, x if x is non-zero, or zero if both are zero.
3831 return yc[0] ? ( y.s = -b, y ) : new BigNumber( xc[0] ? x :
3832
3833 // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
3834 ROUNDING_MODE == 3 ? -0 : 0 );
3835 }
3836 }
3837
3838 xe = bitFloor(xe);
3839 ye = bitFloor(ye);
3840 xc = xc.slice();
3841
3842 // Determine which is the bigger number.
3843 if ( a = xe - ye ) {
3844
3845 if ( xLTy = a < 0 ) {
3846 a = -a;
3847 t = xc;
3848 } else {
3849 ye = xe;
3850 t = yc;
3851 }
3852
3853 t.reverse();
3854
3855 // Prepend zeros to equalise exponents.
3856 for ( b = a; b--; t.push(0) );
3857 t.reverse();
3858 } else {
3859
3860 // Exponents equal. Check digit by digit.
3861 j = ( xLTy = ( a = xc.length ) < ( b = yc.length ) ) ? a : b;
3862
3863 for ( a = b = 0; b < j; b++ ) {
3864
3865 if ( xc[b] != yc[b] ) {
3866 xLTy = xc[b] < yc[b];
3867 break;
3868 }
3869 }
3870 }
3871
3872 // x < y? Point xc to the array of the bigger number.
3873 if (xLTy) t = xc, xc = yc, yc = t, y.s = -y.s;
3874
3875 b = ( j = yc.length ) - ( i = xc.length );
3876
3877 // Append zeros to xc if shorter.
3878 // No need to add zeros to yc if shorter as subtract only needs to start at yc.length.
3879 if ( b > 0 ) for ( ; b--; xc[i++] = 0 );
3880 b = BASE - 1;
3881
3882 // Subtract yc from xc.
3883 for ( ; j > a; ) {
3884
3885 if ( xc[--j] < yc[j] ) {
3886 for ( i = j; i && !xc[--i]; xc[i] = b );
3887 --xc[i];
3888 xc[j] += BASE;
3889 }
3890
3891 xc[j] -= yc[j];
3892 }
3893
3894 // Remove leading zeros and adjust exponent accordingly.
3895 for ( ; xc[0] == 0; xc.splice(0, 1), --ye );
3896
3897 // Zero?
3898 if ( !xc[0] ) {
3899
3900 // Following IEEE 754 (2008) 6.3,
3901 // n - n = +0 but n - n = -0 when rounding towards -Infinity.
3902 y.s = ROUNDING_MODE == 3 ? -1 : 1;
3903 y.c = [ y.e = 0 ];
3904 return y;
3905 }
3906
3907 // No need to check for Infinity as +x - +y != Infinity && -x - -y != Infinity
3908 // for finite x and y.
3909 return normalise( y, xc, ye );
3910 };
3911
3912
3913 /*
3914 * n % 0 = N
3915 * n % N = N
3916 * n % I = n
3917 * 0 % n = 0
3918 * -0 % n = -0
3919 * 0 % 0 = N
3920 * 0 % N = N
3921 * 0 % I = 0
3922 * N % n = N
3923 * N % 0 = N
3924 * N % N = N
3925 * N % I = N
3926 * I % n = N
3927 * I % 0 = N
3928 * I % N = N
3929 * I % I = N
3930 *
3931 * Return a new BigNumber whose value is the value of this BigNumber modulo the value of
3932 * BigNumber(y, b). The result depends on the value of MODULO_MODE.
3933 */
3934 P.modulo = P.mod = function ( y, b ) {
3935 var q, s,
3936 x = this;
3937
3938 id = 11;
3939 y = new BigNumber( y, b );
3940
3941 // Return NaN if x is Infinity or NaN, or y is NaN or zero.
3942 if ( !x.c || !y.s || y.c && !y.c[0] ) {
3943 return new BigNumber(NaN);
3944
3945 // Return x if y is Infinity or x is zero.
3946 } else if ( !y.c || x.c && !x.c[0] ) {
3947 return new BigNumber(x);
3948 }
3949
3950 if ( MODULO_MODE == 9 ) {
3951
3952 // Euclidian division: q = sign(y) * floor(x / abs(y))
3953 // r = x - qy where 0 <= r < abs(y)
3954 s = y.s;
3955 y.s = 1;
3956 q = div( x, y, 0, 3 );
3957 y.s = s;
3958 q.s *= s;
3959 } else {
3960 q = div( x, y, 0, MODULO_MODE );
3961 }
3962
3963 return x.minus( q.times(y) );
3964 };
3965
3966
3967 /*
3968 * Return a new BigNumber whose value is the value of this BigNumber negated,
3969 * i.e. multiplied by -1.
3970 */
3971 P.negated = P.neg = function () {
3972 var x = new BigNumber(this);
3973 x.s = -x.s || null;
3974 return x;
3975 };
3976
3977
3978 /*
3979 * n + 0 = n
3980 * n + N = N
3981 * n + I = I
3982 * 0 + n = n
3983 * 0 + 0 = 0
3984 * 0 + N = N
3985 * 0 + I = I
3986 * N + n = N
3987 * N + 0 = N
3988 * N + N = N
3989 * N + I = N
3990 * I + n = I
3991 * I + 0 = I
3992 * I + N = N
3993 * I + I = I
3994 *
3995 * Return a new BigNumber whose value is the value of this BigNumber plus the value of
3996 * BigNumber(y, b).
3997 */
3998 P.plus = P.add = function ( y, b ) {
3999 var t,
4000 x = this,
4001 a = x.s;
4002
4003 id = 12;
4004 y = new BigNumber( y, b );
4005 b = y.s;
4006
4007 // Either NaN?
4008 if ( !a || !b ) return new BigNumber(NaN);
4009
4010 // Signs differ?
4011 if ( a != b ) {
4012 y.s = -b;
4013 return x.minus(y);
4014 }
4015
4016 var xe = x.e / LOG_BASE,
4017 ye = y.e / LOG_BASE,
4018 xc = x.c,
4019 yc = y.c;
4020
4021 if ( !xe || !ye ) {
4022
4023 // Return ±Infinity if either ±Infinity.
4024 if ( !xc || !yc ) return new BigNumber( a / 0 );
4025
4026 // Either zero?
4027 // Return y if y is non-zero, x if x is non-zero, or zero if both are zero.
4028 if ( !xc[0] || !yc[0] ) return yc[0] ? y : new BigNumber( xc[0] ? x : a * 0 );
4029 }
4030
4031 xe = bitFloor(xe);
4032 ye = bitFloor(ye);
4033 xc = xc.slice();
4034
4035 // Prepend zeros to equalise exponents. Faster to use reverse then do unshifts.
4036 if ( a = xe - ye ) {
4037 if ( a > 0 ) {
4038 ye = xe;
4039 t = yc;
4040 } else {
4041 a = -a;
4042 t = xc;
4043 }
4044
4045 t.reverse();
4046 for ( ; a--; t.push(0) );
4047 t.reverse();
4048 }
4049
4050 a = xc.length;
4051 b = yc.length;
4052
4053 // Point xc to the longer array, and b to the shorter length.
4054 if ( a - b < 0 ) t = yc, yc = xc, xc = t, b = a;
4055
4056 // Only start adding at yc.length - 1 as the further digits of xc can be ignored.
4057 for ( a = 0; b; ) {
4058 a = ( xc[--b] = xc[b] + yc[b] + a ) / BASE | 0;
4059 xc[b] = BASE === xc[b] ? 0 : xc[b] % BASE;
4060 }
4061
4062 if (a) {
4063 xc = [a].concat(xc);
4064 ++ye;
4065 }
4066
4067 // No need to check for zero, as +x + +y != 0 && -x + -y != 0
4068 // ye = MAX_EXP + 1 possible
4069 return normalise( y, xc, ye );
4070 };
4071
4072
4073 /*
4074 * Return the number of significant digits of the value of this BigNumber.
4075 *
4076 * [z] {boolean|number} Whether to count integer-part trailing zeros: true, false, 1 or 0.
4077 */
4078 P.precision = P.sd = function (z) {
4079 var n, v,
4080 x = this,
4081 c = x.c;
4082
4083 // 'precision() argument not a boolean or binary digit: {z}'
4084 if ( z != null && z !== !!z && z !== 1 && z !== 0 ) {
4085 if (ERRORS) raise( 13, 'argument' + notBool, z );
4086 if ( z != !!z ) z = null;
4087 }
4088
4089 if ( !c ) return null;
4090 v = c.length - 1;
4091 n = v * LOG_BASE + 1;
4092
4093 if ( v = c[v] ) {
4094
4095 // Subtract the number of trailing zeros of the last element.
4096 for ( ; v % 10 == 0; v /= 10, n-- );
4097
4098 // Add the number of digits of the first element.
4099 for ( v = c[0]; v >= 10; v /= 10, n++ );
4100 }
4101
4102 if ( z && x.e + 1 > n ) n = x.e + 1;
4103
4104 return n;
4105 };
4106
4107
4108 /*
4109 * Return a new BigNumber whose value is the value of this BigNumber rounded to a maximum of
4110 * dp decimal places using rounding mode rm, or to 0 and ROUNDING_MODE respectively if
4111 * omitted.
4112 *
4113 * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
4114 * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
4115 *
4116 * 'round() decimal places out of range: {dp}'
4117 * 'round() decimal places not an integer: {dp}'
4118 * 'round() rounding mode not an integer: {rm}'
4119 * 'round() rounding mode out of range: {rm}'
4120 */
4121 P.round = function ( dp, rm ) {
4122 var n = new BigNumber(this);
4123
4124 if ( dp == null || isValidInt( dp, 0, MAX, 15 ) ) {
4125 round( n, ~~dp + this.e + 1, rm == null ||
4126 !isValidInt( rm, 0, 8, 15, roundingMode ) ? ROUNDING_MODE : rm | 0 );
4127 }
4128
4129 return n;
4130 };
4131
4132
4133 /*
4134 * Return a new BigNumber whose value is the value of this BigNumber shifted by k places
4135 * (powers of 10). Shift to the right if n > 0, and to the left if n < 0.
4136 *
4137 * k {number} Integer, -MAX_SAFE_INTEGER to MAX_SAFE_INTEGER inclusive.
4138 *
4139 * If k is out of range and ERRORS is false, the result will be ±0 if k < 0, or ±Infinity
4140 * otherwise.
4141 *
4142 * 'shift() argument not an integer: {k}'
4143 * 'shift() argument out of range: {k}'
4144 */
4145 P.shift = function (k) {
4146 var n = this;
4147 return isValidInt( k, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER, 16, 'argument' )
4148
4149 // k < 1e+21, or truncate(k) will produce exponential notation.
4150 ? n.times( '1e' + truncate(k) )
4151 : new BigNumber( n.c && n.c[0] && ( k < -MAX_SAFE_INTEGER || k > MAX_SAFE_INTEGER )
4152 ? n.s * ( k < 0 ? 0 : 1 / 0 )
4153 : n );
4154 };
4155
4156
4157 /*
4158 * sqrt(-n) = N
4159 * sqrt( N) = N
4160 * sqrt(-I) = N
4161 * sqrt( I) = I
4162 * sqrt( 0) = 0
4163 * sqrt(-0) = -0
4164 *
4165 * Return a new BigNumber whose value is the square root of the value of this BigNumber,
4166 * rounded according to DECIMAL_PLACES and ROUNDING_MODE.
4167 */
4168 P.squareRoot = P.sqrt = function () {
4169 var m, n, r, rep, t,
4170 x = this,
4171 c = x.c,
4172 s = x.s,
4173 e = x.e,
4174 dp = DECIMAL_PLACES + 4,
4175 half = new BigNumber('0.5');
4176
4177 // Negative/NaN/Infinity/zero?
4178 if ( s !== 1 || !c || !c[0] ) {
4179 return new BigNumber( !s || s < 0 && ( !c || c[0] ) ? NaN : c ? x : 1 / 0 );
4180 }
4181
4182 // Initial estimate.
4183 s = Math.sqrt( +x );
4184
4185 // Math.sqrt underflow/overflow?
4186 // Pass x to Math.sqrt as integer, then adjust the exponent of the result.
4187 if ( s == 0 || s == 1 / 0 ) {
4188 n = coeffToString(c);
4189 if ( ( n.length + e ) % 2 == 0 ) n += '0';
4190 s = Math.sqrt(n);
4191 e = bitFloor( ( e + 1 ) / 2 ) - ( e < 0 || e % 2 );
4192
4193 if ( s == 1 / 0 ) {
4194 n = '1e' + e;
4195 } else {
4196 n = s.toExponential();
4197 n = n.slice( 0, n.indexOf('e') + 1 ) + e;
4198 }
4199
4200 r = new BigNumber(n);
4201 } else {
4202 r = new BigNumber( s + '' );
4203 }
4204
4205 // Check for zero.
4206 // r could be zero if MIN_EXP is changed after the this value was created.
4207 // This would cause a division by zero (x/t) and hence Infinity below, which would cause
4208 // coeffToString to throw.
4209 if ( r.c[0] ) {
4210 e = r.e;
4211 s = e + dp;
4212 if ( s < 3 ) s = 0;
4213
4214 // Newton-Raphson iteration.
4215 for ( ; ; ) {
4216 t = r;
4217 r = half.times( t.plus( div( x, t, dp, 1 ) ) );
4218
4219 if ( coeffToString( t.c ).slice( 0, s ) === ( n =
4220 coeffToString( r.c ) ).slice( 0, s ) ) {
4221
4222 // The exponent of r may here be one less than the final result exponent,
4223 // e.g 0.0009999 (e-4) --> 0.001 (e-3), so adjust s so the rounding digits
4224 // are indexed correctly.
4225 if ( r.e < e ) --s;
4226 n = n.slice( s - 3, s + 1 );
4227
4228 // The 4th rounding digit may be in error by -1 so if the 4 rounding digits
4229 // are 9999 or 4999 (i.e. approaching a rounding boundary) continue the
4230 // iteration.
4231 if ( n == '9999' || !rep && n == '4999' ) {
4232
4233 // On the first iteration only, check to see if rounding up gives the
4234 // exact result as the nines may infinitely repeat.
4235 if ( !rep ) {
4236 round( t, t.e + DECIMAL_PLACES + 2, 0 );
4237
4238 if ( t.times(t).eq(x) ) {
4239 r = t;
4240 break;
4241 }
4242 }
4243
4244 dp += 4;
4245 s += 4;
4246 rep = 1;
4247 } else {
4248
4249 // If rounding digits are null, 0{0,4} or 50{0,3}, check for exact
4250 // result. If not, then there are further digits and m will be truthy.
4251 if ( !+n || !+n.slice(1) && n.charAt(0) == '5' ) {
4252
4253 // Truncate to the first rounding digit.
4254 round( r, r.e + DECIMAL_PLACES + 2, 1 );
4255 m = !r.times(r).eq(x);
4256 }
4257
4258 break;
4259 }
4260 }
4261 }
4262 }
4263
4264 return round( r, r.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m );
4265 };
4266
4267
4268 /*
4269 * n * 0 = 0
4270 * n * N = N
4271 * n * I = I
4272 * 0 * n = 0
4273 * 0 * 0 = 0
4274 * 0 * N = N
4275 * 0 * I = N
4276 * N * n = N
4277 * N * 0 = N
4278 * N * N = N
4279 * N * I = N
4280 * I * n = I
4281 * I * 0 = N
4282 * I * N = N
4283 * I * I = I
4284 *
4285 * Return a new BigNumber whose value is the value of this BigNumber times the value of
4286 * BigNumber(y, b).
4287 */
4288 P.times = P.mul = function ( y, b ) {
4289 var c, e, i, j, k, m, xcL, xlo, xhi, ycL, ylo, yhi, zc,
4290 base, sqrtBase,
4291 x = this,
4292 xc = x.c,
4293 yc = ( id = 17, y = new BigNumber( y, b ) ).c;
4294
4295 // Either NaN, ±Infinity or ±0?
4296 if ( !xc || !yc || !xc[0] || !yc[0] ) {
4297
4298 // Return NaN if either is NaN, or one is 0 and the other is Infinity.
4299 if ( !x.s || !y.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc ) {
4300 y.c = y.e = y.s = null;
4301 } else {
4302 y.s *= x.s;
4303
4304 // Return ±Infinity if either is ±Infinity.
4305 if ( !xc || !yc ) {
4306 y.c = y.e = null;
4307
4308 // Return ±0 if either is ±0.
4309 } else {
4310 y.c = [0];
4311 y.e = 0;
4312 }
4313 }
4314
4315 return y;
4316 }
4317
4318 e = bitFloor( x.e / LOG_BASE ) + bitFloor( y.e / LOG_BASE );
4319 y.s *= x.s;
4320 xcL = xc.length;
4321 ycL = yc.length;
4322
4323 // Ensure xc points to longer array and xcL to its length.
4324 if ( xcL < ycL ) zc = xc, xc = yc, yc = zc, i = xcL, xcL = ycL, ycL = i;
4325
4326 // Initialise the result array with zeros.
4327 for ( i = xcL + ycL, zc = []; i--; zc.push(0) );
4328
4329 base = BASE;
4330 sqrtBase = SQRT_BASE;
4331
4332 for ( i = ycL; --i >= 0; ) {
4333 c = 0;
4334 ylo = yc[i] % sqrtBase;
4335 yhi = yc[i] / sqrtBase | 0;
4336
4337 for ( k = xcL, j = i + k; j > i; ) {
4338 xlo = xc[--k] % sqrtBase;
4339 xhi = xc[k] / sqrtBase | 0;
4340 m = yhi * xlo + xhi * ylo;
4341 xlo = ylo * xlo + ( ( m % sqrtBase ) * sqrtBase ) + zc[j] + c;
4342 c = ( xlo / base | 0 ) + ( m / sqrtBase | 0 ) + yhi * xhi;
4343 zc[j--] = xlo % base;
4344 }
4345
4346 zc[j] = c;
4347 }
4348
4349 if (c) {
4350 ++e;
4351 } else {
4352 zc.splice(0, 1);
4353 }
4354
4355 return normalise( y, zc, e );
4356 };
4357
4358
4359 /*
4360 * Return a new BigNumber whose value is the value of this BigNumber rounded to a maximum of
4361 * sd significant digits using rounding mode rm, or ROUNDING_MODE if rm is omitted.
4362 *
4363 * [sd] {number} Significant digits. Integer, 1 to MAX inclusive.
4364 * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
4365 *
4366 * 'toDigits() precision out of range: {sd}'
4367 * 'toDigits() precision not an integer: {sd}'
4368 * 'toDigits() rounding mode not an integer: {rm}'
4369 * 'toDigits() rounding mode out of range: {rm}'
4370 */
4371 P.toDigits = function ( sd, rm ) {
4372 var n = new BigNumber(this);
4373 sd = sd == null || !isValidInt( sd, 1, MAX, 18, 'precision' ) ? null : sd | 0;
4374 rm = rm == null || !isValidInt( rm, 0, 8, 18, roundingMode ) ? ROUNDING_MODE : rm | 0;
4375 return sd ? round( n, sd, rm ) : n;
4376 };
4377
4378
4379 /*
4380 * Return a string representing the value of this BigNumber in exponential notation and
4381 * rounded using ROUNDING_MODE to dp fixed decimal places.
4382 *
4383 * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
4384 * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
4385 *
4386 * 'toExponential() decimal places not an integer: {dp}'
4387 * 'toExponential() decimal places out of range: {dp}'
4388 * 'toExponential() rounding mode not an integer: {rm}'
4389 * 'toExponential() rounding mode out of range: {rm}'
4390 */
4391 P.toExponential = function ( dp, rm ) {
4392 return format( this,
4393 dp != null && isValidInt( dp, 0, MAX, 19 ) ? ~~dp + 1 : null, rm, 19 );
4394 };
4395
4396
4397 /*
4398 * Return a string representing the value of this BigNumber in fixed-point notation rounding
4399 * to dp fixed decimal places using rounding mode rm, or ROUNDING_MODE if rm is omitted.
4400 *
4401 * Note: as with JavaScript's number type, (-0).toFixed(0) is '0',
4402 * but e.g. (-0.00001).toFixed(0) is '-0'.
4403 *
4404 * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
4405 * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
4406 *
4407 * 'toFixed() decimal places not an integer: {dp}'
4408 * 'toFixed() decimal places out of range: {dp}'
4409 * 'toFixed() rounding mode not an integer: {rm}'
4410 * 'toFixed() rounding mode out of range: {rm}'
4411 */
4412 P.toFixed = function ( dp, rm ) {
4413 return format( this, dp != null && isValidInt( dp, 0, MAX, 20 )
4414 ? ~~dp + this.e + 1 : null, rm, 20 );
4415 };
4416
4417
4418 /*
4419 * Return a string representing the value of this BigNumber in fixed-point notation rounded
4420 * using rm or ROUNDING_MODE to dp decimal places, and formatted according to the properties
4421 * of the FORMAT object (see BigNumber.config).
4422 *
4423 * FORMAT = {
4424 * decimalSeparator : '.',
4425 * groupSeparator : ',',
4426 * groupSize : 3,
4427 * secondaryGroupSize : 0,
4428 * fractionGroupSeparator : '\xA0', // non-breaking space
4429 * fractionGroupSize : 0
4430 * };
4431 *
4432 * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
4433 * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
4434 *
4435 * 'toFormat() decimal places not an integer: {dp}'
4436 * 'toFormat() decimal places out of range: {dp}'
4437 * 'toFormat() rounding mode not an integer: {rm}'
4438 * 'toFormat() rounding mode out of range: {rm}'
4439 */
4440 P.toFormat = function ( dp, rm ) {
4441 var str = format( this, dp != null && isValidInt( dp, 0, MAX, 21 )
4442 ? ~~dp + this.e + 1 : null, rm, 21 );
4443
4444 if ( this.c ) {
4445 var i,
4446 arr = str.split('.'),
4447 g1 = +FORMAT.groupSize,
4448 g2 = +FORMAT.secondaryGroupSize,
4449 groupSeparator = FORMAT.groupSeparator,
4450 intPart = arr[0],
4451 fractionPart = arr[1],
4452 isNeg = this.s < 0,
4453 intDigits = isNeg ? intPart.slice(1) : intPart,
4454 len = intDigits.length;
4455
4456 if (g2) i = g1, g1 = g2, g2 = i, len -= i;
4457
4458 if ( g1 > 0 && len > 0 ) {
4459 i = len % g1 || g1;
4460 intPart = intDigits.substr( 0, i );
4461
4462 for ( ; i < len; i += g1 ) {
4463 intPart += groupSeparator + intDigits.substr( i, g1 );
4464 }
4465
4466 if ( g2 > 0 ) intPart += groupSeparator + intDigits.slice(i);
4467 if (isNeg) intPart = '-' + intPart;
4468 }
4469
4470 str = fractionPart
4471 ? intPart + FORMAT.decimalSeparator + ( ( g2 = +FORMAT.fractionGroupSize )
4472 ? fractionPart.replace( new RegExp( '\\d{' + g2 + '}\\B', 'g' ),
4473 '$&' + FORMAT.fractionGroupSeparator )
4474 : fractionPart )
4475 : intPart;
4476 }
4477
4478 return str;
4479 };
4480
4481
4482 /*
4483 * Return a string array representing the value of this BigNumber as a simple fraction with
4484 * an integer numerator and an integer denominator. The denominator will be a positive
4485 * non-zero value less than or equal to the specified maximum denominator. If a maximum
4486 * denominator is not specified, the denominator will be the lowest value necessary to
4487 * represent the number exactly.
4488 *
4489 * [md] {number|string|BigNumber} Integer >= 1 and < Infinity. The maximum denominator.
4490 *
4491 * 'toFraction() max denominator not an integer: {md}'
4492 * 'toFraction() max denominator out of range: {md}'
4493 */
4494 P.toFraction = function (md) {
4495 var arr, d0, d2, e, exp, n, n0, q, s,
4496 k = ERRORS,
4497 x = this,
4498 xc = x.c,
4499 d = new BigNumber(ONE),
4500 n1 = d0 = new BigNumber(ONE),
4501 d1 = n0 = new BigNumber(ONE);
4502
4503 if ( md != null ) {
4504 ERRORS = false;
4505 n = new BigNumber(md);
4506 ERRORS = k;
4507
4508 if ( !( k = n.isInt() ) || n.lt(ONE) ) {
4509
4510 if (ERRORS) {
4511 raise( 22,
4512 'max denominator ' + ( k ? 'out of range' : 'not an integer' ), md );
4513 }
4514
4515 // ERRORS is false:
4516 // If md is a finite non-integer >= 1, round it to an integer and use it.
4517 md = !k && n.c && round( n, n.e + 1, 1 ).gte(ONE) ? n : null;
4518 }
4519 }
4520
4521 if ( !xc ) return x.toString();
4522 s = coeffToString(xc);
4523
4524 // Determine initial denominator.
4525 // d is a power of 10 and the minimum max denominator that specifies the value exactly.
4526 e = d.e = s.length - x.e - 1;
4527 d.c[0] = POWS_TEN[ ( exp = e % LOG_BASE ) < 0 ? LOG_BASE + exp : exp ];
4528 md = !md || n.cmp(d) > 0 ? ( e > 0 ? d : n1 ) : n;
4529
4530 exp = MAX_EXP;
4531 MAX_EXP = 1 / 0;
4532 n = new BigNumber(s);
4533
4534 // n0 = d1 = 0
4535 n0.c[0] = 0;
4536
4537 for ( ; ; ) {
4538 q = div( n, d, 0, 1 );
4539 d2 = d0.plus( q.times(d1) );
4540 if ( d2.cmp(md) == 1 ) break;
4541 d0 = d1;
4542 d1 = d2;
4543 n1 = n0.plus( q.times( d2 = n1 ) );
4544 n0 = d2;
4545 d = n.minus( q.times( d2 = d ) );
4546 n = d2;
4547 }
4548
4549 d2 = div( md.minus(d0), d1, 0, 1 );
4550 n0 = n0.plus( d2.times(n1) );
4551 d0 = d0.plus( d2.times(d1) );
4552 n0.s = n1.s = x.s;
4553 e *= 2;
4554
4555 // Determine which fraction is closer to x, n0/d0 or n1/d1
4556 arr = div( n1, d1, e, ROUNDING_MODE ).minus(x).abs().cmp(
4557 div( n0, d0, e, ROUNDING_MODE ).minus(x).abs() ) < 1
4558 ? [ n1.toString(), d1.toString() ]
4559 : [ n0.toString(), d0.toString() ];
4560
4561 MAX_EXP = exp;
4562 return arr;
4563 };
4564
4565
4566 /*
4567 * Return the value of this BigNumber converted to a number primitive.
4568 */
4569 P.toNumber = function () {
4570 return +this;
4571 };
4572
4573
4574 /*
4575 * Return a BigNumber whose value is the value of this BigNumber raised to the power n.
4576 * If m is present, return the result modulo m.
4577 * If n is negative round according to DECIMAL_PLACES and ROUNDING_MODE.
4578 * If POW_PRECISION is non-zero and m is not present, round to POW_PRECISION using
4579 * ROUNDING_MODE.
4580 *
4581 * The modular power operation works efficiently when x, n, and m are positive integers,
4582 * otherwise it is equivalent to calculating x.toPower(n).modulo(m) (with POW_PRECISION 0).
4583 *
4584 * n {number} Integer, -MAX_SAFE_INTEGER to MAX_SAFE_INTEGER inclusive.
4585 * [m] {number|string|BigNumber} The modulus.
4586 *
4587 * 'pow() exponent not an integer: {n}'
4588 * 'pow() exponent out of range: {n}'
4589 *
4590 * Performs 54 loop iterations for n of 9007199254740991.
4591 */
4592 P.toPower = P.pow = function ( n, m ) {
4593 var k, y, z,
4594 i = mathfloor( n < 0 ? -n : +n ),
4595 x = this;
4596
4597 if ( m != null ) {
4598 id = 23;
4599 m = new BigNumber(m);
4600 }
4601
4602 // Pass ±Infinity to Math.pow if exponent is out of range.
4603 if ( !isValidInt( n, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER, 23, 'exponent' ) &&
4604 ( !isFinite(n) || i > MAX_SAFE_INTEGER && ( n /= 0 ) ||
4605 parseFloat(n) != n && !( n = NaN ) ) || n == 0 ) {
4606 k = Math.pow( +x, n );
4607 return new BigNumber( m ? k % m : k );
4608 }
4609
4610 if (m) {
4611 if ( n > 1 && x.gt(ONE) && x.isInt() && m.gt(ONE) && m.isInt() ) {
4612 x = x.mod(m);
4613 } else {
4614 z = m;
4615
4616 // Nullify m so only a single mod operation is performed at the end.
4617 m = null;
4618 }
4619 } else if (POW_PRECISION) {
4620
4621 // Truncating each coefficient array to a length of k after each multiplication
4622 // equates to truncating significant digits to POW_PRECISION + [28, 41],
4623 // i.e. there will be a minimum of 28 guard digits retained.
4624 // (Using + 1.5 would give [9, 21] guard digits.)
4625 k = mathceil( POW_PRECISION / LOG_BASE + 2 );
4626 }
4627
4628 y = new BigNumber(ONE);
4629
4630 for ( ; ; ) {
4631 if ( i % 2 ) {
4632 y = y.times(x);
4633 if ( !y.c ) break;
4634 if (k) {
4635 if ( y.c.length > k ) y.c.length = k;
4636 } else if (m) {
4637 y = y.mod(m);
4638 }
4639 }
4640
4641 i = mathfloor( i / 2 );
4642 if ( !i ) break;
4643 x = x.times(x);
4644 if (k) {
4645 if ( x.c && x.c.length > k ) x.c.length = k;
4646 } else if (m) {
4647 x = x.mod(m);
4648 }
4649 }
4650
4651 if (m) return y;
4652 if ( n < 0 ) y = ONE.div(y);
4653
4654 return z ? y.mod(z) : k ? round( y, POW_PRECISION, ROUNDING_MODE ) : y;
4655 };
4656
4657
4658 /*
4659 * Return a string representing the value of this BigNumber rounded to sd significant digits
4660 * using rounding mode rm or ROUNDING_MODE. If sd is less than the number of digits
4661 * necessary to represent the integer part of the value in fixed-point notation, then use
4662 * exponential notation.
4663 *
4664 * [sd] {number} Significant digits. Integer, 1 to MAX inclusive.
4665 * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
4666 *
4667 * 'toPrecision() precision not an integer: {sd}'
4668 * 'toPrecision() precision out of range: {sd}'
4669 * 'toPrecision() rounding mode not an integer: {rm}'
4670 * 'toPrecision() rounding mode out of range: {rm}'
4671 */
4672 P.toPrecision = function ( sd, rm ) {
4673 return format( this, sd != null && isValidInt( sd, 1, MAX, 24, 'precision' )
4674 ? sd | 0 : null, rm, 24 );
4675 };
4676
4677
4678 /*
4679 * Return a string representing the value of this BigNumber in base b, or base 10 if b is
4680 * omitted. If a base is specified, including base 10, round according to DECIMAL_PLACES and
4681 * ROUNDING_MODE. If a base is not specified, and this BigNumber has a positive exponent
4682 * that is equal to or greater than TO_EXP_POS, or a negative exponent equal to or less than
4683 * TO_EXP_NEG, return exponential notation.
4684 *
4685 * [b] {number} Integer, 2 to 64 inclusive.
4686 *
4687 * 'toString() base not an integer: {b}'
4688 * 'toString() base out of range: {b}'
4689 */
4690 P.toString = function (b) {
4691 var str,
4692 n = this,
4693 s = n.s,
4694 e = n.e;
4695
4696 // Infinity or NaN?
4697 if ( e === null ) {
4698
4699 if (s) {
4700 str = 'Infinity';
4701 if ( s < 0 ) str = '-' + str;
4702 } else {
4703 str = 'NaN';
4704 }
4705 } else {
4706 str = coeffToString( n.c );
4707
4708 if ( b == null || !isValidInt( b, 2, 64, 25, 'base' ) ) {
4709 str = e <= TO_EXP_NEG || e >= TO_EXP_POS
4710 ? toExponential( str, e )
4711 : toFixedPoint( str, e );
4712 } else {
4713 str = convertBase( toFixedPoint( str, e ), b | 0, 10, s );
4714 }
4715
4716 if ( s < 0 && n.c[0] ) str = '-' + str;
4717 }
4718
4719 return str;
4720 };
4721
4722
4723 /*
4724 * Return a new BigNumber whose value is the value of this BigNumber truncated to a whole
4725 * number.
4726 */
4727 P.truncated = P.trunc = function () {
4728 return round( new BigNumber(this), this.e + 1, 1 );
4729 };
4730
4731
4732 /*
4733 * Return as toString, but do not accept a base argument, and include the minus sign for
4734 * negative zero.
4735 */
4736 P.valueOf = P.toJSON = function () {
4737 var str,
4738 n = this,
4739 e = n.e;
4740
4741 if ( e === null ) return n.toString();
4742
4743 str = coeffToString( n.c );
4744
4745 str = e <= TO_EXP_NEG || e >= TO_EXP_POS
4746 ? toExponential( str, e )
4747 : toFixedPoint( str, e );
4748
4749 return n.s < 0 ? '-' + str : str;
4750 };
4751
4752
4753 P.isBigNumber = true;
4754
4755 if ( config != null ) BigNumber.config(config);
4756
4757 return BigNumber;
4758 }
4759
4760
4761 // PRIVATE HELPER FUNCTIONS
4762
4763
4764 function bitFloor(n) {
4765 var i = n | 0;
4766 return n > 0 || n === i ? i : i - 1;
4767 }
4768
4769
4770 // Return a coefficient array as a string of base 10 digits.
4771 function coeffToString(a) {
4772 var s, z,
4773 i = 1,
4774 j = a.length,
4775 r = a[0] + '';
4776
4777 for ( ; i < j; ) {
4778 s = a[i++] + '';
4779 z = LOG_BASE - s.length;
4780 for ( ; z--; s = '0' + s );
4781 r += s;
4782 }
4783
4784 // Determine trailing zeros.
4785 for ( j = r.length; r.charCodeAt(--j) === 48; );
4786 return r.slice( 0, j + 1 || 1 );
4787 }
4788
4789
4790 // Compare the value of BigNumbers x and y.
4791 function compare( x, y ) {
4792 var a, b,
4793 xc = x.c,
4794 yc = y.c,
4795 i = x.s,
4796 j = y.s,
4797 k = x.e,
4798 l = y.e;
4799
4800 // Either NaN?
4801 if ( !i || !j ) return null;
4802
4803 a = xc && !xc[0];
4804 b = yc && !yc[0];
4805
4806 // Either zero?
4807 if ( a || b ) return a ? b ? 0 : -j : i;
4808
4809 // Signs differ?
4810 if ( i != j ) return i;
4811
4812 a = i < 0;
4813 b = k == l;
4814
4815 // Either Infinity?
4816 if ( !xc || !yc ) return b ? 0 : !xc ^ a ? 1 : -1;
4817
4818 // Compare exponents.
4819 if ( !b ) return k > l ^ a ? 1 : -1;
4820
4821 j = ( k = xc.length ) < ( l = yc.length ) ? k : l;
4822
4823 // Compare digit by digit.
4824 for ( i = 0; i < j; i++ ) if ( xc[i] != yc[i] ) return xc[i] > yc[i] ^ a ? 1 : -1;
4825
4826 // Compare lengths.
4827 return k == l ? 0 : k > l ^ a ? 1 : -1;
4828 }
4829
4830
4831 /*
4832 * Return true if n is a valid number in range, otherwise false.
4833 * Use for argument validation when ERRORS is false.
4834 * Note: parseInt('1e+1') == 1 but parseFloat('1e+1') == 10.
4835 */
4836 function intValidatorNoErrors( n, min, max ) {
4837 return ( n = truncate(n) ) >= min && n <= max;
4838 }
4839
4840
4841 function isArray(obj) {
4842 return Object.prototype.toString.call(obj) == '[object Array]';
4843 }
4844
4845
4846 /*
4847 * Convert string of baseIn to an array of numbers of baseOut.
4848 * Eg. convertBase('255', 10, 16) returns [15, 15].
4849 * Eg. convertBase('ff', 16, 10) returns [2, 5, 5].
4850 */
4851 function toBaseOut( str, baseIn, baseOut ) {
4852 var j,
4853 arr = [0],
4854 arrL,
4855 i = 0,
4856 len = str.length;
4857
4858 for ( ; i < len; ) {
4859 for ( arrL = arr.length; arrL--; arr[arrL] *= baseIn );
4860 arr[ j = 0 ] += ALPHABET.indexOf( str.charAt( i++ ) );
4861
4862 for ( ; j < arr.length; j++ ) {
4863
4864 if ( arr[j] > baseOut - 1 ) {
4865 if ( arr[j + 1] == null ) arr[j + 1] = 0;
4866 arr[j + 1] += arr[j] / baseOut | 0;
4867 arr[j] %= baseOut;
4868 }
4869 }
4870 }
4871
4872 return arr.reverse();
4873 }
4874
4875
4876 function toExponential( str, e ) {
4877 return ( str.length > 1 ? str.charAt(0) + '.' + str.slice(1) : str ) +
4878 ( e < 0 ? 'e' : 'e+' ) + e;
4879 }
4880
4881
4882 function toFixedPoint( str, e ) {
4883 var len, z;
4884
4885 // Negative exponent?
4886 if ( e < 0 ) {
4887
4888 // Prepend zeros.
4889 for ( z = '0.'; ++e; z += '0' );
4890 str = z + str;
4891
4892 // Positive exponent
4893 } else {
4894 len = str.length;
4895
4896 // Append zeros.
4897 if ( ++e > len ) {
4898 for ( z = '0', e -= len; --e; z += '0' );
4899 str += z;
4900 } else if ( e < len ) {
4901 str = str.slice( 0, e ) + '.' + str.slice(e);
4902 }
4903 }
4904
4905 return str;
4906 }
4907
4908
4909 function truncate(n) {
4910 n = parseFloat(n);
4911 return n < 0 ? mathceil(n) : mathfloor(n);
4912 }
4913
4914
4915 // EXPORT
4916
4917
4918 BigNumber = constructorFactory();
4919 BigNumber['default'] = BigNumber.BigNumber = BigNumber;
4920
4921
4922 // AMD.
4923 if ( typeof define == 'function' && define.amd ) {
4924 define( function () { return BigNumber; } );
4925
4926 // Node.js and other environments that support module.exports.
4927 } else if ( typeof module != 'undefined' && module.exports ) {
4928 module.exports = BigNumber;
4929
4930 // Browser.
4931 } else {
4932 if ( !globalObj ) globalObj = typeof self != 'undefined' ? self : Function('return this')();
4933 globalObj.BigNumber = BigNumber;
4934 }
4935})(this);
4936
4937},{}],18:[function(require,module,exports){
4938(function (module, exports) {
4939 'use strict';
4940
4941 // Utils
4942 function assert (val, msg) {
4943 if (!val) throw new Error(msg || 'Assertion failed');
4944 }
4945
4946 // Could use `inherits` module, but don't want to move from single file
4947 // architecture yet.
4948 function inherits (ctor, superCtor) {
4949 ctor.super_ = superCtor;
4950 var TempCtor = function () {};
4951 TempCtor.prototype = superCtor.prototype;
4952 ctor.prototype = new TempCtor();
4953 ctor.prototype.constructor = ctor;
4954 }
4955
4956 // BN
4957
4958 function BN (number, base, endian) {
4959 if (BN.isBN(number)) {
4960 return number;
4961 }
4962
4963 this.negative = 0;
4964 this.words = null;
4965 this.length = 0;
4966
4967 // Reduction context
4968 this.red = null;
4969
4970 if (number !== null) {
4971 if (base === 'le' || base === 'be') {
4972 endian = base;
4973 base = 10;
4974 }
4975
4976 this._init(number || 0, base || 10, endian || 'be');
4977 }
4978 }
4979 if (typeof module === 'object') {
4980 module.exports = BN;
4981 } else {
4982 exports.BN = BN;
4983 }
4984
4985 BN.BN = BN;
4986 BN.wordSize = 26;
4987
4988 var Buffer;
4989 try {
4990 Buffer = require('buffer').Buffer;
4991 } catch (e) {
4992 }
4993
4994 BN.isBN = function isBN (num) {
4995 if (num instanceof BN) {
4996 return true;
4997 }
4998
4999 return num !== null && typeof num === 'object' &&
5000 num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);
5001 };
5002
5003 BN.max = function max (left, right) {
5004 if (left.cmp(right) > 0) return left;
5005 return right;
5006 };
5007
5008 BN.min = function min (left, right) {
5009 if (left.cmp(right) < 0) return left;
5010 return right;
5011 };
5012
5013 BN.prototype._init = function init (number, base, endian) {
5014 if (typeof number === 'number') {
5015 return this._initNumber(number, base, endian);
5016 }
5017
5018 if (typeof number === 'object') {
5019 return this._initArray(number, base, endian);
5020 }
5021
5022 if (base === 'hex') {
5023 base = 16;
5024 }
5025 assert(base === (base | 0) && base >= 2 && base <= 36);
5026
5027 number = number.toString().replace(/\s+/g, '');
5028 var start = 0;
5029 if (number[0] === '-') {
5030 start++;
5031 }
5032
5033 if (base === 16) {
5034 this._parseHex(number, start);
5035 } else {
5036 this._parseBase(number, base, start);
5037 }
5038
5039 if (number[0] === '-') {
5040 this.negative = 1;
5041 }
5042
5043 this.strip();
5044
5045 if (endian !== 'le') return;
5046
5047 this._initArray(this.toArray(), base, endian);
5048 };
5049
5050 BN.prototype._initNumber = function _initNumber (number, base, endian) {
5051 if (number < 0) {
5052 this.negative = 1;
5053 number = -number;
5054 }
5055 if (number < 0x4000000) {
5056 this.words = [ number & 0x3ffffff ];
5057 this.length = 1;
5058 } else if (number < 0x10000000000000) {
5059 this.words = [
5060 number & 0x3ffffff,
5061 (number / 0x4000000) & 0x3ffffff
5062 ];
5063 this.length = 2;
5064 } else {
5065 assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)
5066 this.words = [
5067 number & 0x3ffffff,
5068 (number / 0x4000000) & 0x3ffffff,
5069 1
5070 ];
5071 this.length = 3;
5072 }
5073
5074 if (endian !== 'le') return;
5075
5076 // Reverse the bytes
5077 this._initArray(this.toArray(), base, endian);
5078 };
5079
5080 BN.prototype._initArray = function _initArray (number, base, endian) {
5081 // Perhaps a Uint8Array
5082 assert(typeof number.length === 'number');
5083 if (number.length <= 0) {
5084 this.words = [ 0 ];
5085 this.length = 1;
5086 return this;
5087 }
5088
5089 this.length = Math.ceil(number.length / 3);
5090 this.words = new Array(this.length);
5091 for (var i = 0; i < this.length; i++) {
5092 this.words[i] = 0;
5093 }
5094
5095 var j, w;
5096 var off = 0;
5097 if (endian === 'be') {
5098 for (i = number.length - 1, j = 0; i >= 0; i -= 3) {
5099 w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16);
5100 this.words[j] |= (w << off) & 0x3ffffff;
5101 this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
5102 off += 24;
5103 if (off >= 26) {
5104 off -= 26;
5105 j++;
5106 }
5107 }
5108 } else if (endian === 'le') {
5109 for (i = 0, j = 0; i < number.length; i += 3) {
5110 w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16);
5111 this.words[j] |= (w << off) & 0x3ffffff;
5112 this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
5113 off += 24;
5114 if (off >= 26) {
5115 off -= 26;
5116 j++;
5117 }
5118 }
5119 }
5120 return this.strip();
5121 };
5122
5123 function parseHex (str, start, end) {
5124 var r = 0;
5125 var len = Math.min(str.length, end);
5126 for (var i = start; i < len; i++) {
5127 var c = str.charCodeAt(i) - 48;
5128
5129 r <<= 4;
5130
5131 // 'a' - 'f'
5132 if (c >= 49 && c <= 54) {
5133 r |= c - 49 + 0xa;
5134
5135 // 'A' - 'F'
5136 } else if (c >= 17 && c <= 22) {
5137 r |= c - 17 + 0xa;
5138
5139 // '0' - '9'
5140 } else {
5141 r |= c & 0xf;
5142 }
5143 }
5144 return r;
5145 }
5146
5147 BN.prototype._parseHex = function _parseHex (number, start) {
5148 // Create possibly bigger array to ensure that it fits the number
5149 this.length = Math.ceil((number.length - start) / 6);
5150 this.words = new Array(this.length);
5151 for (var i = 0; i < this.length; i++) {
5152 this.words[i] = 0;
5153 }
5154
5155 var j, w;
5156 // Scan 24-bit chunks and add them to the number
5157 var off = 0;
5158 for (i = number.length - 6, j = 0; i >= start; i -= 6) {
5159 w = parseHex(number, i, i + 6);
5160 this.words[j] |= (w << off) & 0x3ffffff;
5161 // NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb
5162 this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;
5163 off += 24;
5164 if (off >= 26) {
5165 off -= 26;
5166 j++;
5167 }
5168 }
5169 if (i + 6 !== start) {
5170 w = parseHex(number, start, i + 6);
5171 this.words[j] |= (w << off) & 0x3ffffff;
5172 this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;
5173 }
5174 this.strip();
5175 };
5176
5177 function parseBase (str, start, end, mul) {
5178 var r = 0;
5179 var len = Math.min(str.length, end);
5180 for (var i = start; i < len; i++) {
5181 var c = str.charCodeAt(i) - 48;
5182
5183 r *= mul;
5184
5185 // 'a'
5186 if (c >= 49) {
5187 r += c - 49 + 0xa;
5188
5189 // 'A'
5190 } else if (c >= 17) {
5191 r += c - 17 + 0xa;
5192
5193 // '0' - '9'
5194 } else {
5195 r += c;
5196 }
5197 }
5198 return r;
5199 }
5200
5201 BN.prototype._parseBase = function _parseBase (number, base, start) {
5202 // Initialize as zero
5203 this.words = [ 0 ];
5204 this.length = 1;
5205
5206 // Find length of limb in base
5207 for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {
5208 limbLen++;
5209 }
5210 limbLen--;
5211 limbPow = (limbPow / base) | 0;
5212
5213 var total = number.length - start;
5214 var mod = total % limbLen;
5215 var end = Math.min(total, total - mod) + start;
5216
5217 var word = 0;
5218 for (var i = start; i < end; i += limbLen) {
5219 word = parseBase(number, i, i + limbLen, base);
5220
5221 this.imuln(limbPow);
5222 if (this.words[0] + word < 0x4000000) {
5223 this.words[0] += word;
5224 } else {
5225 this._iaddn(word);
5226 }
5227 }
5228
5229 if (mod !== 0) {
5230 var pow = 1;
5231 word = parseBase(number, i, number.length, base);
5232
5233 for (i = 0; i < mod; i++) {
5234 pow *= base;
5235 }
5236
5237 this.imuln(pow);
5238 if (this.words[0] + word < 0x4000000) {
5239 this.words[0] += word;
5240 } else {
5241 this._iaddn(word);
5242 }
5243 }
5244 };
5245
5246 BN.prototype.copy = function copy (dest) {
5247 dest.words = new Array(this.length);
5248 for (var i = 0; i < this.length; i++) {
5249 dest.words[i] = this.words[i];
5250 }
5251 dest.length = this.length;
5252 dest.negative = this.negative;
5253 dest.red = this.red;
5254 };
5255
5256 BN.prototype.clone = function clone () {
5257 var r = new BN(null);
5258 this.copy(r);
5259 return r;
5260 };
5261
5262 BN.prototype._expand = function _expand (size) {
5263 while (this.length < size) {
5264 this.words[this.length++] = 0;
5265 }
5266 return this;
5267 };
5268
5269 // Remove leading `0` from `this`
5270 BN.prototype.strip = function strip () {
5271 while (this.length > 1 && this.words[this.length - 1] === 0) {
5272 this.length--;
5273 }
5274 return this._normSign();
5275 };
5276
5277 BN.prototype._normSign = function _normSign () {
5278 // -0 = 0
5279 if (this.length === 1 && this.words[0] === 0) {
5280 this.negative = 0;
5281 }
5282 return this;
5283 };
5284
5285 BN.prototype.inspect = function inspect () {
5286 return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';
5287 };
5288
5289 /*
5290
5291 var zeros = [];
5292 var groupSizes = [];
5293 var groupBases = [];
5294
5295 var s = '';
5296 var i = -1;
5297 while (++i < BN.wordSize) {
5298 zeros[i] = s;
5299 s += '0';
5300 }
5301 groupSizes[0] = 0;
5302 groupSizes[1] = 0;
5303 groupBases[0] = 0;
5304 groupBases[1] = 0;
5305 var base = 2 - 1;
5306 while (++base < 36 + 1) {
5307 var groupSize = 0;
5308 var groupBase = 1;
5309 while (groupBase < (1 << BN.wordSize) / base) {
5310 groupBase *= base;
5311 groupSize += 1;
5312 }
5313 groupSizes[base] = groupSize;
5314 groupBases[base] = groupBase;
5315 }
5316
5317 */
5318
5319 var zeros = [
5320 '',
5321 '0',
5322 '00',
5323 '000',
5324 '0000',
5325 '00000',
5326 '000000',
5327 '0000000',
5328 '00000000',
5329 '000000000',
5330 '0000000000',
5331 '00000000000',
5332 '000000000000',
5333 '0000000000000',
5334 '00000000000000',
5335 '000000000000000',
5336 '0000000000000000',
5337 '00000000000000000',
5338 '000000000000000000',
5339 '0000000000000000000',
5340 '00000000000000000000',
5341 '000000000000000000000',
5342 '0000000000000000000000',
5343 '00000000000000000000000',
5344 '000000000000000000000000',
5345 '0000000000000000000000000'
5346 ];
5347
5348 var groupSizes = [
5349 0, 0,
5350 25, 16, 12, 11, 10, 9, 8,
5351 8, 7, 7, 7, 7, 6, 6,
5352 6, 6, 6, 6, 6, 5, 5,
5353 5, 5, 5, 5, 5, 5, 5,
5354 5, 5, 5, 5, 5, 5, 5
5355 ];
5356
5357 var groupBases = [
5358 0, 0,
5359 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216,
5360 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625,
5361 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632,
5362 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149,
5363 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176
5364 ];
5365
5366 BN.prototype.toString = function toString (base, padding) {
5367 base = base || 10;
5368 padding = padding | 0 || 1;
5369
5370 var out;
5371 if (base === 16 || base === 'hex') {
5372 out = '';
5373 var off = 0;
5374 var carry = 0;
5375 for (var i = 0; i < this.length; i++) {
5376 var w = this.words[i];
5377 var word = (((w << off) | carry) & 0xffffff).toString(16);
5378 carry = (w >>> (24 - off)) & 0xffffff;
5379 if (carry !== 0 || i !== this.length - 1) {
5380 out = zeros[6 - word.length] + word + out;
5381 } else {
5382 out = word + out;
5383 }
5384 off += 2;
5385 if (off >= 26) {
5386 off -= 26;
5387 i--;
5388 }
5389 }
5390 if (carry !== 0) {
5391 out = carry.toString(16) + out;
5392 }
5393 while (out.length % padding !== 0) {
5394 out = '0' + out;
5395 }
5396 if (this.negative !== 0) {
5397 out = '-' + out;
5398 }
5399 return out;
5400 }
5401
5402 if (base === (base | 0) && base >= 2 && base <= 36) {
5403 // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));
5404 var groupSize = groupSizes[base];
5405 // var groupBase = Math.pow(base, groupSize);
5406 var groupBase = groupBases[base];
5407 out = '';
5408 var c = this.clone();
5409 c.negative = 0;
5410 while (!c.isZero()) {
5411 var r = c.modn(groupBase).toString(base);
5412 c = c.idivn(groupBase);
5413
5414 if (!c.isZero()) {
5415 out = zeros[groupSize - r.length] + r + out;
5416 } else {
5417 out = r + out;
5418 }
5419 }
5420 if (this.isZero()) {
5421 out = '0' + out;
5422 }
5423 while (out.length % padding !== 0) {
5424 out = '0' + out;
5425 }
5426 if (this.negative !== 0) {
5427 out = '-' + out;
5428 }
5429 return out;
5430 }
5431
5432 assert(false, 'Base should be between 2 and 36');
5433 };
5434
5435 BN.prototype.toNumber = function toNumber () {
5436 var ret = this.words[0];
5437 if (this.length === 2) {
5438 ret += this.words[1] * 0x4000000;
5439 } else if (this.length === 3 && this.words[2] === 0x01) {
5440 // NOTE: at this stage it is known that the top bit is set
5441 ret += 0x10000000000000 + (this.words[1] * 0x4000000);
5442 } else if (this.length > 2) {
5443 assert(false, 'Number can only safely store up to 53 bits');
5444 }
5445 return (this.negative !== 0) ? -ret : ret;
5446 };
5447
5448 BN.prototype.toJSON = function toJSON () {
5449 return this.toString(16);
5450 };
5451
5452 BN.prototype.toBuffer = function toBuffer (endian, length) {
5453 assert(typeof Buffer !== 'undefined');
5454 return this.toArrayLike(Buffer, endian, length);
5455 };
5456
5457 BN.prototype.toArray = function toArray (endian, length) {
5458 return this.toArrayLike(Array, endian, length);
5459 };
5460
5461 BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) {
5462 var byteLength = this.byteLength();
5463 var reqLength = length || Math.max(1, byteLength);
5464 assert(byteLength <= reqLength, 'byte array longer than desired length');
5465 assert(reqLength > 0, 'Requested array length <= 0');
5466
5467 this.strip();
5468 var littleEndian = endian === 'le';
5469 var res = new ArrayType(reqLength);
5470
5471 var b, i;
5472 var q = this.clone();
5473 if (!littleEndian) {
5474 // Assume big-endian
5475 for (i = 0; i < reqLength - byteLength; i++) {
5476 res[i] = 0;
5477 }
5478
5479 for (i = 0; !q.isZero(); i++) {
5480 b = q.andln(0xff);
5481 q.iushrn(8);
5482
5483 res[reqLength - i - 1] = b;
5484 }
5485 } else {
5486 for (i = 0; !q.isZero(); i++) {
5487 b = q.andln(0xff);
5488 q.iushrn(8);
5489
5490 res[i] = b;
5491 }
5492
5493 for (; i < reqLength; i++) {
5494 res[i] = 0;
5495 }
5496 }
5497
5498 return res;
5499 };
5500
5501 if (Math.clz32) {
5502 BN.prototype._countBits = function _countBits (w) {
5503 return 32 - Math.clz32(w);
5504 };
5505 } else {
5506 BN.prototype._countBits = function _countBits (w) {
5507 var t = w;
5508 var r = 0;
5509 if (t >= 0x1000) {
5510 r += 13;
5511 t >>>= 13;
5512 }
5513 if (t >= 0x40) {
5514 r += 7;
5515 t >>>= 7;
5516 }
5517 if (t >= 0x8) {
5518 r += 4;
5519 t >>>= 4;
5520 }
5521 if (t >= 0x02) {
5522 r += 2;
5523 t >>>= 2;
5524 }
5525 return r + t;
5526 };
5527 }
5528
5529 BN.prototype._zeroBits = function _zeroBits (w) {
5530 // Short-cut
5531 if (w === 0) return 26;
5532
5533 var t = w;
5534 var r = 0;
5535 if ((t & 0x1fff) === 0) {
5536 r += 13;
5537 t >>>= 13;
5538 }
5539 if ((t & 0x7f) === 0) {
5540 r += 7;
5541 t >>>= 7;
5542 }
5543 if ((t & 0xf) === 0) {
5544 r += 4;
5545 t >>>= 4;
5546 }
5547 if ((t & 0x3) === 0) {
5548 r += 2;
5549 t >>>= 2;
5550 }
5551 if ((t & 0x1) === 0) {
5552 r++;
5553 }
5554 return r;
5555 };
5556
5557 // Return number of used bits in a BN
5558 BN.prototype.bitLength = function bitLength () {
5559 var w = this.words[this.length - 1];
5560 var hi = this._countBits(w);
5561 return (this.length - 1) * 26 + hi;
5562 };
5563
5564 function toBitArray (num) {
5565 var w = new Array(num.bitLength());
5566
5567 for (var bit = 0; bit < w.length; bit++) {
5568 var off = (bit / 26) | 0;
5569 var wbit = bit % 26;
5570
5571 w[bit] = (num.words[off] & (1 << wbit)) >>> wbit;
5572 }
5573
5574 return w;
5575 }
5576
5577 // Number of trailing zero bits
5578 BN.prototype.zeroBits = function zeroBits () {
5579 if (this.isZero()) return 0;
5580
5581 var r = 0;
5582 for (var i = 0; i < this.length; i++) {
5583 var b = this._zeroBits(this.words[i]);
5584 r += b;
5585 if (b !== 26) break;
5586 }
5587 return r;
5588 };
5589
5590 BN.prototype.byteLength = function byteLength () {
5591 return Math.ceil(this.bitLength() / 8);
5592 };
5593
5594 BN.prototype.toTwos = function toTwos (width) {
5595 if (this.negative !== 0) {
5596 return this.abs().inotn(width).iaddn(1);
5597 }
5598 return this.clone();
5599 };
5600
5601 BN.prototype.fromTwos = function fromTwos (width) {
5602 if (this.testn(width - 1)) {
5603 return this.notn(width).iaddn(1).ineg();
5604 }
5605 return this.clone();
5606 };
5607
5608 BN.prototype.isNeg = function isNeg () {
5609 return this.negative !== 0;
5610 };
5611
5612 // Return negative clone of `this`
5613 BN.prototype.neg = function neg () {
5614 return this.clone().ineg();
5615 };
5616
5617 BN.prototype.ineg = function ineg () {
5618 if (!this.isZero()) {
5619 this.negative ^= 1;
5620 }
5621
5622 return this;
5623 };
5624
5625 // Or `num` with `this` in-place
5626 BN.prototype.iuor = function iuor (num) {
5627 while (this.length < num.length) {
5628 this.words[this.length++] = 0;
5629 }
5630
5631 for (var i = 0; i < num.length; i++) {
5632 this.words[i] = this.words[i] | num.words[i];
5633 }
5634
5635 return this.strip();
5636 };
5637
5638 BN.prototype.ior = function ior (num) {
5639 assert((this.negative | num.negative) === 0);
5640 return this.iuor(num);
5641 };
5642
5643 // Or `num` with `this`
5644 BN.prototype.or = function or (num) {
5645 if (this.length > num.length) return this.clone().ior(num);
5646 return num.clone().ior(this);
5647 };
5648
5649 BN.prototype.uor = function uor (num) {
5650 if (this.length > num.length) return this.clone().iuor(num);
5651 return num.clone().iuor(this);
5652 };
5653
5654 // And `num` with `this` in-place
5655 BN.prototype.iuand = function iuand (num) {
5656 // b = min-length(num, this)
5657 var b;
5658 if (this.length > num.length) {
5659 b = num;
5660 } else {
5661 b = this;
5662 }
5663
5664 for (var i = 0; i < b.length; i++) {
5665 this.words[i] = this.words[i] & num.words[i];
5666 }
5667
5668 this.length = b.length;
5669
5670 return this.strip();
5671 };
5672
5673 BN.prototype.iand = function iand (num) {
5674 assert((this.negative | num.negative) === 0);
5675 return this.iuand(num);
5676 };
5677
5678 // And `num` with `this`
5679 BN.prototype.and = function and (num) {
5680 if (this.length > num.length) return this.clone().iand(num);
5681 return num.clone().iand(this);
5682 };
5683
5684 BN.prototype.uand = function uand (num) {
5685 if (this.length > num.length) return this.clone().iuand(num);
5686 return num.clone().iuand(this);
5687 };
5688
5689 // Xor `num` with `this` in-place
5690 BN.prototype.iuxor = function iuxor (num) {
5691 // a.length > b.length
5692 var a;
5693 var b;
5694 if (this.length > num.length) {
5695 a = this;
5696 b = num;
5697 } else {
5698 a = num;
5699 b = this;
5700 }
5701
5702 for (var i = 0; i < b.length; i++) {
5703 this.words[i] = a.words[i] ^ b.words[i];
5704 }
5705
5706 if (this !== a) {
5707 for (; i < a.length; i++) {
5708 this.words[i] = a.words[i];
5709 }
5710 }
5711
5712 this.length = a.length;
5713
5714 return this.strip();
5715 };
5716
5717 BN.prototype.ixor = function ixor (num) {
5718 assert((this.negative | num.negative) === 0);
5719 return this.iuxor(num);
5720 };
5721
5722 // Xor `num` with `this`
5723 BN.prototype.xor = function xor (num) {
5724 if (this.length > num.length) return this.clone().ixor(num);
5725 return num.clone().ixor(this);
5726 };
5727
5728 BN.prototype.uxor = function uxor (num) {
5729 if (this.length > num.length) return this.clone().iuxor(num);
5730 return num.clone().iuxor(this);
5731 };
5732
5733 // Not ``this`` with ``width`` bitwidth
5734 BN.prototype.inotn = function inotn (width) {
5735 assert(typeof width === 'number' && width >= 0);
5736
5737 var bytesNeeded = Math.ceil(width / 26) | 0;
5738 var bitsLeft = width % 26;
5739
5740 // Extend the buffer with leading zeroes
5741 this._expand(bytesNeeded);
5742
5743 if (bitsLeft > 0) {
5744 bytesNeeded--;
5745 }
5746
5747 // Handle complete words
5748 for (var i = 0; i < bytesNeeded; i++) {
5749 this.words[i] = ~this.words[i] & 0x3ffffff;
5750 }
5751
5752 // Handle the residue
5753 if (bitsLeft > 0) {
5754 this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft));
5755 }
5756
5757 // And remove leading zeroes
5758 return this.strip();
5759 };
5760
5761 BN.prototype.notn = function notn (width) {
5762 return this.clone().inotn(width);
5763 };
5764
5765 // Set `bit` of `this`
5766 BN.prototype.setn = function setn (bit, val) {
5767 assert(typeof bit === 'number' && bit >= 0);
5768
5769 var off = (bit / 26) | 0;
5770 var wbit = bit % 26;
5771
5772 this._expand(off + 1);
5773
5774 if (val) {
5775 this.words[off] = this.words[off] | (1 << wbit);
5776 } else {
5777 this.words[off] = this.words[off] & ~(1 << wbit);
5778 }
5779
5780 return this.strip();
5781 };
5782
5783 // Add `num` to `this` in-place
5784 BN.prototype.iadd = function iadd (num) {
5785 var r;
5786
5787 // negative + positive
5788 if (this.negative !== 0 && num.negative === 0) {
5789 this.negative = 0;
5790 r = this.isub(num);
5791 this.negative ^= 1;
5792 return this._normSign();
5793
5794 // positive + negative
5795 } else if (this.negative === 0 && num.negative !== 0) {
5796 num.negative = 0;
5797 r = this.isub(num);
5798 num.negative = 1;
5799 return r._normSign();
5800 }
5801
5802 // a.length > b.length
5803 var a, b;
5804 if (this.length > num.length) {
5805 a = this;
5806 b = num;
5807 } else {
5808 a = num;
5809 b = this;
5810 }
5811
5812 var carry = 0;
5813 for (var i = 0; i < b.length; i++) {
5814 r = (a.words[i] | 0) + (b.words[i] | 0) + carry;
5815 this.words[i] = r & 0x3ffffff;
5816 carry = r >>> 26;
5817 }
5818 for (; carry !== 0 && i < a.length; i++) {
5819 r = (a.words[i] | 0) + carry;
5820 this.words[i] = r & 0x3ffffff;
5821 carry = r >>> 26;
5822 }
5823
5824 this.length = a.length;
5825 if (carry !== 0) {
5826 this.words[this.length] = carry;
5827 this.length++;
5828 // Copy the rest of the words
5829 } else if (a !== this) {
5830 for (; i < a.length; i++) {
5831 this.words[i] = a.words[i];
5832 }
5833 }
5834
5835 return this;
5836 };
5837
5838 // Add `num` to `this`
5839 BN.prototype.add = function add (num) {
5840 var res;
5841 if (num.negative !== 0 && this.negative === 0) {
5842 num.negative = 0;
5843 res = this.sub(num);
5844 num.negative ^= 1;
5845 return res;
5846 } else if (num.negative === 0 && this.negative !== 0) {
5847 this.negative = 0;
5848 res = num.sub(this);
5849 this.negative = 1;
5850 return res;
5851 }
5852
5853 if (this.length > num.length) return this.clone().iadd(num);
5854
5855 return num.clone().iadd(this);
5856 };
5857
5858 // Subtract `num` from `this` in-place
5859 BN.prototype.isub = function isub (num) {
5860 // this - (-num) = this + num
5861 if (num.negative !== 0) {
5862 num.negative = 0;
5863 var r = this.iadd(num);
5864 num.negative = 1;
5865 return r._normSign();
5866
5867 // -this - num = -(this + num)
5868 } else if (this.negative !== 0) {
5869 this.negative = 0;
5870 this.iadd(num);
5871 this.negative = 1;
5872 return this._normSign();
5873 }
5874
5875 // At this point both numbers are positive
5876 var cmp = this.cmp(num);
5877
5878 // Optimization - zeroify
5879 if (cmp === 0) {
5880 this.negative = 0;
5881 this.length = 1;
5882 this.words[0] = 0;
5883 return this;
5884 }
5885
5886 // a > b
5887 var a, b;
5888 if (cmp > 0) {
5889 a = this;
5890 b = num;
5891 } else {
5892 a = num;
5893 b = this;
5894 }
5895
5896 var carry = 0;
5897 for (var i = 0; i < b.length; i++) {
5898 r = (a.words[i] | 0) - (b.words[i] | 0) + carry;
5899 carry = r >> 26;
5900 this.words[i] = r & 0x3ffffff;
5901 }
5902 for (; carry !== 0 && i < a.length; i++) {
5903 r = (a.words[i] | 0) + carry;
5904 carry = r >> 26;
5905 this.words[i] = r & 0x3ffffff;
5906 }
5907
5908 // Copy rest of the words
5909 if (carry === 0 && i < a.length && a !== this) {
5910 for (; i < a.length; i++) {
5911 this.words[i] = a.words[i];
5912 }
5913 }
5914
5915 this.length = Math.max(this.length, i);
5916
5917 if (a !== this) {
5918 this.negative = 1;
5919 }
5920
5921 return this.strip();
5922 };
5923
5924 // Subtract `num` from `this`
5925 BN.prototype.sub = function sub (num) {
5926 return this.clone().isub(num);
5927 };
5928
5929 function smallMulTo (self, num, out) {
5930 out.negative = num.negative ^ self.negative;
5931 var len = (self.length + num.length) | 0;
5932 out.length = len;
5933 len = (len - 1) | 0;
5934
5935 // Peel one iteration (compiler can't do it, because of code complexity)
5936 var a = self.words[0] | 0;
5937 var b = num.words[0] | 0;
5938 var r = a * b;
5939
5940 var lo = r & 0x3ffffff;
5941 var carry = (r / 0x4000000) | 0;
5942 out.words[0] = lo;
5943
5944 for (var k = 1; k < len; k++) {
5945 // Sum all words with the same `i + j = k` and accumulate `ncarry`,
5946 // note that ncarry could be >= 0x3ffffff
5947 var ncarry = carry >>> 26;
5948 var rword = carry & 0x3ffffff;
5949 var maxJ = Math.min(k, num.length - 1);
5950 for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
5951 var i = (k - j) | 0;
5952 a = self.words[i] | 0;
5953 b = num.words[j] | 0;
5954 r = a * b + rword;
5955 ncarry += (r / 0x4000000) | 0;
5956 rword = r & 0x3ffffff;
5957 }
5958 out.words[k] = rword | 0;
5959 carry = ncarry | 0;
5960 }
5961 if (carry !== 0) {
5962 out.words[k] = carry | 0;
5963 } else {
5964 out.length--;
5965 }
5966
5967 return out.strip();
5968 }
5969
5970 // TODO(indutny): it may be reasonable to omit it for users who don't need
5971 // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit
5972 // multiplication (like elliptic secp256k1).
5973 var comb10MulTo = function comb10MulTo (self, num, out) {
5974 var a = self.words;
5975 var b = num.words;
5976 var o = out.words;
5977 var c = 0;
5978 var lo;
5979 var mid;
5980 var hi;
5981 var a0 = a[0] | 0;
5982 var al0 = a0 & 0x1fff;
5983 var ah0 = a0 >>> 13;
5984 var a1 = a[1] | 0;
5985 var al1 = a1 & 0x1fff;
5986 var ah1 = a1 >>> 13;
5987 var a2 = a[2] | 0;
5988 var al2 = a2 & 0x1fff;
5989 var ah2 = a2 >>> 13;
5990 var a3 = a[3] | 0;
5991 var al3 = a3 & 0x1fff;
5992 var ah3 = a3 >>> 13;
5993 var a4 = a[4] | 0;
5994 var al4 = a4 & 0x1fff;
5995 var ah4 = a4 >>> 13;
5996 var a5 = a[5] | 0;
5997 var al5 = a5 & 0x1fff;
5998 var ah5 = a5 >>> 13;
5999 var a6 = a[6] | 0;
6000 var al6 = a6 & 0x1fff;
6001 var ah6 = a6 >>> 13;
6002 var a7 = a[7] | 0;
6003 var al7 = a7 & 0x1fff;
6004 var ah7 = a7 >>> 13;
6005 var a8 = a[8] | 0;
6006 var al8 = a8 & 0x1fff;
6007 var ah8 = a8 >>> 13;
6008 var a9 = a[9] | 0;
6009 var al9 = a9 & 0x1fff;
6010 var ah9 = a9 >>> 13;
6011 var b0 = b[0] | 0;
6012 var bl0 = b0 & 0x1fff;
6013 var bh0 = b0 >>> 13;
6014 var b1 = b[1] | 0;
6015 var bl1 = b1 & 0x1fff;
6016 var bh1 = b1 >>> 13;
6017 var b2 = b[2] | 0;
6018 var bl2 = b2 & 0x1fff;
6019 var bh2 = b2 >>> 13;
6020 var b3 = b[3] | 0;
6021 var bl3 = b3 & 0x1fff;
6022 var bh3 = b3 >>> 13;
6023 var b4 = b[4] | 0;
6024 var bl4 = b4 & 0x1fff;
6025 var bh4 = b4 >>> 13;
6026 var b5 = b[5] | 0;
6027 var bl5 = b5 & 0x1fff;
6028 var bh5 = b5 >>> 13;
6029 var b6 = b[6] | 0;
6030 var bl6 = b6 & 0x1fff;
6031 var bh6 = b6 >>> 13;
6032 var b7 = b[7] | 0;
6033 var bl7 = b7 & 0x1fff;
6034 var bh7 = b7 >>> 13;
6035 var b8 = b[8] | 0;
6036 var bl8 = b8 & 0x1fff;
6037 var bh8 = b8 >>> 13;
6038 var b9 = b[9] | 0;
6039 var bl9 = b9 & 0x1fff;
6040 var bh9 = b9 >>> 13;
6041
6042 out.negative = self.negative ^ num.negative;
6043 out.length = 19;
6044 /* k = 0 */
6045 lo = Math.imul(al0, bl0);
6046 mid = Math.imul(al0, bh0);
6047 mid = (mid + Math.imul(ah0, bl0)) | 0;
6048 hi = Math.imul(ah0, bh0);
6049 var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6050 c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0;
6051 w0 &= 0x3ffffff;
6052 /* k = 1 */
6053 lo = Math.imul(al1, bl0);
6054 mid = Math.imul(al1, bh0);
6055 mid = (mid + Math.imul(ah1, bl0)) | 0;
6056 hi = Math.imul(ah1, bh0);
6057 lo = (lo + Math.imul(al0, bl1)) | 0;
6058 mid = (mid + Math.imul(al0, bh1)) | 0;
6059 mid = (mid + Math.imul(ah0, bl1)) | 0;
6060 hi = (hi + Math.imul(ah0, bh1)) | 0;
6061 var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6062 c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0;
6063 w1 &= 0x3ffffff;
6064 /* k = 2 */
6065 lo = Math.imul(al2, bl0);
6066 mid = Math.imul(al2, bh0);
6067 mid = (mid + Math.imul(ah2, bl0)) | 0;
6068 hi = Math.imul(ah2, bh0);
6069 lo = (lo + Math.imul(al1, bl1)) | 0;
6070 mid = (mid + Math.imul(al1, bh1)) | 0;
6071 mid = (mid + Math.imul(ah1, bl1)) | 0;
6072 hi = (hi + Math.imul(ah1, bh1)) | 0;
6073 lo = (lo + Math.imul(al0, bl2)) | 0;
6074 mid = (mid + Math.imul(al0, bh2)) | 0;
6075 mid = (mid + Math.imul(ah0, bl2)) | 0;
6076 hi = (hi + Math.imul(ah0, bh2)) | 0;
6077 var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6078 c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0;
6079 w2 &= 0x3ffffff;
6080 /* k = 3 */
6081 lo = Math.imul(al3, bl0);
6082 mid = Math.imul(al3, bh0);
6083 mid = (mid + Math.imul(ah3, bl0)) | 0;
6084 hi = Math.imul(ah3, bh0);
6085 lo = (lo + Math.imul(al2, bl1)) | 0;
6086 mid = (mid + Math.imul(al2, bh1)) | 0;
6087 mid = (mid + Math.imul(ah2, bl1)) | 0;
6088 hi = (hi + Math.imul(ah2, bh1)) | 0;
6089 lo = (lo + Math.imul(al1, bl2)) | 0;
6090 mid = (mid + Math.imul(al1, bh2)) | 0;
6091 mid = (mid + Math.imul(ah1, bl2)) | 0;
6092 hi = (hi + Math.imul(ah1, bh2)) | 0;
6093 lo = (lo + Math.imul(al0, bl3)) | 0;
6094 mid = (mid + Math.imul(al0, bh3)) | 0;
6095 mid = (mid + Math.imul(ah0, bl3)) | 0;
6096 hi = (hi + Math.imul(ah0, bh3)) | 0;
6097 var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6098 c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0;
6099 w3 &= 0x3ffffff;
6100 /* k = 4 */
6101 lo = Math.imul(al4, bl0);
6102 mid = Math.imul(al4, bh0);
6103 mid = (mid + Math.imul(ah4, bl0)) | 0;
6104 hi = Math.imul(ah4, bh0);
6105 lo = (lo + Math.imul(al3, bl1)) | 0;
6106 mid = (mid + Math.imul(al3, bh1)) | 0;
6107 mid = (mid + Math.imul(ah3, bl1)) | 0;
6108 hi = (hi + Math.imul(ah3, bh1)) | 0;
6109 lo = (lo + Math.imul(al2, bl2)) | 0;
6110 mid = (mid + Math.imul(al2, bh2)) | 0;
6111 mid = (mid + Math.imul(ah2, bl2)) | 0;
6112 hi = (hi + Math.imul(ah2, bh2)) | 0;
6113 lo = (lo + Math.imul(al1, bl3)) | 0;
6114 mid = (mid + Math.imul(al1, bh3)) | 0;
6115 mid = (mid + Math.imul(ah1, bl3)) | 0;
6116 hi = (hi + Math.imul(ah1, bh3)) | 0;
6117 lo = (lo + Math.imul(al0, bl4)) | 0;
6118 mid = (mid + Math.imul(al0, bh4)) | 0;
6119 mid = (mid + Math.imul(ah0, bl4)) | 0;
6120 hi = (hi + Math.imul(ah0, bh4)) | 0;
6121 var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6122 c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0;
6123 w4 &= 0x3ffffff;
6124 /* k = 5 */
6125 lo = Math.imul(al5, bl0);
6126 mid = Math.imul(al5, bh0);
6127 mid = (mid + Math.imul(ah5, bl0)) | 0;
6128 hi = Math.imul(ah5, bh0);
6129 lo = (lo + Math.imul(al4, bl1)) | 0;
6130 mid = (mid + Math.imul(al4, bh1)) | 0;
6131 mid = (mid + Math.imul(ah4, bl1)) | 0;
6132 hi = (hi + Math.imul(ah4, bh1)) | 0;
6133 lo = (lo + Math.imul(al3, bl2)) | 0;
6134 mid = (mid + Math.imul(al3, bh2)) | 0;
6135 mid = (mid + Math.imul(ah3, bl2)) | 0;
6136 hi = (hi + Math.imul(ah3, bh2)) | 0;
6137 lo = (lo + Math.imul(al2, bl3)) | 0;
6138 mid = (mid + Math.imul(al2, bh3)) | 0;
6139 mid = (mid + Math.imul(ah2, bl3)) | 0;
6140 hi = (hi + Math.imul(ah2, bh3)) | 0;
6141 lo = (lo + Math.imul(al1, bl4)) | 0;
6142 mid = (mid + Math.imul(al1, bh4)) | 0;
6143 mid = (mid + Math.imul(ah1, bl4)) | 0;
6144 hi = (hi + Math.imul(ah1, bh4)) | 0;
6145 lo = (lo + Math.imul(al0, bl5)) | 0;
6146 mid = (mid + Math.imul(al0, bh5)) | 0;
6147 mid = (mid + Math.imul(ah0, bl5)) | 0;
6148 hi = (hi + Math.imul(ah0, bh5)) | 0;
6149 var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6150 c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0;
6151 w5 &= 0x3ffffff;
6152 /* k = 6 */
6153 lo = Math.imul(al6, bl0);
6154 mid = Math.imul(al6, bh0);
6155 mid = (mid + Math.imul(ah6, bl0)) | 0;
6156 hi = Math.imul(ah6, bh0);
6157 lo = (lo + Math.imul(al5, bl1)) | 0;
6158 mid = (mid + Math.imul(al5, bh1)) | 0;
6159 mid = (mid + Math.imul(ah5, bl1)) | 0;
6160 hi = (hi + Math.imul(ah5, bh1)) | 0;
6161 lo = (lo + Math.imul(al4, bl2)) | 0;
6162 mid = (mid + Math.imul(al4, bh2)) | 0;
6163 mid = (mid + Math.imul(ah4, bl2)) | 0;
6164 hi = (hi + Math.imul(ah4, bh2)) | 0;
6165 lo = (lo + Math.imul(al3, bl3)) | 0;
6166 mid = (mid + Math.imul(al3, bh3)) | 0;
6167 mid = (mid + Math.imul(ah3, bl3)) | 0;
6168 hi = (hi + Math.imul(ah3, bh3)) | 0;
6169 lo = (lo + Math.imul(al2, bl4)) | 0;
6170 mid = (mid + Math.imul(al2, bh4)) | 0;
6171 mid = (mid + Math.imul(ah2, bl4)) | 0;
6172 hi = (hi + Math.imul(ah2, bh4)) | 0;
6173 lo = (lo + Math.imul(al1, bl5)) | 0;
6174 mid = (mid + Math.imul(al1, bh5)) | 0;
6175 mid = (mid + Math.imul(ah1, bl5)) | 0;
6176 hi = (hi + Math.imul(ah1, bh5)) | 0;
6177 lo = (lo + Math.imul(al0, bl6)) | 0;
6178 mid = (mid + Math.imul(al0, bh6)) | 0;
6179 mid = (mid + Math.imul(ah0, bl6)) | 0;
6180 hi = (hi + Math.imul(ah0, bh6)) | 0;
6181 var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6182 c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0;
6183 w6 &= 0x3ffffff;
6184 /* k = 7 */
6185 lo = Math.imul(al7, bl0);
6186 mid = Math.imul(al7, bh0);
6187 mid = (mid + Math.imul(ah7, bl0)) | 0;
6188 hi = Math.imul(ah7, bh0);
6189 lo = (lo + Math.imul(al6, bl1)) | 0;
6190 mid = (mid + Math.imul(al6, bh1)) | 0;
6191 mid = (mid + Math.imul(ah6, bl1)) | 0;
6192 hi = (hi + Math.imul(ah6, bh1)) | 0;
6193 lo = (lo + Math.imul(al5, bl2)) | 0;
6194 mid = (mid + Math.imul(al5, bh2)) | 0;
6195 mid = (mid + Math.imul(ah5, bl2)) | 0;
6196 hi = (hi + Math.imul(ah5, bh2)) | 0;
6197 lo = (lo + Math.imul(al4, bl3)) | 0;
6198 mid = (mid + Math.imul(al4, bh3)) | 0;
6199 mid = (mid + Math.imul(ah4, bl3)) | 0;
6200 hi = (hi + Math.imul(ah4, bh3)) | 0;
6201 lo = (lo + Math.imul(al3, bl4)) | 0;
6202 mid = (mid + Math.imul(al3, bh4)) | 0;
6203 mid = (mid + Math.imul(ah3, bl4)) | 0;
6204 hi = (hi + Math.imul(ah3, bh4)) | 0;
6205 lo = (lo + Math.imul(al2, bl5)) | 0;
6206 mid = (mid + Math.imul(al2, bh5)) | 0;
6207 mid = (mid + Math.imul(ah2, bl5)) | 0;
6208 hi = (hi + Math.imul(ah2, bh5)) | 0;
6209 lo = (lo + Math.imul(al1, bl6)) | 0;
6210 mid = (mid + Math.imul(al1, bh6)) | 0;
6211 mid = (mid + Math.imul(ah1, bl6)) | 0;
6212 hi = (hi + Math.imul(ah1, bh6)) | 0;
6213 lo = (lo + Math.imul(al0, bl7)) | 0;
6214 mid = (mid + Math.imul(al0, bh7)) | 0;
6215 mid = (mid + Math.imul(ah0, bl7)) | 0;
6216 hi = (hi + Math.imul(ah0, bh7)) | 0;
6217 var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6218 c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0;
6219 w7 &= 0x3ffffff;
6220 /* k = 8 */
6221 lo = Math.imul(al8, bl0);
6222 mid = Math.imul(al8, bh0);
6223 mid = (mid + Math.imul(ah8, bl0)) | 0;
6224 hi = Math.imul(ah8, bh0);
6225 lo = (lo + Math.imul(al7, bl1)) | 0;
6226 mid = (mid + Math.imul(al7, bh1)) | 0;
6227 mid = (mid + Math.imul(ah7, bl1)) | 0;
6228 hi = (hi + Math.imul(ah7, bh1)) | 0;
6229 lo = (lo + Math.imul(al6, bl2)) | 0;
6230 mid = (mid + Math.imul(al6, bh2)) | 0;
6231 mid = (mid + Math.imul(ah6, bl2)) | 0;
6232 hi = (hi + Math.imul(ah6, bh2)) | 0;
6233 lo = (lo + Math.imul(al5, bl3)) | 0;
6234 mid = (mid + Math.imul(al5, bh3)) | 0;
6235 mid = (mid + Math.imul(ah5, bl3)) | 0;
6236 hi = (hi + Math.imul(ah5, bh3)) | 0;
6237 lo = (lo + Math.imul(al4, bl4)) | 0;
6238 mid = (mid + Math.imul(al4, bh4)) | 0;
6239 mid = (mid + Math.imul(ah4, bl4)) | 0;
6240 hi = (hi + Math.imul(ah4, bh4)) | 0;
6241 lo = (lo + Math.imul(al3, bl5)) | 0;
6242 mid = (mid + Math.imul(al3, bh5)) | 0;
6243 mid = (mid + Math.imul(ah3, bl5)) | 0;
6244 hi = (hi + Math.imul(ah3, bh5)) | 0;
6245 lo = (lo + Math.imul(al2, bl6)) | 0;
6246 mid = (mid + Math.imul(al2, bh6)) | 0;
6247 mid = (mid + Math.imul(ah2, bl6)) | 0;
6248 hi = (hi + Math.imul(ah2, bh6)) | 0;
6249 lo = (lo + Math.imul(al1, bl7)) | 0;
6250 mid = (mid + Math.imul(al1, bh7)) | 0;
6251 mid = (mid + Math.imul(ah1, bl7)) | 0;
6252 hi = (hi + Math.imul(ah1, bh7)) | 0;
6253 lo = (lo + Math.imul(al0, bl8)) | 0;
6254 mid = (mid + Math.imul(al0, bh8)) | 0;
6255 mid = (mid + Math.imul(ah0, bl8)) | 0;
6256 hi = (hi + Math.imul(ah0, bh8)) | 0;
6257 var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6258 c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0;
6259 w8 &= 0x3ffffff;
6260 /* k = 9 */
6261 lo = Math.imul(al9, bl0);
6262 mid = Math.imul(al9, bh0);
6263 mid = (mid + Math.imul(ah9, bl0)) | 0;
6264 hi = Math.imul(ah9, bh0);
6265 lo = (lo + Math.imul(al8, bl1)) | 0;
6266 mid = (mid + Math.imul(al8, bh1)) | 0;
6267 mid = (mid + Math.imul(ah8, bl1)) | 0;
6268 hi = (hi + Math.imul(ah8, bh1)) | 0;
6269 lo = (lo + Math.imul(al7, bl2)) | 0;
6270 mid = (mid + Math.imul(al7, bh2)) | 0;
6271 mid = (mid + Math.imul(ah7, bl2)) | 0;
6272 hi = (hi + Math.imul(ah7, bh2)) | 0;
6273 lo = (lo + Math.imul(al6, bl3)) | 0;
6274 mid = (mid + Math.imul(al6, bh3)) | 0;
6275 mid = (mid + Math.imul(ah6, bl3)) | 0;
6276 hi = (hi + Math.imul(ah6, bh3)) | 0;
6277 lo = (lo + Math.imul(al5, bl4)) | 0;
6278 mid = (mid + Math.imul(al5, bh4)) | 0;
6279 mid = (mid + Math.imul(ah5, bl4)) | 0;
6280 hi = (hi + Math.imul(ah5, bh4)) | 0;
6281 lo = (lo + Math.imul(al4, bl5)) | 0;
6282 mid = (mid + Math.imul(al4, bh5)) | 0;
6283 mid = (mid + Math.imul(ah4, bl5)) | 0;
6284 hi = (hi + Math.imul(ah4, bh5)) | 0;
6285 lo = (lo + Math.imul(al3, bl6)) | 0;
6286 mid = (mid + Math.imul(al3, bh6)) | 0;
6287 mid = (mid + Math.imul(ah3, bl6)) | 0;
6288 hi = (hi + Math.imul(ah3, bh6)) | 0;
6289 lo = (lo + Math.imul(al2, bl7)) | 0;
6290 mid = (mid + Math.imul(al2, bh7)) | 0;
6291 mid = (mid + Math.imul(ah2, bl7)) | 0;
6292 hi = (hi + Math.imul(ah2, bh7)) | 0;
6293 lo = (lo + Math.imul(al1, bl8)) | 0;
6294 mid = (mid + Math.imul(al1, bh8)) | 0;
6295 mid = (mid + Math.imul(ah1, bl8)) | 0;
6296 hi = (hi + Math.imul(ah1, bh8)) | 0;
6297 lo = (lo + Math.imul(al0, bl9)) | 0;
6298 mid = (mid + Math.imul(al0, bh9)) | 0;
6299 mid = (mid + Math.imul(ah0, bl9)) | 0;
6300 hi = (hi + Math.imul(ah0, bh9)) | 0;
6301 var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6302 c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0;
6303 w9 &= 0x3ffffff;
6304 /* k = 10 */
6305 lo = Math.imul(al9, bl1);
6306 mid = Math.imul(al9, bh1);
6307 mid = (mid + Math.imul(ah9, bl1)) | 0;
6308 hi = Math.imul(ah9, bh1);
6309 lo = (lo + Math.imul(al8, bl2)) | 0;
6310 mid = (mid + Math.imul(al8, bh2)) | 0;
6311 mid = (mid + Math.imul(ah8, bl2)) | 0;
6312 hi = (hi + Math.imul(ah8, bh2)) | 0;
6313 lo = (lo + Math.imul(al7, bl3)) | 0;
6314 mid = (mid + Math.imul(al7, bh3)) | 0;
6315 mid = (mid + Math.imul(ah7, bl3)) | 0;
6316 hi = (hi + Math.imul(ah7, bh3)) | 0;
6317 lo = (lo + Math.imul(al6, bl4)) | 0;
6318 mid = (mid + Math.imul(al6, bh4)) | 0;
6319 mid = (mid + Math.imul(ah6, bl4)) | 0;
6320 hi = (hi + Math.imul(ah6, bh4)) | 0;
6321 lo = (lo + Math.imul(al5, bl5)) | 0;
6322 mid = (mid + Math.imul(al5, bh5)) | 0;
6323 mid = (mid + Math.imul(ah5, bl5)) | 0;
6324 hi = (hi + Math.imul(ah5, bh5)) | 0;
6325 lo = (lo + Math.imul(al4, bl6)) | 0;
6326 mid = (mid + Math.imul(al4, bh6)) | 0;
6327 mid = (mid + Math.imul(ah4, bl6)) | 0;
6328 hi = (hi + Math.imul(ah4, bh6)) | 0;
6329 lo = (lo + Math.imul(al3, bl7)) | 0;
6330 mid = (mid + Math.imul(al3, bh7)) | 0;
6331 mid = (mid + Math.imul(ah3, bl7)) | 0;
6332 hi = (hi + Math.imul(ah3, bh7)) | 0;
6333 lo = (lo + Math.imul(al2, bl8)) | 0;
6334 mid = (mid + Math.imul(al2, bh8)) | 0;
6335 mid = (mid + Math.imul(ah2, bl8)) | 0;
6336 hi = (hi + Math.imul(ah2, bh8)) | 0;
6337 lo = (lo + Math.imul(al1, bl9)) | 0;
6338 mid = (mid + Math.imul(al1, bh9)) | 0;
6339 mid = (mid + Math.imul(ah1, bl9)) | 0;
6340 hi = (hi + Math.imul(ah1, bh9)) | 0;
6341 var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6342 c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0;
6343 w10 &= 0x3ffffff;
6344 /* k = 11 */
6345 lo = Math.imul(al9, bl2);
6346 mid = Math.imul(al9, bh2);
6347 mid = (mid + Math.imul(ah9, bl2)) | 0;
6348 hi = Math.imul(ah9, bh2);
6349 lo = (lo + Math.imul(al8, bl3)) | 0;
6350 mid = (mid + Math.imul(al8, bh3)) | 0;
6351 mid = (mid + Math.imul(ah8, bl3)) | 0;
6352 hi = (hi + Math.imul(ah8, bh3)) | 0;
6353 lo = (lo + Math.imul(al7, bl4)) | 0;
6354 mid = (mid + Math.imul(al7, bh4)) | 0;
6355 mid = (mid + Math.imul(ah7, bl4)) | 0;
6356 hi = (hi + Math.imul(ah7, bh4)) | 0;
6357 lo = (lo + Math.imul(al6, bl5)) | 0;
6358 mid = (mid + Math.imul(al6, bh5)) | 0;
6359 mid = (mid + Math.imul(ah6, bl5)) | 0;
6360 hi = (hi + Math.imul(ah6, bh5)) | 0;
6361 lo = (lo + Math.imul(al5, bl6)) | 0;
6362 mid = (mid + Math.imul(al5, bh6)) | 0;
6363 mid = (mid + Math.imul(ah5, bl6)) | 0;
6364 hi = (hi + Math.imul(ah5, bh6)) | 0;
6365 lo = (lo + Math.imul(al4, bl7)) | 0;
6366 mid = (mid + Math.imul(al4, bh7)) | 0;
6367 mid = (mid + Math.imul(ah4, bl7)) | 0;
6368 hi = (hi + Math.imul(ah4, bh7)) | 0;
6369 lo = (lo + Math.imul(al3, bl8)) | 0;
6370 mid = (mid + Math.imul(al3, bh8)) | 0;
6371 mid = (mid + Math.imul(ah3, bl8)) | 0;
6372 hi = (hi + Math.imul(ah3, bh8)) | 0;
6373 lo = (lo + Math.imul(al2, bl9)) | 0;
6374 mid = (mid + Math.imul(al2, bh9)) | 0;
6375 mid = (mid + Math.imul(ah2, bl9)) | 0;
6376 hi = (hi + Math.imul(ah2, bh9)) | 0;
6377 var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6378 c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0;
6379 w11 &= 0x3ffffff;
6380 /* k = 12 */
6381 lo = Math.imul(al9, bl3);
6382 mid = Math.imul(al9, bh3);
6383 mid = (mid + Math.imul(ah9, bl3)) | 0;
6384 hi = Math.imul(ah9, bh3);
6385 lo = (lo + Math.imul(al8, bl4)) | 0;
6386 mid = (mid + Math.imul(al8, bh4)) | 0;
6387 mid = (mid + Math.imul(ah8, bl4)) | 0;
6388 hi = (hi + Math.imul(ah8, bh4)) | 0;
6389 lo = (lo + Math.imul(al7, bl5)) | 0;
6390 mid = (mid + Math.imul(al7, bh5)) | 0;
6391 mid = (mid + Math.imul(ah7, bl5)) | 0;
6392 hi = (hi + Math.imul(ah7, bh5)) | 0;
6393 lo = (lo + Math.imul(al6, bl6)) | 0;
6394 mid = (mid + Math.imul(al6, bh6)) | 0;
6395 mid = (mid + Math.imul(ah6, bl6)) | 0;
6396 hi = (hi + Math.imul(ah6, bh6)) | 0;
6397 lo = (lo + Math.imul(al5, bl7)) | 0;
6398 mid = (mid + Math.imul(al5, bh7)) | 0;
6399 mid = (mid + Math.imul(ah5, bl7)) | 0;
6400 hi = (hi + Math.imul(ah5, bh7)) | 0;
6401 lo = (lo + Math.imul(al4, bl8)) | 0;
6402 mid = (mid + Math.imul(al4, bh8)) | 0;
6403 mid = (mid + Math.imul(ah4, bl8)) | 0;
6404 hi = (hi + Math.imul(ah4, bh8)) | 0;
6405 lo = (lo + Math.imul(al3, bl9)) | 0;
6406 mid = (mid + Math.imul(al3, bh9)) | 0;
6407 mid = (mid + Math.imul(ah3, bl9)) | 0;
6408 hi = (hi + Math.imul(ah3, bh9)) | 0;
6409 var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6410 c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0;
6411 w12 &= 0x3ffffff;
6412 /* k = 13 */
6413 lo = Math.imul(al9, bl4);
6414 mid = Math.imul(al9, bh4);
6415 mid = (mid + Math.imul(ah9, bl4)) | 0;
6416 hi = Math.imul(ah9, bh4);
6417 lo = (lo + Math.imul(al8, bl5)) | 0;
6418 mid = (mid + Math.imul(al8, bh5)) | 0;
6419 mid = (mid + Math.imul(ah8, bl5)) | 0;
6420 hi = (hi + Math.imul(ah8, bh5)) | 0;
6421 lo = (lo + Math.imul(al7, bl6)) | 0;
6422 mid = (mid + Math.imul(al7, bh6)) | 0;
6423 mid = (mid + Math.imul(ah7, bl6)) | 0;
6424 hi = (hi + Math.imul(ah7, bh6)) | 0;
6425 lo = (lo + Math.imul(al6, bl7)) | 0;
6426 mid = (mid + Math.imul(al6, bh7)) | 0;
6427 mid = (mid + Math.imul(ah6, bl7)) | 0;
6428 hi = (hi + Math.imul(ah6, bh7)) | 0;
6429 lo = (lo + Math.imul(al5, bl8)) | 0;
6430 mid = (mid + Math.imul(al5, bh8)) | 0;
6431 mid = (mid + Math.imul(ah5, bl8)) | 0;
6432 hi = (hi + Math.imul(ah5, bh8)) | 0;
6433 lo = (lo + Math.imul(al4, bl9)) | 0;
6434 mid = (mid + Math.imul(al4, bh9)) | 0;
6435 mid = (mid + Math.imul(ah4, bl9)) | 0;
6436 hi = (hi + Math.imul(ah4, bh9)) | 0;
6437 var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6438 c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0;
6439 w13 &= 0x3ffffff;
6440 /* k = 14 */
6441 lo = Math.imul(al9, bl5);
6442 mid = Math.imul(al9, bh5);
6443 mid = (mid + Math.imul(ah9, bl5)) | 0;
6444 hi = Math.imul(ah9, bh5);
6445 lo = (lo + Math.imul(al8, bl6)) | 0;
6446 mid = (mid + Math.imul(al8, bh6)) | 0;
6447 mid = (mid + Math.imul(ah8, bl6)) | 0;
6448 hi = (hi + Math.imul(ah8, bh6)) | 0;
6449 lo = (lo + Math.imul(al7, bl7)) | 0;
6450 mid = (mid + Math.imul(al7, bh7)) | 0;
6451 mid = (mid + Math.imul(ah7, bl7)) | 0;
6452 hi = (hi + Math.imul(ah7, bh7)) | 0;
6453 lo = (lo + Math.imul(al6, bl8)) | 0;
6454 mid = (mid + Math.imul(al6, bh8)) | 0;
6455 mid = (mid + Math.imul(ah6, bl8)) | 0;
6456 hi = (hi + Math.imul(ah6, bh8)) | 0;
6457 lo = (lo + Math.imul(al5, bl9)) | 0;
6458 mid = (mid + Math.imul(al5, bh9)) | 0;
6459 mid = (mid + Math.imul(ah5, bl9)) | 0;
6460 hi = (hi + Math.imul(ah5, bh9)) | 0;
6461 var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6462 c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0;
6463 w14 &= 0x3ffffff;
6464 /* k = 15 */
6465 lo = Math.imul(al9, bl6);
6466 mid = Math.imul(al9, bh6);
6467 mid = (mid + Math.imul(ah9, bl6)) | 0;
6468 hi = Math.imul(ah9, bh6);
6469 lo = (lo + Math.imul(al8, bl7)) | 0;
6470 mid = (mid + Math.imul(al8, bh7)) | 0;
6471 mid = (mid + Math.imul(ah8, bl7)) | 0;
6472 hi = (hi + Math.imul(ah8, bh7)) | 0;
6473 lo = (lo + Math.imul(al7, bl8)) | 0;
6474 mid = (mid + Math.imul(al7, bh8)) | 0;
6475 mid = (mid + Math.imul(ah7, bl8)) | 0;
6476 hi = (hi + Math.imul(ah7, bh8)) | 0;
6477 lo = (lo + Math.imul(al6, bl9)) | 0;
6478 mid = (mid + Math.imul(al6, bh9)) | 0;
6479 mid = (mid + Math.imul(ah6, bl9)) | 0;
6480 hi = (hi + Math.imul(ah6, bh9)) | 0;
6481 var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6482 c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0;
6483 w15 &= 0x3ffffff;
6484 /* k = 16 */
6485 lo = Math.imul(al9, bl7);
6486 mid = Math.imul(al9, bh7);
6487 mid = (mid + Math.imul(ah9, bl7)) | 0;
6488 hi = Math.imul(ah9, bh7);
6489 lo = (lo + Math.imul(al8, bl8)) | 0;
6490 mid = (mid + Math.imul(al8, bh8)) | 0;
6491 mid = (mid + Math.imul(ah8, bl8)) | 0;
6492 hi = (hi + Math.imul(ah8, bh8)) | 0;
6493 lo = (lo + Math.imul(al7, bl9)) | 0;
6494 mid = (mid + Math.imul(al7, bh9)) | 0;
6495 mid = (mid + Math.imul(ah7, bl9)) | 0;
6496 hi = (hi + Math.imul(ah7, bh9)) | 0;
6497 var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6498 c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0;
6499 w16 &= 0x3ffffff;
6500 /* k = 17 */
6501 lo = Math.imul(al9, bl8);
6502 mid = Math.imul(al9, bh8);
6503 mid = (mid + Math.imul(ah9, bl8)) | 0;
6504 hi = Math.imul(ah9, bh8);
6505 lo = (lo + Math.imul(al8, bl9)) | 0;
6506 mid = (mid + Math.imul(al8, bh9)) | 0;
6507 mid = (mid + Math.imul(ah8, bl9)) | 0;
6508 hi = (hi + Math.imul(ah8, bh9)) | 0;
6509 var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6510 c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0;
6511 w17 &= 0x3ffffff;
6512 /* k = 18 */
6513 lo = Math.imul(al9, bl9);
6514 mid = Math.imul(al9, bh9);
6515 mid = (mid + Math.imul(ah9, bl9)) | 0;
6516 hi = Math.imul(ah9, bh9);
6517 var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
6518 c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0;
6519 w18 &= 0x3ffffff;
6520 o[0] = w0;
6521 o[1] = w1;
6522 o[2] = w2;
6523 o[3] = w3;
6524 o[4] = w4;
6525 o[5] = w5;
6526 o[6] = w6;
6527 o[7] = w7;
6528 o[8] = w8;
6529 o[9] = w9;
6530 o[10] = w10;
6531 o[11] = w11;
6532 o[12] = w12;
6533 o[13] = w13;
6534 o[14] = w14;
6535 o[15] = w15;
6536 o[16] = w16;
6537 o[17] = w17;
6538 o[18] = w18;
6539 if (c !== 0) {
6540 o[19] = c;
6541 out.length++;
6542 }
6543 return out;
6544 };
6545
6546 // Polyfill comb
6547 if (!Math.imul) {
6548 comb10MulTo = smallMulTo;
6549 }
6550
6551 function bigMulTo (self, num, out) {
6552 out.negative = num.negative ^ self.negative;
6553 out.length = self.length + num.length;
6554
6555 var carry = 0;
6556 var hncarry = 0;
6557 for (var k = 0; k < out.length - 1; k++) {
6558 // Sum all words with the same `i + j = k` and accumulate `ncarry`,
6559 // note that ncarry could be >= 0x3ffffff
6560 var ncarry = hncarry;
6561 hncarry = 0;
6562 var rword = carry & 0x3ffffff;
6563 var maxJ = Math.min(k, num.length - 1);
6564 for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
6565 var i = k - j;
6566 var a = self.words[i] | 0;
6567 var b = num.words[j] | 0;
6568 var r = a * b;
6569
6570 var lo = r & 0x3ffffff;
6571 ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0;
6572 lo = (lo + rword) | 0;
6573 rword = lo & 0x3ffffff;
6574 ncarry = (ncarry + (lo >>> 26)) | 0;
6575
6576 hncarry += ncarry >>> 26;
6577 ncarry &= 0x3ffffff;
6578 }
6579 out.words[k] = rword;
6580 carry = ncarry;
6581 ncarry = hncarry;
6582 }
6583 if (carry !== 0) {
6584 out.words[k] = carry;
6585 } else {
6586 out.length--;
6587 }
6588
6589 return out.strip();
6590 }
6591
6592 function jumboMulTo (self, num, out) {
6593 var fftm = new FFTM();
6594 return fftm.mulp(self, num, out);
6595 }
6596
6597 BN.prototype.mulTo = function mulTo (num, out) {
6598 var res;
6599 var len = this.length + num.length;
6600 if (this.length === 10 && num.length === 10) {
6601 res = comb10MulTo(this, num, out);
6602 } else if (len < 63) {
6603 res = smallMulTo(this, num, out);
6604 } else if (len < 1024) {
6605 res = bigMulTo(this, num, out);
6606 } else {
6607 res = jumboMulTo(this, num, out);
6608 }
6609
6610 return res;
6611 };
6612
6613 // Cooley-Tukey algorithm for FFT
6614 // slightly revisited to rely on looping instead of recursion
6615
6616 function FFTM (x, y) {
6617 this.x = x;
6618 this.y = y;
6619 }
6620
6621 FFTM.prototype.makeRBT = function makeRBT (N) {
6622 var t = new Array(N);
6623 var l = BN.prototype._countBits(N) - 1;
6624 for (var i = 0; i < N; i++) {
6625 t[i] = this.revBin(i, l, N);
6626 }
6627
6628 return t;
6629 };
6630
6631 // Returns binary-reversed representation of `x`
6632 FFTM.prototype.revBin = function revBin (x, l, N) {
6633 if (x === 0 || x === N - 1) return x;
6634
6635 var rb = 0;
6636 for (var i = 0; i < l; i++) {
6637 rb |= (x & 1) << (l - i - 1);
6638 x >>= 1;
6639 }
6640
6641 return rb;
6642 };
6643
6644 // Performs "tweedling" phase, therefore 'emulating'
6645 // behaviour of the recursive algorithm
6646 FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) {
6647 for (var i = 0; i < N; i++) {
6648 rtws[i] = rws[rbt[i]];
6649 itws[i] = iws[rbt[i]];
6650 }
6651 };
6652
6653 FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) {
6654 this.permute(rbt, rws, iws, rtws, itws, N);
6655
6656 for (var s = 1; s < N; s <<= 1) {
6657 var l = s << 1;
6658
6659 var rtwdf = Math.cos(2 * Math.PI / l);
6660 var itwdf = Math.sin(2 * Math.PI / l);
6661
6662 for (var p = 0; p < N; p += l) {
6663 var rtwdf_ = rtwdf;
6664 var itwdf_ = itwdf;
6665
6666 for (var j = 0; j < s; j++) {
6667 var re = rtws[p + j];
6668 var ie = itws[p + j];
6669
6670 var ro = rtws[p + j + s];
6671 var io = itws[p + j + s];
6672
6673 var rx = rtwdf_ * ro - itwdf_ * io;
6674
6675 io = rtwdf_ * io + itwdf_ * ro;
6676 ro = rx;
6677
6678 rtws[p + j] = re + ro;
6679 itws[p + j] = ie + io;
6680
6681 rtws[p + j + s] = re - ro;
6682 itws[p + j + s] = ie - io;
6683
6684 /* jshint maxdepth : false */
6685 if (j !== l) {
6686 rx = rtwdf * rtwdf_ - itwdf * itwdf_;
6687
6688 itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;
6689 rtwdf_ = rx;
6690 }
6691 }
6692 }
6693 }
6694 };
6695
6696 FFTM.prototype.guessLen13b = function guessLen13b (n, m) {
6697 var N = Math.max(m, n) | 1;
6698 var odd = N & 1;
6699 var i = 0;
6700 for (N = N / 2 | 0; N; N = N >>> 1) {
6701 i++;
6702 }
6703
6704 return 1 << i + 1 + odd;
6705 };
6706
6707 FFTM.prototype.conjugate = function conjugate (rws, iws, N) {
6708 if (N <= 1) return;
6709
6710 for (var i = 0; i < N / 2; i++) {
6711 var t = rws[i];
6712
6713 rws[i] = rws[N - i - 1];
6714 rws[N - i - 1] = t;
6715
6716 t = iws[i];
6717
6718 iws[i] = -iws[N - i - 1];
6719 iws[N - i - 1] = -t;
6720 }
6721 };
6722
6723 FFTM.prototype.normalize13b = function normalize13b (ws, N) {
6724 var carry = 0;
6725 for (var i = 0; i < N / 2; i++) {
6726 var w = Math.round(ws[2 * i + 1] / N) * 0x2000 +
6727 Math.round(ws[2 * i] / N) +
6728 carry;
6729
6730 ws[i] = w & 0x3ffffff;
6731
6732 if (w < 0x4000000) {
6733 carry = 0;
6734 } else {
6735 carry = w / 0x4000000 | 0;
6736 }
6737 }
6738
6739 return ws;
6740 };
6741
6742 FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) {
6743 var carry = 0;
6744 for (var i = 0; i < len; i++) {
6745 carry = carry + (ws[i] | 0);
6746
6747 rws[2 * i] = carry & 0x1fff; carry = carry >>> 13;
6748 rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13;
6749 }
6750
6751 // Pad with zeroes
6752 for (i = 2 * len; i < N; ++i) {
6753 rws[i] = 0;
6754 }
6755
6756 assert(carry === 0);
6757 assert((carry & ~0x1fff) === 0);
6758 };
6759
6760 FFTM.prototype.stub = function stub (N) {
6761 var ph = new Array(N);
6762 for (var i = 0; i < N; i++) {
6763 ph[i] = 0;
6764 }
6765
6766 return ph;
6767 };
6768
6769 FFTM.prototype.mulp = function mulp (x, y, out) {
6770 var N = 2 * this.guessLen13b(x.length, y.length);
6771
6772 var rbt = this.makeRBT(N);
6773
6774 var _ = this.stub(N);
6775
6776 var rws = new Array(N);
6777 var rwst = new Array(N);
6778 var iwst = new Array(N);
6779
6780 var nrws = new Array(N);
6781 var nrwst = new Array(N);
6782 var niwst = new Array(N);
6783
6784 var rmws = out.words;
6785 rmws.length = N;
6786
6787 this.convert13b(x.words, x.length, rws, N);
6788 this.convert13b(y.words, y.length, nrws, N);
6789
6790 this.transform(rws, _, rwst, iwst, N, rbt);
6791 this.transform(nrws, _, nrwst, niwst, N, rbt);
6792
6793 for (var i = 0; i < N; i++) {
6794 var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];
6795 iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];
6796 rwst[i] = rx;
6797 }
6798
6799 this.conjugate(rwst, iwst, N);
6800 this.transform(rwst, iwst, rmws, _, N, rbt);
6801 this.conjugate(rmws, _, N);
6802 this.normalize13b(rmws, N);
6803
6804 out.negative = x.negative ^ y.negative;
6805 out.length = x.length + y.length;
6806 return out.strip();
6807 };
6808
6809 // Multiply `this` by `num`
6810 BN.prototype.mul = function mul (num) {
6811 var out = new BN(null);
6812 out.words = new Array(this.length + num.length);
6813 return this.mulTo(num, out);
6814 };
6815
6816 // Multiply employing FFT
6817 BN.prototype.mulf = function mulf (num) {
6818 var out = new BN(null);
6819 out.words = new Array(this.length + num.length);
6820 return jumboMulTo(this, num, out);
6821 };
6822
6823 // In-place Multiplication
6824 BN.prototype.imul = function imul (num) {
6825 return this.clone().mulTo(num, this);
6826 };
6827
6828 BN.prototype.imuln = function imuln (num) {
6829 assert(typeof num === 'number');
6830 assert(num < 0x4000000);
6831
6832 // Carry
6833 var carry = 0;
6834 for (var i = 0; i < this.length; i++) {
6835 var w = (this.words[i] | 0) * num;
6836 var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);
6837 carry >>= 26;
6838 carry += (w / 0x4000000) | 0;
6839 // NOTE: lo is 27bit maximum
6840 carry += lo >>> 26;
6841 this.words[i] = lo & 0x3ffffff;
6842 }
6843
6844 if (carry !== 0) {
6845 this.words[i] = carry;
6846 this.length++;
6847 }
6848
6849 return this;
6850 };
6851
6852 BN.prototype.muln = function muln (num) {
6853 return this.clone().imuln(num);
6854 };
6855
6856 // `this` * `this`
6857 BN.prototype.sqr = function sqr () {
6858 return this.mul(this);
6859 };
6860
6861 // `this` * `this` in-place
6862 BN.prototype.isqr = function isqr () {
6863 return this.imul(this.clone());
6864 };
6865
6866 // Math.pow(`this`, `num`)
6867 BN.prototype.pow = function pow (num) {
6868 var w = toBitArray(num);
6869 if (w.length === 0) return new BN(1);
6870
6871 // Skip leading zeroes
6872 var res = this;
6873 for (var i = 0; i < w.length; i++, res = res.sqr()) {
6874 if (w[i] !== 0) break;
6875 }
6876
6877 if (++i < w.length) {
6878 for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {
6879 if (w[i] === 0) continue;
6880
6881 res = res.mul(q);
6882 }
6883 }
6884
6885 return res;
6886 };
6887
6888 // Shift-left in-place
6889 BN.prototype.iushln = function iushln (bits) {
6890 assert(typeof bits === 'number' && bits >= 0);
6891 var r = bits % 26;
6892 var s = (bits - r) / 26;
6893 var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r);
6894 var i;
6895
6896 if (r !== 0) {
6897 var carry = 0;
6898
6899 for (i = 0; i < this.length; i++) {
6900 var newCarry = this.words[i] & carryMask;
6901 var c = ((this.words[i] | 0) - newCarry) << r;
6902 this.words[i] = c | carry;
6903 carry = newCarry >>> (26 - r);
6904 }
6905
6906 if (carry) {
6907 this.words[i] = carry;
6908 this.length++;
6909 }
6910 }
6911
6912 if (s !== 0) {
6913 for (i = this.length - 1; i >= 0; i--) {
6914 this.words[i + s] = this.words[i];
6915 }
6916
6917 for (i = 0; i < s; i++) {
6918 this.words[i] = 0;
6919 }
6920
6921 this.length += s;
6922 }
6923
6924 return this.strip();
6925 };
6926
6927 BN.prototype.ishln = function ishln (bits) {
6928 // TODO(indutny): implement me
6929 assert(this.negative === 0);
6930 return this.iushln(bits);
6931 };
6932
6933 // Shift-right in-place
6934 // NOTE: `hint` is a lowest bit before trailing zeroes
6935 // NOTE: if `extended` is present - it will be filled with destroyed bits
6936 BN.prototype.iushrn = function iushrn (bits, hint, extended) {
6937 assert(typeof bits === 'number' && bits >= 0);
6938 var h;
6939 if (hint) {
6940 h = (hint - (hint % 26)) / 26;
6941 } else {
6942 h = 0;
6943 }
6944
6945 var r = bits % 26;
6946 var s = Math.min((bits - r) / 26, this.length);
6947 var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
6948 var maskedWords = extended;
6949
6950 h -= s;
6951 h = Math.max(0, h);
6952
6953 // Extended mode, copy masked part
6954 if (maskedWords) {
6955 for (var i = 0; i < s; i++) {
6956 maskedWords.words[i] = this.words[i];
6957 }
6958 maskedWords.length = s;
6959 }
6960
6961 if (s === 0) {
6962 // No-op, we should not move anything at all
6963 } else if (this.length > s) {
6964 this.length -= s;
6965 for (i = 0; i < this.length; i++) {
6966 this.words[i] = this.words[i + s];
6967 }
6968 } else {
6969 this.words[0] = 0;
6970 this.length = 1;
6971 }
6972
6973 var carry = 0;
6974 for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {
6975 var word = this.words[i] | 0;
6976 this.words[i] = (carry << (26 - r)) | (word >>> r);
6977 carry = word & mask;
6978 }
6979
6980 // Push carried bits as a mask
6981 if (maskedWords && carry !== 0) {
6982 maskedWords.words[maskedWords.length++] = carry;
6983 }
6984
6985 if (this.length === 0) {
6986 this.words[0] = 0;
6987 this.length = 1;
6988 }
6989
6990 return this.strip();
6991 };
6992
6993 BN.prototype.ishrn = function ishrn (bits, hint, extended) {
6994 // TODO(indutny): implement me
6995 assert(this.negative === 0);
6996 return this.iushrn(bits, hint, extended);
6997 };
6998
6999 // Shift-left
7000 BN.prototype.shln = function shln (bits) {
7001 return this.clone().ishln(bits);
7002 };
7003
7004 BN.prototype.ushln = function ushln (bits) {
7005 return this.clone().iushln(bits);
7006 };
7007
7008 // Shift-right
7009 BN.prototype.shrn = function shrn (bits) {
7010 return this.clone().ishrn(bits);
7011 };
7012
7013 BN.prototype.ushrn = function ushrn (bits) {
7014 return this.clone().iushrn(bits);
7015 };
7016
7017 // Test if n bit is set
7018 BN.prototype.testn = function testn (bit) {
7019 assert(typeof bit === 'number' && bit >= 0);
7020 var r = bit % 26;
7021 var s = (bit - r) / 26;
7022 var q = 1 << r;
7023
7024 // Fast case: bit is much higher than all existing words
7025 if (this.length <= s) return false;
7026
7027 // Check bit and return
7028 var w = this.words[s];
7029
7030 return !!(w & q);
7031 };
7032
7033 // Return only lowers bits of number (in-place)
7034 BN.prototype.imaskn = function imaskn (bits) {
7035 assert(typeof bits === 'number' && bits >= 0);
7036 var r = bits % 26;
7037 var s = (bits - r) / 26;
7038
7039 assert(this.negative === 0, 'imaskn works only with positive numbers');
7040
7041 if (this.length <= s) {
7042 return this;
7043 }
7044
7045 if (r !== 0) {
7046 s++;
7047 }
7048 this.length = Math.min(s, this.length);
7049
7050 if (r !== 0) {
7051 var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
7052 this.words[this.length - 1] &= mask;
7053 }
7054
7055 return this.strip();
7056 };
7057
7058 // Return only lowers bits of number
7059 BN.prototype.maskn = function maskn (bits) {
7060 return this.clone().imaskn(bits);
7061 };
7062
7063 // Add plain number `num` to `this`
7064 BN.prototype.iaddn = function iaddn (num) {
7065 assert(typeof num === 'number');
7066 assert(num < 0x4000000);
7067 if (num < 0) return this.isubn(-num);
7068
7069 // Possible sign change
7070 if (this.negative !== 0) {
7071 if (this.length === 1 && (this.words[0] | 0) < num) {
7072 this.words[0] = num - (this.words[0] | 0);
7073 this.negative = 0;
7074 return this;
7075 }
7076
7077 this.negative = 0;
7078 this.isubn(num);
7079 this.negative = 1;
7080 return this;
7081 }
7082
7083 // Add without checks
7084 return this._iaddn(num);
7085 };
7086
7087 BN.prototype._iaddn = function _iaddn (num) {
7088 this.words[0] += num;
7089
7090 // Carry
7091 for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {
7092 this.words[i] -= 0x4000000;
7093 if (i === this.length - 1) {
7094 this.words[i + 1] = 1;
7095 } else {
7096 this.words[i + 1]++;
7097 }
7098 }
7099 this.length = Math.max(this.length, i + 1);
7100
7101 return this;
7102 };
7103
7104 // Subtract plain number `num` from `this`
7105 BN.prototype.isubn = function isubn (num) {
7106 assert(typeof num === 'number');
7107 assert(num < 0x4000000);
7108 if (num < 0) return this.iaddn(-num);
7109
7110 if (this.negative !== 0) {
7111 this.negative = 0;
7112 this.iaddn(num);
7113 this.negative = 1;
7114 return this;
7115 }
7116
7117 this.words[0] -= num;
7118
7119 if (this.length === 1 && this.words[0] < 0) {
7120 this.words[0] = -this.words[0];
7121 this.negative = 1;
7122 } else {
7123 // Carry
7124 for (var i = 0; i < this.length && this.words[i] < 0; i++) {
7125 this.words[i] += 0x4000000;
7126 this.words[i + 1] -= 1;
7127 }
7128 }
7129
7130 return this.strip();
7131 };
7132
7133 BN.prototype.addn = function addn (num) {
7134 return this.clone().iaddn(num);
7135 };
7136
7137 BN.prototype.subn = function subn (num) {
7138 return this.clone().isubn(num);
7139 };
7140
7141 BN.prototype.iabs = function iabs () {
7142 this.negative = 0;
7143
7144 return this;
7145 };
7146
7147 BN.prototype.abs = function abs () {
7148 return this.clone().iabs();
7149 };
7150
7151 BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) {
7152 var len = num.length + shift;
7153 var i;
7154
7155 this._expand(len);
7156
7157 var w;
7158 var carry = 0;
7159 for (i = 0; i < num.length; i++) {
7160 w = (this.words[i + shift] | 0) + carry;
7161 var right = (num.words[i] | 0) * mul;
7162 w -= right & 0x3ffffff;
7163 carry = (w >> 26) - ((right / 0x4000000) | 0);
7164 this.words[i + shift] = w & 0x3ffffff;
7165 }
7166 for (; i < this.length - shift; i++) {
7167 w = (this.words[i + shift] | 0) + carry;
7168 carry = w >> 26;
7169 this.words[i + shift] = w & 0x3ffffff;
7170 }
7171
7172 if (carry === 0) return this.strip();
7173
7174 // Subtraction overflow
7175 assert(carry === -1);
7176 carry = 0;
7177 for (i = 0; i < this.length; i++) {
7178 w = -(this.words[i] | 0) + carry;
7179 carry = w >> 26;
7180 this.words[i] = w & 0x3ffffff;
7181 }
7182 this.negative = 1;
7183
7184 return this.strip();
7185 };
7186
7187 BN.prototype._wordDiv = function _wordDiv (num, mode) {
7188 var shift = this.length - num.length;
7189
7190 var a = this.clone();
7191 var b = num;
7192
7193 // Normalize
7194 var bhi = b.words[b.length - 1] | 0;
7195 var bhiBits = this._countBits(bhi);
7196 shift = 26 - bhiBits;
7197 if (shift !== 0) {
7198 b = b.ushln(shift);
7199 a.iushln(shift);
7200 bhi = b.words[b.length - 1] | 0;
7201 }
7202
7203 // Initialize quotient
7204 var m = a.length - b.length;
7205 var q;
7206
7207 if (mode !== 'mod') {
7208 q = new BN(null);
7209 q.length = m + 1;
7210 q.words = new Array(q.length);
7211 for (var i = 0; i < q.length; i++) {
7212 q.words[i] = 0;
7213 }
7214 }
7215
7216 var diff = a.clone()._ishlnsubmul(b, 1, m);
7217 if (diff.negative === 0) {
7218 a = diff;
7219 if (q) {
7220 q.words[m] = 1;
7221 }
7222 }
7223
7224 for (var j = m - 1; j >= 0; j--) {
7225 var qj = (a.words[b.length + j] | 0) * 0x4000000 +
7226 (a.words[b.length + j - 1] | 0);
7227
7228 // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max
7229 // (0x7ffffff)
7230 qj = Math.min((qj / bhi) | 0, 0x3ffffff);
7231
7232 a._ishlnsubmul(b, qj, j);
7233 while (a.negative !== 0) {
7234 qj--;
7235 a.negative = 0;
7236 a._ishlnsubmul(b, 1, j);
7237 if (!a.isZero()) {
7238 a.negative ^= 1;
7239 }
7240 }
7241 if (q) {
7242 q.words[j] = qj;
7243 }
7244 }
7245 if (q) {
7246 q.strip();
7247 }
7248 a.strip();
7249
7250 // Denormalize
7251 if (mode !== 'div' && shift !== 0) {
7252 a.iushrn(shift);
7253 }
7254
7255 return {
7256 div: q || null,
7257 mod: a
7258 };
7259 };
7260
7261 // NOTE: 1) `mode` can be set to `mod` to request mod only,
7262 // to `div` to request div only, or be absent to
7263 // request both div & mod
7264 // 2) `positive` is true if unsigned mod is requested
7265 BN.prototype.divmod = function divmod (num, mode, positive) {
7266 assert(!num.isZero());
7267
7268 if (this.isZero()) {
7269 return {
7270 div: new BN(0),
7271 mod: new BN(0)
7272 };
7273 }
7274
7275 var div, mod, res;
7276 if (this.negative !== 0 && num.negative === 0) {
7277 res = this.neg().divmod(num, mode);
7278
7279 if (mode !== 'mod') {
7280 div = res.div.neg();
7281 }
7282
7283 if (mode !== 'div') {
7284 mod = res.mod.neg();
7285 if (positive && mod.negative !== 0) {
7286 mod.iadd(num);
7287 }
7288 }
7289
7290 return {
7291 div: div,
7292 mod: mod
7293 };
7294 }
7295
7296 if (this.negative === 0 && num.negative !== 0) {
7297 res = this.divmod(num.neg(), mode);
7298
7299 if (mode !== 'mod') {
7300 div = res.div.neg();
7301 }
7302
7303 return {
7304 div: div,
7305 mod: res.mod
7306 };
7307 }
7308
7309 if ((this.negative & num.negative) !== 0) {
7310 res = this.neg().divmod(num.neg(), mode);
7311
7312 if (mode !== 'div') {
7313 mod = res.mod.neg();
7314 if (positive && mod.negative !== 0) {
7315 mod.isub(num);
7316 }
7317 }
7318
7319 return {
7320 div: res.div,
7321 mod: mod
7322 };
7323 }
7324
7325 // Both numbers are positive at this point
7326
7327 // Strip both numbers to approximate shift value
7328 if (num.length > this.length || this.cmp(num) < 0) {
7329 return {
7330 div: new BN(0),
7331 mod: this
7332 };
7333 }
7334
7335 // Very short reduction
7336 if (num.length === 1) {
7337 if (mode === 'div') {
7338 return {
7339 div: this.divn(num.words[0]),
7340 mod: null
7341 };
7342 }
7343
7344 if (mode === 'mod') {
7345 return {
7346 div: null,
7347 mod: new BN(this.modn(num.words[0]))
7348 };
7349 }
7350
7351 return {
7352 div: this.divn(num.words[0]),
7353 mod: new BN(this.modn(num.words[0]))
7354 };
7355 }
7356
7357 return this._wordDiv(num, mode);
7358 };
7359
7360 // Find `this` / `num`
7361 BN.prototype.div = function div (num) {
7362 return this.divmod(num, 'div', false).div;
7363 };
7364
7365 // Find `this` % `num`
7366 BN.prototype.mod = function mod (num) {
7367 return this.divmod(num, 'mod', false).mod;
7368 };
7369
7370 BN.prototype.umod = function umod (num) {
7371 return this.divmod(num, 'mod', true).mod;
7372 };
7373
7374 // Find Round(`this` / `num`)
7375 BN.prototype.divRound = function divRound (num) {
7376 var dm = this.divmod(num);
7377
7378 // Fast case - exact division
7379 if (dm.mod.isZero()) return dm.div;
7380
7381 var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
7382
7383 var half = num.ushrn(1);
7384 var r2 = num.andln(1);
7385 var cmp = mod.cmp(half);
7386
7387 // Round down
7388 if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;
7389
7390 // Round up
7391 return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
7392 };
7393
7394 BN.prototype.modn = function modn (num) {
7395 assert(num <= 0x3ffffff);
7396 var p = (1 << 26) % num;
7397
7398 var acc = 0;
7399 for (var i = this.length - 1; i >= 0; i--) {
7400 acc = (p * acc + (this.words[i] | 0)) % num;
7401 }
7402
7403 return acc;
7404 };
7405
7406 // In-place division by number
7407 BN.prototype.idivn = function idivn (num) {
7408 assert(num <= 0x3ffffff);
7409
7410 var carry = 0;
7411 for (var i = this.length - 1; i >= 0; i--) {
7412 var w = (this.words[i] | 0) + carry * 0x4000000;
7413 this.words[i] = (w / num) | 0;
7414 carry = w % num;
7415 }
7416
7417 return this.strip();
7418 };
7419
7420 BN.prototype.divn = function divn (num) {
7421 return this.clone().idivn(num);
7422 };
7423
7424 BN.prototype.egcd = function egcd (p) {
7425 assert(p.negative === 0);
7426 assert(!p.isZero());
7427
7428 var x = this;
7429 var y = p.clone();
7430
7431 if (x.negative !== 0) {
7432 x = x.umod(p);
7433 } else {
7434 x = x.clone();
7435 }
7436
7437 // A * x + B * y = x
7438 var A = new BN(1);
7439 var B = new BN(0);
7440
7441 // C * x + D * y = y
7442 var C = new BN(0);
7443 var D = new BN(1);
7444
7445 var g = 0;
7446
7447 while (x.isEven() && y.isEven()) {
7448 x.iushrn(1);
7449 y.iushrn(1);
7450 ++g;
7451 }
7452
7453 var yp = y.clone();
7454 var xp = x.clone();
7455
7456 while (!x.isZero()) {
7457 for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
7458 if (i > 0) {
7459 x.iushrn(i);
7460 while (i-- > 0) {
7461 if (A.isOdd() || B.isOdd()) {
7462 A.iadd(yp);
7463 B.isub(xp);
7464 }
7465
7466 A.iushrn(1);
7467 B.iushrn(1);
7468 }
7469 }
7470
7471 for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
7472 if (j > 0) {
7473 y.iushrn(j);
7474 while (j-- > 0) {
7475 if (C.isOdd() || D.isOdd()) {
7476 C.iadd(yp);
7477 D.isub(xp);
7478 }
7479
7480 C.iushrn(1);
7481 D.iushrn(1);
7482 }
7483 }
7484
7485 if (x.cmp(y) >= 0) {
7486 x.isub(y);
7487 A.isub(C);
7488 B.isub(D);
7489 } else {
7490 y.isub(x);
7491 C.isub(A);
7492 D.isub(B);
7493 }
7494 }
7495
7496 return {
7497 a: C,
7498 b: D,
7499 gcd: y.iushln(g)
7500 };
7501 };
7502
7503 // This is reduced incarnation of the binary EEA
7504 // above, designated to invert members of the
7505 // _prime_ fields F(p) at a maximal speed
7506 BN.prototype._invmp = function _invmp (p) {
7507 assert(p.negative === 0);
7508 assert(!p.isZero());
7509
7510 var a = this;
7511 var b = p.clone();
7512
7513 if (a.negative !== 0) {
7514 a = a.umod(p);
7515 } else {
7516 a = a.clone();
7517 }
7518
7519 var x1 = new BN(1);
7520 var x2 = new BN(0);
7521
7522 var delta = b.clone();
7523
7524 while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
7525 for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
7526 if (i > 0) {
7527 a.iushrn(i);
7528 while (i-- > 0) {
7529 if (x1.isOdd()) {
7530 x1.iadd(delta);
7531 }
7532
7533 x1.iushrn(1);
7534 }
7535 }
7536
7537 for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
7538 if (j > 0) {
7539 b.iushrn(j);
7540 while (j-- > 0) {
7541 if (x2.isOdd()) {
7542 x2.iadd(delta);
7543 }
7544
7545 x2.iushrn(1);
7546 }
7547 }
7548
7549 if (a.cmp(b) >= 0) {
7550 a.isub(b);
7551 x1.isub(x2);
7552 } else {
7553 b.isub(a);
7554 x2.isub(x1);
7555 }
7556 }
7557
7558 var res;
7559 if (a.cmpn(1) === 0) {
7560 res = x1;
7561 } else {
7562 res = x2;
7563 }
7564
7565 if (res.cmpn(0) < 0) {
7566 res.iadd(p);
7567 }
7568
7569 return res;
7570 };
7571
7572 BN.prototype.gcd = function gcd (num) {
7573 if (this.isZero()) return num.abs();
7574 if (num.isZero()) return this.abs();
7575
7576 var a = this.clone();
7577 var b = num.clone();
7578 a.negative = 0;
7579 b.negative = 0;
7580
7581 // Remove common factor of two
7582 for (var shift = 0; a.isEven() && b.isEven(); shift++) {
7583 a.iushrn(1);
7584 b.iushrn(1);
7585 }
7586
7587 do {
7588 while (a.isEven()) {
7589 a.iushrn(1);
7590 }
7591 while (b.isEven()) {
7592 b.iushrn(1);
7593 }
7594
7595 var r = a.cmp(b);
7596 if (r < 0) {
7597 // Swap `a` and `b` to make `a` always bigger than `b`
7598 var t = a;
7599 a = b;
7600 b = t;
7601 } else if (r === 0 || b.cmpn(1) === 0) {
7602 break;
7603 }
7604
7605 a.isub(b);
7606 } while (true);
7607
7608 return b.iushln(shift);
7609 };
7610
7611 // Invert number in the field F(num)
7612 BN.prototype.invm = function invm (num) {
7613 return this.egcd(num).a.umod(num);
7614 };
7615
7616 BN.prototype.isEven = function isEven () {
7617 return (this.words[0] & 1) === 0;
7618 };
7619
7620 BN.prototype.isOdd = function isOdd () {
7621 return (this.words[0] & 1) === 1;
7622 };
7623
7624 // And first word and num
7625 BN.prototype.andln = function andln (num) {
7626 return this.words[0] & num;
7627 };
7628
7629 // Increment at the bit position in-line
7630 BN.prototype.bincn = function bincn (bit) {
7631 assert(typeof bit === 'number');
7632 var r = bit % 26;
7633 var s = (bit - r) / 26;
7634 var q = 1 << r;
7635
7636 // Fast case: bit is much higher than all existing words
7637 if (this.length <= s) {
7638 this._expand(s + 1);
7639 this.words[s] |= q;
7640 return this;
7641 }
7642
7643 // Add bit and propagate, if needed
7644 var carry = q;
7645 for (var i = s; carry !== 0 && i < this.length; i++) {
7646 var w = this.words[i] | 0;
7647 w += carry;
7648 carry = w >>> 26;
7649 w &= 0x3ffffff;
7650 this.words[i] = w;
7651 }
7652 if (carry !== 0) {
7653 this.words[i] = carry;
7654 this.length++;
7655 }
7656 return this;
7657 };
7658
7659 BN.prototype.isZero = function isZero () {
7660 return this.length === 1 && this.words[0] === 0;
7661 };
7662
7663 BN.prototype.cmpn = function cmpn (num) {
7664 var negative = num < 0;
7665
7666 if (this.negative !== 0 && !negative) return -1;
7667 if (this.negative === 0 && negative) return 1;
7668
7669 this.strip();
7670
7671 var res;
7672 if (this.length > 1) {
7673 res = 1;
7674 } else {
7675 if (negative) {
7676 num = -num;
7677 }
7678
7679 assert(num <= 0x3ffffff, 'Number is too big');
7680
7681 var w = this.words[0] | 0;
7682 res = w === num ? 0 : w < num ? -1 : 1;
7683 }
7684 if (this.negative !== 0) return -res | 0;
7685 return res;
7686 };
7687
7688 // Compare two numbers and return:
7689 // 1 - if `this` > `num`
7690 // 0 - if `this` == `num`
7691 // -1 - if `this` < `num`
7692 BN.prototype.cmp = function cmp (num) {
7693 if (this.negative !== 0 && num.negative === 0) return -1;
7694 if (this.negative === 0 && num.negative !== 0) return 1;
7695
7696 var res = this.ucmp(num);
7697 if (this.negative !== 0) return -res | 0;
7698 return res;
7699 };
7700
7701 // Unsigned comparison
7702 BN.prototype.ucmp = function ucmp (num) {
7703 // At this point both numbers have the same sign
7704 if (this.length > num.length) return 1;
7705 if (this.length < num.length) return -1;
7706
7707 var res = 0;
7708 for (var i = this.length - 1; i >= 0; i--) {
7709 var a = this.words[i] | 0;
7710 var b = num.words[i] | 0;
7711
7712 if (a === b) continue;
7713 if (a < b) {
7714 res = -1;
7715 } else if (a > b) {
7716 res = 1;
7717 }
7718 break;
7719 }
7720 return res;
7721 };
7722
7723 BN.prototype.gtn = function gtn (num) {
7724 return this.cmpn(num) === 1;
7725 };
7726
7727 BN.prototype.gt = function gt (num) {
7728 return this.cmp(num) === 1;
7729 };
7730
7731 BN.prototype.gten = function gten (num) {
7732 return this.cmpn(num) >= 0;
7733 };
7734
7735 BN.prototype.gte = function gte (num) {
7736 return this.cmp(num) >= 0;
7737 };
7738
7739 BN.prototype.ltn = function ltn (num) {
7740 return this.cmpn(num) === -1;
7741 };
7742
7743 BN.prototype.lt = function lt (num) {
7744 return this.cmp(num) === -1;
7745 };
7746
7747 BN.prototype.lten = function lten (num) {
7748 return this.cmpn(num) <= 0;
7749 };
7750
7751 BN.prototype.lte = function lte (num) {
7752 return this.cmp(num) <= 0;
7753 };
7754
7755 BN.prototype.eqn = function eqn (num) {
7756 return this.cmpn(num) === 0;
7757 };
7758
7759 BN.prototype.eq = function eq (num) {
7760 return this.cmp(num) === 0;
7761 };
7762
7763 //
7764 // A reduce context, could be using montgomery or something better, depending
7765 // on the `m` itself.
7766 //
7767 BN.red = function red (num) {
7768 return new Red(num);
7769 };
7770
7771 BN.prototype.toRed = function toRed (ctx) {
7772 assert(!this.red, 'Already a number in reduction context');
7773 assert(this.negative === 0, 'red works only with positives');
7774 return ctx.convertTo(this)._forceRed(ctx);
7775 };
7776
7777 BN.prototype.fromRed = function fromRed () {
7778 assert(this.red, 'fromRed works only with numbers in reduction context');
7779 return this.red.convertFrom(this);
7780 };
7781
7782 BN.prototype._forceRed = function _forceRed (ctx) {
7783 this.red = ctx;
7784 return this;
7785 };
7786
7787 BN.prototype.forceRed = function forceRed (ctx) {
7788 assert(!this.red, 'Already a number in reduction context');
7789 return this._forceRed(ctx);
7790 };
7791
7792 BN.prototype.redAdd = function redAdd (num) {
7793 assert(this.red, 'redAdd works only with red numbers');
7794 return this.red.add(this, num);
7795 };
7796
7797 BN.prototype.redIAdd = function redIAdd (num) {
7798 assert(this.red, 'redIAdd works only with red numbers');
7799 return this.red.iadd(this, num);
7800 };
7801
7802 BN.prototype.redSub = function redSub (num) {
7803 assert(this.red, 'redSub works only with red numbers');
7804 return this.red.sub(this, num);
7805 };
7806
7807 BN.prototype.redISub = function redISub (num) {
7808 assert(this.red, 'redISub works only with red numbers');
7809 return this.red.isub(this, num);
7810 };
7811
7812 BN.prototype.redShl = function redShl (num) {
7813 assert(this.red, 'redShl works only with red numbers');
7814 return this.red.shl(this, num);
7815 };
7816
7817 BN.prototype.redMul = function redMul (num) {
7818 assert(this.red, 'redMul works only with red numbers');
7819 this.red._verify2(this, num);
7820 return this.red.mul(this, num);
7821 };
7822
7823 BN.prototype.redIMul = function redIMul (num) {
7824 assert(this.red, 'redMul works only with red numbers');
7825 this.red._verify2(this, num);
7826 return this.red.imul(this, num);
7827 };
7828
7829 BN.prototype.redSqr = function redSqr () {
7830 assert(this.red, 'redSqr works only with red numbers');
7831 this.red._verify1(this);
7832 return this.red.sqr(this);
7833 };
7834
7835 BN.prototype.redISqr = function redISqr () {
7836 assert(this.red, 'redISqr works only with red numbers');
7837 this.red._verify1(this);
7838 return this.red.isqr(this);
7839 };
7840
7841 // Square root over p
7842 BN.prototype.redSqrt = function redSqrt () {
7843 assert(this.red, 'redSqrt works only with red numbers');
7844 this.red._verify1(this);
7845 return this.red.sqrt(this);
7846 };
7847
7848 BN.prototype.redInvm = function redInvm () {
7849 assert(this.red, 'redInvm works only with red numbers');
7850 this.red._verify1(this);
7851 return this.red.invm(this);
7852 };
7853
7854 // Return negative clone of `this` % `red modulo`
7855 BN.prototype.redNeg = function redNeg () {
7856 assert(this.red, 'redNeg works only with red numbers');
7857 this.red._verify1(this);
7858 return this.red.neg(this);
7859 };
7860
7861 BN.prototype.redPow = function redPow (num) {
7862 assert(this.red && !num.red, 'redPow(normalNum)');
7863 this.red._verify1(this);
7864 return this.red.pow(this, num);
7865 };
7866
7867 // Prime numbers with efficient reduction
7868 var primes = {
7869 k256: null,
7870 p224: null,
7871 p192: null,
7872 p25519: null
7873 };
7874
7875 // Pseudo-Mersenne prime
7876 function MPrime (name, p) {
7877 // P = 2 ^ N - K
7878 this.name = name;
7879 this.p = new BN(p, 16);
7880 this.n = this.p.bitLength();
7881 this.k = new BN(1).iushln(this.n).isub(this.p);
7882
7883 this.tmp = this._tmp();
7884 }
7885
7886 MPrime.prototype._tmp = function _tmp () {
7887 var tmp = new BN(null);
7888 tmp.words = new Array(Math.ceil(this.n / 13));
7889 return tmp;
7890 };
7891
7892 MPrime.prototype.ireduce = function ireduce (num) {
7893 // Assumes that `num` is less than `P^2`
7894 // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)
7895 var r = num;
7896 var rlen;
7897
7898 do {
7899 this.split(r, this.tmp);
7900 r = this.imulK(r);
7901 r = r.iadd(this.tmp);
7902 rlen = r.bitLength();
7903 } while (rlen > this.n);
7904
7905 var cmp = rlen < this.n ? -1 : r.ucmp(this.p);
7906 if (cmp === 0) {
7907 r.words[0] = 0;
7908 r.length = 1;
7909 } else if (cmp > 0) {
7910 r.isub(this.p);
7911 } else {
7912 r.strip();
7913 }
7914
7915 return r;
7916 };
7917
7918 MPrime.prototype.split = function split (input, out) {
7919 input.iushrn(this.n, 0, out);
7920 };
7921
7922 MPrime.prototype.imulK = function imulK (num) {
7923 return num.imul(this.k);
7924 };
7925
7926 function K256 () {
7927 MPrime.call(
7928 this,
7929 'k256',
7930 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');
7931 }
7932 inherits(K256, MPrime);
7933
7934 K256.prototype.split = function split (input, output) {
7935 // 256 = 9 * 26 + 22
7936 var mask = 0x3fffff;
7937
7938 var outLen = Math.min(input.length, 9);
7939 for (var i = 0; i < outLen; i++) {
7940 output.words[i] = input.words[i];
7941 }
7942 output.length = outLen;
7943
7944 if (input.length <= 9) {
7945 input.words[0] = 0;
7946 input.length = 1;
7947 return;
7948 }
7949
7950 // Shift by 9 limbs
7951 var prev = input.words[9];
7952 output.words[output.length++] = prev & mask;
7953
7954 for (i = 10; i < input.length; i++) {
7955 var next = input.words[i] | 0;
7956 input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22);
7957 prev = next;
7958 }
7959 prev >>>= 22;
7960 input.words[i - 10] = prev;
7961 if (prev === 0 && input.length > 10) {
7962 input.length -= 10;
7963 } else {
7964 input.length -= 9;
7965 }
7966 };
7967
7968 K256.prototype.imulK = function imulK (num) {
7969 // K = 0x1000003d1 = [ 0x40, 0x3d1 ]
7970 num.words[num.length] = 0;
7971 num.words[num.length + 1] = 0;
7972 num.length += 2;
7973
7974 // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390
7975 var lo = 0;
7976 for (var i = 0; i < num.length; i++) {
7977 var w = num.words[i] | 0;
7978 lo += w * 0x3d1;
7979 num.words[i] = lo & 0x3ffffff;
7980 lo = w * 0x40 + ((lo / 0x4000000) | 0);
7981 }
7982
7983 // Fast length reduction
7984 if (num.words[num.length - 1] === 0) {
7985 num.length--;
7986 if (num.words[num.length - 1] === 0) {
7987 num.length--;
7988 }
7989 }
7990 return num;
7991 };
7992
7993 function P224 () {
7994 MPrime.call(
7995 this,
7996 'p224',
7997 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');
7998 }
7999 inherits(P224, MPrime);
8000
8001 function P192 () {
8002 MPrime.call(
8003 this,
8004 'p192',
8005 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');
8006 }
8007 inherits(P192, MPrime);
8008
8009 function P25519 () {
8010 // 2 ^ 255 - 19
8011 MPrime.call(
8012 this,
8013 '25519',
8014 '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');
8015 }
8016 inherits(P25519, MPrime);
8017
8018 P25519.prototype.imulK = function imulK (num) {
8019 // K = 0x13
8020 var carry = 0;
8021 for (var i = 0; i < num.length; i++) {
8022 var hi = (num.words[i] | 0) * 0x13 + carry;
8023 var lo = hi & 0x3ffffff;
8024 hi >>>= 26;
8025
8026 num.words[i] = lo;
8027 carry = hi;
8028 }
8029 if (carry !== 0) {
8030 num.words[num.length++] = carry;
8031 }
8032 return num;
8033 };
8034
8035 // Exported mostly for testing purposes, use plain name instead
8036 BN._prime = function prime (name) {
8037 // Cached version of prime
8038 if (primes[name]) return primes[name];
8039
8040 var prime;
8041 if (name === 'k256') {
8042 prime = new K256();
8043 } else if (name === 'p224') {
8044 prime = new P224();
8045 } else if (name === 'p192') {
8046 prime = new P192();
8047 } else if (name === 'p25519') {
8048 prime = new P25519();
8049 } else {
8050 throw new Error('Unknown prime ' + name);
8051 }
8052 primes[name] = prime;
8053
8054 return prime;
8055 };
8056
8057 //
8058 // Base reduction engine
8059 //
8060 function Red (m) {
8061 if (typeof m === 'string') {
8062 var prime = BN._prime(m);
8063 this.m = prime.p;
8064 this.prime = prime;
8065 } else {
8066 assert(m.gtn(1), 'modulus must be greater than 1');
8067 this.m = m;
8068 this.prime = null;
8069 }
8070 }
8071
8072 Red.prototype._verify1 = function _verify1 (a) {
8073 assert(a.negative === 0, 'red works only with positives');
8074 assert(a.red, 'red works only with red numbers');
8075 };
8076
8077 Red.prototype._verify2 = function _verify2 (a, b) {
8078 assert((a.negative | b.negative) === 0, 'red works only with positives');
8079 assert(a.red && a.red === b.red,
8080 'red works only with red numbers');
8081 };
8082
8083 Red.prototype.imod = function imod (a) {
8084 if (this.prime) return this.prime.ireduce(a)._forceRed(this);
8085 return a.umod(this.m)._forceRed(this);
8086 };
8087
8088 Red.prototype.neg = function neg (a) {
8089 if (a.isZero()) {
8090 return a.clone();
8091 }
8092
8093 return this.m.sub(a)._forceRed(this);
8094 };
8095
8096 Red.prototype.add = function add (a, b) {
8097 this._verify2(a, b);
8098
8099 var res = a.add(b);
8100 if (res.cmp(this.m) >= 0) {
8101 res.isub(this.m);
8102 }
8103 return res._forceRed(this);
8104 };
8105
8106 Red.prototype.iadd = function iadd (a, b) {
8107 this._verify2(a, b);
8108
8109 var res = a.iadd(b);
8110 if (res.cmp(this.m) >= 0) {
8111 res.isub(this.m);
8112 }
8113 return res;
8114 };
8115
8116 Red.prototype.sub = function sub (a, b) {
8117 this._verify2(a, b);
8118
8119 var res = a.sub(b);
8120 if (res.cmpn(0) < 0) {
8121 res.iadd(this.m);
8122 }
8123 return res._forceRed(this);
8124 };
8125
8126 Red.prototype.isub = function isub (a, b) {
8127 this._verify2(a, b);
8128
8129 var res = a.isub(b);
8130 if (res.cmpn(0) < 0) {
8131 res.iadd(this.m);
8132 }
8133 return res;
8134 };
8135
8136 Red.prototype.shl = function shl (a, num) {
8137 this._verify1(a);
8138 return this.imod(a.ushln(num));
8139 };
8140
8141 Red.prototype.imul = function imul (a, b) {
8142 this._verify2(a, b);
8143 return this.imod(a.imul(b));
8144 };
8145
8146 Red.prototype.mul = function mul (a, b) {
8147 this._verify2(a, b);
8148 return this.imod(a.mul(b));
8149 };
8150
8151 Red.prototype.isqr = function isqr (a) {
8152 return this.imul(a, a.clone());
8153 };
8154
8155 Red.prototype.sqr = function sqr (a) {
8156 return this.mul(a, a);
8157 };
8158
8159 Red.prototype.sqrt = function sqrt (a) {
8160 if (a.isZero()) return a.clone();
8161
8162 var mod3 = this.m.andln(3);
8163 assert(mod3 % 2 === 1);
8164
8165 // Fast case
8166 if (mod3 === 3) {
8167 var pow = this.m.add(new BN(1)).iushrn(2);
8168 return this.pow(a, pow);
8169 }
8170
8171 // Tonelli-Shanks algorithm (Totally unoptimized and slow)
8172 //
8173 // Find Q and S, that Q * 2 ^ S = (P - 1)
8174 var q = this.m.subn(1);
8175 var s = 0;
8176 while (!q.isZero() && q.andln(1) === 0) {
8177 s++;
8178 q.iushrn(1);
8179 }
8180 assert(!q.isZero());
8181
8182 var one = new BN(1).toRed(this);
8183 var nOne = one.redNeg();
8184
8185 // Find quadratic non-residue
8186 // NOTE: Max is such because of generalized Riemann hypothesis.
8187 var lpow = this.m.subn(1).iushrn(1);
8188 var z = this.m.bitLength();
8189 z = new BN(2 * z * z).toRed(this);
8190
8191 while (this.pow(z, lpow).cmp(nOne) !== 0) {
8192 z.redIAdd(nOne);
8193 }
8194
8195 var c = this.pow(z, q);
8196 var r = this.pow(a, q.addn(1).iushrn(1));
8197 var t = this.pow(a, q);
8198 var m = s;
8199 while (t.cmp(one) !== 0) {
8200 var tmp = t;
8201 for (var i = 0; tmp.cmp(one) !== 0; i++) {
8202 tmp = tmp.redSqr();
8203 }
8204 assert(i < m);
8205 var b = this.pow(c, new BN(1).iushln(m - i - 1));
8206
8207 r = r.redMul(b);
8208 c = b.redSqr();
8209 t = t.redMul(c);
8210 m = i;
8211 }
8212
8213 return r;
8214 };
8215
8216 Red.prototype.invm = function invm (a) {
8217 var inv = a._invmp(this.m);
8218 if (inv.negative !== 0) {
8219 inv.negative = 0;
8220 return this.imod(inv).redNeg();
8221 } else {
8222 return this.imod(inv);
8223 }
8224 };
8225
8226 Red.prototype.pow = function pow (a, num) {
8227 if (num.isZero()) return new BN(1).toRed(this);
8228 if (num.cmpn(1) === 0) return a.clone();
8229
8230 var windowSize = 4;
8231 var wnd = new Array(1 << windowSize);
8232 wnd[0] = new BN(1).toRed(this);
8233 wnd[1] = a;
8234 for (var i = 2; i < wnd.length; i++) {
8235 wnd[i] = this.mul(wnd[i - 1], a);
8236 }
8237
8238 var res = wnd[0];
8239 var current = 0;
8240 var currentLen = 0;
8241 var start = num.bitLength() % 26;
8242 if (start === 0) {
8243 start = 26;
8244 }
8245
8246 for (i = num.length - 1; i >= 0; i--) {
8247 var word = num.words[i];
8248 for (var j = start - 1; j >= 0; j--) {
8249 var bit = (word >> j) & 1;
8250 if (res !== wnd[0]) {
8251 res = this.sqr(res);
8252 }
8253
8254 if (bit === 0 && current === 0) {
8255 currentLen = 0;
8256 continue;
8257 }
8258
8259 current <<= 1;
8260 current |= bit;
8261 currentLen++;
8262 if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;
8263
8264 res = this.mul(res, wnd[current]);
8265 currentLen = 0;
8266 current = 0;
8267 }
8268 start = 26;
8269 }
8270
8271 return res;
8272 };
8273
8274 Red.prototype.convertTo = function convertTo (num) {
8275 var r = num.umod(this.m);
8276
8277 return r === num ? r.clone() : r;
8278 };
8279
8280 Red.prototype.convertFrom = function convertFrom (num) {
8281 var res = num.clone();
8282 res.red = null;
8283 return res;
8284 };
8285
8286 //
8287 // Montgomery method engine
8288 //
8289
8290 BN.mont = function mont (num) {
8291 return new Mont(num);
8292 };
8293
8294 function Mont (m) {
8295 Red.call(this, m);
8296
8297 this.shift = this.m.bitLength();
8298 if (this.shift % 26 !== 0) {
8299 this.shift += 26 - (this.shift % 26);
8300 }
8301
8302 this.r = new BN(1).iushln(this.shift);
8303 this.r2 = this.imod(this.r.sqr());
8304 this.rinv = this.r._invmp(this.m);
8305
8306 this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
8307 this.minv = this.minv.umod(this.r);
8308 this.minv = this.r.sub(this.minv);
8309 }
8310 inherits(Mont, Red);
8311
8312 Mont.prototype.convertTo = function convertTo (num) {
8313 return this.imod(num.ushln(this.shift));
8314 };
8315
8316 Mont.prototype.convertFrom = function convertFrom (num) {
8317 var r = this.imod(num.mul(this.rinv));
8318 r.red = null;
8319 return r;
8320 };
8321
8322 Mont.prototype.imul = function imul (a, b) {
8323 if (a.isZero() || b.isZero()) {
8324 a.words[0] = 0;
8325 a.length = 1;
8326 return a;
8327 }
8328
8329 var t = a.imul(b);
8330 var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
8331 var u = t.isub(c).iushrn(this.shift);
8332 var res = u;
8333
8334 if (u.cmp(this.m) >= 0) {
8335 res = u.isub(this.m);
8336 } else if (u.cmpn(0) < 0) {
8337 res = u.iadd(this.m);
8338 }
8339
8340 return res._forceRed(this);
8341 };
8342
8343 Mont.prototype.mul = function mul (a, b) {
8344 if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);
8345
8346 var t = a.mul(b);
8347 var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
8348 var u = t.isub(c).iushrn(this.shift);
8349 var res = u;
8350 if (u.cmp(this.m) >= 0) {
8351 res = u.isub(this.m);
8352 } else if (u.cmpn(0) < 0) {
8353 res = u.iadd(this.m);
8354 }
8355
8356 return res._forceRed(this);
8357 };
8358
8359 Mont.prototype.invm = function invm (a) {
8360 // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R
8361 var res = this.imod(a._invmp(this.m).mul(this.r2));
8362 return res._forceRed(this);
8363 };
8364})(typeof module === 'undefined' || module, this);
8365
8366},{"buffer":20}],19:[function(require,module,exports){
8367var r;
8368
8369module.exports = function rand(len) {
8370 if (!r)
8371 r = new Rand(null);
8372
8373 return r.generate(len);
8374};
8375
8376function Rand(rand) {
8377 this.rand = rand;
8378}
8379module.exports.Rand = Rand;
8380
8381Rand.prototype.generate = function generate(len) {
8382 return this._rand(len);
8383};
8384
8385// Emulate crypto API using randy
8386Rand.prototype._rand = function _rand(n) {
8387 if (this.rand.getBytes)
8388 return this.rand.getBytes(n);
8389
8390 var res = new Uint8Array(n);
8391 for (var i = 0; i < res.length; i++)
8392 res[i] = this.rand.getByte();
8393 return res;
8394};
8395
8396if (typeof self === 'object') {
8397 if (self.crypto && self.crypto.getRandomValues) {
8398 // Modern browsers
8399 Rand.prototype._rand = function _rand(n) {
8400 var arr = new Uint8Array(n);
8401 self.crypto.getRandomValues(arr);
8402 return arr;
8403 };
8404 } else if (self.msCrypto && self.msCrypto.getRandomValues) {
8405 // IE
8406 Rand.prototype._rand = function _rand(n) {
8407 var arr = new Uint8Array(n);
8408 self.msCrypto.getRandomValues(arr);
8409 return arr;
8410 };
8411
8412 // Safari's WebWorkers do not have `crypto`
8413 } else if (typeof window === 'object') {
8414 // Old junk
8415 Rand.prototype._rand = function() {
8416 throw new Error('Not implemented yet');
8417 };
8418 }
8419} else {
8420 // Node.js or Web worker with no crypto support
8421 try {
8422 var crypto = require('crypto');
8423 if (typeof crypto.randomBytes !== 'function')
8424 throw new Error('Not supported');
8425
8426 Rand.prototype._rand = function _rand(n) {
8427 return crypto.randomBytes(n);
8428 };
8429 } catch (e) {
8430 }
8431}
8432
8433},{"crypto":20}],20:[function(require,module,exports){
8434
8435},{}],21:[function(require,module,exports){
8436// based on the aes implimentation in triple sec
8437// https://github.com/keybase/triplesec
8438// which is in turn based on the one from crypto-js
8439// https://code.google.com/p/crypto-js/
8440
8441var Buffer = require('safe-buffer').Buffer
8442
8443function asUInt32Array (buf) {
8444 if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf)
8445
8446 var len = (buf.length / 4) | 0
8447 var out = new Array(len)
8448
8449 for (var i = 0; i < len; i++) {
8450 out[i] = buf.readUInt32BE(i * 4)
8451 }
8452
8453 return out
8454}
8455
8456function scrubVec (v) {
8457 for (var i = 0; i < v.length; v++) {
8458 v[i] = 0
8459 }
8460}
8461
8462function cryptBlock (M, keySchedule, SUB_MIX, SBOX, nRounds) {
8463 var SUB_MIX0 = SUB_MIX[0]
8464 var SUB_MIX1 = SUB_MIX[1]
8465 var SUB_MIX2 = SUB_MIX[2]
8466 var SUB_MIX3 = SUB_MIX[3]
8467
8468 var s0 = M[0] ^ keySchedule[0]
8469 var s1 = M[1] ^ keySchedule[1]
8470 var s2 = M[2] ^ keySchedule[2]
8471 var s3 = M[3] ^ keySchedule[3]
8472 var t0, t1, t2, t3
8473 var ksRow = 4
8474
8475 for (var round = 1; round < nRounds; round++) {
8476 t0 = SUB_MIX0[s0 >>> 24] ^ SUB_MIX1[(s1 >>> 16) & 0xff] ^ SUB_MIX2[(s2 >>> 8) & 0xff] ^ SUB_MIX3[s3 & 0xff] ^ keySchedule[ksRow++]
8477 t1 = SUB_MIX0[s1 >>> 24] ^ SUB_MIX1[(s2 >>> 16) & 0xff] ^ SUB_MIX2[(s3 >>> 8) & 0xff] ^ SUB_MIX3[s0 & 0xff] ^ keySchedule[ksRow++]
8478 t2 = SUB_MIX0[s2 >>> 24] ^ SUB_MIX1[(s3 >>> 16) & 0xff] ^ SUB_MIX2[(s0 >>> 8) & 0xff] ^ SUB_MIX3[s1 & 0xff] ^ keySchedule[ksRow++]
8479 t3 = SUB_MIX0[s3 >>> 24] ^ SUB_MIX1[(s0 >>> 16) & 0xff] ^ SUB_MIX2[(s1 >>> 8) & 0xff] ^ SUB_MIX3[s2 & 0xff] ^ keySchedule[ksRow++]
8480 s0 = t0
8481 s1 = t1
8482 s2 = t2
8483 s3 = t3
8484 }
8485
8486 t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++]
8487 t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++]
8488 t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++]
8489 t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++]
8490 t0 = t0 >>> 0
8491 t1 = t1 >>> 0
8492 t2 = t2 >>> 0
8493 t3 = t3 >>> 0
8494
8495 return [t0, t1, t2, t3]
8496}
8497
8498// AES constants
8499var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36]
8500var G = (function () {
8501 // Compute double table
8502 var d = new Array(256)
8503 for (var j = 0; j < 256; j++) {
8504 if (j < 128) {
8505 d[j] = j << 1
8506 } else {
8507 d[j] = (j << 1) ^ 0x11b
8508 }
8509 }
8510
8511 var SBOX = []
8512 var INV_SBOX = []
8513 var SUB_MIX = [[], [], [], []]
8514 var INV_SUB_MIX = [[], [], [], []]
8515
8516 // Walk GF(2^8)
8517 var x = 0
8518 var xi = 0
8519 for (var i = 0; i < 256; ++i) {
8520 // Compute sbox
8521 var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4)
8522 sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63
8523 SBOX[x] = sx
8524 INV_SBOX[sx] = x
8525
8526 // Compute multiplication
8527 var x2 = d[x]
8528 var x4 = d[x2]
8529 var x8 = d[x4]
8530
8531 // Compute sub bytes, mix columns tables
8532 var t = (d[sx] * 0x101) ^ (sx * 0x1010100)
8533 SUB_MIX[0][x] = (t << 24) | (t >>> 8)
8534 SUB_MIX[1][x] = (t << 16) | (t >>> 16)
8535 SUB_MIX[2][x] = (t << 8) | (t >>> 24)
8536 SUB_MIX[3][x] = t
8537
8538 // Compute inv sub bytes, inv mix columns tables
8539 t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100)
8540 INV_SUB_MIX[0][sx] = (t << 24) | (t >>> 8)
8541 INV_SUB_MIX[1][sx] = (t << 16) | (t >>> 16)
8542 INV_SUB_MIX[2][sx] = (t << 8) | (t >>> 24)
8543 INV_SUB_MIX[3][sx] = t
8544
8545 if (x === 0) {
8546 x = xi = 1
8547 } else {
8548 x = x2 ^ d[d[d[x8 ^ x2]]]
8549 xi ^= d[d[xi]]
8550 }
8551 }
8552
8553 return {
8554 SBOX: SBOX,
8555 INV_SBOX: INV_SBOX,
8556 SUB_MIX: SUB_MIX,
8557 INV_SUB_MIX: INV_SUB_MIX
8558 }
8559})()
8560
8561function AES (key) {
8562 this._key = asUInt32Array(key)
8563 this._reset()
8564}
8565
8566AES.blockSize = 4 * 4
8567AES.keySize = 256 / 8
8568AES.prototype.blockSize = AES.blockSize
8569AES.prototype.keySize = AES.keySize
8570AES.prototype._reset = function () {
8571 var keyWords = this._key
8572 var keySize = keyWords.length
8573 var nRounds = keySize + 6
8574 var ksRows = (nRounds + 1) * 4
8575
8576 var keySchedule = []
8577 for (var k = 0; k < keySize; k++) {
8578 keySchedule[k] = keyWords[k]
8579 }
8580
8581 for (k = keySize; k < ksRows; k++) {
8582 var t = keySchedule[k - 1]
8583
8584 if (k % keySize === 0) {
8585 t = (t << 8) | (t >>> 24)
8586 t =
8587 (G.SBOX[t >>> 24] << 24) |
8588 (G.SBOX[(t >>> 16) & 0xff] << 16) |
8589 (G.SBOX[(t >>> 8) & 0xff] << 8) |
8590 (G.SBOX[t & 0xff])
8591
8592 t ^= RCON[(k / keySize) | 0] << 24
8593 } else if (keySize > 6 && k % keySize === 4) {
8594 t =
8595 (G.SBOX[t >>> 24] << 24) |
8596 (G.SBOX[(t >>> 16) & 0xff] << 16) |
8597 (G.SBOX[(t >>> 8) & 0xff] << 8) |
8598 (G.SBOX[t & 0xff])
8599 }
8600
8601 keySchedule[k] = keySchedule[k - keySize] ^ t
8602 }
8603
8604 var invKeySchedule = []
8605 for (var ik = 0; ik < ksRows; ik++) {
8606 var ksR = ksRows - ik
8607 var tt = keySchedule[ksR - (ik % 4 ? 0 : 4)]
8608
8609 if (ik < 4 || ksR <= 4) {
8610 invKeySchedule[ik] = tt
8611 } else {
8612 invKeySchedule[ik] =
8613 G.INV_SUB_MIX[0][G.SBOX[tt >>> 24]] ^
8614 G.INV_SUB_MIX[1][G.SBOX[(tt >>> 16) & 0xff]] ^
8615 G.INV_SUB_MIX[2][G.SBOX[(tt >>> 8) & 0xff]] ^
8616 G.INV_SUB_MIX[3][G.SBOX[tt & 0xff]]
8617 }
8618 }
8619
8620 this._nRounds = nRounds
8621 this._keySchedule = keySchedule
8622 this._invKeySchedule = invKeySchedule
8623}
8624
8625AES.prototype.encryptBlockRaw = function (M) {
8626 M = asUInt32Array(M)
8627 return cryptBlock(M, this._keySchedule, G.SUB_MIX, G.SBOX, this._nRounds)
8628}
8629
8630AES.prototype.encryptBlock = function (M) {
8631 var out = this.encryptBlockRaw(M)
8632 var buf = Buffer.allocUnsafe(16)
8633 buf.writeUInt32BE(out[0], 0)
8634 buf.writeUInt32BE(out[1], 4)
8635 buf.writeUInt32BE(out[2], 8)
8636 buf.writeUInt32BE(out[3], 12)
8637 return buf
8638}
8639
8640AES.prototype.decryptBlock = function (M) {
8641 M = asUInt32Array(M)
8642
8643 // swap
8644 var m1 = M[1]
8645 M[1] = M[3]
8646 M[3] = m1
8647
8648 var out = cryptBlock(M, this._invKeySchedule, G.INV_SUB_MIX, G.INV_SBOX, this._nRounds)
8649 var buf = Buffer.allocUnsafe(16)
8650 buf.writeUInt32BE(out[0], 0)
8651 buf.writeUInt32BE(out[3], 4)
8652 buf.writeUInt32BE(out[2], 8)
8653 buf.writeUInt32BE(out[1], 12)
8654 return buf
8655}
8656
8657AES.prototype.scrub = function () {
8658 scrubVec(this._keySchedule)
8659 scrubVec(this._invKeySchedule)
8660 scrubVec(this._key)
8661}
8662
8663module.exports.AES = AES
8664
8665},{"safe-buffer":398}],22:[function(require,module,exports){
8666var aes = require('./aes')
8667var Buffer = require('safe-buffer').Buffer
8668var Transform = require('cipher-base')
8669var inherits = require('inherits')
8670var GHASH = require('./ghash')
8671var xor = require('buffer-xor')
8672var incr32 = require('./incr32')
8673
8674function xorTest (a, b) {
8675 var out = 0
8676 if (a.length !== b.length) out++
8677
8678 var len = Math.min(a.length, b.length)
8679 for (var i = 0; i < len; ++i) {
8680 out += (a[i] ^ b[i])
8681 }
8682
8683 return out
8684}
8685
8686function calcIv (self, iv, ck) {
8687 if (iv.length === 12) {
8688 self._finID = Buffer.concat([iv, Buffer.from([0, 0, 0, 1])])
8689 return Buffer.concat([iv, Buffer.from([0, 0, 0, 2])])
8690 }
8691 var ghash = new GHASH(ck)
8692 var len = iv.length
8693 var toPad = len % 16
8694 ghash.update(iv)
8695 if (toPad) {
8696 toPad = 16 - toPad
8697 ghash.update(Buffer.alloc(toPad, 0))
8698 }
8699 ghash.update(Buffer.alloc(8, 0))
8700 var ivBits = len * 8
8701 var tail = Buffer.alloc(8)
8702 tail.writeUIntBE(ivBits, 0, 8)
8703 ghash.update(tail)
8704 self._finID = ghash.state
8705 var out = Buffer.from(self._finID)
8706 incr32(out)
8707 return out
8708}
8709function StreamCipher (mode, key, iv, decrypt) {
8710 Transform.call(this)
8711
8712 var h = Buffer.alloc(4, 0)
8713
8714 this._cipher = new aes.AES(key)
8715 var ck = this._cipher.encryptBlock(h)
8716 this._ghash = new GHASH(ck)
8717 iv = calcIv(this, iv, ck)
8718
8719 this._prev = Buffer.from(iv)
8720 this._cache = Buffer.allocUnsafe(0)
8721 this._secCache = Buffer.allocUnsafe(0)
8722 this._decrypt = decrypt
8723 this._alen = 0
8724 this._len = 0
8725 this._mode = mode
8726
8727 this._authTag = null
8728 this._called = false
8729}
8730
8731inherits(StreamCipher, Transform)
8732
8733StreamCipher.prototype._update = function (chunk) {
8734 if (!this._called && this._alen) {
8735 var rump = 16 - (this._alen % 16)
8736 if (rump < 16) {
8737 rump = Buffer.alloc(rump, 0)
8738 this._ghash.update(rump)
8739 }
8740 }
8741
8742 this._called = true
8743 var out = this._mode.encrypt(this, chunk)
8744 if (this._decrypt) {
8745 this._ghash.update(chunk)
8746 } else {
8747 this._ghash.update(out)
8748 }
8749 this._len += chunk.length
8750 return out
8751}
8752
8753StreamCipher.prototype._final = function () {
8754 if (this._decrypt && !this._authTag) throw new Error('Unsupported state or unable to authenticate data')
8755
8756 var tag = xor(this._ghash.final(this._alen * 8, this._len * 8), this._cipher.encryptBlock(this._finID))
8757 if (this._decrypt && xorTest(tag, this._authTag)) throw new Error('Unsupported state or unable to authenticate data')
8758
8759 this._authTag = tag
8760 this._cipher.scrub()
8761}
8762
8763StreamCipher.prototype.getAuthTag = function getAuthTag () {
8764 if (this._decrypt || !Buffer.isBuffer(this._authTag)) throw new Error('Attempting to get auth tag in unsupported state')
8765
8766 return this._authTag
8767}
8768
8769StreamCipher.prototype.setAuthTag = function setAuthTag (tag) {
8770 if (!this._decrypt) throw new Error('Attempting to set auth tag in unsupported state')
8771
8772 this._authTag = tag
8773}
8774
8775StreamCipher.prototype.setAAD = function setAAD (buf) {
8776 if (this._called) throw new Error('Attempting to set AAD in unsupported state')
8777
8778 this._ghash.update(buf)
8779 this._alen += buf.length
8780}
8781
8782module.exports = StreamCipher
8783
8784},{"./aes":21,"./ghash":26,"./incr32":27,"buffer-xor":49,"cipher-base":51,"inherits":119,"safe-buffer":398}],23:[function(require,module,exports){
8785var ciphers = require('./encrypter')
8786var deciphers = require('./decrypter')
8787var modes = require('./modes/list.json')
8788
8789function getCiphers () {
8790 return Object.keys(modes)
8791}
8792
8793exports.createCipher = exports.Cipher = ciphers.createCipher
8794exports.createCipheriv = exports.Cipheriv = ciphers.createCipheriv
8795exports.createDecipher = exports.Decipher = deciphers.createDecipher
8796exports.createDecipheriv = exports.Decipheriv = deciphers.createDecipheriv
8797exports.listCiphers = exports.getCiphers = getCiphers
8798
8799},{"./decrypter":24,"./encrypter":25,"./modes/list.json":35}],24:[function(require,module,exports){
8800var AuthCipher = require('./authCipher')
8801var Buffer = require('safe-buffer').Buffer
8802var MODES = require('./modes')
8803var StreamCipher = require('./streamCipher')
8804var Transform = require('cipher-base')
8805var aes = require('./aes')
8806var ebtk = require('evp_bytestokey')
8807var inherits = require('inherits')
8808
8809function Decipher (mode, key, iv) {
8810 Transform.call(this)
8811
8812 this._cache = new Splitter()
8813 this._last = void 0
8814 this._cipher = new aes.AES(key)
8815 this._prev = Buffer.from(iv)
8816 this._mode = mode
8817 this._autopadding = true
8818}
8819
8820inherits(Decipher, Transform)
8821
8822Decipher.prototype._update = function (data) {
8823 this._cache.add(data)
8824 var chunk
8825 var thing
8826 var out = []
8827 while ((chunk = this._cache.get(this._autopadding))) {
8828 thing = this._mode.decrypt(this, chunk)
8829 out.push(thing)
8830 }
8831 return Buffer.concat(out)
8832}
8833
8834Decipher.prototype._final = function () {
8835 var chunk = this._cache.flush()
8836 if (this._autopadding) {
8837 return unpad(this._mode.decrypt(this, chunk))
8838 } else if (chunk) {
8839 throw new Error('data not multiple of block length')
8840 }
8841}
8842
8843Decipher.prototype.setAutoPadding = function (setTo) {
8844 this._autopadding = !!setTo
8845 return this
8846}
8847
8848function Splitter () {
8849 this.cache = Buffer.allocUnsafe(0)
8850}
8851
8852Splitter.prototype.add = function (data) {
8853 this.cache = Buffer.concat([this.cache, data])
8854}
8855
8856Splitter.prototype.get = function (autoPadding) {
8857 var out
8858 if (autoPadding) {
8859 if (this.cache.length > 16) {
8860 out = this.cache.slice(0, 16)
8861 this.cache = this.cache.slice(16)
8862 return out
8863 }
8864 } else {
8865 if (this.cache.length >= 16) {
8866 out = this.cache.slice(0, 16)
8867 this.cache = this.cache.slice(16)
8868 return out
8869 }
8870 }
8871
8872 return null
8873}
8874
8875Splitter.prototype.flush = function () {
8876 if (this.cache.length) return this.cache
8877}
8878
8879function unpad (last) {
8880 var padded = last[15]
8881 if (padded < 1 || padded > 16) {
8882 throw new Error('unable to decrypt data')
8883 }
8884 var i = -1
8885 while (++i < padded) {
8886 if (last[(i + (16 - padded))] !== padded) {
8887 throw new Error('unable to decrypt data')
8888 }
8889 }
8890 if (padded === 16) return
8891
8892 return last.slice(0, 16 - padded)
8893}
8894
8895function createDecipheriv (suite, password, iv) {
8896 var config = MODES[suite.toLowerCase()]
8897 if (!config) throw new TypeError('invalid suite type')
8898
8899 if (typeof iv === 'string') iv = Buffer.from(iv)
8900 if (config.mode !== 'GCM' && iv.length !== config.iv) throw new TypeError('invalid iv length ' + iv.length)
8901
8902 if (typeof password === 'string') password = Buffer.from(password)
8903 if (password.length !== config.key / 8) throw new TypeError('invalid key length ' + password.length)
8904
8905 if (config.type === 'stream') {
8906 return new StreamCipher(config.module, password, iv, true)
8907 } else if (config.type === 'auth') {
8908 return new AuthCipher(config.module, password, iv, true)
8909 }
8910
8911 return new Decipher(config.module, password, iv)
8912}
8913
8914function createDecipher (suite, password) {
8915 var config = MODES[suite.toLowerCase()]
8916 if (!config) throw new TypeError('invalid suite type')
8917
8918 var keys = ebtk(password, false, config.key, config.iv)
8919 return createDecipheriv(suite, keys.key, keys.iv)
8920}
8921
8922exports.createDecipher = createDecipher
8923exports.createDecipheriv = createDecipheriv
8924
8925},{"./aes":21,"./authCipher":22,"./modes":34,"./streamCipher":37,"cipher-base":51,"evp_bytestokey":103,"inherits":119,"safe-buffer":398}],25:[function(require,module,exports){
8926var MODES = require('./modes')
8927var AuthCipher = require('./authCipher')
8928var Buffer = require('safe-buffer').Buffer
8929var StreamCipher = require('./streamCipher')
8930var Transform = require('cipher-base')
8931var aes = require('./aes')
8932var ebtk = require('evp_bytestokey')
8933var inherits = require('inherits')
8934
8935function Cipher (mode, key, iv) {
8936 Transform.call(this)
8937
8938 this._cache = new Splitter()
8939 this._cipher = new aes.AES(key)
8940 this._prev = Buffer.from(iv)
8941 this._mode = mode
8942 this._autopadding = true
8943}
8944
8945inherits(Cipher, Transform)
8946
8947Cipher.prototype._update = function (data) {
8948 this._cache.add(data)
8949 var chunk
8950 var thing
8951 var out = []
8952
8953 while ((chunk = this._cache.get())) {
8954 thing = this._mode.encrypt(this, chunk)
8955 out.push(thing)
8956 }
8957
8958 return Buffer.concat(out)
8959}
8960
8961var PADDING = Buffer.alloc(16, 0x10)
8962
8963Cipher.prototype._final = function () {
8964 var chunk = this._cache.flush()
8965 if (this._autopadding) {
8966 chunk = this._mode.encrypt(this, chunk)
8967 this._cipher.scrub()
8968 return chunk
8969 }
8970
8971 if (!chunk.equals(PADDING)) {
8972 this._cipher.scrub()
8973 throw new Error('data not multiple of block length')
8974 }
8975}
8976
8977Cipher.prototype.setAutoPadding = function (setTo) {
8978 this._autopadding = !!setTo
8979 return this
8980}
8981
8982function Splitter () {
8983 this.cache = Buffer.allocUnsafe(0)
8984}
8985
8986Splitter.prototype.add = function (data) {
8987 this.cache = Buffer.concat([this.cache, data])
8988}
8989
8990Splitter.prototype.get = function () {
8991 if (this.cache.length > 15) {
8992 var out = this.cache.slice(0, 16)
8993 this.cache = this.cache.slice(16)
8994 return out
8995 }
8996 return null
8997}
8998
8999Splitter.prototype.flush = function () {
9000 var len = 16 - this.cache.length
9001 var padBuff = Buffer.allocUnsafe(len)
9002
9003 var i = -1
9004 while (++i < len) {
9005 padBuff.writeUInt8(len, i)
9006 }
9007
9008 return Buffer.concat([this.cache, padBuff])
9009}
9010
9011function createCipheriv (suite, password, iv) {
9012 var config = MODES[suite.toLowerCase()]
9013 if (!config) throw new TypeError('invalid suite type')
9014
9015 if (typeof password === 'string') password = Buffer.from(password)
9016 if (password.length !== config.key / 8) throw new TypeError('invalid key length ' + password.length)
9017
9018 if (typeof iv === 'string') iv = Buffer.from(iv)
9019 if (config.mode !== 'GCM' && iv.length !== config.iv) throw new TypeError('invalid iv length ' + iv.length)
9020
9021 if (config.type === 'stream') {
9022 return new StreamCipher(config.module, password, iv)
9023 } else if (config.type === 'auth') {
9024 return new AuthCipher(config.module, password, iv)
9025 }
9026
9027 return new Cipher(config.module, password, iv)
9028}
9029
9030function createCipher (suite, password) {
9031 var config = MODES[suite.toLowerCase()]
9032 if (!config) throw new TypeError('invalid suite type')
9033
9034 var keys = ebtk(password, false, config.key, config.iv)
9035 return createCipheriv(suite, keys.key, keys.iv)
9036}
9037
9038exports.createCipheriv = createCipheriv
9039exports.createCipher = createCipher
9040
9041},{"./aes":21,"./authCipher":22,"./modes":34,"./streamCipher":37,"cipher-base":51,"evp_bytestokey":103,"inherits":119,"safe-buffer":398}],26:[function(require,module,exports){
9042var Buffer = require('safe-buffer').Buffer
9043var ZEROES = Buffer.alloc(16, 0)
9044
9045function toArray (buf) {
9046 return [
9047 buf.readUInt32BE(0),
9048 buf.readUInt32BE(4),
9049 buf.readUInt32BE(8),
9050 buf.readUInt32BE(12)
9051 ]
9052}
9053
9054function fromArray (out) {
9055 var buf = Buffer.allocUnsafe(16)
9056 buf.writeUInt32BE(out[0] >>> 0, 0)
9057 buf.writeUInt32BE(out[1] >>> 0, 4)
9058 buf.writeUInt32BE(out[2] >>> 0, 8)
9059 buf.writeUInt32BE(out[3] >>> 0, 12)
9060 return buf
9061}
9062
9063function GHASH (key) {
9064 this.h = key
9065 this.state = Buffer.alloc(16, 0)
9066 this.cache = Buffer.allocUnsafe(0)
9067}
9068
9069// from http://bitwiseshiftleft.github.io/sjcl/doc/symbols/src/core_gcm.js.html
9070// by Juho Vähä-Herttua
9071GHASH.prototype.ghash = function (block) {
9072 var i = -1
9073 while (++i < block.length) {
9074 this.state[i] ^= block[i]
9075 }
9076 this._multiply()
9077}
9078
9079GHASH.prototype._multiply = function () {
9080 var Vi = toArray(this.h)
9081 var Zi = [0, 0, 0, 0]
9082 var j, xi, lsbVi
9083 var i = -1
9084 while (++i < 128) {
9085 xi = (this.state[~~(i / 8)] & (1 << (7 - (i % 8)))) !== 0
9086 if (xi) {
9087 // Z_i+1 = Z_i ^ V_i
9088 Zi[0] ^= Vi[0]
9089 Zi[1] ^= Vi[1]
9090 Zi[2] ^= Vi[2]
9091 Zi[3] ^= Vi[3]
9092 }
9093
9094 // Store the value of LSB(V_i)
9095 lsbVi = (Vi[3] & 1) !== 0
9096
9097 // V_i+1 = V_i >> 1
9098 for (j = 3; j > 0; j--) {
9099 Vi[j] = (Vi[j] >>> 1) | ((Vi[j - 1] & 1) << 31)
9100 }
9101 Vi[0] = Vi[0] >>> 1
9102
9103 // If LSB(V_i) is 1, V_i+1 = (V_i >> 1) ^ R
9104 if (lsbVi) {
9105 Vi[0] = Vi[0] ^ (0xe1 << 24)
9106 }
9107 }
9108 this.state = fromArray(Zi)
9109}
9110
9111GHASH.prototype.update = function (buf) {
9112 this.cache = Buffer.concat([this.cache, buf])
9113 var chunk
9114 while (this.cache.length >= 16) {
9115 chunk = this.cache.slice(0, 16)
9116 this.cache = this.cache.slice(16)
9117 this.ghash(chunk)
9118 }
9119}
9120
9121GHASH.prototype.final = function (abl, bl) {
9122 if (this.cache.length) {
9123 this.ghash(Buffer.concat([this.cache, ZEROES], 16))
9124 }
9125
9126 this.ghash(fromArray([0, abl, 0, bl]))
9127 return this.state
9128}
9129
9130module.exports = GHASH
9131
9132},{"safe-buffer":398}],27:[function(require,module,exports){
9133function incr32 (iv) {
9134 var len = iv.length
9135 var item
9136 while (len--) {
9137 item = iv.readUInt8(len)
9138 if (item === 255) {
9139 iv.writeUInt8(0, len)
9140 } else {
9141 item++
9142 iv.writeUInt8(item, len)
9143 break
9144 }
9145 }
9146}
9147module.exports = incr32
9148
9149},{}],28:[function(require,module,exports){
9150var xor = require('buffer-xor')
9151
9152exports.encrypt = function (self, block) {
9153 var data = xor(block, self._prev)
9154
9155 self._prev = self._cipher.encryptBlock(data)
9156 return self._prev
9157}
9158
9159exports.decrypt = function (self, block) {
9160 var pad = self._prev
9161
9162 self._prev = block
9163 var out = self._cipher.decryptBlock(block)
9164
9165 return xor(out, pad)
9166}
9167
9168},{"buffer-xor":49}],29:[function(require,module,exports){
9169var Buffer = require('safe-buffer').Buffer
9170var xor = require('buffer-xor')
9171
9172function encryptStart (self, data, decrypt) {
9173 var len = data.length
9174 var out = xor(data, self._cache)
9175 self._cache = self._cache.slice(len)
9176 self._prev = Buffer.concat([self._prev, decrypt ? data : out])
9177 return out
9178}
9179
9180exports.encrypt = function (self, data, decrypt) {
9181 var out = Buffer.allocUnsafe(0)
9182 var len
9183
9184 while (data.length) {
9185 if (self._cache.length === 0) {
9186 self._cache = self._cipher.encryptBlock(self._prev)
9187 self._prev = Buffer.allocUnsafe(0)
9188 }
9189
9190 if (self._cache.length <= data.length) {
9191 len = self._cache.length
9192 out = Buffer.concat([out, encryptStart(self, data.slice(0, len), decrypt)])
9193 data = data.slice(len)
9194 } else {
9195 out = Buffer.concat([out, encryptStart(self, data, decrypt)])
9196 break
9197 }
9198 }
9199
9200 return out
9201}
9202
9203},{"buffer-xor":49,"safe-buffer":398}],30:[function(require,module,exports){
9204var Buffer = require('safe-buffer').Buffer
9205
9206function encryptByte (self, byteParam, decrypt) {
9207 var pad
9208 var i = -1
9209 var len = 8
9210 var out = 0
9211 var bit, value
9212 while (++i < len) {
9213 pad = self._cipher.encryptBlock(self._prev)
9214 bit = (byteParam & (1 << (7 - i))) ? 0x80 : 0
9215 value = pad[0] ^ bit
9216 out += ((value & 0x80) >> (i % 8))
9217 self._prev = shiftIn(self._prev, decrypt ? bit : value)
9218 }
9219 return out
9220}
9221
9222function shiftIn (buffer, value) {
9223 var len = buffer.length
9224 var i = -1
9225 var out = Buffer.allocUnsafe(buffer.length)
9226 buffer = Buffer.concat([buffer, Buffer.from([value])])
9227
9228 while (++i < len) {
9229 out[i] = buffer[i] << 1 | buffer[i + 1] >> (7)
9230 }
9231
9232 return out
9233}
9234
9235exports.encrypt = function (self, chunk, decrypt) {
9236 var len = chunk.length
9237 var out = Buffer.allocUnsafe(len)
9238 var i = -1
9239
9240 while (++i < len) {
9241 out[i] = encryptByte(self, chunk[i], decrypt)
9242 }
9243
9244 return out
9245}
9246
9247},{"safe-buffer":398}],31:[function(require,module,exports){
9248var Buffer = require('safe-buffer').Buffer
9249
9250function encryptByte (self, byteParam, decrypt) {
9251 var pad = self._cipher.encryptBlock(self._prev)
9252 var out = pad[0] ^ byteParam
9253
9254 self._prev = Buffer.concat([
9255 self._prev.slice(1),
9256 Buffer.from([decrypt ? byteParam : out])
9257 ])
9258
9259 return out
9260}
9261
9262exports.encrypt = function (self, chunk, decrypt) {
9263 var len = chunk.length
9264 var out = Buffer.allocUnsafe(len)
9265 var i = -1
9266
9267 while (++i < len) {
9268 out[i] = encryptByte(self, chunk[i], decrypt)
9269 }
9270
9271 return out
9272}
9273
9274},{"safe-buffer":398}],32:[function(require,module,exports){
9275var xor = require('buffer-xor')
9276var Buffer = require('safe-buffer').Buffer
9277var incr32 = require('../incr32')
9278
9279function getBlock (self) {
9280 var out = self._cipher.encryptBlockRaw(self._prev)
9281 incr32(self._prev)
9282 return out
9283}
9284
9285var blockSize = 16
9286exports.encrypt = function (self, chunk) {
9287 var chunkNum = Math.ceil(chunk.length / blockSize)
9288 var start = self._cache.length
9289 self._cache = Buffer.concat([
9290 self._cache,
9291 Buffer.allocUnsafe(chunkNum * blockSize)
9292 ])
9293 for (var i = 0; i < chunkNum; i++) {
9294 var out = getBlock(self)
9295 var offset = start + i * blockSize
9296 self._cache.writeUInt32BE(out[0], offset + 0)
9297 self._cache.writeUInt32BE(out[1], offset + 4)
9298 self._cache.writeUInt32BE(out[2], offset + 8)
9299 self._cache.writeUInt32BE(out[3], offset + 12)
9300 }
9301 var pad = self._cache.slice(0, chunk.length)
9302 self._cache = self._cache.slice(chunk.length)
9303 return xor(chunk, pad)
9304}
9305
9306},{"../incr32":27,"buffer-xor":49,"safe-buffer":398}],33:[function(require,module,exports){
9307exports.encrypt = function (self, block) {
9308 return self._cipher.encryptBlock(block)
9309}
9310
9311exports.decrypt = function (self, block) {
9312 return self._cipher.decryptBlock(block)
9313}
9314
9315},{}],34:[function(require,module,exports){
9316var modeModules = {
9317 ECB: require('./ecb'),
9318 CBC: require('./cbc'),
9319 CFB: require('./cfb'),
9320 CFB8: require('./cfb8'),
9321 CFB1: require('./cfb1'),
9322 OFB: require('./ofb'),
9323 CTR: require('./ctr'),
9324 GCM: require('./ctr')
9325}
9326
9327var modes = require('./list.json')
9328
9329for (var key in modes) {
9330 modes[key].module = modeModules[modes[key].mode]
9331}
9332
9333module.exports = modes
9334
9335},{"./cbc":28,"./cfb":29,"./cfb1":30,"./cfb8":31,"./ctr":32,"./ecb":33,"./list.json":35,"./ofb":36}],35:[function(require,module,exports){
9336module.exports={
9337 "aes-128-ecb": {
9338 "cipher": "AES",
9339 "key": 128,
9340 "iv": 0,
9341 "mode": "ECB",
9342 "type": "block"
9343 },
9344 "aes-192-ecb": {
9345 "cipher": "AES",
9346 "key": 192,
9347 "iv": 0,
9348 "mode": "ECB",
9349 "type": "block"
9350 },
9351 "aes-256-ecb": {
9352 "cipher": "AES",
9353 "key": 256,
9354 "iv": 0,
9355 "mode": "ECB",
9356 "type": "block"
9357 },
9358 "aes-128-cbc": {
9359 "cipher": "AES",
9360 "key": 128,
9361 "iv": 16,
9362 "mode": "CBC",
9363 "type": "block"
9364 },
9365 "aes-192-cbc": {
9366 "cipher": "AES",
9367 "key": 192,
9368 "iv": 16,
9369 "mode": "CBC",
9370 "type": "block"
9371 },
9372 "aes-256-cbc": {
9373 "cipher": "AES",
9374 "key": 256,
9375 "iv": 16,
9376 "mode": "CBC",
9377 "type": "block"
9378 },
9379 "aes128": {
9380 "cipher": "AES",
9381 "key": 128,
9382 "iv": 16,
9383 "mode": "CBC",
9384 "type": "block"
9385 },
9386 "aes192": {
9387 "cipher": "AES",
9388 "key": 192,
9389 "iv": 16,
9390 "mode": "CBC",
9391 "type": "block"
9392 },
9393 "aes256": {
9394 "cipher": "AES",
9395 "key": 256,
9396 "iv": 16,
9397 "mode": "CBC",
9398 "type": "block"
9399 },
9400 "aes-128-cfb": {
9401 "cipher": "AES",
9402 "key": 128,
9403 "iv": 16,
9404 "mode": "CFB",
9405 "type": "stream"
9406 },
9407 "aes-192-cfb": {
9408 "cipher": "AES",
9409 "key": 192,
9410 "iv": 16,
9411 "mode": "CFB",
9412 "type": "stream"
9413 },
9414 "aes-256-cfb": {
9415 "cipher": "AES",
9416 "key": 256,
9417 "iv": 16,
9418 "mode": "CFB",
9419 "type": "stream"
9420 },
9421 "aes-128-cfb8": {
9422 "cipher": "AES",
9423 "key": 128,
9424 "iv": 16,
9425 "mode": "CFB8",
9426 "type": "stream"
9427 },
9428 "aes-192-cfb8": {
9429 "cipher": "AES",
9430 "key": 192,
9431 "iv": 16,
9432 "mode": "CFB8",
9433 "type": "stream"
9434 },
9435 "aes-256-cfb8": {
9436 "cipher": "AES",
9437 "key": 256,
9438 "iv": 16,
9439 "mode": "CFB8",
9440 "type": "stream"
9441 },
9442 "aes-128-cfb1": {
9443 "cipher": "AES",
9444 "key": 128,
9445 "iv": 16,
9446 "mode": "CFB1",
9447 "type": "stream"
9448 },
9449 "aes-192-cfb1": {
9450 "cipher": "AES",
9451 "key": 192,
9452 "iv": 16,
9453 "mode": "CFB1",
9454 "type": "stream"
9455 },
9456 "aes-256-cfb1": {
9457 "cipher": "AES",
9458 "key": 256,
9459 "iv": 16,
9460 "mode": "CFB1",
9461 "type": "stream"
9462 },
9463 "aes-128-ofb": {
9464 "cipher": "AES",
9465 "key": 128,
9466 "iv": 16,
9467 "mode": "OFB",
9468 "type": "stream"
9469 },
9470 "aes-192-ofb": {
9471 "cipher": "AES",
9472 "key": 192,
9473 "iv": 16,
9474 "mode": "OFB",
9475 "type": "stream"
9476 },
9477 "aes-256-ofb": {
9478 "cipher": "AES",
9479 "key": 256,
9480 "iv": 16,
9481 "mode": "OFB",
9482 "type": "stream"
9483 },
9484 "aes-128-ctr": {
9485 "cipher": "AES",
9486 "key": 128,
9487 "iv": 16,
9488 "mode": "CTR",
9489 "type": "stream"
9490 },
9491 "aes-192-ctr": {
9492 "cipher": "AES",
9493 "key": 192,
9494 "iv": 16,
9495 "mode": "CTR",
9496 "type": "stream"
9497 },
9498 "aes-256-ctr": {
9499 "cipher": "AES",
9500 "key": 256,
9501 "iv": 16,
9502 "mode": "CTR",
9503 "type": "stream"
9504 },
9505 "aes-128-gcm": {
9506 "cipher": "AES",
9507 "key": 128,
9508 "iv": 12,
9509 "mode": "GCM",
9510 "type": "auth"
9511 },
9512 "aes-192-gcm": {
9513 "cipher": "AES",
9514 "key": 192,
9515 "iv": 12,
9516 "mode": "GCM",
9517 "type": "auth"
9518 },
9519 "aes-256-gcm": {
9520 "cipher": "AES",
9521 "key": 256,
9522 "iv": 12,
9523 "mode": "GCM",
9524 "type": "auth"
9525 }
9526}
9527
9528},{}],36:[function(require,module,exports){
9529(function (Buffer){
9530var xor = require('buffer-xor')
9531
9532function getBlock (self) {
9533 self._prev = self._cipher.encryptBlock(self._prev)
9534 return self._prev
9535}
9536
9537exports.encrypt = function (self, chunk) {
9538 while (self._cache.length < chunk.length) {
9539 self._cache = Buffer.concat([self._cache, getBlock(self)])
9540 }
9541
9542 var pad = self._cache.slice(0, chunk.length)
9543 self._cache = self._cache.slice(chunk.length)
9544 return xor(chunk, pad)
9545}
9546
9547}).call(this,require("buffer").Buffer)
9548},{"buffer":50,"buffer-xor":49}],37:[function(require,module,exports){
9549var aes = require('./aes')
9550var Buffer = require('safe-buffer').Buffer
9551var Transform = require('cipher-base')
9552var inherits = require('inherits')
9553
9554function StreamCipher (mode, key, iv, decrypt) {
9555 Transform.call(this)
9556
9557 this._cipher = new aes.AES(key)
9558 this._prev = Buffer.from(iv)
9559 this._cache = Buffer.allocUnsafe(0)
9560 this._secCache = Buffer.allocUnsafe(0)
9561 this._decrypt = decrypt
9562 this._mode = mode
9563}
9564
9565inherits(StreamCipher, Transform)
9566
9567StreamCipher.prototype._update = function (chunk) {
9568 return this._mode.encrypt(this, chunk, this._decrypt)
9569}
9570
9571StreamCipher.prototype._final = function () {
9572 this._cipher.scrub()
9573}
9574
9575module.exports = StreamCipher
9576
9577},{"./aes":21,"cipher-base":51,"inherits":119,"safe-buffer":398}],38:[function(require,module,exports){
9578var DES = require('browserify-des')
9579var aes = require('browserify-aes/browser')
9580var aesModes = require('browserify-aes/modes')
9581var desModes = require('browserify-des/modes')
9582var ebtk = require('evp_bytestokey')
9583
9584function createCipher (suite, password) {
9585 suite = suite.toLowerCase()
9586
9587 var keyLen, ivLen
9588 if (aesModes[suite]) {
9589 keyLen = aesModes[suite].key
9590 ivLen = aesModes[suite].iv
9591 } else if (desModes[suite]) {
9592 keyLen = desModes[suite].key * 8
9593 ivLen = desModes[suite].iv
9594 } else {
9595 throw new TypeError('invalid suite type')
9596 }
9597
9598 var keys = ebtk(password, false, keyLen, ivLen)
9599 return createCipheriv(suite, keys.key, keys.iv)
9600}
9601
9602function createDecipher (suite, password) {
9603 suite = suite.toLowerCase()
9604
9605 var keyLen, ivLen
9606 if (aesModes[suite]) {
9607 keyLen = aesModes[suite].key
9608 ivLen = aesModes[suite].iv
9609 } else if (desModes[suite]) {
9610 keyLen = desModes[suite].key * 8
9611 ivLen = desModes[suite].iv
9612 } else {
9613 throw new TypeError('invalid suite type')
9614 }
9615
9616 var keys = ebtk(password, false, keyLen, ivLen)
9617 return createDecipheriv(suite, keys.key, keys.iv)
9618}
9619
9620function createCipheriv (suite, key, iv) {
9621 suite = suite.toLowerCase()
9622 if (aesModes[suite]) return aes.createCipheriv(suite, key, iv)
9623 if (desModes[suite]) return new DES({ key: key, iv: iv, mode: suite })
9624
9625 throw new TypeError('invalid suite type')
9626}
9627
9628function createDecipheriv (suite, key, iv) {
9629 suite = suite.toLowerCase()
9630 if (aesModes[suite]) return aes.createDecipheriv(suite, key, iv)
9631 if (desModes[suite]) return new DES({ key: key, iv: iv, mode: suite, decrypt: true })
9632
9633 throw new TypeError('invalid suite type')
9634}
9635
9636function getCiphers () {
9637 return Object.keys(desModes).concat(aes.getCiphers())
9638}
9639
9640exports.createCipher = exports.Cipher = createCipher
9641exports.createCipheriv = exports.Cipheriv = createCipheriv
9642exports.createDecipher = exports.Decipher = createDecipher
9643exports.createDecipheriv = exports.Decipheriv = createDecipheriv
9644exports.listCiphers = exports.getCiphers = getCiphers
9645
9646},{"browserify-aes/browser":23,"browserify-aes/modes":34,"browserify-des":39,"browserify-des/modes":40,"evp_bytestokey":103}],39:[function(require,module,exports){
9647var CipherBase = require('cipher-base')
9648var des = require('des.js')
9649var inherits = require('inherits')
9650var Buffer = require('safe-buffer').Buffer
9651
9652var modes = {
9653 'des-ede3-cbc': des.CBC.instantiate(des.EDE),
9654 'des-ede3': des.EDE,
9655 'des-ede-cbc': des.CBC.instantiate(des.EDE),
9656 'des-ede': des.EDE,
9657 'des-cbc': des.CBC.instantiate(des.DES),
9658 'des-ecb': des.DES
9659}
9660modes.des = modes['des-cbc']
9661modes.des3 = modes['des-ede3-cbc']
9662module.exports = DES
9663inherits(DES, CipherBase)
9664function DES (opts) {
9665 CipherBase.call(this)
9666 var modeName = opts.mode.toLowerCase()
9667 var mode = modes[modeName]
9668 var type
9669 if (opts.decrypt) {
9670 type = 'decrypt'
9671 } else {
9672 type = 'encrypt'
9673 }
9674 var key = opts.key
9675 if (!Buffer.isBuffer(key)) {
9676 key = Buffer.from(key)
9677 }
9678 if (modeName === 'des-ede' || modeName === 'des-ede-cbc') {
9679 key = Buffer.concat([key, key.slice(0, 8)])
9680 }
9681 var iv = opts.iv
9682 if (!Buffer.isBuffer(iv)) {
9683 iv = Buffer.from(iv)
9684 }
9685 this._des = mode.create({
9686 key: key,
9687 iv: iv,
9688 type: type
9689 })
9690}
9691DES.prototype._update = function (data) {
9692 return Buffer.from(this._des.update(data))
9693}
9694DES.prototype._final = function () {
9695 return Buffer.from(this._des.final())
9696}
9697
9698},{"cipher-base":51,"des.js":74,"inherits":119,"safe-buffer":398}],40:[function(require,module,exports){
9699exports['des-ecb'] = {
9700 key: 8,
9701 iv: 0
9702}
9703exports['des-cbc'] = exports.des = {
9704 key: 8,
9705 iv: 8
9706}
9707exports['des-ede3-cbc'] = exports.des3 = {
9708 key: 24,
9709 iv: 8
9710}
9711exports['des-ede3'] = {
9712 key: 24,
9713 iv: 0
9714}
9715exports['des-ede-cbc'] = {
9716 key: 16,
9717 iv: 8
9718}
9719exports['des-ede'] = {
9720 key: 16,
9721 iv: 0
9722}
9723
9724},{}],41:[function(require,module,exports){
9725(function (Buffer){
9726var bn = require('bn.js');
9727var randomBytes = require('randombytes');
9728module.exports = crt;
9729function blind(priv) {
9730 var r = getr(priv);
9731 var blinder = r.toRed(bn.mont(priv.modulus))
9732 .redPow(new bn(priv.publicExponent)).fromRed();
9733 return {
9734 blinder: blinder,
9735 unblinder:r.invm(priv.modulus)
9736 };
9737}
9738function crt(msg, priv) {
9739 var blinds = blind(priv);
9740 var len = priv.modulus.byteLength();
9741 var mod = bn.mont(priv.modulus);
9742 var blinded = new bn(msg).mul(blinds.blinder).umod(priv.modulus);
9743 var c1 = blinded.toRed(bn.mont(priv.prime1));
9744 var c2 = blinded.toRed(bn.mont(priv.prime2));
9745 var qinv = priv.coefficient;
9746 var p = priv.prime1;
9747 var q = priv.prime2;
9748 var m1 = c1.redPow(priv.exponent1);
9749 var m2 = c2.redPow(priv.exponent2);
9750 m1 = m1.fromRed();
9751 m2 = m2.fromRed();
9752 var h = m1.isub(m2).imul(qinv).umod(p);
9753 h.imul(q);
9754 m2.iadd(h);
9755 return new Buffer(m2.imul(blinds.unblinder).umod(priv.modulus).toArray(false, len));
9756}
9757crt.getr = getr;
9758function getr(priv) {
9759 var len = priv.modulus.byteLength();
9760 var r = new bn(randomBytes(len));
9761 while (r.cmp(priv.modulus) >= 0 || !r.umod(priv.prime1) || !r.umod(priv.prime2)) {
9762 r = new bn(randomBytes(len));
9763 }
9764 return r;
9765}
9766
9767}).call(this,require("buffer").Buffer)
9768},{"bn.js":18,"buffer":50,"randombytes":381}],42:[function(require,module,exports){
9769module.exports = require('./browser/algorithms.json')
9770
9771},{"./browser/algorithms.json":43}],43:[function(require,module,exports){
9772module.exports={
9773 "sha224WithRSAEncryption": {
9774 "sign": "rsa",
9775 "hash": "sha224",
9776 "id": "302d300d06096086480165030402040500041c"
9777 },
9778 "RSA-SHA224": {
9779 "sign": "ecdsa/rsa",
9780 "hash": "sha224",
9781 "id": "302d300d06096086480165030402040500041c"
9782 },
9783 "sha256WithRSAEncryption": {
9784 "sign": "rsa",
9785 "hash": "sha256",
9786 "id": "3031300d060960864801650304020105000420"
9787 },
9788 "RSA-SHA256": {
9789 "sign": "ecdsa/rsa",
9790 "hash": "sha256",
9791 "id": "3031300d060960864801650304020105000420"
9792 },
9793 "sha384WithRSAEncryption": {
9794 "sign": "rsa",
9795 "hash": "sha384",
9796 "id": "3041300d060960864801650304020205000430"
9797 },
9798 "RSA-SHA384": {
9799 "sign": "ecdsa/rsa",
9800 "hash": "sha384",
9801 "id": "3041300d060960864801650304020205000430"
9802 },
9803 "sha512WithRSAEncryption": {
9804 "sign": "rsa",
9805 "hash": "sha512",
9806 "id": "3051300d060960864801650304020305000440"
9807 },
9808 "RSA-SHA512": {
9809 "sign": "ecdsa/rsa",
9810 "hash": "sha512",
9811 "id": "3051300d060960864801650304020305000440"
9812 },
9813 "RSA-SHA1": {
9814 "sign": "rsa",
9815 "hash": "sha1",
9816 "id": "3021300906052b0e03021a05000414"
9817 },
9818 "ecdsa-with-SHA1": {
9819 "sign": "ecdsa",
9820 "hash": "sha1",
9821 "id": ""
9822 },
9823 "sha256": {
9824 "sign": "ecdsa",
9825 "hash": "sha256",
9826 "id": ""
9827 },
9828 "sha224": {
9829 "sign": "ecdsa",
9830 "hash": "sha224",
9831 "id": ""
9832 },
9833 "sha384": {
9834 "sign": "ecdsa",
9835 "hash": "sha384",
9836 "id": ""
9837 },
9838 "sha512": {
9839 "sign": "ecdsa",
9840 "hash": "sha512",
9841 "id": ""
9842 },
9843 "DSA-SHA": {
9844 "sign": "dsa",
9845 "hash": "sha1",
9846 "id": ""
9847 },
9848 "DSA-SHA1": {
9849 "sign": "dsa",
9850 "hash": "sha1",
9851 "id": ""
9852 },
9853 "DSA": {
9854 "sign": "dsa",
9855 "hash": "sha1",
9856 "id": ""
9857 },
9858 "DSA-WITH-SHA224": {
9859 "sign": "dsa",
9860 "hash": "sha224",
9861 "id": ""
9862 },
9863 "DSA-SHA224": {
9864 "sign": "dsa",
9865 "hash": "sha224",
9866 "id": ""
9867 },
9868 "DSA-WITH-SHA256": {
9869 "sign": "dsa",
9870 "hash": "sha256",
9871 "id": ""
9872 },
9873 "DSA-SHA256": {
9874 "sign": "dsa",
9875 "hash": "sha256",
9876 "id": ""
9877 },
9878 "DSA-WITH-SHA384": {
9879 "sign": "dsa",
9880 "hash": "sha384",
9881 "id": ""
9882 },
9883 "DSA-SHA384": {
9884 "sign": "dsa",
9885 "hash": "sha384",
9886 "id": ""
9887 },
9888 "DSA-WITH-SHA512": {
9889 "sign": "dsa",
9890 "hash": "sha512",
9891 "id": ""
9892 },
9893 "DSA-SHA512": {
9894 "sign": "dsa",
9895 "hash": "sha512",
9896 "id": ""
9897 },
9898 "DSA-RIPEMD160": {
9899 "sign": "dsa",
9900 "hash": "rmd160",
9901 "id": ""
9902 },
9903 "ripemd160WithRSA": {
9904 "sign": "rsa",
9905 "hash": "rmd160",
9906 "id": "3021300906052b2403020105000414"
9907 },
9908 "RSA-RIPEMD160": {
9909 "sign": "rsa",
9910 "hash": "rmd160",
9911 "id": "3021300906052b2403020105000414"
9912 },
9913 "md5WithRSAEncryption": {
9914 "sign": "rsa",
9915 "hash": "md5",
9916 "id": "3020300c06082a864886f70d020505000410"
9917 },
9918 "RSA-MD5": {
9919 "sign": "rsa",
9920 "hash": "md5",
9921 "id": "3020300c06082a864886f70d020505000410"
9922 }
9923}
9924
9925},{}],44:[function(require,module,exports){
9926module.exports={
9927 "1.3.132.0.10": "secp256k1",
9928 "1.3.132.0.33": "p224",
9929 "1.2.840.10045.3.1.1": "p192",
9930 "1.2.840.10045.3.1.7": "p256",
9931 "1.3.132.0.34": "p384",
9932 "1.3.132.0.35": "p521"
9933}
9934
9935},{}],45:[function(require,module,exports){
9936(function (Buffer){
9937var createHash = require('create-hash')
9938var stream = require('stream')
9939var inherits = require('inherits')
9940var sign = require('./sign')
9941var verify = require('./verify')
9942
9943var algorithms = require('./algorithms.json')
9944Object.keys(algorithms).forEach(function (key) {
9945 algorithms[key].id = new Buffer(algorithms[key].id, 'hex')
9946 algorithms[key.toLowerCase()] = algorithms[key]
9947})
9948
9949function Sign (algorithm) {
9950 stream.Writable.call(this)
9951
9952 var data = algorithms[algorithm]
9953 if (!data) throw new Error('Unknown message digest')
9954
9955 this._hashType = data.hash
9956 this._hash = createHash(data.hash)
9957 this._tag = data.id
9958 this._signType = data.sign
9959}
9960inherits(Sign, stream.Writable)
9961
9962Sign.prototype._write = function _write (data, _, done) {
9963 this._hash.update(data)
9964 done()
9965}
9966
9967Sign.prototype.update = function update (data, enc) {
9968 if (typeof data === 'string') data = new Buffer(data, enc)
9969
9970 this._hash.update(data)
9971 return this
9972}
9973
9974Sign.prototype.sign = function signMethod (key, enc) {
9975 this.end()
9976 var hash = this._hash.digest()
9977 var sig = sign(hash, key, this._hashType, this._signType, this._tag)
9978
9979 return enc ? sig.toString(enc) : sig
9980}
9981
9982function Verify (algorithm) {
9983 stream.Writable.call(this)
9984
9985 var data = algorithms[algorithm]
9986 if (!data) throw new Error('Unknown message digest')
9987
9988 this._hash = createHash(data.hash)
9989 this._tag = data.id
9990 this._signType = data.sign
9991}
9992inherits(Verify, stream.Writable)
9993
9994Verify.prototype._write = function _write (data, _, done) {
9995 this._hash.update(data)
9996 done()
9997}
9998
9999Verify.prototype.update = function update (data, enc) {
10000 if (typeof data === 'string') data = new Buffer(data, enc)
10001
10002 this._hash.update(data)
10003 return this
10004}
10005
10006Verify.prototype.verify = function verifyMethod (key, sig, enc) {
10007 if (typeof sig === 'string') sig = new Buffer(sig, enc)
10008
10009 this.end()
10010 var hash = this._hash.digest()
10011 return verify(sig, hash, key, this._signType, this._tag)
10012}
10013
10014function createSign (algorithm) {
10015 return new Sign(algorithm)
10016}
10017
10018function createVerify (algorithm) {
10019 return new Verify(algorithm)
10020}
10021
10022module.exports = {
10023 Sign: createSign,
10024 Verify: createVerify,
10025 createSign: createSign,
10026 createVerify: createVerify
10027}
10028
10029}).call(this,require("buffer").Buffer)
10030},{"./algorithms.json":43,"./sign":46,"./verify":47,"buffer":50,"create-hash":68,"inherits":119,"stream":437}],46:[function(require,module,exports){
10031(function (Buffer){
10032// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js
10033var createHmac = require('create-hmac')
10034var crt = require('browserify-rsa')
10035var EC = require('elliptic').ec
10036var BN = require('bn.js')
10037var parseKeys = require('parse-asn1')
10038var curves = require('./curves.json')
10039
10040function sign (hash, key, hashType, signType, tag) {
10041 var priv = parseKeys(key)
10042 if (priv.curve) {
10043 // rsa keys can be interpreted as ecdsa ones in openssl
10044 if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type')
10045 return ecSign(hash, priv)
10046 } else if (priv.type === 'dsa') {
10047 if (signType !== 'dsa') throw new Error('wrong private key type')
10048 return dsaSign(hash, priv, hashType)
10049 } else {
10050 if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type')
10051 }
10052 hash = Buffer.concat([tag, hash])
10053 var len = priv.modulus.byteLength()
10054 var pad = [ 0, 1 ]
10055 while (hash.length + pad.length + 1 < len) pad.push(0xff)
10056 pad.push(0x00)
10057 var i = -1
10058 while (++i < hash.length) pad.push(hash[i])
10059
10060 var out = crt(pad, priv)
10061 return out
10062}
10063
10064function ecSign (hash, priv) {
10065 var curveId = curves[priv.curve.join('.')]
10066 if (!curveId) throw new Error('unknown curve ' + priv.curve.join('.'))
10067
10068 var curve = new EC(curveId)
10069 var key = curve.keyFromPrivate(priv.privateKey)
10070 var out = key.sign(hash)
10071
10072 return new Buffer(out.toDER())
10073}
10074
10075function dsaSign (hash, priv, algo) {
10076 var x = priv.params.priv_key
10077 var p = priv.params.p
10078 var q = priv.params.q
10079 var g = priv.params.g
10080 var r = new BN(0)
10081 var k
10082 var H = bits2int(hash, q).mod(q)
10083 var s = false
10084 var kv = getKey(x, q, hash, algo)
10085 while (s === false) {
10086 k = makeKey(q, kv, algo)
10087 r = makeR(g, k, p, q)
10088 s = k.invm(q).imul(H.add(x.mul(r))).mod(q)
10089 if (s.cmpn(0) === 0) {
10090 s = false
10091 r = new BN(0)
10092 }
10093 }
10094 return toDER(r, s)
10095}
10096
10097function toDER (r, s) {
10098 r = r.toArray()
10099 s = s.toArray()
10100
10101 // Pad values
10102 if (r[0] & 0x80) r = [ 0 ].concat(r)
10103 if (s[0] & 0x80) s = [ 0 ].concat(s)
10104
10105 var total = r.length + s.length + 4
10106 var res = [ 0x30, total, 0x02, r.length ]
10107 res = res.concat(r, [ 0x02, s.length ], s)
10108 return new Buffer(res)
10109}
10110
10111function getKey (x, q, hash, algo) {
10112 x = new Buffer(x.toArray())
10113 if (x.length < q.byteLength()) {
10114 var zeros = new Buffer(q.byteLength() - x.length)
10115 zeros.fill(0)
10116 x = Buffer.concat([ zeros, x ])
10117 }
10118 var hlen = hash.length
10119 var hbits = bits2octets(hash, q)
10120 var v = new Buffer(hlen)
10121 v.fill(1)
10122 var k = new Buffer(hlen)
10123 k.fill(0)
10124 k = createHmac(algo, k).update(v).update(new Buffer([ 0 ])).update(x).update(hbits).digest()
10125 v = createHmac(algo, k).update(v).digest()
10126 k = createHmac(algo, k).update(v).update(new Buffer([ 1 ])).update(x).update(hbits).digest()
10127 v = createHmac(algo, k).update(v).digest()
10128 return { k: k, v: v }
10129}
10130
10131function bits2int (obits, q) {
10132 var bits = new BN(obits)
10133 var shift = (obits.length << 3) - q.bitLength()
10134 if (shift > 0) bits.ishrn(shift)
10135 return bits
10136}
10137
10138function bits2octets (bits, q) {
10139 bits = bits2int(bits, q)
10140 bits = bits.mod(q)
10141 var out = new Buffer(bits.toArray())
10142 if (out.length < q.byteLength()) {
10143 var zeros = new Buffer(q.byteLength() - out.length)
10144 zeros.fill(0)
10145 out = Buffer.concat([ zeros, out ])
10146 }
10147 return out
10148}
10149
10150function makeKey (q, kv, algo) {
10151 var t
10152 var k
10153
10154 do {
10155 t = new Buffer(0)
10156
10157 while (t.length * 8 < q.bitLength()) {
10158 kv.v = createHmac(algo, kv.k).update(kv.v).digest()
10159 t = Buffer.concat([ t, kv.v ])
10160 }
10161
10162 k = bits2int(t, q)
10163 kv.k = createHmac(algo, kv.k).update(kv.v).update(new Buffer([ 0 ])).digest()
10164 kv.v = createHmac(algo, kv.k).update(kv.v).digest()
10165 } while (k.cmp(q) !== -1)
10166
10167 return k
10168}
10169
10170function makeR (g, k, p, q) {
10171 return g.toRed(BN.mont(p)).redPow(k).fromRed().mod(q)
10172}
10173
10174module.exports = sign
10175module.exports.getKey = getKey
10176module.exports.makeKey = makeKey
10177
10178}).call(this,require("buffer").Buffer)
10179},{"./curves.json":44,"bn.js":18,"browserify-rsa":41,"buffer":50,"create-hmac":70,"elliptic":86,"parse-asn1":366}],47:[function(require,module,exports){
10180(function (Buffer){
10181// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js
10182var BN = require('bn.js')
10183var EC = require('elliptic').ec
10184var parseKeys = require('parse-asn1')
10185var curves = require('./curves.json')
10186
10187function verify (sig, hash, key, signType, tag) {
10188 var pub = parseKeys(key)
10189 if (pub.type === 'ec') {
10190 // rsa keys can be interpreted as ecdsa ones in openssl
10191 if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type')
10192 return ecVerify(sig, hash, pub)
10193 } else if (pub.type === 'dsa') {
10194 if (signType !== 'dsa') throw new Error('wrong public key type')
10195 return dsaVerify(sig, hash, pub)
10196 } else {
10197 if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type')
10198 }
10199 hash = Buffer.concat([tag, hash])
10200 var len = pub.modulus.byteLength()
10201 var pad = [ 1 ]
10202 var padNum = 0
10203 while (hash.length + pad.length + 2 < len) {
10204 pad.push(0xff)
10205 padNum++
10206 }
10207 pad.push(0x00)
10208 var i = -1
10209 while (++i < hash.length) {
10210 pad.push(hash[i])
10211 }
10212 pad = new Buffer(pad)
10213 var red = BN.mont(pub.modulus)
10214 sig = new BN(sig).toRed(red)
10215
10216 sig = sig.redPow(new BN(pub.publicExponent))
10217 sig = new Buffer(sig.fromRed().toArray())
10218 var out = padNum < 8 ? 1 : 0
10219 len = Math.min(sig.length, pad.length)
10220 if (sig.length !== pad.length) out = 1
10221
10222 i = -1
10223 while (++i < len) out |= sig[i] ^ pad[i]
10224 return out === 0
10225}
10226
10227function ecVerify (sig, hash, pub) {
10228 var curveId = curves[pub.data.algorithm.curve.join('.')]
10229 if (!curveId) throw new Error('unknown curve ' + pub.data.algorithm.curve.join('.'))
10230
10231 var curve = new EC(curveId)
10232 var pubkey = pub.data.subjectPrivateKey.data
10233
10234 return curve.verify(hash, sig, pubkey)
10235}
10236
10237function dsaVerify (sig, hash, pub) {
10238 var p = pub.data.p
10239 var q = pub.data.q
10240 var g = pub.data.g
10241 var y = pub.data.pub_key
10242 var unpacked = parseKeys.signature.decode(sig, 'der')
10243 var s = unpacked.s
10244 var r = unpacked.r
10245 checkValue(s, q)
10246 checkValue(r, q)
10247 var montp = BN.mont(p)
10248 var w = s.invm(q)
10249 var v = g.toRed(montp)
10250 .redPow(new BN(hash).mul(w).mod(q))
10251 .fromRed()
10252 .mul(y.toRed(montp).redPow(r.mul(w).mod(q)).fromRed())
10253 .mod(p)
10254 .mod(q)
10255 return v.cmp(r) === 0
10256}
10257
10258function checkValue (b, q) {
10259 if (b.cmpn(0) <= 0) throw new Error('invalid sig')
10260 if (b.cmp(q) >= q) throw new Error('invalid sig')
10261}
10262
10263module.exports = verify
10264
10265}).call(this,require("buffer").Buffer)
10266},{"./curves.json":44,"bn.js":18,"buffer":50,"elliptic":86,"parse-asn1":366}],48:[function(require,module,exports){
10267arguments[4][20][0].apply(exports,arguments)
10268},{"dup":20}],49:[function(require,module,exports){
10269(function (Buffer){
10270module.exports = function xor (a, b) {
10271 var length = Math.min(a.length, b.length)
10272 var buffer = new Buffer(length)
10273
10274 for (var i = 0; i < length; ++i) {
10275 buffer[i] = a[i] ^ b[i]
10276 }
10277
10278 return buffer
10279}
10280
10281}).call(this,require("buffer").Buffer)
10282},{"buffer":50}],50:[function(require,module,exports){
10283/*!
10284 * The buffer module from node.js, for the browser.
10285 *
10286 * @author Feross Aboukhadijeh <https://feross.org>
10287 * @license MIT
10288 */
10289/* eslint-disable no-proto */
10290
10291'use strict'
10292
10293var base64 = require('base64-js')
10294var ieee754 = require('ieee754')
10295
10296exports.Buffer = Buffer
10297exports.SlowBuffer = SlowBuffer
10298exports.INSPECT_MAX_BYTES = 50
10299
10300var K_MAX_LENGTH = 0x7fffffff
10301exports.kMaxLength = K_MAX_LENGTH
10302
10303/**
10304 * If `Buffer.TYPED_ARRAY_SUPPORT`:
10305 * === true Use Uint8Array implementation (fastest)
10306 * === false Print warning and recommend using `buffer` v4.x which has an Object
10307 * implementation (most compatible, even IE6)
10308 *
10309 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
10310 * Opera 11.6+, iOS 4.2+.
10311 *
10312 * We report that the browser does not support typed arrays if the are not subclassable
10313 * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
10314 * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
10315 * for __proto__ and has a buggy typed array implementation.
10316 */
10317Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
10318
10319if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
10320 typeof console.error === 'function') {
10321 console.error(
10322 'This browser lacks typed array (Uint8Array) support which is required by ' +
10323 '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
10324 )
10325}
10326
10327function typedArraySupport () {
10328 // Can typed array instances can be augmented?
10329 try {
10330 var arr = new Uint8Array(1)
10331 arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } }
10332 return arr.foo() === 42
10333 } catch (e) {
10334 return false
10335 }
10336}
10337
10338Object.defineProperty(Buffer.prototype, 'parent', {
10339 enumerable: true,
10340 get: function () {
10341 if (!Buffer.isBuffer(this)) return undefined
10342 return this.buffer
10343 }
10344})
10345
10346Object.defineProperty(Buffer.prototype, 'offset', {
10347 enumerable: true,
10348 get: function () {
10349 if (!Buffer.isBuffer(this)) return undefined
10350 return this.byteOffset
10351 }
10352})
10353
10354function createBuffer (length) {
10355 if (length > K_MAX_LENGTH) {
10356 throw new RangeError('The value "' + length + '" is invalid for option "size"')
10357 }
10358 // Return an augmented `Uint8Array` instance
10359 var buf = new Uint8Array(length)
10360 buf.__proto__ = Buffer.prototype
10361 return buf
10362}
10363
10364/**
10365 * The Buffer constructor returns instances of `Uint8Array` that have their
10366 * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
10367 * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
10368 * and the `Uint8Array` methods. Square bracket notation works as expected -- it
10369 * returns a single octet.
10370 *
10371 * The `Uint8Array` prototype remains unmodified.
10372 */
10373
10374function Buffer (arg, encodingOrOffset, length) {
10375 // Common case.
10376 if (typeof arg === 'number') {
10377 if (typeof encodingOrOffset === 'string') {
10378 throw new TypeError(
10379 'The "string" argument must be of type string. Received type number'
10380 )
10381 }
10382 return allocUnsafe(arg)
10383 }
10384 return from(arg, encodingOrOffset, length)
10385}
10386
10387// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
10388if (typeof Symbol !== 'undefined' && Symbol.species != null &&
10389 Buffer[Symbol.species] === Buffer) {
10390 Object.defineProperty(Buffer, Symbol.species, {
10391 value: null,
10392 configurable: true,
10393 enumerable: false,
10394 writable: false
10395 })
10396}
10397
10398Buffer.poolSize = 8192 // not used by this implementation
10399
10400function from (value, encodingOrOffset, length) {
10401 if (typeof value === 'string') {
10402 return fromString(value, encodingOrOffset)
10403 }
10404
10405 if (ArrayBuffer.isView(value)) {
10406 return fromArrayLike(value)
10407 }
10408
10409 if (value == null) {
10410 throw TypeError(
10411 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
10412 'or Array-like Object. Received type ' + (typeof value)
10413 )
10414 }
10415
10416 if (isInstance(value, ArrayBuffer) ||
10417 (value && isInstance(value.buffer, ArrayBuffer))) {
10418 return fromArrayBuffer(value, encodingOrOffset, length)
10419 }
10420
10421 if (typeof value === 'number') {
10422 throw new TypeError(
10423 'The "value" argument must not be of type number. Received type number'
10424 )
10425 }
10426
10427 var valueOf = value.valueOf && value.valueOf()
10428 if (valueOf != null && valueOf !== value) {
10429 return Buffer.from(valueOf, encodingOrOffset, length)
10430 }
10431
10432 var b = fromObject(value)
10433 if (b) return b
10434
10435 if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
10436 typeof value[Symbol.toPrimitive] === 'function') {
10437 return Buffer.from(
10438 value[Symbol.toPrimitive]('string'), encodingOrOffset, length
10439 )
10440 }
10441
10442 throw new TypeError(
10443 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
10444 'or Array-like Object. Received type ' + (typeof value)
10445 )
10446}
10447
10448/**
10449 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
10450 * if value is a number.
10451 * Buffer.from(str[, encoding])
10452 * Buffer.from(array)
10453 * Buffer.from(buffer)
10454 * Buffer.from(arrayBuffer[, byteOffset[, length]])
10455 **/
10456Buffer.from = function (value, encodingOrOffset, length) {
10457 return from(value, encodingOrOffset, length)
10458}
10459
10460// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
10461// https://github.com/feross/buffer/pull/148
10462Buffer.prototype.__proto__ = Uint8Array.prototype
10463Buffer.__proto__ = Uint8Array
10464
10465function assertSize (size) {
10466 if (typeof size !== 'number') {
10467 throw new TypeError('"size" argument must be of type number')
10468 } else if (size < 0) {
10469 throw new RangeError('The value "' + size + '" is invalid for option "size"')
10470 }
10471}
10472
10473function alloc (size, fill, encoding) {
10474 assertSize(size)
10475 if (size <= 0) {
10476 return createBuffer(size)
10477 }
10478 if (fill !== undefined) {
10479 // Only pay attention to encoding if it's a string. This
10480 // prevents accidentally sending in a number that would
10481 // be interpretted as a start offset.
10482 return typeof encoding === 'string'
10483 ? createBuffer(size).fill(fill, encoding)
10484 : createBuffer(size).fill(fill)
10485 }
10486 return createBuffer(size)
10487}
10488
10489/**
10490 * Creates a new filled Buffer instance.
10491 * alloc(size[, fill[, encoding]])
10492 **/
10493Buffer.alloc = function (size, fill, encoding) {
10494 return alloc(size, fill, encoding)
10495}
10496
10497function allocUnsafe (size) {
10498 assertSize(size)
10499 return createBuffer(size < 0 ? 0 : checked(size) | 0)
10500}
10501
10502/**
10503 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
10504 * */
10505Buffer.allocUnsafe = function (size) {
10506 return allocUnsafe(size)
10507}
10508/**
10509 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
10510 */
10511Buffer.allocUnsafeSlow = function (size) {
10512 return allocUnsafe(size)
10513}
10514
10515function fromString (string, encoding) {
10516 if (typeof encoding !== 'string' || encoding === '') {
10517 encoding = 'utf8'
10518 }
10519
10520 if (!Buffer.isEncoding(encoding)) {
10521 throw new TypeError('Unknown encoding: ' + encoding)
10522 }
10523
10524 var length = byteLength(string, encoding) | 0
10525 var buf = createBuffer(length)
10526
10527 var actual = buf.write(string, encoding)
10528
10529 if (actual !== length) {
10530 // Writing a hex string, for example, that contains invalid characters will
10531 // cause everything after the first invalid character to be ignored. (e.g.
10532 // 'abxxcd' will be treated as 'ab')
10533 buf = buf.slice(0, actual)
10534 }
10535
10536 return buf
10537}
10538
10539function fromArrayLike (array) {
10540 var length = array.length < 0 ? 0 : checked(array.length) | 0
10541 var buf = createBuffer(length)
10542 for (var i = 0; i < length; i += 1) {
10543 buf[i] = array[i] & 255
10544 }
10545 return buf
10546}
10547
10548function fromArrayBuffer (array, byteOffset, length) {
10549 if (byteOffset < 0 || array.byteLength < byteOffset) {
10550 throw new RangeError('"offset" is outside of buffer bounds')
10551 }
10552
10553 if (array.byteLength < byteOffset + (length || 0)) {
10554 throw new RangeError('"length" is outside of buffer bounds')
10555 }
10556
10557 var buf
10558 if (byteOffset === undefined && length === undefined) {
10559 buf = new Uint8Array(array)
10560 } else if (length === undefined) {
10561 buf = new Uint8Array(array, byteOffset)
10562 } else {
10563 buf = new Uint8Array(array, byteOffset, length)
10564 }
10565
10566 // Return an augmented `Uint8Array` instance
10567 buf.__proto__ = Buffer.prototype
10568 return buf
10569}
10570
10571function fromObject (obj) {
10572 if (Buffer.isBuffer(obj)) {
10573 var len = checked(obj.length) | 0
10574 var buf = createBuffer(len)
10575
10576 if (buf.length === 0) {
10577 return buf
10578 }
10579
10580 obj.copy(buf, 0, 0, len)
10581 return buf
10582 }
10583
10584 if (obj.length !== undefined) {
10585 if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
10586 return createBuffer(0)
10587 }
10588 return fromArrayLike(obj)
10589 }
10590
10591 if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
10592 return fromArrayLike(obj.data)
10593 }
10594}
10595
10596function checked (length) {
10597 // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
10598 // length is NaN (which is otherwise coerced to zero.)
10599 if (length >= K_MAX_LENGTH) {
10600 throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
10601 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
10602 }
10603 return length | 0
10604}
10605
10606function SlowBuffer (length) {
10607 if (+length != length) { // eslint-disable-line eqeqeq
10608 length = 0
10609 }
10610 return Buffer.alloc(+length)
10611}
10612
10613Buffer.isBuffer = function isBuffer (b) {
10614 return b != null && b._isBuffer === true &&
10615 b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
10616}
10617
10618Buffer.compare = function compare (a, b) {
10619 if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)
10620 if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)
10621 if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
10622 throw new TypeError(
10623 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
10624 )
10625 }
10626
10627 if (a === b) return 0
10628
10629 var x = a.length
10630 var y = b.length
10631
10632 for (var i = 0, len = Math.min(x, y); i < len; ++i) {
10633 if (a[i] !== b[i]) {
10634 x = a[i]
10635 y = b[i]
10636 break
10637 }
10638 }
10639
10640 if (x < y) return -1
10641 if (y < x) return 1
10642 return 0
10643}
10644
10645Buffer.isEncoding = function isEncoding (encoding) {
10646 switch (String(encoding).toLowerCase()) {
10647 case 'hex':
10648 case 'utf8':
10649 case 'utf-8':
10650 case 'ascii':
10651 case 'latin1':
10652 case 'binary':
10653 case 'base64':
10654 case 'ucs2':
10655 case 'ucs-2':
10656 case 'utf16le':
10657 case 'utf-16le':
10658 return true
10659 default:
10660 return false
10661 }
10662}
10663
10664Buffer.concat = function concat (list, length) {
10665 if (!Array.isArray(list)) {
10666 throw new TypeError('"list" argument must be an Array of Buffers')
10667 }
10668
10669 if (list.length === 0) {
10670 return Buffer.alloc(0)
10671 }
10672
10673 var i
10674 if (length === undefined) {
10675 length = 0
10676 for (i = 0; i < list.length; ++i) {
10677 length += list[i].length
10678 }
10679 }
10680
10681 var buffer = Buffer.allocUnsafe(length)
10682 var pos = 0
10683 for (i = 0; i < list.length; ++i) {
10684 var buf = list[i]
10685 if (isInstance(buf, Uint8Array)) {
10686 buf = Buffer.from(buf)
10687 }
10688 if (!Buffer.isBuffer(buf)) {
10689 throw new TypeError('"list" argument must be an Array of Buffers')
10690 }
10691 buf.copy(buffer, pos)
10692 pos += buf.length
10693 }
10694 return buffer
10695}
10696
10697function byteLength (string, encoding) {
10698 if (Buffer.isBuffer(string)) {
10699 return string.length
10700 }
10701 if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
10702 return string.byteLength
10703 }
10704 if (typeof string !== 'string') {
10705 throw new TypeError(
10706 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
10707 'Received type ' + typeof string
10708 )
10709 }
10710
10711 var len = string.length
10712 var mustMatch = (arguments.length > 2 && arguments[2] === true)
10713 if (!mustMatch && len === 0) return 0
10714
10715 // Use a for loop to avoid recursion
10716 var loweredCase = false
10717 for (;;) {
10718 switch (encoding) {
10719 case 'ascii':
10720 case 'latin1':
10721 case 'binary':
10722 return len
10723 case 'utf8':
10724 case 'utf-8':
10725 return utf8ToBytes(string).length
10726 case 'ucs2':
10727 case 'ucs-2':
10728 case 'utf16le':
10729 case 'utf-16le':
10730 return len * 2
10731 case 'hex':
10732 return len >>> 1
10733 case 'base64':
10734 return base64ToBytes(string).length
10735 default:
10736 if (loweredCase) {
10737 return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
10738 }
10739 encoding = ('' + encoding).toLowerCase()
10740 loweredCase = true
10741 }
10742 }
10743}
10744Buffer.byteLength = byteLength
10745
10746function slowToString (encoding, start, end) {
10747 var loweredCase = false
10748
10749 // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
10750 // property of a typed array.
10751
10752 // This behaves neither like String nor Uint8Array in that we set start/end
10753 // to their upper/lower bounds if the value passed is out of range.
10754 // undefined is handled specially as per ECMA-262 6th Edition,
10755 // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
10756 if (start === undefined || start < 0) {
10757 start = 0
10758 }
10759 // Return early if start > this.length. Done here to prevent potential uint32
10760 // coercion fail below.
10761 if (start > this.length) {
10762 return ''
10763 }
10764
10765 if (end === undefined || end > this.length) {
10766 end = this.length
10767 }
10768
10769 if (end <= 0) {
10770 return ''
10771 }
10772
10773 // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
10774 end >>>= 0
10775 start >>>= 0
10776
10777 if (end <= start) {
10778 return ''
10779 }
10780
10781 if (!encoding) encoding = 'utf8'
10782
10783 while (true) {
10784 switch (encoding) {
10785 case 'hex':
10786 return hexSlice(this, start, end)
10787
10788 case 'utf8':
10789 case 'utf-8':
10790 return utf8Slice(this, start, end)
10791
10792 case 'ascii':
10793 return asciiSlice(this, start, end)
10794
10795 case 'latin1':
10796 case 'binary':
10797 return latin1Slice(this, start, end)
10798
10799 case 'base64':
10800 return base64Slice(this, start, end)
10801
10802 case 'ucs2':
10803 case 'ucs-2':
10804 case 'utf16le':
10805 case 'utf-16le':
10806 return utf16leSlice(this, start, end)
10807
10808 default:
10809 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
10810 encoding = (encoding + '').toLowerCase()
10811 loweredCase = true
10812 }
10813 }
10814}
10815
10816// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
10817// to detect a Buffer instance. It's not possible to use `instanceof Buffer`
10818// reliably in a browserify context because there could be multiple different
10819// copies of the 'buffer' package in use. This method works even for Buffer
10820// instances that were created from another copy of the `buffer` package.
10821// See: https://github.com/feross/buffer/issues/154
10822Buffer.prototype._isBuffer = true
10823
10824function swap (b, n, m) {
10825 var i = b[n]
10826 b[n] = b[m]
10827 b[m] = i
10828}
10829
10830Buffer.prototype.swap16 = function swap16 () {
10831 var len = this.length
10832 if (len % 2 !== 0) {
10833 throw new RangeError('Buffer size must be a multiple of 16-bits')
10834 }
10835 for (var i = 0; i < len; i += 2) {
10836 swap(this, i, i + 1)
10837 }
10838 return this
10839}
10840
10841Buffer.prototype.swap32 = function swap32 () {
10842 var len = this.length
10843 if (len % 4 !== 0) {
10844 throw new RangeError('Buffer size must be a multiple of 32-bits')
10845 }
10846 for (var i = 0; i < len; i += 4) {
10847 swap(this, i, i + 3)
10848 swap(this, i + 1, i + 2)
10849 }
10850 return this
10851}
10852
10853Buffer.prototype.swap64 = function swap64 () {
10854 var len = this.length
10855 if (len % 8 !== 0) {
10856 throw new RangeError('Buffer size must be a multiple of 64-bits')
10857 }
10858 for (var i = 0; i < len; i += 8) {
10859 swap(this, i, i + 7)
10860 swap(this, i + 1, i + 6)
10861 swap(this, i + 2, i + 5)
10862 swap(this, i + 3, i + 4)
10863 }
10864 return this
10865}
10866
10867Buffer.prototype.toString = function toString () {
10868 var length = this.length
10869 if (length === 0) return ''
10870 if (arguments.length === 0) return utf8Slice(this, 0, length)
10871 return slowToString.apply(this, arguments)
10872}
10873
10874Buffer.prototype.toLocaleString = Buffer.prototype.toString
10875
10876Buffer.prototype.equals = function equals (b) {
10877 if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
10878 if (this === b) return true
10879 return Buffer.compare(this, b) === 0
10880}
10881
10882Buffer.prototype.inspect = function inspect () {
10883 var str = ''
10884 var max = exports.INSPECT_MAX_BYTES
10885 str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()
10886 if (this.length > max) str += ' ... '
10887 return '<Buffer ' + str + '>'
10888}
10889
10890Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
10891 if (isInstance(target, Uint8Array)) {
10892 target = Buffer.from(target, target.offset, target.byteLength)
10893 }
10894 if (!Buffer.isBuffer(target)) {
10895 throw new TypeError(
10896 'The "target" argument must be one of type Buffer or Uint8Array. ' +
10897 'Received type ' + (typeof target)
10898 )
10899 }
10900
10901 if (start === undefined) {
10902 start = 0
10903 }
10904 if (end === undefined) {
10905 end = target ? target.length : 0
10906 }
10907 if (thisStart === undefined) {
10908 thisStart = 0
10909 }
10910 if (thisEnd === undefined) {
10911 thisEnd = this.length
10912 }
10913
10914 if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
10915 throw new RangeError('out of range index')
10916 }
10917
10918 if (thisStart >= thisEnd && start >= end) {
10919 return 0
10920 }
10921 if (thisStart >= thisEnd) {
10922 return -1
10923 }
10924 if (start >= end) {
10925 return 1
10926 }
10927
10928 start >>>= 0
10929 end >>>= 0
10930 thisStart >>>= 0
10931 thisEnd >>>= 0
10932
10933 if (this === target) return 0
10934
10935 var x = thisEnd - thisStart
10936 var y = end - start
10937 var len = Math.min(x, y)
10938
10939 var thisCopy = this.slice(thisStart, thisEnd)
10940 var targetCopy = target.slice(start, end)
10941
10942 for (var i = 0; i < len; ++i) {
10943 if (thisCopy[i] !== targetCopy[i]) {
10944 x = thisCopy[i]
10945 y = targetCopy[i]
10946 break
10947 }
10948 }
10949
10950 if (x < y) return -1
10951 if (y < x) return 1
10952 return 0
10953}
10954
10955// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
10956// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
10957//
10958// Arguments:
10959// - buffer - a Buffer to search
10960// - val - a string, Buffer, or number
10961// - byteOffset - an index into `buffer`; will be clamped to an int32
10962// - encoding - an optional encoding, relevant is val is a string
10963// - dir - true for indexOf, false for lastIndexOf
10964function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
10965 // Empty buffer means no match
10966 if (buffer.length === 0) return -1
10967
10968 // Normalize byteOffset
10969 if (typeof byteOffset === 'string') {
10970 encoding = byteOffset
10971 byteOffset = 0
10972 } else if (byteOffset > 0x7fffffff) {
10973 byteOffset = 0x7fffffff
10974 } else if (byteOffset < -0x80000000) {
10975 byteOffset = -0x80000000
10976 }
10977 byteOffset = +byteOffset // Coerce to Number.
10978 if (numberIsNaN(byteOffset)) {
10979 // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
10980 byteOffset = dir ? 0 : (buffer.length - 1)
10981 }
10982
10983 // Normalize byteOffset: negative offsets start from the end of the buffer
10984 if (byteOffset < 0) byteOffset = buffer.length + byteOffset
10985 if (byteOffset >= buffer.length) {
10986 if (dir) return -1
10987 else byteOffset = buffer.length - 1
10988 } else if (byteOffset < 0) {
10989 if (dir) byteOffset = 0
10990 else return -1
10991 }
10992
10993 // Normalize val
10994 if (typeof val === 'string') {
10995 val = Buffer.from(val, encoding)
10996 }
10997
10998 // Finally, search either indexOf (if dir is true) or lastIndexOf
10999 if (Buffer.isBuffer(val)) {
11000 // Special case: looking for empty string/buffer always fails
11001 if (val.length === 0) {
11002 return -1
11003 }
11004 return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
11005 } else if (typeof val === 'number') {
11006 val = val & 0xFF // Search for a byte value [0-255]
11007 if (typeof Uint8Array.prototype.indexOf === 'function') {
11008 if (dir) {
11009 return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
11010 } else {
11011 return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
11012 }
11013 }
11014 return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
11015 }
11016
11017 throw new TypeError('val must be string, number or Buffer')
11018}
11019
11020function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
11021 var indexSize = 1
11022 var arrLength = arr.length
11023 var valLength = val.length
11024
11025 if (encoding !== undefined) {
11026 encoding = String(encoding).toLowerCase()
11027 if (encoding === 'ucs2' || encoding === 'ucs-2' ||
11028 encoding === 'utf16le' || encoding === 'utf-16le') {
11029 if (arr.length < 2 || val.length < 2) {
11030 return -1
11031 }
11032 indexSize = 2
11033 arrLength /= 2
11034 valLength /= 2
11035 byteOffset /= 2
11036 }
11037 }
11038
11039 function read (buf, i) {
11040 if (indexSize === 1) {
11041 return buf[i]
11042 } else {
11043 return buf.readUInt16BE(i * indexSize)
11044 }
11045 }
11046
11047 var i
11048 if (dir) {
11049 var foundIndex = -1
11050 for (i = byteOffset; i < arrLength; i++) {
11051 if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
11052 if (foundIndex === -1) foundIndex = i
11053 if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
11054 } else {
11055 if (foundIndex !== -1) i -= i - foundIndex
11056 foundIndex = -1
11057 }
11058 }
11059 } else {
11060 if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
11061 for (i = byteOffset; i >= 0; i--) {
11062 var found = true
11063 for (var j = 0; j < valLength; j++) {
11064 if (read(arr, i + j) !== read(val, j)) {
11065 found = false
11066 break
11067 }
11068 }
11069 if (found) return i
11070 }
11071 }
11072
11073 return -1
11074}
11075
11076Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
11077 return this.indexOf(val, byteOffset, encoding) !== -1
11078}
11079
11080Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
11081 return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
11082}
11083
11084Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
11085 return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
11086}
11087
11088function hexWrite (buf, string, offset, length) {
11089 offset = Number(offset) || 0
11090 var remaining = buf.length - offset
11091 if (!length) {
11092 length = remaining
11093 } else {
11094 length = Number(length)
11095 if (length > remaining) {
11096 length = remaining
11097 }
11098 }
11099
11100 var strLen = string.length
11101
11102 if (length > strLen / 2) {
11103 length = strLen / 2
11104 }
11105 for (var i = 0; i < length; ++i) {
11106 var parsed = parseInt(string.substr(i * 2, 2), 16)
11107 if (numberIsNaN(parsed)) return i
11108 buf[offset + i] = parsed
11109 }
11110 return i
11111}
11112
11113function utf8Write (buf, string, offset, length) {
11114 return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
11115}
11116
11117function asciiWrite (buf, string, offset, length) {
11118 return blitBuffer(asciiToBytes(string), buf, offset, length)
11119}
11120
11121function latin1Write (buf, string, offset, length) {
11122 return asciiWrite(buf, string, offset, length)
11123}
11124
11125function base64Write (buf, string, offset, length) {
11126 return blitBuffer(base64ToBytes(string), buf, offset, length)
11127}
11128
11129function ucs2Write (buf, string, offset, length) {
11130 return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
11131}
11132
11133Buffer.prototype.write = function write (string, offset, length, encoding) {
11134 // Buffer#write(string)
11135 if (offset === undefined) {
11136 encoding = 'utf8'
11137 length = this.length
11138 offset = 0
11139 // Buffer#write(string, encoding)
11140 } else if (length === undefined && typeof offset === 'string') {
11141 encoding = offset
11142 length = this.length
11143 offset = 0
11144 // Buffer#write(string, offset[, length][, encoding])
11145 } else if (isFinite(offset)) {
11146 offset = offset >>> 0
11147 if (isFinite(length)) {
11148 length = length >>> 0
11149 if (encoding === undefined) encoding = 'utf8'
11150 } else {
11151 encoding = length
11152 length = undefined
11153 }
11154 } else {
11155 throw new Error(
11156 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
11157 )
11158 }
11159
11160 var remaining = this.length - offset
11161 if (length === undefined || length > remaining) length = remaining
11162
11163 if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
11164 throw new RangeError('Attempt to write outside buffer bounds')
11165 }
11166
11167 if (!encoding) encoding = 'utf8'
11168
11169 var loweredCase = false
11170 for (;;) {
11171 switch (encoding) {
11172 case 'hex':
11173 return hexWrite(this, string, offset, length)
11174
11175 case 'utf8':
11176 case 'utf-8':
11177 return utf8Write(this, string, offset, length)
11178
11179 case 'ascii':
11180 return asciiWrite(this, string, offset, length)
11181
11182 case 'latin1':
11183 case 'binary':
11184 return latin1Write(this, string, offset, length)
11185
11186 case 'base64':
11187 // Warning: maxLength not taken into account in base64Write
11188 return base64Write(this, string, offset, length)
11189
11190 case 'ucs2':
11191 case 'ucs-2':
11192 case 'utf16le':
11193 case 'utf-16le':
11194 return ucs2Write(this, string, offset, length)
11195
11196 default:
11197 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
11198 encoding = ('' + encoding).toLowerCase()
11199 loweredCase = true
11200 }
11201 }
11202}
11203
11204Buffer.prototype.toJSON = function toJSON () {
11205 return {
11206 type: 'Buffer',
11207 data: Array.prototype.slice.call(this._arr || this, 0)
11208 }
11209}
11210
11211function base64Slice (buf, start, end) {
11212 if (start === 0 && end === buf.length) {
11213 return base64.fromByteArray(buf)
11214 } else {
11215 return base64.fromByteArray(buf.slice(start, end))
11216 }
11217}
11218
11219function utf8Slice (buf, start, end) {
11220 end = Math.min(buf.length, end)
11221 var res = []
11222
11223 var i = start
11224 while (i < end) {
11225 var firstByte = buf[i]
11226 var codePoint = null
11227 var bytesPerSequence = (firstByte > 0xEF) ? 4
11228 : (firstByte > 0xDF) ? 3
11229 : (firstByte > 0xBF) ? 2
11230 : 1
11231
11232 if (i + bytesPerSequence <= end) {
11233 var secondByte, thirdByte, fourthByte, tempCodePoint
11234
11235 switch (bytesPerSequence) {
11236 case 1:
11237 if (firstByte < 0x80) {
11238 codePoint = firstByte
11239 }
11240 break
11241 case 2:
11242 secondByte = buf[i + 1]
11243 if ((secondByte & 0xC0) === 0x80) {
11244 tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
11245 if (tempCodePoint > 0x7F) {
11246 codePoint = tempCodePoint
11247 }
11248 }
11249 break
11250 case 3:
11251 secondByte = buf[i + 1]
11252 thirdByte = buf[i + 2]
11253 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
11254 tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
11255 if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
11256 codePoint = tempCodePoint
11257 }
11258 }
11259 break
11260 case 4:
11261 secondByte = buf[i + 1]
11262 thirdByte = buf[i + 2]
11263 fourthByte = buf[i + 3]
11264 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
11265 tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
11266 if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
11267 codePoint = tempCodePoint
11268 }
11269 }
11270 }
11271 }
11272
11273 if (codePoint === null) {
11274 // we did not generate a valid codePoint so insert a
11275 // replacement char (U+FFFD) and advance only 1 byte
11276 codePoint = 0xFFFD
11277 bytesPerSequence = 1
11278 } else if (codePoint > 0xFFFF) {
11279 // encode to utf16 (surrogate pair dance)
11280 codePoint -= 0x10000
11281 res.push(codePoint >>> 10 & 0x3FF | 0xD800)
11282 codePoint = 0xDC00 | codePoint & 0x3FF
11283 }
11284
11285 res.push(codePoint)
11286 i += bytesPerSequence
11287 }
11288
11289 return decodeCodePointsArray(res)
11290}
11291
11292// Based on http://stackoverflow.com/a/22747272/680742, the browser with
11293// the lowest limit is Chrome, with 0x10000 args.
11294// We go 1 magnitude less, for safety
11295var MAX_ARGUMENTS_LENGTH = 0x1000
11296
11297function decodeCodePointsArray (codePoints) {
11298 var len = codePoints.length
11299 if (len <= MAX_ARGUMENTS_LENGTH) {
11300 return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
11301 }
11302
11303 // Decode in chunks to avoid "call stack size exceeded".
11304 var res = ''
11305 var i = 0
11306 while (i < len) {
11307 res += String.fromCharCode.apply(
11308 String,
11309 codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
11310 )
11311 }
11312 return res
11313}
11314
11315function asciiSlice (buf, start, end) {
11316 var ret = ''
11317 end = Math.min(buf.length, end)
11318
11319 for (var i = start; i < end; ++i) {
11320 ret += String.fromCharCode(buf[i] & 0x7F)
11321 }
11322 return ret
11323}
11324
11325function latin1Slice (buf, start, end) {
11326 var ret = ''
11327 end = Math.min(buf.length, end)
11328
11329 for (var i = start; i < end; ++i) {
11330 ret += String.fromCharCode(buf[i])
11331 }
11332 return ret
11333}
11334
11335function hexSlice (buf, start, end) {
11336 var len = buf.length
11337
11338 if (!start || start < 0) start = 0
11339 if (!end || end < 0 || end > len) end = len
11340
11341 var out = ''
11342 for (var i = start; i < end; ++i) {
11343 out += toHex(buf[i])
11344 }
11345 return out
11346}
11347
11348function utf16leSlice (buf, start, end) {
11349 var bytes = buf.slice(start, end)
11350 var res = ''
11351 for (var i = 0; i < bytes.length; i += 2) {
11352 res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
11353 }
11354 return res
11355}
11356
11357Buffer.prototype.slice = function slice (start, end) {
11358 var len = this.length
11359 start = ~~start
11360 end = end === undefined ? len : ~~end
11361
11362 if (start < 0) {
11363 start += len
11364 if (start < 0) start = 0
11365 } else if (start > len) {
11366 start = len
11367 }
11368
11369 if (end < 0) {
11370 end += len
11371 if (end < 0) end = 0
11372 } else if (end > len) {
11373 end = len
11374 }
11375
11376 if (end < start) end = start
11377
11378 var newBuf = this.subarray(start, end)
11379 // Return an augmented `Uint8Array` instance
11380 newBuf.__proto__ = Buffer.prototype
11381 return newBuf
11382}
11383
11384/*
11385 * Need to make sure that buffer isn't trying to write out of bounds.
11386 */
11387function checkOffset (offset, ext, length) {
11388 if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
11389 if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
11390}
11391
11392Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
11393 offset = offset >>> 0
11394 byteLength = byteLength >>> 0
11395 if (!noAssert) checkOffset(offset, byteLength, this.length)
11396
11397 var val = this[offset]
11398 var mul = 1
11399 var i = 0
11400 while (++i < byteLength && (mul *= 0x100)) {
11401 val += this[offset + i] * mul
11402 }
11403
11404 return val
11405}
11406
11407Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
11408 offset = offset >>> 0
11409 byteLength = byteLength >>> 0
11410 if (!noAssert) {
11411 checkOffset(offset, byteLength, this.length)
11412 }
11413
11414 var val = this[offset + --byteLength]
11415 var mul = 1
11416 while (byteLength > 0 && (mul *= 0x100)) {
11417 val += this[offset + --byteLength] * mul
11418 }
11419
11420 return val
11421}
11422
11423Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
11424 offset = offset >>> 0
11425 if (!noAssert) checkOffset(offset, 1, this.length)
11426 return this[offset]
11427}
11428
11429Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
11430 offset = offset >>> 0
11431 if (!noAssert) checkOffset(offset, 2, this.length)
11432 return this[offset] | (this[offset + 1] << 8)
11433}
11434
11435Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
11436 offset = offset >>> 0
11437 if (!noAssert) checkOffset(offset, 2, this.length)
11438 return (this[offset] << 8) | this[offset + 1]
11439}
11440
11441Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
11442 offset = offset >>> 0
11443 if (!noAssert) checkOffset(offset, 4, this.length)
11444
11445 return ((this[offset]) |
11446 (this[offset + 1] << 8) |
11447 (this[offset + 2] << 16)) +
11448 (this[offset + 3] * 0x1000000)
11449}
11450
11451Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
11452 offset = offset >>> 0
11453 if (!noAssert) checkOffset(offset, 4, this.length)
11454
11455 return (this[offset] * 0x1000000) +
11456 ((this[offset + 1] << 16) |
11457 (this[offset + 2] << 8) |
11458 this[offset + 3])
11459}
11460
11461Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
11462 offset = offset >>> 0
11463 byteLength = byteLength >>> 0
11464 if (!noAssert) checkOffset(offset, byteLength, this.length)
11465
11466 var val = this[offset]
11467 var mul = 1
11468 var i = 0
11469 while (++i < byteLength && (mul *= 0x100)) {
11470 val += this[offset + i] * mul
11471 }
11472 mul *= 0x80
11473
11474 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
11475
11476 return val
11477}
11478
11479Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
11480 offset = offset >>> 0
11481 byteLength = byteLength >>> 0
11482 if (!noAssert) checkOffset(offset, byteLength, this.length)
11483
11484 var i = byteLength
11485 var mul = 1
11486 var val = this[offset + --i]
11487 while (i > 0 && (mul *= 0x100)) {
11488 val += this[offset + --i] * mul
11489 }
11490 mul *= 0x80
11491
11492 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
11493
11494 return val
11495}
11496
11497Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
11498 offset = offset >>> 0
11499 if (!noAssert) checkOffset(offset, 1, this.length)
11500 if (!(this[offset] & 0x80)) return (this[offset])
11501 return ((0xff - this[offset] + 1) * -1)
11502}
11503
11504Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
11505 offset = offset >>> 0
11506 if (!noAssert) checkOffset(offset, 2, this.length)
11507 var val = this[offset] | (this[offset + 1] << 8)
11508 return (val & 0x8000) ? val | 0xFFFF0000 : val
11509}
11510
11511Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
11512 offset = offset >>> 0
11513 if (!noAssert) checkOffset(offset, 2, this.length)
11514 var val = this[offset + 1] | (this[offset] << 8)
11515 return (val & 0x8000) ? val | 0xFFFF0000 : val
11516}
11517
11518Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
11519 offset = offset >>> 0
11520 if (!noAssert) checkOffset(offset, 4, this.length)
11521
11522 return (this[offset]) |
11523 (this[offset + 1] << 8) |
11524 (this[offset + 2] << 16) |
11525 (this[offset + 3] << 24)
11526}
11527
11528Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
11529 offset = offset >>> 0
11530 if (!noAssert) checkOffset(offset, 4, this.length)
11531
11532 return (this[offset] << 24) |
11533 (this[offset + 1] << 16) |
11534 (this[offset + 2] << 8) |
11535 (this[offset + 3])
11536}
11537
11538Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
11539 offset = offset >>> 0
11540 if (!noAssert) checkOffset(offset, 4, this.length)
11541 return ieee754.read(this, offset, true, 23, 4)
11542}
11543
11544Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
11545 offset = offset >>> 0
11546 if (!noAssert) checkOffset(offset, 4, this.length)
11547 return ieee754.read(this, offset, false, 23, 4)
11548}
11549
11550Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
11551 offset = offset >>> 0
11552 if (!noAssert) checkOffset(offset, 8, this.length)
11553 return ieee754.read(this, offset, true, 52, 8)
11554}
11555
11556Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
11557 offset = offset >>> 0
11558 if (!noAssert) checkOffset(offset, 8, this.length)
11559 return ieee754.read(this, offset, false, 52, 8)
11560}
11561
11562function checkInt (buf, value, offset, ext, max, min) {
11563 if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
11564 if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
11565 if (offset + ext > buf.length) throw new RangeError('Index out of range')
11566}
11567
11568Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
11569 value = +value
11570 offset = offset >>> 0
11571 byteLength = byteLength >>> 0
11572 if (!noAssert) {
11573 var maxBytes = Math.pow(2, 8 * byteLength) - 1
11574 checkInt(this, value, offset, byteLength, maxBytes, 0)
11575 }
11576
11577 var mul = 1
11578 var i = 0
11579 this[offset] = value & 0xFF
11580 while (++i < byteLength && (mul *= 0x100)) {
11581 this[offset + i] = (value / mul) & 0xFF
11582 }
11583
11584 return offset + byteLength
11585}
11586
11587Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
11588 value = +value
11589 offset = offset >>> 0
11590 byteLength = byteLength >>> 0
11591 if (!noAssert) {
11592 var maxBytes = Math.pow(2, 8 * byteLength) - 1
11593 checkInt(this, value, offset, byteLength, maxBytes, 0)
11594 }
11595
11596 var i = byteLength - 1
11597 var mul = 1
11598 this[offset + i] = value & 0xFF
11599 while (--i >= 0 && (mul *= 0x100)) {
11600 this[offset + i] = (value / mul) & 0xFF
11601 }
11602
11603 return offset + byteLength
11604}
11605
11606Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
11607 value = +value
11608 offset = offset >>> 0
11609 if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
11610 this[offset] = (value & 0xff)
11611 return offset + 1
11612}
11613
11614Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
11615 value = +value
11616 offset = offset >>> 0
11617 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
11618 this[offset] = (value & 0xff)
11619 this[offset + 1] = (value >>> 8)
11620 return offset + 2
11621}
11622
11623Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
11624 value = +value
11625 offset = offset >>> 0
11626 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
11627 this[offset] = (value >>> 8)
11628 this[offset + 1] = (value & 0xff)
11629 return offset + 2
11630}
11631
11632Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
11633 value = +value
11634 offset = offset >>> 0
11635 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
11636 this[offset + 3] = (value >>> 24)
11637 this[offset + 2] = (value >>> 16)
11638 this[offset + 1] = (value >>> 8)
11639 this[offset] = (value & 0xff)
11640 return offset + 4
11641}
11642
11643Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
11644 value = +value
11645 offset = offset >>> 0
11646 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
11647 this[offset] = (value >>> 24)
11648 this[offset + 1] = (value >>> 16)
11649 this[offset + 2] = (value >>> 8)
11650 this[offset + 3] = (value & 0xff)
11651 return offset + 4
11652}
11653
11654Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
11655 value = +value
11656 offset = offset >>> 0
11657 if (!noAssert) {
11658 var limit = Math.pow(2, (8 * byteLength) - 1)
11659
11660 checkInt(this, value, offset, byteLength, limit - 1, -limit)
11661 }
11662
11663 var i = 0
11664 var mul = 1
11665 var sub = 0
11666 this[offset] = value & 0xFF
11667 while (++i < byteLength && (mul *= 0x100)) {
11668 if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
11669 sub = 1
11670 }
11671 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
11672 }
11673
11674 return offset + byteLength
11675}
11676
11677Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
11678 value = +value
11679 offset = offset >>> 0
11680 if (!noAssert) {
11681 var limit = Math.pow(2, (8 * byteLength) - 1)
11682
11683 checkInt(this, value, offset, byteLength, limit - 1, -limit)
11684 }
11685
11686 var i = byteLength - 1
11687 var mul = 1
11688 var sub = 0
11689 this[offset + i] = value & 0xFF
11690 while (--i >= 0 && (mul *= 0x100)) {
11691 if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
11692 sub = 1
11693 }
11694 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
11695 }
11696
11697 return offset + byteLength
11698}
11699
11700Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
11701 value = +value
11702 offset = offset >>> 0
11703 if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
11704 if (value < 0) value = 0xff + value + 1
11705 this[offset] = (value & 0xff)
11706 return offset + 1
11707}
11708
11709Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
11710 value = +value
11711 offset = offset >>> 0
11712 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
11713 this[offset] = (value & 0xff)
11714 this[offset + 1] = (value >>> 8)
11715 return offset + 2
11716}
11717
11718Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
11719 value = +value
11720 offset = offset >>> 0
11721 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
11722 this[offset] = (value >>> 8)
11723 this[offset + 1] = (value & 0xff)
11724 return offset + 2
11725}
11726
11727Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
11728 value = +value
11729 offset = offset >>> 0
11730 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
11731 this[offset] = (value & 0xff)
11732 this[offset + 1] = (value >>> 8)
11733 this[offset + 2] = (value >>> 16)
11734 this[offset + 3] = (value >>> 24)
11735 return offset + 4
11736}
11737
11738Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
11739 value = +value
11740 offset = offset >>> 0
11741 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
11742 if (value < 0) value = 0xffffffff + value + 1
11743 this[offset] = (value >>> 24)
11744 this[offset + 1] = (value >>> 16)
11745 this[offset + 2] = (value >>> 8)
11746 this[offset + 3] = (value & 0xff)
11747 return offset + 4
11748}
11749
11750function checkIEEE754 (buf, value, offset, ext, max, min) {
11751 if (offset + ext > buf.length) throw new RangeError('Index out of range')
11752 if (offset < 0) throw new RangeError('Index out of range')
11753}
11754
11755function writeFloat (buf, value, offset, littleEndian, noAssert) {
11756 value = +value
11757 offset = offset >>> 0
11758 if (!noAssert) {
11759 checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
11760 }
11761 ieee754.write(buf, value, offset, littleEndian, 23, 4)
11762 return offset + 4
11763}
11764
11765Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
11766 return writeFloat(this, value, offset, true, noAssert)
11767}
11768
11769Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
11770 return writeFloat(this, value, offset, false, noAssert)
11771}
11772
11773function writeDouble (buf, value, offset, littleEndian, noAssert) {
11774 value = +value
11775 offset = offset >>> 0
11776 if (!noAssert) {
11777 checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
11778 }
11779 ieee754.write(buf, value, offset, littleEndian, 52, 8)
11780 return offset + 8
11781}
11782
11783Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
11784 return writeDouble(this, value, offset, true, noAssert)
11785}
11786
11787Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
11788 return writeDouble(this, value, offset, false, noAssert)
11789}
11790
11791// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
11792Buffer.prototype.copy = function copy (target, targetStart, start, end) {
11793 if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
11794 if (!start) start = 0
11795 if (!end && end !== 0) end = this.length
11796 if (targetStart >= target.length) targetStart = target.length
11797 if (!targetStart) targetStart = 0
11798 if (end > 0 && end < start) end = start
11799
11800 // Copy 0 bytes; we're done
11801 if (end === start) return 0
11802 if (target.length === 0 || this.length === 0) return 0
11803
11804 // Fatal error conditions
11805 if (targetStart < 0) {
11806 throw new RangeError('targetStart out of bounds')
11807 }
11808 if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
11809 if (end < 0) throw new RangeError('sourceEnd out of bounds')
11810
11811 // Are we oob?
11812 if (end > this.length) end = this.length
11813 if (target.length - targetStart < end - start) {
11814 end = target.length - targetStart + start
11815 }
11816
11817 var len = end - start
11818
11819 if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
11820 // Use built-in when available, missing from IE11
11821 this.copyWithin(targetStart, start, end)
11822 } else if (this === target && start < targetStart && targetStart < end) {
11823 // descending copy from end
11824 for (var i = len - 1; i >= 0; --i) {
11825 target[i + targetStart] = this[i + start]
11826 }
11827 } else {
11828 Uint8Array.prototype.set.call(
11829 target,
11830 this.subarray(start, end),
11831 targetStart
11832 )
11833 }
11834
11835 return len
11836}
11837
11838// Usage:
11839// buffer.fill(number[, offset[, end]])
11840// buffer.fill(buffer[, offset[, end]])
11841// buffer.fill(string[, offset[, end]][, encoding])
11842Buffer.prototype.fill = function fill (val, start, end, encoding) {
11843 // Handle string cases:
11844 if (typeof val === 'string') {
11845 if (typeof start === 'string') {
11846 encoding = start
11847 start = 0
11848 end = this.length
11849 } else if (typeof end === 'string') {
11850 encoding = end
11851 end = this.length
11852 }
11853 if (encoding !== undefined && typeof encoding !== 'string') {
11854 throw new TypeError('encoding must be a string')
11855 }
11856 if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
11857 throw new TypeError('Unknown encoding: ' + encoding)
11858 }
11859 if (val.length === 1) {
11860 var code = val.charCodeAt(0)
11861 if ((encoding === 'utf8' && code < 128) ||
11862 encoding === 'latin1') {
11863 // Fast path: If `val` fits into a single byte, use that numeric value.
11864 val = code
11865 }
11866 }
11867 } else if (typeof val === 'number') {
11868 val = val & 255
11869 }
11870
11871 // Invalid ranges are not set to a default, so can range check early.
11872 if (start < 0 || this.length < start || this.length < end) {
11873 throw new RangeError('Out of range index')
11874 }
11875
11876 if (end <= start) {
11877 return this
11878 }
11879
11880 start = start >>> 0
11881 end = end === undefined ? this.length : end >>> 0
11882
11883 if (!val) val = 0
11884
11885 var i
11886 if (typeof val === 'number') {
11887 for (i = start; i < end; ++i) {
11888 this[i] = val
11889 }
11890 } else {
11891 var bytes = Buffer.isBuffer(val)
11892 ? val
11893 : Buffer.from(val, encoding)
11894 var len = bytes.length
11895 if (len === 0) {
11896 throw new TypeError('The value "' + val +
11897 '" is invalid for argument "value"')
11898 }
11899 for (i = 0; i < end - start; ++i) {
11900 this[i + start] = bytes[i % len]
11901 }
11902 }
11903
11904 return this
11905}
11906
11907// HELPER FUNCTIONS
11908// ================
11909
11910var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
11911
11912function base64clean (str) {
11913 // Node takes equal signs as end of the Base64 encoding
11914 str = str.split('=')[0]
11915 // Node strips out invalid characters like \n and \t from the string, base64-js does not
11916 str = str.trim().replace(INVALID_BASE64_RE, '')
11917 // Node converts strings with length < 2 to ''
11918 if (str.length < 2) return ''
11919 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
11920 while (str.length % 4 !== 0) {
11921 str = str + '='
11922 }
11923 return str
11924}
11925
11926function toHex (n) {
11927 if (n < 16) return '0' + n.toString(16)
11928 return n.toString(16)
11929}
11930
11931function utf8ToBytes (string, units) {
11932 units = units || Infinity
11933 var codePoint
11934 var length = string.length
11935 var leadSurrogate = null
11936 var bytes = []
11937
11938 for (var i = 0; i < length; ++i) {
11939 codePoint = string.charCodeAt(i)
11940
11941 // is surrogate component
11942 if (codePoint > 0xD7FF && codePoint < 0xE000) {
11943 // last char was a lead
11944 if (!leadSurrogate) {
11945 // no lead yet
11946 if (codePoint > 0xDBFF) {
11947 // unexpected trail
11948 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
11949 continue
11950 } else if (i + 1 === length) {
11951 // unpaired lead
11952 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
11953 continue
11954 }
11955
11956 // valid lead
11957 leadSurrogate = codePoint
11958
11959 continue
11960 }
11961
11962 // 2 leads in a row
11963 if (codePoint < 0xDC00) {
11964 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
11965 leadSurrogate = codePoint
11966 continue
11967 }
11968
11969 // valid surrogate pair
11970 codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
11971 } else if (leadSurrogate) {
11972 // valid bmp char, but last char was a lead
11973 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
11974 }
11975
11976 leadSurrogate = null
11977
11978 // encode utf8
11979 if (codePoint < 0x80) {
11980 if ((units -= 1) < 0) break
11981 bytes.push(codePoint)
11982 } else if (codePoint < 0x800) {
11983 if ((units -= 2) < 0) break
11984 bytes.push(
11985 codePoint >> 0x6 | 0xC0,
11986 codePoint & 0x3F | 0x80
11987 )
11988 } else if (codePoint < 0x10000) {
11989 if ((units -= 3) < 0) break
11990 bytes.push(
11991 codePoint >> 0xC | 0xE0,
11992 codePoint >> 0x6 & 0x3F | 0x80,
11993 codePoint & 0x3F | 0x80
11994 )
11995 } else if (codePoint < 0x110000) {
11996 if ((units -= 4) < 0) break
11997 bytes.push(
11998 codePoint >> 0x12 | 0xF0,
11999 codePoint >> 0xC & 0x3F | 0x80,
12000 codePoint >> 0x6 & 0x3F | 0x80,
12001 codePoint & 0x3F | 0x80
12002 )
12003 } else {
12004 throw new Error('Invalid code point')
12005 }
12006 }
12007
12008 return bytes
12009}
12010
12011function asciiToBytes (str) {
12012 var byteArray = []
12013 for (var i = 0; i < str.length; ++i) {
12014 // Node's code seems to be doing this and not & 0x7F..
12015 byteArray.push(str.charCodeAt(i) & 0xFF)
12016 }
12017 return byteArray
12018}
12019
12020function utf16leToBytes (str, units) {
12021 var c, hi, lo
12022 var byteArray = []
12023 for (var i = 0; i < str.length; ++i) {
12024 if ((units -= 2) < 0) break
12025
12026 c = str.charCodeAt(i)
12027 hi = c >> 8
12028 lo = c % 256
12029 byteArray.push(lo)
12030 byteArray.push(hi)
12031 }
12032
12033 return byteArray
12034}
12035
12036function base64ToBytes (str) {
12037 return base64.toByteArray(base64clean(str))
12038}
12039
12040function blitBuffer (src, dst, offset, length) {
12041 for (var i = 0; i < length; ++i) {
12042 if ((i + offset >= dst.length) || (i >= src.length)) break
12043 dst[i + offset] = src[i]
12044 }
12045 return i
12046}
12047
12048// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
12049// the `instanceof` check but they should be treated as of that type.
12050// See: https://github.com/feross/buffer/issues/166
12051function isInstance (obj, type) {
12052 return obj instanceof type ||
12053 (obj != null && obj.constructor != null && obj.constructor.name != null &&
12054 obj.constructor.name === type.name)
12055}
12056function numberIsNaN (obj) {
12057 // For IE11 support
12058 return obj !== obj // eslint-disable-line no-self-compare
12059}
12060
12061},{"base64-js":16,"ieee754":118}],51:[function(require,module,exports){
12062var Buffer = require('safe-buffer').Buffer
12063var Transform = require('stream').Transform
12064var StringDecoder = require('string_decoder').StringDecoder
12065var inherits = require('inherits')
12066
12067function CipherBase (hashMode) {
12068 Transform.call(this)
12069 this.hashMode = typeof hashMode === 'string'
12070 if (this.hashMode) {
12071 this[hashMode] = this._finalOrDigest
12072 } else {
12073 this.final = this._finalOrDigest
12074 }
12075 if (this._final) {
12076 this.__final = this._final
12077 this._final = null
12078 }
12079 this._decoder = null
12080 this._encoding = null
12081}
12082inherits(CipherBase, Transform)
12083
12084CipherBase.prototype.update = function (data, inputEnc, outputEnc) {
12085 if (typeof data === 'string') {
12086 data = Buffer.from(data, inputEnc)
12087 }
12088
12089 var outData = this._update(data)
12090 if (this.hashMode) return this
12091
12092 if (outputEnc) {
12093 outData = this._toString(outData, outputEnc)
12094 }
12095
12096 return outData
12097}
12098
12099CipherBase.prototype.setAutoPadding = function () {}
12100CipherBase.prototype.getAuthTag = function () {
12101 throw new Error('trying to get auth tag in unsupported state')
12102}
12103
12104CipherBase.prototype.setAuthTag = function () {
12105 throw new Error('trying to set auth tag in unsupported state')
12106}
12107
12108CipherBase.prototype.setAAD = function () {
12109 throw new Error('trying to set aad in unsupported state')
12110}
12111
12112CipherBase.prototype._transform = function (data, _, next) {
12113 var err
12114 try {
12115 if (this.hashMode) {
12116 this._update(data)
12117 } else {
12118 this.push(this._update(data))
12119 }
12120 } catch (e) {
12121 err = e
12122 } finally {
12123 next(err)
12124 }
12125}
12126CipherBase.prototype._flush = function (done) {
12127 var err
12128 try {
12129 this.push(this.__final())
12130 } catch (e) {
12131 err = e
12132 }
12133
12134 done(err)
12135}
12136CipherBase.prototype._finalOrDigest = function (outputEnc) {
12137 var outData = this.__final() || Buffer.alloc(0)
12138 if (outputEnc) {
12139 outData = this._toString(outData, outputEnc, true)
12140 }
12141 return outData
12142}
12143
12144CipherBase.prototype._toString = function (value, enc, fin) {
12145 if (!this._decoder) {
12146 this._decoder = new StringDecoder(enc)
12147 this._encoding = enc
12148 }
12149
12150 if (this._encoding !== enc) throw new Error('can\'t switch encodings')
12151
12152 var out = this._decoder.write(value)
12153 if (fin) {
12154 out += this._decoder.end()
12155 }
12156
12157 return out
12158}
12159
12160module.exports = CipherBase
12161
12162},{"inherits":119,"safe-buffer":398,"stream":437,"string_decoder":438}],52:[function(require,module,exports){
12163(function (Buffer){
12164// Copyright Joyent, Inc. and other Node contributors.
12165//
12166// Permission is hereby granted, free of charge, to any person obtaining a
12167// copy of this software and associated documentation files (the
12168// "Software"), to deal in the Software without restriction, including
12169// without limitation the rights to use, copy, modify, merge, publish,
12170// distribute, sublicense, and/or sell copies of the Software, and to permit
12171// persons to whom the Software is furnished to do so, subject to the
12172// following conditions:
12173//
12174// The above copyright notice and this permission notice shall be included
12175// in all copies or substantial portions of the Software.
12176//
12177// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
12178// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
12179// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
12180// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
12181// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
12182// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
12183// USE OR OTHER DEALINGS IN THE SOFTWARE.
12184
12185// NOTE: These type checking functions intentionally don't use `instanceof`
12186// because it is fragile and can be easily faked with `Object.create()`.
12187
12188function isArray(arg) {
12189 if (Array.isArray) {
12190 return Array.isArray(arg);
12191 }
12192 return objectToString(arg) === '[object Array]';
12193}
12194exports.isArray = isArray;
12195
12196function isBoolean(arg) {
12197 return typeof arg === 'boolean';
12198}
12199exports.isBoolean = isBoolean;
12200
12201function isNull(arg) {
12202 return arg === null;
12203}
12204exports.isNull = isNull;
12205
12206function isNullOrUndefined(arg) {
12207 return arg == null;
12208}
12209exports.isNullOrUndefined = isNullOrUndefined;
12210
12211function isNumber(arg) {
12212 return typeof arg === 'number';
12213}
12214exports.isNumber = isNumber;
12215
12216function isString(arg) {
12217 return typeof arg === 'string';
12218}
12219exports.isString = isString;
12220
12221function isSymbol(arg) {
12222 return typeof arg === 'symbol';
12223}
12224exports.isSymbol = isSymbol;
12225
12226function isUndefined(arg) {
12227 return arg === void 0;
12228}
12229exports.isUndefined = isUndefined;
12230
12231function isRegExp(re) {
12232 return objectToString(re) === '[object RegExp]';
12233}
12234exports.isRegExp = isRegExp;
12235
12236function isObject(arg) {
12237 return typeof arg === 'object' && arg !== null;
12238}
12239exports.isObject = isObject;
12240
12241function isDate(d) {
12242 return objectToString(d) === '[object Date]';
12243}
12244exports.isDate = isDate;
12245
12246function isError(e) {
12247 return (objectToString(e) === '[object Error]' || e instanceof Error);
12248}
12249exports.isError = isError;
12250
12251function isFunction(arg) {
12252 return typeof arg === 'function';
12253}
12254exports.isFunction = isFunction;
12255
12256function isPrimitive(arg) {
12257 return arg === null ||
12258 typeof arg === 'boolean' ||
12259 typeof arg === 'number' ||
12260 typeof arg === 'string' ||
12261 typeof arg === 'symbol' || // ES6 symbol
12262 typeof arg === 'undefined';
12263}
12264exports.isPrimitive = isPrimitive;
12265
12266exports.isBuffer = Buffer.isBuffer;
12267
12268function objectToString(o) {
12269 return Object.prototype.toString.call(o);
12270}
12271
12272}).call(this,{"isBuffer":require("../../is-buffer/index.js")})
12273},{"../../is-buffer/index.js":120}],53:[function(require,module,exports){
12274'use strict';
12275
12276var _buffer = require('buffer');
12277
12278var _create_buffer = require('./create_buffer');
12279
12280var _create_buffer2 = _interopRequireDefault(_create_buffer);
12281
12282var _define_crc = require('./define_crc');
12283
12284var _define_crc2 = _interopRequireDefault(_define_crc);
12285
12286function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12287
12288module.exports = (0, _define_crc2.default)('crc1', function (buf, previous) {
12289 if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf);
12290
12291 var crc = ~~previous;
12292 var accum = 0;
12293
12294 for (var index = 0; index < buf.length; index++) {
12295 var byte = buf[index];
12296 accum += byte;
12297 }
12298
12299 crc += accum % 256;
12300 return crc % 256;
12301});
12302},{"./create_buffer":64,"./define_crc":65,"buffer":50}],54:[function(require,module,exports){
12303'use strict';
12304
12305var _buffer = require('buffer');
12306
12307var _create_buffer = require('./create_buffer');
12308
12309var _create_buffer2 = _interopRequireDefault(_create_buffer);
12310
12311var _define_crc = require('./define_crc');
12312
12313var _define_crc2 = _interopRequireDefault(_define_crc);
12314
12315function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12316
12317// Generated by `./pycrc.py --algorithm=table-driven --model=crc-16 --generate=c`
12318var TABLE = [0x0000, 0xc0c1, 0xc181, 0x0140, 0xc301, 0x03c0, 0x0280, 0xc241, 0xc601, 0x06c0, 0x0780, 0xc741, 0x0500, 0xc5c1, 0xc481, 0x0440, 0xcc01, 0x0cc0, 0x0d80, 0xcd41, 0x0f00, 0xcfc1, 0xce81, 0x0e40, 0x0a00, 0xcac1, 0xcb81, 0x0b40, 0xc901, 0x09c0, 0x0880, 0xc841, 0xd801, 0x18c0, 0x1980, 0xd941, 0x1b00, 0xdbc1, 0xda81, 0x1a40, 0x1e00, 0xdec1, 0xdf81, 0x1f40, 0xdd01, 0x1dc0, 0x1c80, 0xdc41, 0x1400, 0xd4c1, 0xd581, 0x1540, 0xd701, 0x17c0, 0x1680, 0xd641, 0xd201, 0x12c0, 0x1380, 0xd341, 0x1100, 0xd1c1, 0xd081, 0x1040, 0xf001, 0x30c0, 0x3180, 0xf141, 0x3300, 0xf3c1, 0xf281, 0x3240, 0x3600, 0xf6c1, 0xf781, 0x3740, 0xf501, 0x35c0, 0x3480, 0xf441, 0x3c00, 0xfcc1, 0xfd81, 0x3d40, 0xff01, 0x3fc0, 0x3e80, 0xfe41, 0xfa01, 0x3ac0, 0x3b80, 0xfb41, 0x3900, 0xf9c1, 0xf881, 0x3840, 0x2800, 0xe8c1, 0xe981, 0x2940, 0xeb01, 0x2bc0, 0x2a80, 0xea41, 0xee01, 0x2ec0, 0x2f80, 0xef41, 0x2d00, 0xedc1, 0xec81, 0x2c40, 0xe401, 0x24c0, 0x2580, 0xe541, 0x2700, 0xe7c1, 0xe681, 0x2640, 0x2200, 0xe2c1, 0xe381, 0x2340, 0xe101, 0x21c0, 0x2080, 0xe041, 0xa001, 0x60c0, 0x6180, 0xa141, 0x6300, 0xa3c1, 0xa281, 0x6240, 0x6600, 0xa6c1, 0xa781, 0x6740, 0xa501, 0x65c0, 0x6480, 0xa441, 0x6c00, 0xacc1, 0xad81, 0x6d40, 0xaf01, 0x6fc0, 0x6e80, 0xae41, 0xaa01, 0x6ac0, 0x6b80, 0xab41, 0x6900, 0xa9c1, 0xa881, 0x6840, 0x7800, 0xb8c1, 0xb981, 0x7940, 0xbb01, 0x7bc0, 0x7a80, 0xba41, 0xbe01, 0x7ec0, 0x7f80, 0xbf41, 0x7d00, 0xbdc1, 0xbc81, 0x7c40, 0xb401, 0x74c0, 0x7580, 0xb541, 0x7700, 0xb7c1, 0xb681, 0x7640, 0x7200, 0xb2c1, 0xb381, 0x7340, 0xb101, 0x71c0, 0x7080, 0xb041, 0x5000, 0x90c1, 0x9181, 0x5140, 0x9301, 0x53c0, 0x5280, 0x9241, 0x9601, 0x56c0, 0x5780, 0x9741, 0x5500, 0x95c1, 0x9481, 0x5440, 0x9c01, 0x5cc0, 0x5d80, 0x9d41, 0x5f00, 0x9fc1, 0x9e81, 0x5e40, 0x5a00, 0x9ac1, 0x9b81, 0x5b40, 0x9901, 0x59c0, 0x5880, 0x9841, 0x8801, 0x48c0, 0x4980, 0x8941, 0x4b00, 0x8bc1, 0x8a81, 0x4a40, 0x4e00, 0x8ec1, 0x8f81, 0x4f40, 0x8d01, 0x4dc0, 0x4c80, 0x8c41, 0x4400, 0x84c1, 0x8581, 0x4540, 0x8701, 0x47c0, 0x4680, 0x8641, 0x8201, 0x42c0, 0x4380, 0x8341, 0x4100, 0x81c1, 0x8081, 0x4040];
12319
12320if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE);
12321
12322module.exports = (0, _define_crc2.default)('crc-16', function (buf, previous) {
12323 if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf);
12324
12325 var crc = ~~previous;
12326
12327 for (var index = 0; index < buf.length; index++) {
12328 var byte = buf[index];
12329 crc = (TABLE[(crc ^ byte) & 0xff] ^ crc >> 8) & 0xffff;
12330 }
12331
12332 return crc;
12333});
12334},{"./create_buffer":64,"./define_crc":65,"buffer":50}],55:[function(require,module,exports){
12335'use strict';
12336
12337var _buffer = require('buffer');
12338
12339var _create_buffer = require('./create_buffer');
12340
12341var _create_buffer2 = _interopRequireDefault(_create_buffer);
12342
12343var _define_crc = require('./define_crc');
12344
12345var _define_crc2 = _interopRequireDefault(_define_crc);
12346
12347function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12348
12349// Generated by `./pycrc.py --algorithm=table-driven --model=ccitt --generate=c`
12350var TABLE = [0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70, 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067, 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c, 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0];
12351
12352if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE);
12353
12354module.exports = (0, _define_crc2.default)('ccitt', function (buf, previous) {
12355 if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf);
12356
12357 var crc = typeof previous !== 'undefined' ? ~~previous : 0xffff;
12358
12359 for (var index = 0; index < buf.length; index++) {
12360 var byte = buf[index];
12361 crc = (TABLE[(crc >> 8 ^ byte) & 0xff] ^ crc << 8) & 0xffff;
12362 }
12363
12364 return crc;
12365});
12366},{"./create_buffer":64,"./define_crc":65,"buffer":50}],56:[function(require,module,exports){
12367'use strict';
12368
12369var _buffer = require('buffer');
12370
12371var _create_buffer = require('./create_buffer');
12372
12373var _create_buffer2 = _interopRequireDefault(_create_buffer);
12374
12375var _define_crc = require('./define_crc');
12376
12377var _define_crc2 = _interopRequireDefault(_define_crc);
12378
12379function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12380
12381// Generated by `./pycrc.py --algorithm=table-driven --model=kermit --generate=c`
12382var TABLE = [0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7, 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e, 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876, 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd, 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5, 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c, 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974, 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb, 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3, 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a, 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72, 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9, 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1, 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738, 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70, 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7, 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff, 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036, 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e, 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5, 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd, 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134, 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c, 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3, 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb, 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232, 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a, 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1, 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9, 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78];
12383
12384if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE);
12385
12386module.exports = (0, _define_crc2.default)('kermit', function (buf, previous) {
12387 if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf);
12388
12389 var crc = typeof previous !== 'undefined' ? ~~previous : 0x0000;
12390
12391 for (var index = 0; index < buf.length; index++) {
12392 var byte = buf[index];
12393 crc = (TABLE[(crc ^ byte) & 0xff] ^ crc >> 8) & 0xffff;
12394 }
12395
12396 return crc;
12397});
12398},{"./create_buffer":64,"./define_crc":65,"buffer":50}],57:[function(require,module,exports){
12399'use strict';
12400
12401var _buffer = require('buffer');
12402
12403var _create_buffer = require('./create_buffer');
12404
12405var _create_buffer2 = _interopRequireDefault(_create_buffer);
12406
12407var _define_crc = require('./define_crc');
12408
12409var _define_crc2 = _interopRequireDefault(_define_crc);
12410
12411function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12412
12413// Generated by `./pycrc.py --algorithm=table-driven --model=crc-16-modbus --generate=c`
12414var TABLE = [0x0000, 0xc0c1, 0xc181, 0x0140, 0xc301, 0x03c0, 0x0280, 0xc241, 0xc601, 0x06c0, 0x0780, 0xc741, 0x0500, 0xc5c1, 0xc481, 0x0440, 0xcc01, 0x0cc0, 0x0d80, 0xcd41, 0x0f00, 0xcfc1, 0xce81, 0x0e40, 0x0a00, 0xcac1, 0xcb81, 0x0b40, 0xc901, 0x09c0, 0x0880, 0xc841, 0xd801, 0x18c0, 0x1980, 0xd941, 0x1b00, 0xdbc1, 0xda81, 0x1a40, 0x1e00, 0xdec1, 0xdf81, 0x1f40, 0xdd01, 0x1dc0, 0x1c80, 0xdc41, 0x1400, 0xd4c1, 0xd581, 0x1540, 0xd701, 0x17c0, 0x1680, 0xd641, 0xd201, 0x12c0, 0x1380, 0xd341, 0x1100, 0xd1c1, 0xd081, 0x1040, 0xf001, 0x30c0, 0x3180, 0xf141, 0x3300, 0xf3c1, 0xf281, 0x3240, 0x3600, 0xf6c1, 0xf781, 0x3740, 0xf501, 0x35c0, 0x3480, 0xf441, 0x3c00, 0xfcc1, 0xfd81, 0x3d40, 0xff01, 0x3fc0, 0x3e80, 0xfe41, 0xfa01, 0x3ac0, 0x3b80, 0xfb41, 0x3900, 0xf9c1, 0xf881, 0x3840, 0x2800, 0xe8c1, 0xe981, 0x2940, 0xeb01, 0x2bc0, 0x2a80, 0xea41, 0xee01, 0x2ec0, 0x2f80, 0xef41, 0x2d00, 0xedc1, 0xec81, 0x2c40, 0xe401, 0x24c0, 0x2580, 0xe541, 0x2700, 0xe7c1, 0xe681, 0x2640, 0x2200, 0xe2c1, 0xe381, 0x2340, 0xe101, 0x21c0, 0x2080, 0xe041, 0xa001, 0x60c0, 0x6180, 0xa141, 0x6300, 0xa3c1, 0xa281, 0x6240, 0x6600, 0xa6c1, 0xa781, 0x6740, 0xa501, 0x65c0, 0x6480, 0xa441, 0x6c00, 0xacc1, 0xad81, 0x6d40, 0xaf01, 0x6fc0, 0x6e80, 0xae41, 0xaa01, 0x6ac0, 0x6b80, 0xab41, 0x6900, 0xa9c1, 0xa881, 0x6840, 0x7800, 0xb8c1, 0xb981, 0x7940, 0xbb01, 0x7bc0, 0x7a80, 0xba41, 0xbe01, 0x7ec0, 0x7f80, 0xbf41, 0x7d00, 0xbdc1, 0xbc81, 0x7c40, 0xb401, 0x74c0, 0x7580, 0xb541, 0x7700, 0xb7c1, 0xb681, 0x7640, 0x7200, 0xb2c1, 0xb381, 0x7340, 0xb101, 0x71c0, 0x7080, 0xb041, 0x5000, 0x90c1, 0x9181, 0x5140, 0x9301, 0x53c0, 0x5280, 0x9241, 0x9601, 0x56c0, 0x5780, 0x9741, 0x5500, 0x95c1, 0x9481, 0x5440, 0x9c01, 0x5cc0, 0x5d80, 0x9d41, 0x5f00, 0x9fc1, 0x9e81, 0x5e40, 0x5a00, 0x9ac1, 0x9b81, 0x5b40, 0x9901, 0x59c0, 0x5880, 0x9841, 0x8801, 0x48c0, 0x4980, 0x8941, 0x4b00, 0x8bc1, 0x8a81, 0x4a40, 0x4e00, 0x8ec1, 0x8f81, 0x4f40, 0x8d01, 0x4dc0, 0x4c80, 0x8c41, 0x4400, 0x84c1, 0x8581, 0x4540, 0x8701, 0x47c0, 0x4680, 0x8641, 0x8201, 0x42c0, 0x4380, 0x8341, 0x4100, 0x81c1, 0x8081, 0x4040];
12415
12416if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE);
12417
12418module.exports = (0, _define_crc2.default)('crc-16-modbus', function (buf, previous) {
12419 if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf);
12420
12421 var crc = typeof previous !== 'undefined' ? ~~previous : 0xffff;
12422
12423 for (var index = 0; index < buf.length; index++) {
12424 var byte = buf[index];
12425 crc = (TABLE[(crc ^ byte) & 0xff] ^ crc >> 8) & 0xffff;
12426 }
12427
12428 return crc;
12429});
12430},{"./create_buffer":64,"./define_crc":65,"buffer":50}],58:[function(require,module,exports){
12431'use strict';
12432
12433var _buffer = require('buffer');
12434
12435var _create_buffer = require('./create_buffer');
12436
12437var _create_buffer2 = _interopRequireDefault(_create_buffer);
12438
12439var _define_crc = require('./define_crc');
12440
12441var _define_crc2 = _interopRequireDefault(_define_crc);
12442
12443function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12444
12445module.exports = (0, _define_crc2.default)('xmodem', function (buf, previous) {
12446 if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf);
12447
12448 var crc = typeof previous !== 'undefined' ? ~~previous : 0x0;
12449
12450 for (var index = 0; index < buf.length; index++) {
12451 var byte = buf[index];
12452 var code = crc >>> 8 & 0xFF;
12453
12454 code ^= byte & 0xFF;
12455 code ^= code >>> 4;
12456 crc = crc << 8 & 0xFFFF;
12457 crc ^= code;
12458 code = code << 5 & 0xFFFF;
12459 crc ^= code;
12460 code = code << 7 & 0xFFFF;
12461 crc ^= code;
12462 }
12463
12464 return crc;
12465});
12466},{"./create_buffer":64,"./define_crc":65,"buffer":50}],59:[function(require,module,exports){
12467'use strict';
12468
12469var _buffer = require('buffer');
12470
12471var _create_buffer = require('./create_buffer');
12472
12473var _create_buffer2 = _interopRequireDefault(_create_buffer);
12474
12475var _define_crc = require('./define_crc');
12476
12477var _define_crc2 = _interopRequireDefault(_define_crc);
12478
12479function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12480
12481// Generated by `./pycrc.py --algorithm=table-drive --model=crc-24 --generate=c`
12482var TABLE = [0x000000, 0x864cfb, 0x8ad50d, 0x0c99f6, 0x93e6e1, 0x15aa1a, 0x1933ec, 0x9f7f17, 0xa18139, 0x27cdc2, 0x2b5434, 0xad18cf, 0x3267d8, 0xb42b23, 0xb8b2d5, 0x3efe2e, 0xc54e89, 0x430272, 0x4f9b84, 0xc9d77f, 0x56a868, 0xd0e493, 0xdc7d65, 0x5a319e, 0x64cfb0, 0xe2834b, 0xee1abd, 0x685646, 0xf72951, 0x7165aa, 0x7dfc5c, 0xfbb0a7, 0x0cd1e9, 0x8a9d12, 0x8604e4, 0x00481f, 0x9f3708, 0x197bf3, 0x15e205, 0x93aefe, 0xad50d0, 0x2b1c2b, 0x2785dd, 0xa1c926, 0x3eb631, 0xb8faca, 0xb4633c, 0x322fc7, 0xc99f60, 0x4fd39b, 0x434a6d, 0xc50696, 0x5a7981, 0xdc357a, 0xd0ac8c, 0x56e077, 0x681e59, 0xee52a2, 0xe2cb54, 0x6487af, 0xfbf8b8, 0x7db443, 0x712db5, 0xf7614e, 0x19a3d2, 0x9fef29, 0x9376df, 0x153a24, 0x8a4533, 0x0c09c8, 0x00903e, 0x86dcc5, 0xb822eb, 0x3e6e10, 0x32f7e6, 0xb4bb1d, 0x2bc40a, 0xad88f1, 0xa11107, 0x275dfc, 0xdced5b, 0x5aa1a0, 0x563856, 0xd074ad, 0x4f0bba, 0xc94741, 0xc5deb7, 0x43924c, 0x7d6c62, 0xfb2099, 0xf7b96f, 0x71f594, 0xee8a83, 0x68c678, 0x645f8e, 0xe21375, 0x15723b, 0x933ec0, 0x9fa736, 0x19ebcd, 0x8694da, 0x00d821, 0x0c41d7, 0x8a0d2c, 0xb4f302, 0x32bff9, 0x3e260f, 0xb86af4, 0x2715e3, 0xa15918, 0xadc0ee, 0x2b8c15, 0xd03cb2, 0x567049, 0x5ae9bf, 0xdca544, 0x43da53, 0xc596a8, 0xc90f5e, 0x4f43a5, 0x71bd8b, 0xf7f170, 0xfb6886, 0x7d247d, 0xe25b6a, 0x641791, 0x688e67, 0xeec29c, 0x3347a4, 0xb50b5f, 0xb992a9, 0x3fde52, 0xa0a145, 0x26edbe, 0x2a7448, 0xac38b3, 0x92c69d, 0x148a66, 0x181390, 0x9e5f6b, 0x01207c, 0x876c87, 0x8bf571, 0x0db98a, 0xf6092d, 0x7045d6, 0x7cdc20, 0xfa90db, 0x65efcc, 0xe3a337, 0xef3ac1, 0x69763a, 0x578814, 0xd1c4ef, 0xdd5d19, 0x5b11e2, 0xc46ef5, 0x42220e, 0x4ebbf8, 0xc8f703, 0x3f964d, 0xb9dab6, 0xb54340, 0x330fbb, 0xac70ac, 0x2a3c57, 0x26a5a1, 0xa0e95a, 0x9e1774, 0x185b8f, 0x14c279, 0x928e82, 0x0df195, 0x8bbd6e, 0x872498, 0x016863, 0xfad8c4, 0x7c943f, 0x700dc9, 0xf64132, 0x693e25, 0xef72de, 0xe3eb28, 0x65a7d3, 0x5b59fd, 0xdd1506, 0xd18cf0, 0x57c00b, 0xc8bf1c, 0x4ef3e7, 0x426a11, 0xc426ea, 0x2ae476, 0xaca88d, 0xa0317b, 0x267d80, 0xb90297, 0x3f4e6c, 0x33d79a, 0xb59b61, 0x8b654f, 0x0d29b4, 0x01b042, 0x87fcb9, 0x1883ae, 0x9ecf55, 0x9256a3, 0x141a58, 0xefaaff, 0x69e604, 0x657ff2, 0xe33309, 0x7c4c1e, 0xfa00e5, 0xf69913, 0x70d5e8, 0x4e2bc6, 0xc8673d, 0xc4fecb, 0x42b230, 0xddcd27, 0x5b81dc, 0x57182a, 0xd154d1, 0x26359f, 0xa07964, 0xace092, 0x2aac69, 0xb5d37e, 0x339f85, 0x3f0673, 0xb94a88, 0x87b4a6, 0x01f85d, 0x0d61ab, 0x8b2d50, 0x145247, 0x921ebc, 0x9e874a, 0x18cbb1, 0xe37b16, 0x6537ed, 0x69ae1b, 0xefe2e0, 0x709df7, 0xf6d10c, 0xfa48fa, 0x7c0401, 0x42fa2f, 0xc4b6d4, 0xc82f22, 0x4e63d9, 0xd11cce, 0x575035, 0x5bc9c3, 0xdd8538];
12483
12484if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE);
12485
12486module.exports = (0, _define_crc2.default)('crc-24', function (buf, previous) {
12487 if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf);
12488
12489 var crc = typeof previous !== 'undefined' ? ~~previous : 0xb704ce;
12490
12491 for (var index = 0; index < buf.length; index++) {
12492 var byte = buf[index];
12493 crc = (TABLE[(crc >> 16 ^ byte) & 0xff] ^ crc << 8) & 0xffffff;
12494 }
12495
12496 return crc;
12497});
12498},{"./create_buffer":64,"./define_crc":65,"buffer":50}],60:[function(require,module,exports){
12499'use strict';
12500
12501var _buffer = require('buffer');
12502
12503var _create_buffer = require('./create_buffer');
12504
12505var _create_buffer2 = _interopRequireDefault(_create_buffer);
12506
12507var _define_crc = require('./define_crc');
12508
12509var _define_crc2 = _interopRequireDefault(_define_crc);
12510
12511function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12512
12513// Generated by `./pycrc.py --algorithm=table-driven --model=crc-32 --generate=c`
12514var TABLE = [0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d];
12515
12516if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE);
12517
12518module.exports = (0, _define_crc2.default)('crc-32', function (buf, previous) {
12519 if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf);
12520
12521 var crc = previous === 0 ? 0 : ~~previous ^ -1;
12522
12523 for (var index = 0; index < buf.length; index++) {
12524 var byte = buf[index];
12525 crc = TABLE[(crc ^ byte) & 0xff] ^ crc >>> 8;
12526 }
12527
12528 return crc ^ -1;
12529});
12530},{"./create_buffer":64,"./define_crc":65,"buffer":50}],61:[function(require,module,exports){
12531'use strict';
12532
12533var _buffer = require('buffer');
12534
12535var _create_buffer = require('./create_buffer');
12536
12537var _create_buffer2 = _interopRequireDefault(_create_buffer);
12538
12539var _define_crc = require('./define_crc');
12540
12541var _define_crc2 = _interopRequireDefault(_define_crc);
12542
12543function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12544
12545// Generated by `./pycrc.py --algorithm=table-driven --model=crc-8 --generate=c`
12546var TABLE = [0x00, 0x07, 0x0e, 0x09, 0x1c, 0x1b, 0x12, 0x15, 0x38, 0x3f, 0x36, 0x31, 0x24, 0x23, 0x2a, 0x2d, 0x70, 0x77, 0x7e, 0x79, 0x6c, 0x6b, 0x62, 0x65, 0x48, 0x4f, 0x46, 0x41, 0x54, 0x53, 0x5a, 0x5d, 0xe0, 0xe7, 0xee, 0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 0x1a, 0x1d, 0x14, 0x13, 0xae, 0xa9, 0xa0, 0xa7, 0xb2, 0xb5, 0xbc, 0xbb, 0x96, 0x91, 0x98, 0x9f, 0x8a, 0x8d, 0x84, 0x83, 0xde, 0xd9, 0xd0, 0xd7, 0xc2, 0xc5, 0xcc, 0xcb, 0xe6, 0xe1, 0xe8, 0xef, 0xfa, 0xfd, 0xf4, 0xf3];
12547
12548if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE);
12549
12550module.exports = (0, _define_crc2.default)('crc-8', function (buf, previous) {
12551 if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf);
12552
12553 var crc = ~~previous;
12554
12555 for (var index = 0; index < buf.length; index++) {
12556 var byte = buf[index];
12557 crc = TABLE[(crc ^ byte) & 0xff] & 0xff;
12558 }
12559
12560 return crc;
12561});
12562},{"./create_buffer":64,"./define_crc":65,"buffer":50}],62:[function(require,module,exports){
12563'use strict';
12564
12565var _buffer = require('buffer');
12566
12567var _create_buffer = require('./create_buffer');
12568
12569var _create_buffer2 = _interopRequireDefault(_create_buffer);
12570
12571var _define_crc = require('./define_crc');
12572
12573var _define_crc2 = _interopRequireDefault(_define_crc);
12574
12575function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12576
12577// Generated by `./pycrc.py --algorithm=table-driven --model=dallas-1-wire --generate=c`
12578var TABLE = [0x00, 0x5e, 0xbc, 0xe2, 0x61, 0x3f, 0xdd, 0x83, 0xc2, 0x9c, 0x7e, 0x20, 0xa3, 0xfd, 0x1f, 0x41, 0x9d, 0xc3, 0x21, 0x7f, 0xfc, 0xa2, 0x40, 0x1e, 0x5f, 0x01, 0xe3, 0xbd, 0x3e, 0x60, 0x82, 0xdc, 0x23, 0x7d, 0x9f, 0xc1, 0x42, 0x1c, 0xfe, 0xa0, 0xe1, 0xbf, 0x5d, 0x03, 0x80, 0xde, 0x3c, 0x62, 0xbe, 0xe0, 0x02, 0x5c, 0xdf, 0x81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8, 0x74, 0x2a, 0xc8, 0x96, 0x15, 0x4b, 0xa9, 0xf7, 0xb6, 0xe8, 0x0a, 0x54, 0xd7, 0x89, 0x6b, 0x35];
12579
12580if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE);
12581
12582module.exports = (0, _define_crc2.default)('dallas-1-wire', function (buf, previous) {
12583 if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf);
12584
12585 var crc = ~~previous;
12586
12587 for (var index = 0; index < buf.length; index++) {
12588 var byte = buf[index];
12589 crc = TABLE[(crc ^ byte) & 0xff] & 0xff;
12590 }
12591
12592 return crc;
12593});
12594},{"./create_buffer":64,"./define_crc":65,"buffer":50}],63:[function(require,module,exports){
12595'use strict';
12596
12597var _buffer = require('buffer');
12598
12599var _create_buffer = require('./create_buffer');
12600
12601var _create_buffer2 = _interopRequireDefault(_create_buffer);
12602
12603var _define_crc = require('./define_crc');
12604
12605var _define_crc2 = _interopRequireDefault(_define_crc);
12606
12607function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12608
12609// Generated by `./pycrc.py --algorithm=table-driven --model=jam --generate=c`
12610var TABLE = [0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d];
12611
12612if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE);
12613
12614module.exports = (0, _define_crc2.default)('jam', function (buf) {
12615 var previous = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
12616
12617 if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf);
12618
12619 var crc = previous === 0 ? 0 : ~~previous;
12620
12621 for (var index = 0; index < buf.length; index++) {
12622 var byte = buf[index];
12623 crc = TABLE[(crc ^ byte) & 0xff] ^ crc >>> 8;
12624 }
12625
12626 return crc;
12627});
12628},{"./create_buffer":64,"./define_crc":65,"buffer":50}],64:[function(require,module,exports){
12629'use strict';
12630
12631Object.defineProperty(exports, "__esModule", {
12632 value: true
12633});
12634
12635var _buffer = require('buffer');
12636
12637var createBuffer = _buffer.Buffer.from && _buffer.Buffer.alloc && _buffer.Buffer.allocUnsafe && _buffer.Buffer.allocUnsafeSlow ? _buffer.Buffer.from
12638
12639// support for Node < 5.10
12640: function (val) {
12641 return new _buffer.Buffer(val);
12642};
12643
12644exports.default = createBuffer;
12645},{"buffer":50}],65:[function(require,module,exports){
12646"use strict";
12647
12648Object.defineProperty(exports, "__esModule", {
12649 value: true
12650});
12651
12652exports.default = function (model, calc) {
12653 var fn = function fn(buf, previous) {
12654 return calc(buf, previous) >>> 0;
12655 };
12656 fn.signed = calc;
12657 fn.unsigned = fn;
12658 fn.model = model;
12659
12660 return fn;
12661};
12662},{}],66:[function(require,module,exports){
12663'use strict';
12664
12665module.exports = {
12666 crc1: require('./crc1'),
12667 crc8: require('./crc8'),
12668 crc81wire: require('./crc8_1wire'),
12669 crc16: require('./crc16'),
12670 crc16ccitt: require('./crc16_ccitt'),
12671 crc16modbus: require('./crc16_modbus'),
12672 crc16xmodem: require('./crc16_xmodem'),
12673 crc16kermit: require('./crc16_kermit'),
12674 crc24: require('./crc24'),
12675 crc32: require('./crc32'),
12676 crcjam: require('./crcjam')
12677};
12678},{"./crc1":53,"./crc16":54,"./crc16_ccitt":55,"./crc16_kermit":56,"./crc16_modbus":57,"./crc16_xmodem":58,"./crc24":59,"./crc32":60,"./crc8":61,"./crc8_1wire":62,"./crcjam":63}],67:[function(require,module,exports){
12679(function (Buffer){
12680var elliptic = require('elliptic')
12681var BN = require('bn.js')
12682
12683module.exports = function createECDH (curve) {
12684 return new ECDH(curve)
12685}
12686
12687var aliases = {
12688 secp256k1: {
12689 name: 'secp256k1',
12690 byteLength: 32
12691 },
12692 secp224r1: {
12693 name: 'p224',
12694 byteLength: 28
12695 },
12696 prime256v1: {
12697 name: 'p256',
12698 byteLength: 32
12699 },
12700 prime192v1: {
12701 name: 'p192',
12702 byteLength: 24
12703 },
12704 ed25519: {
12705 name: 'ed25519',
12706 byteLength: 32
12707 },
12708 secp384r1: {
12709 name: 'p384',
12710 byteLength: 48
12711 },
12712 secp521r1: {
12713 name: 'p521',
12714 byteLength: 66
12715 }
12716}
12717
12718aliases.p224 = aliases.secp224r1
12719aliases.p256 = aliases.secp256r1 = aliases.prime256v1
12720aliases.p192 = aliases.secp192r1 = aliases.prime192v1
12721aliases.p384 = aliases.secp384r1
12722aliases.p521 = aliases.secp521r1
12723
12724function ECDH (curve) {
12725 this.curveType = aliases[curve]
12726 if (!this.curveType) {
12727 this.curveType = {
12728 name: curve
12729 }
12730 }
12731 this.curve = new elliptic.ec(this.curveType.name) // eslint-disable-line new-cap
12732 this.keys = void 0
12733}
12734
12735ECDH.prototype.generateKeys = function (enc, format) {
12736 this.keys = this.curve.genKeyPair()
12737 return this.getPublicKey(enc, format)
12738}
12739
12740ECDH.prototype.computeSecret = function (other, inenc, enc) {
12741 inenc = inenc || 'utf8'
12742 if (!Buffer.isBuffer(other)) {
12743 other = new Buffer(other, inenc)
12744 }
12745 var otherPub = this.curve.keyFromPublic(other).getPublic()
12746 var out = otherPub.mul(this.keys.getPrivate()).getX()
12747 return formatReturnValue(out, enc, this.curveType.byteLength)
12748}
12749
12750ECDH.prototype.getPublicKey = function (enc, format) {
12751 var key = this.keys.getPublic(format === 'compressed', true)
12752 if (format === 'hybrid') {
12753 if (key[key.length - 1] % 2) {
12754 key[0] = 7
12755 } else {
12756 key[0] = 6
12757 }
12758 }
12759 return formatReturnValue(key, enc)
12760}
12761
12762ECDH.prototype.getPrivateKey = function (enc) {
12763 return formatReturnValue(this.keys.getPrivate(), enc)
12764}
12765
12766ECDH.prototype.setPublicKey = function (pub, enc) {
12767 enc = enc || 'utf8'
12768 if (!Buffer.isBuffer(pub)) {
12769 pub = new Buffer(pub, enc)
12770 }
12771 this.keys._importPublic(pub)
12772 return this
12773}
12774
12775ECDH.prototype.setPrivateKey = function (priv, enc) {
12776 enc = enc || 'utf8'
12777 if (!Buffer.isBuffer(priv)) {
12778 priv = new Buffer(priv, enc)
12779 }
12780
12781 var _priv = new BN(priv)
12782 _priv = _priv.toString(16)
12783 this.keys = this.curve.genKeyPair()
12784 this.keys._importPrivate(_priv)
12785 return this
12786}
12787
12788function formatReturnValue (bn, enc, len) {
12789 if (!Array.isArray(bn)) {
12790 bn = bn.toArray()
12791 }
12792 var buf = new Buffer(bn)
12793 if (len && buf.length < len) {
12794 var zeros = new Buffer(len - buf.length)
12795 zeros.fill(0)
12796 buf = Buffer.concat([zeros, buf])
12797 }
12798 if (!enc) {
12799 return buf
12800 } else {
12801 return buf.toString(enc)
12802 }
12803}
12804
12805}).call(this,require("buffer").Buffer)
12806},{"bn.js":18,"buffer":50,"elliptic":86}],68:[function(require,module,exports){
12807'use strict'
12808var inherits = require('inherits')
12809var MD5 = require('md5.js')
12810var RIPEMD160 = require('ripemd160')
12811var sha = require('sha.js')
12812var Base = require('cipher-base')
12813
12814function Hash (hash) {
12815 Base.call(this, 'digest')
12816
12817 this._hash = hash
12818}
12819
12820inherits(Hash, Base)
12821
12822Hash.prototype._update = function (data) {
12823 this._hash.update(data)
12824}
12825
12826Hash.prototype._final = function () {
12827 return this._hash.digest()
12828}
12829
12830module.exports = function createHash (alg) {
12831 alg = alg.toLowerCase()
12832 if (alg === 'md5') return new MD5()
12833 if (alg === 'rmd160' || alg === 'ripemd160') return new RIPEMD160()
12834
12835 return new Hash(sha(alg))
12836}
12837
12838},{"cipher-base":51,"inherits":119,"md5.js":358,"ripemd160":397,"sha.js":400}],69:[function(require,module,exports){
12839var MD5 = require('md5.js')
12840
12841module.exports = function (buffer) {
12842 return new MD5().update(buffer).digest()
12843}
12844
12845},{"md5.js":358}],70:[function(require,module,exports){
12846'use strict'
12847var inherits = require('inherits')
12848var Legacy = require('./legacy')
12849var Base = require('cipher-base')
12850var Buffer = require('safe-buffer').Buffer
12851var md5 = require('create-hash/md5')
12852var RIPEMD160 = require('ripemd160')
12853
12854var sha = require('sha.js')
12855
12856var ZEROS = Buffer.alloc(128)
12857
12858function Hmac (alg, key) {
12859 Base.call(this, 'digest')
12860 if (typeof key === 'string') {
12861 key = Buffer.from(key)
12862 }
12863
12864 var blocksize = (alg === 'sha512' || alg === 'sha384') ? 128 : 64
12865
12866 this._alg = alg
12867 this._key = key
12868 if (key.length > blocksize) {
12869 var hash = alg === 'rmd160' ? new RIPEMD160() : sha(alg)
12870 key = hash.update(key).digest()
12871 } else if (key.length < blocksize) {
12872 key = Buffer.concat([key, ZEROS], blocksize)
12873 }
12874
12875 var ipad = this._ipad = Buffer.allocUnsafe(blocksize)
12876 var opad = this._opad = Buffer.allocUnsafe(blocksize)
12877
12878 for (var i = 0; i < blocksize; i++) {
12879 ipad[i] = key[i] ^ 0x36
12880 opad[i] = key[i] ^ 0x5C
12881 }
12882 this._hash = alg === 'rmd160' ? new RIPEMD160() : sha(alg)
12883 this._hash.update(ipad)
12884}
12885
12886inherits(Hmac, Base)
12887
12888Hmac.prototype._update = function (data) {
12889 this._hash.update(data)
12890}
12891
12892Hmac.prototype._final = function () {
12893 var h = this._hash.digest()
12894 var hash = this._alg === 'rmd160' ? new RIPEMD160() : sha(this._alg)
12895 return hash.update(this._opad).update(h).digest()
12896}
12897
12898module.exports = function createHmac (alg, key) {
12899 alg = alg.toLowerCase()
12900 if (alg === 'rmd160' || alg === 'ripemd160') {
12901 return new Hmac('rmd160', key)
12902 }
12903 if (alg === 'md5') {
12904 return new Legacy(md5, key)
12905 }
12906 return new Hmac(alg, key)
12907}
12908
12909},{"./legacy":71,"cipher-base":51,"create-hash/md5":69,"inherits":119,"ripemd160":397,"safe-buffer":398,"sha.js":400}],71:[function(require,module,exports){
12910'use strict'
12911var inherits = require('inherits')
12912var Buffer = require('safe-buffer').Buffer
12913
12914var Base = require('cipher-base')
12915
12916var ZEROS = Buffer.alloc(128)
12917var blocksize = 64
12918
12919function Hmac (alg, key) {
12920 Base.call(this, 'digest')
12921 if (typeof key === 'string') {
12922 key = Buffer.from(key)
12923 }
12924
12925 this._alg = alg
12926 this._key = key
12927
12928 if (key.length > blocksize) {
12929 key = alg(key)
12930 } else if (key.length < blocksize) {
12931 key = Buffer.concat([key, ZEROS], blocksize)
12932 }
12933
12934 var ipad = this._ipad = Buffer.allocUnsafe(blocksize)
12935 var opad = this._opad = Buffer.allocUnsafe(blocksize)
12936
12937 for (var i = 0; i < blocksize; i++) {
12938 ipad[i] = key[i] ^ 0x36
12939 opad[i] = key[i] ^ 0x5C
12940 }
12941
12942 this._hash = [ipad]
12943}
12944
12945inherits(Hmac, Base)
12946
12947Hmac.prototype._update = function (data) {
12948 this._hash.push(data)
12949}
12950
12951Hmac.prototype._final = function () {
12952 var h = this._alg(Buffer.concat(this._hash))
12953 return this._alg(Buffer.concat([this._opad, h]))
12954}
12955module.exports = Hmac
12956
12957},{"cipher-base":51,"inherits":119,"safe-buffer":398}],72:[function(require,module,exports){
12958'use strict'
12959
12960exports.randomBytes = exports.rng = exports.pseudoRandomBytes = exports.prng = require('randombytes')
12961exports.createHash = exports.Hash = require('create-hash')
12962exports.createHmac = exports.Hmac = require('create-hmac')
12963
12964var algos = require('browserify-sign/algos')
12965var algoKeys = Object.keys(algos)
12966var hashes = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160'].concat(algoKeys)
12967exports.getHashes = function () {
12968 return hashes
12969}
12970
12971var p = require('pbkdf2')
12972exports.pbkdf2 = p.pbkdf2
12973exports.pbkdf2Sync = p.pbkdf2Sync
12974
12975var aes = require('browserify-cipher')
12976
12977exports.Cipher = aes.Cipher
12978exports.createCipher = aes.createCipher
12979exports.Cipheriv = aes.Cipheriv
12980exports.createCipheriv = aes.createCipheriv
12981exports.Decipher = aes.Decipher
12982exports.createDecipher = aes.createDecipher
12983exports.Decipheriv = aes.Decipheriv
12984exports.createDecipheriv = aes.createDecipheriv
12985exports.getCiphers = aes.getCiphers
12986exports.listCiphers = aes.listCiphers
12987
12988var dh = require('diffie-hellman')
12989
12990exports.DiffieHellmanGroup = dh.DiffieHellmanGroup
12991exports.createDiffieHellmanGroup = dh.createDiffieHellmanGroup
12992exports.getDiffieHellman = dh.getDiffieHellman
12993exports.createDiffieHellman = dh.createDiffieHellman
12994exports.DiffieHellman = dh.DiffieHellman
12995
12996var sign = require('browserify-sign')
12997
12998exports.createSign = sign.createSign
12999exports.Sign = sign.Sign
13000exports.createVerify = sign.createVerify
13001exports.Verify = sign.Verify
13002
13003exports.createECDH = require('create-ecdh')
13004
13005var publicEncrypt = require('public-encrypt')
13006
13007exports.publicEncrypt = publicEncrypt.publicEncrypt
13008exports.privateEncrypt = publicEncrypt.privateEncrypt
13009exports.publicDecrypt = publicEncrypt.publicDecrypt
13010exports.privateDecrypt = publicEncrypt.privateDecrypt
13011
13012// the least I can do is make error messages for the rest of the node.js/crypto api.
13013// ;[
13014// 'createCredentials'
13015// ].forEach(function (name) {
13016// exports[name] = function () {
13017// throw new Error([
13018// 'sorry, ' + name + ' is not implemented yet',
13019// 'we accept pull requests',
13020// 'https://github.com/crypto-browserify/crypto-browserify'
13021// ].join('\n'))
13022// }
13023// })
13024
13025var rf = require('randomfill')
13026
13027exports.randomFill = rf.randomFill
13028exports.randomFillSync = rf.randomFillSync
13029
13030exports.createCredentials = function () {
13031 throw new Error([
13032 'sorry, createCredentials is not implemented yet',
13033 'we accept pull requests',
13034 'https://github.com/crypto-browserify/crypto-browserify'
13035 ].join('\n'))
13036}
13037
13038exports.constants = {
13039 'DH_CHECK_P_NOT_SAFE_PRIME': 2,
13040 'DH_CHECK_P_NOT_PRIME': 1,
13041 'DH_UNABLE_TO_CHECK_GENERATOR': 4,
13042 'DH_NOT_SUITABLE_GENERATOR': 8,
13043 'NPN_ENABLED': 1,
13044 'ALPN_ENABLED': 1,
13045 'RSA_PKCS1_PADDING': 1,
13046 'RSA_SSLV23_PADDING': 2,
13047 'RSA_NO_PADDING': 3,
13048 'RSA_PKCS1_OAEP_PADDING': 4,
13049 'RSA_X931_PADDING': 5,
13050 'RSA_PKCS1_PSS_PADDING': 6,
13051 'POINT_CONVERSION_COMPRESSED': 2,
13052 'POINT_CONVERSION_UNCOMPRESSED': 4,
13053 'POINT_CONVERSION_HYBRID': 6
13054}
13055
13056},{"browserify-cipher":38,"browserify-sign":45,"browserify-sign/algos":42,"create-ecdh":67,"create-hash":68,"create-hmac":70,"diffie-hellman":80,"pbkdf2":368,"public-encrypt":375,"randombytes":381,"randomfill":382}],73:[function(require,module,exports){
13057(function (Buffer){
13058var Cursor = function(buffer)
13059{
13060 if (!(this instanceof Cursor))
13061 {
13062 return new Cursor(buffer);
13063 }
13064
13065 if (!(buffer instanceof Buffer))
13066 {
13067 buffer = new Buffer(buffer);
13068 }
13069
13070 this._setBuffer(buffer);
13071 this.rewind();
13072};
13073
13074Cursor.prototype._setBuffer = function(buffer)
13075{
13076 this._buffer = buffer;
13077 this.length = buffer.length;
13078};
13079
13080Cursor.prototype.buffer = function()
13081{
13082 return this._buffer;
13083};
13084
13085Cursor.prototype.tap = function(cb)
13086{
13087 cb(this);
13088 return this;
13089};
13090
13091Cursor.prototype.clone = function(newIndex)
13092{
13093 var c = new this.constructor(this.buffer());
13094 c.seek(arguments.length === 0 ? this.tell() : newIndex);
13095
13096 return c;
13097};
13098
13099Cursor.prototype.tell = function()
13100{
13101 return this._index;
13102};
13103
13104Cursor.prototype.seek = function(op, index)
13105{
13106 if (arguments.length == 1)
13107 {
13108 index = op;
13109 op = '=';
13110 }
13111
13112 if (op == '+')
13113 {
13114 this._index += index;
13115 }
13116 else if (op == '-')
13117 {
13118 this._index -= index;
13119 }
13120 else
13121 {
13122 this._index = index;
13123 }
13124
13125 return this;
13126};
13127
13128Cursor.prototype.rewind = function()
13129{
13130 return this.seek(0);
13131};
13132
13133Cursor.prototype.eof = function()
13134{
13135 return this.tell() == this.buffer().length;
13136};
13137
13138Cursor.prototype.write = function(string, length, encoding)
13139{
13140 return this.seek('+', this.buffer().write(string, this.tell(), length, encoding));
13141};
13142
13143Cursor.prototype.fill = function(value, length)
13144{
13145 if (arguments.length == 1)
13146 {
13147 length = this.buffer().length - this.tell();
13148 }
13149
13150 this.buffer().fill(value, this.tell(), this.tell() + length);
13151 this.seek('+', length);
13152
13153 return this;
13154};
13155
13156Cursor.prototype.slice = function(length)
13157{
13158 if (arguments.length === 0)
13159 {
13160 length = this.length - this.tell();
13161 }
13162
13163 var c = new this.constructor(this.buffer().slice(this.tell(), this.tell() + length));
13164 this.seek('+', length);
13165
13166 return c;
13167};
13168
13169Cursor.prototype.copyFrom = function(source)
13170{
13171 var buf = source instanceof Buffer ? source: source.buffer();
13172 buf.copy(this.buffer(), this.tell(), 0, buf.length);
13173 this.seek('+', buf.length);
13174
13175 return this;
13176};
13177
13178Cursor.prototype.concat = function(list)
13179{
13180 for (var i in list)
13181 {
13182 if (list[i] instanceof Cursor)
13183 {
13184 list[i] = list[i].buffer();
13185 }
13186 }
13187
13188 list.unshift(this.buffer());
13189
13190 var b = Buffer.concat(list);
13191 this._setBuffer(b);
13192
13193 return this;
13194};
13195
13196Cursor.prototype.toString = function(encoding, length)
13197{
13198 if (arguments.length === 0)
13199 {
13200 encoding = 'utf8';
13201 length = this.buffer().length - this.tell();
13202 }
13203 else if (arguments.length === 1)
13204 {
13205 length = this.buffer().length - this.tell();
13206 }
13207
13208 var val = this.buffer().toString(encoding, this.tell(), this.tell() + length);
13209 this.seek('+', length);
13210
13211 return val;
13212};
13213
13214[
13215 [1, ['readInt8', 'readUInt8']],
13216 [2, ['readInt16BE', 'readInt16LE', 'readUInt16BE', 'readUInt16LE']],
13217 [4, ['readInt32BE', 'readInt32LE', 'readUInt32BE', 'readUInt32LE', 'readFloatBE', 'readFloatLE']],
13218 [8, ['readDoubleBE', 'readDoubleLE']]
13219].forEach(function(arr)
13220{
13221 arr[1].forEach(function(method)
13222 {
13223 Cursor.prototype[method] = function()
13224 {
13225 var val = this.buffer()[method](this.tell());
13226 this.seek('+', arr[0]);
13227
13228 return val;
13229 };
13230 });
13231});
13232
13233[
13234 [1, ['writeInt8', 'writeUInt8']],
13235 [2, ['writeInt16BE', 'writeInt16LE', 'writeUInt16BE', 'writeUInt16LE']],
13236 [4, ['writeInt32BE', 'writeInt32LE', 'writeUInt32BE', 'writeUInt32LE', 'writeFloatBE', 'writeFloatLE']],
13237 [8, ['writeDoubleBE', 'writeDoubleLE']]
13238].forEach(function(arr)
13239{
13240 arr[1].forEach(function(method)
13241 {
13242 Cursor.prototype[method] = function(val)
13243 {
13244 val = this.buffer()[method](val, this.tell());
13245 this.seek('+', arr[0]);
13246
13247 return this;
13248 };
13249 });
13250});
13251
13252//basic extend functionality to facilitate
13253//writing your own cursor while still providing
13254//access to low level r/w functionality
13255Cursor.extend = function(C, proto)
13256{
13257 var parent = this;
13258
13259 if (arguments.length === 1)
13260 {
13261 proto = C;
13262 C = null;
13263 }
13264
13265 proto = proto || {};
13266
13267 C = C || function ctor(buffer)
13268 {
13269 if (!(this instanceof C))
13270 {
13271 return new C(buffer);
13272 }
13273
13274 parent.call(this, buffer);
13275 };
13276
13277 require('util').inherits(C, parent);
13278
13279 C.extend = parent.extend;
13280 C.define = parent.define;
13281
13282 for (var i in proto)
13283 {
13284 C.define(i, proto[i]);
13285 }
13286
13287 return C;
13288};
13289
13290Cursor.define = function(name, fn)
13291{
13292 var proto = this.prototype[name];
13293
13294 this.prototype[name] = proto && function()
13295 {
13296 this.__super = proto;
13297 return fn.apply(this, arguments);
13298 } || fn;
13299};
13300
13301module.exports = Cursor;
13302
13303}).call(this,require("buffer").Buffer)
13304},{"buffer":50,"util":443}],74:[function(require,module,exports){
13305'use strict';
13306
13307exports.utils = require('./des/utils');
13308exports.Cipher = require('./des/cipher');
13309exports.DES = require('./des/des');
13310exports.CBC = require('./des/cbc');
13311exports.EDE = require('./des/ede');
13312
13313},{"./des/cbc":75,"./des/cipher":76,"./des/des":77,"./des/ede":78,"./des/utils":79}],75:[function(require,module,exports){
13314'use strict';
13315
13316var assert = require('minimalistic-assert');
13317var inherits = require('inherits');
13318
13319var proto = {};
13320
13321function CBCState(iv) {
13322 assert.equal(iv.length, 8, 'Invalid IV length');
13323
13324 this.iv = new Array(8);
13325 for (var i = 0; i < this.iv.length; i++)
13326 this.iv[i] = iv[i];
13327}
13328
13329function instantiate(Base) {
13330 function CBC(options) {
13331 Base.call(this, options);
13332 this._cbcInit();
13333 }
13334 inherits(CBC, Base);
13335
13336 var keys = Object.keys(proto);
13337 for (var i = 0; i < keys.length; i++) {
13338 var key = keys[i];
13339 CBC.prototype[key] = proto[key];
13340 }
13341
13342 CBC.create = function create(options) {
13343 return new CBC(options);
13344 };
13345
13346 return CBC;
13347}
13348
13349exports.instantiate = instantiate;
13350
13351proto._cbcInit = function _cbcInit() {
13352 var state = new CBCState(this.options.iv);
13353 this._cbcState = state;
13354};
13355
13356proto._update = function _update(inp, inOff, out, outOff) {
13357 var state = this._cbcState;
13358 var superProto = this.constructor.super_.prototype;
13359
13360 var iv = state.iv;
13361 if (this.type === 'encrypt') {
13362 for (var i = 0; i < this.blockSize; i++)
13363 iv[i] ^= inp[inOff + i];
13364
13365 superProto._update.call(this, iv, 0, out, outOff);
13366
13367 for (var i = 0; i < this.blockSize; i++)
13368 iv[i] = out[outOff + i];
13369 } else {
13370 superProto._update.call(this, inp, inOff, out, outOff);
13371
13372 for (var i = 0; i < this.blockSize; i++)
13373 out[outOff + i] ^= iv[i];
13374
13375 for (var i = 0; i < this.blockSize; i++)
13376 iv[i] = inp[inOff + i];
13377 }
13378};
13379
13380},{"inherits":119,"minimalistic-assert":360}],76:[function(require,module,exports){
13381'use strict';
13382
13383var assert = require('minimalistic-assert');
13384
13385function Cipher(options) {
13386 this.options = options;
13387
13388 this.type = this.options.type;
13389 this.blockSize = 8;
13390 this._init();
13391
13392 this.buffer = new Array(this.blockSize);
13393 this.bufferOff = 0;
13394}
13395module.exports = Cipher;
13396
13397Cipher.prototype._init = function _init() {
13398 // Might be overrided
13399};
13400
13401Cipher.prototype.update = function update(data) {
13402 if (data.length === 0)
13403 return [];
13404
13405 if (this.type === 'decrypt')
13406 return this._updateDecrypt(data);
13407 else
13408 return this._updateEncrypt(data);
13409};
13410
13411Cipher.prototype._buffer = function _buffer(data, off) {
13412 // Append data to buffer
13413 var min = Math.min(this.buffer.length - this.bufferOff, data.length - off);
13414 for (var i = 0; i < min; i++)
13415 this.buffer[this.bufferOff + i] = data[off + i];
13416 this.bufferOff += min;
13417
13418 // Shift next
13419 return min;
13420};
13421
13422Cipher.prototype._flushBuffer = function _flushBuffer(out, off) {
13423 this._update(this.buffer, 0, out, off);
13424 this.bufferOff = 0;
13425 return this.blockSize;
13426};
13427
13428Cipher.prototype._updateEncrypt = function _updateEncrypt(data) {
13429 var inputOff = 0;
13430 var outputOff = 0;
13431
13432 var count = ((this.bufferOff + data.length) / this.blockSize) | 0;
13433 var out = new Array(count * this.blockSize);
13434
13435 if (this.bufferOff !== 0) {
13436 inputOff += this._buffer(data, inputOff);
13437
13438 if (this.bufferOff === this.buffer.length)
13439 outputOff += this._flushBuffer(out, outputOff);
13440 }
13441
13442 // Write blocks
13443 var max = data.length - ((data.length - inputOff) % this.blockSize);
13444 for (; inputOff < max; inputOff += this.blockSize) {
13445 this._update(data, inputOff, out, outputOff);
13446 outputOff += this.blockSize;
13447 }
13448
13449 // Queue rest
13450 for (; inputOff < data.length; inputOff++, this.bufferOff++)
13451 this.buffer[this.bufferOff] = data[inputOff];
13452
13453 return out;
13454};
13455
13456Cipher.prototype._updateDecrypt = function _updateDecrypt(data) {
13457 var inputOff = 0;
13458 var outputOff = 0;
13459
13460 var count = Math.ceil((this.bufferOff + data.length) / this.blockSize) - 1;
13461 var out = new Array(count * this.blockSize);
13462
13463 // TODO(indutny): optimize it, this is far from optimal
13464 for (; count > 0; count--) {
13465 inputOff += this._buffer(data, inputOff);
13466 outputOff += this._flushBuffer(out, outputOff);
13467 }
13468
13469 // Buffer rest of the input
13470 inputOff += this._buffer(data, inputOff);
13471
13472 return out;
13473};
13474
13475Cipher.prototype.final = function final(buffer) {
13476 var first;
13477 if (buffer)
13478 first = this.update(buffer);
13479
13480 var last;
13481 if (this.type === 'encrypt')
13482 last = this._finalEncrypt();
13483 else
13484 last = this._finalDecrypt();
13485
13486 if (first)
13487 return first.concat(last);
13488 else
13489 return last;
13490};
13491
13492Cipher.prototype._pad = function _pad(buffer, off) {
13493 if (off === 0)
13494 return false;
13495
13496 while (off < buffer.length)
13497 buffer[off++] = 0;
13498
13499 return true;
13500};
13501
13502Cipher.prototype._finalEncrypt = function _finalEncrypt() {
13503 if (!this._pad(this.buffer, this.bufferOff))
13504 return [];
13505
13506 var out = new Array(this.blockSize);
13507 this._update(this.buffer, 0, out, 0);
13508 return out;
13509};
13510
13511Cipher.prototype._unpad = function _unpad(buffer) {
13512 return buffer;
13513};
13514
13515Cipher.prototype._finalDecrypt = function _finalDecrypt() {
13516 assert.equal(this.bufferOff, this.blockSize, 'Not enough data to decrypt');
13517 var out = new Array(this.blockSize);
13518 this._flushBuffer(out, 0);
13519
13520 return this._unpad(out);
13521};
13522
13523},{"minimalistic-assert":360}],77:[function(require,module,exports){
13524'use strict';
13525
13526var assert = require('minimalistic-assert');
13527var inherits = require('inherits');
13528
13529var des = require('../des');
13530var utils = des.utils;
13531var Cipher = des.Cipher;
13532
13533function DESState() {
13534 this.tmp = new Array(2);
13535 this.keys = null;
13536}
13537
13538function DES(options) {
13539 Cipher.call(this, options);
13540
13541 var state = new DESState();
13542 this._desState = state;
13543
13544 this.deriveKeys(state, options.key);
13545}
13546inherits(DES, Cipher);
13547module.exports = DES;
13548
13549DES.create = function create(options) {
13550 return new DES(options);
13551};
13552
13553var shiftTable = [
13554 1, 1, 2, 2, 2, 2, 2, 2,
13555 1, 2, 2, 2, 2, 2, 2, 1
13556];
13557
13558DES.prototype.deriveKeys = function deriveKeys(state, key) {
13559 state.keys = new Array(16 * 2);
13560
13561 assert.equal(key.length, this.blockSize, 'Invalid key length');
13562
13563 var kL = utils.readUInt32BE(key, 0);
13564 var kR = utils.readUInt32BE(key, 4);
13565
13566 utils.pc1(kL, kR, state.tmp, 0);
13567 kL = state.tmp[0];
13568 kR = state.tmp[1];
13569 for (var i = 0; i < state.keys.length; i += 2) {
13570 var shift = shiftTable[i >>> 1];
13571 kL = utils.r28shl(kL, shift);
13572 kR = utils.r28shl(kR, shift);
13573 utils.pc2(kL, kR, state.keys, i);
13574 }
13575};
13576
13577DES.prototype._update = function _update(inp, inOff, out, outOff) {
13578 var state = this._desState;
13579
13580 var l = utils.readUInt32BE(inp, inOff);
13581 var r = utils.readUInt32BE(inp, inOff + 4);
13582
13583 // Initial Permutation
13584 utils.ip(l, r, state.tmp, 0);
13585 l = state.tmp[0];
13586 r = state.tmp[1];
13587
13588 if (this.type === 'encrypt')
13589 this._encrypt(state, l, r, state.tmp, 0);
13590 else
13591 this._decrypt(state, l, r, state.tmp, 0);
13592
13593 l = state.tmp[0];
13594 r = state.tmp[1];
13595
13596 utils.writeUInt32BE(out, l, outOff);
13597 utils.writeUInt32BE(out, r, outOff + 4);
13598};
13599
13600DES.prototype._pad = function _pad(buffer, off) {
13601 var value = buffer.length - off;
13602 for (var i = off; i < buffer.length; i++)
13603 buffer[i] = value;
13604
13605 return true;
13606};
13607
13608DES.prototype._unpad = function _unpad(buffer) {
13609 var pad = buffer[buffer.length - 1];
13610 for (var i = buffer.length - pad; i < buffer.length; i++)
13611 assert.equal(buffer[i], pad);
13612
13613 return buffer.slice(0, buffer.length - pad);
13614};
13615
13616DES.prototype._encrypt = function _encrypt(state, lStart, rStart, out, off) {
13617 var l = lStart;
13618 var r = rStart;
13619
13620 // Apply f() x16 times
13621 for (var i = 0; i < state.keys.length; i += 2) {
13622 var keyL = state.keys[i];
13623 var keyR = state.keys[i + 1];
13624
13625 // f(r, k)
13626 utils.expand(r, state.tmp, 0);
13627
13628 keyL ^= state.tmp[0];
13629 keyR ^= state.tmp[1];
13630 var s = utils.substitute(keyL, keyR);
13631 var f = utils.permute(s);
13632
13633 var t = r;
13634 r = (l ^ f) >>> 0;
13635 l = t;
13636 }
13637
13638 // Reverse Initial Permutation
13639 utils.rip(r, l, out, off);
13640};
13641
13642DES.prototype._decrypt = function _decrypt(state, lStart, rStart, out, off) {
13643 var l = rStart;
13644 var r = lStart;
13645
13646 // Apply f() x16 times
13647 for (var i = state.keys.length - 2; i >= 0; i -= 2) {
13648 var keyL = state.keys[i];
13649 var keyR = state.keys[i + 1];
13650
13651 // f(r, k)
13652 utils.expand(l, state.tmp, 0);
13653
13654 keyL ^= state.tmp[0];
13655 keyR ^= state.tmp[1];
13656 var s = utils.substitute(keyL, keyR);
13657 var f = utils.permute(s);
13658
13659 var t = l;
13660 l = (r ^ f) >>> 0;
13661 r = t;
13662 }
13663
13664 // Reverse Initial Permutation
13665 utils.rip(l, r, out, off);
13666};
13667
13668},{"../des":74,"inherits":119,"minimalistic-assert":360}],78:[function(require,module,exports){
13669'use strict';
13670
13671var assert = require('minimalistic-assert');
13672var inherits = require('inherits');
13673
13674var des = require('../des');
13675var Cipher = des.Cipher;
13676var DES = des.DES;
13677
13678function EDEState(type, key) {
13679 assert.equal(key.length, 24, 'Invalid key length');
13680
13681 var k1 = key.slice(0, 8);
13682 var k2 = key.slice(8, 16);
13683 var k3 = key.slice(16, 24);
13684
13685 if (type === 'encrypt') {
13686 this.ciphers = [
13687 DES.create({ type: 'encrypt', key: k1 }),
13688 DES.create({ type: 'decrypt', key: k2 }),
13689 DES.create({ type: 'encrypt', key: k3 })
13690 ];
13691 } else {
13692 this.ciphers = [
13693 DES.create({ type: 'decrypt', key: k3 }),
13694 DES.create({ type: 'encrypt', key: k2 }),
13695 DES.create({ type: 'decrypt', key: k1 })
13696 ];
13697 }
13698}
13699
13700function EDE(options) {
13701 Cipher.call(this, options);
13702
13703 var state = new EDEState(this.type, this.options.key);
13704 this._edeState = state;
13705}
13706inherits(EDE, Cipher);
13707
13708module.exports = EDE;
13709
13710EDE.create = function create(options) {
13711 return new EDE(options);
13712};
13713
13714EDE.prototype._update = function _update(inp, inOff, out, outOff) {
13715 var state = this._edeState;
13716
13717 state.ciphers[0]._update(inp, inOff, out, outOff);
13718 state.ciphers[1]._update(out, outOff, out, outOff);
13719 state.ciphers[2]._update(out, outOff, out, outOff);
13720};
13721
13722EDE.prototype._pad = DES.prototype._pad;
13723EDE.prototype._unpad = DES.prototype._unpad;
13724
13725},{"../des":74,"inherits":119,"minimalistic-assert":360}],79:[function(require,module,exports){
13726'use strict';
13727
13728exports.readUInt32BE = function readUInt32BE(bytes, off) {
13729 var res = (bytes[0 + off] << 24) |
13730 (bytes[1 + off] << 16) |
13731 (bytes[2 + off] << 8) |
13732 bytes[3 + off];
13733 return res >>> 0;
13734};
13735
13736exports.writeUInt32BE = function writeUInt32BE(bytes, value, off) {
13737 bytes[0 + off] = value >>> 24;
13738 bytes[1 + off] = (value >>> 16) & 0xff;
13739 bytes[2 + off] = (value >>> 8) & 0xff;
13740 bytes[3 + off] = value & 0xff;
13741};
13742
13743exports.ip = function ip(inL, inR, out, off) {
13744 var outL = 0;
13745 var outR = 0;
13746
13747 for (var i = 6; i >= 0; i -= 2) {
13748 for (var j = 0; j <= 24; j += 8) {
13749 outL <<= 1;
13750 outL |= (inR >>> (j + i)) & 1;
13751 }
13752 for (var j = 0; j <= 24; j += 8) {
13753 outL <<= 1;
13754 outL |= (inL >>> (j + i)) & 1;
13755 }
13756 }
13757
13758 for (var i = 6; i >= 0; i -= 2) {
13759 for (var j = 1; j <= 25; j += 8) {
13760 outR <<= 1;
13761 outR |= (inR >>> (j + i)) & 1;
13762 }
13763 for (var j = 1; j <= 25; j += 8) {
13764 outR <<= 1;
13765 outR |= (inL >>> (j + i)) & 1;
13766 }
13767 }
13768
13769 out[off + 0] = outL >>> 0;
13770 out[off + 1] = outR >>> 0;
13771};
13772
13773exports.rip = function rip(inL, inR, out, off) {
13774 var outL = 0;
13775 var outR = 0;
13776
13777 for (var i = 0; i < 4; i++) {
13778 for (var j = 24; j >= 0; j -= 8) {
13779 outL <<= 1;
13780 outL |= (inR >>> (j + i)) & 1;
13781 outL <<= 1;
13782 outL |= (inL >>> (j + i)) & 1;
13783 }
13784 }
13785 for (var i = 4; i < 8; i++) {
13786 for (var j = 24; j >= 0; j -= 8) {
13787 outR <<= 1;
13788 outR |= (inR >>> (j + i)) & 1;
13789 outR <<= 1;
13790 outR |= (inL >>> (j + i)) & 1;
13791 }
13792 }
13793
13794 out[off + 0] = outL >>> 0;
13795 out[off + 1] = outR >>> 0;
13796};
13797
13798exports.pc1 = function pc1(inL, inR, out, off) {
13799 var outL = 0;
13800 var outR = 0;
13801
13802 // 7, 15, 23, 31, 39, 47, 55, 63
13803 // 6, 14, 22, 30, 39, 47, 55, 63
13804 // 5, 13, 21, 29, 39, 47, 55, 63
13805 // 4, 12, 20, 28
13806 for (var i = 7; i >= 5; i--) {
13807 for (var j = 0; j <= 24; j += 8) {
13808 outL <<= 1;
13809 outL |= (inR >> (j + i)) & 1;
13810 }
13811 for (var j = 0; j <= 24; j += 8) {
13812 outL <<= 1;
13813 outL |= (inL >> (j + i)) & 1;
13814 }
13815 }
13816 for (var j = 0; j <= 24; j += 8) {
13817 outL <<= 1;
13818 outL |= (inR >> (j + i)) & 1;
13819 }
13820
13821 // 1, 9, 17, 25, 33, 41, 49, 57
13822 // 2, 10, 18, 26, 34, 42, 50, 58
13823 // 3, 11, 19, 27, 35, 43, 51, 59
13824 // 36, 44, 52, 60
13825 for (var i = 1; i <= 3; i++) {
13826 for (var j = 0; j <= 24; j += 8) {
13827 outR <<= 1;
13828 outR |= (inR >> (j + i)) & 1;
13829 }
13830 for (var j = 0; j <= 24; j += 8) {
13831 outR <<= 1;
13832 outR |= (inL >> (j + i)) & 1;
13833 }
13834 }
13835 for (var j = 0; j <= 24; j += 8) {
13836 outR <<= 1;
13837 outR |= (inL >> (j + i)) & 1;
13838 }
13839
13840 out[off + 0] = outL >>> 0;
13841 out[off + 1] = outR >>> 0;
13842};
13843
13844exports.r28shl = function r28shl(num, shift) {
13845 return ((num << shift) & 0xfffffff) | (num >>> (28 - shift));
13846};
13847
13848var pc2table = [
13849 // inL => outL
13850 14, 11, 17, 4, 27, 23, 25, 0,
13851 13, 22, 7, 18, 5, 9, 16, 24,
13852 2, 20, 12, 21, 1, 8, 15, 26,
13853
13854 // inR => outR
13855 15, 4, 25, 19, 9, 1, 26, 16,
13856 5, 11, 23, 8, 12, 7, 17, 0,
13857 22, 3, 10, 14, 6, 20, 27, 24
13858];
13859
13860exports.pc2 = function pc2(inL, inR, out, off) {
13861 var outL = 0;
13862 var outR = 0;
13863
13864 var len = pc2table.length >>> 1;
13865 for (var i = 0; i < len; i++) {
13866 outL <<= 1;
13867 outL |= (inL >>> pc2table[i]) & 0x1;
13868 }
13869 for (var i = len; i < pc2table.length; i++) {
13870 outR <<= 1;
13871 outR |= (inR >>> pc2table[i]) & 0x1;
13872 }
13873
13874 out[off + 0] = outL >>> 0;
13875 out[off + 1] = outR >>> 0;
13876};
13877
13878exports.expand = function expand(r, out, off) {
13879 var outL = 0;
13880 var outR = 0;
13881
13882 outL = ((r & 1) << 5) | (r >>> 27);
13883 for (var i = 23; i >= 15; i -= 4) {
13884 outL <<= 6;
13885 outL |= (r >>> i) & 0x3f;
13886 }
13887 for (var i = 11; i >= 3; i -= 4) {
13888 outR |= (r >>> i) & 0x3f;
13889 outR <<= 6;
13890 }
13891 outR |= ((r & 0x1f) << 1) | (r >>> 31);
13892
13893 out[off + 0] = outL >>> 0;
13894 out[off + 1] = outR >>> 0;
13895};
13896
13897var sTable = [
13898 14, 0, 4, 15, 13, 7, 1, 4, 2, 14, 15, 2, 11, 13, 8, 1,
13899 3, 10, 10, 6, 6, 12, 12, 11, 5, 9, 9, 5, 0, 3, 7, 8,
13900 4, 15, 1, 12, 14, 8, 8, 2, 13, 4, 6, 9, 2, 1, 11, 7,
13901 15, 5, 12, 11, 9, 3, 7, 14, 3, 10, 10, 0, 5, 6, 0, 13,
13902
13903 15, 3, 1, 13, 8, 4, 14, 7, 6, 15, 11, 2, 3, 8, 4, 14,
13904 9, 12, 7, 0, 2, 1, 13, 10, 12, 6, 0, 9, 5, 11, 10, 5,
13905 0, 13, 14, 8, 7, 10, 11, 1, 10, 3, 4, 15, 13, 4, 1, 2,
13906 5, 11, 8, 6, 12, 7, 6, 12, 9, 0, 3, 5, 2, 14, 15, 9,
13907
13908 10, 13, 0, 7, 9, 0, 14, 9, 6, 3, 3, 4, 15, 6, 5, 10,
13909 1, 2, 13, 8, 12, 5, 7, 14, 11, 12, 4, 11, 2, 15, 8, 1,
13910 13, 1, 6, 10, 4, 13, 9, 0, 8, 6, 15, 9, 3, 8, 0, 7,
13911 11, 4, 1, 15, 2, 14, 12, 3, 5, 11, 10, 5, 14, 2, 7, 12,
13912
13913 7, 13, 13, 8, 14, 11, 3, 5, 0, 6, 6, 15, 9, 0, 10, 3,
13914 1, 4, 2, 7, 8, 2, 5, 12, 11, 1, 12, 10, 4, 14, 15, 9,
13915 10, 3, 6, 15, 9, 0, 0, 6, 12, 10, 11, 1, 7, 13, 13, 8,
13916 15, 9, 1, 4, 3, 5, 14, 11, 5, 12, 2, 7, 8, 2, 4, 14,
13917
13918 2, 14, 12, 11, 4, 2, 1, 12, 7, 4, 10, 7, 11, 13, 6, 1,
13919 8, 5, 5, 0, 3, 15, 15, 10, 13, 3, 0, 9, 14, 8, 9, 6,
13920 4, 11, 2, 8, 1, 12, 11, 7, 10, 1, 13, 14, 7, 2, 8, 13,
13921 15, 6, 9, 15, 12, 0, 5, 9, 6, 10, 3, 4, 0, 5, 14, 3,
13922
13923 12, 10, 1, 15, 10, 4, 15, 2, 9, 7, 2, 12, 6, 9, 8, 5,
13924 0, 6, 13, 1, 3, 13, 4, 14, 14, 0, 7, 11, 5, 3, 11, 8,
13925 9, 4, 14, 3, 15, 2, 5, 12, 2, 9, 8, 5, 12, 15, 3, 10,
13926 7, 11, 0, 14, 4, 1, 10, 7, 1, 6, 13, 0, 11, 8, 6, 13,
13927
13928 4, 13, 11, 0, 2, 11, 14, 7, 15, 4, 0, 9, 8, 1, 13, 10,
13929 3, 14, 12, 3, 9, 5, 7, 12, 5, 2, 10, 15, 6, 8, 1, 6,
13930 1, 6, 4, 11, 11, 13, 13, 8, 12, 1, 3, 4, 7, 10, 14, 7,
13931 10, 9, 15, 5, 6, 0, 8, 15, 0, 14, 5, 2, 9, 3, 2, 12,
13932
13933 13, 1, 2, 15, 8, 13, 4, 8, 6, 10, 15, 3, 11, 7, 1, 4,
13934 10, 12, 9, 5, 3, 6, 14, 11, 5, 0, 0, 14, 12, 9, 7, 2,
13935 7, 2, 11, 1, 4, 14, 1, 7, 9, 4, 12, 10, 14, 8, 2, 13,
13936 0, 15, 6, 12, 10, 9, 13, 0, 15, 3, 3, 5, 5, 6, 8, 11
13937];
13938
13939exports.substitute = function substitute(inL, inR) {
13940 var out = 0;
13941 for (var i = 0; i < 4; i++) {
13942 var b = (inL >>> (18 - i * 6)) & 0x3f;
13943 var sb = sTable[i * 0x40 + b];
13944
13945 out <<= 4;
13946 out |= sb;
13947 }
13948 for (var i = 0; i < 4; i++) {
13949 var b = (inR >>> (18 - i * 6)) & 0x3f;
13950 var sb = sTable[4 * 0x40 + i * 0x40 + b];
13951
13952 out <<= 4;
13953 out |= sb;
13954 }
13955 return out >>> 0;
13956};
13957
13958var permuteTable = [
13959 16, 25, 12, 11, 3, 20, 4, 15, 31, 17, 9, 6, 27, 14, 1, 22,
13960 30, 24, 8, 18, 0, 5, 29, 23, 13, 19, 2, 26, 10, 21, 28, 7
13961];
13962
13963exports.permute = function permute(num) {
13964 var out = 0;
13965 for (var i = 0; i < permuteTable.length; i++) {
13966 out <<= 1;
13967 out |= (num >>> permuteTable[i]) & 0x1;
13968 }
13969 return out >>> 0;
13970};
13971
13972exports.padSplit = function padSplit(num, size, group) {
13973 var str = num.toString(2);
13974 while (str.length < size)
13975 str = '0' + str;
13976
13977 var out = [];
13978 for (var i = 0; i < size; i += group)
13979 out.push(str.slice(i, i + group));
13980 return out.join(' ');
13981};
13982
13983},{}],80:[function(require,module,exports){
13984(function (Buffer){
13985var generatePrime = require('./lib/generatePrime')
13986var primes = require('./lib/primes.json')
13987
13988var DH = require('./lib/dh')
13989
13990function getDiffieHellman (mod) {
13991 var prime = new Buffer(primes[mod].prime, 'hex')
13992 var gen = new Buffer(primes[mod].gen, 'hex')
13993
13994 return new DH(prime, gen)
13995}
13996
13997var ENCODINGS = {
13998 'binary': true, 'hex': true, 'base64': true
13999}
14000
14001function createDiffieHellman (prime, enc, generator, genc) {
14002 if (Buffer.isBuffer(enc) || ENCODINGS[enc] === undefined) {
14003 return createDiffieHellman(prime, 'binary', enc, generator)
14004 }
14005
14006 enc = enc || 'binary'
14007 genc = genc || 'binary'
14008 generator = generator || new Buffer([2])
14009
14010 if (!Buffer.isBuffer(generator)) {
14011 generator = new Buffer(generator, genc)
14012 }
14013
14014 if (typeof prime === 'number') {
14015 return new DH(generatePrime(prime, generator), generator, true)
14016 }
14017
14018 if (!Buffer.isBuffer(prime)) {
14019 prime = new Buffer(prime, enc)
14020 }
14021
14022 return new DH(prime, generator, true)
14023}
14024
14025exports.DiffieHellmanGroup = exports.createDiffieHellmanGroup = exports.getDiffieHellman = getDiffieHellman
14026exports.createDiffieHellman = exports.DiffieHellman = createDiffieHellman
14027
14028}).call(this,require("buffer").Buffer)
14029},{"./lib/dh":81,"./lib/generatePrime":82,"./lib/primes.json":83,"buffer":50}],81:[function(require,module,exports){
14030(function (Buffer){
14031var BN = require('bn.js');
14032var MillerRabin = require('miller-rabin');
14033var millerRabin = new MillerRabin();
14034var TWENTYFOUR = new BN(24);
14035var ELEVEN = new BN(11);
14036var TEN = new BN(10);
14037var THREE = new BN(3);
14038var SEVEN = new BN(7);
14039var primes = require('./generatePrime');
14040var randomBytes = require('randombytes');
14041module.exports = DH;
14042
14043function setPublicKey(pub, enc) {
14044 enc = enc || 'utf8';
14045 if (!Buffer.isBuffer(pub)) {
14046 pub = new Buffer(pub, enc);
14047 }
14048 this._pub = new BN(pub);
14049 return this;
14050}
14051
14052function setPrivateKey(priv, enc) {
14053 enc = enc || 'utf8';
14054 if (!Buffer.isBuffer(priv)) {
14055 priv = new Buffer(priv, enc);
14056 }
14057 this._priv = new BN(priv);
14058 return this;
14059}
14060
14061var primeCache = {};
14062function checkPrime(prime, generator) {
14063 var gen = generator.toString('hex');
14064 var hex = [gen, prime.toString(16)].join('_');
14065 if (hex in primeCache) {
14066 return primeCache[hex];
14067 }
14068 var error = 0;
14069
14070 if (prime.isEven() ||
14071 !primes.simpleSieve ||
14072 !primes.fermatTest(prime) ||
14073 !millerRabin.test(prime)) {
14074 //not a prime so +1
14075 error += 1;
14076
14077 if (gen === '02' || gen === '05') {
14078 // we'd be able to check the generator
14079 // it would fail so +8
14080 error += 8;
14081 } else {
14082 //we wouldn't be able to test the generator
14083 // so +4
14084 error += 4;
14085 }
14086 primeCache[hex] = error;
14087 return error;
14088 }
14089 if (!millerRabin.test(prime.shrn(1))) {
14090 //not a safe prime
14091 error += 2;
14092 }
14093 var rem;
14094 switch (gen) {
14095 case '02':
14096 if (prime.mod(TWENTYFOUR).cmp(ELEVEN)) {
14097 // unsuidable generator
14098 error += 8;
14099 }
14100 break;
14101 case '05':
14102 rem = prime.mod(TEN);
14103 if (rem.cmp(THREE) && rem.cmp(SEVEN)) {
14104 // prime mod 10 needs to equal 3 or 7
14105 error += 8;
14106 }
14107 break;
14108 default:
14109 error += 4;
14110 }
14111 primeCache[hex] = error;
14112 return error;
14113}
14114
14115function DH(prime, generator, malleable) {
14116 this.setGenerator(generator);
14117 this.__prime = new BN(prime);
14118 this._prime = BN.mont(this.__prime);
14119 this._primeLen = prime.length;
14120 this._pub = undefined;
14121 this._priv = undefined;
14122 this._primeCode = undefined;
14123 if (malleable) {
14124 this.setPublicKey = setPublicKey;
14125 this.setPrivateKey = setPrivateKey;
14126 } else {
14127 this._primeCode = 8;
14128 }
14129}
14130Object.defineProperty(DH.prototype, 'verifyError', {
14131 enumerable: true,
14132 get: function () {
14133 if (typeof this._primeCode !== 'number') {
14134 this._primeCode = checkPrime(this.__prime, this.__gen);
14135 }
14136 return this._primeCode;
14137 }
14138});
14139DH.prototype.generateKeys = function () {
14140 if (!this._priv) {
14141 this._priv = new BN(randomBytes(this._primeLen));
14142 }
14143 this._pub = this._gen.toRed(this._prime).redPow(this._priv).fromRed();
14144 return this.getPublicKey();
14145};
14146
14147DH.prototype.computeSecret = function (other) {
14148 other = new BN(other);
14149 other = other.toRed(this._prime);
14150 var secret = other.redPow(this._priv).fromRed();
14151 var out = new Buffer(secret.toArray());
14152 var prime = this.getPrime();
14153 if (out.length < prime.length) {
14154 var front = new Buffer(prime.length - out.length);
14155 front.fill(0);
14156 out = Buffer.concat([front, out]);
14157 }
14158 return out;
14159};
14160
14161DH.prototype.getPublicKey = function getPublicKey(enc) {
14162 return formatReturnValue(this._pub, enc);
14163};
14164
14165DH.prototype.getPrivateKey = function getPrivateKey(enc) {
14166 return formatReturnValue(this._priv, enc);
14167};
14168
14169DH.prototype.getPrime = function (enc) {
14170 return formatReturnValue(this.__prime, enc);
14171};
14172
14173DH.prototype.getGenerator = function (enc) {
14174 return formatReturnValue(this._gen, enc);
14175};
14176
14177DH.prototype.setGenerator = function (gen, enc) {
14178 enc = enc || 'utf8';
14179 if (!Buffer.isBuffer(gen)) {
14180 gen = new Buffer(gen, enc);
14181 }
14182 this.__gen = gen;
14183 this._gen = new BN(gen);
14184 return this;
14185};
14186
14187function formatReturnValue(bn, enc) {
14188 var buf = new Buffer(bn.toArray());
14189 if (!enc) {
14190 return buf;
14191 } else {
14192 return buf.toString(enc);
14193 }
14194}
14195
14196}).call(this,require("buffer").Buffer)
14197},{"./generatePrime":82,"bn.js":18,"buffer":50,"miller-rabin":359,"randombytes":381}],82:[function(require,module,exports){
14198var randomBytes = require('randombytes');
14199module.exports = findPrime;
14200findPrime.simpleSieve = simpleSieve;
14201findPrime.fermatTest = fermatTest;
14202var BN = require('bn.js');
14203var TWENTYFOUR = new BN(24);
14204var MillerRabin = require('miller-rabin');
14205var millerRabin = new MillerRabin();
14206var ONE = new BN(1);
14207var TWO = new BN(2);
14208var FIVE = new BN(5);
14209var SIXTEEN = new BN(16);
14210var EIGHT = new BN(8);
14211var TEN = new BN(10);
14212var THREE = new BN(3);
14213var SEVEN = new BN(7);
14214var ELEVEN = new BN(11);
14215var FOUR = new BN(4);
14216var TWELVE = new BN(12);
14217var primes = null;
14218
14219function _getPrimes() {
14220 if (primes !== null)
14221 return primes;
14222
14223 var limit = 0x100000;
14224 var res = [];
14225 res[0] = 2;
14226 for (var i = 1, k = 3; k < limit; k += 2) {
14227 var sqrt = Math.ceil(Math.sqrt(k));
14228 for (var j = 0; j < i && res[j] <= sqrt; j++)
14229 if (k % res[j] === 0)
14230 break;
14231
14232 if (i !== j && res[j] <= sqrt)
14233 continue;
14234
14235 res[i++] = k;
14236 }
14237 primes = res;
14238 return res;
14239}
14240
14241function simpleSieve(p) {
14242 var primes = _getPrimes();
14243
14244 for (var i = 0; i < primes.length; i++)
14245 if (p.modn(primes[i]) === 0) {
14246 if (p.cmpn(primes[i]) === 0) {
14247 return true;
14248 } else {
14249 return false;
14250 }
14251 }
14252
14253 return true;
14254}
14255
14256function fermatTest(p) {
14257 var red = BN.mont(p);
14258 return TWO.toRed(red).redPow(p.subn(1)).fromRed().cmpn(1) === 0;
14259}
14260
14261function findPrime(bits, gen) {
14262 if (bits < 16) {
14263 // this is what openssl does
14264 if (gen === 2 || gen === 5) {
14265 return new BN([0x8c, 0x7b]);
14266 } else {
14267 return new BN([0x8c, 0x27]);
14268 }
14269 }
14270 gen = new BN(gen);
14271
14272 var num, n2;
14273
14274 while (true) {
14275 num = new BN(randomBytes(Math.ceil(bits / 8)));
14276 while (num.bitLength() > bits) {
14277 num.ishrn(1);
14278 }
14279 if (num.isEven()) {
14280 num.iadd(ONE);
14281 }
14282 if (!num.testn(1)) {
14283 num.iadd(TWO);
14284 }
14285 if (!gen.cmp(TWO)) {
14286 while (num.mod(TWENTYFOUR).cmp(ELEVEN)) {
14287 num.iadd(FOUR);
14288 }
14289 } else if (!gen.cmp(FIVE)) {
14290 while (num.mod(TEN).cmp(THREE)) {
14291 num.iadd(FOUR);
14292 }
14293 }
14294 n2 = num.shrn(1);
14295 if (simpleSieve(n2) && simpleSieve(num) &&
14296 fermatTest(n2) && fermatTest(num) &&
14297 millerRabin.test(n2) && millerRabin.test(num)) {
14298 return num;
14299 }
14300 }
14301
14302}
14303
14304},{"bn.js":18,"miller-rabin":359,"randombytes":381}],83:[function(require,module,exports){
14305module.exports={
14306 "modp1": {
14307 "gen": "02",
14308 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"
14309 },
14310 "modp2": {
14311 "gen": "02",
14312 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"
14313 },
14314 "modp5": {
14315 "gen": "02",
14316 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"
14317 },
14318 "modp14": {
14319 "gen": "02",
14320 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"
14321 },
14322 "modp15": {
14323 "gen": "02",
14324 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"
14325 },
14326 "modp16": {
14327 "gen": "02",
14328 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"
14329 },
14330 "modp17": {
14331 "gen": "02",
14332 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"
14333 },
14334 "modp18": {
14335 "gen": "02",
14336 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"
14337 }
14338}
14339},{}],84:[function(require,module,exports){
14340(function (Buffer){
14341"use strict";
14342Object.defineProperty(exports, "__esModule", { value: true });
14343const createHmac = require("create-hmac");
14344const naclFactory = require("js-nacl");
14345const utils_1 = require("./utils");
14346const ED25519_CURVE = 'ed25519 seed';
14347const HARDENED_OFFSET = 0x80000000;
14348let naclInstance;
14349naclFactory.instantiate((nacl) => (naclInstance = nacl));
14350exports.getMasterKeyFromSeed = (seed) => {
14351 const hmac = createHmac('sha512', ED25519_CURVE);
14352 const I = hmac.update(Buffer.from(seed, 'hex')).digest();
14353 const IL = I.slice(0, 32);
14354 const IR = I.slice(32);
14355 return {
14356 key: IL,
14357 chainCode: IR,
14358 };
14359};
14360const CKDPriv = ({ key, chainCode }, index) => {
14361 const indexBuffer = Buffer.allocUnsafe(4);
14362 indexBuffer.writeUInt32BE(index, 0);
14363 const data = Buffer.concat([Buffer.alloc(1, 0), key, indexBuffer]);
14364 const I = createHmac('sha512', chainCode)
14365 .update(data)
14366 .digest();
14367 const IL = I.slice(0, 32);
14368 const IR = I.slice(32);
14369 return {
14370 key: IL,
14371 chainCode: IR,
14372 };
14373};
14374exports.getPublicKey = (privateKey, withZeroByte = true) => {
14375 const { signPk } = naclInstance.crypto_sign_seed_keypair(privateKey);
14376 const zero = Buffer.alloc(1, 0);
14377 return withZeroByte ?
14378 Buffer.concat([zero, Buffer.from(signPk)]) :
14379 Buffer.from(signPk);
14380};
14381exports.isValidPath = (path) => {
14382 if (!utils_1.pathRegex.test(path)) {
14383 return false;
14384 }
14385 return !path
14386 .split('/')
14387 .slice(1)
14388 .map(utils_1.replaceDerive)
14389 .some(isNaN);
14390};
14391exports.derivePath = (path, seed) => {
14392 if (!exports.isValidPath(path)) {
14393 throw new Error('Invalid derivation path');
14394 }
14395 const { key, chainCode } = exports.getMasterKeyFromSeed(seed);
14396 const segments = path
14397 .split('/')
14398 .slice(1)
14399 .map(utils_1.replaceDerive)
14400 .map(el => parseInt(el, 10));
14401 return segments.reduce((parentKeys, segment) => CKDPriv(parentKeys, segment + HARDENED_OFFSET), { key, chainCode });
14402};
14403
14404}).call(this,require("buffer").Buffer)
14405},{"./utils":85,"buffer":50,"create-hmac":70,"js-nacl":122}],85:[function(require,module,exports){
14406"use strict";
14407Object.defineProperty(exports, "__esModule", { value: true });
14408exports.pathRegex = new RegExp("^m(\\/[0-9]+')+$");
14409exports.replaceDerive = (val) => val.replace("'", '');
14410
14411},{}],86:[function(require,module,exports){
14412'use strict';
14413
14414var elliptic = exports;
14415
14416elliptic.version = require('../package.json').version;
14417elliptic.utils = require('./elliptic/utils');
14418elliptic.rand = require('brorand');
14419elliptic.curve = require('./elliptic/curve');
14420elliptic.curves = require('./elliptic/curves');
14421
14422// Protocols
14423elliptic.ec = require('./elliptic/ec');
14424elliptic.eddsa = require('./elliptic/eddsa');
14425
14426},{"../package.json":101,"./elliptic/curve":89,"./elliptic/curves":92,"./elliptic/ec":93,"./elliptic/eddsa":96,"./elliptic/utils":100,"brorand":19}],87:[function(require,module,exports){
14427'use strict';
14428
14429var BN = require('bn.js');
14430var elliptic = require('../../elliptic');
14431var utils = elliptic.utils;
14432var getNAF = utils.getNAF;
14433var getJSF = utils.getJSF;
14434var assert = utils.assert;
14435
14436function BaseCurve(type, conf) {
14437 this.type = type;
14438 this.p = new BN(conf.p, 16);
14439
14440 // Use Montgomery, when there is no fast reduction for the prime
14441 this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p);
14442
14443 // Useful for many curves
14444 this.zero = new BN(0).toRed(this.red);
14445 this.one = new BN(1).toRed(this.red);
14446 this.two = new BN(2).toRed(this.red);
14447
14448 // Curve configuration, optional
14449 this.n = conf.n && new BN(conf.n, 16);
14450 this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed);
14451
14452 // Temporary arrays
14453 this._wnafT1 = new Array(4);
14454 this._wnafT2 = new Array(4);
14455 this._wnafT3 = new Array(4);
14456 this._wnafT4 = new Array(4);
14457
14458 // Generalized Greg Maxwell's trick
14459 var adjustCount = this.n && this.p.div(this.n);
14460 if (!adjustCount || adjustCount.cmpn(100) > 0) {
14461 this.redN = null;
14462 } else {
14463 this._maxwellTrick = true;
14464 this.redN = this.n.toRed(this.red);
14465 }
14466}
14467module.exports = BaseCurve;
14468
14469BaseCurve.prototype.point = function point() {
14470 throw new Error('Not implemented');
14471};
14472
14473BaseCurve.prototype.validate = function validate() {
14474 throw new Error('Not implemented');
14475};
14476
14477BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) {
14478 assert(p.precomputed);
14479 var doubles = p._getDoubles();
14480
14481 var naf = getNAF(k, 1);
14482 var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1);
14483 I /= 3;
14484
14485 // Translate into more windowed form
14486 var repr = [];
14487 for (var j = 0; j < naf.length; j += doubles.step) {
14488 var nafW = 0;
14489 for (var k = j + doubles.step - 1; k >= j; k--)
14490 nafW = (nafW << 1) + naf[k];
14491 repr.push(nafW);
14492 }
14493
14494 var a = this.jpoint(null, null, null);
14495 var b = this.jpoint(null, null, null);
14496 for (var i = I; i > 0; i--) {
14497 for (var j = 0; j < repr.length; j++) {
14498 var nafW = repr[j];
14499 if (nafW === i)
14500 b = b.mixedAdd(doubles.points[j]);
14501 else if (nafW === -i)
14502 b = b.mixedAdd(doubles.points[j].neg());
14503 }
14504 a = a.add(b);
14505 }
14506 return a.toP();
14507};
14508
14509BaseCurve.prototype._wnafMul = function _wnafMul(p, k) {
14510 var w = 4;
14511
14512 // Precompute window
14513 var nafPoints = p._getNAFPoints(w);
14514 w = nafPoints.wnd;
14515 var wnd = nafPoints.points;
14516
14517 // Get NAF form
14518 var naf = getNAF(k, w);
14519
14520 // Add `this`*(N+1) for every w-NAF index
14521 var acc = this.jpoint(null, null, null);
14522 for (var i = naf.length - 1; i >= 0; i--) {
14523 // Count zeroes
14524 for (var k = 0; i >= 0 && naf[i] === 0; i--)
14525 k++;
14526 if (i >= 0)
14527 k++;
14528 acc = acc.dblp(k);
14529
14530 if (i < 0)
14531 break;
14532 var z = naf[i];
14533 assert(z !== 0);
14534 if (p.type === 'affine') {
14535 // J +- P
14536 if (z > 0)
14537 acc = acc.mixedAdd(wnd[(z - 1) >> 1]);
14538 else
14539 acc = acc.mixedAdd(wnd[(-z - 1) >> 1].neg());
14540 } else {
14541 // J +- J
14542 if (z > 0)
14543 acc = acc.add(wnd[(z - 1) >> 1]);
14544 else
14545 acc = acc.add(wnd[(-z - 1) >> 1].neg());
14546 }
14547 }
14548 return p.type === 'affine' ? acc.toP() : acc;
14549};
14550
14551BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW,
14552 points,
14553 coeffs,
14554 len,
14555 jacobianResult) {
14556 var wndWidth = this._wnafT1;
14557 var wnd = this._wnafT2;
14558 var naf = this._wnafT3;
14559
14560 // Fill all arrays
14561 var max = 0;
14562 for (var i = 0; i < len; i++) {
14563 var p = points[i];
14564 var nafPoints = p._getNAFPoints(defW);
14565 wndWidth[i] = nafPoints.wnd;
14566 wnd[i] = nafPoints.points;
14567 }
14568
14569 // Comb small window NAFs
14570 for (var i = len - 1; i >= 1; i -= 2) {
14571 var a = i - 1;
14572 var b = i;
14573 if (wndWidth[a] !== 1 || wndWidth[b] !== 1) {
14574 naf[a] = getNAF(coeffs[a], wndWidth[a]);
14575 naf[b] = getNAF(coeffs[b], wndWidth[b]);
14576 max = Math.max(naf[a].length, max);
14577 max = Math.max(naf[b].length, max);
14578 continue;
14579 }
14580
14581 var comb = [
14582 points[a], /* 1 */
14583 null, /* 3 */
14584 null, /* 5 */
14585 points[b] /* 7 */
14586 ];
14587
14588 // Try to avoid Projective points, if possible
14589 if (points[a].y.cmp(points[b].y) === 0) {
14590 comb[1] = points[a].add(points[b]);
14591 comb[2] = points[a].toJ().mixedAdd(points[b].neg());
14592 } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) {
14593 comb[1] = points[a].toJ().mixedAdd(points[b]);
14594 comb[2] = points[a].add(points[b].neg());
14595 } else {
14596 comb[1] = points[a].toJ().mixedAdd(points[b]);
14597 comb[2] = points[a].toJ().mixedAdd(points[b].neg());
14598 }
14599
14600 var index = [
14601 -3, /* -1 -1 */
14602 -1, /* -1 0 */
14603 -5, /* -1 1 */
14604 -7, /* 0 -1 */
14605 0, /* 0 0 */
14606 7, /* 0 1 */
14607 5, /* 1 -1 */
14608 1, /* 1 0 */
14609 3 /* 1 1 */
14610 ];
14611
14612 var jsf = getJSF(coeffs[a], coeffs[b]);
14613 max = Math.max(jsf[0].length, max);
14614 naf[a] = new Array(max);
14615 naf[b] = new Array(max);
14616 for (var j = 0; j < max; j++) {
14617 var ja = jsf[0][j] | 0;
14618 var jb = jsf[1][j] | 0;
14619
14620 naf[a][j] = index[(ja + 1) * 3 + (jb + 1)];
14621 naf[b][j] = 0;
14622 wnd[a] = comb;
14623 }
14624 }
14625
14626 var acc = this.jpoint(null, null, null);
14627 var tmp = this._wnafT4;
14628 for (var i = max; i >= 0; i--) {
14629 var k = 0;
14630
14631 while (i >= 0) {
14632 var zero = true;
14633 for (var j = 0; j < len; j++) {
14634 tmp[j] = naf[j][i] | 0;
14635 if (tmp[j] !== 0)
14636 zero = false;
14637 }
14638 if (!zero)
14639 break;
14640 k++;
14641 i--;
14642 }
14643 if (i >= 0)
14644 k++;
14645 acc = acc.dblp(k);
14646 if (i < 0)
14647 break;
14648
14649 for (var j = 0; j < len; j++) {
14650 var z = tmp[j];
14651 var p;
14652 if (z === 0)
14653 continue;
14654 else if (z > 0)
14655 p = wnd[j][(z - 1) >> 1];
14656 else if (z < 0)
14657 p = wnd[j][(-z - 1) >> 1].neg();
14658
14659 if (p.type === 'affine')
14660 acc = acc.mixedAdd(p);
14661 else
14662 acc = acc.add(p);
14663 }
14664 }
14665 // Zeroify references
14666 for (var i = 0; i < len; i++)
14667 wnd[i] = null;
14668
14669 if (jacobianResult)
14670 return acc;
14671 else
14672 return acc.toP();
14673};
14674
14675function BasePoint(curve, type) {
14676 this.curve = curve;
14677 this.type = type;
14678 this.precomputed = null;
14679}
14680BaseCurve.BasePoint = BasePoint;
14681
14682BasePoint.prototype.eq = function eq(/*other*/) {
14683 throw new Error('Not implemented');
14684};
14685
14686BasePoint.prototype.validate = function validate() {
14687 return this.curve.validate(this);
14688};
14689
14690BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
14691 bytes = utils.toArray(bytes, enc);
14692
14693 var len = this.p.byteLength();
14694
14695 // uncompressed, hybrid-odd, hybrid-even
14696 if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) &&
14697 bytes.length - 1 === 2 * len) {
14698 if (bytes[0] === 0x06)
14699 assert(bytes[bytes.length - 1] % 2 === 0);
14700 else if (bytes[0] === 0x07)
14701 assert(bytes[bytes.length - 1] % 2 === 1);
14702
14703 var res = this.point(bytes.slice(1, 1 + len),
14704 bytes.slice(1 + len, 1 + 2 * len));
14705
14706 return res;
14707 } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) &&
14708 bytes.length - 1 === len) {
14709 return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03);
14710 }
14711 throw new Error('Unknown point format');
14712};
14713
14714BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) {
14715 return this.encode(enc, true);
14716};
14717
14718BasePoint.prototype._encode = function _encode(compact) {
14719 var len = this.curve.p.byteLength();
14720 var x = this.getX().toArray('be', len);
14721
14722 if (compact)
14723 return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x);
14724
14725 return [ 0x04 ].concat(x, this.getY().toArray('be', len)) ;
14726};
14727
14728BasePoint.prototype.encode = function encode(enc, compact) {
14729 return utils.encode(this._encode(compact), enc);
14730};
14731
14732BasePoint.prototype.precompute = function precompute(power) {
14733 if (this.precomputed)
14734 return this;
14735
14736 var precomputed = {
14737 doubles: null,
14738 naf: null,
14739 beta: null
14740 };
14741 precomputed.naf = this._getNAFPoints(8);
14742 precomputed.doubles = this._getDoubles(4, power);
14743 precomputed.beta = this._getBeta();
14744 this.precomputed = precomputed;
14745
14746 return this;
14747};
14748
14749BasePoint.prototype._hasDoubles = function _hasDoubles(k) {
14750 if (!this.precomputed)
14751 return false;
14752
14753 var doubles = this.precomputed.doubles;
14754 if (!doubles)
14755 return false;
14756
14757 return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step);
14758};
14759
14760BasePoint.prototype._getDoubles = function _getDoubles(step, power) {
14761 if (this.precomputed && this.precomputed.doubles)
14762 return this.precomputed.doubles;
14763
14764 var doubles = [ this ];
14765 var acc = this;
14766 for (var i = 0; i < power; i += step) {
14767 for (var j = 0; j < step; j++)
14768 acc = acc.dbl();
14769 doubles.push(acc);
14770 }
14771 return {
14772 step: step,
14773 points: doubles
14774 };
14775};
14776
14777BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) {
14778 if (this.precomputed && this.precomputed.naf)
14779 return this.precomputed.naf;
14780
14781 var res = [ this ];
14782 var max = (1 << wnd) - 1;
14783 var dbl = max === 1 ? null : this.dbl();
14784 for (var i = 1; i < max; i++)
14785 res[i] = res[i - 1].add(dbl);
14786 return {
14787 wnd: wnd,
14788 points: res
14789 };
14790};
14791
14792BasePoint.prototype._getBeta = function _getBeta() {
14793 return null;
14794};
14795
14796BasePoint.prototype.dblp = function dblp(k) {
14797 var r = this;
14798 for (var i = 0; i < k; i++)
14799 r = r.dbl();
14800 return r;
14801};
14802
14803},{"../../elliptic":86,"bn.js":18}],88:[function(require,module,exports){
14804'use strict';
14805
14806var curve = require('../curve');
14807var elliptic = require('../../elliptic');
14808var BN = require('bn.js');
14809var inherits = require('inherits');
14810var Base = curve.base;
14811
14812var assert = elliptic.utils.assert;
14813
14814function EdwardsCurve(conf) {
14815 // NOTE: Important as we are creating point in Base.call()
14816 this.twisted = (conf.a | 0) !== 1;
14817 this.mOneA = this.twisted && (conf.a | 0) === -1;
14818 this.extended = this.mOneA;
14819
14820 Base.call(this, 'edwards', conf);
14821
14822 this.a = new BN(conf.a, 16).umod(this.red.m);
14823 this.a = this.a.toRed(this.red);
14824 this.c = new BN(conf.c, 16).toRed(this.red);
14825 this.c2 = this.c.redSqr();
14826 this.d = new BN(conf.d, 16).toRed(this.red);
14827 this.dd = this.d.redAdd(this.d);
14828
14829 assert(!this.twisted || this.c.fromRed().cmpn(1) === 0);
14830 this.oneC = (conf.c | 0) === 1;
14831}
14832inherits(EdwardsCurve, Base);
14833module.exports = EdwardsCurve;
14834
14835EdwardsCurve.prototype._mulA = function _mulA(num) {
14836 if (this.mOneA)
14837 return num.redNeg();
14838 else
14839 return this.a.redMul(num);
14840};
14841
14842EdwardsCurve.prototype._mulC = function _mulC(num) {
14843 if (this.oneC)
14844 return num;
14845 else
14846 return this.c.redMul(num);
14847};
14848
14849// Just for compatibility with Short curve
14850EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) {
14851 return this.point(x, y, z, t);
14852};
14853
14854EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) {
14855 x = new BN(x, 16);
14856 if (!x.red)
14857 x = x.toRed(this.red);
14858
14859 var x2 = x.redSqr();
14860 var rhs = this.c2.redSub(this.a.redMul(x2));
14861 var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x2));
14862
14863 var y2 = rhs.redMul(lhs.redInvm());
14864 var y = y2.redSqrt();
14865 if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
14866 throw new Error('invalid point');
14867
14868 var isOdd = y.fromRed().isOdd();
14869 if (odd && !isOdd || !odd && isOdd)
14870 y = y.redNeg();
14871
14872 return this.point(x, y);
14873};
14874
14875EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) {
14876 y = new BN(y, 16);
14877 if (!y.red)
14878 y = y.toRed(this.red);
14879
14880 // x^2 = (y^2 - c^2) / (c^2 d y^2 - a)
14881 var y2 = y.redSqr();
14882 var lhs = y2.redSub(this.c2);
14883 var rhs = y2.redMul(this.d).redMul(this.c2).redSub(this.a);
14884 var x2 = lhs.redMul(rhs.redInvm());
14885
14886 if (x2.cmp(this.zero) === 0) {
14887 if (odd)
14888 throw new Error('invalid point');
14889 else
14890 return this.point(this.zero, y);
14891 }
14892
14893 var x = x2.redSqrt();
14894 if (x.redSqr().redSub(x2).cmp(this.zero) !== 0)
14895 throw new Error('invalid point');
14896
14897 if (x.fromRed().isOdd() !== odd)
14898 x = x.redNeg();
14899
14900 return this.point(x, y);
14901};
14902
14903EdwardsCurve.prototype.validate = function validate(point) {
14904 if (point.isInfinity())
14905 return true;
14906
14907 // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2)
14908 point.normalize();
14909
14910 var x2 = point.x.redSqr();
14911 var y2 = point.y.redSqr();
14912 var lhs = x2.redMul(this.a).redAdd(y2);
14913 var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2)));
14914
14915 return lhs.cmp(rhs) === 0;
14916};
14917
14918function Point(curve, x, y, z, t) {
14919 Base.BasePoint.call(this, curve, 'projective');
14920 if (x === null && y === null && z === null) {
14921 this.x = this.curve.zero;
14922 this.y = this.curve.one;
14923 this.z = this.curve.one;
14924 this.t = this.curve.zero;
14925 this.zOne = true;
14926 } else {
14927 this.x = new BN(x, 16);
14928 this.y = new BN(y, 16);
14929 this.z = z ? new BN(z, 16) : this.curve.one;
14930 this.t = t && new BN(t, 16);
14931 if (!this.x.red)
14932 this.x = this.x.toRed(this.curve.red);
14933 if (!this.y.red)
14934 this.y = this.y.toRed(this.curve.red);
14935 if (!this.z.red)
14936 this.z = this.z.toRed(this.curve.red);
14937 if (this.t && !this.t.red)
14938 this.t = this.t.toRed(this.curve.red);
14939 this.zOne = this.z === this.curve.one;
14940
14941 // Use extended coordinates
14942 if (this.curve.extended && !this.t) {
14943 this.t = this.x.redMul(this.y);
14944 if (!this.zOne)
14945 this.t = this.t.redMul(this.z.redInvm());
14946 }
14947 }
14948}
14949inherits(Point, Base.BasePoint);
14950
14951EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
14952 return Point.fromJSON(this, obj);
14953};
14954
14955EdwardsCurve.prototype.point = function point(x, y, z, t) {
14956 return new Point(this, x, y, z, t);
14957};
14958
14959Point.fromJSON = function fromJSON(curve, obj) {
14960 return new Point(curve, obj[0], obj[1], obj[2]);
14961};
14962
14963Point.prototype.inspect = function inspect() {
14964 if (this.isInfinity())
14965 return '<EC Point Infinity>';
14966 return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
14967 ' y: ' + this.y.fromRed().toString(16, 2) +
14968 ' z: ' + this.z.fromRed().toString(16, 2) + '>';
14969};
14970
14971Point.prototype.isInfinity = function isInfinity() {
14972 // XXX This code assumes that zero is always zero in red
14973 return this.x.cmpn(0) === 0 &&
14974 (this.y.cmp(this.z) === 0 ||
14975 (this.zOne && this.y.cmp(this.curve.c) === 0));
14976};
14977
14978Point.prototype._extDbl = function _extDbl() {
14979 // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
14980 // #doubling-dbl-2008-hwcd
14981 // 4M + 4S
14982
14983 // A = X1^2
14984 var a = this.x.redSqr();
14985 // B = Y1^2
14986 var b = this.y.redSqr();
14987 // C = 2 * Z1^2
14988 var c = this.z.redSqr();
14989 c = c.redIAdd(c);
14990 // D = a * A
14991 var d = this.curve._mulA(a);
14992 // E = (X1 + Y1)^2 - A - B
14993 var e = this.x.redAdd(this.y).redSqr().redISub(a).redISub(b);
14994 // G = D + B
14995 var g = d.redAdd(b);
14996 // F = G - C
14997 var f = g.redSub(c);
14998 // H = D - B
14999 var h = d.redSub(b);
15000 // X3 = E * F
15001 var nx = e.redMul(f);
15002 // Y3 = G * H
15003 var ny = g.redMul(h);
15004 // T3 = E * H
15005 var nt = e.redMul(h);
15006 // Z3 = F * G
15007 var nz = f.redMul(g);
15008 return this.curve.point(nx, ny, nz, nt);
15009};
15010
15011Point.prototype._projDbl = function _projDbl() {
15012 // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
15013 // #doubling-dbl-2008-bbjlp
15014 // #doubling-dbl-2007-bl
15015 // and others
15016 // Generally 3M + 4S or 2M + 4S
15017
15018 // B = (X1 + Y1)^2
15019 var b = this.x.redAdd(this.y).redSqr();
15020 // C = X1^2
15021 var c = this.x.redSqr();
15022 // D = Y1^2
15023 var d = this.y.redSqr();
15024
15025 var nx;
15026 var ny;
15027 var nz;
15028 if (this.curve.twisted) {
15029 // E = a * C
15030 var e = this.curve._mulA(c);
15031 // F = E + D
15032 var f = e.redAdd(d);
15033 if (this.zOne) {
15034 // X3 = (B - C - D) * (F - 2)
15035 nx = b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two));
15036 // Y3 = F * (E - D)
15037 ny = f.redMul(e.redSub(d));
15038 // Z3 = F^2 - 2 * F
15039 nz = f.redSqr().redSub(f).redSub(f);
15040 } else {
15041 // H = Z1^2
15042 var h = this.z.redSqr();
15043 // J = F - 2 * H
15044 var j = f.redSub(h).redISub(h);
15045 // X3 = (B-C-D)*J
15046 nx = b.redSub(c).redISub(d).redMul(j);
15047 // Y3 = F * (E - D)
15048 ny = f.redMul(e.redSub(d));
15049 // Z3 = F * J
15050 nz = f.redMul(j);
15051 }
15052 } else {
15053 // E = C + D
15054 var e = c.redAdd(d);
15055 // H = (c * Z1)^2
15056 var h = this.curve._mulC(this.z).redSqr();
15057 // J = E - 2 * H
15058 var j = e.redSub(h).redSub(h);
15059 // X3 = c * (B - E) * J
15060 nx = this.curve._mulC(b.redISub(e)).redMul(j);
15061 // Y3 = c * E * (C - D)
15062 ny = this.curve._mulC(e).redMul(c.redISub(d));
15063 // Z3 = E * J
15064 nz = e.redMul(j);
15065 }
15066 return this.curve.point(nx, ny, nz);
15067};
15068
15069Point.prototype.dbl = function dbl() {
15070 if (this.isInfinity())
15071 return this;
15072
15073 // Double in extended coordinates
15074 if (this.curve.extended)
15075 return this._extDbl();
15076 else
15077 return this._projDbl();
15078};
15079
15080Point.prototype._extAdd = function _extAdd(p) {
15081 // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
15082 // #addition-add-2008-hwcd-3
15083 // 8M
15084
15085 // A = (Y1 - X1) * (Y2 - X2)
15086 var a = this.y.redSub(this.x).redMul(p.y.redSub(p.x));
15087 // B = (Y1 + X1) * (Y2 + X2)
15088 var b = this.y.redAdd(this.x).redMul(p.y.redAdd(p.x));
15089 // C = T1 * k * T2
15090 var c = this.t.redMul(this.curve.dd).redMul(p.t);
15091 // D = Z1 * 2 * Z2
15092 var d = this.z.redMul(p.z.redAdd(p.z));
15093 // E = B - A
15094 var e = b.redSub(a);
15095 // F = D - C
15096 var f = d.redSub(c);
15097 // G = D + C
15098 var g = d.redAdd(c);
15099 // H = B + A
15100 var h = b.redAdd(a);
15101 // X3 = E * F
15102 var nx = e.redMul(f);
15103 // Y3 = G * H
15104 var ny = g.redMul(h);
15105 // T3 = E * H
15106 var nt = e.redMul(h);
15107 // Z3 = F * G
15108 var nz = f.redMul(g);
15109 return this.curve.point(nx, ny, nz, nt);
15110};
15111
15112Point.prototype._projAdd = function _projAdd(p) {
15113 // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
15114 // #addition-add-2008-bbjlp
15115 // #addition-add-2007-bl
15116 // 10M + 1S
15117
15118 // A = Z1 * Z2
15119 var a = this.z.redMul(p.z);
15120 // B = A^2
15121 var b = a.redSqr();
15122 // C = X1 * X2
15123 var c = this.x.redMul(p.x);
15124 // D = Y1 * Y2
15125 var d = this.y.redMul(p.y);
15126 // E = d * C * D
15127 var e = this.curve.d.redMul(c).redMul(d);
15128 // F = B - E
15129 var f = b.redSub(e);
15130 // G = B + E
15131 var g = b.redAdd(e);
15132 // X3 = A * F * ((X1 + Y1) * (X2 + Y2) - C - D)
15133 var tmp = this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d);
15134 var nx = a.redMul(f).redMul(tmp);
15135 var ny;
15136 var nz;
15137 if (this.curve.twisted) {
15138 // Y3 = A * G * (D - a * C)
15139 ny = a.redMul(g).redMul(d.redSub(this.curve._mulA(c)));
15140 // Z3 = F * G
15141 nz = f.redMul(g);
15142 } else {
15143 // Y3 = A * G * (D - C)
15144 ny = a.redMul(g).redMul(d.redSub(c));
15145 // Z3 = c * F * G
15146 nz = this.curve._mulC(f).redMul(g);
15147 }
15148 return this.curve.point(nx, ny, nz);
15149};
15150
15151Point.prototype.add = function add(p) {
15152 if (this.isInfinity())
15153 return p;
15154 if (p.isInfinity())
15155 return this;
15156
15157 if (this.curve.extended)
15158 return this._extAdd(p);
15159 else
15160 return this._projAdd(p);
15161};
15162
15163Point.prototype.mul = function mul(k) {
15164 if (this._hasDoubles(k))
15165 return this.curve._fixedNafMul(this, k);
15166 else
15167 return this.curve._wnafMul(this, k);
15168};
15169
15170Point.prototype.mulAdd = function mulAdd(k1, p, k2) {
15171 return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false);
15172};
15173
15174Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) {
15175 return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true);
15176};
15177
15178Point.prototype.normalize = function normalize() {
15179 if (this.zOne)
15180 return this;
15181
15182 // Normalize coordinates
15183 var zi = this.z.redInvm();
15184 this.x = this.x.redMul(zi);
15185 this.y = this.y.redMul(zi);
15186 if (this.t)
15187 this.t = this.t.redMul(zi);
15188 this.z = this.curve.one;
15189 this.zOne = true;
15190 return this;
15191};
15192
15193Point.prototype.neg = function neg() {
15194 return this.curve.point(this.x.redNeg(),
15195 this.y,
15196 this.z,
15197 this.t && this.t.redNeg());
15198};
15199
15200Point.prototype.getX = function getX() {
15201 this.normalize();
15202 return this.x.fromRed();
15203};
15204
15205Point.prototype.getY = function getY() {
15206 this.normalize();
15207 return this.y.fromRed();
15208};
15209
15210Point.prototype.eq = function eq(other) {
15211 return this === other ||
15212 this.getX().cmp(other.getX()) === 0 &&
15213 this.getY().cmp(other.getY()) === 0;
15214};
15215
15216Point.prototype.eqXToP = function eqXToP(x) {
15217 var rx = x.toRed(this.curve.red).redMul(this.z);
15218 if (this.x.cmp(rx) === 0)
15219 return true;
15220
15221 var xc = x.clone();
15222 var t = this.curve.redN.redMul(this.z);
15223 for (;;) {
15224 xc.iadd(this.curve.n);
15225 if (xc.cmp(this.curve.p) >= 0)
15226 return false;
15227
15228 rx.redIAdd(t);
15229 if (this.x.cmp(rx) === 0)
15230 return true;
15231 }
15232};
15233
15234// Compatibility with BaseCurve
15235Point.prototype.toP = Point.prototype.normalize;
15236Point.prototype.mixedAdd = Point.prototype.add;
15237
15238},{"../../elliptic":86,"../curve":89,"bn.js":18,"inherits":119}],89:[function(require,module,exports){
15239'use strict';
15240
15241var curve = exports;
15242
15243curve.base = require('./base');
15244curve.short = require('./short');
15245curve.mont = require('./mont');
15246curve.edwards = require('./edwards');
15247
15248},{"./base":87,"./edwards":88,"./mont":90,"./short":91}],90:[function(require,module,exports){
15249'use strict';
15250
15251var curve = require('../curve');
15252var BN = require('bn.js');
15253var inherits = require('inherits');
15254var Base = curve.base;
15255
15256var elliptic = require('../../elliptic');
15257var utils = elliptic.utils;
15258
15259function MontCurve(conf) {
15260 Base.call(this, 'mont', conf);
15261
15262 this.a = new BN(conf.a, 16).toRed(this.red);
15263 this.b = new BN(conf.b, 16).toRed(this.red);
15264 this.i4 = new BN(4).toRed(this.red).redInvm();
15265 this.two = new BN(2).toRed(this.red);
15266 this.a24 = this.i4.redMul(this.a.redAdd(this.two));
15267}
15268inherits(MontCurve, Base);
15269module.exports = MontCurve;
15270
15271MontCurve.prototype.validate = function validate(point) {
15272 var x = point.normalize().x;
15273 var x2 = x.redSqr();
15274 var rhs = x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x);
15275 var y = rhs.redSqrt();
15276
15277 return y.redSqr().cmp(rhs) === 0;
15278};
15279
15280function Point(curve, x, z) {
15281 Base.BasePoint.call(this, curve, 'projective');
15282 if (x === null && z === null) {
15283 this.x = this.curve.one;
15284 this.z = this.curve.zero;
15285 } else {
15286 this.x = new BN(x, 16);
15287 this.z = new BN(z, 16);
15288 if (!this.x.red)
15289 this.x = this.x.toRed(this.curve.red);
15290 if (!this.z.red)
15291 this.z = this.z.toRed(this.curve.red);
15292 }
15293}
15294inherits(Point, Base.BasePoint);
15295
15296MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
15297 return this.point(utils.toArray(bytes, enc), 1);
15298};
15299
15300MontCurve.prototype.point = function point(x, z) {
15301 return new Point(this, x, z);
15302};
15303
15304MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
15305 return Point.fromJSON(this, obj);
15306};
15307
15308Point.prototype.precompute = function precompute() {
15309 // No-op
15310};
15311
15312Point.prototype._encode = function _encode() {
15313 return this.getX().toArray('be', this.curve.p.byteLength());
15314};
15315
15316Point.fromJSON = function fromJSON(curve, obj) {
15317 return new Point(curve, obj[0], obj[1] || curve.one);
15318};
15319
15320Point.prototype.inspect = function inspect() {
15321 if (this.isInfinity())
15322 return '<EC Point Infinity>';
15323 return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
15324 ' z: ' + this.z.fromRed().toString(16, 2) + '>';
15325};
15326
15327Point.prototype.isInfinity = function isInfinity() {
15328 // XXX This code assumes that zero is always zero in red
15329 return this.z.cmpn(0) === 0;
15330};
15331
15332Point.prototype.dbl = function dbl() {
15333 // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3
15334 // 2M + 2S + 4A
15335
15336 // A = X1 + Z1
15337 var a = this.x.redAdd(this.z);
15338 // AA = A^2
15339 var aa = a.redSqr();
15340 // B = X1 - Z1
15341 var b = this.x.redSub(this.z);
15342 // BB = B^2
15343 var bb = b.redSqr();
15344 // C = AA - BB
15345 var c = aa.redSub(bb);
15346 // X3 = AA * BB
15347 var nx = aa.redMul(bb);
15348 // Z3 = C * (BB + A24 * C)
15349 var nz = c.redMul(bb.redAdd(this.curve.a24.redMul(c)));
15350 return this.curve.point(nx, nz);
15351};
15352
15353Point.prototype.add = function add() {
15354 throw new Error('Not supported on Montgomery curve');
15355};
15356
15357Point.prototype.diffAdd = function diffAdd(p, diff) {
15358 // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3
15359 // 4M + 2S + 6A
15360
15361 // A = X2 + Z2
15362 var a = this.x.redAdd(this.z);
15363 // B = X2 - Z2
15364 var b = this.x.redSub(this.z);
15365 // C = X3 + Z3
15366 var c = p.x.redAdd(p.z);
15367 // D = X3 - Z3
15368 var d = p.x.redSub(p.z);
15369 // DA = D * A
15370 var da = d.redMul(a);
15371 // CB = C * B
15372 var cb = c.redMul(b);
15373 // X5 = Z1 * (DA + CB)^2
15374 var nx = diff.z.redMul(da.redAdd(cb).redSqr());
15375 // Z5 = X1 * (DA - CB)^2
15376 var nz = diff.x.redMul(da.redISub(cb).redSqr());
15377 return this.curve.point(nx, nz);
15378};
15379
15380Point.prototype.mul = function mul(k) {
15381 var t = k.clone();
15382 var a = this; // (N / 2) * Q + Q
15383 var b = this.curve.point(null, null); // (N / 2) * Q
15384 var c = this; // Q
15385
15386 for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1))
15387 bits.push(t.andln(1));
15388
15389 for (var i = bits.length - 1; i >= 0; i--) {
15390 if (bits[i] === 0) {
15391 // N * Q + Q = ((N / 2) * Q + Q)) + (N / 2) * Q
15392 a = a.diffAdd(b, c);
15393 // N * Q = 2 * ((N / 2) * Q + Q))
15394 b = b.dbl();
15395 } else {
15396 // N * Q = ((N / 2) * Q + Q) + ((N / 2) * Q)
15397 b = a.diffAdd(b, c);
15398 // N * Q + Q = 2 * ((N / 2) * Q + Q)
15399 a = a.dbl();
15400 }
15401 }
15402 return b;
15403};
15404
15405Point.prototype.mulAdd = function mulAdd() {
15406 throw new Error('Not supported on Montgomery curve');
15407};
15408
15409Point.prototype.jumlAdd = function jumlAdd() {
15410 throw new Error('Not supported on Montgomery curve');
15411};
15412
15413Point.prototype.eq = function eq(other) {
15414 return this.getX().cmp(other.getX()) === 0;
15415};
15416
15417Point.prototype.normalize = function normalize() {
15418 this.x = this.x.redMul(this.z.redInvm());
15419 this.z = this.curve.one;
15420 return this;
15421};
15422
15423Point.prototype.getX = function getX() {
15424 // Normalize coordinates
15425 this.normalize();
15426
15427 return this.x.fromRed();
15428};
15429
15430},{"../../elliptic":86,"../curve":89,"bn.js":18,"inherits":119}],91:[function(require,module,exports){
15431'use strict';
15432
15433var curve = require('../curve');
15434var elliptic = require('../../elliptic');
15435var BN = require('bn.js');
15436var inherits = require('inherits');
15437var Base = curve.base;
15438
15439var assert = elliptic.utils.assert;
15440
15441function ShortCurve(conf) {
15442 Base.call(this, 'short', conf);
15443
15444 this.a = new BN(conf.a, 16).toRed(this.red);
15445 this.b = new BN(conf.b, 16).toRed(this.red);
15446 this.tinv = this.two.redInvm();
15447
15448 this.zeroA = this.a.fromRed().cmpn(0) === 0;
15449 this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0;
15450
15451 // If the curve is endomorphic, precalculate beta and lambda
15452 this.endo = this._getEndomorphism(conf);
15453 this._endoWnafT1 = new Array(4);
15454 this._endoWnafT2 = new Array(4);
15455}
15456inherits(ShortCurve, Base);
15457module.exports = ShortCurve;
15458
15459ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) {
15460 // No efficient endomorphism
15461 if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)
15462 return;
15463
15464 // Compute beta and lambda, that lambda * P = (beta * Px; Py)
15465 var beta;
15466 var lambda;
15467 if (conf.beta) {
15468 beta = new BN(conf.beta, 16).toRed(this.red);
15469 } else {
15470 var betas = this._getEndoRoots(this.p);
15471 // Choose the smallest beta
15472 beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1];
15473 beta = beta.toRed(this.red);
15474 }
15475 if (conf.lambda) {
15476 lambda = new BN(conf.lambda, 16);
15477 } else {
15478 // Choose the lambda that is matching selected beta
15479 var lambdas = this._getEndoRoots(this.n);
15480 if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) {
15481 lambda = lambdas[0];
15482 } else {
15483 lambda = lambdas[1];
15484 assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0);
15485 }
15486 }
15487
15488 // Get basis vectors, used for balanced length-two representation
15489 var basis;
15490 if (conf.basis) {
15491 basis = conf.basis.map(function(vec) {
15492 return {
15493 a: new BN(vec.a, 16),
15494 b: new BN(vec.b, 16)
15495 };
15496 });
15497 } else {
15498 basis = this._getEndoBasis(lambda);
15499 }
15500
15501 return {
15502 beta: beta,
15503 lambda: lambda,
15504 basis: basis
15505 };
15506};
15507
15508ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) {
15509 // Find roots of for x^2 + x + 1 in F
15510 // Root = (-1 +- Sqrt(-3)) / 2
15511 //
15512 var red = num === this.p ? this.red : BN.mont(num);
15513 var tinv = new BN(2).toRed(red).redInvm();
15514 var ntinv = tinv.redNeg();
15515
15516 var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv);
15517
15518 var l1 = ntinv.redAdd(s).fromRed();
15519 var l2 = ntinv.redSub(s).fromRed();
15520 return [ l1, l2 ];
15521};
15522
15523ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) {
15524 // aprxSqrt >= sqrt(this.n)
15525 var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2));
15526
15527 // 3.74
15528 // Run EGCD, until r(L + 1) < aprxSqrt
15529 var u = lambda;
15530 var v = this.n.clone();
15531 var x1 = new BN(1);
15532 var y1 = new BN(0);
15533 var x2 = new BN(0);
15534 var y2 = new BN(1);
15535
15536 // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n)
15537 var a0;
15538 var b0;
15539 // First vector
15540 var a1;
15541 var b1;
15542 // Second vector
15543 var a2;
15544 var b2;
15545
15546 var prevR;
15547 var i = 0;
15548 var r;
15549 var x;
15550 while (u.cmpn(0) !== 0) {
15551 var q = v.div(u);
15552 r = v.sub(q.mul(u));
15553 x = x2.sub(q.mul(x1));
15554 var y = y2.sub(q.mul(y1));
15555
15556 if (!a1 && r.cmp(aprxSqrt) < 0) {
15557 a0 = prevR.neg();
15558 b0 = x1;
15559 a1 = r.neg();
15560 b1 = x;
15561 } else if (a1 && ++i === 2) {
15562 break;
15563 }
15564 prevR = r;
15565
15566 v = u;
15567 u = r;
15568 x2 = x1;
15569 x1 = x;
15570 y2 = y1;
15571 y1 = y;
15572 }
15573 a2 = r.neg();
15574 b2 = x;
15575
15576 var len1 = a1.sqr().add(b1.sqr());
15577 var len2 = a2.sqr().add(b2.sqr());
15578 if (len2.cmp(len1) >= 0) {
15579 a2 = a0;
15580 b2 = b0;
15581 }
15582
15583 // Normalize signs
15584 if (a1.negative) {
15585 a1 = a1.neg();
15586 b1 = b1.neg();
15587 }
15588 if (a2.negative) {
15589 a2 = a2.neg();
15590 b2 = b2.neg();
15591 }
15592
15593 return [
15594 { a: a1, b: b1 },
15595 { a: a2, b: b2 }
15596 ];
15597};
15598
15599ShortCurve.prototype._endoSplit = function _endoSplit(k) {
15600 var basis = this.endo.basis;
15601 var v1 = basis[0];
15602 var v2 = basis[1];
15603
15604 var c1 = v2.b.mul(k).divRound(this.n);
15605 var c2 = v1.b.neg().mul(k).divRound(this.n);
15606
15607 var p1 = c1.mul(v1.a);
15608 var p2 = c2.mul(v2.a);
15609 var q1 = c1.mul(v1.b);
15610 var q2 = c2.mul(v2.b);
15611
15612 // Calculate answer
15613 var k1 = k.sub(p1).sub(p2);
15614 var k2 = q1.add(q2).neg();
15615 return { k1: k1, k2: k2 };
15616};
15617
15618ShortCurve.prototype.pointFromX = function pointFromX(x, odd) {
15619 x = new BN(x, 16);
15620 if (!x.red)
15621 x = x.toRed(this.red);
15622
15623 var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b);
15624 var y = y2.redSqrt();
15625 if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
15626 throw new Error('invalid point');
15627
15628 // XXX Is there any way to tell if the number is odd without converting it
15629 // to non-red form?
15630 var isOdd = y.fromRed().isOdd();
15631 if (odd && !isOdd || !odd && isOdd)
15632 y = y.redNeg();
15633
15634 return this.point(x, y);
15635};
15636
15637ShortCurve.prototype.validate = function validate(point) {
15638 if (point.inf)
15639 return true;
15640
15641 var x = point.x;
15642 var y = point.y;
15643
15644 var ax = this.a.redMul(x);
15645 var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b);
15646 return y.redSqr().redISub(rhs).cmpn(0) === 0;
15647};
15648
15649ShortCurve.prototype._endoWnafMulAdd =
15650 function _endoWnafMulAdd(points, coeffs, jacobianResult) {
15651 var npoints = this._endoWnafT1;
15652 var ncoeffs = this._endoWnafT2;
15653 for (var i = 0; i < points.length; i++) {
15654 var split = this._endoSplit(coeffs[i]);
15655 var p = points[i];
15656 var beta = p._getBeta();
15657
15658 if (split.k1.negative) {
15659 split.k1.ineg();
15660 p = p.neg(true);
15661 }
15662 if (split.k2.negative) {
15663 split.k2.ineg();
15664 beta = beta.neg(true);
15665 }
15666
15667 npoints[i * 2] = p;
15668 npoints[i * 2 + 1] = beta;
15669 ncoeffs[i * 2] = split.k1;
15670 ncoeffs[i * 2 + 1] = split.k2;
15671 }
15672 var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult);
15673
15674 // Clean-up references to points and coefficients
15675 for (var j = 0; j < i * 2; j++) {
15676 npoints[j] = null;
15677 ncoeffs[j] = null;
15678 }
15679 return res;
15680};
15681
15682function Point(curve, x, y, isRed) {
15683 Base.BasePoint.call(this, curve, 'affine');
15684 if (x === null && y === null) {
15685 this.x = null;
15686 this.y = null;
15687 this.inf = true;
15688 } else {
15689 this.x = new BN(x, 16);
15690 this.y = new BN(y, 16);
15691 // Force redgomery representation when loading from JSON
15692 if (isRed) {
15693 this.x.forceRed(this.curve.red);
15694 this.y.forceRed(this.curve.red);
15695 }
15696 if (!this.x.red)
15697 this.x = this.x.toRed(this.curve.red);
15698 if (!this.y.red)
15699 this.y = this.y.toRed(this.curve.red);
15700 this.inf = false;
15701 }
15702}
15703inherits(Point, Base.BasePoint);
15704
15705ShortCurve.prototype.point = function point(x, y, isRed) {
15706 return new Point(this, x, y, isRed);
15707};
15708
15709ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) {
15710 return Point.fromJSON(this, obj, red);
15711};
15712
15713Point.prototype._getBeta = function _getBeta() {
15714 if (!this.curve.endo)
15715 return;
15716
15717 var pre = this.precomputed;
15718 if (pre && pre.beta)
15719 return pre.beta;
15720
15721 var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y);
15722 if (pre) {
15723 var curve = this.curve;
15724 var endoMul = function(p) {
15725 return curve.point(p.x.redMul(curve.endo.beta), p.y);
15726 };
15727 pre.beta = beta;
15728 beta.precomputed = {
15729 beta: null,
15730 naf: pre.naf && {
15731 wnd: pre.naf.wnd,
15732 points: pre.naf.points.map(endoMul)
15733 },
15734 doubles: pre.doubles && {
15735 step: pre.doubles.step,
15736 points: pre.doubles.points.map(endoMul)
15737 }
15738 };
15739 }
15740 return beta;
15741};
15742
15743Point.prototype.toJSON = function toJSON() {
15744 if (!this.precomputed)
15745 return [ this.x, this.y ];
15746
15747 return [ this.x, this.y, this.precomputed && {
15748 doubles: this.precomputed.doubles && {
15749 step: this.precomputed.doubles.step,
15750 points: this.precomputed.doubles.points.slice(1)
15751 },
15752 naf: this.precomputed.naf && {
15753 wnd: this.precomputed.naf.wnd,
15754 points: this.precomputed.naf.points.slice(1)
15755 }
15756 } ];
15757};
15758
15759Point.fromJSON = function fromJSON(curve, obj, red) {
15760 if (typeof obj === 'string')
15761 obj = JSON.parse(obj);
15762 var res = curve.point(obj[0], obj[1], red);
15763 if (!obj[2])
15764 return res;
15765
15766 function obj2point(obj) {
15767 return curve.point(obj[0], obj[1], red);
15768 }
15769
15770 var pre = obj[2];
15771 res.precomputed = {
15772 beta: null,
15773 doubles: pre.doubles && {
15774 step: pre.doubles.step,
15775 points: [ res ].concat(pre.doubles.points.map(obj2point))
15776 },
15777 naf: pre.naf && {
15778 wnd: pre.naf.wnd,
15779 points: [ res ].concat(pre.naf.points.map(obj2point))
15780 }
15781 };
15782 return res;
15783};
15784
15785Point.prototype.inspect = function inspect() {
15786 if (this.isInfinity())
15787 return '<EC Point Infinity>';
15788 return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
15789 ' y: ' + this.y.fromRed().toString(16, 2) + '>';
15790};
15791
15792Point.prototype.isInfinity = function isInfinity() {
15793 return this.inf;
15794};
15795
15796Point.prototype.add = function add(p) {
15797 // O + P = P
15798 if (this.inf)
15799 return p;
15800
15801 // P + O = P
15802 if (p.inf)
15803 return this;
15804
15805 // P + P = 2P
15806 if (this.eq(p))
15807 return this.dbl();
15808
15809 // P + (-P) = O
15810 if (this.neg().eq(p))
15811 return this.curve.point(null, null);
15812
15813 // P + Q = O
15814 if (this.x.cmp(p.x) === 0)
15815 return this.curve.point(null, null);
15816
15817 var c = this.y.redSub(p.y);
15818 if (c.cmpn(0) !== 0)
15819 c = c.redMul(this.x.redSub(p.x).redInvm());
15820 var nx = c.redSqr().redISub(this.x).redISub(p.x);
15821 var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
15822 return this.curve.point(nx, ny);
15823};
15824
15825Point.prototype.dbl = function dbl() {
15826 if (this.inf)
15827 return this;
15828
15829 // 2P = O
15830 var ys1 = this.y.redAdd(this.y);
15831 if (ys1.cmpn(0) === 0)
15832 return this.curve.point(null, null);
15833
15834 var a = this.curve.a;
15835
15836 var x2 = this.x.redSqr();
15837 var dyinv = ys1.redInvm();
15838 var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv);
15839
15840 var nx = c.redSqr().redISub(this.x.redAdd(this.x));
15841 var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
15842 return this.curve.point(nx, ny);
15843};
15844
15845Point.prototype.getX = function getX() {
15846 return this.x.fromRed();
15847};
15848
15849Point.prototype.getY = function getY() {
15850 return this.y.fromRed();
15851};
15852
15853Point.prototype.mul = function mul(k) {
15854 k = new BN(k, 16);
15855
15856 if (this._hasDoubles(k))
15857 return this.curve._fixedNafMul(this, k);
15858 else if (this.curve.endo)
15859 return this.curve._endoWnafMulAdd([ this ], [ k ]);
15860 else
15861 return this.curve._wnafMul(this, k);
15862};
15863
15864Point.prototype.mulAdd = function mulAdd(k1, p2, k2) {
15865 var points = [ this, p2 ];
15866 var coeffs = [ k1, k2 ];
15867 if (this.curve.endo)
15868 return this.curve._endoWnafMulAdd(points, coeffs);
15869 else
15870 return this.curve._wnafMulAdd(1, points, coeffs, 2);
15871};
15872
15873Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) {
15874 var points = [ this, p2 ];
15875 var coeffs = [ k1, k2 ];
15876 if (this.curve.endo)
15877 return this.curve._endoWnafMulAdd(points, coeffs, true);
15878 else
15879 return this.curve._wnafMulAdd(1, points, coeffs, 2, true);
15880};
15881
15882Point.prototype.eq = function eq(p) {
15883 return this === p ||
15884 this.inf === p.inf &&
15885 (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0);
15886};
15887
15888Point.prototype.neg = function neg(_precompute) {
15889 if (this.inf)
15890 return this;
15891
15892 var res = this.curve.point(this.x, this.y.redNeg());
15893 if (_precompute && this.precomputed) {
15894 var pre = this.precomputed;
15895 var negate = function(p) {
15896 return p.neg();
15897 };
15898 res.precomputed = {
15899 naf: pre.naf && {
15900 wnd: pre.naf.wnd,
15901 points: pre.naf.points.map(negate)
15902 },
15903 doubles: pre.doubles && {
15904 step: pre.doubles.step,
15905 points: pre.doubles.points.map(negate)
15906 }
15907 };
15908 }
15909 return res;
15910};
15911
15912Point.prototype.toJ = function toJ() {
15913 if (this.inf)
15914 return this.curve.jpoint(null, null, null);
15915
15916 var res = this.curve.jpoint(this.x, this.y, this.curve.one);
15917 return res;
15918};
15919
15920function JPoint(curve, x, y, z) {
15921 Base.BasePoint.call(this, curve, 'jacobian');
15922 if (x === null && y === null && z === null) {
15923 this.x = this.curve.one;
15924 this.y = this.curve.one;
15925 this.z = new BN(0);
15926 } else {
15927 this.x = new BN(x, 16);
15928 this.y = new BN(y, 16);
15929 this.z = new BN(z, 16);
15930 }
15931 if (!this.x.red)
15932 this.x = this.x.toRed(this.curve.red);
15933 if (!this.y.red)
15934 this.y = this.y.toRed(this.curve.red);
15935 if (!this.z.red)
15936 this.z = this.z.toRed(this.curve.red);
15937
15938 this.zOne = this.z === this.curve.one;
15939}
15940inherits(JPoint, Base.BasePoint);
15941
15942ShortCurve.prototype.jpoint = function jpoint(x, y, z) {
15943 return new JPoint(this, x, y, z);
15944};
15945
15946JPoint.prototype.toP = function toP() {
15947 if (this.isInfinity())
15948 return this.curve.point(null, null);
15949
15950 var zinv = this.z.redInvm();
15951 var zinv2 = zinv.redSqr();
15952 var ax = this.x.redMul(zinv2);
15953 var ay = this.y.redMul(zinv2).redMul(zinv);
15954
15955 return this.curve.point(ax, ay);
15956};
15957
15958JPoint.prototype.neg = function neg() {
15959 return this.curve.jpoint(this.x, this.y.redNeg(), this.z);
15960};
15961
15962JPoint.prototype.add = function add(p) {
15963 // O + P = P
15964 if (this.isInfinity())
15965 return p;
15966
15967 // P + O = P
15968 if (p.isInfinity())
15969 return this;
15970
15971 // 12M + 4S + 7A
15972 var pz2 = p.z.redSqr();
15973 var z2 = this.z.redSqr();
15974 var u1 = this.x.redMul(pz2);
15975 var u2 = p.x.redMul(z2);
15976 var s1 = this.y.redMul(pz2.redMul(p.z));
15977 var s2 = p.y.redMul(z2.redMul(this.z));
15978
15979 var h = u1.redSub(u2);
15980 var r = s1.redSub(s2);
15981 if (h.cmpn(0) === 0) {
15982 if (r.cmpn(0) !== 0)
15983 return this.curve.jpoint(null, null, null);
15984 else
15985 return this.dbl();
15986 }
15987
15988 var h2 = h.redSqr();
15989 var h3 = h2.redMul(h);
15990 var v = u1.redMul(h2);
15991
15992 var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
15993 var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
15994 var nz = this.z.redMul(p.z).redMul(h);
15995
15996 return this.curve.jpoint(nx, ny, nz);
15997};
15998
15999JPoint.prototype.mixedAdd = function mixedAdd(p) {
16000 // O + P = P
16001 if (this.isInfinity())
16002 return p.toJ();
16003
16004 // P + O = P
16005 if (p.isInfinity())
16006 return this;
16007
16008 // 8M + 3S + 7A
16009 var z2 = this.z.redSqr();
16010 var u1 = this.x;
16011 var u2 = p.x.redMul(z2);
16012 var s1 = this.y;
16013 var s2 = p.y.redMul(z2).redMul(this.z);
16014
16015 var h = u1.redSub(u2);
16016 var r = s1.redSub(s2);
16017 if (h.cmpn(0) === 0) {
16018 if (r.cmpn(0) !== 0)
16019 return this.curve.jpoint(null, null, null);
16020 else
16021 return this.dbl();
16022 }
16023
16024 var h2 = h.redSqr();
16025 var h3 = h2.redMul(h);
16026 var v = u1.redMul(h2);
16027
16028 var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
16029 var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
16030 var nz = this.z.redMul(h);
16031
16032 return this.curve.jpoint(nx, ny, nz);
16033};
16034
16035JPoint.prototype.dblp = function dblp(pow) {
16036 if (pow === 0)
16037 return this;
16038 if (this.isInfinity())
16039 return this;
16040 if (!pow)
16041 return this.dbl();
16042
16043 if (this.curve.zeroA || this.curve.threeA) {
16044 var r = this;
16045 for (var i = 0; i < pow; i++)
16046 r = r.dbl();
16047 return r;
16048 }
16049
16050 // 1M + 2S + 1A + N * (4S + 5M + 8A)
16051 // N = 1 => 6M + 6S + 9A
16052 var a = this.curve.a;
16053 var tinv = this.curve.tinv;
16054
16055 var jx = this.x;
16056 var jy = this.y;
16057 var jz = this.z;
16058 var jz4 = jz.redSqr().redSqr();
16059
16060 // Reuse results
16061 var jyd = jy.redAdd(jy);
16062 for (var i = 0; i < pow; i++) {
16063 var jx2 = jx.redSqr();
16064 var jyd2 = jyd.redSqr();
16065 var jyd4 = jyd2.redSqr();
16066 var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
16067
16068 var t1 = jx.redMul(jyd2);
16069 var nx = c.redSqr().redISub(t1.redAdd(t1));
16070 var t2 = t1.redISub(nx);
16071 var dny = c.redMul(t2);
16072 dny = dny.redIAdd(dny).redISub(jyd4);
16073 var nz = jyd.redMul(jz);
16074 if (i + 1 < pow)
16075 jz4 = jz4.redMul(jyd4);
16076
16077 jx = nx;
16078 jz = nz;
16079 jyd = dny;
16080 }
16081
16082 return this.curve.jpoint(jx, jyd.redMul(tinv), jz);
16083};
16084
16085JPoint.prototype.dbl = function dbl() {
16086 if (this.isInfinity())
16087 return this;
16088
16089 if (this.curve.zeroA)
16090 return this._zeroDbl();
16091 else if (this.curve.threeA)
16092 return this._threeDbl();
16093 else
16094 return this._dbl();
16095};
16096
16097JPoint.prototype._zeroDbl = function _zeroDbl() {
16098 var nx;
16099 var ny;
16100 var nz;
16101 // Z = 1
16102 if (this.zOne) {
16103 // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
16104 // #doubling-mdbl-2007-bl
16105 // 1M + 5S + 14A
16106
16107 // XX = X1^2
16108 var xx = this.x.redSqr();
16109 // YY = Y1^2
16110 var yy = this.y.redSqr();
16111 // YYYY = YY^2
16112 var yyyy = yy.redSqr();
16113 // S = 2 * ((X1 + YY)^2 - XX - YYYY)
16114 var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
16115 s = s.redIAdd(s);
16116 // M = 3 * XX + a; a = 0
16117 var m = xx.redAdd(xx).redIAdd(xx);
16118 // T = M ^ 2 - 2*S
16119 var t = m.redSqr().redISub(s).redISub(s);
16120
16121 // 8 * YYYY
16122 var yyyy8 = yyyy.redIAdd(yyyy);
16123 yyyy8 = yyyy8.redIAdd(yyyy8);
16124 yyyy8 = yyyy8.redIAdd(yyyy8);
16125
16126 // X3 = T
16127 nx = t;
16128 // Y3 = M * (S - T) - 8 * YYYY
16129 ny = m.redMul(s.redISub(t)).redISub(yyyy8);
16130 // Z3 = 2*Y1
16131 nz = this.y.redAdd(this.y);
16132 } else {
16133 // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
16134 // #doubling-dbl-2009-l
16135 // 2M + 5S + 13A
16136
16137 // A = X1^2
16138 var a = this.x.redSqr();
16139 // B = Y1^2
16140 var b = this.y.redSqr();
16141 // C = B^2
16142 var c = b.redSqr();
16143 // D = 2 * ((X1 + B)^2 - A - C)
16144 var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c);
16145 d = d.redIAdd(d);
16146 // E = 3 * A
16147 var e = a.redAdd(a).redIAdd(a);
16148 // F = E^2
16149 var f = e.redSqr();
16150
16151 // 8 * C
16152 var c8 = c.redIAdd(c);
16153 c8 = c8.redIAdd(c8);
16154 c8 = c8.redIAdd(c8);
16155
16156 // X3 = F - 2 * D
16157 nx = f.redISub(d).redISub(d);
16158 // Y3 = E * (D - X3) - 8 * C
16159 ny = e.redMul(d.redISub(nx)).redISub(c8);
16160 // Z3 = 2 * Y1 * Z1
16161 nz = this.y.redMul(this.z);
16162 nz = nz.redIAdd(nz);
16163 }
16164
16165 return this.curve.jpoint(nx, ny, nz);
16166};
16167
16168JPoint.prototype._threeDbl = function _threeDbl() {
16169 var nx;
16170 var ny;
16171 var nz;
16172 // Z = 1
16173 if (this.zOne) {
16174 // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html
16175 // #doubling-mdbl-2007-bl
16176 // 1M + 5S + 15A
16177
16178 // XX = X1^2
16179 var xx = this.x.redSqr();
16180 // YY = Y1^2
16181 var yy = this.y.redSqr();
16182 // YYYY = YY^2
16183 var yyyy = yy.redSqr();
16184 // S = 2 * ((X1 + YY)^2 - XX - YYYY)
16185 var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
16186 s = s.redIAdd(s);
16187 // M = 3 * XX + a
16188 var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a);
16189 // T = M^2 - 2 * S
16190 var t = m.redSqr().redISub(s).redISub(s);
16191 // X3 = T
16192 nx = t;
16193 // Y3 = M * (S - T) - 8 * YYYY
16194 var yyyy8 = yyyy.redIAdd(yyyy);
16195 yyyy8 = yyyy8.redIAdd(yyyy8);
16196 yyyy8 = yyyy8.redIAdd(yyyy8);
16197 ny = m.redMul(s.redISub(t)).redISub(yyyy8);
16198 // Z3 = 2 * Y1
16199 nz = this.y.redAdd(this.y);
16200 } else {
16201 // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b
16202 // 3M + 5S
16203
16204 // delta = Z1^2
16205 var delta = this.z.redSqr();
16206 // gamma = Y1^2
16207 var gamma = this.y.redSqr();
16208 // beta = X1 * gamma
16209 var beta = this.x.redMul(gamma);
16210 // alpha = 3 * (X1 - delta) * (X1 + delta)
16211 var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta));
16212 alpha = alpha.redAdd(alpha).redIAdd(alpha);
16213 // X3 = alpha^2 - 8 * beta
16214 var beta4 = beta.redIAdd(beta);
16215 beta4 = beta4.redIAdd(beta4);
16216 var beta8 = beta4.redAdd(beta4);
16217 nx = alpha.redSqr().redISub(beta8);
16218 // Z3 = (Y1 + Z1)^2 - gamma - delta
16219 nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta);
16220 // Y3 = alpha * (4 * beta - X3) - 8 * gamma^2
16221 var ggamma8 = gamma.redSqr();
16222 ggamma8 = ggamma8.redIAdd(ggamma8);
16223 ggamma8 = ggamma8.redIAdd(ggamma8);
16224 ggamma8 = ggamma8.redIAdd(ggamma8);
16225 ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8);
16226 }
16227
16228 return this.curve.jpoint(nx, ny, nz);
16229};
16230
16231JPoint.prototype._dbl = function _dbl() {
16232 var a = this.curve.a;
16233
16234 // 4M + 6S + 10A
16235 var jx = this.x;
16236 var jy = this.y;
16237 var jz = this.z;
16238 var jz4 = jz.redSqr().redSqr();
16239
16240 var jx2 = jx.redSqr();
16241 var jy2 = jy.redSqr();
16242
16243 var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
16244
16245 var jxd4 = jx.redAdd(jx);
16246 jxd4 = jxd4.redIAdd(jxd4);
16247 var t1 = jxd4.redMul(jy2);
16248 var nx = c.redSqr().redISub(t1.redAdd(t1));
16249 var t2 = t1.redISub(nx);
16250
16251 var jyd8 = jy2.redSqr();
16252 jyd8 = jyd8.redIAdd(jyd8);
16253 jyd8 = jyd8.redIAdd(jyd8);
16254 jyd8 = jyd8.redIAdd(jyd8);
16255 var ny = c.redMul(t2).redISub(jyd8);
16256 var nz = jy.redAdd(jy).redMul(jz);
16257
16258 return this.curve.jpoint(nx, ny, nz);
16259};
16260
16261JPoint.prototype.trpl = function trpl() {
16262 if (!this.curve.zeroA)
16263 return this.dbl().add(this);
16264
16265 // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl
16266 // 5M + 10S + ...
16267
16268 // XX = X1^2
16269 var xx = this.x.redSqr();
16270 // YY = Y1^2
16271 var yy = this.y.redSqr();
16272 // ZZ = Z1^2
16273 var zz = this.z.redSqr();
16274 // YYYY = YY^2
16275 var yyyy = yy.redSqr();
16276 // M = 3 * XX + a * ZZ2; a = 0
16277 var m = xx.redAdd(xx).redIAdd(xx);
16278 // MM = M^2
16279 var mm = m.redSqr();
16280 // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM
16281 var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
16282 e = e.redIAdd(e);
16283 e = e.redAdd(e).redIAdd(e);
16284 e = e.redISub(mm);
16285 // EE = E^2
16286 var ee = e.redSqr();
16287 // T = 16*YYYY
16288 var t = yyyy.redIAdd(yyyy);
16289 t = t.redIAdd(t);
16290 t = t.redIAdd(t);
16291 t = t.redIAdd(t);
16292 // U = (M + E)^2 - MM - EE - T
16293 var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t);
16294 // X3 = 4 * (X1 * EE - 4 * YY * U)
16295 var yyu4 = yy.redMul(u);
16296 yyu4 = yyu4.redIAdd(yyu4);
16297 yyu4 = yyu4.redIAdd(yyu4);
16298 var nx = this.x.redMul(ee).redISub(yyu4);
16299 nx = nx.redIAdd(nx);
16300 nx = nx.redIAdd(nx);
16301 // Y3 = 8 * Y1 * (U * (T - U) - E * EE)
16302 var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee)));
16303 ny = ny.redIAdd(ny);
16304 ny = ny.redIAdd(ny);
16305 ny = ny.redIAdd(ny);
16306 // Z3 = (Z1 + E)^2 - ZZ - EE
16307 var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee);
16308
16309 return this.curve.jpoint(nx, ny, nz);
16310};
16311
16312JPoint.prototype.mul = function mul(k, kbase) {
16313 k = new BN(k, kbase);
16314
16315 return this.curve._wnafMul(this, k);
16316};
16317
16318JPoint.prototype.eq = function eq(p) {
16319 if (p.type === 'affine')
16320 return this.eq(p.toJ());
16321
16322 if (this === p)
16323 return true;
16324
16325 // x1 * z2^2 == x2 * z1^2
16326 var z2 = this.z.redSqr();
16327 var pz2 = p.z.redSqr();
16328 if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0)
16329 return false;
16330
16331 // y1 * z2^3 == y2 * z1^3
16332 var z3 = z2.redMul(this.z);
16333 var pz3 = pz2.redMul(p.z);
16334 return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0;
16335};
16336
16337JPoint.prototype.eqXToP = function eqXToP(x) {
16338 var zs = this.z.redSqr();
16339 var rx = x.toRed(this.curve.red).redMul(zs);
16340 if (this.x.cmp(rx) === 0)
16341 return true;
16342
16343 var xc = x.clone();
16344 var t = this.curve.redN.redMul(zs);
16345 for (;;) {
16346 xc.iadd(this.curve.n);
16347 if (xc.cmp(this.curve.p) >= 0)
16348 return false;
16349
16350 rx.redIAdd(t);
16351 if (this.x.cmp(rx) === 0)
16352 return true;
16353 }
16354};
16355
16356JPoint.prototype.inspect = function inspect() {
16357 if (this.isInfinity())
16358 return '<EC JPoint Infinity>';
16359 return '<EC JPoint x: ' + this.x.toString(16, 2) +
16360 ' y: ' + this.y.toString(16, 2) +
16361 ' z: ' + this.z.toString(16, 2) + '>';
16362};
16363
16364JPoint.prototype.isInfinity = function isInfinity() {
16365 // XXX This code assumes that zero is always zero in red
16366 return this.z.cmpn(0) === 0;
16367};
16368
16369},{"../../elliptic":86,"../curve":89,"bn.js":18,"inherits":119}],92:[function(require,module,exports){
16370'use strict';
16371
16372var curves = exports;
16373
16374var hash = require('hash.js');
16375var elliptic = require('../elliptic');
16376
16377var assert = elliptic.utils.assert;
16378
16379function PresetCurve(options) {
16380 if (options.type === 'short')
16381 this.curve = new elliptic.curve.short(options);
16382 else if (options.type === 'edwards')
16383 this.curve = new elliptic.curve.edwards(options);
16384 else
16385 this.curve = new elliptic.curve.mont(options);
16386 this.g = this.curve.g;
16387 this.n = this.curve.n;
16388 this.hash = options.hash;
16389
16390 assert(this.g.validate(), 'Invalid curve');
16391 assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O');
16392}
16393curves.PresetCurve = PresetCurve;
16394
16395function defineCurve(name, options) {
16396 Object.defineProperty(curves, name, {
16397 configurable: true,
16398 enumerable: true,
16399 get: function() {
16400 var curve = new PresetCurve(options);
16401 Object.defineProperty(curves, name, {
16402 configurable: true,
16403 enumerable: true,
16404 value: curve
16405 });
16406 return curve;
16407 }
16408 });
16409}
16410
16411defineCurve('p192', {
16412 type: 'short',
16413 prime: 'p192',
16414 p: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff',
16415 a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc',
16416 b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1',
16417 n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831',
16418 hash: hash.sha256,
16419 gRed: false,
16420 g: [
16421 '188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012',
16422 '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811'
16423 ]
16424});
16425
16426defineCurve('p224', {
16427 type: 'short',
16428 prime: 'p224',
16429 p: 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001',
16430 a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe',
16431 b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4',
16432 n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d',
16433 hash: hash.sha256,
16434 gRed: false,
16435 g: [
16436 'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21',
16437 'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34'
16438 ]
16439});
16440
16441defineCurve('p256', {
16442 type: 'short',
16443 prime: null,
16444 p: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff',
16445 a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc',
16446 b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b',
16447 n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551',
16448 hash: hash.sha256,
16449 gRed: false,
16450 g: [
16451 '6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296',
16452 '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5'
16453 ]
16454});
16455
16456defineCurve('p384', {
16457 type: 'short',
16458 prime: null,
16459 p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
16460 'fffffffe ffffffff 00000000 00000000 ffffffff',
16461 a: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
16462 'fffffffe ffffffff 00000000 00000000 fffffffc',
16463 b: 'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f ' +
16464 '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef',
16465 n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' +
16466 'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973',
16467 hash: hash.sha384,
16468 gRed: false,
16469 g: [
16470 'aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' +
16471 '5502f25d bf55296c 3a545e38 72760ab7',
16472 '3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' +
16473 '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f'
16474 ]
16475});
16476
16477defineCurve('p521', {
16478 type: 'short',
16479 prime: null,
16480 p: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
16481 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
16482 'ffffffff ffffffff ffffffff ffffffff ffffffff',
16483 a: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
16484 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
16485 'ffffffff ffffffff ffffffff ffffffff fffffffc',
16486 b: '00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b ' +
16487 '99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd ' +
16488 '3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00',
16489 n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
16490 'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' +
16491 'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409',
16492 hash: hash.sha512,
16493 gRed: false,
16494 g: [
16495 '000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' +
16496 '053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 ' +
16497 'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66',
16498 '00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' +
16499 '579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' +
16500 '3fad0761 353c7086 a272c240 88be9476 9fd16650'
16501 ]
16502});
16503
16504defineCurve('curve25519', {
16505 type: 'mont',
16506 prime: 'p25519',
16507 p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
16508 a: '76d06',
16509 b: '1',
16510 n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
16511 hash: hash.sha256,
16512 gRed: false,
16513 g: [
16514 '9'
16515 ]
16516});
16517
16518defineCurve('ed25519', {
16519 type: 'edwards',
16520 prime: 'p25519',
16521 p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
16522 a: '-1',
16523 c: '1',
16524 // -121665 * (121666^(-1)) (mod P)
16525 d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3',
16526 n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
16527 hash: hash.sha256,
16528 gRed: false,
16529 g: [
16530 '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a',
16531
16532 // 4/5
16533 '6666666666666666666666666666666666666666666666666666666666666658'
16534 ]
16535});
16536
16537var pre;
16538try {
16539 pre = require('./precomputed/secp256k1');
16540} catch (e) {
16541 pre = undefined;
16542}
16543
16544defineCurve('secp256k1', {
16545 type: 'short',
16546 prime: 'k256',
16547 p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f',
16548 a: '0',
16549 b: '7',
16550 n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141',
16551 h: '1',
16552 hash: hash.sha256,
16553
16554 // Precomputed endomorphism
16555 beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee',
16556 lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72',
16557 basis: [
16558 {
16559 a: '3086d221a7d46bcde86c90e49284eb15',
16560 b: '-e4437ed6010e88286f547fa90abfe4c3'
16561 },
16562 {
16563 a: '114ca50f7a8e2f3f657c1108d9d44cfd8',
16564 b: '3086d221a7d46bcde86c90e49284eb15'
16565 }
16566 ],
16567
16568 gRed: false,
16569 g: [
16570 '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
16571 '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8',
16572 pre
16573 ]
16574});
16575
16576},{"../elliptic":86,"./precomputed/secp256k1":99,"hash.js":105}],93:[function(require,module,exports){
16577'use strict';
16578
16579var BN = require('bn.js');
16580var HmacDRBG = require('hmac-drbg');
16581var elliptic = require('../../elliptic');
16582var utils = elliptic.utils;
16583var assert = utils.assert;
16584
16585var KeyPair = require('./key');
16586var Signature = require('./signature');
16587
16588function EC(options) {
16589 if (!(this instanceof EC))
16590 return new EC(options);
16591
16592 // Shortcut `elliptic.ec(curve-name)`
16593 if (typeof options === 'string') {
16594 assert(elliptic.curves.hasOwnProperty(options), 'Unknown curve ' + options);
16595
16596 options = elliptic.curves[options];
16597 }
16598
16599 // Shortcut for `elliptic.ec(elliptic.curves.curveName)`
16600 if (options instanceof elliptic.curves.PresetCurve)
16601 options = { curve: options };
16602
16603 this.curve = options.curve.curve;
16604 this.n = this.curve.n;
16605 this.nh = this.n.ushrn(1);
16606 this.g = this.curve.g;
16607
16608 // Point on curve
16609 this.g = options.curve.g;
16610 this.g.precompute(options.curve.n.bitLength() + 1);
16611
16612 // Hash for function for DRBG
16613 this.hash = options.hash || options.curve.hash;
16614}
16615module.exports = EC;
16616
16617EC.prototype.keyPair = function keyPair(options) {
16618 return new KeyPair(this, options);
16619};
16620
16621EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) {
16622 return KeyPair.fromPrivate(this, priv, enc);
16623};
16624
16625EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) {
16626 return KeyPair.fromPublic(this, pub, enc);
16627};
16628
16629EC.prototype.genKeyPair = function genKeyPair(options) {
16630 if (!options)
16631 options = {};
16632
16633 // Instantiate Hmac_DRBG
16634 var drbg = new HmacDRBG({
16635 hash: this.hash,
16636 pers: options.pers,
16637 persEnc: options.persEnc || 'utf8',
16638 entropy: options.entropy || elliptic.rand(this.hash.hmacStrength),
16639 entropyEnc: options.entropy && options.entropyEnc || 'utf8',
16640 nonce: this.n.toArray()
16641 });
16642
16643 var bytes = this.n.byteLength();
16644 var ns2 = this.n.sub(new BN(2));
16645 do {
16646 var priv = new BN(drbg.generate(bytes));
16647 if (priv.cmp(ns2) > 0)
16648 continue;
16649
16650 priv.iaddn(1);
16651 return this.keyFromPrivate(priv);
16652 } while (true);
16653};
16654
16655EC.prototype._truncateToN = function truncateToN(msg, truncOnly) {
16656 var delta = msg.byteLength() * 8 - this.n.bitLength();
16657 if (delta > 0)
16658 msg = msg.ushrn(delta);
16659 if (!truncOnly && msg.cmp(this.n) >= 0)
16660 return msg.sub(this.n);
16661 else
16662 return msg;
16663};
16664
16665EC.prototype.sign = function sign(msg, key, enc, options) {
16666 if (typeof enc === 'object') {
16667 options = enc;
16668 enc = null;
16669 }
16670 if (!options)
16671 options = {};
16672
16673 key = this.keyFromPrivate(key, enc);
16674 msg = this._truncateToN(new BN(msg, 16));
16675
16676 // Zero-extend key to provide enough entropy
16677 var bytes = this.n.byteLength();
16678 var bkey = key.getPrivate().toArray('be', bytes);
16679
16680 // Zero-extend nonce to have the same byte size as N
16681 var nonce = msg.toArray('be', bytes);
16682
16683 // Instantiate Hmac_DRBG
16684 var drbg = new HmacDRBG({
16685 hash: this.hash,
16686 entropy: bkey,
16687 nonce: nonce,
16688 pers: options.pers,
16689 persEnc: options.persEnc || 'utf8'
16690 });
16691
16692 // Number of bytes to generate
16693 var ns1 = this.n.sub(new BN(1));
16694
16695 for (var iter = 0; true; iter++) {
16696 var k = options.k ?
16697 options.k(iter) :
16698 new BN(drbg.generate(this.n.byteLength()));
16699 k = this._truncateToN(k, true);
16700 if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0)
16701 continue;
16702
16703 var kp = this.g.mul(k);
16704 if (kp.isInfinity())
16705 continue;
16706
16707 var kpX = kp.getX();
16708 var r = kpX.umod(this.n);
16709 if (r.cmpn(0) === 0)
16710 continue;
16711
16712 var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg));
16713 s = s.umod(this.n);
16714 if (s.cmpn(0) === 0)
16715 continue;
16716
16717 var recoveryParam = (kp.getY().isOdd() ? 1 : 0) |
16718 (kpX.cmp(r) !== 0 ? 2 : 0);
16719
16720 // Use complement of `s`, if it is > `n / 2`
16721 if (options.canonical && s.cmp(this.nh) > 0) {
16722 s = this.n.sub(s);
16723 recoveryParam ^= 1;
16724 }
16725
16726 return new Signature({ r: r, s: s, recoveryParam: recoveryParam });
16727 }
16728};
16729
16730EC.prototype.verify = function verify(msg, signature, key, enc) {
16731 msg = this._truncateToN(new BN(msg, 16));
16732 key = this.keyFromPublic(key, enc);
16733 signature = new Signature(signature, 'hex');
16734
16735 // Perform primitive values validation
16736 var r = signature.r;
16737 var s = signature.s;
16738 if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0)
16739 return false;
16740 if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0)
16741 return false;
16742
16743 // Validate signature
16744 var sinv = s.invm(this.n);
16745 var u1 = sinv.mul(msg).umod(this.n);
16746 var u2 = sinv.mul(r).umod(this.n);
16747
16748 if (!this.curve._maxwellTrick) {
16749 var p = this.g.mulAdd(u1, key.getPublic(), u2);
16750 if (p.isInfinity())
16751 return false;
16752
16753 return p.getX().umod(this.n).cmp(r) === 0;
16754 }
16755
16756 // NOTE: Greg Maxwell's trick, inspired by:
16757 // https://git.io/vad3K
16758
16759 var p = this.g.jmulAdd(u1, key.getPublic(), u2);
16760 if (p.isInfinity())
16761 return false;
16762
16763 // Compare `p.x` of Jacobian point with `r`,
16764 // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the
16765 // inverse of `p.z^2`
16766 return p.eqXToP(r);
16767};
16768
16769EC.prototype.recoverPubKey = function(msg, signature, j, enc) {
16770 assert((3 & j) === j, 'The recovery param is more than two bits');
16771 signature = new Signature(signature, enc);
16772
16773 var n = this.n;
16774 var e = new BN(msg);
16775 var r = signature.r;
16776 var s = signature.s;
16777
16778 // A set LSB signifies that the y-coordinate is odd
16779 var isYOdd = j & 1;
16780 var isSecondKey = j >> 1;
16781 if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey)
16782 throw new Error('Unable to find sencond key candinate');
16783
16784 // 1.1. Let x = r + jn.
16785 if (isSecondKey)
16786 r = this.curve.pointFromX(r.add(this.curve.n), isYOdd);
16787 else
16788 r = this.curve.pointFromX(r, isYOdd);
16789
16790 var rInv = signature.r.invm(n);
16791 var s1 = n.sub(e).mul(rInv).umod(n);
16792 var s2 = s.mul(rInv).umod(n);
16793
16794 // 1.6.1 Compute Q = r^-1 (sR - eG)
16795 // Q = r^-1 (sR + -eG)
16796 return this.g.mulAdd(s1, r, s2);
16797};
16798
16799EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) {
16800 signature = new Signature(signature, enc);
16801 if (signature.recoveryParam !== null)
16802 return signature.recoveryParam;
16803
16804 for (var i = 0; i < 4; i++) {
16805 var Qprime;
16806 try {
16807 Qprime = this.recoverPubKey(e, signature, i);
16808 } catch (e) {
16809 continue;
16810 }
16811
16812 if (Qprime.eq(Q))
16813 return i;
16814 }
16815 throw new Error('Unable to find valid recovery factor');
16816};
16817
16818},{"../../elliptic":86,"./key":94,"./signature":95,"bn.js":18,"hmac-drbg":117}],94:[function(require,module,exports){
16819'use strict';
16820
16821var BN = require('bn.js');
16822var elliptic = require('../../elliptic');
16823var utils = elliptic.utils;
16824var assert = utils.assert;
16825
16826function KeyPair(ec, options) {
16827 this.ec = ec;
16828 this.priv = null;
16829 this.pub = null;
16830
16831 // KeyPair(ec, { priv: ..., pub: ... })
16832 if (options.priv)
16833 this._importPrivate(options.priv, options.privEnc);
16834 if (options.pub)
16835 this._importPublic(options.pub, options.pubEnc);
16836}
16837module.exports = KeyPair;
16838
16839KeyPair.fromPublic = function fromPublic(ec, pub, enc) {
16840 if (pub instanceof KeyPair)
16841 return pub;
16842
16843 return new KeyPair(ec, {
16844 pub: pub,
16845 pubEnc: enc
16846 });
16847};
16848
16849KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) {
16850 if (priv instanceof KeyPair)
16851 return priv;
16852
16853 return new KeyPair(ec, {
16854 priv: priv,
16855 privEnc: enc
16856 });
16857};
16858
16859KeyPair.prototype.validate = function validate() {
16860 var pub = this.getPublic();
16861
16862 if (pub.isInfinity())
16863 return { result: false, reason: 'Invalid public key' };
16864 if (!pub.validate())
16865 return { result: false, reason: 'Public key is not a point' };
16866 if (!pub.mul(this.ec.curve.n).isInfinity())
16867 return { result: false, reason: 'Public key * N != O' };
16868
16869 return { result: true, reason: null };
16870};
16871
16872KeyPair.prototype.getPublic = function getPublic(compact, enc) {
16873 // compact is optional argument
16874 if (typeof compact === 'string') {
16875 enc = compact;
16876 compact = null;
16877 }
16878
16879 if (!this.pub)
16880 this.pub = this.ec.g.mul(this.priv);
16881
16882 if (!enc)
16883 return this.pub;
16884
16885 return this.pub.encode(enc, compact);
16886};
16887
16888KeyPair.prototype.getPrivate = function getPrivate(enc) {
16889 if (enc === 'hex')
16890 return this.priv.toString(16, 2);
16891 else
16892 return this.priv;
16893};
16894
16895KeyPair.prototype._importPrivate = function _importPrivate(key, enc) {
16896 this.priv = new BN(key, enc || 16);
16897
16898 // Ensure that the priv won't be bigger than n, otherwise we may fail
16899 // in fixed multiplication method
16900 this.priv = this.priv.umod(this.ec.curve.n);
16901};
16902
16903KeyPair.prototype._importPublic = function _importPublic(key, enc) {
16904 if (key.x || key.y) {
16905 // Montgomery points only have an `x` coordinate.
16906 // Weierstrass/Edwards points on the other hand have both `x` and
16907 // `y` coordinates.
16908 if (this.ec.curve.type === 'mont') {
16909 assert(key.x, 'Need x coordinate');
16910 } else if (this.ec.curve.type === 'short' ||
16911 this.ec.curve.type === 'edwards') {
16912 assert(key.x && key.y, 'Need both x and y coordinate');
16913 }
16914 this.pub = this.ec.curve.point(key.x, key.y);
16915 return;
16916 }
16917 this.pub = this.ec.curve.decodePoint(key, enc);
16918};
16919
16920// ECDH
16921KeyPair.prototype.derive = function derive(pub) {
16922 return pub.mul(this.priv).getX();
16923};
16924
16925// ECDSA
16926KeyPair.prototype.sign = function sign(msg, enc, options) {
16927 return this.ec.sign(msg, this, enc, options);
16928};
16929
16930KeyPair.prototype.verify = function verify(msg, signature) {
16931 return this.ec.verify(msg, signature, this);
16932};
16933
16934KeyPair.prototype.inspect = function inspect() {
16935 return '<Key priv: ' + (this.priv && this.priv.toString(16, 2)) +
16936 ' pub: ' + (this.pub && this.pub.inspect()) + ' >';
16937};
16938
16939},{"../../elliptic":86,"bn.js":18}],95:[function(require,module,exports){
16940'use strict';
16941
16942var BN = require('bn.js');
16943
16944var elliptic = require('../../elliptic');
16945var utils = elliptic.utils;
16946var assert = utils.assert;
16947
16948function Signature(options, enc) {
16949 if (options instanceof Signature)
16950 return options;
16951
16952 if (this._importDER(options, enc))
16953 return;
16954
16955 assert(options.r && options.s, 'Signature without r or s');
16956 this.r = new BN(options.r, 16);
16957 this.s = new BN(options.s, 16);
16958 if (options.recoveryParam === undefined)
16959 this.recoveryParam = null;
16960 else
16961 this.recoveryParam = options.recoveryParam;
16962}
16963module.exports = Signature;
16964
16965function Position() {
16966 this.place = 0;
16967}
16968
16969function getLength(buf, p) {
16970 var initial = buf[p.place++];
16971 if (!(initial & 0x80)) {
16972 return initial;
16973 }
16974 var octetLen = initial & 0xf;
16975 var val = 0;
16976 for (var i = 0, off = p.place; i < octetLen; i++, off++) {
16977 val <<= 8;
16978 val |= buf[off];
16979 }
16980 p.place = off;
16981 return val;
16982}
16983
16984function rmPadding(buf) {
16985 var i = 0;
16986 var len = buf.length - 1;
16987 while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) {
16988 i++;
16989 }
16990 if (i === 0) {
16991 return buf;
16992 }
16993 return buf.slice(i);
16994}
16995
16996Signature.prototype._importDER = function _importDER(data, enc) {
16997 data = utils.toArray(data, enc);
16998 var p = new Position();
16999 if (data[p.place++] !== 0x30) {
17000 return false;
17001 }
17002 var len = getLength(data, p);
17003 if ((len + p.place) !== data.length) {
17004 return false;
17005 }
17006 if (data[p.place++] !== 0x02) {
17007 return false;
17008 }
17009 var rlen = getLength(data, p);
17010 var r = data.slice(p.place, rlen + p.place);
17011 p.place += rlen;
17012 if (data[p.place++] !== 0x02) {
17013 return false;
17014 }
17015 var slen = getLength(data, p);
17016 if (data.length !== slen + p.place) {
17017 return false;
17018 }
17019 var s = data.slice(p.place, slen + p.place);
17020 if (r[0] === 0 && (r[1] & 0x80)) {
17021 r = r.slice(1);
17022 }
17023 if (s[0] === 0 && (s[1] & 0x80)) {
17024 s = s.slice(1);
17025 }
17026
17027 this.r = new BN(r);
17028 this.s = new BN(s);
17029 this.recoveryParam = null;
17030
17031 return true;
17032};
17033
17034function constructLength(arr, len) {
17035 if (len < 0x80) {
17036 arr.push(len);
17037 return;
17038 }
17039 var octets = 1 + (Math.log(len) / Math.LN2 >>> 3);
17040 arr.push(octets | 0x80);
17041 while (--octets) {
17042 arr.push((len >>> (octets << 3)) & 0xff);
17043 }
17044 arr.push(len);
17045}
17046
17047Signature.prototype.toDER = function toDER(enc) {
17048 var r = this.r.toArray();
17049 var s = this.s.toArray();
17050
17051 // Pad values
17052 if (r[0] & 0x80)
17053 r = [ 0 ].concat(r);
17054 // Pad values
17055 if (s[0] & 0x80)
17056 s = [ 0 ].concat(s);
17057
17058 r = rmPadding(r);
17059 s = rmPadding(s);
17060
17061 while (!s[0] && !(s[1] & 0x80)) {
17062 s = s.slice(1);
17063 }
17064 var arr = [ 0x02 ];
17065 constructLength(arr, r.length);
17066 arr = arr.concat(r);
17067 arr.push(0x02);
17068 constructLength(arr, s.length);
17069 var backHalf = arr.concat(s);
17070 var res = [ 0x30 ];
17071 constructLength(res, backHalf.length);
17072 res = res.concat(backHalf);
17073 return utils.encode(res, enc);
17074};
17075
17076},{"../../elliptic":86,"bn.js":18}],96:[function(require,module,exports){
17077'use strict';
17078
17079var hash = require('hash.js');
17080var elliptic = require('../../elliptic');
17081var utils = elliptic.utils;
17082var assert = utils.assert;
17083var parseBytes = utils.parseBytes;
17084var KeyPair = require('./key');
17085var Signature = require('./signature');
17086
17087function EDDSA(curve) {
17088 assert(curve === 'ed25519', 'only tested with ed25519 so far');
17089
17090 if (!(this instanceof EDDSA))
17091 return new EDDSA(curve);
17092
17093 var curve = elliptic.curves[curve].curve;
17094 this.curve = curve;
17095 this.g = curve.g;
17096 this.g.precompute(curve.n.bitLength() + 1);
17097
17098 this.pointClass = curve.point().constructor;
17099 this.encodingLength = Math.ceil(curve.n.bitLength() / 8);
17100 this.hash = hash.sha512;
17101}
17102
17103module.exports = EDDSA;
17104
17105/**
17106* @param {Array|String} message - message bytes
17107* @param {Array|String|KeyPair} secret - secret bytes or a keypair
17108* @returns {Signature} - signature
17109*/
17110EDDSA.prototype.sign = function sign(message, secret) {
17111 message = parseBytes(message);
17112 var key = this.keyFromSecret(secret);
17113 var r = this.hashInt(key.messagePrefix(), message);
17114 var R = this.g.mul(r);
17115 var Rencoded = this.encodePoint(R);
17116 var s_ = this.hashInt(Rencoded, key.pubBytes(), message)
17117 .mul(key.priv());
17118 var S = r.add(s_).umod(this.curve.n);
17119 return this.makeSignature({ R: R, S: S, Rencoded: Rencoded });
17120};
17121
17122/**
17123* @param {Array} message - message bytes
17124* @param {Array|String|Signature} sig - sig bytes
17125* @param {Array|String|Point|KeyPair} pub - public key
17126* @returns {Boolean} - true if public key matches sig of message
17127*/
17128EDDSA.prototype.verify = function verify(message, sig, pub) {
17129 message = parseBytes(message);
17130 sig = this.makeSignature(sig);
17131 var key = this.keyFromPublic(pub);
17132 var h = this.hashInt(sig.Rencoded(), key.pubBytes(), message);
17133 var SG = this.g.mul(sig.S());
17134 var RplusAh = sig.R().add(key.pub().mul(h));
17135 return RplusAh.eq(SG);
17136};
17137
17138EDDSA.prototype.hashInt = function hashInt() {
17139 var hash = this.hash();
17140 for (var i = 0; i < arguments.length; i++)
17141 hash.update(arguments[i]);
17142 return utils.intFromLE(hash.digest()).umod(this.curve.n);
17143};
17144
17145EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) {
17146 return KeyPair.fromPublic(this, pub);
17147};
17148
17149EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) {
17150 return KeyPair.fromSecret(this, secret);
17151};
17152
17153EDDSA.prototype.makeSignature = function makeSignature(sig) {
17154 if (sig instanceof Signature)
17155 return sig;
17156 return new Signature(this, sig);
17157};
17158
17159/**
17160* * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.2
17161*
17162* EDDSA defines methods for encoding and decoding points and integers. These are
17163* helper convenience methods, that pass along to utility functions implied
17164* parameters.
17165*
17166*/
17167EDDSA.prototype.encodePoint = function encodePoint(point) {
17168 var enc = point.getY().toArray('le', this.encodingLength);
17169 enc[this.encodingLength - 1] |= point.getX().isOdd() ? 0x80 : 0;
17170 return enc;
17171};
17172
17173EDDSA.prototype.decodePoint = function decodePoint(bytes) {
17174 bytes = utils.parseBytes(bytes);
17175
17176 var lastIx = bytes.length - 1;
17177 var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80);
17178 var xIsOdd = (bytes[lastIx] & 0x80) !== 0;
17179
17180 var y = utils.intFromLE(normed);
17181 return this.curve.pointFromY(y, xIsOdd);
17182};
17183
17184EDDSA.prototype.encodeInt = function encodeInt(num) {
17185 return num.toArray('le', this.encodingLength);
17186};
17187
17188EDDSA.prototype.decodeInt = function decodeInt(bytes) {
17189 return utils.intFromLE(bytes);
17190};
17191
17192EDDSA.prototype.isPoint = function isPoint(val) {
17193 return val instanceof this.pointClass;
17194};
17195
17196},{"../../elliptic":86,"./key":97,"./signature":98,"hash.js":105}],97:[function(require,module,exports){
17197'use strict';
17198
17199var elliptic = require('../../elliptic');
17200var utils = elliptic.utils;
17201var assert = utils.assert;
17202var parseBytes = utils.parseBytes;
17203var cachedProperty = utils.cachedProperty;
17204
17205/**
17206* @param {EDDSA} eddsa - instance
17207* @param {Object} params - public/private key parameters
17208*
17209* @param {Array<Byte>} [params.secret] - secret seed bytes
17210* @param {Point} [params.pub] - public key point (aka `A` in eddsa terms)
17211* @param {Array<Byte>} [params.pub] - public key point encoded as bytes
17212*
17213*/
17214function KeyPair(eddsa, params) {
17215 this.eddsa = eddsa;
17216 this._secret = parseBytes(params.secret);
17217 if (eddsa.isPoint(params.pub))
17218 this._pub = params.pub;
17219 else
17220 this._pubBytes = parseBytes(params.pub);
17221}
17222
17223KeyPair.fromPublic = function fromPublic(eddsa, pub) {
17224 if (pub instanceof KeyPair)
17225 return pub;
17226 return new KeyPair(eddsa, { pub: pub });
17227};
17228
17229KeyPair.fromSecret = function fromSecret(eddsa, secret) {
17230 if (secret instanceof KeyPair)
17231 return secret;
17232 return new KeyPair(eddsa, { secret: secret });
17233};
17234
17235KeyPair.prototype.secret = function secret() {
17236 return this._secret;
17237};
17238
17239cachedProperty(KeyPair, 'pubBytes', function pubBytes() {
17240 return this.eddsa.encodePoint(this.pub());
17241});
17242
17243cachedProperty(KeyPair, 'pub', function pub() {
17244 if (this._pubBytes)
17245 return this.eddsa.decodePoint(this._pubBytes);
17246 return this.eddsa.g.mul(this.priv());
17247});
17248
17249cachedProperty(KeyPair, 'privBytes', function privBytes() {
17250 var eddsa = this.eddsa;
17251 var hash = this.hash();
17252 var lastIx = eddsa.encodingLength - 1;
17253
17254 var a = hash.slice(0, eddsa.encodingLength);
17255 a[0] &= 248;
17256 a[lastIx] &= 127;
17257 a[lastIx] |= 64;
17258
17259 return a;
17260});
17261
17262cachedProperty(KeyPair, 'priv', function priv() {
17263 return this.eddsa.decodeInt(this.privBytes());
17264});
17265
17266cachedProperty(KeyPair, 'hash', function hash() {
17267 return this.eddsa.hash().update(this.secret()).digest();
17268});
17269
17270cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() {
17271 return this.hash().slice(this.eddsa.encodingLength);
17272});
17273
17274KeyPair.prototype.sign = function sign(message) {
17275 assert(this._secret, 'KeyPair can only verify');
17276 return this.eddsa.sign(message, this);
17277};
17278
17279KeyPair.prototype.verify = function verify(message, sig) {
17280 return this.eddsa.verify(message, sig, this);
17281};
17282
17283KeyPair.prototype.getSecret = function getSecret(enc) {
17284 assert(this._secret, 'KeyPair is public only');
17285 return utils.encode(this.secret(), enc);
17286};
17287
17288KeyPair.prototype.getPublic = function getPublic(enc) {
17289 return utils.encode(this.pubBytes(), enc);
17290};
17291
17292module.exports = KeyPair;
17293
17294},{"../../elliptic":86}],98:[function(require,module,exports){
17295'use strict';
17296
17297var BN = require('bn.js');
17298var elliptic = require('../../elliptic');
17299var utils = elliptic.utils;
17300var assert = utils.assert;
17301var cachedProperty = utils.cachedProperty;
17302var parseBytes = utils.parseBytes;
17303
17304/**
17305* @param {EDDSA} eddsa - eddsa instance
17306* @param {Array<Bytes>|Object} sig -
17307* @param {Array<Bytes>|Point} [sig.R] - R point as Point or bytes
17308* @param {Array<Bytes>|bn} [sig.S] - S scalar as bn or bytes
17309* @param {Array<Bytes>} [sig.Rencoded] - R point encoded
17310* @param {Array<Bytes>} [sig.Sencoded] - S scalar encoded
17311*/
17312function Signature(eddsa, sig) {
17313 this.eddsa = eddsa;
17314
17315 if (typeof sig !== 'object')
17316 sig = parseBytes(sig);
17317
17318 if (Array.isArray(sig)) {
17319 sig = {
17320 R: sig.slice(0, eddsa.encodingLength),
17321 S: sig.slice(eddsa.encodingLength)
17322 };
17323 }
17324
17325 assert(sig.R && sig.S, 'Signature without R or S');
17326
17327 if (eddsa.isPoint(sig.R))
17328 this._R = sig.R;
17329 if (sig.S instanceof BN)
17330 this._S = sig.S;
17331
17332 this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded;
17333 this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded;
17334}
17335
17336cachedProperty(Signature, 'S', function S() {
17337 return this.eddsa.decodeInt(this.Sencoded());
17338});
17339
17340cachedProperty(Signature, 'R', function R() {
17341 return this.eddsa.decodePoint(this.Rencoded());
17342});
17343
17344cachedProperty(Signature, 'Rencoded', function Rencoded() {
17345 return this.eddsa.encodePoint(this.R());
17346});
17347
17348cachedProperty(Signature, 'Sencoded', function Sencoded() {
17349 return this.eddsa.encodeInt(this.S());
17350});
17351
17352Signature.prototype.toBytes = function toBytes() {
17353 return this.Rencoded().concat(this.Sencoded());
17354};
17355
17356Signature.prototype.toHex = function toHex() {
17357 return utils.encode(this.toBytes(), 'hex').toUpperCase();
17358};
17359
17360module.exports = Signature;
17361
17362},{"../../elliptic":86,"bn.js":18}],99:[function(require,module,exports){
17363module.exports = {
17364 doubles: {
17365 step: 4,
17366 points: [
17367 [
17368 'e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a',
17369 'f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821'
17370 ],
17371 [
17372 '8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508',
17373 '11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf'
17374 ],
17375 [
17376 '175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739',
17377 'd3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695'
17378 ],
17379 [
17380 '363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640',
17381 '4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9'
17382 ],
17383 [
17384 '8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c',
17385 '4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36'
17386 ],
17387 [
17388 '723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda',
17389 '96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f'
17390 ],
17391 [
17392 'eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa',
17393 '5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999'
17394 ],
17395 [
17396 '100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0',
17397 'cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09'
17398 ],
17399 [
17400 'e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d',
17401 '9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d'
17402 ],
17403 [
17404 'feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d',
17405 'e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088'
17406 ],
17407 [
17408 'da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1',
17409 '9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d'
17410 ],
17411 [
17412 '53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0',
17413 '5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8'
17414 ],
17415 [
17416 '8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047',
17417 '10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a'
17418 ],
17419 [
17420 '385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862',
17421 '283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453'
17422 ],
17423 [
17424 '6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7',
17425 '7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160'
17426 ],
17427 [
17428 '3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd',
17429 '56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0'
17430 ],
17431 [
17432 '85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83',
17433 '7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6'
17434 ],
17435 [
17436 '948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a',
17437 '53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589'
17438 ],
17439 [
17440 '6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8',
17441 'bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17'
17442 ],
17443 [
17444 'e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d',
17445 '4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda'
17446 ],
17447 [
17448 'e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725',
17449 '7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd'
17450 ],
17451 [
17452 '213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754',
17453 '4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2'
17454 ],
17455 [
17456 '4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c',
17457 '17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6'
17458 ],
17459 [
17460 'fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6',
17461 '6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f'
17462 ],
17463 [
17464 '76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39',
17465 'c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01'
17466 ],
17467 [
17468 'c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891',
17469 '893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3'
17470 ],
17471 [
17472 'd895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b',
17473 'febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f'
17474 ],
17475 [
17476 'b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03',
17477 '2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7'
17478 ],
17479 [
17480 'e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d',
17481 'eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78'
17482 ],
17483 [
17484 'a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070',
17485 '7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1'
17486 ],
17487 [
17488 '90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4',
17489 'e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150'
17490 ],
17491 [
17492 '8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da',
17493 '662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82'
17494 ],
17495 [
17496 'e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11',
17497 '1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc'
17498 ],
17499 [
17500 '8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e',
17501 'efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b'
17502 ],
17503 [
17504 'e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41',
17505 '2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51'
17506 ],
17507 [
17508 'b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef',
17509 '67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45'
17510 ],
17511 [
17512 'd68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8',
17513 'db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120'
17514 ],
17515 [
17516 '324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d',
17517 '648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84'
17518 ],
17519 [
17520 '4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96',
17521 '35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d'
17522 ],
17523 [
17524 '9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd',
17525 'ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d'
17526 ],
17527 [
17528 '6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5',
17529 '9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8'
17530 ],
17531 [
17532 'a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266',
17533 '40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8'
17534 ],
17535 [
17536 '7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71',
17537 '34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac'
17538 ],
17539 [
17540 '928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac',
17541 'c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f'
17542 ],
17543 [
17544 '85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751',
17545 '1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962'
17546 ],
17547 [
17548 'ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e',
17549 '493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907'
17550 ],
17551 [
17552 '827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241',
17553 'c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec'
17554 ],
17555 [
17556 'eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3',
17557 'be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d'
17558 ],
17559 [
17560 'e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f',
17561 '4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414'
17562 ],
17563 [
17564 '1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19',
17565 'aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd'
17566 ],
17567 [
17568 '146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be',
17569 'b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0'
17570 ],
17571 [
17572 'fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9',
17573 '6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811'
17574 ],
17575 [
17576 'da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2',
17577 '8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1'
17578 ],
17579 [
17580 'a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13',
17581 '7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c'
17582 ],
17583 [
17584 '174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c',
17585 'ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73'
17586 ],
17587 [
17588 '959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba',
17589 '2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd'
17590 ],
17591 [
17592 'd2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151',
17593 'e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405'
17594 ],
17595 [
17596 '64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073',
17597 'd99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589'
17598 ],
17599 [
17600 '8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458',
17601 '38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e'
17602 ],
17603 [
17604 '13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b',
17605 '69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27'
17606 ],
17607 [
17608 'bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366',
17609 'd3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1'
17610 ],
17611 [
17612 '8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa',
17613 '40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482'
17614 ],
17615 [
17616 '8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0',
17617 '620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945'
17618 ],
17619 [
17620 'dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787',
17621 '7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573'
17622 ],
17623 [
17624 'f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e',
17625 'ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82'
17626 ]
17627 ]
17628 },
17629 naf: {
17630 wnd: 7,
17631 points: [
17632 [
17633 'f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9',
17634 '388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672'
17635 ],
17636 [
17637 '2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4',
17638 'd8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6'
17639 ],
17640 [
17641 '5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc',
17642 '6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da'
17643 ],
17644 [
17645 'acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe',
17646 'cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37'
17647 ],
17648 [
17649 '774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb',
17650 'd984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b'
17651 ],
17652 [
17653 'f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8',
17654 'ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81'
17655 ],
17656 [
17657 'd7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e',
17658 '581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58'
17659 ],
17660 [
17661 'defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34',
17662 '4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77'
17663 ],
17664 [
17665 '2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c',
17666 '85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a'
17667 ],
17668 [
17669 '352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5',
17670 '321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c'
17671 ],
17672 [
17673 '2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f',
17674 '2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67'
17675 ],
17676 [
17677 '9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714',
17678 '73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402'
17679 ],
17680 [
17681 'daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729',
17682 'a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55'
17683 ],
17684 [
17685 'c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db',
17686 '2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482'
17687 ],
17688 [
17689 '6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4',
17690 'e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82'
17691 ],
17692 [
17693 '1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5',
17694 'b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396'
17695 ],
17696 [
17697 '605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479',
17698 '2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49'
17699 ],
17700 [
17701 '62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d',
17702 '80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf'
17703 ],
17704 [
17705 '80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f',
17706 '1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a'
17707 ],
17708 [
17709 '7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb',
17710 'd0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7'
17711 ],
17712 [
17713 'd528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9',
17714 'eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933'
17715 ],
17716 [
17717 '49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963',
17718 '758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a'
17719 ],
17720 [
17721 '77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74',
17722 '958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6'
17723 ],
17724 [
17725 'f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530',
17726 'e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37'
17727 ],
17728 [
17729 '463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b',
17730 '5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e'
17731 ],
17732 [
17733 'f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247',
17734 'cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6'
17735 ],
17736 [
17737 'caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1',
17738 'cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476'
17739 ],
17740 [
17741 '2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120',
17742 '4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40'
17743 ],
17744 [
17745 '7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435',
17746 '91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61'
17747 ],
17748 [
17749 '754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18',
17750 '673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683'
17751 ],
17752 [
17753 'e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8',
17754 '59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5'
17755 ],
17756 [
17757 '186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb',
17758 '3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b'
17759 ],
17760 [
17761 'df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f',
17762 '55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417'
17763 ],
17764 [
17765 '5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143',
17766 'efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868'
17767 ],
17768 [
17769 '290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba',
17770 'e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a'
17771 ],
17772 [
17773 'af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45',
17774 'f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6'
17775 ],
17776 [
17777 '766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a',
17778 '744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996'
17779 ],
17780 [
17781 '59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e',
17782 'c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e'
17783 ],
17784 [
17785 'f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8',
17786 'e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d'
17787 ],
17788 [
17789 '7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c',
17790 '30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2'
17791 ],
17792 [
17793 '948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519',
17794 'e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e'
17795 ],
17796 [
17797 '7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab',
17798 '100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437'
17799 ],
17800 [
17801 '3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca',
17802 'ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311'
17803 ],
17804 [
17805 'd3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf',
17806 '8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4'
17807 ],
17808 [
17809 '1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610',
17810 '68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575'
17811 ],
17812 [
17813 '733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4',
17814 'f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d'
17815 ],
17816 [
17817 '15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c',
17818 'd56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d'
17819 ],
17820 [
17821 'a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940',
17822 'edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629'
17823 ],
17824 [
17825 'e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980',
17826 'a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06'
17827 ],
17828 [
17829 '311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3',
17830 '66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374'
17831 ],
17832 [
17833 '34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf',
17834 '9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee'
17835 ],
17836 [
17837 'f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63',
17838 '4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1'
17839 ],
17840 [
17841 'd7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448',
17842 'fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b'
17843 ],
17844 [
17845 '32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf',
17846 '5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661'
17847 ],
17848 [
17849 '7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5',
17850 '8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6'
17851 ],
17852 [
17853 'ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6',
17854 '8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e'
17855 ],
17856 [
17857 '16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5',
17858 '5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d'
17859 ],
17860 [
17861 'eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99',
17862 'f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc'
17863 ],
17864 [
17865 '78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51',
17866 'f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4'
17867 ],
17868 [
17869 '494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5',
17870 '42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c'
17871 ],
17872 [
17873 'a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5',
17874 '204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b'
17875 ],
17876 [
17877 'c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997',
17878 '4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913'
17879 ],
17880 [
17881 '841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881',
17882 '73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154'
17883 ],
17884 [
17885 '5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5',
17886 '39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865'
17887 ],
17888 [
17889 '36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66',
17890 'd2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc'
17891 ],
17892 [
17893 '336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726',
17894 'ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224'
17895 ],
17896 [
17897 '8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede',
17898 '6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e'
17899 ],
17900 [
17901 '1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94',
17902 '60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6'
17903 ],
17904 [
17905 '85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31',
17906 '3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511'
17907 ],
17908 [
17909 '29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51',
17910 'b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b'
17911 ],
17912 [
17913 'a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252',
17914 'ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2'
17915 ],
17916 [
17917 '4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5',
17918 'cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c'
17919 ],
17920 [
17921 'd24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b',
17922 '6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3'
17923 ],
17924 [
17925 'ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4',
17926 '322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d'
17927 ],
17928 [
17929 'af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f',
17930 '6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700'
17931 ],
17932 [
17933 'e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889',
17934 '2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4'
17935 ],
17936 [
17937 '591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246',
17938 'b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196'
17939 ],
17940 [
17941 '11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984',
17942 '998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4'
17943 ],
17944 [
17945 '3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a',
17946 'b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257'
17947 ],
17948 [
17949 'cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030',
17950 'bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13'
17951 ],
17952 [
17953 'c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197',
17954 '6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096'
17955 ],
17956 [
17957 'c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593',
17958 'c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38'
17959 ],
17960 [
17961 'a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef',
17962 '21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f'
17963 ],
17964 [
17965 '347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38',
17966 '60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448'
17967 ],
17968 [
17969 'da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a',
17970 '49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a'
17971 ],
17972 [
17973 'c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111',
17974 '5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4'
17975 ],
17976 [
17977 '4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502',
17978 '7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437'
17979 ],
17980 [
17981 '3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea',
17982 'be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7'
17983 ],
17984 [
17985 'cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26',
17986 '8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d'
17987 ],
17988 [
17989 'b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986',
17990 '39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a'
17991 ],
17992 [
17993 'd4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e',
17994 '62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54'
17995 ],
17996 [
17997 '48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4',
17998 '25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77'
17999 ],
18000 [
18001 'dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda',
18002 'ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517'
18003 ],
18004 [
18005 '6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859',
18006 'cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10'
18007 ],
18008 [
18009 'e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f',
18010 'f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125'
18011 ],
18012 [
18013 'eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c',
18014 '6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e'
18015 ],
18016 [
18017 '13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942',
18018 'fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1'
18019 ],
18020 [
18021 'ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a',
18022 '1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2'
18023 ],
18024 [
18025 'b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80',
18026 '5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423'
18027 ],
18028 [
18029 'ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d',
18030 '438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8'
18031 ],
18032 [
18033 '8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1',
18034 'cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758'
18035 ],
18036 [
18037 '52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63',
18038 'c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375'
18039 ],
18040 [
18041 'e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352',
18042 '6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d'
18043 ],
18044 [
18045 '7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193',
18046 'ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec'
18047 ],
18048 [
18049 '5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00',
18050 '9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0'
18051 ],
18052 [
18053 '32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58',
18054 'ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c'
18055 ],
18056 [
18057 'e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7',
18058 'd3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4'
18059 ],
18060 [
18061 '8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8',
18062 'c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f'
18063 ],
18064 [
18065 '4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e',
18066 '67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649'
18067 ],
18068 [
18069 '3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d',
18070 'cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826'
18071 ],
18072 [
18073 '674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b',
18074 '299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5'
18075 ],
18076 [
18077 'd32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f',
18078 'f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87'
18079 ],
18080 [
18081 '30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6',
18082 '462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b'
18083 ],
18084 [
18085 'be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297',
18086 '62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc'
18087 ],
18088 [
18089 '93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a',
18090 '7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c'
18091 ],
18092 [
18093 'b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c',
18094 'ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f'
18095 ],
18096 [
18097 'd5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52',
18098 '4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a'
18099 ],
18100 [
18101 'd3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb',
18102 'bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46'
18103 ],
18104 [
18105 '463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065',
18106 'bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f'
18107 ],
18108 [
18109 '7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917',
18110 '603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03'
18111 ],
18112 [
18113 '74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9',
18114 'cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08'
18115 ],
18116 [
18117 '30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3',
18118 '553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8'
18119 ],
18120 [
18121 '9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57',
18122 '712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373'
18123 ],
18124 [
18125 '176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66',
18126 'ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3'
18127 ],
18128 [
18129 '75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8',
18130 '9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8'
18131 ],
18132 [
18133 '809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721',
18134 '9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1'
18135 ],
18136 [
18137 '1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180',
18138 '4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9'
18139 ]
18140 ]
18141 }
18142};
18143
18144},{}],100:[function(require,module,exports){
18145'use strict';
18146
18147var utils = exports;
18148var BN = require('bn.js');
18149var minAssert = require('minimalistic-assert');
18150var minUtils = require('minimalistic-crypto-utils');
18151
18152utils.assert = minAssert;
18153utils.toArray = minUtils.toArray;
18154utils.zero2 = minUtils.zero2;
18155utils.toHex = minUtils.toHex;
18156utils.encode = minUtils.encode;
18157
18158// Represent num in a w-NAF form
18159function getNAF(num, w) {
18160 var naf = [];
18161 var ws = 1 << (w + 1);
18162 var k = num.clone();
18163 while (k.cmpn(1) >= 0) {
18164 var z;
18165 if (k.isOdd()) {
18166 var mod = k.andln(ws - 1);
18167 if (mod > (ws >> 1) - 1)
18168 z = (ws >> 1) - mod;
18169 else
18170 z = mod;
18171 k.isubn(z);
18172 } else {
18173 z = 0;
18174 }
18175 naf.push(z);
18176
18177 // Optimization, shift by word if possible
18178 var shift = (k.cmpn(0) !== 0 && k.andln(ws - 1) === 0) ? (w + 1) : 1;
18179 for (var i = 1; i < shift; i++)
18180 naf.push(0);
18181 k.iushrn(shift);
18182 }
18183
18184 return naf;
18185}
18186utils.getNAF = getNAF;
18187
18188// Represent k1, k2 in a Joint Sparse Form
18189function getJSF(k1, k2) {
18190 var jsf = [
18191 [],
18192 []
18193 ];
18194
18195 k1 = k1.clone();
18196 k2 = k2.clone();
18197 var d1 = 0;
18198 var d2 = 0;
18199 while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) {
18200
18201 // First phase
18202 var m14 = (k1.andln(3) + d1) & 3;
18203 var m24 = (k2.andln(3) + d2) & 3;
18204 if (m14 === 3)
18205 m14 = -1;
18206 if (m24 === 3)
18207 m24 = -1;
18208 var u1;
18209 if ((m14 & 1) === 0) {
18210 u1 = 0;
18211 } else {
18212 var m8 = (k1.andln(7) + d1) & 7;
18213 if ((m8 === 3 || m8 === 5) && m24 === 2)
18214 u1 = -m14;
18215 else
18216 u1 = m14;
18217 }
18218 jsf[0].push(u1);
18219
18220 var u2;
18221 if ((m24 & 1) === 0) {
18222 u2 = 0;
18223 } else {
18224 var m8 = (k2.andln(7) + d2) & 7;
18225 if ((m8 === 3 || m8 === 5) && m14 === 2)
18226 u2 = -m24;
18227 else
18228 u2 = m24;
18229 }
18230 jsf[1].push(u2);
18231
18232 // Second phase
18233 if (2 * d1 === u1 + 1)
18234 d1 = 1 - d1;
18235 if (2 * d2 === u2 + 1)
18236 d2 = 1 - d2;
18237 k1.iushrn(1);
18238 k2.iushrn(1);
18239 }
18240
18241 return jsf;
18242}
18243utils.getJSF = getJSF;
18244
18245function cachedProperty(obj, name, computer) {
18246 var key = '_' + name;
18247 obj.prototype[name] = function cachedProperty() {
18248 return this[key] !== undefined ? this[key] :
18249 this[key] = computer.call(this);
18250 };
18251}
18252utils.cachedProperty = cachedProperty;
18253
18254function parseBytes(bytes) {
18255 return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') :
18256 bytes;
18257}
18258utils.parseBytes = parseBytes;
18259
18260function intFromLE(bytes) {
18261 return new BN(bytes, 'hex', 'le');
18262}
18263utils.intFromLE = intFromLE;
18264
18265
18266},{"bn.js":18,"minimalistic-assert":360,"minimalistic-crypto-utils":361}],101:[function(require,module,exports){
18267module.exports={
18268 "_args": [
18269 [
18270 "elliptic@6.4.1",
18271 "/var/www/sui.li/bip39/htdocs/libs/stellar-util"
18272 ]
18273 ],
18274 "_development": true,
18275 "_from": "elliptic@6.4.1",
18276 "_id": "elliptic@6.4.1",
18277 "_inBundle": false,
18278 "_integrity": "sha512-BsXLz5sqX8OHcsh7CqBMztyXARmGQ3LWPtGjJi6DiJHq5C/qvi9P3OqgswKSDftbu8+IoI/QDTAm2fFnQ9SZSQ==",
18279 "_location": "/elliptic",
18280 "_phantomChildren": {},
18281 "_requested": {
18282 "type": "version",
18283 "registry": true,
18284 "raw": "elliptic@6.4.1",
18285 "name": "elliptic",
18286 "escapedName": "elliptic",
18287 "rawSpec": "6.4.1",
18288 "saveSpec": null,
18289 "fetchSpec": "6.4.1"
18290 },
18291 "_requiredBy": [
18292 "/browserify-sign",
18293 "/create-ecdh"
18294 ],
18295 "_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.1.tgz",
18296 "_spec": "6.4.1",
18297 "_where": "/var/www/sui.li/bip39/htdocs/libs/stellar-util",
18298 "author": {
18299 "name": "Fedor Indutny",
18300 "email": "fedor@indutny.com"
18301 },
18302 "bugs": {
18303 "url": "https://github.com/indutny/elliptic/issues"
18304 },
18305 "dependencies": {
18306 "bn.js": "^4.4.0",
18307 "brorand": "^1.0.1",
18308 "hash.js": "^1.0.0",
18309 "hmac-drbg": "^1.0.0",
18310 "inherits": "^2.0.1",
18311 "minimalistic-assert": "^1.0.0",
18312 "minimalistic-crypto-utils": "^1.0.0"
18313 },
18314 "description": "EC cryptography",
18315 "devDependencies": {
18316 "brfs": "^1.4.3",
18317 "coveralls": "^2.11.3",
18318 "grunt": "^0.4.5",
18319 "grunt-browserify": "^5.0.0",
18320 "grunt-cli": "^1.2.0",
18321 "grunt-contrib-connect": "^1.0.0",
18322 "grunt-contrib-copy": "^1.0.0",
18323 "grunt-contrib-uglify": "^1.0.1",
18324 "grunt-mocha-istanbul": "^3.0.1",
18325 "grunt-saucelabs": "^8.6.2",
18326 "istanbul": "^0.4.2",
18327 "jscs": "^2.9.0",
18328 "jshint": "^2.6.0",
18329 "mocha": "^2.1.0"
18330 },
18331 "files": [
18332 "lib"
18333 ],
18334 "homepage": "https://github.com/indutny/elliptic",
18335 "keywords": [
18336 "EC",
18337 "Elliptic",
18338 "curve",
18339 "Cryptography"
18340 ],
18341 "license": "MIT",
18342 "main": "lib/elliptic.js",
18343 "name": "elliptic",
18344 "repository": {
18345 "type": "git",
18346 "url": "git+ssh://git@github.com/indutny/elliptic.git"
18347 },
18348 "scripts": {
18349 "jscs": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",
18350 "jshint": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",
18351 "lint": "npm run jscs && npm run jshint",
18352 "test": "npm run lint && npm run unit",
18353 "unit": "istanbul test _mocha --reporter=spec test/index.js",
18354 "version": "grunt dist && git add dist/"
18355 },
18356 "version": "6.4.1"
18357}
18358
18359},{}],102:[function(require,module,exports){
18360// Copyright Joyent, Inc. and other Node contributors.
18361//
18362// Permission is hereby granted, free of charge, to any person obtaining a
18363// copy of this software and associated documentation files (the
18364// "Software"), to deal in the Software without restriction, including
18365// without limitation the rights to use, copy, modify, merge, publish,
18366// distribute, sublicense, and/or sell copies of the Software, and to permit
18367// persons to whom the Software is furnished to do so, subject to the
18368// following conditions:
18369//
18370// The above copyright notice and this permission notice shall be included
18371// in all copies or substantial portions of the Software.
18372//
18373// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18374// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18375// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
18376// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18377// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
18378// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
18379// USE OR OTHER DEALINGS IN THE SOFTWARE.
18380
18381var objectCreate = Object.create || objectCreatePolyfill
18382var objectKeys = Object.keys || objectKeysPolyfill
18383var bind = Function.prototype.bind || functionBindPolyfill
18384
18385function EventEmitter() {
18386 if (!this._events || !Object.prototype.hasOwnProperty.call(this, '_events')) {
18387 this._events = objectCreate(null);
18388 this._eventsCount = 0;
18389 }
18390
18391 this._maxListeners = this._maxListeners || undefined;
18392}
18393module.exports = EventEmitter;
18394
18395// Backwards-compat with node 0.10.x
18396EventEmitter.EventEmitter = EventEmitter;
18397
18398EventEmitter.prototype._events = undefined;
18399EventEmitter.prototype._maxListeners = undefined;
18400
18401// By default EventEmitters will print a warning if more than 10 listeners are
18402// added to it. This is a useful default which helps finding memory leaks.
18403var defaultMaxListeners = 10;
18404
18405var hasDefineProperty;
18406try {
18407 var o = {};
18408 if (Object.defineProperty) Object.defineProperty(o, 'x', { value: 0 });
18409 hasDefineProperty = o.x === 0;
18410} catch (err) { hasDefineProperty = false }
18411if (hasDefineProperty) {
18412 Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
18413 enumerable: true,
18414 get: function() {
18415 return defaultMaxListeners;
18416 },
18417 set: function(arg) {
18418 // check whether the input is a positive number (whose value is zero or
18419 // greater and not a NaN).
18420 if (typeof arg !== 'number' || arg < 0 || arg !== arg)
18421 throw new TypeError('"defaultMaxListeners" must be a positive number');
18422 defaultMaxListeners = arg;
18423 }
18424 });
18425} else {
18426 EventEmitter.defaultMaxListeners = defaultMaxListeners;
18427}
18428
18429// Obviously not all Emitters should be limited to 10. This function allows
18430// that to be increased. Set to zero for unlimited.
18431EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
18432 if (typeof n !== 'number' || n < 0 || isNaN(n))
18433 throw new TypeError('"n" argument must be a positive number');
18434 this._maxListeners = n;
18435 return this;
18436};
18437
18438function $getMaxListeners(that) {
18439 if (that._maxListeners === undefined)
18440 return EventEmitter.defaultMaxListeners;
18441 return that._maxListeners;
18442}
18443
18444EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
18445 return $getMaxListeners(this);
18446};
18447
18448// These standalone emit* functions are used to optimize calling of event
18449// handlers for fast cases because emit() itself often has a variable number of
18450// arguments and can be deoptimized because of that. These functions always have
18451// the same number of arguments and thus do not get deoptimized, so the code
18452// inside them can execute faster.
18453function emitNone(handler, isFn, self) {
18454 if (isFn)
18455 handler.call(self);
18456 else {
18457 var len = handler.length;
18458 var listeners = arrayClone(handler, len);
18459 for (var i = 0; i < len; ++i)
18460 listeners[i].call(self);
18461 }
18462}
18463function emitOne(handler, isFn, self, arg1) {
18464 if (isFn)
18465 handler.call(self, arg1);
18466 else {
18467 var len = handler.length;
18468 var listeners = arrayClone(handler, len);
18469 for (var i = 0; i < len; ++i)
18470 listeners[i].call(self, arg1);
18471 }
18472}
18473function emitTwo(handler, isFn, self, arg1, arg2) {
18474 if (isFn)
18475 handler.call(self, arg1, arg2);
18476 else {
18477 var len = handler.length;
18478 var listeners = arrayClone(handler, len);
18479 for (var i = 0; i < len; ++i)
18480 listeners[i].call(self, arg1, arg2);
18481 }
18482}
18483function emitThree(handler, isFn, self, arg1, arg2, arg3) {
18484 if (isFn)
18485 handler.call(self, arg1, arg2, arg3);
18486 else {
18487 var len = handler.length;
18488 var listeners = arrayClone(handler, len);
18489 for (var i = 0; i < len; ++i)
18490 listeners[i].call(self, arg1, arg2, arg3);
18491 }
18492}
18493
18494function emitMany(handler, isFn, self, args) {
18495 if (isFn)
18496 handler.apply(self, args);
18497 else {
18498 var len = handler.length;
18499 var listeners = arrayClone(handler, len);
18500 for (var i = 0; i < len; ++i)
18501 listeners[i].apply(self, args);
18502 }
18503}
18504
18505EventEmitter.prototype.emit = function emit(type) {
18506 var er, handler, len, args, i, events;
18507 var doError = (type === 'error');
18508
18509 events = this._events;
18510 if (events)
18511 doError = (doError && events.error == null);
18512 else if (!doError)
18513 return false;
18514
18515 // If there is no 'error' event listener then throw.
18516 if (doError) {
18517 if (arguments.length > 1)
18518 er = arguments[1];
18519 if (er instanceof Error) {
18520 throw er; // Unhandled 'error' event
18521 } else {
18522 // At least give some kind of context to the user
18523 var err = new Error('Unhandled "error" event. (' + er + ')');
18524 err.context = er;
18525 throw err;
18526 }
18527 return false;
18528 }
18529
18530 handler = events[type];
18531
18532 if (!handler)
18533 return false;
18534
18535 var isFn = typeof handler === 'function';
18536 len = arguments.length;
18537 switch (len) {
18538 // fast cases
18539 case 1:
18540 emitNone(handler, isFn, this);
18541 break;
18542 case 2:
18543 emitOne(handler, isFn, this, arguments[1]);
18544 break;
18545 case 3:
18546 emitTwo(handler, isFn, this, arguments[1], arguments[2]);
18547 break;
18548 case 4:
18549 emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
18550 break;
18551 // slower
18552 default:
18553 args = new Array(len - 1);
18554 for (i = 1; i < len; i++)
18555 args[i - 1] = arguments[i];
18556 emitMany(handler, isFn, this, args);
18557 }
18558
18559 return true;
18560};
18561
18562function _addListener(target, type, listener, prepend) {
18563 var m;
18564 var events;
18565 var existing;
18566
18567 if (typeof listener !== 'function')
18568 throw new TypeError('"listener" argument must be a function');
18569
18570 events = target._events;
18571 if (!events) {
18572 events = target._events = objectCreate(null);
18573 target._eventsCount = 0;
18574 } else {
18575 // To avoid recursion in the case that type === "newListener"! Before
18576 // adding it to the listeners, first emit "newListener".
18577 if (events.newListener) {
18578 target.emit('newListener', type,
18579 listener.listener ? listener.listener : listener);
18580
18581 // Re-assign `events` because a newListener handler could have caused the
18582 // this._events to be assigned to a new object
18583 events = target._events;
18584 }
18585 existing = events[type];
18586 }
18587
18588 if (!existing) {
18589 // Optimize the case of one listener. Don't need the extra array object.
18590 existing = events[type] = listener;
18591 ++target._eventsCount;
18592 } else {
18593 if (typeof existing === 'function') {
18594 // Adding the second element, need to change to array.
18595 existing = events[type] =
18596 prepend ? [listener, existing] : [existing, listener];
18597 } else {
18598 // If we've already got an array, just append.
18599 if (prepend) {
18600 existing.unshift(listener);
18601 } else {
18602 existing.push(listener);
18603 }
18604 }
18605
18606 // Check for listener leak
18607 if (!existing.warned) {
18608 m = $getMaxListeners(target);
18609 if (m && m > 0 && existing.length > m) {
18610 existing.warned = true;
18611 var w = new Error('Possible EventEmitter memory leak detected. ' +
18612 existing.length + ' "' + String(type) + '" listeners ' +
18613 'added. Use emitter.setMaxListeners() to ' +
18614 'increase limit.');
18615 w.name = 'MaxListenersExceededWarning';
18616 w.emitter = target;
18617 w.type = type;
18618 w.count = existing.length;
18619 if (typeof console === 'object' && console.warn) {
18620 console.warn('%s: %s', w.name, w.message);
18621 }
18622 }
18623 }
18624 }
18625
18626 return target;
18627}
18628
18629EventEmitter.prototype.addListener = function addListener(type, listener) {
18630 return _addListener(this, type, listener, false);
18631};
18632
18633EventEmitter.prototype.on = EventEmitter.prototype.addListener;
18634
18635EventEmitter.prototype.prependListener =
18636 function prependListener(type, listener) {
18637 return _addListener(this, type, listener, true);
18638 };
18639
18640function onceWrapper() {
18641 if (!this.fired) {
18642 this.target.removeListener(this.type, this.wrapFn);
18643 this.fired = true;
18644 switch (arguments.length) {
18645 case 0:
18646 return this.listener.call(this.target);
18647 case 1:
18648 return this.listener.call(this.target, arguments[0]);
18649 case 2:
18650 return this.listener.call(this.target, arguments[0], arguments[1]);
18651 case 3:
18652 return this.listener.call(this.target, arguments[0], arguments[1],
18653 arguments[2]);
18654 default:
18655 var args = new Array(arguments.length);
18656 for (var i = 0; i < args.length; ++i)
18657 args[i] = arguments[i];
18658 this.listener.apply(this.target, args);
18659 }
18660 }
18661}
18662
18663function _onceWrap(target, type, listener) {
18664 var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
18665 var wrapped = bind.call(onceWrapper, state);
18666 wrapped.listener = listener;
18667 state.wrapFn = wrapped;
18668 return wrapped;
18669}
18670
18671EventEmitter.prototype.once = function once(type, listener) {
18672 if (typeof listener !== 'function')
18673 throw new TypeError('"listener" argument must be a function');
18674 this.on(type, _onceWrap(this, type, listener));
18675 return this;
18676};
18677
18678EventEmitter.prototype.prependOnceListener =
18679 function prependOnceListener(type, listener) {
18680 if (typeof listener !== 'function')
18681 throw new TypeError('"listener" argument must be a function');
18682 this.prependListener(type, _onceWrap(this, type, listener));
18683 return this;
18684 };
18685
18686// Emits a 'removeListener' event if and only if the listener was removed.
18687EventEmitter.prototype.removeListener =
18688 function removeListener(type, listener) {
18689 var list, events, position, i, originalListener;
18690
18691 if (typeof listener !== 'function')
18692 throw new TypeError('"listener" argument must be a function');
18693
18694 events = this._events;
18695 if (!events)
18696 return this;
18697
18698 list = events[type];
18699 if (!list)
18700 return this;
18701
18702 if (list === listener || list.listener === listener) {
18703 if (--this._eventsCount === 0)
18704 this._events = objectCreate(null);
18705 else {
18706 delete events[type];
18707 if (events.removeListener)
18708 this.emit('removeListener', type, list.listener || listener);
18709 }
18710 } else if (typeof list !== 'function') {
18711 position = -1;
18712
18713 for (i = list.length - 1; i >= 0; i--) {
18714 if (list[i] === listener || list[i].listener === listener) {
18715 originalListener = list[i].listener;
18716 position = i;
18717 break;
18718 }
18719 }
18720
18721 if (position < 0)
18722 return this;
18723
18724 if (position === 0)
18725 list.shift();
18726 else
18727 spliceOne(list, position);
18728
18729 if (list.length === 1)
18730 events[type] = list[0];
18731
18732 if (events.removeListener)
18733 this.emit('removeListener', type, originalListener || listener);
18734 }
18735
18736 return this;
18737 };
18738
18739EventEmitter.prototype.removeAllListeners =
18740 function removeAllListeners(type) {
18741 var listeners, events, i;
18742
18743 events = this._events;
18744 if (!events)
18745 return this;
18746
18747 // not listening for removeListener, no need to emit
18748 if (!events.removeListener) {
18749 if (arguments.length === 0) {
18750 this._events = objectCreate(null);
18751 this._eventsCount = 0;
18752 } else if (events[type]) {
18753 if (--this._eventsCount === 0)
18754 this._events = objectCreate(null);
18755 else
18756 delete events[type];
18757 }
18758 return this;
18759 }
18760
18761 // emit removeListener for all listeners on all events
18762 if (arguments.length === 0) {
18763 var keys = objectKeys(events);
18764 var key;
18765 for (i = 0; i < keys.length; ++i) {
18766 key = keys[i];
18767 if (key === 'removeListener') continue;
18768 this.removeAllListeners(key);
18769 }
18770 this.removeAllListeners('removeListener');
18771 this._events = objectCreate(null);
18772 this._eventsCount = 0;
18773 return this;
18774 }
18775
18776 listeners = events[type];
18777
18778 if (typeof listeners === 'function') {
18779 this.removeListener(type, listeners);
18780 } else if (listeners) {
18781 // LIFO order
18782 for (i = listeners.length - 1; i >= 0; i--) {
18783 this.removeListener(type, listeners[i]);
18784 }
18785 }
18786
18787 return this;
18788 };
18789
18790function _listeners(target, type, unwrap) {
18791 var events = target._events;
18792
18793 if (!events)
18794 return [];
18795
18796 var evlistener = events[type];
18797 if (!evlistener)
18798 return [];
18799
18800 if (typeof evlistener === 'function')
18801 return unwrap ? [evlistener.listener || evlistener] : [evlistener];
18802
18803 return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
18804}
18805
18806EventEmitter.prototype.listeners = function listeners(type) {
18807 return _listeners(this, type, true);
18808};
18809
18810EventEmitter.prototype.rawListeners = function rawListeners(type) {
18811 return _listeners(this, type, false);
18812};
18813
18814EventEmitter.listenerCount = function(emitter, type) {
18815 if (typeof emitter.listenerCount === 'function') {
18816 return emitter.listenerCount(type);
18817 } else {
18818 return listenerCount.call(emitter, type);
18819 }
18820};
18821
18822EventEmitter.prototype.listenerCount = listenerCount;
18823function listenerCount(type) {
18824 var events = this._events;
18825
18826 if (events) {
18827 var evlistener = events[type];
18828
18829 if (typeof evlistener === 'function') {
18830 return 1;
18831 } else if (evlistener) {
18832 return evlistener.length;
18833 }
18834 }
18835
18836 return 0;
18837}
18838
18839EventEmitter.prototype.eventNames = function eventNames() {
18840 return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
18841};
18842
18843// About 1.5x faster than the two-arg version of Array#splice().
18844function spliceOne(list, index) {
18845 for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1)
18846 list[i] = list[k];
18847 list.pop();
18848}
18849
18850function arrayClone(arr, n) {
18851 var copy = new Array(n);
18852 for (var i = 0; i < n; ++i)
18853 copy[i] = arr[i];
18854 return copy;
18855}
18856
18857function unwrapListeners(arr) {
18858 var ret = new Array(arr.length);
18859 for (var i = 0; i < ret.length; ++i) {
18860 ret[i] = arr[i].listener || arr[i];
18861 }
18862 return ret;
18863}
18864
18865function objectCreatePolyfill(proto) {
18866 var F = function() {};
18867 F.prototype = proto;
18868 return new F;
18869}
18870function objectKeysPolyfill(obj) {
18871 var keys = [];
18872 for (var k in obj) if (Object.prototype.hasOwnProperty.call(obj, k)) {
18873 keys.push(k);
18874 }
18875 return k;
18876}
18877function functionBindPolyfill(context) {
18878 var fn = this;
18879 return function () {
18880 return fn.apply(context, arguments);
18881 };
18882}
18883
18884},{}],103:[function(require,module,exports){
18885var Buffer = require('safe-buffer').Buffer
18886var MD5 = require('md5.js')
18887
18888/* eslint-disable camelcase */
18889function EVP_BytesToKey (password, salt, keyBits, ivLen) {
18890 if (!Buffer.isBuffer(password)) password = Buffer.from(password, 'binary')
18891 if (salt) {
18892 if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, 'binary')
18893 if (salt.length !== 8) throw new RangeError('salt should be Buffer with 8 byte length')
18894 }
18895
18896 var keyLen = keyBits / 8
18897 var key = Buffer.alloc(keyLen)
18898 var iv = Buffer.alloc(ivLen || 0)
18899 var tmp = Buffer.alloc(0)
18900
18901 while (keyLen > 0 || ivLen > 0) {
18902 var hash = new MD5()
18903 hash.update(tmp)
18904 hash.update(password)
18905 if (salt) hash.update(salt)
18906 tmp = hash.digest()
18907
18908 var used = 0
18909
18910 if (keyLen > 0) {
18911 var keyStart = key.length - keyLen
18912 used = Math.min(keyLen, tmp.length)
18913 tmp.copy(key, keyStart, 0, used)
18914 keyLen -= used
18915 }
18916
18917 if (used < tmp.length && ivLen > 0) {
18918 var ivStart = iv.length - ivLen
18919 var length = Math.min(ivLen, tmp.length - used)
18920 tmp.copy(iv, ivStart, used, used + length)
18921 ivLen -= length
18922 }
18923 }
18924
18925 tmp.fill(0)
18926 return { key: key, iv: iv }
18927}
18928
18929module.exports = EVP_BytesToKey
18930
18931},{"md5.js":358,"safe-buffer":398}],104:[function(require,module,exports){
18932'use strict'
18933var Buffer = require('safe-buffer').Buffer
18934var Transform = require('stream').Transform
18935var inherits = require('inherits')
18936
18937function throwIfNotStringOrBuffer (val, prefix) {
18938 if (!Buffer.isBuffer(val) && typeof val !== 'string') {
18939 throw new TypeError(prefix + ' must be a string or a buffer')
18940 }
18941}
18942
18943function HashBase (blockSize) {
18944 Transform.call(this)
18945
18946 this._block = Buffer.allocUnsafe(blockSize)
18947 this._blockSize = blockSize
18948 this._blockOffset = 0
18949 this._length = [0, 0, 0, 0]
18950
18951 this._finalized = false
18952}
18953
18954inherits(HashBase, Transform)
18955
18956HashBase.prototype._transform = function (chunk, encoding, callback) {
18957 var error = null
18958 try {
18959 this.update(chunk, encoding)
18960 } catch (err) {
18961 error = err
18962 }
18963
18964 callback(error)
18965}
18966
18967HashBase.prototype._flush = function (callback) {
18968 var error = null
18969 try {
18970 this.push(this.digest())
18971 } catch (err) {
18972 error = err
18973 }
18974
18975 callback(error)
18976}
18977
18978HashBase.prototype.update = function (data, encoding) {
18979 throwIfNotStringOrBuffer(data, 'Data')
18980 if (this._finalized) throw new Error('Digest already called')
18981 if (!Buffer.isBuffer(data)) data = Buffer.from(data, encoding)
18982
18983 // consume data
18984 var block = this._block
18985 var offset = 0
18986 while (this._blockOffset + data.length - offset >= this._blockSize) {
18987 for (var i = this._blockOffset; i < this._blockSize;) block[i++] = data[offset++]
18988 this._update()
18989 this._blockOffset = 0
18990 }
18991 while (offset < data.length) block[this._blockOffset++] = data[offset++]
18992
18993 // update length
18994 for (var j = 0, carry = data.length * 8; carry > 0; ++j) {
18995 this._length[j] += carry
18996 carry = (this._length[j] / 0x0100000000) | 0
18997 if (carry > 0) this._length[j] -= 0x0100000000 * carry
18998 }
18999
19000 return this
19001}
19002
19003HashBase.prototype._update = function () {
19004 throw new Error('_update is not implemented')
19005}
19006
19007HashBase.prototype.digest = function (encoding) {
19008 if (this._finalized) throw new Error('Digest already called')
19009 this._finalized = true
19010
19011 var digest = this._digest()
19012 if (encoding !== undefined) digest = digest.toString(encoding)
19013
19014 // reset state
19015 this._block.fill(0)
19016 this._blockOffset = 0
19017 for (var i = 0; i < 4; ++i) this._length[i] = 0
19018
19019 return digest
19020}
19021
19022HashBase.prototype._digest = function () {
19023 throw new Error('_digest is not implemented')
19024}
19025
19026module.exports = HashBase
19027
19028},{"inherits":119,"safe-buffer":398,"stream":437}],105:[function(require,module,exports){
19029var hash = exports;
19030
19031hash.utils = require('./hash/utils');
19032hash.common = require('./hash/common');
19033hash.sha = require('./hash/sha');
19034hash.ripemd = require('./hash/ripemd');
19035hash.hmac = require('./hash/hmac');
19036
19037// Proxy hash functions to the main object
19038hash.sha1 = hash.sha.sha1;
19039hash.sha256 = hash.sha.sha256;
19040hash.sha224 = hash.sha.sha224;
19041hash.sha384 = hash.sha.sha384;
19042hash.sha512 = hash.sha.sha512;
19043hash.ripemd160 = hash.ripemd.ripemd160;
19044
19045},{"./hash/common":106,"./hash/hmac":107,"./hash/ripemd":108,"./hash/sha":109,"./hash/utils":116}],106:[function(require,module,exports){
19046'use strict';
19047
19048var utils = require('./utils');
19049var assert = require('minimalistic-assert');
19050
19051function BlockHash() {
19052 this.pending = null;
19053 this.pendingTotal = 0;
19054 this.blockSize = this.constructor.blockSize;
19055 this.outSize = this.constructor.outSize;
19056 this.hmacStrength = this.constructor.hmacStrength;
19057 this.padLength = this.constructor.padLength / 8;
19058 this.endian = 'big';
19059
19060 this._delta8 = this.blockSize / 8;
19061 this._delta32 = this.blockSize / 32;
19062}
19063exports.BlockHash = BlockHash;
19064
19065BlockHash.prototype.update = function update(msg, enc) {
19066 // Convert message to array, pad it, and join into 32bit blocks
19067 msg = utils.toArray(msg, enc);
19068 if (!this.pending)
19069 this.pending = msg;
19070 else
19071 this.pending = this.pending.concat(msg);
19072 this.pendingTotal += msg.length;
19073
19074 // Enough data, try updating
19075 if (this.pending.length >= this._delta8) {
19076 msg = this.pending;
19077
19078 // Process pending data in blocks
19079 var r = msg.length % this._delta8;
19080 this.pending = msg.slice(msg.length - r, msg.length);
19081 if (this.pending.length === 0)
19082 this.pending = null;
19083
19084 msg = utils.join32(msg, 0, msg.length - r, this.endian);
19085 for (var i = 0; i < msg.length; i += this._delta32)
19086 this._update(msg, i, i + this._delta32);
19087 }
19088
19089 return this;
19090};
19091
19092BlockHash.prototype.digest = function digest(enc) {
19093 this.update(this._pad());
19094 assert(this.pending === null);
19095
19096 return this._digest(enc);
19097};
19098
19099BlockHash.prototype._pad = function pad() {
19100 var len = this.pendingTotal;
19101 var bytes = this._delta8;
19102 var k = bytes - ((len + this.padLength) % bytes);
19103 var res = new Array(k + this.padLength);
19104 res[0] = 0x80;
19105 for (var i = 1; i < k; i++)
19106 res[i] = 0;
19107
19108 // Append length
19109 len <<= 3;
19110 if (this.endian === 'big') {
19111 for (var t = 8; t < this.padLength; t++)
19112 res[i++] = 0;
19113
19114 res[i++] = 0;
19115 res[i++] = 0;
19116 res[i++] = 0;
19117 res[i++] = 0;
19118 res[i++] = (len >>> 24) & 0xff;
19119 res[i++] = (len >>> 16) & 0xff;
19120 res[i++] = (len >>> 8) & 0xff;
19121 res[i++] = len & 0xff;
19122 } else {
19123 res[i++] = len & 0xff;
19124 res[i++] = (len >>> 8) & 0xff;
19125 res[i++] = (len >>> 16) & 0xff;
19126 res[i++] = (len >>> 24) & 0xff;
19127 res[i++] = 0;
19128 res[i++] = 0;
19129 res[i++] = 0;
19130 res[i++] = 0;
19131
19132 for (t = 8; t < this.padLength; t++)
19133 res[i++] = 0;
19134 }
19135
19136 return res;
19137};
19138
19139},{"./utils":116,"minimalistic-assert":360}],107:[function(require,module,exports){
19140'use strict';
19141
19142var utils = require('./utils');
19143var assert = require('minimalistic-assert');
19144
19145function Hmac(hash, key, enc) {
19146 if (!(this instanceof Hmac))
19147 return new Hmac(hash, key, enc);
19148 this.Hash = hash;
19149 this.blockSize = hash.blockSize / 8;
19150 this.outSize = hash.outSize / 8;
19151 this.inner = null;
19152 this.outer = null;
19153
19154 this._init(utils.toArray(key, enc));
19155}
19156module.exports = Hmac;
19157
19158Hmac.prototype._init = function init(key) {
19159 // Shorten key, if needed
19160 if (key.length > this.blockSize)
19161 key = new this.Hash().update(key).digest();
19162 assert(key.length <= this.blockSize);
19163
19164 // Add padding to key
19165 for (var i = key.length; i < this.blockSize; i++)
19166 key.push(0);
19167
19168 for (i = 0; i < key.length; i++)
19169 key[i] ^= 0x36;
19170 this.inner = new this.Hash().update(key);
19171
19172 // 0x36 ^ 0x5c = 0x6a
19173 for (i = 0; i < key.length; i++)
19174 key[i] ^= 0x6a;
19175 this.outer = new this.Hash().update(key);
19176};
19177
19178Hmac.prototype.update = function update(msg, enc) {
19179 this.inner.update(msg, enc);
19180 return this;
19181};
19182
19183Hmac.prototype.digest = function digest(enc) {
19184 this.outer.update(this.inner.digest());
19185 return this.outer.digest(enc);
19186};
19187
19188},{"./utils":116,"minimalistic-assert":360}],108:[function(require,module,exports){
19189'use strict';
19190
19191var utils = require('./utils');
19192var common = require('./common');
19193
19194var rotl32 = utils.rotl32;
19195var sum32 = utils.sum32;
19196var sum32_3 = utils.sum32_3;
19197var sum32_4 = utils.sum32_4;
19198var BlockHash = common.BlockHash;
19199
19200function RIPEMD160() {
19201 if (!(this instanceof RIPEMD160))
19202 return new RIPEMD160();
19203
19204 BlockHash.call(this);
19205
19206 this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ];
19207 this.endian = 'little';
19208}
19209utils.inherits(RIPEMD160, BlockHash);
19210exports.ripemd160 = RIPEMD160;
19211
19212RIPEMD160.blockSize = 512;
19213RIPEMD160.outSize = 160;
19214RIPEMD160.hmacStrength = 192;
19215RIPEMD160.padLength = 64;
19216
19217RIPEMD160.prototype._update = function update(msg, start) {
19218 var A = this.h[0];
19219 var B = this.h[1];
19220 var C = this.h[2];
19221 var D = this.h[3];
19222 var E = this.h[4];
19223 var Ah = A;
19224 var Bh = B;
19225 var Ch = C;
19226 var Dh = D;
19227 var Eh = E;
19228 for (var j = 0; j < 80; j++) {
19229 var T = sum32(
19230 rotl32(
19231 sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)),
19232 s[j]),
19233 E);
19234 A = E;
19235 E = D;
19236 D = rotl32(C, 10);
19237 C = B;
19238 B = T;
19239 T = sum32(
19240 rotl32(
19241 sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)),
19242 sh[j]),
19243 Eh);
19244 Ah = Eh;
19245 Eh = Dh;
19246 Dh = rotl32(Ch, 10);
19247 Ch = Bh;
19248 Bh = T;
19249 }
19250 T = sum32_3(this.h[1], C, Dh);
19251 this.h[1] = sum32_3(this.h[2], D, Eh);
19252 this.h[2] = sum32_3(this.h[3], E, Ah);
19253 this.h[3] = sum32_3(this.h[4], A, Bh);
19254 this.h[4] = sum32_3(this.h[0], B, Ch);
19255 this.h[0] = T;
19256};
19257
19258RIPEMD160.prototype._digest = function digest(enc) {
19259 if (enc === 'hex')
19260 return utils.toHex32(this.h, 'little');
19261 else
19262 return utils.split32(this.h, 'little');
19263};
19264
19265function f(j, x, y, z) {
19266 if (j <= 15)
19267 return x ^ y ^ z;
19268 else if (j <= 31)
19269 return (x & y) | ((~x) & z);
19270 else if (j <= 47)
19271 return (x | (~y)) ^ z;
19272 else if (j <= 63)
19273 return (x & z) | (y & (~z));
19274 else
19275 return x ^ (y | (~z));
19276}
19277
19278function K(j) {
19279 if (j <= 15)
19280 return 0x00000000;
19281 else if (j <= 31)
19282 return 0x5a827999;
19283 else if (j <= 47)
19284 return 0x6ed9eba1;
19285 else if (j <= 63)
19286 return 0x8f1bbcdc;
19287 else
19288 return 0xa953fd4e;
19289}
19290
19291function Kh(j) {
19292 if (j <= 15)
19293 return 0x50a28be6;
19294 else if (j <= 31)
19295 return 0x5c4dd124;
19296 else if (j <= 47)
19297 return 0x6d703ef3;
19298 else if (j <= 63)
19299 return 0x7a6d76e9;
19300 else
19301 return 0x00000000;
19302}
19303
19304var r = [
19305 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
19306 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
19307 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
19308 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
19309 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
19310];
19311
19312var rh = [
19313 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
19314 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
19315 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
19316 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
19317 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
19318];
19319
19320var s = [
19321 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
19322 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
19323 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
19324 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
19325 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
19326];
19327
19328var sh = [
19329 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
19330 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
19331 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
19332 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
19333 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
19334];
19335
19336},{"./common":106,"./utils":116}],109:[function(require,module,exports){
19337'use strict';
19338
19339exports.sha1 = require('./sha/1');
19340exports.sha224 = require('./sha/224');
19341exports.sha256 = require('./sha/256');
19342exports.sha384 = require('./sha/384');
19343exports.sha512 = require('./sha/512');
19344
19345},{"./sha/1":110,"./sha/224":111,"./sha/256":112,"./sha/384":113,"./sha/512":114}],110:[function(require,module,exports){
19346'use strict';
19347
19348var utils = require('../utils');
19349var common = require('../common');
19350var shaCommon = require('./common');
19351
19352var rotl32 = utils.rotl32;
19353var sum32 = utils.sum32;
19354var sum32_5 = utils.sum32_5;
19355var ft_1 = shaCommon.ft_1;
19356var BlockHash = common.BlockHash;
19357
19358var sha1_K = [
19359 0x5A827999, 0x6ED9EBA1,
19360 0x8F1BBCDC, 0xCA62C1D6
19361];
19362
19363function SHA1() {
19364 if (!(this instanceof SHA1))
19365 return new SHA1();
19366
19367 BlockHash.call(this);
19368 this.h = [
19369 0x67452301, 0xefcdab89, 0x98badcfe,
19370 0x10325476, 0xc3d2e1f0 ];
19371 this.W = new Array(80);
19372}
19373
19374utils.inherits(SHA1, BlockHash);
19375module.exports = SHA1;
19376
19377SHA1.blockSize = 512;
19378SHA1.outSize = 160;
19379SHA1.hmacStrength = 80;
19380SHA1.padLength = 64;
19381
19382SHA1.prototype._update = function _update(msg, start) {
19383 var W = this.W;
19384
19385 for (var i = 0; i < 16; i++)
19386 W[i] = msg[start + i];
19387
19388 for(; i < W.length; i++)
19389 W[i] = rotl32(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1);
19390
19391 var a = this.h[0];
19392 var b = this.h[1];
19393 var c = this.h[2];
19394 var d = this.h[3];
19395 var e = this.h[4];
19396
19397 for (i = 0; i < W.length; i++) {
19398 var s = ~~(i / 20);
19399 var t = sum32_5(rotl32(a, 5), ft_1(s, b, c, d), e, W[i], sha1_K[s]);
19400 e = d;
19401 d = c;
19402 c = rotl32(b, 30);
19403 b = a;
19404 a = t;
19405 }
19406
19407 this.h[0] = sum32(this.h[0], a);
19408 this.h[1] = sum32(this.h[1], b);
19409 this.h[2] = sum32(this.h[2], c);
19410 this.h[3] = sum32(this.h[3], d);
19411 this.h[4] = sum32(this.h[4], e);
19412};
19413
19414SHA1.prototype._digest = function digest(enc) {
19415 if (enc === 'hex')
19416 return utils.toHex32(this.h, 'big');
19417 else
19418 return utils.split32(this.h, 'big');
19419};
19420
19421},{"../common":106,"../utils":116,"./common":115}],111:[function(require,module,exports){
19422'use strict';
19423
19424var utils = require('../utils');
19425var SHA256 = require('./256');
19426
19427function SHA224() {
19428 if (!(this instanceof SHA224))
19429 return new SHA224();
19430
19431 SHA256.call(this);
19432 this.h = [
19433 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
19434 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 ];
19435}
19436utils.inherits(SHA224, SHA256);
19437module.exports = SHA224;
19438
19439SHA224.blockSize = 512;
19440SHA224.outSize = 224;
19441SHA224.hmacStrength = 192;
19442SHA224.padLength = 64;
19443
19444SHA224.prototype._digest = function digest(enc) {
19445 // Just truncate output
19446 if (enc === 'hex')
19447 return utils.toHex32(this.h.slice(0, 7), 'big');
19448 else
19449 return utils.split32(this.h.slice(0, 7), 'big');
19450};
19451
19452
19453},{"../utils":116,"./256":112}],112:[function(require,module,exports){
19454'use strict';
19455
19456var utils = require('../utils');
19457var common = require('../common');
19458var shaCommon = require('./common');
19459var assert = require('minimalistic-assert');
19460
19461var sum32 = utils.sum32;
19462var sum32_4 = utils.sum32_4;
19463var sum32_5 = utils.sum32_5;
19464var ch32 = shaCommon.ch32;
19465var maj32 = shaCommon.maj32;
19466var s0_256 = shaCommon.s0_256;
19467var s1_256 = shaCommon.s1_256;
19468var g0_256 = shaCommon.g0_256;
19469var g1_256 = shaCommon.g1_256;
19470
19471var BlockHash = common.BlockHash;
19472
19473var sha256_K = [
19474 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
19475 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
19476 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
19477 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
19478 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
19479 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
19480 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
19481 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
19482 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
19483 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
19484 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
19485 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
19486 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
19487 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
19488 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
19489 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
19490];
19491
19492function SHA256() {
19493 if (!(this instanceof SHA256))
19494 return new SHA256();
19495
19496 BlockHash.call(this);
19497 this.h = [
19498 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
19499 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
19500 ];
19501 this.k = sha256_K;
19502 this.W = new Array(64);
19503}
19504utils.inherits(SHA256, BlockHash);
19505module.exports = SHA256;
19506
19507SHA256.blockSize = 512;
19508SHA256.outSize = 256;
19509SHA256.hmacStrength = 192;
19510SHA256.padLength = 64;
19511
19512SHA256.prototype._update = function _update(msg, start) {
19513 var W = this.W;
19514
19515 for (var i = 0; i < 16; i++)
19516 W[i] = msg[start + i];
19517 for (; i < W.length; i++)
19518 W[i] = sum32_4(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]);
19519
19520 var a = this.h[0];
19521 var b = this.h[1];
19522 var c = this.h[2];
19523 var d = this.h[3];
19524 var e = this.h[4];
19525 var f = this.h[5];
19526 var g = this.h[6];
19527 var h = this.h[7];
19528
19529 assert(this.k.length === W.length);
19530 for (i = 0; i < W.length; i++) {
19531 var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]);
19532 var T2 = sum32(s0_256(a), maj32(a, b, c));
19533 h = g;
19534 g = f;
19535 f = e;
19536 e = sum32(d, T1);
19537 d = c;
19538 c = b;
19539 b = a;
19540 a = sum32(T1, T2);
19541 }
19542
19543 this.h[0] = sum32(this.h[0], a);
19544 this.h[1] = sum32(this.h[1], b);
19545 this.h[2] = sum32(this.h[2], c);
19546 this.h[3] = sum32(this.h[3], d);
19547 this.h[4] = sum32(this.h[4], e);
19548 this.h[5] = sum32(this.h[5], f);
19549 this.h[6] = sum32(this.h[6], g);
19550 this.h[7] = sum32(this.h[7], h);
19551};
19552
19553SHA256.prototype._digest = function digest(enc) {
19554 if (enc === 'hex')
19555 return utils.toHex32(this.h, 'big');
19556 else
19557 return utils.split32(this.h, 'big');
19558};
19559
19560},{"../common":106,"../utils":116,"./common":115,"minimalistic-assert":360}],113:[function(require,module,exports){
19561'use strict';
19562
19563var utils = require('../utils');
19564
19565var SHA512 = require('./512');
19566
19567function SHA384() {
19568 if (!(this instanceof SHA384))
19569 return new SHA384();
19570
19571 SHA512.call(this);
19572 this.h = [
19573 0xcbbb9d5d, 0xc1059ed8,
19574 0x629a292a, 0x367cd507,
19575 0x9159015a, 0x3070dd17,
19576 0x152fecd8, 0xf70e5939,
19577 0x67332667, 0xffc00b31,
19578 0x8eb44a87, 0x68581511,
19579 0xdb0c2e0d, 0x64f98fa7,
19580 0x47b5481d, 0xbefa4fa4 ];
19581}
19582utils.inherits(SHA384, SHA512);
19583module.exports = SHA384;
19584
19585SHA384.blockSize = 1024;
19586SHA384.outSize = 384;
19587SHA384.hmacStrength = 192;
19588SHA384.padLength = 128;
19589
19590SHA384.prototype._digest = function digest(enc) {
19591 if (enc === 'hex')
19592 return utils.toHex32(this.h.slice(0, 12), 'big');
19593 else
19594 return utils.split32(this.h.slice(0, 12), 'big');
19595};
19596
19597},{"../utils":116,"./512":114}],114:[function(require,module,exports){
19598'use strict';
19599
19600var utils = require('../utils');
19601var common = require('../common');
19602var assert = require('minimalistic-assert');
19603
19604var rotr64_hi = utils.rotr64_hi;
19605var rotr64_lo = utils.rotr64_lo;
19606var shr64_hi = utils.shr64_hi;
19607var shr64_lo = utils.shr64_lo;
19608var sum64 = utils.sum64;
19609var sum64_hi = utils.sum64_hi;
19610var sum64_lo = utils.sum64_lo;
19611var sum64_4_hi = utils.sum64_4_hi;
19612var sum64_4_lo = utils.sum64_4_lo;
19613var sum64_5_hi = utils.sum64_5_hi;
19614var sum64_5_lo = utils.sum64_5_lo;
19615
19616var BlockHash = common.BlockHash;
19617
19618var sha512_K = [
19619 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
19620 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
19621 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
19622 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
19623 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
19624 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
19625 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
19626 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
19627 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
19628 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
19629 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
19630 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
19631 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
19632 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
19633 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
19634 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
19635 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
19636 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
19637 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
19638 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
19639 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
19640 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
19641 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
19642 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
19643 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
19644 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
19645 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
19646 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
19647 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
19648 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
19649 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
19650 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
19651 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
19652 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
19653 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
19654 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
19655 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
19656 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
19657 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
19658 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
19659];
19660
19661function SHA512() {
19662 if (!(this instanceof SHA512))
19663 return new SHA512();
19664
19665 BlockHash.call(this);
19666 this.h = [
19667 0x6a09e667, 0xf3bcc908,
19668 0xbb67ae85, 0x84caa73b,
19669 0x3c6ef372, 0xfe94f82b,
19670 0xa54ff53a, 0x5f1d36f1,
19671 0x510e527f, 0xade682d1,
19672 0x9b05688c, 0x2b3e6c1f,
19673 0x1f83d9ab, 0xfb41bd6b,
19674 0x5be0cd19, 0x137e2179 ];
19675 this.k = sha512_K;
19676 this.W = new Array(160);
19677}
19678utils.inherits(SHA512, BlockHash);
19679module.exports = SHA512;
19680
19681SHA512.blockSize = 1024;
19682SHA512.outSize = 512;
19683SHA512.hmacStrength = 192;
19684SHA512.padLength = 128;
19685
19686SHA512.prototype._prepareBlock = function _prepareBlock(msg, start) {
19687 var W = this.W;
19688
19689 // 32 x 32bit words
19690 for (var i = 0; i < 32; i++)
19691 W[i] = msg[start + i];
19692 for (; i < W.length; i += 2) {
19693 var c0_hi = g1_512_hi(W[i - 4], W[i - 3]); // i - 2
19694 var c0_lo = g1_512_lo(W[i - 4], W[i - 3]);
19695 var c1_hi = W[i - 14]; // i - 7
19696 var c1_lo = W[i - 13];
19697 var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); // i - 15
19698 var c2_lo = g0_512_lo(W[i - 30], W[i - 29]);
19699 var c3_hi = W[i - 32]; // i - 16
19700 var c3_lo = W[i - 31];
19701
19702 W[i] = sum64_4_hi(
19703 c0_hi, c0_lo,
19704 c1_hi, c1_lo,
19705 c2_hi, c2_lo,
19706 c3_hi, c3_lo);
19707 W[i + 1] = sum64_4_lo(
19708 c0_hi, c0_lo,
19709 c1_hi, c1_lo,
19710 c2_hi, c2_lo,
19711 c3_hi, c3_lo);
19712 }
19713};
19714
19715SHA512.prototype._update = function _update(msg, start) {
19716 this._prepareBlock(msg, start);
19717
19718 var W = this.W;
19719
19720 var ah = this.h[0];
19721 var al = this.h[1];
19722 var bh = this.h[2];
19723 var bl = this.h[3];
19724 var ch = this.h[4];
19725 var cl = this.h[5];
19726 var dh = this.h[6];
19727 var dl = this.h[7];
19728 var eh = this.h[8];
19729 var el = this.h[9];
19730 var fh = this.h[10];
19731 var fl = this.h[11];
19732 var gh = this.h[12];
19733 var gl = this.h[13];
19734 var hh = this.h[14];
19735 var hl = this.h[15];
19736
19737 assert(this.k.length === W.length);
19738 for (var i = 0; i < W.length; i += 2) {
19739 var c0_hi = hh;
19740 var c0_lo = hl;
19741 var c1_hi = s1_512_hi(eh, el);
19742 var c1_lo = s1_512_lo(eh, el);
19743 var c2_hi = ch64_hi(eh, el, fh, fl, gh, gl);
19744 var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl);
19745 var c3_hi = this.k[i];
19746 var c3_lo = this.k[i + 1];
19747 var c4_hi = W[i];
19748 var c4_lo = W[i + 1];
19749
19750 var T1_hi = sum64_5_hi(
19751 c0_hi, c0_lo,
19752 c1_hi, c1_lo,
19753 c2_hi, c2_lo,
19754 c3_hi, c3_lo,
19755 c4_hi, c4_lo);
19756 var T1_lo = sum64_5_lo(
19757 c0_hi, c0_lo,
19758 c1_hi, c1_lo,
19759 c2_hi, c2_lo,
19760 c3_hi, c3_lo,
19761 c4_hi, c4_lo);
19762
19763 c0_hi = s0_512_hi(ah, al);
19764 c0_lo = s0_512_lo(ah, al);
19765 c1_hi = maj64_hi(ah, al, bh, bl, ch, cl);
19766 c1_lo = maj64_lo(ah, al, bh, bl, ch, cl);
19767
19768 var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo);
19769 var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo);
19770
19771 hh = gh;
19772 hl = gl;
19773
19774 gh = fh;
19775 gl = fl;
19776
19777 fh = eh;
19778 fl = el;
19779
19780 eh = sum64_hi(dh, dl, T1_hi, T1_lo);
19781 el = sum64_lo(dl, dl, T1_hi, T1_lo);
19782
19783 dh = ch;
19784 dl = cl;
19785
19786 ch = bh;
19787 cl = bl;
19788
19789 bh = ah;
19790 bl = al;
19791
19792 ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo);
19793 al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo);
19794 }
19795
19796 sum64(this.h, 0, ah, al);
19797 sum64(this.h, 2, bh, bl);
19798 sum64(this.h, 4, ch, cl);
19799 sum64(this.h, 6, dh, dl);
19800 sum64(this.h, 8, eh, el);
19801 sum64(this.h, 10, fh, fl);
19802 sum64(this.h, 12, gh, gl);
19803 sum64(this.h, 14, hh, hl);
19804};
19805
19806SHA512.prototype._digest = function digest(enc) {
19807 if (enc === 'hex')
19808 return utils.toHex32(this.h, 'big');
19809 else
19810 return utils.split32(this.h, 'big');
19811};
19812
19813function ch64_hi(xh, xl, yh, yl, zh) {
19814 var r = (xh & yh) ^ ((~xh) & zh);
19815 if (r < 0)
19816 r += 0x100000000;
19817 return r;
19818}
19819
19820function ch64_lo(xh, xl, yh, yl, zh, zl) {
19821 var r = (xl & yl) ^ ((~xl) & zl);
19822 if (r < 0)
19823 r += 0x100000000;
19824 return r;
19825}
19826
19827function maj64_hi(xh, xl, yh, yl, zh) {
19828 var r = (xh & yh) ^ (xh & zh) ^ (yh & zh);
19829 if (r < 0)
19830 r += 0x100000000;
19831 return r;
19832}
19833
19834function maj64_lo(xh, xl, yh, yl, zh, zl) {
19835 var r = (xl & yl) ^ (xl & zl) ^ (yl & zl);
19836 if (r < 0)
19837 r += 0x100000000;
19838 return r;
19839}
19840
19841function s0_512_hi(xh, xl) {
19842 var c0_hi = rotr64_hi(xh, xl, 28);
19843 var c1_hi = rotr64_hi(xl, xh, 2); // 34
19844 var c2_hi = rotr64_hi(xl, xh, 7); // 39
19845
19846 var r = c0_hi ^ c1_hi ^ c2_hi;
19847 if (r < 0)
19848 r += 0x100000000;
19849 return r;
19850}
19851
19852function s0_512_lo(xh, xl) {
19853 var c0_lo = rotr64_lo(xh, xl, 28);
19854 var c1_lo = rotr64_lo(xl, xh, 2); // 34
19855 var c2_lo = rotr64_lo(xl, xh, 7); // 39
19856
19857 var r = c0_lo ^ c1_lo ^ c2_lo;
19858 if (r < 0)
19859 r += 0x100000000;
19860 return r;
19861}
19862
19863function s1_512_hi(xh, xl) {
19864 var c0_hi = rotr64_hi(xh, xl, 14);
19865 var c1_hi = rotr64_hi(xh, xl, 18);
19866 var c2_hi = rotr64_hi(xl, xh, 9); // 41
19867
19868 var r = c0_hi ^ c1_hi ^ c2_hi;
19869 if (r < 0)
19870 r += 0x100000000;
19871 return r;
19872}
19873
19874function s1_512_lo(xh, xl) {
19875 var c0_lo = rotr64_lo(xh, xl, 14);
19876 var c1_lo = rotr64_lo(xh, xl, 18);
19877 var c2_lo = rotr64_lo(xl, xh, 9); // 41
19878
19879 var r = c0_lo ^ c1_lo ^ c2_lo;
19880 if (r < 0)
19881 r += 0x100000000;
19882 return r;
19883}
19884
19885function g0_512_hi(xh, xl) {
19886 var c0_hi = rotr64_hi(xh, xl, 1);
19887 var c1_hi = rotr64_hi(xh, xl, 8);
19888 var c2_hi = shr64_hi(xh, xl, 7);
19889
19890 var r = c0_hi ^ c1_hi ^ c2_hi;
19891 if (r < 0)
19892 r += 0x100000000;
19893 return r;
19894}
19895
19896function g0_512_lo(xh, xl) {
19897 var c0_lo = rotr64_lo(xh, xl, 1);
19898 var c1_lo = rotr64_lo(xh, xl, 8);
19899 var c2_lo = shr64_lo(xh, xl, 7);
19900
19901 var r = c0_lo ^ c1_lo ^ c2_lo;
19902 if (r < 0)
19903 r += 0x100000000;
19904 return r;
19905}
19906
19907function g1_512_hi(xh, xl) {
19908 var c0_hi = rotr64_hi(xh, xl, 19);
19909 var c1_hi = rotr64_hi(xl, xh, 29); // 61
19910 var c2_hi = shr64_hi(xh, xl, 6);
19911
19912 var r = c0_hi ^ c1_hi ^ c2_hi;
19913 if (r < 0)
19914 r += 0x100000000;
19915 return r;
19916}
19917
19918function g1_512_lo(xh, xl) {
19919 var c0_lo = rotr64_lo(xh, xl, 19);
19920 var c1_lo = rotr64_lo(xl, xh, 29); // 61
19921 var c2_lo = shr64_lo(xh, xl, 6);
19922
19923 var r = c0_lo ^ c1_lo ^ c2_lo;
19924 if (r < 0)
19925 r += 0x100000000;
19926 return r;
19927}
19928
19929},{"../common":106,"../utils":116,"minimalistic-assert":360}],115:[function(require,module,exports){
19930'use strict';
19931
19932var utils = require('../utils');
19933var rotr32 = utils.rotr32;
19934
19935function ft_1(s, x, y, z) {
19936 if (s === 0)
19937 return ch32(x, y, z);
19938 if (s === 1 || s === 3)
19939 return p32(x, y, z);
19940 if (s === 2)
19941 return maj32(x, y, z);
19942}
19943exports.ft_1 = ft_1;
19944
19945function ch32(x, y, z) {
19946 return (x & y) ^ ((~x) & z);
19947}
19948exports.ch32 = ch32;
19949
19950function maj32(x, y, z) {
19951 return (x & y) ^ (x & z) ^ (y & z);
19952}
19953exports.maj32 = maj32;
19954
19955function p32(x, y, z) {
19956 return x ^ y ^ z;
19957}
19958exports.p32 = p32;
19959
19960function s0_256(x) {
19961 return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22);
19962}
19963exports.s0_256 = s0_256;
19964
19965function s1_256(x) {
19966 return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25);
19967}
19968exports.s1_256 = s1_256;
19969
19970function g0_256(x) {
19971 return rotr32(x, 7) ^ rotr32(x, 18) ^ (x >>> 3);
19972}
19973exports.g0_256 = g0_256;
19974
19975function g1_256(x) {
19976 return rotr32(x, 17) ^ rotr32(x, 19) ^ (x >>> 10);
19977}
19978exports.g1_256 = g1_256;
19979
19980},{"../utils":116}],116:[function(require,module,exports){
19981'use strict';
19982
19983var assert = require('minimalistic-assert');
19984var inherits = require('inherits');
19985
19986exports.inherits = inherits;
19987
19988function isSurrogatePair(msg, i) {
19989 if ((msg.charCodeAt(i) & 0xFC00) !== 0xD800) {
19990 return false;
19991 }
19992 if (i < 0 || i + 1 >= msg.length) {
19993 return false;
19994 }
19995 return (msg.charCodeAt(i + 1) & 0xFC00) === 0xDC00;
19996}
19997
19998function toArray(msg, enc) {
19999 if (Array.isArray(msg))
20000 return msg.slice();
20001 if (!msg)
20002 return [];
20003 var res = [];
20004 if (typeof msg === 'string') {
20005 if (!enc) {
20006 // Inspired by stringToUtf8ByteArray() in closure-library by Google
20007 // https://github.com/google/closure-library/blob/8598d87242af59aac233270742c8984e2b2bdbe0/closure/goog/crypt/crypt.js#L117-L143
20008 // Apache License 2.0
20009 // https://github.com/google/closure-library/blob/master/LICENSE
20010 var p = 0;
20011 for (var i = 0; i < msg.length; i++) {
20012 var c = msg.charCodeAt(i);
20013 if (c < 128) {
20014 res[p++] = c;
20015 } else if (c < 2048) {
20016 res[p++] = (c >> 6) | 192;
20017 res[p++] = (c & 63) | 128;
20018 } else if (isSurrogatePair(msg, i)) {
20019 c = 0x10000 + ((c & 0x03FF) << 10) + (msg.charCodeAt(++i) & 0x03FF);
20020 res[p++] = (c >> 18) | 240;
20021 res[p++] = ((c >> 12) & 63) | 128;
20022 res[p++] = ((c >> 6) & 63) | 128;
20023 res[p++] = (c & 63) | 128;
20024 } else {
20025 res[p++] = (c >> 12) | 224;
20026 res[p++] = ((c >> 6) & 63) | 128;
20027 res[p++] = (c & 63) | 128;
20028 }
20029 }
20030 } else if (enc === 'hex') {
20031 msg = msg.replace(/[^a-z0-9]+/ig, '');
20032 if (msg.length % 2 !== 0)
20033 msg = '0' + msg;
20034 for (i = 0; i < msg.length; i += 2)
20035 res.push(parseInt(msg[i] + msg[i + 1], 16));
20036 }
20037 } else {
20038 for (i = 0; i < msg.length; i++)
20039 res[i] = msg[i] | 0;
20040 }
20041 return res;
20042}
20043exports.toArray = toArray;
20044
20045function toHex(msg) {
20046 var res = '';
20047 for (var i = 0; i < msg.length; i++)
20048 res += zero2(msg[i].toString(16));
20049 return res;
20050}
20051exports.toHex = toHex;
20052
20053function htonl(w) {
20054 var res = (w >>> 24) |
20055 ((w >>> 8) & 0xff00) |
20056 ((w << 8) & 0xff0000) |
20057 ((w & 0xff) << 24);
20058 return res >>> 0;
20059}
20060exports.htonl = htonl;
20061
20062function toHex32(msg, endian) {
20063 var res = '';
20064 for (var i = 0; i < msg.length; i++) {
20065 var w = msg[i];
20066 if (endian === 'little')
20067 w = htonl(w);
20068 res += zero8(w.toString(16));
20069 }
20070 return res;
20071}
20072exports.toHex32 = toHex32;
20073
20074function zero2(word) {
20075 if (word.length === 1)
20076 return '0' + word;
20077 else
20078 return word;
20079}
20080exports.zero2 = zero2;
20081
20082function zero8(word) {
20083 if (word.length === 7)
20084 return '0' + word;
20085 else if (word.length === 6)
20086 return '00' + word;
20087 else if (word.length === 5)
20088 return '000' + word;
20089 else if (word.length === 4)
20090 return '0000' + word;
20091 else if (word.length === 3)
20092 return '00000' + word;
20093 else if (word.length === 2)
20094 return '000000' + word;
20095 else if (word.length === 1)
20096 return '0000000' + word;
20097 else
20098 return word;
20099}
20100exports.zero8 = zero8;
20101
20102function join32(msg, start, end, endian) {
20103 var len = end - start;
20104 assert(len % 4 === 0);
20105 var res = new Array(len / 4);
20106 for (var i = 0, k = start; i < res.length; i++, k += 4) {
20107 var w;
20108 if (endian === 'big')
20109 w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3];
20110 else
20111 w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k];
20112 res[i] = w >>> 0;
20113 }
20114 return res;
20115}
20116exports.join32 = join32;
20117
20118function split32(msg, endian) {
20119 var res = new Array(msg.length * 4);
20120 for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
20121 var m = msg[i];
20122 if (endian === 'big') {
20123 res[k] = m >>> 24;
20124 res[k + 1] = (m >>> 16) & 0xff;
20125 res[k + 2] = (m >>> 8) & 0xff;
20126 res[k + 3] = m & 0xff;
20127 } else {
20128 res[k + 3] = m >>> 24;
20129 res[k + 2] = (m >>> 16) & 0xff;
20130 res[k + 1] = (m >>> 8) & 0xff;
20131 res[k] = m & 0xff;
20132 }
20133 }
20134 return res;
20135}
20136exports.split32 = split32;
20137
20138function rotr32(w, b) {
20139 return (w >>> b) | (w << (32 - b));
20140}
20141exports.rotr32 = rotr32;
20142
20143function rotl32(w, b) {
20144 return (w << b) | (w >>> (32 - b));
20145}
20146exports.rotl32 = rotl32;
20147
20148function sum32(a, b) {
20149 return (a + b) >>> 0;
20150}
20151exports.sum32 = sum32;
20152
20153function sum32_3(a, b, c) {
20154 return (a + b + c) >>> 0;
20155}
20156exports.sum32_3 = sum32_3;
20157
20158function sum32_4(a, b, c, d) {
20159 return (a + b + c + d) >>> 0;
20160}
20161exports.sum32_4 = sum32_4;
20162
20163function sum32_5(a, b, c, d, e) {
20164 return (a + b + c + d + e) >>> 0;
20165}
20166exports.sum32_5 = sum32_5;
20167
20168function sum64(buf, pos, ah, al) {
20169 var bh = buf[pos];
20170 var bl = buf[pos + 1];
20171
20172 var lo = (al + bl) >>> 0;
20173 var hi = (lo < al ? 1 : 0) + ah + bh;
20174 buf[pos] = hi >>> 0;
20175 buf[pos + 1] = lo;
20176}
20177exports.sum64 = sum64;
20178
20179function sum64_hi(ah, al, bh, bl) {
20180 var lo = (al + bl) >>> 0;
20181 var hi = (lo < al ? 1 : 0) + ah + bh;
20182 return hi >>> 0;
20183}
20184exports.sum64_hi = sum64_hi;
20185
20186function sum64_lo(ah, al, bh, bl) {
20187 var lo = al + bl;
20188 return lo >>> 0;
20189}
20190exports.sum64_lo = sum64_lo;
20191
20192function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) {
20193 var carry = 0;
20194 var lo = al;
20195 lo = (lo + bl) >>> 0;
20196 carry += lo < al ? 1 : 0;
20197 lo = (lo + cl) >>> 0;
20198 carry += lo < cl ? 1 : 0;
20199 lo = (lo + dl) >>> 0;
20200 carry += lo < dl ? 1 : 0;
20201
20202 var hi = ah + bh + ch + dh + carry;
20203 return hi >>> 0;
20204}
20205exports.sum64_4_hi = sum64_4_hi;
20206
20207function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) {
20208 var lo = al + bl + cl + dl;
20209 return lo >>> 0;
20210}
20211exports.sum64_4_lo = sum64_4_lo;
20212
20213function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
20214 var carry = 0;
20215 var lo = al;
20216 lo = (lo + bl) >>> 0;
20217 carry += lo < al ? 1 : 0;
20218 lo = (lo + cl) >>> 0;
20219 carry += lo < cl ? 1 : 0;
20220 lo = (lo + dl) >>> 0;
20221 carry += lo < dl ? 1 : 0;
20222 lo = (lo + el) >>> 0;
20223 carry += lo < el ? 1 : 0;
20224
20225 var hi = ah + bh + ch + dh + eh + carry;
20226 return hi >>> 0;
20227}
20228exports.sum64_5_hi = sum64_5_hi;
20229
20230function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
20231 var lo = al + bl + cl + dl + el;
20232
20233 return lo >>> 0;
20234}
20235exports.sum64_5_lo = sum64_5_lo;
20236
20237function rotr64_hi(ah, al, num) {
20238 var r = (al << (32 - num)) | (ah >>> num);
20239 return r >>> 0;
20240}
20241exports.rotr64_hi = rotr64_hi;
20242
20243function rotr64_lo(ah, al, num) {
20244 var r = (ah << (32 - num)) | (al >>> num);
20245 return r >>> 0;
20246}
20247exports.rotr64_lo = rotr64_lo;
20248
20249function shr64_hi(ah, al, num) {
20250 return ah >>> num;
20251}
20252exports.shr64_hi = shr64_hi;
20253
20254function shr64_lo(ah, al, num) {
20255 var r = (ah << (32 - num)) | (al >>> num);
20256 return r >>> 0;
20257}
20258exports.shr64_lo = shr64_lo;
20259
20260},{"inherits":119,"minimalistic-assert":360}],117:[function(require,module,exports){
20261'use strict';
20262
20263var hash = require('hash.js');
20264var utils = require('minimalistic-crypto-utils');
20265var assert = require('minimalistic-assert');
20266
20267function HmacDRBG(options) {
20268 if (!(this instanceof HmacDRBG))
20269 return new HmacDRBG(options);
20270 this.hash = options.hash;
20271 this.predResist = !!options.predResist;
20272
20273 this.outLen = this.hash.outSize;
20274 this.minEntropy = options.minEntropy || this.hash.hmacStrength;
20275
20276 this._reseed = null;
20277 this.reseedInterval = null;
20278 this.K = null;
20279 this.V = null;
20280
20281 var entropy = utils.toArray(options.entropy, options.entropyEnc || 'hex');
20282 var nonce = utils.toArray(options.nonce, options.nonceEnc || 'hex');
20283 var pers = utils.toArray(options.pers, options.persEnc || 'hex');
20284 assert(entropy.length >= (this.minEntropy / 8),
20285 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
20286 this._init(entropy, nonce, pers);
20287}
20288module.exports = HmacDRBG;
20289
20290HmacDRBG.prototype._init = function init(entropy, nonce, pers) {
20291 var seed = entropy.concat(nonce).concat(pers);
20292
20293 this.K = new Array(this.outLen / 8);
20294 this.V = new Array(this.outLen / 8);
20295 for (var i = 0; i < this.V.length; i++) {
20296 this.K[i] = 0x00;
20297 this.V[i] = 0x01;
20298 }
20299
20300 this._update(seed);
20301 this._reseed = 1;
20302 this.reseedInterval = 0x1000000000000; // 2^48
20303};
20304
20305HmacDRBG.prototype._hmac = function hmac() {
20306 return new hash.hmac(this.hash, this.K);
20307};
20308
20309HmacDRBG.prototype._update = function update(seed) {
20310 var kmac = this._hmac()
20311 .update(this.V)
20312 .update([ 0x00 ]);
20313 if (seed)
20314 kmac = kmac.update(seed);
20315 this.K = kmac.digest();
20316 this.V = this._hmac().update(this.V).digest();
20317 if (!seed)
20318 return;
20319
20320 this.K = this._hmac()
20321 .update(this.V)
20322 .update([ 0x01 ])
20323 .update(seed)
20324 .digest();
20325 this.V = this._hmac().update(this.V).digest();
20326};
20327
20328HmacDRBG.prototype.reseed = function reseed(entropy, entropyEnc, add, addEnc) {
20329 // Optional entropy enc
20330 if (typeof entropyEnc !== 'string') {
20331 addEnc = add;
20332 add = entropyEnc;
20333 entropyEnc = null;
20334 }
20335
20336 entropy = utils.toArray(entropy, entropyEnc);
20337 add = utils.toArray(add, addEnc);
20338
20339 assert(entropy.length >= (this.minEntropy / 8),
20340 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
20341
20342 this._update(entropy.concat(add || []));
20343 this._reseed = 1;
20344};
20345
20346HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) {
20347 if (this._reseed > this.reseedInterval)
20348 throw new Error('Reseed is required');
20349
20350 // Optional encoding
20351 if (typeof enc !== 'string') {
20352 addEnc = add;
20353 add = enc;
20354 enc = null;
20355 }
20356
20357 // Optional additional data
20358 if (add) {
20359 add = utils.toArray(add, addEnc || 'hex');
20360 this._update(add);
20361 }
20362
20363 var temp = [];
20364 while (temp.length < len) {
20365 this.V = this._hmac().update(this.V).digest();
20366 temp = temp.concat(this.V);
20367 }
20368
20369 var res = temp.slice(0, len);
20370 this._update(add);
20371 this._reseed++;
20372 return utils.encode(res, enc);
20373};
20374
20375},{"hash.js":105,"minimalistic-assert":360,"minimalistic-crypto-utils":361}],118:[function(require,module,exports){
20376exports.read = function (buffer, offset, isLE, mLen, nBytes) {
20377 var e, m
20378 var eLen = (nBytes * 8) - mLen - 1
20379 var eMax = (1 << eLen) - 1
20380 var eBias = eMax >> 1
20381 var nBits = -7
20382 var i = isLE ? (nBytes - 1) : 0
20383 var d = isLE ? -1 : 1
20384 var s = buffer[offset + i]
20385
20386 i += d
20387
20388 e = s & ((1 << (-nBits)) - 1)
20389 s >>= (-nBits)
20390 nBits += eLen
20391 for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
20392
20393 m = e & ((1 << (-nBits)) - 1)
20394 e >>= (-nBits)
20395 nBits += mLen
20396 for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
20397
20398 if (e === 0) {
20399 e = 1 - eBias
20400 } else if (e === eMax) {
20401 return m ? NaN : ((s ? -1 : 1) * Infinity)
20402 } else {
20403 m = m + Math.pow(2, mLen)
20404 e = e - eBias
20405 }
20406 return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
20407}
20408
20409exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
20410 var e, m, c
20411 var eLen = (nBytes * 8) - mLen - 1
20412 var eMax = (1 << eLen) - 1
20413 var eBias = eMax >> 1
20414 var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
20415 var i = isLE ? 0 : (nBytes - 1)
20416 var d = isLE ? 1 : -1
20417 var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
20418
20419 value = Math.abs(value)
20420
20421 if (isNaN(value) || value === Infinity) {
20422 m = isNaN(value) ? 1 : 0
20423 e = eMax
20424 } else {
20425 e = Math.floor(Math.log(value) / Math.LN2)
20426 if (value * (c = Math.pow(2, -e)) < 1) {
20427 e--
20428 c *= 2
20429 }
20430 if (e + eBias >= 1) {
20431 value += rt / c
20432 } else {
20433 value += rt * Math.pow(2, 1 - eBias)
20434 }
20435 if (value * c >= 2) {
20436 e++
20437 c /= 2
20438 }
20439
20440 if (e + eBias >= eMax) {
20441 m = 0
20442 e = eMax
20443 } else if (e + eBias >= 1) {
20444 m = ((value * c) - 1) * Math.pow(2, mLen)
20445 e = e + eBias
20446 } else {
20447 m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
20448 e = 0
20449 }
20450 }
20451
20452 for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
20453
20454 e = (e << mLen) | m
20455 eLen += mLen
20456 for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
20457
20458 buffer[offset + i - d] |= s * 128
20459}
20460
20461},{}],119:[function(require,module,exports){
20462if (typeof Object.create === 'function') {
20463 // implementation from standard node.js 'util' module
20464 module.exports = function inherits(ctor, superCtor) {
20465 ctor.super_ = superCtor
20466 ctor.prototype = Object.create(superCtor.prototype, {
20467 constructor: {
20468 value: ctor,
20469 enumerable: false,
20470 writable: true,
20471 configurable: true
20472 }
20473 });
20474 };
20475} else {
20476 // old school shim for old browsers
20477 module.exports = function inherits(ctor, superCtor) {
20478 ctor.super_ = superCtor
20479 var TempCtor = function () {}
20480 TempCtor.prototype = superCtor.prototype
20481 ctor.prototype = new TempCtor()
20482 ctor.prototype.constructor = ctor
20483 }
20484}
20485
20486},{}],120:[function(require,module,exports){
20487/*!
20488 * Determine if an object is a Buffer
20489 *
20490 * @author Feross Aboukhadijeh <https://feross.org>
20491 * @license MIT
20492 */
20493
20494// The _isBuffer check is for Safari 5-7 support, because it's missing
20495// Object.prototype.constructor. Remove this eventually
20496module.exports = function (obj) {
20497 return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
20498}
20499
20500function isBuffer (obj) {
20501 return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
20502}
20503
20504// For Node v0.10 support. Remove this eventually.
20505function isSlowBuffer (obj) {
20506 return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
20507}
20508
20509},{}],121:[function(require,module,exports){
20510var toString = {}.toString;
20511
20512module.exports = Array.isArray || function (arr) {
20513 return toString.call(arr) == '[object Array]';
20514};
20515
20516},{}],122:[function(require,module,exports){
20517(function (process,global,Buffer,__argument0,__argument1,__argument2,__argument3,__dirname){
20518var nacl_factory = {
20519 instantiate: function (on_ready, optionsOpt) {
20520 var options = optionsOpt || {};
20521 var undefined_reference_value = (function (v) { return v; })();
20522 var requested_total_memory = options.requested_total_memory || undefined_reference_value;
20523
20524 if (typeof on_ready !== 'function') {
20525 throw new Error("nacl_factory: Expects on_ready callback as first argument. New in v1.1.0.");
20526 }
20527
20528 return (function (window, document) {
20529 var Module = {
20530 TOTAL_MEMORY: requested_total_memory
20531 };
20532 var nacl_raw = Module;
20533 var Module;
20534 if (typeof Module === 'undefined') {
20535 Module = {};
20536 }
20537 var root = Module;
20538 if (typeof root['sodium'] !== 'object') {
20539 if (typeof global === 'object') {
20540 root = global;
20541 } else if (typeof window === 'object') {
20542 root = window;
20543 }
20544 }
20545 if (typeof root['sodium'] === 'object' && typeof root['sodium']['totalMemory'] === 'number') {
20546 Module['TOTAL_MEMORY'] = root['sodium']['totalMemory'];
20547 }
20548 var _Module = Module;
20549 Module.ready = new Promise(function (resolve, reject) {
20550 var Module = _Module;
20551 Module.onAbort = reject;
20552 Module.onRuntimeInitialized = function () {
20553 try {
20554 /* Test arbitrary wasm function */
20555 Module._crypto_secretbox_keybytes();
20556 resolve();
20557 } catch (err) {
20558 reject(err);
20559 }
20560 };
20561 Module.useBackupModule = function () {
20562 var Module = _Module;
20563 Object.keys(Module).forEach(function(k) {
20564 if (k !== 'getRandomValue') {
20565 delete Module[k];
20566 }
20567 });
20568 var Module=typeof Module!=="undefined"?Module:{};var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}Module["arguments"]=[];Module["thisProgram"]="./this.program";Module["quit"]=(function(status,toThrow){throw toThrow});Module["preRun"]=[];Module["postRun"]=[];var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_IS_SHELL=false;ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}else{return scriptDirectory+path}}if(ENVIRONMENT_IS_NODE){scriptDirectory=__dirname+"/";var nodeFS;var nodePath;Module["read"]=function shell_read(filename,binary){var ret;ret=tryParseAsDataURI(filename);if(!ret){if(!nodeFS)nodeFS=require("fs");if(!nodePath)nodePath=require("path");filename=nodePath["normalize"](filename);ret=nodeFS["readFileSync"](filename)}return binary?ret:ret.toString()};Module["readBinary"]=function readBinary(filename){var ret=Module["read"](filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}assert(ret.buffer);return ret};if(process["argv"].length>1){Module["thisProgram"]=process["argv"][1].replace(/\\/g,"/")}Module["arguments"]=process["argv"].slice(2);if(typeof module!=="undefined"){module["exports"]=Module}process["on"]("unhandledRejection",abort);Module["quit"]=(function(status){process["exit"](status)});Module["inspect"]=(function(){return"[Emscripten Module object]"})}else if(ENVIRONMENT_IS_SHELL){if(typeof read!="undefined"){Module["read"]=function shell_read(f){var data=tryParseAsDataURI(f);if(data){return intArrayToString(data)}return read(f)}}Module["readBinary"]=function readBinary(f){var data;data=tryParseAsDataURI(f);if(data){return data}if(typeof readbuffer==="function"){return new Uint8Array(readbuffer(f))}data=read(f,"binary");assert(typeof data==="object");return data};if(typeof scriptArgs!="undefined"){Module["arguments"]=scriptArgs}else if(typeof arguments!="undefined"){Module["arguments"]=arguments}if(typeof quit==="function"){Module["quit"]=(function(status){quit(status)})}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(document.currentScript){scriptDirectory=document.currentScript.src}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.lastIndexOf("/")+1)}else{scriptDirectory=""}Module["read"]=function shell_read(url){try{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText}catch(err){var data=tryParseAsDataURI(url);if(data){return intArrayToString(data)}throw err}};if(ENVIRONMENT_IS_WORKER){Module["readBinary"]=function readBinary(url){try{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}catch(err){var data=tryParseAsDataURI(url);if(data){return data}throw err}}}Module["readAsync"]=function readAsync(url,onload,onerror){var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=function xhr_onload(){if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}var data=tryParseAsDataURI(url);if(data){onload(data.buffer);return}onerror()};xhr.onerror=onerror;xhr.send(null)};Module["setWindowTitle"]=(function(title){document.title=title})}else{}var out=Module["print"]||(typeof console!=="undefined"?console.log.bind(console):typeof print!=="undefined"?print:null);var err=Module["printErr"]||(typeof printErr!=="undefined"?printErr:typeof console!=="undefined"&&console.warn.bind(console)||out);for(key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}moduleOverrides=undefined;var STACK_ALIGN=16;function staticAlloc(size){var ret=STATICTOP;STATICTOP=STATICTOP+size+15&-16;return ret}function dynamicAlloc(size){var ret=HEAP32[DYNAMICTOP_PTR>>2];var end=ret+size+15&-16;HEAP32[DYNAMICTOP_PTR>>2]=end;if(end>=TOTAL_MEMORY){var success=enlargeMemory();if(!success){HEAP32[DYNAMICTOP_PTR>>2]=ret;return 0}}return ret}function alignMemory(size,factor){if(!factor)factor=STACK_ALIGN;var ret=size=Math.ceil(size/factor)*factor;return ret}function getNativeTypeSize(type){switch(type){case"i1":case"i8":return 1;case"i16":return 2;case"i32":return 4;case"i64":return 8;case"float":return 4;case"double":return 8;default:{if(type[type.length-1]==="*"){return 4}else if(type[0]==="i"){var bits=parseInt(type.substr(1));assert(bits%8===0);return bits/8}else{return 0}}}}function warnOnce(text){if(!warnOnce.shown)warnOnce.shown={};if(!warnOnce.shown[text]){warnOnce.shown[text]=1;err(text)}}var jsCallStartIndex=1;var functionPointers=new Array(8);var funcWrappers={};function dynCall(sig,ptr,args){if(args&&args.length){return Module["dynCall_"+sig].apply(null,[ptr].concat(args))}else{return Module["dynCall_"+sig].call(null,ptr)}}var GLOBAL_BASE=8;var ABORT=false;var EXITSTATUS=0;function assert(condition,text){if(!condition){abort("Assertion failed: "+text)}}function getCFunc(ident){var func=Module["_"+ident];assert(func,"Cannot call unknown function "+ident+", make sure it is exported");return func}var JSfuncs={"stackSave":(function(){stackSave()}),"stackRestore":(function(){stackRestore()}),"arrayToC":(function(arr){var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}),"stringToC":(function(str){var ret=0;if(str!==null&&str!==undefined&&str!==0){var len=(str.length<<2)+1;ret=stackAlloc(len);stringToUTF8(str,ret,len)}return ret})};var toC={"string":JSfuncs["stringToC"],"array":JSfuncs["arrayToC"]};function ccall(ident,returnType,argTypes,args,opts){function convertReturnValue(ret){if(returnType==="string")return Pointer_stringify(ret);if(returnType==="boolean")return Boolean(ret);return ret}var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i<args.length;i++){var converter=toC[argTypes[i]];if(converter){if(stack===0)stack=stackSave();cArgs[i]=converter(args[i])}else{cArgs[i]=args[i]}}}var ret=func.apply(null,cArgs);ret=convertReturnValue(ret);if(stack!==0)stackRestore(stack);return ret}function setValue(ptr,value,type,noSafe){type=type||"i8";if(type.charAt(type.length-1)==="*")type="i32";switch(type){case"i1":HEAP8[ptr>>0]=value;break;case"i8":HEAP8[ptr>>0]=value;break;case"i16":HEAP16[ptr>>1]=value;break;case"i32":HEAP32[ptr>>2]=value;break;case"i64":tempI64=[value>>>0,(tempDouble=value,+Math_abs(tempDouble)>=+1?tempDouble>+0?(Math_min(+Math_floor(tempDouble/+4294967296),+4294967295)|0)>>>0:~~+Math_ceil((tempDouble- +(~~tempDouble>>>0))/+4294967296)>>>0:0)],HEAP32[ptr>>2]=tempI64[0],HEAP32[ptr+4>>2]=tempI64[1];break;case"float":HEAPF32[ptr>>2]=value;break;case"double":HEAPF64[ptr>>3]=value;break;default:abort("invalid type for setValue: "+type)}}function getValue(ptr,type,noSafe){type=type||"i8";if(type.charAt(type.length-1)==="*")type="i32";switch(type){case"i1":return HEAP8[ptr>>0];case"i8":return HEAP8[ptr>>0];case"i16":return HEAP16[ptr>>1];case"i32":return HEAP32[ptr>>2];case"i64":return HEAP32[ptr>>2];case"float":return HEAPF32[ptr>>2];case"double":return HEAPF64[ptr>>3];default:abort("invalid type for getValue: "+type)}return null}var ALLOC_STATIC=2;var ALLOC_NONE=4;function Pointer_stringify(ptr,length){if(length===0||!ptr)return"";var hasUtf=0;var t;var i=0;while(1){t=HEAPU8[ptr+i>>0];hasUtf|=t;if(t==0&&!length)break;i++;if(length&&i==length)break}if(!length)length=i;var ret="";if(hasUtf<128){var MAX_CHUNK=1024;var curr;while(length>0){curr=String.fromCharCode.apply(String,HEAPU8.subarray(ptr,ptr+Math.min(length,MAX_CHUNK)));ret=ret?ret+curr:curr;ptr+=MAX_CHUNK;length-=MAX_CHUNK}return ret}return UTF8ToString(ptr)}var UTF8Decoder=typeof TextDecoder!=="undefined"?new TextDecoder("utf8"):undefined;function UTF8ArrayToString(u8Array,idx){var endPtr=idx;while(u8Array[endPtr])++endPtr;if(endPtr-idx>16&&u8Array.subarray&&UTF8Decoder){return UTF8Decoder.decode(u8Array.subarray(idx,endPtr))}else{var u0,u1,u2,u3,u4,u5;var str="";while(1){u0=u8Array[idx++];if(!u0)return str;if(!(u0&128)){str+=String.fromCharCode(u0);continue}u1=u8Array[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}u2=u8Array[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u3=u8Array[idx++]&63;if((u0&248)==240){u0=(u0&7)<<18|u1<<12|u2<<6|u3}else{u4=u8Array[idx++]&63;if((u0&252)==248){u0=(u0&3)<<24|u1<<18|u2<<12|u3<<6|u4}else{u5=u8Array[idx++]&63;u0=(u0&1)<<30|u1<<24|u2<<18|u3<<12|u4<<6|u5}}}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}}}function UTF8ToString(ptr){return UTF8ArrayToString(HEAPU8,ptr)}function stringToUTF8Array(str,outU8Array,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i<str.length;++i){var u=str.charCodeAt(i);if(u>=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;outU8Array[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;outU8Array[outIdx++]=192|u>>6;outU8Array[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;outU8Array[outIdx++]=224|u>>12;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else if(u<=2097151){if(outIdx+3>=endIdx)break;outU8Array[outIdx++]=240|u>>18;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else if(u<=67108863){if(outIdx+4>=endIdx)break;outU8Array[outIdx++]=248|u>>24;outU8Array[outIdx++]=128|u>>18&63;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else{if(outIdx+5>=endIdx)break;outU8Array[outIdx++]=252|u>>30;outU8Array[outIdx++]=128|u>>24&63;outU8Array[outIdx++]=128|u>>18&63;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}}outU8Array[outIdx]=0;return outIdx-startIdx}function stringToUTF8(str,outPtr,maxBytesToWrite){return stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite)}function lengthBytesUTF8(str){var len=0;for(var i=0;i<str.length;++i){var u=str.charCodeAt(i);if(u>=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127){++len}else if(u<=2047){len+=2}else if(u<=65535){len+=3}else if(u<=2097151){len+=4}else if(u<=67108863){len+=5}else{len+=6}}return len}var UTF16Decoder=typeof TextDecoder!=="undefined"?new TextDecoder("utf-16le"):undefined;function demangle(func){return func}function demangleAll(text){var regex=/__Z[\w\d_]+/g;return text.replace(regex,(function(x){var y=demangle(x);return x===y?x:y+" ["+x+"]"}))}function jsStackTrace(){var err=new Error;if(!err.stack){try{throw new Error(0)}catch(e){err=e}if(!err.stack){return"(no stack trace available)"}}return err.stack.toString()}var PAGE_SIZE=16384;var WASM_PAGE_SIZE=65536;var ASMJS_PAGE_SIZE=16777216;var MIN_TOTAL_MEMORY=16777216;function alignUp(x,multiple){if(x%multiple>0){x+=multiple-x%multiple}return x}var buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateGlobalBuffer(buf){Module["buffer"]=buffer=buf}function updateGlobalBufferViews(){Module["HEAP8"]=HEAP8=new Int8Array(buffer);Module["HEAP16"]=HEAP16=new Int16Array(buffer);Module["HEAP32"]=HEAP32=new Int32Array(buffer);Module["HEAPU8"]=HEAPU8=new Uint8Array(buffer);Module["HEAPU16"]=HEAPU16=new Uint16Array(buffer);Module["HEAPU32"]=HEAPU32=new Uint32Array(buffer);Module["HEAPF32"]=HEAPF32=new Float32Array(buffer);Module["HEAPF64"]=HEAPF64=new Float64Array(buffer)}var STATIC_BASE,STATICTOP,staticSealed;var STACK_BASE,STACKTOP,STACK_MAX;var DYNAMIC_BASE,DYNAMICTOP_PTR;STATIC_BASE=STATICTOP=STACK_BASE=STACKTOP=STACK_MAX=DYNAMIC_BASE=DYNAMICTOP_PTR=0;staticSealed=false;function abortOnCannotGrowMemory(){abort("Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value "+TOTAL_MEMORY+", (2) compile with -s ALLOW_MEMORY_GROWTH=1 which allows increasing the size at runtime but prevents some optimizations, (3) set Module.TOTAL_MEMORY to a higher value before the program runs, or (4) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 ")}if(!Module["reallocBuffer"])Module["reallocBuffer"]=(function(size){var ret;try{var oldHEAP8=HEAP8;ret=new ArrayBuffer(size);var temp=new Int8Array(ret);temp.set(oldHEAP8)}catch(e){return false}var success=_emscripten_replace_memory(ret);if(!success)return false;return ret});function enlargeMemory(){var PAGE_MULTIPLE=Module["usingWasm"]?WASM_PAGE_SIZE:ASMJS_PAGE_SIZE;var LIMIT=2147483648-PAGE_MULTIPLE;if(HEAP32[DYNAMICTOP_PTR>>2]>LIMIT){return false}var OLD_TOTAL_MEMORY=TOTAL_MEMORY;TOTAL_MEMORY=Math.max(TOTAL_MEMORY,MIN_TOTAL_MEMORY);while(TOTAL_MEMORY<HEAP32[DYNAMICTOP_PTR>>2]){if(TOTAL_MEMORY<=536870912){TOTAL_MEMORY=alignUp(2*TOTAL_MEMORY,PAGE_MULTIPLE)}else{TOTAL_MEMORY=Math.min(alignUp((3*TOTAL_MEMORY+2147483648)/4,PAGE_MULTIPLE),LIMIT)}}var replacement=Module["reallocBuffer"](TOTAL_MEMORY);if(!replacement||replacement.byteLength!=TOTAL_MEMORY){TOTAL_MEMORY=OLD_TOTAL_MEMORY;return false}updateGlobalBuffer(replacement);updateGlobalBufferViews();return true}var byteLength;try{byteLength=Function.prototype.call.bind(Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,"byteLength").get);byteLength(new ArrayBuffer(4))}catch(e){byteLength=(function(buffer){return buffer.byteLength})}var TOTAL_STACK=Module["TOTAL_STACK"]||5242880;var TOTAL_MEMORY=Module["TOTAL_MEMORY"]||16777216;if(TOTAL_MEMORY<TOTAL_STACK)err("TOTAL_MEMORY should be larger than TOTAL_STACK, was "+TOTAL_MEMORY+"! (TOTAL_STACK="+TOTAL_STACK+")");if(Module["buffer"]){buffer=Module["buffer"]}else{{buffer=new ArrayBuffer(TOTAL_MEMORY)}Module["buffer"]=buffer}updateGlobalBufferViews();function getTotalMemory(){return TOTAL_MEMORY}function callRuntimeCallbacks(callbacks){while(callbacks.length>0){var callback=callbacks.shift();if(typeof callback=="function"){callback();continue}var func=callback.func;if(typeof func==="number"){if(callback.arg===undefined){Module["dynCall_v"](func)}else{Module["dynCall_vi"](func,callback.arg)}}else{func(callback.arg===undefined?null:callback.arg)}}}var __ATPRERUN__=[];var __ATINIT__=[];var __ATMAIN__=[];var __ATEXIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;var runtimeExited=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function ensureInitRuntime(){if(runtimeInitialized)return;runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function exitRuntime(){callRuntimeCallbacks(__ATEXIT__);runtimeExited=true}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}function writeArrayToMemory(array,buffer){HEAP8.set(array,buffer)}function writeAsciiToMemory(str,buffer,dontAddNull){for(var i=0;i<str.length;++i){HEAP8[buffer++>>0]=str.charCodeAt(i)}if(!dontAddNull)HEAP8[buffer>>0]=0}var Math_abs=Math.abs;var Math_ceil=Math.ceil;var Math_floor=Math.floor;var Math_min=Math.min;var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}Module["preloadedImages"]={};Module["preloadedAudios"]={};var memoryInitializer=null;var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(filename){return String.prototype.startsWith?filename.startsWith(dataURIPrefix):filename.indexOf(dataURIPrefix)===0}var ASM_CONSTS=[(function(){return Module.getRandomValue()}),(function(){if(Module.getRandomValue===undefined){try{var window_="object"===typeof window?window:self;var crypto_=typeof window_.crypto!=="undefined"?window_.crypto:window_.msCrypto;var randomValuesStandard=(function(){var buf=new Uint32Array(1);crypto_.getRandomValues(buf);return buf[0]>>>0});randomValuesStandard();Module.getRandomValue=randomValuesStandard}catch(e){try{var crypto=require("crypto");var randomValueNodeJS=(function(){var buf=crypto["randomBytes"](4);return(buf[0]<<24|buf[1]<<16|buf[2]<<8|buf[3])>>>0});randomValueNodeJS();Module.getRandomValue=randomValueNodeJS}catch(e){throw"No secure random number generator found"}}}})];function _emscripten_asm_const_i(code){return ASM_CONSTS[code]()}STATIC_BASE=GLOBAL_BASE;STATICTOP=STATIC_BASE+36016;__ATINIT__.push();memoryInitializer="data:application/octet-stream;base64,AAAAAAAAAAC2eFn/hXLTAL1uFf8PCmoAKcABAJjoef+8PKD/mXHO/wC34v60DUj/AAAAAAAAAACwoA7+08mG/54YjwB/aTUAYAy9AKfX+/+fTID+amXh/x78BACSDK4AAAAAAAAAAABZ8bL+CuWm/3vdKv4eFNQAUoADADDR8wB3eUD/MuOc/wBuxQFnG5AAAAAAAAAAAACFO4wBvfEk//glwwFg3DcAt0w+/8NCPQAyTKQB4aRM/0w9o/91Ph8AUZFA/3ZBDgCic9b/BoouAHzm9P8Kio8ANBrCALj0TACBjykBvvQT/3uqev9igUQAedWTAFZlHv+hZ5sAjFlD/+/lvgFDC7UAxvCJ/u5FvP9Dl+4AEyps/+VVcQEyRIf/EWoJADJnAf9QAagBI5ge/xCouQE4Wej/ZdL8ACn6RwDMqk//Di7v/1BN7wC91kv/EY35ACZQTP++VXUAVuSqAJzY0AHDz6T/lkJM/6/hEP+NUGIBTNvyAMaicgAu2pgAmyvx/pugaP8zu6UAAhGvAEJUoAH3Oh4AI0E1/kXsvwAthvUBo3vdACBuFP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RNOQAddyP/sv4ewA4Eq7/upek/zPo0AGg5Cv/+R0ZAUS+PwANAAAAAP8AAAAA9QAAAAAAAPsAAAAAAAD9AAAAAPMAAAAABwAAAAAAAwAAAADzAAAAAAUAAAAAAAAAAAsAAAAAAAsAAAAA8wAAAAAAAP0AAAAAAP8AAAAAAwAAAAD1AAAAAAAAAA8AAAAAAP8AAAAA/wAAAAAHAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACbolY/CsiewRcP0ifLvmPDV36wF08YzObE4AohtU/wFxxdqcD1N2E+6PAt2DRBnDyogU/osOczGTsf9d5KsA3rs////////////////////////////////////////f+3///////////////////////////////////////9/7v///////////////////////////////////////3/t0/VcGmMSWNac96Le+d4UAAAAAAAAAAAAAAAAAAAAEAZtBwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGfmCWqFrme7cvNuPDr1T6V/Ug5RjGgFm6vZgx8ZzeBbmC+KQpFEN3HP+8C1pdu16VvCVjnxEfFZpII/ktVeHKuYqgfYAVuDEr6FMSTDfQxVdF2+cv6x3oCnBtybdPGbwcFpm+SGR77vxp3BD8yhDCRvLOktqoR0StypsFzaiPl2UlE+mG3GMajIJwOwx39Zv/ML4MZHkafVUWPKBmcpKRSFCrcnOCEbLvxtLE0TDThTVHMKZbsKanYuycKBhSxykqHov6JLZhqocItLwqNRbMcZ6JLRJAaZ1oU1DvRwoGoQFsGkGQhsNx5Md0gntbywNLMMHDlKqthOT8qcW/NvLmjugo90b2OleBR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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAODrenw7QbiuFlbj+vGfxGraCY3rnDKx/YZiBRZfSbgAX5yVvKNQjCSx0LFVnIPvWwREXMRYHI6G2CJO3dCfEVfs////////////////////////////////////////f+3///////////////////////////////////////9/7v///////////////////////////////////////3/N63p8O0G4rhZW4/rxn8Rq2gmN65wysf2GYgUWX0m4gEyclbyjUIwksdCxVZyD71sERFzEWByOhtgiTt3QnxHX2f/////////////////////////////////////////a/////////////////////////////////////////9v/////////////////////////////////////////U2lnRWQyNTUxOSBubyBFZDI1NTE5IGNvbGxpc2lvbnMBAAAAAAAAAAAAAAAAAAAAaG1hY3NoYTUxMjI1NgBjdXJ2ZTI1NTE5eHNhbHNhMjBwb2x5MTMwNQBTLT5idWZsZW4gPD0gQkxBS0UyQl9CTE9DS0JZVEVTAGNyeXB0b19nZW5lcmljaGFzaC9ibGFrZTJiL3JlZi9ibGFrZTJiLXJlZi5jAGNyeXB0b19nZW5lcmljaGFzaF9ibGFrZTJiX19maW5hbABvdXRsZW4gPD0gVUlOVDhfTUFYAGNyeXB0b19nZW5lcmljaGFzaC9ibGFrZTJiL3JlZi9nZW5lcmljaGFzaF9ibGFrZTJiLmMAY3J5cHRvX2dlbmVyaWNoYXNoX2JsYWtlMmJfZmluYWwAc2hhNTEyAGJsYWtlMmIAeDI1NTE5Ymxha2UyYgBwb2x5MTMwNQAkYXJnb24yaWQAJGFyZ29uMmkAJHY9ACRtPQAsdD0ALHA9ACRhcmdvbjJpZCR2PQAkYXJnb24yaSR2PQAkYXJnb24yaWQkACRhcmdvbjJpJABhcm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ByYW5kb20gbnVtYmVyIGdlbmVyYXRvciBmb3VuZCc7IH0gfSB9IH0ATGlic29kaXVtRFJHYnVmX2xlbiA8PSBTSVpFX01BWAByYW5kb21ieXRlcy9yYW5kb21ieXRlcy5jAHJhbmRvbWJ5dGVzAGI2NF9wb3MgPD0gYjY0X2xlbgBzb2RpdW0vY29kZWNzLmMAc29kaXVtX2JpbjJiYXNlNjQAMS4wLjE2AC4vMDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoAJDck";var tempDoublePtr=STATICTOP;STATICTOP+=16;function ___assert_fail(condition,filename,line,func){abort("Assertion failed: "+Pointer_stringify(condition)+", at: "+[filename?Pointer_stringify(filename):"unknown filename",line,func?Pointer_stringify(func):"unknown function"])}function _abort(){Module["abort"]()}function _emscripten_memcpy_big(dest,src,num){HEAPU8.set(HEAPU8.subarray(src,src+num),dest);return dest}function ___setErrNo(value){if(Module["___errno_location"])HEAP32[Module["___errno_location"]()>>2]=value;return value}var ERRNO_CODES={EPERM:1,ENOENT:2,ESRCH:3,EINTR:4,EIO:5,ENXIO:6,E2BIG:7,ENOEXEC:8,EBADF:9,ECHILD:10,EAGAIN:11,EWOULDBLOCK:11,ENOMEM:12,EACCES:13,EFAULT:14,ENOTBLK:15,EBUSY:16,EEXIST:17,EXDEV:18,ENODEV:19,ENOTDIR:20,EISDIR:21,EINVAL:22,ENFILE:23,EMFILE:24,ENOTTY:25,ETXTBSY:26,EFBIG:27,ENOSPC:28,ESPIPE:29,EROFS:30,EMLINK:31,EPIPE:32,EDOM:33,ERANGE:34,ENOMSG:42,EIDRM:43,ECHRNG:44,EL2NSYNC:45,EL3HLT:46,EL3RST:47,ELNRNG:48,EUNATCH:49,ENOCSI:50,EL2HLT:51,EDEADLK:35,ENOLCK:37,EBADE:52,EBADR:53,EXFULL:54,ENOANO:55,EBADRQC:56,EBADSLT:57,EDEADLOCK:35,EBFONT:59,ENOSTR:60,ENODATA:61,ETIME:62,ENOSR:63,ENONET:64,ENOPKG:65,EREMOTE:66,ENOLINK:67,EADV:68,ESRMNT:69,ECOMM:70,EPROTO:71,EMULTIHOP:72,EDOTDOT:73,EBADMSG:74,ENOTUNIQ:76,EBADFD:77,EREMCHG:78,ELIBACC:79,ELIBBAD:80,ELIBSCN:81,ELIBMAX:82,ELIBEXEC:83,ENOSYS:38,ENOTEMPTY:39,ENAMETOOLONG:36,ELOOP:40,EOPNOTSUPP:95,EPFNOSUPPORT:96,ECONNRESET:104,ENOBUFS:105,EAFNOSUPPORT:97,EPROTOTYPE:91,ENOTSOCK:88,ENOPROTOOPT:92,ESHUTDOWN:108,ECONNREFUSED:111,EADDRINUSE:98,ECONNABORTED:103,ENETUNREACH:101,ENETDOWN:100,ETIMEDOUT:110,EHOSTDOWN:112,EHOSTUNREACH:113,EINPROGRESS:115,EALREADY:114,EDESTADDRREQ:89,EMSGSIZE:90,EPROTONOSUPPORT:93,ESOCKTNOSUPPORT:94,EADDRNOTAVAIL:99,ENETRESET:102,EISCONN:106,ENOTCONN:107,ETOOMANYREFS:109,EUSERS:87,EDQUOT:122,ESTALE:116,ENOTSUP:95,ENOMEDIUM:123,EILSEQ:84,EOVERFLOW:75,ECANCELED:125,ENOTRECOVERABLE:131,EOWNERDEAD:130,ESTRPIPE:86};function _sysconf(name){switch(name){case 30:return PAGE_SIZE;case 85:var maxHeapSize=2*1024*1024*1024-16777216;return maxHeapSize/PAGE_SIZE;case 132:case 133:case 12:case 137:case 138:case 15:case 235:case 16:case 17:case 18:case 19:case 20:case 149:case 13:case 10:case 236:case 153:case 9:case 21:case 22:case 159:case 154:case 14:case 77:case 78:case 139:case 80:case 81:case 82:case 68:case 67:case 164:case 11:case 29:case 47:case 48:case 95:case 52:case 51:case 46:return 200809;case 79:return 0;case 27:case 246:case 127:case 128:case 23:case 24:case 160:case 161:case 181:case 182:case 242:case 183:case 184:case 243:case 244:case 245:case 165:case 178:case 179:case 49:case 50:case 168:case 169:case 175:case 170:case 171:case 172:case 97:case 76:case 32:case 173:case 35:return-1;case 176:case 177:case 7:case 155:case 8:case 157:case 125:case 126:case 92:case 93:case 129:case 130:case 131:case 94:case 91:return 1;case 74:case 60:case 69:case 70:case 4:return 1024;case 31:case 42:case 72:return 32;case 87:case 26:case 33:return 2147483647;case 34:case 1:return 47839;case 38:case 36:return 99;case 43:case 37:return 2048;case 0:return 2097152;case 3:return 65536;case 28:return 32768;case 44:return 32767;case 75:return 16384;case 39:return 1e3;case 89:return 700;case 71:return 256;case 40:return 255;case 2:return 100;case 180:return 64;case 25:return 20;case 5:return 16;case 6:return 6;case 73:return 4;case 84:{if(typeof navigator==="object")return navigator["hardwareConcurrency"]||1;return 1}}___setErrNo(ERRNO_CODES.EINVAL);return-1}DYNAMICTOP_PTR=staticAlloc(4);STACK_BASE=STACKTOP=alignMemory(STATICTOP);STACK_MAX=STACK_BASE+TOTAL_STACK;DYNAMIC_BASE=alignMemory(STACK_MAX);HEAP32[DYNAMICTOP_PTR>>2]=DYNAMIC_BASE;staticSealed=true;var ASSERTIONS=false;function intArrayToString(array){var ret=[];for(var i=0;i<array.length;i++){var chr=array[i];if(chr>255){if(ASSERTIONS){assert(false,"Character code "+chr+" ("+String.fromCharCode(chr)+") at offset "+i+" not in 0x00-0xFF.")}chr&=255}ret.push(String.fromCharCode(chr))}return ret.join("")}var decodeBase64=typeof atob==="function"?atob:(function(input){var keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{enc1=keyStr.indexOf(input.charAt(i++));enc2=keyStr.indexOf(input.charAt(i++));enc3=keyStr.indexOf(input.charAt(i++));enc4=keyStr.indexOf(input.charAt(i++));chr1=enc1<<2|enc2>>4;chr2=(enc2&15)<<4|enc3>>2;chr3=(enc3&3)<<6|enc4;output=output+String.fromCharCode(chr1);if(enc3!==64){output=output+String.fromCharCode(chr2)}if(enc4!==64){output=output+String.fromCharCode(chr3)}}while(i<input.length);return output});function intArrayFromBase64(s){if(typeof ENVIRONMENT_IS_NODE==="boolean"&&ENVIRONMENT_IS_NODE){var buf;try{buf=Buffer.from(s,"base64")}catch(_){buf=new Buffer(s,"base64")}return new Uint8Array(buf.buffer,buf.byteOffset,buf.byteLength)}try{var decoded=decodeBase64(s);var bytes=new Uint8Array(decoded.length);for(var i=0;i<decoded.length;++i){bytes[i]=decoded.charCodeAt(i)}return bytes}catch(_){throw new Error("Converting base64 string to bytes failed.")}}function tryParseAsDataURI(filename){if(!isDataURI(filename)){return}return intArrayFromBase64(filename.slice(dataURIPrefix.length))}Module.asmGlobalArg={"Math":Math,"Int8Array":Int8Array,"Int16Array":Int16Array,"Int32Array":Int32Array,"Uint8Array":Uint8Array,"Uint16Array":Uint16Array,"Uint32Array":Uint32Array,"Float32Array":Float32Array,"Float64Array":Float64Array,"NaN":NaN,"Infinity":Infinity,"byteLength":byteLength};Module.asmLibraryArg={"a":abort,"b":assert,"c":enlargeMemory,"d":getTotalMemory,"e":abortOnCannotGrowMemory,"f":___assert_fail,"g":___setErrNo,"h":_abort,"i":_emscripten_asm_const_i,"j":_emscripten_memcpy_big,"k":_sysconf,"l":DYNAMICTOP_PTR,"m":tempDoublePtr,"n":STACKTOP,"o":STACK_MAX};// EMSCRIPTEN_START_ASM
20569var asm=(/** @suppress {uselessCode} */ function(global,env,buffer) {
20570"almost asm";var a=global.Int8Array;var b=new a(buffer);var c=global.Int16Array;var d=new c(buffer);var e=global.Int32Array;var f=new e(buffer);var g=global.Uint8Array;var h=new g(buffer);var i=global.Uint16Array;var j=new i(buffer);var k=global.Uint32Array;var l=new k(buffer);var m=global.Float32Array;var n=new m(buffer);var o=global.Float64Array;var p=new o(buffer);var q=global.byteLength;var r=env.l|0;var s=env.m|0;var t=env.n|0;var u=env.o|0;var v=0;var w=0;var x=0;var y=0;var z=global.NaN,A=global.Infinity;var B=0,C=0,D=0,E=0,F=0.0;var G=0;var H=global.Math.floor;var I=global.Math.abs;var J=global.Math.sqrt;var K=global.Math.pow;var L=global.Math.cos;var M=global.Math.sin;var N=global.Math.tan;var O=global.Math.acos;var P=global.Math.asin;var Q=global.Math.atan;var R=global.Math.atan2;var S=global.Math.exp;var T=global.Math.log;var U=global.Math.ceil;var V=global.Math.imul;var W=global.Math.min;var X=global.Math.max;var Y=global.Math.clz32;var Z=env.a;var _=env.b;var $=env.c;var aa=env.d;var ba=env.e;var ca=env.f;var da=env.g;var ea=env.h;var fa=env.i;var ga=env.j;var ha=env.k;var ia=0.0;function ja(newBuffer){if(q(newBuffer)&16777215||q(newBuffer)<=16777215||q(newBuffer)>2147483648)return false;b=new a(newBuffer);d=new c(newBuffer);f=new e(newBuffer);h=new g(newBuffer);j=new i(newBuffer);l=new k(newBuffer);n=new m(newBuffer);p=new o(newBuffer);buffer=newBuffer;return true}
20571// EMSCRIPTEN_START_FUNCS
20572function ka(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0;e=t;g=t=t+63&-64;t=t+256|0;c=0;do{h=tf(b+(c<<3)|0)|0;d=g+128+(c<<3)|0;f[d>>2]=h;f[d+4>>2]=G;c=c+1|0}while((c|0)!=16);c=g;b=a;d=c+64|0;do{f[c>>2]=f[b>>2];c=c+4|0;b=b+4|0}while((c|0)<(d|0));f[g+88>>2]=1595750129;f[g+88+4>>2]=-1521486534;N=f[a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ua=G;rc=Af(_a&2097151|0,0,X&2097151|0,0)|0;qc=G;pc=Af(wb&2097151|0,0,lb&2097151|0,0)|0;Ga=G;E=Af(Ja&2097151|0,0,X&2097151|0,0)|0;va=G;D=Af(_a&2097151|0,0,lb&2097151|0,0)|0;kc=G;na=Af(wb&2097151|0,0,cb&2097151|0,0)|0;na=Lg(D|0,kc|0,na|0,G|0)|0;va=Lg(na|0,G|0,E|0,va|0)|0;wa=Lg(va|0,G|0,wa&2097151|0,0)|0;va=G;E=Af(g&2097151|0,0,X&2097151|0,0)|0;na=G;kc=Af(Ja&2097151|0,0,lb&2097151|0,0)|0;D=G;oc=Af(_a&2097151|0,0,cb&2097151|0,0)|0;nc=G;mc=Af(wb&2097151|0,0,kb&2097151|0,0)|0;lc=G;S=Af(h&2097151|0,0,X&2097151|0,0)|0;pa=G;bc=Af(g&2097151|0,0,lb&2097151|0,0)|0;Ea=G;dc=Af(Ja&2097151|0,0,cb&2097151|0,0)|0;p=G;ec=Af(_a&2097151|0,0,kb&2097151|0,0)|0;fc=G;cc=Af(wb&2097151|0,0,Ya&2097151|0,0)|0;cc=Lg(ec|0,fc|0,cc|0,G|0)|0;p=Lg(cc|0,G|0,dc|0,p|0)|0;Ea=Lg(p|0,G|0,bc|0,Ea|0)|0;pa=Lg(Ea|0,G|0,S|0,pa|0)|0;qa=Lg(pa|0,G|0,qa&2097151|0,0)|0;pa=G;S=Af(u&2097151|0,0,X&2097151|0,0)|0;Ea=G;bc=Af(h&2097151|0,0,lb&2097151|0,0)|0;p=G;dc=Af(g&2097151|0,0,cb&2097151|0,0)|0;cc=G;fc=Af(Ja&2097151|0,0,kb&2097151|0,0)|0;ec=G;jc=Af(_a&2097151|0,0,Ya&2097151|0,0)|0;ic=G;hc=Af(wb&2097151|0,0,L&2097151|0,0)|0;gc=G;c=Af(Ca&2097151|0,0,X&2097151|0,0)|0;$a=G;Qb=Af(u&2097151|0,0,lb&2097151|0,0)|0;i=G;Sb=Af(h&2097151|0,0,cb&2097151|0,0)|0;k=G;Ub=Af(g&2097151|0,0,kb&2097151|0,0)|0;Rb=G;Wb=Af(Ja&2097151|0,0,Ya&2097151|0,0)|0;Tb=G;Xb=Af(_a&2097151|0,0,L&2097151|0,0)|0;Yb=G;Vb=Af(wb&2097151|0,0,aa&2097151|0,0)|0;Vb=Lg(Xb|0,Yb|0,Vb|0,G|0)|0;Tb=Lg(Vb|0,G|0,Wb|0,Tb|0)|0;Rb=Lg(Tb|0,G|0,Ub|0,Rb|0)|0;k=Lg(Rb|0,G|0,Sb|0,k|0)|0;i=Lg(k|0,G|0,Qb|0,i|0)|0;$a=Lg(i|0,G|0,c|0,$a|0)|0;fb=Lg($a|0,G|0,fb&2097151|0,0)|0;$a=G;c=Af(Z&2097151|0,0,X&2097151|0,0)|0;i=G;Qb=Af(Ca&2097151|0,0,lb&2097151|0,0)|0;k=G;Sb=Af(u&2097151|0,0,cb&2097151|0,0)|0;Rb=G;Ub=Af(h&2097151|0,0,kb&2097151|0,0)|0;Tb=G;Wb=Af(g&2097151|0,0,Ya&2097151|0,0)|0;Vb=G;Yb=Af(Ja&2097151|0,0,L&2097151|0,0)|0;Xb=G;ac=Af(_a&2097151|0,0,aa&2097151|0,0)|0;$b=G;_b=Af(wb&2097151|0,0,f&2097151|0,0)|0;Zb=G;Bb=Af(ra&2097151|0,0,X&2097151|0,0)|0;j=G;y=Af(Z&2097151|0,0,lb&2097151|0,0)|0;Sa=G;zb=Af(Ca&2097151|0,0,cb&2097151|0,0)|0;Ab=G;Db=Af(u&2097151|0,0,kb&2097151|0,0)|0;x=G;Fb=Af(h&2097151|0,0,Ya&2097151|0,0)|0;Cb=G;Hb=Af(g&2097151|0,0,L&2097151|0,0)|0;Eb=G;Jb=Af(Ja&2097151|0,0,aa&2097151|0,0)|0;Gb=G;Kb=Af(_a&2097151|0,0,f&2097151|0,0)|0;Lb=G;Ib=Af(wb&2097151|0,0,M&2097151|0,0)|0;Ib=Lg(Kb|0,Lb|0,Ib|0,G|0)|0;Gb=Lg(Ib|0,G|0,Jb|0,Gb|0)|0;Eb=Lg(Gb|0,G|0,Hb|0,Eb|0)|0;Cb=Lg(Eb|0,G|0,Fb|0,Cb|0)|0;x=Lg(Cb|0,G|0,Db|0,x|0)|0;Ab=Lg(x|0,G|0,zb|0,Ab|0)|0;j=Lg(Ab|0,G|0,Bb|0,j|0)|0;Sa=Lg(j|0,G|0,y|0,Sa|0)|0;Ra=Lg(Sa|0,G|0,Ra&2097151|0,0)|0;Sa=G;y=Af(I&2097151|0,0,X&2097151|0,0)|0;j=G;Bb=Af(ra&2097151|0,0,lb&2097151|0,0)|0;Ab=G;zb=Af(Z&2097151|0,0,cb&2097151|0,0)|0;x=G;Db=Af(Ca&2097151|0,0,kb&2097151|0,0)|0;Cb=G;Fb=Af(u&2097151|0,0,Ya&2097151|0,0)|0;Eb=G;Hb=Af(h&2097151|0,0,L&2097151|0,0)|0;Gb=G;Jb=Af(g&2097151|0,0,aa&2097151|0,0)|0;Ib=G;Lb=Af(Ja&2097151|0,0,f&2097151|0,0)|0;Kb=G;Pb=Af(_a&2097151|0,0,M&2097151|0,0)|0;Ob=G;Nb=Af(wb&2097151|0,0,z&2097151|0,0)|0;Mb=G;Y=Af(rb&2097151|0,0,X&2097151|0,0)|0;W=G;C=Af(I&2097151|0,0,lb&2097151|0,0)|0;B=G;Oa=Af(ra&2097151|0,0,cb&2097151|0,0)|0;Na=G;ob=Af(Z&2097151|0,0,kb&2097151|0,0)|0;nb=G;N=Af(Ca&2097151|0,0,Ya&2097151|0,0)|0;n=G;eb=Af(u&2097151|0,0,L&2097151|0,0)|0;db=G;Ia=Af(h&2097151|0,0,aa&2097151|0,0)|0;Ha=G;Ua=Af(g&2097151|0,0,f&2097151|0,0)|0;Ta=G;A=Af(Ja&2097151|0,0,M&2097151|0,0)|0;e=G;yb=Af(_a&2097151|0,0,z&2097151|0,0)|0;tb=G;ub=Af(wb&2097151|0,0,da&2097151|0,0)|0;ub=Lg(yb|0,tb|0,ub|0,G|0)|0;e=Lg(ub|0,G|0,A|0,e|0)|0;Ta=Lg(e|0,G|0,Ua|0,Ta|0)|0;Ha=Lg(Ta|0,G|0,Ia|0,Ha|0)|0;db=Lg(Ha|0,G|0,eb|0,db|0)|0;n=Lg(db|0,G|0,N|0,n|0)|0;Na=Lg(n|0,G|0,Oa|0,Na|0)|0;nb=Lg(Na|0,G|0,ob|0,nb|0)|0;B=Lg(nb|0,G|0,C|0,B|0)|0;W=Lg(B|0,G|0,Y|0,W|0)|0;V=Lg(W|0,G|0,V&2097151|0,0)|0;W=G;X=Af(U|0,T|0,X&2097151|0,0)|0;Y=G;B=Af(rb&2097151|0,0,lb&2097151|0,0)|0;C=G;nb=Af(I&2097151|0,0,cb&2097151|0,0)|0;ob=G;Na=Af(ra&2097151|0,0,kb&2097151|0,0)|0;Oa=G;n=Af(Z&2097151|0,0,Ya&2097151|0,0)|0;N=G;db=Af(Ca&2097151|0,0,L&2097151|0,0)|0;eb=G;Ha=Af(u&2097151|0,0,aa&2097151|0,0)|0;Ia=G;Ta=Af(h&2097151|0,0,f&2097151|0,0)|0;Ua=G;e=Af(g&2097151|0,0,M&2097151|0,0)|0;A=G;ub=Af(Ja&2097151|0,0,z&2097151|0,0)|0;tb=G;yb=Af(_a&2097151|0,0,da&2097151|0,0)|0;xb=G;wb=Af(wb&2097151|0,0,ha|0,ia|0)|0;vb=G;lb=Af(U|0,T|0,lb&2097151|0,0)|0;mb=G;_=Af(rb&2097151|0,0,cb&2097151|0,0)|0;bb=G;pb=Af(I&2097151|0,0,kb&2097151|0,0)|0;r=G;ca=Af(ra&2097151|0,0,Ya&2097151|0,0)|0;R=G;Q=Af(Z&2097151|0,0,L&2097151|0,0)|0;qb=G;la=Af(Ca&2097151|0,0,aa&2097151|0,0)|0;t=G;ea=Af(u&2097151|0,0,f&2097151|0,0)|0;ma=G;Wa=Af(h&2097151|0,0,M&2097151|0,0)|0;ja=G;Za=Af(g&2097151|0,0,z&2097151|0,0)|0;Va=G;jb=Af(Ja&2097151|0,0,da&2097151|0,0)|0;Ka=G;_a=Af(_a&2097151|0,0,ha|0,ia|0)|0;_a=Lg(jb|0,Ka|0,_a|0,G|0)|0;Va=Lg(_a|0,G|0,Za|0,Va|0)|0;ja=Lg(Va|0,G|0,Wa|0,ja|0)|0;ma=Lg(ja|0,G|0,ea|0,ma|0)|0;t=Lg(ma|0,G|0,la|0,t|0)|0;R=Lg(t|0,G|0,ca|0,R|0)|0;qb=Lg(R|0,G|0,Q|0,qb|0)|0;r=Lg(qb|0,G|0,pb|0,r|0)|0;bb=Lg(r|0,G|0,_|0,bb|0)|0;mb=Lg(bb|0,G|0,lb|0,mb|0)|0;lb=G;cb=Af(U|0,T|0,cb&2097151|0,0)|0;bb=G;_=Af(rb&2097151|0,0,kb&2097151|0,0)|0;r=G;pb=Af(I&2097151|0,0,Ya&2097151|0,0)|0;qb=G;Q=Af(ra&2097151|0,0,L&2097151|0,0)|0;R=G;ca=Af(Z&2097151|0,0,aa&2097151|0,0)|0;t=G;la=Af(Ca&2097151|0,0,f&2097151|0,0)|0;ma=G;ea=Af(u&2097151|0,0,M&2097151|0,0)|0;ja=G;Wa=Af(h&2097151|0,0,z&2097151|0,0)|0;Va=G;Za=Af(g&2097151|0,0,da&2097151|0,0)|0;_a=G;Ja=Af(Ja&2097151|0,0,ha|0,ia|0)|0;Ka=G;kb=Af(U|0,T|0,kb&2097151|0,0)|0;jb=G;hb=Af(rb&2097151|0,0,Ya&2097151|0,0)|0;Xa=G;v=Af(I&2097151|0,0,L&2097151|0,0)|0;ib=G;Aa=Af(ra&2097151|0,0,aa&2097151|0,0)|0;F=G;o=Af(Z&2097151|0,0,f&2097151|0,0)|0;d=G;m=Af(Ca&2097151|0,0,M&2097151|0,0)|0;Fa=G;ba=Af(u&2097151|0,0,z&2097151|0,0)|0;$=G;sb=Af(h&2097151|0,0,da&2097151|0,0)|0;s=G;g=Af(g&2097151|0,0,ha|0,ia|0)|0;g=Lg(sb|0,s|0,g|0,G|0)|0;$=Lg(g|0,G|0,ba|0,$|0)|0;Fa=Lg($|0,G|0,m|0,Fa|0)|0;F=Lg(Fa|0,G|0,Aa|0,F|0)|0;d=Lg(F|0,G|0,o|0,d|0)|0;ib=Lg(d|0,G|0,v|0,ib|0)|0;Xa=Lg(ib|0,G|0,hb|0,Xa|0)|0;jb=Lg(Xa|0,G|0,kb|0,jb|0)|0;kb=G;Ya=Af(U|0,T|0,Ya&2097151|0,0)|0;Xa=G;hb=Af(rb&2097151|0,0,L&2097151|0,0)|0;ib=G;v=Af(I&2097151|0,0,aa&2097151|0,0)|0;d=G;o=Af(ra&2097151|0,0,f&2097151|0,0)|0;F=G;Aa=Af(Z&2097151|0,0,M&2097151|0,0)|0;Fa=G;m=Af(Ca&2097151|0,0,z&2097151|0,0)|0;$=G;ba=Af(u&2097151|0,0,da&2097151|0,0)|0;g=G;h=Af(h&2097151|0,0,ha|0,ia|0)|0;s=G;L=Af(U|0,T|0,L&2097151|0,0)|0;sb=G;Ma=Af(rb&2097151|0,0,aa&2097151|0,0)|0;J=G;ga=Af(I&2097151|0,0,f&2097151|0,0)|0;La=G;w=Af(ra&2097151|0,0,M&2097151|0,0)|0;O=G;P=Af(Z&2097151|0,0,z&2097151|0,0)|0;fa=G;q=Af(Ca&2097151|0,0,da&2097151|0,0)|0;Ba=G;u=Af(u&2097151|0,0,ha|0,ia|0)|0;u=Lg(q|0,Ba|0,u|0,G|0)|0;O=Lg(u|0,G|0,w|0,O|0)|0;fa=Lg(O|0,G|0,P|0,fa|0)|0;La=Lg(fa|0,G|0,ga|0,La|0)|0;J=Lg(La|0,G|0,Ma|0,J|0)|0;sb=Lg(J|0,G|0,L|0,sb|0)|0;L=G;aa=Af(U|0,T|0,aa&2097151|0,0)|0;J=G;Ma=Af(rb&2097151|0,0,f&2097151|0,0)|0;La=G;ga=Af(I&2097151|0,0,M&2097151|0,0)|0;fa=G;P=Af(ra&2097151|0,0,z&2097151|0,0)|0;O=G;w=Af(Z&2097151|0,0,da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11?16:a+11&-8;l=f[8878]|0;if(l>>>(n>>>3)&3|0){a=35552+((l>>>(n>>>3)&1^1)+(n>>>3)<<1<<2)|0;b=f[a+8>>2]|0;c=f[b+8>>2]|0;if((c|0)==(a|0))f[8878]=l&~(1<<(l>>>(n>>>3)&1^1)+(n>>>3));else{f[c+12>>2]=a;f[a+8>>2]=c}w=(l>>>(n>>>3)&1^1)+(n>>>3)<<3;f[b+4>>2]=w|3;f[b+w+4>>2]=f[b+w+4>>2]|1;w=b+8|0;t=x;return w|0}m=f[8880]|0;if(n>>>0>m>>>0){if(l>>>(n>>>3)|0){a=l>>>(n>>>3)<<(n>>>3)&(2<<(n>>>3)|0-(2<<(n>>>3)));e=((a&0-a)+-1|0)>>>(((a&0-a)+-1|0)>>>12&16);d=e>>>(e>>>5&8)>>>(e>>>(e>>>5&8)>>>2&4);d=(e>>>5&8|((a&0-a)+-1|0)>>>12&16|e>>>(e>>>5&8)>>>2&4|d>>>1&2|d>>>(d>>>1&2)>>>1&1)+(d>>>(d>>>1&2)>>>(d>>>(d>>>1&2)>>>1&1))|0;e=f[35552+(d<<1<<2)+8>>2]|0;a=f[e+8>>2]|0;if((a|0)==(35552+(d<<1<<2)|0)){f[8878]=l&~(1<<d);a=l&~(1<<d)}else{f[a+12>>2]=35552+(d<<1<<2);f[35552+(d<<1<<2)+8>>2]=a;a=l}f[e+4>>2]=n|3;f[e+n+4>>2]=(d<<3)-n|1;f[e+(d<<3)>>2]=(d<<3)-n;if(m|0){c=f[8883]|0;if(!(a&1<<(m>>>3))){f[8878]=a|1<<(m>>>3);a=35552+(m>>>3<<1<<2)|0;b=35552+(m>>>3<<1<<2)+8|0}else{a=f[35552+(m>>>3<<1<<2)+8>>2]|0;b=35552+(m>>>3<<1<<2)+8|0}f[b>>2]=c;f[a+12>>2]=c;f[c+8>>2]=a;f[c+12>>2]=35552+(m>>>3<<1<<2)}f[8880]=(d<<3)-n;f[8883]=e+n;w=e+8|0;t=x;return w|0}h=f[8879]|0;if(h){b=((h&0-h)+-1|0)>>>(((h&0-h)+-1|0)>>>12&16);k=b>>>(b>>>5&8)>>>(b>>>(b>>>5&8)>>>2&4);k=f[35816+((b>>>5&8|((h&0-h)+-1|0)>>>12&16|b>>>(b>>>5&8)>>>2&4|k>>>1&2|k>>>(k>>>1&2)>>>1&1)+(k>>>(k>>>1&2)>>>(k>>>(k>>>1&2)>>>1&1))<<2)>>2]|0;b=k;j=k;k=(f[k+4>>2]&-8)-n|0;while(1){a=f[b+16>>2]|0;if(!a){a=f[b+20>>2]|0;if(!a)break}i=(f[a+4>>2]&-8)-n|0;e=i>>>0<k>>>0;b=a;j=e?a:j;k=e?i:k}i=j+n|0;if(i>>>0>j>>>0){e=f[j+24>>2]|0;a=f[j+12>>2]|0;do if((a|0)==(j|0)){b=j+20|0;a=f[b>>2]|0;if(!a){b=j+16|0;a=f[b>>2]|0;if(!a){b=0;break}}while(1){d=a+20|0;c=f[d>>2]|0;if(!c){d=a+16|0;c=f[d>>2]|0;if(!c)break;else{a=c;b=d}}else{a=c;b=d}}f[b>>2]=0;b=a}else{b=f[j+8>>2]|0;f[b+12>>2]=a;f[a+8>>2]=b;b=a}while(0);do if(e|0){a=f[j+28>>2]|0;if((j|0)==(f[35816+(a<<2)>>2]|0)){f[35816+(a<<2)>>2]=b;if(!b){f[8879]=h&~(1<<a);break}}else{f[((f[e+16>>2]|0)==(j|0)?e+16|0:e+20|0)>>2]=b;if(!b)break}f[b+24>>2]=e;a=f[j+16>>2]|0;if(a|0){f[b+16>>2]=a;f[a+24>>2]=b}a=f[j+20>>2]|0;if(a|0){f[b+20>>2]=a;f[a+24>>2]=b}}while(0);if(k>>>0<16){w=k+n|0;f[j+4>>2]=w|3;w=j+w+4|0;f[w>>2]=f[w>>2]|1}else{f[j+4>>2]=n|3;f[i+4>>2]=k|1;f[i+k>>2]=k;if(m|0){c=f[8883]|0;if(!(1<<(m>>>3)&l)){f[8878]=1<<(m>>>3)|l;a=35552+(m>>>3<<1<<2)|0;b=35552+(m>>>3<<1<<2)+8|0}else{a=f[35552+(m>>>3<<1<<2)+8>>2]|0;b=35552+(m>>>3<<1<<2)+8|0}f[b>>2]=c;f[a+12>>2]=c;f[c+8>>2]=a;f[c+12>>2]=35552+(m>>>3<<1<<2)}f[8880]=k;f[8883]=i}w=j+8|0;t=x;return w|0}}}}else if(a>>>0<=4294967231){n=a+11&-8;d=f[8879]|0;if(d){if((a+11|0)>>>8)if(n>>>0>16777215)j=31;else{j=(a+11|0)>>>8<<((((a+11|0)>>>8)+1048320|0)>>>16&8);j=14-((j+520192|0)>>>16&4|(((a+11|0)>>>8)+1048320|0)>>>16&8|((j<<((j+520192|0)>>>16&4))+245760|0)>>>16&2)+(j<<((j+520192|0)>>>16&4)<<(((j<<((j+520192|0)>>>16&4))+245760|0)>>>16&2)>>>15)|0;j=n>>>(j+7|0)&1|j<<1}else j=0;a=f[35816+(j<<2)>>2]|0;a:do if(!a){c=0;a=0;b=0-n|0;s=61}else{h=0;b=0-n|0;i=n<<((j|0)==31?0:25-(j>>>1)|0);c=0;while(1){e=(f[a+4>>2]&-8)-n|0;if(e>>>0<b>>>0)if(!e){e=a;b=0;c=a;s=65;break a}else{h=a;b=e}s=f[a+20>>2]|0;a=f[a+16+(i>>>31<<2)>>2]|0;c=(s|0)==0|(s|0)==(a|0)?c:s;if(!a){a=h;s=61;break}else i=i<<1}}while(0);if((s|0)==61){if((c|0)==0&(a|0)==0){a=2<<j;if(!((a|0-a)&d))break;l=((a|0-a)&d&0-((a|0-a)&d))+-1|0;m=l>>>(l>>>12&16)>>>(l>>>(l>>>12&16)>>>5&8);c=m>>>(m>>>2&4)>>>(m>>>(m>>>2&4)>>>1&2);a=0;c=f[35816+((l>>>(l>>>12&16)>>>5&8|l>>>12&16|m>>>2&4|m>>>(m>>>2&4)>>>1&2|c>>>1&1)+(c>>>(c>>>1&1))<<2)>>2]|0}if(!c){i=a;h=b}else{e=a;s=65}}if((s|0)==65)while(1){m=(f[c+4>>2]&-8)-n|0;a=m>>>0<b>>>0;b=a?m:b;e=a?c:e;a=f[c+16>>2]|0;if(!a)a=f[c+20>>2]|0;if(!a){i=e;h=b;break}else c=a}if(((i|0)!=0?h>>>0<((f[8880]|0)-n|0)>>>0:0)?(k=i+n|0,k>>>0>i>>>0):0){g=f[i+24>>2]|0;a=f[i+12>>2]|0;do if((a|0)==(i|0)){b=i+20|0;a=f[b>>2]|0;if(!a){b=i+16|0;a=f[b>>2]|0;if(!a){a=0;break}}while(1){e=a+20|0;c=f[e>>2]|0;if(!c){e=a+16|0;c=f[e>>2]|0;if(!c)break;else{a=c;b=e}}else{a=c;b=e}}f[b>>2]=0}else{w=f[i+8>>2]|0;f[w+12>>2]=a;f[a+8>>2]=w}while(0);do if(g){b=f[i+28>>2]|0;if((i|0)==(f[35816+(b<<2)>>2]|0)){f[35816+(b<<2)>>2]=a;if(!a){f[8879]=d&~(1<<b);d=d&~(1<<b);break}}else{f[((f[g+16>>2]|0)==(i|0)?g+16|0:g+20|0)>>2]=a;if(!a)break}f[a+24>>2]=g;b=f[i+16>>2]|0;if(b|0){f[a+16>>2]=b;f[b+24>>2]=a}b=f[i+20>>2]|0;if(b){f[a+20>>2]=b;f[b+24>>2]=a}}while(0);b:do if(h>>>0<16){w=h+n|0;f[i+4>>2]=w|3;w=i+w+4|0;f[w>>2]=f[w>>2]|1}else{f[i+4>>2]=n|3;f[k+4>>2]=h|1;f[k+h>>2]=h;c=h>>>3;if(h>>>0<256){a=f[8878]|0;if(!(a&1<<c)){f[8878]=a|1<<c;a=35552+(c<<1<<2)|0;b=35552+(c<<1<<2)+8|0}else{a=f[35552+(c<<1<<2)+8>>2]|0;b=35552+(c<<1<<2)+8|0}f[b>>2]=k;f[a+12>>2]=k;f[k+8>>2]=a;f[k+12>>2]=35552+(c<<1<<2);break}a=h>>>8;if(a)if(h>>>0>16777215)c=31;else{c=a<<((a+1048320|0)>>>16&8)<<(((a<<((a+1048320|0)>>>16&8))+520192|0)>>>16&4);c=14-(((a<<((a+1048320|0)>>>16&8))+520192|0)>>>16&4|(a+1048320|0)>>>16&8|(c+245760|0)>>>16&2)+(c<<((c+245760|0)>>>16&2)>>>15)|0;c=h>>>(c+7|0)&1|c<<1}else c=0;a=35816+(c<<2)|0;f[k+28>>2]=c;f[k+16+4>>2]=0;f[k+16>>2]=0;b=1<<c;if(!(d&b)){f[8879]=d|b;f[a>>2]=k;f[k+24>>2]=a;f[k+12>>2]=k;f[k+8>>2]=k;break}a=f[a>>2]|0;c:do if((f[a+4>>2]&-8|0)!=(h|0)){d=h<<((c|0)==31?0:25-(c>>>1)|0);while(1){c=a+16+(d>>>31<<2)|0;b=f[c>>2]|0;if(!b)break;if((f[b+4>>2]&-8|0)==(h|0)){a=b;break c}else{d=d<<1;a=b}}f[c>>2]=k;f[k+24>>2]=a;f[k+12>>2]=k;f[k+8>>2]=k;break b}while(0);v=a+8|0;w=f[v>>2]|0;f[w+12>>2]=k;f[v>>2]=k;f[k+8>>2]=w;f[k+12>>2]=a;f[k+24>>2]=0}while(0);w=i+8|0;t=x;return w|0}}}else n=-1;while(0);c=f[8880]|0;if(c>>>0>=n>>>0){a=c-n|0;b=f[8883]|0;if(a>>>0>15){w=b+n|0;f[8883]=w;f[8880]=a;f[w+4>>2]=a|1;f[b+c>>2]=a;f[b+4>>2]=n|3}else{f[8880]=0;f[8883]=0;f[b+4>>2]=c|3;f[b+c+4>>2]=f[b+c+4>>2]|1}w=b+8|0;t=x;return w|0}e=f[8881]|0;if(e>>>0>n>>>0){u=e-n|0;f[8881]=u;w=f[8884]|0;v=w+n|0;f[8884]=v;f[v+4>>2]=u|1;f[w+4>>2]=n|3;w=w+8|0;t=x;return w|0}if(!(f[8996]|0)){f[8998]=4096;f[8997]=4096;f[8999]=-1;f[9e3]=-1;f[9001]=0;f[8989]=0;f[8996]=o&-16^1431655768;a=4096}else a=f[8998]|0;h=n+48|0;i=n+47|0;k=a+i|0;j=0-a|0;if((k&j)>>>0<=n>>>0){w=0;t=x;return w|0}a=f[8988]|0;if(a|0?(o=f[8986]|0,(o+(k&j)|0)>>>0<=o>>>0?1:(o+(k&j)|0)>>>0>a>>>0):0){w=0;t=x;return w|0}d:do if(!(f[8989]&4)){c=f[8884]|0;e:do if(c){b=35960;while(1){a=f[b>>2]|0;if(a>>>0<=c>>>0?(p=b+4|0,(a+(f[p>>2]|0)|0)>>>0>c>>>0):0)break;a=f[b+8>>2]|0;if(!a){s=128;break e}else b=a}if((k-e&j)>>>0<2147483647){a=be(k-e&j|0)|0;if((a|0)==((f[b>>2]|0)+(f[p>>2]|0)|0))if((a|0)==(-1|0))a=k-e&j;else{h=k-e&j;g=a;s=145;break d}else{d=a;c=k-e&j;s=136}}else a=0}else s=128;while(0);do if((s|0)==128){b=be(0)|0;if((b|0)!=(-1|0)?(r=f[8997]|0,r=((r+-1&b|0)==0?0:(r+-1+b&0-r)-b|0)+(k&j)|0,q=f[8986]|0,r>>>0>n>>>0&r>>>0<2147483647):0){p=f[8988]|0;if(p|0?(r+q|0)>>>0<=q>>>0|(r+q|0)>>>0>p>>>0:0){a=0;break}a=be(r|0)|0;if((a|0)==(b|0)){h=r;g=b;s=145;break d}else{d=a;c=r;s=136}}else a=0}while(0);do if((s|0)==136){b=0-c|0;if(!(h>>>0>c>>>0&(c>>>0<2147483647&(d|0)!=(-1|0))))if((d|0)==(-1|0)){a=0;break}else{h=c;g=d;s=145;break d}a=f[8998]|0;a=i-c+a&0-a;if(a>>>0>=2147483647){h=c;g=d;s=145;break d}if((be(a|0)|0)==(-1|0)){be(b|0)|0;a=0;break}else{h=a+c|0;g=d;s=145;break d}}while(0);f[8989]=f[8989]|4;s=143}else{a=0;s=143}while(0);if(((s|0)==143?(k&j)>>>0<2147483647:0)?(g=be(k&j|0)|0,u=be(0)|0,v=(u-g|0)>>>0>(n+40|0)>>>0,!((g|0)==(-1|0)|v^1|g>>>0<u>>>0&((g|0)!=(-1|0)&(u|0)!=(-1|0))^1)):0){h=v?u-g|0:a;s=145}if((s|0)==145){a=(f[8986]|0)+h|0;f[8986]=a;if(a>>>0>(f[8987]|0)>>>0)f[8987]=a;j=f[8884]|0;f:do if(j){a=35960;while(1){b=f[a>>2]|0;c=a+4|0;d=f[c>>2]|0;if((g|0)==(b+d|0)){s=154;break}e=f[a+8>>2]|0;if(!e)break;else a=e}if(((s|0)==154?(f[a+12>>2]&8|0)==0:0)?g>>>0>j>>>0&b>>>0<=j>>>0:0){f[c>>2]=d+h;w=(f[8881]|0)+h|0;v=(j+8&7|0)==0?0:0-(j+8)&7;f[8884]=j+v;f[8881]=w-v;f[j+v+4>>2]=w-v|1;f[j+w+4>>2]=40;f[8885]=f[9e3];break}if(g>>>0<(f[8882]|0)>>>0)f[8882]=g;c=g+h|0;a=35960;while(1){if((f[a>>2]|0)==(c|0)){s=162;break}b=f[a+8>>2]|0;if(!b)break;else a=b}if((s|0)==162?(f[a+12>>2]&8|0)==0:0){f[a>>2]=g;l=a+4|0;f[l>>2]=(f[l>>2]|0)+h;l=g+8|0;l=g+((l&7|0)==0?0:0-l&7)|0;a=c+((c+8&7|0)==0?0:0-(c+8)&7)|0;k=l+n|0;i=a-l-n|0;f[l+4>>2]=n|3;g:do if((j|0)==(a|0)){w=(f[8881]|0)+i|0;f[8881]=w;f[8884]=k;f[k+4>>2]=w|1}else{if((f[8883]|0)==(a|0)){w=(f[8880]|0)+i|0;f[8880]=w;f[8883]=k;f[k+4>>2]=w|1;f[k+w>>2]=w;break}h=f[a+4>>2]|0;if((h&3|0)==1){h:do if(h>>>0<256){b=f[a+8>>2]|0;c=f[a+12>>2]|0;if((c|0)==(b|0)){f[8878]=f[8878]&~(1<<(h>>>3));break}else{f[b+12>>2]=c;f[c+8>>2]=b;break}}else{g=f[a+24>>2]|0;b=f[a+12>>2]|0;do if((b|0)==(a|0)){b=f[a+16+4>>2]|0;if(!b){b=f[a+16>>2]|0;if(!b){b=0;break}else c=a+16|0}else c=a+16+4|0;while(1){e=b+20|0;d=f[e>>2]|0;if(!d){e=b+16|0;d=f[e>>2]|0;if(!d)break;else{b=d;c=e}}else{b=d;c=e}}f[c>>2]=0}else{w=f[a+8>>2]|0;f[w+12>>2]=b;f[b+8>>2]=w}while(0);if(!g)break;c=f[a+28>>2]|0;do if((f[35816+(c<<2)>>2]|0)!=(a|0)){f[((f[g+16>>2]|0)==(a|0)?g+16|0:g+20|0)>>2]=b;if(!b)break h}else{f[35816+(c<<2)>>2]=b;if(b|0)break;f[8879]=f[8879]&~(1<<c);break h}while(0);f[b+24>>2]=g;c=f[a+16>>2]|0;if(c|0){f[b+16>>2]=c;f[c+24>>2]=b}c=f[a+16+4>>2]|0;if(!c)break;f[b+20>>2]=c;f[c+24>>2]=b}while(0);a=a+(h&-8)|0;e=(h&-8)+i|0}else e=i;c=a+4|0;f[c>>2]=f[c>>2]&-2;f[k+4>>2]=e|1;f[k+e>>2]=e;c=e>>>3;if(e>>>0<256){a=f[8878]|0;if(!(a&1<<c)){f[8878]=a|1<<c;a=35552+(c<<1<<2)|0;b=35552+(c<<1<<2)+8|0}else{a=f[35552+(c<<1<<2)+8>>2]|0;b=35552+(c<<1<<2)+8|0}f[b>>2]=k;f[a+12>>2]=k;f[k+8>>2]=a;f[k+12>>2]=35552+(c<<1<<2);break}a=e>>>8;do if(!a)d=0;else{if(e>>>0>16777215){d=31;break}d=a<<((a+1048320|0)>>>16&8)<<(((a<<((a+1048320|0)>>>16&8))+520192|0)>>>16&4);d=14-(((a<<((a+1048320|0)>>>16&8))+520192|0)>>>16&4|(a+1048320|0)>>>16&8|(d+245760|0)>>>16&2)+(d<<((d+245760|0)>>>16&2)>>>15)|0;d=e>>>(d+7|0)&1|d<<1}while(0);a=35816+(d<<2)|0;f[k+28>>2]=d;f[k+16+4>>2]=0;f[k+16>>2]=0;b=f[8879]|0;c=1<<d;if(!(b&c)){f[8879]=b|c;f[a>>2]=k;f[k+24>>2]=a;f[k+12>>2]=k;f[k+8>>2]=k;break}a=f[a>>2]|0;i:do if((f[a+4>>2]&-8|0)!=(e|0)){d=e<<((d|0)==31?0:25-(d>>>1)|0);while(1){c=a+16+(d>>>31<<2)|0;b=f[c>>2]|0;if(!b)break;if((f[b+4>>2]&-8|0)==(e|0)){a=b;break i}else{d=d<<1;a=b}}f[c>>2]=k;f[k+24>>2]=a;f[k+12>>2]=k;f[k+8>>2]=k;break g}while(0);v=a+8|0;w=f[v>>2]|0;f[w+12>>2]=k;f[v>>2]=k;f[k+8>>2]=w;f[k+12>>2]=a;f[k+24>>2]=0}while(0);w=l+8|0;t=x;return w|0}a=35960;while(1){b=f[a>>2]|0;if(b>>>0<=j>>>0?(w=b+(f[a+4>>2]|0)|0,w>>>0>j>>>0):0)break;a=f[a+8>>2]|0}e=w+-47+((w+-47+8&7|0)==0?0:0-(w+-47+8)&7)|0;e=e>>>0<(j+16|0)>>>0?j:e;a=h+-40|0;u=g+8|0;u=(u&7|0)==0?0:0-u&7;v=g+u|0;f[8884]=v;f[8881]=a-u;f[v+4>>2]=a-u|1;f[g+a+4>>2]=40;f[8885]=f[9e3];f[e+4>>2]=27;f[e+8>>2]=f[8990];f[e+8+4>>2]=f[8991];f[e+8+8>>2]=f[8992];f[e+8+12>>2]=f[8993];f[8990]=g;f[8991]=h;f[8993]=0;f[8992]=e+8;a=e+24|0;do{v=a;a=a+4|0;f[a>>2]=7}while((v+8|0)>>>0<w>>>0);if((e|0)!=(j|0)){f[e+4>>2]=f[e+4>>2]&-2;f[j+4>>2]=e-j|1;f[e>>2]=e-j;if((e-j|0)>>>0<256){c=35552+((e-j|0)>>>3<<1<<2)|0;a=f[8878]|0;if(!(a&1<<((e-j|0)>>>3))){f[8878]=a|1<<((e-j|0)>>>3);a=c;b=c+8|0}else{a=f[c+8>>2]|0;b=c+8|0}f[b>>2]=j;f[a+12>>2]=j;f[j+8>>2]=a;f[j+12>>2]=c;break}if((e-j|0)>>>8)if((e-j|0)>>>0>16777215)d=31;else{d=(e-j|0)>>>8<<((((e-j|0)>>>8)+1048320|0)>>>16&8);d=14-((d+520192|0)>>>16&4|(((e-j|0)>>>8)+1048320|0)>>>16&8|((d<<((d+520192|0)>>>16&4))+245760|0)>>>16&2)+(d<<((d+520192|0)>>>16&4)<<(((d<<((d+520192|0)>>>16&4))+245760|0)>>>16&2)>>>15)|0;d=(e-j|0)>>>(d+7|0)&1|d<<1}else d=0;a=35816+(d<<2)|0;f[j+28>>2]=d;f[j+20>>2]=0;f[j+16>>2]=0;b=f[8879]|0;c=1<<d;if(!(b&c)){f[8879]=b|c;f[a>>2]=j;f[j+24>>2]=a;f[j+12>>2]=j;f[j+8>>2]=j;break}a=f[a>>2]|0;j:do if((f[a+4>>2]&-8|0)!=(e-j|0)){d=e-j<<((d|0)==31?0:25-(d>>>1)|0);while(1){c=a+16+(d>>>31<<2)|0;b=f[c>>2]|0;if(!b)break;if((f[b+4>>2]&-8|0)==(e-j|0)){a=b;break j}else{d=d<<1;a=b}}f[c>>2]=j;f[j+24>>2]=a;f[j+12>>2]=j;f[j+8>>2]=j;break f}while(0);v=a+8|0;w=f[v>>2]|0;f[w+12>>2]=j;f[v>>2]=j;f[j+8>>2]=w;f[j+12>>2]=a;f[j+24>>2]=0}}else{w=f[8882]|0;if((w|0)==0|g>>>0<w>>>0)f[8882]=g;f[8990]=g;f[8991]=h;f[8993]=0;f[8887]=f[8996];f[8886]=-1;f[8891]=35552;f[8890]=35552;f[8893]=35560;f[8892]=35560;f[8895]=35568;f[8894]=35568;f[8897]=35576;f[8896]=35576;f[8899]=35584;f[8898]=35584;f[8901]=35592;f[8900]=35592;f[8903]=35600;f[8902]=35600;f[8905]=35608;f[8904]=35608;f[8907]=35616;f[8906]=35616;f[8909]=35624;f[8908]=35624;f[8911]=35632;f[8910]=35632;f[8913]=35640;f[8912]=35640;f[8915]=35648;f[8914]=35648;f[8917]=35656;f[8916]=35656;f[8919]=35664;f[8918]=35664;f[8921]=35672;f[8920]=35672;f[8923]=35680;f[8922]=35680;f[8925]=35688;f[8924]=35688;f[8927]=35696;f[8926]=35696;f[8929]=35704;f[8928]=35704;f[8931]=35712;f[8930]=35712;f[8933]=35720;f[8932]=35720;f[8935]=35728;f[8934]=35728;f[8937]=35736;f[8936]=35736;f[8939]=35744;f[8938]=35744;f[8941]=35752;f[8940]=35752;f[8943]=35760;f[8942]=35760;f[8945]=35768;f[8944]=35768;f[8947]=35776;f[8946]=35776;f[8949]=35784;f[8948]=35784;f[8951]=35792;f[8950]=35792;f[8953]=35800;f[8952]=35800;w=h+-40|0;u=g+8|0;u=(u&7|0)==0?0:0-u&7;v=g+u|0;f[8884]=v;f[8881]=w-u;f[v+4>>2]=w-u|1;f[g+w+4>>2]=40;f[8885]=f[9e3]}while(0);a=f[8881]|0;if(a>>>0>n>>>0){u=a-n|0;f[8881]=u;w=f[8884]|0;v=w+n|0;f[8884]=v;f[v+4>>2]=u|1;f[w+4>>2]=n|3;w=w+8|0;t=x;return w|0}}f[9002]=12;w=0;t=x;return w|0}function oa(a){a=a|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0;P=Cf(b[a>>0]|0,b[a+1>>0]|0,b[a+2>>0]|0)|0;S=we(a+2|0)|0;S=$f(S|0,G|0,5)|0;F=Cf(b[a+5>>0]|0,b[a+6>>0]|0,b[a+7>>0]|0)|0;F=$f(F|0,G|0,2)|0;m=we(a+7|0)|0;m=$f(m|0,G|0,7)|0;Q=we(a+10|0)|0;Q=$f(Q|0,G|0,4)|0;W=Cf(b[a+13>>0]|0,b[a+14>>0]|0,b[a+15>>0]|0)|0;W=$f(W|0,G|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0,0,666643,0)|0;M=G;u=Af(C&2097151|0,0,470296,0)|0;Z=G;D=Af(C&2097151|0,0,654183,0)|0;d=G;U=Af(C&2097151|0,0,-997805,-1)|0;T=G;O=Af(C&2097151|0,0,136657,0)|0;p=G;C=Af(C&2097151|0,0,-683901,-1)|0;C=Lg(r|0,c|0,C|0,G|0)|0;c=G;r=Af(x&2097151|0,0,666643,0)|0;V=G;y=Af(x&2097151|0,0,470296,0)|0;aa=G;K=Af(x&2097151|0,0,654183,0)|0;h=G;na=Af(x&2097151|0,0,-997805,-1)|0;ia=G;Y=Af(x&2097151|0,0,136657,0)|0;E=G;x=Af(x&2097151|0,0,-683901,-1)|0;N=Lg(x|0,G|0,N&2097151|0,0)|0;j=Lg(N|0,G|0,w|0,j|0)|0;p=Lg(j|0,G|0,O|0,p|0)|0;O=G;j=Af(k&2097151|0,0,666643,0)|0;w=G;N=Af(k&2097151|0,0,470296,0)|0;x=G;n=Af(k&2097151|0,0,654183,0)|0;X=G;H=Af(k&2097151|0,0,-997805,-1)|0;I=G;pa=Af(k&2097151|0,0,136657,0)|0;oa=G;k=Af(k&2097151|0,0,-683901,-1)|0;l=G;o=Af(ra&2097151|0,0,666643,0)|0;B=G;fa=Af(ra&2097151|0,0,470296,0)|0;ga=G;da=Af(ra&2097151|0,0,654183,0)|0;ca=G;ka=Af(ra&2097151|0,0,-997805,-1)|0;J=G;_=Af(ra&2097151|0,0,136657,0)|0;t=G;ra=Af(ra&2097151|0,0,-683901,-1)|0;qa=Lg(ra|0,G|0,qa&2097151|0,0)|0;oa=Lg(qa|0,G|0,pa|0,oa|0)|0;ia=Lg(oa|0,G|0,na|0,ia|0)|0;s=Lg(ia|0,G|0,ja|0,s|0)|0;d=Lg(s|0,G|0,D|0,d|0)|0;D=G;s=Af(ba&2097151|0,0,666643,0)|0;v=Lg(s|0,G|0,v&2097151|0,0)|0;s=G;ja=Af(ba&2097151|0,0,470296,0)|0;ia=G;na=Af(ba&2097151|0,0,654183,0)|0;ma=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a+36>>2]=b;return}function va(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;m=tf(e)|0;o=G;f=tf(e+8|0)|0;g=G;d=Wf(c|0,d|0,56)|0;e=G;if((b+c+(0-(c&7))|0)==(b|0)){q=f^2037671283;j=g^1952801890;n=m^1886610805;k=o^1936682341;i=f^1852075907;r=g^1685025377;g=m^1852142177;f=o^1819895653}else{s=b;q=f^2037671283;j=g^1952801890;n=m^1886610805;l=o^1936682341;k=f^1852075907;i=g^1685025377;g=m^1852142177;f=o^1819895653;while(1){p=tf(s)|0;t=G;v=p^q;j=t^j;l=Lg(n|0,l|0,k|0,i|0)|0;r=G;n=yf(k,i,13)|0;k=G^r;r=yf(l,r,32)|0;q=G;m=Lg(v|0,j|0,g|0,f|0)|0;o=G;j=yf(v,j,16)|0;i=G^o;q=Lg(j^m|0,i|0,r|0,q|0)|0;r=G;i=yf(j^m,i,21)|0;j=r^G;o=Lg(m|0,o|0,n^l|0,k|0)|0;m=G;k=yf(n^l,k,17)|0;f=G^m;m=yf(o,m,32)|0;g=G;r=Lg(k^o|0,f|0,q|0,r|0)|0;l=G;f=yf(k^o,f,13)|0;o=G^l;l=yf(r,l,32)|0;k=G;g=Lg(m|0,g|0,q^i|0,j|0)|0;m=G;j=yf(q^i,j,16)|0;i=G^m;k=Lg(j^g|0,i|0,l|0,k|0)|0;l=G;i=yf(j^g,i,21)|0;j=l^G;m=Lg(f^r|0,o|0,g|0,m|0)|0;g=G;o=yf(f^r,o,17)|0;r=G^g;g=yf(m,g,32)|0;f=G;s=s+8|0;if((s|0)==(b+c+(0-(c&7))|0)){b=b+c+(0-(c&7))|0;q=k^i;n=k^p;k=l^t;i=o^m;break}else{q=k^i;n=k^p;l=l^t;k=o^m;i=r}}}switch(c&7){case 7:{d=Wf(h[b+6>>0]|0|0,0,48)|0|d;e=G|e;u=6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+4>>2]=g|1;f[h+g>>2]=g;return}if(d>>>0<256){b=f[h+8>>2]|0;a=f[h+12>>2]|0;if((a|0)==(b|0)){f[8878]=f[8878]&~(1<<(d>>>3));i=h;b=g;break}else{f[b+12>>2]=a;f[a+8>>2]=b;i=h;b=g;break}}e=f[h+24>>2]|0;b=f[h+12>>2]|0;do if((b|0)==(h|0)){b=f[h+16+4>>2]|0;if(!b){b=f[h+16>>2]|0;if(!b){b=0;break}else a=h+16|0}else a=h+16+4|0;while(1){d=b+20|0;c=f[d>>2]|0;if(!c){d=b+16|0;c=f[d>>2]|0;if(!c)break;else{b=c;a=d}}else{b=c;a=d}}f[a>>2]=0}else{i=f[h+8>>2]|0;f[i+12>>2]=b;f[b+8>>2]=i}while(0);if(e){a=f[h+28>>2]|0;if((f[35816+(a<<2)>>2]|0)==(h|0)){f[35816+(a<<2)>>2]=b;if(!b){f[8879]=f[8879]&~(1<<a);i=h;b=g;break}}else{f[((f[e+16>>2]|0)==(h|0)?e+16|0:e+20|0)>>2]=b;if(!b){i=h;b=g;break}}f[b+24>>2]=e;a=f[h+16>>2]|0;if(a|0){f[b+16>>2]=a;f[a+24>>2]=b}a=f[h+16+4>>2]|0;if(a){f[b+20>>2]=a;f[a+24>>2]=b;i=h;b=g}else{i=h;b=g}}else{i=h;b=g}}else{i=a+-8|0;b=c&-8;h=a+-8|0}while(0);if(h>>>0>=j>>>0)return;c=f[j+4>>2]|0;if(!(c&1))return;if(!(c&2)){if((f[8884]|0)==(j|0)){j=(f[8881]|0)+b|0;f[8881]=j;f[8884]=i;f[i+4>>2]=j|1;if((i|0)!=(f[8883]|0))return;f[8883]=0;f[8880]=0;return}if((f[8883]|0)==(j|0)){j=(f[8880]|0)+b|0;f[8880]=j;f[8883]=h;f[i+4>>2]=j|1;f[h+j>>2]=j;return}e=(c&-8)+b|0;do if(c>>>0<256){a=f[j+8>>2]|0;b=f[j+12>>2]|0;if((b|0)==(a|0)){f[8878]=f[8878]&~(1<<(c>>>3));break}else{f[a+12>>2]=b;f[b+8>>2]=a;break}}else{g=f[j+24>>2]|0;b=f[j+12>>2]|0;do if((b|0)==(j|0)){b=f[j+16+4>>2]|0;if(!b){b=f[j+16>>2]|0;if(!b){a=0;break}else a=j+16|0}else a=j+16+4|0;while(1){d=b+20|0;c=f[d>>2]|0;if(!c){d=b+16|0;c=f[d>>2]|0;if(!c)break;else{b=c;a=d}}else{b=c;a=d}}f[a>>2]=0;a=b}else{a=f[j+8>>2]|0;f[a+12>>2]=b;f[b+8>>2]=a;a=b}while(0);if(g|0){b=f[j+28>>2]|0;if((f[35816+(b<<2)>>2]|0)==(j|0)){f[35816+(b<<2)>>2]=a;if(!a){f[8879]=f[8879]&~(1<<b);break}}else{f[((f[g+16>>2]|0)==(j|0)?g+16|0:g+20|0)>>2]=a;if(!a)break}f[a+24>>2]=g;b=f[j+16>>2]|0;if(b|0){f[a+16>>2]=b;f[b+24>>2]=a}b=f[j+16+4>>2]|0;if(b|0){f[a+20>>2]=b;f[b+24>>2]=a}}}while(0);f[i+4>>2]=e|1;f[h+e>>2]=e;if((i|0)==(f[8883]|0)){f[8880]=e;return}}else{f[j+4>>2]=c&-2;f[i+4>>2]=b|1;f[h+b>>2]=b;e=b}c=e>>>3;if(e>>>0<256){b=f[8878]|0;if(!(b&1<<c)){f[8878]=b|1<<c;b=35552+(c<<1<<2)|0;a=35552+(c<<1<<2)+8|0}else{b=f[35552+(c<<1<<2)+8>>2]|0;a=35552+(c<<1<<2)+8|0}f[a>>2]=i;f[b+12>>2]=i;f[i+8>>2]=b;f[i+12>>2]=35552+(c<<1<<2);return}b=e>>>8;if(b)if(e>>>0>16777215)d=31;else{d=b<<((b+1048320|0)>>>16&8)<<(((b<<((b+1048320|0)>>>16&8))+520192|0)>>>16&4);d=14-(((b<<((b+1048320|0)>>>16&8))+520192|0)>>>16&4|(b+1048320|0)>>>16&8|(d+245760|0)>>>16&2)+(d<<((d+245760|0)>>>16&2)>>>15)|0;d=e>>>(d+7|0)&1|d<<1}else d=0;b=35816+(d<<2)|0;f[i+28>>2]=d;f[i+20>>2]=0;f[i+16>>2]=0;a=f[8879]|0;c=1<<d;a:do if(!(a&c)){f[8879]=a|c;f[b>>2]=i;f[i+24>>2]=b;f[i+12>>2]=i;f[i+8>>2]=i}else{b=f[b>>2]|0;b:do if((f[b+4>>2]&-8|0)!=(e|0)){d=e<<((d|0)==31?0:25-(d>>>1)|0);while(1){c=b+16+(d>>>31<<2)|0;a=f[c>>2]|0;if(!a)break;if((f[a+4>>2]&-8|0)==(e|0)){b=a;break b}else{d=d<<1;b=a}}f[c>>2]=i;f[i+24>>2]=b;f[i+12>>2]=i;f[i+8>>2]=i;break a}while(0);h=b+8|0;j=f[h>>2]|0;f[j+12>>2]=i;f[h>>2]=i;f[i+8>>2]=j;f[i+12>>2]=b;f[i+24>>2]=0}while(0);j=(f[8886]|0)+-1|0;f[8886]=j;if(j|0)return;b=35968;while(1){b=f[b>>2]|0;if(!b)break;else b=b+8|0}f[8886]=-1;return}function xa(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0;c=f[a+4>>2]|0;do if(!(c&1)){i=f[a>>2]|0;if(!(c&3))return;if((f[8883]|0)==(a+(0-i)|0)){c=f[a+b+4>>2]|0;if((c&3|0)!=3){j=a+(0-i)|0;c=i+b|0;break}f[8880]=i+b;f[a+b+4>>2]=c&-2;f[a+(0-i)+4>>2]=i+b|1;f[a+b>>2]=i+b;return}if(i>>>0<256){c=f[a+(0-i)+8>>2]|0;d=f[a+(0-i)+12>>2]|0;if((d|0)==(c|0)){f[8878]=f[8878]&~(1<<(i>>>3));j=a+(0-i)|0;c=i+b|0;break}else{f[c+12>>2]=d;f[d+8>>2]=c;j=a+(0-i)|0;c=i+b|0;break}}h=f[a+(0-i)+24>>2]|0;c=f[a+(0-i)+12>>2]|0;do if((c|0)==(a+(0-i)|0)){d=a+(0-i)+16|0;c=f[d+4>>2]|0;if(!c){c=f[d>>2]|0;if(!c){c=0;break}}else d=d+4|0;while(1){g=c+20|0;e=f[g>>2]|0;if(!e){g=c+16|0;e=f[g>>2]|0;if(!e)break;else{c=e;d=g}}else{c=e;d=g}}f[d>>2]=0}else{j=f[a+(0-i)+8>>2]|0;f[j+12>>2]=c;f[c+8>>2]=j}while(0);if(h){d=f[a+(0-i)+28>>2]|0;if((f[35816+(d<<2)>>2]|0)==(a+(0-i)|0)){f[35816+(d<<2)>>2]=c;if(!c){f[8879]=f[8879]&~(1<<d);j=a+(0-i)|0;c=i+b|0;break}}else{f[((f[h+16>>2]|0)==(a+(0-i)|0)?h+16|0:h+20|0)>>2]=c;if(!c){j=a+(0-i)|0;c=i+b|0;break}}f[c+24>>2]=h;d=f[a+(0-i)+16>>2]|0;if(d|0){f[c+16>>2]=d;f[d+24>>2]=c}d=f[a+(0-i)+16+4>>2]|0;if(d){f[c+20>>2]=d;f[d+24>>2]=c;j=a+(0-i)|0;c=i+b|0}else{j=a+(0-i)|0;c=i+b|0}}else{j=a+(0-i)|0;c=i+b|0}}else{j=a;c=b}while(0);e=f[a+b+4>>2]|0;if(!(e&2)){if((f[8884]|0)==(a+b|0)){b=(f[8881]|0)+c|0;f[8881]=b;f[8884]=j;f[j+4>>2]=b|1;if((j|0)!=(f[8883]|0))return;f[8883]=0;f[8880]=0;return}if((f[8883]|0)==(a+b|0)){b=(f[8880]|0)+c|0;f[8880]=b;f[8883]=j;f[j+4>>2]=b|1;f[j+b>>2]=b;return}h=(e&-8)+c|0;do if(e>>>0<256){d=f[a+b+8>>2]|0;c=f[a+b+12>>2]|0;if((c|0)==(d|0)){f[8878]=f[8878]&~(1<<(e>>>3));break}else{f[d+12>>2]=c;f[c+8>>2]=d;break}}else{i=f[a+b+24>>2]|0;c=f[a+b+12>>2]|0;do if((c|0)==(a+b|0)){c=f[a+b+16+4>>2]|0;if(!c){c=f[a+b+16>>2]|0;if(!c){d=0;break}else d=a+b+16|0}else d=a+b+16+4|0;while(1){g=c+20|0;e=f[g>>2]|0;if(!e){g=c+16|0;e=f[g>>2]|0;if(!e)break;else{c=e;d=g}}else{c=e;d=g}}f[d>>2]=0;d=c}else{d=f[a+b+8>>2]|0;f[d+12>>2]=c;f[c+8>>2]=d;d=c}while(0);if(i|0){c=f[a+b+28>>2]|0;if((f[35816+(c<<2)>>2]|0)==(a+b|0)){f[35816+(c<<2)>>2]=d;if(!d){f[8879]=f[8879]&~(1<<c);break}}else{f[((f[i+16>>2]|0)==(a+b|0)?i+16|0:i+20|0)>>2]=d;if(!d)break}f[d+24>>2]=i;c=f[a+b+16>>2]|0;if(c|0){f[d+16>>2]=c;f[c+24>>2]=d}c=f[a+b+16+4>>2]|0;if(c|0){f[d+20>>2]=c;f[c+24>>2]=d}}}while(0);f[j+4>>2]=h|1;f[j+h>>2]=h;if((j|0)==(f[8883]|0)){f[8880]=h;return}}else{f[a+b+4>>2]=e&-2;f[j+4>>2]=c|1;f[j+c>>2]=c;h=c}e=h>>>3;if(h>>>0<256){c=f[8878]|0;if(!(c&1<<e)){f[8878]=c|1<<e;c=35552+(e<<1<<2)|0;d=35552+(e<<1<<2)+8|0}else{c=f[35552+(e<<1<<2)+8>>2]|0;d=35552+(e<<1<<2)+8|0}f[d>>2]=j;f[c+12>>2]=j;f[j+8>>2]=c;f[j+12>>2]=35552+(e<<1<<2);return}c=h>>>8;if(c)if(h>>>0>16777215)g=31;else{g=c<<((c+1048320|0)>>>16&8)<<(((c<<((c+1048320|0)>>>16&8))+520192|0)>>>16&4);g=14-(((c<<((c+1048320|0)>>>16&8))+520192|0)>>>16&4|(c+1048320|0)>>>16&8|(g+245760|0)>>>16&2)+(g<<((g+245760|0)>>>16&2)>>>15)|0;g=h>>>(g+7|0)&1|g<<1}else g=0;c=35816+(g<<2)|0;f[j+28>>2]=g;f[j+20>>2]=0;f[j+16>>2]=0;d=f[8879]|0;e=1<<g;if(!(d&e)){f[8879]=d|e;f[c>>2]=j;f[j+24>>2]=c;f[j+12>>2]=j;f[j+8>>2]=j;return}c=f[c>>2]|0;a:do if((f[c+4>>2]&-8|0)!=(h|0)){g=h<<((g|0)==31?0:25-(g>>>1)|0);while(1){e=c+16+(g>>>31<<2)|0;d=f[e>>2]|0;if(!d)break;if((f[d+4>>2]&-8|0)==(h|0)){c=d;break a}else{g=g<<1;c=d}}f[e>>2]=j;f[j+24>>2]=c;f[j+12>>2]=j;f[j+8>>2]=j;return}while(0);a=c+8|0;b=f[a>>2]|0;f[b+12>>2]=j;f[a>>2]=j;f[j+8>>2]=b;f[j+12>>2]=c;f[j+24>>2]=0;return}function ya(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;m=tf(e)|0;o=G;f=tf(e+8|0)|0;g=G;d=Wf(c|0,d|0,56)|0;e=G;if((b+c+(0-(c&7))|0)==(b|0)){q=f^2037671283;j=g^1952801890;n=m^1886610805;k=o^1936682341;i=f^1852075885;r=g^1685025377;g=m^1852142177;f=o^1819895653}else{s=b;q=f^2037671283;j=g^1952801890;n=m^1886610805;l=o^1936682341;k=f^1852075885;i=g^1685025377;g=m^1852142177;f=o^1819895653;while(1){p=tf(s)|0;t=G;v=p^q;j=t^j;l=Lg(n|0,l|0,k|0,i|0)|0;r=G;n=yf(k,i,13)|0;k=G^r;r=yf(l,r,32)|0;q=G;m=Lg(v|0,j|0,g|0,f|0)|0;o=G;j=yf(v,j,16)|0;i=G^o;q=Lg(j^m|0,i|0,r|0,q|0)|0;r=G;i=yf(j^m,i,21)|0;j=r^G;o=Lg(m|0,o|0,n^l|0,k|0)|0;m=G;k=yf(n^l,k,17)|0;f=G^m;m=yf(o,m,32)|0;g=G;r=Lg(k^o|0,f|0,q|0,r|0)|0;l=G;f=yf(k^o,f,13)|0;o=G^l;l=yf(r,l,32)|0;k=G;g=Lg(m|0,g|0,q^i|0,j|0)|0;m=G;j=yf(q^i,j,16)|0;i=G^m;k=Lg(j^g|0,i|0,l|0,k|0)|0;l=G;i=yf(j^g,i,21)|0;j=l^G;m=Lg(f^r|0,o|0,g|0,m|0)|0;g=G;o=yf(f^r,o,17)|0;r=G^g;g=yf(m,g,32)|0;f=G;s=s+8|0;if((s|0)==(b+c+(0-(c&7))|0)){b=b+c+(0-(c&7))|0;q=k^i;n=k^p;k=l^t;i=o^m;break}else{q=k^i;n=k^p;l=l^t;k=o^m;i=r}}}switch(c&7){case 7:{d=Wf(h[b+6>>0]|0|0,0,48)|0|d;e=G|e;u=6;break}case 6:{u=6;break}case 5:{u=7;break}case 4:{u=8;break}case 3:{u=9;break}case 2:{u=10;break}case 1:{u=11;break}default:{}}if((u|0)==6){v=Wf(h[b+5>>0]|0|0,0,40)|0;e=G|e;d=v|d;u=7}if((u|0)==7){e=h[b+4>>0]|0|e;u=8}if((u|0)==8){v=Wf(h[b+3>>0]|0|0,0,24)|0;d=v|d;e=G|e;u=9}if((u|0)==9){v=Wf(h[b+2>>0]|0|0,0,16)|0;d=v|d;e=G|e;u=10}if((u|0)==10){v=Wf(h[b+1>>0]|0|0,0,8)|0;d=v|d;e=G|e;u=11}if((u|0)==11)d=d|(h[b>>0]|0);s=d^q;c=e^j;o=Lg(n|0,k|0,i|0,r|0)|0;p=G;q=yf(i,r,13)|0;b=G^p;p=yf(o,p,32)|0;u=G;t=Lg(s|0,c|0,g|0,f|0)|0;v=G;r=yf(s,c,16)|0;c=G^v;u=Lg(r^t|0,c|0,p|0,u|0)|0;p=G;c=yf(r^t,c,21)|0;r=p^G;v=Lg(t|0,v|0,q^o|0,b|0)|0;t=G;b=yf(q^o,b,17)|0;o=G^t;t=yf(v,t,32)|0;q=G;p=Lg(b^v|0,o|0,u|0,p|0)|0;s=G;o=yf(b^v,o,13)|0;v=G^s;s=yf(p,s,32)|0;b=G;q=Lg(t|0,q|0,u^c|0,r|0)|0;t=G;r=yf(u^c,r,16)|0;c=G^t;b=Lg(r^q|0,c|0,s|0,b|0)|0;s=G;c=yf(r^q,c,21)|0;r=s^G;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0;m=Lg(m|0,e|0,-16,-1)|0;e=G;if(!(e>>>0>0|(e|0)==0&m>>>0>15)){k=(h*5|0)+(i&67108863)&67108863;j=(((h*5|0)+(i&67108863)|0)>>>26)+(g&67108863)|0;i=d&67108863;h=l&67108863;g=n&67108863;break}else{k=(h*5|0)+(i&67108863)&67108863;j=(((h*5|0)+(i&67108863)|0)>>>26)+(g&67108863)|0;i=d&67108863;h=l&67108863;g=n&67108863;c=c+16|0}}}f[a+20>>2]=k;f[a+24>>2]=j;f[a+28>>2]=i;f[a+32>>2]=h;f[a+36>>2]=g;return}function Ba(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;k=we(c)|0;j=G;w=Cf(b[c+4>>0]|0,b[c+5>>0]|0,b[c+6>>0]|0)|0;w=Wf(w|0,G|0,6)|0;x=G;i=Cf(b[c+7>>0]|0,b[c+8>>0]|0,b[c+9>>0]|0)|0;i=Wf(i|0,G|0,5)|0;h=G;u=Cf(b[c+10>>0]|0,b[c+11>>0]|0,b[c+12>>0]|0)|0;u=Wf(u|0,G|0,3)|0;v=G;g=Cf(b[c+13>>0]|0,b[c+14>>0]|0,b[c+15>>0]|0)|0;g=Wf(g|0,G|0,2)|0;e=G;s=we(c+16|0)|0;t=G;l=Cf(b[c+20>>0]|0,b[c+21>>0]|0,b[c+22>>0]|0)|0;l=Wf(l|0,G|0,7)|0;d=G;m=Cf(b[c+23>>0]|0,b[c+24>>0]|0,b[c+25>>0]|0)|0;m=Wf(m|0,G|0,5)|0;r=G;n=Cf(b[c+26>>0]|0,b[c+27>>0]|0,b[c+28>>0]|0)|0;n=Wf(n|0,G|0,4)|0;o=G;p=Cf(b[c+29>>0]|0,b[c+30>>0]|0,b[c+31>>0]|0)|0;p=Wf(p|0,G|0,2)|0;q=Lg(p&33554428|0,0,16777216,0)|0;y=$f(q|0,G|0,25)|0;y=Ig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>2]=h;f[a+24>>2]=g;f[a+28>>2]=e;f[a+32>>2]=d;f[a+36>>2]=c;return}function Ca(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0;j=f[b>>2]|0;v=f[b+4>>2]|0;h=f[b+8>>2]|0;t=f[b+12>>2]|0;e=f[b+16>>2]|0;r=f[b+20>>2]|0;c=f[b+24>>2]|0;l=f[b+28>>2]|0;m=f[b+32>>2]|0;x=f[b+36>>2]|0;j=Af(j|0,((j|0)<0)<<31>>31|0,121666,0)|0;i=G;v=Af(v|0,((v|0)<0)<<31>>31|0,121666,0)|0;w=G;h=Af(h|0,((h|0)<0)<<31>>31|0,121666,0)|0;g=G;t=Af(t|0,((t|0)<0)<<31>>31|0,121666,0)|0;u=G;e=Af(e|0,((e|0)<0)<<31>>31|0,121666,0)|0;d=G;r=Af(r|0,((r|0)<0)<<31>>31|0,121666,0)|0;s=G;c=Af(c|0,((c|0)<0)<<31>>31|0,121666,0)|0;b=G;l=Af(l|0,((l|0)<0)<<31>>31|0,121666,0)|0;q=G;m=Af(m|0,((m|0)<0)<<31>>31|0,121666,0)|0;n=G;x=Af(x|0,((x|0)<0)<<31>>31|0,121666,0)|0;o=G;p=Lg(x|0,o|0,16777216,0)|0;k=Nf(p|0,G|0,25)|0;k=Af(k|0,G|0,19,0)|0;i=Lg(k|0,G|0,j|0,i|0)|0;j=G;p=Ig(x|0,o|0,p&-33554432|0,0)|0;o=G;x=Lg(v|0,w|0,16777216,0)|0;k=Nf(x|0,G|0,25)|0;g=Lg(k|0,G|0,h|0,g|0)|0;h=G;x=Ig(v|0,w|0,x&-33554432|0,0)|0;w=G;v=Lg(t|0,u|0,16777216,0)|0;k=Nf(v|0,G|0,25)|0;d=Lg(k|0,G|0,e|0,d|0)|0;e=G;v=Ig(t|0,u|0,v&-33554432|0,0)|0;u=G;t=Lg(r|0,s|0,16777216,0)|0;k=Nf(t|0,G|0,25)|0;b=Lg(k|0,G|0,c|0,b|0)|0;c=G;t=Ig(r|0,s|0,t&-33554432|0,0)|0;s=G;r=Lg(l|0,q|0,16777216,0)|0;k=Nf(r|0,G|0,25)|0;n=Lg(k|0,G|0,m|0,n|0)|0;m=G;r=Ig(l|0,q|0,r&-33554432|0,0)|0;q=G;l=Lg(i|0,j|0,33554432,0)|0;k=$f(l|0,G|0,26)|0;k=Lg(x|0,w|0,k|0,G|0)|0;l=Ig(i|0,j|0,l&-67108864|0,0)|0;j=Lg(g|0,h|0,33554432,0)|0;i=$f(j|0,G|0,26)|0;i=Lg(v|0,u|0,i|0,G|0)|0;j=Ig(g|0,h|0,j&-67108864|0,0)|0;h=Lg(d|0,e|0,33554432,0)|0;g=$f(h|0,G|0,26)|0;g=Lg(t|0,s|0,g|0,G|0)|0;h=Ig(d|0,e|0,h&-67108864|0,0)|0;e=Lg(b|0,c|0,33554432,0)|0;d=$f(e|0,G|0,26)|0;d=Lg(r|0,q|0,d|0,G|0)|0;e=Ig(b|0,c|0,e&-67108864|0,0)|0;c=Lg(n|0,m|0,33554432,0)|0;b=$f(c|0,G|0,26)|0;b=Lg(p|0,o|0,b|0,G|0)|0;c=Ig(n|0,m|0,c&-67108864|0,0)|0;f[a>>2]=l;f[a+4>>2]=k;f[a+8>>2]=j;f[a+12>>2]=i;f[a+16>>2]=h;f[a+20>>2]=g;f[a+24>>2]=e;f[a+28>>2]=d;f[a+32>>2]=c;f[a+36>>2]=b;return}function Da(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;if(!b)if(!d){if(e|0){f[e>>2]=(a>>>0)%(c>>>0);f[e+4>>2]=0}d=0;e=(a>>>0)/(c>>>0)>>>0;return (G=d,e)|0}else{if(!e){d=0;e=0;return (G=d,e)|0}f[e>>2]=a|0;f[e+4>>2]=b&0;d=0;e=0;return (G=d,e)|0}do if(c){if(d|0){h=(Y(d|0)|0)-(Y(b|0)|0)|0;if(h>>>0<=31){n=h+1|0;i=a>>>((h+1|0)>>>0)&h-31>>31|b<<31-h;m=b>>>((h+1|0)>>>0)&h-31>>31;g=0;h=a<<31-h;break}if(!e){d=0;e=0;return (G=d,e)|0}f[e>>2]=a|0;f[e+4>>2]=b|b&0;d=0;e=0;return (G=d,e)|0}if(c-1&c|0){h=(Y(c|0)|0)+33-(Y(b|0)|0)|0;n=h;i=32-h-1>>31&b>>>((h-32|0)>>>0)|(b<<32-h|a>>>(h>>>0))&h-32>>31;m=h-32>>31&b>>>(h>>>0);g=a<<64-h&32-h>>31;h=(b<<64-h|a>>>((h-32|0)>>>0))&32-h>>31|a<<32-h&h-33>>31;break}if(e|0){f[e>>2]=c-1&a;f[e+4>>2]=0}if((c|0)==1){d=b|b&0;e=a|0|0;return (G=d,e)|0}else{e=hi(c|0)|0;d=b>>>(e>>>0)|0;e=b<<32-e|a>>>(e>>>0)|0;return (G=d,e)|0}}else{if(!d){if(e|0){f[e>>2]=(b>>>0)%(c>>>0);f[e+4>>2]=0}d=0;e=(b>>>0)/(c>>>0)>>>0;return (G=d,e)|0}if(!a){if(e|0){f[e>>2]=0;f[e+4>>2]=(b>>>0)%(d>>>0)}c=0;e=(b>>>0)/(d>>>0)>>>0;return (G=c,e)|0}if(!(d-1&d)){if(e|0){f[e>>2]=a|0;f[e+4>>2]=d-1&b|b&0}c=0;e=b>>>((hi(d|0)|0)>>>0);return (G=c,e)|0}h=(Y(d|0)|0)-(Y(b|0)|0)|0;if(h>>>0<=30){n=h+1|0;i=b<<31-h|a>>>((h+1|0)>>>0);m=b>>>((h+1|0)>>>0);g=0;h=a<<31-h;break}if(!e){d=0;e=0;return (G=d,e)|0}f[e>>2]=a|0;f[e+4>>2]=b|b&0;d=0;e=0;return (G=d,e)|0}while(0);if(!n){j=h;b=m;a=0;h=0}else{k=Lg(c|0|0,d|d&0|0,-1,-1)|0;l=G;j=h;b=m;a=n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0,d+z|0);Qg(a+8|0,c+A|0);Qg(a+12|0,b+B|0);Qg(a+16|0,f+C|0);Qg(a+20|0,p+G|0);Qg(a+24|0,g+v|0);Qg(a+28|0,h+w|0);Qg(a+32|0,i+x|0);Qg(a+36|0,j+t|0);Qg(a+40|0,q+H|0);Qg(a+44|0,k+D|0);Qg(a+48|0,n+E|0);Qg(a+52|0,m+F|0);Qg(a+56|0,l+u|0);Qg(a+60|0,r+y|0);return}function Ga(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0;m=t;j=t=t+63&-64;t=t+16|0;switch(e|0){case 2:{if(c>>>0<13)e=-31;else{e=a;g=34347;h=e+13|0;do{b[e>>0]=b[g>>0]|0;e=e+1|0;g=g+1|0}while((e|0)<(h|0));a=a+12|0;g=c+-12|0;h=6}break}case 1:{if(c>>>0<12)e=-31;else{e=a;g=34360;h=e+12|0;do{b[e>>0]=b[g>>0]|0;e=e+1|0;g=g+1|0}while((e|0)<(h|0));a=a+11|0;g=c+-11|0;h=6}break}default:e=-31}do if((h|0)==6){e=xb(d)|0;if(!e){td(j,19);e=Sc(j)|0;h=a+e|0;i=g-e|0;if(g>>>0<=e>>>0){e=-31;break}qb(a|0,j|0,e+1|0)|0;if(i>>>0>=4){b[h>>0]=36;b[h+1>>0]=109;b[h+2>>0]=61;b[h+3>>0]=0;td(j,f[d+44>>2]|0);g=Sc(j)|0;a=h+3+g|0;if((i+-3|0)>>>0<=g>>>0){e=-31;break}qb(h+3|0,j|0,g+1|0)|0;if((i+-3-g|0)>>>0>=4){b[a>>0]=44;b[a+1>>0]=116;b[a+2>>0]=61;b[a+3>>0]=0;td(j,f[d+40>>2]|0);e=Sc(j)|0;h=a+3+e|0;c=i+-3-g+-3-e|0;if((i+-3-g+-3|0)>>>0<=e>>>0){e=-31;break}qb(a+3|0,j|0,e+1|0)|0;if(c>>>0>=4){b[h>>0]=44;b[h+1>>0]=112;b[h+2>>0]=61;b[h+3>>0]=0;td(j,f[d+48>>2]|0);g=Sc(j)|0;if((c+-3|0)>>>0<=g>>>0){e=-31;break}qb(h+3|0,j|0,g+1|0)|0;e=h+3+g+1|0;if(((c+-3-g|0)>>>0>=2?(b[h+3+g>>0]=36,b[h+3+g+1>>0]=0,(Ta(e,c+-3-g+-1|0,f[d+16>>2]|0,f[d+20>>2]|0,3)|0)!=0):0)?(k=Sc(e)|0,l=c+-3-g+-1-k|0,l>>>0>=2):0){b[e+k>>0]=36;b[e+k+1>>0]=0;l=(Ta(e+k+1|0,l+-1|0,f[d>>2]|0,f[d+4>>2]|0,3)|0)==0;t=m;return (l?-31:0)|0}else e=-31}else e=-31}else e=-31}else e=-31}}while(0);t=m;return e|0}function Ha(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0;if(!d){d=1797285236;e=2036477234;f=857760878;g=1634760805}else{g=yh(d)|0;f=yh(d+4|0)|0;e=yh(d+8|0)|0;d=yh(d+12|0)|0}r=yh(c)|0;q=yh(c+4|0)|0;p=yh(c+8|0)|0;o=yh(c+12|0)|0;n=yh(c+16|0)|0;m=yh(c+20|0)|0;l=yh(c+24|0)|0;k=yh(c+28|0)|0;j=yh(b)|0;i=yh(b+4|0)|0;h=yh(b+8|0)|0;s=0;b=yh(b+12|0)|0;c=g;do{L=r+c|0;A=oi(j^L,16)|0;z=A+n|0;M=oi(z^r,12)|0;A=oi(M+L^A,8)|0;w=oi(A+z^M,7)|0;H=q+f|0;u=oi(i^H,16)|0;t=u+m|0;I=oi(t^q,12)|0;u=oi(I+H^u,8)|0;N=oi(u+t^I,7)|0;C=p+e|0;v=oi(h^C,16)|0;B=v+l|0;D=oi(B^p,12)|0;v=oi(D+C^v,8)|0;J=oi(v+B^D,7)|0;x=o+d|0;F=oi(b^x,16)|0;g=F+k|0;y=oi(g^o,12)|0;F=oi(y+x^F,8)|0;E=oi(F+g^y,7)|0;K=oi(F^N+(M+L),16)|0;G=oi(K+(v+B)^N,12)|0;c=G+(N+(M+L))|0;b=oi(c^K,8)|0;l=b+(K+(v+B))|0;q=oi(l^G,7)|0;G=oi(J+(I+H)^A,16)|0;B=oi(G+(F+g)^J,12)|0;f=B+(J+(I+H))|0;j=oi(f^G,8)|0;k=j+(G+(F+g))|0;p=oi(k^B,7)|0;B=oi(E+(D+C)^u,16)|0;g=oi(B+(A+z)^E,12)|0;e=g+(E+(D+C))|0;i=oi(e^B,8)|0;n=i+(B+(A+z))|0;o=oi(n^g,7)|0;v=oi(y+x+w^v,16)|0;g=oi(v+(u+t)^w,12)|0;d=g+(y+x+w)|0;h=oi(d^v,8)|0;m=h+(v+(u+t))|0;r=oi(m^g,7)|0;s=s+1|0}while((s|0)!=10);Qg(a,c);Qg(a+4|0,f);Qg(a+8|0,e);Qg(a+12|0,d);Qg(a+16|0,j);Qg(a+20|0,i);Qg(a+24|0,h);Qg(a+28|0,b);return 0}function Ia(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0;h=t;i=t=t+63&-64;t=t+2272|0;Lb(i+1536|0,c);Lb(i+1280|0,e);If(i,d);Jf(i+2112|0,d);wf(i+1792|0,i+2112|0);Xc(i+2112|0,i+1792|0,i);wf(i+1952|0,i+2112|0);If(i+160|0,i+1952|0);Xc(i+2112|0,i+1792|0,i+160|0);wf(i+1952|0,i+2112|0);If(i+320|0,i+1952|0);Xc(i+2112|0,i+1792|0,i+320|0);wf(i+1952|0,i+2112|0);If(i+480|0,i+1952|0);Xc(i+2112|0,i+1792|0,i+480|0);wf(i+1952|0,i+2112|0);If(i+640|0,i+1952|0);Xc(i+2112|0,i+1792|0,i+640|0);wf(i+1952|0,i+2112|0);If(i+800|0,i+1952|0);Xc(i+2112|0,i+1792|0,i+800|0);wf(i+1952|0,i+2112|0);If(i+960|0,i+1952|0);Xc(i+2112|0,i+1792|0,i+960|0);wf(i+1952|0,i+2112|0);If(i+1120|0,i+1952|0);di(a);c=255;while(1){if(b[i+1536+c>>0]|0){f=c;g=5;break}if(b[i+1280+c>>0]|0){f=c;g=5;break}if(!c)break;else c=c+-1|0}if((g|0)==5?(f|0)>-1:0)while(1){ud(i+2112|0,a);c=b[i+1536+f>>0]|0;if(c<<24>>24<=0){if(c<<24>>24<0){wf(i+1952|0,i+2112|0);Wc(i+2112|0,i+1952|0,i+((((c<<24>>24)/-2|0)<<24>>24)*160|0)|0)}}else{wf(i+1952|0,i+2112|0);Xc(i+2112|0,i+1952|0,i+(((c&255)>>>1&255)*160|0)|0)}c=b[i+1280+f>>0]|0;if(c<<24>>24<=0){if(c<<24>>24<0){wf(i+1952|0,i+2112|0);_c(i+2112|0,i+1952|0,160+((((c<<24>>24)/-2|0)<<24>>24)*120|0)|0)}}else{wf(i+1952|0,i+2112|0);$c(i+2112|0,i+1952|0,160+(((c&255)>>>1&255)*120|0)|0)}jg(a,i+2112|0);if((f|0)>0)f=f+-1|0;else break}t=h;return}function Ja(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;m=t;l=t=t+63&-64;t=t+704|0;a:do if(!((d|0)==0&(e|0)==0)){q=f[a+72>>2]|0;o=f[a+72+4>>2]|0;k=$f(q|0,o|0,3)|0;n=Wf(d|0,e|0,3)|0;p=G;i=$f(d|0,e|0,61)|0;j=G;o=Lg(q|0,o|0,n|0,p|0)|0;q=G;f[a+72>>2]=o;f[a+72+4>>2]=q;g=f[a+64>>2]|0;h=f[a+64+4>>2]|0;if(q>>>0<p>>>0|(q|0)==(p|0)&o>>>0<n>>>0){g=Lg(g|0,h|0,1,0)|0;h=G;f[a+64>>2]=g;f[a+64+4>>2]=h}j=Lg(g|0,h|0,i|0,j|0)|0;f[a+64>>2]=j;f[a+64+4>>2]=G;j=Ig(128,0,k&127|0,0)|0;g=G;if(g>>>0>e>>>0|(g|0)==(e|0)&j>>>0>d>>>0){g=0;h=0;while(1){p=b[c+g>>0]|0;q=Lg(g|0,h|0,k&127|0,0)|0;b[a+80+q>>0]=p;g=Lg(g|0,h|0,1,0)|0;h=G;if(!(h>>>0<e>>>0|(h|0)==(e|0)&g>>>0<d>>>0))break a}}if(!((j|0)==0&(g|0)==0)){h=0;i=0;do{p=b[c+h>>0]|0;q=Lg(h|0,i|0,k&127|0,0)|0;b[a+80+q>>0]=p;h=Lg(h|0,i|0,1,0)|0;i=G}while(i>>>0<g>>>0|(i|0)==(g|0)&h>>>0<j>>>0)}ma(a,a+80|0,l,l+640|0);g=Ig(d|0,e|0,j|0,g|0)|0;h=G;if(h>>>0>0|(h|0)==0&g>>>0>127){i=c+j|0;do{ma(a,i,l,l+640|0);i=i+128|0;g=Lg(g|0,h|0,-128,-1)|0;h=G}while(h>>>0>0|(h|0)==0&g>>>0>127);j=i}else j=c+j|0;g=g&127;if(!((g|0)==0&0==0)){h=0;i=0;do{b[a+80+h>>0]=b[j+h>>0]|0;h=Lg(h|0,i|0,1,0)|0;i=G}while(i>>>0<0|(i|0)==0&h>>>0<g>>>0)}ye(l,704)}while(0);t=m;return 0}function Ka(a,c,d,e,g,h,i,j){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;s=t;r=t=t+63&-64;t=t+16|0;f[r>>2]=0;Sh(j);if(e){l=0;n=0;m=0;k=0;a:while(1){while(1){p=b[d+k>>0]|0;if(!(j&4))o=Pc(p)|0;else o=Lc(p)|0;if((o|0)!=255)break;if(!g){o=18;break a}if(!(sh(g,p)|0)){o=19;break a}k=k+1|0;if(k>>>0>=e>>>0){o=17;break a}}n=o+(n<<6)|0;o=l+6|0;if(o>>>0>7){l=l+-2|0;if(m>>>0>=c>>>0){o=13;break}b[a+m>>0]=n>>>l;m=m+1|0}else l=o;k=k+1|0;if(k>>>0>=e>>>0){o=16;break}}if((o|0)==13){f[r>>2]=k;f[9002]=34;k=-1}else if((o|0)==16){f[r>>2]=k;k=0}else if((o|0)==17){f[r>>2]=k;k=0}else if((o|0)==18){f[r>>2]=k;k=0}else if((o|0)==19){f[r>>2]=k;k=0}if(l>>>0>4){k=-1;m=0}else o=21}else{k=0;m=0;n=0;l=0;o=21}do if((o|0)==21)if(!((1<<l)+-1&n)){if(!(k|j&2))k=vc(d,e,r,g,l>>>1)|0;if(!k)if((g|0)!=0?(q=f[r>>2]|0,q>>>0<e>>>0):0){k=q;while(1){if(!(sh(g,b[d+k>>0]|0)|0)){o=31;break}k=k+1|0;if(k>>>0>=e>>>0){o=30;break}}if((o|0)==30){f[r>>2]=k;k=0;break}else if((o|0)==31){f[r>>2]=k;k=0;break}}else k=0;else m=0}else{k=-1;m=0}while(0);l=f[r>>2]|0;if(!i){if((l|0)!=(e|0)){f[9002]=22;k=-1}}else f[i>>2]=d+l;if(h|0)f[h>>2]=m;t=s;return k|0}function La(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0;if(!d){d=1797285236;e=2036477234;f=857760878;o=1634760805}else{o=yh(d)|0;f=yh(d+4|0)|0;e=yh(d+8|0)|0;d=yh(d+12|0)|0}n=yh(c)|0;m=yh(c+4|0)|0;l=yh(c+8|0)|0;k=yh(c+12|0)|0;t=yh(c+16|0)|0;s=yh(c+20|0)|0;r=yh(c+24|0)|0;q=yh(c+28|0)|0;j=yh(b)|0;i=yh(b+4|0)|0;h=yh(b+8|0)|0;g=yh(b+12|0)|0;p=20;b=f;c=o;do{B=(oi(s+c|0,7)|0)^k;y=(oi(B+c|0,9)|0)^h;v=(oi(y+B|0,13)|0)^s;E=(oi(v+y|0,18)|0)^c;x=(oi(b+n|0,7)|0)^g;u=(oi(x+b|0,9)|0)^r;H=(oi(u+x|0,13)|0)^n;A=(oi(H+u|0,18)|0)^b;f=(oi(e+j|0,7)|0)^q;G=(oi(f+e|0,9)|0)^m;D=(oi(G+f|0,13)|0)^j;w=(oi(D+G|0,18)|0)^e;F=(oi(d+t|0,7)|0)^l;C=(oi(F+d|0,9)|0)^i;z=(oi(C+F|0,13)|0)^t;o=(oi(z+C|0,18)|0)^d;n=(oi(F+E|0,7)|0)^H;m=(oi(n+E|0,9)|0)^G;l=(oi(m+n|0,13)|0)^F;c=(oi(l+m|0,18)|0)^E;j=(oi(A+B|0,7)|0)^D;i=(oi(j+A|0,9)|0)^C;k=(oi(i+j|0,13)|0)^B;b=(oi(k+i|0,18)|0)^A;t=(oi(w+x|0,7)|0)^z;h=(oi(t+w|0,9)|0)^y;g=(oi(h+t|0,13)|0)^x;e=(oi(g+h|0,18)|0)^w;s=(oi(o+f|0,7)|0)^v;r=(oi(s+o|0,9)|0)^u;q=(oi(r+s|0,13)|0)^f;d=(oi(q+r|0,18)|0)^o;p=p+-2|0}while((p|0)!=0);Qg(a,c);Qg(a+4|0,b);Qg(a+8|0,e);Qg(a+12|0,d);Qg(a+16|0,j);Qg(a+20|0,i);Qg(a+24|0,h);Qg(a+28|0,g);return 0}function Ma(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0;k=t;j=t=t+63&-64;t=t+16|0;h=f[a+20>>2]|0;i=f[a+4>>2]|0;f[a+20>>2]=0;f[a+4>>2]=0;switch(d|0){case 2:{if(!(qd(c,34312,9)|0)){c=c+9|0;g=4}else c=-32;break}case 1:{if(!(qd(c,34322,8)|0)){c=c+8|0;g=4}else c=-32;break}default:c=-26}do if((g|0)==4)if((qd(c,34331,3)|0)==0?(e=Kc(c+3|0,j+4|0)|0,(e|0)!=0):0)if((f[j+4>>2]|0)==19)if(!(qd(e,34335,3)|0)){c=Kc(e+3|0,j+4|0)|0;if(!c){c=-32;break}f[a+44>>2]=f[j+4>>2];if(!(qd(c,34339,3)|0)){c=Kc(c+3|0,j+4|0)|0;if(!c){c=-32;break}f[a+40>>2]=f[j+4>>2];if(!(qd(c,34343,3)|0)){c=Kc(c+3|0,j+4|0)|0;if(!c){c=-32;break}g=f[j+4>>2]|0;f[a+48>>2]=g;f[a+52>>2]=g;g=(b[c>>0]|0)==36;c=g?c+1|0:c;if(g){f[j+4>>2]=h;g=f[a+16>>2]|0;if(Ka(g,h,c,Sc(c)|0,0,j+4|0,j,3)|0){c=-32;break}f[a+20>>2]=f[j+4>>2];c=f[j>>2]|0;h=(b[c>>0]|0)==36;c=h?c+1|0:c;if(h){f[j+4>>2]=i;h=f[a>>2]|0;if(Ka(h,i,c,Sc(c)|0,0,j+4|0,j,3)|0){c=-32;break}f[a+4>>2]=f[j+4>>2];d=f[j>>2]|0;c=xb(a)|0;if(!c)c=(b[d>>0]|0)==0?0:-32}else c=-32}else c=-32}else c=-32}else c=-32}else c=-32;else c=-26;else c=-32;while(0);t=k;return c|0}function Na(a,c,d,e,g,h,i,j,k,l){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;l=l|0;var m=0,n=0,o=0,p=0,q=0;q=t;p=t=t+63&-64;t=t+352|0;if(d|0){f[d>>2]=0;f[d+4>>2]=0}if(e|0)b[e>>0]=-1;do if(!(i>>>0<0|(i|0)==0&h>>>0<17)){n=Lg(h|0,i|0,-17,-1)|0;o=G;if(o>>>0>0|(o|0)==0&n>>>0>4294967278)Fj();Wg(p+16|0,64,0,a+32|0,a)|0;Lh(p+80|0,p+16|0)|0;ye(p+16|0,64);Kg(p+80|0,j,k,l)|0;j=Ig(0,0,k|0,l|0)|0;Kg(p+80|0,35456,j&15,0)|0;j=p+16|0;m=j+64|0;do{f[j>>2]=0;j=j+4|0}while((j|0)<(m|0));b[p+16>>0]=b[g>>0]|0;Sf(p+16|0,p+16|0,64,0,a+32|0,1,a)|0;j=b[p+16>>0]|0;b[p+16>>0]=b[g>>0]|0;Kg(p+80|0,p+16|0,64,0)|0;Kg(p+80|0,g+1|0,n,o)|0;m=Lg(h|0,i|0,15,0)|0;Kg(p+80|0,35456,m&15,0)|0;We(p+336|0,k,l);Kg(p+80|0,p+336|0,8,0)|0;l=Lg(h|0,i|0,47,0)|0;We(p+336|0,l,G);Kg(p+80|0,p+336|0,8,0)|0;Kh(p+80|0,p)|0;ye(p+80|0,256);if(hd(p,g+1+n|0,16)|0){ye(p,16);j=-1;break}Sf(c,g+1|0,n,o,a+32|0,2,a)|0;Of(a+36|0,p);of(a+32|0);if(!((j&2)==0?!(ge(a+32|0,4)|0):0))Gb(a);if(d|0){f[d>>2]=n;f[d+4>>2]=o}if(e|0){b[e>>0]=j;j=0}else j=0}else j=-1;while(0);t=q;return j|0}function Oa(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,f=0,g=0,i=0;e=t;f=t=t+63&-64;t=t+4032|0;If(f,d);Jf(f+3584|0,d);wf(f+2464|0,f+3584|0);If(f+160|0,f+2464|0);Xc(f+3424|0,d,f+160|0);wf(f+2304|0,f+3424|0);If(f+320|0,f+2304|0);Jf(f+3264|0,f+2464|0);wf(f+2144|0,f+3264|0);If(f+480|0,f+2144|0);Xc(f+3104|0,d,f+480|0);wf(f+1984|0,f+3104|0);If(f+640|0,f+1984|0);Jf(f+2944|0,f+2304|0);wf(f+1824|0,f+2944|0);If(f+800|0,f+1824|0);Xc(f+2784|0,d,f+800|0);wf(f+1664|0,f+2784|0);If(f+960|0,f+1664|0);Jf(f+2624|0,f+2144|0);wf(f+1504|0,f+2624|0);If(f+1120|0,f+1504|0);d=0;do{i=b[c+d>>0]|0;g=d<<1;b[f+1280+g>>0]=i&15;b[f+1280+(g|1)>>0]=(i&255)>>>4;d=d+1|0}while((d|0)!=32);d=0;c=0;do{i=f+1280+c|0;g=d+(h[i>>0]|0)|0;d=(g<<24)+134217728>>28;b[i>>0]=g-(d<<4);c=c+1|0}while((c|0)!=63);d=d+(h[f+1280+63>>0]|0)&255;b[f+1280+63>>0]=d;Gh(a);cc(f+1344|0,f,d);Xc(f+3864|0,a,f+1344|0);d=63;do{jg(f+3744|0,f+3864|0);ud(f+3864|0,f+3744|0);jg(f+3744|0,f+3864|0);ud(f+3864|0,f+3744|0);jg(f+3744|0,f+3864|0);ud(f+3864|0,f+3744|0);jg(f+3744|0,f+3864|0);ud(f+3864|0,f+3744|0);wf(a,f+3864|0);d=d+-1|0;cc(f+1344|0,f,b[f+1280+d>>0]|0);Xc(f+3864|0,a,f+1344|0)}while((d|0)!=0);wf(a,f+3864|0);t=e;return}function Pa(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;m=t;l=t=t+63&-64;t=t+288|0;a:do if(!((d|0)==0&(e|0)==0)){i=f[a+32>>2]|0;g=f[a+32+4>>2]|0;j=$f(i|0,g|0,3)|0;k=Wf(d|0,e|0,3)|0;k=Lg(i|0,g|0,k|0,G|0)|0;f[a+32>>2]=k;f[a+32+4>>2]=G;k=Ig(64,0,j&63|0,0)|0;g=G;if(g>>>0>e>>>0|(g|0)==(e|0)&k>>>0>d>>>0){g=0;h=0;while(1){k=b[c+g>>0]|0;l=Lg(g|0,h|0,j&63|0,0)|0;b[a+40+l>>0]=k;g=Lg(g|0,h|0,1,0)|0;h=G;if(!(h>>>0<e>>>0|(h|0)==(e|0)&g>>>0<d>>>0))break a}}if(!((k|0)==0&(g|0)==0)){h=0;i=0;do{o=b[c+h>>0]|0;n=Lg(h|0,i|0,j&63|0,0)|0;b[a+40+n>>0]=o;h=Lg(h|0,i|0,1,0)|0;i=G}while(i>>>0<g>>>0|(i|0)==(g|0)&h>>>0<k>>>0)}sa(a,a+40|0,l,l+256|0);g=Ig(d|0,e|0,k|0,g|0)|0;h=G;if(h>>>0>0|(h|0)==0&g>>>0>63){i=c+k|0;do{sa(a,i,l,l+256|0);i=i+64|0;g=Lg(g|0,h|0,-64,-1)|0;h=G}while(h>>>0>0|(h|0)==0&g>>>0>63);j=i}else j=c+k|0;g=g&63;if(!((g|0)==0&0==0)){h=0;i=0;do{b[a+40+h>>0]=b[j+h>>0]|0;h=Lg(h|0,i|0,1,0)|0;i=G}while(i>>>0<0|(i|0)==0&h>>>0<g>>>0)}ye(l,288)}while(0);t=m;return 0}function Qa(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;d=t;e=t=t+63&-64;t=t+400|0;if(!((a|0)==0|(b|0)==0)){Td(e,0,0,64)|0;Qg(e+384|0,f[b+48>>2]|0);Ug(e,e+384|0,4,0)|0;Qg(e+384|0,f[b+4>>2]|0);Ug(e,e+384|0,4,0)|0;Qg(e+384|0,f[b+44>>2]|0);Ug(e,e+384|0,4,0)|0;Qg(e+384|0,f[b+40>>2]|0);Ug(e,e+384|0,4,0)|0;Qg(e+384|0,19);Ug(e,e+384|0,4,0)|0;Qg(e+384|0,c);Ug(e,e+384|0,4,0)|0;Qg(e+384|0,f[b+12>>2]|0);Ug(e,e+384|0,4,0)|0;c=f[b+8>>2]|0;if(c|0?(Ug(e,c,f[b+12>>2]|0,0)|0,f[b+56>>2]&1|0):0){ye(f[b+8>>2]|0,f[b+12>>2]|0);f[b+12>>2]=0}Qg(e+384|0,f[b+20>>2]|0);Ug(e,e+384|0,4,0)|0;c=f[b+16>>2]|0;if(c|0)Ug(e,c,f[b+20>>2]|0,0)|0;Qg(e+384|0,f[b+28>>2]|0);Ug(e,e+384|0,4,0)|0;c=f[b+24>>2]|0;if(c|0?(Ug(e,c,f[b+28>>2]|0,0)|0,f[b+56>>2]&2|0):0){ye(f[b+24>>2]|0,f[b+28>>2]|0);f[b+28>>2]=0}Qg(e+384|0,f[b+36>>2]|0);Ug(e,e+384|0,4,0)|0;c=f[b+32>>2]|0;if(c|0)Ug(e,c,f[b+36>>2]|0,0)|0;Bf(e,a,64)|0}t=d;return}function Ra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);if(c>>>0<65){if((Td(k,0,0,c)|0)>=0){Ug(k,k+512|0,4,0)|0;Ug(k,d,e,0)|0;Bf(k,a,c)|0}}else a:do if((Td(k,0,0,64)|0)>=0?(Ug(k,k+512|0,4,0)|0,Ug(k,d,e,0)|0,(Bf(k,k+448|0,64)|0)>=0):0){g=a;h=k+448|0;i=g+32|0;do{b[g>>0]=b[h>>0]|0;g=g+1|0;h=h+1|0}while((g|0)<(i|0));g=k+384|0;h=k+448|0;i=g+64|0;do{f[g>>2]=f[h>>2];g=g+4|0;h=h+4|0}while((g|0)<(i|0));if((c+-32|0)>>>0>64){e=c+-32|0;d=a+32|0;do{if((Se(k+448|0,64,k+384|0,64,0,0,0)|0)<0)break a;g=d;h=k+448|0;i=g+32|0;do{b[g>>0]=b[h>>0]|0;g=g+1|0;h=h+1|0}while((g|0)<(i|0));e=e+-32|0;d=d+32|0;g=k+384|0;h=k+448|0;i=g+64|0;do{f[g>>2]=f[h>>2];g=g+4|0;h=h+4|0}while((g|0)<(i|0))}while(e>>>0>64)}else{e=c+-32|0;d=a+32|0}if((Se(k+448|0,e,k+384|0,64,0,0,0)|0)>=0)qb(d|0,k+448|0,e|0)|0}while(0);ye(k,384);t=j;return}function Ta(a,c,d,e,f){a=a|0;c=c|0;d=d|0;e=e|0;f=f|0;var g=0,i=0,j=0,k=0,l=0,m=0;Sh(f);i=(V((e>>>0)/3|0,-3)|0)+e|0;g=((e>>>0)/3|0)<<2;do if(i)if(!(f&2)){g=g+4|0;break}else{g=(g|2)+(i>>>1)|0;break}while(0);if(g>>>0>=c>>>0)Fj();if(!(f&4))if(e|0){k=0;l=0;i=0;f=0;do{j=k;k=k+1|0;l=l<<8|(h[d+j>>0]|0);f=f+8|0;if(f>>>0>5)while(1){f=f+-6|0;m=(af(l>>>f&63)|0)&255;j=i+1|0;b[a+i>>0]=m;if(f>>>0>5)i=j;else{i=j;break}}}while((k|0)!=(e|0));if(f){m=(af(l<<6-f&63)|0)&255;b[a+i>>0]=m;i=i+1|0}}else i=0;else if(e|0){k=0;f=0;l=0;i=0;do{m=l;l=l+1|0;k=k<<8|(h[d+m>>0]|0);f=f+8|0;if(f>>>0>5)while(1){f=f+-6|0;m=(Ze(k>>>f&63)|0)&255;j=i+1|0;b[a+i>>0]=m;if(f>>>0>5)i=j;else{i=j;break}}}while((l|0)!=(e|0));if(f){m=(Ze(k<<6-f&63)|0)&255;b[a+i>>0]=m;i=i+1|0}}else i=0;if(g>>>0<i>>>0)ca(35289,35308,230,35324);if(g>>>0>i>>>0)ec(a+i|0,61,g-i|0)|0;else g=i;m=g+1|0;ec(a+g|0,0,(m>>>0<c>>>0?c:m)-g|0)|0;return a|0}function Ua(a,c,d,e,g,i,j,k){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;i=i|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0;n=t;o=t=t+63&-64;t=t+112|0;if(!((d|0)==0&(e|0)==0)){m=o;l=m+32|0;do{b[m>>0]=b[k>>0]|0;m=m+1|0;k=k+1|0}while((m|0)<(l|0));k=h[g+4>>0]|h[g+4+1>>0]<<8|h[g+4+2>>0]<<16|h[g+4+3>>0]<<24;f[o+96>>2]=h[g>>0]|h[g+1>>0]<<8|h[g+2>>0]<<16|h[g+3>>0]<<24;f[o+96+4>>2]=k;k=8;while(1){b[o+96+k>>0]=i;i=$f(i|0,j|0,8)|0;k=k+1|0;if((k|0)==16)break;else j=G}if(e>>>0>0|(e|0)==0&d>>>0>63){k=a;i=d;while(1){vh(o+32|0,o+96|0,o,0)|0;a=0;do{b[k+a>>0]=b[o+32+a>>0]^b[c+a>>0];a=a+1|0}while((a|0)!=64);a=1;j=8;while(1){d=o+96+j|0;a=a+(h[d>>0]|0)|0;b[d>>0]=a;j=j+1|0;if((j|0)==16)break;else a=a>>>8}j=Lg(i|0,e|0,-64,-1)|0;e=G;a=k+64|0;c=c+64|0;if(e>>>0>0|(e|0)==0&j>>>0>63){k=a;i=j}else break}}else j=d;if(!((j|0)==0&(e|0)==0)?(vh(o+32|0,o+96|0,o,0)|0,j|0):0){e=0;do{b[a+e>>0]=b[o+32+e>>0]^b[c+e>>0];e=e+1|0}while((e|0)!=(j|0))}ye(o+32|0,64);ye(o,32)}t=n;return 0}function Va(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;a:do if(a|0){do if((f[a+36>>2]|0)==2){d=f[c>>2]|0;if((d|0)==0?(h[c+8>>0]|0)<=1:0){e=6;break}m=0;l=f[a+4>>2]|0}else e=6;while(0);if((e|0)==6){l=f[a+4>>2]|0;tb(a,c,l);m=1;d=f[c>>2]|0}g=b[c+8>>0]|0;d=(d|0)==0&g<<24>>24==0?2:0;e=f[a+24>>2]|0;j=V(e,f[c+4>>2]|0)|0;k=f[a+20>>2]|0;g=j+d+(V(k,g&255)|0)|0;if(d>>>0<k>>>0){k=g;g=(((g>>>0)%(e>>>0)|0|0)==0?e+-1|0:-1)+g|0;while(1){j=((k>>>0)%(e>>>0)|0|0)==1?k+-1|0:g;if(m)e=l+(d<<3)|0;else e=(f[(f[a>>2]|0)+4>>2]|0)+(j<<10)|0;i=e;o=f[i>>2]|0;i=pf(f[i+4>>2]|0,0,f[a+28>>2]|0,0)|0;n=f[c>>2]|0;g=b[c+8>>0]|0;e=f[c+4>>2]|0;i=(n|0)==0&g<<24>>24==0?e:i;f[c+12>>2]=d;g=Sb(a,n,g,d,o,((i|0)==(e|0)?(((n|0)==0&g<<24>>24==0?0:G)|0)==0:0)&1)|0;e=f[(f[a>>2]|0)+4>>2]|0;g=e+((V(f[a+24>>2]|0,i)|0)<<10)+(g<<10)|0;i=e+(k<<10)|0;if(!n)ra(e+(j<<10)|0,g,i);else qa(e+(j<<10)|0,g,i);d=d+1|0;if(d>>>0>=(f[a+20>>2]|0)>>>0)break a;k=k+1|0;g=j+1|0;e=f[a+24>>2]|0}}}while(0);return}function Wa(a,c,d,e,g,i){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;i=i|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;p=t;q=t=t+63&-64;t=t+112|0;if(!((d|0)==0&(e|0)==0)){k=q;j=k+32|0;do{b[k>>0]=b[i>>0]|0;k=k+1|0;i=i+1|0}while((k|0)<(j|0));k=h[g+4>>0]|h[g+4+1>>0]<<8|h[g+4+2>>0]<<16|h[g+4+3>>0]<<24;f[q+96>>2]=h[g>>0]|h[g+1>>0]<<8|h[g+2>>0]<<16|h[g+3>>0]<<24;f[q+96+4>>2]=k;f[q+96+8>>2]=0;f[q+96+8+4>>2]=0;if(e>>>0>0|(e|0)==0&d>>>0>63){k=c;g=d;do{th(q+32|0,q+96|0,q,0)|0;i=0;do{b[a+i>>0]=b[q+32+i>>0]^b[k+i>>0];i=i+1|0}while((i|0)!=64);i=1;j=8;while(1){d=q+96+j|0;i=i+(h[d>>0]|0)|0;b[d>>0]=i;j=j+1|0;if((j|0)==16)break;else i=i>>>8}g=Lg(g|0,e|0,-64,-1)|0;e=G;a=a+64|0;k=k+64|0}while(e>>>0>0|(e|0)==0&g>>>0>63);if(!((g|0)==0&(e|0)==0)){m=a;n=g;o=k;l=10}}else{m=a;n=d;o=c;l=10}if((l|0)==10?(th(q+32|0,q+96|0,q,0)|0,n|0):0){i=0;do{b[m+i>>0]=b[q+32+i>>0]^b[o+i>>0];i=i+1|0}while((i|0)!=(n|0))}ye(q+32|0,64);ye(q,32)}t=p;return 0}function Xa(a,c,d,e,g,i){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;i=i|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;p=t;q=t=t+63&-64;t=t+112|0;if(!((d|0)==0&(e|0)==0)){k=q;j=k+32|0;do{b[k>>0]=b[i>>0]|0;k=k+1|0;i=i+1|0}while((k|0)<(j|0));k=h[g+4>>0]|h[g+4+1>>0]<<8|h[g+4+2>>0]<<16|h[g+4+3>>0]<<24;f[q+96>>2]=h[g>>0]|h[g+1>>0]<<8|h[g+2>>0]<<16|h[g+3>>0]<<24;f[q+96+4>>2]=k;f[q+96+8>>2]=0;f[q+96+8+4>>2]=0;if(e>>>0>0|(e|0)==0&d>>>0>63){k=c;g=d;do{uh(q+32|0,q+96|0,q,0)|0;i=0;do{b[a+i>>0]=b[q+32+i>>0]^b[k+i>>0];i=i+1|0}while((i|0)!=64);i=1;j=8;while(1){d=q+96+j|0;i=i+(h[d>>0]|0)|0;b[d>>0]=i;j=j+1|0;if((j|0)==16)break;else i=i>>>8}g=Lg(g|0,e|0,-64,-1)|0;e=G;a=a+64|0;k=k+64|0}while(e>>>0>0|(e|0)==0&g>>>0>63);if(!((g|0)==0&(e|0)==0)){m=a;n=g;o=k;l=10}}else{m=a;n=d;o=c;l=10}if((l|0)==10?(uh(q+32|0,q+96|0,q,0)|0,n|0):0){i=0;do{b[m+i>>0]=b[q+32+i>>0]^b[o+i>>0];i=i+1|0}while((i|0)!=(n|0))}ye(q+32|0,64);ye(q,32)}t=p;return 0}function Ya(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,f=0,g=0;g=t;f=t=t+63&-64;t=t+336|0;if(!(Jc(d)|0)){e=0;do{b[a+e>>0]=b[c+e>>0]|0;e=e+1|0}while((e|0)!=32);b[a>>0]=b[a>>0]&-8;b[a+31>>0]=b[a+31>>0]&63|64;Ba(f+288|0,d);Bg(f+240|0);ph(f+192|0);Rc(f+144|0,f+288|0);Bg(f+96|0);e=0;c=254;while(1){d=e;e=(h[a+(c>>>3)>>0]|0)>>>(c&7)&1;d=e^d;ib(f+240|0,f+144|0,d);ib(f+192|0,f+96|0,d);Vb(f+48|0,f+144|0,f+96|0);Vb(f,f+240|0,f+192|0);Wb(f+240|0,f+240|0,f+192|0);Wb(f+192|0,f+144|0,f+96|0);pa(f+96|0,f+48|0,f+240|0);pa(f+192|0,f+192|0,f);ua(f+48|0,f);ua(f,f+240|0);Wb(f+144|0,f+96|0,f+192|0);Vb(f+192|0,f+96|0,f+192|0);pa(f+240|0,f,f+48|0);Vb(f,f,f+48|0);ua(f+192|0,f+192|0);Ca(f+96|0,f);ua(f+144|0,f+144|0);Wb(f+48|0,f+48|0,f+96|0);pa(f+96|0,f+288|0,f+192|0);pa(f+192|0,f,f+48|0);if(!c)break;else c=c+-1|0}ib(f+240|0,f+144|0,e);ib(f+192|0,f+96|0,e);Za(f+192|0,f+192|0);pa(f+240|0,f+240|0,f+192|0);rb(a,f+240|0);e=0}else e=-1;t=g;return e|0}function Za(a,b){a=a|0;b=b|0;var c=0,d=0;c=t;d=t=t+63&-64;t=t+192|0;ua(d+144|0,b);ua(d+96|0,d+144|0);ua(d+96|0,d+96|0);pa(d+96|0,b,d+96|0);pa(d+144|0,d+144|0,d+96|0);ua(d+48|0,d+144|0);pa(d+96|0,d+96|0,d+48|0);ua(d+48|0,d+96|0);b=1;do{ua(d+48|0,d+48|0);b=b+1|0}while((b|0)!=5);pa(d+96|0,d+48|0,d+96|0);ua(d+48|0,d+96|0);b=1;do{ua(d+48|0,d+48|0);b=b+1|0}while((b|0)!=10);pa(d+48|0,d+48|0,d+96|0);ua(d,d+48|0);b=1;do{ua(d,d);b=b+1|0}while((b|0)!=20);pa(d+48|0,d,d+48|0);ua(d+48|0,d+48|0);b=1;do{ua(d+48|0,d+48|0);b=b+1|0}while((b|0)!=10);pa(d+96|0,d+48|0,d+96|0);ua(d+48|0,d+96|0);b=1;do{ua(d+48|0,d+48|0);b=b+1|0}while((b|0)!=50);pa(d+48|0,d+48|0,d+96|0);ua(d,d+48|0);b=1;do{ua(d,d);b=b+1|0}while((b|0)!=100);pa(d+48|0,d,d+48|0);ua(d+48|0,d+48|0);b=1;do{ua(d+48|0,d+48|0);b=b+1|0}while((b|0)!=50);pa(d+96|0,d+48|0,d+96|0);ua(d+96|0,d+96|0);b=1;do{ua(d+96|0,d+96|0);b=b+1|0}while((b|0)!=5);pa(a,d+96|0,d+144|0);t=c;return}function _a(a,c,d,e,g,h,i,j,k,l){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;l=l|0;var m=0,n=0,o=0;n=t;o=t=t+63&-64;t=t+336|0;if(d|0){f[d>>2]=0;f[d+4>>2]=0}if(h>>>0>0|(h|0)==0&g>>>0>4294967278)Fj();Wg(o,64,0,a+32|0,a)|0;Lh(o+64|0,o)|0;ye(o,64);Kg(o+64|0,i,j,k)|0;i=Ig(0,0,j|0,k|0)|0;Kg(o+64|0,35456,i&15,0)|0;i=o;m=i+64|0;do{f[i>>2]=0;i=i+4|0}while((i|0)<(m|0));b[o>>0]=l;Sf(o,o,64,0,a+32|0,1,a)|0;Kg(o+64|0,o,64,0)|0;b[c>>0]=b[o>>0]|0;Sf(c+1|0,e,g,h,a+32|0,2,a)|0;Kg(o+64|0,c+1|0,g,h)|0;Kg(o+64|0,35456,g&15,0)|0;We(o+320|0,j,k);Kg(o+64|0,o+320|0,8,0)|0;k=Lg(g|0,h|0,64,0)|0;We(o+320|0,k,G);Kg(o+64|0,o+320|0,8,0)|0;Kh(o+64|0,c+1+g|0)|0;ye(o+64|0,256);Of(a+36|0,c+1+g|0);of(a+32|0);if(!((l&2)==0?!(ge(a+32|0,4)|0):0))Gb(a);if(d|0){o=Lg(g|0,h|0,17,0)|0;f[d>>2]=o;f[d+4>>2]=G}t=n;return 0}function $a(a,b){a=a|0;b=b|0;var c=0,d=0;c=t;d=t=t+63&-64;t=t+192|0;ua(d+144|0,b);pa(d+96|0,d+144|0,b);ua(d+144|0,d+96|0);ua(d+48|0,d+144|0);ua(d+48|0,d+48|0);pa(d+48|0,d+48|0,d+144|0);pa(d+96|0,d+48|0,b);ua(d+48|0,d+96|0);b=1;do{ua(d+48|0,d+48|0);b=b+1|0}while((b|0)!=5);pa(d+96|0,d+48|0,d+96|0);ua(d+48|0,d+96|0);b=1;do{ua(d+48|0,d+48|0);b=b+1|0}while((b|0)!=10);pa(d+48|0,d+48|0,d+96|0);ua(d,d+48|0);b=1;do{ua(d,d);b=b+1|0}while((b|0)!=20);pa(d+48|0,d,d+48|0);ua(d+48|0,d+48|0);b=1;do{ua(d+48|0,d+48|0);b=b+1|0}while((b|0)!=10);pa(d+96|0,d+48|0,d+96|0);ua(d+48|0,d+96|0);b=1;do{ua(d+48|0,d+48|0);b=b+1|0}while((b|0)!=50);pa(d+48|0,d+48|0,d+96|0);ua(d,d+48|0);b=1;do{ua(d,d);b=b+1|0}while((b|0)!=100);pa(d+48|0,d,d+48|0);ua(d+48|0,d+48|0);b=1;do{ua(d+48|0,d+48|0);b=b+1|0}while((b|0)!=50);pa(d+96|0,d+48|0,d+96|0);ua(d+96|0,d+96|0);b=1;do{ua(d+96|0,d+96|0);b=b+1|0}while((b|0)!=4);pa(a,d+96|0,d+144|0);t=c;return}function ab(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;e=f[a+56>>2]|0;d=f[a+56+4>>2]|0;if(!((e|0)==0&(d|0)==0)){b[a+64+e>>0]=1;d=Lg(e|0,d|0,1,0)|0;g=G;if(g>>>0<0|(g|0)==0&d>>>0<16)ec(a+64+d|0,0,14-e+1|0)|0;b[a+80>>0]=1;Aa(a,a+64|0,16,0)}e=f[a+24>>2]|0;g=(f[a+28>>2]|0)+(e>>>26)|0;i=(g>>>26)+(f[a+32>>2]|0)|0;j=(i>>>26)+(f[a+36>>2]|0)|0;n=((j>>>26)*5|0)+(f[a+20>>2]|0)|0;l=(((n&67108863)+5|0)>>>26)+((n>>>26)+(e&67108863))|0;k=(j|-67108864)+(((((l>>>26)+(g&67108863)|0)>>>26)+(i&67108863)|0)>>>26)|0;m=(k>>>31)+-1&67108863;i=k>>31&(i&67108863)|m&(((l>>>26)+(g&67108863)|0)>>>26)+(i&67108863);h=Lg(k>>31&(n&67108863)|m&(n&67108863)+5|(k>>31&(n>>>26)+(e&67108863)|m&l)<<26|0,0,f[a+40>>2]|0,0)|0;d=G;e=Lg((k>>31&(n>>>26)+(e&67108863)|m&l)>>>6|(k>>31&(g&67108863)|m&(l>>>26)+(g&67108863))<<20|0,0,f[a+44>>2]|0,0)|0;d=Lg(e|0,G|0,d|0,0)|0;e=G;g=Lg((k>>31&(g&67108863)|m&(l>>>26)+(g&67108863))>>>12|i<<14|0,0,f[a+48>>2]|0,0)|0;e=Lg(g|0,G|0,e|0,0)|0;g=G;i=Lg(((k>>>31)+-1&k|k>>31&j)<<8|i>>>18|0,0,f[a+52>>2]|0,0)|0;g=Lg(i|0,G|0,g|0,0)|0;Qg(c,h);Qg(c+4|0,d);Qg(c+8|0,e);Qg(c+12|0,g);ye(a,88);return}function bb(a,b,c,d,e,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;var i=0,j=0,k=0,l=0;j=t;k=t=t+63&-64;t=t+352|0;Ha(k,g,h,0)|0;if(a>>>0>c>>>0?0<e>>>0|0==(e|0)&(a-c|0)>>>0<d>>>0:0)i=5;else if(c>>>0>a>>>0?0<e>>>0|0==(e|0)&(c-a|0)>>>0<d>>>0:0)i=5;if((i|0)==5){se(a|0,c|0,d|0)|0;c=a}f[k+32>>2]=0;f[k+32+4>>2]=0;f[k+32+8>>2]=0;f[k+32+12>>2]=0;f[k+32+16>>2]=0;f[k+32+20>>2]=0;f[k+32+24>>2]=0;f[k+32+28>>2]=0;h=e>>>0>0|(e|0)==0&d>>>0>32?32:d;i=e>>>0>0|(e|0)==0&d>>>0>32?0:e;if(!((h|0)==0&(i|0)==0)){l=~e>>>0>4294967295|(~e|0)==-1&~d>>>0>4294967263?~d:-33;qb(k+32+32|0,c|0,-2-l+1|0)|0}l=Lg(h|0,i|0,32,0)|0;wg(k+32|0,k+32|0,l,G,g+16|0,k)|0;Lh(k+96|0,k+32|0)|0;if(!((h|0)==0&(i|0)==0)){l=~e>>>0>4294967295|(~e|0)==-1&~d>>>0>4294967263?~d:-33;qb(a|0,k+32+32|0,-2-l+1|0)|0}ye(k+32|0,64);if(e>>>0>0|(e|0)==0&d>>>0>32){l=Ig(d|0,e|0,h|0,i|0)|0;Gf(a+h|0,c+h|0,l,G,g+16|0,1,0,k)|0}ye(k,32);Kg(k+96|0,a,d,e)|0;Kh(k+96|0,b)|0;ye(k+96|0,256);t=j;return 0}function cb(a,c){a=a|0;c=c|0;var d=0,e=0,f=0;e=t;f=t=t+63&-64;t=t+1760|0;If(f,c);Jf(f+1600|0,c);wf(f+1280|0,f+1600|0);Xc(f+1600|0,f+1280|0,f);wf(f+1440|0,f+1600|0);If(f+160|0,f+1440|0);Xc(f+1600|0,f+1280|0,f+160|0);wf(f+1440|0,f+1600|0);If(f+320|0,f+1440|0);Xc(f+1600|0,f+1280|0,f+320|0);wf(f+1440|0,f+1600|0);If(f+480|0,f+1440|0);Xc(f+1600|0,f+1280|0,f+480|0);wf(f+1440|0,f+1600|0);If(f+640|0,f+1440|0);Xc(f+1600|0,f+1280|0,f+640|0);wf(f+1440|0,f+1600|0);If(f+800|0,f+1440|0);Xc(f+1600|0,f+1280|0,f+800|0);wf(f+1440|0,f+1600|0);If(f+960|0,f+1440|0);Xc(f+1600|0,f+1280|0,f+960|0);wf(f+1440|0,f+1600|0);If(f+1120|0,f+1440|0);Gh(a);c=252;while(1){Jf(f+1600|0,a);d=b[31840+c>>0]|0;if(d<<24>>24<=0){if(d<<24>>24<0){wf(f+1440|0,f+1600|0);Wc(f+1600|0,f+1440|0,f+((((d<<24>>24)/-2|0)<<24>>24)*160|0)|0)}}else{wf(f+1440|0,f+1600|0);Xc(f+1600|0,f+1440|0,f+(((d&255)>>>1&255)*160|0)|0)}wf(a,f+1600|0);if(!c)break;else c=c+-1|0}t=e;return}function db(a,b,c,d,e,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;var i=0,j=0,k=0,l=0;j=t;k=t=t+63&-64;t=t+352|0;La(k,g,h,0)|0;if(a>>>0>c>>>0?0<e>>>0|0==(e|0)&(a-c|0)>>>0<d>>>0:0)i=5;else if(c>>>0>a>>>0?0<e>>>0|0==(e|0)&(c-a|0)>>>0<d>>>0:0)i=5;if((i|0)==5){se(a|0,c|0,d|0)|0;c=a}f[k+32>>2]=0;f[k+32+4>>2]=0;f[k+32+8>>2]=0;f[k+32+12>>2]=0;f[k+32+16>>2]=0;f[k+32+20>>2]=0;f[k+32+24>>2]=0;f[k+32+28>>2]=0;h=e>>>0>0|(e|0)==0&d>>>0>32?32:d;i=e>>>0>0|(e|0)==0&d>>>0>32?0:e;if(!((h|0)==0&(i|0)==0)){l=~e>>>0>4294967295|(~e|0)==-1&~d>>>0>4294967263?~d:-33;qb(k+32+32|0,c|0,-2-l+1|0)|0}l=Lg(h|0,i|0,32,0)|0;sg(k+32|0,k+32|0,l,G,g+16|0,k)|0;Lh(k+96|0,k+32|0)|0;if(!((h|0)==0&(i|0)==0)){l=~e>>>0>4294967295|(~e|0)==-1&~d>>>0>4294967263?~d:-33;qb(a|0,k+32+32|0,-2-l+1|0)|0}ye(k+32|0,64);if(e>>>0>0|(e|0)==0&d>>>0>32){l=Ig(d|0,e|0,h|0,i|0)|0;Ef(a+h|0,c+h|0,l,G,g+16|0,1,0,k)|0}ye(k,32);Kg(k+96|0,a,d,e)|0;Kh(k+96|0,b)|0;ye(k+96|0,256);t=j;return 0}function eb(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;d=t;e=t=t+63&-64;t=t+144|0;ua(e+96|0,b);ua(e+48|0,e+96|0);ua(e+48|0,e+48|0);pa(e+48|0,b,e+48|0);pa(e+96|0,e+96|0,e+48|0);ua(e+96|0,e+96|0);pa(e+96|0,e+48|0,e+96|0);ua(e+48|0,e+96|0);c=1;do{ua(e+48|0,e+48|0);c=c+1|0}while((c|0)!=5);pa(e+96|0,e+48|0,e+96|0);ua(e+48|0,e+96|0);c=1;do{ua(e+48|0,e+48|0);c=c+1|0}while((c|0)!=10);pa(e+48|0,e+48|0,e+96|0);ua(e,e+48|0);c=1;do{ua(e,e);c=c+1|0}while((c|0)!=20);pa(e+48|0,e,e+48|0);ua(e+48|0,e+48|0);c=1;do{ua(e+48|0,e+48|0);c=c+1|0}while((c|0)!=10);pa(e+96|0,e+48|0,e+96|0);ua(e+48|0,e+96|0);c=1;do{ua(e+48|0,e+48|0);c=c+1|0}while((c|0)!=50);pa(e+48|0,e+48|0,e+96|0);ua(e,e+48|0);c=1;do{ua(e,e);c=c+1|0}while((c|0)!=100);pa(e+48|0,e,e+48|0);ua(e+48|0,e+48|0);c=1;do{ua(e+48|0,e+48|0);c=c+1|0}while((c|0)!=50);pa(e+96|0,e+48|0,e+96|0);ua(e+96|0,e+96|0);ua(e+96|0,e+96|0);pa(a,e+96|0,b);t=d;return}function fb(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0;g=t;i=t=t+63&-64;t=t+960|0;e=a;d=e+32|0;do{b[e>>0]=b[c>>0]|0;e=e+1|0;c=c+1|0}while((e|0)<(d|0));e=h[a+31>>0]|0;b[a+31>>0]=e&127;Ba(i+384|0,a);ta(i+384|0,i+384|0);f[i+384>>2]=(f[i+384>>2]|0)+1;Za(i+384|0,i+384|0);pa(i+336|0,32352,i+384|0);Dc(i+336|0,i+336|0);ua(i+288|0,i+336|0);pa(i+240|0,i+336|0,i+288|0);Wb(i+480|0,i+240|0,i+336|0);pa(i+288|0,i+288|0,32352);Wb(i+480|0,i+288|0,i+480|0);$a(i+480|0,i+480|0);rb(a,i+480|0);d=b[a+1>>0]&1;Dc(i+432|0,i+336|0);Fb(i+336|0,i+432|0,d);ph(i+288|0);Fb(i+288|0,32352,d);Vb(i+336|0,i+336|0,i+288|0);Bg(i+192|0);Wb(i+144|0,i+336|0,i+192|0);Vb(i+48|0,i+336|0,i+192|0);Za(i+96|0,i+144|0);pa(i,i+48|0,i+96|0);rb(a,i);b[a+31>>0]=e&128|(h[a+31>>0]|0);if(!(Hb(i+800|0,a)|0)){Jf(i+640|0,i+800|0);jg(i+520|0,i+640|0);ud(i+640|0,i+520|0);jg(i+520|0,i+640|0);ud(i+640|0,i+520|0);wf(i+800|0,i+640|0);Pd(a,i+800|0);t=g;return}else ea()}function gb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0;i=t;h=t=t+63&-64;t=t+64|0;if(c<<24>>24?(c&255)<=64:0){if(!(fi(f[a+80>>2]|0,f[a+80+4>>2]|0)|0)){d=f[a+352>>2]|0;do if(d>>>0>128){Gd(a,128,0);ka(a,a+96|0);d=(f[a+352>>2]|0)+-128|0;f[a+352>>2]=d;if(d>>>0<129){qb(a+96|0,a+224|0,d|0)|0;e=a+96|0;g=f[a+352>>2]|0;break}else ca(34057,34089,304,34134)}else{e=a+96|0;g=d}while(0);Gd(a,g,0);Pg(a);d=f[a+352>>2]|0;ec(a+96+d|0,0,256-d|0)|0;ka(a,e);We(h,f[a>>2]|0,f[a+4>>2]|0);We(h+8|0,f[a+8>>2]|0,f[a+8+4>>2]|0);We(h+16|0,f[a+16>>2]|0,f[a+16+4>>2]|0);We(h+24|0,f[a+24>>2]|0,f[a+24+4>>2]|0);We(h+32|0,f[a+32>>2]|0,f[a+32+4>>2]|0);We(h+40|0,f[a+40>>2]|0,f[a+40+4>>2]|0);We(h+48|0,f[a+48>>2]|0,f[a+48+4>>2]|0);We(h+56|0,f[a+56>>2]|0,f[a+56+4>>2]|0);qb(b|0,h|0,c&255|0)|0;ye(a,64);ye(e,256);d=0}else d=-1;t=i;return d|0}Fj();return 0}function hb(a,b,c,d,e,g,h,i,j,k,l){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;l=l|0;var m=0,n=0,o=0;o=Af(j|0,0,i|0,0)|0;n=G;do if(n>>>0>0|(n|0)==0&o>>>0>1073741823){f[9002]=27;a=-1}else{if(h>>>0>0|(h|0)==0&g>>>0>4294967295){f[9002]=27;a=-1;break}o=Lg(g|0,h|0,-1,-1)|0;if(h>>>0<0|(h|0)==0&g>>>0<2|((o&g|0)!=0|(G&h|0)!=0)){f[9002]=22;a=-1;break}if((i|0)==0|(j|0)==0){f[9002]=22;a=-1;break}if(!(i>>>0>16777215?1:(33554431/(j>>>0)|0)>>>0<i>>>0)?!(0<h>>>0|(0==(h|0)?(33554431/(i>>>0)|0)>>>0<g>>>0:0)):0){n=V(i<<7,j)|0;o=V(i<<7,g)|0;if((n+o|0)>>>0<o>>>0){f[9002]=12;a=-1;break}m=n+o+(i<<8|64)|0;if(m>>>0<(i<<8|64)>>>0){f[9002]=12;a=-1;break}if((f[a+8>>2]|0)>>>0<m>>>0?(Mh(a),(Wd(a,m)|0)==0):0){a=-1;break}m=f[a+4>>2]|0;yc(b,c,d,e,m,n);a=0;do{ob(m+(V(i<<7,a)|0)|0,i,g,h,m+n|0,m+n+o|0);a=a+1|0}while((a|0)!=(j|0));yc(b,c,m,n,k,l);a=0;break}f[9002]=12;a=-1}while(0);return a|0}function ib(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0;x=f[a>>2]|0;v=f[a+4>>2]|0;t=f[a+8>>2]|0;r=f[a+12>>2]|0;p=f[a+16>>2]|0;n=f[a+20>>2]|0;l=f[a+24>>2]|0;j=f[a+28>>2]|0;h=f[a+32>>2]|0;e=f[a+36>>2]|0;w=f[b>>2]|0;u=f[b+4>>2]|0;s=f[b+8>>2]|0;q=f[b+12>>2]|0;o=f[b+16>>2]|0;m=f[b+20>>2]|0;k=f[b+24>>2]|0;i=f[b+28>>2]|0;g=f[b+32>>2]|0;d=f[b+36>>2]|0;f[a>>2]=(w^x)&0-c^x;f[a+4>>2]=(u^v)&0-c^v;f[a+8>>2]=(s^t)&0-c^t;f[a+12>>2]=(q^r)&0-c^r;f[a+16>>2]=(o^p)&0-c^p;f[a+20>>2]=(m^n)&0-c^n;f[a+24>>2]=(k^l)&0-c^l;f[a+28>>2]=(i^j)&0-c^j;f[a+32>>2]=(g^h)&0-c^h;f[a+36>>2]=(d^e)&0-c^e;f[b>>2]=(w^x)&0-c^w;f[b+4>>2]=(u^v)&0-c^u;f[b+8>>2]=(s^t)&0-c^s;f[b+12>>2]=(q^r)&0-c^q;f[b+16>>2]=(o^p)&0-c^o;f[b+20>>2]=(m^n)&0-c^m;f[b+24>>2]=(k^l)&0-c^k;f[b+28>>2]=(i^j)&0-c^i;f[b+32>>2]=(g^h)&0-c^g;f[b+36>>2]=(d^e)&0-c^d;return}function jb(a,c,d,e,g,i,j){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;i=i|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0;a:do if(e){l=0;m=0;k=0;p=0;b:while(1){while(1){n=h[d+k>>0]|0;o=(((n&223)+201&255)+65526^((n&223)+201&255)+65520)>>>8;if((o|((n^48)+65526|0)>>>8)&255|0)break;if(!((g|0)!=0&l<<24>>24==0)){n=0;break b}if(!(sh(g,n)|0)){q=17;break a}k=k+1|0;if(k>>>0<e>>>0)l=0;else{q=17;break a}}n=o&(n&223)+201|((n^48)+65526|0)>>>8&(n^48);if(m>>>0>=c>>>0){q=9;break}if(!(l<<24>>24))n=n<<4&255;else{b[a+m>>0]=n|p&255;m=m+1|0;n=p}l=~l;k=k+1|0;if(k>>>0<e>>>0)p=n;else{n=0;break}}if((q|0)==9){f[9002]=34;n=-1}if(!(l<<24>>24))if(!n){q=17;break}else{l=k;k=-1;m=0;break}else{f[9002]=22;l=k+-1|0;k=-1;m=0;break}}else{m=0;k=0;q=17}while(0);if((q|0)==17){l=k;k=0}if(!j){if((l|0)!=(e|0)){f[9002]=22;k=-1}}else f[j>>2]=d+l;if(i|0)f[i>>2]=m;return k|0}function kb(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var i=0,j=0,k=0,l=0,m=0,n=0,o=0;n=t;o=t=t+63&-64;t=t+112|0;if(!((c|0)==0&(d|0)==0)){j=o;i=j+32|0;do{b[j>>0]=b[g>>0]|0;j=j+1|0;g=g+1|0}while((j|0)<(i|0));j=h[e+4>>0]|h[e+4+1>>0]<<8|h[e+4+2>>0]<<16|h[e+4+3>>0]<<24;f[o+96>>2]=h[e>>0]|h[e+1>>0]<<8|h[e+2>>0]<<16|h[e+3>>0]<<24;f[o+96+4>>2]=j;f[o+96+8>>2]=0;f[o+96+8+4>>2]=0;if(d>>>0>0|(d|0)==0&c>>>0>63){do{th(a,o+96|0,o,0)|0;g=1;i=8;while(1){j=o+96+i|0;g=g+(h[j>>0]|0)|0;b[j>>0]=g;i=i+1|0;if((i|0)==16)break;else g=g>>>8}c=Lg(c|0,d|0,-64,-1)|0;d=G;a=a+64|0}while(d>>>0>0|(d|0)==0&c>>>0>63);if(!((c|0)==0&(d|0)==0)){l=a;m=c;k=8}}else{l=a;m=c;k=8}if((k|0)==8?(th(o+32|0,o+96|0,o,0)|0,m|0):0){g=0;do{b[l+g>>0]=b[o+32+g>>0]|0;g=g+1|0}while((g|0)!=(m|0))}ye(o+32|0,64);ye(o,32)}t=n;return 0}function lb(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var i=0,j=0,k=0,l=0,m=0,n=0,o=0;n=t;o=t=t+63&-64;t=t+112|0;if(!((c|0)==0&(d|0)==0)){j=o;i=j+32|0;do{b[j>>0]=b[g>>0]|0;j=j+1|0;g=g+1|0}while((j|0)<(i|0));j=h[e+4>>0]|h[e+4+1>>0]<<8|h[e+4+2>>0]<<16|h[e+4+3>>0]<<24;f[o+96>>2]=h[e>>0]|h[e+1>>0]<<8|h[e+2>>0]<<16|h[e+3>>0]<<24;f[o+96+4>>2]=j;f[o+96+8>>2]=0;f[o+96+8+4>>2]=0;if(d>>>0>0|(d|0)==0&c>>>0>63){do{uh(a,o+96|0,o,0)|0;g=1;i=8;while(1){j=o+96+i|0;g=g+(h[j>>0]|0)|0;b[j>>0]=g;i=i+1|0;if((i|0)==16)break;else g=g>>>8}c=Lg(c|0,d|0,-64,-1)|0;d=G;a=a+64|0}while(d>>>0>0|(d|0)==0&c>>>0>63);if(!((c|0)==0&(d|0)==0)){l=a;m=c;k=8}}else{l=a;m=c;k=8}if((k|0)==8?(uh(o+32|0,o+96|0,o,0)|0,m|0):0){g=0;do{b[l+g>>0]=b[o+32+g>>0]|0;g=g+1|0}while((g|0)!=(m|0))}ye(o+32|0,64);ye(o,32)}t=n;return 0}function mb(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var i=0,j=0,k=0,l=0,m=0,n=0,o=0;n=t;o=t=t+63&-64;t=t+112|0;if(!((c|0)==0&(d|0)==0)){j=o;i=j+32|0;do{b[j>>0]=b[g>>0]|0;j=j+1|0;g=g+1|0}while((j|0)<(i|0));j=h[e+4>>0]|h[e+4+1>>0]<<8|h[e+4+2>>0]<<16|h[e+4+3>>0]<<24;f[o+96>>2]=h[e>>0]|h[e+1>>0]<<8|h[e+2>>0]<<16|h[e+3>>0]<<24;f[o+96+4>>2]=j;f[o+96+8>>2]=0;f[o+96+8+4>>2]=0;if(d>>>0>0|(d|0)==0&c>>>0>63){do{vh(a,o+96|0,o,0)|0;g=1;i=8;while(1){j=o+96+i|0;g=g+(h[j>>0]|0)|0;b[j>>0]=g;i=i+1|0;if((i|0)==16)break;else g=g>>>8}c=Lg(c|0,d|0,-64,-1)|0;d=G;a=a+64|0}while(d>>>0>0|(d|0)==0&c>>>0>63);if(!((c|0)==0&(d|0)==0)){l=a;m=c;k=8}}else{l=a;m=c;k=8}if((k|0)==8?(vh(o+32|0,o+96|0,o,0)|0,m|0):0){g=0;do{b[l+g>>0]=b[o+32+g>>0]|0;g=g+1|0}while((g|0)!=(m|0))}ye(o+32|0,64);ye(o,32)}t=n;return 0}function nb(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0;j=t;i=t=t+63&-64;t=t+96|0;Ha(i,f,g,0)|0;hh(i+32|0,32,0,f+16|0,i)|0;if(!(vg(c,b,d,e,i+32|0)|0))if(!a)c=0;else{if(b>>>0>=a>>>0?0<e>>>0|0==(e|0)&(b-a|0)>>>0<d>>>0:0)h=8;else if(a>>>0>=b>>>0?0<e>>>0|0==(e|0)&(a-b|0)>>>0<d>>>0:0)h=8;if((h|0)==8){se(a|0,b|0,d|0)|0;b=a}c=e>>>0>0|(e|0)==0&d>>>0>32?32:d;g=e>>>0>0|(e|0)==0&d>>>0>32?0:e;if((c|0)==0&(g|0)==0)wg(i+32|0,i+32|0,32,0,f+16|0,i)|0;else{h=~e>>>0>4294967295|(~e|0)==-1&~d>>>0>4294967263?~d:-33;qb(i+32+32|0,b|0,-2-h+1|0)|0;k=Lg(c|0,g|0,32,0)|0;wg(i+32|0,i+32|0,k,G,f+16|0,i)|0;qb(a|0,i+32+32|0,-2-h+1|0)|0}if(e>>>0>0|(e|0)==0&d>>>0>32){k=Ig(d|0,e|0,c|0,g|0)|0;Gf(a+c|0,b+c|0,k,G,f+16|0,1,0,i)|0}ye(i,32);c=0}else{ye(i,32);c=-1}t=j;return c|0}function ob(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0;if(b<<5|0){h=0;do{k=yh(a+(h<<2)|0)|0;f[g+(h<<2)>>2]=k;h=h+1|0}while((h|0)!=(b<<5|0))}if(!((c|0)==0&(d|0)==0)){h=0;i=0;do{rf(e+((V(b<<5,h)|0)<<2)|0,g,b<<7);sd(g,g+(b<<5<<2)|0,g+(b<<6<<2)|0,b);rf(e+((V(h|1,b<<5)|0)<<2)|0,g+(b<<5<<2)|0,b<<7);sd(g+(b<<5<<2)|0,g,g+(b<<6<<2)|0,b);h=Lg(h|0,i|0,2,0)|0;i=G}while(i>>>0<d>>>0|(i|0)==(d|0)&h>>>0<c>>>0);h=Lg(c|0,d|0,-1,-1)|0;i=G;j=0;k=0;do{l=oh(g,b)|0;$e(g,e+((V(b<<5,l&h)|0)<<2)|0,b<<7);sd(g,g+(b<<5<<2)|0,g+(b<<6<<2)|0,b);l=oh(g+(b<<5<<2)|0,b)|0;$e(g+(b<<5<<2)|0,e+((V(b<<5,l&h)|0)<<2)|0,b<<7);sd(g+(b<<5<<2)|0,g,g+(b<<6<<2)|0,b);j=Lg(j|0,k|0,2,0)|0;k=G}while(k>>>0<d>>>0|(k|0)==(d|0)&j>>>0<c>>>0)}if(b<<5|0){h=0;do{Qg(a+(h<<2)|0,f[g+(h<<2)>>2]|0);h=h+1|0}while((h|0)!=(b<<5|0))}return}function pb(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0;j=t;i=t=t+63&-64;t=t+96|0;La(i,f,g,0)|0;ch(i+32|0,32,0,f+16|0,i)|0;if(!(vg(c,b,d,e,i+32|0)|0))if(!a)c=0;else{if(b>>>0>=a>>>0?0<e>>>0|0==(e|0)&(b-a|0)>>>0<d>>>0:0)h=8;else if(a>>>0>=b>>>0?0<e>>>0|0==(e|0)&(a-b|0)>>>0<d>>>0:0)h=8;if((h|0)==8){se(a|0,b|0,d|0)|0;b=a}c=e>>>0>0|(e|0)==0&d>>>0>32?32:d;g=e>>>0>0|(e|0)==0&d>>>0>32?0:e;if((c|0)==0&(g|0)==0)sg(i+32|0,i+32|0,32,0,f+16|0,i)|0;else{h=~e>>>0>4294967295|(~e|0)==-1&~d>>>0>4294967263?~d:-33;qb(i+32+32|0,b|0,-2-h+1|0)|0;k=Lg(c|0,g|0,32,0)|0;sg(i+32|0,i+32|0,k,G,f+16|0,i)|0;qb(a|0,i+32+32|0,-2-h+1|0)|0}if(e>>>0>0|(e|0)==0&d>>>0>32){k=Ig(d|0,e|0,c|0,g|0)|0;Ef(a+c|0,b+c|0,k,G,f+16|0,1,0,i)|0}ye(i,32);c=0}else{ye(i,32);c=-1}t=j;return c|0}function qb(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0;if((d|0)>=8192)return ga(a|0,c|0,d|0)|0;h=a|0;g=a+d|0;if((a&3)==(c&3)){while(a&3){if(!d)return h|0;b[a>>0]=b[c>>0]|0;a=a+1|0;c=c+1|0;d=d-1|0}d=g&-4|0;e=d-64|0;while((a|0)<=(e|0)){f[a>>2]=f[c>>2];f[a+4>>2]=f[c+4>>2];f[a+8>>2]=f[c+8>>2];f[a+12>>2]=f[c+12>>2];f[a+16>>2]=f[c+16>>2];f[a+20>>2]=f[c+20>>2];f[a+24>>2]=f[c+24>>2];f[a+28>>2]=f[c+28>>2];f[a+32>>2]=f[c+32>>2];f[a+36>>2]=f[c+36>>2];f[a+40>>2]=f[c+40>>2];f[a+44>>2]=f[c+44>>2];f[a+48>>2]=f[c+48>>2];f[a+52>>2]=f[c+52>>2];f[a+56>>2]=f[c+56>>2];f[a+60>>2]=f[c+60>>2];a=a+64|0;c=c+64|0}while((a|0)<(d|0)){f[a>>2]=f[c>>2];a=a+4|0;c=c+4|0}}else{d=g-4|0;while((a|0)<(d|0)){b[a>>0]=b[c>>0]|0;b[a+1>>0]=b[c+1>>0]|0;b[a+2>>0]=b[c+2>>0]|0;b[a+3>>0]=b[c+3>>0]|0;a=a+4|0;c=c+4|0}}while((a|0)<(g|0)){b[a>>0]=b[c>>0]|0;a=a+1|0;c=c+1|0}return h|0}function rb(a,c){a=a|0;c=c|0;var d=0,e=0,g=0;d=t;g=t=t+63&-64;t=t+48|0;vb(g,c);c=f[g>>2]|0;b[a>>0]=c;b[a+1>>0]=c>>>8;b[a+2>>0]=c>>>16;e=f[g+4>>2]|0;b[a+3>>0]=e<<2|c>>>24;b[a+4>>0]=e>>>6;b[a+5>>0]=e>>>14;c=f[g+8>>2]|0;b[a+6>>0]=c<<3|e>>>22;b[a+7>>0]=c>>>5;b[a+8>>0]=c>>>13;e=f[g+12>>2]|0;b[a+9>>0]=e<<5|c>>>21;b[a+10>>0]=e>>>3;b[a+11>>0]=e>>>11;c=f[g+16>>2]|0;b[a+12>>0]=c<<6|e>>>19;b[a+13>>0]=c>>>2;b[a+14>>0]=c>>>10;b[a+15>>0]=c>>>18;c=f[g+20>>2]|0;b[a+16>>0]=c;b[a+17>>0]=c>>>8;b[a+18>>0]=c>>>16;e=f[g+24>>2]|0;b[a+19>>0]=e<<1|c>>>24;b[a+20>>0]=e>>>7;b[a+21>>0]=e>>>15;c=f[g+28>>2]|0;b[a+22>>0]=c<<3|e>>>23;b[a+23>>0]=c>>>5;b[a+24>>0]=c>>>13;e=f[g+32>>2]|0;b[a+25>>0]=e<<4|c>>>21;b[a+26>>0]=e>>>4;b[a+27>>0]=e>>>12;c=f[g+36>>2]|0;b[a+28>>0]=c<<6|e>>>20;b[a+29>>0]=c>>>2;b[a+30>>0]=c>>>10;b[a+31>>0]=c>>>18;t=d;return}function sb(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0;l=t;k=t=t+63&-64;t=t+64|0;e=k+8|0;g=e+52|0;do{f[e>>2]=0;e=e+4|0}while((e|0)<(g|0));e=Sc(a)|0;f[k+36>>2]=e;f[k+20>>2]=e;f[k+4>>2]=e;g=na(e)|0;f[k+32>>2]=g;h=na(e)|0;f[k+16>>2]=h;i=na(e)|0;f[k>>2]=i;do if((g|0)==0|((h|0)==0|(i|0)==0)){wa(g);wa(h);wa(i);e=-22}else{j=na(e)|0;if(!j){wa(g);wa(h);wa(i);e=-22;break}e=Ma(k,a,d)|0;if(e|0){wa(f[k+32>>2]|0);wa(f[k+16>>2]|0);wa(f[k>>2]|0);wa(j);break}d=Db(f[k+40>>2]|0,f[k+44>>2]|0,f[k+52>>2]|0,b,c,f[k+16>>2]|0,f[k+20>>2]|0,j,f[k+4>>2]|0,0,0,d)|0;wa(f[k+32>>2]|0);wa(f[k+16>>2]|0);if((d|0)==0?(hd(j,f[k>>2]|0,f[k+4>>2]|0)|0)==0:0)e=0;else e=-35;wa(j);wa(f[k>>2]|0)}while(0);t=l;return e|0}function tb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,i=0,j=0;e=t;g=t=t+63&-64;t=t+4096|0;ui(g+3072|0);ui(g+2048|0);if((a|0)!=0&(b|0)!=0?(f[g+2048>>2]=f[b>>2],f[g+2048+4>>2]=0,f[g+2048+8>>2]=f[b+4>>2],f[g+2048+8+4>>2]=0,f[g+2048+16>>2]=h[b+8>>0],f[g+2048+16+4>>2]=0,f[g+2048+24>>2]=f[a+16>>2],f[g+2048+24+4>>2]=0,f[g+2048+32>>2]=f[a+8>>2],f[g+2048+32+4>>2]=0,f[g+2048+40>>2]=f[a+36>>2],f[g+2048+40+4>>2]=0,f[a+20>>2]|0):0){b=0;do{d=b&127;if(!d){i=Lg(f[g+2048+48>>2]|0,f[g+2048+48+4>>2]|0,1,0)|0;f[g+2048+48>>2]=i;f[g+2048+48+4>>2]=G;ui(g);ui(g+1024|0);qa(g+3072|0,g+2048|0,g);qa(g+3072|0,g,g+1024|0)}j=f[g+1024+(d<<3)+4>>2]|0;i=c+(b<<3)|0;f[i>>2]=f[g+1024+(d<<3)>>2];f[i+4>>2]=j;b=b+1|0}while(b>>>0<(f[a+20>>2]|0)>>>0)}t=e;return}function ub(a,c){a=a|0;c=c|0;var d=0,e=0,f=0,g=0,i=0;e=t;f=t=t+63&-64;t=t+464|0;d=0;do{i=b[c+d>>0]|0;g=d<<1;b[f+g>>0]=i&15;b[f+(g|1)>>0]=(i&255)>>>4;d=d+1|0}while((d|0)!=32);d=0;c=0;do{i=f+c|0;g=d+(h[i>>0]|0)|0;d=(g<<24)+134217728>>28;b[i>>0]=g-(d<<4);c=c+1|0}while((c|0)!=63);b[f+63>>0]=d+(h[f+63>>0]|0);Gh(a);d=1;do{Fh(f+64|0,d>>>1,b[f+d>>0]|0);$c(f+304|0,a,f+64|0);wf(a,f+304|0);d=d+2|0}while(d>>>0<64);Jf(f+304|0,a);jg(f+184|0,f+304|0);ud(f+304|0,f+184|0);jg(f+184|0,f+304|0);ud(f+304|0,f+184|0);jg(f+184|0,f+304|0);ud(f+304|0,f+184|0);wf(a,f+304|0);d=0;do{Fh(f+64|0,d>>>1,b[f+d>>0]|0);$c(f+304|0,a,f+64|0);wf(a,f+304|0);d=d+2|0}while(d>>>0<64);t=e;return}function vb(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;l=f[b>>2]|0;n=f[b+4>>2]|0;j=f[b+8>>2]|0;i=f[b+12>>2]|0;h=f[b+16>>2]|0;m=f[b+20>>2]|0;e=f[b+24>>2]|0;d=f[b+28>>2]|0;c=f[b+32>>2]|0;b=f[b+36>>2]|0;k=(((((((((((((((b*19|0)+16777216|0)>>>25)+l>>26)+n>>25)+j>>26)+i>>25)+h>>26)+m>>25)+e>>26)+d>>25)+c>>26)+b>>25)*19|0)+l>>26)+n|0;g=((((k>>25)+j>>26)+i>>25)+h>>26)+m|0;f[a>>2]=((((((((((((((b*19|0)+16777216|0)>>>25)+l>>26)+n>>25)+j>>26)+i>>25)+h>>26)+m>>25)+e>>26)+d>>25)+c>>26)+b>>25)*19|0)+l&67108863;f[a+4>>2]=k&33554431;f[a+8>>2]=(k>>25)+j&67108863;f[a+12>>2]=((k>>25)+j>>26)+i&33554431;f[a+16>>2]=(((k>>25)+j>>26)+i>>25)+h&67108863;f[a+20>>2]=g&33554431;f[a+24>>2]=(g>>25)+e&67108863;f[a+28>>2]=((g>>25)+e>>26)+d&33554431;f[a+32>>2]=(((g>>25)+e>>26)+d>>25)+c&67108863;f[a+36>>2]=((((g>>25)+e>>26)+d>>25)+c>>26)+b&33554431;return}function wb(a,b,c,d,e,f,g,h,i,j,k){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;var l=0;l=t;t=t+352|0;Wg(l+16|0,64,0,j,k)|0;Lh(l+80|0,l+16|0)|0;ye(l+16|0,64);Kg(l+80|0,g,h,i)|0;b=Ig(0,0,h|0,i|0)|0;Kg(l+80|0,35424,b&15,0)|0;Kg(l+80|0,c,d,e)|0;b=Ig(0,0,d|0,e|0)|0;Kg(l+80|0,35424,b&15,0)|0;We(l+336|0,h,i);Kg(l+80|0,l+336|0,8,0)|0;We(l+336|0,d,e);Kg(l+80|0,l+336|0,8,0)|0;Kh(l+80|0,l)|0;ye(l+80|0,256);b=ki(l,f)|0;ye(l,16);do if(a)if(!b){Sf(a,c,d,e,j,1,k)|0;b=0;break}else{ec(a|0,0,d|0)|0;b=-1;break}while(0);t=l;return b|0}function xb(a){a=a|0;var b=0,c=0;do if(a)if(f[a>>2]|0)if((f[a+4>>2]|0)>>>0>=16){if((f[a+8>>2]|0)==0?f[a+12>>2]|0:0){b=-18;break}b=f[a+20>>2]|0;if(!(f[a+16>>2]|0))return ((b|0)==0?-6:-19)|0;if(b>>>0>=8){if((f[a+24>>2]|0)==0?f[a+28>>2]|0:0){b=-20;break}if((f[a+32>>2]|0)==0?f[a+36>>2]|0:0){b=-21;break}b=f[a+44>>2]|0;if(b>>>0>=8)if(b>>>0<=2097152){c=f[a+48>>2]|0;if(b>>>0>=c<<3>>>0)if(f[a+40>>2]|0)if(c)if(c>>>0>16777215)b=-17;else{a=f[a+52>>2]|0;return ((a|0)==0?-28:a>>>0>16777215?-29:0)|0}else b=-16;else b=-12;else b=-14}else b=-15;else b=-14}else b=-6}else b=-2;else b=-1;else b=-25;while(0);return b|0}function yb(a,c,d,e,g,h){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;var i=0,j=0;i=t;j=t=t+63&-64;t=t+192|0;if((c+-1&255)>63)Fj();if((d|0)!=0&e<<24>>24!=0?(e&255)<=64:0){b[j+128>>0]=c;b[j+128+1>>0]=e;b[j+128+2>>0]=1;b[j+128+3>>0]=1;Dh(j+128+4|0);We(j+128+8|0,0,0);f[j+128+16>>2]=0;f[j+128+16+4>>2]=0;f[j+128+16+8>>2]=0;f[j+128+16+12>>2]=0;if(!g){f[j+128+32>>2]=0;f[j+128+32+4>>2]=0;f[j+128+32+8>>2]=0;f[j+128+32+12>>2]=0}else Kf(j+128|0,g);if(!h){f[j+128+48>>2]=0;f[j+128+48+4>>2]=0;f[j+128+48+8>>2]=0;f[j+128+48+12>>2]=0}else Hf(j+128|0,h);ie(a,j+128|0);ec(j+(e&255)|0,0,128-(e&255)|0)|0;qb(j|0,d|0,e&255|0)|0;Nb(a,j,128,0);ye(j,128);t=i;return}Fj()}function zb(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0;h=b>>>0>0|(b|0)==0&a>>>0>32768?a:32768;b=b>>>0>0|(b|0)==0&a>>>0>32768?b:0;f[g>>2]=8;a:do if(b>>>0<0|(b|0)==0&h>>>0<c>>>5>>>0){f[e>>2]=1;a=Nh(h|0,b|0,f[g>>2]<<2|0,0)|0;f[d>>2]=1;a=$f(a|0,G|0,1)|0;b=G;c=1;do{g=Wf(1,0,c|0)|0;e=G;c=c+1|0;if(e>>>0>b>>>0|(e|0)==(b|0)&g>>>0>a>>>0)break a;f[d>>2]=c}while(c>>>0<63)}else{f[d>>2]=1;a=1;while(1){i=Wf(1,0,a|0)|0;j=G;if(j>>>0>0|(j|0)==0&i>>>0>c>>>11>>>0)break;a=a+1|0;f[d>>2]=a;if(a>>>0>=63){a=63;break}}d=$f(h|0,b|0,2)|0;d=$f(d|0,G|0,a|0)|0;i=G;j=i>>>0<0|(i|0)==0&d>>>0<1073741823?d:1073741823;f[e>>2]=(j>>>0)/((f[g>>2]|0)>>>0)|0}while(0);return}function Ab(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0;i=t;t=t+192|0;if(d>>>0>128){Ne(a)|0;Ja(a,c,d,0)|0;df(a,i)|0;d=64;c=i}Ne(a)|0;e=i+64|0;g=e+128|0;do{f[e>>2]=909522486;e=e+4|0}while((e|0)<(g|0));h=(d|0)==0;if(!h?(b[i+64>>0]=b[c>>0]^54,(d|0)!=1):0){e=1;do{g=i+64+e|0;b[g>>0]=b[g>>0]^b[c+e>>0];e=e+1|0}while((e|0)!=(d|0))}Ja(a,i+64|0,128,0)|0;Ne(a+208|0)|0;e=i+64|0;g=e+128|0;do{f[e>>2]=1549556828;e=e+4|0}while((e|0)<(g|0));if(!h?(b[i+64>>0]=b[c>>0]^92,(d|0)!=1):0){e=1;do{h=i+64+e|0;b[h>>0]=b[h>>0]^b[c+e>>0];e=e+1|0}while((e|0)!=(d|0))}Ja(a+208|0,i+64|0,128,0)|0;ye(i+64|0,128);ye(i,64);t=i;return 0}function Bb(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0;i=t;t=t+96|0;if(d>>>0>64){de(a)|0;Pa(a,c,d,0)|0;gf(a,i)|0;d=32;c=i}de(a)|0;e=i+32|0;g=e+64|0;do{f[e>>2]=909522486;e=e+4|0}while((e|0)<(g|0));h=(d|0)==0;if(!h?(b[i+32>>0]=b[c>>0]^54,(d|0)!=1):0){e=1;do{g=i+32+e|0;b[g>>0]=b[g>>0]^b[c+e>>0];e=e+1|0}while((e|0)!=(d|0))}Pa(a,i+32|0,64,0)|0;de(a+104|0)|0;e=i+32|0;g=e+64|0;do{f[e>>2]=1549556828;e=e+4|0}while((e|0)<(g|0));if(!h?(b[i+32>>0]=b[c>>0]^92,(d|0)!=1):0){e=1;do{h=i+32+e|0;b[h>>0]=b[h>>0]^b[c+e>>0];e=e+1|0}while((e|0)!=(d|0))}Pa(a+104|0,i+32|0,64,0)|0;ye(i+32|0,64);ye(i,32);t=i;return 0}function Cb(a){a=a|0;var b=0,c=0,d=0,e=0;if(a>>>0>=4294967168){f[9002]=12;e=0;return e|0}e=a>>>0<11?16:a+11&-8;d=na(e+76|0)|0;if(!d){e=0;return e|0}do if(d&63){c=((d+63&-64)+-8-(d+-8)|0)>>>0>15?(d+63&-64)+-8|0:(d+63&-64)+56|0;a=c-(d+-8)|0;b=f[d+-4>>2]|0;if(!(b&3)){f[c>>2]=(f[d+-8>>2]|0)+a;f[c+4>>2]=(b&-8)-a;a=c;break}else{f[c+4>>2]=(b&-8)-a|f[c+4>>2]&1|2;f[c+((b&-8)-a)+4>>2]=f[c+((b&-8)-a)+4>>2]|1;f[d+-4>>2]=a|f[d+-4>>2]&1|2;f[c+4>>2]=f[c+4>>2]|1;xa(d+-8|0,a);a=c;break}}else{a=d+-8|0;c=d+-8|0}while(0);a=a+4|0;b=f[a>>2]|0;if(b&3|0?(b&-8)>>>0>(e+16|0)>>>0:0){d=c+e|0;f[a>>2]=e|b&1|2;f[d+4>>2]=(b&-8)-e|3;a=c+(b&-8)+4|0;f[a>>2]=f[a>>2]|1;xa(d,(b&-8)-e|0)}e=c+8|0;return e|0}function Db(a,b,c,d,e,g,h,i,j,k,l,m){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;l=l|0;m=m|0;var n=0,o=0,p=0;p=t;o=t=t+63&-64;t=t+64|0;n=na(j)|0;do if(!n)a=-22;else{f[o>>2]=n;f[o+4>>2]=j;f[o+8>>2]=d;f[o+12>>2]=e;f[o+16>>2]=g;f[o+20>>2]=h;f[o+24>>2]=0;f[o+24+4>>2]=0;f[o+24+8>>2]=0;f[o+24+12>>2]=0;f[o+40>>2]=a;f[o+44>>2]=b;f[o+48>>2]=c;f[o+52>>2]=c;f[o+56>>2]=0;a=Qb(o,m)|0;if(a|0){ye(n,j);wa(n);break}if(i|0)qb(i|0,n|0,j|0)|0;if((k|0)!=0&(l|0)!=0?Ga(k,l,o,m)|0:0){ye(n,j);ye(k,l);wa(n);a=-31;break}ye(n,j);wa(n);a=0}while(0);t=p;return a|0}function Eb(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;e=t;c=t=t+63&-64;t=t+288|0;Ba(a+40|0,b);Bg(a+80|0);ua(c+240|0,a+40|0);pa(c+192|0,c+240|0,16);Vb(c+240|0,c+240|0,a+80|0);Wb(c+192|0,c+192|0,a+80|0);ua(c+144|0,c+192|0);pa(c+144|0,c+144|0,c+192|0);ua(a,c+144|0);pa(a,a,c+192|0);pa(a,a,c+240|0);eb(a,a);pa(a,a,c+144|0);pa(a,a,c+240|0);ua(c+96|0,a);pa(c+96|0,c+96|0,c+192|0);Vb(c+48|0,c+96|0,c+240|0);if(!(Mf(c+48|0)|0)){Wb(c,c+96|0,c+240|0);if(!(Mf(c)|0))a=-1;else{pa(a,a,64);d=4}}else d=4;if((d|0)==4){d=Xf(a)|0;if((d|0)==((h[b+31>>0]|0)>>>7|0))Dc(a,a);pa(a+120|0,a,a+40|0);a=0}t=e;return a|0}function Fb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0;w=f[a>>2]|0;u=f[a+4>>2]|0;s=f[a+8>>2]|0;q=f[a+12>>2]|0;o=f[a+16>>2]|0;m=f[a+20>>2]|0;k=f[a+24>>2]|0;i=f[a+28>>2]|0;g=f[a+32>>2]|0;d=f[a+36>>2]|0;v=(f[b+4>>2]^u)&0-c;t=(f[b+8>>2]^s)&0-c;r=(f[b+12>>2]^q)&0-c;p=(f[b+16>>2]^o)&0-c;n=(f[b+20>>2]^m)&0-c;l=(f[b+24>>2]^k)&0-c;j=(f[b+28>>2]^i)&0-c;h=(f[b+32>>2]^g)&0-c;e=(f[b+36>>2]^d)&0-c;f[a>>2]=(f[b>>2]^w)&0-c^w;f[a+4>>2]=v^u;f[a+8>>2]=t^s;f[a+12>>2]=r^q;f[a+16>>2]=p^o;f[a+20>>2]=n^m;f[a+24>>2]=l^k;f[a+28>>2]=j^i;f[a+32>>2]=h^g;f[a+36>>2]=e^d;return}function Gb(a){a=a|0;var c=0,d=0,e=0,g=0,i=0;d=t;e=t=t+63&-64;t=t+48|0;c=e;g=a;i=c+32|0;do{b[c>>0]=b[g>>0]|0;c=c+1|0;g=g+1|0}while((c|0)<(i|0));c=h[a+36+4>>0]|h[a+36+4+1>>0]<<8|h[a+36+4+2>>0]<<16|h[a+36+4+3>>0]<<24;f[e+32>>2]=h[a+36>>0]|h[a+36+1>>0]<<8|h[a+36+2>>0]<<16|h[a+36+3>>0]<<24;f[e+32+4>>2]=c;pg(e,e,40,0,a+32|0,a)|0;c=a;g=e;i=c+32|0;do{b[c>>0]=b[g>>0]|0;c=c+1|0;g=g+1|0}while((c|0)<(i|0));g=f[e+32>>2]|0;i=f[e+32+4>>2]|0;b[a+36>>0]=g;b[a+36+1>>0]=g>>8;b[a+36+2>>0]=g>>16;b[a+36+3>>0]=g>>24;b[a+36+4>>0]=i;b[a+36+4+1>>0]=i>>8;b[a+36+4+2>>0]=i>>16;b[a+36+4+3>>0]=i>>24;yg(a);t=d;return}function Hb(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0;e=t;g=t=t+63&-64;t=t+384|0;Ba(a+40|0,b);Bg(a+80|0);ua(g+336|0,a+40|0);pa(g+288|0,g+336|0,16);Vb(g+336|0,g+336|0,a+80|0);Wb(g+288|0,g+288|0,a+80|0);ua(g+240|0,g+288|0);pa(g+240|0,g+240|0,g+288|0);ua(a,g+240|0);pa(a,a,g+288|0);pa(a,a,g+336|0);eb(a,a);pa(a,a,g+240|0);pa(a,a,g+336|0);ua(g+192|0,a);pa(g+192|0,g+192|0,g+288|0);Vb(g+144|0,g+192|0,g+336|0);Wb(g+96|0,g+192|0,g+336|0);c=Mf(g+144|0)|0;d=Mf(g+96|0)|0;pa(g,a,64);Fb(a,g,1-c|0);Dc(g+48|0,a);f=Xf(a)|0;Fb(a,g+48|0,(h[b+31>>0]|0)>>>7^f);pa(a+120|0,a,a+40|0);t=e;return (d|c)+-1|0}function Ib(a,b,c,d,e,g,h,i,j,k,l,m){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;l=l|0;m=m|0;k=t;t=t+336|0;Wg(k,64,0,l,m)|0;Lh(k+64|0,k)|0;ye(k,64);Kg(k+64|0,h,i,j)|0;h=Ig(0,0,i|0,j|0)|0;Kg(k+64|0,35424,h&15,0)|0;Sf(a,d,e,g,l,1,m)|0;Kg(k+64|0,a,e,g)|0;h=Ig(0,0,e|0,g|0)|0;Kg(k+64|0,35424,h&15,0)|0;We(k+320|0,i,j);Kg(k+64|0,k+320|0,8,0)|0;We(k+320|0,e,g);Kg(k+64|0,k+320|0,8,0)|0;Kh(k+64|0,b)|0;ye(k+64|0,256);if(c|0){f[c>>2]=16;f[c+4>>2]=0}t=k;return 0}function Jb(a,b,c,d,e,f,g,h,i,j,k){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;var l=0;l=t;t=t+352|0;hh(l+16|0,64,0,j,k)|0;Lh(l+80|0,l+16|0)|0;ye(l+16|0,64);Kg(l+80|0,g,h,i)|0;We(l+336|0,h,i);Kg(l+80|0,l+336|0,8,0)|0;Kg(l+80|0,c,d,e)|0;We(l+336|0,d,e);Kg(l+80|0,l+336|0,8,0)|0;Kh(l+80|0,l)|0;ye(l+80|0,256);b=ki(l,f)|0;ye(l,16);do if(a)if(!b){Gf(a,c,d,e,j,1,0,k)|0;b=0;break}else{ec(a|0,0,d|0)|0;b=-1;break}while(0);t=l;return b|0}function Kb(a){a=a|0;var c=0,d=0,e=0,g=0;a:do if(1){c=35349;d=65;do{if((b[c>>0]|0)==(a&255)<<24>>24){g=6;break a}c=c+1|0;d=d+-1|0;e=(d|0)!=0}while(e&(c&3|0)!=0);if(e)g=6;else c=0}else{c=35349;d=65;g=6}while(0);b:do if((g|0)==6)if((b[c>>0]|0)!=(a&255)<<24>>24){e=V(a&255,16843009)|0;c:do if(d>>>0>3){do{g=f[c>>2]^e;if((g&-2139062144^-2139062144)&g+-16843009|0)break c;c=c+4|0;d=d+-4|0}while(d>>>0>3);if(!d){c=0;break b}}while(0);while(1){if((b[c>>0]|0)==(a&255)<<24>>24)break b;d=d+-1|0;if(!d){c=0;break}else c=c+1|0}}while(0);return c|0}function Lb(a,c){a=a|0;c=c|0;var d=0,e=0,f=0,g=0,i=0;d=0;do{b[a+d>>0]=(h[c+(d>>>3)>>0]|0)>>>(d&7)&1;d=d+1|0}while((d|0)!=256);g=0;do{i=a+g|0;a:do if(b[i>>0]|0){f=1;do{d=f+g|0;if(d>>>0>=256)break a;c=b[a+d>>0]|0;b:do if(c<<24>>24){c=c<<24>>24<<f;e=b[i>>0]|0;if((c+e|0)<16){b[i>>0]=c+e;b[a+d>>0]=0;break}if((e-c|0)<-15)break a;b[i>>0]=e-c;while(1){c=a+d|0;if(!(b[c>>0]|0))break;b[c>>0]=0;d=d+1|0;if(d>>>0>=256)break b}b[c>>0]=1}while(0);f=f+1|0}while(f>>>0<7)}while(0);g=g+1|0}while((g|0)!=256);return}function Mb(a,b,c,d,e,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;var i=0,j=0;i=t;j=t=t+63&-64;t=t+560|0;Gg(j+192|0,h);He(j+128|0,g,32,0)|0;Ja(j+192|0,j+128+32|0,32,0)|0;Ja(j+192|0,c,d,e)|0;df(j+192|0,j+64|0)|0;se(a+32|0,g+32|0,32)|0;oa(j+64|0);ub(j+400|0,j+64|0);Pd(a,j+400|0);Gg(j+192|0,h);Ja(j+192|0,a,64,0)|0;Ja(j+192|0,c,d,e)|0;df(j+192|0,j)|0;oa(j);rh(j+128|0);la(a+32|0,j,j+128|0,j+64|0);ye(j+128|0,64);ye(j+64|0,64);if(b|0){f[b>>2]=64;f[b+4>>2]=0}t=i;return}function Nb(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0;a:do if(!((d|0)==0&(e|0)==0)){g=f[a+352>>2]|0;j=e;while(1){i=256-g|0;e=a+96+g|0;if(!(j>>>0>0|(j|0)==0&d>>>0>i>>>0))break;qb(e|0,c|0,i|0)|0;f[a+352>>2]=(f[a+352>>2]|0)+i;Gd(a,128,0);ka(a,a+96|0);e=a+96|0;g=a+224|0;h=e+128|0;do{b[e>>0]=b[g>>0]|0;e=e+1|0;g=g+1|0}while((e|0)<(h|0));g=(f[a+352>>2]|0)+-128|0;f[a+352>>2]=g;e=Ig(d|0,j|0,i|0,0)|0;j=G;if((e|0)==0&(j|0)==0)break a;else{c=c+i|0;d=e}}qb(e|0,c|0,d|0)|0;f[a+352>>2]=(f[a+352>>2]|0)+d}while(0);return}function Ob(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0;j=t;i=t=t+63&-64;t=t+64|0;h=Sc(a)|0;if(!(c>>>0>0|(c|0)==0&b>>>0>4294967295|h>>>0>127)){c=i;g=c+60|0;do{f[c>>2]=0;c=c+4|0}while((c|0)<(g|0));g=Zf(h)|0;if(!g)c=-1;else{f[i+16>>2]=g;f[i+8>>2]=g;f[i>>2]=g;f[i+20>>2]=h;f[i+12>>2]=h;f[i+4>>2]=h;f[i+24>>2]=0;f[i+24+4>>2]=0;f[i+24+8>>2]=0;f[i+24+12>>2]=0;if(!(Ma(i,a,e)|0))if((f[i+40>>2]|0)==(b|0))c=(f[i+44>>2]|0)!=(d>>>10|0)&1;else c=1;else{f[9002]=22;c=-1}wa(g)}}else{f[9002]=22;c=-1}t=j;return c|0}function Pb(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;var g=0,h=0;h=t;g=t=t+63&-64;t=t+592|0;if(((((ce(a+32|0)|0)!=0?(Zb(a)|0)==0:0)?(hf(e)|0)!=0:0)?(Zb(e)|0)==0:0)?(Eb(g+424|0,e)|0)==0:0){Gg(g+96|0,f);Ja(g+96|0,a,32,0)|0;Ja(g+96|0,e,32,0)|0;Ja(g+96|0,b,c,d)|0;df(g+96|0,g+32|0)|0;oa(g+32|0);Ia(g+304|0,g+32|0,g+424|0,a+32|0);Pd(g,g+304|0);f=ji(g,a)|0;a=((g|0)==(a|0)?-1:f)|(hd(a,g,32)|0)}else a=-1;t=h;return a|0}function Qb(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0;e=t;d=t=t+63&-64;t=t+48|0;c=xb(a)|0;if(!c)if((b+-1|0)>>>0<=1){g=f[a+44>>2]|0;c=f[a+48>>2]|0;g=((g>>>0<c<<3>>>0?c<<3:g)>>>0)/(c<<2>>>0)|0;h=V(g,c<<2)|0;f[d>>2]=0;f[d+8>>2]=f[a+40>>2];f[d+12>>2]=-1;f[d+16>>2]=h;f[d+20>>2]=g;f[d+24>>2]=g<<2;f[d+28>>2]=c;f[d+32>>2]=f[a+52>>2];f[d+36>>2]=b;c=Ic(d,a)|0;if(!c){if(f[d+8>>2]|0){c=0;do{nc(d,c);c=c+1|0}while(c>>>0<(f[d+8>>2]|0)>>>0)}mc(a,d);c=0}}else c=-26;t=e;return c|0}function Rb(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;o=t;n=t=t+63&-64;t=t+48|0;m=$d(e,n+40|0,n+36|0,n+32|0)|0;if(m){j=Wf(1,0,f[n+40>>2]|0)|0;k=G;h=si(m)|0;if(!h)h=Sc(m)|0;else h=h-m|0;i=h+(m-e)|0;if((!((i+45|0)>>>0>102|(i+45|0)>>>0<h>>>0)?(hb(a,c,d,m,h,j,k,f[n+36>>2]|0,f[n+32>>2]|0,n,32)|0)==0:0)?(qb(g|0,e|0,i|0)|0,b[g+i>>0]=36,l=zd(g+i+1|0,g+102-(g+i+1)|0,n)|0,ye(n,32),(l|0)!=0&l>>>0<(g+102|0)>>>0):0)b[l>>0]=0;else g=0}else g=0;t=o;return g|0}function Sb(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0;do if(!b){if(!(c<<24>>24)){h=d+-1|0;break}h=V(f[a+20>>2]|0,c&255)|0;if(!g){h=h+(((d|0)==0)<<31>>31)|0;break}else{h=d+-1+h|0;break}}else{h=(f[a+24>>2]|0)-(f[a+20>>2]|0)|0;if(!g){h=h+(((d|0)==0)<<31>>31)|0;break}else{h=d+-1+h|0;break}}while(0);Af(e|0,0,e|0,0)|0;Af(G|0,0,h|0,0)|0;g=Ig(h+-1|0,0,G|0,0)|0;if((b|0)==0|c<<24>>24==3){h=0;d=0}else{h=V(f[a+20>>2]|0,(c&255)+1|0)|0;d=0}c=Lg(g|0,G|0,h|0,d|0)|0;a=pf(c|0,G|0,f[a+24>>2]|0,0)|0;return a|0}function Tb(a,c){a=a|0;c=c|0;var d=0,e=0;a:do if(!(c&255))a=a+(Sc(a)|0)|0;else{if(a&3)do{e=b[a>>0]|0;if(e<<24>>24==0?1:e<<24>>24==(c&255)<<24>>24)break a;a=a+1|0}while((a&3|0)!=0);e=V(c&255,16843009)|0;d=f[a>>2]|0;b:do if(!((d&-2139062144^-2139062144)&d+-16843009))do{d=d^e;if((d&-2139062144^-2139062144)&d+-16843009|0)break b;a=a+4|0;d=f[a>>2]|0}while(!((d&-2139062144^-2139062144)&d+-16843009|0));while(0);while(1){e=b[a>>0]|0;if(e<<24>>24==0?1:e<<24>>24==(c&255)<<24>>24)break;else a=a+1|0}}while(0);return a|0}function Ub(a,c,d,e,g,h,i){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;var j=0,k=0,l=0,m=0;m=t;k=t=t+63&-64;t=t+128|0;j=a;l=j+102|0;do{b[j>>0]=0;j=j+1|0}while((j|0)<(l|0));do if(!(e>>>0>0|(e|0)==0&d>>>0>4294967295)){zb(g,h,i,k+104|0,k+100|0,k+96|0);uf(k+64|0,32);if(!(Mc(f[k+104>>2]|0,f[k+96>>2]|0,f[k+100>>2]|0,k+64|0,k)|0)){f[9002]=22;a=-1;break}zi(k+108|0);l=(Rb(k+108|0,c,d,k,a)|0)==0;Ai(k+108|0);if(l){f[9002]=22;a=-1}else a=0}else{f[9002]=27;a=-1}while(0);t=m;return a|0}function Vb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;m=(f[b+4>>2]|0)-(f[c+4>>2]|0)|0;l=(f[b+8>>2]|0)-(f[c+8>>2]|0)|0;k=(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|0;We(k+320|0,i,j);Kg(k+64|0,k+320|0,8,0)|0;Gf(a,d,e,g,l,1,0,m)|0;Kg(k+64|0,a,e,g)|0;We(k+320|0,e,g);Kg(k+64|0,k+320|0,8,0)|0;Kh(k+64|0,b)|0;ye(k+64|0,256);if(c|0){f[c>>2]=16;f[c+4>>2]=0}t=k;return 0}function Yb(a,c,d){a=a|0;c=c|0;d=d|0;var e=0;uf(c,24);Ha(a,c,d,0)|0;yg(a);e=h[c+16>>0]|h[c+16+1>>0]<<8|h[c+16+2>>0]<<16|h[c+16+3>>0]<<24;d=h[c+16+4>>0]|h[c+16+4+1>>0]<<8|h[c+16+4+2>>0]<<16|h[c+16+4+3>>0]<<24;b[a+36>>0]=e;b[a+36+1>>0]=e>>8;b[a+36+2>>0]=e>>16;b[a+36+3>>0]=e>>24;b[a+36+4>>0]=d;b[a+36+4+1>>0]=d>>8;b[a+36+4+2>>0]=d>>16;b[a+36+4+3>>0]=d>>24;b[a+44>>0]=0;b[a+44+1>>0]=0;b[a+44+2>>0]=0;b[a+44+3>>0]=0;b[a+44+4>>0]=0;b[a+44+4+1>>0]=0;b[a+44+4+2>>0]=0;b[a+44+4+3>>0]=0;return 0}function Zb(a){a=a|0;var c=0,d=0,e=0,f=0,g=0,i=0;f=t;g=t=t+63&-64;t=t+16|0;b[g>>0]=0;b[g+1>>0]=0;b[g+2>>0]=0;b[g+3>>0]=0;b[g+4>>0]=0;b[g+5>>0]=0;b[g+6>>0]=0;d=0;do{e=b[a+d>>0]|0;c=0;do{i=g+c|0;b[i>>0]=b[i>>0]|b[32096+(c<<5)+d>>0]^e;c=c+1|0}while((c|0)!=7);d=d+1|0}while((d|0)!=31);d=b[a+31>>0]&127;c=0;do{i=g+c|0;b[i>>0]=b[i>>0]|d^b[32096+(c<<5)+31>>0];c=c+1|0}while((c|0)!=7);c=0;d=0;do{c=(h[g+d>>0]|0)+-1|c;d=d+1|0}while((d|0)!=7);t=f;return c>>>8&1|0}function _b(a,c,d){a=a|0;c=c|0;d=d|0;var e=0;Ha(a,c,d,0)|0;yg(a);e=h[c+16>>0]|h[c+16+1>>0]<<8|h[c+16+2>>0]<<16|h[c+16+3>>0]<<24;d=h[c+16+4>>0]|h[c+16+4+1>>0]<<8|h[c+16+4+2>>0]<<16|h[c+16+4+3>>0]<<24;b[a+36>>0]=e;b[a+36+1>>0]=e>>8;b[a+36+2>>0]=e>>16;b[a+36+3>>0]=e>>24;b[a+36+4>>0]=d;b[a+36+4+1>>0]=d>>8;b[a+36+4+2>>0]=d>>16;b[a+36+4+3>>0]=d>>24;b[a+44>>0]=0;b[a+44+1>>0]=0;b[a+44+2>>0]=0;b[a+44+3>>0]=0;b[a+44+4>>0]=0;b[a+44+4+1>>0]=0;b[a+44+4+2>>0]=0;b[a+44+4+3>>0]=0;return 0}function $b(a,c,d,e,f){a=a|0;c=c|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0;i=t;h=t=t+63&-64;t=t+480|0;g=(a|0)==0?c:a;c=(c|0)==0?g:c;if(!g)Fj();if(!(Oh(h+448|0,e,f)|0)){jh(h,0,0,64)|0;Yg(h,h+448|0,32,0)|0;ye(h+448|0,32);Yg(h,f,32,0)|0;Yg(h,d,32,0)|0;Bh(h,h+384|0,64)|0;ye(h,384);a=0;do{b[c+a>>0]=b[h+384+a>>0]|0;b[g+a>>0]=b[h+384+(a+32)>>0]|0;a=a+1|0}while((a|0)!=32);ye(h+384|0,64);a=0}else a=-1;t=i;return a|0}function ac(a,c,d,e,f){a=a|0;c=c|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0;i=t;h=t=t+63&-64;t=t+480|0;g=(a|0)==0?c:a;c=(c|0)==0?g:c;if(!g)Fj();if(!(Oh(h+448|0,e,f)|0)){jh(h,0,0,64)|0;Yg(h,h+448|0,32,0)|0;ye(h+448|0,32);Yg(h,d,32,0)|0;Yg(h,f,32,0)|0;Bh(h,h+384|0,64)|0;ye(h,384);a=0;do{b[g+a>>0]=b[h+384+a>>0]|0;b[c+a>>0]=b[h+384+(a+32)>>0]|0;a=a+1|0}while((a|0)!=32);ye(h+384|0,64);a=0}else a=-1;t=i;return a|0}function bc(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0;g=t;h=t=t+63&-64;t=t+64|0;if((c+-1&255)>63)Fj();b[h>>0]=c;b[h+1>>0]=0;b[h+2>>0]=1;b[h+3>>0]=1;Dh(h+4|0);We(h+8|0,0,0);f[h+16>>2]=0;f[h+16+4>>2]=0;f[h+16+8>>2]=0;f[h+16+12>>2]=0;if(!d){f[h+32>>2]=0;f[h+32+4>>2]=0;f[h+32+8>>2]=0;f[h+32+12>>2]=0}else Kf(h,d);if(!e){f[h+48>>2]=0;f[h+48+4>>2]=0;f[h+48+8>>2]=0;f[h+48+12>>2]=0}else Hf(h,e);ie(a,h);t=g;return}function cc(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0;d=t;f=t=t+63&-64;t=t+160|0;e=Li(c)|0;c=(c<<24>>24)-((0-(e&255)&c<<24>>24)<<1)&255;zh(a);nf(a,b,gi(c,1)|0);nf(a,b+160|0,gi(c,2)|0);nf(a,b+320|0,gi(c,3)|0);nf(a,b+480|0,gi(c,4)|0);nf(a,b+640|0,gi(c,5)|0);nf(a,b+800|0,gi(c,6)|0);nf(a,b+960|0,gi(c,7)|0);nf(a,b+1120|0,gi(c,8)|0);Rc(f,a+40|0);Rc(f+40|0,a);Rc(f+80|0,a+80|0);Dc(f+120|0,a+120|0);nf(a,f,e);t=d;return}
20573function dc(a,b,c,d,e,g,h,i,j,k,l){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;l=l|0;ec(a|0,0,b|0)|0;do if(!(c>>>0>0|(c|0)==0&b>>>0>4294967295)){if(c>>>0<0|(c|0)==0&b>>>0<16){f[9002]=22;a=-1;break}if((j|g)>>>0>0|(j|g|0)==0&(i|e)>>>0>4294967295|k>>>0>2147483648){f[9002]=27;a=-1;break}if(j>>>0<0|(j|0)==0&i>>>0<3|k>>>0<8192){f[9002]=22;a=-1;break}if((l|0)==1){a=((fg(i,k>>>10,d,e,h,a,b)|0)!=0)<<31>>31;break}else{f[9002]=22;a=-1;break}}else{f[9002]=27;a=-1}while(0);return a|0}function ec(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0;e=a+d|0;c=c&255;if((d|0)>=67){while(a&3){b[a>>0]=c;a=a+1|0}g=c|c<<8|c<<16|c<<24;while((a|0)<=((e&-4)-64|0)){f[a>>2]=g;f[a+4>>2]=g;f[a+8>>2]=g;f[a+12>>2]=g;f[a+16>>2]=g;f[a+20>>2]=g;f[a+24>>2]=g;f[a+28>>2]=g;f[a+32>>2]=g;f[a+36>>2]=g;f[a+40>>2]=g;f[a+44>>2]=g;f[a+48>>2]=g;f[a+52>>2]=g;f[a+56>>2]=g;f[a+60>>2]=g;a=a+64|0}while((a|0)<(e&-4|0)){f[a>>2]=g;a=a+4|0}}while((a|0)<(e|0)){b[a>>0]=c;a=a+1|0}return e-d|0}function fc(a,b,c,d,e,g,h,i,j,k,l){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;l=l|0;ec(a|0,0,b|0)|0;do if(!(c>>>0>0|(c|0)==0&b>>>0>4294967295)){if(c>>>0<0|(c|0)==0&b>>>0<16){f[9002]=22;a=-1;break}if((j|g)>>>0>0|(j|g|0)==0&(i|e)>>>0>4294967295|k>>>0>2147483648){f[9002]=27;a=-1;break}if((i|0)==0&(j|0)==0|k>>>0<8192){f[9002]=22;a=-1;break}if((l|0)==2){a=((cg(i,k>>>10,d,e,h,a,b)|0)!=0)<<31>>31;break}else{f[9002]=22;a=-1;break}}else{f[9002]=27;a=-1}while(0);return a|0}function gc(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0;h=t;i=t=t+63&-64;t=t+192|0;if((c+-1&255)>63)Fj();if((e+-1&255)>63|(d|0)==0)Fj();else{b[i+128>>0]=c;b[i+128+1>>0]=e;b[i+128+2>>0]=1;b[i+128+3>>0]=1;Dh(i+128+4|0);We(i+128+8|0,0,0);c=i+128+16|0;g=c+48|0;do{f[c>>2]=0;c=c+4|0}while((c|0)<(g|0));ie(a,i+128|0);ec(i+(e&255)|0,0,128-(e&255)|0)|0;qb(i|0,d|0,e&255|0)|0;Nb(a,i,128,0);ye(i,128);t=h;return}}function hc(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var i=0,j=0,k=0,l=0;l=t;k=t=t+63&-64;t=t+16|0;if(e){if(!(e+-1&e))i=e+-1&d;else i=(d>>>0)%(e>>>0)|0;j=e+-1-i|0;if(j>>>0>=~d>>>0)Fj();if((j+d|0)>>>0<g>>>0){if(a|0)f[a>>2]=j+d+1;b[k>>0]=0;i=0;do{g=((i^j)+-1|0)>>>24;a=c+(j+d)+(0-i)|0;b[a>>0]=g&128|b[k>>0]&b[a>>0]&255;b[k>>0]=g|(h[k>>0]|0);i=i+1|0}while((i|0)!=(e|0));i=0}else i=-1}else i=-1;t=l;return i|0}function ic(a,c){a=a|0;c=c|0;var d=0;d=(yh(c)|0)&67108863;f[a>>2]=d;d=(yh(c+3|0)|0)>>>2&67108611;f[a+4>>2]=d;d=(yh(c+6|0)|0)>>>4&67092735;f[a+8>>2]=d;d=(yh(c+9|0)|0)>>>6&66076671;f[a+12>>2]=d;d=(yh(c+12|0)|0)>>>8&1048575;f[a+16>>2]=d;f[a+20>>2]=0;f[a+20+4>>2]=0;f[a+20+8>>2]=0;f[a+20+12>>2]=0;f[a+20+16>>2]=0;d=yh(c+16|0)|0;f[a+40>>2]=d;d=yh(c+20|0)|0;f[a+44>>2]=d;d=yh(c+24|0)|0;f[a+48>>2]=d;c=yh(c+28|0)|0;f[a+52>>2]=c;f[a+56>>2]=0;f[a+56+4>>2]=0;b[a+80>>0]=0;return}function jc(a,b,c,d,e,g,h,i,j,k){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;var l=0,m=0;m=t;l=t=t+63&-64;t=t+16|0;ec(a|0,0,b|0)|0;do if(!((g|c)>>>0>0|(g|c|0)==0&(e|b)>>>0>4294967295))if(c>>>0<0|(c|0)==0&b>>>0<16){f[9002]=22;a=-1;break}else{zb(i,j,k,l+8|0,l+4|0,l);k=Wf(1,0,f[l+8>>2]|0)|0;a=Hd(d,e,h,32,k,G,f[l>>2]|0,f[l+4>>2]|0,a,b)|0;break}else{f[9002]=27;a=-1}while(0);t=m;return a|0}function kc(a,b,c,d,e,f,g,h,i){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;var j=0,k=0;j=t;k=t=t+63&-64;t=t+384|0;if((b|0)==0&((e|0)!=0|(f|0)!=0))Fj();if(!a)Fj();if((d+-1&255)>63)Fj();if(!((c|0)!=0|g<<24>>24==0))Fj();if((g&255)>64)Fj();if(!(g<<24>>24))bc(k,d,h,i);else yb(k,d,c,g,h,i);Nb(k,b,e,f);gb(k,a,d)|0;t=j;return}function lc(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0;do if(!(e>>>0<0|(e|0)==0&d>>>0<64)?(h=Lg(d|0,e|0,-64,-1)|0,i=G,!(i>>>0>0|(i|0)==0&h>>>0>4294967231)):0){if(tg(c,c+64|0,h,i,g)|0){if(!a){j=10;break}ec(a|0,0,h|0)|0;j=10;break}if(b|0){f[b>>2]=h;f[b+4>>2]=i}if(!a)a=0;else{se(a|0,c+64|0,h|0)|0;a=0}}else j=10;while(0);if((j|0)==10)if(!b)a=-1;else{f[b>>2]=0;f[b+4>>2]=0;a=-1}return a|0}function mc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0;d=t;e=t=t+63&-64;t=t+2048|0;if((a|0)!=0&(b|0)!=0){li(e+1024|0,(f[(f[b>>2]|0)+4>>2]|0)+(f[b+24>>2]<<10)+-1024|0);if((f[b+28>>2]|0)>>>0>1){c=1;do{g=f[b+24>>2]|0;g=g+-1+(V(g,c)|0)|0;Ae(e+1024|0,(f[(f[b>>2]|0)+4>>2]|0)+(g<<10)|0);c=c+1|0}while(c>>>0<(f[b+28>>2]|0)>>>0)}sf(e,e+1024|0);Sa(f[a>>2]|0,f[a+4>>2]|0,e,1024);ye(e+1024|0,1024);ye(e,1024);og(b,f[a+56>>2]|0)}t=d;return}function nc(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0;g=t;h=t=t+63&-64;t=t+32|0;if(a|0?(d=f[a+28>>2]|0,d|0):0){f[h>>2]=c;e=0;c=d;do{b[h+8>>0]=e;if(!c)c=0;else{d=0;do{f[h+4>>2]=d;f[h+12>>2]=0;f[h+16>>2]=f[h>>2];f[h+16+4>>2]=f[h+4>>2];f[h+16+8>>2]=f[h+8>>2];f[h+16+12>>2]=f[h+12>>2];Va(a,h+16|0);d=d+1|0;c=f[a+28>>2]|0}while(d>>>0<c>>>0)}e=e+1|0}while((e|0)!=4)}t=g;return}function oc(a,b,c,d,e,g,i,j,k,l,m,n){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;i=i|0;j=j|0;k=k|0;l=l|0;m=m|0;n=n|0;l=t;t=t+48|0;f[l+32>>2]=0;Ha(l,m,n,0)|0;n=h[m+16+4>>0]|h[m+16+4+1>>0]<<8|h[m+16+4+2>>0]<<16|h[m+16+4+3>>0]<<24;f[l+32+4>>2]=h[m+16>>0]|h[m+16+1>>0]<<8|h[m+16+2>>0]<<16|h[m+16+3>>0]<<24;f[l+32+4+4>>2]=n;Ib(a,b,c,d,e,g,i,j,k,0,l+32|0,l)|0;ye(l,32);t=l;return 0}function pc(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var i=0,j=0,k=0;j=t;i=t=t+63&-64;t=t+32|0;k=h[e+4>>0]|h[e+4+1>>0]<<8|h[e+4+2>>0]<<16|h[e+4+3>>0]<<24;f[i+16>>2]=h[e>>0]|h[e+1>>0]<<8|h[e+2>>0]<<16|h[e+3>>0]<<24;f[i+16+4>>2]=k;f[i+16+8>>2]=0;f[i+16+8+4>>2]=0;We(i,c,d);f[i+8>>2]=0;f[i+8+4>>2]=0;if((b+-16|0)>>>0>48){f[9002]=22;a=-1}else a=he(a,b,0,0,0,g,32,i,i+16|0)|0;t=j;return a|0}function qc(a,b,c,d,e,g,i,j,k,l,m){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;i=i|0;j=j|0;k=k|0;l=l|0;m=m|0;b=t;t=t+48|0;f[b+32>>2]=0;Ha(b,l,m,0)|0;m=h[l+16+4>>0]|h[l+16+4+1>>0]<<8|h[l+16+4+2>>0]<<16|h[l+16+4+3>>0]<<24;f[b+32+4>>2]=h[l+16>>0]|h[l+16+1>>0]<<8|h[l+16+2>>0]<<16|h[l+16+3>>0]<<24;f[b+32+4+4>>2]=m;l=wb(a,0,c,d,e,g,i,j,k,b+32|0,b)|0;ye(b,32);t=b;return l|0}function rc(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0;d=t;f=t=t+63&-64;t=t+128|0;e=Li(c)|0;c=(c<<24>>24)-((0-(e&255)&c<<24>>24)<<1)&255;Wh(a);ag(a,b,gi(c,1)|0);ag(a,b+120|0,gi(c,2)|0);ag(a,b+240|0,gi(c,3)|0);ag(a,b+360|0,gi(c,4)|0);ag(a,b+480|0,gi(c,5)|0);ag(a,b+600|0,gi(c,6)|0);ag(a,b+720|0,gi(c,7)|0);ag(a,b+840|0,gi(c,8)|0);Rc(f,a+40|0);Rc(f+40|0,a);Dc(f+80|0,a+80|0);ag(a,f,e);t=d;return}function sc(a,b,c,d,e,g,h,i,j,k,l){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;l=l|0;var m=0,n=0,o=0;if(g>>>0>0|(g|0)==0&e>>>0>15){m=Lg(e|0,g|0,-16,-1)|0;n=G;g=qc(a,0,d,m,n,d+e+-16|0,h,i,j,k,l)|0;if(!b)c=g;else{c=g;a=(g|0)==0?m:0;g=(g|0)==0?n:0;o=4}}else if(!b)c=-1;else{c=-1;a=0;g=0;o=4}if((o|0)==4){f[b>>2]=a;f[b+4>>2]=g}return c|0}function tc(a,b,c,d,e,g,h,i,j,k,l){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;l=l|0;var m=0,n=0,o=0;if(g>>>0>0|(g|0)==0&e>>>0>15){m=Lg(e|0,g|0,-16,-1)|0;n=G;g=wb(a,0,d,m,n,d+e+-16|0,h,i,j,k,l)|0;if(!b)c=g;else{c=g;a=(g|0)==0?m:0;g=(g|0)==0?n:0;o=4}}else if(!b)c=-1;else{c=-1;a=0;g=0;o=4}if((o|0)==4){f[b>>2]=a;f[b+4>>2]=g}return c|0}function uc(a,c,d,e,g,h,i){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;var j=0,k=0,l=0,m=0;m=t;k=t=t+63&-64;t=t+16|0;j=a;l=j+128|0;do{b[j>>0]=0;j=j+1|0}while((j|0)<(l|0));do if(!((h|e)>>>0>0|(h|e|0)==0&(g|d)>>>0>4294967295|i>>>0>2147483648))if(h>>>0<0|(h|0)==0&g>>>0<3|i>>>0<8192){f[9002]=22;a=-1;break}else{uf(k,16);a=((rg(g,i>>>10,c,d,k,a)|0)!=0)<<31>>31;break}else{f[9002]=27;a=-1}while(0);t=m;return a|0}function vc(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0;a:do if(g){i=f[d>>2]|0;while(1){if(i>>>0>=c>>>0){h=4;break}h=b[a+i>>0]|0;if(h<<24>>24!=61){if(!e){h=9;break}if(!(sh(e,h<<24>>24)|0)){h=9;break}}else g=g+-1|0;i=i+1|0;f[d>>2]=i;if(!g){g=0;break a}}if((h|0)==4){f[9002]=34;g=-1;break}else if((h|0)==9){f[9002]=22;g=-1;break}}else g=0;while(0);return g|0}function wc(a,b,c,d,e,g,h,i,j,k,l){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;l=l|0;var m=0,n=0,o=0;if(g>>>0>0|(g|0)==0&e>>>0>15){m=Lg(e|0,g|0,-16,-1)|0;n=G;g=Jb(a,0,d,m,n,d+e+-16|0,h,i,j,k,l)|0;if(!b)c=g;else{c=g;a=(g|0)==0?m:0;g=(g|0)==0?n:0;o=4}}else if(!b)c=-1;else{c=-1;a=0;g=0;o=4}if((o|0)==4){f[b>>2]=a;f[b+4>>2]=g}return c|0}function xc(a,c,d,e,g,h,i){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;var j=0,k=0,l=0,m=0;m=t;k=t=t+63&-64;t=t+16|0;j=a;l=j+128|0;do{b[j>>0]=0;j=j+1|0}while((j|0)<(l|0));do if(!((h|e)>>>0>0|(h|e|0)==0&(g|d)>>>0>4294967295|i>>>0>2147483648))if((g|0)==0&(h|0)==0|i>>>0<8192){f[9002]=22;a=-1;break}else{uf(k,16);a=((qg(g,i>>>10,c,d,k,a)|0)!=0)<<31>>31;break}else{f[9002]=27;a=-1}while(0);t=m;return a|0}function yc(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;var g=0,h=0;g=t;h=t=t+63&-64;t=t+464|0;Bb(h+240|0,a,b)|0;bh(h+240|0,c,d,0)|0;if(f|0){a=0;b=0;do{a=a+1|0;Mg(h+448|0,a);qb(h+32|0,h+240|0,208)|0;bh(h+32|0,h+448|0,4,0)|0;Ve(h+32|0,h)|0;d=f-b|0;qb(e+b|0,h|0,(d>>>0<32?d:32)|0)|0;b=a<<5}while(b>>>0<f>>>0)}ye(h+240|0,208);t=g;return}function zc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;e=t;d=t=t+63&-64;t=t+16|0;do if((((a|0)!=0?(b|0)!=0:0)?((b<<10>>>0)/(b>>>0)|0|0)==1024:0)?(c=na(12)|0,f[a>>2]=c,(c|0)!=0):0){f[c+4>>2]=0;f[c>>2]=0;c=Uf(d,b<<10)|0;f[9002]=c;if(c|0){f[d>>2]=0;c=-22;break}c=f[d>>2]|0;if(c){f[f[a>>2]>>2]=c;f[(f[a>>2]|0)+4>>2]=c;f[(f[a>>2]|0)+8>>2]=b<<10;c=0}else c=-22}else c=-22;while(0);t=e;return c|0}function Ac(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0;h=t;i=t=t+63&-64;t=t+384|0;if((b|0)==0&((e|0)!=0|(f|0)!=0))Fj();if(!a)Fj();if((d+-1&255)>63)Fj();if(!((c|0)!=0|g<<24>>24==0))Fj();if((g&255)>64)Fj();if(!(g<<24>>24))ed(i,d);else gc(i,d,c,g);Nb(i,b,e,f);gb(i,a,d)|0;t=h;return}function Bc(a,c,d,e,f){a=a|0;c=c|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0;k=t;h=t=t+63&-64;t=t+96|0;if(!(_g(h+32|0,h)|0)){g=a;i=h+32|0;j=g+32|0;do{b[g>>0]=b[i>>0]|0;g=g+1|0;i=i+1|0}while((g|0)<(j|0));le(h+64|0,h+32|0,f);a=qe(a+32|0,c,d,e,h+64|0,f,h)|0;ye(h,32);ye(h+32|0,32);ye(h+64|0,24)}else a=-1;t=k;return a|0}function Cc(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,f=0;f=t;e=t=t+63&-64;t=t+320|0;if((((hf(d)|0)!=0?(Zb(d)|0)==0:0)?(Hb(e,d)|0)==0:0)?(Df(e)|0)!=0:0){d=0;do{b[a+d>>0]=b[c+d>>0]|0;d=d+1|0}while((d|0)!=32);rh(a);Oa(e+160|0,a,e);Pd(a,e+160|0);if(!(jf(a)|0))d=((ge(c,32)|0)!=0)<<31>>31;else d=-1}else d=-1;t=f;return d|0}function Dc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;l=0-(f[b+4>>2]|0)|0;k=0-(f[b+8>>2]|0)|0;j=0-(f[b+12>>2]|0)|0;i=0-(f[b+16>>2]|0)|0;h=0-(f[b+20>>2]|0)|0;g=0-(f[b+24>>2]|0)|0;e=0-(f[b+28>>2]|0)|0;d=0-(f[b+32>>2]|0)|0;c=0-(f[b+36>>2]|0)|0;f[a>>2]=0-(f[b>>2]|0);f[a+4>>2]=l;f[a+8>>2]=k;f[a+12>>2]=j;f[a+16>>2]=i;f[a+20>>2]=h;f[a+24>>2]=g;f[a+28>>2]=e;f[a+32>>2]=d;f[a+36>>2]=c;return}function Ec(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;d=t;e=t=t+63&-64;t=t+1024|0;if(f[b+28>>2]|0){c=0;do{Qg(a+64|0,0);Qg(a+68|0,c);Sa(e,1024,a,72);ff((f[(f[b>>2]|0)+4>>2]|0)+((V(f[b+24>>2]|0,c)|0)<<10)|0,e);Qg(a+64|0,1);Sa(e,1024,a,72);ff((f[(f[b>>2]|0)+4>>2]|0)+((V(f[b+24>>2]|0,c)|0)+1<<10)|0,e);c=c+1|0}while(c>>>0<(f[b+28>>2]|0)>>>0)}ye(e,1024);t=d;return}function Fc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0;l=t;k=t=t+63&-64;t=t+16|0;f[k>>2]=0;if((d+-1|0)>>>0<c>>>0){i=0;j=0;e=0;while(1){e=e&255;g=h[b+(c+-1)+(0-i)>>0]|0;m=((f[k>>2]|0)+511&e+511&(g^128)+511)>>>8&1;f[k>>2]=i&0-m|f[k>>2];j=m|j&255;i=i+1|0;if((i|0)==(d|0))break;else e=e|g}f[a>>2]=c+-1-(f[k>>2]|0);e=j+-1|0}else e=-1;t=l;return e|0}function Gc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;d=f[a+32>>2]|0;c=f[a+32+4>>2]|0;e=$f(d|0,c|0,3)|0;if((e&63)>>>0<56){if(56-(e&63)|0)qb(a+40+(e&63)|0,32688,56-(e&63)|0)|0}else{if(64-(e&63)|0)qb(a+40+(e&63)|0,32688,64-(e&63)|0)|0;sa(a,a+40|0,b,b+256|0);c=a+40|0;d=c+56|0;do{f[c>>2]=0;c=c+4|0}while((c|0)<(d|0));d=f[a+32>>2]|0;c=f[a+32+4>>2]|0}jd(a+96|0,d,c);sa(a,a+40|0,b,b+256|0);return}function Hc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0;g=t;e=t=t+63&-64;t=t+32|0;zb(b,c,d,e+20|0,e+12|0,e+4|0);do if((gg(a)|0)==101){if(!($d(a,e+16|0,e,e+8|0)|0)){f[9002]=22;a=-1;break}if((f[e+20>>2]|0)==(f[e+16>>2]|0)?(f[e+4>>2]|0)==(f[e>>2]|0):0)a=(f[e+12>>2]|0)!=(f[e+8>>2]|0)&1;else a=1}else{f[9002]=22;a=-1}while(0);t=g;return a|0}function Ic(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;e=t;d=t=t+63&-64;t=t+80|0;do if(!((a|0)==0|(b|0)==0)){c=na(f[a+20>>2]<<3)|0;f[a+4>>2]=c;if(c){c=zc(a,f[a+16>>2]|0)|0;if(!c){Qa(d,b,f[a+36>>2]|0);ye(d+64|0,8);Ec(d,a);ye(d,72);c=0;break}else{og(a,f[b+56>>2]|0);break}}else c=-22}else c=-25;while(0);t=e;return c|0}function Jc(a){a=a|0;var c=0,d=0,e=0,f=0,g=0,i=0;f=t;g=t=t+63&-64;t=t+16|0;c=g;d=c+12|0;do{b[c>>0]=0;c=c+1|0}while((c|0)<(d|0));d=0;do{e=b[a+d>>0]|0;c=0;do{i=g+c|0;b[i>>0]=b[i>>0]|b[33584+(c<<5)+d>>0]^e;c=c+1|0}while((c|0)!=12);d=d+1|0}while((d|0)!=32);c=0;d=0;do{c=(h[g+d>>0]|0)+-1|c;d=d+1|0}while((d|0)!=12);t=f;return c>>>8&1|0}function Kc(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0;i=b[a>>0]|0;a:do if((i+-48&255)<=9){g=0;h=a;e=i;while(1){d=(e<<24>>24)+-48|0;e=g*10|0;if(!(g>>>0<429496730&(d>>>0>~e>>>0^1))){d=0;break a}g=(d>>>0>~e>>>0?0:d)+e|0;d=h+1|0;e=b[d>>0]|0;if((e+-48&255)>9)break;else h=d}if((d|0)!=(a|0)?(h|0)==(a|0)|i<<24>>24!=48:0)f[c>>2]=g;else d=0}else d=0;while(0);return d|0}function Lc(a){a=a|0;return ((0-((0-(a^95)|0)>>>8&63^63|(0-(a^45)|0)>>>8&62^62|((a+65439|0)>>>8^255)&a+185&((122-a|0)>>>8&255^255)|((a+-65|0)>>>8^255)&a+-65&((90-a|0)>>>8&255^255)|((a+65488|0)>>>8^255)&a+4&((57-a|0)>>>8&255^255))|0)>>>8&255^255)&(0-(a^65)|0)>>>8|((0-(a^95)|0)>>>8&63^63|(0-(a^45)|0)>>>8&62^62|((a+65439|0)>>>8^255)&a+185&((122-a|0)>>>8&255^255)|((a+-65|0)>>>8^255)&a+-65&((90-a|0)>>>8&255^255)|((a+65488|0)>>>8^255)&a+4&((57-a|0)>>>8&255^255))|0}function Mc(a,c,d,e,f){a=a|0;c=c|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0;if((((a>>>0<=63?(j=Af(d|0,0,c|0,0)|0,k=G,!(k>>>0>0|(k|0)==0&j>>>0>1073741823)):0)?(b[f>>0]=36,b[f+1>>0]=55,b[f+2>>0]=36,b[f+3>>0]=b[35349+a>>0]|0,g=Ed(f+4|0,54,c,30)|0,(g|0)!=0):0)?(h=Ed(g,f+58-g|0,d,30)|0,(h|0)!=0):0)?(i=zd(h,f+58-h|0,e)|0,(i|0)!=0&i>>>0<(f+58|0)>>>0):0)b[i>>0]=0;else f=0;return f|0}function Nc(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0;h=t;i=t=t+63&-64;t=t+16|0;se(a+64|0,c|0,d|0)|0;lg(a,i,a+64|0,d,e,g)|0;if((f[i>>2]|0)==64&(f[i+4>>2]|0)==0)if(b|0){a=Lg(d|0,e|0,64,0)|0;f[b>>2]=a;f[b+4>>2]=G;a=0}else a=0;else{if(b|0){f[b>>2]=0;f[b+4>>2]=0}ec(a|0,0,d+64|0)|0;a=-1}t=h;return a|0}function Oc(a,c,d,e,f,g){a=a|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0;i=t;h=t=t+63&-64;t=t+32|0;if(!(e>>>0<0|(e|0)==0&d>>>0<32)?(me(h,32,0,f,g)|0,j=Lg(d|0,e|0,-32,-1)|0,(vg(c+16|0,c+32|0,j,G,h)|0)==0):0){kg(a,c,d,e,f,g)|0;c=a+32|0;do{b[a>>0]=0;a=a+1|0}while((a|0)<(c|0));a=0}else a=-1;t=i;return a|0}function Pc(a){a=a|0;return ((0-((0-(a^47)|0)>>>8&63^63|(0-(a^43)|0)>>>8&62^62|((a+65439|0)>>>8^255)&a+185&((122-a|0)>>>8&255^255)|((a+-65|0)>>>8^255)&a+-65&((90-a|0)>>>8&255^255)|((a+65488|0)>>>8^255)&a+4&((57-a|0)>>>8&255^255))|0)>>>8&255^255)&(0-(a^65)|0)>>>8|((0-(a^47)|0)>>>8&63^63|(0-(a^43)|0)>>>8&62^62|((a+65439|0)>>>8^255)&a+185&((122-a|0)>>>8&255^255)|((a+-65|0)>>>8^255)&a+-65&((90-a|0)>>>8&255^255)|((a+65488|0)>>>8^255)&a+4&((57-a|0)>>>8&255^255))|0}function Qc(a,b,c,e){a=a|0;b=b|0;c=c|0;e=e|0;var g=0,h=0,i=0;i=t;g=t=t+63&-64;t=t+128|0;if((gg(a)|0)==101){zi(g+104|0);e=g;h=e+100|0;do{f[e>>2]=0;e=e+4|0}while((e|0)<(h|0));d[g+100>>1]=0;c=(Rb(g+104|0,b,c,a,g)|0)==0;Ai(g+104|0);if(!c){e=hd(g,a,102)|0;ye(g,102)}else e=-1}else e=-1;t=i;return e|0}function Rc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;l=f[b+4>>2]|0;k=f[b+8>>2]|0;j=f[b+12>>2]|0;i=f[b+16>>2]|0;h=f[b+20>>2]|0;g=f[b+24>>2]|0;e=f[b+28>>2]|0;d=f[b+32>>2]|0;c=f[b+36>>2]|0;f[a>>2]=f[b>>2];f[a+4>>2]=l;f[a+8>>2]=k;f[a+12>>2]=j;f[a+16>>2]=i;f[a+20>>2]=h;f[a+24>>2]=g;f[a+28>>2]=e;f[a+32>>2]=d;f[a+36>>2]=c;return}function Sc(a){a=a|0;var c=0,d=0,e=0;a:do if(!(a&3)){c=a;e=5}else{c=a;d=a;while(1){if(!(b[c>>0]|0)){c=d;break a}c=c+1|0;d=c;if(!(d&3)){e=5;break}}}while(0);if((e|0)==5){while(1){d=f[c>>2]|0;if(!((d&-2139062144^-2139062144)&d+-16843009))c=c+4|0;else break}if((d&255)<<24>>24)do c=c+1|0;while((b[c>>0]|0)!=0)}return c-a|0}function Tc(a,c,d,e,f){a=a|0;c=c|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0;j=t;t=t+96|0;if(!(Qh(j+32|0,j)|0)){g=a;h=j+32|0;i=g+32|0;do{b[g>>0]=b[h>>0]|0;g=g+1|0;h=h+1|0}while((g|0)<(i|0));le(j+64|0,j+32|0,f);a=Xe(a+32|0,c,d,e,j+64|0,f,j)|0;ye(j,32);ye(j+32|0,32);ye(j+64|0,24)}else a=-1;t=j;return a|0}function Uc(a,b){a=a|0;b=b|0;var c=0;f[a>>2]=1634760805;f[a+4>>2]=857760878;f[a+8>>2]=2036477234;f[a+12>>2]=1797285236;c=yh(b)|0;f[a+16>>2]=c;c=yh(b+4|0)|0;f[a+20>>2]=c;c=yh(b+8|0)|0;f[a+24>>2]=c;c=yh(b+12|0)|0;f[a+28>>2]=c;c=yh(b+16|0)|0;f[a+32>>2]=c;c=yh(b+20|0)|0;f[a+36>>2]=c;c=yh(b+24|0)|0;f[a+40>>2]=c;b=yh(b+28|0)|0;f[a+44>>2]=b;return}function Vc(a,b){a=a|0;b=b|0;var c=0,d=0;c=$f(f[a+72>>2]|0,f[a+72+4>>2]|0,3)|0;if((c&127)>>>0<112){if(112-(c&127)|0)qb(a+80+(c&127)|0,33456,112-(c&127)|0)|0}else{if(128-(c&127)|0)qb(a+80+(c&127)|0,33456,128-(c&127)|0)|0;ma(a,a+80|0,b,b+640|0);c=a+80|0;d=c+112|0;do{f[c>>2]=0;c=c+4|0}while((c|0)<(d|0))}Te(a+192|0,a+64|0,16);ma(a,a+80|0,b,b+640|0);return}function Wc(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;d=t;e=t=t+63&-64;t=t+48|0;Wb(a,b+40|0,b);Vb(a+40|0,b+40|0,b);pa(a+80|0,a,c+40|0);pa(a+40|0,a+40|0,c);pa(a+120|0,c+120|0,b+120|0);pa(a,b+80|0,c+80|0);Wb(e,a,a);Vb(a,a+80|0,a+40|0);Wb(a+40|0,a+80|0,a+40|0);Vb(a+80|0,e,a+120|0);Wb(a+120|0,e,a+120|0);t=d;return}function Xc(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;d=t;e=t=t+63&-64;t=t+48|0;Wb(a,b+40|0,b);Vb(a+40|0,b+40|0,b);pa(a+80|0,a,c);pa(a+40|0,a+40|0,c+40|0);pa(a+120|0,c+120|0,b+120|0);pa(a,b+80|0,c+80|0);Wb(e,a,a);Vb(a,a+80|0,a+40|0);Wb(a+40|0,a+80|0,a+40|0);Wb(a+80|0,e,a+120|0);Vb(a+120|0,e,a+120|0);t=d;return}function Yc(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,i=0;f=h[a+7>>0]|0;g=Wf(h[a+6>>0]|0|0,0,8)|0;i=G;e=Wf(h[a+5>>0]|0|0,0,16)|0;i=i|G;d=Wf(h[a+4>>0]|0|0,0,24)|0;i=i|G|(h[a+3>>0]|0);c=Wf(h[a+2>>0]|0|0,0,40)|0;i=i|G;b=Wf(h[a+1>>0]|0|0,0,48)|0;i=i|G;a=Wf(h[a>>0]|0|0,0,56)|0;G=i|G;return g|f|e|d|c|b|a|0}function Zc(a,b){a=a|0;b=b|0;var c=0,d=0;d=t;c=t=t+63&-64;t=t+256|0;if(((Zb(b)|0)==0?(Eb(c+88|0,b)|0)==0:0)?(Df(c+88|0)|0)!=0:0){Bg(c);Vb(c,c,c+88+40|0);Za(c,c);Bg(c+48|0);Wb(c+48|0,c+48|0,c+88+40|0);pa(c+48|0,c+48|0,c);rb(a,c+48|0);a=0}else a=-1;t=d;return a|0}function _c(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;d=t;e=t=t+63&-64;t=t+48|0;Wb(a,b+40|0,b);Vb(a+40|0,b+40|0,b);pa(a+80|0,a,c+40|0);pa(a+40|0,a+40|0,c);pa(a+120|0,c+80|0,b+120|0);Wb(e,b+80|0,b+80|0);Vb(a,a+80|0,a+40|0);Wb(a+40|0,a+80|0,a+40|0);Vb(a+80|0,e,a+120|0);Wb(a+120|0,e,a+120|0);t=d;return}function $c(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;d=t;e=t=t+63&-64;t=t+48|0;Wb(a,b+40|0,b);Vb(a+40|0,b+40|0,b);pa(a+80|0,a,c);pa(a+40|0,a+40|0,c+40|0);pa(a+120|0,c+80|0,b+120|0);Wb(e,b+80|0,b+80|0);Vb(a,a+80|0,a+40|0);Wb(a+40|0,a+80|0,a+40|0);Wb(a+80|0,e,a+120|0);Vb(a+120|0,e,a+120|0);t=d;return}function ad(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;e=t;d=t=t+63&-64;t=t+800|0;if((((Hb(d+640|0,b)|0)==0?(cd(d+640|0)|0)!=0:0)?(Hb(d+480|0,c)|0)==0:0)?(cd(d+480|0)|0)!=0:0){If(d,d+480|0);Wc(d+160|0,d+640|0,d);wf(d+320|0,d+160|0);Pd(a,d+320|0);a=0}else a=-1;t=e;return a|0}function bd(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;e=t;d=t=t+63&-64;t=t+800|0;if((((Hb(d+640|0,b)|0)==0?(cd(d+640|0)|0)!=0:0)?(Hb(d+480|0,c)|0)==0:0)?(cd(d+480|0)|0)!=0:0){If(d,d+480|0);Xc(d+160|0,d+640|0,d);wf(d+320|0,d+160|0);Pd(a,d+320|0);a=0}else a=-1;t=e;return a|0}function cd(a){a=a|0;var b=0,c=0;b=t;c=t=t+63&-64;t=t+288|0;ua(c+240|0,a);ua(c+192|0,a+40|0);ua(c+144|0,a+80|0);Vb(c+48|0,c+192|0,c+240|0);pa(c+48|0,c+48|0,c+144|0);pa(c,c+240|0,c+192|0);pa(c,c,16);ua(c+96|0,c+144|0);Wb(c,c,c+96|0);Vb(c+48|0,c+48|0,c);a=Mf(c+48|0)|0;t=b;return a|0}function dd(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var f=0,g=0;if(!(e>>>0<2147483647&e<<1>>>0<c>>>0))Fj();if(!e)c=0;else{c=0;do{g=h[d+c>>0]|0;f=c<<1;b[a+f>>0]=(g>>>4)+87+(((g>>>4)+65526|0)>>>8&217);b[a+(f|1)>>0]=(((g&15)<<8)+22272+((g&15)+65526&55552)|0)>>>8;c=c+1|0}while((c|0)!=(e|0));c=e<<1}b[a+c>>0]=0;return a|0}function ed(a,c){a=a|0;c=c|0;var d=0,e=0,g=0;e=t;g=t=t+63&-64;t=t+64|0;if((c+-1&255)>63)Fj();else{b[g>>0]=c;b[g+1>>0]=0;b[g+2>>0]=1;b[g+3>>0]=1;Dh(g+4|0);We(g+8|0,0,0);c=g+16|0;d=c+48|0;do{f[c>>2]=0;c=c+4|0}while((c|0)<(d|0));ie(a,g);t=e;return}}function fd(a,c){a=a|0;c=c|0;var d=0,e=0,f=0;e=t;f=t=t+63&-64;t=t+208|0;d=0;do{b[a+d>>0]=b[c+d>>0]|0;d=d+1|0}while((d|0)!=32);b[a>>0]=b[a>>0]&-8;b[a+31>>0]=b[a+31>>0]&63|64;ub(f+40|0,a);Re(f,f+40+40|0,f+40+80|0);rb(a,f);t=e;return 0}function gd(a,b,c,d,e,g,h,i,j,k,l){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;l=l|0;if(e>>>0>0|(e|0)==0&d>>>0>4294967279)Fj();oc(a,a+d|0,0,c,d,e,g,h,i,0,k,l)|0;if(b|0){k=Lg(d|0,e|0,16,0)|0;f[b>>2]=k;f[b+4>>2]=G}return 0}function hd(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0;e=t;g=t=t+63&-64;t=t+16|0;f[g+4>>2]=a;f[g>>2]=c;b[g+8>>0]=0;if(d|0){a=0;do{b[g+8>>0]=b[g+8>>0]|b[(f[g>>2]|0)+a>>0]^b[(f[g+4>>2]|0)+a>>0];a=a+1|0}while((a|0)!=(d|0))}t=e;return (((h[g+8>>0]|0)+511|0)>>>8&1)+-1|0}function id(a,b,c,d,e,g,h,i,j,k,l){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;l=l|0;if(e>>>0>0|(e|0)==0&d>>>0>4294967279)Fj();Ib(a,a+d|0,0,c,d,e,g,h,i,0,k,l)|0;if(b|0){k=Lg(d|0,e|0,16,0)|0;f[b>>2]=k;f[b+4>>2]=G}return 0}function jd(a,c,d){a=a|0;c=c|0;d=d|0;var e=0;b[a+7>>0]=c;e=$f(c|0,d|0,8)|0;b[a+6>>0]=e;e=$f(c|0,d|0,16)|0;b[a+5>>0]=e;e=$f(c|0,d|0,24)|0;b[a+4>>0]=e;b[a+3>>0]=d;e=$f(c|0,d|0,40)|0;b[a+2>>0]=e;e=$f(c|0,d|0,48)|0;b[a+1>>0]=e;d=$f(c|0,d|0,56)|0;b[a>>0]=d;return}function kd(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;var g=0,h=0;h=t;g=t=t+63&-64;t=t+32|0;if(d>>>0<0|(d|0)==0&c>>>0<48)a=-1;else{c=Lg(c|0,d|0,-32,-1)|0;d=G;le(g,b,e);a=_d(a,b+32|0,c,d,g,b,f)|0}t=h;return a|0}function ld(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var i=0,j=0;j=t;i=t=t+63&-64;t=t+32|0;if(!(ne(i,g,h)|0)){a=mf(a,b,c,d,e,f,i)|0;ye(i,32)}else a=-1;t=j;return a|0}function md(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var i=0,j=0;j=t;i=t=t+63&-64;t=t+32|0;if(!(ne(i,g,h)|0)){qf(a,b,c,d,e,f,i)|0;ye(i,32);a=0}else a=-1;t=j;return a|0}function nd(a,b,c,d,e,g,h,i,j,k,l){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;l=l|0;if(e>>>0>0|(e|0)==0&d>>>0>4294967279)Fj();Xb(a,a+d|0,0,c,d,e,g,h,i,0,k,l)|0;if(b|0){k=Lg(d|0,e|0,16,0)|0;f[b>>2]=k;f[b+4>>2]=G}return 0}function od(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var i=0,j=0;i=t;j=t=t+63&-64;t=t+80|0;if(!((c|0)==0&(d|0)==0)){Qg(j+64|0,f);Qg(j+64+4|0,g);Uc(j,h);je(j,e,j+64|0);za(j,b,a,c,d);ye(j,64)}t=i;return 0}function pd(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0;e=t;g=t=t+63&-64;t=t+16|0;f[g+8>>2]=a;f[g+4>>2]=c;f[g>>2]=0;a=0;do{f[g>>2]=f[g>>2]|(b[(f[g+4>>2]|0)+a>>0]^b[(f[g+8>>2]|0)+a>>0])&255;a=a+1|0}while((a|0)!=(d|0));t=e;return (((f[g>>2]|0)+511|0)>>>8&1)+-1|0}function qd(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,f=0;e=b[a>>0]|0;a:do if(!(e<<24>>24))e=0;else while(1){d=d+-1|0;f=b[c>>0]|0;if(!(e<<24>>24==f<<24>>24&((d|0)!=0&f<<24>>24!=0)))break a;a=a+1|0;c=c+1|0;e=b[a>>0]|0;if(!(e<<24>>24)){e=0;break}}while(0);return (e&255)-(h[c>>0]|0)|0}function rd(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0;h=t;e=t=t+63&-64;t=t+16|0;g=0;d=0;while(1){if(Og(e,b[c>>0]|0)|0){d=3;break}c=c+1|0;g=f[e>>2]<<d|g;d=d+6|0;if(d>>>0>=30){d=5;break}}if((d|0)==3){f[a>>2]=0;c=0}else if((d|0)==5)f[a>>2]=g;t=h;return c|0}function sd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0;ig(c,a+((d<<5)+-16<<2)|0);if(d<<1|0){e=0;do{g=e<<4;zf(c,a+(g<<2)|0);Ea(c);f=e<<3;ig(b+(f<<2)|0,c);zf(c,a+((g|16)<<2)|0);Ea(c);ig(b+(f+(d<<4)<<2)|0,c);e=e+2|0}while(e>>>0<d<<1>>>0)}return}function td(a,c){a=a|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0;f=t;g=t=t+63&-64;t=t+16|0;e=10;while(1){h=c;c=(c>>>0)/10|0;i=(h+(V(c,-10)|0)|48)&255;d=e+-1|0;b[g+d>>0]=i;if(!(h>>>0>9&(d|0)!=0))break;else e=d}i=11-e|0;qb(a|0,g+d|0,i|0)|0;b[a+i>>0]=0;t=f;return}function ud(a,b){a=a|0;b=b|0;var c=0,d=0;c=t;d=t=t+63&-64;t=t+48|0;ua(a,b);ua(a+80|0,b+40|0);ta(a+120|0,b+80|0);Wb(a+40|0,b,b+40|0);ua(d,a+40|0);Wb(a+40|0,a+80|0,a);Vb(a+80|0,a+80|0,a);Vb(a,d,a+40|0);Vb(a+120|0,a+120|0,a+80|0);t=c;return}function vd(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,f=0;f=t;e=t=t+63&-64;t=t+16|0;b[e>>0]=0;if(!(Ya(a,c,d)|0)){c=0;do{b[e>>0]=b[e>>0]|b[a+c>>0];c=c+1|0}while((c|0)!=32);c=0-(((h[e>>0]|0)+511|0)>>>8&1)|0}else c=-1;t=f;return c|0}function wd(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;do if(!(c>>>0>64|(d+-1|0)>>>0>63))if((b|0)==0|(c|0)==0){bc(a,d&255,e,f);a=0;break}else{yb(a,d&255,b,c&255,e,f);a=0;break}else a=-1;while(0);return a|0}function xd(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0;g=t;h=t=t+63&-64;t=t+64|0;He(h,d,32,0)|0;d=c;e=h;f=d+32|0;do{b[d>>0]=b[e>>0]|0;d=d+1|0;e=e+1|0}while((d|0)<(f|0));ye(h,64);h=Jh(a,c)|0;t=g;return h|0}function yd(a,c,d,e,f,g){a=a|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;if(e>>>0<0|(e|0)==0&d>>>0<32)a=-1;else{kg(a,c,d,e,f,g)|0;c=Lg(d|0,e|0,-32,-1)|0;Eg(a+16|0,a+32|0,c,G,a)|0;c=a+16|0;do{b[a>>0]=0;a=a+1|0}while((a|0)<(c|0));a=0}return a|0}function zd(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0;e=0;g=a;while(1){a=0;d=0;do{f=e;e=e+1|0;d=(h[c+f>>0]|0)<<a|d;a=a+8|0;f=e>>>0<32}while(f&a>>>0<24);a=Ed(g,b,d,a)|0;if(!a){a=0;break}b=b+g-a|0;if(!f)break;else g=a}return a|0}function Ad(a,b,c,d,e,g,h,i,j,k,l){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;l=l|0;switch(l|0){case 1:{a=dc(a,b,c,d,e,g,h,i,j,k,1)|0;break}case 2:{a=fc(a,b,c,d,e,g,h,i,j,k,2)|0;break}default:{f[9002]=22;a=-1}}return a|0}function Bd(a,c){a=a|0;c=c|0;var d=0,e=0,f=0;e=t;f=t=t+63&-64;t=t+64|0;He(f,c,32,0)|0;b[f>>0]=b[f>>0]&-8;b[f+31>>0]=b[f+31>>0]&63|64;c=f;d=a+32|0;do{b[a>>0]=b[c>>0]|0;a=a+1|0;c=c+1|0}while((a|0)<(d|0));ye(f,64);t=e;return 0}function Cd(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;var g=0,h=0;h=t;g=t=t+63&-64;t=t+32|0;if(d>>>0<0|(d|0)==0&c>>>0<48)a=-1;else{c=Lg(c|0,d|0,-32,-1)|0;d=G;le(g,b,e);a=ve(a,b+32|0,c,d,g,b,f)|0}t=h;return a|0}function Dd(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0;h=t;i=t=t+63&-64;t=t+80|0;if(!((c|0)==0&(d|0)==0)){Qg(i+64|0,f);Uc(i,g);Be(i,e,i+64|0);za(i,b,a,c,d);ye(i,64)}t=h;return 0}function Ed(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var f=0,g=0;a:do if(e){f=0;while(1){if(!c){a=0;break a}g=a+1|0;b[a>>0]=b[35349+(d&63)>>0]|0;f=f+6|0;if(f>>>0>=e>>>0){a=g;break}else{d=d>>>6;c=c+-1|0;a=g}}}while(0);return a|0}function Fd(a,c){a=a|0;c=c|0;var d=0,e=0,f=0;e=t;f=t=t+63&-64;t=t+160|0;d=0;do{b[a+d>>0]=b[c+d>>0]|0;d=d+1|0}while((d|0)!=32);rh(a);ub(f,a);Pd(a,f);f=((ge(c,32)|0)!=0)<<31>>31;t=e;return f|0}function Gd(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;d=Lg(f[a+64>>2]|0,f[a+64+4>>2]|0,b|0,c|0)|0;e=G;f[a+64>>2]=d;f[a+64+4>>2]=e;c=Lg(f[a+72>>2]|0,f[a+72+4>>2]|0,(e>>>0<c>>>0|(e|0)==(c|0)&d>>>0<b>>>0)&1|0,0)|0;f[a+72>>2]=c;f[a+72+4>>2]=G;return}function Hd(a,b,c,d,e,f,g,h,i,j){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;var k=0,l=0;k=t;l=t=t+63&-64;t=t+16|0;zi(l);j=hb(l,a,b,c,d,e,f,g,h,i,j)|0;Ai(l);t=k;return j|0}function Id(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0;i=t;h=t=t+63&-64;t=t+32|0;if(!(oe(h,f,g)|0)){a=ng(a,b,c,d,e,h)|0;ye(h,32)}else a=-1;t=i;return a|0}function Jd(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,f=0;e=t;f=t=t+63&-64;t=t+160|0;He(c,d,32,0)|0;b[c>>0]=b[c>>0]&-8;b[c+31>>0]=b[c+31>>0]&63|64;ub(f,c);Pd(a,f);se(c|0,d|0,32)|0;se(c+32|0,a|0,32)|0;t=e;return 0}function Kd(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0;i=t;h=t=t+63&-64;t=t+32|0;if(!(oe(h,f,g)|0)){a=xg(a,b,c,d,e,h)|0;ye(h,32)}else a=-1;t=i;return a|0}function Ld(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var i=0,j=0;i=t;j=t=t+63&-64;t=t+32|0;La(j,e,h,0)|0;h=Ef(a,b,c,d,e+16|0,f,g,j)|0;ye(j,32);t=i;return h|0}function Md(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;do if(qd(a,34372,10)|0)if(!(qd(a,34383,9)|0)){a=ih(a,b,c,d)|0;break}else{f[9002]=22;a=-1;break}else a=fh(a,b,c,d)|0;while(0);return a|0}function Nd(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0;f=t;g=t=t+63&-64;t=t+64|0;if(!((b|0)==0&(c|0)==0)){Uc(g,e);Be(g,d,0);ec(a|0,0,b|0)|0;za(g,a,a,b,c);ye(g,64)}t=f;return 0}function Od(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;a:do if(d>>>0>0|(d|0)==0&c>>>0>4294967295){f[9002]=27;a=-1}else{switch($h(a,b,c)|0){case 0:{a=0;break a}case -35:{f[9002]=22;break}default:{}}a=-1}while(0);return a|0}function Pd(a,c){a=a|0;c=c|0;var d=0,e=0;d=t;e=t=t+63&-64;t=t+144|0;Za(e+96|0,c+80|0);pa(e+48|0,c,e+96|0);pa(e,c+40|0,e+96|0);rb(a,e);c=(Xf(e+48|0)|0)<<7;b[a+31>>0]=c^(h[a+31>>0]|0);t=d;return}function Qd(a){a=a|0;var b=0,c=0;c=t;b=t=t+63&-64;t=t+160|0;if((((hf(a)|0)!=0?(Zb(a)|0)==0:0)?(Hb(b,a)|0)==0:0)?(cd(b)|0)!=0:0)a=(Df(b)|0)!=0&1;else a=0;t=c;return a|0}function Rd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;a:do if(d>>>0>0|(d|0)==0&c>>>0>4294967295){f[9002]=27;a=-1}else{switch(ai(a,b,c)|0){case 0:{a=0;break a}case -35:{f[9002]=22;break}default:{}}a=-1}while(0);return a|0}function Sd(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var i=0;switch(h|0){case 1:{i=uc(a,b,c,d,e,f,g)|0;break}case 2:{i=xc(a,b,c,d,e,f,g)|0;break}default:Fj()}return i|0}function Td(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;do if(!(c>>>0>64|(d+-1|0)>>>0>63))if((b|0)==0|(c|0)==0){ed(a,d&255);a=0;break}else{gc(a,d&255,b,c&255);a=0;break}else a=-1;while(0);return a|0}function Ud(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0;f=t;g=t=t+63&-64;t=t+64|0;if(!((b|0)==0&(c|0)==0)){Uc(g,e);je(g,d,0);ec(a|0,0,b|0)|0;za(g,a,a,b,c);ye(g,64)}t=f;return 0}function Vd(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var i=0,j=0;i=t;j=t=t+63&-64;t=t+32|0;Ha(j,e,h,0)|0;h=Gf(a,b,c,d,e+16|0,f,g,j)|0;t=i;return h|0}function Wd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;d=t;c=t=t+63&-64;t=t+16|0;e=Uf(c,b)|0;f[9002]=e;if(!e)c=f[c>>2]|0;else{f[c>>2]=0;c=0}f[a>>2]=c;f[a+4>>2]=c;f[a+8>>2]=(c|0)==0?0:b;t=d;return c|0}function Xd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;do if(qd(a,34372,10)|0)if(!(qd(a,34383,9)|0)){a=Rd(a,b,c,d)|0;break}else{f[9002]=22;a=-1;break}else a=Od(a,b,c,d)|0;while(0);return a|0}function Yd(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var i=0;i=t;t=t+32|0;if(!(qh(i,g,h)|0)){a=Pf(a,b,c,d,e,f,i)|0;ye(i,32)}else a=-1;t=i;return a|0}function Zd(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var i=0;i=t;t=t+32|0;if(!(qh(i,g,h)|0)){Tf(a,b,c,d,e,f,i)|0;ye(i,32);a=0}else a=-1;t=i;return a|0}function _d(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;if(d>>>0<0|(d|0)==0&c>>>0<16)a=-1;else{d=Lg(c|0,d|0,-16,-1)|0;a=ld(a,b+16|0,b,d,G,e,f,g)|0}return a|0}function $d(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var f=0;if(((((b[a>>0]|0)==36?(b[a+1>>0]|0)==55:0)?(b[a+2>>0]|0)==36:0)?(Og(c,b[a+3>>0]|0)|0)==0:0)?(f=rd(d,a+4|0)|0,(f|0)!=0):0)a=rd(e,f)|0;else a=0;return a|0}function ae(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;if(d>>>0<0|(d|0)==0&c>>>0<16)a=-1;else{d=Lg(c|0,d|0,-16,-1)|0;a=mf(a,b+16|0,b,d,G,e,f)|0}return a|0}function be(a){a=a|0;var b=0;b=f[r>>2]|0;if((a|0)>0&(b+a|0)<(b|0)|(b+a|0)<0){ba()|0;da(12);return -1}f[r>>2]=b+a;if((b+a|0)>(aa()|0)?($()|0)==0:0){f[r>>2]=b;da(12);return -1}return b|0}function ce(a){a=a|0;var c=0,d=0,e=0,f=0,g=0;d=32;c=1;e=0;while(1){d=d+-1|0;f=b[a+d>>0]|0;g=b[32320+d>>0]|0;c=c&255;e=(f&255)-(g&255)>>8&c|e&255;if(!d)break;else c=(((g^f)&255)+65535|0)>>>8&c}return (e|0)!=0|0}function de(a){a=a|0;f[a+32>>2]=0;f[a+32+4>>2]=0;f[a>>2]=f[8100];f[a+4>>2]=f[8101];f[a+8>>2]=f[8102];f[a+12>>2]=f[8103];f[a+16>>2]=f[8104];f[a+20>>2]=f[8105];f[a+24>>2]=f[8106];f[a+28>>2]=f[8107];return 0}function ee(){}function fe(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=V(b&65535,a&65535)|0;e=(c>>>16)+(V(b&65535,a>>>16)|0)|0;d=V(b>>>16,a&65535)|0;return (G=(e>>>16)+(V(b>>>16,a>>>16)|0)+(((e&65535)+d|0)>>>16)|0,e+d<<16|c&65535|0)|0}function ge(a,c){a=a|0;c=c|0;var d=0,e=0,f=0;e=t;f=t=t+63&-64;t=t+16|0;b[f>>0]=0;d=0;do{b[f>>0]=b[f>>0]|b[a+d>>0];d=d+1|0}while((d|0)!=(c|0));t=e;return ((h[f>>0]|0)+511|0)>>>8&1|0}function he(a,b,c,d,e,f,g,h,i){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;if((b+-1|0)>>>0>63|g>>>0>64)a=-1;else{kc(a,c,f,b&255,d,e,g&255,h,i);a=0}return a|0}function ie(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0;vf(a);c=0;do{g=tf(b+(c<<3)|0)|0;d=a+(c<<3)|0;e=f[d+4>>2]^G;f[d>>2]=f[d>>2]^g;f[d+4>>2]=e;c=c+1|0}while((c|0)!=8);return}function je(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;if(!c){f[a+48>>2]=0;c=0}else{d=yh(c)|0;f[a+48>>2]=d;c=yh(c+4|0)|0}f[a+52>>2]=c;d=yh(b)|0;f[a+56>>2]=d;d=yh(b+4|0)|0;f[a+60>>2]=d;return}function ke(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;if(d>>>0<0|(d|0)==0&c>>>0<16)a=-1;else{d=Lg(c|0,d|0,-16,-1)|0;a=nb(a,b+16|0,b,d,G,e,f)|0}return a|0}function le(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;d=t;e=t=t+63&-64;t=t+384|0;jh(e,0,0,24)|0;Yg(e,b,32,0)|0;Yg(e,c,32,0)|0;Bh(e,a,24)|0;t=d;return}function me(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0;f=t;g=t=t+63&-64;t=t+32|0;La(g,d,e,0)|0;e=ch(a,b,c,d+16|0,g)|0;ye(g,32);t=f;return e|0}function ne(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;e=t;d=t=t+63&-64;t=t+32|0;if(!(vd(d,c,b)|0)){Ha(a,35488,d,0)|0;a=0}else a=-1;t=e;return a|0}function oe(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;e=t;d=t=t+63&-64;t=t+32|0;if(!(vd(d,c,b)|0)){La(a,35440,d,0)|0;a=0}else a=-1;t=e;return a|0}function pe(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0;f=t;t=t+32|0;Me(f,b,c,d,e)|0;e=ji(a,f)|0;e=((f|0)==(a|0)?-1:e)|(hd(f,a,32)|0);t=f;return e|0}function qe(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;if(d>>>0>0|(d|0)==0&c>>>0>4294967279)Fj();else return md(a+16|0,a,b,c,d,e,f,g)|0;return 0}function re(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;if(d>>>0>0|(d|0)==0&c>>>0>4294967279)Fj();else{qf(a+16|0,a,b,c,d,e,f)|0;return 0}return 0}function se(a,c,d){a=a|0;c=c|0;d=d|0;var e=0;if((c|0)<(a|0)&(a|0)<(c+d|0)){e=a;c=c+d|0;a=a+d|0;while((d|0)>0){a=a-1|0;c=c-1|0;d=d-1|0;b[a>>0]=b[c>>0]|0}a=e}else qb(a,c,d)|0;return a|0}function te(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0;f=t;t=t+64|0;Le(f,b,c,d,e)|0;e=ii(a,f)|0;e=((f|0)==(a|0)?-1:e)|(hd(f,a,64)|0);t=f;return e|0}function ue(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0;f=t;t=t+32|0;Je(f,b,c,d,e)|0;e=ji(a,f)|0;e=((f|0)==(a|0)?-1:e)|(hd(f,a,32)|0);t=f;return e|0}function ve(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;if(d>>>0<0|(d|0)==0&c>>>0<16)a=-1;else{d=Lg(c|0,d|0,-16,-1)|0;a=Yd(a,b+16|0,b,d,G,e,f,g)|0}return a|0}function we(a){a=a|0;var b=0,c=0,d=0,e=0;c=h[a>>0]|0;d=Wf(h[a+1>>0]|0|0,0,8)|0;e=G;b=Wf(h[a+2>>0]|0|0,0,16)|0;e=e|G;a=Wf(h[a+3>>0]|0|0,0,24)|0;G=e|G;return d|c|b|a|0}function xe(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0;f=t;g=t=t+63&-64;t=t+16|0;Ke(g,b,c,d,e)|0;e=ki(a,g)|0;t=f;return e|0}function ye(a,c){a=a|0;c=c|0;var d=0,e=0;d=t;e=t=t+63&-64;t=t+16|0;f[e>>2]=a;if(c|0){a=0;do{b[(f[e>>2]|0)+a>>0]=0;a=a+1|0}while((a|0)!=(c|0))}t=d;return}function ze(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;if(d>>>0<0|(d|0)==0&c>>>0<16)a=-1;else{d=Lg(c|0,d|0,-16,-1)|0;a=Pf(a,b+16|0,b,d,G,e,f)|0}return a|0}function Ae(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0;c=0;do{g=b+(c<<3)|0;d=a+(c<<3)|0;e=f[d+4>>2]^f[g+4>>2];f[d>>2]=f[d>>2]^f[g>>2];f[d+4>>2]=e;c=c+1|0}while((c|0)!=128);return}function Be(a,b,c){a=a|0;b=b|0;c=c|0;if(!c)c=0;else c=yh(c)|0;f[a+48>>2]=c;c=yh(b)|0;f[a+52>>2]=c;c=yh(b+4|0)|0;f[a+56>>2]=c;b=yh(b+8|0)|0;f[a+60>>2]=b;return}function Ce(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0;f=t;g=t=t+63&-64;t=t+32|0;Ha(g,d,e,0)|0;e=hh(a,b,c,d+16|0,g)|0;t=f;return e|0}function De(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;if(d>>>0<0|(d|0)==0&c>>>0<16)a=-1;else{d=Lg(c|0,d|0,-16,-1)|0;a=pb(a,b+16|0,b,d,G,e,f)|0}return a|0}function Ee(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;if(d>>>0>0|(d|0)==0&c>>>0>4294967279)Fj();else{bb(a+16|0,a,b,c,d,e,f)|0;return 0}return 0}function Fe(a,c){a=a|0;c=c|0;var d=0,e=0;e=t;t=t+64|0;Ue(a,e)|0;a=e;d=c+32|0;do{b[c>>0]=b[a>>0]|0;c=c+1|0;a=a+1|0}while((c|0)<(d|0));t=e;return 0}function Ge(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0;f=Lg(c|0,d|0,a|0,b|0)|0;e=G;d=Wf(a|0,b|0,1)|0;d=Af(d&-2|0,G&1|0,c|0,0)|0;d=Lg(f|0,e|0,d|0,G|0)|0;return d|0}function He(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0;e=t;f=t=t+63&-64;t=t+208|0;Ne(f)|0;Ja(f,b,c,d)|0;df(f,a)|0;t=e;return 0}function Ie(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0;e=t;f=t=t+63&-64;t=t+112|0;de(f)|0;Pa(f,b,c,d)|0;gf(f,a)|0;t=e;return 0}function Je(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0;f=t;t=t+208|0;Bb(f,e,32)|0;bh(f,b,c,d)|0;Ve(f,a)|0;t=f;return 0}function Ke(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0;f=t;g=t=t+63&-64;t=t+96|0;ic(g,e);Ra(g,b,c,d);ab(g,a);t=f;return 0}function Le(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0;f=t;t=t+416|0;Ab(f,e,32)|0;eh(f,b,c,d)|0;Ue(f,a)|0;t=f;return 0}function Me(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0;f=t;t=t+416|0;wh(f,e,32)|0;lh(f,b,c,d)|0;Fe(f,a)|0;t=f;return 0}function Ne(a){a=a|0;var b=0,c=0;f[a+64>>2]=0;f[a+64+4>>2]=0;f[a+64+8>>2]=0;f[a+64+12>>2]=0;b=32752;c=a+64|0;do{f[a>>2]=f[b>>2];a=a+4|0;b=b+4|0}while((a|0)<(c|0));return 0}function Oe(a,c){a=a|0;c=c|0;var d=0;a:do if(!c)c=0;else{d=c;while(1){d=d+-1|0;c=a+d|0;if((b[c>>0]|0)==36)break a;if(!d){c=0;break}}}while(0);return c|0}function Pe(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0;e=t;f=t=t+63&-64;t=t+64|0;df(a,f)|0;Mb(b,c,f,64,0,d,1);t=e;return 0}function Qe(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;d=t;e=t=t+63&-64;t=t+64|0;df(a,e)|0;c=Pb(b,e,64,0,c,1)|0;t=d;return c|0}function Re(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;d=t;e=t=t+63&-64;t=t+96|0;Wb(e+48|0,c,b);Vb(e,c,b);Za(e,e);pa(a,e+48|0,e);t=d;return}function Se(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;if((b+-1|0)>>>0>63|g>>>0>64)a=-1;else{Ac(a,c,f,b&255,d,e,g&255);a=0}return a|0}function Te(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;if(c>>>3|0){d=0;do{e=b+(d<<3)|0;jd(a+(d<<3)|0,f[e>>2]|0,f[e+4>>2]|0);d=d+1|0}while((d|0)!=(c>>>3|0))}return}function Ue(a,b){a=a|0;b=b|0;var c=0;c=t;t=t+64|0;df(a,c)|0;Ja(a+208|0,c,64,0)|0;df(a+208|0,b)|0;ye(c,64);t=c;return 0}function Ve(a,b){a=a|0;b=b|0;var c=0;c=t;t=t+32|0;gf(a,c)|0;Pa(a+104|0,c,32,0)|0;gf(a+104|0,b)|0;ye(c,32);t=c;return 0}function We(a,c,d){a=a|0;c=c|0;d=d|0;b[a>>0]=c;b[a+1>>0]=c>>8;b[a+2>>0]=c>>16;b[a+3>>0]=c>>24;b[a+4>>0]=d;b[a+4+1>>0]=d>>8;b[a+4+2>>0]=d>>16;b[a+4+3>>0]=d>>24;return}function Xe(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;if(d>>>0>0|(d|0)==0&c>>>0>4294967279)Fj();else return Zd(a+16|0,a,b,c,d,e,f,g)|0;return 0}function Ye(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;if(d>>>0>0|(d|0)==0&c>>>0>4294967279)Fj();else{Tf(a+16|0,a,b,c,d,e,f)|0;return 0}return 0}function Ze(a){a=a|0;return (0-(a^62)|0)>>>8&45^45|(a+65510|0)>>>8&255&a+65|(0-(a^63)|0)>>>8&95^95|(a+65484|0)>>>8&a+71&((a+65510|0)>>>8&255^255)|(a+65474|0)>>>8&a+252&((a+65484|0)>>>8&255^255)|0}function _e(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;if(d>>>0>0|(d|0)==0&c>>>0>4294967279)Fj();else{db(a+16|0,a,b,c,d,e,f)|0;return 0}return 0}function $e(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;if(c>>>2|0){d=0;do{e=a+(d<<2)|0;f[e>>2]=f[e>>2]^f[b+(d<<2)>>2];d=d+1|0}while((d|0)!=(c>>>2|0))}return}function af(a){a=a|0;return (0-(a^62)|0)>>>8&43^43|(a+65510|0)>>>8&255&a+65|(0-(a^63)|0)>>>8&47^47|(a+65484|0)>>>8&a+71&((a+65510|0)>>>8&255^255)|(a+65474|0)>>>8&a+252&((a+65484|0)>>>8&255^255)|0}function bf(a,b){a=a|0;b=b|0;var c=0,d=0;c=t;d=t=t+63&-64;t=t+32|0;uf(d,32);Jd(a,b,d)|0;ye(d,32);t=c;return 0}function cf(a,b){a=a|0;b=b|0;if(b|0){b=f[a>>2]|0;if(b|0)ye(f[b+4>>2]|0,f[a+16>>2]<<10);b=f[a+4>>2]|0;if(b|0)ye(b,f[a+20>>2]<<3)}return}function df(a,b){a=a|0;b=b|0;var c=0,d=0;c=t;d=t=t+63&-64;t=t+704|0;Vc(a,d);Te(b,a,64);ye(d,704);ye(a,208);t=c;return 0}function ef(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=0;do{e=Yc(b+(c<<3)|0)|0;d=a+(c<<3)|0;f[d>>2]=e;f[d+4>>2]=G;c=c+1|0}while((c|0)!=16);return}function ff(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=0;do{e=tf(b+(c<<3)|0)|0;d=a+(c<<3)|0;f[d>>2]=e;f[d+4>>2]=G;c=c+1|0}while((c|0)!=128);return}function gf(a,b){a=a|0;b=b|0;var c=0,d=0;c=t;d=t=t+63&-64;t=t+288|0;Gc(a,d);Vf(b,a);ye(d,288);ye(a,104);t=c;return 0}function hf(a){a=a|0;var c=0,d=0;c=b[a+31>>0]&127^127;d=30;do{c=c|~b[a+d>>0];d=d+-1|0}while((d|0)!=0);return (236-(h[a>>0]|0)&(c&255)+511)>>>8&1^1|0}function jf(a){a=a|0;var c=0,d=0;c=1;d=b[a>>0]^1;do{d=b[a+c>>0]|d;c=c+1|0}while((c|0)!=31);return (((b[a+31>>0]&127|d)&255)+511|0)>>>8&1|0}function kf(a){a=a|0;var b=0;if(a>>>0<2)a=0;else{do b=Hi()|0;while(b>>>0<(((0-a|0)>>>0)%(a>>>0)|0)>>>0);a=(b>>>0)%(a>>>0)|0}return a|0}function lf(a,b){a=a|0;b=b|0;var c=0;Sh(b);c=(V((a>>>0)/3|0,-3)|0)+a|0;return (((a>>>0)/3|0)<<2|1)+(4-(3-c&0-(b>>>1&1))&0-((c>>>1|c)&1))|0}function mf(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;return nb(a,b,c,d,e,f,g)|0}function nf(a,b,c){a=a|0;b=b|0;c=c|0;Fb(a,b,c&255);Fb(a+40|0,b+40|0,c&255);Fb(a+80|0,b+80|0,c&255);Fb(a+120|0,b+120|0,c&255);return}function of(a){a=a|0;var c=0,d=0,e=0;d=0;c=1;while(1){e=a+d|0;c=c+(h[e>>0]|0)|0;b[e>>0]=c;d=d+1|0;if((d|0)==4)break;else c=c>>>8}return}function pf(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=t;t=t+16|0;Da(a,b,c,d,e|0)|0;t=e;return (G=f[e+4>>2]|0,f[e>>2]|0)|0}function qf(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;bb(a,b,c,d,e,f,g)|0;return 0}function rf(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;if(c>>>2|0){d=0;do{f[a+(d<<2)>>2]=f[b+(d<<2)>>2];d=d+1|0}while((d|0)!=(c>>>2|0))}return}function sf(a,b){a=a|0;b=b|0;var c=0,d=0;c=0;do{d=b+(c<<3)|0;We(a+(c<<3)|0,f[d>>2]|0,f[d+4>>2]|0);c=c+1|0}while((c|0)!=128);return}function tf(a){a=a|0;G=h[a+4>>0]|h[a+4+1>>0]<<8|h[a+4+2>>0]<<16|h[a+4+3>>0]<<24;return h[a>>0]|h[a+1>>0]<<8|h[a+2>>0]<<16|h[a+3>>0]<<24|0}function uf(a,c){a=a|0;c=c|0;var d=0,e=0;if(c|0){d=0;do{e=(Hi()|0)&255;b[a+d>>0]=e;d=d+1|0}while((d|0)!=(c|0))}return}function vf(a){a=a|0;var b=0,c=0,d=0;b=a;c=32752;d=b+64|0;do{f[b>>2]=f[c>>2];b=b+4|0;c=c+4|0}while((b|0)<(d|0));ec(a+64|0,0,293)|0;return}function wf(a,b){a=a|0;b=b|0;pa(a,b,b+120|0);pa(a+40|0,b+40|0,b+80|0);pa(a+80|0,b+80|0,b+120|0);pa(a+120|0,b,b+40|0);return}function xf(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;d=$f(a|0,b|0,c|0)|0;e=G;c=Wf(a|0,b|0,64-c|0)|0;G=G|e;return c|d|0}function yf(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;d=Wf(a|0,b|0,c|0)|0;e=G;c=$f(a|0,b|0,64-c|0)|0;G=G|e;return c|d|0}function zf(a,b){a=a|0;b=b|0;var c=0,d=0;c=0;do{d=a+(c<<2)|0;f[d>>2]=f[d>>2]^f[b+(c<<2)>>2];c=c+1|0}while((c|0)!=16);return}function Af(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0;e=fe(a,c)|0;f=G;return (G=(V(b,c)|0)+(V(d,a)|0)+f|f&0,e|0|0)|0}function Bf(a,b,c){a=a|0;b=b|0;c=c|0;if(c>>>0<256)return gb(a,b,c&255)|0;else ca(34168,34188,103,34241);return 0}function Cf(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;b=Wf(b&255|0,0,8)|0;d=G;c=Wf(c&255|0,0,16)|0;G=d|G;return b|a&255|c|0}function Df(a){a=a|0;var b=0,c=0;b=t;c=t=t+63&-64;t=t+160|0;cb(c,a);a=Mf(c)|0;t=b;return a|0}function Ef(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;return Ua(a,b,c,d,e,f,g,h)|0}function Ff(a,b){a=a|0;b=b|0;var c=0,d=0;c=0;do{d=$g(b+(c<<2)|0)|0;f[a+(c<<2)>>2]=d;c=c+1|0}while((c|0)!=16);return}function Gf(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;return od(a,b,c,d,e,f,g,h)|0}function Hf(a,c){a=a|0;c=c|0;var d=0;d=a+48|0;a=d+16|0;do{b[d>>0]=b[c>>0]|0;d=d+1|0;c=c+1|0}while((d|0)<(a|0));return}function If(a,b){a=a|0;b=b|0;Wb(a,b+40|0,b);Vb(a+40|0,b+40|0,b);Rc(a+80|0,b+80|0);pa(a+120|0,b+120|0,112);return}function Jf(a,b){a=a|0;b=b|0;var c=0,d=0;c=t;d=t=t+63&-64;t=t+128|0;Vg(d,b);ud(a,d);t=c;return}function Kf(a,c){a=a|0;c=c|0;var d=0;d=a+32|0;a=d+16|0;do{b[d>>0]=b[c>>0]|0;d=d+1|0;c=c+1|0}while((d|0)<(a|0));return}function Lf(){var a=0;a=ha(30)|0;if((a|0)>0)f[8877]=a;else a=f[8877]|0;if(a>>>0<16)Fj();else{uf(35472,16);return}}function Mf(a){a=a|0;var b=0,c=0;b=t;c=t=t+63&-64;t=t+32|0;rb(c,a);a=ge(c,32)|0;t=b;return a|0}function Nf(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){G=b>>c;return a>>>c|(b&(1<<c)-1)<<32-c}G=(b|0)<0?-1:0;return b>>c-32|0}function Of(a,c){a=a|0;c=c|0;var d=0,e=0;d=0;do{e=a+d|0;b[e>>0]=b[e>>0]^b[c+d>>0];d=d+1|0}while((d|0)!=8);return}function Pf(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;return pb(a,b,c,d,e,f,g)|0}function Qf(){var a=0,b=0;a=t;b=t=t+63&-64;t=t+16|0;Ih(b);if(f[b>>2]|0)Ih(b);t=a;return}function Rf(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;return Id(a,b,c,d,e,f,g)|0}function Sf(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;return Dd(a,b,c,d,e,f,g)|0}function Tf(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;db(a,b,c,d,e,f,g)|0;return 0}function Uf(a,b){a=a|0;b=b|0;var c=0;if(b>>>0<=4294967168?(c=Cb(b)|0,(c|0)!=0):0){f[a>>2]=c;a=0}else a=12;return a|0}function Vf(a,b){a=a|0;b=b|0;var c=0;c=0;do{Mg(a+(c<<2)|0,f[b+(c<<2)>>2]|0);c=c+1|0}while((c|0)!=8);return}function Wf(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){G=b<<c|(a&(1<<c)-1<<32-c)>>>32-c;return a<<c}G=a<<c-32;return 0}function Xf(a){a=a|0;var c=0,d=0;d=t;c=t=t+63&-64;t=t+32|0;rb(c,a);t=d;return b[c>>0]&1|0}function Yf(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;return Kd(a,b,c,d,e,f,g)|0}function Zf(a){a=a|0;var b=0;b=na(a)|0;if(!b)return b|0;if(!(f[b+-4>>2]&3))return b|0;ec(b|0,0,a|0)|0;return b|0}function _f(){var a=0;if(!(f[8876]|0)){qi();Gi();Lf();f[8876]=1;a=0}else a=1;return a|0}function $f(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){G=b>>>c;return a>>>c|(b&(1<<c)-1)<<32-c}G=0;return b>>>c-32|0}function ag(a,b,c){a=a|0;b=b|0;c=c|0;Fb(a,b,c&255);Fb(a+40|0,b+40|0,c&255);Fb(a+80|0,b+80|0,c&255);return}function bg(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;return Se(a,b,c,d,e,f,g)|0}function cg(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;return Db(a,b,1,c,d,e,16,f,g,0,0,2)|0}function dg(a,b,c){a=a|0;b=b|0;c=c|0;if(c>>>0<1|(c|0)==1&b>>>0<0){uf(a,b);return}else ca(35231,35251,204,35277)}function eg(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;return xc(a,b,c,d,e,f,g)|0}function fg(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;return Db(a,b,1,c,d,e,16,f,g,0,0,1)|0}function gg(a){a=a|0;var c=0;c=0;while(1){if(!(b[a+c>>0]|0))break;c=c+1|0;if(c>>>0>=102){c=102;break}}return c|0}function hg(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Vd(a,b,c,d,e,0,0,f)|0}function ig(a,b){a=a|0;b=b|0;var c=0;c=0;do{f[a+(c<<2)>>2]=f[b+(c<<2)>>2];c=c+1|0}while((c|0)!=16);return}function jg(a,b){a=a|0;b=b|0;pa(a,b,b+120|0);pa(a+40|0,b+40|0,b+80|0);pa(a+80|0,b+80|0,b+120|0);return}function kg(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Ld(a,b,c,d,e,0,0,f)|0}function lg(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;Mb(a,b,c,d,e,f,0);return 0}function mg(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return pc(a,b,c,d,e,f)|0}function ng(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Oc(a,b,c,d,e,f)|0}function og(a,b){a=a|0;b=b|0;cf(a,b&4);wa(f[a+4>>2]|0);f[a+4>>2]=0;Hh(f[a>>2]|0);f[a>>2]=0;return}function pg(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Dd(a,b,c,d,e,0,f)|0}function qg(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Db(a,b,1,c,d,e,16,0,32,f,128,2)|0}function rg(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Db(a,b,1,c,d,e,16,0,32,f,128,1)|0}function sg(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Ua(a,b,c,d,e,0,0,f)|0}function tg(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return Pb(a,b,c,d,e,0)|0}function ug(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;lg(a,b,c,d,e,f)|0;return 0}function vg(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return xe(a,b,c,d,e)|0}function wg(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return od(a,b,c,d,e,0,0,f)|0}function xg(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return yd(a,b,c,d,e,f)|0}function yg(a){a=a|0;b[a+32>>0]=1;b[a+32+1>>0]=0;b[a+32+2>>0]=0;b[a+32+3>>0]=0;return}function zg(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return ng(a,b,c,d,e,f)|0}function Ag(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return kg(a,b,c,d,e,f)|0}function Bg(a){a=a|0;var b=0;f[a>>2]=1;a=a+4|0;b=a+36|0;do{f[a>>2]=0;a=a+4|0}while((a|0)<(b|0));return}function Cg(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return tg(a,b,c,d,e)|0}function Dg(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return lc(a,b,c,d,e,f)|0}function Eg(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return Ke(a,b,c,d,e)|0}function Fg(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return vg(a,b,c,d,e)|0}function Gg(a,b){a=a|0;b=b|0;Ne(a)|0;if(b|0)Ja(a,33968,34,0)|0;return}function Hg(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return xg(a,b,c,d,e,f)|0}function Ig(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;d=b-d-(c>>>0>a>>>0|0)>>>0;return (G=d,a-c>>>0|0)|0}function Jg(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Nc(a,b,c,d,e,f)|0}function Kg(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return gh(a,b,c,d)|0}function Lg(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return (G=b+d+(a+c>>>0>>>0<a>>>0|0)>>>0,a+c>>>0|0)|0}function Mg(a,c){a=a|0;c=c|0;b[a+3>>0]=c;b[a+2>>0]=c>>>8;b[a+1>>0]=c>>>16;b[a>>0]=c>>>24;return}function Ng(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return pe(a,b,c,d,e)|0}function Og(a,b){a=a|0;b=b|0;b=Kb(b&255)|0;f[a>>2]=(b|0)==0?0:b-35349|0;return ((b|0)==0)<<31>>31|0}function Pg(a){a=a|0;if(b[a+356>>0]|0)ei(a);f[a+80>>2]=-1;f[a+80+4>>2]=-1;return}function Qg(a,c){a=a|0;c=c|0;b[a>>0]=c;b[a+1>>0]=c>>8;b[a+2>>0]=c>>16;b[a+3>>0]=c>>24;return}function Rg(a,b,c){a=a|0;b=b|0;c=c|0;bg(b,32,c,32,0,0,0)|0;return Uh(a,b)|0}function Sg(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;ya(a,b,c,d,e)|0;return 0}function Tg(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return Eg(a,b,c,d,e)|0}function Ug(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;Nb(a,b,c,d);return 0}function Vg(a,b){a=a|0;b=b|0;Rc(a,b);Rc(a+40|0,b+40|0);Rc(a+80|0,b+80|0);return}function Wg(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return Nd(a,b,c,d,e)|0}function Xg(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;Pe(a,b,c,d)|0;return 0}function Yg(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;Ug(a,b,c,d)|0;return 0}function Zg(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;Me(a,b,c,d,e)|0;return 0}function _g(a,b){a=a|0;b=b|0;uf(b,32);return Jh(a,b)|0}function $g(a){a=a|0;return (h[a+2>>0]|0)<<8|(h[a+3>>0]|0)|(h[a+1>>0]|0)<<16|(h[a>>0]|0)<<24|0}function ah(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Kg(a,b,c,d)|0}function bh(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;Pa(a,b,c,d)|0;return 0}function ch(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return mb(a,b,c,d,e)|0}function dh(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return me(a,b,c,d,e)|0}function eh(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;Ja(a,b,c,d)|0;return 0}function fh(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Ob(a,b,c,d,2)|0}function gh(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;Ra(a,b,c,d);return 0}function hh(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return Ud(a,b,c,d,e)|0}function ih(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Ob(a,b,c,d,1)|0}function jh(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Td(a,b,c,d)|0}function kh(a,b,c){a=a|0;b=b|0;c=c|0;return xd(a,b,c)|0}function lh(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;eh(a,b,c,d)|0;return 0}function mh(a,b){a=a|0;b=b|0;fb(a,b);return 0-(Zb(a)|0)|0}function nh(a,b,c){a=a|0;b=b|0;c=c|0;Wg(a,b,0,35219,c)|0;return}function oh(a,b){a=a|0;b=b|0;G=f[a+-64+(b<<7)+4>>2]|0;return f[a+-64+(b<<7)>>2]|0}function ph(a){a=a|0;var b=0;b=a+40|0;do{f[a>>2]=0;a=a+4|0}while((a|0)<(b|0));return}function qh(a,b,c){a=a|0;b=b|0;c=c|0;return oe(a,b,c)|0}function rh(a){a=a|0;b[a>>0]=b[a>>0]&-8;b[a+31>>0]=b[a+31>>0]&63|64;return}function sh(a,c){a=a|0;c=c|0;a=Tb(a,c)|0;return ((b[a>>0]|0)==(c&255)<<24>>24?a:0)|0}function th(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;Fa(a,b,c,d,12);return 0}function uh(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;Fa(a,b,c,d,8);return 0}function vh(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;Fa(a,b,c,d,20);return 0}function wh(a,b,c){a=a|0;b=b|0;c=c|0;Ab(a,b,c)|0;return 0}function xh(a,b,c){a=a|0;b=b|0;c=c|0;Jd(a,b,c)|0;return 0}function yh(a){a=a|0;return h[a>>0]|h[a+1>>0]<<8|h[a+2>>0]<<16|h[a+3>>0]<<24|0}function zh(a){a=a|0;Bg(a);Bg(a+40|0);Bg(a+80|0);ph(a+120|0);return}function Ah(a,b,c){a=a|0;b=b|0;c=c|0;return Qe(a,b,c)|0}function Bh(a,b,c){a=a|0;b=b|0;c=c|0;return Bf(a,b,c)|0}function Ch(a){a=a|0;var b=0;b=t;t=t+a|0;t=t+15&-16;return b|0}function Dh(a){a=a|0;b[a>>0]=0;b[a+1>>0]=0;b[a+2>>0]=0;b[a+3>>0]=0;return}function Eh(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;He(a,b,c,d)|0;return 0}function Fh(a,b,c){a=a|0;b=b|0;c=c|0;rc(a,1120+(b*960|0)|0,c);return}function Gh(a){a=a|0;ph(a);Bg(a+40|0);Bg(a+80|0);ph(a+120|0);return}function Hh(a){a=a|0;var b=0;if(a|0?(b=f[a>>2]|0,b|0):0)wa(b);wa(a);return}function Ih(a){a=a|0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;return}function Jh(a,b){a=a|0;b=b|0;return fd(a,b)|0}function Kh(a,b){a=a|0;b=b|0;return Xh(a,b)|0}function Lh(a,b){a=a|0;b=b|0;return bi(a,b)|0}function Mh(a){a=a|0;var b=0;b=f[a>>2]|0;if(b|0)wa(b);Zh(a);return}function Nh(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Da(a,b,c,d,0)|0}function Oh(a,b,c){a=a|0;b=b|0;c=c|0;return vd(a,b,c)|0}function Ph(a,b){a=a|0;b=b|0;uf(b,32);return Uh(a,b)|0}function Qh(a,b){a=a|0;b=b|0;return _g(a,b)|0}function Rh(a,b){a=a|0;b=b|0;return Kh(a,b)|0}function Sh(a){a=a|0;if((a&-7|0)==1)return;else Fj()}function Th(a,b){a=a|0;b=b|0;se(a|0,b+32|0,32)|0;return 0}function Uh(a,b){a=a|0;b=b|0;return Jh(a,b)|0}function Vh(a,b){a=a|0;b=b|0;return Lh(a,b)|0}function Wh(a){a=a|0;Bg(a);Bg(a+40|0);ph(a+80|0);return}function Xh(a,b){a=a|0;b=b|0;ab(a,b);return 0}function Yh(a,b){a=a|0;b=b|0;if(!v){v=a;w=b}}function Zh(a){a=a|0;f[a+4>>2]=0;f[a>>2]=0;f[a+8>>2]=0;return}function _h(a,b){a=a|0;b=b|0;se(a|0,b|0,32)|0;return 0}function $h(a,b,c){a=a|0;b=b|0;c=c|0;return sb(a,b,c,2)|0}function ai(a,b,c){a=a|0;b=b|0;c=c|0;return sb(a,b,c,1)|0}function bi(a,b){a=a|0;b=b|0;ic(a,b);return 0}function ci(a,b){a=a|0;b=b|0;bf(a,b)|0;return 0}function di(a){a=a|0;ph(a);Bg(a+40|0);Bg(a+80|0);return}function ei(a){a=a|0;f[a+88>>2]=-1;f[a+88+4>>2]=-1;return}function fi(a,b){a=a|0;b=b|0;return ((a|0)!=0|(b|0)!=0)&1|0}function gi(a,b){a=a|0;b=b|0;return (((b^a)&255)+-1|0)>>>31&255|0}function hi(a){a=a|0;return (a?31-(Y(a^a-1)|0)|0:32)|0}function ii(a,b){a=a|0;b=b|0;return pd(a,b,64)|0}function ji(a,b){a=a|0;b=b|0;return pd(a,b,32)|0}function ki(a,b){a=a|0;b=b|0;return pd(a,b,16)|0}function li(a,b){a=a|0;b=b|0;qb(a|0,b|0,1024)|0;return}function mi(a){a=a|0;Ne(a)|0;return 0}function ni(a,b){a=a|0;b=b|0;t=a;u=b}function oi(a,b){a=a|0;b=b|0;return a>>>(32-b|0)|a<<b|0}function pi(a){a=a|0;mi(a)|0;return 0}function qi(){Qf();return}function ri(a,b){a=a|0;b=b|0;return a<<32-b|a>>>b|0}function si(a){a=a|0;return Oe(a,(Sc(a)|0)+1|0)|0}function ti(a){a=a|0;uf(a,16);return}function ui(a){a=a|0;ec(a|0,0,1024)|0;return}function vi(){return 524288}function wi(a){a=a|0;uf(a,32);return}function xi(){return -18}function yi(){return 16777216}function zi(a){a=a|0;Zh(a);return}function Ai(a){a=a|0;Mh(a);return}function Bi(){return 32768}function Ci(){return 52}function Di(){return 33554432}function Ei(){return 35414}function Fi(){return 536870912}function Gi(){fa(1)|0;return}function Hi(){return fa(0)|0}function Ii(){return 134217728}function Ji(){return 17}function Ki(){return 102}function Li(a){a=a|0;return (a&255)>>>7|0}function Mi(){return 1073741824}function Ni(){return 67108864}function Oi(){return 12}function Pi(){return 268435456}function Qi(){return 6}function Ri(){return -2147483648}function Si(){return 34456}function Ti(){return 34383}function Ui(){return 416}function Vi(a){a=a|0;t=a}function Wi(){return 4}function Xi(){return 34303}function Yi(a){a=a|0;G=a}function Zi(){return 34401}function _i(){return 3}function $i(){return 256}function aj(){return 104}function bj(){return 384}function cj(){return 34429}function dj(){return 34412}function ej(){return 10}function fj(){return 8192}function gj(){return 34447}function hj(){return 34372}function ij(){return 34393}function jj(){return 1}function kj(){return 35342}function lj(){return 34439}function mj(){return 2}function nj(){return 34274}function oj(){return 34016}function pj(){return 208}function qj(){return 128}function rj(){return -1}function sj(){return 34281}function tj(){return 34030}function uj(){return 34289}function vj(){return 8}function wj(){return 24}function xj(){return G|0}function yj(){return 48}function zj(){return 16}function Aj(){return 36008}function Bj(){return t|0}function Cj(){return 64}function Dj(){return 32}function Ej(){return 0}function Fj(){ea()}
20574
20575// EMSCRIPTEN_END_FUNCS
20576return{___errno_location:Aj,___muldi3:Af,___udivdi3:Nh,___uremdi3:pf,_bitshift64Ashr:Nf,_bitshift64Lshr:$f,_bitshift64Shl:Wf,_crypto_aead_chacha20poly1305_abytes:zj,_crypto_aead_chacha20poly1305_decrypt:wc,_crypto_aead_chacha20poly1305_decrypt_detached:Jb,_crypto_aead_chacha20poly1305_encrypt:nd,_crypto_aead_chacha20poly1305_encrypt_detached:Xb,_crypto_aead_chacha20poly1305_ietf_abytes:zj,_crypto_aead_chacha20poly1305_ietf_decrypt:tc,_crypto_aead_chacha20poly1305_ietf_decrypt_detached:wb,_crypto_aead_chacha20poly1305_ietf_encrypt:id,_crypto_aead_chacha20poly1305_ietf_encrypt_detached:Ib,_crypto_aead_chacha20poly1305_ietf_keybytes:Dj,_crypto_aead_chacha20poly1305_ietf_keygen:wi,_crypto_aead_chacha20poly1305_ietf_npubbytes:Oi,_crypto_aead_chacha20poly1305_ietf_nsecbytes:Ej,_crypto_aead_chacha20poly1305_keybytes:Dj,_crypto_aead_chacha20poly1305_keygen:wi,_crypto_aead_chacha20poly1305_npubbytes:vj,_crypto_aead_chacha20poly1305_nsecbytes:Ej,_crypto_aead_xchacha20poly1305_ietf_abytes:zj,_crypto_aead_xchacha20poly1305_ietf_decrypt:sc,_crypto_aead_xchacha20poly1305_ietf_decrypt_detached:qc,_crypto_aead_xchacha20poly1305_ietf_encrypt:gd,_crypto_aead_xchacha20poly1305_ietf_encrypt_detached:oc,_crypto_aead_xchacha20poly1305_ietf_keybytes:Dj,_crypto_aead_xchacha20poly1305_ietf_keygen:wi,_crypto_aead_xchacha20poly1305_ietf_npubbytes:wj,_crypto_aead_xchacha20poly1305_ietf_nsecbytes:Ej,_crypto_auth:Zg,_crypto_auth_bytes:Dj,_crypto_auth_hmacsha256:Je,_crypto_auth_hmacsha256_bytes:Dj,_crypto_auth_hmacsha256_final:Ve,_crypto_auth_hmacsha256_init:Bb,_crypto_auth_hmacsha256_keybytes:Dj,_crypto_auth_hmacsha256_keygen:wi,_crypto_auth_hmacsha256_statebytes:pj,_crypto_auth_hmacsha256_update:bh,_crypto_auth_hmacsha256_verify:ue,_crypto_auth_hmacsha512:Le,_crypto_auth_hmacsha512256:Me,_crypto_auth_hmacsha512256_bytes:Dj,_crypto_auth_hmacsha512256_final:Fe,_crypto_auth_hmacsha512256_init:wh,_crypto_auth_hmacsha512256_keybytes:Dj,_crypto_auth_hmacsha512256_keygen:wi,_crypto_auth_hmacsha512256_statebytes:Ui,_crypto_auth_hmacsha512256_update:lh,_crypto_auth_hmacsha512256_verify:pe,_crypto_auth_hmacsha512_bytes:Cj,_crypto_auth_hmacsha512_final:Ue,_crypto_auth_hmacsha512_init:Ab,_crypto_auth_hmacsha512_keybytes:Dj,_crypto_auth_hmacsha512_keygen:wi,_crypto_auth_hmacsha512_statebytes:Ui,_crypto_auth_hmacsha512_update:eh,_crypto_auth_hmacsha512_verify:te,_crypto_auth_keybytes:Dj,_crypto_auth_keygen:wi,_crypto_auth_primitive:oj,_crypto_auth_verify:Ng,_crypto_box:Yf,_crypto_box_afternm:Hg,_crypto_box_beforenm:qh,_crypto_box_beforenmbytes:Dj,_crypto_box_boxzerobytes:zj,_crypto_box_curve25519xchacha20poly1305_beforenm:ne,_crypto_box_curve25519xchacha20poly1305_beforenmbytes:Dj,_crypto_box_curve25519xchacha20poly1305_detached:md,_crypto_box_curve25519xchacha20poly1305_detached_afternm:qf,_crypto_box_curve25519xchacha20poly1305_easy:qe,_crypto_box_curve25519xchacha20poly1305_easy_afternm:re,_crypto_box_curve25519xchacha20poly1305_keypair:_g,_crypto_box_curve25519xchacha20poly1305_macbytes:zj,_crypto_box_curve25519xchacha20poly1305_noncebytes:wj,_crypto_box_curve25519xchacha20poly1305_open_detached:ld,_crypto_box_curve25519xchacha20poly1305_open_detached_afternm:mf,_crypto_box_curve25519xchacha20poly1305_open_easy:_d,_crypto_box_curve25519xchacha20poly1305_open_easy_afternm:ae,_crypto_box_curve25519xchacha20poly1305_publickeybytes:Dj,_crypto_box_curve25519xchacha20poly1305_seal:Bc,_crypto_box_curve25519xchacha20poly1305_seal_open:kd,_crypto_box_curve25519xchacha20poly1305_sealbytes:yj,_crypto_box_curve25519xchacha20poly1305_secretkeybytes:Dj,_crypto_box_curve25519xchacha20poly1305_seed_keypair:xd,_crypto_box_curve25519xchacha20poly1305_seedbytes:Dj,_crypto_box_curve25519xsalsa20poly1305:Kd,_crypto_box_curve25519xsalsa20poly1305_afternm:xg,_crypto_box_curve25519xsalsa20poly1305_beforenm:oe,_crypto_box_curve25519xsalsa20poly1305_beforenmbytes:Dj,_crypto_box_curve25519xsalsa20poly1305_boxzerobytes:zj,_crypto_box_curve25519xsalsa20poly1305_keypair:_g,_crypto_box_curve25519xsalsa20poly1305_macbytes:zj,_crypto_box_curve25519xsalsa20poly1305_noncebytes:wj,_crypto_box_curve25519xsalsa20poly1305_open:Id,_crypto_box_curve25519xsalsa20poly1305_open_afternm:ng,_crypto_box_curve25519xsalsa20poly1305_publickeybytes:Dj,_crypto_box_curve25519xsalsa20poly1305_secretkeybytes:Dj,_crypto_box_curve25519xsalsa20poly1305_seed_keypair:xd,_crypto_box_curve25519xsalsa20poly1305_seedbytes:Dj,_crypto_box_curve25519xsalsa20poly1305_zerobytes:Dj,_crypto_box_detached:Zd,_crypto_box_detached_afternm:Tf,_crypto_box_easy:Xe,_crypto_box_easy_afternm:Ye,_crypto_box_keypair:Qh,_crypto_box_macbytes:zj,_crypto_box_noncebytes:wj,_crypto_box_open:Rf,_crypto_box_open_afternm:zg,_crypto_box_open_detached:Yd,_crypto_box_open_detached_afternm:Pf,_crypto_box_open_easy:ve,_crypto_box_open_easy_afternm:ze,_crypto_box_primitive:tj,_crypto_box_publickeybytes:Dj,_crypto_box_seal:Tc,_crypto_box_seal_open:Cd,_crypto_box_sealbytes:yj,_crypto_box_secretkeybytes:Dj,_crypto_box_seed_keypair:kh,_crypto_box_seedbytes:Dj,_crypto_box_zerobytes:Dj,_crypto_core_ed25519_add:bd,_crypto_core_ed25519_bytes:Dj,_crypto_core_ed25519_from_uniform:mh,_crypto_core_ed25519_is_valid_point:Qd,_crypto_core_ed25519_sub:ad,_crypto_core_ed25519_uniformbytes:Dj,_crypto_core_hchacha20:Ha,_crypto_core_hchacha20_constbytes:zj,_crypto_core_hchacha20_inputbytes:zj,_crypto_core_hchacha20_keybytes:Dj,_crypto_core_hchacha20_outputbytes:Dj,_crypto_core_hsalsa20:La,_crypto_core_hsalsa20_constbytes:zj,_crypto_core_hsalsa20_inputbytes:zj,_crypto_core_hsalsa20_keybytes:Dj,_crypto_core_hsalsa20_outputbytes:Dj,_crypto_core_salsa20:vh,_crypto_core_salsa2012:th,_crypto_core_salsa2012_constbytes:zj,_crypto_core_salsa2012_inputbytes:zj,_crypto_core_salsa2012_keybytes:Dj,_crypto_core_salsa2012_outputbytes:Cj,_crypto_core_salsa208:uh,_crypto_core_salsa208_constbytes:zj,_crypto_core_salsa208_inputbytes:zj,_crypto_core_salsa208_keybytes:Dj,_crypto_core_salsa208_outputbytes:Cj,_crypto_core_salsa20_constbytes:zj,_crypto_core_salsa20_inputbytes:zj,_crypto_core_salsa20_keybytes:Dj,_crypto_core_salsa20_outputbytes:Cj,_crypto_generichash:bg,_crypto_generichash_blake2b:Se,_crypto_generichash_blake2b_bytes:Dj,_crypto_generichash_blake2b_bytes_max:Cj,_crypto_generichash_blake2b_bytes_min:zj,_crypto_generichash_blake2b_final:Bf,_crypto_generichash_blake2b_init:Td,_crypto_generichash_blake2b_init_salt_personal:wd,_crypto_generichash_blake2b_keybytes:Dj,_crypto_generichash_blake2b_keybytes_max:Cj,_crypto_generichash_blake2b_keybytes_min:zj,_crypto_generichash_blake2b_keygen:wi,_crypto_generichash_blake2b_personalbytes:zj,_crypto_generichash_blake2b_salt_personal:he,_crypto_generichash_blake2b_saltbytes:zj,_crypto_generichash_blake2b_statebytes:bj,_crypto_generichash_blake2b_update:Ug,_crypto_generichash_bytes:Dj,_crypto_generichash_bytes_max:Cj,_crypto_generichash_bytes_min:zj,_crypto_generichash_final:Bh,_crypto_generichash_init:jh,_crypto_generichash_keybytes:Dj,_crypto_generichash_keybytes_max:Cj,_crypto_generichash_keybytes_min:zj,_crypto_generichash_keygen:wi,_crypto_generichash_primitive:sj,_crypto_generichash_statebytes:bj,_crypto_generichash_update:Yg,_crypto_hash:Eh,_crypto_hash_bytes:Cj,_crypto_hash_primitive:nj,_crypto_hash_sha256:Ie,_crypto_hash_sha256_bytes:Dj,_crypto_hash_sha256_final:gf,_crypto_hash_sha256_init:de,_crypto_hash_sha256_statebytes:aj,_crypto_hash_sha256_update:Pa,_crypto_hash_sha512:He,_crypto_hash_sha512_bytes:Cj,_crypto_hash_sha512_final:df,_crypto_hash_sha512_init:Ne,_crypto_hash_sha512_statebytes:pj,_crypto_hash_sha512_update:Ja,_crypto_kdf_blake2b_bytes_max:Cj,_crypto_kdf_blake2b_bytes_min:zj,_crypto_kdf_blake2b_contextbytes:vj,_crypto_kdf_blake2b_derive_from_key:pc,_crypto_kdf_blake2b_keybytes:Dj,_crypto_kdf_bytes_max:Cj,_crypto_kdf_bytes_min:zj,_crypto_kdf_contextbytes:vj,_crypto_kdf_derive_from_key:mg,_crypto_kdf_keybytes:Dj,_crypto_kdf_keygen:wi,_crypto_kdf_primitive:sj,_crypto_kx_client_session_keys:ac,_crypto_kx_keypair:Ph,_crypto_kx_primitive:uj,_crypto_kx_publickeybytes:Dj,_crypto_kx_secretkeybytes:Dj,_crypto_kx_seed_keypair:Rg,_crypto_kx_seedbytes:Dj,_crypto_kx_server_session_keys:$b,_crypto_kx_sessionkeybytes:Dj,_crypto_onetimeauth:Tg,_crypto_onetimeauth_bytes:zj,_crypto_onetimeauth_final:Rh,_crypto_onetimeauth_init:Vh,_crypto_onetimeauth_keybytes:Dj,_crypto_onetimeauth_keygen:wi,_crypto_onetimeauth_poly1305:Eg,_crypto_onetimeauth_poly1305_bytes:zj,_crypto_onetimeauth_poly1305_final:Kh,_crypto_onetimeauth_poly1305_init:Lh,_crypto_onetimeauth_poly1305_keybytes:Dj,_crypto_onetimeauth_poly1305_keygen:wi,_crypto_onetimeauth_poly1305_statebytes:$i,_crypto_onetimeauth_poly1305_update:Kg,_crypto_onetimeauth_poly1305_verify:vg,_crypto_onetimeauth_primitive:Xi,_crypto_onetimeauth_statebytes:$i,_crypto_onetimeauth_update:ah,_crypto_onetimeauth_verify:Fg,_crypto_pwhash:Ad,_crypto_pwhash_alg_argon2i13:jj,_crypto_pwhash_alg_argon2id13:mj,_crypto_pwhash_alg_default:mj,_crypto_pwhash_argon2i:dc,_crypto_pwhash_argon2i_alg_argon2i13:jj,_crypto_pwhash_argon2i_bytes_max:rj,_crypto_pwhash_argon2i_bytes_min:zj,_crypto_pwhash_argon2i_memlimit_interactive:Di,_crypto_pwhash_argon2i_memlimit_max:Ri,_crypto_pwhash_argon2i_memlimit_min:fj,_crypto_pwhash_argon2i_memlimit_moderate:Ii,_crypto_pwhash_argon2i_memlimit_sensitive:Fi,_crypto_pwhash_argon2i_opslimit_interactive:Wi,_crypto_pwhash_argon2i_opslimit_max:rj,_crypto_pwhash_argon2i_opslimit_min:_i,_crypto_pwhash_argon2i_opslimit_moderate:Qi,_crypto_pwhash_argon2i_opslimit_sensitive:vj,_crypto_pwhash_argon2i_passwd_max:rj,_crypto_pwhash_argon2i_passwd_min:Ej,_crypto_pwhash_argon2i_saltbytes:zj,_crypto_pwhash_argon2i_str:uc,_crypto_pwhash_argon2i_str_needs_rehash:ih,_crypto_pwhash_argon2i_str_verify:Rd,_crypto_pwhash_argon2i_strbytes:qj,_crypto_pwhash_argon2i_strprefix:Ti,_crypto_pwhash_argon2id:fc,_crypto_pwhash_argon2id_alg_argon2id13:mj,_crypto_pwhash_argon2id_bytes_max:rj,_crypto_pwhash_argon2id_bytes_min:zj,_crypto_pwhash_argon2id_memlimit_interactive:Ni,_crypto_pwhash_argon2id_memlimit_max:Ri,_crypto_pwhash_argon2id_memlimit_min:fj,_crypto_pwhash_argon2id_memlimit_moderate:Pi,_crypto_pwhash_argon2id_memlimit_sensitive:Mi,_crypto_pwhash_argon2id_opslimit_interactive:mj,_crypto_pwhash_argon2id_opslimit_max:rj,_crypto_pwhash_argon2id_opslimit_min:jj,_crypto_pwhash_argon2id_opslimit_moderate:_i,_crypto_pwhash_argon2id_opslimit_sensitive:Wi,_crypto_pwhash_argon2id_passwd_max:rj,_crypto_pwhash_argon2id_passwd_min:Ej,_crypto_pwhash_argon2id_saltbytes:zj,_crypto_pwhash_argon2id_str:xc,_crypto_pwhash_argon2id_str_needs_rehash:fh,_crypto_pwhash_argon2id_str_verify:Od,_crypto_pwhash_argon2id_strbytes:qj,_crypto_pwhash_argon2id_strprefix:hj,_crypto_pwhash_bytes_max:rj,_crypto_pwhash_bytes_min:zj,_crypto_pwhash_memlimit_interactive:Ni,_crypto_pwhash_memlimit_max:Ri,_crypto_pwhash_memlimit_min:fj,_crypto_pwhash_memlimit_moderate:Pi,_crypto_pwhash_memlimit_sensitive:Mi,_crypto_pwhash_opslimit_interactive:mj,_crypto_pwhash_opslimit_max:rj,_crypto_pwhash_opslimit_min:jj,_crypto_pwhash_opslimit_moderate:_i,_crypto_pwhash_opslimit_sensitive:Wi,_crypto_pwhash_passwd_max:rj,_crypto_pwhash_passwd_min:Ej,_crypto_pwhash_primitive:ij,_crypto_pwhash_saltbytes:zj,_crypto_pwhash_scryptsalsa208sha256:jc,_crypto_pwhash_scryptsalsa208sha256_bytes_max:rj,_crypto_pwhash_scryptsalsa208sha256_bytes_min:zj,_crypto_pwhash_scryptsalsa208sha256_ll:Hd,_crypto_pwhash_scryptsalsa208sha256_memlimit_interactive:yi,_crypto_pwhash_scryptsalsa208sha256_memlimit_max:rj,_crypto_pwhash_scryptsalsa208sha256_memlimit_min:yi,_crypto_pwhash_scryptsalsa208sha256_memlimit_sensitive:Mi,_crypto_pwhash_scryptsalsa208sha256_opslimit_interactive:vi,_crypto_pwhash_scryptsalsa208sha256_opslimit_max:rj,_crypto_pwhash_scryptsalsa208sha256_opslimit_min:Bi,_crypto_pwhash_scryptsalsa208sha256_opslimit_sensitive:Di,_crypto_pwhash_scryptsalsa208sha256_passwd_max:rj,_crypto_pwhash_scryptsalsa208sha256_passwd_min:Ej,_crypto_pwhash_scryptsalsa208sha256_saltbytes:Dj,_crypto_pwhash_scryptsalsa208sha256_str:Ub,_crypto_pwhash_scryptsalsa208sha256_str_needs_rehash:Hc,_crypto_pwhash_scryptsalsa208sha256_str_verify:Qc,_crypto_pwhash_scryptsalsa208sha256_strbytes:Ki,_crypto_pwhash_scryptsalsa208sha256_strprefix:Ei,_crypto_pwhash_str:eg,_crypto_pwhash_str_alg:Sd,_crypto_pwhash_str_needs_rehash:Md,_crypto_pwhash_str_verify:Xd,_crypto_pwhash_strbytes:qj,_crypto_pwhash_strprefix:hj,_crypto_scalarmult:Oh,_crypto_scalarmult_base:Uh,_crypto_scalarmult_bytes:Dj,_crypto_scalarmult_curve25519:vd,_crypto_scalarmult_curve25519_base:Jh,_crypto_scalarmult_curve25519_bytes:Dj,_crypto_scalarmult_curve25519_scalarbytes:Dj,_crypto_scalarmult_ed25519:Cc,_crypto_scalarmult_ed25519_base:Fd,_crypto_scalarmult_ed25519_bytes:Dj,_crypto_scalarmult_ed25519_scalarbytes:Dj,_crypto_scalarmult_primitive:Zi,_crypto_scalarmult_scalarbytes:Dj,_crypto_secretbox:xg,_crypto_secretbox_boxzerobytes:zj,_crypto_secretbox_detached:db,_crypto_secretbox_easy:_e,_crypto_secretbox_keybytes:Dj,_crypto_secretbox_keygen:wi,_crypto_secretbox_macbytes:zj,_crypto_secretbox_noncebytes:wj,_crypto_secretbox_open:ng,_crypto_secretbox_open_detached:pb,_crypto_secretbox_open_easy:De,_crypto_secretbox_primitive:dj,_crypto_secretbox_xchacha20poly1305_detached:bb,_crypto_secretbox_xchacha20poly1305_easy:Ee,_crypto_secretbox_xchacha20poly1305_keybytes:Dj,_crypto_secretbox_xchacha20poly1305_macbytes:zj,_crypto_secretbox_xchacha20poly1305_noncebytes:wj,_crypto_secretbox_xchacha20poly1305_open_detached:nb,_crypto_secretbox_xchacha20poly1305_open_easy:ke,_crypto_secretbox_xsalsa20poly1305:yd,_crypto_secretbox_xsalsa20poly1305_boxzerobytes:zj,_crypto_secretbox_xsalsa20poly1305_keybytes:Dj,_crypto_secretbox_xsalsa20poly1305_keygen:wi,_crypto_secretbox_xsalsa20poly1305_macbytes:zj,_crypto_secretbox_xsalsa20poly1305_noncebytes:wj,_crypto_secretbox_xsalsa20poly1305_open:Oc,_crypto_secretbox_xsalsa20poly1305_zerobytes:Dj,_crypto_secretbox_zerobytes:Dj,_crypto_secretstream_xchacha20poly1305_abytes:Ji,_crypto_secretstream_xchacha20poly1305_headerbytes:wj,_crypto_secretstream_xchacha20poly1305_init_pull:_b,_crypto_secretstream_xchacha20poly1305_init_push:Yb,_crypto_secretstream_xchacha20poly1305_keybytes:Dj,_crypto_secretstream_xchacha20poly1305_keygen:wi,_crypto_secretstream_xchacha20poly1305_messagebytes_max:xi,_crypto_secretstream_xchacha20poly1305_pull:Na,_crypto_secretstream_xchacha20poly1305_push:_a,_crypto_secretstream_xchacha20poly1305_rekey:Gb,_crypto_secretstream_xchacha20poly1305_statebytes:Ci,_crypto_secretstream_xchacha20poly1305_tag_final:_i,_crypto_secretstream_xchacha20poly1305_tag_message:Ej,_crypto_secretstream_xchacha20poly1305_tag_push:jj,_crypto_secretstream_xchacha20poly1305_tag_rekey:mj,_crypto_shorthash:Sg,_crypto_shorthash_bytes:vj,_crypto_shorthash_keybytes:zj,_crypto_shorthash_keygen:ti,_crypto_shorthash_primitive:cj,_crypto_shorthash_siphash24:ya,_crypto_shorthash_siphash24_bytes:vj,_crypto_shorthash_siphash24_keybytes:zj,_crypto_shorthash_siphashx24:va,_crypto_shorthash_siphashx24_bytes:zj,_crypto_shorthash_siphashx24_keybytes:zj,_crypto_sign:Jg,_crypto_sign_bytes:Cj,_crypto_sign_detached:ug,_crypto_sign_ed25519:Nc,_crypto_sign_ed25519_bytes:Cj,_crypto_sign_ed25519_detached:lg,_crypto_sign_ed25519_keypair:bf,_crypto_sign_ed25519_open:lc,_crypto_sign_ed25519_pk_to_curve25519:Zc,_crypto_sign_ed25519_publickeybytes:Dj,_crypto_sign_ed25519_secretkeybytes:Cj,_crypto_sign_ed25519_seed_keypair:Jd,_crypto_sign_ed25519_seedbytes:Dj,_crypto_sign_ed25519_sk_to_curve25519:Bd,_crypto_sign_ed25519_sk_to_pk:Th,_crypto_sign_ed25519_sk_to_seed:_h,_crypto_sign_ed25519_verify_detached:tg,_crypto_sign_ed25519ph_final_create:Pe,_crypto_sign_ed25519ph_final_verify:Qe,_crypto_sign_ed25519ph_init:mi,_crypto_sign_ed25519ph_statebytes:pj,_crypto_sign_ed25519ph_update:eh,_crypto_sign_final_create:Xg,_crypto_sign_final_verify:Ah,_crypto_sign_init:pi,_crypto_sign_keypair:ci,_crypto_sign_open:Dg,_crypto_sign_primitive:lj,_crypto_sign_publickeybytes:Dj,_crypto_sign_secretkeybytes:Cj,_crypto_sign_seed_keypair:xh,_crypto_sign_seedbytes:Dj,_crypto_sign_statebytes:pj,_crypto_sign_update:lh,_crypto_sign_verify_detached:Cg,_crypto_stream:dh,_crypto_stream_chacha20:hh,_crypto_stream_chacha20_ietf:Wg,_crypto_stream_chacha20_ietf_keybytes:Dj,_crypto_stream_chacha20_ietf_keygen:wi,_crypto_stream_chacha20_ietf_noncebytes:Oi,_crypto_stream_chacha20_ietf_xor:pg,_crypto_stream_chacha20_ietf_xor_ic:Sf,_crypto_stream_chacha20_keybytes:Dj,_crypto_stream_chacha20_keygen:wi,_crypto_stream_chacha20_noncebytes:vj,_crypto_stream_chacha20_xor:wg,_crypto_stream_chacha20_xor_ic:Gf,_crypto_stream_keybytes:Dj,_crypto_stream_keygen:wi,_crypto_stream_noncebytes:wj,_crypto_stream_primitive:gj,_crypto_stream_salsa20:ch,_crypto_stream_salsa2012:kb,_crypto_stream_salsa2012_keybytes:Dj,_crypto_stream_salsa2012_keygen:wi,_crypto_stream_salsa2012_noncebytes:vj,_crypto_stream_salsa2012_xor:Wa,_crypto_stream_salsa208:lb,_crypto_stream_salsa208_keybytes:Dj,_crypto_stream_salsa208_keygen:wi,_crypto_stream_salsa208_messagebytes_max:rj,_crypto_stream_salsa208_noncebytes:vj,_crypto_stream_salsa208_xor:Xa,_crypto_stream_salsa20_keybytes:Dj,_crypto_stream_salsa20_keygen:wi,_crypto_stream_salsa20_noncebytes:vj,_crypto_stream_salsa20_xor:sg,_crypto_stream_salsa20_xor_ic:Ef,_crypto_stream_xchacha20:Ce,_crypto_stream_xchacha20_keybytes:Dj,_crypto_stream_xchacha20_keygen:wi,_crypto_stream_xchacha20_noncebytes:wj,_crypto_stream_xchacha20_xor:hg,_crypto_stream_xchacha20_xor_ic:Vd,_crypto_stream_xor:Ag,_crypto_stream_xsalsa20:me,_crypto_stream_xsalsa20_keybytes:Dj,_crypto_stream_xsalsa20_keygen:wi,_crypto_stream_xsalsa20_noncebytes:wj,_crypto_stream_xsalsa20_xor:kg,_crypto_stream_xsalsa20_xor_ic:Ld,_crypto_verify_16:ki,_crypto_verify_16_bytes:zj,_crypto_verify_32:ji,_crypto_verify_32_bytes:Dj,_crypto_verify_64:ii,_crypto_verify_64_bytes:Cj,_emscripten_replace_memory:ja,_free:wa,_i64Add:Lg,_i64Subtract:Ig,_malloc:na,_memcpy:qb,_memmove:se,_memset:ec,_randombytes:dg,_randombytes_buf:uf,_randombytes_buf_deterministic:nh,_randombytes_close:Ej,_randombytes_implementation_name:Si,_randombytes_random:Hi,_randombytes_seedbytes:Dj,_randombytes_stir:Gi,_randombytes_uniform:kf,_sbrk:be,_sodium_base642bin:Ka,_sodium_base64_encoded_len:lf,_sodium_bin2base64:Ta,_sodium_bin2hex:dd,_sodium_hex2bin:jb,_sodium_init:_f,_sodium_library_minimal:Ej,_sodium_library_version_major:ej,_sodium_library_version_minor:jj,_sodium_pad:hc,_sodium_unpad:Fc,_sodium_version_string:kj,establishStackSpace:ni,getTempRet0:xj,runPostSets:ee,setTempRet0:Yi,setThrew:Yh,stackAlloc:Ch,stackRestore:Vi,stackSave:Bj}})
20577
20578
20579// EMSCRIPTEN_END_ASM
20580(Module.asmGlobalArg,Module.asmLibraryArg,buffer);var ___errno_location=Module["___errno_location"]=asm["___errno_location"];var ___muldi3=Module["___muldi3"]=asm["___muldi3"];var ___udivdi3=Module["___udivdi3"]=asm["___udivdi3"];var ___uremdi3=Module["___uremdi3"]=asm["___uremdi3"];var _bitshift64Ashr=Module["_bitshift64Ashr"]=asm["_bitshift64Ashr"];var _bitshift64Lshr=Module["_bitshift64Lshr"]=asm["_bitshift64Lshr"];var _bitshift64Shl=Module["_bitshift64Shl"]=asm["_bitshift64Shl"];var _crypto_aead_chacha20poly1305_abytes=Module["_crypto_aead_chacha20poly1305_abytes"]=asm["_crypto_aead_chacha20poly1305_abytes"];var _crypto_aead_chacha20poly1305_decrypt=Module["_crypto_aead_chacha20poly1305_decrypt"]=asm["_crypto_aead_chacha20poly1305_decrypt"];var _crypto_aead_chacha20poly1305_decrypt_detached=Module["_crypto_aead_chacha20poly1305_decrypt_detached"]=asm["_crypto_aead_chacha20poly1305_decrypt_detached"];var _crypto_aead_chacha20poly1305_encrypt=Module["_crypto_aead_chacha20poly1305_encrypt"]=asm["_crypto_aead_chacha20poly1305_encrypt"];var _crypto_aead_chacha20poly1305_encrypt_detached=Module["_crypto_aead_chacha20poly1305_encrypt_detached"]=asm["_crypto_aead_chacha20poly1305_encrypt_detached"];var _crypto_aead_chacha20poly1305_ietf_abytes=Module["_crypto_aead_chacha20poly1305_ietf_abytes"]=asm["_crypto_aead_chacha20poly1305_ietf_abytes"];var _crypto_aead_chacha20poly1305_ietf_decrypt=Module["_crypto_aead_chacha20poly1305_ietf_decrypt"]=asm["_crypto_aead_chacha20poly1305_ietf_decrypt"];var _crypto_aead_chacha20poly1305_ietf_decrypt_detached=Module["_crypto_aead_chacha20poly1305_ietf_decrypt_detached"]=asm["_crypto_aead_chacha20poly1305_ietf_decrypt_detached"];var _crypto_aead_chacha20poly1305_ietf_encrypt=Module["_crypto_aead_chacha20poly1305_ietf_encrypt"]=asm["_crypto_aead_chacha20poly1305_ietf_encrypt"];var _crypto_aead_chacha20poly1305_ietf_encrypt_detached=Module["_crypto_aead_chacha20poly1305_ietf_encrypt_detached"]=asm["_crypto_aead_chacha20poly1305_ietf_encrypt_detached"];var _crypto_aead_chacha20poly1305_ietf_keybytes=Module["_crypto_aead_chacha20poly1305_ietf_keybytes"]=asm["_crypto_aead_chacha20poly1305_ietf_keybytes"];var _crypto_aead_chacha20poly1305_ietf_keygen=Module["_crypto_aead_chacha20poly1305_ietf_keygen"]=asm["_crypto_aead_chacha20poly1305_ietf_keygen"];var _crypto_aead_chacha20poly1305_ietf_npubbytes=Module["_crypto_aead_chacha20poly1305_ietf_npubbytes"]=asm["_crypto_aead_chacha20poly1305_ietf_npubbytes"];var _crypto_aead_chacha20poly1305_ietf_nsecbytes=Module["_crypto_aead_chacha20poly1305_ietf_nsecbytes"]=asm["_crypto_aead_chacha20poly1305_ietf_nsecbytes"];var _crypto_aead_chacha20poly1305_keybytes=Module["_crypto_aead_chacha20poly1305_keybytes"]=asm["_crypto_aead_chacha20poly1305_keybytes"];var _crypto_aead_chacha20poly1305_keygen=Module["_crypto_aead_chacha20poly1305_keygen"]=asm["_crypto_aead_chacha20poly1305_keygen"];var _crypto_aead_chacha20poly1305_npubbytes=Module["_crypto_aead_chacha20poly1305_npubbytes"]=asm["_crypto_aead_chacha20poly1305_npubbytes"];var _crypto_aead_chacha20poly1305_nsecbytes=Module["_crypto_aead_chacha20poly1305_nsecbytes"]=asm["_crypto_aead_chacha20poly1305_nsecbytes"];var _crypto_aead_xchacha20poly1305_ietf_abytes=Module["_crypto_aead_xchacha20poly1305_ietf_abytes"]=asm["_crypto_aead_xchacha20poly1305_ietf_abytes"];var _crypto_aead_xchacha20poly1305_ietf_decrypt=Module["_crypto_aead_xchacha20poly1305_ietf_decrypt"]=asm["_crypto_aead_xchacha20poly1305_ietf_decrypt"];var _crypto_aead_xchacha20poly1305_ietf_decrypt_detached=Module["_crypto_aead_xchacha20poly1305_ietf_decrypt_detached"]=asm["_crypto_aead_xchacha20poly1305_ietf_decrypt_detached"];var _crypto_aead_xchacha20poly1305_ietf_encrypt=Module["_crypto_aead_xchacha20poly1305_ietf_encrypt"]=asm["_crypto_aead_xchacha20poly1305_ietf_encrypt"];var _crypto_aead_xchacha20poly1305_ietf_encrypt_detached=Module["_crypto_aead_xchacha20poly1305_ietf_encrypt_detached"]=asm["_crypto_aead_xchacha20poly1305_ietf_encrypt_detached"];var _crypto_aead_xchacha20poly1305_ietf_keybytes=Module["_crypto_aead_xchacha20poly1305_ietf_keybytes"]=asm["_crypto_aead_xchacha20poly1305_ietf_keybytes"];var _crypto_aead_xchacha20poly1305_ietf_keygen=Module["_crypto_aead_xchacha20poly1305_ietf_keygen"]=asm["_crypto_aead_xchacha20poly1305_ietf_keygen"];var _crypto_aead_xchacha20poly1305_ietf_npubbytes=Module["_crypto_aead_xchacha20poly1305_ietf_npubbytes"]=asm["_crypto_aead_xchacha20poly1305_ietf_npubbytes"];var _crypto_aead_xchacha20poly1305_ietf_nsecbytes=Module["_crypto_aead_xchacha20poly1305_ietf_nsecbytes"]=asm["_crypto_aead_xchacha20poly1305_ietf_nsecbytes"];var _crypto_auth=Module["_crypto_auth"]=asm["_crypto_auth"];var _crypto_auth_bytes=Module["_crypto_auth_bytes"]=asm["_crypto_auth_bytes"];var _crypto_auth_hmacsha256=Module["_crypto_auth_hmacsha256"]=asm["_crypto_auth_hmacsha256"];var _crypto_auth_hmacsha256_bytes=Module["_crypto_auth_hmacsha256_bytes"]=asm["_crypto_auth_hmacsha256_bytes"];var _crypto_auth_hmacsha256_final=Module["_crypto_auth_hmacsha256_final"]=asm["_crypto_auth_hmacsha256_final"];var _crypto_auth_hmacsha256_init=Module["_crypto_auth_hmacsha256_init"]=asm["_crypto_auth_hmacsha256_init"];var _crypto_auth_hmacsha256_keybytes=Module["_crypto_auth_hmacsha256_keybytes"]=asm["_crypto_auth_hmacsha256_keybytes"];var _crypto_auth_hmacsha256_keygen=Module["_crypto_auth_hmacsha256_keygen"]=asm["_crypto_auth_hmacsha256_keygen"];var _crypto_auth_hmacsha256_statebytes=Module["_crypto_auth_hmacsha256_statebytes"]=asm["_crypto_auth_hmacsha256_statebytes"];var _crypto_auth_hmacsha256_update=Module["_crypto_auth_hmacsha256_update"]=asm["_crypto_auth_hmacsha256_update"];var _crypto_auth_hmacsha256_verify=Module["_crypto_auth_hmacsha256_verify"]=asm["_crypto_auth_hmacsha256_verify"];var _crypto_auth_hmacsha512=Module["_crypto_auth_hmacsha512"]=asm["_crypto_auth_hmacsha512"];var _crypto_auth_hmacsha512256=Module["_crypto_auth_hmacsha512256"]=asm["_crypto_auth_hmacsha512256"];var _crypto_auth_hmacsha512256_bytes=Module["_crypto_auth_hmacsha512256_bytes"]=asm["_crypto_auth_hmacsha512256_bytes"];var _crypto_auth_hmacsha512256_final=Module["_crypto_auth_hmacsha512256_final"]=asm["_crypto_auth_hmacsha512256_final"];var _crypto_auth_hmacsha512256_init=Module["_crypto_auth_hmacsha512256_init"]=asm["_crypto_auth_hmacsha512256_init"];var _crypto_auth_hmacsha512256_keybytes=Module["_crypto_auth_hmacsha512256_keybytes"]=asm["_crypto_auth_hmacsha512256_keybytes"];var _crypto_auth_hmacsha512256_keygen=Module["_crypto_auth_hmacsha512256_keygen"]=asm["_crypto_auth_hmacsha512256_keygen"];var _crypto_auth_hmacsha512256_statebytes=Module["_crypto_auth_hmacsha512256_statebytes"]=asm["_crypto_auth_hmacsha512256_statebytes"];var _crypto_auth_hmacsha512256_update=Module["_crypto_auth_hmacsha512256_update"]=asm["_crypto_auth_hmacsha512256_update"];var _crypto_auth_hmacsha512256_verify=Module["_crypto_auth_hmacsha512256_verify"]=asm["_crypto_auth_hmacsha512256_verify"];var _crypto_auth_hmacsha512_bytes=Module["_crypto_auth_hmacsha512_bytes"]=asm["_crypto_auth_hmacsha512_bytes"];var _crypto_auth_hmacsha512_final=Module["_crypto_auth_hmacsha512_final"]=asm["_crypto_auth_hmacsha512_final"];var _crypto_auth_hmacsha512_init=Module["_crypto_auth_hmacsha512_init"]=asm["_crypto_auth_hmacsha512_init"];var _crypto_auth_hmacsha512_keybytes=Module["_crypto_auth_hmacsha512_keybytes"]=asm["_crypto_auth_hmacsha512_keybytes"];var _crypto_auth_hmacsha512_keygen=Module["_crypto_auth_hmacsha512_keygen"]=asm["_crypto_auth_hmacsha512_keygen"];var _crypto_auth_hmacsha512_statebytes=Module["_crypto_auth_hmacsha512_statebytes"]=asm["_crypto_auth_hmacsha512_statebytes"];var _crypto_auth_hmacsha512_update=Module["_crypto_auth_hmacsha512_update"]=asm["_crypto_auth_hmacsha512_update"];var _crypto_auth_hmacsha512_verify=Module["_crypto_auth_hmacsha512_verify"]=asm["_crypto_auth_hmacsha512_verify"];var _crypto_auth_keybytes=Module["_crypto_auth_keybytes"]=asm["_crypto_auth_keybytes"];var _crypto_auth_keygen=Module["_crypto_auth_keygen"]=asm["_crypto_auth_keygen"];var _crypto_auth_primitive=Module["_crypto_auth_primitive"]=asm["_crypto_auth_primitive"];var _crypto_auth_verify=Module["_crypto_auth_verify"]=asm["_crypto_auth_verify"];var _crypto_box=Module["_crypto_box"]=asm["_crypto_box"];var _crypto_box_afternm=Module["_crypto_box_afternm"]=asm["_crypto_box_afternm"];var _crypto_box_beforenm=Module["_crypto_box_beforenm"]=asm["_crypto_box_beforenm"];var _crypto_box_beforenmbytes=Module["_crypto_box_beforenmbytes"]=asm["_crypto_box_beforenmbytes"];var _crypto_box_boxzerobytes=Module["_crypto_box_boxzerobytes"]=asm["_crypto_box_boxzerobytes"];var _crypto_box_curve25519xchacha20poly1305_beforenm=Module["_crypto_box_curve25519xchacha20poly1305_beforenm"]=asm["_crypto_box_curve25519xchacha20poly1305_beforenm"];var _crypto_box_curve25519xchacha20poly1305_beforenmbytes=Module["_crypto_box_curve25519xchacha20poly1305_beforenmbytes"]=asm["_crypto_box_curve25519xchacha20poly1305_beforenmbytes"];var _crypto_box_curve25519xchacha20poly1305_detached=Module["_crypto_box_curve25519xchacha20poly1305_detached"]=asm["_crypto_box_curve25519xchacha20poly1305_detached"];var _crypto_box_curve25519xchacha20poly1305_detached_afternm=Module["_crypto_box_curve25519xchacha20poly1305_detached_afternm"]=asm["_crypto_box_curve25519xchacha20poly1305_detached_afternm"];var _crypto_box_curve25519xchacha20poly1305_easy=Module["_crypto_box_curve25519xchacha20poly1305_easy"]=asm["_crypto_box_curve25519xchacha20poly1305_easy"];var _crypto_box_curve25519xchacha20poly1305_easy_afternm=Module["_crypto_box_curve25519xchacha20poly1305_easy_afternm"]=asm["_crypto_box_curve25519xchacha20poly1305_easy_afternm"];var _crypto_box_curve25519xchacha20poly1305_keypair=Module["_crypto_box_curve25519xchacha20poly1305_keypair"]=asm["_crypto_box_curve25519xchacha20poly1305_keypair"];var _crypto_box_curve25519xchacha20poly1305_macbytes=Module["_crypto_box_curve25519xchacha20poly1305_macbytes"]=asm["_crypto_box_curve25519xchacha20poly1305_macbytes"];var _crypto_box_curve25519xchacha20poly1305_noncebytes=Module["_crypto_box_curve25519xchacha20poly1305_noncebytes"]=asm["_crypto_box_curve25519xchacha20poly1305_noncebytes"];var _crypto_box_curve25519xchacha20poly1305_open_detached=Module["_crypto_box_curve25519xchacha20poly1305_open_detached"]=asm["_crypto_box_curve25519xchacha20poly1305_open_detached"];var _crypto_box_curve25519xchacha20poly1305_open_detached_afternm=Module["_crypto_box_curve25519xchacha20poly1305_open_detached_afternm"]=asm["_crypto_box_curve25519xchacha20poly1305_open_detached_afternm"];var _crypto_box_curve25519xchacha20poly1305_open_easy=Module["_crypto_box_curve25519xchacha20poly1305_open_easy"]=asm["_crypto_box_curve25519xchacha20poly1305_open_easy"];var _crypto_box_curve25519xchacha20poly1305_open_easy_afternm=Module["_crypto_box_curve25519xchacha20poly1305_open_easy_afternm"]=asm["_crypto_box_curve25519xchacha20poly1305_open_easy_afternm"];var _crypto_box_curve25519xchacha20poly1305_publickeybytes=Module["_crypto_box_curve25519xchacha20poly1305_publickeybytes"]=asm["_crypto_box_curve25519xchacha20poly1305_publickeybytes"];var _crypto_box_curve25519xchacha20poly1305_seal=Module["_crypto_box_curve25519xchacha20poly1305_seal"]=asm["_crypto_box_curve25519xchacha20poly1305_seal"];var _crypto_box_curve25519xchacha20poly1305_seal_open=Module["_crypto_box_curve25519xchacha20poly1305_seal_open"]=asm["_crypto_box_curve25519xchacha20poly1305_seal_open"];var _crypto_box_curve25519xchacha20poly1305_sealbytes=Module["_crypto_box_curve25519xchacha20poly1305_sealbytes"]=asm["_crypto_box_curve25519xchacha20poly1305_sealbytes"];var _crypto_box_curve25519xchacha20poly1305_secretkeybytes=Module["_crypto_box_curve25519xchacha20poly1305_secretkeybytes"]=asm["_crypto_box_curve25519xchacha20poly1305_secretkeybytes"];var _crypto_box_curve25519xchacha20poly1305_seed_keypair=Module["_crypto_box_curve25519xchacha20poly1305_seed_keypair"]=asm["_crypto_box_curve25519xchacha20poly1305_seed_keypair"];var _crypto_box_curve25519xchacha20poly1305_seedbytes=Module["_crypto_box_curve25519xchacha20poly1305_seedbytes"]=asm["_crypto_box_curve25519xchacha20poly1305_seedbytes"];var _crypto_box_curve25519xsalsa20poly1305=Module["_crypto_box_curve25519xsalsa20poly1305"]=asm["_crypto_box_curve25519xsalsa20poly1305"];var _crypto_box_curve25519xsalsa20poly1305_afternm=Module["_crypto_box_curve25519xsalsa20poly1305_afternm"]=asm["_crypto_box_curve25519xsalsa20poly1305_afternm"];var _crypto_box_curve25519xsalsa20poly1305_beforenm=Module["_crypto_box_curve25519xsalsa20poly1305_beforenm"]=asm["_crypto_box_curve25519xsalsa20poly1305_beforenm"];var _crypto_box_curve25519xsalsa20poly1305_beforenmbytes=Module["_crypto_box_curve25519xsalsa20poly1305_beforenmbytes"]=asm["_crypto_box_curve25519xsalsa20poly1305_beforenmbytes"];var _crypto_box_curve25519xsalsa20poly1305_boxzerobytes=Module["_crypto_box_curve25519xsalsa20poly1305_boxzerobytes"]=asm["_crypto_box_curve25519xsalsa20poly1305_boxzerobytes"];var _crypto_box_curve25519xsalsa20poly1305_keypair=Module["_crypto_box_curve25519xsalsa20poly1305_keypair"]=asm["_crypto_box_curve25519xsalsa20poly1305_keypair"];var _crypto_box_curve25519xsalsa20poly1305_macbytes=Module["_crypto_box_curve25519xsalsa20poly1305_macbytes"]=asm["_crypto_box_curve25519xsalsa20poly1305_macbytes"];var _crypto_box_curve25519xsalsa20poly1305_noncebytes=Module["_crypto_box_curve25519xsalsa20poly1305_noncebytes"]=asm["_crypto_box_curve25519xsalsa20poly1305_noncebytes"];var _crypto_box_curve25519xsalsa20poly1305_open=Module["_crypto_box_curve25519xsalsa20poly1305_open"]=asm["_crypto_box_curve25519xsalsa20poly1305_open"];var _crypto_box_curve25519xsalsa20poly1305_open_afternm=Module["_crypto_box_curve25519xsalsa20poly1305_open_afternm"]=asm["_crypto_box_curve25519xsalsa20poly1305_open_afternm"];var _crypto_box_curve25519xsalsa20poly1305_publickeybytes=Module["_crypto_box_curve25519xsalsa20poly1305_publickeybytes"]=asm["_crypto_box_curve25519xsalsa20poly1305_publickeybytes"];var _crypto_box_curve25519xsalsa20poly1305_secretkeybytes=Module["_crypto_box_curve25519xsalsa20poly1305_secretkeybytes"]=asm["_crypto_box_curve25519xsalsa20poly1305_secretkeybytes"];var _crypto_box_curve25519xsalsa20poly1305_seed_keypair=Module["_crypto_box_curve25519xsalsa20poly1305_seed_keypair"]=asm["_crypto_box_curve25519xsalsa20poly1305_seed_keypair"];var _crypto_box_curve25519xsalsa20poly1305_seedbytes=Module["_crypto_box_curve25519xsalsa20poly1305_seedbytes"]=asm["_crypto_box_curve25519xsalsa20poly1305_seedbytes"];var _crypto_box_curve25519xsalsa20poly1305_zerobytes=Module["_crypto_box_curve25519xsalsa20poly1305_zerobytes"]=asm["_crypto_box_curve25519xsalsa20poly1305_zerobytes"];var _crypto_box_detached=Module["_crypto_box_detached"]=asm["_crypto_box_detached"];var _crypto_box_detached_afternm=Module["_crypto_box_detached_afternm"]=asm["_crypto_box_detached_afternm"];var _crypto_box_easy=Module["_crypto_box_easy"]=asm["_crypto_box_easy"];var _crypto_box_easy_afternm=Module["_crypto_box_easy_afternm"]=asm["_crypto_box_easy_afternm"];var _crypto_box_keypair=Module["_crypto_box_keypair"]=asm["_crypto_box_keypair"];var _crypto_box_macbytes=Module["_crypto_box_macbytes"]=asm["_crypto_box_macbytes"];var _crypto_box_noncebytes=Module["_crypto_box_noncebytes"]=asm["_crypto_box_noncebytes"];var _crypto_box_open=Module["_crypto_box_open"]=asm["_crypto_box_open"];var _crypto_box_open_afternm=Module["_crypto_box_open_afternm"]=asm["_crypto_box_open_afternm"];var _crypto_box_open_detached=Module["_crypto_box_open_detached"]=asm["_crypto_box_open_detached"];var _crypto_box_open_detached_afternm=Module["_crypto_box_open_detached_afternm"]=asm["_crypto_box_open_detached_afternm"];var _crypto_box_open_easy=Module["_crypto_box_open_easy"]=asm["_crypto_box_open_easy"];var _crypto_box_open_easy_afternm=Module["_crypto_box_open_easy_afternm"]=asm["_crypto_box_open_easy_afternm"];var _crypto_box_primitive=Module["_crypto_box_primitive"]=asm["_crypto_box_primitive"];var _crypto_box_publickeybytes=Module["_crypto_box_publickeybytes"]=asm["_crypto_box_publickeybytes"];var _crypto_box_seal=Module["_crypto_box_seal"]=asm["_crypto_box_seal"];var _crypto_box_seal_open=Module["_crypto_box_seal_open"]=asm["_crypto_box_seal_open"];var _crypto_box_sealbytes=Module["_crypto_box_sealbytes"]=asm["_crypto_box_sealbytes"];var _crypto_box_secretkeybytes=Module["_crypto_box_secretkeybytes"]=asm["_crypto_box_secretkeybytes"];var _crypto_box_seed_keypair=Module["_crypto_box_seed_keypair"]=asm["_crypto_box_seed_keypair"];var _crypto_box_seedbytes=Module["_crypto_box_seedbytes"]=asm["_crypto_box_seedbytes"];var _crypto_box_zerobytes=Module["_crypto_box_zerobytes"]=asm["_crypto_box_zerobytes"];var _crypto_core_ed25519_add=Module["_crypto_core_ed25519_add"]=asm["_crypto_core_ed25519_add"];var _crypto_core_ed25519_bytes=Module["_crypto_core_ed25519_bytes"]=asm["_crypto_core_ed25519_bytes"];var _crypto_core_ed25519_from_uniform=Module["_crypto_core_ed25519_from_uniform"]=asm["_crypto_core_ed25519_from_uniform"];var _crypto_core_ed25519_is_valid_point=Module["_crypto_core_ed25519_is_valid_point"]=asm["_crypto_core_ed25519_is_valid_point"];var _crypto_core_ed25519_sub=Module["_crypto_core_ed25519_sub"]=asm["_crypto_core_ed25519_sub"];var _crypto_core_ed25519_uniformbytes=Module["_crypto_core_ed25519_uniformbytes"]=asm["_crypto_core_ed25519_uniformbytes"];var _crypto_core_hchacha20=Module["_crypto_core_hchacha20"]=asm["_crypto_core_hchacha20"];var _crypto_core_hchacha20_constbytes=Module["_crypto_core_hchacha20_constbytes"]=asm["_crypto_core_hchacha20_constbytes"];var _crypto_core_hchacha20_inputbytes=Module["_crypto_core_hchacha20_inputbytes"]=asm["_crypto_core_hchacha20_inputbytes"];var _crypto_core_hchacha20_keybytes=Module["_crypto_core_hchacha20_keybytes"]=asm["_crypto_core_hchacha20_keybytes"];var _crypto_core_hchacha20_outputbytes=Module["_crypto_core_hchacha20_outputbytes"]=asm["_crypto_core_hchacha20_outputbytes"];var _crypto_core_hsalsa20=Module["_crypto_core_hsalsa20"]=asm["_crypto_core_hsalsa20"];var _crypto_core_hsalsa20_constbytes=Module["_crypto_core_hsalsa20_constbytes"]=asm["_crypto_core_hsalsa20_constbytes"];var _crypto_core_hsalsa20_inputbytes=Module["_crypto_core_hsalsa20_inputbytes"]=asm["_crypto_core_hsalsa20_inputbytes"];var _crypto_core_hsalsa20_keybytes=Module["_crypto_core_hsalsa20_keybytes"]=asm["_crypto_core_hsalsa20_keybytes"];var _crypto_core_hsalsa20_outputbytes=Module["_crypto_core_hsalsa20_outputbytes"]=asm["_crypto_core_hsalsa20_outputbytes"];var _crypto_core_salsa20=Module["_crypto_core_salsa20"]=asm["_crypto_core_salsa20"];var _crypto_core_salsa2012=Module["_crypto_core_salsa2012"]=asm["_crypto_core_salsa2012"];var _crypto_core_salsa2012_constbytes=Module["_crypto_core_salsa2012_constbytes"]=asm["_crypto_core_salsa2012_constbytes"];var _crypto_core_salsa2012_inputbytes=Module["_crypto_core_salsa2012_inputbytes"]=asm["_crypto_core_salsa2012_inputbytes"];var _crypto_core_salsa2012_keybytes=Module["_crypto_core_salsa2012_keybytes"]=asm["_crypto_core_salsa2012_keybytes"];var _crypto_core_salsa2012_outputbytes=Module["_crypto_core_salsa2012_outputbytes"]=asm["_crypto_core_salsa2012_outputbytes"];var _crypto_core_salsa208=Module["_crypto_core_salsa208"]=asm["_crypto_core_salsa208"];var _crypto_core_salsa208_constbytes=Module["_crypto_core_salsa208_constbytes"]=asm["_crypto_core_salsa208_constbytes"];var _crypto_core_salsa208_inputbytes=Module["_crypto_core_salsa208_inputbytes"]=asm["_crypto_core_salsa208_inputbytes"];var _crypto_core_salsa208_keybytes=Module["_crypto_core_salsa208_keybytes"]=asm["_crypto_core_salsa208_keybytes"];var _crypto_core_salsa208_outputbytes=Module["_crypto_core_salsa208_outputbytes"]=asm["_crypto_core_salsa208_outputbytes"];var _crypto_core_salsa20_constbytes=Module["_crypto_core_salsa20_constbytes"]=asm["_crypto_core_salsa20_constbytes"];var _crypto_core_salsa20_inputbytes=Module["_crypto_core_salsa20_inputbytes"]=asm["_crypto_core_salsa20_inputbytes"];var _crypto_core_salsa20_keybytes=Module["_crypto_core_salsa20_keybytes"]=asm["_crypto_core_salsa20_keybytes"];var _crypto_core_salsa20_outputbytes=Module["_crypto_core_salsa20_outputbytes"]=asm["_crypto_core_salsa20_outputbytes"];var _crypto_generichash=Module["_crypto_generichash"]=asm["_crypto_generichash"];var _crypto_generichash_blake2b=Module["_crypto_generichash_blake2b"]=asm["_crypto_generichash_blake2b"];var _crypto_generichash_blake2b_bytes=Module["_crypto_generichash_blake2b_bytes"]=asm["_crypto_generichash_blake2b_bytes"];var _crypto_generichash_blake2b_bytes_max=Module["_crypto_generichash_blake2b_bytes_max"]=asm["_crypto_generichash_blake2b_bytes_max"];var _crypto_generichash_blake2b_bytes_min=Module["_crypto_generichash_blake2b_bytes_min"]=asm["_crypto_generichash_blake2b_bytes_min"];var _crypto_generichash_blake2b_final=Module["_crypto_generichash_blake2b_final"]=asm["_crypto_generichash_blake2b_final"];var _crypto_generichash_blake2b_init=Module["_crypto_generichash_blake2b_init"]=asm["_crypto_generichash_blake2b_init"];var _crypto_generichash_blake2b_init_salt_personal=Module["_crypto_generichash_blake2b_init_salt_personal"]=asm["_crypto_generichash_blake2b_init_salt_personal"];var _crypto_generichash_blake2b_keybytes=Module["_crypto_generichash_blake2b_keybytes"]=asm["_crypto_generichash_blake2b_keybytes"];var _crypto_generichash_blake2b_keybytes_max=Module["_crypto_generichash_blake2b_keybytes_max"]=asm["_crypto_generichash_blake2b_keybytes_max"];var _crypto_generichash_blake2b_keybytes_min=Module["_crypto_generichash_blake2b_keybytes_min"]=asm["_crypto_generichash_blake2b_keybytes_min"];var _crypto_generichash_blake2b_keygen=Module["_crypto_generichash_blake2b_keygen"]=asm["_crypto_generichash_blake2b_keygen"];var _crypto_generichash_blake2b_personalbytes=Module["_crypto_generichash_blake2b_personalbytes"]=asm["_crypto_generichash_blake2b_personalbytes"];var _crypto_generichash_blake2b_salt_personal=Module["_crypto_generichash_blake2b_salt_personal"]=asm["_crypto_generichash_blake2b_salt_personal"];var _crypto_generichash_blake2b_saltbytes=Module["_crypto_generichash_blake2b_saltbytes"]=asm["_crypto_generichash_blake2b_saltbytes"];var _crypto_generichash_blake2b_statebytes=Module["_crypto_generichash_blake2b_statebytes"]=asm["_crypto_generichash_blake2b_statebytes"];var _crypto_generichash_blake2b_update=Module["_crypto_generichash_blake2b_update"]=asm["_crypto_generichash_blake2b_update"];var _crypto_generichash_bytes=Module["_crypto_generichash_bytes"]=asm["_crypto_generichash_bytes"];var _crypto_generichash_bytes_max=Module["_crypto_generichash_bytes_max"]=asm["_crypto_generichash_bytes_max"];var _crypto_generichash_bytes_min=Module["_crypto_generichash_bytes_min"]=asm["_crypto_generichash_bytes_min"];var _crypto_generichash_final=Module["_crypto_generichash_final"]=asm["_crypto_generichash_final"];var _crypto_generichash_init=Module["_crypto_generichash_init"]=asm["_crypto_generichash_init"];var _crypto_generichash_keybytes=Module["_crypto_generichash_keybytes"]=asm["_crypto_generichash_keybytes"];var _crypto_generichash_keybytes_max=Module["_crypto_generichash_keybytes_max"]=asm["_crypto_generichash_keybytes_max"];var _crypto_generichash_keybytes_min=Module["_crypto_generichash_keybytes_min"]=asm["_crypto_generichash_keybytes_min"];var _crypto_generichash_keygen=Module["_crypto_generichash_keygen"]=asm["_crypto_generichash_keygen"];var _crypto_generichash_primitive=Module["_crypto_generichash_primitive"]=asm["_crypto_generichash_primitive"];var _crypto_generichash_statebytes=Module["_crypto_generichash_statebytes"]=asm["_crypto_generichash_statebytes"];var _crypto_generichash_update=Module["_crypto_generichash_update"]=asm["_crypto_generichash_update"];var _crypto_hash=Module["_crypto_hash"]=asm["_crypto_hash"];var _crypto_hash_bytes=Module["_crypto_hash_bytes"]=asm["_crypto_hash_bytes"];var _crypto_hash_primitive=Module["_crypto_hash_primitive"]=asm["_crypto_hash_primitive"];var _crypto_hash_sha256=Module["_crypto_hash_sha256"]=asm["_crypto_hash_sha256"];var _crypto_hash_sha256_bytes=Module["_crypto_hash_sha256_bytes"]=asm["_crypto_hash_sha256_bytes"];var _crypto_hash_sha256_final=Module["_crypto_hash_sha256_final"]=asm["_crypto_hash_sha256_final"];var _crypto_hash_sha256_init=Module["_crypto_hash_sha256_init"]=asm["_crypto_hash_sha256_init"];var _crypto_hash_sha256_statebytes=Module["_crypto_hash_sha256_statebytes"]=asm["_crypto_hash_sha256_statebytes"];var _crypto_hash_sha256_update=Module["_crypto_hash_sha256_update"]=asm["_crypto_hash_sha256_update"];var _crypto_hash_sha512=Module["_crypto_hash_sha512"]=asm["_crypto_hash_sha512"];var _crypto_hash_sha512_bytes=Module["_crypto_hash_sha512_bytes"]=asm["_crypto_hash_sha512_bytes"];var _crypto_hash_sha512_final=Module["_crypto_hash_sha512_final"]=asm["_crypto_hash_sha512_final"];var _crypto_hash_sha512_init=Module["_crypto_hash_sha512_init"]=asm["_crypto_hash_sha512_init"];var _crypto_hash_sha512_statebytes=Module["_crypto_hash_sha512_statebytes"]=asm["_crypto_hash_sha512_statebytes"];var _crypto_hash_sha512_update=Module["_crypto_hash_sha512_update"]=asm["_crypto_hash_sha512_update"];var _crypto_kdf_blake2b_bytes_max=Module["_crypto_kdf_blake2b_bytes_max"]=asm["_crypto_kdf_blake2b_bytes_max"];var _crypto_kdf_blake2b_bytes_min=Module["_crypto_kdf_blake2b_bytes_min"]=asm["_crypto_kdf_blake2b_bytes_min"];var _crypto_kdf_blake2b_contextbytes=Module["_crypto_kdf_blake2b_contextbytes"]=asm["_crypto_kdf_blake2b_contextbytes"];var _crypto_kdf_blake2b_derive_from_key=Module["_crypto_kdf_blake2b_derive_from_key"]=asm["_crypto_kdf_blake2b_derive_from_key"];var _crypto_kdf_blake2b_keybytes=Module["_crypto_kdf_blake2b_keybytes"]=asm["_crypto_kdf_blake2b_keybytes"];var _crypto_kdf_bytes_max=Module["_crypto_kdf_bytes_max"]=asm["_crypto_kdf_bytes_max"];var _crypto_kdf_bytes_min=Module["_crypto_kdf_bytes_min"]=asm["_crypto_kdf_bytes_min"];var _crypto_kdf_contextbytes=Module["_crypto_kdf_contextbytes"]=asm["_crypto_kdf_contextbytes"];var _crypto_kdf_derive_from_key=Module["_crypto_kdf_derive_from_key"]=asm["_crypto_kdf_derive_from_key"];var _crypto_kdf_keybytes=Module["_crypto_kdf_keybytes"]=asm["_crypto_kdf_keybytes"];var _crypto_kdf_keygen=Module["_crypto_kdf_keygen"]=asm["_crypto_kdf_keygen"];var _crypto_kdf_primitive=Module["_crypto_kdf_primitive"]=asm["_crypto_kdf_primitive"];var _crypto_kx_client_session_keys=Module["_crypto_kx_client_session_keys"]=asm["_crypto_kx_client_session_keys"];var _crypto_kx_keypair=Module["_crypto_kx_keypair"]=asm["_crypto_kx_keypair"];var _crypto_kx_primitive=Module["_crypto_kx_primitive"]=asm["_crypto_kx_primitive"];var _crypto_kx_publickeybytes=Module["_crypto_kx_publickeybytes"]=asm["_crypto_kx_publickeybytes"];var _crypto_kx_secretkeybytes=Module["_crypto_kx_secretkeybytes"]=asm["_crypto_kx_secretkeybytes"];var _crypto_kx_seed_keypair=Module["_crypto_kx_seed_keypair"]=asm["_crypto_kx_seed_keypair"];var _crypto_kx_seedbytes=Module["_crypto_kx_seedbytes"]=asm["_crypto_kx_seedbytes"];var _crypto_kx_server_session_keys=Module["_crypto_kx_server_session_keys"]=asm["_crypto_kx_server_session_keys"];var _crypto_kx_sessionkeybytes=Module["_crypto_kx_sessionkeybytes"]=asm["_crypto_kx_sessionkeybytes"];var _crypto_onetimeauth=Module["_crypto_onetimeauth"]=asm["_crypto_onetimeauth"];var _crypto_onetimeauth_bytes=Module["_crypto_onetimeauth_bytes"]=asm["_crypto_onetimeauth_bytes"];var _crypto_onetimeauth_final=Module["_crypto_onetimeauth_final"]=asm["_crypto_onetimeauth_final"];var _crypto_onetimeauth_init=Module["_crypto_onetimeauth_init"]=asm["_crypto_onetimeauth_init"];var _crypto_onetimeauth_keybytes=Module["_crypto_onetimeauth_keybytes"]=asm["_crypto_onetimeauth_keybytes"];var _crypto_onetimeauth_keygen=Module["_crypto_onetimeauth_keygen"]=asm["_crypto_onetimeauth_keygen"];var _crypto_onetimeauth_poly1305=Module["_crypto_onetimeauth_poly1305"]=asm["_crypto_onetimeauth_poly1305"];var _crypto_onetimeauth_poly1305_bytes=Module["_crypto_onetimeauth_poly1305_bytes"]=asm["_crypto_onetimeauth_poly1305_bytes"];var _crypto_onetimeauth_poly1305_final=Module["_crypto_onetimeauth_poly1305_final"]=asm["_crypto_onetimeauth_poly1305_final"];var _crypto_onetimeauth_poly1305_init=Module["_crypto_onetimeauth_poly1305_init"]=asm["_crypto_onetimeauth_poly1305_init"];var _crypto_onetimeauth_poly1305_keybytes=Module["_crypto_onetimeauth_poly1305_keybytes"]=asm["_crypto_onetimeauth_poly1305_keybytes"];var _crypto_onetimeauth_poly1305_keygen=Module["_crypto_onetimeauth_poly1305_keygen"]=asm["_crypto_onetimeauth_poly1305_keygen"];var _crypto_onetimeauth_poly1305_statebytes=Module["_crypto_onetimeauth_poly1305_statebytes"]=asm["_crypto_onetimeauth_poly1305_statebytes"];var _crypto_onetimeauth_poly1305_update=Module["_crypto_onetimeauth_poly1305_update"]=asm["_crypto_onetimeauth_poly1305_update"];var _crypto_onetimeauth_poly1305_verify=Module["_crypto_onetimeauth_poly1305_verify"]=asm["_crypto_onetimeauth_poly1305_verify"];var _crypto_onetimeauth_primitive=Module["_crypto_onetimeauth_primitive"]=asm["_crypto_onetimeauth_primitive"];var _crypto_onetimeauth_statebytes=Module["_crypto_onetimeauth_statebytes"]=asm["_crypto_onetimeauth_statebytes"];var _crypto_onetimeauth_update=Module["_crypto_onetimeauth_update"]=asm["_crypto_onetimeauth_update"];var _crypto_onetimeauth_verify=Module["_crypto_onetimeauth_verify"]=asm["_crypto_onetimeauth_verify"];var _crypto_pwhash=Module["_crypto_pwhash"]=asm["_crypto_pwhash"];var _crypto_pwhash_alg_argon2i13=Module["_crypto_pwhash_alg_argon2i13"]=asm["_crypto_pwhash_alg_argon2i13"];var _crypto_pwhash_alg_argon2id13=Module["_crypto_pwhash_alg_argon2id13"]=asm["_crypto_pwhash_alg_argon2id13"];var _crypto_pwhash_alg_default=Module["_crypto_pwhash_alg_default"]=asm["_crypto_pwhash_alg_default"];var _crypto_pwhash_argon2i=Module["_crypto_pwhash_argon2i"]=asm["_crypto_pwhash_argon2i"];var _crypto_pwhash_argon2i_alg_argon2i13=Module["_crypto_pwhash_argon2i_alg_argon2i13"]=asm["_crypto_pwhash_argon2i_alg_argon2i13"];var _crypto_pwhash_argon2i_bytes_max=Module["_crypto_pwhash_argon2i_bytes_max"]=asm["_crypto_pwhash_argon2i_bytes_max"];var _crypto_pwhash_argon2i_bytes_min=Module["_crypto_pwhash_argon2i_bytes_min"]=asm["_crypto_pwhash_argon2i_bytes_min"];var _crypto_pwhash_argon2i_memlimit_interactive=Module["_crypto_pwhash_argon2i_memlimit_interactive"]=asm["_crypto_pwhash_argon2i_memlimit_interactive"];var _crypto_pwhash_argon2i_memlimit_max=Module["_crypto_pwhash_argon2i_memlimit_max"]=asm["_crypto_pwhash_argon2i_memlimit_max"];var _crypto_pwhash_argon2i_memlimit_min=Module["_crypto_pwhash_argon2i_memlimit_min"]=asm["_crypto_pwhash_argon2i_memlimit_min"];var _crypto_pwhash_argon2i_memlimit_moderate=Module["_crypto_pwhash_argon2i_memlimit_moderate"]=asm["_crypto_pwhash_argon2i_memlimit_moderate"];var _crypto_pwhash_argon2i_memlimit_sensitive=Module["_crypto_pwhash_argon2i_memlimit_sensitive"]=asm["_crypto_pwhash_argon2i_memlimit_sensitive"];var _crypto_pwhash_argon2i_opslimit_interactive=Module["_crypto_pwhash_argon2i_opslimit_interactive"]=asm["_crypto_pwhash_argon2i_opslimit_interactive"];var _crypto_pwhash_argon2i_opslimit_max=Module["_crypto_pwhash_argon2i_opslimit_max"]=asm["_crypto_pwhash_argon2i_opslimit_max"];var _crypto_pwhash_argon2i_opslimit_min=Module["_crypto_pwhash_argon2i_opslimit_min"]=asm["_crypto_pwhash_argon2i_opslimit_min"];var _crypto_pwhash_argon2i_opslimit_moderate=Module["_crypto_pwhash_argon2i_opslimit_moderate"]=asm["_crypto_pwhash_argon2i_opslimit_moderate"];var _crypto_pwhash_argon2i_opslimit_sensitive=Module["_crypto_pwhash_argon2i_opslimit_sensitive"]=asm["_crypto_pwhash_argon2i_opslimit_sensitive"];var _crypto_pwhash_argon2i_passwd_max=Module["_crypto_pwhash_argon2i_passwd_max"]=asm["_crypto_pwhash_argon2i_passwd_max"];var _crypto_pwhash_argon2i_passwd_min=Module["_crypto_pwhash_argon2i_passwd_min"]=asm["_crypto_pwhash_argon2i_passwd_min"];var _crypto_pwhash_argon2i_saltbytes=Module["_crypto_pwhash_argon2i_saltbytes"]=asm["_crypto_pwhash_argon2i_saltbytes"];var _crypto_pwhash_argon2i_str=Module["_crypto_pwhash_argon2i_str"]=asm["_crypto_pwhash_argon2i_str"];var _crypto_pwhash_argon2i_str_needs_rehash=Module["_crypto_pwhash_argon2i_str_needs_rehash"]=asm["_crypto_pwhash_argon2i_str_needs_rehash"];var _crypto_pwhash_argon2i_str_verify=Module["_crypto_pwhash_argon2i_str_verify"]=asm["_crypto_pwhash_argon2i_str_verify"];var _crypto_pwhash_argon2i_strbytes=Module["_crypto_pwhash_argon2i_strbytes"]=asm["_crypto_pwhash_argon2i_strbytes"];var _crypto_pwhash_argon2i_strprefix=Module["_crypto_pwhash_argon2i_strprefix"]=asm["_crypto_pwhash_argon2i_strprefix"];var _crypto_pwhash_argon2id=Module["_crypto_pwhash_argon2id"]=asm["_crypto_pwhash_argon2id"];var _crypto_pwhash_argon2id_alg_argon2id13=Module["_crypto_pwhash_argon2id_alg_argon2id13"]=asm["_crypto_pwhash_argon2id_alg_argon2id13"];var _crypto_pwhash_argon2id_bytes_max=Module["_crypto_pwhash_argon2id_bytes_max"]=asm["_crypto_pwhash_argon2id_bytes_max"];var _crypto_pwhash_argon2id_bytes_min=Module["_crypto_pwhash_argon2id_bytes_min"]=asm["_crypto_pwhash_argon2id_bytes_min"];var _crypto_pwhash_argon2id_memlimit_interactive=Module["_crypto_pwhash_argon2id_memlimit_interactive"]=asm["_crypto_pwhash_argon2id_memlimit_interactive"];var _crypto_pwhash_argon2id_memlimit_max=Module["_crypto_pwhash_argon2id_memlimit_max"]=asm["_crypto_pwhash_argon2id_memlimit_max"];var _crypto_pwhash_argon2id_memlimit_min=Module["_crypto_pwhash_argon2id_memlimit_min"]=asm["_crypto_pwhash_argon2id_memlimit_min"];var _crypto_pwhash_argon2id_memlimit_moderate=Module["_crypto_pwhash_argon2id_memlimit_moderate"]=asm["_crypto_pwhash_argon2id_memlimit_moderate"];var _crypto_pwhash_argon2id_memlimit_sensitive=Module["_crypto_pwhash_argon2id_memlimit_sensitive"]=asm["_crypto_pwhash_argon2id_memlimit_sensitive"];var _crypto_pwhash_argon2id_opslimit_interactive=Module["_crypto_pwhash_argon2id_opslimit_interactive"]=asm["_crypto_pwhash_argon2id_opslimit_interactive"];var _crypto_pwhash_argon2id_opslimit_max=Module["_crypto_pwhash_argon2id_opslimit_max"]=asm["_crypto_pwhash_argon2id_opslimit_max"];var _crypto_pwhash_argon2id_opslimit_min=Module["_crypto_pwhash_argon2id_opslimit_min"]=asm["_crypto_pwhash_argon2id_opslimit_min"];var _crypto_pwhash_argon2id_opslimit_moderate=Module["_crypto_pwhash_argon2id_opslimit_moderate"]=asm["_crypto_pwhash_argon2id_opslimit_moderate"];var _crypto_pwhash_argon2id_opslimit_sensitive=Module["_crypto_pwhash_argon2id_opslimit_sensitive"]=asm["_crypto_pwhash_argon2id_opslimit_sensitive"];var _crypto_pwhash_argon2id_passwd_max=Module["_crypto_pwhash_argon2id_passwd_max"]=asm["_crypto_pwhash_argon2id_passwd_max"];var _crypto_pwhash_argon2id_passwd_min=Module["_crypto_pwhash_argon2id_passwd_min"]=asm["_crypto_pwhash_argon2id_passwd_min"];var _crypto_pwhash_argon2id_saltbytes=Module["_crypto_pwhash_argon2id_saltbytes"]=asm["_crypto_pwhash_argon2id_saltbytes"];var _crypto_pwhash_argon2id_str=Module["_crypto_pwhash_argon2id_str"]=asm["_crypto_pwhash_argon2id_str"];var _crypto_pwhash_argon2id_str_needs_rehash=Module["_crypto_pwhash_argon2id_str_needs_rehash"]=asm["_crypto_pwhash_argon2id_str_needs_rehash"];var _crypto_pwhash_argon2id_str_verify=Module["_crypto_pwhash_argon2id_str_verify"]=asm["_crypto_pwhash_argon2id_str_verify"];var _crypto_pwhash_argon2id_strbytes=Module["_crypto_pwhash_argon2id_strbytes"]=asm["_crypto_pwhash_argon2id_strbytes"];var _crypto_pwhash_argon2id_strprefix=Module["_crypto_pwhash_argon2id_strprefix"]=asm["_crypto_pwhash_argon2id_strprefix"];var _crypto_pwhash_bytes_max=Module["_crypto_pwhash_bytes_max"]=asm["_crypto_pwhash_bytes_max"];var _crypto_pwhash_bytes_min=Module["_crypto_pwhash_bytes_min"]=asm["_crypto_pwhash_bytes_min"];var _crypto_pwhash_memlimit_interactive=Module["_crypto_pwhash_memlimit_interactive"]=asm["_crypto_pwhash_memlimit_interactive"];var _crypto_pwhash_memlimit_max=Module["_crypto_pwhash_memlimit_max"]=asm["_crypto_pwhash_memlimit_max"];var _crypto_pwhash_memlimit_min=Module["_crypto_pwhash_memlimit_min"]=asm["_crypto_pwhash_memlimit_min"];var _crypto_pwhash_memlimit_moderate=Module["_crypto_pwhash_memlimit_moderate"]=asm["_crypto_pwhash_memlimit_moderate"];var _crypto_pwhash_memlimit_sensitive=Module["_crypto_pwhash_memlimit_sensitive"]=asm["_crypto_pwhash_memlimit_sensitive"];var _crypto_pwhash_opslimit_interactive=Module["_crypto_pwhash_opslimit_interactive"]=asm["_crypto_pwhash_opslimit_interactive"];var _crypto_pwhash_opslimit_max=Module["_crypto_pwhash_opslimit_max"]=asm["_crypto_pwhash_opslimit_max"];var _crypto_pwhash_opslimit_min=Module["_crypto_pwhash_opslimit_min"]=asm["_crypto_pwhash_opslimit_min"];var _crypto_pwhash_opslimit_moderate=Module["_crypto_pwhash_opslimit_moderate"]=asm["_crypto_pwhash_opslimit_moderate"];var _crypto_pwhash_opslimit_sensitive=Module["_crypto_pwhash_opslimit_sensitive"]=asm["_crypto_pwhash_opslimit_sensitive"];var _crypto_pwhash_passwd_max=Module["_crypto_pwhash_passwd_max"]=asm["_crypto_pwhash_passwd_max"];var _crypto_pwhash_passwd_min=Module["_crypto_pwhash_passwd_min"]=asm["_crypto_pwhash_passwd_min"];var _crypto_pwhash_primitive=Module["_crypto_pwhash_primitive"]=asm["_crypto_pwhash_primitive"];var _crypto_pwhash_saltbytes=Module["_crypto_pwhash_saltbytes"]=asm["_crypto_pwhash_saltbytes"];var _crypto_pwhash_scryptsalsa208sha256=Module["_crypto_pwhash_scryptsalsa208sha256"]=asm["_crypto_pwhash_scryptsalsa208sha256"];var _crypto_pwhash_scryptsalsa208sha256_bytes_max=Module["_crypto_pwhash_scryptsalsa208sha256_bytes_max"]=asm["_crypto_pwhash_scryptsalsa208sha256_bytes_max"];var _crypto_pwhash_scryptsalsa208sha256_bytes_min=Module["_crypto_pwhash_scryptsalsa208sha256_bytes_min"]=asm["_crypto_pwhash_scryptsalsa208sha256_bytes_min"];var _crypto_pwhash_scryptsalsa208sha256_ll=Module["_crypto_pwhash_scryptsalsa208sha256_ll"]=asm["_crypto_pwhash_scryptsalsa208sha256_ll"];var _crypto_pwhash_scryptsalsa208sha256_memlimit_interactive=Module["_crypto_pwhash_scryptsalsa208sha256_memlimit_interactive"]=asm["_crypto_pwhash_scryptsalsa208sha256_memlimit_interactive"];var _crypto_pwhash_scryptsalsa208sha256_memlimit_max=Module["_crypto_pwhash_scryptsalsa208sha256_memlimit_max"]=asm["_crypto_pwhash_scryptsalsa208sha256_memlimit_max"];var _crypto_pwhash_scryptsalsa208sha256_memlimit_min=Module["_crypto_pwhash_scryptsalsa208sha256_memlimit_min"]=asm["_crypto_pwhash_scryptsalsa208sha256_memlimit_min"];var _crypto_pwhash_scryptsalsa208sha256_memlimit_sensitive=Module["_crypto_pwhash_scryptsalsa208sha256_memlimit_sensitive"]=asm["_crypto_pwhash_scryptsalsa208sha256_memlimit_sensitive"];var _crypto_pwhash_scryptsalsa208sha256_opslimit_interactive=Module["_crypto_pwhash_scryptsalsa208sha256_opslimit_interactive"]=asm["_crypto_pwhash_scryptsalsa208sha256_opslimit_interactive"];var _crypto_pwhash_scryptsalsa208sha256_opslimit_max=Module["_crypto_pwhash_scryptsalsa208sha256_opslimit_max"]=asm["_crypto_pwhash_scryptsalsa208sha256_opslimit_max"];var _crypto_pwhash_scryptsalsa208sha256_opslimit_min=Module["_crypto_pwhash_scryptsalsa208sha256_opslimit_min"]=asm["_crypto_pwhash_scryptsalsa208sha256_opslimit_min"];var _crypto_pwhash_scryptsalsa208sha256_opslimit_sensitive=Module["_crypto_pwhash_scryptsalsa208sha256_opslimit_sensitive"]=asm["_crypto_pwhash_scryptsalsa208sha256_opslimit_sensitive"];var _crypto_pwhash_scryptsalsa208sha256_passwd_max=Module["_crypto_pwhash_scryptsalsa208sha256_passwd_max"]=asm["_crypto_pwhash_scryptsalsa208sha256_passwd_max"];var _crypto_pwhash_scryptsalsa208sha256_passwd_min=Module["_crypto_pwhash_scryptsalsa208sha256_passwd_min"]=asm["_crypto_pwhash_scryptsalsa208sha256_passwd_min"];var _crypto_pwhash_scryptsalsa208sha256_saltbytes=Module["_crypto_pwhash_scryptsalsa208sha256_saltbytes"]=asm["_crypto_pwhash_scryptsalsa208sha256_saltbytes"];var _crypto_pwhash_scryptsalsa208sha256_str=Module["_crypto_pwhash_scryptsalsa208sha256_str"]=asm["_crypto_pwhash_scryptsalsa208sha256_str"];var _crypto_pwhash_scryptsalsa208sha256_str_needs_rehash=Module["_crypto_pwhash_scryptsalsa208sha256_str_needs_rehash"]=asm["_crypto_pwhash_scryptsalsa208sha256_str_needs_rehash"];var _crypto_pwhash_scryptsalsa208sha256_str_verify=Module["_crypto_pwhash_scryptsalsa208sha256_str_verify"]=asm["_crypto_pwhash_scryptsalsa208sha256_str_verify"];var _crypto_pwhash_scryptsalsa208sha256_strbytes=Module["_crypto_pwhash_scryptsalsa208sha256_strbytes"]=asm["_crypto_pwhash_scryptsalsa208sha256_strbytes"];var _crypto_pwhash_scryptsalsa208sha256_strprefix=Module["_crypto_pwhash_scryptsalsa208sha256_strprefix"]=asm["_crypto_pwhash_scryptsalsa208sha256_strprefix"];var _crypto_pwhash_str=Module["_crypto_pwhash_str"]=asm["_crypto_pwhash_str"];var _crypto_pwhash_str_alg=Module["_crypto_pwhash_str_alg"]=asm["_crypto_pwhash_str_alg"];var _crypto_pwhash_str_needs_rehash=Module["_crypto_pwhash_str_needs_rehash"]=asm["_crypto_pwhash_str_needs_rehash"];var _crypto_pwhash_str_verify=Module["_crypto_pwhash_str_verify"]=asm["_crypto_pwhash_str_verify"];var _crypto_pwhash_strbytes=Module["_crypto_pwhash_strbytes"]=asm["_crypto_pwhash_strbytes"];var _crypto_pwhash_strprefix=Module["_crypto_pwhash_strprefix"]=asm["_crypto_pwhash_strprefix"];var _crypto_scalarmult=Module["_crypto_scalarmult"]=asm["_crypto_scalarmult"];var _crypto_scalarmult_base=Module["_crypto_scalarmult_base"]=asm["_crypto_scalarmult_base"];var _crypto_scalarmult_bytes=Module["_crypto_scalarmult_bytes"]=asm["_crypto_scalarmult_bytes"];var _crypto_scalarmult_curve25519=Module["_crypto_scalarmult_curve25519"]=asm["_crypto_scalarmult_curve25519"];var _crypto_scalarmult_curve25519_base=Module["_crypto_scalarmult_curve25519_base"]=asm["_crypto_scalarmult_curve25519_base"];var _crypto_scalarmult_curve25519_bytes=Module["_crypto_scalarmult_curve25519_bytes"]=asm["_crypto_scalarmult_curve25519_bytes"];var _crypto_scalarmult_curve25519_scalarbytes=Module["_crypto_scalarmult_curve25519_scalarbytes"]=asm["_crypto_scalarmult_curve25519_scalarbytes"];var _crypto_scalarmult_ed25519=Module["_crypto_scalarmult_ed25519"]=asm["_crypto_scalarmult_ed25519"];var _crypto_scalarmult_ed25519_base=Module["_crypto_scalarmult_ed25519_base"]=asm["_crypto_scalarmult_ed25519_base"];var _crypto_scalarmult_ed25519_bytes=Module["_crypto_scalarmult_ed25519_bytes"]=asm["_crypto_scalarmult_ed25519_bytes"];var _crypto_scalarmult_ed25519_scalarbytes=Module["_crypto_scalarmult_ed25519_scalarbytes"]=asm["_crypto_scalarmult_ed25519_scalarbytes"];var _crypto_scalarmult_primitive=Module["_crypto_scalarmult_primitive"]=asm["_crypto_scalarmult_primitive"];var _crypto_scalarmult_scalarbytes=Module["_crypto_scalarmult_scalarbytes"]=asm["_crypto_scalarmult_scalarbytes"];var _crypto_secretbox=Module["_crypto_secretbox"]=asm["_crypto_secretbox"];var _crypto_secretbox_boxzerobytes=Module["_crypto_secretbox_boxzerobytes"]=asm["_crypto_secretbox_boxzerobytes"];var _crypto_secretbox_detached=Module["_crypto_secretbox_detached"]=asm["_crypto_secretbox_detached"];var _crypto_secretbox_easy=Module["_crypto_secretbox_easy"]=asm["_crypto_secretbox_easy"];var _crypto_secretbox_keybytes=Module["_crypto_secretbox_keybytes"]=asm["_crypto_secretbox_keybytes"];var _crypto_secretbox_keygen=Module["_crypto_secretbox_keygen"]=asm["_crypto_secretbox_keygen"];var _crypto_secretbox_macbytes=Module["_crypto_secretbox_macbytes"]=asm["_crypto_secretbox_macbytes"];var _crypto_secretbox_noncebytes=Module["_crypto_secretbox_noncebytes"]=asm["_crypto_secretbox_noncebytes"];var _crypto_secretbox_open=Module["_crypto_secretbox_open"]=asm["_crypto_secretbox_open"];var _crypto_secretbox_open_detached=Module["_crypto_secretbox_open_detached"]=asm["_crypto_secretbox_open_detached"];var _crypto_secretbox_open_easy=Module["_crypto_secretbox_open_easy"]=asm["_crypto_secretbox_open_easy"];var _crypto_secretbox_primitive=Module["_crypto_secretbox_primitive"]=asm["_crypto_secretbox_primitive"];var _crypto_secretbox_xchacha20poly1305_detached=Module["_crypto_secretbox_xchacha20poly1305_detached"]=asm["_crypto_secretbox_xchacha20poly1305_detached"];var _crypto_secretbox_xchacha20poly1305_easy=Module["_crypto_secretbox_xchacha20poly1305_easy"]=asm["_crypto_secretbox_xchacha20poly1305_easy"];var _crypto_secretbox_xchacha20poly1305_keybytes=Module["_crypto_secretbox_xchacha20poly1305_keybytes"]=asm["_crypto_secretbox_xchacha20poly1305_keybytes"];var _crypto_secretbox_xchacha20poly1305_macbytes=Module["_crypto_secretbox_xchacha20poly1305_macbytes"]=asm["_crypto_secretbox_xchacha20poly1305_macbytes"];var _crypto_secretbox_xchacha20poly1305_noncebytes=Module["_crypto_secretbox_xchacha20poly1305_noncebytes"]=asm["_crypto_secretbox_xchacha20poly1305_noncebytes"];var _crypto_secretbox_xchacha20poly1305_open_detached=Module["_crypto_secretbox_xchacha20poly1305_open_detached"]=asm["_crypto_secretbox_xchacha20poly1305_open_detached"];var _crypto_secretbox_xchacha20poly1305_open_easy=Module["_crypto_secretbox_xchacha20poly1305_open_easy"]=asm["_crypto_secretbox_xchacha20poly1305_open_easy"];var _crypto_secretbox_xsalsa20poly1305=Module["_crypto_secretbox_xsalsa20poly1305"]=asm["_crypto_secretbox_xsalsa20poly1305"];var _crypto_secretbox_xsalsa20poly1305_boxzerobytes=Module["_crypto_secretbox_xsalsa20poly1305_boxzerobytes"]=asm["_crypto_secretbox_xsalsa20poly1305_boxzerobytes"];var _crypto_secretbox_xsalsa20poly1305_keybytes=Module["_crypto_secretbox_xsalsa20poly1305_keybytes"]=asm["_crypto_secretbox_xsalsa20poly1305_keybytes"];var _crypto_secretbox_xsalsa20poly1305_keygen=Module["_crypto_secretbox_xsalsa20poly1305_keygen"]=asm["_crypto_secretbox_xsalsa20poly1305_keygen"];var _crypto_secretbox_xsalsa20poly1305_macbytes=Module["_crypto_secretbox_xsalsa20poly1305_macbytes"]=asm["_crypto_secretbox_xsalsa20poly1305_macbytes"];var _crypto_secretbox_xsalsa20poly1305_noncebytes=Module["_crypto_secretbox_xsalsa20poly1305_noncebytes"]=asm["_crypto_secretbox_xsalsa20poly1305_noncebytes"];var _crypto_secretbox_xsalsa20poly1305_open=Module["_crypto_secretbox_xsalsa20poly1305_open"]=asm["_crypto_secretbox_xsalsa20poly1305_open"];var _crypto_secretbox_xsalsa20poly1305_zerobytes=Module["_crypto_secretbox_xsalsa20poly1305_zerobytes"]=asm["_crypto_secretbox_xsalsa20poly1305_zerobytes"];var _crypto_secretbox_zerobytes=Module["_crypto_secretbox_zerobytes"]=asm["_crypto_secretbox_zerobytes"];var _crypto_secretstream_xchacha20poly1305_abytes=Module["_crypto_secretstream_xchacha20poly1305_abytes"]=asm["_crypto_secretstream_xchacha20poly1305_abytes"];var _crypto_secretstream_xchacha20poly1305_headerbytes=Module["_crypto_secretstream_xchacha20poly1305_headerbytes"]=asm["_crypto_secretstream_xchacha20poly1305_headerbytes"];var _crypto_secretstream_xchacha20poly1305_init_pull=Module["_crypto_secretstream_xchacha20poly1305_init_pull"]=asm["_crypto_secretstream_xchacha20poly1305_init_pull"];var _crypto_secretstream_xchacha20poly1305_init_push=Module["_crypto_secretstream_xchacha20poly1305_init_push"]=asm["_crypto_secretstream_xchacha20poly1305_init_push"];var _crypto_secretstream_xchacha20poly1305_keybytes=Module["_crypto_secretstream_xchacha20poly1305_keybytes"]=asm["_crypto_secretstream_xchacha20poly1305_keybytes"];var _crypto_secretstream_xchacha20poly1305_keygen=Module["_crypto_secretstream_xchacha20poly1305_keygen"]=asm["_crypto_secretstream_xchacha20poly1305_keygen"];var _crypto_secretstream_xchacha20poly1305_messagebytes_max=Module["_crypto_secretstream_xchacha20poly1305_messagebytes_max"]=asm["_crypto_secretstream_xchacha20poly1305_messagebytes_max"];var _crypto_secretstream_xchacha20poly1305_pull=Module["_crypto_secretstream_xchacha20poly1305_pull"]=asm["_crypto_secretstream_xchacha20poly1305_pull"];var _crypto_secretstream_xchacha20poly1305_push=Module["_crypto_secretstream_xchacha20poly1305_push"]=asm["_crypto_secretstream_xchacha20poly1305_push"];var _crypto_secretstream_xchacha20poly1305_rekey=Module["_crypto_secretstream_xchacha20poly1305_rekey"]=asm["_crypto_secretstream_xchacha20poly1305_rekey"];var _crypto_secretstream_xchacha20poly1305_statebytes=Module["_crypto_secretstream_xchacha20poly1305_statebytes"]=asm["_crypto_secretstream_xchacha20poly1305_statebytes"];var _crypto_secretstream_xchacha20poly1305_tag_final=Module["_crypto_secretstream_xchacha20poly1305_tag_final"]=asm["_crypto_secretstream_xchacha20poly1305_tag_final"];var _crypto_secretstream_xchacha20poly1305_tag_message=Module["_crypto_secretstream_xchacha20poly1305_tag_message"]=asm["_crypto_secretstream_xchacha20poly1305_tag_message"];var _crypto_secretstream_xchacha20poly1305_tag_push=Module["_crypto_secretstream_xchacha20poly1305_tag_push"]=asm["_crypto_secretstream_xchacha20poly1305_tag_push"];var _crypto_secretstream_xchacha20poly1305_tag_rekey=Module["_crypto_secretstream_xchacha20poly1305_tag_rekey"]=asm["_crypto_secretstream_xchacha20poly1305_tag_rekey"];var _crypto_shorthash=Module["_crypto_shorthash"]=asm["_crypto_shorthash"];var _crypto_shorthash_bytes=Module["_crypto_shorthash_bytes"]=asm["_crypto_shorthash_bytes"];var _crypto_shorthash_keybytes=Module["_crypto_shorthash_keybytes"]=asm["_crypto_shorthash_keybytes"];var _crypto_shorthash_keygen=Module["_crypto_shorthash_keygen"]=asm["_crypto_shorthash_keygen"];var _crypto_shorthash_primitive=Module["_crypto_shorthash_primitive"]=asm["_crypto_shorthash_primitive"];var _crypto_shorthash_siphash24=Module["_crypto_shorthash_siphash24"]=asm["_crypto_shorthash_siphash24"];var _crypto_shorthash_siphash24_bytes=Module["_crypto_shorthash_siphash24_bytes"]=asm["_crypto_shorthash_siphash24_bytes"];var _crypto_shorthash_siphash24_keybytes=Module["_crypto_shorthash_siphash24_keybytes"]=asm["_crypto_shorthash_siphash24_keybytes"];var _crypto_shorthash_siphashx24=Module["_crypto_shorthash_siphashx24"]=asm["_crypto_shorthash_siphashx24"];var _crypto_shorthash_siphashx24_bytes=Module["_crypto_shorthash_siphashx24_bytes"]=asm["_crypto_shorthash_siphashx24_bytes"];var _crypto_shorthash_siphashx24_keybytes=Module["_crypto_shorthash_siphashx24_keybytes"]=asm["_crypto_shorthash_siphashx24_keybytes"];var _crypto_sign=Module["_crypto_sign"]=asm["_crypto_sign"];var _crypto_sign_bytes=Module["_crypto_sign_bytes"]=asm["_crypto_sign_bytes"];var _crypto_sign_detached=Module["_crypto_sign_detached"]=asm["_crypto_sign_detached"];var _crypto_sign_ed25519=Module["_crypto_sign_ed25519"]=asm["_crypto_sign_ed25519"];var _crypto_sign_ed25519_bytes=Module["_crypto_sign_ed25519_bytes"]=asm["_crypto_sign_ed25519_bytes"];var _crypto_sign_ed25519_detached=Module["_crypto_sign_ed25519_detached"]=asm["_crypto_sign_ed25519_detached"];var _crypto_sign_ed25519_keypair=Module["_crypto_sign_ed25519_keypair"]=asm["_crypto_sign_ed25519_keypair"];var _crypto_sign_ed25519_open=Module["_crypto_sign_ed25519_open"]=asm["_crypto_sign_ed25519_open"];var _crypto_sign_ed25519_pk_to_curve25519=Module["_crypto_sign_ed25519_pk_to_curve25519"]=asm["_crypto_sign_ed25519_pk_to_curve25519"];var _crypto_sign_ed25519_publickeybytes=Module["_crypto_sign_ed25519_publickeybytes"]=asm["_crypto_sign_ed25519_publickeybytes"];var _crypto_sign_ed25519_secretkeybytes=Module["_crypto_sign_ed25519_secretkeybytes"]=asm["_crypto_sign_ed25519_secretkeybytes"];var _crypto_sign_ed25519_seed_keypair=Module["_crypto_sign_ed25519_seed_keypair"]=asm["_crypto_sign_ed25519_seed_keypair"];var _crypto_sign_ed25519_seedbytes=Module["_crypto_sign_ed25519_seedbytes"]=asm["_crypto_sign_ed25519_seedbytes"];var _crypto_sign_ed25519_sk_to_curve25519=Module["_crypto_sign_ed25519_sk_to_curve25519"]=asm["_crypto_sign_ed25519_sk_to_curve25519"];var _crypto_sign_ed25519_sk_to_pk=Module["_crypto_sign_ed25519_sk_to_pk"]=asm["_crypto_sign_ed25519_sk_to_pk"];var _crypto_sign_ed25519_sk_to_seed=Module["_crypto_sign_ed25519_sk_to_seed"]=asm["_crypto_sign_ed25519_sk_to_seed"];var _crypto_sign_ed25519_verify_detached=Module["_crypto_sign_ed25519_verify_detached"]=asm["_crypto_sign_ed25519_verify_detached"];var _crypto_sign_ed25519ph_final_create=Module["_crypto_sign_ed25519ph_final_create"]=asm["_crypto_sign_ed25519ph_final_create"];var _crypto_sign_ed25519ph_final_verify=Module["_crypto_sign_ed25519ph_final_verify"]=asm["_crypto_sign_ed25519ph_final_verify"];var _crypto_sign_ed25519ph_init=Module["_crypto_sign_ed25519ph_init"]=asm["_crypto_sign_ed25519ph_init"];var _crypto_sign_ed25519ph_statebytes=Module["_crypto_sign_ed25519ph_statebytes"]=asm["_crypto_sign_ed25519ph_statebytes"];var _crypto_sign_ed25519ph_update=Module["_crypto_sign_ed25519ph_update"]=asm["_crypto_sign_ed25519ph_update"];var _crypto_sign_final_create=Module["_crypto_sign_final_create"]=asm["_crypto_sign_final_create"];var _crypto_sign_final_verify=Module["_crypto_sign_final_verify"]=asm["_crypto_sign_final_verify"];var _crypto_sign_init=Module["_crypto_sign_init"]=asm["_crypto_sign_init"];var _crypto_sign_keypair=Module["_crypto_sign_keypair"]=asm["_crypto_sign_keypair"];var _crypto_sign_open=Module["_crypto_sign_open"]=asm["_crypto_sign_open"];var _crypto_sign_primitive=Module["_crypto_sign_primitive"]=asm["_crypto_sign_primitive"];var _crypto_sign_publickeybytes=Module["_crypto_sign_publickeybytes"]=asm["_crypto_sign_publickeybytes"];var _crypto_sign_secretkeybytes=Module["_crypto_sign_secretkeybytes"]=asm["_crypto_sign_secretkeybytes"];var _crypto_sign_seed_keypair=Module["_crypto_sign_seed_keypair"]=asm["_crypto_sign_seed_keypair"];var _crypto_sign_seedbytes=Module["_crypto_sign_seedbytes"]=asm["_crypto_sign_seedbytes"];var _crypto_sign_statebytes=Module["_crypto_sign_statebytes"]=asm["_crypto_sign_statebytes"];var _crypto_sign_update=Module["_crypto_sign_update"]=asm["_crypto_sign_update"];var _crypto_sign_verify_detached=Module["_crypto_sign_verify_detached"]=asm["_crypto_sign_verify_detached"];var _crypto_stream=Module["_crypto_stream"]=asm["_crypto_stream"];var _crypto_stream_chacha20=Module["_crypto_stream_chacha20"]=asm["_crypto_stream_chacha20"];var _crypto_stream_chacha20_ietf=Module["_crypto_stream_chacha20_ietf"]=asm["_crypto_stream_chacha20_ietf"];var _crypto_stream_chacha20_ietf_keybytes=Module["_crypto_stream_chacha20_ietf_keybytes"]=asm["_crypto_stream_chacha20_ietf_keybytes"];var _crypto_stream_chacha20_ietf_keygen=Module["_crypto_stream_chacha20_ietf_keygen"]=asm["_crypto_stream_chacha20_ietf_keygen"];var _crypto_stream_chacha20_ietf_noncebytes=Module["_crypto_stream_chacha20_ietf_noncebytes"]=asm["_crypto_stream_chacha20_ietf_noncebytes"];var _crypto_stream_chacha20_ietf_xor=Module["_crypto_stream_chacha20_ietf_xor"]=asm["_crypto_stream_chacha20_ietf_xor"];var _crypto_stream_chacha20_ietf_xor_ic=Module["_crypto_stream_chacha20_ietf_xor_ic"]=asm["_crypto_stream_chacha20_ietf_xor_ic"];var _crypto_stream_chacha20_keybytes=Module["_crypto_stream_chacha20_keybytes"]=asm["_crypto_stream_chacha20_keybytes"];var _crypto_stream_chacha20_keygen=Module["_crypto_stream_chacha20_keygen"]=asm["_crypto_stream_chacha20_keygen"];var _crypto_stream_chacha20_noncebytes=Module["_crypto_stream_chacha20_noncebytes"]=asm["_crypto_stream_chacha20_noncebytes"];var _crypto_stream_chacha20_xor=Module["_crypto_stream_chacha20_xor"]=asm["_crypto_stream_chacha20_xor"];var _crypto_stream_chacha20_xor_ic=Module["_crypto_stream_chacha20_xor_ic"]=asm["_crypto_stream_chacha20_xor_ic"];var _crypto_stream_keybytes=Module["_crypto_stream_keybytes"]=asm["_crypto_stream_keybytes"];var _crypto_stream_keygen=Module["_crypto_stream_keygen"]=asm["_crypto_stream_keygen"];var _crypto_stream_noncebytes=Module["_crypto_stream_noncebytes"]=asm["_crypto_stream_noncebytes"];var _crypto_stream_primitive=Module["_crypto_stream_primitive"]=asm["_crypto_stream_primitive"];var _crypto_stream_salsa20=Module["_crypto_stream_salsa20"]=asm["_crypto_stream_salsa20"];var _crypto_stream_salsa2012=Module["_crypto_stream_salsa2012"]=asm["_crypto_stream_salsa2012"];var _crypto_stream_salsa2012_keybytes=Module["_crypto_stream_salsa2012_keybytes"]=asm["_crypto_stream_salsa2012_keybytes"];var _crypto_stream_salsa2012_keygen=Module["_crypto_stream_salsa2012_keygen"]=asm["_crypto_stream_salsa2012_keygen"];var _crypto_stream_salsa2012_noncebytes=Module["_crypto_stream_salsa2012_noncebytes"]=asm["_crypto_stream_salsa2012_noncebytes"];var _crypto_stream_salsa2012_xor=Module["_crypto_stream_salsa2012_xor"]=asm["_crypto_stream_salsa2012_xor"];var _crypto_stream_salsa208=Module["_crypto_stream_salsa208"]=asm["_crypto_stream_salsa208"];var _crypto_stream_salsa208_keybytes=Module["_crypto_stream_salsa208_keybytes"]=asm["_crypto_stream_salsa208_keybytes"];var _crypto_stream_salsa208_keygen=Module["_crypto_stream_salsa208_keygen"]=asm["_crypto_stream_salsa208_keygen"];var _crypto_stream_salsa208_messagebytes_max=Module["_crypto_stream_salsa208_messagebytes_max"]=asm["_crypto_stream_salsa208_messagebytes_max"];var _crypto_stream_salsa208_noncebytes=Module["_crypto_stream_salsa208_noncebytes"]=asm["_crypto_stream_salsa208_noncebytes"];var _crypto_stream_salsa208_xor=Module["_crypto_stream_salsa208_xor"]=asm["_crypto_stream_salsa208_xor"];var _crypto_stream_salsa20_keybytes=Module["_crypto_stream_salsa20_keybytes"]=asm["_crypto_stream_salsa20_keybytes"];var _crypto_stream_salsa20_keygen=Module["_crypto_stream_salsa20_keygen"]=asm["_crypto_stream_salsa20_keygen"];var _crypto_stream_salsa20_noncebytes=Module["_crypto_stream_salsa20_noncebytes"]=asm["_crypto_stream_salsa20_noncebytes"];var _crypto_stream_salsa20_xor=Module["_crypto_stream_salsa20_xor"]=asm["_crypto_stream_salsa20_xor"];var _crypto_stream_salsa20_xor_ic=Module["_crypto_stream_salsa20_xor_ic"]=asm["_crypto_stream_salsa20_xor_ic"];var _crypto_stream_xchacha20=Module["_crypto_stream_xchacha20"]=asm["_crypto_stream_xchacha20"];var _crypto_stream_xchacha20_keybytes=Module["_crypto_stream_xchacha20_keybytes"]=asm["_crypto_stream_xchacha20_keybytes"];var _crypto_stream_xchacha20_keygen=Module["_crypto_stream_xchacha20_keygen"]=asm["_crypto_stream_xchacha20_keygen"];var _crypto_stream_xchacha20_noncebytes=Module["_crypto_stream_xchacha20_noncebytes"]=asm["_crypto_stream_xchacha20_noncebytes"];var _crypto_stream_xchacha20_xor=Module["_crypto_stream_xchacha20_xor"]=asm["_crypto_stream_xchacha20_xor"];var _crypto_stream_xchacha20_xor_ic=Module["_crypto_stream_xchacha20_xor_ic"]=asm["_crypto_stream_xchacha20_xor_ic"];var _crypto_stream_xor=Module["_crypto_stream_xor"]=asm["_crypto_stream_xor"];var _crypto_stream_xsalsa20=Module["_crypto_stream_xsalsa20"]=asm["_crypto_stream_xsalsa20"];var _crypto_stream_xsalsa20_keybytes=Module["_crypto_stream_xsalsa20_keybytes"]=asm["_crypto_stream_xsalsa20_keybytes"];var _crypto_stream_xsalsa20_keygen=Module["_crypto_stream_xsalsa20_keygen"]=asm["_crypto_stream_xsalsa20_keygen"];var _crypto_stream_xsalsa20_noncebytes=Module["_crypto_stream_xsalsa20_noncebytes"]=asm["_crypto_stream_xsalsa20_noncebytes"];var _crypto_stream_xsalsa20_xor=Module["_crypto_stream_xsalsa20_xor"]=asm["_crypto_stream_xsalsa20_xor"];var _crypto_stream_xsalsa20_xor_ic=Module["_crypto_stream_xsalsa20_xor_ic"]=asm["_crypto_stream_xsalsa20_xor_ic"];var _crypto_verify_16=Module["_crypto_verify_16"]=asm["_crypto_verify_16"];var _crypto_verify_16_bytes=Module["_crypto_verify_16_bytes"]=asm["_crypto_verify_16_bytes"];var _crypto_verify_32=Module["_crypto_verify_32"]=asm["_crypto_verify_32"];var _crypto_verify_32_bytes=Module["_crypto_verify_32_bytes"]=asm["_crypto_verify_32_bytes"];var _crypto_verify_64=Module["_crypto_verify_64"]=asm["_crypto_verify_64"];var _crypto_verify_64_bytes=Module["_crypto_verify_64_bytes"]=asm["_crypto_verify_64_bytes"];var _emscripten_replace_memory=Module["_emscripten_replace_memory"]=asm["_emscripten_replace_memory"];var _free=Module["_free"]=asm["_free"];var _i64Add=Module["_i64Add"]=asm["_i64Add"];var _i64Subtract=Module["_i64Subtract"]=asm["_i64Subtract"];var _malloc=Module["_malloc"]=asm["_malloc"];var _memcpy=Module["_memcpy"]=asm["_memcpy"];var _memmove=Module["_memmove"]=asm["_memmove"];var _memset=Module["_memset"]=asm["_memset"];var _randombytes=Module["_randombytes"]=asm["_randombytes"];var _randombytes_buf=Module["_randombytes_buf"]=asm["_randombytes_buf"];var _randombytes_buf_deterministic=Module["_randombytes_buf_deterministic"]=asm["_randombytes_buf_deterministic"];var _randombytes_close=Module["_randombytes_close"]=asm["_randombytes_close"];var _randombytes_implementation_name=Module["_randombytes_implementation_name"]=asm["_randombytes_implementation_name"];var _randombytes_random=Module["_randombytes_random"]=asm["_randombytes_random"];var _randombytes_seedbytes=Module["_randombytes_seedbytes"]=asm["_randombytes_seedbytes"];var _randombytes_stir=Module["_randombytes_stir"]=asm["_randombytes_stir"];var _randombytes_uniform=Module["_randombytes_uniform"]=asm["_randombytes_uniform"];var _sbrk=Module["_sbrk"]=asm["_sbrk"];var _sodium_base642bin=Module["_sodium_base642bin"]=asm["_sodium_base642bin"];var _sodium_base64_encoded_len=Module["_sodium_base64_encoded_len"]=asm["_sodium_base64_encoded_len"];var _sodium_bin2base64=Module["_sodium_bin2base64"]=asm["_sodium_bin2base64"];var _sodium_bin2hex=Module["_sodium_bin2hex"]=asm["_sodium_bin2hex"];var _sodium_hex2bin=Module["_sodium_hex2bin"]=asm["_sodium_hex2bin"];var _sodium_init=Module["_sodium_init"]=asm["_sodium_init"];var _sodium_library_minimal=Module["_sodium_library_minimal"]=asm["_sodium_library_minimal"];var _sodium_library_version_major=Module["_sodium_library_version_major"]=asm["_sodium_library_version_major"];var _sodium_library_version_minor=Module["_sodium_library_version_minor"]=asm["_sodium_library_version_minor"];var _sodium_pad=Module["_sodium_pad"]=asm["_sodium_pad"];var _sodium_unpad=Module["_sodium_unpad"]=asm["_sodium_unpad"];var _sodium_version_string=Module["_sodium_version_string"]=asm["_sodium_version_string"];var establishStackSpace=Module["establishStackSpace"]=asm["establishStackSpace"];var getTempRet0=Module["getTempRet0"]=asm["getTempRet0"];var runPostSets=Module["runPostSets"]=asm["runPostSets"];var setTempRet0=Module["setTempRet0"]=asm["setTempRet0"];var setThrew=Module["setThrew"]=asm["setThrew"];var stackAlloc=Module["stackAlloc"]=asm["stackAlloc"];var stackRestore=Module["stackRestore"]=asm["stackRestore"];var stackSave=Module["stackSave"]=asm["stackSave"];Module["asm"]=asm;Module["setValue"]=setValue;Module["getValue"]=getValue;Module["Pointer_stringify"]=Pointer_stringify;if(memoryInitializer){if(!isDataURI(memoryInitializer)){memoryInitializer=locateFile(memoryInitializer)}if(ENVIRONMENT_IS_NODE||ENVIRONMENT_IS_SHELL){var data=Module["readBinary"](memoryInitializer);HEAPU8.set(data,GLOBAL_BASE)}else{addRunDependency("memory initializer");var applyMemoryInitializer=(function(data){if(data.byteLength)data=new Uint8Array(data);HEAPU8.set(data,GLOBAL_BASE);if(Module["memoryInitializerRequest"])delete Module["memoryInitializerRequest"].response;removeRunDependency("memory initializer")});function doBrowserLoad(){Module["readAsync"](memoryInitializer,applyMemoryInitializer,(function(){throw"could not load memory initializer "+memoryInitializer}))}var memoryInitializerBytes=tryParseAsDataURI(memoryInitializer);if(memoryInitializerBytes){applyMemoryInitializer(memoryInitializerBytes.buffer)}else if(Module["memoryInitializerRequest"]){function useRequest(){var request=Module["memoryInitializerRequest"];var response=request.response;if(request.status!==200&&request.status!==0){var data=tryParseAsDataURI(Module["memoryInitializerRequestURL"]);if(data){response=data.buffer}else{console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+request.status+", retrying "+memoryInitializer);doBrowserLoad();return}}applyMemoryInitializer(response)}if(Module["memoryInitializerRequest"].response){setTimeout(useRequest,0)}else{Module["memoryInitializerRequest"].addEventListener("load",useRequest)}}else{doBrowserLoad()}}}function ExitStatus(status){this.name="ExitStatus";this.message="Program terminated with exit("+status+")";this.status=status}ExitStatus.prototype=new Error;ExitStatus.prototype.constructor=ExitStatus;var initialStackTop;dependenciesFulfilled=function runCaller(){if(!Module["calledRun"])run();if(!Module["calledRun"])dependenciesFulfilled=runCaller};function run(args){args=args||Module["arguments"];if(runDependencies>0){return}preRun();if(runDependencies>0)return;if(Module["calledRun"])return;function doRun(){if(Module["calledRun"])return;Module["calledRun"]=true;if(ABORT)return;ensureInitRuntime();preMain();if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout((function(){setTimeout((function(){Module["setStatus"]("")}),1);doRun()}),1)}else{doRun()}}Module["run"]=run;function abort(what){if(Module["onAbort"]){Module["onAbort"](what)}if(what!==undefined){out(what);err(what);what=JSON.stringify(what)}else{what=""}ABORT=true;EXITSTATUS=1;throw"abort("+what+"). Build with -s ASSERTIONS=1 for more info."}Module["abort"]=abort;if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}Module["noExitRuntime"]=true;run()
20581 };
20582 var Module=typeof Module!=="undefined"?Module:{};var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}Module["arguments"]=[];Module["thisProgram"]="./this.program";Module["quit"]=(function(status,toThrow){throw toThrow});Module["preRun"]=[];Module["postRun"]=[];var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_IS_SHELL=false;ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}else{return scriptDirectory+path}}if(ENVIRONMENT_IS_NODE){scriptDirectory=__dirname+"/";var nodeFS;var nodePath;Module["read"]=function shell_read(filename,binary){var ret;ret=tryParseAsDataURI(filename);if(!ret){if(!nodeFS)nodeFS=require("fs");if(!nodePath)nodePath=require("path");filename=nodePath["normalize"](filename);ret=nodeFS["readFileSync"](filename)}return binary?ret:ret.toString()};Module["readBinary"]=function readBinary(filename){var ret=Module["read"](filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}assert(ret.buffer);return ret};if(process["argv"].length>1){Module["thisProgram"]=process["argv"][1].replace(/\\/g,"/")}Module["arguments"]=process["argv"].slice(2);if(typeof module!=="undefined"){module["exports"]=Module}process["on"]("unhandledRejection",abort);Module["quit"]=(function(status){process["exit"](status)});Module["inspect"]=(function(){return"[Emscripten Module object]"})}else if(ENVIRONMENT_IS_SHELL){if(typeof read!="undefined"){Module["read"]=function shell_read(f){var data=tryParseAsDataURI(f);if(data){return intArrayToString(data)}return read(f)}}Module["readBinary"]=function readBinary(f){var data;data=tryParseAsDataURI(f);if(data){return data}if(typeof readbuffer==="function"){return new Uint8Array(readbuffer(f))}data=read(f,"binary");assert(typeof data==="object");return data};if(typeof scriptArgs!="undefined"){Module["arguments"]=scriptArgs}else if(typeof arguments!="undefined"){Module["arguments"]=arguments}if(typeof quit==="function"){Module["quit"]=(function(status){quit(status)})}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(document.currentScript){scriptDirectory=document.currentScript.src}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.lastIndexOf("/")+1)}else{scriptDirectory=""}Module["read"]=function shell_read(url){try{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText}catch(err){var data=tryParseAsDataURI(url);if(data){return intArrayToString(data)}throw err}};if(ENVIRONMENT_IS_WORKER){Module["readBinary"]=function readBinary(url){try{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}catch(err){var data=tryParseAsDataURI(url);if(data){return data}throw err}}}Module["readAsync"]=function readAsync(url,onload,onerror){var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=function xhr_onload(){if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}var data=tryParseAsDataURI(url);if(data){onload(data.buffer);return}onerror()};xhr.onerror=onerror;xhr.send(null)};Module["setWindowTitle"]=(function(title){document.title=title})}else{}var out=Module["print"]||(typeof console!=="undefined"?console.log.bind(console):typeof print!=="undefined"?print:null);var err=Module["printErr"]||(typeof printErr!=="undefined"?printErr:typeof console!=="undefined"&&console.warn.bind(console)||out);for(key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}moduleOverrides=undefined;var STACK_ALIGN=16;function staticAlloc(size){var ret=STATICTOP;STATICTOP=STATICTOP+size+15&-16;return ret}function alignMemory(size,factor){if(!factor)factor=STACK_ALIGN;var ret=size=Math.ceil(size/factor)*factor;return ret}var asm2wasmImports={"f64-rem":(function(x,y){return x%y}),"debugger":(function(){debugger})};var functionPointers=new Array(8);var GLOBAL_BASE=1024;var ABORT=false;var EXITSTATUS=0;function assert(condition,text){if(!condition){abort("Assertion failed: "+text)}}function setValue(ptr,value,type,noSafe){type=type||"i8";if(type.charAt(type.length-1)==="*")type="i32";switch(type){case"i1":HEAP8[ptr>>0]=value;break;case"i8":HEAP8[ptr>>0]=value;break;case"i16":HEAP16[ptr>>1]=value;break;case"i32":HEAP32[ptr>>2]=value;break;case"i64":tempI64=[value>>>0,(tempDouble=value,+Math_abs(tempDouble)>=1?tempDouble>0?(Math_min(+Math_floor(tempDouble/4294967296),4294967295)|0)>>>0:~~+Math_ceil((tempDouble- +(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[ptr>>2]=tempI64[0],HEAP32[ptr+4>>2]=tempI64[1];break;case"float":HEAPF32[ptr>>2]=value;break;case"double":HEAPF64[ptr>>3]=value;break;default:abort("invalid type for setValue: "+type)}}function getValue(ptr,type,noSafe){type=type||"i8";if(type.charAt(type.length-1)==="*")type="i32";switch(type){case"i1":return HEAP8[ptr>>0];case"i8":return HEAP8[ptr>>0];case"i16":return HEAP16[ptr>>1];case"i32":return HEAP32[ptr>>2];case"i64":return HEAP32[ptr>>2];case"float":return HEAPF32[ptr>>2];case"double":return HEAPF64[ptr>>3];default:abort("invalid type for getValue: "+type)}return null}function Pointer_stringify(ptr,length){if(length===0||!ptr)return"";var hasUtf=0;var t;var i=0;while(1){t=HEAPU8[ptr+i>>0];hasUtf|=t;if(t==0&&!length)break;i++;if(length&&i==length)break}if(!length)length=i;var ret="";if(hasUtf<128){var MAX_CHUNK=1024;var curr;while(length>0){curr=String.fromCharCode.apply(String,HEAPU8.subarray(ptr,ptr+Math.min(length,MAX_CHUNK)));ret=ret?ret+curr:curr;ptr+=MAX_CHUNK;length-=MAX_CHUNK}return ret}return UTF8ToString(ptr)}var UTF8Decoder=typeof TextDecoder!=="undefined"?new TextDecoder("utf8"):undefined;function UTF8ArrayToString(u8Array,idx){var endPtr=idx;while(u8Array[endPtr])++endPtr;if(endPtr-idx>16&&u8Array.subarray&&UTF8Decoder){return UTF8Decoder.decode(u8Array.subarray(idx,endPtr))}else{var u0,u1,u2,u3,u4,u5;var str="";while(1){u0=u8Array[idx++];if(!u0)return str;if(!(u0&128)){str+=String.fromCharCode(u0);continue}u1=u8Array[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}u2=u8Array[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u3=u8Array[idx++]&63;if((u0&248)==240){u0=(u0&7)<<18|u1<<12|u2<<6|u3}else{u4=u8Array[idx++]&63;if((u0&252)==248){u0=(u0&3)<<24|u1<<18|u2<<12|u3<<6|u4}else{u5=u8Array[idx++]&63;u0=(u0&1)<<30|u1<<24|u2<<18|u3<<12|u4<<6|u5}}}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}}}function UTF8ToString(ptr){return UTF8ArrayToString(HEAPU8,ptr)}var UTF16Decoder=typeof TextDecoder!=="undefined"?new TextDecoder("utf-16le"):undefined;var PAGE_SIZE=16384;var WASM_PAGE_SIZE=65536;var ASMJS_PAGE_SIZE=16777216;var MIN_TOTAL_MEMORY=16777216;function alignUp(x,multiple){if(x%multiple>0){x+=multiple-x%multiple}return x}var buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateGlobalBuffer(buf){Module["buffer"]=buffer=buf}function updateGlobalBufferViews(){Module["HEAP8"]=HEAP8=new Int8Array(buffer);Module["HEAP16"]=HEAP16=new Int16Array(buffer);Module["HEAP32"]=HEAP32=new Int32Array(buffer);Module["HEAPU8"]=HEAPU8=new Uint8Array(buffer);Module["HEAPU16"]=HEAPU16=new Uint16Array(buffer);Module["HEAPU32"]=HEAPU32=new Uint32Array(buffer);Module["HEAPF32"]=HEAPF32=new Float32Array(buffer);Module["HEAPF64"]=HEAPF64=new Float64Array(buffer)}var STATIC_BASE,STATICTOP,staticSealed;var STACK_BASE,STACKTOP,STACK_MAX;var DYNAMIC_BASE,DYNAMICTOP_PTR;STATIC_BASE=STATICTOP=STACK_BASE=STACKTOP=STACK_MAX=DYNAMIC_BASE=DYNAMICTOP_PTR=0;staticSealed=false;function abortOnCannotGrowMemory(){abort("Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value "+TOTAL_MEMORY+", (2) compile with -s ALLOW_MEMORY_GROWTH=1 which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 ")}if(!Module["reallocBuffer"])Module["reallocBuffer"]=(function(size){var ret;try{var oldHEAP8=HEAP8;ret=new ArrayBuffer(size);var temp=new Int8Array(ret);temp.set(oldHEAP8)}catch(e){return false}var success=_emscripten_replace_memory(ret);if(!success)return false;return ret});function enlargeMemory(){var PAGE_MULTIPLE=Module["usingWasm"]?WASM_PAGE_SIZE:ASMJS_PAGE_SIZE;var LIMIT=2147483648-PAGE_MULTIPLE;if(HEAP32[DYNAMICTOP_PTR>>2]>LIMIT){return false}var OLD_TOTAL_MEMORY=TOTAL_MEMORY;TOTAL_MEMORY=Math.max(TOTAL_MEMORY,MIN_TOTAL_MEMORY);while(TOTAL_MEMORY<HEAP32[DYNAMICTOP_PTR>>2]){if(TOTAL_MEMORY<=536870912){TOTAL_MEMORY=alignUp(2*TOTAL_MEMORY,PAGE_MULTIPLE)}else{TOTAL_MEMORY=Math.min(alignUp((3*TOTAL_MEMORY+2147483648)/4,PAGE_MULTIPLE),LIMIT)}}var replacement=Module["reallocBuffer"](TOTAL_MEMORY);if(!replacement||replacement.byteLength!=TOTAL_MEMORY){TOTAL_MEMORY=OLD_TOTAL_MEMORY;return false}updateGlobalBuffer(replacement);updateGlobalBufferViews();return true}var byteLength;try{byteLength=Function.prototype.call.bind(Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,"byteLength").get);byteLength(new ArrayBuffer(4))}catch(e){byteLength=(function(buffer){return buffer.byteLength})}var TOTAL_STACK=Module["TOTAL_STACK"]||5242880;var TOTAL_MEMORY=Module["TOTAL_MEMORY"]||16777216;if(TOTAL_MEMORY<TOTAL_STACK)err("TOTAL_MEMORY should be larger than TOTAL_STACK, was "+TOTAL_MEMORY+"! (TOTAL_STACK="+TOTAL_STACK+")");if(Module["buffer"]){buffer=Module["buffer"]}else{if(typeof WebAssembly==="object"&&typeof WebAssembly.Memory==="function"){Module["wasmMemory"]=new WebAssembly.Memory({"initial":TOTAL_MEMORY/WASM_PAGE_SIZE});buffer=Module["wasmMemory"].buffer}else{buffer=new ArrayBuffer(TOTAL_MEMORY)}Module["buffer"]=buffer}updateGlobalBufferViews();function getTotalMemory(){return TOTAL_MEMORY}function callRuntimeCallbacks(callbacks){while(callbacks.length>0){var callback=callbacks.shift();if(typeof callback=="function"){callback();continue}var func=callback.func;if(typeof func==="number"){if(callback.arg===undefined){Module["dynCall_v"](func)}else{Module["dynCall_vi"](func,callback.arg)}}else{func(callback.arg===undefined?null:callback.arg)}}}var __ATPRERUN__=[];var __ATINIT__=[];var __ATMAIN__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function ensureInitRuntime(){if(runtimeInitialized)return;runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}var Math_abs=Math.abs;var Math_ceil=Math.ceil;var Math_floor=Math.floor;var Math_min=Math.min;var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}Module["preloadedImages"]={};Module["preloadedAudios"]={};var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(filename){return String.prototype.startsWith?filename.startsWith(dataURIPrefix):filename.indexOf(dataURIPrefix)===0}function integrateWasmJS(){var wasmTextFile="";var wasmBinaryFile="data:application/octet-stream;base64,AGFzbQEAAAAB8QM3YAABf2AEf39/fwBgAX8AYAAAYAF/AX9gA39/fwF/YAJ/fwBgCX9/f39+f35/fwF/YAJ/fgBgCH9/f35/fn9/AX9gCH9/fn9/fn9/AX9gA39/fgF/YAJ/fwF/YAR/f35/AX9gBn9/f35/fwF/YAd/f39+f39/AX9gBX9/fn9/AX9gBn9/fn9/fwF/YAN/f38AYAF/AX5gA39/fwF+YAR/f39/AX9gBX9/f39/AGACfn8BfmADf39+AGAGf39/f39/AGAGf39/f35/AGAIf39/f35/f38AYAh/f39+f39/fwF/YAZ/f39/f38Bf2AFf39/f38Bf2ACfn4BfmAMf39/f39/f39/f39/AX9gCH9+f35/fn9/AX9gBX9/fn5/AX9gA39+fwF/YAR/fn9/AX9gBn9/fn5/fwF/YAh/f39/fn9+fwF/YAh/f39/f35/fgF/YAV/f39+fwF/YAZ/f39+f38AYAZ/f35/fn8Bf2AEf39/fgBgB39/f39/f38Bf2AIf39/f39/f38Bf2AJf39/f35/f39/AX9gB39+f35/fn8Bf2AFfn9/f38AYAp/f39/f35/f39/AX9gBX9/fn9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ZaAC9AQJaaAC/AQJfaAARAiRoAB4CYWkALAJiaQC9AQJjaQC8AgJkaQBnAmVpABMCZmkAZgJnaQARAmhpAPQBAmlpACICamkAHQJraQAwAmxpALoCAm1pACgCbmkA1gMCb2kANAJwaQDZAwJxaQDYAwJyaQARAnNpAPMBAnRpANcDAnVpAJABAnZpANMDAndpAJEBAnhpANUDAnlpANQDAnppAM8DAkFpADQCQmkAyQMCQ2kASgJEaQDMAwJFaQDLAwJGaQDKAwrJ+gWyBBMAIABBwAAgAWuthiAAIAGtiIQLEAAgAEEgIAFrdCAAIAF2cgseACABIAB8IABCAYZC/v///x+DIAFC/////w+DfnwLEAAgAEEgIAFrdiAAIAF0cgsTACAAQcAAIAFrrYggACABrYaEC1ABA38CfyMDIQQjA0E/akFAcSQDIwMhAiMDQRBqJAMgAiAANgIAIAEEQEEAIQADQCACKAIAIABqQQA6AAAgAEEBaiIAIAFHDQALCyAECyQDC8UJAg1/KX4gAigCBCIDrCEQIAIoAggiBKwhGCACKAIMIgWsIRsgAigCECIGrCEdIAIoAhQiB6whHyACKAIYIgisISYgAigCHCIJrCEtIAIoAiAiCqwhMCABKAIEIgusISAgASgCDCIMrCEhIAEoAhQiDawhIiABKAIcIg6sISMgASgCJCIPrCEkIANBE2ysIA9BAXSsIid+IAIoAgCsIhEgASgCAKwiEn58IARBE2ysIi4gASgCIKwiE358IAVBE2ysIiggDkEBdKwiKX58IAZBE2ysIiUgASgCGKwiFH58IAdBE2ysIh4gDUEBdKwiKn58IAhBE2ysIhwgASgCEKwiFX58IAlBE2ysIhkgDEEBdKwiK358IApBE2ysIhcgASgCCKwiFn58IAIoAiQiAUETbKwiGiALQQF0rCIsfnwhMSAQIBR+IBEgI358IBggIn58IBsgFX58IB0gIX58IB8gFn58ICYgIH58IC0gEn58IBcgJH58IBogE358IBAgKn4gESAUfnwgGCAVfnwgGyArfnwgHSAWfnwgHyAsfnwgJiASfnwgGSAnfnwgFyATfnwgGiApfnwgECAVfiARICJ+fCAYIC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AAgASABQfgAaiICEA8gAEEoaiABQShqIgMgAUHQAGoiBBAPIABB0ABqIAQgAhAPIABB+ABqIAEgAxAPCx8AIAFB/wFxrUIIhiAAQf8Bca2EIAJB/wFxrUIQhoQLDQAgACABIAIQnAJBAAvIAQEJfyACKAIEIAEoAgRqIQMgAigCCCABKAIIaiEEIAIoAgwgASgCDGohBSACKAIQIAEoAhBqIQYgAigCFCABKAIUaiEHIAIoAhggASgCGGohCCACKAIcIAEoAhxqIQkgAigCICABKAIgaiEKIAIoAiQgASgCJGohCyAAIAIoAgAgASgCAGo2AgAgACADNgIEIAAgBDYCCCAAIAU2AgwgACAGNgIQIAAgBzYCFCAAIAg2AhggACAJNgIcIAAgCjYCICAAIAs2AiQLJgAgAC0AAa1CCIYgAC0AAK2EIAAtAAKtQhCGhCAALQADrUIYhoQLwwMBA38gAkGAwABOBEAgACABIAIQBQ8LIAAhBCAAIAJqIQMgAEEDcSABQQNxRgRAA0AgAEEDcQRAIAJFBEAgBA8LIAAgASwAADoAACAAQQFqIQAgAUEBaiEBIAJBAWshAgwBCwsgA0F8cSICQUBqIQUDQCAAIAVMBEAgACABKAIANgIAIAAgASgCBDYCBCAAIAEoAgg2AgggACABKAIMNgIMIAAgASgCEDYCECAAIAEoAhQ2AhQgACABKAIYNgIYIAAgASgCHDYCHCAAIAEoAiA2AiAgACABKAIkNgIkIAAgASgCKDYCKCAAIAEoAiw2AiwgACABKAIwNgIwIAAgASgCNDYCNCAAIAEoAjg2AjggACABKAI8NgI8IABBQGshACABQUBrIQEMAQsLA0AgACACSARAIAAgASgCADYCACAAQQRqIQAgAUEEaiEBDAELCwUgA0EEayECA0AgACACSARAIAAgASwAADoAACAAIAEsAAE6AAEgACABLAACOgACIAAgASwAAzoAAyAAQQRqIQAgAUEEaiEBDAELCwsDQCAAIANIBEAgACABLAAAOgAAIABBAWohACABQQFqIQEMAQsLIAQLyAEBCX8gASgCBCACKAIEayEDIAEoAgggAigCCGshBCABKAIMIAIoAgxrIQUg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AtDAQN/An8jAyEEIwNBP2pBQHEkAyMDIQIjA0GgAmokAyAAIAIQpQQgASAAEKQEIAJBoAIQDiAAQegAEA4gBAskA0EACzsAIABCADcDICAAQYCFAikDADcDACAAQYiFAikDADcDCCAAQZCFAikDADcDECAAQZiFAikDADcDGEEACy0AIAJBgAJJBEAgACABIAJB/wFxEKsBDwVB6JICQfySAkHnAEGxkwIQAgtBAAtEACACQcAASyADQX9qQT9LcgR/QX8FIANB/wFxIQMgAUUgAkVyBEAgACADEKsCBSAAIAMgASACQf8BcRCnAgtBAAsiAAvcAgIGfwF+AkAgAkIAUgRAIABB4ABqIQMgAEHgAWohBCABIQYgAEHgAmoiBSgCACEBA0ACQCAAQeAAaiABaiEIIAJBgAIgAWsiB60iCVgNACAIIAYgBxAZGiAFIAUoAgAgB2o2AgAgAEKAARCtASAAIAMQrgEgAyAEKQAANwAAIAMgBCkACDcACCADIAQpABA3ABAgAyAEKQAYNwAYIAMgBCkAIDcAICADIAQpACg3ACggAyAEKQAwNwAwIAMgBCkAODcAOCADQUBrIARBQGspAAA3AAAgAyAEKQBINwBIIAMgBCkAUDcAUCADIAQpAFg3AFggAyAEKQBgNwBgIAMgBCkAaDcAaCADIAQpAHA3AHAgAyAEKQB4NwB4IAUgBSgCAEGAf2oiATYCACACIAl9IgJCAFENAyAGIAdqIQYMAQsLIAggBiACpyIAEBkaIAUgBSgCACAAajYCAAsLCxEAIAAgASACIANBCBCvAUEACxEAIAAgASACIANBDBCvAUEACxEAIAAgASACIANBFBCvAUEAC5oBAQZ/An8jAyEGIwNBP2pBQHEkAyMDIQEjA0GgAmokAyABQfABaiICIAAQECABQcABaiIDIABBKGoQECABQZABaiIEIABB0ABqEBAgAUEwaiIAIAMgAhAaIAAgACAEEA8gASACIAMQDyABIAFBgAgQDyABQeAAaiICIAQQECABIAEgAhAXIAAgACABEBogABBFIQAgBgskAyAAC5kEARV+IAEQGCECIAEsAAQgASwABSABLAAGEBVCBoYhByABLAAHIAEsAAggASwACR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ANgIsCxEAIAAgASACIANCACAEEPsBCw0AIAAgASACEEIaQQALBQBB0AELCQAgACABEPoDC3YBA38CfyMDIQUjA0E/akFAcSQDIwMhAyMDQRBqJAMgA0EAOgAAIAAgASACEPsDBH9BfwVBACEBA0AgAyADLAAAIAAgAWosAAByOgAAIAFBAWoiAUEgRw0AC0EAIAMtAABB/wNqQQh2QQFxawshACAFCyQDIAAL8wMBL38gASgCACIMIAAoAgAiDXNBACACayICcSEDIAFBBGoiDigCACIPIABBBGoiECgCACIRcyACcSEEIAFBCGoiEigCACITIABBCGoiFCgCACIVcyACcSEFIAFBDGoiFigCACIXIABBDGoiGCgCACIZcyACcSEGIAFBEGoiGigCACIbIABBEGoiHCgCACIdcyACcSEHIAFBFGoiHigCACIfIABBFGoiICgCACIhcyACcSEIIAFBGGoiIigCACIjIABBGGoiJCgCACIlcyACcSEJIAFBHGoiJigCACInIABBHGoiKCgCACIpcyACcSEKIAFBIGoiKigCACIrIABBIGoiLCgCACItcyACcSELIAFBJGoiLigCACIvIABBJGoiMCgCACIxcyACcSECIAAgAyANczYCACAQIAQgEXM2AgAgFCAFIBVzNgIAIBggBiAZczYCACAcIAcgHXM2AgAgICAIICFzNgIAICQgCSAlczYCACAoIAogKXM2AgAgLCALIC1zNgIAIDAgAiAxczYCACABIAMgDHM2AgAgDiAEIA9zNgIAIBIgBSATczYCACAWIAYgF3M2AgAgGiAHIBtzNgIAIB4gCCAfczYCACAiIAkgI3M2AgAgJiAKICdzNgIAICogCyArczYCACAuIAIgL3M2AgALBABBAwsMACAAQQBBgAgQIRoLegEHfwJ/IwMhCCMDQT9qQUBxJAMjAyEFIwNBEGokA0EKIQIDQCAFIAJBf2oiA2oiBiABIAFBCm4iB0F2bGpBMHI6AAAgAUEJSyADQQBHcQRAIAMhAiAHIQEMAQsLIAAgBkELIAJrIgEQGRogACABakEAOgAAIAgLJAMLuwEBBX8CQCAALAAAIgZBUGpBGHRBGHVB/wFxQQlMBEAgACEEIAYhAgNAIANBmr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MhBSMDQcABaiQDIAUhBiACQYABSwR/IAAQQRogACABIAKtECUaIAAgBhA1GiAGIQFBwAAFIAILIQQgABBBGiAFQUBrIgNCtuzYsePGjZs2NwMAIANCtuzYsePGjZs2NwMIIANCtuzYsePGjZs2NwMQIANCtuzYsePGjZs2NwMYIANCtuzYsePGjZs2NwMgIANCtuzYsePGjZs2NwMoIANCtuzYsePGjZs2NwMwIANCtuzYsePGjZs2NwM4IANBQGtCtuzYsePGjZs2NwMAIANCtuzYsePGjZs2NwNIIANCtuzYsePGjZs2NwNQIANCtuzYsePGjZs2NwNYIANCtuzYsePGjZs2NwNgIANCtuzYsePGjZs2NwNoIANCtuzYsePGjZs2NwNwIANCtuzYsePGjZs2NwN4IARFIgdFBEAgAyABLAAAQTZzOgAAIARBAUcEQEEBIQIDQCADIAJqIgggCCwAACABIAJqLAAAczoAACACQQFqIgIgBEcNAAsLCyAAIANCgAEQJRogAEHQAWoiAhBBGiADQty48eLFi5eu3AA3AwAgA0LcuPHixYuXrtwANwMIIANC3Ljx4sWLl67cADcDECADQty48eLFi5eu3AA3AxggA0LcuPHixYuXrtwANwMgIANC3Ljx4sWLl67cADcDKCADQty48eLFi5eu3AA3AzAgA0LcuPHixYuXrtwANwM4IANBQGtC3Ljx4sWLl67cADcDACADQty48eLFi5eu3AA3A0ggA0LcuPHixYuXrtwANwNQIANC3Ljx4sWLl67cADcDWCADQty48eLFi5eu3AA3A2AgA0LcuPHixYuXrtwANwNoIANC3Ljx4sWLl67cADcDcCADQty48eLFi5eu3AA3A3ggB0UEQCADIAEsAABB3ABzOgAAIARBAUcEQEEBIQADQCADIABqIgcgBywAACABIABqLAAAczoAACAAQQFqIgAgBEcNAAsLCyACIANCgAEQJRogA0GAARAOIAZBwAAQDiAFJANBAAu6BAELfwJ/IwMhEiMDQT9qQUBxJAMjAyEKIwNBEGokAyAKQQA2AgAgBxCSAQJAAkAgAwR/IAdBBHFFIQ8gBEUhEAJ/AkACQAJAAkACQANAA0ACQCACIAh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EMaiAVIBpqEBIgAEEQaiAKIBtqEBIgAEEUaiADIBNqEBIgAEEYaiALIBxqEBIgAEEcaiABIB1qEBIgAEEgaiACIB5qEBIgAEEkaiAWIB9qEBIgAEEoaiAQIBRqEBIgAEEsaiAMICBqEBIgAEEwaiAFICNqEBIgAEE0aiAHICJqEBIgAEE4aiANICFqEBIgAEE8aiARIBdqEBILjBQCFH8dfiAALAAAIABBAWoiBywAACAAQQJqIgIsAAAQFUL///8AgyEgIAIQGEIFiEL///8AgyEjIABBBWoiCCwAACAAQQZqIgksAAAgAEEHaiIDLAAAEBVCAohC////AIMhJiADEBhCB4hC////AIMhJyAAQQpqIgoQGEIEiEL///8AgyEoIABBDWoiCywAACAAQQ5qIgwsAAAgAEEPaiIELAAAEBVCAYhC////AIMhLiAEEBhCBohC////AIMhISAAQRJqIg0sAAAgAEETaiIOLAAAIABBFGoiDywAABAVQgOIQv///wCDISQgAEEVaiIQLAAAIABBFmoiESwAACAAQRdqIgUsAAAQFUL///8AgyEeIAUQGEIFiEL///8AgyElIABBGmoiEiwAACAAQRtqIhMsAAAgAEEcaiIGLAAAEBVCAohC////AIMhHSAGEBhCB4hC////AIMhGyAAQR9qIhQQGEIEiEL///8AgyEfIAAsACIgACwAIyAAQSRqIgEsAAAQFUIBiEL///8AgyEiIAEQGEIGiEL///8AgyEpIAAsACcgACwAKCAALAApEBVCA4hC////AIMhLyAALAAqIAAsACsgAEEsaiIBLAAAEBVC////AIMhHCABEBhCBYhC////AIMhKiAALAAvIAAsADAgAEExaiIBLAAAEBVCAohC////AIMhFSABEBhCB4hC////AIMhFiAAQTRqEBhCBIhC////AIMhFyAALAA3IAAsADggAEE5aiIBLAAAEBVCAYhC////AIMhGSABEBhCBohC////AIMhGCAAQTxqEBhCA4giGkKDoVZ+IBx8IRwgF0KDoVZ+ICJ8IBlC0asIfnwgGkLn9id+fCAYQtOMQ358IBZCg6FWfiAffCAXQtGrCH58IBlC04xDfnwgGkKY2hx+fCAYQuf2J358IiJC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ACIAV8IgKFQRUQDSAEIAJ8IgKFIARBERANhSACQSAQDYU3AABBAAsrAQJ/A0AgACACaiIDIAMsAAAgASACaiwAAHM6AAAgAkEBaiICQQhHDQALC4QBAQN/An8jAyEHIwNBP2pBQHEkAyMDIQUjA0EgaiQDIAJCIFQEf0F/BSAFQiAgAyAEEPYBGiABQRBqIAFBIGogAkJgfCAFEHYEf0F/BSAAIAEgAiADIAQQlAEaIABCADcAACAAQgA3AAggAEIANwAQIABCADcAGEEACwshACAHCyQDIAALQAAgAkIgVAR/QX8FIAAgASACIAMgBBCUARogAEEQaiAAQSBqIAJCYHwgABCfAhogAEIANwAAIABCADcACEEACwtIAAJ/IAJC/////w9WBEBBmKECQRs2AgAFAkAgACABIAKnQQIQlgJBXWsiAARAIABBI0cNAUEADAMLQZihAkEWNgIACwtBfwsLiwIBA38CfyMDIQcjA0E/akFAcSQDIwMhBSMDQRBqJAMgAEIANwAAIABCADcACCAAQgA3ABAgAEIANwAYIABCADcAICAAQgA3ACggAEIANwAwIABCADcAOCAAQUBrQgA3AAAgAEIANwBIIABCADcAUCAAQgA3AFggAEIANwBgIABCADcAaCAAQgA3AHAgAEIANwB4IAMgAoRC/////w9WIARBgICAgHhLcgR/QZihAkEbNgIAQX8FIANCAFEgBEGAwABJcgR/QZihAkEWNgIAQX8FIAVBEBAoIAOnIARBCnZBASABIAKnIAVBEEEAQSAgAEGAAUECEFJBAEdBH3RBH3ULCyEAIAcLJAMgAAu/AQEBfyAAQQAgAaciCBAhGgJ/IAFC/////w9WBH9BmKECQRs2AgBBfwUgAUIQVARAQZihAkEWNgIAQX8MAgsgBSADhEL/////D1YgBkGAgICAeEtyBEBBmKECQRs2AgBBfwwCCyAFQgBRIAZBgMAASXIEQEGYoQJBFjYCAEF/DAILIAdBAkYEfyAFpyAGQQp2QQEgAiADpyAEQRAgACAIQQBBAEECEFJBAEdBH3RBH3UFQZihAkEWNgIAQX8LCwsLCABBgICAgAELBwBBgICAIAsGAEG0lAILUQEDfy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ADIAJBBGoQeiACQQhqQgAQHCACQRBqIgFCADcDACABQgA3AwggAUIANwMQIAFCADcDGCABQgA3AyAgAUIANwMoIAAgAhB7IAMkAwsLEAAgACABIAIgAyAEIAUQeQsFAEGAAwsGAEHZkwILtwEBA38jAyEJIwNB4AJqJAMgCUEQaiIIQsAAIAYgBxBRGiAJQdAAaiIKIAgQMxogCEHAABAOIAogBCAFEBYaIAlB0AJqIgggBRAcIAogCEIIEBYaIAogASACEBYaIAggAhAcIAogCEIIEBYaIAogCRAyGiAKQYACEA4gCSADEGchCCAJQRAQDiAABEAgCAR/IABBACACpxAhGkF/BSAAIAEgAiAGQgEgBxBHGkEACyEICyAJJAMgCAsTACAAIAFBwAdsQdAQaiACELYECwsAIABB/wFxQQd2C5cCAQR/An8jAyEGIwNBP2pBQHEkAyMDIQQjA0GgAWokAyACQRh0QRh1IgNBACACELECIgJB/wFxayADcUEBdGtB/wFxIQMgABAjIABBKGoQIyAAQdAAahAjIABB+ABqEEMgACABIANBARAkEDogACABQaABaiADQQIQJBA6IAAgAUHAAmogA0EDECQQOiAAIAFB4ANqIANBBBAkEDogACABQYAFaiADQQUQJBA6IAAgAUGgBmogA0EGECQQOiAAIAFBwAdqIANBBxAkEDogACABQeAIaiADQQgQJBA6IAQgAEEoahAtIARBKGogABAtIARB0ABqIABB0ABqEC0gBEH4AGogAEH4AGoQRCAAIAQgAhA6IAYLJAMLgwcCCX8ffiABKAIEIgWsIRcgASgCCCIGrCERIAEoAgwiB6whFSABKAIQIgisIQwgASgCFCICrCEYIAEoAhgiA6whDyABKAIcIgSsIRsgASgCICIJrCEZIAEoAiQiCqwhHSACQSZsrCAYfiABKAIAIgGsIgsgC358IANBE2ysIhogCEEBdKwiHn58IARBJmysIhQgB0EBdKwiEn58IAlBE2ysIhAgBkEBdKwiFn58IApBJmysIgsgBUEBdKwiDX58QgGGIR8gEiANfiARIBF+fCAMIAFBAXSsIg5+fCAUIBt+fCAQIANBAXSsfnwgCyACQQF0rCITfnxC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QiCGhCAJIAoQlAILLQAgACABrSACrUIghoQgAyAErSAFrUIghoQgBiAHrSAIrUIghoQgCSAKEIIECxIAIAAgASACrSADrUIghoQQJQsSACAAIAEgAq0gA61CIIaEEE0LEgAgACABIAKtIAOtQiCGhBBCCxMAIAAgASACrSADrUIghoQQowQLFQAgACABIAKtIAOtQiCGhBBNGkEACxIAIAAgASACrSADrUIghoQQOAsSACAAIAEgAq0gA61CIIaEECALHQAgACABIAIgA60gBK1CIIaEIAUgBiAHIAgQpQILGAAgACABIAIgA60gBK1CIIaEIAUgBhB5CxkAIAAgASACIAOtIAStQiCGhCAFIAYQrAILFwAgACABIAKtIAOtQiCGhCAEIAUQuAILFQAgACABIAKtIAOtQiCGhCAEELkCCxcAIAAgASACrSADrUIghoQgBCAFELsCCxkAIAAgASACrSADrUIghoQgBCAFIAYQvAELGQAgACABIAIgA60gBK1CIIaEIAUgBhCDAQsbACAAIAEgAiADrSAErUIghoQgBSAGIAcQvgELFwAgACABIAKtIAOtQiCGhCAEIAUQ3QILGQAgACABIAKtIAOtQiCGhCAEIAUgBhDDAQsZACAAIAEgAiADrSAErUIghoQgBSAGEIQBCxsAIAAgASACIAOtIAStQiCGhCAFIAYgBxDGAQsXACAAIAEgAq0gA61CIIaEIAQgBRDEAwsVACAAIAEgAq0gA61CIIaEIAQQxQMLFwAgACABIAKtIAOtQiCGhCAEIAUQxgMLGQAgACABIAKtIAOtQiCGhCAEIAUgBhDpAQsZACAAIAEgAiADrSAErUIghoQgBSAGEIwBCxsAIAAgASACIAOtIAStQiCGhCAFIAYgBxDqAQsXACAAIAEgAq0gA61CIIaEIAQgBRDHAwsLACAAIAEgAhCCAQsZACAAIAEgAq0gA61CIIaEIAQgBSAGEOsBCxkAIAAgASACIAOtIAStQiCGhCAFIAYQjQELGwAgACABIAIgA60gBK1CIIaEIAUgBiAHEOwBCxUAIAAgASACrSADrUIghoQgBBC2AwsTACAAIAEgAq0gA61CIIaEENcBCxUAIAAgASACrSADrUIghoQgB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B0IQCEA8gBCACIAQQFyAEIAQQsAQgACAEEDwgACwAAUEBcSEEIANBsANqIgYgARBEIAEgBiAEECogAhBDIAJB0IQCIAQQKiABIAEgAhAaIANBwAFqIgIQIyADQZABaiIEIAEgAhAXIANBMGoiBiABIAIQGiADQeAAaiIBIAQQRiADIAYgARAPIAAgAxA8IAggCUGAAXEgCC0AAHI6AAAgA0GgBmoiASAAED0EQBAABSAFIAEQNyAHIAUQLiAFIAcQKSAHIAUQLiAFIAcQKSABIAUQFCAAIAEQOyAKJAMLC2MBBX9BICEBQQEhAgNAIAAgAUF/aiIBaiwAACIEQf8BcSABQbCEAmosAAAiBUH/AXFrQQh1IAJB/wFxIgJxIANyIQMgBSAEc0H/AXFB//8DakEIdiACcSECIAENAAsgA0EARws7ACADQu////8PVgRAEAALIAAgACADp2pBACACIAMgBCAFIAYgBxCzARogAQRAIAEgA0IQfDcDAAtBAAvXIAIBfzd+IAEsAAAgASwAASABQQJqIgQsAAAQFUL///8AgyEFIAQQGEIFiEL///8AgyEJIAEsAAUgASwABiABQQdqIgQsAAAQFUICiEL///8AgyEPIAQQGEIHiEL///8AgyEQIAFBCmoQGEIEiEL///8AgyEKIAEsAA0gASwADiABQQ9qIgQsAAAQFUIBiEL///8AgyELIAQQGEIGiEL///8AgyEHIAEsABIgASwAEyABLAAUEBVCA4hC////AIMhBiABLAAVIAEsABYgAUEXaiIELAAAEBVC////AIMhDCAEEBhCBYhC////AIMhDSABLAAaIAEsABsgAUEcaiIBLAAAEBVCAohC////AIMhCCABEBhCB4ghDiACLAAAIAIsAAEgAkECaiIBLAAAEBVC////AIMhGSABEBhCBYhC////AIMhGiACLAAFIAIsAAYgAkEHaiIBLAAAEBVCAohC////AIMhGyABEBhCB4hC////AIMhHiACQQpqEBhCBIhC////AIMhEyACLAANIAIsAA4gAkEPaiIBLAAAEBVCAYhC////AIMhFyABEBhCBohC////AIMhGCACLAASIAIsABMgAiwAFBAVQgOIQv///wCDIRQgAiwAFSACLAAWIAJBF2oiASwAABAVQv///wCDIRUgARAYQgWIQv///wCDIRYgAiwAGiACLAAbIAJBHGoiASwAABAVQgKIQv///wCDIRIgARAYQgeIIREgAywAACADLAABIANBAmoiASwAABAVQv///wCDISEgARAYQgWIQv///wCDIR8gAywABSADLAAGIANBB2oiASwAABAVQgKIQv///wCDISwgARAYQgeIQv///wCDIS0gA0EKahAYQgSIQv///wCDIS4gAywADSADLAAOIANBD2oiASwAABAVQgGIQv///wCDIS8gARAYQgaIQv///wCDITAgAywAEiADLAATIAMsABQQFUIDiEL///8AgyExIAMsABUgAywAFiADQRdqIgEsAAAQFUL///8AgyEnIAEQGEIFiEL///8AgyEoIBogDX4gGSAIfnwgGyAMfnwgHiAGfnwgEyAHfnwgFyALfnwgGCAKfnwgFSAPfnwgFCAQfnwgFiAJfnwgEiAFfnwgAywAGiADLAAbIANBHGoiASwAABAVQgKIQv///wCDfCIyQoCAQH0hIyAWIAh+IBUgDn58IBIgDX58IBEgDH58IBQgDn4gFSAIfnwgFiANfnwgEiAMfnwgESAGfnwiIEKAgEB9IhxCFYd8ISIgGiAFfiAZIAl+fCAffCAhIBkgBX58IjNCgIBAfSI0QhWIfCI1QoCAQH0hKyAVIA1+IBggDn58IBQgCH58IBYgDH58IBIgBn58IBEgB358IBggCH4gFyAOfnwgFSAMfnwgFCANfnwgFiAGfnwgEiAHfnwgESALfnwiH0KAgEB9Ih1CFYd8IjZCgIBAfSI3QhWHICAgHEKAgIB/g318ISEgHyARIA5+IiBCgIBAfSIcQhWHIh9Cg6FWfnwgHUKAgIB/g30gFyAIfiATIA5+fCAYIA1+fCAVIAZ+fCAUIAx+fCAWIAd+fCASIAt+fCARIAp+fCATIAh+IB4gDn58IBcgDX58IBggDH58IBUgB358IBQgBn58IBYgC358IBIgCn58IBEgEH58Ih1CgIBAfSIkQhWHfCI4QoCAQH0iOUIVh3whJiAdIB9C04xDfnwgESAIfiASIA5+fCASIAh+IBYgDn58IBEgDX58Ih1CgIBAfSIpQhWHfCIlQ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A/wAAAAADAAAAAPUAAAAAAAAADwAAAAAA/wAAAAD/AAAAAAcAAAAABQBBzIICCwEBAEHwggILAQEAQZCDAguwASbolY/CsiewRcP0ifLvmPDV36wF08YzObE4AohtU/wFxxdqcD1N2E+6PAt2DRBnDyogU/osOczGTsf9d5KsA3rs////////////////////////////////////////f+3///////////////////////////////////////9/7v///////////////////////////////////////3/t0/VcGmMSWNac96Le+d4UAEHPhAILBBAGbQcAQYCFAguhAmfmCWqFrme7cvNuPDr1T6V/Ug5RjGgFm6vZgx8ZzeBbmC+KQpFEN3HP+8C1pdu16VvCVjnxEfFZpII/ktVeHKuYqgfYAVuDEr6FMSTDfQxVdF2+cv6x3oCnBtybdPGbwcFpm+SGR77vxp3BD8yhDCRvLOktqoR0StypsFzaiPl2UlE+mG3GMajIJwOwx39Zv/ML4MZHkafVUWPKBmcpKRSFCrcnOCEbLvxtLE0TDThTVHMKZbsKanYuycKBhSxykqHov6JLZhqocItLwqNRbMcZ6JLRJAaZ1oU1DvRwoGoQFsGkGQhsNx5Md0gntbywNLMMHDlKqthOT8qcW/NvLmjugo90b2OleBR4yIQIAseM+v++kOtsUKT3o/m+8nhxxoAAQeCHAgvBBQjJvPNn5glqO6fKhIWuZ7sr+JT+cvNuPPE2HV869U+l0YLmrX9SDlEfbD4rjGgFm2u9Qfur2YMfeSF+ExnN4FsirijXmC+KQs1l7yORRDdxLztN7M/7wLW824mBpdu16Ti1SPNbwlY5GdAFtvER8VmbTxmvpII/khiBbdrVXhyrQgIDo5iqB9i+b3BFAVuDEoyy5E6+hTEk4rT/1cN9DFVviXvydF2+crGWFjv+sd6ANRLHJacG3JuUJmnPdPGbwdJK8Z7BaZvk4yVPOIZHvu+11YyLxp3BD2WcrHfMoQwkdQIrWW8s6S2D5KZuqoR0StT7Qb3cqbBctVMRg9qI+Xar32buUlE+mBAytC1txjGoPyH7mMgnA7DkDu++x39Zv8KPqD3zC+DGJacKk0eRp9VvggPgUWPKBnBuDgpnKSkU/C/SRoUKtycmySZcOCEbLu0qxFr8bSxN37OVnRMNOFPeY6+LVHMKZaiydzy7Cmp25q7tRy7JwoE7NYIUhSxykmQD8Uyh6L+iATBCvEtmGqiRl/jQcItLwjC+VAajUWzHGFLv1hnoktEQqWVVJAaZ1iogcVeFNQ70uNG7MnCgahDI0NK4FsGkGVOrQVEIbDcemeuO30x3SCeoSJvhtbywNGNaycWzDBw5y4pB40qq2E5z42N3T8qcW6O4stbzby5o/LLvXe6Cj3RgLxdDb2OleHKr8KEUeMiE7DlkGggCx4woHmMj+v++kOm9gt7rbFCkFXnGsvej+b4rU3Lj8nhxxpxhJurOPifKB8LAIce4htEe6+DN1n3a6njRbu5/T331um8Xcqpn8AammMiixX1jCq4N+b4EmD8RG0ccEzULcRuEfQQj9XfbKJMkx0B7q8oyvL7JFQq+njxMDRCcxGcdQ7ZCPsu+1MVMKn5l/Jwpf1ns+tY6q2/LXxdYR0qMGURsgABBwI4CCwEBAEHgjgIL4QLg63p8O0G4rhZW4/rxn8Rq2gmN65wysf2GYgUWX0m4AF+clbyjUIwksdCxVZyD71sERFzEWByOhtgiTt3QnxFX7P///////////////////////////////////////3/t////////////////////////////////////////f+7///////////////////////////////////////9/zet6fDtBuK4WVuP68Z/EatoJjeucMrH9hmIFFl9JuIBMnJW8o1CMJLHQsVWcg+9bBERcxFgcjobYIk7d0J8R19n/////////////////////////////////////////2v/////////////////////////////////////////b/////////////////////////////////////////1NpZ0VkMjU1MTkgbm8gRWQyNTUxOSBjb2xsaXNpb25zAQBB0JECC/kKaG1hY3NoYTUxMjI1NgBjdXJ2ZTI1NTE5eHNhbHNhMjBwb2x5MTMwNQBTLT5idWZsZW4gPD0gQkxBS0UyQl9CTE9DS0JZVEVTAGNyeXB0b19nZW5lcmljaGFzaC9ibGFrZTJiL3JlZi9ibGFrZTJiLXJlZi5jAGNyeXB0b19nZW5lcmljaGFzaF9ibGFrZTJiX19maW5hbABvdXRsZW4gPD0gVUlOVDhfTUFYAGNyeXB0b19nZW5lcm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5cHRvWydyYW5kb21CeXRlcyddKDQpOyByZXR1cm4gKGJ1ZlswXSA8PCAyNCB8IGJ1ZlsxXSA8PCAxNiB8IGJ1ZlsyXSA8PCA4IHwgYnVmWzNdKSA+Pj4gMDsgfTsgcmFuZG9tVmFsdWVOb2RlSlMoKTsgTW9kdWxlLmdldFJhbmRvbVZhbHVlID0gcmFuZG9tVmFsdWVOb2RlSlM7IH0gY2F0Y2ggKGUpIHsgdGhyb3cgJ05vIHNlY3VyZSByYW5kb20gbnVtYmVyIGdlbmVyYXRvciBmb3VuZCc7IH0gfSB9IH0ATGlic29kaXVtRFJHYnVmX2xlbiA8PSBTSVpFX01BWAByYW5kb21ieXRlcy9yYW5kb21ieXRlcy5jAHJhbmRvbWJ5dGVzAGI2NF9wb3MgPD0gYjY0X2xlbgBzb2RpdW0vY29kZWNzLmMAc29kaXVtX2JpbjJiYXNlNjQAMS4wLjE2AC4vMDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoAJDck";var asmjsCodeFile="";if(!isDataURI(wasmTextFile)){wasmTextFile=locateFile(wasmTextFile)}if(!isDataURI(wasmBinaryFile)){wasmBinaryFile=locateFile(wasmBinaryFile)}if(!isDataURI(asmjsCodeFile)){asmjsCodeFile=locateFile(asmjsCodeFile)}var wasmPageSize=64*1024;var info={"global":null,"env":null,"asm2wasm":asm2wasmImports,"parent":Module};var exports=null;function mergeMemory(newBuffer){var oldBuffer=Module["buffer"];if(newBuffer.byteLength<oldBuffer.byteLength){err("the new buffer in mergeMemory is smaller than the previous one. in native wasm, we should grow memory here")}var oldView=new Int8Array(oldBuffer);var newView=new Int8Array(newBuffer);newView.set(oldView);updateGlobalBuffer(newBuffer);updateGlobalBufferViews()}function getBinary(){try{if(Module["wasmBinary"]){return new Uint8Array(Module["wasmBinary"])}var binary=tryParseAsDataURI(wasmBinaryFile);if(binary){return binary}if(Module["readBinary"]){return Module["readBinary"](wasmBinaryFile)}else{throw"both async and sync fetching of the wasm failed"}}catch(err){abort(err)}}function getBinaryPromise(){if(!Module["wasmBinary"]&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)&&typeof fetch==="function"){return fetch(wasmBinaryFile,{credentials:"same-origin"}).then((function(response){if(!response["ok"]){throw"failed to load wasm binary file at '"+wasmBinaryFile+"'"}return response["arrayBuffer"]()})).catch((function(){return getBinary()}))}return new Promise((function(resolve,reject){resolve(getBinary())}))}function doNativeWasm(global,env,providedBuffer){if(typeof WebAssembly!=="object"){err("no native wasm support detected");return false}if(!(Module["wasmMemory"]instanceof WebAssembly.Memory)){err("no native wasm Memory in use");return false}env["memory"]=Module["wasmMemory"];info["global"]={"NaN":NaN,"Infinity":Infinity};info["global.Math"]=Math;info["env"]=env;function receiveInstance(instance,module){exports=instance.exports;if(exports.memory)mergeMemory(exports.memory);Module["asm"]=exports;Module["usingWasm"]=true;removeRunDependency("wasm-instantiate")}addRunDependency("wasm-instantiate");if(Module["instantiateWasm"]){try{return Module["instantiateWasm"](info,receiveInstance)}catch(e){err("Module.instantiateWasm callback failed with error: "+e);return false}}function receiveInstantiatedSource(output){receiveInstance(output["instance"],output["module"])}function instantiateArrayBuffer(receiver){getBinaryPromise().then((function(binary){return WebAssembly.instantiate(binary,info)})).then(receiver,(function(reason){err("failed to asynchronously prepare wasm: "+reason);abort(reason)}))}if(!Module["wasmBinary"]&&typeof WebAssembly.instantiateStreaming==="function"&&!isDataURI(wasmBinaryFile)&&typeof fetch==="function"){WebAssembly.instantiateStreaming(fetch(wasmBinaryFile,{credentials:"same-origin"}),info).then(receiveInstantiatedSource,(function(reason){err("wasm streaming compile failed: "+reason);err("falling back to ArrayBuffer instantiation");instantiateArrayBuffer(receiveInstantiatedSource)}))}else{instantiateArrayBuffer(receiveInstantiatedSource)}return{}}Module["asmPreload"]=Module["asm"];var asmjsReallocBuffer=Module["reallocBuffer"];var wasmReallocBuffer=(function(size){var PAGE_MULTIPLE=Module["usingWasm"]?WASM_PAGE_SIZE:ASMJS_PAGE_SIZE;size=alignUp(size,PAGE_MULTIPLE);var old=Module["buffer"];var oldSize=old.byteLength;if(Module["usingWasm"]){try{var result=Module["wasmMemory"].grow((size-oldSize)/wasmPageSize);if(result!==(-1|0)){return Module["buffer"]=Module["wasmMemory"].buffer}else{return null}}catch(e){return null}}});Module["reallocBuffer"]=(function(size){if(finalMethod==="asmjs"){return asmjsReallocBuffer(size)}else{return wasmReallocBuffer(size)}});var finalMethod="";Module["asm"]=(function(global,env,providedBuffer){if(!env["table"]){var TABLE_SIZE=Module["wasmTableSize"];if(TABLE_SIZE===undefined)TABLE_SIZE=1024;var MAX_TABLE_SIZE=Module["wasmMaxTableSize"];if(typeof WebAssembly==="object"&&typeof WebAssembly.Table==="function"){if(MAX_TABLE_SIZE!==undefined){env["table"]=new WebAssembly.Table({"initial":TABLE_SIZE,"maximum":MAX_TABLE_SIZE,"element":"anyfunc"})}else{env["table"]=new WebAssembly.Table({"initial":TABLE_SIZE,element:"anyfunc"})}}else{env["table"]=new Array(TABLE_SIZE)}Module["wasmTable"]=env["table"]}if(!env["__memory_base"]){env["__memory_base"]=Module["STATIC_BASE"]}if(!env["__table_base"]){env["__table_base"]=0}var exports;exports=doNativeWasm(global,env,providedBuffer);assert(exports,"no binaryen method succeeded.");return exports})}integrateWasmJS();var ASM_CONSTS=[(function(){return Module.getRandomValue()}),(function(){if(Module.getRandomValue===undefined){try{var window_="object"===typeof window?window:self;var crypto_=typeof window_.crypto!=="undefined"?window_.crypto:window_.msCrypto;var randomValuesStandard=(function(){var buf=new Uint32Array(1);crypto_.getRandomValues(buf);return buf[0]>>>0});randomValuesStandard();Module.getRandomValue=randomValuesStandard}catch(e){try{var crypto=require("crypto");var randomValueNodeJS=(function(){var buf=crypto["randomBytes"](4);return(buf[0]<<24|buf[1]<<16|buf[2]<<8|buf[3])>>>0});randomValueNodeJS();Module.getRandomValue=randomValueNodeJS}catch(e){throw"No secure random number generator found"}}}})];function _emscripten_asm_const_i(code){return ASM_CONSTS[code]()}STATIC_BASE=GLOBAL_BASE;STATICTOP=STATIC_BASE+37024;__ATINIT__.push();var STATIC_BUMP=37024;Module["STATIC_BASE"]=STATIC_BASE;Module["STATIC_BUMP"]=STATIC_BUMP;STATICTOP+=16;function ___assert_fail(condition,filename,line,func){abort("Assertion failed: "+Pointer_stringify(condition)+", at: "+[filename?Pointer_stringify(filename):"unknown filename",line,func?Pointer_stringify(func):"unknown function"])}function _abort(){Module["abort"]()}function _emscripten_memcpy_big(dest,src,num){HEAPU8.set(HEAPU8.subarray(src,src+num),dest);return dest}function ___setErrNo(value){if(Module["___errno_location"])HEAP32[Module["___errno_location"]()>>2]=value;return value}var ERRNO_CODES={EPERM:1,ENOENT:2,ESRCH:3,EINTR:4,EIO:5,ENXIO:6,E2BIG:7,ENOEXEC:8,EBADF:9,ECHILD:10,EAGAIN:11,EWOULDBLOCK:11,ENOMEM:12,EACCES:13,EFAULT:14,ENOTBLK:15,EBUSY:16,EEXIST:17,EXDEV:18,ENODEV:19,ENOTDIR:20,EISDIR:21,EINVAL:22,ENFILE:23,EMFILE:24,ENOTTY:25,ETXTBSY:26,EFBIG:27,ENOSPC:28,ESPIPE:29,EROFS:30,EMLINK:31,EPIPE:32,EDOM:33,ERANGE:34,ENOMSG:42,EIDRM:43,ECHRNG:44,EL2NSYNC:45,EL3HLT:46,EL3RST:47,ELNRNG:48,EUNATCH:49,ENOCSI:50,EL2HLT:51,EDEADLK:35,ENOLCK:37,EBADE:52,EBADR:53,EXFULL:54,ENOANO:55,EBADRQC:56,EBADSLT:57,EDEADLOCK:35,EBFONT:59,ENOSTR:60,ENODATA:61,ETIME:62,ENOSR:63,ENONET:64,ENOPKG:65,EREMOTE:66,ENOLINK:67,EADV:68,ESRMNT:69,ECOMM:70,EPROTO:71,EMULTIHOP:72,EDOTDOT:73,EBADMSG:74,ENOTUNIQ:76,EBADFD:77,EREMCHG:78,ELIBACC:79,ELIBBAD:80,ELIBSCN:81,ELIBMAX:82,ELIBEXEC:83,ENOSYS:38,ENOTEMPTY:39,ENAMETOOLONG:36,ELOOP:40,EOPNOTSUPP:95,EPFNOSUPPORT:96,ECONNRESET:104,ENOBUFS:105,EAFNOSUPPORT:97,EPROTOTYPE:91,ENOTSOCK:88,ENOPROTOOPT:92,ESHUTDOWN:108,ECONNREFUSED:111,EADDRINUSE:98,ECONNABORTED:103,ENETUNREACH:101,ENETDOWN:100,ETIMEDOUT:110,EHOSTDOWN:112,EHOSTUNREACH:113,EINPROGRESS:115,EALREADY:114,EDESTADDRREQ:89,EMSGSIZE:90,EPROTONOSUPPORT:93,ESOCKTNOSUPPORT:94,EADDRNOTAVAIL:99,ENETRESET:102,EISCONN:106,ENOTCONN:107,ETOOMANYREFS:109,EUSERS:87,EDQUOT:122,ESTALE:116,ENOTSUP:95,ENOMEDIUM:123,EILSEQ:84,EOVERFLOW:75,ECANCELED:125,ENOTRECOVERABLE:131,EOWNERDEAD:130,ESTRPIPE:86};function _sysconf(name){switch(name){case 30:return PAGE_SIZE;case 85:var maxHeapSize=2*1024*1024*1024-65536;return maxHeapSize/PAGE_SIZE;case 132:case 133:case 12:case 137:case 138:case 15:case 235:case 16:case 17:case 18:case 19:case 20:case 149:case 13:case 10:case 236:case 153:case 9:case 21:case 22:case 159:case 154:case 14:case 77:case 78:case 139:case 80:case 81:case 82:case 68:case 67:case 164:case 11:case 29:case 47:case 48:case 95:case 52:case 51:case 46:return 200809;case 79:return 0;case 27:case 246:case 127:case 128:case 23:case 24:case 160:case 161:case 181:case 182:case 242:case 183:case 184:case 243:case 244:case 245:case 165:case 178:case 179:case 49:case 50:case 168:case 169:case 175:case 170:case 171:case 172:case 97:case 76:case 32:case 173:case 35:return-1;case 176:case 177:case 7:case 155:case 8:case 157:case 125:case 126:case 92:case 93:case 129:case 130:case 131:case 94:case 91:return 1;case 74:case 60:case 69:case 70:case 4:return 1024;case 31:case 42:case 72:return 32;case 87:case 26:case 33:return 2147483647;case 34:case 1:return 47839;case 38:case 36:return 99;case 43:case 37:return 2048;case 0:return 2097152;case 3:return 65536;case 28:return 32768;case 44:return 32767;case 75:return 16384;case 39:return 1e3;case 89:return 700;case 71:return 256;case 40:return 255;case 2:return 100;case 180:return 64;case 25:return 20;case 5:return 16;case 6:return 6;case 73:return 4;case 84:{if(typeof navigator==="object")return navigator["hardwareConcurrency"]||1;return 1}}___setErrNo(ERRNO_CODES.EINVAL);return-1}DYNAMICTOP_PTR=staticAlloc(4);STACK_BASE=STACKTOP=alignMemory(STATICTOP);STACK_MAX=STACK_BASE+TOTAL_STACK;DYNAMIC_BASE=alignMemory(STACK_MAX);HEAP32[DYNAMICTOP_PTR>>2]=DYNAMIC_BASE;staticSealed=true;var ASSERTIONS=false;function intArrayToString(array){var ret=[];for(var i=0;i<array.length;i++){var chr=array[i];if(chr>255){if(ASSERTIONS){assert(false,"Character code "+chr+" ("+String.fromCharCode(chr)+") at offset "+i+" not in 0x00-0xFF.")}chr&=255}ret.push(String.fromCharCode(chr))}return ret.join("")}var decodeBase64=typeof atob==="function"?atob:(function(input){var keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{enc1=keyStr.indexOf(input.charAt(i++));enc2=keyStr.indexOf(input.charAt(i++));enc3=keyStr.indexOf(input.charAt(i++));enc4=keyStr.indexOf(input.charAt(i++));chr1=enc1<<2|enc2>>4;chr2=(enc2&15)<<4|enc3>>2;chr3=(enc3&3)<<6|enc4;output=output+String.fromCharCode(chr1);if(enc3!==64){output=output+String.fromCharCode(chr2)}if(enc4!==64){output=output+String.fromCharCode(chr3)}}while(i<input.length);return output});function intArrayFromBase64(s){if(typeof ENVIRONMENT_IS_NODE==="boolean"&&ENVIRONMENT_IS_NODE){var buf;try{buf=Buffer.from(s,"base64")}catch(_){buf=new Buffer(s,"base64")}return new Uint8Array(buf.buffer,buf.byteOffset,buf.byteLength)}try{var decoded=decodeBase64(s);var bytes=new Uint8Array(decoded.length);for(var i=0;i<decoded.length;++i){bytes[i]=decoded.charCodeAt(i)}return bytes}catch(_){throw new Error("Converting base64 string to bytes failed.")}}function tryParseAsDataURI(filename){if(!isDataURI(filename)){return}return intArrayFromBase64(filename.slice(dataURIPrefix.length))}Module["wasmTableSize"]=0;Module["wasmMaxTableSize"]=0;Module.asmGlobalArg={};Module.asmLibraryArg={"k":enlargeMemory,"j":getTotalMemory,"i":abortOnCannotGrowMemory,"e":___assert_fail,"f":___setErrNo,"c":_abort,"d":_emscripten_asm_const_i,"h":_emscripten_memcpy_big,"g":_sysconf,"a":DYNAMICTOP_PTR,"b":STACKTOP};var asm=Module["asm"](Module.asmGlobalArg,Module.asmLibraryArg,buffer);Module["asm"]=asm;var ___errno_location=Module["___errno_location"]=(function(){return Module["asm"]["l"].apply(null,arguments)});var _crypto_aead_chacha20poly1305_abytes=Module["_crypto_aead_chacha20poly1305_abytes"]=(function(){return Module["asm"]["m"].apply(null,arguments)});var _crypto_aead_chacha20poly1305_decrypt=Module["_crypto_aead_chacha20poly1305_decrypt"]=(function(){return Module["asm"]["n"].apply(null,arguments)});var _crypto_aead_chacha20poly1305_decrypt_detached=Module["_crypto_aead_chacha20poly1305_decrypt_detached"]=(function(){return Module["asm"]["o"].apply(null,arguments)});var _crypto_aead_chacha20poly1305_encrypt=Module["_crypto_aead_chacha20poly1305_encrypt"]=(function(){return Module["asm"]["p"].apply(null,arguments)});var _crypto_aead_chacha20poly1305_encrypt_detached=Module["_crypto_aead_chacha20poly1305_encrypt_detached"]=(function(){return Module["asm"]["q"].apply(null,arguments)});var _crypto_aead_chacha20poly1305_ietf_abytes=Module["_crypto_aead_chacha20poly1305_ietf_abytes"]=(function(){return Module["asm"]["r"].apply(null,arguments)});var _crypto_aead_chacha20poly1305_ietf_decrypt=Module["_crypto_aead_chacha20poly1305_ietf_decrypt"]=(function(){return Module["asm"]["s"].apply(null,arguments)});var _crypto_aead_chacha20poly1305_ietf_decrypt_detached=Module["_crypto_aead_chacha20poly1305_ietf_decrypt_detached"]=(function(){return Module["asm"]["t"].apply(null,arguments)});var _crypto_aead_chacha20poly1305_ietf_encrypt=Module["_crypto_aead_chacha20poly1305_ietf_encrypt"]=(function(){return Module["asm"]["u"].apply(null,arguments)});var _crypto_aead_chacha20poly1305_ietf_encrypt_detached=Module["_crypto_aead_chacha20poly1305_ietf_encrypt_detached"]=(function(){return Module["asm"]["v"].apply(null,arguments)});var _crypto_aead_chacha20poly1305_ietf_keybytes=Module["_crypto_aead_chacha20poly1305_ietf_keybytes"]=(function(){return Module["asm"]["w"].apply(null,arguments)});var _crypto_aead_chacha20poly1305_ietf_keygen=Module["_crypto_aead_chacha20poly1305_ietf_keygen"]=(function(){return Module["asm"]["x"].apply(null,arguments)});var _crypto_aead_chacha20poly1305_ietf_npubbytes=Module["_crypto_aead_chacha20poly1305_ietf_npubbytes"]=(function(){return Module["asm"]["y"].apply(null,arguments)});var _crypto_aead_chacha20poly1305_ietf_nsecbytes=Module["_crypto_aead_chacha20poly1305_ietf_nsecbytes"]=(function(){return Module["asm"]["z"].apply(null,arguments)});var _crypto_aead_chacha20poly1305_keybytes=Module["_crypto_aead_chacha20poly1305_keybytes"]=(function(){return Module["asm"]["A"].apply(null,arguments)});var _crypto_aead_chacha20poly1305_keygen=Module["_crypto_aead_chacha20poly1305_keygen"]=(function(){return Module["asm"]["B"].apply(null,arguments)});var _crypto_aead_chacha20poly1305_npubbytes=Module["_crypto_aead_chacha20poly1305_npubbytes"]=(function(){return Module["asm"]["C"].apply(null,arguments)});var _crypto_aead_chacha20poly1305_nsecbytes=Module["_crypto_aead_chacha20poly1305_nsecbytes"]=(function(){return Module["asm"]["D"].apply(null,arguments)});var _crypto_aead_xchacha20poly1305_ietf_abytes=Module["_crypto_aead_xchacha20poly1305_ietf_abytes"]=(function(){return Module["asm"]["E"].apply(null,arguments)});var _crypto_aead_xchacha20poly1305_ietf_decrypt=Module["_crypto_aead_xchacha20poly1305_ietf_decrypt"]=(function(){return Module["asm"]["F"].apply(null,arguments)});var _crypto_aead_xchacha20poly1305_ietf_decrypt_detached=Module["_crypto_aead_xchacha20poly1305_ietf_decrypt_detached"]=(function(){return Module["asm"]["G"].apply(null,arguments)});var _crypto_aead_xchacha20poly1305_ietf_encrypt=Module["_crypto_aead_xchacha20poly1305_ietf_encrypt"]=(function(){return Module["asm"]["H"].apply(null,arguments)});var _crypto_aead_xchacha20poly1305_ietf_encrypt_detached=Module["_crypto_aead_xchacha20poly1305_ietf_encrypt_detached"]=(function(){return Module["asm"]["I"].apply(null,arguments)});var _crypto_aead_xchacha20poly1305_ietf_keybytes=Module["_crypto_aead_xchacha20poly1305_ietf_keybytes"]=(function(){return Module["asm"]["J"].apply(null,arguments)});var _crypto_aead_xchacha20poly1305_ietf_keygen=Module["_crypto_aead_xchacha20poly1305_ietf_keygen"]=(function(){return Module["asm"]["K"].apply(null,arguments)});var _crypto_aead_xchacha20poly1305_ietf_npubbytes=Module["_crypto_aead_xchacha20poly1305_ietf_npubbytes"]=(function(){return Module["asm"]["L"].apply(null,arguments)});var _crypto_aead_xchacha20poly1305_ietf_nsecbytes=Module["_crypto_aead_xchacha20poly1305_ietf_nsecbytes"]=(function(){return Module["asm"]["M"].apply(null,arguments)});var _crypto_auth=Module["_crypto_auth"]=(function(){return Module["asm"]["N"].apply(null,arguments)});var _crypto_auth_bytes=Module["_crypto_auth_bytes"]=(function(){return Module["asm"]["O"].apply(null,arguments)});var _crypto_auth_hmacsha256=Module["_crypto_auth_hmacsha256"]=(function(){return Module["asm"]["P"].apply(null,arguments)});var _crypto_auth_hmacsha256_bytes=Module["_crypto_auth_hmacsha256_bytes"]=(function(){return Module["asm"]["Q"].apply(null,arguments)});var _crypto_auth_hmacsha256_final=Module["_crypto_auth_hmacsha256_final"]=(function(){return Module["asm"]["R"].apply(null,arguments)});var _crypto_auth_hmacsha256_init=Module["_crypto_auth_hmacsha256_init"]=(function(){return Module["asm"]["S"].apply(null,arguments)});var _crypto_auth_hmacsha256_keybytes=Module["_crypto_auth_hmacsha256_keybytes"]=(function(){return Module["asm"]["T"].apply(null,arguments)});var _crypto_auth_hmacsha256_keygen=Module["_crypto_auth_hmacsha256_keygen"]=(function(){return Module["asm"]["U"].apply(null,arguments)});var _crypto_auth_hmacsha256_statebytes=Module["_crypto_auth_hmacsha256_statebytes"]=(function(){return Module["asm"]["V"].apply(null,arguments)});var _crypto_auth_hmacsha256_update=Module["_crypto_auth_hmacsha256_update"]=(function(){return Module["asm"]["W"].apply(null,arguments)});var _crypto_auth_hmacsha256_verify=Module["_crypto_auth_hmacsha256_verify"]=(function(){return Module["asm"]["X"].apply(null,arguments)});var _crypto_auth_hmacsha512=Module["_crypto_auth_hmacsha512"]=(function(){return Module["asm"]["Y"].apply(null,arguments)});var _crypto_auth_hmacsha512256=Module["_crypto_auth_hmacsha512256"]=(function(){return Module["asm"]["Z"].apply(null,arguments)});var _crypto_auth_hmacsha512256_bytes=Module["_crypto_auth_hmacsha512256_bytes"]=(function(){return Module["asm"]["_"].apply(null,arguments)});var _crypto_auth_hmacsha512256_final=Module["_crypto_auth_hmacsha512256_final"]=(function(){return Module["asm"]["$"].apply(null,arguments)});var _crypto_auth_hmacsha512256_init=Module["_crypto_auth_hmacsha512256_init"]=(function(){return Module["asm"]["aa"].apply(null,arguments)});var _crypto_auth_hmacsha512256_keybytes=Module["_crypto_auth_hmacsha512256_keybytes"]=(function(){return Module["asm"]["ba"].apply(null,arguments)});var _crypto_auth_hmacsha512256_keygen=Module["_crypto_auth_hmacsha512256_keygen"]=(function(){return Module["asm"]["ca"].apply(null,arguments)});var _crypto_auth_hmacsha512256_statebytes=Module["_crypto_auth_hmacsha512256_statebytes"]=(function(){return Module["asm"]["da"].apply(null,arguments)});var _crypto_auth_hmacsha512256_update=Module["_crypto_auth_hmacsha512256_update"]=(function(){return Module["asm"]["ea"].apply(null,arguments)});var _crypto_auth_hmacsha512256_verify=Module["_crypto_auth_hmacsha512256_verify"]=(function(){return Module["asm"]["fa"].apply(null,arguments)});var _crypto_auth_hmacsha512_bytes=Module["_crypto_auth_hmacsha512_bytes"]=(function(){return Module["asm"]["ga"].apply(null,arguments)});var _crypto_auth_hmacsha512_final=Module["_crypto_auth_hmacsha512_final"]=(function(){return Module["asm"]["ha"].apply(null,arguments)});var _crypto_auth_hmacsha512_init=Module["_crypto_auth_hmacsha512_init"]=(function(){return Module["asm"]["ia"].apply(null,arguments)});var _crypto_auth_hmacsha512_keybytes=Module["_crypto_auth_hmacsha512_keybytes"]=(function(){return Module["asm"]["ja"].apply(null,arguments)});var _crypto_auth_hmacsha512_keygen=Module["_crypto_auth_hmacsha512_keygen"]=(function(){return Module["asm"]["ka"].apply(null,arguments)});var _crypto_auth_hmacsha512_statebytes=Module["_crypto_auth_hmacsha512_statebytes"]=(function(){return Module["asm"]["la"].apply(null,arguments)});var _crypto_auth_hmacsha512_update=Module["_crypto_auth_hmacsha512_update"]=(function(){return Module["asm"]["ma"].apply(null,arguments)});var _crypto_auth_hmacsha512_verify=Module["_crypto_auth_hmacsha512_verify"]=(function(){return Module["asm"]["na"].apply(null,arguments)});var _crypto_auth_keybytes=Module["_crypto_auth_keybytes"]=(function(){return Module["asm"]["oa"].apply(null,arguments)});var _crypto_auth_keygen=Module["_crypto_auth_keygen"]=(function(){return Module["asm"]["pa"].apply(null,arguments)});var _crypto_auth_primitive=Module["_crypto_auth_primitive"]=(function(){return Module["asm"]["qa"].apply(null,arguments)});var _crypto_auth_verify=Module["_crypto_auth_verify"]=(function(){return Module["asm"]["ra"].apply(null,arguments)});var _crypto_box=Module["_crypto_box"]=(function(){return Module["asm"]["sa"].apply(null,arguments)});var _crypto_box_afternm=Module["_crypto_box_afternm"]=(function(){return Module["asm"]["ta"].apply(null,arguments)});var _crypto_box_beforenm=Module["_crypto_box_beforenm"]=(function(){return Module["asm"]["ua"].apply(null,arguments)});var _crypto_box_beforenmbytes=Module["_crypto_box_beforenmbytes"]=(function(){return Module["asm"]["va"].apply(null,arguments)});var _crypto_box_boxzerobytes=Module["_crypto_box_boxzerobytes"]=(function(){return Module["asm"]["wa"].apply(null,arguments)});var _crypto_box_curve25519xchacha20poly1305_beforenm=Module["_crypto_box_curve25519xchacha20poly1305_beforenm"]=(function(){return Module["asm"]["xa"].apply(null,arguments)});var _crypto_box_curve25519xchacha20poly1305_beforenmbytes=Module["_crypto_box_curve25519xchacha20poly1305_beforenmbytes"]=(function(){return Module["asm"]["ya"].apply(null,arguments)});var _crypto_box_curve25519xchacha20poly1305_detached=Module["_crypto_box_curve25519xchacha20poly1305_detached"]=(function(){return Module["asm"]["za"].apply(null,arguments)});var _crypto_box_curve25519xchacha20poly1305_detached_afternm=Module["_crypto_box_curve25519xchacha20poly1305_detached_afternm"]=(function(){return Module["asm"]["Aa"].apply(null,arguments)});var _crypto_box_curve25519xchacha20poly1305_easy=Module["_crypto_box_curve25519xchacha20poly1305_easy"]=(function(){return Module["asm"]["Ba"].apply(null,arguments)});var _crypto_box_curve25519xchacha20poly1305_easy_afternm=Module["_crypto_box_curve25519xchacha20poly1305_easy_afternm"]=(function(){return Module["asm"]["Ca"].apply(null,arguments)});var _crypto_box_curve25519xchacha20poly1305_keypair=Module["_crypto_box_curve25519xchacha20poly1305_keypair"]=(function(){return Module["asm"]["Da"].apply(null,arguments)});var _crypto_box_curve25519xchacha20poly1305_macbytes=Module["_crypto_box_curve25519xchacha20poly1305_macbytes"]=(function(){return Module["asm"]["Ea"].apply(null,arguments)});var _crypto_box_curve25519xchacha20poly1305_noncebytes=Module["_crypto_box_curve25519xchacha20poly1305_noncebytes"]=(function(){return Module["asm"]["Fa"].apply(null,arguments)});var _crypto_box_curve25519xchacha20poly1305_open_detached=Module["_crypto_box_curve25519xchacha20poly1305_open_detached"]=(function(){return Module["asm"]["Ga"].apply(null,arguments)});var _crypto_box_curve25519xchacha20poly1305_open_detached_afternm=Module["_crypto_box_curve25519xchacha20poly1305_open_detached_afternm"]=(function(){return Module["asm"]["Ha"].apply(null,arguments)});var _crypto_box_curve25519xchacha20poly1305_open_easy=Module["_crypto_box_curve25519xchacha20poly1305_open_easy"]=(function(){return Module["asm"]["Ia"].apply(null,arguments)});var _crypto_box_curve25519xchacha20poly1305_open_easy_afternm=Module["_crypto_box_curve25519xchacha20poly1305_open_easy_afternm"]=(function(){return Module["asm"]["Ja"].apply(null,arguments)});var _crypto_box_curve25519xchacha20poly1305_publickeybytes=Module["_crypto_box_curve25519xchacha20poly1305_publickeybytes"]=(function(){return Module["asm"]["Ka"].apply(null,arguments)});var _crypto_box_curve25519xchacha20poly1305_seal=Module["_crypto_box_curve25519xchacha20poly1305_seal"]=(function(){return Module["asm"]["La"].apply(null,arguments)});var _crypto_box_curve25519xchacha20poly1305_seal_open=Module["_crypto_box_curve25519xchacha20poly1305_seal_open"]=(function(){return Module["asm"]["Ma"].apply(null,arguments)});var _crypto_box_curve25519xchacha20poly1305_sealbytes=Module["_crypto_box_curve25519xchacha20poly1305_sealbytes"]=(function(){return Module["asm"]["Na"].apply(null,arguments)});var _crypto_box_curve25519xchacha20poly1305_secretkeybytes=Module["_crypto_box_curve25519xchacha20poly1305_secretkeybytes"]=(function(){return Module["asm"]["Oa"].apply(null,arguments)});var _crypto_box_curve25519xchacha20poly1305_seed_keypair=Module["_crypto_box_curve25519xchacha20poly1305_seed_keypair"]=(function(){return Module["asm"]["Pa"].apply(null,arguments)});var _crypto_box_curve25519xchacha20poly1305_seedbytes=Module["_crypto_box_curve25519xchacha20poly1305_seedbytes"]=(function(){return Module["asm"]["Qa"].apply(null,arguments)});var _crypto_box_curve25519xsalsa20poly1305=Module["_crypto_box_curve25519xsalsa20poly1305"]=(function(){return Module["asm"]["Ra"].apply(null,arguments)});var _crypto_box_curve25519xsalsa20poly1305_afternm=Module["_crypto_box_curve25519xsalsa20poly1305_afternm"]=(function(){return Module["asm"]["Sa"].apply(null,arguments)});var _crypto_box_curve25519xsalsa20poly1305_beforenm=Module["_crypto_box_curve25519xsalsa20poly1305_beforenm"]=(function(){return Module["asm"]["Ta"].apply(null,arguments)});var _crypto_box_curve25519xsalsa20poly1305_beforenmbytes=Module["_crypto_box_curve25519xsalsa20poly1305_beforenmbytes"]=(function(){return Module["asm"]["Ua"].apply(null,arguments)});var _crypto_box_curve25519xsalsa20poly1305_boxzerobytes=Module["_crypto_box_curve25519xsalsa20poly1305_boxzerobytes"]=(function(){return Module["asm"]["Va"].apply(null,arguments)});var _crypto_box_curve25519xsalsa20poly1305_keypair=Module["_crypto_box_curve25519xsalsa20poly1305_keypair"]=(function(){return Module["asm"]["Wa"].apply(null,arguments)});var _crypto_box_curve25519xsalsa20poly1305_macbytes=Module["_crypto_box_curve25519xsalsa20poly1305_macbytes"]=(function(){return Module["asm"]["Xa"].apply(null,arguments)});var _crypto_box_curve25519xsalsa20poly1305_noncebytes=Module["_crypto_box_curve25519xsalsa20poly1305_noncebytes"]=(function(){return Module["asm"]["Ya"].apply(null,arguments)});var _crypto_box_curve25519xsalsa20poly1305_open=Module["_crypto_box_curve25519xsalsa20poly1305_open"]=(function(){return Module["asm"]["Za"].apply(null,arguments)});var _crypto_box_curve25519xsalsa20poly1305_open_afternm=Module["_crypto_box_curve25519xsalsa20poly1305_open_afternm"]=(function(){return Module["asm"]["_a"].apply(null,arguments)});var _crypto_box_curve25519xsalsa20poly1305_publickeybytes=Module["_crypto_box_curve25519xsalsa20poly1305_publickeybytes"]=(function(){return Module["asm"]["$a"].apply(null,arguments)});var _crypto_box_curve25519xsalsa20poly1305_secretkeybytes=Module["_crypto_box_curve25519xsalsa20poly1305_secretkeybytes"]=(function(){return Module["asm"]["ab"].apply(null,arguments)});var _crypto_box_curve25519xsalsa20poly1305_seed_keypair=Module["_crypto_box_curve25519xsalsa20poly1305_seed_keypair"]=(function(){return Module["asm"]["bb"].apply(null,arguments)});var _crypto_box_curve25519xsalsa20poly1305_seedbytes=Module["_crypto_box_curve25519xsalsa20poly1305_seedbytes"]=(function(){return Module["asm"]["cb"].apply(null,arguments)});var _crypto_box_curve25519xsalsa20poly1305_zerobytes=Module["_crypto_box_curve25519xsalsa20poly1305_zerobytes"]=(function(){return Module["asm"]["db"].apply(null,arguments)});var _crypto_box_detached=Module["_crypto_box_detached"]=(function(){return Module["asm"]["eb"].apply(null,arguments)});var _crypto_box_detached_afternm=Module["_crypto_box_detached_afternm"]=(function(){return Module["asm"]["fb"].apply(null,arguments)});var _crypto_box_easy=Module["_crypto_box_easy"]=(function(){return Module["asm"]["gb"].apply(null,arguments)});var _crypto_box_easy_afternm=Module["_crypto_box_easy_afternm"]=(function(){return Module["asm"]["hb"].apply(null,arguments)});var _crypto_box_keypair=Module["_crypto_box_keypair"]=(function(){return Module["asm"]["ib"].apply(null,arguments)});var _crypto_box_macbytes=Module["_crypto_box_macbytes"]=(function(){return Module["asm"]["jb"].apply(null,arguments)});var _crypto_box_noncebytes=Module["_crypto_box_noncebytes"]=(function(){return Module["asm"]["kb"].apply(null,arguments)});var _crypto_box_open=Module["_crypto_box_open"]=(function(){return Module["asm"]["lb"].apply(null,arguments)});var _crypto_box_open_afternm=Module["_crypto_box_open_afternm"]=(function(){return Module["asm"]["mb"].apply(null,arguments)});var _crypto_box_open_detached=Module["_crypto_box_open_detached"]=(function(){return Module["asm"]["nb"].apply(null,arguments)});var _crypto_box_open_detached_afternm=Module["_crypto_box_open_detached_afternm"]=(function(){return Module["asm"]["ob"].apply(null,arguments)});var _crypto_box_open_easy=Module["_crypto_box_open_easy"]=(function(){return Module["asm"]["pb"].apply(null,arguments)});var _crypto_box_open_easy_afternm=Module["_crypto_box_open_easy_afternm"]=(function(){return Module["asm"]["qb"].apply(null,arguments)});var _crypto_box_primitive=Module["_crypto_box_primitive"]=(function(){return Module["asm"]["rb"].apply(null,arguments)});var _crypto_box_publickeybytes=Module["_crypto_box_publickeybytes"]=(function(){return Module["asm"]["sb"].apply(null,arguments)});var _crypto_box_seal=Module["_crypto_box_seal"]=(function(){return Module["asm"]["tb"].apply(null,arguments)});var _crypto_box_seal_open=Module["_crypto_box_seal_open"]=(function(){return Module["asm"]["ub"].apply(null,arguments)});var _crypto_box_sealbytes=Module["_crypto_box_sealbytes"]=(function(){return Module["asm"]["vb"].apply(null,arguments)});var _crypto_box_secretkeybytes=Module["_crypto_box_secretkeybytes"]=(function(){return Module["asm"]["wb"].apply(null,arguments)});var _crypto_box_seed_keypair=Module["_crypto_box_seed_keypair"]=(function(){return Module["asm"]["xb"].apply(null,arguments)});var _crypto_box_seedbytes=Module["_crypto_box_seedbytes"]=(function(){return Module["asm"]["yb"].apply(null,arguments)});var _crypto_box_zerobytes=Module["_crypto_box_zerobytes"]=(function(){return Module["asm"]["zb"].apply(null,arguments)});var _crypto_core_ed25519_add=Module["_crypto_core_ed25519_add"]=(function(){return Module["asm"]["Ab"].apply(null,arguments)});var _crypto_core_ed25519_bytes=Module["_crypto_core_ed25519_bytes"]=(function(){return Module["asm"]["Bb"].apply(null,arguments)});var _crypto_core_ed25519_from_uniform=Module["_crypto_core_ed25519_from_uniform"]=(function(){return Module["asm"]["Cb"].apply(null,arguments)});var _crypto_core_ed25519_is_valid_point=Module["_crypto_core_ed25519_is_valid_point"]=(function(){return Module["asm"]["Db"].apply(null,arguments)});var _crypto_core_ed25519_sub=Module["_crypto_core_ed25519_sub"]=(function(){return Module["asm"]["Eb"].apply(null,arguments)});var _crypto_core_ed25519_uniformbytes=Module["_crypto_core_ed25519_uniformbytes"]=(function(){return Module["asm"]["Fb"].apply(null,arguments)});var _crypto_core_hchacha20=Module["_crypto_core_hchacha20"]=(function(){return Module["asm"]["Gb"].apply(null,arguments)});var _crypto_core_hchacha20_constbytes=Module["_crypto_core_hchacha20_constbytes"]=(function(){return Module["asm"]["Hb"].apply(null,arguments)});var _crypto_core_hchacha20_inputbytes=Module["_crypto_core_hchacha20_inputbytes"]=(function(){return Module["asm"]["Ib"].apply(null,arguments)});var _crypto_core_hchacha20_keybytes=Module["_crypto_core_hchacha20_keybytes"]=(function(){return Module["asm"]["Jb"].apply(null,arguments)});var _crypto_core_hchacha20_outputbytes=Module["_crypto_core_hchacha20_outputbytes"]=(function(){return Module["asm"]["Kb"].apply(null,arguments)});var _crypto_core_hsalsa20=Module["_crypto_core_hsalsa20"]=(function(){return Module["asm"]["Lb"].apply(null,arguments)});var _crypto_core_hsalsa20_constbytes=Module["_crypto_core_hsalsa20_constbytes"]=(function(){return Module["asm"]["Mb"].apply(null,arguments)});var _crypto_core_hsalsa20_inputbytes=Module["_crypto_core_hsalsa20_inputbytes"]=(function(){return Module["asm"]["Nb"].apply(null,arguments)});var _crypto_core_hsalsa20_keybytes=Module["_crypto_core_hsalsa20_keybytes"]=(function(){return Module["asm"]["Ob"].apply(null,arguments)});var _crypto_core_hsalsa20_outputbytes=Module["_crypto_core_hsalsa20_outputbytes"]=(function(){return Module["asm"]["Pb"].apply(null,arguments)});var _crypto_core_salsa20=Module["_crypto_core_salsa20"]=(function(){return Module["asm"]["Qb"].apply(null,arguments)});var _crypto_core_salsa2012=Module["_crypto_core_salsa2012"]=(function(){return Module["asm"]["Rb"].apply(null,arguments)});var _crypto_core_salsa2012_constbytes=Module["_crypto_core_salsa2012_constbytes"]=(function(){return Module["asm"]["Sb"].apply(null,arguments)});var _crypto_core_salsa2012_inputbytes=Module["_crypto_core_salsa2012_inputbytes"]=(function(){return Module["asm"]["Tb"].apply(null,arguments)});var _crypto_core_salsa2012_keybytes=Module["_crypto_core_salsa2012_keybytes"]=(function(){return Module["asm"]["Ub"].apply(null,arguments)});var _crypto_core_salsa2012_outputbytes=Module["_crypto_core_salsa2012_outputbytes"]=(function(){return Module["asm"]["Vb"].apply(null,arguments)});var _crypto_core_salsa208=Module["_crypto_core_salsa208"]=(function(){return Module["asm"]["Wb"].apply(null,arguments)});var _crypto_core_salsa208_constbytes=Module["_crypto_core_salsa208_constbytes"]=(function(){return Module["asm"]["Xb"].apply(null,arguments)});var _crypto_core_salsa208_inputbytes=Module["_crypto_core_salsa208_inputbytes"]=(function(){return Module["asm"]["Yb"].apply(null,arguments)});var _crypto_core_salsa208_keybytes=Module["_crypto_core_salsa208_keybytes"]=(function(){return Module["asm"]["Zb"].apply(null,arguments)});var _crypto_core_salsa208_outputbytes=Module["_crypto_core_salsa208_outputbytes"]=(function(){return Module["asm"]["_b"].apply(null,arguments)});var _crypto_core_salsa20_constbytes=Module["_crypto_core_salsa20_constbytes"]=(function(){return Module["asm"]["$b"].apply(null,arguments)});var _crypto_core_salsa20_inputbytes=Module["_crypto_core_salsa20_inputbytes"]=(function(){return Module["asm"]["ac"].apply(null,arguments)});var _crypto_core_salsa20_keybytes=Module["_crypto_core_salsa20_keybytes"]=(function(){return Module["asm"]["bc"].apply(null,arguments)});var _crypto_core_salsa20_outputbytes=Module["_crypto_core_salsa20_outputbytes"]=(function(){return Module["asm"]["cc"].apply(null,arguments)});var _crypto_generichash=Module["_crypto_generichash"]=(function(){return Module["asm"]["dc"].apply(null,arguments)});var _crypto_generichash_blake2b=Module["_crypto_generichash_blake2b"]=(function(){return Module["asm"]["ec"].apply(null,arguments)});var _crypto_generichash_blake2b_bytes=Module["_crypto_generichash_blake2b_bytes"]=(function(){return Module["asm"]["fc"].apply(null,arguments)});var _crypto_generichash_blake2b_bytes_max=Module["_crypto_generichash_blake2b_bytes_max"]=(function(){return Module["asm"]["gc"].apply(null,arguments)});var _crypto_generichash_blake2b_bytes_min=Module["_crypto_generichash_blake2b_bytes_min"]=(function(){return Module["asm"]["hc"].apply(null,arguments)});var _crypto_generichash_blake2b_final=Module["_crypto_generichash_blake2b_final"]=(function(){return Module["asm"]["ic"].apply(null,arguments)});var _crypto_generichash_blake2b_init=Module["_crypto_generichash_blake2b_init"]=(function(){return Module["asm"]["jc"].apply(null,arguments)});var _crypto_generichash_blake2b_init_salt_personal=Module["_crypto_generichash_blake2b_init_salt_personal"]=(function(){return Module["asm"]["kc"].apply(null,arguments)});var _crypto_generichash_blake2b_keybytes=Module["_crypto_generichash_blake2b_keybytes"]=(function(){return Module["asm"]["lc"].apply(null,arguments)});var _crypto_generichash_blake2b_keybytes_max=Module["_crypto_generichash_blake2b_keybytes_max"]=(function(){return Module["asm"]["mc"].apply(null,arguments)});var _crypto_generichash_blake2b_keybytes_min=Module["_crypto_generichash_blake2b_keybytes_min"]=(function(){return Module["asm"]["nc"].apply(null,arguments)});var _crypto_generichash_blake2b_keygen=Module["_crypto_generichash_blake2b_keygen"]=(function(){return Module["asm"]["oc"].apply(null,arguments)});var _crypto_generichash_blake2b_personalbytes=Module["_crypto_generichash_blake2b_personalbytes"]=(function(){return Module["asm"]["pc"].apply(null,arguments)});var _crypto_generichash_blake2b_salt_personal=Module["_crypto_generichash_blake2b_salt_personal"]=(function(){return Module["asm"]["qc"].apply(null,arguments)});var _crypto_generichash_blake2b_saltbytes=Module["_crypto_generichash_blake2b_saltbytes"]=(function(){return Module["asm"]["rc"].apply(null,arguments)});var _crypto_generichash_blake2b_statebytes=Module["_crypto_generichash_blake2b_statebytes"]=(function(){return Module["asm"]["sc"].apply(null,arguments)});var _crypto_generichash_blake2b_update=Module["_crypto_generichash_blake2b_update"]=(function(){return Module["asm"]["tc"].apply(null,arguments)});var _crypto_generichash_bytes=Module["_crypto_generichash_bytes"]=(function(){return Module["asm"]["uc"].apply(null,arguments)});var _crypto_generichash_bytes_max=Module["_crypto_generichash_bytes_max"]=(function(){return Module["asm"]["vc"].apply(null,arguments)});var _crypto_generichash_bytes_min=Module["_crypto_generichash_bytes_min"]=(function(){return Module["asm"]["wc"].apply(null,arguments)});var _crypto_generichash_final=Module["_crypto_generichash_final"]=(function(){return Module["asm"]["xc"].apply(null,arguments)});var _crypto_generichash_init=Module["_crypto_generichash_init"]=(function(){return Module["asm"]["yc"].apply(null,arguments)});var _crypto_generichash_keybytes=Module["_crypto_generichash_keybytes"]=(function(){return Module["asm"]["zc"].apply(null,arguments)});var _crypto_generichash_keybytes_max=Module["_crypto_generichash_keybytes_max"]=(function(){return Module["asm"]["Ac"].apply(null,arguments)});var _crypto_generichash_keybytes_min=Module["_crypto_generichash_keybytes_min"]=(function(){return Module["asm"]["Bc"].apply(null,arguments)});var _crypto_generichash_keygen=Module["_crypto_generichash_keygen"]=(function(){return Module["asm"]["Cc"].apply(null,arguments)});var _crypto_generichash_primitive=Module["_crypto_generichash_primitive"]=(function(){return Module["asm"]["Dc"].apply(null,arguments)});var _crypto_generichash_statebytes=Module["_crypto_generichash_statebytes"]=(function(){return Module["asm"]["Ec"].apply(null,arguments)});var _crypto_generichash_update=Module["_crypto_generichash_update"]=(function(){return Module["asm"]["Fc"].apply(null,arguments)});var _crypto_hash=Module["_crypto_hash"]=(function(){return Module["asm"]["Gc"].apply(null,arguments)});var _crypto_hash_bytes=Module["_crypto_hash_bytes"]=(function(){return Module["asm"]["Hc"].apply(null,arguments)});var _crypto_hash_primitive=Module["_crypto_hash_primitive"]=(function(){return Module["asm"]["Ic"].apply(null,arguments)});var _crypto_hash_sha256=Module["_crypto_hash_sha256"]=(function(){return Module["asm"]["Jc"].apply(null,arguments)});var _crypto_hash_sha256_bytes=Module["_crypto_hash_sha256_bytes"]=(function(){return Module["asm"]["Kc"].apply(null,arguments)});var _crypto_hash_sha256_final=Module["_crypto_hash_sha256_final"]=(function(){return Module["asm"]["Lc"].apply(null,arguments)});var _crypto_hash_sha256_init=Module["_crypto_hash_sha256_init"]=(function(){return Module["asm"]["Mc"].apply(null,arguments)});var _crypto_hash_sha256_statebytes=Module["_crypto_hash_sha256_statebytes"]=(function(){return Module["asm"]["Nc"].apply(null,arguments)});var _crypto_hash_sha256_update=Module["_crypto_hash_sha256_update"]=(function(){return Module["asm"]["Oc"].apply(null,arguments)});var _crypto_hash_sha512=Module["_crypto_hash_sha512"]=(function(){return Module["asm"]["Pc"].apply(null,arguments)});var _crypto_hash_sha512_bytes=Module["_crypto_hash_sha512_bytes"]=(function(){return Module["asm"]["Qc"].apply(null,arguments)});var _crypto_hash_sha512_final=Module["_crypto_hash_sha512_final"]=(function(){return Module["asm"]["Rc"].apply(null,arguments)});var _crypto_hash_sha512_init=Module["_crypto_hash_sha512_init"]=(function(){return Module["asm"]["Sc"].apply(null,arguments)});var _crypto_hash_sha512_statebytes=Module["_crypto_hash_sha512_statebytes"]=(function(){return Module["asm"]["Tc"].apply(null,arguments)});var _crypto_hash_sha512_update=Module["_crypto_hash_sha512_update"]=(function(){return Module["asm"]["Uc"].apply(null,arguments)});var _crypto_kdf_blake2b_bytes_max=Module["_crypto_kdf_blake2b_bytes_max"]=(function(){return Module["asm"]["Vc"].apply(null,arguments)});var _crypto_kdf_blake2b_bytes_min=Module["_crypto_kdf_blake2b_bytes_min"]=(function(){return Module["asm"]["Wc"].apply(null,arguments)});var _crypto_kdf_blake2b_contextbytes=Module["_crypto_kdf_blake2b_contextbytes"]=(function(){return Module["asm"]["Xc"].apply(null,arguments)});var _crypto_kdf_blake2b_derive_from_key=Module["_crypto_kdf_blake2b_derive_from_key"]=(function(){return Module["asm"]["Yc"].apply(null,arguments)});var _crypto_kdf_blake2b_keybytes=Module["_crypto_kdf_blake2b_keybytes"]=(function(){return Module["asm"]["Zc"].apply(null,arguments)});var _crypto_kdf_bytes_max=Module["_crypto_kdf_bytes_max"]=(function(){return Module["asm"]["_c"].apply(null,arguments)});var _crypto_kdf_bytes_min=Module["_crypto_kdf_bytes_min"]=(function(){return Module["asm"]["$c"].apply(null,arguments)});var _crypto_kdf_contextbytes=Module["_crypto_kdf_contextbytes"]=(function(){return Module["asm"]["ad"].apply(null,arguments)});var _crypto_kdf_derive_from_key=Module["_crypto_kdf_derive_from_key"]=(function(){return Module["asm"]["bd"].apply(null,arguments)});var _crypto_kdf_keybytes=Module["_crypto_kdf_keybytes"]=(function(){return Module["asm"]["cd"].apply(null,arguments)});var _crypto_kdf_keygen=Module["_crypto_kdf_keygen"]=(function(){return Module["asm"]["dd"].apply(null,arguments)});var _crypto_kdf_primitive=Module["_crypto_kdf_primitive"]=(function(){return Module["asm"]["ed"].apply(null,arguments)});var _crypto_kx_client_session_keys=Module["_crypto_kx_client_session_keys"]=(function(){return Module["asm"]["fd"].apply(null,arguments)});var _crypto_kx_keypair=Module["_crypto_kx_keypair"]=(function(){return Module["asm"]["gd"].apply(null,arguments)});var _crypto_kx_primitive=Module["_crypto_kx_primitive"]=(function(){return Module["asm"]["hd"].apply(null,arguments)});var _crypto_kx_publickeybytes=Module["_crypto_kx_publickeybytes"]=(function(){return Module["asm"]["id"].apply(null,arguments)});var _crypto_kx_secretkeybytes=Module["_crypto_kx_secretkeybytes"]=(function(){return Module["asm"]["jd"].apply(null,arguments)});var _crypto_kx_seed_keypair=Module["_crypto_kx_seed_keypair"]=(function(){return Module["asm"]["kd"].apply(null,arguments)});var _crypto_kx_seedbytes=Module["_crypto_kx_seedbytes"]=(function(){return Module["asm"]["ld"].apply(null,arguments)});var _crypto_kx_server_session_keys=Module["_crypto_kx_server_session_keys"]=(function(){return Module["asm"]["md"].apply(null,arguments)});var _crypto_kx_sessionkeybytes=Module["_crypto_kx_sessionkeybytes"]=(function(){return Module["asm"]["nd"].apply(null,arguments)});var _crypto_onetimeauth=Module["_crypto_onetimeauth"]=(function(){return Module["asm"]["od"].apply(null,arguments)});var _crypto_onetimeauth_bytes=Module["_crypto_onetimeauth_bytes"]=(function(){return Module["asm"]["pd"].apply(null,arguments)});var _crypto_onetimeauth_final=Module["_crypto_onetimeauth_final"]=(function(){return Module["asm"]["qd"].apply(null,arguments)});var _crypto_onetimeauth_init=Module["_crypto_onetimeauth_init"]=(function(){return Module["asm"]["rd"].apply(null,arguments)});var _crypto_onetimeauth_keybytes=Module["_crypto_onetimeauth_keybytes"]=(function(){return Module["asm"]["sd"].apply(null,arguments)});var _crypto_onetimeauth_keygen=Module["_crypto_onetimeauth_keygen"]=(function(){return Module["asm"]["td"].apply(null,arguments)});var _crypto_onetimeauth_poly1305=Module["_crypto_onetimeauth_poly1305"]=(function(){return Module["asm"]["ud"].apply(null,arguments)});var _crypto_onetimeauth_poly1305_bytes=Module["_crypto_onetimeauth_poly1305_bytes"]=(function(){return Module["asm"]["vd"].apply(null,arguments)});var _crypto_onetimeauth_poly1305_final=Module["_crypto_onetimeauth_poly1305_final"]=(function(){return Module["asm"]["wd"].apply(null,arguments)});var _crypto_onetimeauth_poly1305_init=Module["_crypto_onetimeauth_poly1305_init"]=(function(){return Module["asm"]["xd"].apply(null,arguments)});var _crypto_onetimeauth_poly1305_keybytes=Module["_crypto_onetimeauth_poly1305_keybytes"]=(function(){return Module["asm"]["yd"].apply(null,arguments)});var _crypto_onetimeauth_poly1305_keygen=Module["_crypto_onetimeauth_poly1305_keygen"]=(function(){return Module["asm"]["zd"].apply(null,arguments)});var _crypto_onetimeauth_poly1305_statebytes=Module["_crypto_onetimeauth_poly1305_statebytes"]=(function(){return Module["asm"]["Ad"].apply(null,arguments)});var _crypto_onetimeauth_poly1305_update=Module["_crypto_onetimeauth_poly1305_update"]=(function(){return Module["asm"]["Bd"].apply(null,arguments)});var _crypto_onetimeauth_poly1305_verify=Module["_crypto_onetimeauth_poly1305_verify"]=(function(){return Module["asm"]["Cd"].apply(null,arguments)});var _crypto_onetimeauth_primitive=Module["_crypto_onetimeauth_primitive"]=(function(){return Module["asm"]["Dd"].apply(null,arguments)});var _crypto_onetimeauth_statebytes=Module["_crypto_onetimeauth_statebytes"]=(function(){return Module["asm"]["Ed"].apply(null,arguments)});var _crypto_onetimeauth_update=Module["_crypto_onetimeauth_update"]=(function(){return Module["asm"]["Fd"].apply(null,arguments)});var _crypto_onetimeauth_verify=Module["_crypto_onetimeauth_verify"]=(function(){return Module["asm"]["Gd"].apply(null,arguments)});var _crypto_pwhash=Module["_crypto_pwhash"]=(function(){return Module["asm"]["Hd"].apply(null,arguments)});var _crypto_pwhash_alg_argon2i13=Module["_crypto_pwhash_alg_argon2i13"]=(function(){return Module["asm"]["Id"].apply(null,arguments)});var _crypto_pwhash_alg_argon2id13=Module["_crypto_pwhash_alg_argon2id13"]=(function(){return Module["asm"]["Jd"].apply(null,arguments)});var _crypto_pwhash_alg_default=Module["_crypto_pwhash_alg_default"]=(function(){return Module["asm"]["Kd"].apply(null,arguments)});var _crypto_pwhash_argon2i=Module["_crypto_pwhash_argon2i"]=(function(){return Module["asm"]["Ld"].apply(null,arguments)});var _crypto_pwhash_argon2i_alg_argon2i13=Module["_crypto_pwhash_argon2i_alg_argon2i13"]=(function(){return Module["asm"]["Md"].apply(null,arguments)});var _crypto_pwhash_argon2i_bytes_max=Module["_crypto_pwhash_argon2i_bytes_max"]=(function(){return Module["asm"]["Nd"].apply(null,arguments)});var _crypto_pwhash_argon2i_bytes_min=Module["_crypto_pwhash_argon2i_bytes_min"]=(function(){return Module["asm"]["Od"].apply(null,arguments)});var _crypto_pwhash_argon2i_memlimit_interactive=Module["_crypto_pwhash_argon2i_memlimit_interactive"]=(function(){return Module["asm"]["Pd"].apply(null,arguments)});var _crypto_pwhash_argon2i_memlimit_max=Module["_crypto_pwhash_argon2i_memlimit_max"]=(function(){return Module["asm"]["Qd"].apply(null,arguments)});var _crypto_pwhash_argon2i_memlimit_min=Module["_crypto_pwhash_argon2i_memlimit_min"]=(function(){return Module["asm"]["Rd"].apply(null,arguments)});var _crypto_pwhash_argon2i_memlimit_moderate=Module["_crypto_pwhash_argon2i_memlimit_moderate"]=(function(){return Module["asm"]["Sd"].apply(null,arguments)});var _crypto_pwhash_argon2i_memlimit_sensitive=Module["_crypto_pwhash_argon2i_memlimit_sensitive"]=(function(){return Module["asm"]["Td"].apply(null,arguments)});var _crypto_pwhash_argon2i_opslimit_interactive=Module["_crypto_pwhash_argon2i_opslimit_interactive"]=(function(){return Module["asm"]["Ud"].apply(null,arguments)});var _crypto_pwhash_argon2i_opslimit_max=Module["_crypto_pwhash_argon2i_opslimit_max"]=(function(){return Module["asm"]["Vd"].apply(null,arguments)});var _crypto_pwhash_argon2i_opslimit_min=Module["_crypto_pwhash_argon2i_opslimit_min"]=(function(){return Module["asm"]["Wd"].apply(null,arguments)});var _crypto_pwhash_argon2i_opslimit_moderate=Module["_crypto_pwhash_argon2i_opslimit_moderate"]=(function(){return Module["asm"]["Xd"].apply(null,arguments)});var _crypto_pwhash_argon2i_opslimit_sensitive=Module["_crypto_pwhash_argon2i_opslimit_sensitive"]=(function(){return Module["asm"]["Yd"].apply(null,arguments)});var _crypto_pwhash_argon2i_passwd_max=Module["_crypto_pwhash_argon2i_passwd_max"]=(function(){return Module["asm"]["Zd"].apply(null,arguments)});var _crypto_pwhash_argon2i_passwd_min=Module["_crypto_pwhash_argon2i_passwd_min"]=(function(){return Module["asm"]["_d"].apply(null,arguments)});var _crypto_pwhash_argon2i_saltbytes=Module["_crypto_pwhash_argon2i_saltbytes"]=(function(){return Module["asm"]["$d"].apply(null,arguments)});var _crypto_pwhash_argon2i_str=Module["_crypto_pwhash_argon2i_str"]=(function(){return Module["asm"]["ae"].apply(null,arguments)});var _crypto_pwhash_argon2i_str_needs_rehash=Module["_crypto_pwhash_argon2i_str_needs_rehash"]=(function(){return Module["asm"]["be"].apply(null,arguments)});var _crypto_pwhash_argon2i_str_verify=Module["_crypto_pwhash_argon2i_str_verify"]=(function(){return Module["asm"]["ce"].apply(null,arguments)});var _crypto_pwhash_argon2i_strbytes=Module["_crypto_pwhash_argon2i_strbytes"]=(function(){return Module["asm"]["de"].apply(null,arguments)});var _crypto_pwhash_argon2i_strprefix=Module["_crypto_pwhash_argon2i_strprefix"]=(function(){return Module["asm"]["ee"].apply(null,arguments)});var _crypto_pwhash_argon2id=Module["_crypto_pwhash_argon2id"]=(function(){return Module["asm"]["fe"].apply(null,arguments)});var _crypto_pwhash_argon2id_alg_argon2id13=Module["_crypto_pwhash_argon2id_alg_argon2id13"]=(function(){return Module["asm"]["ge"].apply(null,arguments)});var _crypto_pwhash_argon2id_bytes_max=Module["_crypto_pwhash_argon2id_bytes_max"]=(function(){return Module["asm"]["he"].apply(null,arguments)});var _crypto_pwhash_argon2id_bytes_min=Module["_crypto_pwhash_argon2id_bytes_min"]=(function(){return Module["asm"]["ie"].apply(null,arguments)});var _crypto_pwhash_argon2id_memlimit_interactive=Module["_crypto_pwhash_argon2id_memlimit_interactive"]=(function(){return Module["asm"]["je"].apply(null,arguments)});var _crypto_pwhash_argon2id_memlimit_max=Module["_crypto_pwhash_argon2id_memlimit_max"]=(function(){return Module["asm"]["ke"].apply(null,arguments)});var _crypto_pwhash_argon2id_memlimit_min=Module["_crypto_pwhash_argon2id_memlimit_min"]=(function(){return Module["asm"]["le"].apply(null,arguments)});var _crypto_pwhash_argon2id_memlimit_moderate=Module["_crypto_pwhash_argon2id_memlimit_moderate"]=(function(){return Module["asm"]["me"].apply(null,arguments)});var _crypto_pwhash_argon2id_memlimit_sensitive=Module["_crypto_pwhash_argon2id_memlimit_sensitive"]=(function(){return Module["asm"]["ne"].apply(null,arguments)});var _crypto_pwhash_argon2id_opslimit_interactive=Module["_crypto_pwhash_argon2id_opslimit_interactive"]=(function(){return Module["asm"]["oe"].apply(null,arguments)});var _crypto_pwhash_argon2id_opslimit_max=Module["_crypto_pwhash_argon2id_opslimit_max"]=(function(){return Module["asm"]["pe"].apply(null,arguments)});var _crypto_pwhash_argon2id_opslimit_min=Module["_crypto_pwhash_argon2id_opslimit_min"]=(function(){return Module["asm"]["qe"].apply(null,arguments)});var _crypto_pwhash_argon2id_opslimit_moderate=Module["_crypto_pwhash_argon2id_opslimit_moderate"]=(function(){return Module["asm"]["re"].apply(null,arguments)});var _crypto_pwhash_argon2id_opslimit_sensitive=Module["_crypto_pwhash_argon2id_opslimit_sensitive"]=(function(){return Module["asm"]["se"].apply(null,arguments)});var _crypto_pwhash_argon2id_passwd_max=Module["_crypto_pwhash_argon2id_passwd_max"]=(function(){return Module["asm"]["te"].apply(null,arguments)});var _crypto_pwhash_argon2id_passwd_min=Module["_crypto_pwhash_argon2id_passwd_min"]=(function(){return Module["asm"]["ue"].apply(null,arguments)});var _crypto_pwhash_argon2id_saltbytes=Module["_crypto_pwhash_argon2id_saltbytes"]=(function(){return Module["asm"]["ve"].apply(null,arguments)});var _crypto_pwhash_argon2id_str=Module["_crypto_pwhash_argon2id_str"]=(function(){return Module["asm"]["we"].apply(null,arguments)});var _crypto_pwhash_argon2id_str_needs_rehash=Module["_crypto_pwhash_argon2id_str_needs_rehash"]=(function(){return Module["asm"]["xe"].apply(null,arguments)});var _crypto_pwhash_argon2id_str_verify=Module["_crypto_pwhash_argon2id_str_verify"]=(function(){return Module["asm"]["ye"].apply(null,arguments)});var _crypto_pwhash_argon2id_strbytes=Module["_crypto_pwhash_argon2id_strbytes"]=(function(){return Module["asm"]["ze"].apply(null,arguments)});var _crypto_pwhash_argon2id_strprefix=Module["_crypto_pwhash_argon2id_strprefix"]=(function(){return Module["asm"]["Ae"].apply(null,arguments)});var _crypto_pwhash_bytes_max=Module["_crypto_pwhash_bytes_max"]=(function(){return Module["asm"]["Be"].apply(null,arguments)});var _crypto_pwhash_bytes_min=Module["_crypto_pwhash_bytes_min"]=(function(){return Module["asm"]["Ce"].apply(null,arguments)});var _crypto_pwhash_memlimit_interactive=Module["_crypto_pwhash_memlimit_interactive"]=(function(){return Module["asm"]["De"].apply(null,arguments)});var _crypto_pwhash_memlimit_max=Module["_crypto_pwhash_memlimit_max"]=(function(){return Module["asm"]["Ee"].apply(null,arguments)});var _crypto_pwhash_memlimit_min=Module["_crypto_pwhash_memlimit_min"]=(function(){return Module["asm"]["Fe"].apply(null,arguments)});var _crypto_pwhash_memlimit_moderate=Module["_crypto_pwhash_memlimit_moderate"]=(function(){return Module["asm"]["Ge"].apply(null,arguments)});var _crypto_pwhash_memlimit_sensitive=Module["_crypto_pwhash_memlimit_sensitive"]=(function(){return Module["asm"]["He"].apply(null,arguments)});var _crypto_pwhash_opslimit_interactive=Module["_crypto_pwhash_opslimit_interactive"]=(function(){return Module["asm"]["Ie"].apply(null,arguments)});var _crypto_pwhash_opslimit_max=Module["_crypto_pwhash_opslimit_max"]=(function(){return Module["asm"]["Je"].apply(null,arguments)});var _crypto_pwhash_opslimit_min=Module["_crypto_pwhash_opslimit_min"]=(function(){return Module["asm"]["Ke"].apply(null,arguments)});var _crypto_pwhash_opslimit_moderate=Module["_crypto_pwhash_opslimit_moderate"]=(function(){return Module["asm"]["Le"].apply(null,arguments)});var _crypto_pwhash_opslimit_sensitive=Module["_crypto_pwhash_opslimit_sensitive"]=(function(){return Module["asm"]["Me"].apply(null,arguments)});var _crypto_pwhash_passwd_max=Module["_crypto_pwhash_passwd_max"]=(function(){return Module["asm"]["Ne"].apply(null,arguments)});var _crypto_pwhash_passwd_min=Module["_crypto_pwhash_passwd_min"]=(function(){return Module["asm"]["Oe"].apply(null,arguments)});var _crypto_pwhash_primitive=Module["_crypto_pwhash_primitive"]=(function(){return Module["asm"]["Pe"].apply(null,arguments)});var _crypto_pwhash_saltbytes=Module["_crypto_pwhash_saltbytes"]=(function(){return Module["asm"]["Qe"].apply(null,arguments)});var _crypto_pwhash_scryptsalsa208sha256=Module["_crypto_pwhash_scryptsalsa208sha256"]=(function(){return Module["asm"]["Re"].apply(null,arguments)});var _crypto_pwhash_scryptsalsa208sha256_bytes_max=Module["_crypto_pwhash_scryptsalsa208sha256_bytes_max"]=(function(){return Module["asm"]["Se"].apply(null,arguments)});var _crypto_pwhash_scryptsalsa208sha256_bytes_min=Module["_crypto_pwhash_scryptsalsa208sha256_bytes_min"]=(function(){return Module["asm"]["Te"].apply(null,arguments)});var _crypto_pwhash_scryptsalsa208sha256_ll=Module["_crypto_pwhash_scryptsalsa208sha256_ll"]=(function(){return Module["asm"]["Ue"].apply(null,arguments)});var _crypto_pwhash_scryptsalsa208sha256_memlimit_interactive=Module["_crypto_pwhash_scryptsalsa208sha256_memlimit_interactive"]=(function(){return Module["asm"]["Ve"].apply(null,arguments)});var _crypto_pwhash_scryptsalsa208sha256_memlimit_max=Module["_crypto_pwhash_scryptsalsa208sha256_memlimit_max"]=(function(){return Module["asm"]["We"].apply(null,arguments)});var _crypto_pwhash_scryptsalsa208sha256_memlimit_min=Module["_crypto_pwhash_scryptsalsa208sha256_memlimit_min"]=(function(){return Module["asm"]["Xe"].apply(null,arguments)});var _crypto_pwhash_scryptsalsa208sha256_memlimit_sensitive=Module["_crypto_pwhash_scryptsalsa208sha256_memlimit_sensitive"]=(function(){return Module["asm"]["Ye"].apply(null,arguments)});var _crypto_pwhash_scryptsalsa208sha256_opslimit_interactive=Module["_crypto_pwhash_scryptsalsa208sha256_opslimit_interactive"]=(function(){return Module["asm"]["Ze"].apply(null,arguments)});var _crypto_pwhash_scryptsalsa208sha256_opslimit_max=Module["_crypto_pwhash_scryptsalsa208sha256_opslimit_max"]=(function(){return Module["asm"]["_e"].apply(null,arguments)});var _crypto_pwhash_scryptsalsa208sha256_opslimit_min=Module["_crypto_pwhash_scryptsalsa208sha256_opslimit_min"]=(function(){return Module["asm"]["$e"].apply(null,arguments)});var _crypto_pwhash_scryptsalsa208sha256_opslimit_sensitive=Module["_crypto_pwhash_scryptsalsa208sha256_opslimit_sensitive"]=(function(){return Module["asm"]["af"].apply(null,arguments)});var _crypto_pwhash_scryptsalsa208sha256_passwd_max=Module["_crypto_pwhash_scryptsalsa208sha256_passwd_max"]=(function(){return Module["asm"]["bf"].apply(null,arguments)});var _crypto_pwhash_scryptsalsa208sha256_passwd_min=Module["_crypto_pwhash_scryptsalsa208sha256_passwd_min"]=(function(){return Module["asm"]["cf"].apply(null,arguments)});var _crypto_pwhash_scryptsalsa208sha256_saltbytes=Module["_crypto_pwhash_scryptsalsa208sha256_saltbytes"]=(function(){return Module["asm"]["df"].apply(null,arguments)});var _crypto_pwhash_scryptsalsa208sha256_str=Module["_crypto_pwhash_scryptsalsa208sha256_str"]=(function(){return Module["asm"]["ef"].apply(null,arguments)});var _crypto_pwhash_scryptsalsa208sha256_str_needs_rehash=Module["_crypto_pwhash_scryptsalsa208sha256_str_needs_rehash"]=(function(){return Module["asm"]["ff"].apply(null,arguments)});var _crypto_pwhash_scryptsalsa208sha256_str_verify=Module["_crypto_pwhash_scryptsalsa208sha256_str_verify"]=(function(){return Module["asm"]["gf"].apply(null,arguments)});var _crypto_pwhash_scryptsalsa208sha256_strbytes=Module["_crypto_pwhash_scryptsalsa208sha256_strbytes"]=(function(){return Module["asm"]["hf"].apply(null,arguments)});var _crypto_pwhash_scryptsalsa208sha256_strprefix=Module["_crypto_pwhash_scryptsalsa208sha256_strprefix"]=(function(){return Module["asm"]["jf"].apply(null,arguments)});var _crypto_pwhash_str=Module["_crypto_pwhash_str"]=(function(){return Module["asm"]["kf"].apply(null,arguments)});var _crypto_pwhash_str_alg=Module["_crypto_pwhash_str_alg"]=(function(){return Module["asm"]["lf"].apply(null,arguments)});var _crypto_pwhash_str_needs_rehash=Module["_crypto_pwhash_str_needs_rehash"]=(function(){return Module["asm"]["mf"].apply(null,arguments)});var _crypto_pwhash_str_verify=Module["_crypto_pwhash_str_verify"]=(function(){return Module["asm"]["nf"].apply(null,arguments)});var _crypto_pwhash_strbytes=Module["_crypto_pwhash_strbytes"]=(function(){return Module["asm"]["of"].apply(null,arguments)});var _crypto_pwhash_strprefix=Module["_crypto_pwhash_strprefix"]=(function(){return Module["asm"]["pf"].apply(null,arguments)});var _crypto_scalarmult=Module["_crypto_scalarmult"]=(function(){return Module["asm"]["qf"].apply(null,arguments)});var _crypto_scalarmult_base=Module["_crypto_scalarmult_base"]=(function(){return Module["asm"]["rf"].apply(null,arguments)});var _crypto_scalarmult_bytes=Module["_crypto_scalarmult_bytes"]=(function(){return Module["asm"]["sf"].apply(null,arguments)});var _crypto_scalarmult_curve25519=Module["_crypto_scalarmult_curve25519"]=(function(){return Module["asm"]["tf"].apply(null,arguments)});var _crypto_scalarmult_curve25519_base=Module["_crypto_scalarmult_curve25519_base"]=(function(){return Module["asm"]["uf"].apply(null,arguments)});var _crypto_scalarmult_curve25519_bytes=Module["_crypto_scalarmult_curve25519_bytes"]=(function(){return Module["asm"]["vf"].apply(null,arguments)});var _crypto_scalarmult_curve25519_scalarbytes=Module["_crypto_scalarmult_curve25519_scalarbytes"]=(function(){return Module["asm"]["wf"].apply(null,arguments)});var _crypto_scalarmult_ed25519=Module["_crypto_scalarmult_ed25519"]=(function(){return Module["asm"]["xf"].apply(null,arguments)});var _crypto_scalarmult_ed25519_base=Module["_crypto_scalarmult_ed25519_base"]=(function(){return Module["asm"]["yf"].apply(null,arguments)});var _crypto_scalarmult_ed25519_bytes=Module["_crypto_scalarmult_ed25519_bytes"]=(function(){return Module["asm"]["zf"].apply(null,arguments)});var _crypto_scalarmult_ed25519_scalarbytes=Module["_crypto_scalarmult_ed25519_scalarbytes"]=(function(){return Module["asm"]["Af"].apply(null,arguments)});var _crypto_scalarmult_primitive=Module["_crypto_scalarmult_primitive"]=(function(){return Module["asm"]["Bf"].apply(null,arguments)});var _crypto_scalarmult_scalarbytes=Module["_crypto_scalarmult_scalarbytes"]=(function(){return Module["asm"]["Cf"].apply(null,arguments)});var _crypto_secretbox=Module["_crypto_secretbox"]=(function(){return Module["asm"]["Df"].apply(null,arguments)});var _crypto_secretbox_boxzerobytes=Module["_crypto_secretbox_boxzerobytes"]=(function(){return Module["asm"]["Ef"].apply(null,arguments)});var _crypto_secretbox_detached=Module["_crypto_secretbox_detached"]=(function(){return Module["asm"]["Ff"].apply(null,arguments)});var _crypto_secretbox_easy=Module["_crypto_secretbox_easy"]=(function(){return Module["asm"]["Gf"].apply(null,arguments)});var _crypto_secretbox_keybytes=Module["_crypto_secretbox_keybytes"]=(function(){return Module["asm"]["Hf"].apply(null,arguments)});var _crypto_secretbox_keygen=Module["_crypto_secretbox_keygen"]=(function(){return Module["asm"]["If"].apply(null,arguments)});var _crypto_secretbox_macbytes=Module["_crypto_secretbox_macbytes"]=(function(){return Module["asm"]["Jf"].apply(null,arguments)});var _crypto_secretbox_noncebytes=Module["_crypto_secretbox_noncebytes"]=(function(){return Module["asm"]["Kf"].apply(null,arguments)});var _crypto_secretbox_open=Module["_crypto_secretbox_open"]=(function(){return Module["asm"]["Lf"].apply(null,arguments)});var _crypto_secretbox_open_detached=Module["_crypto_secretbox_open_detached"]=(function(){return Module["asm"]["Mf"].apply(null,arguments)});var _crypto_secretbox_open_easy=Module["_crypto_secretbox_open_easy"]=(function(){return Module["asm"]["Nf"].apply(null,arguments)});var _crypto_secretbox_primitive=Module["_crypto_secretbox_primitive"]=(function(){return Module["asm"]["Of"].apply(null,arguments)});var _crypto_secretbox_xchacha20poly1305_detached=Module["_crypto_secretbox_xchacha20poly1305_detached"]=(function(){return Module["asm"]["Pf"].apply(null,arguments)});var _crypto_secretbox_xchacha20poly1305_easy=Module["_crypto_secretbox_xchacha20poly1305_easy"]=(function(){return Module["asm"]["Qf"].apply(null,arguments)});var _crypto_secretbox_xchacha20poly1305_keybytes=Module["_crypto_secretbox_xchacha20poly1305_keybytes"]=(function(){return Module["asm"]["Rf"].apply(null,arguments)});var _crypto_secretbox_xchacha20poly1305_macbytes=Module["_crypto_secretbox_xchacha20poly1305_macbytes"]=(function(){return Module["asm"]["Sf"].apply(null,arguments)});var _crypto_secretbox_xchacha20poly1305_noncebytes=Module["_crypto_secretbox_xchacha20poly1305_noncebytes"]=(function(){return Module["asm"]["Tf"].apply(null,arguments)});var _crypto_secretbox_xchacha20poly1305_open_detached=Module["_crypto_secretbox_xchacha20poly1305_open_detached"]=(function(){return Module["asm"]["Uf"].apply(null,arguments)});var _crypto_secretbox_xchacha20poly1305_open_easy=Module["_crypto_secretbox_xchacha20poly1305_open_easy"]=(function(){return Module["asm"]["Vf"].apply(null,arguments)});var _crypto_secretbox_xsalsa20poly1305=Module["_crypto_secretbox_xsalsa20poly1305"]=(function(){return Module["asm"]["Wf"].apply(null,arguments)});var _crypto_secretbox_xsalsa20poly1305_boxzerobytes=Module["_crypto_secretbox_xsalsa20poly1305_boxzerobytes"]=(function(){return Module["asm"]["Xf"].apply(null,arguments)});var _crypto_secretbox_xsalsa20poly1305_keybytes=Module["_crypto_secretbox_xsalsa20poly1305_keybytes"]=(function(){return Module["asm"]["Yf"].apply(null,arguments)});var _crypto_secretbox_xsalsa20poly1305_keygen=Module["_crypto_secretbox_xsalsa20poly1305_keygen"]=(function(){return Module["asm"]["Zf"].apply(null,arguments)});var _crypto_secretbox_xsalsa20poly1305_macbytes=Module["_crypto_secretbox_xsalsa20poly1305_macbytes"]=(function(){return Module["asm"]["_f"].apply(null,arguments)});var _crypto_secretbox_xsalsa20poly1305_noncebytes=Module["_crypto_secretbox_xsalsa20poly1305_noncebytes"]=(function(){return Module["asm"]["$f"].apply(null,arguments)});var _crypto_secretbox_xsalsa20poly1305_open=Module["_crypto_secretbox_xsalsa20poly1305_open"]=(function(){return Module["asm"]["ag"].apply(null,arguments)});var _crypto_secretbox_xsalsa20poly1305_zerobytes=Module["_crypto_secretbox_xsalsa20poly1305_zerobytes"]=(function(){return Module["asm"]["bg"].apply(null,arguments)});var _crypto_secretbox_zerobytes=Module["_crypto_secretbox_zerobytes"]=(function(){return Module["asm"]["cg"].apply(null,arguments)});var _crypto_secretstream_xchacha20poly1305_abytes=Module["_crypto_secretstream_xchacha20poly1305_abytes"]=(function(){return Module["asm"]["dg"].apply(null,arguments)});var _crypto_secretstream_xchacha20poly1305_headerbytes=Module["_crypto_secretstream_xchacha20poly1305_headerbytes"]=(function(){return Module["asm"]["eg"].apply(null,arguments)});var _crypto_secretstream_xchacha20poly1305_init_pull=Module["_crypto_secretstream_xchacha20poly1305_init_pull"]=(function(){return Module["asm"]["fg"].apply(null,arguments)});var _crypto_secretstream_xchacha20poly1305_init_push=Module["_crypto_secretstream_xchacha20poly1305_init_push"]=(function(){return Module["asm"]["gg"].apply(null,arguments)});var _crypto_secretstream_xchacha20poly1305_keybytes=Module["_crypto_secretstream_xchacha20poly1305_keybytes"]=(function(){return Module["asm"]["hg"].apply(null,arguments)});var _crypto_secretstream_xchacha20poly1305_keygen=Module["_crypto_secretstream_xchacha20poly1305_keygen"]=(function(){return Module["asm"]["ig"].apply(null,arguments)});var _crypto_secretstream_xchacha20poly1305_messagebytes_max=Module["_crypto_secretstream_xchacha20poly1305_messagebytes_max"]=(function(){return Module["asm"]["jg"].apply(null,arguments)});var _crypto_secretstream_xchacha20poly1305_pull=Module["_crypto_secretstream_xchacha20poly1305_pull"]=(function(){return Module["asm"]["kg"].apply(null,arguments)});var _crypto_secretstream_xchacha20poly1305_push=Module["_crypto_secretstream_xchacha20poly1305_push"]=(function(){return Module["asm"]["lg"].apply(null,arguments)});var _crypto_secretstream_xchacha20poly1305_rekey=Module["_crypto_secretstream_xchacha20poly1305_rekey"]=(function(){return Module["asm"]["mg"].apply(null,arguments)});var _crypto_secretstream_xchacha20poly1305_statebytes=Module["_crypto_secretstream_xchacha20poly1305_statebytes"]=(function(){return Module["asm"]["ng"].apply(null,arguments)});var _crypto_secretstream_xchacha20poly1305_tag_final=Module["_crypto_secretstream_xchacha20poly1305_tag_final"]=(function(){return Module["asm"]["og"].apply(null,arguments)});var _crypto_secretstream_xchacha20poly1305_tag_message=Module["_crypto_secretstream_xchacha20poly1305_tag_message"]=(function(){return Module["asm"]["pg"].apply(null,arguments)});var _crypto_secretstream_xchacha20poly1305_tag_push=Module["_crypto_secretstream_xchacha20poly1305_tag_push"]=(function(){return Module["asm"]["qg"].apply(null,arguments)});var _crypto_secretstream_xchacha20poly1305_tag_rekey=Module["_crypto_secretstream_xchacha20poly1305_tag_rekey"]=(function(){return Module["asm"]["rg"].apply(null,arguments)});var _crypto_shorthash=Module["_crypto_shorthash"]=(function(){return Module["asm"]["sg"].apply(null,arguments)});var _crypto_shorthash_bytes=Module["_crypto_shorthash_bytes"]=(function(){return Module["asm"]["tg"].apply(null,arguments)});var _crypto_shorthash_keybytes=Module["_crypto_shorthash_keybytes"]=(function(){return Module["asm"]["ug"].apply(null,arguments)});var _crypto_shorthash_keygen=Module["_crypto_shorthash_keygen"]=(function(){return Module["asm"]["vg"].apply(null,arguments)});var _crypto_shorthash_primitive=Module["_crypto_shorthash_primitive"]=(function(){return Module["asm"]["wg"].apply(null,arguments)});var _crypto_shorthash_siphash24=Module["_crypto_shorthash_siphash24"]=(function(){return Module["asm"]["xg"].apply(null,arguments)});var _crypto_shorthash_siphash24_bytes=Module["_crypto_shorthash_siphash24_bytes"]=(function(){return Module["asm"]["yg"].apply(null,arguments)});var _crypto_shorthash_siphash24_keybytes=Module["_crypto_shorthash_siphash24_keybytes"]=(function(){return Module["asm"]["zg"].apply(null,arguments)});var _crypto_shorthash_siphashx24=Module["_crypto_shorthash_siphashx24"]=(function(){return Module["asm"]["Ag"].apply(null,arguments)});var _crypto_shorthash_siphashx24_bytes=Module["_crypto_shorthash_siphashx24_bytes"]=(function(){return Module["asm"]["Bg"].apply(null,arguments)});var _crypto_shorthash_siphashx24_keybytes=Module["_crypto_shorthash_siphashx24_keybytes"]=(function(){return Module["asm"]["Cg"].apply(null,arguments)});var _crypto_sign=Module["_crypto_sign"]=(function(){return Module["asm"]["Dg"].apply(null,arguments)});var _crypto_sign_bytes=Module["_crypto_sign_bytes"]=(function(){return Module["asm"]["Eg"].apply(null,arguments)});var _crypto_sign_detached=Module["_crypto_sign_detached"]=(function(){return Module["asm"]["Fg"].apply(null,arguments)});var _crypto_sign_ed25519=Module["_crypto_sign_ed25519"]=(function(){return Module["asm"]["Gg"].apply(null,arguments)});var _crypto_sign_ed25519_bytes=Module["_crypto_sign_ed25519_bytes"]=(function(){return Module["asm"]["Hg"].apply(null,arguments)});var _crypto_sign_ed25519_detached=Module["_crypto_sign_ed25519_detached"]=(function(){return Module["asm"]["Ig"].apply(null,arguments)});var _crypto_sign_ed25519_keypair=Module["_crypto_sign_ed25519_keypair"]=(function(){return Module["asm"]["Jg"].apply(null,arguments)});var _crypto_sign_ed25519_open=Module["_crypto_sign_ed25519_open"]=(function(){return Module["asm"]["Kg"].apply(null,arguments)});var _crypto_sign_ed25519_pk_to_curve25519=Module["_crypto_sign_ed25519_pk_to_curve25519"]=(function(){return Module["asm"]["Lg"].apply(null,arguments)});var _crypto_sign_ed25519_publickeybytes=Module["_crypto_sign_ed25519_publickeybytes"]=(function(){return Module["asm"]["Mg"].apply(null,arguments)});var _crypto_sign_ed25519_secretkeybytes=Module["_crypto_sign_ed25519_secretkeybytes"]=(function(){return Module["asm"]["Ng"].apply(null,arguments)});var _crypto_sign_ed25519_seed_keypair=Module["_crypto_sign_ed25519_seed_keypair"]=(function(){return Module["asm"]["Og"].apply(null,arguments)});var _crypto_sign_ed25519_seedbytes=Module["_crypto_sign_ed25519_seedbytes"]=(function(){return Module["asm"]["Pg"].apply(null,arguments)});var _crypto_sign_ed25519_sk_to_curve25519=Module["_crypto_sign_ed25519_sk_to_curve25519"]=(function(){return Module["asm"]["Qg"].apply(null,arguments)});var _crypto_sign_ed25519_sk_to_pk=Module["_crypto_sign_ed25519_sk_to_pk"]=(function(){return Module["asm"]["Rg"].apply(null,arguments)});var _crypto_sign_ed25519_sk_to_seed=Module["_crypto_sign_ed25519_sk_to_seed"]=(function(){return Module["asm"]["Sg"].apply(null,arguments)});var _crypto_sign_ed25519_verify_detached=Module["_crypto_sign_ed25519_verify_detached"]=(function(){return Module["asm"]["Tg"].apply(null,arguments)});var _crypto_sign_ed25519ph_final_create=Module["_crypto_sign_ed25519ph_final_create"]=(function(){return Module["asm"]["Ug"].apply(null,arguments)});var _crypto_sign_ed25519ph_final_verify=Module["_crypto_sign_ed25519ph_final_verify"]=(function(){return Module["asm"]["Vg"].apply(null,arguments)});var _crypto_sign_ed25519ph_init=Module["_crypto_sign_ed25519ph_init"]=(function(){return Module["asm"]["Wg"].apply(null,arguments)});var _crypto_sign_ed25519ph_statebytes=Module["_crypto_sign_ed25519ph_statebytes"]=(function(){return Module["asm"]["Xg"].apply(null,arguments)});var _crypto_sign_ed25519ph_update=Module["_crypto_sign_ed25519ph_update"]=(function(){return Module["asm"]["Yg"].apply(null,arguments)});var _crypto_sign_final_create=Module["_crypto_sign_final_create"]=(function(){return Module["asm"]["Zg"].apply(null,arguments)});var _crypto_sign_final_verify=Module["_crypto_sign_final_verify"]=(function(){return Module["asm"]["_g"].apply(null,arguments)});var _crypto_sign_init=Module["_crypto_sign_init"]=(function(){return Module["asm"]["$g"].apply(null,arguments)});var _crypto_sign_keypair=Module["_crypto_sign_keypair"]=(function(){return Module["asm"]["ah"].apply(null,arguments)});var _crypto_sign_open=Module["_crypto_sign_open"]=(function(){return Module["asm"]["bh"].apply(null,arguments)});var _crypto_sign_primitive=Module["_crypto_sign_primitive"]=(function(){return Module["asm"]["ch"].apply(null,arguments)});var _crypto_sign_publickeybytes=Module["_crypto_sign_publickeybytes"]=(function(){return Module["asm"]["dh"].apply(null,arguments)});var _crypto_sign_secretkeybytes=Module["_crypto_sign_secretkeybytes"]=(function(){return Module["asm"]["eh"].apply(null,arguments)});var _crypto_sign_seed_keypair=Module["_crypto_sign_seed_keypair"]=(function(){return Module["asm"]["fh"].apply(null,arguments)});var _crypto_sign_seedbytes=Module["_crypto_sign_seedbytes"]=(function(){return Module["asm"]["gh"].apply(null,arguments)});var _crypto_sign_statebytes=Module["_crypto_sign_statebytes"]=(function(){return Module["asm"]["hh"].apply(null,arguments)});var _crypto_sign_update=Module["_crypto_sign_update"]=(function(){return Module["asm"]["ih"].apply(null,arguments)});var _crypto_sign_verify_detached=Module["_crypto_sign_verify_detached"]=(function(){return Module["asm"]["jh"].apply(null,arguments)});var _crypto_stream=Module["_crypto_stream"]=(function(){return Module["asm"]["kh"].apply(null,arguments)});var _crypto_stream_chacha20=Module["_crypto_stream_chacha20"]=(function(){return Module["asm"]["lh"].apply(null,arguments)});var _crypto_stream_chacha20_ietf=Module["_crypto_stream_chacha20_ietf"]=(function(){return Module["asm"]["mh"].apply(null,arguments)});var _crypto_stream_chacha20_ietf_keybytes=Module["_crypto_stream_chacha20_ietf_keybytes"]=(function(){return Module["asm"]["nh"].apply(null,arguments)});var _crypto_stream_chacha20_ietf_keygen=Module["_crypto_stream_chacha20_ietf_keygen"]=(function(){return Module["asm"]["oh"].apply(null,arguments)});var _crypto_stream_chacha20_ietf_noncebytes=Module["_crypto_stream_chacha20_ietf_noncebytes"]=(function(){return Module["asm"]["ph"].apply(null,arguments)});var _crypto_stream_chacha20_ietf_xor=Module["_crypto_stream_chacha20_ietf_xor"]=(function(){return Module["asm"]["qh"].apply(null,arguments)});var _crypto_stream_chacha20_ietf_xor_ic=Module["_crypto_stream_chacha20_ietf_xor_ic"]=(function(){return Module["asm"]["rh"].apply(null,arguments)});var _crypto_stream_chacha20_keybytes=Module["_crypto_stream_chacha20_keybytes"]=(function(){return Module["asm"]["sh"].apply(null,arguments)});var _crypto_stream_chacha20_keygen=Module["_crypto_stream_chacha20_keygen"]=(function(){return Module["asm"]["th"].apply(null,arguments)});var _crypto_stream_chacha20_noncebytes=Module["_crypto_stream_chacha20_noncebytes"]=(function(){return Module["asm"]["uh"].apply(null,arguments)});var _crypto_stream_chacha20_xor=Module["_crypto_stream_chacha20_xor"]=(function(){return Module["asm"]["vh"].apply(null,arguments)});var _crypto_stream_chacha20_xor_ic=Module["_crypto_stream_chacha20_xor_ic"]=(function(){return Module["asm"]["wh"].apply(null,arguments)});var _crypto_stream_keybytes=Module["_crypto_stream_keybytes"]=(function(){return Module["asm"]["xh"].apply(null,arguments)});var _crypto_stream_keygen=Module["_crypto_stream_keygen"]=(function(){return Module["asm"]["yh"].apply(null,arguments)});var _crypto_stream_noncebytes=Module["_crypto_stream_noncebytes"]=(function(){return Module["asm"]["zh"].apply(null,arguments)});var _crypto_stream_primitive=Module["_crypto_stream_primitive"]=(function(){return Module["asm"]["Ah"].apply(null,arguments)});var _crypto_stream_salsa20=Module["_crypto_stream_salsa20"]=(function(){return Module["asm"]["Bh"].apply(null,arguments)});var _crypto_stream_salsa2012=Module["_crypto_stream_salsa2012"]=(function(){return Module["asm"]["Ch"].apply(null,arguments)});var _crypto_stream_salsa2012_keybytes=Module["_crypto_stream_salsa2012_keybytes"]=(function(){return Module["asm"]["Dh"].apply(null,arguments)});var _crypto_stream_salsa2012_keygen=Module["_crypto_stream_salsa2012_keygen"]=(function(){return Module["asm"]["Eh"].apply(null,arguments)});var _crypto_stream_salsa2012_noncebytes=Module["_crypto_stream_salsa2012_noncebytes"]=(function(){return Module["asm"]["Fh"].apply(null,arguments)});var _crypto_stream_salsa2012_xor=Module["_crypto_stream_salsa2012_xor"]=(function(){return Module["asm"]["Gh"].apply(null,arguments)});var _crypto_stream_salsa208=Module["_crypto_stream_salsa208"]=(function(){return Module["asm"]["Hh"].apply(null,arguments)});var _crypto_stream_salsa208_keybytes=Module["_crypto_stream_salsa208_keybytes"]=(function(){return Module["asm"]["Ih"].apply(null,arguments)});var _crypto_stream_salsa208_keygen=Module["_crypto_stream_salsa208_keygen"]=(function(){return Module["asm"]["Jh"].apply(null,arguments)});var _crypto_stream_salsa208_messagebytes_max=Module["_crypto_stream_salsa208_messagebytes_max"]=(function(){return Module["asm"]["Kh"].apply(null,arguments)});var _crypto_stream_salsa208_noncebytes=Module["_crypto_stream_salsa208_noncebytes"]=(function(){return Module["asm"]["Lh"].apply(null,arguments)});var _crypto_stream_salsa208_xor=Module["_crypto_stream_salsa208_xor"]=(function(){return Module["asm"]["Mh"].apply(null,arguments)});var _crypto_stream_salsa20_keybytes=Module["_crypto_stream_salsa20_keybytes"]=(function(){return Module["asm"]["Nh"].apply(null,arguments)});var _crypto_stream_salsa20_keygen=Module["_crypto_stream_salsa20_keygen"]=(function(){return Module["asm"]["Oh"].apply(null,arguments)});var _crypto_stream_salsa20_noncebytes=Module["_crypto_stream_salsa20_noncebytes"]=(function(){return Module["asm"]["Ph"].apply(null,arguments)});var _crypto_stream_salsa20_xor=Module["_crypto_stream_salsa20_xor"]=(function(){return Module["asm"]["Qh"].apply(null,arguments)});var _crypto_stream_salsa20_xor_ic=Module["_crypto_stream_salsa20_xor_ic"]=(function(){return Module["asm"]["Rh"].apply(null,arguments)});var _crypto_stream_xchacha20=Module["_crypto_stream_xchacha20"]=(function(){return Module["asm"]["Sh"].apply(null,arguments)});var _crypto_stream_xchacha20_keybytes=Module["_crypto_stream_xchacha20_keybytes"]=(function(){return Module["asm"]["Th"].apply(null,arguments)});var _crypto_stream_xchacha20_keygen=Module["_crypto_stream_xchacha20_keygen"]=(function(){return Module["asm"]["Uh"].apply(null,arguments)});var _crypto_stream_xchacha20_noncebytes=Module["_crypto_stream_xchacha20_noncebytes"]=(function(){return Module["asm"]["Vh"].apply(null,arguments)});var _crypto_stream_xchacha20_xor=Module["_crypto_stream_xchacha20_xor"]=(function(){return Module["asm"]["Wh"].apply(null,arguments)});var _crypto_stream_xchacha20_xor_ic=Module["_crypto_stream_xchacha20_xor_ic"]=(function(){return Module["asm"]["Xh"].apply(null,arguments)});var _crypto_stream_xor=Module["_crypto_stream_xor"]=(function(){return Module["asm"]["Yh"].apply(null,arguments)});var _crypto_stream_xsalsa20=Module["_crypto_stream_xsalsa20"]=(function(){return Module["asm"]["Zh"].apply(null,arguments)});var _crypto_stream_xsalsa20_keybytes=Module["_crypto_stream_xsalsa20_keybytes"]=(function(){return Module["asm"]["_h"].apply(null,arguments)});var _crypto_stream_xsalsa20_keygen=Module["_crypto_stream_xsalsa20_keygen"]=(function(){return Module["asm"]["$h"].apply(null,arguments)});var _crypto_stream_xsalsa20_noncebytes=Module["_crypto_stream_xsalsa20_noncebytes"]=(function(){return Module["asm"]["ai"].apply(null,arguments)});var _crypto_stream_xsalsa20_xor=Module["_crypto_stream_xsalsa20_xor"]=(function(){return Module["asm"]["bi"].apply(null,arguments)});var _crypto_stream_xsalsa20_xor_ic=Module["_crypto_stream_xsalsa20_xor_ic"]=(function(){return Module["asm"]["ci"].apply(null,arguments)});var _crypto_verify_16=Module["_crypto_verify_16"]=(function(){return Module["asm"]["di"].apply(null,arguments)});var _crypto_verify_16_bytes=Module["_crypto_verify_16_bytes"]=(function(){return Module["asm"]["ei"].apply(null,arguments)});var _crypto_verify_32=Module["_crypto_verify_32"]=(function(){return Module["asm"]["fi"].apply(null,arguments)});var _crypto_verify_32_bytes=Module["_crypto_verify_32_bytes"]=(function(){return Module["asm"]["gi"].apply(null,arguments)});var _crypto_verify_64=Module["_crypto_verify_64"]=(function(){return Module["asm"]["hi"].apply(null,arguments)});var _crypto_verify_64_bytes=Module["_crypto_verify_64_bytes"]=(function(){return Module["asm"]["ii"].apply(null,arguments)});var _emscripten_replace_memory=Module["_emscripten_replace_memory"]=(function(){return Module["asm"]["_emscripten_replace_memory"].apply(null,arguments)});var _free=Module["_free"]=(function(){return Module["asm"]["ji"].apply(null,arguments)});var _malloc=Module["_malloc"]=(function(){return Module["asm"]["ki"].apply(null,arguments)});var _randombytes=Module["_randombytes"]=(function(){return Module["asm"]["li"].apply(null,arguments)});var _randombytes_buf=Module["_randombytes_buf"]=(function(){return Module["asm"]["mi"].apply(null,arguments)});var _randombytes_buf_deterministic=Module["_randombytes_buf_deterministic"]=(function(){return Module["asm"]["ni"].apply(null,arguments)});var _randombytes_close=Module["_randombytes_close"]=(function(){return Module["asm"]["oi"].apply(null,arguments)});var _randombytes_implementation_name=Module["_randombytes_implementation_name"]=(function(){return Module["asm"]["pi"].apply(null,arguments)});var _randombytes_random=Module["_randombytes_random"]=(function(){return Module["asm"]["qi"].apply(null,arguments)});var _randombytes_seedbytes=Module["_randombytes_seedbytes"]=(function(){return Module["asm"]["ri"].apply(null,arguments)});var _randombytes_stir=Module["_randombytes_stir"]=(function(){return Module["asm"]["si"].apply(null,arguments)});var _randombytes_uniform=Module["_randombytes_uniform"]=(function(){return Module["asm"]["ti"].apply(null,arguments)});var _sodium_base642bin=Module["_sodium_base642bin"]=(function(){return Module["asm"]["ui"].apply(null,arguments)});var _sodium_base64_encoded_len=Module["_sodium_base64_encoded_len"]=(function(){return Module["asm"]["vi"].apply(null,arguments)});var _sodium_bin2base64=Module["_sodium_bin2base64"]=(function(){return Module["asm"]["wi"].apply(null,arguments)});var _sodium_bin2hex=Module["_sodium_bin2hex"]=(function(){return Module["asm"]["xi"].apply(null,arguments)});var _sodium_hex2bin=Module["_sodium_hex2bin"]=(function(){return Module["asm"]["yi"].apply(null,arguments)});var _sodium_init=Module["_sodium_init"]=(function(){return Module["asm"]["zi"].apply(null,arguments)});var _sodium_library_minimal=Module["_sodium_library_minimal"]=(function(){return Module["asm"]["Ai"].apply(null,arguments)});var _sodium_library_version_major=Module["_sodium_library_version_major"]=(function(){return Module["asm"]["Bi"].apply(null,arguments)});var _sodium_library_version_minor=Module["_sodium_library_version_minor"]=(function(){return Module["asm"]["Ci"].apply(null,arguments)});var _sodium_pad=Module["_sodium_pad"]=(function(){return Module["asm"]["Di"].apply(null,arguments)});var _sodium_unpad=Module["_sodium_unpad"]=(function(){return Module["asm"]["Ei"].apply(null,arguments)});var _sodium_version_string=Module["_sodium_version_string"]=(function(){return Module["asm"]["Fi"].apply(null,arguments)});Module["asm"]=asm;Module["setValue"]=setValue;Module["getValue"]=getValue;Module["Pointer_stringify"]=Pointer_stringify;function ExitStatus(status){this.name="ExitStatus";this.message="Program terminated with exit("+status+")";this.status=status}ExitStatus.prototype=new Error;ExitStatus.prototype.constructor=ExitStatus;dependenciesFulfilled=function runCaller(){if(!Module["calledRun"])run();if(!Module["calledRun"])dependenciesFulfilled=runCaller};function run(args){args=args||Module["arguments"];if(runDependencies>0){return}preRun();if(runDependencies>0)return;if(Module["calledRun"])return;function doRun(){if(Module["calledRun"])return;Module["calledRun"]=true;if(ABORT)return;ensureInitRuntime();preMain();if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout((function(){setTimeout((function(){Module["setStatus"]("")}),1);doRun()}),1)}else{doRun()}}Module["run"]=run;function abort(what){if(Module["onAbort"]){Module["onAbort"](what)}if(what!==undefined){out(what);err(what);what=JSON.stringify(what)}else{what=""}ABORT=true;EXITSTATUS=1;throw"abort("+what+"). Build with -s ASSERTIONS=1 for more info."}Module["abort"]=abort;if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}Module["noExitRuntime"]=true;run()
20583 }).catch(function () {
20584 _Module.useBackupModule();
20585 });
20586function nacl_cooked(nacl_raw) {
20587 'use strict';
20588 var exports = {};
20589
20590 //---------------------------------------------------------------------------
20591 // Horrifying UTF-8 and hex codecs
20592
20593 function encode_utf8(s) {
20594 return encode_latin1(unescape(encodeURIComponent(s)));
20595 }
20596
20597 function encode_latin1(s) {
20598 var result = new Uint8Array(s.length);
20599 for (var i = 0; i < s.length; i++) {
20600 var c = s.charCodeAt(i);
20601 if ((c & 0xff) !== c) throw {message: "Cannot encode string in Latin1", str: s};
20602 result[i] = (c & 0xff);
20603 }
20604 return result;
20605 }
20606
20607 function decode_utf8(bs) {
20608 return decodeURIComponent(escape(decode_latin1(bs)));
20609 }
20610
20611 function decode_latin1(bs) {
20612 var encoded = [];
20613 for (var i = 0; i < bs.length; i++) {
20614 encoded.push(String.fromCharCode(bs[i]));
20615 }
20616 return encoded.join('');
20617 }
20618
20619 function to_hex(bs) {
20620 var encoded = [];
20621 for (var i = 0; i < bs.length; i++) {
20622 encoded.push("0123456789abcdef"[(bs[i] >> 4) & 15]);
20623 encoded.push("0123456789abcdef"[bs[i] & 15]);
20624 }
20625 return encoded.join('');
20626 }
20627
20628 function from_hex(s) {
20629 var result = new Uint8Array(s.length / 2);
20630 for (var i = 0; i < s.length / 2; i++) {
20631 result[i] = parseInt(s.substr(2*i,2),16);
20632 }
20633 return result;
20634 }
20635
20636 //---------------------------------------------------------------------------
20637 // Allocation
20638
20639 function MALLOC(nbytes) {
20640 var result = nacl_raw._malloc(nbytes);
20641 if (result === 0) {
20642 throw {message: "malloc() failed", nbytes: nbytes};
20643 }
20644 return result;
20645 }
20646
20647 function FREE(pointer) {
20648 nacl_raw._free(pointer);
20649 }
20650
20651 //---------------------------------------------------------------------------
20652
20653 function injectBytes(bs, leftPadding) {
20654 var p = leftPadding || 0;
20655 var address = MALLOC(bs.length + p);
20656 nacl_raw.HEAPU8.set(bs, address + p);
20657 for (var i = address; i < address + p; i++) {
20658 nacl_raw.HEAPU8[i] = 0;
20659 }
20660 return address;
20661 }
20662
20663 function check_injectBytes(function_name, what, thing, expected_length, leftPadding) {
20664 check_length(function_name, what, thing, expected_length);
20665 return injectBytes(thing, leftPadding);
20666 }
20667
20668 function extractBytes(address, length) {
20669 var result = new Uint8Array(length);
20670 result.set(nacl_raw.HEAPU8.subarray(address, address + length));
20671 return result;
20672 }
20673
20674 //---------------------------------------------------------------------------
20675
20676 function check(function_name, result) {
20677 if (result !== 0) {
20678 throw {message: "nacl_raw." + function_name + " signalled an error"};
20679 }
20680 }
20681
20682 function check_length(function_name, what, thing, expected_length) {
20683 if (thing.length !== expected_length) {
20684 throw {message: "nacl." + function_name + " expected " +
20685 expected_length + "-byte " + what + " but got length " + thing.length};
20686 }
20687 }
20688
20689 function Target(length) {
20690 this.length = length;
20691 this.address = MALLOC(length);
20692 }
20693
20694 Target.prototype.extractBytes = function (offset) {
20695 var result = extractBytes(this.address + (offset || 0), this.length - (offset || 0));
20696 FREE(this.address);
20697 this.address = null;
20698 return result;
20699 };
20700
20701 function free_all(addresses) {
20702 for (var i = 0; i < addresses.length; i++) {
20703 FREE(addresses[i]);
20704 }
20705 }
20706
20707 //---------------------------------------------------------------------------
20708 // Randomness
20709
20710 function random_bytes(count) {
20711 var bs = new Target(count);
20712 nacl_raw._randombytes_buf(bs.address, count);
20713 return bs.extractBytes();
20714 }
20715
20716 nacl_raw._randombytes_stir();
20717
20718 //---------------------------------------------------------------------------
20719 // Boxing
20720
20721 function crypto_box_keypair() {
20722 var pk = new Target(nacl_raw._crypto_box_publickeybytes());
20723 var sk = new Target(nacl_raw._crypto_box_secretkeybytes());
20724 check("_crypto_box_keypair", nacl_raw._crypto_box_keypair(pk.address, sk.address));
20725 return {boxPk: pk.extractBytes(), boxSk: sk.extractBytes()};
20726 }
20727
20728 function crypto_box_random_nonce() {
20729 return random_bytes(nacl_raw._crypto_box_noncebytes());
20730 }
20731
20732 function crypto_box(msg, nonce, pk, sk) {
20733 var m = injectBytes(msg, nacl_raw._crypto_box_zerobytes());
20734 var na = check_injectBytes("crypto_box", "nonce", nonce, nacl_raw._crypto_box_noncebytes());
20735 var pka = check_injectBytes("crypto_box", "pk", pk, nacl_raw._crypto_box_publickeybytes());
20736 var ska = check_injectBytes("crypto_box", "sk", sk, nacl_raw._crypto_box_secretkeybytes());
20737 var c = new Target(msg.length + nacl_raw._crypto_box_zerobytes());
20738 check("_crypto_box", nacl_raw._crypto_box(c.address, m, c.length, 0, na, pka, ska));
20739 free_all([m, na, pka, ska]);
20740 return c.extractBytes(nacl_raw._crypto_box_boxzerobytes());
20741 }
20742
20743 function crypto_box_open(ciphertext, nonce, pk, sk) {
20744 var c = injectBytes(ciphertext, nacl_raw._crypto_box_boxzerobytes());
20745 var na = check_injectBytes("crypto_box_open",
20746 "nonce", nonce, nacl_raw._crypto_box_noncebytes());
20747 var pka = check_injectBytes("crypto_box_open",
20748 "pk", pk, nacl_raw._crypto_box_publickeybytes());
20749 var ska = check_injectBytes("crypto_box_open",
20750 "sk", sk, nacl_raw._crypto_box_secretkeybytes());
20751 var m = new Target(ciphertext.length + nacl_raw._crypto_box_boxzerobytes());
20752 check("_crypto_box_open", nacl_raw._crypto_box_open(m.address, c, m.length, 0, na, pka, ska));
20753 free_all([c, na, pka, ska]);
20754 return m.extractBytes(nacl_raw._crypto_box_zerobytes());
20755 }
20756
20757 function crypto_box_precompute(pk, sk) {
20758 var pka = check_injectBytes("crypto_box_precompute",
20759 "pk", pk, nacl_raw._crypto_box_publickeybytes());
20760 var ska = check_injectBytes("crypto_box_precompute",
20761 "sk", sk, nacl_raw._crypto_box_secretkeybytes());
20762 var k = new Target(nacl_raw._crypto_box_beforenmbytes());
20763 check("_crypto_box_beforenm",
20764 nacl_raw._crypto_box_beforenm(k.address, pka, ska));
20765 free_all([pka, ska]);
20766 return {boxK: k.extractBytes()};
20767 }
20768
20769 function crypto_box_precomputed(msg, nonce, state) {
20770 var m = injectBytes(msg, nacl_raw._crypto_box_zerobytes());
20771 var na = check_injectBytes("crypto_box_precomputed",
20772 "nonce", nonce, nacl_raw._crypto_box_noncebytes());
20773 var ka = check_injectBytes("crypto_box_precomputed",
20774 "boxK", state.boxK, nacl_raw._crypto_box_beforenmbytes());
20775 var c = new Target(msg.length + nacl_raw._crypto_box_zerobytes());
20776 check("_crypto_box_afternm",
20777 nacl_raw._crypto_box_afternm(c.address, m, c.length, 0, na, ka));
20778 free_all([m, na, ka]);
20779 return c.extractBytes(nacl_raw._crypto_box_boxzerobytes());
20780 }
20781
20782 function crypto_box_open_precomputed(ciphertext, nonce, state) {
20783 var c = injectBytes(ciphertext, nacl_raw._crypto_box_boxzerobytes());
20784 var na = check_injectBytes("crypto_box_open_precomputed",
20785 "nonce", nonce, nacl_raw._crypto_box_noncebytes());
20786 var ka = check_injectBytes("crypto_box_open_precomputed",
20787 "boxK", state.boxK, nacl_raw._crypto_box_beforenmbytes());
20788 var m = new Target(ciphertext.length + nacl_raw._crypto_box_boxzerobytes());
20789 check("_crypto_box_open_afternm",
20790 nacl_raw._crypto_box_open_afternm(m.address, c, m.length, 0, na, ka));
20791 free_all([c, na, ka]);
20792 return m.extractBytes(nacl_raw._crypto_box_zerobytes());
20793 }
20794
20795 //---------------------------------------------------------------------------
20796 // Hashing
20797
20798 function crypto_hash(bs) {
20799 var address = injectBytes(bs);
20800 var hash = new Target(nacl_raw._crypto_hash_bytes());
20801 check("_crypto_hash", nacl_raw._crypto_hash(hash.address, address, bs.length, 0));
20802 FREE(address);
20803 return hash.extractBytes();
20804 }
20805
20806 function crypto_hash_sha256(bs) {
20807 var address = injectBytes(bs);
20808 var hash = new Target(nacl_raw._crypto_hash_sha256_bytes());
20809 check("_crypto_hash_sha256",
20810 nacl_raw._crypto_hash_sha256(hash.address, address, bs.length, 0));
20811 FREE(address);
20812 return hash.extractBytes();
20813 }
20814
20815 function crypto_hash_string(s) {
20816 return crypto_hash(encode_utf8(s));
20817 }
20818
20819 //---------------------------------------------------------------------------
20820 // Symmetric-key encryption
20821
20822 function crypto_stream_random_nonce() {
20823 return random_bytes(nacl_raw._crypto_stream_noncebytes());
20824 }
20825
20826 function crypto_stream(len, nonce, key) {
20827 var na = check_injectBytes("crypto_stream",
20828 "nonce", nonce, nacl_raw._crypto_stream_noncebytes());
20829 var ka = check_injectBytes("crypto_stream",
20830 "key", key, nacl_raw._crypto_stream_keybytes());
20831 var out = new Target(len);
20832 check("_crypto_stream", nacl_raw._crypto_stream(out.address, len, 0, na, ka));
20833 free_all([na, ka]);
20834 return out.extractBytes();
20835 }
20836
20837 function crypto_stream_xor(msg, nonce, key) {
20838 var na = check_injectBytes("crypto_stream_xor",
20839 "nonce", nonce, nacl_raw._crypto_stream_noncebytes());
20840 var ka = check_injectBytes("crypto_stream_xor",
20841 "key", key, nacl_raw._crypto_stream_keybytes());
20842 var ma = injectBytes(msg);
20843 var out = new Target(msg.length);
20844 check("_crypto_stream_xor",
20845 nacl_raw._crypto_stream_xor(out.address, ma, msg.length, 0, na, ka));
20846 free_all([na, ka, ma]);
20847 return out.extractBytes();
20848 }
20849
20850 //---------------------------------------------------------------------------
20851 // One-time authentication
20852
20853 function crypto_onetimeauth(msg, key) {
20854 var ka = check_injectBytes("crypto_onetimeauth",
20855 "key", key, nacl_raw._crypto_onetimeauth_keybytes());
20856 var ma = injectBytes(msg);
20857 var authenticator = new Target(nacl_raw._crypto_onetimeauth_bytes());
20858 check("_crypto_onetimeauth",
20859 nacl_raw._crypto_onetimeauth(authenticator.address, ma, msg.length, 0, ka));
20860 free_all([ka, ma]);
20861 return authenticator.extractBytes();
20862 }
20863
20864 function crypto_onetimeauth_verify(authenticator, msg, key) {
20865 if (authenticator.length != nacl_raw._crypto_onetimeauth_bytes()) return false;
20866 var ka = check_injectBytes("crypto_onetimeauth_verify",
20867 "key", key, nacl_raw._crypto_onetimeauth_keybytes());
20868 var ma = injectBytes(msg);
20869 var aa = injectBytes(authenticator);
20870 var result = nacl_raw._crypto_onetimeauth_verify(aa, ma, msg.length, 0, ka);
20871 free_all([ka, ma, aa]);
20872 return (result == 0);
20873 }
20874
20875 //---------------------------------------------------------------------------
20876 // Authentication
20877
20878 function crypto_auth(msg, key) {
20879 var ka = check_injectBytes("crypto_auth", "key", key, nacl_raw._crypto_auth_keybytes());
20880 var ma = injectBytes(msg);
20881 var authenticator = new Target(nacl_raw._crypto_auth_bytes());
20882 check("_crypto_auth", nacl_raw._crypto_auth(authenticator.address, ma, msg.length, 0, ka));
20883 free_all([ka, ma]);
20884 return authenticator.extractBytes();
20885 }
20886
20887 function crypto_auth_verify(authenticator, msg, key) {
20888 if (authenticator.length != nacl_raw._crypto_auth_bytes()) return false;
20889 var ka = check_injectBytes("crypto_auth_verify",
20890 "key", key, nacl_raw._crypto_auth_keybytes());
20891 var ma = injectBytes(msg);
20892 var aa = injectBytes(authenticator);
20893 var result = nacl_raw._crypto_auth_verify(aa, ma, msg.length, 0, ka);
20894 free_all([ka, ma, aa]);
20895 return (result == 0);
20896 }
20897
20898 //---------------------------------------------------------------------------
20899 // Authenticated symmetric-key encryption
20900
20901 function crypto_secretbox_random_nonce() {
20902 return random_bytes(nacl_raw._crypto_secretbox_noncebytes());
20903 }
20904
20905 function crypto_secretbox(msg, nonce, key) {
20906 var m = injectBytes(msg, nacl_raw._crypto_secretbox_zerobytes());
20907 var na = check_injectBytes("crypto_secretbox",
20908 "nonce", nonce, nacl_raw._crypto_secretbox_noncebytes());
20909 var ka = check_injectBytes("crypto_secretbox",
20910 "key", key, nacl_raw._crypto_secretbox_keybytes());
20911 var c = new Target(msg.length + nacl_raw._crypto_secretbox_zerobytes());
20912 check("_crypto_secretbox", nacl_raw._crypto_secretbox(c.address, m, c.length, 0, na, ka));
20913 free_all([m, na, ka]);
20914 return c.extractBytes(nacl_raw._crypto_secretbox_boxzerobytes());
20915 }
20916
20917 function crypto_secretbox_open(ciphertext, nonce, key) {
20918 var c = injectBytes(ciphertext, nacl_raw._crypto_secretbox_boxzerobytes());
20919 var na = check_injectBytes("crypto_secretbox_open",
20920 "nonce", nonce, nacl_raw._crypto_secretbox_noncebytes());
20921 var ka = check_injectBytes("crypto_secretbox_open",
20922 "key", key, nacl_raw._crypto_secretbox_keybytes());
20923 var m = new Target(ciphertext.length + nacl_raw._crypto_secretbox_boxzerobytes());
20924 check("_crypto_secretbox_open",
20925 nacl_raw._crypto_secretbox_open(m.address, c, m.length, 0, na, ka));
20926 free_all([c, na, ka]);
20927 return m.extractBytes(nacl_raw._crypto_secretbox_zerobytes());
20928 }
20929
20930 //---------------------------------------------------------------------------
20931 // Boxing with ephemeral keys
20932
20933 function crypto_box_seal(msg, pk) {
20934 var m = injectBytes(msg);
20935 var pka = check_injectBytes("crypto_box_seal",
20936 "pk", pk, nacl_raw._crypto_box_publickeybytes());
20937 var c = new Target(msg.length + nacl_raw._crypto_box_sealbytes());
20938 check("_crypto_box_seal", nacl_raw._crypto_box_seal(c.address, m, msg.length, 0, pka));
20939 free_all([m, pka]);
20940 return c.extractBytes();
20941 }
20942
20943 function crypto_box_seal_open(ciphertext, pk, sk) {
20944 var c = injectBytes(ciphertext);
20945 var pka = check_injectBytes("crypto_box_seal_open",
20946 "pk", pk, nacl_raw._crypto_box_publickeybytes());
20947 var ska = check_injectBytes("crypto_box_seal_open",
20948 "sk", sk, nacl_raw._crypto_box_secretkeybytes());
20949 var m = new Target(ciphertext.length - nacl_raw._crypto_box_sealbytes());
20950 check("_crypto_box_seal_open",
20951 nacl_raw._crypto_box_seal_open(m.address, c, ciphertext.length, 0, pka, ska));
20952 free_all([c, pka, ska]);
20953 return m.extractBytes();
20954 }
20955
20956 //---------------------------------------------------------------------------
20957 // Signing
20958
20959 function crypto_sign_keypair() {
20960 var pk = new Target(nacl_raw._crypto_sign_publickeybytes());
20961 var sk = new Target(nacl_raw._crypto_sign_secretkeybytes());
20962 check("_crypto_sign_keypair", nacl_raw._crypto_sign_keypair(pk.address, sk.address));
20963 return {signPk: pk.extractBytes(), signSk: sk.extractBytes()};
20964 }
20965
20966 function crypto_sign(msg, sk) {
20967 var ma = injectBytes(msg);
20968 var ska = check_injectBytes("crypto_sign", "sk", sk, nacl_raw._crypto_sign_secretkeybytes());
20969 var sm = new Target(msg.length + nacl_raw._crypto_sign_bytes());
20970 var smlen = new Target(8);
20971 check("_crypto_sign",
20972 nacl_raw._crypto_sign(sm.address, smlen.address, ma, msg.length, 0, ska));
20973 free_all([ma, ska]);
20974 sm.length = nacl_raw.HEAPU32[smlen.address >> 2];
20975 FREE(smlen.address);
20976 return sm.extractBytes();
20977 }
20978
20979 function crypto_sign_detached(msg, sk) {
20980 // WARNING: Experimental. Works for ed25519 but not necessarily other implementations.
20981 var signed_msg = crypto_sign(msg, sk);
20982 return signed_msg.subarray(0, nacl_raw._crypto_sign_bytes());
20983 }
20984
20985 function crypto_sign_open(sm, pk) {
20986 var sma = injectBytes(sm);
20987 var pka = check_injectBytes("crypto_sign_open",
20988 "pk", pk, nacl_raw._crypto_sign_publickeybytes());
20989 var m = new Target(sm.length);
20990 var mlen = new Target(8);
20991 if (nacl_raw._crypto_sign_open(m.address, mlen.address, sma, sm.length, 0, pka) === 0) {
20992 free_all([sma, pka]);
20993 m.length = nacl_raw.HEAPU32[mlen.address >> 2];
20994 FREE(mlen.address);
20995 return m.extractBytes();
20996 } else {
20997 free_all([sma, pka, m.address, mlen.address]);
20998 return null;
20999 }
21000 }
21001
21002 function crypto_sign_verify_detached(detached_signature, msg, pk) {
21003 // WARNING: Experimental. Works for ed25519 but not necessarily other implementations.
21004 var signed_msg = new Uint8Array(detached_signature.length + msg.length);
21005 signed_msg.set(detached_signature, 0);
21006 signed_msg.set(msg, detached_signature.length);
21007 return crypto_sign_open(signed_msg, pk) !== null;
21008 }
21009
21010 //---------------------------------------------------------------------------
21011 // Keys
21012
21013 function crypto_sign_seed_keypair(bs) {
21014 var seeda = check_injectBytes("crypto_sign_seed_keypair",
21015 "seed", bs, nacl_raw._crypto_sign_secretkeybytes() / 2);
21016 var pk = new Target(nacl_raw._crypto_sign_publickeybytes());
21017 var sk = new Target(nacl_raw._crypto_sign_secretkeybytes());
21018 check("_crypto_sign_seed_keypair",
21019 nacl_raw._crypto_sign_seed_keypair(pk.address, sk.address, seeda));
21020 FREE(seeda);
21021 return {signPk: pk.extractBytes(), signSk: sk.extractBytes()};
21022 }
21023
21024 function crypto_box_seed_keypair(bs) {
21025 var hash = new Uint8Array(crypto_hash(bs));
21026 return crypto_box_keypair_from_raw_sk(hash.subarray(0,
21027 nacl_raw._crypto_box_secretkeybytes()));
21028 }
21029
21030 function crypto_box_keypair_from_raw_sk(sk) {
21031 return {boxPk: crypto_scalarmult_base(sk), boxSk: sk};
21032 }
21033
21034 //---------------------------------------------------------------------------
21035 // Scalarmult
21036
21037 function crypto_scalarmult(n,p) {
21038 var na = check_injectBytes("crypto_scalarmult", "n", n,
21039 nacl_raw._crypto_scalarmult_curve25519_scalarbytes());
21040 var pa = check_injectBytes("crypto_scalarmult", "p", p,
21041 nacl_raw._crypto_scalarmult_curve25519_bytes());
21042 var q = new Target(nacl_raw._crypto_scalarmult_curve25519_bytes());
21043 check("_crypto_scalarmult_curve25519",
21044 nacl_raw._crypto_scalarmult_curve25519(q.address, na, pa));
21045 FREE(na);
21046 FREE(pa);
21047 return q.extractBytes();
21048 }
21049
21050 function crypto_scalarmult_base(n) {
21051 var na = check_injectBytes("crypto_scalarmult_base", "n", n,
21052 nacl_raw._crypto_scalarmult_curve25519_scalarbytes());
21053 var q = new Target(nacl_raw._crypto_scalarmult_curve25519_bytes());
21054 check("_crypto_scalarmult_curve25519_base",
21055 nacl_raw._crypto_scalarmult_curve25519_base(q.address, na));
21056 FREE(na);
21057 return q.extractBytes();
21058 }
21059
21060 //---------------------------------------------------------------------------
21061
21062 exports.crypto_auth_BYTES = nacl_raw._crypto_auth_bytes();
21063 exports.crypto_auth_KEYBYTES = nacl_raw._crypto_auth_keybytes();
21064 exports.crypto_box_BEFORENMBYTES = nacl_raw._crypto_box_beforenmbytes();
21065 exports.crypto_box_BOXZEROBYTES = nacl_raw._crypto_box_boxzerobytes();
21066 exports.crypto_box_NONCEBYTES = nacl_raw._crypto_box_noncebytes();
21067 exports.crypto_box_PUBLICKEYBYTES = nacl_raw._crypto_box_publickeybytes();
21068 exports.crypto_box_SECRETKEYBYTES = nacl_raw._crypto_box_secretkeybytes();
21069 exports.crypto_box_ZEROBYTES = nacl_raw._crypto_box_zerobytes();
21070 exports.crypto_hash_BYTES = nacl_raw._crypto_hash_bytes();
21071 exports.crypto_hash_sha256_BYTES = nacl_raw._crypto_hash_sha256_bytes();
21072 // exports.crypto_hashblocks_BLOCKBYTES = nacl_raw._crypto_hashblocks_blockbytes();
21073 // exports.crypto_hashblocks_STATEBYTES = nacl_raw._crypto_hashblocks_statebytes();
21074 exports.crypto_onetimeauth_BYTES = nacl_raw._crypto_onetimeauth_bytes();
21075 exports.crypto_onetimeauth_KEYBYTES = nacl_raw._crypto_onetimeauth_keybytes();
21076 exports.crypto_secretbox_BOXZEROBYTES = nacl_raw._crypto_secretbox_boxzerobytes();
21077 exports.crypto_secretbox_KEYBYTES = nacl_raw._crypto_secretbox_keybytes();
21078 exports.crypto_secretbox_NONCEBYTES = nacl_raw._crypto_secretbox_noncebytes();
21079 exports.crypto_secretbox_ZEROBYTES = nacl_raw._crypto_secretbox_zerobytes();
21080 exports.crypto_sign_BYTES = nacl_raw._crypto_sign_bytes();
21081 exports.crypto_sign_PUBLICKEYBYTES = nacl_raw._crypto_sign_publickeybytes();
21082 exports.crypto_sign_SECRETKEYBYTES = nacl_raw._crypto_sign_secretkeybytes();
21083 // exports.crypto_stream_BEFORENMBYTES = nacl_raw._crypto_stream_beforenmbytes();
21084 exports.crypto_stream_KEYBYTES = nacl_raw._crypto_stream_keybytes();
21085 exports.crypto_stream_NONCEBYTES = nacl_raw._crypto_stream_noncebytes();
21086 exports.crypto_scalarmult_SCALARBYTES = nacl_raw._crypto_scalarmult_curve25519_scalarbytes();
21087 exports.crypto_scalarmult_BYTES = nacl_raw._crypto_scalarmult_curve25519_bytes();
21088
21089 exports.encode_utf8 = encode_utf8;
21090 exports.encode_latin1 = encode_latin1;
21091 exports.decode_utf8 = decode_utf8;
21092 exports.decode_latin1 = decode_latin1;
21093 exports.to_hex = to_hex;
21094 exports.from_hex = from_hex;
21095
21096 exports.random_bytes = random_bytes;
21097
21098 exports.crypto_box_keypair = crypto_box_keypair;
21099 exports.crypto_box_random_nonce = crypto_box_random_nonce;
21100 exports.crypto_box = crypto_box;
21101 exports.crypto_box_open = crypto_box_open;
21102 exports.crypto_box_precompute = crypto_box_precompute;
21103 exports.crypto_box_precomputed = crypto_box_precomputed;
21104 exports.crypto_box_open_precomputed = crypto_box_open_precomputed;
21105
21106 exports.crypto_stream_random_nonce = crypto_stream_random_nonce;
21107 exports.crypto_stream = crypto_stream;
21108 exports.crypto_stream_xor = crypto_stream_xor;
21109
21110 exports.crypto_onetimeauth = crypto_onetimeauth;
21111 exports.crypto_onetimeauth_verify = crypto_onetimeauth_verify;
21112
21113 exports.crypto_auth = crypto_auth;
21114 exports.crypto_auth_verify = crypto_auth_verify;
21115
21116 exports.crypto_secretbox_random_nonce = crypto_secretbox_random_nonce;
21117 exports.crypto_secretbox = crypto_secretbox;
21118 exports.crypto_secretbox_open = crypto_secretbox_open;
21119
21120 exports.crypto_box_seal = crypto_box_seal;
21121 exports.crypto_box_seal_open = crypto_box_seal_open;
21122
21123 exports.crypto_sign_keypair = crypto_sign_keypair;
21124 exports.crypto_sign = crypto_sign;
21125 exports.crypto_sign_detached = crypto_sign_detached;
21126 exports.crypto_sign_open = crypto_sign_open;
21127 exports.crypto_sign_verify_detached = crypto_sign_verify_detached;
21128
21129 exports.crypto_hash = crypto_hash;
21130 exports.crypto_hash_sha256 = crypto_hash_sha256;
21131 exports.crypto_hash_string = crypto_hash_string;
21132
21133 exports.crypto_sign_seed_keypair = crypto_sign_seed_keypair;
21134 exports.crypto_box_seed_keypair = crypto_box_seed_keypair;
21135 exports.crypto_box_keypair_from_raw_sk = crypto_box_keypair_from_raw_sk;
21136 // Backwards-compatibility:
21137 exports.crypto_sign_keypair_from_seed = crypto_sign_seed_keypair;
21138 exports.crypto_box_keypair_from_seed = crypto_box_seed_keypair;
21139
21140 exports.crypto_scalarmult = crypto_scalarmult;
21141 exports.crypto_scalarmult_base = crypto_scalarmult_base;
21142
21143 return exports;
21144}
21145 return nacl_raw.ready.then(function () {
21146 var nacl = nacl_cooked(nacl_raw);
21147 nacl.nacl_raw = nacl_raw;
21148 on_ready(nacl);
21149 return nacl;
21150 });
21151 })((typeof window !== 'undefined') ? window : undefined_reference_value,
21152 (typeof document !== 'undefined') ? document : undefined_reference_value);
21153 }
21154};
21155
21156// export common.js module to allow one js file for browser and node.js
21157if (typeof module !== 'undefined' && module.exports) {
21158 module.exports = nacl_factory;
21159}
21160
21161}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/js-nacl/lib")
21162},{"_process":374,"buffer":50,"crypto":72,"fs":48,"path":367}],123:[function(require,module,exports){
21163"use strict";
21164
21165var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
21166
21167var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
21168
21169var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
21170
21171Object.defineProperty(exports, "__esModule", {
21172 value: true
21173});
21174
21175var every = _interopRequire(require("lodash/every"));
21176
21177var each = _interopRequire(require("lodash/each"));
21178
21179var times = _interopRequire(require("lodash/times"));
21180
21181var isArray = _interopRequire(require("lodash/isArray"));
21182
21183var includeIoMixin = _interopRequire(require("./io-mixin"));
21184
21185var Array = exports.Array = (function () {
21186 function Array(childType, length) {
21187 _classCallCheck(this, Array);
21188
21189 this._childType = childType;
21190 this._length = length;
21191 }
21192
21193 _createClass(Array, {
21194 read: {
21195 value: function read(io) {
21196 var _this = this;
21197
21198 return times(this._length, function () {
21199 return _this._childType.read(io);
21200 });
21201 }
21202 },
21203 write: {
21204 value: function write(value, io) {
21205 var _this = this;
21206
21207 if (!isArray(value)) {
21208 throw new Error("XDR Write Error: value is not array");
21209 }
21210
21211 if (value.length !== this._length) {
21212 throw new Error("XDR Write Error: Got array of size " + value.length + "," + ("expected " + this._length));
21213 }
21214
21215 each(value, function (child) {
21216 return _this._childType.write(child, io);
21217 });
21218 }
21219 },
21220 isValid: {
21221 value: function isValid(value) {
21222 var _this = this;
21223
21224 if (!isArray(value)) {
21225 return false;
21226 }
21227 if (value.length !== this._length) {
21228 return false;
21229 }
21230
21231 return every(value, function (child) {
21232 return _this._childType.isValid(child);
21233 });
21234 }
21235 }
21236 });
21237
21238 return Array;
21239})();
21240
21241includeIoMixin(Array.prototype);
21242},{"./io-mixin":133,"lodash/each":312,"lodash/every":314,"lodash/isArray":323,"lodash/times":350}],124:[function(require,module,exports){
21243"use strict";
21244
21245var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
21246
21247Object.defineProperty(exports, "__esModule", {
21248 value: true
21249});
21250
21251var Int = require("./int").Int;
21252
21253var isBoolean = _interopRequire(require("lodash/isBoolean"));
21254
21255var includeIoMixin = _interopRequire(require("./io-mixin"));
21256
21257var Bool = {
21258 read: function read(io) {
21259 var value = Int.read(io);
21260
21261 switch (value) {
21262 case 0:
21263 return false;
21264 case 1:
21265 return true;
21266 default:
21267 throw new Error("XDR Read Error: Got " + value + " when trying to read a bool");
21268 }
21269 },
21270
21271 write: function write(value, io) {
21272 var intVal = value ? 1 : 0;
21273 return Int.write(intVal, io);
21274 },
21275
21276 isValid: function isValid(value) {
21277 return isBoolean(value);
21278 }
21279};
21280
21281exports.Bool = Bool;
21282includeIoMixin(Bool);
21283},{"./int":132,"./io-mixin":133,"lodash/isBoolean":325}],125:[function(require,module,exports){
21284"use strict";
21285
21286var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
21287
21288var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { "default": obj }; };
21289
21290var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
21291
21292var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
21293
21294var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
21295
21296exports.config = config;
21297Object.defineProperty(exports, "__esModule", {
21298 value: true
21299});
21300
21301var XDR = _interopRequireWildcard(require("./types"));
21302
21303var isUndefined = _interopRequire(require("lodash/isUndefined"));
21304
21305var isPlainObject = _interopRequire(require("lodash/isPlainObject"));
21306
21307var isArray = _interopRequire(require("lodash/isArray"));
21308
21309var each = _interopRequire(require("lodash/each"));
21310
21311var map = _interopRequire(require("lodash/map"));
21312
21313var pick = _interopRequire(require("lodash/pick"));
21314
21315function config(fn) {
21316 var types = arguments[1] === undefined ? {} : arguments[1];
21317
21318 if (fn) {
21319 var builder = new TypeBuilder(types);
21320 fn(builder);
21321 builder.resolve();
21322 }
21323
21324 return types;
21325}
21326
21327var Reference = exports.Reference = (function () {
21328 function Reference() {
21329 _classCallCheck(this, Reference);
21330 }
21331
21332 _createClass(Reference, {
21333 resolve: {
21334 /* jshint unused: false */
21335
21336 value: function resolve(context) {
21337 throw new Error("implement resolve in child class");
21338 }
21339 }
21340 });
21341
21342 return Reference;
21343})();
21344
21345var SimpleReference = (function (_Reference) {
21346 function SimpleReference(name) {
21347 _classCallCheck(this, SimpleReference);
21348
21349 this.name = name;
21350 }
21351
21352 _inherits(SimpleReference, _Reference);
21353
21354 _createClass(SimpleReference, {
21355 resolve: {
21356 value: function resolve(context) {
21357 var defn = context.definitions[this.name];
21358 return defn.resolve(context);
21359 }
21360 }
21361 });
21362
21363 return SimpleReference;
21364})(Reference);
21365
21366var ArrayReference = (function (_Reference2) {
21367 function ArrayReference(childReference, length) {
21368 var variable = arguments[2] === undefined ? false : arguments[2];
21369
21370 _classCallCheck(this, ArrayReference);
21371
21372 this.childReference = childReference;
21373 this.length = length;
21374 this.variable = variable;
21375 }
21376
21377 _inherits(ArrayReference, _Reference2);
21378
21379 _createClass(ArrayReference, {
21380 resolve: {
21381 value: function resolve(context) {
21382 var resolvedChild = this.childReference;
21383 var length = this.length;
21384
21385 if (resolvedChild instanceof Reference) {
21386 resolvedChild = resolvedChild.resolve(context);
21387 }
21388
21389 if (length instanceof Reference) {
21390 length = length.resolve(context);
21391 }
21392
21393 if (this.variable) {
21394 return new XDR.VarArray(resolvedChild, length);
21395 } else {
21396 return new XDR.Array(resolvedChild, length);
21397 }
21398 }
21399 }
21400 });
21401
21402 return ArrayReference;
21403})(Reference);
21404
21405var OptionReference = (function (_Reference3) {
21406 function OptionReference(childReference) {
21407 _classCallCheck(this, OptionReference);
21408
21409 this.childReference = childReference;
21410 this.name = childReference.name;
21411 }
21412
21413 _inherits(OptionReference, _Reference3);
21414
21415 _createClass(OptionReference, {
21416 resolve: {
21417 value: function resolve(context) {
21418 var resolvedChild = this.childReference;
21419
21420 if (resolvedChild instanceof Reference) {
21421 resolvedChild = resolvedChild.resolve(context);
21422 }
21423
21424 return new XDR.Option(resolvedChild);
21425 }
21426 }
21427 });
21428
21429 return OptionReference;
21430})(Reference);
21431
21432var SizedReference = (function (_Reference4) {
21433 function SizedReference(sizedType, length) {
21434 _classCallCheck(this, SizedReference);
21435
21436 this.sizedType = sizedType;
21437 this.length = length;
21438 }
21439
21440 _inherits(SizedReference, _Reference4);
21441
21442 _createClass(SizedReference, {
21443 resolve: {
21444 value: function resolve(context) {
21445 var length = this.length;
21446
21447 if (length instanceof Reference) {
21448 length = length.resolve(context);
21449 }
21450
21451 return new this.sizedType(length);
21452 }
21453 }
21454 });
21455
21456 return SizedReference;
21457})(Reference);
21458
21459var Definition = (function () {
21460 function Definition(constructor, name, config) {
21461 _classCallCheck(this, Definition);
21462
21463 this.constructor = constructor;
21464 this.name = name;
21465 this.config = config;
21466 }
21467
21468 _createClass(Definition, {
21469 resolve: {
21470
21471 // resolve calls the constructor of this definition with the provided context
21472 // and this definitions config values. The definitions constructor should
21473 // populate the final type on `context.results`, and may refer to other
21474 // definitions through `context.definitions`
21475
21476 value: function resolve(context) {
21477 if (this.name in context.results) {
21478 return context.results[this.name];
21479 }
21480
21481 return this.constructor(context, this.name, this.config);
21482 }
21483 }
21484 });
21485
21486 return Definition;
21487})();
21488
21489var TypeBuilder = (function () {
21490 function TypeBuilder(destination) {
21491 _classCallCheck(this, TypeBuilder);
21492
21493 this._destination = destination;
21494 this._definitions = {};
21495 }
21496
21497 _createClass(TypeBuilder, {
21498 "enum": {
21499 value: function _enum(name, members) {
21500 var result = new Definition(XDR.Enum.create, name, members);
21501 this.define(name, result);
21502 }
21503 },
21504 struct: {
21505 value: function struct(name, members) {
21506 var result = new Definition(XDR.Struct.create, name, members);
21507 this.define(name, result);
21508 }
21509 },
21510 union: {
21511 value: function union(name, config) {
21512 var result = new Definition(XDR.Union.create, name, config);
21513 this.define(name, result);
21514 }
21515 },
21516 typedef: {
21517 value: function typedef(name, config) {
21518 // let the reference resoltion system do it's thing
21519 // the "constructor" for a typedef just returns the resolved value
21520 var createTypedef = function (context, name, value) {
21521 if (value instanceof Reference) {
21522 value = value.resolve(context);
21523 }
21524 context.results[name] = value;
21525 return value;
21526 };
21527
21528 var result = new Definition(createTypedef, name, config);
21529 this.define(name, result);
21530 }
21531 },
21532 "const": {
21533 value: function _const(name, config) {
21534 var createConst = function (context, name, value) {
21535 context.results[name] = value;
21536 return value;
21537 };
21538
21539 var result = new Definition(createConst, name, config);
21540 this.define(name, result);
21541 }
21542 },
21543 "void": {
21544 value: function _void() {
21545 return XDR.Void;
21546 }
21547 },
21548 bool: {
21549 value: function bool() {
21550 return XDR.Bool;
21551 }
21552 },
21553 int: {
21554 value: function int() {
21555 return XDR.Int;
21556 }
21557 },
21558 hyper: {
21559 value: function hyper() {
21560 return XDR.Hyper;
21561 }
21562 },
21563 uint: {
21564 value: function uint() {
21565 return XDR.UnsignedInt;
21566 }
21567 },
21568 uhyper: {
21569 value: function uhyper() {
21570 return XDR.UnsignedHyper;
21571 }
21572 },
21573 float: {
21574 value: function float() {
21575 return XDR.Float;
21576 }
21577 },
21578 double: {
21579 value: function double() {
21580 return XDR.Double;
21581 }
21582 },
21583 quadruple: {
21584 value: function quadruple() {
21585 return XDR.Quadruple;
21586 }
21587 },
21588 string: {
21589 value: function string(length) {
21590 return new SizedReference(XDR.String, length);
21591 }
21592 },
21593 opaque: {
21594 value: function opaque(length) {
21595 return new SizedReference(XDR.Opaque, length);
21596 }
21597 },
21598 varOpaque: {
21599 value: function varOpaque(length) {
21600 return new SizedReference(XDR.VarOpaque, length);
21601 }
21602 },
21603 array: {
21604 value: function array(childType, length) {
21605 return new ArrayReference(childType, length);
21606 }
21607 },
21608 varArray: {
21609 value: function varArray(childType, maxLength) {
21610 return new ArrayReference(childType, maxLength, true);
21611 }
21612 },
21613 option: {
21614 value: function option(childType) {
21615 return new OptionReference(childType);
21616 }
21617 },
21618 define: {
21619 value: function define(name, definition) {
21620 if (isUndefined(this._destination[name])) {
21621 this._definitions[name] = definition;
21622 } else {
21623 throw new Error("XDR Error:" + name + " is already defined");
21624 }
21625 }
21626 },
21627 lookup: {
21628 value: function lookup(name) {
21629 return new SimpleReference(name);
21630 }
21631 },
21632 resolve: {
21633 value: function resolve() {
21634 var _this = this;
21635
21636 each(this._definitions, function (defn, name) {
21637 defn.resolve({
21638 definitions: _this._definitions,
21639 results: _this._destination
21640 });
21641 });
21642 }
21643 }
21644 });
21645
21646 return TypeBuilder;
21647})();
21648},{"./types":139,"lodash/each":312,"lodash/isArray":323,"lodash/isPlainObject":335,"lodash/isUndefined":340,"lodash/map":343,"lodash/pick":346}],126:[function(require,module,exports){
21649(function (Buffer){
21650"use strict";
21651
21652var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
21653
21654var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
21655
21656var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
21657
21658var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
21659
21660Object.defineProperty(exports, "__esModule", {
21661 value: true
21662});
21663
21664var BaseCursor = _interopRequire(require("cursor"));
21665
21666var calculatePadding = require("./util").calculatePadding;
21667
21668var Cursor = exports.Cursor = (function (_BaseCursor) {
21669 function Cursor() {
21670 _classCallCheck(this, Cursor);
21671
21672 if (_BaseCursor != null) {
21673 _BaseCursor.apply(this, arguments);
21674 }
21675 }
21676
21677 _inherits(Cursor, _BaseCursor);
21678
21679 _createClass(Cursor, {
21680 writeBufferPadded: {
21681 value: function writeBufferPadded(buffer) {
21682 var padding = calculatePadding(buffer.length);
21683 var paddingBuffer = Buffer.alloc(padding);
21684
21685 return this.copyFrom(new Cursor(buffer)).copyFrom(new Cursor(paddingBuffer));
21686 }
21687 }
21688 });
21689
21690 return Cursor;
21691})(BaseCursor);
21692}).call(this,require("buffer").Buffer)
21693},{"./util":143,"buffer":50,"cursor":73}],127:[function(require,module,exports){
21694"use strict";
21695
21696var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
21697
21698Object.defineProperty(exports, "__esModule", {
21699 value: true
21700});
21701
21702var isNumber = _interopRequire(require("lodash/isNumber"));
21703
21704var includeIoMixin = _interopRequire(require("./io-mixin"));
21705
21706var Double = {
21707
21708 read: function read(io) {
21709 return io.readDoubleBE();
21710 },
21711
21712 write: function write(value, io) {
21713 if (!isNumber(value)) {
21714 throw new Error("XDR Write Error: not a number");
21715 }
21716
21717 io.writeDoubleBE(value);
21718 },
21719
21720 isValid: function isValid(value) {
21721 return isNumber(value);
21722 } };
21723
21724exports.Double = Double;
21725includeIoMixin(Double);
21726},{"./io-mixin":133,"lodash/isNumber":332}],128:[function(require,module,exports){
21727"use strict";
21728
21729var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
21730
21731var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
21732
21733var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
21734
21735var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
21736
21737var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
21738
21739Object.defineProperty(exports, "__esModule", {
21740 value: true
21741});
21742
21743var Int = require("./int").Int;
21744
21745var each = _interopRequire(require("lodash/each"));
21746
21747var vals = _interopRequire(require("lodash/values"));
21748
21749var includeIoMixin = _interopRequire(require("./io-mixin"));
21750
21751var Enum = exports.Enum = (function () {
21752 function Enum(name, value) {
21753 _classCallCheck(this, Enum);
21754
21755 this.name = name;
21756 this.value = value;
21757 }
21758
21759 _createClass(Enum, null, {
21760 read: {
21761 value: function read(io) {
21762 var intVal = Int.read(io);
21763
21764 if (!this._byValue.has(intVal)) {
21765 throw new Error("XDR Read Error: Unknown " + this.enumName + " member for value " + intVal);
21766 }
21767
21768 return this._byValue.get(intVal);
21769 }
21770 },
21771 write: {
21772 value: function write(value, io) {
21773 if (!(value instanceof this)) {
21774 throw new Error("XDR Write Error: Unknown " + value + " is not a " + this.enumName);
21775 }
21776
21777 Int.write(value.value, io);
21778 }
21779 },
21780 isValid: {
21781 value: function isValid(value) {
21782 return value instanceof this;
21783 }
21784 },
21785 members: {
21786 value: function members() {
21787 return this._members;
21788 }
21789 },
21790 values: {
21791 value: function values() {
21792 return vals(this._members);
21793 }
21794 },
21795 fromName: {
21796 value: function fromName(name) {
21797 var result = this._members[name];
21798
21799 if (!result) {
21800 throw new Error("" + name + " is not a member of " + this.enumName);
21801 }
21802
21803 return result;
21804 }
21805 },
21806 fromValue: {
21807 value: function fromValue(value) {
21808 var result = this._byValue.get(value);
21809
21810 if (!result) {
21811 throw new Error("" + value + " is not a value of any member of " + this.enumName);
21812 }
21813
21814 return result;
21815 }
21816 },
21817 create: {
21818 value: function create(context, name, members) {
21819 var ChildEnum = (function (_Enum) {
21820 var _class = function ChildEnum() {
21821 for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
21822 args[_key] = arguments[_key];
21823 }
21824
21825 _classCallCheck(this, _class);
21826
21827 _get(Object.getPrototypeOf(_class.prototype), "constructor", this).apply(this, args);
21828 };
21829
21830 _inherits(_class, _Enum);
21831
21832 return _class;
21833 })(Enum);
21834
21835 ChildEnum.enumName = name;
21836 context.results[name] = ChildEnum;
21837
21838 ChildEnum._members = {};
21839 ChildEnum._byValue = new Map();
21840
21841 each(members, function (value, key) {
21842 var inst = new ChildEnum(key, value);
21843 ChildEnum._members[key] = inst;
21844 ChildEnum._byValue.set(value, inst);
21845 ChildEnum[key] = function () {
21846 return inst;
21847 };
21848 });
21849
21850 return ChildEnum;
21851 }
21852 }
21853 });
21854
21855 return Enum;
21856})();
21857
21858includeIoMixin(Enum);
21859},{"./int":132,"./io-mixin":133,"lodash/each":312,"lodash/values":356}],129:[function(require,module,exports){
21860"use strict";
21861
21862var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
21863
21864Object.defineProperty(exports, "__esModule", {
21865 value: true
21866});
21867
21868var isNumber = _interopRequire(require("lodash/isNumber"));
21869
21870var includeIoMixin = _interopRequire(require("./io-mixin"));
21871
21872var Float = {
21873
21874 read: function read(io) {
21875 return io.readFloatBE();
21876 },
21877
21878 write: function write(value, io) {
21879 if (!isNumber(value)) {
21880 throw new Error("XDR Write Error: not a number");
21881 }
21882
21883 io.writeFloatBE(value);
21884 },
21885
21886 isValid: function isValid(value) {
21887 return isNumber(value);
21888 } };
21889
21890exports.Float = Float;
21891includeIoMixin(Float);
21892},{"./io-mixin":133,"lodash/isNumber":332}],130:[function(require,module,exports){
21893"use strict";
21894
21895var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
21896
21897var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
21898
21899var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
21900
21901var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
21902
21903var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
21904
21905Object.defineProperty(exports, "__esModule", {
21906 value: true
21907});
21908
21909var Long = _interopRequire(require("long"));
21910
21911var includeIoMixin = _interopRequire(require("./io-mixin"));
21912
21913var Hyper = exports.Hyper = (function (_Long) {
21914 function Hyper(low, high) {
21915 _classCallCheck(this, Hyper);
21916
21917 _get(Object.getPrototypeOf(Hyper.prototype), "constructor", this).call(this, low, high, false);
21918 }
21919
21920 _inherits(Hyper, _Long);
21921
21922 _createClass(Hyper, null, {
21923 read: {
21924 value: function read(io) {
21925 var high = io.readInt32BE();
21926 var low = io.readInt32BE();
21927 return this.fromBits(low, high);
21928 }
21929 },
21930 write: {
21931 value: function write(value, io) {
21932 if (!(value instanceof this)) {
21933 throw new Error("XDR Write Error: " + value + " is not a Hyper");
21934 }
21935
21936 io.writeInt32BE(value.high);
21937 io.writeInt32BE(value.low);
21938 }
21939 },
21940 fromString: {
21941 value: function fromString(string) {
21942 if (!/^-?\d+$/.test(string)) {
21943 throw new Error("Invalid hyper string: " + string);
21944 }
21945 var result = _get(Object.getPrototypeOf(Hyper), "fromString", this).call(this, string, false);
21946 return new this(result.low, result.high);
21947 }
21948 },
21949 fromBits: {
21950 value: function fromBits(low, high) {
21951 var result = _get(Object.getPrototypeOf(Hyper), "fromBits", this).call(this, low, high, false);
21952 return new this(result.low, result.high);
21953 }
21954 },
21955 isValid: {
21956 value: function isValid(value) {
21957 return value instanceof this;
21958 }
21959 }
21960 });
21961
21962 return Hyper;
21963})(Long);
21964
21965includeIoMixin(Hyper);
21966
21967Hyper.MAX_VALUE = new Hyper(Long.MAX_VALUE.low, Long.MAX_VALUE.high);
21968Hyper.MIN_VALUE = new Hyper(Long.MIN_VALUE.low, Long.MIN_VALUE.high);
21969},{"./io-mixin":133,"long":357}],131:[function(require,module,exports){
21970"use strict";
21971
21972var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { "default": obj }; };
21973
21974var _defaults = function (obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; };
21975
21976Object.defineProperty(exports, "__esModule", {
21977 value: true
21978});
21979
21980_defaults(exports, _interopRequireWildcard(require("./types")));
21981
21982var _config = require("./config");
21983
21984_defaults(exports, _interopRequireWildcard(_config));
21985
21986var config = _config.config;
21987},{"./config":125,"./types":139}],132:[function(require,module,exports){
21988"use strict";
21989
21990var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
21991
21992Object.defineProperty(exports, "__esModule", {
21993 value: true
21994});
21995
21996var isNumber = _interopRequire(require("lodash/isNumber"));
21997
21998var includeIoMixin = _interopRequire(require("./io-mixin"));
21999
22000var Int = {
22001
22002 read: function read(io) {
22003 return io.readInt32BE();
22004 },
22005
22006 write: function write(value, io) {
22007 if (!isNumber(value)) {
22008 throw new Error("XDR Write Error: not a number");
22009 }
22010
22011 if (Math.floor(value) !== value) {
22012 throw new Error("XDR Write Error: not an integer");
22013 }
22014
22015 io.writeInt32BE(value);
22016 },
22017
22018 isValid: function isValid(value) {
22019 if (!isNumber(value)) {
22020 return false;
22021 }
22022 if (Math.floor(value) !== value) {
22023 return false;
22024 }
22025
22026 return value >= Int.MIN_VALUE && value <= Int.MAX_VALUE;
22027 } };
22028
22029exports.Int = Int;
22030Int.MAX_VALUE = Math.pow(2, 31) - 1;
22031Int.MIN_VALUE = -Math.pow(2, 31);
22032
22033includeIoMixin(Int);
22034},{"./io-mixin":133,"lodash/isNumber":332}],133:[function(require,module,exports){
22035(function (Buffer){
22036"use strict";
22037
22038var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
22039
22040module.exports = includeIoMixin;
22041
22042var Cursor = require("./cursor").Cursor;
22043
22044var extend = _interopRequire(require("lodash/extend"));
22045
22046var isFunction = _interopRequire(require("lodash/isFunction"));
22047
22048//TODO: build a system to grow a buffer as we write to it
22049var BUFFER_SIZE = Math.pow(2, 16);
22050
22051var staticMethods = {
22052 toXDR: function toXDR(val) {
22053 var cursor = new Cursor(BUFFER_SIZE);
22054 this.write(val, cursor);
22055 var bytesWritten = cursor.tell();
22056 cursor.rewind();
22057
22058 return cursor.slice(bytesWritten).buffer();
22059 },
22060
22061 fromXDR: function fromXDR(input) {
22062 var format = arguments[1] === undefined ? "raw" : arguments[1];
22063
22064 var buffer = undefined;
22065 switch (format) {
22066 case "raw":
22067 buffer = input;break;
22068 case "hex":
22069 buffer = Buffer.from(input, "hex");break;
22070 case "base64":
22071 buffer = Buffer.from(input, "base64");break;
22072 default:
22073 throw new Error("Invalid format " + format + ", must be \"raw\", \"hex\", \"base64\"");
22074 }
22075
22076 var cursor = new Cursor(buffer);
22077 var result = this.read(cursor);
22078
22079 //TODO: error out if the entire buffer isn't consumed
22080
22081 return result;
22082 } };
22083
22084var instanceMethods = {
22085 toXDR: function toXDR() {
22086 var format = arguments[0] === undefined ? "raw" : arguments[0];
22087
22088 var buffer = this.constructor.toXDR(this);
22089 switch (format) {
22090 case "raw":
22091 return buffer;
22092 case "hex":
22093 return buffer.toString("hex");
22094 case "base64":
22095 return buffer.toString("base64");
22096 default:
22097 throw new Error("Invalid format " + format + ", must be \"raw\", \"hex\", \"base64\"");
22098 }
22099 }
22100};
22101
22102function includeIoMixin(obj) {
22103 extend(obj, staticMethods);
22104
22105 if (isFunction(obj)) {
22106 extend(obj.prototype, instanceMethods);
22107 }
22108}
22109}).call(this,require("buffer").Buffer)
22110},{"./cursor":126,"buffer":50,"lodash/extend":315,"lodash/isFunction":328}],134:[function(require,module,exports){
22111(function (Buffer){
22112"use strict";
22113
22114var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
22115
22116var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
22117
22118var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
22119
22120Object.defineProperty(exports, "__esModule", {
22121 value: true
22122});
22123
22124var _util = require("./util");
22125
22126var calculatePadding = _util.calculatePadding;
22127var slicePadding = _util.slicePadding;
22128
22129var includeIoMixin = _interopRequire(require("./io-mixin"));
22130
22131var Opaque = exports.Opaque = (function () {
22132 function Opaque(length) {
22133 _classCallCheck(this, Opaque);
22134
22135 this._length = length;
22136 this._padding = calculatePadding(length);
22137 }
22138
22139 _createClass(Opaque, {
22140 read: {
22141 value: function read(io) {
22142 var result = io.slice(this._length);
22143 slicePadding(io, this._padding);
22144 return result.buffer();
22145 }
22146 },
22147 write: {
22148 value: function write(value, io) {
22149 if (value.length !== this._length) {
22150 throw new Error("XDR Write Error: Got " + value.length + " bytes, expected " + this._length);
22151 }
22152
22153 io.writeBufferPadded(value);
22154 }
22155 },
22156 isValid: {
22157 value: function isValid(value) {
22158 return Buffer.isBuffer(value) && value.length === this._length;
22159 }
22160 }
22161 });
22162
22163 return Opaque;
22164})();
22165
22166includeIoMixin(Opaque.prototype);
22167}).call(this,{"isBuffer":require("../../is-buffer/index.js")})
22168},{"../../is-buffer/index.js":120,"./io-mixin":133,"./util":143}],135:[function(require,module,exports){
22169"use strict";
22170
22171var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
22172
22173var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
22174
22175var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
22176
22177Object.defineProperty(exports, "__esModule", {
22178 value: true
22179});
22180
22181var Bool = require("./bool").Bool;
22182
22183var isNull = _interopRequire(require("lodash/isNull"));
22184
22185var isUndefined = _interopRequire(require("lodash/isUndefined"));
22186
22187var includeIoMixin = _interopRequire(require("./io-mixin"));
22188
22189var Option = exports.Option = (function () {
22190 function Option(childType) {
22191 _classCallCheck(this, Option);
22192
22193 this._childType = childType;
22194 }
22195
22196 _createClass(Option, {
22197 read: {
22198 value: function read(io) {
22199 if (Bool.read(io)) {
22200 return this._childType.read(io);
22201 }
22202 }
22203 },
22204 write: {
22205 value: function write(value, io) {
22206 var isPresent = !(isNull(value) || isUndefined(value));
22207
22208 Bool.write(isPresent, io);
22209
22210 if (isPresent) {
22211 this._childType.write(value, io);
22212 }
22213 }
22214 },
22215 isValid: {
22216 value: function isValid(value) {
22217 if (isNull(value)) {
22218 return true;
22219 }
22220 if (isUndefined(value)) {
22221 return true;
22222 }
22223
22224 return this._childType.isValid(value);
22225 }
22226 }
22227 });
22228
22229 return Option;
22230})();
22231
22232includeIoMixin(Option.prototype);
22233},{"./bool":124,"./io-mixin":133,"lodash/isNull":331,"lodash/isUndefined":340}],136:[function(require,module,exports){
22234"use strict";
22235
22236var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
22237
22238Object.defineProperty(exports, "__esModule", {
22239 value: true
22240});
22241
22242var includeIoMixin = _interopRequire(require("./io-mixin"));
22243
22244var Quadruple = {
22245 /* jshint unused: false */
22246
22247 read: function read(io) {
22248 throw new Error("XDR Read Error: quadruple not supported");
22249 },
22250
22251 write: function write(value, io) {
22252 throw new Error("XDR Write Error: quadruple not supported");
22253 },
22254
22255 isValid: function isValid(value) {
22256 return false;
22257 } };
22258
22259exports.Quadruple = Quadruple;
22260includeIoMixin(Quadruple);
22261},{"./io-mixin":133}],137:[function(require,module,exports){
22262(function (Buffer){
22263"use strict";
22264
22265var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
22266
22267var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
22268
22269var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
22270
22271Object.defineProperty(exports, "__esModule", {
22272 value: true
22273});
22274
22275var Int = require("./int").Int;
22276
22277var UnsignedInt = require("./unsigned-int").UnsignedInt;
22278
22279var _util = require("./util");
22280
22281var calculatePadding = _util.calculatePadding;
22282var slicePadding = _util.slicePadding;
22283
22284var isString = _interopRequire(require("lodash/isString"));
22285
22286var isArray = _interopRequire(require("lodash/isArray"));
22287
22288var includeIoMixin = _interopRequire(require("./io-mixin"));
22289
22290var String = exports.String = (function () {
22291 function String() {
22292 var maxLength = arguments[0] === undefined ? UnsignedInt.MAX_VALUE : arguments[0];
22293
22294 _classCallCheck(this, String);
22295
22296 this._maxLength = maxLength;
22297 }
22298
22299 _createClass(String, {
22300 read: {
22301 value: function read(io) {
22302 var length = Int.read(io);
22303
22304 if (length > this._maxLength) {
22305 throw new Error("XDR Read Error: Saw " + length + " length String," + ("max allowed is " + this._maxLength));
22306 }
22307 var padding = calculatePadding(length);
22308 var result = io.slice(length);
22309 slicePadding(io, padding);
22310 return result.buffer();
22311 }
22312 },
22313 readString: {
22314 value: function readString(io) {
22315 return this.read(io).toString("utf8");
22316 }
22317 },
22318 write: {
22319 value: function write(value, io) {
22320 if (value.length > this._maxLength) {
22321 throw new Error("XDR Write Error: Got " + value.length + " bytes," + ("max allows is " + this._maxLength));
22322 }
22323
22324 var buffer = undefined;
22325 if (isString(value)) {
22326 buffer = Buffer.from(value, "utf8");
22327 } else {
22328 buffer = Buffer.from(value);
22329 }
22330
22331 Int.write(buffer.length, io);
22332 io.writeBufferPadded(buffer);
22333 }
22334 },
22335 isValid: {
22336 value: function isValid(value) {
22337 var buffer = undefined;
22338 if (isString(value)) {
22339 buffer = Buffer.from(value, "utf8");
22340 } else if (isArray(value) || Buffer.isBuffer(value)) {
22341 buffer = Buffer.from(value);
22342 } else {
22343 return false;
22344 }
22345 return buffer.length <= this._maxLength;
22346 }
22347 }
22348 });
22349
22350 return String;
22351})();
22352
22353includeIoMixin(String.prototype);
22354}).call(this,require("buffer").Buffer)
22355},{"./int":132,"./io-mixin":133,"./unsigned-int":142,"./util":143,"buffer":50,"lodash/isArray":323,"lodash/isString":337}],138:[function(require,module,exports){
22356"use strict";
22357
22358var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
22359
22360var _slicedToArray = function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { var _arr = []; for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { _arr.push(_step.value); if (i && _arr.length === i) break; } return _arr; } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } };
22361
22362var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
22363
22364var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
22365
22366var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
22367
22368var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
22369
22370Object.defineProperty(exports, "__esModule", {
22371 value: true
22372});
22373
22374var each = _interopRequire(require("lodash/each"));
22375
22376var map = _interopRequire(require("lodash/map"));
22377
22378var isUndefined = _interopRequire(require("lodash/isUndefined"));
22379
22380var fromPairs = _interopRequire(require("lodash/fromPairs"));
22381
22382var Reference = require("./config").Reference;
22383
22384var includeIoMixin = _interopRequire(require("./io-mixin"));
22385
22386var Struct = exports.Struct = (function () {
22387 function Struct(attributes) {
22388 _classCallCheck(this, Struct);
22389
22390 this._attributes = attributes || {};
22391 }
22392
22393 _createClass(Struct, null, {
22394 read: {
22395 value: function read(io) {
22396 var fields = map(this._fields, function (field) {
22397 var _field = _slicedToArray(field, 2);
22398
22399 var name = _field[0];
22400 var type = _field[1];
22401
22402 var value = type.read(io);
22403 return [name, value];
22404 });
22405
22406 return new this(fromPairs(fields));
22407 }
22408 },
22409 write: {
22410 value: function write(value, io) {
22411 if (!(value instanceof this)) {
22412 throw new Error("XDR Write Error: " + value + " is not a " + this.structName);
22413 }
22414 each(this._fields, function (field) {
22415 var _field = _slicedToArray(field, 2);
22416
22417 var name = _field[0];
22418 var type = _field[1];
22419
22420 var attribute = value._attributes[name];
22421 type.write(attribute, io);
22422 });
22423 }
22424 },
22425 isValid: {
22426 value: function isValid(value) {
22427 return value instanceof this;
22428 }
22429 },
22430 create: {
22431 value: function create(context, name, fields) {
22432 var ChildStruct = (function (_Struct) {
22433 var _class = function ChildStruct() {
22434 for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
22435 args[_key] = arguments[_key];
22436 }
22437
22438 _classCallCheck(this, _class);
22439
22440 _get(Object.getPrototypeOf(_class.prototype), "constructor", this).apply(this, args);
22441 };
22442
22443 _inherits(_class, _Struct);
22444
22445 return _class;
22446 })(Struct);
22447
22448 ChildStruct.structName = name;
22449
22450 context.results[name] = ChildStruct;
22451
22452 ChildStruct._fields = fields.map(function (_ref) {
22453 var _ref2 = _slicedToArray(_ref, 2);
22454
22455 var name = _ref2[0];
22456 var field = _ref2[1];
22457
22458 if (field instanceof Reference) {
22459 field = field.resolve(context);
22460 }
22461
22462 return [name, field];
22463 });
22464
22465 each(ChildStruct._fields, function (field) {
22466 var _field = _slicedToArray(field, 1);
22467
22468 var fieldName = _field[0];
22469
22470 ChildStruct.prototype[fieldName] = readOrWriteAttribute(fieldName);
22471 });
22472
22473 return ChildStruct;
22474 }
22475 }
22476 });
22477
22478 return Struct;
22479})();
22480
22481includeIoMixin(Struct);
22482
22483function readOrWriteAttribute(name) {
22484 return function (value) {
22485 if (!isUndefined(value)) {
22486 this._attributes[name] = value;
22487 }
22488
22489 return this._attributes[name];
22490 };
22491}
22492},{"./config":125,"./io-mixin":133,"lodash/each":312,"lodash/fromPairs":318,"lodash/isUndefined":340,"lodash/map":343}],139:[function(require,module,exports){
22493"use strict";
22494
22495var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { "default": obj }; };
22496
22497var _defaults = function (obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; };
22498
22499Object.defineProperty(exports, "__esModule", {
22500 value: true
22501});
22502
22503_defaults(exports, _interopRequireWildcard(require("./int")));
22504
22505_defaults(exports, _interopRequireWildcard(require("./hyper")));
22506
22507_defaults(exports, _interopRequireWildcard(require("./unsigned-int")));
22508
22509_defaults(exports, _interopRequireWildcard(require("./unsigned-hyper")));
22510
22511_defaults(exports, _interopRequireWildcard(require("./float")));
22512
22513_defaults(exports, _interopRequireWildcard(require("./double")));
22514
22515_defaults(exports, _interopRequireWildcard(require("./quadruple")));
22516
22517_defaults(exports, _interopRequireWildcard(require("./bool")));
22518
22519_defaults(exports, _interopRequireWildcard(require("./string")));
22520
22521_defaults(exports, _interopRequireWildcard(require("./opaque")));
22522
22523_defaults(exports, _interopRequireWildcard(require("./var-opaque")));
22524
22525_defaults(exports, _interopRequireWildcard(require("./array")));
22526
22527_defaults(exports, _interopRequireWildcard(require("./var-array")));
22528
22529_defaults(exports, _interopRequireWildcard(require("./option")));
22530
22531_defaults(exports, _interopRequireWildcard(require("./void")));
22532
22533_defaults(exports, _interopRequireWildcard(require("./enum")));
22534
22535_defaults(exports, _interopRequireWildcard(require("./struct")));
22536
22537_defaults(exports, _interopRequireWildcard(require("./union")));
22538},{"./array":123,"./bool":124,"./double":127,"./enum":128,"./float":129,"./hyper":130,"./int":132,"./opaque":134,"./option":135,"./quadruple":136,"./string":137,"./struct":138,"./union":140,"./unsigned-hyper":141,"./unsigned-int":142,"./var-array":144,"./var-opaque":145,"./void":146}],140:[function(require,module,exports){
22539"use strict";
22540
22541var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
22542
22543var _slicedToArray = function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { var _arr = []; for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { _arr.push(_step.value); if (i && _arr.length === i) break; } return _arr; } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } };
22544
22545var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
22546
22547var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
22548
22549var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
22550
22551var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
22552
22553Object.defineProperty(exports, "__esModule", {
22554 value: true
22555});
22556
22557var each = _interopRequire(require("lodash/each"));
22558
22559var isUndefined = _interopRequire(require("lodash/isUndefined"));
22560
22561var isString = _interopRequire(require("lodash/isString"));
22562
22563var Void = require("./void").Void;
22564
22565var Reference = require("./config").Reference;
22566
22567var includeIoMixin = _interopRequire(require("./io-mixin"));
22568
22569var Union = exports.Union = (function () {
22570 function Union(aSwitch, value) {
22571 _classCallCheck(this, Union);
22572
22573 this.set(aSwitch, value);
22574 }
22575
22576 _createClass(Union, {
22577 set: {
22578 value: function set(aSwitch, value) {
22579 if (isString(aSwitch)) {
22580 aSwitch = this.constructor._switchOn.fromName(aSwitch);
22581 }
22582
22583 this._switch = aSwitch;
22584 this._arm = this.constructor.armForSwitch(this._switch);
22585 this._armType = this.constructor.armTypeForArm(this._arm);
22586 this._value = value;
22587 }
22588 },
22589 get: {
22590 value: function get() {
22591 var armName = arguments[0] === undefined ? this._arm : arguments[0];
22592
22593 if (this._arm !== Void && this._arm !== armName) {
22594 throw new Error("" + armName + " not set");
22595 }
22596 return this._value;
22597 }
22598 },
22599 "switch": {
22600 value: function _switch() {
22601 return this._switch;
22602 }
22603 },
22604 arm: {
22605 value: function arm() {
22606 return this._arm;
22607 }
22608 },
22609 armType: {
22610 value: function armType() {
22611 return this._armType;
22612 }
22613 },
22614 value: {
22615 value: function value() {
22616 return this._value;
22617 }
22618 }
22619 }, {
22620 armForSwitch: {
22621 value: function armForSwitch(aSwitch) {
22622 if (this._switches.has(aSwitch)) {
22623 return this._switches.get(aSwitch);
22624 } else if (this._defaultArm) {
22625 return this._defaultArm;
22626 } else {
22627 throw new Error("Bad union switch: " + aSwitch);
22628 }
22629 }
22630 },
22631 armTypeForArm: {
22632 value: function armTypeForArm(arm) {
22633 if (arm === Void) {
22634 return Void;
22635 } else {
22636 return this._arms[arm];
22637 }
22638 }
22639 },
22640 read: {
22641 value: function read(io) {
22642 var aSwitch = this._switchOn.read(io);
22643 var arm = this.armForSwitch(aSwitch);
22644 var armType = this.armTypeForArm(arm);
22645 var value = armType.read(io);
22646 return new this(aSwitch, value);
22647 }
22648 },
22649 write: {
22650 value: function write(value, io) {
22651 if (!(value instanceof this)) {
22652 throw new Error("XDR Write Error: " + value + " is not a " + this.unionName);
22653 }
22654
22655 this._switchOn.write(value["switch"](), io);
22656 value.armType().write(value.value(), io);
22657 }
22658 },
22659 isValid: {
22660 value: function isValid(value) {
22661 return value instanceof this;
22662 }
22663 },
22664 create: {
22665 value: function create(context, name, config) {
22666 var ChildUnion = (function (_Union) {
22667 var _class = function ChildUnion() {
22668 for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
22669 args[_key] = arguments[_key];
22670 }
22671
22672 _classCallCheck(this, _class);
22673
22674 _get(Object.getPrototypeOf(_class.prototype), "constructor", this).apply(this, args);
22675 };
22676
22677 _inherits(_class, _Union);
22678
22679 return _class;
22680 })(Union);
22681
22682 ChildUnion.unionName = name;
22683 context.results[name] = ChildUnion;
22684
22685 if (config.switchOn instanceof Reference) {
22686 ChildUnion._switchOn = config.switchOn.resolve(context);
22687 } else {
22688 ChildUnion._switchOn = config.switchOn;
22689 }
22690
22691 ChildUnion._switches = new Map();
22692 ChildUnion._arms = {};
22693
22694 each(config.arms, function (value, name) {
22695 if (value instanceof Reference) {
22696 value = value.resolve(context);
22697 }
22698
22699 ChildUnion._arms[name] = value;
22700 });
22701
22702 // resolve default arm
22703 var defaultArm = config.defaultArm;
22704 if (defaultArm instanceof Reference) {
22705 defaultArm = defaultArm.resolve(context);
22706 }
22707
22708 ChildUnion._defaultArm = defaultArm;
22709
22710 each(config.switches, function (_ref) {
22711 var _ref2 = _slicedToArray(_ref, 2);
22712
22713 var aSwitch = _ref2[0];
22714 var armName = _ref2[1];
22715
22716 if (isString(aSwitch)) {
22717 aSwitch = ChildUnion._switchOn.fromName(aSwitch);
22718 }
22719
22720 ChildUnion._switches.set(aSwitch, armName);
22721 });
22722
22723 // add enum-based helpers
22724 // NOTE: we don't have good notation for "is a subclass of XDR.Enum",
22725 // and so we use the following check (does _switchOn have a `values`
22726 // attribute) to approximate the intent.
22727 if (!isUndefined(ChildUnion._switchOn.values)) {
22728 each(ChildUnion._switchOn.values(), function (aSwitch) {
22729 // Add enum-based constrocutors
22730 ChildUnion[aSwitch.name] = function (value) {
22731 return new ChildUnion(aSwitch, value);
22732 };
22733
22734 // Add enum-based "set" helpers
22735 ChildUnion.prototype[aSwitch.name] = function (value) {
22736 return this.set(aSwitch, value);
22737 };
22738 });
22739 }
22740
22741 // Add arm accessor helpers
22742 each(ChildUnion._arms, function (type, name) {
22743 if (type === Void) {
22744 return;
22745 }
22746
22747 ChildUnion.prototype[name] = function () {
22748 return this.get(name);
22749 };
22750 });
22751
22752 return ChildUnion;
22753 }
22754 }
22755 });
22756
22757 return Union;
22758})();
22759
22760includeIoMixin(Union);
22761},{"./config":125,"./io-mixin":133,"./void":146,"lodash/each":312,"lodash/isString":337,"lodash/isUndefined":340}],141:[function(require,module,exports){
22762"use strict";
22763
22764var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
22765
22766var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
22767
22768var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
22769
22770var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
22771
22772var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
22773
22774Object.defineProperty(exports, "__esModule", {
22775 value: true
22776});
22777
22778var Long = _interopRequire(require("long"));
22779
22780var includeIoMixin = _interopRequire(require("./io-mixin"));
22781
22782var UnsignedHyper = exports.UnsignedHyper = (function (_Long) {
22783 function UnsignedHyper(low, high) {
22784 _classCallCheck(this, UnsignedHyper);
22785
22786 _get(Object.getPrototypeOf(UnsignedHyper.prototype), "constructor", this).call(this, low, high, true);
22787 }
22788
22789 _inherits(UnsignedHyper, _Long);
22790
22791 _createClass(UnsignedHyper, null, {
22792 read: {
22793 value: function read(io) {
22794 var high = io.readInt32BE();
22795 var low = io.readInt32BE();
22796 return this.fromBits(low, high);
22797 }
22798 },
22799 write: {
22800 value: function write(value, io) {
22801 if (!(value instanceof this)) {
22802 throw new Error("XDR Write Error: " + value + " is not an UnsignedHyper");
22803 }
22804
22805 io.writeInt32BE(value.high);
22806 io.writeInt32BE(value.low);
22807 }
22808 },
22809 fromString: {
22810 value: function fromString(string) {
22811 if (!/^\d+$/.test(string)) {
22812 throw new Error("Invalid hyper string: " + string);
22813 }
22814 var result = _get(Object.getPrototypeOf(UnsignedHyper), "fromString", this).call(this, string, true);
22815 return new this(result.low, result.high);
22816 }
22817 },
22818 fromBits: {
22819 value: function fromBits(low, high) {
22820 var result = _get(Object.getPrototypeOf(UnsignedHyper), "fromBits", this).call(this, low, high, true);
22821 return new this(result.low, result.high);
22822 }
22823 },
22824 isValid: {
22825 value: function isValid(value) {
22826 return value instanceof this;
22827 }
22828 }
22829 });
22830
22831 return UnsignedHyper;
22832})(Long);
22833
22834includeIoMixin(UnsignedHyper);
22835
22836UnsignedHyper.MAX_VALUE = new UnsignedHyper(Long.MAX_UNSIGNED_VALUE.low, Long.MAX_UNSIGNED_VALUE.high);
22837
22838UnsignedHyper.MIN_VALUE = new UnsignedHyper(Long.MIN_VALUE.low, Long.MIN_VALUE.high);
22839},{"./io-mixin":133,"long":357}],142:[function(require,module,exports){
22840"use strict";
22841
22842var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
22843
22844Object.defineProperty(exports, "__esModule", {
22845 value: true
22846});
22847
22848var isNumber = _interopRequire(require("lodash/isNumber"));
22849
22850var includeIoMixin = _interopRequire(require("./io-mixin"));
22851
22852var UnsignedInt = {
22853
22854 read: function read(io) {
22855 return io.readUInt32BE();
22856 },
22857
22858 write: function write(value, io) {
22859 if (!isNumber(value)) {
22860 throw new Error("XDR Write Error: not a number");
22861 }
22862
22863 if (Math.floor(value) !== value) {
22864 throw new Error("XDR Write Error: not an integer");
22865 }
22866
22867 if (value < 0) {
22868 throw new Error("XDR Write Error: negative number " + value);
22869 }
22870
22871 io.writeUInt32BE(value);
22872 },
22873
22874 isValid: function isValid(value) {
22875 if (!isNumber(value)) {
22876 return false;
22877 }
22878 if (Math.floor(value) !== value) {
22879 return false;
22880 }
22881
22882 return value >= UnsignedInt.MIN_VALUE && value <= UnsignedInt.MAX_VALUE;
22883 } };
22884
22885exports.UnsignedInt = UnsignedInt;
22886UnsignedInt.MAX_VALUE = Math.pow(2, 32) - 1;
22887UnsignedInt.MIN_VALUE = 0;
22888
22889includeIoMixin(UnsignedInt);
22890},{"./io-mixin":133,"lodash/isNumber":332}],143:[function(require,module,exports){
22891"use strict";
22892
22893var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
22894
22895exports.calculatePadding = calculatePadding;
22896exports.slicePadding = slicePadding;
22897Object.defineProperty(exports, "__esModule", {
22898 value: true
22899});
22900
22901var every = _interopRequire(require("lodash/every"));
22902
22903function calculatePadding(length) {
22904 switch (length % 4) {
22905 case 0:
22906 return 0;
22907 case 1:
22908 return 3;
22909 case 2:
22910 return 2;
22911 case 3:
22912 return 1;
22913 }
22914}
22915
22916function slicePadding(io, length) {
22917 var padding = io.slice(length);
22918 var allZero = every(padding.buffer(), function (byte) {
22919 return byte === 0;
22920 });
22921
22922 if (allZero !== true) {
22923 throw new Error("XDR Read Error: invalid padding");
22924 }
22925}
22926},{"lodash/every":314}],144:[function(require,module,exports){
22927"use strict";
22928
22929var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
22930
22931var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
22932
22933var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
22934
22935Object.defineProperty(exports, "__esModule", {
22936 value: true
22937});
22938
22939var Int = require("./int").Int;
22940
22941var UnsignedInt = require("./unsigned-int").UnsignedInt;
22942
22943var every = _interopRequire(require("lodash/every"));
22944
22945var each = _interopRequire(require("lodash/each"));
22946
22947var times = _interopRequire(require("lodash/times"));
22948
22949var isArray = _interopRequire(require("lodash/isArray"));
22950
22951var includeIoMixin = _interopRequire(require("./io-mixin"));
22952
22953var VarArray = exports.VarArray = (function () {
22954 function VarArray(childType) {
22955 var maxLength = arguments[1] === undefined ? UnsignedInt.MAX_VALUE : arguments[1];
22956
22957 _classCallCheck(this, VarArray);
22958
22959 this._childType = childType;
22960 this._maxLength = maxLength;
22961 }
22962
22963 _createClass(VarArray, {
22964 read: {
22965 value: function read(io) {
22966 var _this = this;
22967
22968 var length = Int.read(io);
22969
22970 if (length > this._maxLength) {
22971 throw new Error("XDR Read Error: Saw " + length + " length VarArray," + ("max allowed is " + this._maxLength));
22972 }
22973
22974 return times(length, function () {
22975 return _this._childType.read(io);
22976 });
22977 }
22978 },
22979 write: {
22980 value: function write(value, io) {
22981 var _this = this;
22982
22983 if (!isArray(value)) {
22984 throw new Error("XDR Write Error: value is not array");
22985 }
22986
22987 if (value.length > this._maxLength) {
22988 throw new Error("XDR Write Error: Got array of size " + value.length + "," + ("max allowed is " + this._maxLength));
22989 }
22990
22991 Int.write(value.length, io);
22992 each(value, function (child) {
22993 return _this._childType.write(child, io);
22994 });
22995 }
22996 },
22997 isValid: {
22998 value: function isValid(value) {
22999 var _this = this;
23000
23001 if (!isArray(value)) {
23002 return false;
23003 }
23004 if (value.length > this._maxLength) {
23005 return false;
23006 }
23007
23008 return every(value, function (child) {
23009 return _this._childType.isValid(child);
23010 });
23011 }
23012 }
23013 });
23014
23015 return VarArray;
23016})();
23017
23018includeIoMixin(VarArray.prototype);
23019},{"./int":132,"./io-mixin":133,"./unsigned-int":142,"lodash/each":312,"lodash/every":314,"lodash/isArray":323,"lodash/times":350}],145:[function(require,module,exports){
23020(function (Buffer){
23021"use strict";
23022
23023var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
23024
23025var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
23026
23027var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
23028
23029Object.defineProperty(exports, "__esModule", {
23030 value: true
23031});
23032
23033var Int = require("./int").Int;
23034
23035var UnsignedInt = require("./unsigned-int").UnsignedInt;
23036
23037var _util = require("./util");
23038
23039var calculatePadding = _util.calculatePadding;
23040var slicePadding = _util.slicePadding;
23041
23042var includeIoMixin = _interopRequire(require("./io-mixin"));
23043
23044var VarOpaque = exports.VarOpaque = (function () {
23045 function VarOpaque() {
23046 var maxLength = arguments[0] === undefined ? UnsignedInt.MAX_VALUE : arguments[0];
23047
23048 _classCallCheck(this, VarOpaque);
23049
23050 this._maxLength = maxLength;
23051 }
23052
23053 _createClass(VarOpaque, {
23054 read: {
23055 value: function read(io) {
23056 var length = Int.read(io);
23057
23058 if (length > this._maxLength) {
23059 throw new Error("XDR Read Error: Saw " + length + " length VarOpaque," + ("max allowed is " + this._maxLength));
23060 }
23061 var padding = calculatePadding(length);
23062 var result = io.slice(length);
23063 slicePadding(io, padding);
23064 return result.buffer();
23065 }
23066 },
23067 write: {
23068 value: function write(value, io) {
23069 if (value.length > this._maxLength) {
23070 throw new Error("XDR Write Error: Got " + value.length + " bytes," + ("max allows is " + this._maxLength));
23071 }
23072 Int.write(value.length, io);
23073 io.writeBufferPadded(value);
23074 }
23075 },
23076 isValid: {
23077 value: function isValid(value) {
23078 return Buffer.isBuffer(value) && value.length <= this._maxLength;
23079 }
23080 }
23081 });
23082
23083 return VarOpaque;
23084})();
23085
23086includeIoMixin(VarOpaque.prototype);
23087}).call(this,{"isBuffer":require("../../is-buffer/index.js")})
23088},{"../../is-buffer/index.js":120,"./int":132,"./io-mixin":133,"./unsigned-int":142,"./util":143}],146:[function(require,module,exports){
23089"use strict";
23090
23091var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
23092
23093Object.defineProperty(exports, "__esModule", {
23094 value: true
23095});
23096
23097var isUndefined = _interopRequire(require("lodash/isUndefined"));
23098
23099var includeIoMixin = _interopRequire(require("./io-mixin"));
23100
23101var Void = {
23102 /* jshint unused: false */
23103
23104 read: function read(io) {
23105 return undefined;
23106 },
23107
23108 write: function write(value, io) {
23109 if (!isUndefined(value)) {
23110 throw new Error("XDR Write Error: trying to write value to a void slot");
23111 }
23112 },
23113
23114 isValid: function isValid(value) {
23115 return isUndefined(value);
23116 } };
23117
23118exports.Void = Void;
23119includeIoMixin(Void);
23120},{"./io-mixin":133,"lodash/isUndefined":340}],147:[function(require,module,exports){
23121var getNative = require('./_getNative'),
23122 root = require('./_root');
23123
23124/* Built-in method references that are verified to be native. */
23125var DataView = getNative(root, 'DataView');
23126
23127module.exports = DataView;
23128
23129},{"./_getNative":245,"./_root":290}],148:[function(require,module,exports){
23130var hashClear = require('./_hashClear'),
23131 hashDelete = require('./_hashDelete'),
23132 hashGet = require('./_hashGet'),
23133 hashHas = require('./_hashHas'),
23134 hashSet = require('./_hashSet');
23135
23136/**
23137 * Creates a hash object.
23138 *
23139 * @private
23140 * @constructor
23141 * @param {Array} [entries] The key-value pairs to cache.
23142 */
23143function Hash(entries) {
23144 var index = -1,
23145 length = entries == null ? 0 : entries.length;
23146
23147 this.clear();
23148 while (++index < length) {
23149 var entry = entries[index];
23150 this.set(entry[0], entry[1]);
23151 }
23152}
23153
23154// Add methods to `Hash`.
23155Hash.prototype.clear = hashClear;
23156Hash.prototype['delete'] = hashDelete;
23157Hash.prototype.get = hashGet;
23158Hash.prototype.has = hashHas;
23159Hash.prototype.set = hashSet;
23160
23161module.exports = Hash;
23162
23163},{"./_hashClear":254,"./_hashDelete":255,"./_hashGet":256,"./_hashHas":257,"./_hashSet":258}],149:[function(require,module,exports){
23164var listCacheClear = require('./_listCacheClear'),
23165 listCacheDelete = require('./_listCacheDelete'),
23166 listCacheGet = require('./_listCacheGet'),
23167 listCacheHas = require('./_listCacheHas'),
23168 listCacheSet = require('./_listCacheSet');
23169
23170/**
23171 * Creates an list cache object.
23172 *
23173 * @private
23174 * @constructor
23175 * @param {Array} [entries] The key-value pairs to cache.
23176 */
23177function ListCache(entries) {
23178 var index = -1,
23179 length = entries == null ? 0 : entries.length;
23180
23181 this.clear();
23182 while (++index < length) {
23183 var entry = entries[index];
23184 this.set(entry[0], entry[1]);
23185 }
23186}
23187
23188// Add methods to `ListCache`.
23189ListCache.prototype.clear = listCacheClear;
23190ListCache.prototype['delete'] = listCacheDelete;
23191ListCache.prototype.get = listCacheGet;
23192ListCache.prototype.has = listCacheHas;
23193ListCache.prototype.set = listCacheSet;
23194
23195module.exports = ListCache;
23196
23197},{"./_listCacheClear":270,"./_listCacheDelete":271,"./_listCacheGet":272,"./_listCacheHas":273,"./_listCacheSet":274}],150:[function(require,module,exports){
23198var getNative = require('./_getNative'),
23199 root = require('./_root');
23200
23201/* Built-in method references that are verified to be native. */
23202var Map = getNative(root, 'Map');
23203
23204module.exports = Map;
23205
23206},{"./_getNative":245,"./_root":290}],151:[function(require,module,exports){
23207var mapCacheClear = require('./_mapCacheClear'),
23208 mapCacheDelete = require('./_mapCacheDelete'),
23209 mapCacheGet = require('./_mapCacheGet'),
23210 mapCacheHas = require('./_mapCacheHas'),
23211 mapCacheSet = require('./_mapCacheSet');
23212
23213/**
23214 * Creates a map cache object to store key-value pairs.
23215 *
23216 * @private
23217 * @constructor
23218 * @param {Array} [entries] The key-value pairs to cache.
23219 */
23220function MapCache(entries) {
23221 var index = -1,
23222 length = entries == null ? 0 : entries.length;
23223
23224 this.clear();
23225 while (++index < length) {
23226 var entry = entries[index];
23227 this.set(entry[0], entry[1]);
23228 }
23229}
23230
23231// Add methods to `MapCache`.
23232MapCache.prototype.clear = mapCacheClear;
23233MapCache.prototype['delete'] = mapCacheDelete;
23234MapCache.prototype.get = mapCacheGet;
23235MapCache.prototype.has = mapCacheHas;
23236MapCache.prototype.set = mapCacheSet;
23237
23238module.exports = MapCache;
23239
23240},{"./_mapCacheClear":275,"./_mapCacheDelete":276,"./_mapCacheGet":277,"./_mapCacheHas":278,"./_mapCacheSet":279}],152:[function(require,module,exports){
23241var getNative = require('./_getNative'),
23242 root = require('./_root');
23243
23244/* Built-in method references that are verified to be native. */
23245var Promise = getNative(root, 'Promise');
23246
23247module.exports = Promise;
23248
23249},{"./_getNative":245,"./_root":290}],153:[function(require,module,exports){
23250var getNative = require('./_getNative'),
23251 root = require('./_root');
23252
23253/* Built-in method references that are verified to be native. */
23254var Set = getNative(root, 'Set');
23255
23256module.exports = Set;
23257
23258},{"./_getNative":245,"./_root":290}],154:[function(require,module,exports){
23259var MapCache = require('./_MapCache'),
23260 setCacheAdd = require('./_setCacheAdd'),
23261 setCacheHas = require('./_setCacheHas');
23262
23263/**
23264 *
23265 * Creates an array cache object to store unique values.
23266 *
23267 * @private
23268 * @constructor
23269 * @param {Array} [values] The values to cache.
23270 */
23271function SetCache(values) {
23272 var index = -1,
23273 length = values == null ? 0 : values.length;
23274
23275 this.__data__ = new MapCache;
23276 while (++index < length) {
23277 this.add(values[index]);
23278 }
23279}
23280
23281// Add methods to `SetCache`.
23282SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
23283SetCache.prototype.has = setCacheHas;
23284
23285module.exports = SetCache;
23286
23287},{"./_MapCache":151,"./_setCacheAdd":291,"./_setCacheHas":292}],155:[function(require,module,exports){
23288var ListCache = require('./_ListCache'),
23289 stackClear = require('./_stackClear'),
23290 stackDelete = require('./_stackDelete'),
23291 stackGet = require('./_stackGet'),
23292 stackHas = require('./_stackHas'),
23293 stackSet = require('./_stackSet');
23294
23295/**
23296 * Creates a stack cache object to store key-value pairs.
23297 *
23298 * @private
23299 * @constructor
23300 * @param {Array} [entries] The key-value pairs to cache.
23301 */
23302function Stack(entries) {
23303 var data = this.__data__ = new ListCache(entries);
23304 this.size = data.size;
23305}
23306
23307// Add methods to `Stack`.
23308Stack.prototype.clear = stackClear;
23309Stack.prototype['delete'] = stackDelete;
23310Stack.prototype.get = stackGet;
23311Stack.prototype.has = stackHas;
23312Stack.prototype.set = stackSet;
23313
23314module.exports = Stack;
23315
23316},{"./_ListCache":149,"./_stackClear":296,"./_stackDelete":297,"./_stackGet":298,"./_stackHas":299,"./_stackSet":300}],156:[function(require,module,exports){
23317var root = require('./_root');
23318
23319/** Built-in value references. */
23320var Symbol = root.Symbol;
23321
23322module.exports = Symbol;
23323
23324},{"./_root":290}],157:[function(require,module,exports){
23325var root = require('./_root');
23326
23327/** Built-in value references. */
23328var Uint8Array = root.Uint8Array;
23329
23330module.exports = Uint8Array;
23331
23332},{"./_root":290}],158:[function(require,module,exports){
23333var getNative = require('./_getNative'),
23334 root = require('./_root');
23335
23336/* Built-in method references that are verified to be native. */
23337var WeakMap = getNative(root, 'WeakMap');
23338
23339module.exports = WeakMap;
23340
23341},{"./_getNative":245,"./_root":290}],159:[function(require,module,exports){
23342/**
23343 * A faster alternative to `Function#apply`, this function invokes `func`
23344 * with the `this` binding of `thisArg` and the arguments of `args`.
23345 *
23346 * @private
23347 * @param {Function} func The function to invoke.
23348 * @param {*} thisArg The `this` binding of `func`.
23349 * @param {Array} args The arguments to invoke `func` with.
23350 * @returns {*} Returns the result of `func`.
23351 */
23352function apply(func, thisArg, args) {
23353 switch (args.length) {
23354 case 0: return func.call(thisArg);
23355 case 1: return func.call(thisArg, args[0]);
23356 case 2: return func.call(thisArg, args[0], args[1]);
23357 case 3: return func.call(thisArg, args[0], args[1], args[2]);
23358 }
23359 return func.apply(thisArg, args);
23360}
23361
23362module.exports = apply;
23363
23364},{}],160:[function(require,module,exports){
23365/**
23366 * A specialized version of `_.forEach` for arrays without support for
23367 * iteratee shorthands.
23368 *
23369 * @private
23370 * @param {Array} [array] The array to iterate over.
23371 * @param {Function} iteratee The function invoked per iteration.
23372 * @returns {Array} Returns `array`.
23373 */
23374function arrayEach(array, iteratee) {
23375 var index = -1,
23376 length = array == null ? 0 : array.length;
23377
23378 while (++index < length) {
23379 if (iteratee(array[index], index, array) === false) {
23380 break;
23381 }
23382 }
23383 return array;
23384}
23385
23386module.exports = arrayEach;
23387
23388},{}],161:[function(require,module,exports){
23389/**
23390 * A specialized version of `_.every` for arrays without support for
23391 * iteratee shorthands.
23392 *
23393 * @private
23394 * @param {Array} [array] The array to iterate over.
23395 * @param {Function} predicate The function invoked per iteration.
23396 * @returns {boolean} Returns `true` if all elements pass the predicate check,
23397 * else `false`.
23398 */
23399function arrayEvery(array, predicate) {
23400 var index = -1,
23401 length = array == null ? 0 : array.length;
23402
23403 while (++index < length) {
23404 if (!predicate(array[index], index, array)) {
23405 return false;
23406 }
23407 }
23408 return true;
23409}
23410
23411module.exports = arrayEvery;
23412
23413},{}],162:[function(require,module,exports){
23414/**
23415 * A specialized version of `_.filter` for arrays without support for
23416 * iteratee shorthands.
23417 *
23418 * @private
23419 * @param {Array} [array] The array to iterate over.
23420 * @param {Function} predicate The function invoked per iteration.
23421 * @returns {Array} Returns the new filtered array.
23422 */
23423function arrayFilter(array, predicate) {
23424 var index = -1,
23425 length = array == null ? 0 : array.length,
23426 resIndex = 0,
23427 result = [];
23428
23429 while (++index < length) {
23430 var value = array[index];
23431 if (predicate(value, index, array)) {
23432 result[resIndex++] = value;
23433 }
23434 }
23435 return result;
23436}
23437
23438module.exports = arrayFilter;
23439
23440},{}],163:[function(require,module,exports){
23441var baseTimes = require('./_baseTimes'),
23442 isArguments = require('./isArguments'),
23443 isArray = require('./isArray'),
23444 isBuffer = require('./isBuffer'),
23445 isIndex = require('./_isIndex'),
23446 isTypedArray = require('./isTypedArray');
23447
23448/** Used for built-in method references. */
23449var objectProto = Object.prototype;
23450
23451/** Used to check objects for own properties. */
23452var hasOwnProperty = objectProto.hasOwnProperty;
23453
23454/**
23455 * Creates an array of the enumerable property names of the array-like `value`.
23456 *
23457 * @private
23458 * @param {*} value The value to query.
23459 * @param {boolean} inherited Specify returning inherited property names.
23460 * @returns {Array} Returns the array of property names.
23461 */
23462function arrayLikeKeys(value, inherited) {
23463 var isArr = isArray(value),
23464 isArg = !isArr && isArguments(value),
23465 isBuff = !isArr && !isArg && isBuffer(value),
23466 isType = !isArr && !isArg && !isBuff && isTypedArray(value),
23467 skipIndexes = isArr || isArg || isBuff || isType,
23468 result = skipIndexes ? baseTimes(value.length, String) : [],
23469 length = result.length;
23470
23471 for (var key in value) {
23472 if ((inherited || hasOwnProperty.call(value, key)) &&
23473 !(skipIndexes && (
23474 // Safari 9 has enumerable `arguments.length` in strict mode.
23475 key == 'length' ||
23476 // Node.js 0.10 has enumerable non-index properties on buffers.
23477 (isBuff && (key == 'offset' || key == 'parent')) ||
23478 // PhantomJS 2 has enumerable non-index properties on typed arrays.
23479 (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
23480 // Skip index properties.
23481 isIndex(key, length)
23482 ))) {
23483 result.push(key);
23484 }
23485 }
23486 return result;
23487}
23488
23489module.exports = arrayLikeKeys;
23490
23491},{"./_baseTimes":211,"./_isIndex":263,"./isArguments":322,"./isArray":323,"./isBuffer":326,"./isTypedArray":339}],164:[function(require,module,exports){
23492/**
23493 * A specialized version of `_.map` for arrays without support for iteratee
23494 * shorthands.
23495 *
23496 * @private
23497 * @param {Array} [array] The array to iterate over.
23498 * @param {Function} iteratee The function invoked per iteration.
23499 * @returns {Array} Returns the new mapped array.
23500 */
23501function arrayMap(array, iteratee) {
23502 var index = -1,
23503 length = array == null ? 0 : array.length,
23504 result = Array(length);
23505
23506 while (++index < length) {
23507 result[index] = iteratee(array[index], index, array);
23508 }
23509 return result;
23510}
23511
23512module.exports = arrayMap;
23513
23514},{}],165:[function(require,module,exports){
23515/**
23516 * Appends the elements of `values` to `array`.
23517 *
23518 * @private
23519 * @param {Array} array The array to modify.
23520 * @param {Array} values The values to append.
23521 * @returns {Array} Returns `array`.
23522 */
23523function arrayPush(array, values) {
23524 var index = -1,
23525 length = values.length,
23526 offset = array.length;
23527
23528 while (++index < length) {
23529 array[offset + index] = values[index];
23530 }
23531 return array;
23532}
23533
23534module.exports = arrayPush;
23535
23536},{}],166:[function(require,module,exports){
23537/**
23538 * A specialized version of `_.some` for arrays without support for iteratee
23539 * shorthands.
23540 *
23541 * @private
23542 * @param {Array} [array] The array to iterate over.
23543 * @param {Function} predicate The function invoked per iteration.
23544 * @returns {boolean} Returns `true` if any element passes the predicate check,
23545 * else `false`.
23546 */
23547function arraySome(array, predicate) {
23548 var index = -1,
23549 length = array == null ? 0 : array.length;
23550
23551 while (++index < length) {
23552 if (predicate(array[index], index, array)) {
23553 return true;
23554 }
23555 }
23556 return false;
23557}
23558
23559module.exports = arraySome;
23560
23561},{}],167:[function(require,module,exports){
23562var baseProperty = require('./_baseProperty');
23563
23564/**
23565 * Gets the size of an ASCII `string`.
23566 *
23567 * @private
23568 * @param {string} string The string inspect.
23569 * @returns {number} Returns the string size.
23570 */
23571var asciiSize = baseProperty('length');
23572
23573module.exports = asciiSize;
23574
23575},{"./_baseProperty":204}],168:[function(require,module,exports){
23576/**
23577 * Converts an ASCII `string` to an array.
23578 *
23579 * @private
23580 * @param {string} string The string to convert.
23581 * @returns {Array} Returns the converted array.
23582 */
23583function asciiToArray(string) {
23584 return string.split('');
23585}
23586
23587module.exports = asciiToArray;
23588
23589},{}],169:[function(require,module,exports){
23590var baseAssignValue = require('./_baseAssignValue'),
23591 eq = require('./eq');
23592
23593/** Used for built-in method references. */
23594var objectProto = Object.prototype;
23595
23596/** Used to check objects for own properties. */
23597var hasOwnProperty = objectProto.hasOwnProperty;
23598
23599/**
23600 * Assigns `value` to `key` of `object` if the existing value is not equivalent
23601 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
23602 * for equality comparisons.
23603 *
23604 * @private
23605 * @param {Object} object The object to modify.
23606 * @param {string} key The key of the property to assign.
23607 * @param {*} value The value to assign.
23608 */
23609function assignValue(object, key, value) {
23610 var objValue = object[key];
23611 if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
23612 (value === undefined && !(key in object))) {
23613 baseAssignValue(object, key, value);
23614 }
23615}
23616
23617module.exports = assignValue;
23618
23619},{"./_baseAssignValue":173,"./eq":313}],170:[function(require,module,exports){
23620var eq = require('./eq');
23621
23622/**
23623 * Gets the index at which the `key` is found in `array` of key-value pairs.
23624 *
23625 * @private
23626 * @param {Array} array The array to inspect.
23627 * @param {*} key The key to search for.
23628 * @returns {number} Returns the index of the matched value, else `-1`.
23629 */
23630function assocIndexOf(array, key) {
23631 var length = array.length;
23632 while (length--) {
23633 if (eq(array[length][0], key)) {
23634 return length;
23635 }
23636 }
23637 return -1;
23638}
23639
23640module.exports = assocIndexOf;
23641
23642},{"./eq":313}],171:[function(require,module,exports){
23643var copyObject = require('./_copyObject'),
23644 keys = require('./keys');
23645
23646/**
23647 * The base implementation of `_.assign` without support for multiple sources
23648 * or `customizer` functions.
23649 *
23650 * @private
23651 * @param {Object} object The destination object.
23652 * @param {Object} source The source object.
23653 * @returns {Object} Returns `object`.
23654 */
23655function baseAssign(object, source) {
23656 return object && copyObject(source, keys(source), object);
23657}
23658
23659module.exports = baseAssign;
23660
23661},{"./_copyObject":227,"./keys":341}],172:[function(require,module,exports){
23662var copyObject = require('./_copyObject'),
23663 keysIn = require('./keysIn');
23664
23665/**
23666 * The base implementation of `_.assignIn` without support for multiple sources
23667 * or `customizer` functions.
23668 *
23669 * @private
23670 * @param {Object} object The destination object.
23671 * @param {Object} source The source object.
23672 * @returns {Object} Returns `object`.
23673 */
23674function baseAssignIn(object, source) {
23675 return object && copyObject(source, keysIn(source), object);
23676}
23677
23678module.exports = baseAssignIn;
23679
23680},{"./_copyObject":227,"./keysIn":342}],173:[function(require,module,exports){
23681var defineProperty = require('./_defineProperty');
23682
23683/**
23684 * The base implementation of `assignValue` and `assignMergeValue` without
23685 * value checks.
23686 *
23687 * @private
23688 * @param {Object} object The object to modify.
23689 * @param {string} key The key of the property to assign.
23690 * @param {*} value The value to assign.
23691 */
23692function baseAssignValue(object, key, value) {
23693 if (key == '__proto__' && defineProperty) {
23694 defineProperty(object, key, {
23695 'configurable': true,
23696 'enumerable': true,
23697 'value': value,
23698 'writable': true
23699 });
23700 } else {
23701 object[key] = value;
23702 }
23703}
23704
23705module.exports = baseAssignValue;
23706
23707},{"./_defineProperty":235}],174:[function(require,module,exports){
23708var Stack = require('./_Stack'),
23709 arrayEach = require('./_arrayEach'),
23710 assignValue = require('./_assignValue'),
23711 baseAssign = require('./_baseAssign'),
23712 baseAssignIn = require('./_baseAssignIn'),
23713 cloneBuffer = require('./_cloneBuffer'),
23714 copyArray = require('./_copyArray'),
23715 copySymbols = require('./_copySymbols'),
23716 copySymbolsIn = require('./_copySymbolsIn'),
23717 getAllKeys = require('./_getAllKeys'),
23718 getAllKeysIn = require('./_getAllKeysIn'),
23719 getTag = require('./_getTag'),
23720 initCloneArray = require('./_initCloneArray'),
23721 initCloneByTag = require('./_initCloneByTag'),
23722 initCloneObject = require('./_initCloneObject'),
23723 isArray = require('./isArray'),
23724 isBuffer = require('./isBuffer'),
23725 isMap = require('./isMap'),
23726 isObject = require('./isObject'),
23727 isSet = require('./isSet'),
23728 keys = require('./keys');
23729
23730/** Used to compose bitmasks for cloning. */
23731var CLONE_DEEP_FLAG = 1,
23732 CLONE_FLAT_FLAG = 2,
23733 CLONE_SYMBOLS_FLAG = 4;
23734
23735/** `Object#toString` result references. */
23736var argsTag = '[object Arguments]',
23737 arrayTag = '[object Array]',
23738 boolTag = '[object Boolean]',
23739 dateTag = '[object Date]',
23740 errorTag = '[object Error]',
23741 funcTag = '[object Function]',
23742 genTag = '[object GeneratorFunction]',
23743 mapTag = '[object Map]',
23744 numberTag = '[object Number]',
23745 objectTag = '[object Object]',
23746 regexpTag = '[object RegExp]',
23747 setTag = '[object Set]',
23748 stringTag = '[object String]',
23749 symbolTag = '[object Symbol]',
23750 weakMapTag = '[object WeakMap]';
23751
23752var arrayBufferTag = '[object ArrayBuffer]',
23753 dataViewTag = '[object DataView]',
23754 float32Tag = '[object Float32Array]',
23755 float64Tag = '[object Float64Array]',
23756 int8Tag = '[object Int8Array]',
23757 int16Tag = '[object Int16Array]',
23758 int32Tag = '[object Int32Array]',
23759 uint8Tag = '[object Uint8Array]',
23760 uint8ClampedTag = '[object Uint8ClampedArray]',
23761 uint16Tag = '[object Uint16Array]',
23762 uint32Tag = '[object Uint32Array]';
23763
23764/** Used to identify `toStringTag` values supported by `_.clone`. */
23765var cloneableTags = {};
23766cloneableTags[argsTag] = cloneableTags[arrayTag] =
23767cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
23768cloneableTags[boolTag] = cloneableTags[dateTag] =
23769cloneableTags[float32Tag] = cloneableTags[float64Tag] =
23770cloneableTags[int8Tag] = cloneableTags[int16Tag] =
23771cloneableTags[int32Tag] = cloneableTags[mapTag] =
23772cloneableTags[numberTag] = cloneableTags[objectTag] =
23773cloneableTags[regexpTag] = cloneableTags[setTag] =
23774cloneableTags[stringTag] = cloneableTags[symbolTag] =
23775cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
23776cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
23777cloneableTags[errorTag] = cloneableTags[funcTag] =
23778cloneableTags[weakMapTag] = false;
23779
23780/**
23781 * The base implementation of `_.clone` and `_.cloneDeep` which tracks
23782 * traversed objects.
23783 *
23784 * @private
23785 * @param {*} value The value to clone.
23786 * @param {boolean} bitmask The bitmask flags.
23787 * 1 - Deep clone
23788 * 2 - Flatten inherited properties
23789 * 4 - Clone symbols
23790 * @param {Function} [customizer] The function to customize cloning.
23791 * @param {string} [key] The key of `value`.
23792 * @param {Object} [object] The parent object of `value`.
23793 * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
23794 * @returns {*} Returns the cloned value.
23795 */
23796function baseClone(value, bitmask, customizer, key, object, stack) {
23797 var result,
23798 isDeep = bitmask & CLONE_DEEP_FLAG,
23799 isFlat = bitmask & CLONE_FLAT_FLAG,
23800 isFull = bitmask & CLONE_SYMBOLS_FLAG;
23801
23802 if (customizer) {
23803 result = object ? customizer(value, key, object, stack) : customizer(value);
23804 }
23805 if (result !== undefined) {
23806 return result;
23807 }
23808 if (!isObject(value)) {
23809 return value;
23810 }
23811 var isArr = isArray(value);
23812 if (isArr) {
23813 result = initCloneArray(value);
23814 if (!isDeep) {
23815 return copyArray(value, result);
23816 }
23817 } else {
23818 var tag = getTag(value),
23819 isFunc = tag == funcTag || tag == genTag;
23820
23821 if (isBuffer(value)) {
23822 return cloneBuffer(value, isDeep);
23823 }
23824 if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
23825 result = (isFlat || isFunc) ? {} : initCloneObject(value);
23826 if (!isDeep) {
23827 return isFlat
23828 ? copySymbolsIn(value, baseAssignIn(result, value))
23829 : copySymbols(value, baseAssign(result, value));
23830 }
23831 } else {
23832 if (!cloneableTags[tag]) {
23833 return object ? value : {};
23834 }
23835 result = initCloneByTag(value, tag, isDeep);
23836 }
23837 }
23838 // Check for circular references and return its corresponding clone.
23839 stack || (stack = new Stack);
23840 var stacked = stack.get(value);
23841 if (stacked) {
23842 return stacked;
23843 }
23844 stack.set(value, result);
23845
23846 if (isSet(value)) {
23847 value.forEach(function(subValue) {
23848 result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
23849 });
23850
23851 return result;
23852 }
23853
23854 if (isMap(value)) {
23855 value.forEach(function(subValue, key) {
23856 result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
23857 });
23858
23859 return result;
23860 }
23861
23862 var keysFunc = isFull
23863 ? (isFlat ? getAllKeysIn : getAllKeys)
23864 : (isFlat ? keysIn : keys);
23865
23866 var props = isArr ? undefined : keysFunc(value);
23867 arrayEach(props || value, function(subValue, key) {
23868 if (props) {
23869 key = subValue;
23870 subValue = value[key];
23871 }
23872 // Recursively populate clone (susceptible to call stack limits).
23873 assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
23874 });
23875 return result;
23876}
23877
23878module.exports = baseClone;
23879
23880},{"./_Stack":155,"./_arrayEach":160,"./_assignValue":169,"./_baseAssign":171,"./_baseAssignIn":172,"./_cloneBuffer":221,"./_copyArray":226,"./_copySymbols":228,"./_copySymbolsIn":229,"./_getAllKeys":241,"./_getAllKeysIn":242,"./_getTag":250,"./_initCloneArray":259,"./_initCloneByTag":260,"./_initCloneObject":261,"./isArray":323,"./isBuffer":326,"./isMap":330,"./isObject":333,"./isSet":336,"./keys":341}],175:[function(require,module,exports){
23881var isObject = require('./isObject');
23882
23883/** Built-in value references. */
23884var objectCreate = Object.create;
23885
23886/**
23887 * The base implementation of `_.create` without support for assigning
23888 * properties to the created object.
23889 *
23890 * @private
23891 * @param {Object} proto The object to inherit from.
23892 * @returns {Object} Returns the new object.
23893 */
23894var baseCreate = (function() {
23895 function object() {}
23896 return function(proto) {
23897 if (!isObject(proto)) {
23898 return {};
23899 }
23900 if (objectCreate) {
23901 return objectCreate(proto);
23902 }
23903 object.prototype = proto;
23904 var result = new object;
23905 object.prototype = undefined;
23906 return result;
23907 };
23908}());
23909
23910module.exports = baseCreate;
23911
23912},{"./isObject":333}],176:[function(require,module,exports){
23913var baseForOwn = require('./_baseForOwn'),
23914 createBaseEach = require('./_createBaseEach');
23915
23916/**
23917 * The base implementation of `_.forEach` without support for iteratee shorthands.
23918 *
23919 * @private
23920 * @param {Array|Object} collection The collection to iterate over.
23921 * @param {Function} iteratee The function invoked per iteration.
23922 * @returns {Array|Object} Returns `collection`.
23923 */
23924var baseEach = createBaseEach(baseForOwn);
23925
23926module.exports = baseEach;
23927
23928},{"./_baseForOwn":181,"./_createBaseEach":232}],177:[function(require,module,exports){
23929var baseEach = require('./_baseEach');
23930
23931/**
23932 * The base implementation of `_.every` without support for iteratee shorthands.
23933 *
23934 * @private
23935 * @param {Array|Object} collection The collection to iterate over.
23936 * @param {Function} predicate The function invoked per iteration.
23937 * @returns {boolean} Returns `true` if all elements pass the predicate check,
23938 * else `false`
23939 */
23940function baseEvery(collection, predicate) {
23941 var result = true;
23942 baseEach(collection, function(value, index, collection) {
23943 result = !!predicate(value, index, collection);
23944 return result;
23945 });
23946 return result;
23947}
23948
23949module.exports = baseEvery;
23950
23951},{"./_baseEach":176}],178:[function(require,module,exports){
23952/**
23953 * The base implementation of `_.findIndex` and `_.findLastIndex` without
23954 * support for iteratee shorthands.
23955 *
23956 * @private
23957 * @param {Array} array The array to inspect.
23958 * @param {Function} predicate The function invoked per iteration.
23959 * @param {number} fromIndex The index to search from.
23960 * @param {boolean} [fromRight] Specify iterating from right to left.
23961 * @returns {number} Returns the index of the matched value, else `-1`.
23962 */
23963function baseFindIndex(array, predicate, fromIndex, fromRight) {
23964 var length = array.length,
23965 index = fromIndex + (fromRight ? 1 : -1);
23966
23967 while ((fromRight ? index-- : ++index < length)) {
23968 if (predicate(array[index], index, array)) {
23969 return index;
23970 }
23971 }
23972 return -1;
23973}
23974
23975module.exports = baseFindIndex;
23976
23977},{}],179:[function(require,module,exports){
23978var arrayPush = require('./_arrayPush'),
23979 isFlattenable = require('./_isFlattenable');
23980
23981/**
23982 * The base implementation of `_.flatten` with support for restricting flattening.
23983 *
23984 * @private
23985 * @param {Array} array The array to flatten.
23986 * @param {number} depth The maximum recursion depth.
23987 * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
23988 * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
23989 * @param {Array} [result=[]] The initial result value.
23990 * @returns {Array} Returns the new flattened array.
23991 */
23992function baseFlatten(array, depth, predicate, isStrict, result) {
23993 var index = -1,
23994 length = array.length;
23995
23996 predicate || (predicate = isFlattenable);
23997 result || (result = []);
23998
23999 while (++index < length) {
24000 var value = array[index];
24001 if (depth > 0 && predicate(value)) {
24002 if (depth > 1) {
24003 // Recursively flatten arrays (susceptible to call stack limits).
24004 baseFlatten(value, depth - 1, predicate, isStrict, result);
24005 } else {
24006 arrayPush(result, value);
24007 }
24008 } else if (!isStrict) {
24009 result[result.length] = value;
24010 }
24011 }
24012 return result;
24013}
24014
24015module.exports = baseFlatten;
24016
24017},{"./_arrayPush":165,"./_isFlattenable":262}],180:[function(require,module,exports){
24018var createBaseFor = require('./_createBaseFor');
24019
24020/**
24021 * The base implementation of `baseForOwn` which iterates over `object`
24022 * properties returned by `keysFunc` and invokes `iteratee` for each property.
24023 * Iteratee functions may exit iteration early by explicitly returning `false`.
24024 *
24025 * @private
24026 * @param {Object} object The object to iterate over.
24027 * @param {Function} iteratee The function invoked per iteration.
24028 * @param {Function} keysFunc The function to get the keys of `object`.
24029 * @returns {Object} Returns `object`.
24030 */
24031var baseFor = createBaseFor();
24032
24033module.exports = baseFor;
24034
24035},{"./_createBaseFor":233}],181:[function(require,module,exports){
24036var baseFor = require('./_baseFor'),
24037 keys = require('./keys');
24038
24039/**
24040 * The base implementation of `_.forOwn` without support for iteratee shorthands.
24041 *
24042 * @private
24043 * @param {Object} object The object to iterate over.
24044 * @param {Function} iteratee The function invoked per iteration.
24045 * @returns {Object} Returns `object`.
24046 */
24047function baseForOwn(object, iteratee) {
24048 return object && baseFor(object, iteratee, keys);
24049}
24050
24051module.exports = baseForOwn;
24052
24053},{"./_baseFor":180,"./keys":341}],182:[function(require,module,exports){
24054var castPath = require('./_castPath'),
24055 toKey = require('./_toKey');
24056
24057/**
24058 * The base implementation of `_.get` without support for default values.
24059 *
24060 * @private
24061 * @param {Object} object The object to query.
24062 * @param {Array|string} path The path of the property to get.
24063 * @returns {*} Returns the resolved value.
24064 */
24065function baseGet(object, path) {
24066 path = castPath(path, object);
24067
24068 var index = 0,
24069 length = path.length;
24070
24071 while (object != null && index < length) {
24072 object = object[toKey(path[index++])];
24073 }
24074 return (index && index == length) ? object : undefined;
24075}
24076
24077module.exports = baseGet;
24078
24079},{"./_castPath":217,"./_toKey":305}],183:[function(require,module,exports){
24080var arrayPush = require('./_arrayPush'),
24081 isArray = require('./isArray');
24082
24083/**
24084 * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
24085 * `keysFunc` and `symbolsFunc` to get the enumerable property names and
24086 * symbols of `object`.
24087 *
24088 * @private
24089 * @param {Object} object The object to query.
24090 * @param {Function} keysFunc The function to get the keys of `object`.
24091 * @param {Function} symbolsFunc The function to get the symbols of `object`.
24092 * @returns {Array} Returns the array of property names and symbols.
24093 */
24094function baseGetAllKeys(object, keysFunc, symbolsFunc) {
24095 var result = keysFunc(object);
24096 return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
24097}
24098
24099module.exports = baseGetAllKeys;
24100
24101},{"./_arrayPush":165,"./isArray":323}],184:[function(require,module,exports){
24102var Symbol = require('./_Symbol'),
24103 getRawTag = require('./_getRawTag'),
24104 objectToString = require('./_objectToString');
24105
24106/** `Object#toString` result references. */
24107var nullTag = '[object Null]',
24108 undefinedTag = '[object Undefined]';
24109
24110/** Built-in value references. */
24111var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
24112
24113/**
24114 * The base implementation of `getTag` without fallbacks for buggy environments.
24115 *
24116 * @private
24117 * @param {*} value The value to query.
24118 * @returns {string} Returns the `toStringTag`.
24119 */
24120function baseGetTag(value) {
24121 if (value == null) {
24122 return value === undefined ? undefinedTag : nullTag;
24123 }
24124 return (symToStringTag && symToStringTag in Object(value))
24125 ? getRawTag(value)
24126 : objectToString(value);
24127}
24128
24129module.exports = baseGetTag;
24130
24131},{"./_Symbol":156,"./_getRawTag":247,"./_objectToString":287}],185:[function(require,module,exports){
24132/**
24133 * The base implementation of `_.hasIn` without support for deep paths.
24134 *
24135 * @private
24136 * @param {Object} [object] The object to query.
24137 * @param {Array|string} key The key to check.
24138 * @returns {boolean} Returns `true` if `key` exists, else `false`.
24139 */
24140function baseHasIn(object, key) {
24141 return object != null && key in Object(object);
24142}
24143
24144module.exports = baseHasIn;
24145
24146},{}],186:[function(require,module,exports){
24147var baseFindIndex = require('./_baseFindIndex'),
24148 baseIsNaN = require('./_baseIsNaN'),
24149 strictIndexOf = require('./_strictIndexOf');
24150
24151/**
24152 * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
24153 *
24154 * @private
24155 * @param {Array} array The array to inspect.
24156 * @param {*} value The value to search for.
24157 * @param {number} fromIndex The index to search from.
24158 * @returns {number} Returns the index of the matched value, else `-1`.
24159 */
24160function baseIndexOf(array, value, fromIndex) {
24161 return value === value
24162 ? strictIndexOf(array, value, fromIndex)
24163 : baseFindIndex(array, baseIsNaN, fromIndex);
24164}
24165
24166module.exports = baseIndexOf;
24167
24168},{"./_baseFindIndex":178,"./_baseIsNaN":192,"./_strictIndexOf":301}],187:[function(require,module,exports){
24169var baseGetTag = require('./_baseGetTag'),
24170 isObjectLike = require('./isObjectLike');
24171
24172/** `Object#toString` result references. */
24173var argsTag = '[object Arguments]';
24174
24175/**
24176 * The base implementation of `_.isArguments`.
24177 *
24178 * @private
24179 * @param {*} value The value to check.
24180 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
24181 */
24182function baseIsArguments(value) {
24183 return isObjectLike(value) && baseGetTag(value) == argsTag;
24184}
24185
24186module.exports = baseIsArguments;
24187
24188},{"./_baseGetTag":184,"./isObjectLike":334}],188:[function(require,module,exports){
24189var baseIsEqualDeep = require('./_baseIsEqualDeep'),
24190 isObjectLike = require('./isObjectLike');
24191
24192/**
24193 * The base implementation of `_.isEqual` which supports partial comparisons
24194 * and tracks traversed objects.
24195 *
24196 * @private
24197 * @param {*} value The value to compare.
24198 * @param {*} other The other value to compare.
24199 * @param {boolean} bitmask The bitmask flags.
24200 * 1 - Unordered comparison
24201 * 2 - Partial comparison
24202 * @param {Function} [customizer] The function to customize comparisons.
24203 * @param {Object} [stack] Tracks traversed `value` and `other` objects.
24204 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
24205 */
24206function baseIsEqual(value, other, bitmask, customizer, stack) {
24207 if (value === other) {
24208 return true;
24209 }
24210 if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
24211 return value !== value && other !== other;
24212 }
24213 return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
24214}
24215
24216module.exports = baseIsEqual;
24217
24218},{"./_baseIsEqualDeep":189,"./isObjectLike":334}],189:[function(require,module,exports){
24219var Stack = require('./_Stack'),
24220 equalArrays = require('./_equalArrays'),
24221 equalByTag = require('./_equalByTag'),
24222 equalObjects = require('./_equalObjects'),
24223 getTag = require('./_getTag'),
24224 isArray = require('./isArray'),
24225 isBuffer = require('./isBuffer'),
24226 isTypedArray = require('./isTypedArray');
24227
24228/** Used to compose bitmasks for value comparisons. */
24229var COMPARE_PARTIAL_FLAG = 1;
24230
24231/** `Object#toString` result references. */
24232var argsTag = '[object Arguments]',
24233 arrayTag = '[object Array]',
24234 objectTag = '[object Object]';
24235
24236/** Used for built-in method references. */
24237var objectProto = Object.prototype;
24238
24239/** Used to check objects for own properties. */
24240var hasOwnProperty = objectProto.hasOwnProperty;
24241
24242/**
24243 * A specialized version of `baseIsEqual` for arrays and objects which performs
24244 * deep comparisons and tracks traversed objects enabling objects with circular
24245 * references to be compared.
24246 *
24247 * @private
24248 * @param {Object} object The object to compare.
24249 * @param {Object} other The other object to compare.
24250 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
24251 * @param {Function} customizer The function to customize comparisons.
24252 * @param {Function} equalFunc The function to determine equivalents of values.
24253 * @param {Object} [stack] Tracks traversed `object` and `other` objects.
24254 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
24255 */
24256function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
24257 var objIsArr = isArray(object),
24258 othIsArr = isArray(other),
24259 objTag = objIsArr ? arrayTag : getTag(object),
24260 othTag = othIsArr ? arrayTag : getTag(other);
24261
24262 objTag = objTag == argsTag ? objectTag : objTag;
24263 othTag = othTag == argsTag ? objectTag : othTag;
24264
24265 var objIsObj = objTag == objectTag,
24266 othIsObj = othTag == objectTag,
24267 isSameTag = objTag == othTag;
24268
24269 if (isSameTag && isBuffer(object)) {
24270 if (!isBuffer(other)) {
24271 return false;
24272 }
24273 objIsArr = true;
24274 objIsObj = false;
24275 }
24276 if (isSameTag && !objIsObj) {
24277 stack || (stack = new Stack);
24278 return (objIsArr || isTypedArray(object))
24279 ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
24280 : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
24281 }
24282 if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
24283 var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
24284 othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
24285
24286 if (objIsWrapped || othIsWrapped) {
24287 var objUnwrapped = objIsWrapped ? object.value() : object,
24288 othUnwrapped = othIsWrapped ? other.value() : other;
24289
24290 stack || (stack = new Stack);
24291 return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
24292 }
24293 }
24294 if (!isSameTag) {
24295 return false;
24296 }
24297 stack || (stack = new Stack);
24298 return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
24299}
24300
24301module.exports = baseIsEqualDeep;
24302
24303},{"./_Stack":155,"./_equalArrays":236,"./_equalByTag":237,"./_equalObjects":238,"./_getTag":250,"./isArray":323,"./isBuffer":326,"./isTypedArray":339}],190:[function(require,module,exports){
24304var getTag = require('./_getTag'),
24305 isObjectLike = require('./isObjectLike');
24306
24307/** `Object#toString` result references. */
24308var mapTag = '[object Map]';
24309
24310/**
24311 * The base implementation of `_.isMap` without Node.js optimizations.
24312 *
24313 * @private
24314 * @param {*} value The value to check.
24315 * @returns {boolean} Returns `true` if `value` is a map, else `false`.
24316 */
24317function baseIsMap(value) {
24318 return isObjectLike(value) && getTag(value) == mapTag;
24319}
24320
24321module.exports = baseIsMap;
24322
24323},{"./_getTag":250,"./isObjectLike":334}],191:[function(require,module,exports){
24324var Stack = require('./_Stack'),
24325 baseIsEqual = require('./_baseIsEqual');
24326
24327/** Used to compose bitmasks for value comparisons. */
24328var COMPARE_PARTIAL_FLAG = 1,
24329 COMPARE_UNORDERED_FLAG = 2;
24330
24331/**
24332 * The base implementation of `_.isMatch` without support for iteratee shorthands.
24333 *
24334 * @private
24335 * @param {Object} object The object to inspect.
24336 * @param {Object} source The object of property values to match.
24337 * @param {Array} matchData The property names, values, and compare flags to match.
24338 * @param {Function} [customizer] The function to customize comparisons.
24339 * @returns {boolean} Returns `true` if `object` is a match, else `false`.
24340 */
24341function baseIsMatch(object, source, matchData, customizer) {
24342 var index = matchData.length,
24343 length = index,
24344 noCustomizer = !customizer;
24345
24346 if (object == null) {
24347 return !length;
24348 }
24349 object = Object(object);
24350 while (index--) {
24351 var data = matchData[index];
24352 if ((noCustomizer && data[2])
24353 ? data[1] !== object[data[0]]
24354 : !(data[0] in object)
24355 ) {
24356 return false;
24357 }
24358 }
24359 while (++index < length) {
24360 data = matchData[index];
24361 var key = data[0],
24362 objValue = object[key],
24363 srcValue = data[1];
24364
24365 if (noCustomizer && data[2]) {
24366 if (objValue === undefined && !(key in object)) {
24367 return false;
24368 }
24369 } else {
24370 var stack = new Stack;
24371 if (customizer) {
24372 var result = customizer(objValue, srcValue, key, object, source, stack);
24373 }
24374 if (!(result === undefined
24375 ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
24376 : result
24377 )) {
24378 return false;
24379 }
24380 }
24381 }
24382 return true;
24383}
24384
24385module.exports = baseIsMatch;
24386
24387},{"./_Stack":155,"./_baseIsEqual":188}],192:[function(require,module,exports){
24388/**
24389 * The base implementation of `_.isNaN` without support for number objects.
24390 *
24391 * @private
24392 * @param {*} value The value to check.
24393 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
24394 */
24395function baseIsNaN(value) {
24396 return value !== value;
24397}
24398
24399module.exports = baseIsNaN;
24400
24401},{}],193:[function(require,module,exports){
24402var isFunction = require('./isFunction'),
24403 isMasked = require('./_isMasked'),
24404 isObject = require('./isObject'),
24405 toSource = require('./_toSource');
24406
24407/**
24408 * Used to match `RegExp`
24409 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
24410 */
24411var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
24412
24413/** Used to detect host constructors (Safari). */
24414var reIsHostCtor = /^\[object .+?Constructor\]$/;
24415
24416/** Used for built-in method references. */
24417var funcProto = Function.prototype,
24418 objectProto = Object.prototype;
24419
24420/** Used to resolve the decompiled source of functions. */
24421var funcToString = funcProto.toString;
24422
24423/** Used to check objects for own properties. */
24424var hasOwnProperty = objectProto.hasOwnProperty;
24425
24426/** Used to detect if a method is native. */
24427var reIsNative = RegExp('^' +
24428 funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
24429 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
24430);
24431
24432/**
24433 * The base implementation of `_.isNative` without bad shim checks.
24434 *
24435 * @private
24436 * @param {*} value The value to check.
24437 * @returns {boolean} Returns `true` if `value` is a native function,
24438 * else `false`.
24439 */
24440function baseIsNative(value) {
24441 if (!isObject(value) || isMasked(value)) {
24442 return false;
24443 }
24444 var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
24445 return pattern.test(toSource(value));
24446}
24447
24448module.exports = baseIsNative;
24449
24450},{"./_isMasked":267,"./_toSource":306,"./isFunction":328,"./isObject":333}],194:[function(require,module,exports){
24451var getTag = require('./_getTag'),
24452 isObjectLike = require('./isObjectLike');
24453
24454/** `Object#toString` result references. */
24455var setTag = '[object Set]';
24456
24457/**
24458 * The base implementation of `_.isSet` without Node.js optimizations.
24459 *
24460 * @private
24461 * @param {*} value The value to check.
24462 * @returns {boolean} Returns `true` if `value` is a set, else `false`.
24463 */
24464function baseIsSet(value) {
24465 return isObjectLike(value) && getTag(value) == setTag;
24466}
24467
24468module.exports = baseIsSet;
24469
24470},{"./_getTag":250,"./isObjectLike":334}],195:[function(require,module,exports){
24471var baseGetTag = require('./_baseGetTag'),
24472 isLength = require('./isLength'),
24473 isObjectLike = require('./isObjectLike');
24474
24475/** `Object#toString` result references. */
24476var argsTag = '[object Arguments]',
24477 arrayTag = '[object Array]',
24478 boolTag = '[object Boolean]',
24479 dateTag = '[object Date]',
24480 errorTag = '[object Error]',
24481 funcTag = '[object Function]',
24482 mapTag = '[object Map]',
24483 numberTag = '[object Number]',
24484 objectTag = '[object Object]',
24485 regexpTag = '[object RegExp]',
24486 setTag = '[object Set]',
24487 stringTag = '[object String]',
24488 weakMapTag = '[object WeakMap]';
24489
24490var arrayBufferTag = '[object ArrayBuffer]',
24491 dataViewTag = '[object DataView]',
24492 float32Tag = '[object Float32Array]',
24493 float64Tag = '[object Float64Array]',
24494 int8Tag = '[object Int8Array]',
24495 int16Tag = '[object Int16Array]',
24496 int32Tag = '[object Int32Array]',
24497 uint8Tag = '[object Uint8Array]',
24498 uint8ClampedTag = '[object Uint8ClampedArray]',
24499 uint16Tag = '[object Uint16Array]',
24500 uint32Tag = '[object Uint32Array]';
24501
24502/** Used to identify `toStringTag` values of typed arrays. */
24503var typedArrayTags = {};
24504typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
24505typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
24506typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
24507typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
24508typedArrayTags[uint32Tag] = true;
24509typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
24510typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
24511typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
24512typedArrayTags[errorTag] = typedArrayTags[funcTag] =
24513typedArrayTags[mapTag] = typedArrayTags[numberTag] =
24514typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
24515typedArrayTags[setTag] = typedArrayTags[stringTag] =
24516typedArrayTags[weakMapTag] = false;
24517
24518/**
24519 * The base implementation of `_.isTypedArray` without Node.js optimizations.
24520 *
24521 * @private
24522 * @param {*} value The value to check.
24523 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
24524 */
24525function baseIsTypedArray(value) {
24526 return isObjectLike(value) &&
24527 isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
24528}
24529
24530module.exports = baseIsTypedArray;
24531
24532},{"./_baseGetTag":184,"./isLength":329,"./isObjectLike":334}],196:[function(require,module,exports){
24533var baseMatches = require('./_baseMatches'),
24534 baseMatchesProperty = require('./_baseMatchesProperty'),
24535 identity = require('./identity'),
24536 isArray = require('./isArray'),
24537 property = require('./property');
24538
24539/**
24540 * The base implementation of `_.iteratee`.
24541 *
24542 * @private
24543 * @param {*} [value=_.identity] The value to convert to an iteratee.
24544 * @returns {Function} Returns the iteratee.
24545 */
24546function baseIteratee(value) {
24547 // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
24548 // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
24549 if (typeof value == 'function') {
24550 return value;
24551 }
24552 if (value == null) {
24553 return identity;
24554 }
24555 if (typeof value == 'object') {
24556 return isArray(value)
24557 ? baseMatchesProperty(value[0], value[1])
24558 : baseMatches(value);
24559 }
24560 return property(value);
24561}
24562
24563module.exports = baseIteratee;
24564
24565},{"./_baseMatches":200,"./_baseMatchesProperty":201,"./identity":321,"./isArray":323,"./property":347}],197:[function(require,module,exports){
24566var isPrototype = require('./_isPrototype'),
24567 nativeKeys = require('./_nativeKeys');
24568
24569/** Used for built-in method references. */
24570var objectProto = Object.prototype;
24571
24572/** Used to check objects for own properties. */
24573var hasOwnProperty = objectProto.hasOwnProperty;
24574
24575/**
24576 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
24577 *
24578 * @private
24579 * @param {Object} object The object to query.
24580 * @returns {Array} Returns the array of property names.
24581 */
24582function baseKeys(object) {
24583 if (!isPrototype(object)) {
24584 return nativeKeys(object);
24585 }
24586 var result = [];
24587 for (var key in Object(object)) {
24588 if (hasOwnProperty.call(object, key) && key != 'constructor') {
24589 result.push(key);
24590 }
24591 }
24592 return result;
24593}
24594
24595module.exports = baseKeys;
24596
24597},{"./_isPrototype":268,"./_nativeKeys":284}],198:[function(require,module,exports){
24598var isObject = require('./isObject'),
24599 isPrototype = require('./_isPrototype'),
24600 nativeKeysIn = require('./_nativeKeysIn');
24601
24602/** Used for built-in method references. */
24603var objectProto = Object.prototype;
24604
24605/** Used to check objects for own properties. */
24606var hasOwnProperty = objectProto.hasOwnProperty;
24607
24608/**
24609 * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
24610 *
24611 * @private
24612 * @param {Object} object The object to query.
24613 * @returns {Array} Returns the array of property names.
24614 */
24615function baseKeysIn(object) {
24616 if (!isObject(object)) {
24617 return nativeKeysIn(object);
24618 }
24619 var isProto = isPrototype(object),
24620 result = [];
24621
24622 for (var key in object) {
24623 if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
24624 result.push(key);
24625 }
24626 }
24627 return result;
24628}
24629
24630module.exports = baseKeysIn;
24631
24632},{"./_isPrototype":268,"./_nativeKeysIn":285,"./isObject":333}],199:[function(require,module,exports){
24633var baseEach = require('./_baseEach'),
24634 isArrayLike = require('./isArrayLike');
24635
24636/**
24637 * The base implementation of `_.map` without support for iteratee shorthands.
24638 *
24639 * @private
24640 * @param {Array|Object} collection The collection to iterate over.
24641 * @param {Function} iteratee The function invoked per iteration.
24642 * @returns {Array} Returns the new mapped array.
24643 */
24644function baseMap(collection, iteratee) {
24645 var index = -1,
24646 result = isArrayLike(collection) ? Array(collection.length) : [];
24647
24648 baseEach(collection, function(value, key, collection) {
24649 result[++index] = iteratee(value, key, collection);
24650 });
24651 return result;
24652}
24653
24654module.exports = baseMap;
24655
24656},{"./_baseEach":176,"./isArrayLike":324}],200:[function(require,module,exports){
24657var baseIsMatch = require('./_baseIsMatch'),
24658 getMatchData = require('./_getMatchData'),
24659 matchesStrictComparable = require('./_matchesStrictComparable');
24660
24661/**
24662 * The base implementation of `_.matches` which doesn't clone `source`.
24663 *
24664 * @private
24665 * @param {Object} source The object of property values to match.
24666 * @returns {Function} Returns the new spec function.
24667 */
24668function baseMatches(source) {
24669 var matchData = getMatchData(source);
24670 if (matchData.length == 1 && matchData[0][2]) {
24671 return matchesStrictComparable(matchData[0][0], matchData[0][1]);
24672 }
24673 return function(object) {
24674 return object === source || baseIsMatch(object, source, matchData);
24675 };
24676}
24677
24678module.exports = baseMatches;
24679
24680},{"./_baseIsMatch":191,"./_getMatchData":244,"./_matchesStrictComparable":281}],201:[function(require,module,exports){
24681var baseIsEqual = require('./_baseIsEqual'),
24682 get = require('./get'),
24683 hasIn = require('./hasIn'),
24684 isKey = require('./_isKey'),
24685 isStrictComparable = require('./_isStrictComparable'),
24686 matchesStrictComparable = require('./_matchesStrictComparable'),
24687 toKey = require('./_toKey');
24688
24689/** Used to compose bitmasks for value comparisons. */
24690var COMPARE_PARTIAL_FLAG = 1,
24691 COMPARE_UNORDERED_FLAG = 2;
24692
24693/**
24694 * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
24695 *
24696 * @private
24697 * @param {string} path The path of the property to get.
24698 * @param {*} srcValue The value to match.
24699 * @returns {Function} Returns the new spec function.
24700 */
24701function baseMatchesProperty(path, srcValue) {
24702 if (isKey(path) && isStrictComparable(srcValue)) {
24703 return matchesStrictComparable(toKey(path), srcValue);
24704 }
24705 return function(object) {
24706 var objValue = get(object, path);
24707 return (objValue === undefined && objValue === srcValue)
24708 ? hasIn(object, path)
24709 : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
24710 };
24711}
24712
24713module.exports = baseMatchesProperty;
24714
24715},{"./_baseIsEqual":188,"./_isKey":265,"./_isStrictComparable":269,"./_matchesStrictComparable":281,"./_toKey":305,"./get":319,"./hasIn":320}],202:[function(require,module,exports){
24716var basePickBy = require('./_basePickBy'),
24717 hasIn = require('./hasIn');
24718
24719/**
24720 * The base implementation of `_.pick` without support for individual
24721 * property identifiers.
24722 *
24723 * @private
24724 * @param {Object} object The source object.
24725 * @param {string[]} paths The property paths to pick.
24726 * @returns {Object} Returns the new object.
24727 */
24728function basePick(object, paths) {
24729 return basePickBy(object, paths, function(value, path) {
24730 return hasIn(object, path);
24731 });
24732}
24733
24734module.exports = basePick;
24735
24736},{"./_basePickBy":203,"./hasIn":320}],203:[function(require,module,exports){
24737var baseGet = require('./_baseGet'),
24738 baseSet = require('./_baseSet'),
24739 castPath = require('./_castPath');
24740
24741/**
24742 * The base implementation of `_.pickBy` without support for iteratee shorthands.
24743 *
24744 * @private
24745 * @param {Object} object The source object.
24746 * @param {string[]} paths The property paths to pick.
24747 * @param {Function} predicate The function invoked per property.
24748 * @returns {Object} Returns the new object.
24749 */
24750function basePickBy(object, paths, predicate) {
24751 var index = -1,
24752 length = paths.length,
24753 result = {};
24754
24755 while (++index < length) {
24756 var path = paths[index],
24757 value = baseGet(object, path);
24758
24759 if (predicate(value, path)) {
24760 baseSet(result, castPath(path, object), value);
24761 }
24762 }
24763 return result;
24764}
24765
24766module.exports = basePickBy;
24767
24768},{"./_baseGet":182,"./_baseSet":208,"./_castPath":217}],204:[function(require,module,exports){
24769/**
24770 * The base implementation of `_.property` without support for deep paths.
24771 *
24772 * @private
24773 * @param {string} key The key of the property to get.
24774 * @returns {Function} Returns the new accessor function.
24775 */
24776function baseProperty(key) {
24777 return function(object) {
24778 return object == null ? undefined : object[key];
24779 };
24780}
24781
24782module.exports = baseProperty;
24783
24784},{}],205:[function(require,module,exports){
24785var baseGet = require('./_baseGet');
24786
24787/**
24788 * A specialized version of `baseProperty` which supports deep paths.
24789 *
24790 * @private
24791 * @param {Array|string} path The path of the property to get.
24792 * @returns {Function} Returns the new accessor function.
24793 */
24794function basePropertyDeep(path) {
24795 return function(object) {
24796 return baseGet(object, path);
24797 };
24798}
24799
24800module.exports = basePropertyDeep;
24801
24802},{"./_baseGet":182}],206:[function(require,module,exports){
24803/** Used as references for various `Number` constants. */
24804var MAX_SAFE_INTEGER = 9007199254740991;
24805
24806/* Built-in method references for those with the same name as other `lodash` methods. */
24807var nativeFloor = Math.floor;
24808
24809/**
24810 * The base implementation of `_.repeat` which doesn't coerce arguments.
24811 *
24812 * @private
24813 * @param {string} string The string to repeat.
24814 * @param {number} n The number of times to repeat the string.
24815 * @returns {string} Returns the repeated string.
24816 */
24817function baseRepeat(string, n) {
24818 var result = '';
24819 if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
24820 return result;
24821 }
24822 // Leverage the exponentiation by squaring algorithm for a faster repeat.
24823 // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
24824 do {
24825 if (n % 2) {
24826 result += string;
24827 }
24828 n = nativeFloor(n / 2);
24829 if (n) {
24830 string += string;
24831 }
24832 } while (n);
24833
24834 return result;
24835}
24836
24837module.exports = baseRepeat;
24838
24839},{}],207:[function(require,module,exports){
24840var identity = require('./identity'),
24841 overRest = require('./_overRest'),
24842 setToString = require('./_setToString');
24843
24844/**
24845 * The base implementation of `_.rest` which doesn't validate or coerce arguments.
24846 *
24847 * @private
24848 * @param {Function} func The function to apply a rest parameter to.
24849 * @param {number} [start=func.length-1] The start position of the rest parameter.
24850 * @returns {Function} Returns the new function.
24851 */
24852function baseRest(func, start) {
24853 return setToString(overRest(func, start, identity), func + '');
24854}
24855
24856module.exports = baseRest;
24857
24858},{"./_overRest":289,"./_setToString":294,"./identity":321}],208:[function(require,module,exports){
24859var assignValue = require('./_assignValue'),
24860 castPath = require('./_castPath'),
24861 isIndex = require('./_isIndex'),
24862 isObject = require('./isObject'),
24863 toKey = require('./_toKey');
24864
24865/**
24866 * The base implementation of `_.set`.
24867 *
24868 * @private
24869 * @param {Object} object The object to modify.
24870 * @param {Array|string} path The path of the property to set.
24871 * @param {*} value The value to set.
24872 * @param {Function} [customizer] The function to customize path creation.
24873 * @returns {Object} Returns `object`.
24874 */
24875function baseSet(object, path, value, customizer) {
24876 if (!isObject(object)) {
24877 return object;
24878 }
24879 path = castPath(path, object);
24880
24881 var index = -1,
24882 length = path.length,
24883 lastIndex = length - 1,
24884 nested = object;
24885
24886 while (nested != null && ++index < length) {
24887 var key = toKey(path[index]),
24888 newValue = value;
24889
24890 if (index != lastIndex) {
24891 var objValue = nested[key];
24892 newValue = customizer ? customizer(objValue, key, nested) : undefined;
24893 if (newValue === undefined) {
24894 newValue = isObject(objValue)
24895 ? objValue
24896 : (isIndex(path[index + 1]) ? [] : {});
24897 }
24898 }
24899 assignValue(nested, key, newValue);
24900 nested = nested[key];
24901 }
24902 return object;
24903}
24904
24905module.exports = baseSet;
24906
24907},{"./_assignValue":169,"./_castPath":217,"./_isIndex":263,"./_toKey":305,"./isObject":333}],209:[function(require,module,exports){
24908var constant = require('./constant'),
24909 defineProperty = require('./_defineProperty'),
24910 identity = require('./identity');
24911
24912/**
24913 * The base implementation of `setToString` without support for hot loop shorting.
24914 *
24915 * @private
24916 * @param {Function} func The function to modify.
24917 * @param {Function} string The `toString` result.
24918 * @returns {Function} Returns `func`.
24919 */
24920var baseSetToString = !defineProperty ? identity : function(func, string) {
24921 return defineProperty(func, 'toString', {
24922 'configurable': true,
24923 'enumerable': false,
24924 'value': constant(string),
24925 'writable': true
24926 });
24927};
24928
24929module.exports = baseSetToString;
24930
24931},{"./_defineProperty":235,"./constant":311,"./identity":321}],210:[function(require,module,exports){
24932/**
24933 * The base implementation of `_.slice` without an iteratee call guard.
24934 *
24935 * @private
24936 * @param {Array} array The array to slice.
24937 * @param {number} [start=0] The start position.
24938 * @param {number} [end=array.length] The end position.
24939 * @returns {Array} Returns the slice of `array`.
24940 */
24941function baseSlice(array, start, end) {
24942 var index = -1,
24943 length = array.length;
24944
24945 if (start < 0) {
24946 start = -start > length ? 0 : (length + start);
24947 }
24948 end = end > length ? length : end;
24949 if (end < 0) {
24950 end += length;
24951 }
24952 length = start > end ? 0 : ((end - start) >>> 0);
24953 start >>>= 0;
24954
24955 var result = Array(length);
24956 while (++index < length) {
24957 result[index] = array[index + start];
24958 }
24959 return result;
24960}
24961
24962module.exports = baseSlice;
24963
24964},{}],211:[function(require,module,exports){
24965/**
24966 * The base implementation of `_.times` without support for iteratee shorthands
24967 * or max array length checks.
24968 *
24969 * @private
24970 * @param {number} n The number of times to invoke `iteratee`.
24971 * @param {Function} iteratee The function invoked per iteration.
24972 * @returns {Array} Returns the array of results.
24973 */
24974function baseTimes(n, iteratee) {
24975 var index = -1,
24976 result = Array(n);
24977
24978 while (++index < n) {
24979 result[index] = iteratee(index);
24980 }
24981 return result;
24982}
24983
24984module.exports = baseTimes;
24985
24986},{}],212:[function(require,module,exports){
24987var Symbol = require('./_Symbol'),
24988 arrayMap = require('./_arrayMap'),
24989 isArray = require('./isArray'),
24990 isSymbol = require('./isSymbol');
24991
24992/** Used as references for various `Number` constants. */
24993var INFINITY = 1 / 0;
24994
24995/** Used to convert symbols to primitives and strings. */
24996var symbolProto = Symbol ? Symbol.prototype : undefined,
24997 symbolToString = symbolProto ? symbolProto.toString : undefined;
24998
24999/**
25000 * The base implementation of `_.toString` which doesn't convert nullish
25001 * values to empty strings.
25002 *
25003 * @private
25004 * @param {*} value The value to process.
25005 * @returns {string} Returns the string.
25006 */
25007function baseToString(value) {
25008 // Exit early for strings to avoid a performance hit in some environments.
25009 if (typeof value == 'string') {
25010 return value;
25011 }
25012 if (isArray(value)) {
25013 // Recursively convert values (susceptible to call stack limits).
25014 return arrayMap(value, baseToString) + '';
25015 }
25016 if (isSymbol(value)) {
25017 return symbolToString ? symbolToString.call(value) : '';
25018 }
25019 var result = (value + '');
25020 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
25021}
25022
25023module.exports = baseToString;
25024
25025},{"./_Symbol":156,"./_arrayMap":164,"./isArray":323,"./isSymbol":338}],213:[function(require,module,exports){
25026/**
25027 * The base implementation of `_.unary` without support for storing metadata.
25028 *
25029 * @private
25030 * @param {Function} func The function to cap arguments for.
25031 * @returns {Function} Returns the new capped function.
25032 */
25033function baseUnary(func) {
25034 return function(value) {
25035 return func(value);
25036 };
25037}
25038
25039module.exports = baseUnary;
25040
25041},{}],214:[function(require,module,exports){
25042var arrayMap = require('./_arrayMap');
25043
25044/**
25045 * The base implementation of `_.values` and `_.valuesIn` which creates an
25046 * array of `object` property values corresponding to the property names
25047 * of `props`.
25048 *
25049 * @private
25050 * @param {Object} object The object to query.
25051 * @param {Array} props The property names to get values for.
25052 * @returns {Object} Returns the array of property values.
25053 */
25054function baseValues(object, props) {
25055 return arrayMap(props, function(key) {
25056 return object[key];
25057 });
25058}
25059
25060module.exports = baseValues;
25061
25062},{"./_arrayMap":164}],215:[function(require,module,exports){
25063/**
25064 * Checks if a `cache` value for `key` exists.
25065 *
25066 * @private
25067 * @param {Object} cache The cache to query.
25068 * @param {string} key The key of the entry to check.
25069 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
25070 */
25071function cacheHas(cache, key) {
25072 return cache.has(key);
25073}
25074
25075module.exports = cacheHas;
25076
25077},{}],216:[function(require,module,exports){
25078var identity = require('./identity');
25079
25080/**
25081 * Casts `value` to `identity` if it's not a function.
25082 *
25083 * @private
25084 * @param {*} value The value to inspect.
25085 * @returns {Function} Returns cast function.
25086 */
25087function castFunction(value) {
25088 return typeof value == 'function' ? value : identity;
25089}
25090
25091module.exports = castFunction;
25092
25093},{"./identity":321}],217:[function(require,module,exports){
25094var isArray = require('./isArray'),
25095 isKey = require('./_isKey'),
25096 stringToPath = require('./_stringToPath'),
25097 toString = require('./toString');
25098
25099/**
25100 * Casts `value` to a path array if it's not one.
25101 *
25102 * @private
25103 * @param {*} value The value to inspect.
25104 * @param {Object} [object] The object to query keys on.
25105 * @returns {Array} Returns the cast property path array.
25106 */
25107function castPath(value, object) {
25108 if (isArray(value)) {
25109 return value;
25110 }
25111 return isKey(value, object) ? [value] : stringToPath(toString(value));
25112}
25113
25114module.exports = castPath;
25115
25116},{"./_isKey":265,"./_stringToPath":304,"./isArray":323,"./toString":354}],218:[function(require,module,exports){
25117var baseSlice = require('./_baseSlice');
25118
25119/**
25120 * Casts `array` to a slice if it's needed.
25121 *
25122 * @private
25123 * @param {Array} array The array to inspect.
25124 * @param {number} start The start position.
25125 * @param {number} [end=array.length] The end position.
25126 * @returns {Array} Returns the cast slice.
25127 */
25128function castSlice(array, start, end) {
25129 var length = array.length;
25130 end = end === undefined ? length : end;
25131 return (!start && end >= length) ? array : baseSlice(array, start, end);
25132}
25133
25134module.exports = castSlice;
25135
25136},{"./_baseSlice":210}],219:[function(require,module,exports){
25137var baseIndexOf = require('./_baseIndexOf');
25138
25139/**
25140 * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
25141 * that is not found in the character symbols.
25142 *
25143 * @private
25144 * @param {Array} strSymbols The string symbols to inspect.
25145 * @param {Array} chrSymbols The character symbols to find.
25146 * @returns {number} Returns the index of the last unmatched string symbol.
25147 */
25148function charsEndIndex(strSymbols, chrSymbols) {
25149 var index = strSymbols.length;
25150
25151 while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
25152 return index;
25153}
25154
25155module.exports = charsEndIndex;
25156
25157},{"./_baseIndexOf":186}],220:[function(require,module,exports){
25158var Uint8Array = require('./_Uint8Array');
25159
25160/**
25161 * Creates a clone of `arrayBuffer`.
25162 *
25163 * @private
25164 * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
25165 * @returns {ArrayBuffer} Returns the cloned array buffer.
25166 */
25167function cloneArrayBuffer(arrayBuffer) {
25168 var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
25169 new Uint8Array(result).set(new Uint8Array(arrayBuffer));
25170 return result;
25171}
25172
25173module.exports = cloneArrayBuffer;
25174
25175},{"./_Uint8Array":157}],221:[function(require,module,exports){
25176var root = require('./_root');
25177
25178/** Detect free variable `exports`. */
25179var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
25180
25181/** Detect free variable `module`. */
25182var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
25183
25184/** Detect the popular CommonJS extension `module.exports`. */
25185var moduleExports = freeModule && freeModule.exports === freeExports;
25186
25187/** Built-in value references. */
25188var Buffer = moduleExports ? root.Buffer : undefined,
25189 allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined;
25190
25191/**
25192 * Creates a clone of `buffer`.
25193 *
25194 * @private
25195 * @param {Buffer} buffer The buffer to clone.
25196 * @param {boolean} [isDeep] Specify a deep clone.
25197 * @returns {Buffer} Returns the cloned buffer.
25198 */
25199function cloneBuffer(buffer, isDeep) {
25200 if (isDeep) {
25201 return buffer.slice();
25202 }
25203 var length = buffer.length,
25204 result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
25205
25206 buffer.copy(result);
25207 return result;
25208}
25209
25210module.exports = cloneBuffer;
25211
25212},{"./_root":290}],222:[function(require,module,exports){
25213var cloneArrayBuffer = require('./_cloneArrayBuffer');
25214
25215/**
25216 * Creates a clone of `dataView`.
25217 *
25218 * @private
25219 * @param {Object} dataView The data view to clone.
25220 * @param {boolean} [isDeep] Specify a deep clone.
25221 * @returns {Object} Returns the cloned data view.
25222 */
25223function cloneDataView(dataView, isDeep) {
25224 var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
25225 return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
25226}
25227
25228module.exports = cloneDataView;
25229
25230},{"./_cloneArrayBuffer":220}],223:[function(require,module,exports){
25231/** Used to match `RegExp` flags from their coerced string values. */
25232var reFlags = /\w*$/;
25233
25234/**
25235 * Creates a clone of `regexp`.
25236 *
25237 * @private
25238 * @param {Object} regexp The regexp to clone.
25239 * @returns {Object} Returns the cloned regexp.
25240 */
25241function cloneRegExp(regexp) {
25242 var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
25243 result.lastIndex = regexp.lastIndex;
25244 return result;
25245}
25246
25247module.exports = cloneRegExp;
25248
25249},{}],224:[function(require,module,exports){
25250var Symbol = require('./_Symbol');
25251
25252/** Used to convert symbols to primitives and strings. */
25253var symbolProto = Symbol ? Symbol.prototype : undefined,
25254 symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
25255
25256/**
25257 * Creates a clone of the `symbol` object.
25258 *
25259 * @private
25260 * @param {Object} symbol The symbol object to clone.
25261 * @returns {Object} Returns the cloned symbol object.
25262 */
25263function cloneSymbol(symbol) {
25264 return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
25265}
25266
25267module.exports = cloneSymbol;
25268
25269},{"./_Symbol":156}],225:[function(require,module,exports){
25270var cloneArrayBuffer = require('./_cloneArrayBuffer');
25271
25272/**
25273 * Creates a clone of `typedArray`.
25274 *
25275 * @private
25276 * @param {Object} typedArray The typed array to clone.
25277 * @param {boolean} [isDeep] Specify a deep clone.
25278 * @returns {Object} Returns the cloned typed array.
25279 */
25280function cloneTypedArray(typedArray, isDeep) {
25281 var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
25282 return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
25283}
25284
25285module.exports = cloneTypedArray;
25286
25287},{"./_cloneArrayBuffer":220}],226:[function(require,module,exports){
25288/**
25289 * Copies the values of `source` to `array`.
25290 *
25291 * @private
25292 * @param {Array} source The array to copy values from.
25293 * @param {Array} [array=[]] The array to copy values to.
25294 * @returns {Array} Returns `array`.
25295 */
25296function copyArray(source, array) {
25297 var index = -1,
25298 length = source.length;
25299
25300 array || (array = Array(length));
25301 while (++index < length) {
25302 array[index] = source[index];
25303 }
25304 return array;
25305}
25306
25307module.exports = copyArray;
25308
25309},{}],227:[function(require,module,exports){
25310var assignValue = require('./_assignValue'),
25311 baseAssignValue = require('./_baseAssignValue');
25312
25313/**
25314 * Copies properties of `source` to `object`.
25315 *
25316 * @private
25317 * @param {Object} source The object to copy properties from.
25318 * @param {Array} props The property identifiers to copy.
25319 * @param {Object} [object={}] The object to copy properties to.
25320 * @param {Function} [customizer] The function to customize copied values.
25321 * @returns {Object} Returns `object`.
25322 */
25323function copyObject(source, props, object, customizer) {
25324 var isNew = !object;
25325 object || (object = {});
25326
25327 var index = -1,
25328 length = props.length;
25329
25330 while (++index < length) {
25331 var key = props[index];
25332
25333 var newValue = customizer
25334 ? customizer(object[key], source[key], key, object, source)
25335 : undefined;
25336
25337 if (newValue === undefined) {
25338 newValue = source[key];
25339 }
25340 if (isNew) {
25341 baseAssignValue(object, key, newValue);
25342 } else {
25343 assignValue(object, key, newValue);
25344 }
25345 }
25346 return object;
25347}
25348
25349module.exports = copyObject;
25350
25351},{"./_assignValue":169,"./_baseAssignValue":173}],228:[function(require,module,exports){
25352var copyObject = require('./_copyObject'),
25353 getSymbols = require('./_getSymbols');
25354
25355/**
25356 * Copies own symbols of `source` to `object`.
25357 *
25358 * @private
25359 * @param {Object} source The object to copy symbols from.
25360 * @param {Object} [object={}] The object to copy symbols to.
25361 * @returns {Object} Returns `object`.
25362 */
25363function copySymbols(source, object) {
25364 return copyObject(source, getSymbols(source), object);
25365}
25366
25367module.exports = copySymbols;
25368
25369},{"./_copyObject":227,"./_getSymbols":248}],229:[function(require,module,exports){
25370var copyObject = require('./_copyObject'),
25371 getSymbolsIn = require('./_getSymbolsIn');
25372
25373/**
25374 * Copies own and inherited symbols of `source` to `object`.
25375 *
25376 * @private
25377 * @param {Object} source The object to copy symbols from.
25378 * @param {Object} [object={}] The object to copy symbols to.
25379 * @returns {Object} Returns `object`.
25380 */
25381function copySymbolsIn(source, object) {
25382 return copyObject(source, getSymbolsIn(source), object);
25383}
25384
25385module.exports = copySymbolsIn;
25386
25387},{"./_copyObject":227,"./_getSymbolsIn":249}],230:[function(require,module,exports){
25388var root = require('./_root');
25389
25390/** Used to detect overreaching core-js shims. */
25391var coreJsData = root['__core-js_shared__'];
25392
25393module.exports = coreJsData;
25394
25395},{"./_root":290}],231:[function(require,module,exports){
25396var baseRest = require('./_baseRest'),
25397 isIterateeCall = require('./_isIterateeCall');
25398
25399/**
25400 * Creates a function like `_.assign`.
25401 *
25402 * @private
25403 * @param {Function} assigner The function to assign values.
25404 * @returns {Function} Returns the new assigner function.
25405 */
25406function createAssigner(assigner) {
25407 return baseRest(function(object, sources) {
25408 var index = -1,
25409 length = sources.length,
25410 customizer = length > 1 ? sources[length - 1] : undefined,
25411 guard = length > 2 ? sources[2] : undefined;
25412
25413 customizer = (assigner.length > 3 && typeof customizer == 'function')
25414 ? (length--, customizer)
25415 : undefined;
25416
25417 if (guard && isIterateeCall(sources[0], sources[1], guard)) {
25418 customizer = length < 3 ? undefined : customizer;
25419 length = 1;
25420 }
25421 object = Object(object);
25422 while (++index < length) {
25423 var source = sources[index];
25424 if (source) {
25425 assigner(object, source, index, customizer);
25426 }
25427 }
25428 return object;
25429 });
25430}
25431
25432module.exports = createAssigner;
25433
25434},{"./_baseRest":207,"./_isIterateeCall":264}],232:[function(require,module,exports){
25435var isArrayLike = require('./isArrayLike');
25436
25437/**
25438 * Creates a `baseEach` or `baseEachRight` function.
25439 *
25440 * @private
25441 * @param {Function} eachFunc The function to iterate over a collection.
25442 * @param {boolean} [fromRight] Specify iterating from right to left.
25443 * @returns {Function} Returns the new base function.
25444 */
25445function createBaseEach(eachFunc, fromRight) {
25446 return function(collection, iteratee) {
25447 if (collection == null) {
25448 return collection;
25449 }
25450 if (!isArrayLike(collection)) {
25451 return eachFunc(collection, iteratee);
25452 }
25453 var length = collection.length,
25454 index = fromRight ? length : -1,
25455 iterable = Object(collection);
25456
25457 while ((fromRight ? index-- : ++index < length)) {
25458 if (iteratee(iterable[index], index, iterable) === false) {
25459 break;
25460 }
25461 }
25462 return collection;
25463 };
25464}
25465
25466module.exports = createBaseEach;
25467
25468},{"./isArrayLike":324}],233:[function(require,module,exports){
25469/**
25470 * Creates a base function for methods like `_.forIn` and `_.forOwn`.
25471 *
25472 * @private
25473 * @param {boolean} [fromRight] Specify iterating from right to left.
25474 * @returns {Function} Returns the new base function.
25475 */
25476function createBaseFor(fromRight) {
25477 return function(object, iteratee, keysFunc) {
25478 var index = -1,
25479 iterable = Object(object),
25480 props = keysFunc(object),
25481 length = props.length;
25482
25483 while (length--) {
25484 var key = props[fromRight ? length : ++index];
25485 if (iteratee(iterable[key], key, iterable) === false) {
25486 break;
25487 }
25488 }
25489 return object;
25490 };
25491}
25492
25493module.exports = createBaseFor;
25494
25495},{}],234:[function(require,module,exports){
25496var baseRepeat = require('./_baseRepeat'),
25497 baseToString = require('./_baseToString'),
25498 castSlice = require('./_castSlice'),
25499 hasUnicode = require('./_hasUnicode'),
25500 stringSize = require('./_stringSize'),
25501 stringToArray = require('./_stringToArray');
25502
25503/* Built-in method references for those with the same name as other `lodash` methods. */
25504var nativeCeil = Math.ceil;
25505
25506/**
25507 * Creates the padding for `string` based on `length`. The `chars` string
25508 * is truncated if the number of characters exceeds `length`.
25509 *
25510 * @private
25511 * @param {number} length The padding length.
25512 * @param {string} [chars=' '] The string used as padding.
25513 * @returns {string} Returns the padding for `string`.
25514 */
25515function createPadding(length, chars) {
25516 chars = chars === undefined ? ' ' : baseToString(chars);
25517
25518 var charsLength = chars.length;
25519 if (charsLength < 2) {
25520 return charsLength ? baseRepeat(chars, length) : chars;
25521 }
25522 var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
25523 return hasUnicode(chars)
25524 ? castSlice(stringToArray(result), 0, length).join('')
25525 : result.slice(0, length);
25526}
25527
25528module.exports = createPadding;
25529
25530},{"./_baseRepeat":206,"./_baseToString":212,"./_castSlice":218,"./_hasUnicode":253,"./_stringSize":302,"./_stringToArray":303}],235:[function(require,module,exports){
25531var getNative = require('./_getNative');
25532
25533var defineProperty = (function() {
25534 try {
25535 var func = getNative(Object, 'defineProperty');
25536 func({}, '', {});
25537 return func;
25538 } catch (e) {}
25539}());
25540
25541module.exports = defineProperty;
25542
25543},{"./_getNative":245}],236:[function(require,module,exports){
25544var SetCache = require('./_SetCache'),
25545 arraySome = require('./_arraySome'),
25546 cacheHas = require('./_cacheHas');
25547
25548/** Used to compose bitmasks for value comparisons. */
25549var COMPARE_PARTIAL_FLAG = 1,
25550 COMPARE_UNORDERED_FLAG = 2;
25551
25552/**
25553 * A specialized version of `baseIsEqualDeep` for arrays with support for
25554 * partial deep comparisons.
25555 *
25556 * @private
25557 * @param {Array} array The array to compare.
25558 * @param {Array} other The other array to compare.
25559 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
25560 * @param {Function} customizer The function to customize comparisons.
25561 * @param {Function} equalFunc The function to determine equivalents of values.
25562 * @param {Object} stack Tracks traversed `array` and `other` objects.
25563 * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
25564 */
25565function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
25566 var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
25567 arrLength = array.length,
25568 othLength = other.length;
25569
25570 if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
25571 return false;
25572 }
25573 // Assume cyclic values are equal.
25574 var stacked = stack.get(array);
25575 if (stacked && stack.get(other)) {
25576 return stacked == other;
25577 }
25578 var index = -1,
25579 result = true,
25580 seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
25581
25582 stack.set(array, other);
25583 stack.set(other, array);
25584
25585 // Ignore non-index properties.
25586 while (++index < arrLength) {
25587 var arrValue = array[index],
25588 othValue = other[index];
25589
25590 if (customizer) {
25591 var compared = isPartial
25592 ? customizer(othValue, arrValue, index, other, array, stack)
25593 : customizer(arrValue, othValue, index, array, other, stack);
25594 }
25595 if (compared !== undefined) {
25596 if (compared) {
25597 continue;
25598 }
25599 result = false;
25600 break;
25601 }
25602 // Recursively compare arrays (susceptible to call stack limits).
25603 if (seen) {
25604 if (!arraySome(other, function(othValue, othIndex) {
25605 if (!cacheHas(seen, othIndex) &&
25606 (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
25607 return seen.push(othIndex);
25608 }
25609 })) {
25610 result = false;
25611 break;
25612 }
25613 } else if (!(
25614 arrValue === othValue ||
25615 equalFunc(arrValue, othValue, bitmask, customizer, stack)
25616 )) {
25617 result = false;
25618 break;
25619 }
25620 }
25621 stack['delete'](array);
25622 stack['delete'](other);
25623 return result;
25624}
25625
25626module.exports = equalArrays;
25627
25628},{"./_SetCache":154,"./_arraySome":166,"./_cacheHas":215}],237:[function(require,module,exports){
25629var Symbol = require('./_Symbol'),
25630 Uint8Array = require('./_Uint8Array'),
25631 eq = require('./eq'),
25632 equalArrays = require('./_equalArrays'),
25633 mapToArray = require('./_mapToArray'),
25634 setToArray = require('./_setToArray');
25635
25636/** Used to compose bitmasks for value comparisons. */
25637var COMPARE_PARTIAL_FLAG = 1,
25638 COMPARE_UNORDERED_FLAG = 2;
25639
25640/** `Object#toString` result references. */
25641var boolTag = '[object Boolean]',
25642 dateTag = '[object Date]',
25643 errorTag = '[object Error]',
25644 mapTag = '[object Map]',
25645 numberTag = '[object Number]',
25646 regexpTag = '[object RegExp]',
25647 setTag = '[object Set]',
25648 stringTag = '[object String]',
25649 symbolTag = '[object Symbol]';
25650
25651var arrayBufferTag = '[object ArrayBuffer]',
25652 dataViewTag = '[object DataView]';
25653
25654/** Used to convert symbols to primitives and strings. */
25655var symbolProto = Symbol ? Symbol.prototype : undefined,
25656 symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
25657
25658/**
25659 * A specialized version of `baseIsEqualDeep` for comparing objects of
25660 * the same `toStringTag`.
25661 *
25662 * **Note:** This function only supports comparing values with tags of
25663 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
25664 *
25665 * @private
25666 * @param {Object} object The object to compare.
25667 * @param {Object} other The other object to compare.
25668 * @param {string} tag The `toStringTag` of the objects to compare.
25669 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
25670 * @param {Function} customizer The function to customize comparisons.
25671 * @param {Function} equalFunc The function to determine equivalents of values.
25672 * @param {Object} stack Tracks traversed `object` and `other` objects.
25673 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
25674 */
25675function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
25676 switch (tag) {
25677 case dataViewTag:
25678 if ((object.byteLength != other.byteLength) ||
25679 (object.byteOffset != other.byteOffset)) {
25680 return false;
25681 }
25682 object = object.buffer;
25683 other = other.buffer;
25684
25685 case arrayBufferTag:
25686 if ((object.byteLength != other.byteLength) ||
25687 !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
25688 return false;
25689 }
25690 return true;
25691
25692 case boolTag:
25693 case dateTag:
25694 case numberTag:
25695 // Coerce booleans to `1` or `0` and dates to milliseconds.
25696 // Invalid dates are coerced to `NaN`.
25697 return eq(+object, +other);
25698
25699 case errorTag:
25700 return object.name == other.name && object.message == other.message;
25701
25702 case regexpTag:
25703 case stringTag:
25704 // Coerce regexes to strings and treat strings, primitives and objects,
25705 // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
25706 // for more details.
25707 return object == (other + '');
25708
25709 case mapTag:
25710 var convert = mapToArray;
25711
25712 case setTag:
25713 var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
25714 convert || (convert = setToArray);
25715
25716 if (object.size != other.size && !isPartial) {
25717 return false;
25718 }
25719 // Assume cyclic values are equal.
25720 var stacked = stack.get(object);
25721 if (stacked) {
25722 return stacked == other;
25723 }
25724 bitmask |= COMPARE_UNORDERED_FLAG;
25725
25726 // Recursively compare objects (susceptible to call stack limits).
25727 stack.set(object, other);
25728 var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
25729 stack['delete'](object);
25730 return result;
25731
25732 case symbolTag:
25733 if (symbolValueOf) {
25734 return symbolValueOf.call(object) == symbolValueOf.call(other);
25735 }
25736 }
25737 return false;
25738}
25739
25740module.exports = equalByTag;
25741
25742},{"./_Symbol":156,"./_Uint8Array":157,"./_equalArrays":236,"./_mapToArray":280,"./_setToArray":293,"./eq":313}],238:[function(require,module,exports){
25743var getAllKeys = require('./_getAllKeys');
25744
25745/** Used to compose bitmasks for value comparisons. */
25746var COMPARE_PARTIAL_FLAG = 1;
25747
25748/** Used for built-in method references. */
25749var objectProto = Object.prototype;
25750
25751/** Used to check objects for own properties. */
25752var hasOwnProperty = objectProto.hasOwnProperty;
25753
25754/**
25755 * A specialized version of `baseIsEqualDeep` for objects with support for
25756 * partial deep comparisons.
25757 *
25758 * @private
25759 * @param {Object} object The object to compare.
25760 * @param {Object} other The other object to compare.
25761 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
25762 * @param {Function} customizer The function to customize comparisons.
25763 * @param {Function} equalFunc The function to determine equivalents of values.
25764 * @param {Object} stack Tracks traversed `object` and `other` objects.
25765 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
25766 */
25767function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
25768 var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
25769 objProps = getAllKeys(object),
25770 objLength = objProps.length,
25771 othProps = getAllKeys(other),
25772 othLength = othProps.length;
25773
25774 if (objLength != othLength && !isPartial) {
25775 return false;
25776 }
25777 var index = objLength;
25778 while (index--) {
25779 var key = objProps[index];
25780 if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
25781 return false;
25782 }
25783 }
25784 // Assume cyclic values are equal.
25785 var stacked = stack.get(object);
25786 if (stacked && stack.get(other)) {
25787 return stacked == other;
25788 }
25789 var result = true;
25790 stack.set(object, other);
25791 stack.set(other, object);
25792
25793 var skipCtor = isPartial;
25794 while (++index < objLength) {
25795 key = objProps[index];
25796 var objValue = object[key],
25797 othValue = other[key];
25798
25799 if (customizer) {
25800 var compared = isPartial
25801 ? customizer(othValue, objValue, key, other, object, stack)
25802 : customizer(objValue, othValue, key, object, other, stack);
25803 }
25804 // Recursively compare objects (susceptible to call stack limits).
25805 if (!(compared === undefined
25806 ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
25807 : compared
25808 )) {
25809 result = false;
25810 break;
25811 }
25812 skipCtor || (skipCtor = key == 'constructor');
25813 }
25814 if (result && !skipCtor) {
25815 var objCtor = object.constructor,
25816 othCtor = other.constructor;
25817
25818 // Non `Object` object instances with different constructors are not equal.
25819 if (objCtor != othCtor &&
25820 ('constructor' in object && 'constructor' in other) &&
25821 !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
25822 typeof othCtor == 'function' && othCtor instanceof othCtor)) {
25823 result = false;
25824 }
25825 }
25826 stack['delete'](object);
25827 stack['delete'](other);
25828 return result;
25829}
25830
25831module.exports = equalObjects;
25832
25833},{"./_getAllKeys":241}],239:[function(require,module,exports){
25834var flatten = require('./flatten'),
25835 overRest = require('./_overRest'),
25836 setToString = require('./_setToString');
25837
25838/**
25839 * A specialized version of `baseRest` which flattens the rest array.
25840 *
25841 * @private
25842 * @param {Function} func The function to apply a rest parameter to.
25843 * @returns {Function} Returns the new function.
25844 */
25845function flatRest(func) {
25846 return setToString(overRest(func, undefined, flatten), func + '');
25847}
25848
25849module.exports = flatRest;
25850
25851},{"./_overRest":289,"./_setToString":294,"./flatten":316}],240:[function(require,module,exports){
25852(function (global){
25853/** Detect free variable `global` from Node.js. */
25854var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
25855
25856module.exports = freeGlobal;
25857
25858}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
25859},{}],241:[function(require,module,exports){
25860var baseGetAllKeys = require('./_baseGetAllKeys'),
25861 getSymbols = require('./_getSymbols'),
25862 keys = require('./keys');
25863
25864/**
25865 * Creates an array of own enumerable property names and symbols of `object`.
25866 *
25867 * @private
25868 * @param {Object} object The object to query.
25869 * @returns {Array} Returns the array of property names and symbols.
25870 */
25871function getAllKeys(object) {
25872 return baseGetAllKeys(object, keys, getSymbols);
25873}
25874
25875module.exports = getAllKeys;
25876
25877},{"./_baseGetAllKeys":183,"./_getSymbols":248,"./keys":341}],242:[function(require,module,exports){
25878var baseGetAllKeys = require('./_baseGetAllKeys'),
25879 getSymbolsIn = require('./_getSymbolsIn'),
25880 keysIn = require('./keysIn');
25881
25882/**
25883 * Creates an array of own and inherited enumerable property names and
25884 * symbols of `object`.
25885 *
25886 * @private
25887 * @param {Object} object The object to query.
25888 * @returns {Array} Returns the array of property names and symbols.
25889 */
25890function getAllKeysIn(object) {
25891 return baseGetAllKeys(object, keysIn, getSymbolsIn);
25892}
25893
25894module.exports = getAllKeysIn;
25895
25896},{"./_baseGetAllKeys":183,"./_getSymbolsIn":249,"./keysIn":342}],243:[function(require,module,exports){
25897var isKeyable = require('./_isKeyable');
25898
25899/**
25900 * Gets the data for `map`.
25901 *
25902 * @private
25903 * @param {Object} map The map to query.
25904 * @param {string} key The reference key.
25905 * @returns {*} Returns the map data.
25906 */
25907function getMapData(map, key) {
25908 var data = map.__data__;
25909 return isKeyable(key)
25910 ? data[typeof key == 'string' ? 'string' : 'hash']
25911 : data.map;
25912}
25913
25914module.exports = getMapData;
25915
25916},{"./_isKeyable":266}],244:[function(require,module,exports){
25917var isStrictComparable = require('./_isStrictComparable'),
25918 keys = require('./keys');
25919
25920/**
25921 * Gets the property names, values, and compare flags of `object`.
25922 *
25923 * @private
25924 * @param {Object} object The object to query.
25925 * @returns {Array} Returns the match data of `object`.
25926 */
25927function getMatchData(object) {
25928 var result = keys(object),
25929 length = result.length;
25930
25931 while (length--) {
25932 var key = result[length],
25933 value = object[key];
25934
25935 result[length] = [key, value, isStrictComparable(value)];
25936 }
25937 return result;
25938}
25939
25940module.exports = getMatchData;
25941
25942},{"./_isStrictComparable":269,"./keys":341}],245:[function(require,module,exports){
25943var baseIsNative = require('./_baseIsNative'),
25944 getValue = require('./_getValue');
25945
25946/**
25947 * Gets the native function at `key` of `object`.
25948 *
25949 * @private
25950 * @param {Object} object The object to query.
25951 * @param {string} key The key of the method to get.
25952 * @returns {*} Returns the function if it's native, else `undefined`.
25953 */
25954function getNative(object, key) {
25955 var value = getValue(object, key);
25956 return baseIsNative(value) ? value : undefined;
25957}
25958
25959module.exports = getNative;
25960
25961},{"./_baseIsNative":193,"./_getValue":251}],246:[function(require,module,exports){
25962var overArg = require('./_overArg');
25963
25964/** Built-in value references. */
25965var getPrototype = overArg(Object.getPrototypeOf, Object);
25966
25967module.exports = getPrototype;
25968
25969},{"./_overArg":288}],247:[function(require,module,exports){
25970var Symbol = require('./_Symbol');
25971
25972/** Used for built-in method references. */
25973var objectProto = Object.prototype;
25974
25975/** Used to check objects for own properties. */
25976var hasOwnProperty = objectProto.hasOwnProperty;
25977
25978/**
25979 * Used to resolve the
25980 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
25981 * of values.
25982 */
25983var nativeObjectToString = objectProto.toString;
25984
25985/** Built-in value references. */
25986var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
25987
25988/**
25989 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
25990 *
25991 * @private
25992 * @param {*} value The value to query.
25993 * @returns {string} Returns the raw `toStringTag`.
25994 */
25995function getRawTag(value) {
25996 var isOwn = hasOwnProperty.call(value, symToStringTag),
25997 tag = value[symToStringTag];
25998
25999 try {
26000 value[symToStringTag] = undefined;
26001 var unmasked = true;
26002 } catch (e) {}
26003
26004 var result = nativeObjectToString.call(value);
26005 if (unmasked) {
26006 if (isOwn) {
26007 value[symToStringTag] = tag;
26008 } else {
26009 delete value[symToStringTag];
26010 }
26011 }
26012 return result;
26013}
26014
26015module.exports = getRawTag;
26016
26017},{"./_Symbol":156}],248:[function(require,module,exports){
26018var arrayFilter = require('./_arrayFilter'),
26019 stubArray = require('./stubArray');
26020
26021/** Used for built-in method references. */
26022var objectProto = Object.prototype;
26023
26024/** Built-in value references. */
26025var propertyIsEnumerable = objectProto.propertyIsEnumerable;
26026
26027/* Built-in method references for those with the same name as other `lodash` methods. */
26028var nativeGetSymbols = Object.getOwnPropertySymbols;
26029
26030/**
26031 * Creates an array of the own enumerable symbols of `object`.
26032 *
26033 * @private
26034 * @param {Object} object The object to query.
26035 * @returns {Array} Returns the array of symbols.
26036 */
26037var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
26038 if (object == null) {
26039 return [];
26040 }
26041 object = Object(object);
26042 return arrayFilter(nativeGetSymbols(object), function(symbol) {
26043 return propertyIsEnumerable.call(object, symbol);
26044 });
26045};
26046
26047module.exports = getSymbols;
26048
26049},{"./_arrayFilter":162,"./stubArray":348}],249:[function(require,module,exports){
26050var arrayPush = require('./_arrayPush'),
26051 getPrototype = require('./_getPrototype'),
26052 getSymbols = require('./_getSymbols'),
26053 stubArray = require('./stubArray');
26054
26055/* Built-in method references for those with the same name as other `lodash` methods. */
26056var nativeGetSymbols = Object.getOwnPropertySymbols;
26057
26058/**
26059 * Creates an array of the own and inherited enumerable symbols of `object`.
26060 *
26061 * @private
26062 * @param {Object} object The object to query.
26063 * @returns {Array} Returns the array of symbols.
26064 */
26065var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
26066 var result = [];
26067 while (object) {
26068 arrayPush(result, getSymbols(object));
26069 object = getPrototype(object);
26070 }
26071 return result;
26072};
26073
26074module.exports = getSymbolsIn;
26075
26076},{"./_arrayPush":165,"./_getPrototype":246,"./_getSymbols":248,"./stubArray":348}],250:[function(require,module,exports){
26077var DataView = require('./_DataView'),
26078 Map = require('./_Map'),
26079 Promise = require('./_Promise'),
26080 Set = require('./_Set'),
26081 WeakMap = require('./_WeakMap'),
26082 baseGetTag = require('./_baseGetTag'),
26083 toSource = require('./_toSource');
26084
26085/** `Object#toString` result references. */
26086var mapTag = '[object Map]',
26087 objectTag = '[object Object]',
26088 promiseTag = '[object Promise]',
26089 setTag = '[object Set]',
26090 weakMapTag = '[object WeakMap]';
26091
26092var dataViewTag = '[object DataView]';
26093
26094/** Used to detect maps, sets, and weakmaps. */
26095var dataViewCtorString = toSource(DataView),
26096 mapCtorString = toSource(Map),
26097 promiseCtorString = toSource(Promise),
26098 setCtorString = toSource(Set),
26099 weakMapCtorString = toSource(WeakMap);
26100
26101/**
26102 * Gets the `toStringTag` of `value`.
26103 *
26104 * @private
26105 * @param {*} value The value to query.
26106 * @returns {string} Returns the `toStringTag`.
26107 */
26108var getTag = baseGetTag;
26109
26110// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
26111if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
26112 (Map && getTag(new Map) != mapTag) ||
26113 (Promise && getTag(Promise.resolve()) != promiseTag) ||
26114 (Set && getTag(new Set) != setTag) ||
26115 (WeakMap && getTag(new WeakMap) != weakMapTag)) {
26116 getTag = function(value) {
26117 var result = baseGetTag(value),
26118 Ctor = result == objectTag ? value.constructor : undefined,
26119 ctorString = Ctor ? toSource(Ctor) : '';
26120
26121 if (ctorString) {
26122 switch (ctorString) {
26123 case dataViewCtorString: return dataViewTag;
26124 case mapCtorString: return mapTag;
26125 case promiseCtorString: return promiseTag;
26126 case setCtorString: return setTag;
26127 case weakMapCtorString: return weakMapTag;
26128 }
26129 }
26130 return result;
26131 };
26132}
26133
26134module.exports = getTag;
26135
26136},{"./_DataView":147,"./_Map":150,"./_Promise":152,"./_Set":153,"./_WeakMap":158,"./_baseGetTag":184,"./_toSource":306}],251:[function(require,module,exports){
26137/**
26138 * Gets the value at `key` of `object`.
26139 *
26140 * @private
26141 * @param {Object} [object] The object to query.
26142 * @param {string} key The key of the property to get.
26143 * @returns {*} Returns the property value.
26144 */
26145function getValue(object, key) {
26146 return object == null ? undefined : object[key];
26147}
26148
26149module.exports = getValue;
26150
26151},{}],252:[function(require,module,exports){
26152var castPath = require('./_castPath'),
26153 isArguments = require('./isArguments'),
26154 isArray = require('./isArray'),
26155 isIndex = require('./_isIndex'),
26156 isLength = require('./isLength'),
26157 toKey = require('./_toKey');
26158
26159/**
26160 * Checks if `path` exists on `object`.
26161 *
26162 * @private
26163 * @param {Object} object The object to query.
26164 * @param {Array|string} path The path to check.
26165 * @param {Function} hasFunc The function to check properties.
26166 * @returns {boolean} Returns `true` if `path` exists, else `false`.
26167 */
26168function hasPath(object, path, hasFunc) {
26169 path = castPath(path, object);
26170
26171 var index = -1,
26172 length = path.length,
26173 result = false;
26174
26175 while (++index < length) {
26176 var key = toKey(path[index]);
26177 if (!(result = object != null && hasFunc(object, key))) {
26178 break;
26179 }
26180 object = object[key];
26181 }
26182 if (result || ++index != length) {
26183 return result;
26184 }
26185 length = object == null ? 0 : object.length;
26186 return !!length && isLength(length) && isIndex(key, length) &&
26187 (isArray(object) || isArguments(object));
26188}
26189
26190module.exports = hasPath;
26191
26192},{"./_castPath":217,"./_isIndex":263,"./_toKey":305,"./isArguments":322,"./isArray":323,"./isLength":329}],253:[function(require,module,exports){
26193/** Used to compose unicode character classes. */
26194var rsAstralRange = '\\ud800-\\udfff',
26195 rsComboMarksRange = '\\u0300-\\u036f',
26196 reComboHalfMarksRange = '\\ufe20-\\ufe2f',
26197 rsComboSymbolsRange = '\\u20d0-\\u20ff',
26198 rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
26199 rsVarRange = '\\ufe0e\\ufe0f';
26200
26201/** Used to compose unicode capture groups. */
26202var rsZWJ = '\\u200d';
26203
26204/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
26205var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
26206
26207/**
26208 * Checks if `string` contains Unicode symbols.
26209 *
26210 * @private
26211 * @param {string} string The string to inspect.
26212 * @returns {boolean} Returns `true` if a symbol is found, else `false`.
26213 */
26214function hasUnicode(string) {
26215 return reHasUnicode.test(string);
26216}
26217
26218module.exports = hasUnicode;
26219
26220},{}],254:[function(require,module,exports){
26221var nativeCreate = require('./_nativeCreate');
26222
26223/**
26224 * Removes all key-value entries from the hash.
26225 *
26226 * @private
26227 * @name clear
26228 * @memberOf Hash
26229 */
26230function hashClear() {
26231 this.__data__ = nativeCreate ? nativeCreate(null) : {};
26232 this.size = 0;
26233}
26234
26235module.exports = hashClear;
26236
26237},{"./_nativeCreate":283}],255:[function(require,module,exports){
26238/**
26239 * Removes `key` and its value from the hash.
26240 *
26241 * @private
26242 * @name delete
26243 * @memberOf Hash
26244 * @param {Object} hash The hash to modify.
26245 * @param {string} key The key of the value to remove.
26246 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
26247 */
26248function hashDelete(key) {
26249 var result = this.has(key) && delete this.__data__[key];
26250 this.size -= result ? 1 : 0;
26251 return result;
26252}
26253
26254module.exports = hashDelete;
26255
26256},{}],256:[function(require,module,exports){
26257var nativeCreate = require('./_nativeCreate');
26258
26259/** Used to stand-in for `undefined` hash values. */
26260var HASH_UNDEFINED = '__lodash_hash_undefined__';
26261
26262/** Used for built-in method references. */
26263var objectProto = Object.prototype;
26264
26265/** Used to check objects for own properties. */
26266var hasOwnProperty = objectProto.hasOwnProperty;
26267
26268/**
26269 * Gets the hash value for `key`.
26270 *
26271 * @private
26272 * @name get
26273 * @memberOf Hash
26274 * @param {string} key The key of the value to get.
26275 * @returns {*} Returns the entry value.
26276 */
26277function hashGet(key) {
26278 var data = this.__data__;
26279 if (nativeCreate) {
26280 var result = data[key];
26281 return result === HASH_UNDEFINED ? undefined : result;
26282 }
26283 return hasOwnProperty.call(data, key) ? data[key] : undefined;
26284}
26285
26286module.exports = hashGet;
26287
26288},{"./_nativeCreate":283}],257:[function(require,module,exports){
26289var nativeCreate = require('./_nativeCreate');
26290
26291/** Used for built-in method references. */
26292var objectProto = Object.prototype;
26293
26294/** Used to check objects for own properties. */
26295var hasOwnProperty = objectProto.hasOwnProperty;
26296
26297/**
26298 * Checks if a hash value for `key` exists.
26299 *
26300 * @private
26301 * @name has
26302 * @memberOf Hash
26303 * @param {string} key The key of the entry to check.
26304 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
26305 */
26306function hashHas(key) {
26307 var data = this.__data__;
26308 return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
26309}
26310
26311module.exports = hashHas;
26312
26313},{"./_nativeCreate":283}],258:[function(require,module,exports){
26314var nativeCreate = require('./_nativeCreate');
26315
26316/** Used to stand-in for `undefined` hash values. */
26317var HASH_UNDEFINED = '__lodash_hash_undefined__';
26318
26319/**
26320 * Sets the hash `key` to `value`.
26321 *
26322 * @private
26323 * @name set
26324 * @memberOf Hash
26325 * @param {string} key The key of the value to set.
26326 * @param {*} value The value to set.
26327 * @returns {Object} Returns the hash instance.
26328 */
26329function hashSet(key, value) {
26330 var data = this.__data__;
26331 this.size += this.has(key) ? 0 : 1;
26332 data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
26333 return this;
26334}
26335
26336module.exports = hashSet;
26337
26338},{"./_nativeCreate":283}],259:[function(require,module,exports){
26339/** Used for built-in method references. */
26340var objectProto = Object.prototype;
26341
26342/** Used to check objects for own properties. */
26343var hasOwnProperty = objectProto.hasOwnProperty;
26344
26345/**
26346 * Initializes an array clone.
26347 *
26348 * @private
26349 * @param {Array} array The array to clone.
26350 * @returns {Array} Returns the initialized clone.
26351 */
26352function initCloneArray(array) {
26353 var length = array.length,
26354 result = new array.constructor(length);
26355
26356 // Add properties assigned by `RegExp#exec`.
26357 if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
26358 result.index = array.index;
26359 result.input = array.input;
26360 }
26361 return result;
26362}
26363
26364module.exports = initCloneArray;
26365
26366},{}],260:[function(require,module,exports){
26367var cloneArrayBuffer = require('./_cloneArrayBuffer'),
26368 cloneDataView = require('./_cloneDataView'),
26369 cloneRegExp = require('./_cloneRegExp'),
26370 cloneSymbol = require('./_cloneSymbol'),
26371 cloneTypedArray = require('./_cloneTypedArray');
26372
26373/** `Object#toString` result references. */
26374var boolTag = '[object Boolean]',
26375 dateTag = '[object Date]',
26376 mapTag = '[object Map]',
26377 numberTag = '[object Number]',
26378 regexpTag = '[object RegExp]',
26379 setTag = '[object Set]',
26380 stringTag = '[object String]',
26381 symbolTag = '[object Symbol]';
26382
26383var arrayBufferTag = '[object ArrayBuffer]',
26384 dataViewTag = '[object DataView]',
26385 float32Tag = '[object Float32Array]',
26386 float64Tag = '[object Float64Array]',
26387 int8Tag = '[object Int8Array]',
26388 int16Tag = '[object Int16Array]',
26389 int32Tag = '[object Int32Array]',
26390 uint8Tag = '[object Uint8Array]',
26391 uint8ClampedTag = '[object Uint8ClampedArray]',
26392 uint16Tag = '[object Uint16Array]',
26393 uint32Tag = '[object Uint32Array]';
26394
26395/**
26396 * Initializes an object clone based on its `toStringTag`.
26397 *
26398 * **Note:** This function only supports cloning values with tags of
26399 * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
26400 *
26401 * @private
26402 * @param {Object} object The object to clone.
26403 * @param {string} tag The `toStringTag` of the object to clone.
26404 * @param {boolean} [isDeep] Specify a deep clone.
26405 * @returns {Object} Returns the initialized clone.
26406 */
26407function initCloneByTag(object, tag, isDeep) {
26408 var Ctor = object.constructor;
26409 switch (tag) {
26410 case arrayBufferTag:
26411 return cloneArrayBuffer(object);
26412
26413 case boolTag:
26414 case dateTag:
26415 return new Ctor(+object);
26416
26417 case dataViewTag:
26418 return cloneDataView(object, isDeep);
26419
26420 case float32Tag: case float64Tag:
26421 case int8Tag: case int16Tag: case int32Tag:
26422 case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
26423 return cloneTypedArray(object, isDeep);
26424
26425 case mapTag:
26426 return new Ctor;
26427
26428 case numberTag:
26429 case stringTag:
26430 return new Ctor(object);
26431
26432 case regexpTag:
26433 return cloneRegExp(object);
26434
26435 case setTag:
26436 return new Ctor;
26437
26438 case symbolTag:
26439 return cloneSymbol(object);
26440 }
26441}
26442
26443module.exports = initCloneByTag;
26444
26445},{"./_cloneArrayBuffer":220,"./_cloneDataView":222,"./_cloneRegExp":223,"./_cloneSymbol":224,"./_cloneTypedArray":225}],261:[function(require,module,exports){
26446var baseCreate = require('./_baseCreate'),
26447 getPrototype = require('./_getPrototype'),
26448 isPrototype = require('./_isPrototype');
26449
26450/**
26451 * Initializes an object clone.
26452 *
26453 * @private
26454 * @param {Object} object The object to clone.
26455 * @returns {Object} Returns the initialized clone.
26456 */
26457function initCloneObject(object) {
26458 return (typeof object.constructor == 'function' && !isPrototype(object))
26459 ? baseCreate(getPrototype(object))
26460 : {};
26461}
26462
26463module.exports = initCloneObject;
26464
26465},{"./_baseCreate":175,"./_getPrototype":246,"./_isPrototype":268}],262:[function(require,module,exports){
26466var Symbol = require('./_Symbol'),
26467 isArguments = require('./isArguments'),
26468 isArray = require('./isArray');
26469
26470/** Built-in value references. */
26471var spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined;
26472
26473/**
26474 * Checks if `value` is a flattenable `arguments` object or array.
26475 *
26476 * @private
26477 * @param {*} value The value to check.
26478 * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
26479 */
26480function isFlattenable(value) {
26481 return isArray(value) || isArguments(value) ||
26482 !!(spreadableSymbol && value && value[spreadableSymbol]);
26483}
26484
26485module.exports = isFlattenable;
26486
26487},{"./_Symbol":156,"./isArguments":322,"./isArray":323}],263:[function(require,module,exports){
26488/** Used as references for various `Number` constants. */
26489var MAX_SAFE_INTEGER = 9007199254740991;
26490
26491/** Used to detect unsigned integer values. */
26492var reIsUint = /^(?:0|[1-9]\d*)$/;
26493
26494/**
26495 * Checks if `value` is a valid array-like index.
26496 *
26497 * @private
26498 * @param {*} value The value to check.
26499 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
26500 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
26501 */
26502function isIndex(value, length) {
26503 var type = typeof value;
26504 length = length == null ? MAX_SAFE_INTEGER : length;
26505
26506 return !!length &&
26507 (type == 'number' ||
26508 (type != 'symbol' && reIsUint.test(value))) &&
26509 (value > -1 && value % 1 == 0 && value < length);
26510}
26511
26512module.exports = isIndex;
26513
26514},{}],264:[function(require,module,exports){
26515var eq = require('./eq'),
26516 isArrayLike = require('./isArrayLike'),
26517 isIndex = require('./_isIndex'),
26518 isObject = require('./isObject');
26519
26520/**
26521 * Checks if the given arguments are from an iteratee call.
26522 *
26523 * @private
26524 * @param {*} value The potential iteratee value argument.
26525 * @param {*} index The potential iteratee index or key argument.
26526 * @param {*} object The potential iteratee object argument.
26527 * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
26528 * else `false`.
26529 */
26530function isIterateeCall(value, index, object) {
26531 if (!isObject(object)) {
26532 return false;
26533 }
26534 var type = typeof index;
26535 if (type == 'number'
26536 ? (isArrayLike(object) && isIndex(index, object.length))
26537 : (type == 'string' && index in object)
26538 ) {
26539 return eq(object[index], value);
26540 }
26541 return false;
26542}
26543
26544module.exports = isIterateeCall;
26545
26546},{"./_isIndex":263,"./eq":313,"./isArrayLike":324,"./isObject":333}],265:[function(require,module,exports){
26547var isArray = require('./isArray'),
26548 isSymbol = require('./isSymbol');
26549
26550/** Used to match property names within property paths. */
26551var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
26552 reIsPlainProp = /^\w*$/;
26553
26554/**
26555 * Checks if `value` is a property name and not a property path.
26556 *
26557 * @private
26558 * @param {*} value The value to check.
26559 * @param {Object} [object] The object to query keys on.
26560 * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
26561 */
26562function isKey(value, object) {
26563 if (isArray(value)) {
26564 return false;
26565 }
26566 var type = typeof value;
26567 if (type == 'number' || type == 'symbol' || type == 'boolean' ||
26568 value == null || isSymbol(value)) {
26569 return true;
26570 }
26571 return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
26572 (object != null && value in Object(object));
26573}
26574
26575module.exports = isKey;
26576
26577},{"./isArray":323,"./isSymbol":338}],266:[function(require,module,exports){
26578/**
26579 * Checks if `value` is suitable for use as unique object key.
26580 *
26581 * @private
26582 * @param {*} value The value to check.
26583 * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
26584 */
26585function isKeyable(value) {
26586 var type = typeof value;
26587 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
26588 ? (value !== '__proto__')
26589 : (value === null);
26590}
26591
26592module.exports = isKeyable;
26593
26594},{}],267:[function(require,module,exports){
26595var coreJsData = require('./_coreJsData');
26596
26597/** Used to detect methods masquerading as native. */
26598var maskSrcKey = (function() {
26599 var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
26600 return uid ? ('Symbol(src)_1.' + uid) : '';
26601}());
26602
26603/**
26604 * Checks if `func` has its source masked.
26605 *
26606 * @private
26607 * @param {Function} func The function to check.
26608 * @returns {boolean} Returns `true` if `func` is masked, else `false`.
26609 */
26610function isMasked(func) {
26611 return !!maskSrcKey && (maskSrcKey in func);
26612}
26613
26614module.exports = isMasked;
26615
26616},{"./_coreJsData":230}],268:[function(require,module,exports){
26617/** Used for built-in method references. */
26618var objectProto = Object.prototype;
26619
26620/**
26621 * Checks if `value` is likely a prototype object.
26622 *
26623 * @private
26624 * @param {*} value The value to check.
26625 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
26626 */
26627function isPrototype(value) {
26628 var Ctor = value && value.constructor,
26629 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
26630
26631 return value === proto;
26632}
26633
26634module.exports = isPrototype;
26635
26636},{}],269:[function(require,module,exports){
26637var isObject = require('./isObject');
26638
26639/**
26640 * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
26641 *
26642 * @private
26643 * @param {*} value The value to check.
26644 * @returns {boolean} Returns `true` if `value` if suitable for strict
26645 * equality comparisons, else `false`.
26646 */
26647function isStrictComparable(value) {
26648 return value === value && !isObject(value);
26649}
26650
26651module.exports = isStrictComparable;
26652
26653},{"./isObject":333}],270:[function(require,module,exports){
26654/**
26655 * Removes all key-value entries from the list cache.
26656 *
26657 * @private
26658 * @name clear
26659 * @memberOf ListCache
26660 */
26661function listCacheClear() {
26662 this.__data__ = [];
26663 this.size = 0;
26664}
26665
26666module.exports = listCacheClear;
26667
26668},{}],271:[function(require,module,exports){
26669var assocIndexOf = require('./_assocIndexOf');
26670
26671/** Used for built-in method references. */
26672var arrayProto = Array.prototype;
26673
26674/** Built-in value references. */
26675var splice = arrayProto.splice;
26676
26677/**
26678 * Removes `key` and its value from the list cache.
26679 *
26680 * @private
26681 * @name delete
26682 * @memberOf ListCache
26683 * @param {string} key The key of the value to remove.
26684 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
26685 */
26686function listCacheDelete(key) {
26687 var data = this.__data__,
26688 index = assocIndexOf(data, key);
26689
26690 if (index < 0) {
26691 return false;
26692 }
26693 var lastIndex = data.length - 1;
26694 if (index == lastIndex) {
26695 data.pop();
26696 } else {
26697 splice.call(data, index, 1);
26698 }
26699 --this.size;
26700 return true;
26701}
26702
26703module.exports = listCacheDelete;
26704
26705},{"./_assocIndexOf":170}],272:[function(require,module,exports){
26706var assocIndexOf = require('./_assocIndexOf');
26707
26708/**
26709 * Gets the list cache value for `key`.
26710 *
26711 * @private
26712 * @name get
26713 * @memberOf ListCache
26714 * @param {string} key The key of the value to get.
26715 * @returns {*} Returns the entry value.
26716 */
26717function listCacheGet(key) {
26718 var data = this.__data__,
26719 index = assocIndexOf(data, key);
26720
26721 return index < 0 ? undefined : data[index][1];
26722}
26723
26724module.exports = listCacheGet;
26725
26726},{"./_assocIndexOf":170}],273:[function(require,module,exports){
26727var assocIndexOf = require('./_assocIndexOf');
26728
26729/**
26730 * Checks if a list cache value for `key` exists.
26731 *
26732 * @private
26733 * @name has
26734 * @memberOf ListCache
26735 * @param {string} key The key of the entry to check.
26736 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
26737 */
26738function listCacheHas(key) {
26739 return assocIndexOf(this.__data__, key) > -1;
26740}
26741
26742module.exports = listCacheHas;
26743
26744},{"./_assocIndexOf":170}],274:[function(require,module,exports){
26745var assocIndexOf = require('./_assocIndexOf');
26746
26747/**
26748 * Sets the list cache `key` to `value`.
26749 *
26750 * @private
26751 * @name set
26752 * @memberOf ListCache
26753 * @param {string} key The key of the value to set.
26754 * @param {*} value The value to set.
26755 * @returns {Object} Returns the list cache instance.
26756 */
26757function listCacheSet(key, value) {
26758 var data = this.__data__,
26759 index = assocIndexOf(data, key);
26760
26761 if (index < 0) {
26762 ++this.size;
26763 data.push([key, value]);
26764 } else {
26765 data[index][1] = value;
26766 }
26767 return this;
26768}
26769
26770module.exports = listCacheSet;
26771
26772},{"./_assocIndexOf":170}],275:[function(require,module,exports){
26773var Hash = require('./_Hash'),
26774 ListCache = require('./_ListCache'),
26775 Map = require('./_Map');
26776
26777/**
26778 * Removes all key-value entries from the map.
26779 *
26780 * @private
26781 * @name clear
26782 * @memberOf MapCache
26783 */
26784function mapCacheClear() {
26785 this.size = 0;
26786 this.__data__ = {
26787 'hash': new Hash,
26788 'map': new (Map || ListCache),
26789 'string': new Hash
26790 };
26791}
26792
26793module.exports = mapCacheClear;
26794
26795},{"./_Hash":148,"./_ListCache":149,"./_Map":150}],276:[function(require,module,exports){
26796var getMapData = require('./_getMapData');
26797
26798/**
26799 * Removes `key` and its value from the map.
26800 *
26801 * @private
26802 * @name delete
26803 * @memberOf MapCache
26804 * @param {string} key The key of the value to remove.
26805 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
26806 */
26807function mapCacheDelete(key) {
26808 var result = getMapData(this, key)['delete'](key);
26809 this.size -= result ? 1 : 0;
26810 return result;
26811}
26812
26813module.exports = mapCacheDelete;
26814
26815},{"./_getMapData":243}],277:[function(require,module,exports){
26816var getMapData = require('./_getMapData');
26817
26818/**
26819 * Gets the map value for `key`.
26820 *
26821 * @private
26822 * @name get
26823 * @memberOf MapCache
26824 * @param {string} key The key of the value to get.
26825 * @returns {*} Returns the entry value.
26826 */
26827function mapCacheGet(key) {
26828 return getMapData(this, key).get(key);
26829}
26830
26831module.exports = mapCacheGet;
26832
26833},{"./_getMapData":243}],278:[function(require,module,exports){
26834var getMapData = require('./_getMapData');
26835
26836/**
26837 * Checks if a map value for `key` exists.
26838 *
26839 * @private
26840 * @name has
26841 * @memberOf MapCache
26842 * @param {string} key The key of the entry to check.
26843 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
26844 */
26845function mapCacheHas(key) {
26846 return getMapData(this, key).has(key);
26847}
26848
26849module.exports = mapCacheHas;
26850
26851},{"./_getMapData":243}],279:[function(require,module,exports){
26852var getMapData = require('./_getMapData');
26853
26854/**
26855 * Sets the map `key` to `value`.
26856 *
26857 * @private
26858 * @name set
26859 * @memberOf MapCache
26860 * @param {string} key The key of the value to set.
26861 * @param {*} value The value to set.
26862 * @returns {Object} Returns the map cache instance.
26863 */
26864function mapCacheSet(key, value) {
26865 var data = getMapData(this, key),
26866 size = data.size;
26867
26868 data.set(key, value);
26869 this.size += data.size == size ? 0 : 1;
26870 return this;
26871}
26872
26873module.exports = mapCacheSet;
26874
26875},{"./_getMapData":243}],280:[function(require,module,exports){
26876/**
26877 * Converts `map` to its key-value pairs.
26878 *
26879 * @private
26880 * @param {Object} map The map to convert.
26881 * @returns {Array} Returns the key-value pairs.
26882 */
26883function mapToArray(map) {
26884 var index = -1,
26885 result = Array(map.size);
26886
26887 map.forEach(function(value, key) {
26888 result[++index] = [key, value];
26889 });
26890 return result;
26891}
26892
26893module.exports = mapToArray;
26894
26895},{}],281:[function(require,module,exports){
26896/**
26897 * A specialized version of `matchesProperty` for source values suitable
26898 * for strict equality comparisons, i.e. `===`.
26899 *
26900 * @private
26901 * @param {string} key The key of the property to get.
26902 * @param {*} srcValue The value to match.
26903 * @returns {Function} Returns the new spec function.
26904 */
26905function matchesStrictComparable(key, srcValue) {
26906 return function(object) {
26907 if (object == null) {
26908 return false;
26909 }
26910 return object[key] === srcValue &&
26911 (srcValue !== undefined || (key in Object(object)));
26912 };
26913}
26914
26915module.exports = matchesStrictComparable;
26916
26917},{}],282:[function(require,module,exports){
26918var memoize = require('./memoize');
26919
26920/** Used as the maximum memoize cache size. */
26921var MAX_MEMOIZE_SIZE = 500;
26922
26923/**
26924 * A specialized version of `_.memoize` which clears the memoized function's
26925 * cache when it exceeds `MAX_MEMOIZE_SIZE`.
26926 *
26927 * @private
26928 * @param {Function} func The function to have its output memoized.
26929 * @returns {Function} Returns the new memoized function.
26930 */
26931function memoizeCapped(func) {
26932 var result = memoize(func, function(key) {
26933 if (cache.size === MAX_MEMOIZE_SIZE) {
26934 cache.clear();
26935 }
26936 return key;
26937 });
26938
26939 var cache = result.cache;
26940 return result;
26941}
26942
26943module.exports = memoizeCapped;
26944
26945},{"./memoize":344}],283:[function(require,module,exports){
26946var getNative = require('./_getNative');
26947
26948/* Built-in method references that are verified to be native. */
26949var nativeCreate = getNative(Object, 'create');
26950
26951module.exports = nativeCreate;
26952
26953},{"./_getNative":245}],284:[function(require,module,exports){
26954var overArg = require('./_overArg');
26955
26956/* Built-in method references for those with the same name as other `lodash` methods. */
26957var nativeKeys = overArg(Object.keys, Object);
26958
26959module.exports = nativeKeys;
26960
26961},{"./_overArg":288}],285:[function(require,module,exports){
26962/**
26963 * This function is like
26964 * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
26965 * except that it includes inherited enumerable properties.
26966 *
26967 * @private
26968 * @param {Object} object The object to query.
26969 * @returns {Array} Returns the array of property names.
26970 */
26971function nativeKeysIn(object) {
26972 var result = [];
26973 if (object != null) {
26974 for (var key in Object(object)) {
26975 result.push(key);
26976 }
26977 }
26978 return result;
26979}
26980
26981module.exports = nativeKeysIn;
26982
26983},{}],286:[function(require,module,exports){
26984var freeGlobal = require('./_freeGlobal');
26985
26986/** Detect free variable `exports`. */
26987var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
26988
26989/** Detect free variable `module`. */
26990var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
26991
26992/** Detect the popular CommonJS extension `module.exports`. */
26993var moduleExports = freeModule && freeModule.exports === freeExports;
26994
26995/** Detect free variable `process` from Node.js. */
26996var freeProcess = moduleExports && freeGlobal.process;
26997
26998/** Used to access faster Node.js helpers. */
26999var nodeUtil = (function() {
27000 try {
27001 // Use `util.types` for Node.js 10+.
27002 var types = freeModule && freeModule.require && freeModule.require('util').types;
27003
27004 if (types) {
27005 return types;
27006 }
27007
27008 // Legacy `process.binding('util')` for Node.js < 10.
27009 return freeProcess && freeProcess.binding && freeProcess.binding('util');
27010 } catch (e) {}
27011}());
27012
27013module.exports = nodeUtil;
27014
27015},{"./_freeGlobal":240}],287:[function(require,module,exports){
27016/** Used for built-in method references. */
27017var objectProto = Object.prototype;
27018
27019/**
27020 * Used to resolve the
27021 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
27022 * of values.
27023 */
27024var nativeObjectToString = objectProto.toString;
27025
27026/**
27027 * Converts `value` to a string using `Object.prototype.toString`.
27028 *
27029 * @private
27030 * @param {*} value The value to convert.
27031 * @returns {string} Returns the converted string.
27032 */
27033function objectToString(value) {
27034 return nativeObjectToString.call(value);
27035}
27036
27037module.exports = objectToString;
27038
27039},{}],288:[function(require,module,exports){
27040/**
27041 * Creates a unary function that invokes `func` with its argument transformed.
27042 *
27043 * @private
27044 * @param {Function} func The function to wrap.
27045 * @param {Function} transform The argument transform.
27046 * @returns {Function} Returns the new function.
27047 */
27048function overArg(func, transform) {
27049 return function(arg) {
27050 return func(transform(arg));
27051 };
27052}
27053
27054module.exports = overArg;
27055
27056},{}],289:[function(require,module,exports){
27057var apply = require('./_apply');
27058
27059/* Built-in method references for those with the same name as other `lodash` methods. */
27060var nativeMax = Math.max;
27061
27062/**
27063 * A specialized version of `baseRest` which transforms the rest array.
27064 *
27065 * @private
27066 * @param {Function} func The function to apply a rest parameter to.
27067 * @param {number} [start=func.length-1] The start position of the rest parameter.
27068 * @param {Function} transform The rest array transform.
27069 * @returns {Function} Returns the new function.
27070 */
27071function overRest(func, start, transform) {
27072 start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
27073 return function() {
27074 var args = arguments,
27075 index = -1,
27076 length = nativeMax(args.length - start, 0),
27077 array = Array(length);
27078
27079 while (++index < length) {
27080 array[index] = args[start + index];
27081 }
27082 index = -1;
27083 var otherArgs = Array(start + 1);
27084 while (++index < start) {
27085 otherArgs[index] = args[index];
27086 }
27087 otherArgs[start] = transform(array);
27088 return apply(func, this, otherArgs);
27089 };
27090}
27091
27092module.exports = overRest;
27093
27094},{"./_apply":159}],290:[function(require,module,exports){
27095var freeGlobal = require('./_freeGlobal');
27096
27097/** Detect free variable `self`. */
27098var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
27099
27100/** Used as a reference to the global object. */
27101var root = freeGlobal || freeSelf || Function('return this')();
27102
27103module.exports = root;
27104
27105},{"./_freeGlobal":240}],291:[function(require,module,exports){
27106/** Used to stand-in for `undefined` hash values. */
27107var HASH_UNDEFINED = '__lodash_hash_undefined__';
27108
27109/**
27110 * Adds `value` to the array cache.
27111 *
27112 * @private
27113 * @name add
27114 * @memberOf SetCache
27115 * @alias push
27116 * @param {*} value The value to cache.
27117 * @returns {Object} Returns the cache instance.
27118 */
27119function setCacheAdd(value) {
27120 this.__data__.set(value, HASH_UNDEFINED);
27121 return this;
27122}
27123
27124module.exports = setCacheAdd;
27125
27126},{}],292:[function(require,module,exports){
27127/**
27128 * Checks if `value` is in the array cache.
27129 *
27130 * @private
27131 * @name has
27132 * @memberOf SetCache
27133 * @param {*} value The value to search for.
27134 * @returns {number} Returns `true` if `value` is found, else `false`.
27135 */
27136function setCacheHas(value) {
27137 return this.__data__.has(value);
27138}
27139
27140module.exports = setCacheHas;
27141
27142},{}],293:[function(require,module,exports){
27143/**
27144 * Converts `set` to an array of its values.
27145 *
27146 * @private
27147 * @param {Object} set The set to convert.
27148 * @returns {Array} Returns the values.
27149 */
27150function setToArray(set) {
27151 var index = -1,
27152 result = Array(set.size);
27153
27154 set.forEach(function(value) {
27155 result[++index] = value;
27156 });
27157 return result;
27158}
27159
27160module.exports = setToArray;
27161
27162},{}],294:[function(require,module,exports){
27163var baseSetToString = require('./_baseSetToString'),
27164 shortOut = require('./_shortOut');
27165
27166/**
27167 * Sets the `toString` method of `func` to return `string`.
27168 *
27169 * @private
27170 * @param {Function} func The function to modify.
27171 * @param {Function} string The `toString` result.
27172 * @returns {Function} Returns `func`.
27173 */
27174var setToString = shortOut(baseSetToString);
27175
27176module.exports = setToString;
27177
27178},{"./_baseSetToString":209,"./_shortOut":295}],295:[function(require,module,exports){
27179/** Used to detect hot functions by number of calls within a span of milliseconds. */
27180var HOT_COUNT = 800,
27181 HOT_SPAN = 16;
27182
27183/* Built-in method references for those with the same name as other `lodash` methods. */
27184var nativeNow = Date.now;
27185
27186/**
27187 * Creates a function that'll short out and invoke `identity` instead
27188 * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
27189 * milliseconds.
27190 *
27191 * @private
27192 * @param {Function} func The function to restrict.
27193 * @returns {Function} Returns the new shortable function.
27194 */
27195function shortOut(func) {
27196 var count = 0,
27197 lastCalled = 0;
27198
27199 return function() {
27200 var stamp = nativeNow(),
27201 remaining = HOT_SPAN - (stamp - lastCalled);
27202
27203 lastCalled = stamp;
27204 if (remaining > 0) {
27205 if (++count >= HOT_COUNT) {
27206 return arguments[0];
27207 }
27208 } else {
27209 count = 0;
27210 }
27211 return func.apply(undefined, arguments);
27212 };
27213}
27214
27215module.exports = shortOut;
27216
27217},{}],296:[function(require,module,exports){
27218var ListCache = require('./_ListCache');
27219
27220/**
27221 * Removes all key-value entries from the stack.
27222 *
27223 * @private
27224 * @name clear
27225 * @memberOf Stack
27226 */
27227function stackClear() {
27228 this.__data__ = new ListCache;
27229 this.size = 0;
27230}
27231
27232module.exports = stackClear;
27233
27234},{"./_ListCache":149}],297:[function(require,module,exports){
27235/**
27236 * Removes `key` and its value from the stack.
27237 *
27238 * @private
27239 * @name delete
27240 * @memberOf Stack
27241 * @param {string} key The key of the value to remove.
27242 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
27243 */
27244function stackDelete(key) {
27245 var data = this.__data__,
27246 result = data['delete'](key);
27247
27248 this.size = data.size;
27249 return result;
27250}
27251
27252module.exports = stackDelete;
27253
27254},{}],298:[function(require,module,exports){
27255/**
27256 * Gets the stack value for `key`.
27257 *
27258 * @private
27259 * @name get
27260 * @memberOf Stack
27261 * @param {string} key The key of the value to get.
27262 * @returns {*} Returns the entry value.
27263 */
27264function stackGet(key) {
27265 return this.__data__.get(key);
27266}
27267
27268module.exports = stackGet;
27269
27270},{}],299:[function(require,module,exports){
27271/**
27272 * Checks if a stack value for `key` exists.
27273 *
27274 * @private
27275 * @name has
27276 * @memberOf Stack
27277 * @param {string} key The key of the entry to check.
27278 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
27279 */
27280function stackHas(key) {
27281 return this.__data__.has(key);
27282}
27283
27284module.exports = stackHas;
27285
27286},{}],300:[function(require,module,exports){
27287var ListCache = require('./_ListCache'),
27288 Map = require('./_Map'),
27289 MapCache = require('./_MapCache');
27290
27291/** Used as the size to enable large array optimizations. */
27292var LARGE_ARRAY_SIZE = 200;
27293
27294/**
27295 * Sets the stack `key` to `value`.
27296 *
27297 * @private
27298 * @name set
27299 * @memberOf Stack
27300 * @param {string} key The key of the value to set.
27301 * @param {*} value The value to set.
27302 * @returns {Object} Returns the stack cache instance.
27303 */
27304function stackSet(key, value) {
27305 var data = this.__data__;
27306 if (data instanceof ListCache) {
27307 var pairs = data.__data__;
27308 if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
27309 pairs.push([key, value]);
27310 this.size = ++data.size;
27311 return this;
27312 }
27313 data = this.__data__ = new MapCache(pairs);
27314 }
27315 data.set(key, value);
27316 this.size = data.size;
27317 return this;
27318}
27319
27320module.exports = stackSet;
27321
27322},{"./_ListCache":149,"./_Map":150,"./_MapCache":151}],301:[function(require,module,exports){
27323/**
27324 * A specialized version of `_.indexOf` which performs strict equality
27325 * comparisons of values, i.e. `===`.
27326 *
27327 * @private
27328 * @param {Array} array The array to inspect.
27329 * @param {*} value The value to search for.
27330 * @param {number} fromIndex The index to search from.
27331 * @returns {number} Returns the index of the matched value, else `-1`.
27332 */
27333function strictIndexOf(array, value, fromIndex) {
27334 var index = fromIndex - 1,
27335 length = array.length;
27336
27337 while (++index < length) {
27338 if (array[index] === value) {
27339 return index;
27340 }
27341 }
27342 return -1;
27343}
27344
27345module.exports = strictIndexOf;
27346
27347},{}],302:[function(require,module,exports){
27348var asciiSize = require('./_asciiSize'),
27349 hasUnicode = require('./_hasUnicode'),
27350 unicodeSize = require('./_unicodeSize');
27351
27352/**
27353 * Gets the number of symbols in `string`.
27354 *
27355 * @private
27356 * @param {string} string The string to inspect.
27357 * @returns {number} Returns the string size.
27358 */
27359function stringSize(string) {
27360 return hasUnicode(string)
27361 ? unicodeSize(string)
27362 : asciiSize(string);
27363}
27364
27365module.exports = stringSize;
27366
27367},{"./_asciiSize":167,"./_hasUnicode":253,"./_unicodeSize":307}],303:[function(require,module,exports){
27368var asciiToArray = require('./_asciiToArray'),
27369 hasUnicode = require('./_hasUnicode'),
27370 unicodeToArray = require('./_unicodeToArray');
27371
27372/**
27373 * Converts `string` to an array.
27374 *
27375 * @private
27376 * @param {string} string The string to convert.
27377 * @returns {Array} Returns the converted array.
27378 */
27379function stringToArray(string) {
27380 return hasUnicode(string)
27381 ? unicodeToArray(string)
27382 : asciiToArray(string);
27383}
27384
27385module.exports = stringToArray;
27386
27387},{"./_asciiToArray":168,"./_hasUnicode":253,"./_unicodeToArray":308}],304:[function(require,module,exports){
27388var memoizeCapped = require('./_memoizeCapped');
27389
27390/** Used to match property names within property paths. */
27391var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
27392
27393/** Used to match backslashes in property paths. */
27394var reEscapeChar = /\\(\\)?/g;
27395
27396/**
27397 * Converts `string` to a property path array.
27398 *
27399 * @private
27400 * @param {string} string The string to convert.
27401 * @returns {Array} Returns the property path array.
27402 */
27403var stringToPath = memoizeCapped(function(string) {
27404 var result = [];
27405 if (string.charCodeAt(0) === 46 /* . */) {
27406 result.push('');
27407 }
27408 string.replace(rePropName, function(match, number, quote, subString) {
27409 result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
27410 });
27411 return result;
27412});
27413
27414module.exports = stringToPath;
27415
27416},{"./_memoizeCapped":282}],305:[function(require,module,exports){
27417var isSymbol = require('./isSymbol');
27418
27419/** Used as references for various `Number` constants. */
27420var INFINITY = 1 / 0;
27421
27422/**
27423 * Converts `value` to a string key if it's not a string or symbol.
27424 *
27425 * @private
27426 * @param {*} value The value to inspect.
27427 * @returns {string|symbol} Returns the key.
27428 */
27429function toKey(value) {
27430 if (typeof value == 'string' || isSymbol(value)) {
27431 return value;
27432 }
27433 var result = (value + '');
27434 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
27435}
27436
27437module.exports = toKey;
27438
27439},{"./isSymbol":338}],306:[function(require,module,exports){
27440/** Used for built-in method references. */
27441var funcProto = Function.prototype;
27442
27443/** Used to resolve the decompiled source of functions. */
27444var funcToString = funcProto.toString;
27445
27446/**
27447 * Converts `func` to its source code.
27448 *
27449 * @private
27450 * @param {Function} func The function to convert.
27451 * @returns {string} Returns the source code.
27452 */
27453function toSource(func) {
27454 if (func != null) {
27455 try {
27456 return funcToString.call(func);
27457 } catch (e) {}
27458 try {
27459 return (func + '');
27460 } catch (e) {}
27461 }
27462 return '';
27463}
27464
27465module.exports = toSource;
27466
27467},{}],307:[function(require,module,exports){
27468/** Used to compose unicode character classes. */
27469var rsAstralRange = '\\ud800-\\udfff',
27470 rsComboMarksRange = '\\u0300-\\u036f',
27471 reComboHalfMarksRange = '\\ufe20-\\ufe2f',
27472 rsComboSymbolsRange = '\\u20d0-\\u20ff',
27473 rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
27474 rsVarRange = '\\ufe0e\\ufe0f';
27475
27476/** Used to compose unicode capture groups. */
27477var rsAstral = '[' + rsAstralRange + ']',
27478 rsCombo = '[' + rsComboRange + ']',
27479 rsFitz = '\\ud83c[\\udffb-\\udfff]',
27480 rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
27481 rsNonAstral = '[^' + rsAstralRange + ']',
27482 rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
27483 rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
27484 rsZWJ = '\\u200d';
27485
27486/** Used to compose unicode regexes. */
27487var reOptMod = rsModifier + '?',
27488 rsOptVar = '[' + rsVarRange + ']?',
27489 rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
27490 rsSeq = rsOptVar + reOptMod + rsOptJoin,
27491 rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
27492
27493/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
27494var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
27495
27496/**
27497 * Gets the size of a Unicode `string`.
27498 *
27499 * @private
27500 * @param {string} string The string inspect.
27501 * @returns {number} Returns the string size.
27502 */
27503function unicodeSize(string) {
27504 var result = reUnicode.lastIndex = 0;
27505 while (reUnicode.test(string)) {
27506 ++result;
27507 }
27508 return result;
27509}
27510
27511module.exports = unicodeSize;
27512
27513},{}],308:[function(require,module,exports){
27514/** Used to compose unicode character classes. */
27515var rsAstralRange = '\\ud800-\\udfff',
27516 rsComboMarksRange = '\\u0300-\\u036f',
27517 reComboHalfMarksRange = '\\ufe20-\\ufe2f',
27518 rsComboSymbolsRange = '\\u20d0-\\u20ff',
27519 rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
27520 rsVarRange = '\\ufe0e\\ufe0f';
27521
27522/** Used to compose unicode capture groups. */
27523var rsAstral = '[' + rsAstralRange + ']',
27524 rsCombo = '[' + rsComboRange + ']',
27525 rsFitz = '\\ud83c[\\udffb-\\udfff]',
27526 rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
27527 rsNonAstral = '[^' + rsAstralRange + ']',
27528 rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
27529 rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
27530 rsZWJ = '\\u200d';
27531
27532/** Used to compose unicode regexes. */
27533var reOptMod = rsModifier + '?',
27534 rsOptVar = '[' + rsVarRange + ']?',
27535 rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
27536 rsSeq = rsOptVar + reOptMod + rsOptJoin,
27537 rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
27538
27539/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
27540var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
27541
27542/**
27543 * Converts a Unicode `string` to an array.
27544 *
27545 * @private
27546 * @param {string} string The string to convert.
27547 * @returns {Array} Returns the converted array.
27548 */
27549function unicodeToArray(string) {
27550 return string.match(reUnicode) || [];
27551}
27552
27553module.exports = unicodeToArray;
27554
27555},{}],309:[function(require,module,exports){
27556var copyObject = require('./_copyObject'),
27557 createAssigner = require('./_createAssigner'),
27558 keysIn = require('./keysIn');
27559
27560/**
27561 * This method is like `_.assign` except that it iterates over own and
27562 * inherited source properties.
27563 *
27564 * **Note:** This method mutates `object`.
27565 *
27566 * @static
27567 * @memberOf _
27568 * @since 4.0.0
27569 * @alias extend
27570 * @category Object
27571 * @param {Object} object The destination object.
27572 * @param {...Object} [sources] The source objects.
27573 * @returns {Object} Returns `object`.
27574 * @see _.assign
27575 * @example
27576 *
27577 * function Foo() {
27578 * this.a = 1;
27579 * }
27580 *
27581 * function Bar() {
27582 * this.c = 3;
27583 * }
27584 *
27585 * Foo.prototype.b = 2;
27586 * Bar.prototype.d = 4;
27587 *
27588 * _.assignIn({ 'a': 0 }, new Foo, new Bar);
27589 * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
27590 */
27591var assignIn = createAssigner(function(object, source) {
27592 copyObject(source, keysIn(source), object);
27593});
27594
27595module.exports = assignIn;
27596
27597},{"./_copyObject":227,"./_createAssigner":231,"./keysIn":342}],310:[function(require,module,exports){
27598var baseClone = require('./_baseClone');
27599
27600/** Used to compose bitmasks for cloning. */
27601var CLONE_SYMBOLS_FLAG = 4;
27602
27603/**
27604 * Creates a shallow clone of `value`.
27605 *
27606 * **Note:** This method is loosely based on the
27607 * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
27608 * and supports cloning arrays, array buffers, booleans, date objects, maps,
27609 * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
27610 * arrays. The own enumerable properties of `arguments` objects are cloned
27611 * as plain objects. An empty object is returned for uncloneable values such
27612 * as error objects, functions, DOM nodes, and WeakMaps.
27613 *
27614 * @static
27615 * @memberOf _
27616 * @since 0.1.0
27617 * @category Lang
27618 * @param {*} value The value to clone.
27619 * @returns {*} Returns the cloned value.
27620 * @see _.cloneDeep
27621 * @example
27622 *
27623 * var objects = [{ 'a': 1 }, { 'b': 2 }];
27624 *
27625 * var shallow = _.clone(objects);
27626 * console.log(shallow[0] === objects[0]);
27627 * // => true
27628 */
27629function clone(value) {
27630 return baseClone(value, CLONE_SYMBOLS_FLAG);
27631}
27632
27633module.exports = clone;
27634
27635},{"./_baseClone":174}],311:[function(require,module,exports){
27636/**
27637 * Creates a function that returns `value`.
27638 *
27639 * @static
27640 * @memberOf _
27641 * @since 2.4.0
27642 * @category Util
27643 * @param {*} value The value to return from the new function.
27644 * @returns {Function} Returns the new constant function.
27645 * @example
27646 *
27647 * var objects = _.times(2, _.constant({ 'a': 1 }));
27648 *
27649 * console.log(objects);
27650 * // => [{ 'a': 1 }, { 'a': 1 }]
27651 *
27652 * console.log(objects[0] === objects[1]);
27653 * // => true
27654 */
27655function constant(value) {
27656 return function() {
27657 return value;
27658 };
27659}
27660
27661module.exports = constant;
27662
27663},{}],312:[function(require,module,exports){
27664module.exports = require('./forEach');
27665
27666},{"./forEach":317}],313:[function(require,module,exports){
27667/**
27668 * Performs a
27669 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
27670 * comparison between two values to determine if they are equivalent.
27671 *
27672 * @static
27673 * @memberOf _
27674 * @since 4.0.0
27675 * @category Lang
27676 * @param {*} value The value to compare.
27677 * @param {*} other The other value to compare.
27678 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
27679 * @example
27680 *
27681 * var object = { 'a': 1 };
27682 * var other = { 'a': 1 };
27683 *
27684 * _.eq(object, object);
27685 * // => true
27686 *
27687 * _.eq(object, other);
27688 * // => false
27689 *
27690 * _.eq('a', 'a');
27691 * // => true
27692 *
27693 * _.eq('a', Object('a'));
27694 * // => false
27695 *
27696 * _.eq(NaN, NaN);
27697 * // => true
27698 */
27699function eq(value, other) {
27700 return value === other || (value !== value && other !== other);
27701}
27702
27703module.exports = eq;
27704
27705},{}],314:[function(require,module,exports){
27706var arrayEvery = require('./_arrayEvery'),
27707 baseEvery = require('./_baseEvery'),
27708 baseIteratee = require('./_baseIteratee'),
27709 isArray = require('./isArray'),
27710 isIterateeCall = require('./_isIterateeCall');
27711
27712/**
27713 * Checks if `predicate` returns truthy for **all** elements of `collection`.
27714 * Iteration is stopped once `predicate` returns falsey. The predicate is
27715 * invoked with three arguments: (value, index|key, collection).
27716 *
27717 * **Note:** This method returns `true` for
27718 * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
27719 * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
27720 * elements of empty collections.
27721 *
27722 * @static
27723 * @memberOf _
27724 * @since 0.1.0
27725 * @category Collection
27726 * @param {Array|Object} collection The collection to iterate over.
27727 * @param {Function} [predicate=_.identity] The function invoked per iteration.
27728 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
27729 * @returns {boolean} Returns `true` if all elements pass the predicate check,
27730 * else `false`.
27731 * @example
27732 *
27733 * _.every([true, 1, null, 'yes'], Boolean);
27734 * // => false
27735 *
27736 * var users = [
27737 * { 'user': 'barney', 'age': 36, 'active': false },
27738 * { 'user': 'fred', 'age': 40, 'active': false }
27739 * ];
27740 *
27741 * // The `_.matches` iteratee shorthand.
27742 * _.every(users, { 'user': 'barney', 'active': false });
27743 * // => false
27744 *
27745 * // The `_.matchesProperty` iteratee shorthand.
27746 * _.every(users, ['active', false]);
27747 * // => true
27748 *
27749 * // The `_.property` iteratee shorthand.
27750 * _.every(users, 'active');
27751 * // => false
27752 */
27753function every(collection, predicate, guard) {
27754 var func = isArray(collection) ? arrayEvery : baseEvery;
27755 if (guard && isIterateeCall(collection, predicate, guard)) {
27756 predicate = undefined;
27757 }
27758 return func(collection, baseIteratee(predicate, 3));
27759}
27760
27761module.exports = every;
27762
27763},{"./_arrayEvery":161,"./_baseEvery":177,"./_baseIteratee":196,"./_isIterateeCall":264,"./isArray":323}],315:[function(require,module,exports){
27764module.exports = require('./assignIn');
27765
27766},{"./assignIn":309}],316:[function(require,module,exports){
27767var baseFlatten = require('./_baseFlatten');
27768
27769/**
27770 * Flattens `array` a single level deep.
27771 *
27772 * @static
27773 * @memberOf _
27774 * @since 0.1.0
27775 * @category Array
27776 * @param {Array} array The array to flatten.
27777 * @returns {Array} Returns the new flattened array.
27778 * @example
27779 *
27780 * _.flatten([1, [2, [3, [4]], 5]]);
27781 * // => [1, 2, [3, [4]], 5]
27782 */
27783function flatten(array) {
27784 var length = array == null ? 0 : array.length;
27785 return length ? baseFlatten(array, 1) : [];
27786}
27787
27788module.exports = flatten;
27789
27790},{"./_baseFlatten":179}],317:[function(require,module,exports){
27791var arrayEach = require('./_arrayEach'),
27792 baseEach = require('./_baseEach'),
27793 castFunction = require('./_castFunction'),
27794 isArray = require('./isArray');
27795
27796/**
27797 * Iterates over elements of `collection` and invokes `iteratee` for each element.
27798 * The iteratee is invoked with three arguments: (value, index|key, collection).
27799 * Iteratee functions may exit iteration early by explicitly returning `false`.
27800 *
27801 * **Note:** As with other "Collections" methods, objects with a "length"
27802 * property are iterated like arrays. To avoid this behavior use `_.forIn`
27803 * or `_.forOwn` for object iteration.
27804 *
27805 * @static
27806 * @memberOf _
27807 * @since 0.1.0
27808 * @alias each
27809 * @category Collection
27810 * @param {Array|Object} collection The collection to iterate over.
27811 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
27812 * @returns {Array|Object} Returns `collection`.
27813 * @see _.forEachRight
27814 * @example
27815 *
27816 * _.forEach([1, 2], function(value) {
27817 * console.log(value);
27818 * });
27819 * // => Logs `1` then `2`.
27820 *
27821 * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
27822 * console.log(key);
27823 * });
27824 * // => Logs 'a' then 'b' (iteration order is not guaranteed).
27825 */
27826function forEach(collection, iteratee) {
27827 var func = isArray(collection) ? arrayEach : baseEach;
27828 return func(collection, castFunction(iteratee));
27829}
27830
27831module.exports = forEach;
27832
27833},{"./_arrayEach":160,"./_baseEach":176,"./_castFunction":216,"./isArray":323}],318:[function(require,module,exports){
27834/**
27835 * The inverse of `_.toPairs`; this method returns an object composed
27836 * from key-value `pairs`.
27837 *
27838 * @static
27839 * @memberOf _
27840 * @since 4.0.0
27841 * @category Array
27842 * @param {Array} pairs The key-value pairs.
27843 * @returns {Object} Returns the new object.
27844 * @example
27845 *
27846 * _.fromPairs([['a', 1], ['b', 2]]);
27847 * // => { 'a': 1, 'b': 2 }
27848 */
27849function fromPairs(pairs) {
27850 var index = -1,
27851 length = pairs == null ? 0 : pairs.length,
27852 result = {};
27853
27854 while (++index < length) {
27855 var pair = pairs[index];
27856 result[pair[0]] = pair[1];
27857 }
27858 return result;
27859}
27860
27861module.exports = fromPairs;
27862
27863},{}],319:[function(require,module,exports){
27864var baseGet = require('./_baseGet');
27865
27866/**
27867 * Gets the value at `path` of `object`. If the resolved value is
27868 * `undefined`, the `defaultValue` is returned in its place.
27869 *
27870 * @static
27871 * @memberOf _
27872 * @since 3.7.0
27873 * @category Object
27874 * @param {Object} object The object to query.
27875 * @param {Array|string} path The path of the property to get.
27876 * @param {*} [defaultValue] The value returned for `undefined` resolved values.
27877 * @returns {*} Returns the resolved value.
27878 * @example
27879 *
27880 * var object = { 'a': [{ 'b': { 'c': 3 } }] };
27881 *
27882 * _.get(object, 'a[0].b.c');
27883 * // => 3
27884 *
27885 * _.get(object, ['a', '0', 'b', 'c']);
27886 * // => 3
27887 *
27888 * _.get(object, 'a.b.c', 'default');
27889 * // => 'default'
27890 */
27891function get(object, path, defaultValue) {
27892 var result = object == null ? undefined : baseGet(object, path);
27893 return result === undefined ? defaultValue : result;
27894}
27895
27896module.exports = get;
27897
27898},{"./_baseGet":182}],320:[function(require,module,exports){
27899var baseHasIn = require('./_baseHasIn'),
27900 hasPath = require('./_hasPath');
27901
27902/**
27903 * Checks if `path` is a direct or inherited property of `object`.
27904 *
27905 * @static
27906 * @memberOf _
27907 * @since 4.0.0
27908 * @category Object
27909 * @param {Object} object The object to query.
27910 * @param {Array|string} path The path to check.
27911 * @returns {boolean} Returns `true` if `path` exists, else `false`.
27912 * @example
27913 *
27914 * var object = _.create({ 'a': _.create({ 'b': 2 }) });
27915 *
27916 * _.hasIn(object, 'a');
27917 * // => true
27918 *
27919 * _.hasIn(object, 'a.b');
27920 * // => true
27921 *
27922 * _.hasIn(object, ['a', 'b']);
27923 * // => true
27924 *
27925 * _.hasIn(object, 'b');
27926 * // => false
27927 */
27928function hasIn(object, path) {
27929 return object != null && hasPath(object, path, baseHasIn);
27930}
27931
27932module.exports = hasIn;
27933
27934},{"./_baseHasIn":185,"./_hasPath":252}],321:[function(require,module,exports){
27935/**
27936 * This method returns the first argument it receives.
27937 *
27938 * @static
27939 * @since 0.1.0
27940 * @memberOf _
27941 * @category Util
27942 * @param {*} value Any value.
27943 * @returns {*} Returns `value`.
27944 * @example
27945 *
27946 * var object = { 'a': 1 };
27947 *
27948 * console.log(_.identity(object) === object);
27949 * // => true
27950 */
27951function identity(value) {
27952 return value;
27953}
27954
27955module.exports = identity;
27956
27957},{}],322:[function(require,module,exports){
27958var baseIsArguments = require('./_baseIsArguments'),
27959 isObjectLike = require('./isObjectLike');
27960
27961/** Used for built-in method references. */
27962var objectProto = Object.prototype;
27963
27964/** Used to check objects for own properties. */
27965var hasOwnProperty = objectProto.hasOwnProperty;
27966
27967/** Built-in value references. */
27968var propertyIsEnumerable = objectProto.propertyIsEnumerable;
27969
27970/**
27971 * Checks if `value` is likely an `arguments` object.
27972 *
27973 * @static
27974 * @memberOf _
27975 * @since 0.1.0
27976 * @category Lang
27977 * @param {*} value The value to check.
27978 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
27979 * else `false`.
27980 * @example
27981 *
27982 * _.isArguments(function() { return arguments; }());
27983 * // => true
27984 *
27985 * _.isArguments([1, 2, 3]);
27986 * // => false
27987 */
27988var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
27989 return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
27990 !propertyIsEnumerable.call(value, 'callee');
27991};
27992
27993module.exports = isArguments;
27994
27995},{"./_baseIsArguments":187,"./isObjectLike":334}],323:[function(require,module,exports){
27996/**
27997 * Checks if `value` is classified as an `Array` object.
27998 *
27999 * @static
28000 * @memberOf _
28001 * @since 0.1.0
28002 * @category Lang
28003 * @param {*} value The value to check.
28004 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
28005 * @example
28006 *
28007 * _.isArray([1, 2, 3]);
28008 * // => true
28009 *
28010 * _.isArray(document.body.children);
28011 * // => false
28012 *
28013 * _.isArray('abc');
28014 * // => false
28015 *
28016 * _.isArray(_.noop);
28017 * // => false
28018 */
28019var isArray = Array.isArray;
28020
28021module.exports = isArray;
28022
28023},{}],324:[function(require,module,exports){
28024var isFunction = require('./isFunction'),
28025 isLength = require('./isLength');
28026
28027/**
28028 * Checks if `value` is array-like. A value is considered array-like if it's
28029 * not a function and has a `value.length` that's an integer greater than or
28030 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
28031 *
28032 * @static
28033 * @memberOf _
28034 * @since 4.0.0
28035 * @category Lang
28036 * @param {*} value The value to check.
28037 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
28038 * @example
28039 *
28040 * _.isArrayLike([1, 2, 3]);
28041 * // => true
28042 *
28043 * _.isArrayLike(document.body.children);
28044 * // => true
28045 *
28046 * _.isArrayLike('abc');
28047 * // => true
28048 *
28049 * _.isArrayLike(_.noop);
28050 * // => false
28051 */
28052function isArrayLike(value) {
28053 return value != null && isLength(value.length) && !isFunction(value);
28054}
28055
28056module.exports = isArrayLike;
28057
28058},{"./isFunction":328,"./isLength":329}],325:[function(require,module,exports){
28059var baseGetTag = require('./_baseGetTag'),
28060 isObjectLike = require('./isObjectLike');
28061
28062/** `Object#toString` result references. */
28063var boolTag = '[object Boolean]';
28064
28065/**
28066 * Checks if `value` is classified as a boolean primitive or object.
28067 *
28068 * @static
28069 * @memberOf _
28070 * @since 0.1.0
28071 * @category Lang
28072 * @param {*} value The value to check.
28073 * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
28074 * @example
28075 *
28076 * _.isBoolean(false);
28077 * // => true
28078 *
28079 * _.isBoolean(null);
28080 * // => false
28081 */
28082function isBoolean(value) {
28083 return value === true || value === false ||
28084 (isObjectLike(value) && baseGetTag(value) == boolTag);
28085}
28086
28087module.exports = isBoolean;
28088
28089},{"./_baseGetTag":184,"./isObjectLike":334}],326:[function(require,module,exports){
28090var root = require('./_root'),
28091 stubFalse = require('./stubFalse');
28092
28093/** Detect free variable `exports`. */
28094var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
28095
28096/** Detect free variable `module`. */
28097var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
28098
28099/** Detect the popular CommonJS extension `module.exports`. */
28100var moduleExports = freeModule && freeModule.exports === freeExports;
28101
28102/** Built-in value references. */
28103var Buffer = moduleExports ? root.Buffer : undefined;
28104
28105/* Built-in method references for those with the same name as other `lodash` methods. */
28106var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
28107
28108/**
28109 * Checks if `value` is a buffer.
28110 *
28111 * @static
28112 * @memberOf _
28113 * @since 4.3.0
28114 * @category Lang
28115 * @param {*} value The value to check.
28116 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
28117 * @example
28118 *
28119 * _.isBuffer(new Buffer(2));
28120 * // => true
28121 *
28122 * _.isBuffer(new Uint8Array(2));
28123 * // => false
28124 */
28125var isBuffer = nativeIsBuffer || stubFalse;
28126
28127module.exports = isBuffer;
28128
28129},{"./_root":290,"./stubFalse":349}],327:[function(require,module,exports){
28130var root = require('./_root');
28131
28132/* Built-in method references for those with the same name as other `lodash` methods. */
28133var nativeIsFinite = root.isFinite;
28134
28135/**
28136 * Checks if `value` is a finite primitive number.
28137 *
28138 * **Note:** This method is based on
28139 * [`Number.isFinite`](https://mdn.io/Number/isFinite).
28140 *
28141 * @static
28142 * @memberOf _
28143 * @since 0.1.0
28144 * @category Lang
28145 * @param {*} value The value to check.
28146 * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
28147 * @example
28148 *
28149 * _.isFinite(3);
28150 * // => true
28151 *
28152 * _.isFinite(Number.MIN_VALUE);
28153 * // => true
28154 *
28155 * _.isFinite(Infinity);
28156 * // => false
28157 *
28158 * _.isFinite('3');
28159 * // => false
28160 */
28161function isFinite(value) {
28162 return typeof value == 'number' && nativeIsFinite(value);
28163}
28164
28165module.exports = isFinite;
28166
28167},{"./_root":290}],328:[function(require,module,exports){
28168var baseGetTag = require('./_baseGetTag'),
28169 isObject = require('./isObject');
28170
28171/** `Object#toString` result references. */
28172var asyncTag = '[object AsyncFunction]',
28173 funcTag = '[object Function]',
28174 genTag = '[object GeneratorFunction]',
28175 proxyTag = '[object Proxy]';
28176
28177/**
28178 * Checks if `value` is classified as a `Function` object.
28179 *
28180 * @static
28181 * @memberOf _
28182 * @since 0.1.0
28183 * @category Lang
28184 * @param {*} value The value to check.
28185 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
28186 * @example
28187 *
28188 * _.isFunction(_);
28189 * // => true
28190 *
28191 * _.isFunction(/abc/);
28192 * // => false
28193 */
28194function isFunction(value) {
28195 if (!isObject(value)) {
28196 return false;
28197 }
28198 // The use of `Object#toString` avoids issues with the `typeof` operator
28199 // in Safari 9 which returns 'object' for typed arrays and other constructors.
28200 var tag = baseGetTag(value);
28201 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
28202}
28203
28204module.exports = isFunction;
28205
28206},{"./_baseGetTag":184,"./isObject":333}],329:[function(require,module,exports){
28207/** Used as references for various `Number` constants. */
28208var MAX_SAFE_INTEGER = 9007199254740991;
28209
28210/**
28211 * Checks if `value` is a valid array-like length.
28212 *
28213 * **Note:** This method is loosely based on
28214 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
28215 *
28216 * @static
28217 * @memberOf _
28218 * @since 4.0.0
28219 * @category Lang
28220 * @param {*} value The value to check.
28221 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
28222 * @example
28223 *
28224 * _.isLength(3);
28225 * // => true
28226 *
28227 * _.isLength(Number.MIN_VALUE);
28228 * // => false
28229 *
28230 * _.isLength(Infinity);
28231 * // => false
28232 *
28233 * _.isLength('3');
28234 * // => false
28235 */
28236function isLength(value) {
28237 return typeof value == 'number' &&
28238 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
28239}
28240
28241module.exports = isLength;
28242
28243},{}],330:[function(require,module,exports){
28244var baseIsMap = require('./_baseIsMap'),
28245 baseUnary = require('./_baseUnary'),
28246 nodeUtil = require('./_nodeUtil');
28247
28248/* Node.js helper references. */
28249var nodeIsMap = nodeUtil && nodeUtil.isMap;
28250
28251/**
28252 * Checks if `value` is classified as a `Map` object.
28253 *
28254 * @static
28255 * @memberOf _
28256 * @since 4.3.0
28257 * @category Lang
28258 * @param {*} value The value to check.
28259 * @returns {boolean} Returns `true` if `value` is a map, else `false`.
28260 * @example
28261 *
28262 * _.isMap(new Map);
28263 * // => true
28264 *
28265 * _.isMap(new WeakMap);
28266 * // => false
28267 */
28268var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
28269
28270module.exports = isMap;
28271
28272},{"./_baseIsMap":190,"./_baseUnary":213,"./_nodeUtil":286}],331:[function(require,module,exports){
28273/**
28274 * Checks if `value` is `null`.
28275 *
28276 * @static
28277 * @memberOf _
28278 * @since 0.1.0
28279 * @category Lang
28280 * @param {*} value The value to check.
28281 * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
28282 * @example
28283 *
28284 * _.isNull(null);
28285 * // => true
28286 *
28287 * _.isNull(void 0);
28288 * // => false
28289 */
28290function isNull(value) {
28291 return value === null;
28292}
28293
28294module.exports = isNull;
28295
28296},{}],332:[function(require,module,exports){
28297var baseGetTag = require('./_baseGetTag'),
28298 isObjectLike = require('./isObjectLike');
28299
28300/** `Object#toString` result references. */
28301var numberTag = '[object Number]';
28302
28303/**
28304 * Checks if `value` is classified as a `Number` primitive or object.
28305 *
28306 * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
28307 * classified as numbers, use the `_.isFinite` method.
28308 *
28309 * @static
28310 * @memberOf _
28311 * @since 0.1.0
28312 * @category Lang
28313 * @param {*} value The value to check.
28314 * @returns {boolean} Returns `true` if `value` is a number, else `false`.
28315 * @example
28316 *
28317 * _.isNumber(3);
28318 * // => true
28319 *
28320 * _.isNumber(Number.MIN_VALUE);
28321 * // => true
28322 *
28323 * _.isNumber(Infinity);
28324 * // => true
28325 *
28326 * _.isNumber('3');
28327 * // => false
28328 */
28329function isNumber(value) {
28330 return typeof value == 'number' ||
28331 (isObjectLike(value) && baseGetTag(value) == numberTag);
28332}
28333
28334module.exports = isNumber;
28335
28336},{"./_baseGetTag":184,"./isObjectLike":334}],333:[function(require,module,exports){
28337/**
28338 * Checks if `value` is the
28339 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
28340 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
28341 *
28342 * @static
28343 * @memberOf _
28344 * @since 0.1.0
28345 * @category Lang
28346 * @param {*} value The value to check.
28347 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
28348 * @example
28349 *
28350 * _.isObject({});
28351 * // => true
28352 *
28353 * _.isObject([1, 2, 3]);
28354 * // => true
28355 *
28356 * _.isObject(_.noop);
28357 * // => true
28358 *
28359 * _.isObject(null);
28360 * // => false
28361 */
28362function isObject(value) {
28363 var type = typeof value;
28364 return value != null && (type == 'object' || type == 'function');
28365}
28366
28367module.exports = isObject;
28368
28369},{}],334:[function(require,module,exports){
28370/**
28371 * Checks if `value` is object-like. A value is object-like if it's not `null`
28372 * and has a `typeof` result of "object".
28373 *
28374 * @static
28375 * @memberOf _
28376 * @since 4.0.0
28377 * @category Lang
28378 * @param {*} value The value to check.
28379 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
28380 * @example
28381 *
28382 * _.isObjectLike({});
28383 * // => true
28384 *
28385 * _.isObjectLike([1, 2, 3]);
28386 * // => true
28387 *
28388 * _.isObjectLike(_.noop);
28389 * // => false
28390 *
28391 * _.isObjectLike(null);
28392 * // => false
28393 */
28394function isObjectLike(value) {
28395 return value != null && typeof value == 'object';
28396}
28397
28398module.exports = isObjectLike;
28399
28400},{}],335:[function(require,module,exports){
28401var baseGetTag = require('./_baseGetTag'),
28402 getPrototype = require('./_getPrototype'),
28403 isObjectLike = require('./isObjectLike');
28404
28405/** `Object#toString` result references. */
28406var objectTag = '[object Object]';
28407
28408/** Used for built-in method references. */
28409var funcProto = Function.prototype,
28410 objectProto = Object.prototype;
28411
28412/** Used to resolve the decompiled source of functions. */
28413var funcToString = funcProto.toString;
28414
28415/** Used to check objects for own properties. */
28416var hasOwnProperty = objectProto.hasOwnProperty;
28417
28418/** Used to infer the `Object` constructor. */
28419var objectCtorString = funcToString.call(Object);
28420
28421/**
28422 * Checks if `value` is a plain object, that is, an object created by the
28423 * `Object` constructor or one with a `[[Prototype]]` of `null`.
28424 *
28425 * @static
28426 * @memberOf _
28427 * @since 0.8.0
28428 * @category Lang
28429 * @param {*} value The value to check.
28430 * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
28431 * @example
28432 *
28433 * function Foo() {
28434 * this.a = 1;
28435 * }
28436 *
28437 * _.isPlainObject(new Foo);
28438 * // => false
28439 *
28440 * _.isPlainObject([1, 2, 3]);
28441 * // => false
28442 *
28443 * _.isPlainObject({ 'x': 0, 'y': 0 });
28444 * // => true
28445 *
28446 * _.isPlainObject(Object.create(null));
28447 * // => true
28448 */
28449function isPlainObject(value) {
28450 if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
28451 return false;
28452 }
28453 var proto = getPrototype(value);
28454 if (proto === null) {
28455 return true;
28456 }
28457 var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
28458 return typeof Ctor == 'function' && Ctor instanceof Ctor &&
28459 funcToString.call(Ctor) == objectCtorString;
28460}
28461
28462module.exports = isPlainObject;
28463
28464},{"./_baseGetTag":184,"./_getPrototype":246,"./isObjectLike":334}],336:[function(require,module,exports){
28465var baseIsSet = require('./_baseIsSet'),
28466 baseUnary = require('./_baseUnary'),
28467 nodeUtil = require('./_nodeUtil');
28468
28469/* Node.js helper references. */
28470var nodeIsSet = nodeUtil && nodeUtil.isSet;
28471
28472/**
28473 * Checks if `value` is classified as a `Set` object.
28474 *
28475 * @static
28476 * @memberOf _
28477 * @since 4.3.0
28478 * @category Lang
28479 * @param {*} value The value to check.
28480 * @returns {boolean} Returns `true` if `value` is a set, else `false`.
28481 * @example
28482 *
28483 * _.isSet(new Set);
28484 * // => true
28485 *
28486 * _.isSet(new WeakSet);
28487 * // => false
28488 */
28489var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
28490
28491module.exports = isSet;
28492
28493},{"./_baseIsSet":194,"./_baseUnary":213,"./_nodeUtil":286}],337:[function(require,module,exports){
28494var baseGetTag = require('./_baseGetTag'),
28495 isArray = require('./isArray'),
28496 isObjectLike = require('./isObjectLike');
28497
28498/** `Object#toString` result references. */
28499var stringTag = '[object String]';
28500
28501/**
28502 * Checks if `value` is classified as a `String` primitive or object.
28503 *
28504 * @static
28505 * @since 0.1.0
28506 * @memberOf _
28507 * @category Lang
28508 * @param {*} value The value to check.
28509 * @returns {boolean} Returns `true` if `value` is a string, else `false`.
28510 * @example
28511 *
28512 * _.isString('abc');
28513 * // => true
28514 *
28515 * _.isString(1);
28516 * // => false
28517 */
28518function isString(value) {
28519 return typeof value == 'string' ||
28520 (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
28521}
28522
28523module.exports = isString;
28524
28525},{"./_baseGetTag":184,"./isArray":323,"./isObjectLike":334}],338:[function(require,module,exports){
28526var baseGetTag = require('./_baseGetTag'),
28527 isObjectLike = require('./isObjectLike');
28528
28529/** `Object#toString` result references. */
28530var symbolTag = '[object Symbol]';
28531
28532/**
28533 * Checks if `value` is classified as a `Symbol` primitive or object.
28534 *
28535 * @static
28536 * @memberOf _
28537 * @since 4.0.0
28538 * @category Lang
28539 * @param {*} value The value to check.
28540 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
28541 * @example
28542 *
28543 * _.isSymbol(Symbol.iterator);
28544 * // => true
28545 *
28546 * _.isSymbol('abc');
28547 * // => false
28548 */
28549function isSymbol(value) {
28550 return typeof value == 'symbol' ||
28551 (isObjectLike(value) && baseGetTag(value) == symbolTag);
28552}
28553
28554module.exports = isSymbol;
28555
28556},{"./_baseGetTag":184,"./isObjectLike":334}],339:[function(require,module,exports){
28557var baseIsTypedArray = require('./_baseIsTypedArray'),
28558 baseUnary = require('./_baseUnary'),
28559 nodeUtil = require('./_nodeUtil');
28560
28561/* Node.js helper references. */
28562var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
28563
28564/**
28565 * Checks if `value` is classified as a typed array.
28566 *
28567 * @static
28568 * @memberOf _
28569 * @since 3.0.0
28570 * @category Lang
28571 * @param {*} value The value to check.
28572 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
28573 * @example
28574 *
28575 * _.isTypedArray(new Uint8Array);
28576 * // => true
28577 *
28578 * _.isTypedArray([]);
28579 * // => false
28580 */
28581var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
28582
28583module.exports = isTypedArray;
28584
28585},{"./_baseIsTypedArray":195,"./_baseUnary":213,"./_nodeUtil":286}],340:[function(require,module,exports){
28586/**
28587 * Checks if `value` is `undefined`.
28588 *
28589 * @static
28590 * @since 0.1.0
28591 * @memberOf _
28592 * @category Lang
28593 * @param {*} value The value to check.
28594 * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
28595 * @example
28596 *
28597 * _.isUndefined(void 0);
28598 * // => true
28599 *
28600 * _.isUndefined(null);
28601 * // => false
28602 */
28603function isUndefined(value) {
28604 return value === undefined;
28605}
28606
28607module.exports = isUndefined;
28608
28609},{}],341:[function(require,module,exports){
28610var arrayLikeKeys = require('./_arrayLikeKeys'),
28611 baseKeys = require('./_baseKeys'),
28612 isArrayLike = require('./isArrayLike');
28613
28614/**
28615 * Creates an array of the own enumerable property names of `object`.
28616 *
28617 * **Note:** Non-object values are coerced to objects. See the
28618 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
28619 * for more details.
28620 *
28621 * @static
28622 * @since 0.1.0
28623 * @memberOf _
28624 * @category Object
28625 * @param {Object} object The object to query.
28626 * @returns {Array} Returns the array of property names.
28627 * @example
28628 *
28629 * function Foo() {
28630 * this.a = 1;
28631 * this.b = 2;
28632 * }
28633 *
28634 * Foo.prototype.c = 3;
28635 *
28636 * _.keys(new Foo);
28637 * // => ['a', 'b'] (iteration order is not guaranteed)
28638 *
28639 * _.keys('hi');
28640 * // => ['0', '1']
28641 */
28642function keys(object) {
28643 return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
28644}
28645
28646module.exports = keys;
28647
28648},{"./_arrayLikeKeys":163,"./_baseKeys":197,"./isArrayLike":324}],342:[function(require,module,exports){
28649var arrayLikeKeys = require('./_arrayLikeKeys'),
28650 baseKeysIn = require('./_baseKeysIn'),
28651 isArrayLike = require('./isArrayLike');
28652
28653/**
28654 * Creates an array of the own and inherited enumerable property names of `object`.
28655 *
28656 * **Note:** Non-object values are coerced to objects.
28657 *
28658 * @static
28659 * @memberOf _
28660 * @since 3.0.0
28661 * @category Object
28662 * @param {Object} object The object to query.
28663 * @returns {Array} Returns the array of property names.
28664 * @example
28665 *
28666 * function Foo() {
28667 * this.a = 1;
28668 * this.b = 2;
28669 * }
28670 *
28671 * Foo.prototype.c = 3;
28672 *
28673 * _.keysIn(new Foo);
28674 * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
28675 */
28676function keysIn(object) {
28677 return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
28678}
28679
28680module.exports = keysIn;
28681
28682},{"./_arrayLikeKeys":163,"./_baseKeysIn":198,"./isArrayLike":324}],343:[function(require,module,exports){
28683var arrayMap = require('./_arrayMap'),
28684 baseIteratee = require('./_baseIteratee'),
28685 baseMap = require('./_baseMap'),
28686 isArray = require('./isArray');
28687
28688/**
28689 * Creates an array of values by running each element in `collection` thru
28690 * `iteratee`. The iteratee is invoked with three arguments:
28691 * (value, index|key, collection).
28692 *
28693 * Many lodash methods are guarded to work as iteratees for methods like
28694 * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
28695 *
28696 * The guarded methods are:
28697 * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
28698 * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
28699 * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
28700 * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
28701 *
28702 * @static
28703 * @memberOf _
28704 * @since 0.1.0
28705 * @category Collection
28706 * @param {Array|Object} collection The collection to iterate over.
28707 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
28708 * @returns {Array} Returns the new mapped array.
28709 * @example
28710 *
28711 * function square(n) {
28712 * return n * n;
28713 * }
28714 *
28715 * _.map([4, 8], square);
28716 * // => [16, 64]
28717 *
28718 * _.map({ 'a': 4, 'b': 8 }, square);
28719 * // => [16, 64] (iteration order is not guaranteed)
28720 *
28721 * var users = [
28722 * { 'user': 'barney' },
28723 * { 'user': 'fred' }
28724 * ];
28725 *
28726 * // The `_.property` iteratee shorthand.
28727 * _.map(users, 'user');
28728 * // => ['barney', 'fred']
28729 */
28730function map(collection, iteratee) {
28731 var func = isArray(collection) ? arrayMap : baseMap;
28732 return func(collection, baseIteratee(iteratee, 3));
28733}
28734
28735module.exports = map;
28736
28737},{"./_arrayMap":164,"./_baseIteratee":196,"./_baseMap":199,"./isArray":323}],344:[function(require,module,exports){
28738var MapCache = require('./_MapCache');
28739
28740/** Error message constants. */
28741var FUNC_ERROR_TEXT = 'Expected a function';
28742
28743/**
28744 * Creates a function that memoizes the result of `func`. If `resolver` is
28745 * provided, it determines the cache key for storing the result based on the
28746 * arguments provided to the memoized function. By default, the first argument
28747 * provided to the memoized function is used as the map cache key. The `func`
28748 * is invoked with the `this` binding of the memoized function.
28749 *
28750 * **Note:** The cache is exposed as the `cache` property on the memoized
28751 * function. Its creation may be customized by replacing the `_.memoize.Cache`
28752 * constructor with one whose instances implement the
28753 * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
28754 * method interface of `clear`, `delete`, `get`, `has`, and `set`.
28755 *
28756 * @static
28757 * @memberOf _
28758 * @since 0.1.0
28759 * @category Function
28760 * @param {Function} func The function to have its output memoized.
28761 * @param {Function} [resolver] The function to resolve the cache key.
28762 * @returns {Function} Returns the new memoized function.
28763 * @example
28764 *
28765 * var object = { 'a': 1, 'b': 2 };
28766 * var other = { 'c': 3, 'd': 4 };
28767 *
28768 * var values = _.memoize(_.values);
28769 * values(object);
28770 * // => [1, 2]
28771 *
28772 * values(other);
28773 * // => [3, 4]
28774 *
28775 * object.a = 2;
28776 * values(object);
28777 * // => [1, 2]
28778 *
28779 * // Modify the result cache.
28780 * values.cache.set(object, ['a', 'b']);
28781 * values(object);
28782 * // => ['a', 'b']
28783 *
28784 * // Replace `_.memoize.Cache`.
28785 * _.memoize.Cache = WeakMap;
28786 */
28787function memoize(func, resolver) {
28788 if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
28789 throw new TypeError(FUNC_ERROR_TEXT);
28790 }
28791 var memoized = function() {
28792 var args = arguments,
28793 key = resolver ? resolver.apply(this, args) : args[0],
28794 cache = memoized.cache;
28795
28796 if (cache.has(key)) {
28797 return cache.get(key);
28798 }
28799 var result = func.apply(this, args);
28800 memoized.cache = cache.set(key, result) || cache;
28801 return result;
28802 };
28803 memoized.cache = new (memoize.Cache || MapCache);
28804 return memoized;
28805}
28806
28807// Expose `MapCache`.
28808memoize.Cache = MapCache;
28809
28810module.exports = memoize;
28811
28812},{"./_MapCache":151}],345:[function(require,module,exports){
28813var createPadding = require('./_createPadding'),
28814 stringSize = require('./_stringSize'),
28815 toInteger = require('./toInteger'),
28816 toString = require('./toString');
28817
28818/**
28819 * Pads `string` on the right side if it's shorter than `length`. Padding
28820 * characters are truncated if they exceed `length`.
28821 *
28822 * @static
28823 * @memberOf _
28824 * @since 4.0.0
28825 * @category String
28826 * @param {string} [string=''] The string to pad.
28827 * @param {number} [length=0] The padding length.
28828 * @param {string} [chars=' '] The string used as padding.
28829 * @returns {string} Returns the padded string.
28830 * @example
28831 *
28832 * _.padEnd('abc', 6);
28833 * // => 'abc '
28834 *
28835 * _.padEnd('abc', 6, '_-');
28836 * // => 'abc_-_'
28837 *
28838 * _.padEnd('abc', 3);
28839 * // => 'abc'
28840 */
28841function padEnd(string, length, chars) {
28842 string = toString(string);
28843 length = toInteger(length);
28844
28845 var strLength = length ? stringSize(string) : 0;
28846 return (length && strLength < length)
28847 ? (string + createPadding(length - strLength, chars))
28848 : string;
28849}
28850
28851module.exports = padEnd;
28852
28853},{"./_createPadding":234,"./_stringSize":302,"./toInteger":352,"./toString":354}],346:[function(require,module,exports){
28854var basePick = require('./_basePick'),
28855 flatRest = require('./_flatRest');
28856
28857/**
28858 * Creates an object composed of the picked `object` properties.
28859 *
28860 * @static
28861 * @since 0.1.0
28862 * @memberOf _
28863 * @category Object
28864 * @param {Object} object The source object.
28865 * @param {...(string|string[])} [paths] The property paths to pick.
28866 * @returns {Object} Returns the new object.
28867 * @example
28868 *
28869 * var object = { 'a': 1, 'b': '2', 'c': 3 };
28870 *
28871 * _.pick(object, ['a', 'c']);
28872 * // => { 'a': 1, 'c': 3 }
28873 */
28874var pick = flatRest(function(object, paths) {
28875 return object == null ? {} : basePick(object, paths);
28876});
28877
28878module.exports = pick;
28879
28880},{"./_basePick":202,"./_flatRest":239}],347:[function(require,module,exports){
28881var baseProperty = require('./_baseProperty'),
28882 basePropertyDeep = require('./_basePropertyDeep'),
28883 isKey = require('./_isKey'),
28884 toKey = require('./_toKey');
28885
28886/**
28887 * Creates a function that returns the value at `path` of a given object.
28888 *
28889 * @static
28890 * @memberOf _
28891 * @since 2.4.0
28892 * @category Util
28893 * @param {Array|string} path The path of the property to get.
28894 * @returns {Function} Returns the new accessor function.
28895 * @example
28896 *
28897 * var objects = [
28898 * { 'a': { 'b': 2 } },
28899 * { 'a': { 'b': 1 } }
28900 * ];
28901 *
28902 * _.map(objects, _.property('a.b'));
28903 * // => [2, 1]
28904 *
28905 * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
28906 * // => [1, 2]
28907 */
28908function property(path) {
28909 return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
28910}
28911
28912module.exports = property;
28913
28914},{"./_baseProperty":204,"./_basePropertyDeep":205,"./_isKey":265,"./_toKey":305}],348:[function(require,module,exports){
28915/**
28916 * This method returns a new empty array.
28917 *
28918 * @static
28919 * @memberOf _
28920 * @since 4.13.0
28921 * @category Util
28922 * @returns {Array} Returns the new empty array.
28923 * @example
28924 *
28925 * var arrays = _.times(2, _.stubArray);
28926 *
28927 * console.log(arrays);
28928 * // => [[], []]
28929 *
28930 * console.log(arrays[0] === arrays[1]);
28931 * // => false
28932 */
28933function stubArray() {
28934 return [];
28935}
28936
28937module.exports = stubArray;
28938
28939},{}],349:[function(require,module,exports){
28940/**
28941 * This method returns `false`.
28942 *
28943 * @static
28944 * @memberOf _
28945 * @since 4.13.0
28946 * @category Util
28947 * @returns {boolean} Returns `false`.
28948 * @example
28949 *
28950 * _.times(2, _.stubFalse);
28951 * // => [false, false]
28952 */
28953function stubFalse() {
28954 return false;
28955}
28956
28957module.exports = stubFalse;
28958
28959},{}],350:[function(require,module,exports){
28960var baseTimes = require('./_baseTimes'),
28961 castFunction = require('./_castFunction'),
28962 toInteger = require('./toInteger');
28963
28964/** Used as references for various `Number` constants. */
28965var MAX_SAFE_INTEGER = 9007199254740991;
28966
28967/** Used as references for the maximum length and index of an array. */
28968var MAX_ARRAY_LENGTH = 4294967295;
28969
28970/* Built-in method references for those with the same name as other `lodash` methods. */
28971var nativeMin = Math.min;
28972
28973/**
28974 * Invokes the iteratee `n` times, returning an array of the results of
28975 * each invocation. The iteratee is invoked with one argument; (index).
28976 *
28977 * @static
28978 * @since 0.1.0
28979 * @memberOf _
28980 * @category Util
28981 * @param {number} n The number of times to invoke `iteratee`.
28982 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
28983 * @returns {Array} Returns the array of results.
28984 * @example
28985 *
28986 * _.times(3, String);
28987 * // => ['0', '1', '2']
28988 *
28989 * _.times(4, _.constant(0));
28990 * // => [0, 0, 0, 0]
28991 */
28992function times(n, iteratee) {
28993 n = toInteger(n);
28994 if (n < 1 || n > MAX_SAFE_INTEGER) {
28995 return [];
28996 }
28997 var index = MAX_ARRAY_LENGTH,
28998 length = nativeMin(n, MAX_ARRAY_LENGTH);
28999
29000 iteratee = castFunction(iteratee);
29001 n -= MAX_ARRAY_LENGTH;
29002
29003 var result = baseTimes(length, iteratee);
29004 while (++index < n) {
29005 iteratee(index);
29006 }
29007 return result;
29008}
29009
29010module.exports = times;
29011
29012},{"./_baseTimes":211,"./_castFunction":216,"./toInteger":352}],351:[function(require,module,exports){
29013var toNumber = require('./toNumber');
29014
29015/** Used as references for various `Number` constants. */
29016var INFINITY = 1 / 0,
29017 MAX_INTEGER = 1.7976931348623157e+308;
29018
29019/**
29020 * Converts `value` to a finite number.
29021 *
29022 * @static
29023 * @memberOf _
29024 * @since 4.12.0
29025 * @category Lang
29026 * @param {*} value The value to convert.
29027 * @returns {number} Returns the converted number.
29028 * @example
29029 *
29030 * _.toFinite(3.2);
29031 * // => 3.2
29032 *
29033 * _.toFinite(Number.MIN_VALUE);
29034 * // => 5e-324
29035 *
29036 * _.toFinite(Infinity);
29037 * // => 1.7976931348623157e+308
29038 *
29039 * _.toFinite('3.2');
29040 * // => 3.2
29041 */
29042function toFinite(value) {
29043 if (!value) {
29044 return value === 0 ? value : 0;
29045 }
29046 value = toNumber(value);
29047 if (value === INFINITY || value === -INFINITY) {
29048 var sign = (value < 0 ? -1 : 1);
29049 return sign * MAX_INTEGER;
29050 }
29051 return value === value ? value : 0;
29052}
29053
29054module.exports = toFinite;
29055
29056},{"./toNumber":353}],352:[function(require,module,exports){
29057var toFinite = require('./toFinite');
29058
29059/**
29060 * Converts `value` to an integer.
29061 *
29062 * **Note:** This method is loosely based on
29063 * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
29064 *
29065 * @static
29066 * @memberOf _
29067 * @since 4.0.0
29068 * @category Lang
29069 * @param {*} value The value to convert.
29070 * @returns {number} Returns the converted integer.
29071 * @example
29072 *
29073 * _.toInteger(3.2);
29074 * // => 3
29075 *
29076 * _.toInteger(Number.MIN_VALUE);
29077 * // => 0
29078 *
29079 * _.toInteger(Infinity);
29080 * // => 1.7976931348623157e+308
29081 *
29082 * _.toInteger('3.2');
29083 * // => 3
29084 */
29085function toInteger(value) {
29086 var result = toFinite(value),
29087 remainder = result % 1;
29088
29089 return result === result ? (remainder ? result - remainder : result) : 0;
29090}
29091
29092module.exports = toInteger;
29093
29094},{"./toFinite":351}],353:[function(require,module,exports){
29095var isObject = require('./isObject'),
29096 isSymbol = require('./isSymbol');
29097
29098/** Used as references for various `Number` constants. */
29099var NAN = 0 / 0;
29100
29101/** Used to match leading and trailing whitespace. */
29102var reTrim = /^\s+|\s+$/g;
29103
29104/** Used to detect bad signed hexadecimal string values. */
29105var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
29106
29107/** Used to detect binary string values. */
29108var reIsBinary = /^0b[01]+$/i;
29109
29110/** Used to detect octal string values. */
29111var reIsOctal = /^0o[0-7]+$/i;
29112
29113/** Built-in method references without a dependency on `root`. */
29114var freeParseInt = parseInt;
29115
29116/**
29117 * Converts `value` to a number.
29118 *
29119 * @static
29120 * @memberOf _
29121 * @since 4.0.0
29122 * @category Lang
29123 * @param {*} value The value to process.
29124 * @returns {number} Returns the number.
29125 * @example
29126 *
29127 * _.toNumber(3.2);
29128 * // => 3.2
29129 *
29130 * _.toNumber(Number.MIN_VALUE);
29131 * // => 5e-324
29132 *
29133 * _.toNumber(Infinity);
29134 * // => Infinity
29135 *
29136 * _.toNumber('3.2');
29137 * // => 3.2
29138 */
29139function toNumber(value) {
29140 if (typeof value == 'number') {
29141 return value;
29142 }
29143 if (isSymbol(value)) {
29144 return NAN;
29145 }
29146 if (isObject(value)) {
29147 var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
29148 value = isObject(other) ? (other + '') : other;
29149 }
29150 if (typeof value != 'string') {
29151 return value === 0 ? value : +value;
29152 }
29153 value = value.replace(reTrim, '');
29154 var isBinary = reIsBinary.test(value);
29155 return (isBinary || reIsOctal.test(value))
29156 ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
29157 : (reIsBadHex.test(value) ? NAN : +value);
29158}
29159
29160module.exports = toNumber;
29161
29162},{"./isObject":333,"./isSymbol":338}],354:[function(require,module,exports){
29163var baseToString = require('./_baseToString');
29164
29165/**
29166 * Converts `value` to a string. An empty string is returned for `null`
29167 * and `undefined` values. The sign of `-0` is preserved.
29168 *
29169 * @static
29170 * @memberOf _
29171 * @since 4.0.0
29172 * @category Lang
29173 * @param {*} value The value to convert.
29174 * @returns {string} Returns the converted string.
29175 * @example
29176 *
29177 * _.toString(null);
29178 * // => ''
29179 *
29180 * _.toString(-0);
29181 * // => '-0'
29182 *
29183 * _.toString([1, 2, 3]);
29184 * // => '1,2,3'
29185 */
29186function toString(value) {
29187 return value == null ? '' : baseToString(value);
29188}
29189
29190module.exports = toString;
29191
29192},{"./_baseToString":212}],355:[function(require,module,exports){
29193var baseToString = require('./_baseToString'),
29194 castSlice = require('./_castSlice'),
29195 charsEndIndex = require('./_charsEndIndex'),
29196 stringToArray = require('./_stringToArray'),
29197 toString = require('./toString');
29198
29199/** Used to match leading and trailing whitespace. */
29200var reTrimEnd = /\s+$/;
29201
29202/**
29203 * Removes trailing whitespace or specified characters from `string`.
29204 *
29205 * @static
29206 * @memberOf _
29207 * @since 4.0.0
29208 * @category String
29209 * @param {string} [string=''] The string to trim.
29210 * @param {string} [chars=whitespace] The characters to trim.
29211 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
29212 * @returns {string} Returns the trimmed string.
29213 * @example
29214 *
29215 * _.trimEnd(' abc ');
29216 * // => ' abc'
29217 *
29218 * _.trimEnd('-_-abc-_-', '_-');
29219 * // => '-_-abc'
29220 */
29221function trimEnd(string, chars, guard) {
29222 string = toString(string);
29223 if (string && (guard || chars === undefined)) {
29224 return string.replace(reTrimEnd, '');
29225 }
29226 if (!string || !(chars = baseToString(chars))) {
29227 return string;
29228 }
29229 var strSymbols = stringToArray(string),
29230 end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
29231
29232 return castSlice(strSymbols, 0, end).join('');
29233}
29234
29235module.exports = trimEnd;
29236
29237},{"./_baseToString":212,"./_castSlice":218,"./_charsEndIndex":219,"./_stringToArray":303,"./toString":354}],356:[function(require,module,exports){
29238var baseValues = require('./_baseValues'),
29239 keys = require('./keys');
29240
29241/**
29242 * Creates an array of the own enumerable string keyed property values of `object`.
29243 *
29244 * **Note:** Non-object values are coerced to objects.
29245 *
29246 * @static
29247 * @since 0.1.0
29248 * @memberOf _
29249 * @category Object
29250 * @param {Object} object The object to query.
29251 * @returns {Array} Returns the array of property values.
29252 * @example
29253 *
29254 * function Foo() {
29255 * this.a = 1;
29256 * this.b = 2;
29257 * }
29258 *
29259 * Foo.prototype.c = 3;
29260 *
29261 * _.values(new Foo);
29262 * // => [1, 2] (iteration order is not guaranteed)
29263 *
29264 * _.values('hi');
29265 * // => ['h', 'i']
29266 */
29267function values(object) {
29268 return object == null ? [] : baseValues(object, keys(object));
29269}
29270
29271module.exports = values;
29272
29273},{"./_baseValues":214,"./keys":341}],357:[function(require,module,exports){
29274/*
29275 Copyright 2013 Daniel Wirtz <dcode@dcode.io>
29276 Copyright 2009 The Closure Library Authors. All Rights Reserved.
29277
29278 Licensed under the Apache License, Version 2.0 (the "License");
29279 you may not use this file except in compliance with the License.
29280 You may obtain a copy of the License at
29281
29282 http://www.apache.org/licenses/LICENSE-2.0
29283
29284 Unless required by applicable law or agreed to in writing, software
29285 distributed under the License is distributed on an "AS-IS" BASIS,
29286 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29287 See the License for the specific language governing permissions and
29288 limitations under the License.
29289 */
29290
29291/**
29292 * @license Long.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
29293 * Released under the Apache License, Version 2.0
29294 * see: https://github.com/dcodeIO/Long.js for details
29295 */
29296(function(global, factory) {
29297
29298 /* AMD */ if (typeof define === 'function' && define["amd"])
29299 define([], factory);
29300 /* CommonJS */ else if (typeof require === 'function' && typeof module === "object" && module && module["exports"])
29301 module["exports"] = factory();
29302 /* Global */ else
29303 (global["dcodeIO"] = global["dcodeIO"] || {})["Long"] = factory();
29304
29305})(this, function() {
29306 "use strict";
29307
29308 /**
29309 * Constructs a 64 bit two's-complement integer, given its low and high 32 bit values as *signed* integers.
29310 * See the from* functions below for more convenient ways of constructing Longs.
29311 * @exports Long
29312 * @class A Long class for representing a 64 bit two's-complement integer value.
29313 * @param {number} low The low (signed) 32 bits of the long
29314 * @param {number} high The high (signed) 32 bits of the long
29315 * @param {boolean=} unsigned Whether unsigned or not, defaults to `false` for signed
29316 * @constructor
29317 */
29318 function Long(low, high, unsigned) {
29319
29320 /**
29321 * The low 32 bits as a signed value.
29322 * @type {number}
29323 * @expose
29324 */
29325 this.low = low|0;
29326
29327 /**
29328 * The high 32 bits as a signed value.
29329 * @type {number}
29330 * @expose
29331 */
29332 this.high = high|0;
29333
29334 /**
29335 * Whether unsigned or not.
29336 * @type {boolean}
29337 * @expose
29338 */
29339 this.unsigned = !!unsigned;
29340 }
29341
29342 // The internal representation of a long is the two given signed, 32-bit values.
29343 // We use 32-bit pieces because these are the size of integers on which
29344 // Javascript performs bit-operations. For operations like addition and
29345 // multiplication, we split each number into 16 bit pieces, which can easily be
29346 // multiplied within Javascript's floating-point representation without overflow
29347 // or change in sign.
29348 //
29349 // In the algorithms below, we frequently reduce the negative case to the
29350 // positive case by negating the input(s) and then post-processing the result.
29351 // Note that we must ALWAYS check specially whether those values are MIN_VALUE
29352 // (-2^63) because -MIN_VALUE == MIN_VALUE (since 2^63 cannot be represented as
29353 // a positive number, it overflows back into a negative). Not handling this
29354 // case would often result in infinite recursion.
29355 //
29356 // Common constant values ZERO, ONE, NEG_ONE, etc. are defined below the from*
29357 // methods on which they depend.
29358
29359 /**
29360 * An indicator used to reliably determine if an object is a Long or not.
29361 * @type {boolean}
29362 * @const
29363 * @expose
29364 * @private
29365 */
29366 Long.__isLong__;
29367
29368 Object.defineProperty(Long.prototype, "__isLong__", {
29369 value: true,
29370 enumerable: false,
29371 configurable: false
29372 });
29373
29374 /**
29375 * Tests if the specified object is a Long.
29376 * @param {*} obj Object
29377 * @returns {boolean}
29378 * @expose
29379 */
29380 Long.isLong = function isLong(obj) {
29381 return (obj && obj["__isLong__"]) === true;
29382 };
29383
29384 /**
29385 * A cache of the Long representations of small integer values.
29386 * @type {!Object}
29387 * @inner
29388 */
29389 var INT_CACHE = {};
29390
29391 /**
29392 * A cache of the Long representations of small unsigned integer values.
29393 * @type {!Object}
29394 * @inner
29395 */
29396 var UINT_CACHE = {};
29397
29398 /**
29399 * Returns a Long representing the given 32 bit integer value.
29400 * @param {number} value The 32 bit integer in question
29401 * @param {boolean=} unsigned Whether unsigned or not, defaults to `false` for signed
29402 * @returns {!Long} The corresponding Long value
29403 * @expose
29404 */
29405 Long.fromInt = function fromInt(value, unsigned) {
29406 var obj, cachedObj;
29407 if (!unsigned) {
29408 value = value | 0;
29409 if (-128 <= value && value < 128) {
29410 cachedObj = INT_CACHE[value];
29411 if (cachedObj)
29412 return cachedObj;
29413 }
29414 obj = new Long(value, value < 0 ? -1 : 0, false);
29415 if (-128 <= value && value < 128)
29416 INT_CACHE[value] = obj;
29417 return obj;
29418 } else {
29419 value = value >>> 0;
29420 if (0 <= value && value < 256) {
29421 cachedObj = UINT_CACHE[value];
29422 if (cachedObj)
29423 return cachedObj;
29424 }
29425 obj = new Long(value, (value | 0) < 0 ? -1 : 0, true);
29426 if (0 <= value && value < 256)
29427 UINT_CACHE[value] = obj;
29428 return obj;
29429 }
29430 };
29431
29432 /**
29433 * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
29434 * @param {number} value The number in question
29435 * @param {boolean=} unsigned Whether unsigned or not, defaults to `false` for signed
29436 * @returns {!Long} The corresponding Long value
29437 * @expose
29438 */
29439 Long.fromNumber = function fromNumber(value, unsigned) {
29440 unsigned = !!unsigned;
29441 if (isNaN(value) || !isFinite(value))
29442 return Long.ZERO;
29443 if (!unsigned && value <= -TWO_PWR_63_DBL)
29444 return Long.MIN_VALUE;
29445 if (!unsigned && value + 1 >= TWO_PWR_63_DBL)
29446 return Long.MAX_VALUE;
29447 if (unsigned && value >= TWO_PWR_64_DBL)
29448 return Long.MAX_UNSIGNED_VALUE;
29449 if (value < 0)
29450 return Long.fromNumber(-value, unsigned).negate();
29451 return new Long((value % TWO_PWR_32_DBL) | 0, (value / TWO_PWR_32_DBL) | 0, unsigned);
29452 };
29453
29454 /**
29455 * Returns a Long representing the 64 bit integer that comes by concatenating the given low and high bits. Each is
29456 * assumed to use 32 bits.
29457 * @param {number} lowBits The low 32 bits
29458 * @param {number} highBits The high 32 bits
29459 * @param {boolean=} unsigned Whether unsigned or not, defaults to `false` for signed
29460 * @returns {!Long} The corresponding Long value
29461 * @expose
29462 */
29463 Long.fromBits = function fromBits(lowBits, highBits, unsigned) {
29464 return new Long(lowBits, highBits, unsigned);
29465 };
29466
29467 /**
29468 * Returns a Long representation of the given string, written using the specified radix.
29469 * @param {string} str The textual representation of the Long
29470 * @param {(boolean|number)=} unsigned Whether unsigned or not, defaults to `false` for signed
29471 * @param {number=} radix The radix in which the text is written (2-36), defaults to 10
29472 * @returns {!Long} The corresponding Long value
29473 * @expose
29474 */
29475 Long.fromString = function fromString(str, unsigned, radix) {
29476 if (str.length === 0)
29477 throw Error('number format error: empty string');
29478 if (str === "NaN" || str === "Infinity" || str === "+Infinity" || str === "-Infinity")
29479 return Long.ZERO;
29480 if (typeof unsigned === 'number') // For goog.math.long compatibility
29481 radix = unsigned,
29482 unsigned = false;
29483 radix = radix || 10;
29484 if (radix < 2 || 36 < radix)
29485 throw Error('radix out of range: ' + radix);
29486
29487 var p;
29488 if ((p = str.indexOf('-')) > 0)
29489 throw Error('number format error: interior "-" character: ' + str);
29490 else if (p === 0)
29491 return Long.fromString(str.substring(1), unsigned, radix).negate();
29492
29493 // Do several (8) digits each time through the loop, so as to
29494 // minimize the calls to the very expensive emulated div.
29495 var radixToPower = Long.fromNumber(Math.pow(radix, 8));
29496
29497 var result = Long.ZERO;
29498 for (var i = 0; i < str.length; i += 8) {
29499 var size = Math.min(8, str.length - i);
29500 var value = parseInt(str.substring(i, i + size), radix);
29501 if (size < 8) {
29502 var power = Long.fromNumber(Math.pow(radix, size));
29503 result = result.multiply(power).add(Long.fromNumber(value));
29504 } else {
29505 result = result.multiply(radixToPower);
29506 result = result.add(Long.fromNumber(value));
29507 }
29508 }
29509 result.unsigned = unsigned;
29510 return result;
29511 };
29512
29513 /**
29514 * Converts the specified value to a Long.
29515 * @param {!Long|number|string|!{low: number, high: number, unsigned: boolean}} val Value
29516 * @returns {!Long}
29517 * @expose
29518 */
29519 Long.fromValue = function fromValue(val) {
29520 if (val /* is compatible */ instanceof Long)
29521 return val;
29522 if (typeof val === 'number')
29523 return Long.fromNumber(val);
29524 if (typeof val === 'string')
29525 return Long.fromString(val);
29526 // Throws for non-objects, converts non-instanceof Long:
29527 return new Long(val.low, val.high, val.unsigned);
29528 };
29529
29530 // NOTE: the compiler should inline these constant values below and then remove these variables, so there should be
29531 // no runtime penalty for these.
29532
29533 /**
29534 * @type {number}
29535 * @const
29536 * @inner
29537 */
29538 var TWO_PWR_16_DBL = 1 << 16;
29539
29540 /**
29541 * @type {number}
29542 * @const
29543 * @inner
29544 */
29545 var TWO_PWR_24_DBL = 1 << 24;
29546
29547 /**
29548 * @type {number}
29549 * @const
29550 * @inner
29551 */
29552 var TWO_PWR_32_DBL = TWO_PWR_16_DBL * TWO_PWR_16_DBL;
29553
29554 /**
29555 * @type {number}
29556 * @const
29557 * @inner
29558 */
29559 var TWO_PWR_64_DBL = TWO_PWR_32_DBL * TWO_PWR_32_DBL;
29560
29561 /**
29562 * @type {number}
29563 * @const
29564 * @inner
29565 */
29566 var TWO_PWR_63_DBL = TWO_PWR_64_DBL / 2;
29567
29568 /**
29569 * @type {!Long}
29570 * @const
29571 * @inner
29572 */
29573 var TWO_PWR_24 = Long.fromInt(TWO_PWR_24_DBL);
29574
29575 /**
29576 * Signed zero.
29577 * @type {!Long}
29578 * @expose
29579 */
29580 Long.ZERO = Long.fromInt(0);
29581
29582 /**
29583 * Unsigned zero.
29584 * @type {!Long}
29585 * @expose
29586 */
29587 Long.UZERO = Long.fromInt(0, true);
29588
29589 /**
29590 * Signed one.
29591 * @type {!Long}
29592 * @expose
29593 */
29594 Long.ONE = Long.fromInt(1);
29595
29596 /**
29597 * Unsigned one.
29598 * @type {!Long}
29599 * @expose
29600 */
29601 Long.UONE = Long.fromInt(1, true);
29602
29603 /**
29604 * Signed negative one.
29605 * @type {!Long}
29606 * @expose
29607 */
29608 Long.NEG_ONE = Long.fromInt(-1);
29609
29610 /**
29611 * Maximum signed value.
29612 * @type {!Long}
29613 * @expose
29614 */
29615 Long.MAX_VALUE = Long.fromBits(0xFFFFFFFF|0, 0x7FFFFFFF|0, false);
29616
29617 /**
29618 * Maximum unsigned value.
29619 * @type {!Long}
29620 * @expose
29621 */
29622 Long.MAX_UNSIGNED_VALUE = Long.fromBits(0xFFFFFFFF|0, 0xFFFFFFFF|0, true);
29623
29624 /**
29625 * Minimum signed value.
29626 * @type {!Long}
29627 * @expose
29628 */
29629 Long.MIN_VALUE = Long.fromBits(0, 0x80000000|0, false);
29630
29631 /**
29632 * Converts the Long to a 32 bit integer, assuming it is a 32 bit integer.
29633 * @returns {number}
29634 * @expose
29635 */
29636 Long.prototype.toInt = function toInt() {
29637 return this.unsigned ? this.low >>> 0 : this.low;
29638 };
29639
29640 /**
29641 * Converts the Long to a the nearest floating-point representation of this value (double, 53 bit mantissa).
29642 * @returns {number}
29643 * @expose
29644 */
29645 Long.prototype.toNumber = function toNumber() {
29646 if (this.unsigned) {
29647 return ((this.high >>> 0) * TWO_PWR_32_DBL) + (this.low >>> 0);
29648 }
29649 return this.high * TWO_PWR_32_DBL + (this.low >>> 0);
29650 };
29651
29652 /**
29653 * Converts the Long to a string written in the specified radix.
29654 * @param {number=} radix Radix (2-36), defaults to 10
29655 * @returns {string}
29656 * @override
29657 * @throws {RangeError} If `radix` is out of range
29658 * @expose
29659 */
29660 Long.prototype.toString = function toString(radix) {
29661 radix = radix || 10;
29662 if (radix < 2 || 36 < radix)
29663 throw RangeError('radix out of range: ' + radix);
29664 if (this.isZero())
29665 return '0';
29666 var rem;
29667 if (this.isNegative()) { // Unsigned Longs are never negative
29668 if (this.equals(Long.MIN_VALUE)) {
29669 // We need to change the Long value before it can be negated, so we remove
29670 // the bottom-most digit in this base and then recurse to do the rest.
29671 var radixLong = Long.fromNumber(radix);
29672 var div = this.divide(radixLong);
29673 rem = div.multiply(radixLong).subtract(this);
29674 return div.toString(radix) + rem.toInt().toString(radix);
29675 } else
29676 return '-' + this.negate().toString(radix);
29677 }
29678
29679 // Do several (6) digits each time through the loop, so as to
29680 // minimize the calls to the very expensive emulated div.
29681 var radixToPower = Long.fromNumber(Math.pow(radix, 6), this.unsigned);
29682 rem = this;
29683 var result = '';
29684 while (true) {
29685 var remDiv = rem.divide(radixToPower),
29686 intval = rem.subtract(remDiv.multiply(radixToPower)).toInt() >>> 0,
29687 digits = intval.toString(radix);
29688 rem = remDiv;
29689 if (rem.isZero())
29690 return digits + result;
29691 else {
29692 while (digits.length < 6)
29693 digits = '0' + digits;
29694 result = '' + digits + result;
29695 }
29696 }
29697 };
29698
29699 /**
29700 * Gets the high 32 bits as a signed integer.
29701 * @returns {number} Signed high bits
29702 * @expose
29703 */
29704 Long.prototype.getHighBits = function getHighBits() {
29705 return this.high;
29706 };
29707
29708 /**
29709 * Gets the high 32 bits as an unsigned integer.
29710 * @returns {number} Unsigned high bits
29711 * @expose
29712 */
29713 Long.prototype.getHighBitsUnsigned = function getHighBitsUnsigned() {
29714 return this.high >>> 0;
29715 };
29716
29717 /**
29718 * Gets the low 32 bits as a signed integer.
29719 * @returns {number} Signed low bits
29720 * @expose
29721 */
29722 Long.prototype.getLowBits = function getLowBits() {
29723 return this.low;
29724 };
29725
29726 /**
29727 * Gets the low 32 bits as an unsigned integer.
29728 * @returns {number} Unsigned low bits
29729 * @expose
29730 */
29731 Long.prototype.getLowBitsUnsigned = function getLowBitsUnsigned() {
29732 return this.low >>> 0;
29733 };
29734
29735 /**
29736 * Gets the number of bits needed to represent the absolute value of this Long.
29737 * @returns {number}
29738 * @expose
29739 */
29740 Long.prototype.getNumBitsAbs = function getNumBitsAbs() {
29741 if (this.isNegative()) // Unsigned Longs are never negative
29742 return this.equals(Long.MIN_VALUE) ? 64 : this.negate().getNumBitsAbs();
29743 var val = this.high != 0 ? this.high : this.low;
29744 for (var bit = 31; bit > 0; bit--)
29745 if ((val & (1 << bit)) != 0)
29746 break;
29747 return this.high != 0 ? bit + 33 : bit + 1;
29748 };
29749
29750 /**
29751 * Tests if this Long's value equals zero.
29752 * @returns {boolean}
29753 * @expose
29754 */
29755 Long.prototype.isZero = function isZero() {
29756 return this.high === 0 && this.low === 0;
29757 };
29758
29759 /**
29760 * Tests if this Long's value is negative.
29761 * @returns {boolean}
29762 * @expose
29763 */
29764 Long.prototype.isNegative = function isNegative() {
29765 return !this.unsigned && this.high < 0;
29766 };
29767
29768 /**
29769 * Tests if this Long's value is positive.
29770 * @returns {boolean}
29771 * @expose
29772 */
29773 Long.prototype.isPositive = function isPositive() {
29774 return this.unsigned || this.high >= 0;
29775 };
29776
29777 /**
29778 * Tests if this Long's value is odd.
29779 * @returns {boolean}
29780 * @expose
29781 */
29782 Long.prototype.isOdd = function isOdd() {
29783 return (this.low & 1) === 1;
29784 };
29785
29786 /**
29787 * Tests if this Long's value is even.
29788 * @returns {boolean}
29789 * @expose
29790 */
29791 Long.prototype.isEven = function isEven() {
29792 return (this.low & 1) === 0;
29793 };
29794
29795 /**
29796 * Tests if this Long's value equals the specified's.
29797 * @param {!Long|number|string} other Other value
29798 * @returns {boolean}
29799 * @expose
29800 */
29801 Long.prototype.equals = function equals(other) {
29802 if (!Long.isLong(other))
29803 other = Long.fromValue(other);
29804 if (this.unsigned !== other.unsigned && (this.high >>> 31) === 1 && (other.high >>> 31) === 1)
29805 return false;
29806 return this.high === other.high && this.low === other.low;
29807 };
29808
29809 /**
29810 * Tests if this Long's value equals the specified's. This is an alias of {@link Long#equals}.
29811 * @function
29812 * @param {!Long|number|string} other Other value
29813 * @returns {boolean}
29814 * @expose
29815 */
29816 Long.eq = Long.prototype.equals;
29817
29818 /**
29819 * Tests if this Long's value differs from the specified's.
29820 * @param {!Long|number|string} other Other value
29821 * @returns {boolean}
29822 * @expose
29823 */
29824 Long.prototype.notEquals = function notEquals(other) {
29825 return !this.equals(/* validates */ other);
29826 };
29827
29828 /**
29829 * Tests if this Long's value differs from the specified's. This is an alias of {@link Long#notEquals}.
29830 * @function
29831 * @param {!Long|number|string} other Other value
29832 * @returns {boolean}
29833 * @expose
29834 */
29835 Long.neq = Long.prototype.notEquals;
29836
29837 /**
29838 * Tests if this Long's value is less than the specified's.
29839 * @param {!Long|number|string} other Other value
29840 * @returns {boolean}
29841 * @expose
29842 */
29843 Long.prototype.lessThan = function lessThan(other) {
29844 return this.compare(/* validates */ other) < 0;
29845 };
29846
29847 /**
29848 * Tests if this Long's value is less than the specified's. This is an alias of {@link Long#lessThan}.
29849 * @function
29850 * @param {!Long|number|string} other Other value
29851 * @returns {boolean}
29852 * @expose
29853 */
29854 Long.prototype.lt = Long.prototype.lessThan;
29855
29856 /**
29857 * Tests if this Long's value is less than or equal the specified's.
29858 * @param {!Long|number|string} other Other value
29859 * @returns {boolean}
29860 * @expose
29861 */
29862 Long.prototype.lessThanOrEqual = function lessThanOrEqual(other) {
29863 return this.compare(/* validates */ other) <= 0;
29864 };
29865
29866 /**
29867 * Tests if this Long's value is less than or equal the specified's. This is an alias of {@link Long#lessThanOrEqual}.
29868 * @function
29869 * @param {!Long|number|string} other Other value
29870 * @returns {boolean}
29871 * @expose
29872 */
29873 Long.prototype.lte = Long.prototype.lessThanOrEqual;
29874
29875 /**
29876 * Tests if this Long's value is greater than the specified's.
29877 * @param {!Long|number|string} other Other value
29878 * @returns {boolean}
29879 * @expose
29880 */
29881 Long.prototype.greaterThan = function greaterThan(other) {
29882 return this.compare(/* validates */ other) > 0;
29883 };
29884
29885 /**
29886 * Tests if this Long's value is greater than the specified's. This is an alias of {@link Long#greaterThan}.
29887 * @function
29888 * @param {!Long|number|string} other Other value
29889 * @returns {boolean}
29890 * @expose
29891 */
29892 Long.prototype.gt = Long.prototype.greaterThan;
29893
29894 /**
29895 * Tests if this Long's value is greater than or equal the specified's.
29896 * @param {!Long|number|string} other Other value
29897 * @returns {boolean}
29898 * @expose
29899 */
29900 Long.prototype.greaterThanOrEqual = function greaterThanOrEqual(other) {
29901 return this.compare(/* validates */ other) >= 0;
29902 };
29903
29904 /**
29905 * Tests if this Long's value is greater than or equal the specified's. This is an alias of {@link Long#greaterThanOrEqual}.
29906 * @function
29907 * @param {!Long|number|string} other Other value
29908 * @returns {boolean}
29909 * @expose
29910 */
29911 Long.prototype.gte = Long.prototype.greaterThanOrEqual;
29912
29913 /**
29914 * Compares this Long's value with the specified's.
29915 * @param {!Long|number|string} other Other value
29916 * @returns {number} 0 if they are the same, 1 if the this is greater and -1
29917 * if the given one is greater
29918 * @expose
29919 */
29920 Long.prototype.compare = function compare(other) {
29921 if (!Long.isLong(other))
29922 other = Long.fromValue(other);
29923 if (this.equals(other))
29924 return 0;
29925 var thisNeg = this.isNegative(),
29926 otherNeg = other.isNegative();
29927 if (thisNeg && !otherNeg)
29928 return -1;
29929 if (!thisNeg && otherNeg)
29930 return 1;
29931 // At this point the sign bits are the same
29932 if (!this.unsigned)
29933 return this.subtract(other).isNegative() ? -1 : 1;
29934 // Both are positive if at least one is unsigned
29935 return (other.high >>> 0) > (this.high >>> 0) || (other.high === this.high && (other.low >>> 0) > (this.low >>> 0)) ? -1 : 1;
29936 };
29937
29938 /**
29939 * Negates this Long's value.
29940 * @returns {!Long} Negated Long
29941 * @expose
29942 */
29943 Long.prototype.negate = function negate() {
29944 if (!this.unsigned && this.equals(Long.MIN_VALUE))
29945 return Long.MIN_VALUE;
29946 return this.not().add(Long.ONE);
29947 };
29948
29949 /**
29950 * Negates this Long's value. This is an alias of {@link Long#negate}.
29951 * @function
29952 * @returns {!Long} Negated Long
29953 * @expose
29954 */
29955 Long.prototype.neg = Long.prototype.negate;
29956
29957 /**
29958 * Returns the sum of this and the specified Long.
29959 * @param {!Long|number|string} addend Addend
29960 * @returns {!Long} Sum
29961 * @expose
29962 */
29963 Long.prototype.add = function add(addend) {
29964 if (!Long.isLong(addend))
29965 addend = Long.fromValue(addend);
29966
29967 // Divide each number into 4 chunks of 16 bits, and then sum the chunks.
29968
29969 var a48 = this.high >>> 16;
29970 var a32 = this.high & 0xFFFF;
29971 var a16 = this.low >>> 16;
29972 var a00 = this.low & 0xFFFF;
29973
29974 var b48 = addend.high >>> 16;
29975 var b32 = addend.high & 0xFFFF;
29976 var b16 = addend.low >>> 16;
29977 var b00 = addend.low & 0xFFFF;
29978
29979 var c48 = 0, c32 = 0, c16 = 0, c00 = 0;
29980 c00 += a00 + b00;
29981 c16 += c00 >>> 16;
29982 c00 &= 0xFFFF;
29983 c16 += a16 + b16;
29984 c32 += c16 >>> 16;
29985 c16 &= 0xFFFF;
29986 c32 += a32 + b32;
29987 c48 += c32 >>> 16;
29988 c32 &= 0xFFFF;
29989 c48 += a48 + b48;
29990 c48 &= 0xFFFF;
29991 return Long.fromBits((c16 << 16) | c00, (c48 << 16) | c32, this.unsigned);
29992 };
29993
29994 /**
29995 * Returns the difference of this and the specified Long.
29996 * @param {!Long|number|string} subtrahend Subtrahend
29997 * @returns {!Long} Difference
29998 * @expose
29999 */
30000 Long.prototype.subtract = function subtract(subtrahend) {
30001 if (!Long.isLong(subtrahend))
30002 subtrahend = Long.fromValue(subtrahend);
30003 return this.add(subtrahend.negate());
30004 };
30005
30006 /**
30007 * Returns the difference of this and the specified Long. This is an alias of {@link Long#subtract}.
30008 * @function
30009 * @param {!Long|number|string} subtrahend Subtrahend
30010 * @returns {!Long} Difference
30011 * @expose
30012 */
30013 Long.prototype.sub = Long.prototype.subtract;
30014
30015 /**
30016 * Returns the product of this and the specified Long.
30017 * @param {!Long|number|string} multiplier Multiplier
30018 * @returns {!Long} Product
30019 * @expose
30020 */
30021 Long.prototype.multiply = function multiply(multiplier) {
30022 if (this.isZero())
30023 return Long.ZERO;
30024 if (!Long.isLong(multiplier))
30025 multiplier = Long.fromValue(multiplier);
30026 if (multiplier.isZero())
30027 return Long.ZERO;
30028 if (this.equals(Long.MIN_VALUE))
30029 return multiplier.isOdd() ? Long.MIN_VALUE : Long.ZERO;
30030 if (multiplier.equals(Long.MIN_VALUE))
30031 return this.isOdd() ? Long.MIN_VALUE : Long.ZERO;
30032
30033 if (this.isNegative()) {
30034 if (multiplier.isNegative())
30035 return this.negate().multiply(multiplier.negate());
30036 else
30037 return this.negate().multiply(multiplier).negate();
30038 } else if (multiplier.isNegative())
30039 return this.multiply(multiplier.negate()).negate();
30040
30041 // If both longs are small, use float multiplication
30042 if (this.lessThan(TWO_PWR_24) && multiplier.lessThan(TWO_PWR_24))
30043 return Long.fromNumber(this.toNumber() * multiplier.toNumber(), this.unsigned);
30044
30045 // Divide each long into 4 chunks of 16 bits, and then add up 4x4 products.
30046 // We can skip products that would overflow.
30047
30048 var a48 = this.high >>> 16;
30049 var a32 = this.high & 0xFFFF;
30050 var a16 = this.low >>> 16;
30051 var a00 = this.low & 0xFFFF;
30052
30053 var b48 = multiplier.high >>> 16;
30054 var b32 = multiplier.high & 0xFFFF;
30055 var b16 = multiplier.low >>> 16;
30056 var b00 = multiplier.low & 0xFFFF;
30057
30058 var c48 = 0, c32 = 0, c16 = 0, c00 = 0;
30059 c00 += a00 * b00;
30060 c16 += c00 >>> 16;
30061 c00 &= 0xFFFF;
30062 c16 += a16 * b00;
30063 c32 += c16 >>> 16;
30064 c16 &= 0xFFFF;
30065 c16 += a00 * b16;
30066 c32 += c16 >>> 16;
30067 c16 &= 0xFFFF;
30068 c32 += a32 * b00;
30069 c48 += c32 >>> 16;
30070 c32 &= 0xFFFF;
30071 c32 += a16 * b16;
30072 c48 += c32 >>> 16;
30073 c32 &= 0xFFFF;
30074 c32 += a00 * b32;
30075 c48 += c32 >>> 16;
30076 c32 &= 0xFFFF;
30077 c48 += a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48;
30078 c48 &= 0xFFFF;
30079 return Long.fromBits((c16 << 16) | c00, (c48 << 16) | c32, this.unsigned);
30080 };
30081
30082 /**
30083 * Returns the product of this and the specified Long. This is an alias of {@link Long#multiply}.
30084 * @function
30085 * @param {!Long|number|string} multiplier Multiplier
30086 * @returns {!Long} Product
30087 * @expose
30088 */
30089 Long.prototype.mul = Long.prototype.multiply;
30090
30091 /**
30092 * Returns this Long divided by the specified.
30093 * @param {!Long|number|string} divisor Divisor
30094 * @returns {!Long} Quotient
30095 * @expose
30096 */
30097 Long.prototype.divide = function divide(divisor) {
30098 if (!Long.isLong(divisor))
30099 divisor = Long.fromValue(divisor);
30100 if (divisor.isZero())
30101 throw(new Error('division by zero'));
30102 if (this.isZero())
30103 return this.unsigned ? Long.UZERO : Long.ZERO;
30104 var approx, rem, res;
30105 if (this.equals(Long.MIN_VALUE)) {
30106 if (divisor.equals(Long.ONE) || divisor.equals(Long.NEG_ONE))
30107 return Long.MIN_VALUE; // recall that -MIN_VALUE == MIN_VALUE
30108 else if (divisor.equals(Long.MIN_VALUE))
30109 return Long.ONE;
30110 else {
30111 // At this point, we have |other| >= 2, so |this/other| < |MIN_VALUE|.
30112 var halfThis = this.shiftRight(1);
30113 approx = halfThis.divide(divisor).shiftLeft(1);
30114 if (approx.equals(Long.ZERO)) {
30115 return divisor.isNegative() ? Long.ONE : Long.NEG_ONE;
30116 } else {
30117 rem = this.subtract(divisor.multiply(approx));
30118 res = approx.add(rem.divide(divisor));
30119 return res;
30120 }
30121 }
30122 } else if (divisor.equals(Long.MIN_VALUE))
30123 return this.unsigned ? Long.UZERO : Long.ZERO;
30124 if (this.isNegative()) {
30125 if (divisor.isNegative())
30126 return this.negate().divide(divisor.negate());
30127 return this.negate().divide(divisor).negate();
30128 } else if (divisor.isNegative())
30129 return this.divide(divisor.negate()).negate();
30130
30131 // Repeat the following until the remainder is less than other: find a
30132 // floating-point that approximates remainder / other *from below*, add this
30133 // into the result, and subtract it from the remainder. It is critical that
30134 // the approximate value is less than or equal to the real value so that the
30135 // remainder never becomes negative.
30136 res = Long.ZERO;
30137 rem = this;
30138 while (rem.greaterThanOrEqual(divisor)) {
30139 // Approximate the result of division. This may be a little greater or
30140 // smaller than the actual value.
30141 approx = Math.max(1, Math.floor(rem.toNumber() / divisor.toNumber()));
30142
30143 // We will tweak the approximate result by changing it in the 48-th digit or
30144 // the smallest non-fractional digit, whichever is larger.
30145 var log2 = Math.ceil(Math.log(approx) / Math.LN2),
30146 delta = (log2 <= 48) ? 1 : Math.pow(2, log2 - 48),
30147
30148 // Decrease the approximation until it is smaller than the remainder. Note
30149 // that if it is too large, the product overflows and is negative.
30150 approxRes = Long.fromNumber(approx),
30151 approxRem = approxRes.multiply(divisor);
30152 while (approxRem.isNegative() || approxRem.greaterThan(rem)) {
30153 approx -= delta;
30154 approxRes = Long.fromNumber(approx, this.unsigned);
30155 approxRem = approxRes.multiply(divisor);
30156 }
30157
30158 // We know the answer can't be zero... and actually, zero would cause
30159 // infinite recursion since we would make no progress.
30160 if (approxRes.isZero())
30161 approxRes = Long.ONE;
30162
30163 res = res.add(approxRes);
30164 rem = rem.subtract(approxRem);
30165 }
30166 return res;
30167 };
30168
30169 /**
30170 * Returns this Long divided by the specified. This is an alias of {@link Long#divide}.
30171 * @function
30172 * @param {!Long|number|string} divisor Divisor
30173 * @returns {!Long} Quotient
30174 * @expose
30175 */
30176 Long.prototype.div = Long.prototype.divide;
30177
30178 /**
30179 * Returns this Long modulo the specified.
30180 * @param {!Long|number|string} divisor Divisor
30181 * @returns {!Long} Remainder
30182 * @expose
30183 */
30184 Long.prototype.modulo = function modulo(divisor) {
30185 if (!Long.isLong(divisor))
30186 divisor = Long.fromValue(divisor);
30187 return this.subtract(this.divide(divisor).multiply(divisor));
30188 };
30189
30190 /**
30191 * Returns this Long modulo the specified. This is an alias of {@link Long#modulo}.
30192 * @function
30193 * @param {!Long|number|string} divisor Divisor
30194 * @returns {!Long} Remainder
30195 * @expose
30196 */
30197 Long.prototype.mod = Long.prototype.modulo;
30198
30199 /**
30200 * Returns the bitwise NOT of this Long.
30201 * @returns {!Long}
30202 * @expose
30203 */
30204 Long.prototype.not = function not() {
30205 return Long.fromBits(~this.low, ~this.high, this.unsigned);
30206 };
30207
30208 /**
30209 * Returns the bitwise AND of this Long and the specified.
30210 * @param {!Long|number|string} other Other Long
30211 * @returns {!Long}
30212 * @expose
30213 */
30214 Long.prototype.and = function and(other) {
30215 if (!Long.isLong(other))
30216 other = Long.fromValue(other);
30217 return Long.fromBits(this.low & other.low, this.high & other.high, this.unsigned);
30218 };
30219
30220 /**
30221 * Returns the bitwise OR of this Long and the specified.
30222 * @param {!Long|number|string} other Other Long
30223 * @returns {!Long}
30224 * @expose
30225 */
30226 Long.prototype.or = function or(other) {
30227 if (!Long.isLong(other))
30228 other = Long.fromValue(other);
30229 return Long.fromBits(this.low | other.low, this.high | other.high, this.unsigned);
30230 };
30231
30232 /**
30233 * Returns the bitwise XOR of this Long and the given one.
30234 * @param {!Long|number|string} other Other Long
30235 * @returns {!Long}
30236 * @expose
30237 */
30238 Long.prototype.xor = function xor(other) {
30239 if (!Long.isLong(other))
30240 other = Long.fromValue(other);
30241 return Long.fromBits(this.low ^ other.low, this.high ^ other.high, this.unsigned);
30242 };
30243
30244 /**
30245 * Returns this Long with bits shifted to the left by the given amount.
30246 * @param {number|!Long} numBits Number of bits
30247 * @returns {!Long} Shifted Long
30248 * @expose
30249 */
30250 Long.prototype.shiftLeft = function shiftLeft(numBits) {
30251 if (Long.isLong(numBits))
30252 numBits = numBits.toInt();
30253 if ((numBits &= 63) === 0)
30254 return this;
30255 else if (numBits < 32)
30256 return Long.fromBits(this.low << numBits, (this.high << numBits) | (this.low >>> (32 - numBits)), this.unsigned);
30257 else
30258 return Long.fromBits(0, this.low << (numBits - 32), this.unsigned);
30259 };
30260
30261 /**
30262 * Returns this Long with bits shifted to the left by the given amount. This is an alias of {@link Long#shiftLeft}.
30263 * @function
30264 * @param {number|!Long} numBits Number of bits
30265 * @returns {!Long} Shifted Long
30266 * @expose
30267 */
30268 Long.prototype.shl = Long.prototype.shiftLeft;
30269
30270 /**
30271 * Returns this Long with bits arithmetically shifted to the right by the given amount.
30272 * @param {number|!Long} numBits Number of bits
30273 * @returns {!Long} Shifted Long
30274 * @expose
30275 */
30276 Long.prototype.shiftRight = function shiftRight(numBits) {
30277 if (Long.isLong(numBits))
30278 numBits = numBits.toInt();
30279 if ((numBits &= 63) === 0)
30280 return this;
30281 else if (numBits < 32)
30282 return Long.fromBits((this.low >>> numBits) | (this.high << (32 - numBits)), this.high >> numBits, this.unsigned);
30283 else
30284 return Long.fromBits(this.high >> (numBits - 32), this.high >= 0 ? 0 : -1, this.unsigned);
30285 };
30286
30287 /**
30288 * Returns this Long with bits arithmetically shifted to the right by the given amount. This is an alias of {@link Long#shiftRight}.
30289 * @function
30290 * @param {number|!Long} numBits Number of bits
30291 * @returns {!Long} Shifted Long
30292 * @expose
30293 */
30294 Long.prototype.shr = Long.prototype.shiftRight;
30295
30296 /**
30297 * Returns this Long with bits logically shifted to the right by the given amount.
30298 * @param {number|!Long} numBits Number of bits
30299 * @returns {!Long} Shifted Long
30300 * @expose
30301 */
30302 Long.prototype.shiftRightUnsigned = function shiftRightUnsigned(numBits) {
30303 if (Long.isLong(numBits))
30304 numBits = numBits.toInt();
30305 numBits &= 63;
30306 if (numBits === 0)
30307 return this;
30308 else {
30309 var high = this.high;
30310 if (numBits < 32) {
30311 var low = this.low;
30312 return Long.fromBits((low >>> numBits) | (high << (32 - numBits)), high >>> numBits, this.unsigned);
30313 } else if (numBits === 32)
30314 return Long.fromBits(high, 0, this.unsigned);
30315 else
30316 return Long.fromBits(high >>> (numBits - 32), 0, this.unsigned);
30317 }
30318 };
30319
30320 /**
30321 * Returns this Long with bits logically shifted to the right by the given amount. This is an alias of {@link Long#shiftRightUnsigned}.
30322 * @function
30323 * @param {number|!Long} numBits Number of bits
30324 * @returns {!Long} Shifted Long
30325 * @expose
30326 */
30327 Long.prototype.shru = Long.prototype.shiftRightUnsigned;
30328
30329 /**
30330 * Converts this Long to signed.
30331 * @returns {!Long} Signed long
30332 * @expose
30333 */
30334 Long.prototype.toSigned = function toSigned() {
30335 if (!this.unsigned)
30336 return this;
30337 return new Long(this.low, this.high, false);
30338 };
30339
30340 /**
30341 * Converts this Long to unsigned.
30342 * @returns {!Long} Unsigned long
30343 * @expose
30344 */
30345 Long.prototype.toUnsigned = function toUnsigned() {
30346 if (this.unsigned)
30347 return this;
30348 return new Long(this.low, this.high, true);
30349 };
30350
30351 return Long;
30352});
30353
30354},{}],358:[function(require,module,exports){
30355'use strict'
30356var inherits = require('inherits')
30357var HashBase = require('hash-base')
30358var Buffer = require('safe-buffer').Buffer
30359
30360var ARRAY16 = new Array(16)
30361
30362function MD5 () {
30363 HashBase.call(this, 64)
30364
30365 // state
30366 this._a = 0x67452301
30367 this._b = 0xefcdab89
30368 this._c = 0x98badcfe
30369 this._d = 0x10325476
30370}
30371
30372inherits(MD5, HashBase)
30373
30374MD5.prototype._update = function () {
30375 var M = ARRAY16
30376 for (var i = 0; i < 16; ++i) M[i] = this._block.readInt32LE(i * 4)
30377
30378 var a = this._a
30379 var b = this._b
30380 var c = this._c
30381 var d = this._d
30382
30383 a = fnF(a, b, c, d, M[0], 0xd76aa478, 7)
30384 d = fnF(d, a, b, c, M[1], 0xe8c7b756, 12)
30385 c = fnF(c, d, a, b, M[2], 0x242070db, 17)
30386 b = fnF(b, c, d, a, M[3], 0xc1bdceee, 22)
30387 a = fnF(a, b, c, d, M[4], 0xf57c0faf, 7)
30388 d = fnF(d, a, b, c, M[5], 0x4787c62a, 12)
30389 c = fnF(c, d, a, b, M[6], 0xa8304613, 17)
30390 b = fnF(b, c, d, a, M[7], 0xfd469501, 22)
30391 a = fnF(a, b, c, d, M[8], 0x698098d8, 7)
30392 d = fnF(d, a, b, c, M[9], 0x8b44f7af, 12)
30393 c = fnF(c, d, a, b, M[10], 0xffff5bb1, 17)
30394 b = fnF(b, c, d, a, M[11], 0x895cd7be, 22)
30395 a = fnF(a, b, c, d, M[12], 0x6b901122, 7)
30396 d = fnF(d, a, b, c, M[13], 0xfd987193, 12)
30397 c = fnF(c, d, a, b, M[14], 0xa679438e, 17)
30398 b = fnF(b, c, d, a, M[15], 0x49b40821, 22)
30399
30400 a = fnG(a, b, c, d, M[1], 0xf61e2562, 5)
30401 d = fnG(d, a, b, c, M[6], 0xc040b340, 9)
30402 c = fnG(c, d, a, b, M[11], 0x265e5a51, 14)
30403 b = fnG(b, c, d, a, M[0], 0xe9b6c7aa, 20)
30404 a = fnG(a, b, c, d, M[5], 0xd62f105d, 5)
30405 d = fnG(d, a, b, c, M[10], 0x02441453, 9)
30406 c = fnG(c, d, a, b, M[15], 0xd8a1e681, 14)
30407 b = fnG(b, c, d, a, M[4], 0xe7d3fbc8, 20)
30408 a = fnG(a, b, c, d, M[9], 0x21e1cde6, 5)
30409 d = fnG(d, a, b, c, M[14], 0xc33707d6, 9)
30410 c = fnG(c, d, a, b, M[3], 0xf4d50d87, 14)
30411 b = fnG(b, c, d, a, M[8], 0x455a14ed, 20)
30412 a = fnG(a, b, c, d, M[13], 0xa9e3e905, 5)
30413 d = fnG(d, a, b, c, M[2], 0xfcefa3f8, 9)
30414 c = fnG(c, d, a, b, M[7], 0x676f02d9, 14)
30415 b = fnG(b, c, d, a, M[12], 0x8d2a4c8a, 20)
30416
30417 a = fnH(a, b, c, d, M[5], 0xfffa3942, 4)
30418 d = fnH(d, a, b, c, M[8], 0x8771f681, 11)
30419 c = fnH(c, d, a, b, M[11], 0x6d9d6122, 16)
30420 b = fnH(b, c, d, a, M[14], 0xfde5380c, 23)
30421 a = fnH(a, b, c, d, M[1], 0xa4beea44, 4)
30422 d = fnH(d, a, b, c, M[4], 0x4bdecfa9, 11)
30423 c = fnH(c, d, a, b, M[7], 0xf6bb4b60, 16)
30424 b = fnH(b, c, d, a, M[10], 0xbebfbc70, 23)
30425 a = fnH(a, b, c, d, M[13], 0x289b7ec6, 4)
30426 d = fnH(d, a, b, c, M[0], 0xeaa127fa, 11)
30427 c = fnH(c, d, a, b, M[3], 0xd4ef3085, 16)
30428 b = fnH(b, c, d, a, M[6], 0x04881d05, 23)
30429 a = fnH(a, b, c, d, M[9], 0xd9d4d039, 4)
30430 d = fnH(d, a, b, c, M[12], 0xe6db99e5, 11)
30431 c = fnH(c, d, a, b, M[15], 0x1fa27cf8, 16)
30432 b = fnH(b, c, d, a, M[2], 0xc4ac5665, 23)
30433
30434 a = fnI(a, b, c, d, M[0], 0xf4292244, 6)
30435 d = fnI(d, a, b, c, M[7], 0x432aff97, 10)
30436 c = fnI(c, d, a, b, M[14], 0xab9423a7, 15)
30437 b = fnI(b, c, d, a, M[5], 0xfc93a039, 21)
30438 a = fnI(a, b, c, d, M[12], 0x655b59c3, 6)
30439 d = fnI(d, a, b, c, M[3], 0x8f0ccc92, 10)
30440 c = fnI(c, d, a, b, M[10], 0xffeff47d, 15)
30441 b = fnI(b, c, d, a, M[1], 0x85845dd1, 21)
30442 a = fnI(a, b, c, d, M[8], 0x6fa87e4f, 6)
30443 d = fnI(d, a, b, c, M[15], 0xfe2ce6e0, 10)
30444 c = fnI(c, d, a, b, M[6], 0xa3014314, 15)
30445 b = fnI(b, c, d, a, M[13], 0x4e0811a1, 21)
30446 a = fnI(a, b, c, d, M[4], 0xf7537e82, 6)
30447 d = fnI(d, a, b, c, M[11], 0xbd3af235, 10)
30448 c = fnI(c, d, a, b, M[2], 0x2ad7d2bb, 15)
30449 b = fnI(b, c, d, a, M[9], 0xeb86d391, 21)
30450
30451 this._a = (this._a + a) | 0
30452 this._b = (this._b + b) | 0
30453 this._c = (this._c + c) | 0
30454 this._d = (this._d + d) | 0
30455}
30456
30457MD5.prototype._digest = function () {
30458 // create padding and handle blocks
30459 this._block[this._blockOffset++] = 0x80
30460 if (this._blockOffset > 56) {
30461 this._block.fill(0, this._blockOffset, 64)
30462 this._update()
30463 this._blockOffset = 0
30464 }
30465
30466 this._block.fill(0, this._blockOffset, 56)
30467 this._block.writeUInt32LE(this._length[0], 56)
30468 this._block.writeUInt32LE(this._length[1], 60)
30469 this._update()
30470
30471 // produce result
30472 var buffer = Buffer.allocUnsafe(16)
30473 buffer.writeInt32LE(this._a, 0)
30474 buffer.writeInt32LE(this._b, 4)
30475 buffer.writeInt32LE(this._c, 8)
30476 buffer.writeInt32LE(this._d, 12)
30477 return buffer
30478}
30479
30480function rotl (x, n) {
30481 return (x << n) | (x >>> (32 - n))
30482}
30483
30484function fnF (a, b, c, d, m, k, s) {
30485 return (rotl((a + ((b & c) | ((~b) & d)) + m + k) | 0, s) + b) | 0
30486}
30487
30488function fnG (a, b, c, d, m, k, s) {
30489 return (rotl((a + ((b & d) | (c & (~d))) + m + k) | 0, s) + b) | 0
30490}
30491
30492function fnH (a, b, c, d, m, k, s) {
30493 return (rotl((a + (b ^ c ^ d) + m + k) | 0, s) + b) | 0
30494}
30495
30496function fnI (a, b, c, d, m, k, s) {
30497 return (rotl((a + ((c ^ (b | (~d)))) + m + k) | 0, s) + b) | 0
30498}
30499
30500module.exports = MD5
30501
30502},{"hash-base":104,"inherits":119,"safe-buffer":398}],359:[function(require,module,exports){
30503var bn = require('bn.js');
30504var brorand = require('brorand');
30505
30506function MillerRabin(rand) {
30507 this.rand = rand || new brorand.Rand();
30508}
30509module.exports = MillerRabin;
30510
30511MillerRabin.create = function create(rand) {
30512 return new MillerRabin(rand);
30513};
30514
30515MillerRabin.prototype._randbelow = function _randbelow(n) {
30516 var len = n.bitLength();
30517 var min_bytes = Math.ceil(len / 8);
30518
30519 // Generage random bytes until a number less than n is found.
30520 // This ensures that 0..n-1 have an equal probability of being selected.
30521 do
30522 var a = new bn(this.rand.generate(min_bytes));
30523 while (a.cmp(n) >= 0);
30524
30525 return a;
30526};
30527
30528MillerRabin.prototype._randrange = function _randrange(start, stop) {
30529 // Generate a random number greater than or equal to start and less than stop.
30530 var size = stop.sub(start);
30531 return start.add(this._randbelow(size));
30532};
30533
30534MillerRabin.prototype.test = function test(n, k, cb) {
30535 var len = n.bitLength();
30536 var red = bn.mont(n);
30537 var rone = new bn(1).toRed(red);
30538
30539 if (!k)
30540 k = Math.max(1, (len / 48) | 0);
30541
30542 // Find d and s, (n - 1) = (2 ^ s) * d;
30543 var n1 = n.subn(1);
30544 for (var s = 0; !n1.testn(s); s++) {}
30545 var d = n.shrn(s);
30546
30547 var rn1 = n1.toRed(red);
30548
30549 var prime = true;
30550 for (; k > 0; k--) {
30551 var a = this._randrange(new bn(2), n1);
30552 if (cb)
30553 cb(a);
30554
30555 var x = a.toRed(red).redPow(d);
30556 if (x.cmp(rone) === 0 || x.cmp(rn1) === 0)
30557 continue;
30558
30559 for (var i = 1; i < s; i++) {
30560 x = x.redSqr();
30561
30562 if (x.cmp(rone) === 0)
30563 return false;
30564 if (x.cmp(rn1) === 0)
30565 break;
30566 }
30567
30568 if (i === s)
30569 return false;
30570 }
30571
30572 return prime;
30573};
30574
30575MillerRabin.prototype.getDivisor = function getDivisor(n, k) {
30576 var len = n.bitLength();
30577 var red = bn.mont(n);
30578 var rone = new bn(1).toRed(red);
30579
30580 if (!k)
30581 k = Math.max(1, (len / 48) | 0);
30582
30583 // Find d and s, (n - 1) = (2 ^ s) * d;
30584 var n1 = n.subn(1);
30585 for (var s = 0; !n1.testn(s); s++) {}
30586 var d = n.shrn(s);
30587
30588 var rn1 = n1.toRed(red);
30589
30590 for (; k > 0; k--) {
30591 var a = this._randrange(new bn(2), n1);
30592
30593 var g = n.gcd(a);
30594 if (g.cmpn(1) !== 0)
30595 return g;
30596
30597 var x = a.toRed(red).redPow(d);
30598 if (x.cmp(rone) === 0 || x.cmp(rn1) === 0)
30599 continue;
30600
30601 for (var i = 1; i < s; i++) {
30602 x = x.redSqr();
30603
30604 if (x.cmp(rone) === 0)
30605 return x.fromRed().subn(1).gcd(n);
30606 if (x.cmp(rn1) === 0)
30607 break;
30608 }
30609
30610 if (i === s) {
30611 x = x.redSqr();
30612 return x.fromRed().subn(1).gcd(n);
30613 }
30614 }
30615
30616 return false;
30617};
30618
30619},{"bn.js":18,"brorand":19}],360:[function(require,module,exports){
30620module.exports = assert;
30621
30622function assert(val, msg) {
30623 if (!val)
30624 throw new Error(msg || 'Assertion failed');
30625}
30626
30627assert.equal = function assertEqual(l, r, msg) {
30628 if (l != r)
30629 throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r));
30630};
30631
30632},{}],361:[function(require,module,exports){
30633'use strict';
30634
30635var utils = exports;
30636
30637function toArray(msg, enc) {
30638 if (Array.isArray(msg))
30639 return msg.slice();
30640 if (!msg)
30641 return [];
30642 var res = [];
30643 if (typeof msg !== 'string') {
30644 for (var i = 0; i < msg.length; i++)
30645 res[i] = msg[i] | 0;
30646 return res;
30647 }
30648 if (enc === 'hex') {
30649 msg = msg.replace(/[^a-z0-9]+/ig, '');
30650 if (msg.length % 2 !== 0)
30651 msg = '0' + msg;
30652 for (var i = 0; i < msg.length; i += 2)
30653 res.push(parseInt(msg[i] + msg[i + 1], 16));
30654 } else {
30655 for (var i = 0; i < msg.length; i++) {
30656 var c = msg.charCodeAt(i);
30657 var hi = c >> 8;
30658 var lo = c & 0xff;
30659 if (hi)
30660 res.push(hi, lo);
30661 else
30662 res.push(lo);
30663 }
30664 }
30665 return res;
30666}
30667utils.toArray = toArray;
30668
30669function zero2(word) {
30670 if (word.length === 1)
30671 return '0' + word;
30672 else
30673 return word;
30674}
30675utils.zero2 = zero2;
30676
30677function toHex(msg) {
30678 var res = '';
30679 for (var i = 0; i < msg.length; i++)
30680 res += zero2(msg[i].toString(16));
30681 return res;
30682}
30683utils.toHex = toHex;
30684
30685utils.encode = function encode(arr, enc) {
30686 if (enc === 'hex')
30687 return toHex(arr);
30688 else
30689 return arr;
30690};
30691
30692},{}],362:[function(require,module,exports){
30693module.exports={"2.16.840.1.101.3.4.1.1": "aes-128-ecb",
30694"2.16.840.1.101.3.4.1.2": "aes-128-cbc",
30695"2.16.840.1.101.3.4.1.3": "aes-128-ofb",
30696"2.16.840.1.101.3.4.1.4": "aes-128-cfb",
30697"2.16.840.1.101.3.4.1.21": "aes-192-ecb",
30698"2.16.840.1.101.3.4.1.22": "aes-192-cbc",
30699"2.16.840.1.101.3.4.1.23": "aes-192-ofb",
30700"2.16.840.1.101.3.4.1.24": "aes-192-cfb",
30701"2.16.840.1.101.3.4.1.41": "aes-256-ecb",
30702"2.16.840.1.101.3.4.1.42": "aes-256-cbc",
30703"2.16.840.1.101.3.4.1.43": "aes-256-ofb",
30704"2.16.840.1.101.3.4.1.44": "aes-256-cfb"
30705}
30706},{}],363:[function(require,module,exports){
30707// from https://github.com/indutny/self-signed/blob/gh-pages/lib/asn1.js
30708// Fedor, you are amazing.
30709'use strict'
30710
30711var asn1 = require('asn1.js')
30712
30713exports.certificate = require('./certificate')
30714
30715var RSAPrivateKey = asn1.define('RSAPrivateKey', function () {
30716 this.seq().obj(
30717 this.key('version').int(),
30718 this.key('modulus').int(),
30719 this.key('publicExponent').int(),
30720 this.key('privateExponent').int(),
30721 this.key('prime1').int(),
30722 this.key('prime2').int(),
30723 this.key('exponent1').int(),
30724 this.key('exponent2').int(),
30725 this.key('coefficient').int()
30726 )
30727})
30728exports.RSAPrivateKey = RSAPrivateKey
30729
30730var RSAPublicKey = asn1.define('RSAPublicKey', function () {
30731 this.seq().obj(
30732 this.key('modulus').int(),
30733 this.key('publicExponent').int()
30734 )
30735})
30736exports.RSAPublicKey = RSAPublicKey
30737
30738var PublicKey = asn1.define('SubjectPublicKeyInfo', function () {
30739 this.seq().obj(
30740 this.key('algorithm').use(AlgorithmIdentifier),
30741 this.key('subjectPublicKey').bitstr()
30742 )
30743})
30744exports.PublicKey = PublicKey
30745
30746var AlgorithmIdentifier = asn1.define('AlgorithmIdentifier', function () {
30747 this.seq().obj(
30748 this.key('algorithm').objid(),
30749 this.key('none').null_().optional(),
30750 this.key('curve').objid().optional(),
30751 this.key('params').seq().obj(
30752 this.key('p').int(),
30753 this.key('q').int(),
30754 this.key('g').int()
30755 ).optional()
30756 )
30757})
30758
30759var PrivateKeyInfo = asn1.define('PrivateKeyInfo', function () {
30760 this.seq().obj(
30761 this.key('version').int(),
30762 this.key('algorithm').use(AlgorithmIdentifier),
30763 this.key('subjectPrivateKey').octstr()
30764 )
30765})
30766exports.PrivateKey = PrivateKeyInfo
30767var EncryptedPrivateKeyInfo = asn1.define('EncryptedPrivateKeyInfo', function () {
30768 this.seq().obj(
30769 this.key('algorithm').seq().obj(
30770 this.key('id').objid(),
30771 this.key('decrypt').seq().obj(
30772 this.key('kde').seq().obj(
30773 this.key('id').objid(),
30774 this.key('kdeparams').seq().obj(
30775 this.key('salt').octstr(),
30776 this.key('iters').int()
30777 )
30778 ),
30779 this.key('cipher').seq().obj(
30780 this.key('algo').objid(),
30781 this.key('iv').octstr()
30782 )
30783 )
30784 ),
30785 this.key('subjectPrivateKey').octstr()
30786 )
30787})
30788
30789exports.EncryptedPrivateKey = EncryptedPrivateKeyInfo
30790
30791var DSAPrivateKey = asn1.define('DSAPrivateKey', function () {
30792 this.seq().obj(
30793 this.key('version').int(),
30794 this.key('p').int(),
30795 this.key('q').int(),
30796 this.key('g').int(),
30797 this.key('pub_key').int(),
30798 this.key('priv_key').int()
30799 )
30800})
30801exports.DSAPrivateKey = DSAPrivateKey
30802
30803exports.DSAparam = asn1.define('DSAparam', function () {
30804 this.int()
30805})
30806
30807var ECPrivateKey = asn1.define('ECPrivateKey', function () {
30808 this.seq().obj(
30809 this.key('version').int(),
30810 this.key('privateKey').octstr(),
30811 this.key('parameters').optional().explicit(0).use(ECParameters),
30812 this.key('publicKey').optional().explicit(1).bitstr()
30813 )
30814})
30815exports.ECPrivateKey = ECPrivateKey
30816
30817var ECParameters = asn1.define('ECParameters', function () {
30818 this.choice({
30819 namedCurve: this.objid()
30820 })
30821})
30822
30823exports.signature = asn1.define('signature', function () {
30824 this.seq().obj(
30825 this.key('r').int(),
30826 this.key('s').int()
30827 )
30828})
30829
30830},{"./certificate":364,"asn1.js":1}],364:[function(require,module,exports){
30831// from https://github.com/Rantanen/node-dtls/blob/25a7dc861bda38cfeac93a723500eea4f0ac2e86/Certificate.js
30832// thanks to @Rantanen
30833
30834'use strict'
30835
30836var asn = require('asn1.js')
30837
30838var Time = asn.define('Time', function () {
30839 this.choice({
30840 utcTime: this.utctime(),
30841 generalTime: this.gentime()
30842 })
30843})
30844
30845var AttributeTypeValue = asn.define('AttributeTypeValue', function () {
30846 this.seq().obj(
30847 this.key('type').objid(),
30848 this.key('value').any()
30849 )
30850})
30851
30852var AlgorithmIdentifier = asn.define('AlgorithmIdentifier', function () {
30853 this.seq().obj(
30854 this.key('algorithm').objid(),
30855 this.key('parameters').optional()
30856 )
30857})
30858
30859var SubjectPublicKeyInfo = asn.define('SubjectPublicKeyInfo', function () {
30860 this.seq().obj(
30861 this.key('algorithm').use(AlgorithmIdentifier),
30862 this.key('subjectPublicKey').bitstr()
30863 )
30864})
30865
30866var RelativeDistinguishedName = asn.define('RelativeDistinguishedName', function () {
30867 this.setof(AttributeTypeValue)
30868})
30869
30870var RDNSequence = asn.define('RDNSequence', function () {
30871 this.seqof(RelativeDistinguishedName)
30872})
30873
30874var Name = asn.define('Name', function () {
30875 this.choice({
30876 rdnSequence: this.use(RDNSequence)
30877 })
30878})
30879
30880var Validity = asn.define('Validity', function () {
30881 this.seq().obj(
30882 this.key('notBefore').use(Time),
30883 this.key('notAfter').use(Time)
30884 )
30885})
30886
30887var Extension = asn.define('Extension', function () {
30888 this.seq().obj(
30889 this.key('extnID').objid(),
30890 this.key('critical').bool().def(false),
30891 this.key('extnValue').octstr()
30892 )
30893})
30894
30895var TBSCertificate = asn.define('TBSCertificate', function () {
30896 this.seq().obj(
30897 this.key('version').explicit(0).int(),
30898 this.key('serialNumber').int(),
30899 this.key('signature').use(AlgorithmIdentifier),
30900 this.key('issuer').use(Name),
30901 this.key('validity').use(Validity),
30902 this.key('subject').use(Name),
30903 this.key('subjectPublicKeyInfo').use(SubjectPublicKeyInfo),
30904 this.key('issuerUniqueID').implicit(1).bitstr().optional(),
30905 this.key('subjectUniqueID').implicit(2).bitstr().optional(),
30906 this.key('extensions').explicit(3).seqof(Extension).optional()
30907 )
30908})
30909
30910var X509Certificate = asn.define('X509Certificate', function () {
30911 this.seq().obj(
30912 this.key('tbsCertificate').use(TBSCertificate),
30913 this.key('signatureAlgorithm').use(AlgorithmIdentifier),
30914 this.key('signatureValue').bitstr()
30915 )
30916})
30917
30918module.exports = X509Certificate
30919
30920},{"asn1.js":1}],365:[function(require,module,exports){
30921(function (Buffer){
30922// adapted from https://github.com/apatil/pemstrip
30923var findProc = /Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r\+\/\=]+)[\n\r]+/m
30924var startRegex = /^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----/m
30925var fullRegex = /^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----([0-9A-z\n\r\+\/\=]+)-----END \1-----$/m
30926var evp = require('evp_bytestokey')
30927var ciphers = require('browserify-aes')
30928module.exports = function (okey, password) {
30929 var key = okey.toString()
30930 var match = key.match(findProc)
30931 var decrypted
30932 if (!match) {
30933 var match2 = key.match(fullRegex)
30934 decrypted = new Buffer(match2[2].replace(/[\r\n]/g, ''), 'base64')
30935 } else {
30936 var suite = 'aes' + match[1]
30937 var iv = new Buffer(match[2], 'hex')
30938 var cipherText = new Buffer(match[3].replace(/[\r\n]/g, ''), 'base64')
30939 var cipherKey = evp(password, iv.slice(0, 8), parseInt(match[1], 10)).key
30940 var out = []
30941 var cipher = ciphers.createDecipheriv(suite, cipherKey, iv)
30942 out.push(cipher.update(cipherText))
30943 out.push(cipher.final())
30944 decrypted = Buffer.concat(out)
30945 }
30946 var tag = key.match(startRegex)[1]
30947 return {
30948 tag: tag,
30949 data: decrypted
30950 }
30951}
30952
30953}).call(this,require("buffer").Buffer)
30954},{"browserify-aes":23,"buffer":50,"evp_bytestokey":103}],366:[function(require,module,exports){
30955(function (Buffer){
30956var asn1 = require('./asn1')
30957var aesid = require('./aesid.json')
30958var fixProc = require('./fixProc')
30959var ciphers = require('browserify-aes')
30960var compat = require('pbkdf2')
30961module.exports = parseKeys
30962
30963function parseKeys (buffer) {
30964 var password
30965 if (typeof buffer === 'object' && !Buffer.isBuffer(buffer)) {
30966 password = buffer.passphrase
30967 buffer = buffer.key
30968 }
30969 if (typeof buffer === 'string') {
30970 buffer = new Buffer(buffer)
30971 }
30972
30973 var stripped = fixProc(buffer, password)
30974
30975 var type = stripped.tag
30976 var data = stripped.data
30977 var subtype, ndata
30978 switch (type) {
30979 case 'CERTIFICATE':
30980 ndata = asn1.certificate.decode(data, 'der').tbsCertificate.subjectPublicKeyInfo
30981 // falls through
30982 case 'PUBLIC KEY':
30983 if (!ndata) {
30984 ndata = asn1.PublicKey.decode(data, 'der')
30985 }
30986 subtype = ndata.algorithm.algorithm.join('.')
30987 switch (subtype) {
30988 case '1.2.840.113549.1.1.1':
30989 return asn1.RSAPublicKey.decode(ndata.subjectPublicKey.data, 'der')
30990 case '1.2.840.10045.2.1':
30991 ndata.subjectPrivateKey = ndata.subjectPublicKey
30992 return {
30993 type: 'ec',
30994 data: ndata
30995 }
30996 case '1.2.840.10040.4.1':
30997 ndata.algorithm.params.pub_key = asn1.DSAparam.decode(ndata.subjectPublicKey.data, 'der')
30998 return {
30999 type: 'dsa',
31000 data: ndata.algorithm.params
31001 }
31002 default: throw new Error('unknown key id ' + subtype)
31003 }
31004 throw new Error('unknown key type ' + type)
31005 case 'ENCRYPTED PRIVATE KEY':
31006 data = asn1.EncryptedPrivateKey.decode(data, 'der')
31007 data = decrypt(data, password)
31008 // falls through
31009 case 'PRIVATE KEY':
31010 ndata = asn1.PrivateKey.decode(data, 'der')
31011 subtype = ndata.algorithm.algorithm.join('.')
31012 switch (subtype) {
31013 case '1.2.840.113549.1.1.1':
31014 return asn1.RSAPrivateKey.decode(ndata.subjectPrivateKey, 'der')
31015 case '1.2.840.10045.2.1':
31016 return {
31017 curve: ndata.algorithm.curve,
31018 privateKey: asn1.ECPrivateKey.decode(ndata.subjectPrivateKey, 'der').privateKey
31019 }
31020 case '1.2.840.10040.4.1':
31021 ndata.algorithm.params.priv_key = asn1.DSAparam.decode(ndata.subjectPrivateKey, 'der')
31022 return {
31023 type: 'dsa',
31024 params: ndata.algorithm.params
31025 }
31026 default: throw new Error('unknown key id ' + subtype)
31027 }
31028 throw new Error('unknown key type ' + type)
31029 case 'RSA PUBLIC KEY':
31030 return asn1.RSAPublicKey.decode(data, 'der')
31031 case 'RSA PRIVATE KEY':
31032 return asn1.RSAPrivateKey.decode(data, 'der')
31033 case 'DSA PRIVATE KEY':
31034 return {
31035 type: 'dsa',
31036 params: asn1.DSAPrivateKey.decode(data, 'der')
31037 }
31038 case 'EC PRIVATE KEY':
31039 data = asn1.ECPrivateKey.decode(data, 'der')
31040 return {
31041 curve: data.parameters.value,
31042 privateKey: data.privateKey
31043 }
31044 default: throw new Error('unknown key type ' + type)
31045 }
31046}
31047parseKeys.signature = asn1.signature
31048function decrypt (data, password) {
31049 var salt = data.algorithm.decrypt.kde.kdeparams.salt
31050 var iters = parseInt(data.algorithm.decrypt.kde.kdeparams.iters.toString(), 10)
31051 var algo = aesid[data.algorithm.decrypt.cipher.algo.join('.')]
31052 var iv = data.algorithm.decrypt.cipher.iv
31053 var cipherText = data.subjectPrivateKey
31054 var keylen = parseInt(algo.split('-')[1], 10) / 8
31055 var key = compat.pbkdf2Sync(password, salt, iters, keylen)
31056 var cipher = ciphers.createDecipheriv(algo, key, iv)
31057 var out = []
31058 out.push(cipher.update(cipherText))
31059 out.push(cipher.final())
31060 return Buffer.concat(out)
31061}
31062
31063}).call(this,require("buffer").Buffer)
31064},{"./aesid.json":362,"./asn1":363,"./fixProc":365,"browserify-aes":23,"buffer":50,"pbkdf2":368}],367:[function(require,module,exports){
31065(function (process){
31066// .dirname, .basename, and .extname methods are extracted from Node.js v8.11.1,
31067// backported and transplited with Babel, with backwards-compat fixes
31068
31069// Copyright Joyent, Inc. and other Node contributors.
31070//
31071// Permission is hereby granted, free of charge, to any person obtaining a
31072// copy of this software and associated documentation files (the
31073// "Software"), to deal in the Software without restriction, including
31074// without limitation the rights to use, copy, modify, merge, publish,
31075// distribute, sublicense, and/or sell copies of the Software, and to permit
31076// persons to whom the Software is furnished to do so, subject to the
31077// following conditions:
31078//
31079// The above copyright notice and this permission notice shall be included
31080// in all copies or substantial portions of the Software.
31081//
31082// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
31083// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
31084// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
31085// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
31086// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
31087// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
31088// USE OR OTHER DEALINGS IN THE SOFTWARE.
31089
31090// resolves . and .. elements in a path array with directory names there
31091// must be no slashes, empty elements, or device names (c:\) in the array
31092// (so also no leading and trailing slashes - it does not distinguish
31093// relative and absolute paths)
31094function normalizeArray(parts, allowAboveRoot) {
31095 // if the path tries to go above the root, `up` ends up > 0
31096 var up = 0;
31097 for (var i = parts.length - 1; i >= 0; i--) {
31098 var last = parts[i];
31099 if (last === '.') {
31100 parts.splice(i, 1);
31101 } else if (last === '..') {
31102 parts.splice(i, 1);
31103 up++;
31104 } else if (up) {
31105 parts.splice(i, 1);
31106 up--;
31107 }
31108 }
31109
31110 // if the path is allowed to go above the root, restore leading ..s
31111 if (allowAboveRoot) {
31112 for (; up--; up) {
31113 parts.unshift('..');
31114 }
31115 }
31116
31117 return parts;
31118}
31119
31120// path.resolve([from ...], to)
31121// posix version
31122exports.resolve = function() {
31123 var resolvedPath = '',
31124 resolvedAbsolute = false;
31125
31126 for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
31127 var path = (i >= 0) ? arguments[i] : process.cwd();
31128
31129 // Skip empty and invalid entries
31130 if (typeof path !== 'string') {
31131 throw new TypeError('Arguments to path.resolve must be strings');
31132 } else if (!path) {
31133 continue;
31134 }
31135
31136 resolvedPath = path + '/' + resolvedPath;
31137 resolvedAbsolute = path.charAt(0) === '/';
31138 }
31139
31140 // At this point the path should be resolved to a full absolute path, but
31141 // handle relative paths to be safe (might happen when process.cwd() fails)
31142
31143 // Normalize the path
31144 resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
31145 return !!p;
31146 }), !resolvedAbsolute).join('/');
31147
31148 return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
31149};
31150
31151// path.normalize(path)
31152// posix version
31153exports.normalize = function(path) {
31154 var isAbsolute = exports.isAbsolute(path),
31155 trailingSlash = substr(path, -1) === '/';
31156
31157 // Normalize the path
31158 path = normalizeArray(filter(path.split('/'), function(p) {
31159 return !!p;
31160 }), !isAbsolute).join('/');
31161
31162 if (!path && !isAbsolute) {
31163 path = '.';
31164 }
31165 if (path && trailingSlash) {
31166 path += '/';
31167 }
31168
31169 return (isAbsolute ? '/' : '') + path;
31170};
31171
31172// posix version
31173exports.isAbsolute = function(path) {
31174 return path.charAt(0) === '/';
31175};
31176
31177// posix version
31178exports.join = function() {
31179 var paths = Array.prototype.slice.call(arguments, 0);
31180 return exports.normalize(filter(paths, function(p, index) {
31181 if (typeof p !== 'string') {
31182 throw new TypeError('Arguments to path.join must be strings');
31183 }
31184 return p;
31185 }).join('/'));
31186};
31187
31188
31189// path.relative(from, to)
31190// posix version
31191exports.relative = function(from, to) {
31192 from = exports.resolve(from).substr(1);
31193 to = exports.resolve(to).substr(1);
31194
31195 function trim(arr) {
31196 var start = 0;
31197 for (; start < arr.length; start++) {
31198 if (arr[start] !== '') break;
31199 }
31200
31201 var end = arr.length - 1;
31202 for (; end >= 0; end--) {
31203 if (arr[end] !== '') break;
31204 }
31205
31206 if (start > end) return [];
31207 return arr.slice(start, end - start + 1);
31208 }
31209
31210 var fromParts = trim(from.split('/'));
31211 var toParts = trim(to.split('/'));
31212
31213 var length = Math.min(fromParts.length, toParts.length);
31214 var samePartsLength = length;
31215 for (var i = 0; i < length; i++) {
31216 if (fromParts[i] !== toParts[i]) {
31217 samePartsLength = i;
31218 break;
31219 }
31220 }
31221
31222 var outputParts = [];
31223 for (var i = samePartsLength; i < fromParts.length; i++) {
31224 outputParts.push('..');
31225 }
31226
31227 outputParts = outputParts.concat(toParts.slice(samePartsLength));
31228
31229 return outputParts.join('/');
31230};
31231
31232exports.sep = '/';
31233exports.delimiter = ':';
31234
31235exports.dirname = function (path) {
31236 if (typeof path !== 'string') path = path + '';
31237 if (path.length === 0) return '.';
31238 var code = path.charCodeAt(0);
31239 var hasRoot = code === 47 /*/*/;
31240 var end = -1;
31241 var matchedSlash = true;
31242 for (var i = path.length - 1; i >= 1; --i) {
31243 code = path.charCodeAt(i);
31244 if (code === 47 /*/*/) {
31245 if (!matchedSlash) {
31246 end = i;
31247 break;
31248 }
31249 } else {
31250 // We saw the first non-path separator
31251 matchedSlash = false;
31252 }
31253 }
31254
31255 if (end === -1) return hasRoot ? '/' : '.';
31256 if (hasRoot && end === 1) {
31257 // return '//';
31258 // Backwards-compat fix:
31259 return '/';
31260 }
31261 return path.slice(0, end);
31262};
31263
31264function basename(path) {
31265 if (typeof path !== 'string') path = path + '';
31266
31267 var start = 0;
31268 var end = -1;
31269 var matchedSlash = true;
31270 var i;
31271
31272 for (i = path.length - 1; i >= 0; --i) {
31273 if (path.charCodeAt(i) === 47 /*/*/) {
31274 // If we reached a path separator that was not part of a set of path
31275 // separators at the end of the string, stop now
31276 if (!matchedSlash) {
31277 start = i + 1;
31278 break;
31279 }
31280 } else if (end === -1) {
31281 // We saw the first non-path separator, mark this as the end of our
31282 // path component
31283 matchedSlash = false;
31284 end = i + 1;
31285 }
31286 }
31287
31288 if (end === -1) return '';
31289 return path.slice(start, end);
31290}
31291
31292// Uses a mixed approach for backwards-compatibility, as ext behavior changed
31293// in new Node.js versions, so only basename() above is backported here
31294exports.basename = function (path, ext) {
31295 var f = basename(path);
31296 if (ext && f.substr(-1 * ext.length) === ext) {
31297 f = f.substr(0, f.length - ext.length);
31298 }
31299 return f;
31300};
31301
31302exports.extname = function (path) {
31303 if (typeof path !== 'string') path = path + '';
31304 var startDot = -1;
31305 var startPart = 0;
31306 var end = -1;
31307 var matchedSlash = true;
31308 // Track the state of characters (if any) we see before our first dot and
31309 // after any path separator we find
31310 var preDotState = 0;
31311 for (var i = path.length - 1; i >= 0; --i) {
31312 var code = path.charCodeAt(i);
31313 if (code === 47 /*/*/) {
31314 // If we reached a path separator that was not part of a set of path
31315 // separators at the end of the string, stop now
31316 if (!matchedSlash) {
31317 startPart = i + 1;
31318 break;
31319 }
31320 continue;
31321 }
31322 if (end === -1) {
31323 // We saw the first non-path separator, mark this as the end of our
31324 // extension
31325 matchedSlash = false;
31326 end = i + 1;
31327 }
31328 if (code === 46 /*.*/) {
31329 // If this is our first dot, mark it as the start of our extension
31330 if (startDot === -1)
31331 startDot = i;
31332 else if (preDotState !== 1)
31333 preDotState = 1;
31334 } else if (startDot !== -1) {
31335 // We saw a non-dot and non-path separator before our dot, so we should
31336 // have a good chance at having a non-empty extension
31337 preDotState = -1;
31338 }
31339 }
31340
31341 if (startDot === -1 || end === -1 ||
31342 // We saw a non-dot character immediately before the dot
31343 preDotState === 0 ||
31344 // The (right-most) trimmed path component is exactly '..'
31345 preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
31346 return '';
31347 }
31348 return path.slice(startDot, end);
31349};
31350
31351function filter (xs, f) {
31352 if (xs.filter) return xs.filter(f);
31353 var res = [];
31354 for (var i = 0; i < xs.length; i++) {
31355 if (f(xs[i], i, xs)) res.push(xs[i]);
31356 }
31357 return res;
31358}
31359
31360// String.prototype.substr - negative index don't work in IE8
31361var substr = 'ab'.substr(-1) === 'b'
31362 ? function (str, start, len) { return str.substr(start, len) }
31363 : function (str, start, len) {
31364 if (start < 0) start = str.length + start;
31365 return str.substr(start, len);
31366 }
31367;
31368
31369}).call(this,require('_process'))
31370},{"_process":374}],368:[function(require,module,exports){
31371exports.pbkdf2 = require('./lib/async')
31372exports.pbkdf2Sync = require('./lib/sync')
31373
31374},{"./lib/async":369,"./lib/sync":372}],369:[function(require,module,exports){
31375(function (process,global){
31376var checkParameters = require('./precondition')
31377var defaultEncoding = require('./default-encoding')
31378var sync = require('./sync')
31379var Buffer = require('safe-buffer').Buffer
31380
31381var ZERO_BUF
31382var subtle = global.crypto && global.crypto.subtle
31383var toBrowser = {
31384 'sha': 'SHA-1',
31385 'sha-1': 'SHA-1',
31386 'sha1': 'SHA-1',
31387 'sha256': 'SHA-256',
31388 'sha-256': 'SHA-256',
31389 'sha384': 'SHA-384',
31390 'sha-384': 'SHA-384',
31391 'sha-512': 'SHA-512',
31392 'sha512': 'SHA-512'
31393}
31394var checks = []
31395function checkNative (algo) {
31396 if (global.process && !global.process.browser) {
31397 return Promise.resolve(false)
31398 }
31399 if (!subtle || !subtle.importKey || !subtle.deriveBits) {
31400 return Promise.resolve(false)
31401 }
31402 if (checks[algo] !== undefined) {
31403 return checks[algo]
31404 }
31405 ZERO_BUF = ZERO_BUF || Buffer.alloc(8)
31406 var prom = browserPbkdf2(ZERO_BUF, ZERO_BUF, 10, 128, algo)
31407 .then(function () {
31408 return true
31409 }).catch(function () {
31410 return false
31411 })
31412 checks[algo] = prom
31413 return prom
31414}
31415
31416function browserPbkdf2 (password, salt, iterations, length, algo) {
31417 return subtle.importKey(
31418 'raw', password, {name: 'PBKDF2'}, false, ['deriveBits']
31419 ).then(function (key) {
31420 return subtle.deriveBits({
31421 name: 'PBKDF2',
31422 salt: salt,
31423 iterations: iterations,
31424 hash: {
31425 name: algo
31426 }
31427 }, key, length << 3)
31428 }).then(function (res) {
31429 return Buffer.from(res)
31430 })
31431}
31432
31433function resolvePromise (promise, callback) {
31434 promise.then(function (out) {
31435 process.nextTick(function () {
31436 callback(null, out)
31437 })
31438 }, function (e) {
31439 process.nextTick(function () {
31440 callback(e)
31441 })
31442 })
31443}
31444module.exports = function (password, salt, iterations, keylen, digest, callback) {
31445 if (typeof digest === 'function') {
31446 callback = digest
31447 digest = undefined
31448 }
31449
31450 digest = digest || 'sha1'
31451 var algo = toBrowser[digest.toLowerCase()]
31452
31453 if (!algo || typeof global.Promise !== 'function') {
31454 return process.nextTick(function () {
31455 var out
31456 try {
31457 out = sync(password, salt, iterations, keylen, digest)
31458 } catch (e) {
31459 return callback(e)
31460 }
31461 callback(null, out)
31462 })
31463 }
31464
31465 checkParameters(password, salt, iterations, keylen)
31466 if (typeof callback !== 'function') throw new Error('No callback provided to pbkdf2')
31467 if (!Buffer.isBuffer(password)) password = Buffer.from(password, defaultEncoding)
31468 if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, defaultEncoding)
31469
31470 resolvePromise(checkNative(algo).then(function (resp) {
31471 if (resp) return browserPbkdf2(password, salt, iterations, keylen, algo)
31472
31473 return sync(password, salt, iterations, keylen, digest)
31474 }), callback)
31475}
31476
31477}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
31478},{"./default-encoding":370,"./precondition":371,"./sync":372,"_process":374,"safe-buffer":398}],370:[function(require,module,exports){
31479(function (process){
31480var defaultEncoding
31481/* istanbul ignore next */
31482if (process.browser) {
31483 defaultEncoding = 'utf-8'
31484} else {
31485 var pVersionMajor = parseInt(process.version.split('.')[0].slice(1), 10)
31486
31487 defaultEncoding = pVersionMajor >= 6 ? 'utf-8' : 'binary'
31488}
31489module.exports = defaultEncoding
31490
31491}).call(this,require('_process'))
31492},{"_process":374}],371:[function(require,module,exports){
31493(function (Buffer){
31494var MAX_ALLOC = Math.pow(2, 30) - 1 // default in iojs
31495
31496function checkBuffer (buf, name) {
31497 if (typeof buf !== 'string' && !Buffer.isBuffer(buf)) {
31498 throw new TypeError(name + ' must be a buffer or string')
31499 }
31500}
31501
31502module.exports = function (password, salt, iterations, keylen) {
31503 checkBuffer(password, 'Password')
31504 checkBuffer(salt, 'Salt')
31505
31506 if (typeof iterations !== 'number') {
31507 throw new TypeError('Iterations not a number')
31508 }
31509
31510 if (iterations < 0) {
31511 throw new TypeError('Bad iterations')
31512 }
31513
31514 if (typeof keylen !== 'number') {
31515 throw new TypeError('Key length not a number')
31516 }
31517
31518 if (keylen < 0 || keylen > MAX_ALLOC || keylen !== keylen) { /* eslint no-self-compare: 0 */
31519 throw new TypeError('Bad key length')
31520 }
31521}
31522
31523}).call(this,{"isBuffer":require("../../is-buffer/index.js")})
31524},{"../../is-buffer/index.js":120}],372:[function(require,module,exports){
31525var md5 = require('create-hash/md5')
31526var RIPEMD160 = require('ripemd160')
31527var sha = require('sha.js')
31528
31529var checkParameters = require('./precondition')
31530var defaultEncoding = require('./default-encoding')
31531var Buffer = require('safe-buffer').Buffer
31532var ZEROS = Buffer.alloc(128)
31533var sizes = {
31534 md5: 16,
31535 sha1: 20,
31536 sha224: 28,
31537 sha256: 32,
31538 sha384: 48,
31539 sha512: 64,
31540 rmd160: 20,
31541 ripemd160: 20
31542}
31543
31544function Hmac (alg, key, saltLen) {
31545 var hash = getDigest(alg)
31546 var blocksize = (alg === 'sha512' || alg === 'sha384') ? 128 : 64
31547
31548 if (key.length > blocksize) {
31549 key = hash(key)
31550 } else if (key.length < blocksize) {
31551 key = Buffer.concat([key, ZEROS], blocksize)
31552 }
31553
31554 var ipad = Buffer.allocUnsafe(blocksize + sizes[alg])
31555 var opad = Buffer.allocUnsafe(blocksize + sizes[alg])
31556 for (var i = 0; i < blocksize; i++) {
31557 ipad[i] = key[i] ^ 0x36
31558 opad[i] = key[i] ^ 0x5C
31559 }
31560
31561 var ipad1 = Buffer.allocUnsafe(blocksize + saltLen + 4)
31562 ipad.copy(ipad1, 0, 0, blocksize)
31563 this.ipad1 = ipad1
31564 this.ipad2 = ipad
31565 this.opad = opad
31566 this.alg = alg
31567 this.blocksize = blocksize
31568 this.hash = hash
31569 this.size = sizes[alg]
31570}
31571
31572Hmac.prototype.run = function (data, ipad) {
31573 data.copy(ipad, this.blocksize)
31574 var h = this.hash(ipad)
31575 h.copy(this.opad, this.blocksize)
31576 return this.hash(this.opad)
31577}
31578
31579function getDigest (alg) {
31580 function shaFunc (data) {
31581 return sha(alg).update(data).digest()
31582 }
31583 function rmd160Func (data) {
31584 return new RIPEMD160().update(data).digest()
31585 }
31586
31587 if (alg === 'rmd160' || alg === 'ripemd160') return rmd160Func
31588 if (alg === 'md5') return md5
31589 return shaFunc
31590}
31591
31592function pbkdf2 (password, salt, iterations, keylen, digest) {
31593 checkParameters(password, salt, iterations, keylen)
31594
31595 if (!Buffer.isBuffer(password)) password = Buffer.from(password, defaultEncoding)
31596 if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, defaultEncoding)
31597
31598 digest = digest || 'sha1'
31599
31600 var hmac = new Hmac(digest, password, salt.length)
31601
31602 var DK = Buffer.allocUnsafe(keylen)
31603 var block1 = Buffer.allocUnsafe(salt.length + 4)
31604 salt.copy(block1, 0, 0, salt.length)
31605
31606 var destPos = 0
31607 var hLen = sizes[digest]
31608 var l = Math.ceil(keylen / hLen)
31609
31610 for (var i = 1; i <= l; i++) {
31611 block1.writeUInt32BE(i, salt.length)
31612
31613 var T = hmac.run(block1, hmac.ipad1)
31614 var U = T
31615
31616 for (var j = 1; j < iterations; j++) {
31617 U = hmac.run(U, hmac.ipad2)
31618 for (var k = 0; k < hLen; k++) T[k] ^= U[k]
31619 }
31620
31621 T.copy(DK, destPos)
31622 destPos += hLen
31623 }
31624
31625 return DK
31626}
31627
31628module.exports = pbkdf2
31629
31630},{"./default-encoding":370,"./precondition":371,"create-hash/md5":69,"ripemd160":397,"safe-buffer":398,"sha.js":400}],373:[function(require,module,exports){
31631(function (process){
31632'use strict';
31633
31634if (!process.version ||
31635 process.version.indexOf('v0.') === 0 ||
31636 process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
31637 module.exports = { nextTick: nextTick };
31638} else {
31639 module.exports = process
31640}
31641
31642function nextTick(fn, arg1, arg2, arg3) {
31643 if (typeof fn !== 'function') {
31644 throw new TypeError('"callback" argument must be a function');
31645 }
31646 var len = arguments.length;
31647 var args, i;
31648 switch (len) {
31649 case 0:
31650 case 1:
31651 return process.nextTick(fn);
31652 case 2:
31653 return process.nextTick(function afterTickOne() {
31654 fn.call(null, arg1);
31655 });
31656 case 3:
31657 return process.nextTick(function afterTickTwo() {
31658 fn.call(null, arg1, arg2);
31659 });
31660 case 4:
31661 return process.nextTick(function afterTickThree() {
31662 fn.call(null, arg1, arg2, arg3);
31663 });
31664 default:
31665 args = new Array(len - 1);
31666 i = 0;
31667 while (i < args.length) {
31668 args[i++] = arguments[i];
31669 }
31670 return process.nextTick(function afterTick() {
31671 fn.apply(null, args);
31672 });
31673 }
31674}
31675
31676
31677}).call(this,require('_process'))
31678},{"_process":374}],374:[function(require,module,exports){
31679// shim for using process in browser
31680var process = module.exports = {};
31681
31682// cached from whatever global is present so that test runners that stub it
31683// don't break things. But we need to wrap it in a try catch in case it is
31684// wrapped in strict mode code which doesn't define any globals. It's inside a
31685// function because try/catches deoptimize in certain engines.
31686
31687var cachedSetTimeout;
31688var cachedClearTimeout;
31689
31690function defaultSetTimout() {
31691 throw new Error('setTimeout has not been defined');
31692}
31693function defaultClearTimeout () {
31694 throw new Error('clearTimeout has not been defined');
31695}
31696(function () {
31697 try {
31698 if (typeof setTimeout === 'function') {
31699 cachedSetTimeout = setTimeout;
31700 } else {
31701 cachedSetTimeout = defaultSetTimout;
31702 }
31703 } catch (e) {
31704 cachedSetTimeout = defaultSetTimout;
31705 }
31706 try {
31707 if (typeof clearTimeout === 'function') {
31708 cachedClearTimeout = clearTimeout;
31709 } else {
31710 cachedClearTimeout = defaultClearTimeout;
31711 }
31712 } catch (e) {
31713 cachedClearTimeout = defaultClearTimeout;
31714 }
31715} ())
31716function runTimeout(fun) {
31717 if (cachedSetTimeout === setTimeout) {
31718 //normal enviroments in sane situations
31719 return setTimeout(fun, 0);
31720 }
31721 // if setTimeout wasn't available but was latter defined
31722 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
31723 cachedSetTimeout = setTimeout;
31724 return setTimeout(fun, 0);
31725 }
31726 try {
31727 // when when somebody has screwed with setTimeout but no I.E. maddness
31728 return cachedSetTimeout(fun, 0);
31729 } catch(e){
31730 try {
31731 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
31732 return cachedSetTimeout.call(null, fun, 0);
31733 } catch(e){
31734 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
31735 return cachedSetTimeout.call(this, fun, 0);
31736 }
31737 }
31738
31739
31740}
31741function runClearTimeout(marker) {
31742 if (cachedClearTimeout === clearTimeout) {
31743 //normal enviroments in sane situations
31744 return clearTimeout(marker);
31745 }
31746 // if clearTimeout wasn't available but was latter defined
31747 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
31748 cachedClearTimeout = clearTimeout;
31749 return clearTimeout(marker);
31750 }
31751 try {
31752 // when when somebody has screwed with setTimeout but no I.E. maddness
31753 return cachedClearTimeout(marker);
31754 } catch (e){
31755 try {
31756 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
31757 return cachedClearTimeout.call(null, marker);
31758 } catch (e){
31759 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
31760 // Some versions of I.E. have different rules for clearTimeout vs setTimeout
31761 return cachedClearTimeout.call(this, marker);
31762 }
31763 }
31764
31765
31766
31767}
31768var queue = [];
31769var draining = false;
31770var currentQueue;
31771var queueIndex = -1;
31772
31773function cleanUpNextTick() {
31774 if (!draining || !currentQueue) {
31775 return;
31776 }
31777 draining = false;
31778 if (currentQueue.length) {
31779 queue = currentQueue.concat(queue);
31780 } else {
31781 queueIndex = -1;
31782 }
31783 if (queue.length) {
31784 drainQueue();
31785 }
31786}
31787
31788function drainQueue() {
31789 if (draining) {
31790 return;
31791 }
31792 var timeout = runTimeout(cleanUpNextTick);
31793 draining = true;
31794
31795 var len = queue.length;
31796 while(len) {
31797 currentQueue = queue;
31798 queue = [];
31799 while (++queueIndex < len) {
31800 if (currentQueue) {
31801 currentQueue[queueIndex].run();
31802 }
31803 }
31804 queueIndex = -1;
31805 len = queue.length;
31806 }
31807 currentQueue = null;
31808 draining = false;
31809 runClearTimeout(timeout);
31810}
31811
31812process.nextTick = function (fun) {
31813 var args = new Array(arguments.length - 1);
31814 if (arguments.length > 1) {
31815 for (var i = 1; i < arguments.length; i++) {
31816 args[i - 1] = arguments[i];
31817 }
31818 }
31819 queue.push(new Item(fun, args));
31820 if (queue.length === 1 && !draining) {
31821 runTimeout(drainQueue);
31822 }
31823};
31824
31825// v8 likes predictible objects
31826function Item(fun, array) {
31827 this.fun = fun;
31828 this.array = array;
31829}
31830Item.prototype.run = function () {
31831 this.fun.apply(null, this.array);
31832};
31833process.title = 'browser';
31834process.browser = true;
31835process.env = {};
31836process.argv = [];
31837process.version = ''; // empty string to avoid regexp issues
31838process.versions = {};
31839
31840function noop() {}
31841
31842process.on = noop;
31843process.addListener = noop;
31844process.once = noop;
31845process.off = noop;
31846process.removeListener = noop;
31847process.removeAllListeners = noop;
31848process.emit = noop;
31849process.prependListener = noop;
31850process.prependOnceListener = noop;
31851
31852process.listeners = function (name) { return [] }
31853
31854process.binding = function (name) {
31855 throw new Error('process.binding is not supported');
31856};
31857
31858process.cwd = function () { return '/' };
31859process.chdir = function (dir) {
31860 throw new Error('process.chdir is not supported');
31861};
31862process.umask = function() { return 0; };
31863
31864},{}],375:[function(require,module,exports){
31865exports.publicEncrypt = require('./publicEncrypt')
31866exports.privateDecrypt = require('./privateDecrypt')
31867
31868exports.privateEncrypt = function privateEncrypt (key, buf) {
31869 return exports.publicEncrypt(key, buf, true)
31870}
31871
31872exports.publicDecrypt = function publicDecrypt (key, buf) {
31873 return exports.privateDecrypt(key, buf, true)
31874}
31875
31876},{"./privateDecrypt":377,"./publicEncrypt":378}],376:[function(require,module,exports){
31877var createHash = require('create-hash')
31878var Buffer = require('safe-buffer').Buffer
31879
31880module.exports = function (seed, len) {
31881 var t = Buffer.alloc(0)
31882 var i = 0
31883 var c
31884 while (t.length < len) {
31885 c = i2ops(i++)
31886 t = Buffer.concat([t, createHash('sha1').update(seed).update(c).digest()])
31887 }
31888 return t.slice(0, len)
31889}
31890
31891function i2ops (c) {
31892 var out = Buffer.allocUnsafe(4)
31893 out.writeUInt32BE(c, 0)
31894 return out
31895}
31896
31897},{"create-hash":68,"safe-buffer":398}],377:[function(require,module,exports){
31898var parseKeys = require('parse-asn1')
31899var mgf = require('./mgf')
31900var xor = require('./xor')
31901var BN = require('bn.js')
31902var crt = require('browserify-rsa')
31903var createHash = require('create-hash')
31904var withPublic = require('./withPublic')
31905var Buffer = require('safe-buffer').Buffer
31906
31907module.exports = function privateDecrypt (privateKey, enc, reverse) {
31908 var padding
31909 if (privateKey.padding) {
31910 padding = privateKey.padding
31911 } else if (reverse) {
31912 padding = 1
31913 } else {
31914 padding = 4
31915 }
31916
31917 var key = parseKeys(privateKey)
31918 var k = key.modulus.byteLength()
31919 if (enc.length > k || new BN(enc).cmp(key.modulus) >= 0) {
31920 throw new Error('decryption error')
31921 }
31922 var msg
31923 if (reverse) {
31924 msg = withPublic(new BN(enc), key)
31925 } else {
31926 msg = crt(enc, key)
31927 }
31928 var zBuffer = Buffer.alloc(k - msg.length)
31929 msg = Buffer.concat([zBuffer, msg], k)
31930 if (padding === 4) {
31931 return oaep(key, msg)
31932 } else if (padding === 1) {
31933 return pkcs1(key, msg, reverse)
31934 } else if (padding === 3) {
31935 return msg
31936 } else {
31937 throw new Error('unknown padding')
31938 }
31939}
31940
31941function oaep (key, msg) {
31942 var k = key.modulus.byteLength()
31943 var iHash = createHash('sha1').update(Buffer.alloc(0)).digest()
31944 var hLen = iHash.length
31945 if (msg[0] !== 0) {
31946 throw new Error('decryption error')
31947 }
31948 var maskedSeed = msg.slice(1, hLen + 1)
31949 var maskedDb = msg.slice(hLen + 1)
31950 var seed = xor(maskedSeed, mgf(maskedDb, hLen))
31951 var db = xor(maskedDb, mgf(seed, k - hLen - 1))
31952 if (compare(iHash, db.slice(0, hLen))) {
31953 throw new Error('decryption error')
31954 }
31955 var i = hLen
31956 while (db[i] === 0) {
31957 i++
31958 }
31959 if (db[i++] !== 1) {
31960 throw new Error('decryption error')
31961 }
31962 return db.slice(i)
31963}
31964
31965function pkcs1 (key, msg, reverse) {
31966 var p1 = msg.slice(0, 2)
31967 var i = 2
31968 var status = 0
31969 while (msg[i++] !== 0) {
31970 if (i >= msg.length) {
31971 status++
31972 break
31973 }
31974 }
31975 var ps = msg.slice(2, i - 1)
31976
31977 if ((p1.toString('hex') !== '0002' && !reverse) || (p1.toString('hex') !== '0001' && reverse)) {
31978 status++
31979 }
31980 if (ps.length < 8) {
31981 status++
31982 }
31983 if (status) {
31984 throw new Error('decryption error')
31985 }
31986 return msg.slice(i)
31987}
31988function compare (a, b) {
31989 a = Buffer.from(a)
31990 b = Buffer.from(b)
31991 var dif = 0
31992 var len = a.length
31993 if (a.length !== b.length) {
31994 dif++
31995 len = Math.min(a.length, b.length)
31996 }
31997 var i = -1
31998 while (++i < len) {
31999 dif += (a[i] ^ b[i])
32000 }
32001 return dif
32002}
32003
32004},{"./mgf":376,"./withPublic":379,"./xor":380,"bn.js":18,"browserify-rsa":41,"create-hash":68,"parse-asn1":366,"safe-buffer":398}],378:[function(require,module,exports){
32005var parseKeys = require('parse-asn1')
32006var randomBytes = require('randombytes')
32007var createHash = require('create-hash')
32008var mgf = require('./mgf')
32009var xor = require('./xor')
32010var BN = require('bn.js')
32011var withPublic = require('./withPublic')
32012var crt = require('browserify-rsa')
32013var Buffer = require('safe-buffer').Buffer
32014
32015module.exports = function publicEncrypt (publicKey, msg, reverse) {
32016 var padding
32017 if (publicKey.padding) {
32018 padding = publicKey.padding
32019 } else if (reverse) {
32020 padding = 1
32021 } else {
32022 padding = 4
32023 }
32024 var key = parseKeys(publicKey)
32025 var paddedMsg
32026 if (padding === 4) {
32027 paddedMsg = oaep(key, msg)
32028 } else if (padding === 1) {
32029 paddedMsg = pkcs1(key, msg, reverse)
32030 } else if (padding === 3) {
32031 paddedMsg = new BN(msg)
32032 if (paddedMsg.cmp(key.modulus) >= 0) {
32033 throw new Error('data too long for modulus')
32034 }
32035 } else {
32036 throw new Error('unknown padding')
32037 }
32038 if (reverse) {
32039 return crt(paddedMsg, key)
32040 } else {
32041 return withPublic(paddedMsg, key)
32042 }
32043}
32044
32045function oaep (key, msg) {
32046 var k = key.modulus.byteLength()
32047 var mLen = msg.length
32048 var iHash = createHash('sha1').update(Buffer.alloc(0)).digest()
32049 var hLen = iHash.length
32050 var hLen2 = 2 * hLen
32051 if (mLen > k - hLen2 - 2) {
32052 throw new Error('message too long')
32053 }
32054 var ps = Buffer.alloc(k - mLen - hLen2 - 2)
32055 var dblen = k - hLen - 1
32056 var seed = randomBytes(hLen)
32057 var maskedDb = xor(Buffer.concat([iHash, ps, Buffer.alloc(1, 1), msg], dblen), mgf(seed, dblen))
32058 var maskedSeed = xor(seed, mgf(maskedDb, hLen))
32059 return new BN(Buffer.concat([Buffer.alloc(1), maskedSeed, maskedDb], k))
32060}
32061function pkcs1 (key, msg, reverse) {
32062 var mLen = msg.length
32063 var k = key.modulus.byteLength()
32064 if (mLen > k - 11) {
32065 throw new Error('message too long')
32066 }
32067 var ps
32068 if (reverse) {
32069 ps = Buffer.alloc(k - mLen - 3, 0xff)
32070 } else {
32071 ps = nonZero(k - mLen - 3)
32072 }
32073 return new BN(Buffer.concat([Buffer.from([0, reverse ? 1 : 2]), ps, Buffer.alloc(1), msg], k))
32074}
32075function nonZero (len) {
32076 var out = Buffer.allocUnsafe(len)
32077 var i = 0
32078 var cache = randomBytes(len * 2)
32079 var cur = 0
32080 var num
32081 while (i < len) {
32082 if (cur === cache.length) {
32083 cache = randomBytes(len * 2)
32084 cur = 0
32085 }
32086 num = cache[cur++]
32087 if (num) {
32088 out[i++] = num
32089 }
32090 }
32091 return out
32092}
32093
32094},{"./mgf":376,"./withPublic":379,"./xor":380,"bn.js":18,"browserify-rsa":41,"create-hash":68,"parse-asn1":366,"randombytes":381,"safe-buffer":398}],379:[function(require,module,exports){
32095var BN = require('bn.js')
32096var Buffer = require('safe-buffer').Buffer
32097
32098function withPublic (paddedMsg, key) {
32099 return Buffer.from(paddedMsg
32100 .toRed(BN.mont(key.modulus))
32101 .redPow(new BN(key.publicExponent))
32102 .fromRed()
32103 .toArray())
32104}
32105
32106module.exports = withPublic
32107
32108},{"bn.js":18,"safe-buffer":398}],380:[function(require,module,exports){
32109module.exports = function xor (a, b) {
32110 var len = a.length
32111 var i = -1
32112 while (++i < len) {
32113 a[i] ^= b[i]
32114 }
32115 return a
32116}
32117
32118},{}],381:[function(require,module,exports){
32119(function (process,global){
32120'use strict'
32121
32122function oldBrowser () {
32123 throw new Error('Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11')
32124}
32125
32126var Buffer = require('safe-buffer').Buffer
32127var crypto = global.crypto || global.msCrypto
32128
32129if (crypto && crypto.getRandomValues) {
32130 module.exports = randomBytes
32131} else {
32132 module.exports = oldBrowser
32133}
32134
32135function randomBytes (size, cb) {
32136 // phantomjs needs to throw
32137 if (size > 65536) throw new Error('requested too many random bytes')
32138 // in case browserify isn't using the Uint8Array version
32139 var rawBytes = new global.Uint8Array(size)
32140
32141 // This will not work in older browsers.
32142 // See https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues
32143 if (size > 0) { // getRandomValues fails on IE if size == 0
32144 crypto.getRandomValues(rawBytes)
32145 }
32146
32147 // XXX: phantomjs doesn't like a buffer being passed here
32148 var bytes = Buffer.from(rawBytes.buffer)
32149
32150 if (typeof cb === 'function') {
32151 return process.nextTick(function () {
32152 cb(null, bytes)
32153 })
32154 }
32155
32156 return bytes
32157}
32158
32159}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
32160},{"_process":374,"safe-buffer":398}],382:[function(require,module,exports){
32161(function (process,global){
32162'use strict'
32163
32164function oldBrowser () {
32165 throw new Error('secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11')
32166}
32167var safeBuffer = require('safe-buffer')
32168var randombytes = require('randombytes')
32169var Buffer = safeBuffer.Buffer
32170var kBufferMaxLength = safeBuffer.kMaxLength
32171var crypto = global.crypto || global.msCrypto
32172var kMaxUint32 = Math.pow(2, 32) - 1
32173function assertOffset (offset, length) {
32174 if (typeof offset !== 'number' || offset !== offset) { // eslint-disable-line no-self-compare
32175 throw new TypeError('offset must be a number')
32176 }
32177
32178 if (offset > kMaxUint32 || offset < 0) {
32179 throw new TypeError('offset must be a uint32')
32180 }
32181
32182 if (offset > kBufferMaxLength || offset > length) {
32183 throw new RangeError('offset out of range')
32184 }
32185}
32186
32187function assertSize (size, offset, length) {
32188 if (typeof size !== 'number' || size !== size) { // eslint-disable-line no-self-compare
32189 throw new TypeError('size must be a number')
32190 }
32191
32192 if (size > kMaxUint32 || size < 0) {
32193 throw new TypeError('size must be a uint32')
32194 }
32195
32196 if (size + offset > length || size > kBufferMaxLength) {
32197 throw new RangeError('buffer too small')
32198 }
32199}
32200if ((crypto && crypto.getRandomValues) || !process.browser) {
32201 exports.randomFill = randomFill
32202 exports.randomFillSync = randomFillSync
32203} else {
32204 exports.randomFill = oldBrowser
32205 exports.randomFillSync = oldBrowser
32206}
32207function randomFill (buf, offset, size, cb) {
32208 if (!Buffer.isBuffer(buf) && !(buf instanceof global.Uint8Array)) {
32209 throw new TypeError('"buf" argument must be a Buffer or Uint8Array')
32210 }
32211
32212 if (typeof offset === 'function') {
32213 cb = offset
32214 offset = 0
32215 size = buf.length
32216 } else if (typeof size === 'function') {
32217 cb = size
32218 size = buf.length - offset
32219 } else if (typeof cb !== 'function') {
32220 throw new TypeError('"cb" argument must be a function')
32221 }
32222 assertOffset(offset, buf.length)
32223 assertSize(size, offset, buf.length)
32224 return actualFill(buf, offset, size, cb)
32225}
32226
32227function actualFill (buf, offset, size, cb) {
32228 if (process.browser) {
32229 var ourBuf = buf.buffer
32230 var uint = new Uint8Array(ourBuf, offset, size)
32231 crypto.getRandomValues(uint)
32232 if (cb) {
32233 process.nextTick(function () {
32234 cb(null, buf)
32235 })
32236 return
32237 }
32238 return buf
32239 }
32240 if (cb) {
32241 randombytes(size, function (err, bytes) {
32242 if (err) {
32243 return cb(err)
32244 }
32245 bytes.copy(buf, offset)
32246 cb(null, buf)
32247 })
32248 return
32249 }
32250 var bytes = randombytes(size)
32251 bytes.copy(buf, offset)
32252 return buf
32253}
32254function randomFillSync (buf, offset, size) {
32255 if (typeof offset === 'undefined') {
32256 offset = 0
32257 }
32258 if (!Buffer.isBuffer(buf) && !(buf instanceof global.Uint8Array)) {
32259 throw new TypeError('"buf" argument must be a Buffer or Uint8Array')
32260 }
32261
32262 assertOffset(offset, buf.length)
32263
32264 if (size === undefined) size = buf.length - offset
32265
32266 assertSize(size, offset, buf.length)
32267
32268 return actualFill(buf, offset, size)
32269}
32270
32271}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
32272},{"_process":374,"randombytes":381,"safe-buffer":398}],383:[function(require,module,exports){
32273module.exports = require('./lib/_stream_duplex.js');
32274
32275},{"./lib/_stream_duplex.js":384}],384:[function(require,module,exports){
32276// Copyright Joyent, Inc. and other Node contributors.
32277//
32278// Permission is hereby granted, free of charge, to any person obtaining a
32279// copy of this software and associated documentation files (the
32280// "Software"), to deal in the Software without restriction, including
32281// without limitation the rights to use, copy, modify, merge, publish,
32282// distribute, sublicense, and/or sell copies of the Software, and to permit
32283// persons to whom the Software is furnished to do so, subject to the
32284// following conditions:
32285//
32286// The above copyright notice and this permission notice shall be included
32287// in all copies or substantial portions of the Software.
32288//
32289// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
32290// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32291// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
32292// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
32293// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
32294// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
32295// USE OR OTHER DEALINGS IN THE SOFTWARE.
32296
32297// a duplex stream is just a stream that is both readable and writable.
32298// Since JS doesn't have multiple prototypal inheritance, this class
32299// prototypally inherits from Readable, and then parasitically from
32300// Writable.
32301
32302'use strict';
32303
32304/*<replacement>*/
32305
32306var pna = require('process-nextick-args');
32307/*</replacement>*/
32308
32309/*<replacement>*/
32310var objectKeys = Object.keys || function (obj) {
32311 var keys = [];
32312 for (var key in obj) {
32313 keys.push(key);
32314 }return keys;
32315};
32316/*</replacement>*/
32317
32318module.exports = Duplex;
32319
32320/*<replacement>*/
32321var util = require('core-util-is');
32322util.inherits = require('inherits');
32323/*</replacement>*/
32324
32325var Readable = require('./_stream_readable');
32326var Writable = require('./_stream_writable');
32327
32328util.inherits(Duplex, Readable);
32329
32330{
32331 // avoid scope creep, the keys array can then be collected
32332 var keys = objectKeys(Writable.prototype);
32333 for (var v = 0; v < keys.length; v++) {
32334 var method = keys[v];
32335 if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
32336 }
32337}
32338
32339function Duplex(options) {
32340 if (!(this instanceof Duplex)) return new Duplex(options);
32341
32342 Readable.call(this, options);
32343 Writable.call(this, options);
32344
32345 if (options && options.readable === false) this.readable = false;
32346
32347 if (options && options.writable === false) this.writable = false;
32348
32349 this.allowHalfOpen = true;
32350 if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
32351
32352 this.once('end', onend);
32353}
32354
32355Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
32356 // making it explicit this property is not enumerable
32357 // because otherwise some prototype manipulation in
32358 // userland will fail
32359 enumerable: false,
32360 get: function () {
32361 return this._writableState.highWaterMark;
32362 }
32363});
32364
32365// the no-half-open enforcer
32366function onend() {
32367 // if we allow half-open state, or if the writable side ended,
32368 // then we're ok.
32369 if (this.allowHalfOpen || this._writableState.ended) return;
32370
32371 // no more data can be written.
32372 // But allow more writes to happen in this tick.
32373 pna.nextTick(onEndNT, this);
32374}
32375
32376function onEndNT(self) {
32377 self.end();
32378}
32379
32380Object.defineProperty(Duplex.prototype, 'destroyed', {
32381 get: function () {
32382 if (this._readableState === undefined || this._writableState === undefined) {
32383 return false;
32384 }
32385 return this._readableState.destroyed && this._writableState.destroyed;
32386 },
32387 set: function (value) {
32388 // we ignore the value if the stream
32389 // has not been initialized yet
32390 if (this._readableState === undefined || this._writableState === undefined) {
32391 return;
32392 }
32393
32394 // backward compatibility, the user is explicitly
32395 // managing destroyed
32396 this._readableState.destroyed = value;
32397 this._writableState.destroyed = value;
32398 }
32399});
32400
32401Duplex.prototype._destroy = function (err, cb) {
32402 this.push(null);
32403 this.end();
32404
32405 pna.nextTick(cb, err);
32406};
32407},{"./_stream_readable":386,"./_stream_writable":388,"core-util-is":52,"inherits":119,"process-nextick-args":373}],385:[function(require,module,exports){
32408// Copyright Joyent, Inc. and other Node contributors.
32409//
32410// Permission is hereby granted, free of charge, to any person obtaining a
32411// copy of this software and associated documentation files (the
32412// "Software"), to deal in the Software without restriction, including
32413// without limitation the rights to use, copy, modify, merge, publish,
32414// distribute, sublicense, and/or sell copies of the Software, and to permit
32415// persons to whom the Software is furnished to do so, subject to the
32416// following conditions:
32417//
32418// The above copyright notice and this permission notice shall be included
32419// in all copies or substantial portions of the Software.
32420//
32421// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
32422// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32423// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
32424// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
32425// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
32426// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
32427// USE OR OTHER DEALINGS IN THE SOFTWARE.
32428
32429// a passthrough stream.
32430// basically just the most minimal sort of Transform stream.
32431// Every written chunk gets output as-is.
32432
32433'use strict';
32434
32435module.exports = PassThrough;
32436
32437var Transform = require('./_stream_transform');
32438
32439/*<replacement>*/
32440var util = require('core-util-is');
32441util.inherits = require('inherits');
32442/*</replacement>*/
32443
32444util.inherits(PassThrough, Transform);
32445
32446function PassThrough(options) {
32447 if (!(this instanceof PassThrough)) return new PassThrough(options);
32448
32449 Transform.call(this, options);
32450}
32451
32452PassThrough.prototype._transform = function (chunk, encoding, cb) {
32453 cb(null, chunk);
32454};
32455},{"./_stream_transform":387,"core-util-is":52,"inherits":119}],386:[function(require,module,exports){
32456(function (process,global){
32457// Copyright Joyent, Inc. and other Node contributors.
32458//
32459// Permission is hereby granted, free of charge, to any person obtaining a
32460// copy of this software and associated documentation files (the
32461// "Software"), to deal in the Software without restriction, including
32462// without limitation the rights to use, copy, modify, merge, publish,
32463// distribute, sublicense, and/or sell copies of the Software, and to permit
32464// persons to whom the Software is furnished to do so, subject to the
32465// following conditions:
32466//
32467// The above copyright notice and this permission notice shall be included
32468// in all copies or substantial portions of the Software.
32469//
32470// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
32471// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32472// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
32473// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
32474// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
32475// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
32476// USE OR OTHER DEALINGS IN THE SOFTWARE.
32477
32478'use strict';
32479
32480/*<replacement>*/
32481
32482var pna = require('process-nextick-args');
32483/*</replacement>*/
32484
32485module.exports = Readable;
32486
32487/*<replacement>*/
32488var isArray = require('isarray');
32489/*</replacement>*/
32490
32491/*<replacement>*/
32492var Duplex;
32493/*</replacement>*/
32494
32495Readable.ReadableState = ReadableState;
32496
32497/*<replacement>*/
32498var EE = require('events').EventEmitter;
32499
32500var EElistenerCount = function (emitter, type) {
32501 return emitter.listeners(type).length;
32502};
32503/*</replacement>*/
32504
32505/*<replacement>*/
32506var Stream = require('./internal/streams/stream');
32507/*</replacement>*/
32508
32509/*<replacement>*/
32510
32511var Buffer = require('safe-buffer').Buffer;
32512var OurUint8Array = global.Uint8Array || function () {};
32513function _uint8ArrayToBuffer(chunk) {
32514 return Buffer.from(chunk);
32515}
32516function _isUint8Array(obj) {
32517 return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
32518}
32519
32520/*</replacement>*/
32521
32522/*<replacement>*/
32523var util = require('core-util-is');
32524util.inherits = require('inherits');
32525/*</replacement>*/
32526
32527/*<replacement>*/
32528var debugUtil = require('util');
32529var debug = void 0;
32530if (debugUtil && debugUtil.debuglog) {
32531 debug = debugUtil.debuglog('stream');
32532} else {
32533 debug = function () {};
32534}
32535/*</replacement>*/
32536
32537var BufferList = require('./internal/streams/BufferList');
32538var destroyImpl = require('./internal/streams/destroy');
32539var StringDecoder;
32540
32541util.inherits(Readable, Stream);
32542
32543var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
32544
32545function prependListener(emitter, event, fn) {
32546 // Sadly this is not cacheable as some libraries bundle their own
32547 // event emitter implementation with them.
32548 if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);
32549
32550 // This is a hack to make sure that our error handler is attached before any
32551 // userland ones. NEVER DO THIS. This is here only because this code needs
32552 // to continue to work with older versions of Node.js that do not include
32553 // the prependListener() method. The goal is to eventually remove this hack.
32554 if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
32555}
32556
32557function ReadableState(options, stream) {
32558 Duplex = Duplex || require('./_stream_duplex');
32559
32560 options = options || {};
32561
32562 // Duplex streams are both readable and writable, but share
32563 // the same options object.
32564 // However, some cases require setting options to different
32565 // values for the readable and the writable sides of the duplex stream.
32566 // These options can be provided separately as readableXXX and writableXXX.
32567 var isDuplex = stream instanceof Duplex;
32568
32569 // object stream flag. Used to make read(n) ignore n and to
32570 // make all the buffer merging and length checks go away
32571 this.objectMode = !!options.objectMode;
32572
32573 if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
32574
32575 // the point at which it stops calling _read() to fill the buffer
32576 // Note: 0 is a valid value, means "don't call _read preemptively ever"
32577 var hwm = options.highWaterMark;
32578 var readableHwm = options.readableHighWaterMark;
32579 var defaultHwm = this.objectMode ? 16 : 16 * 1024;
32580
32581 if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;
32582
32583 // cast to ints.
32584 this.highWaterMark = Math.floor(this.highWaterMark);
32585
32586 // A linked list is used to store data chunks instead of an array because the
32587 // linked list can remove elements from the beginning faster than
32588 // array.shift()
32589 this.buffer = new BufferList();
32590 this.length = 0;
32591 this.pipes = null;
32592 this.pipesCount = 0;
32593 this.flowing = null;
32594 this.ended = false;
32595 this.endEmitted = false;
32596 this.reading = false;
32597
32598 // a flag to be able to tell if the event 'readable'/'data' is emitted
32599 // immediately, or on a later tick. We set this to true at first, because
32600 // any actions that shouldn't happen until "later" should generally also
32601 // not happen before the first read call.
32602 this.sync = true;
32603
32604 // whenever we return null, then we set a flag to say
32605 // that we're awaiting a 'readable' event emission.
32606 this.needReadable = false;
32607 this.emittedReadable = false;
32608 this.readableListening = false;
32609 this.resumeScheduled = false;
32610
32611 // has it been destroyed
32612 this.destroyed = false;
32613
32614 // Crypto is kind of old and crusty. Historically, its default string
32615 // encoding is 'binary' so we have to make this configurable.
32616 // Everything else in the universe uses 'utf8', though.
32617 this.defaultEncoding = options.defaultEncoding || 'utf8';
32618
32619 // the number of writers that are awaiting a drain event in .pipe()s
32620 this.awaitDrain = 0;
32621
32622 // if true, a maybeReadMore has been scheduled
32623 this.readingMore = false;
32624
32625 this.decoder = null;
32626 this.encoding = null;
32627 if (options.encoding) {
32628 if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
32629 this.decoder = new StringDecoder(options.encoding);
32630 this.encoding = options.encoding;
32631 }
32632}
32633
32634function Readable(options) {
32635 Duplex = Duplex || require('./_stream_duplex');
32636
32637 if (!(this instanceof Readable)) return new Readable(options);
32638
32639 this._readableState = new ReadableState(options, this);
32640
32641 // legacy
32642 this.readable = true;
32643
32644 if (options) {
32645 if (typeof options.read === 'function') this._read = options.read;
32646
32647 if (typeof options.destroy === 'function') this._destroy = options.destroy;
32648 }
32649
32650 Stream.call(this);
32651}
32652
32653Object.defineProperty(Readable.prototype, 'destroyed', {
32654 get: function () {
32655 if (this._readableState === undefined) {
32656 return false;
32657 }
32658 return this._readableState.destroyed;
32659 },
32660 set: function (value) {
32661 // we ignore the value if the stream
32662 // has not been initialized yet
32663 if (!this._readableState) {
32664 return;
32665 }
32666
32667 // backward compatibility, the user is explicitly
32668 // managing destroyed
32669 this._readableState.destroyed = value;
32670 }
32671});
32672
32673Readable.prototype.destroy = destroyImpl.destroy;
32674Readable.prototype._undestroy = destroyImpl.undestroy;
32675Readable.prototype._destroy = function (err, cb) {
32676 this.push(null);
32677 cb(err);
32678};
32679
32680// Manually shove something into the read() buffer.
32681// This returns true if the highWaterMark has not been hit yet,
32682// similar to how Writable.write() returns true if you should
32683// write() some more.
32684Readable.prototype.push = function (chunk, encoding) {
32685 var state = this._readableState;
32686 var skipChunkCheck;
32687
32688 if (!state.objectMode) {
32689 if (typeof chunk === 'string') {
32690 encoding = encoding || state.defaultEncoding;
32691 if (encoding !== state.encoding) {
32692 chunk = Buffer.from(chunk, encoding);
32693 encoding = '';
32694 }
32695 skipChunkCheck = true;
32696 }
32697 } else {
32698 skipChunkCheck = true;
32699 }
32700
32701 return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
32702};
32703
32704// Unshift should *always* be something directly out of read()
32705Readable.prototype.unshift = function (chunk) {
32706 return readableAddChunk(this, chunk, null, true, false);
32707};
32708
32709function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
32710 var state = stream._readableState;
32711 if (chunk === null) {
32712 state.reading = false;
32713 onEofChunk(stream, state);
32714 } else {
32715 var er;
32716 if (!skipChunkCheck) er = chunkInvalid(state, chunk);
32717 if (er) {
32718 stream.emit('error', er);
32719 } else if (state.objectMode || chunk && chunk.length > 0) {
32720 if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
32721 chunk = _uint8ArrayToBuffer(chunk);
32722 }
32723
32724 if (addToFront) {
32725 if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
32726 } else if (state.ended) {
32727 stream.emit('error', new Error('stream.push() after EOF'));
32728 } else {
32729 state.reading = false;
32730 if (state.decoder && !encoding) {
32731 chunk = state.decoder.write(chunk);
32732 if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
32733 } else {
32734 addChunk(stream, state, chunk, false);
32735 }
32736 }
32737 } else if (!addToFront) {
32738 state.reading = false;
32739 }
32740 }
32741
32742 return needMoreData(state);
32743}
32744
32745function addChunk(stream, state, chunk, addToFront) {
32746 if (state.flowing && state.length === 0 && !state.sync) {
32747 stream.emit('data', chunk);
32748 stream.read(0);
32749 } else {
32750 // update the buffer info.
32751 state.length += state.objectMode ? 1 : chunk.length;
32752 if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
32753
32754 if (state.needReadable) emitReadable(stream);
32755 }
32756 maybeReadMore(stream, state);
32757}
32758
32759function chunkInvalid(state, chunk) {
32760 var er;
32761 if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
32762 er = new TypeError('Invalid non-string/buffer chunk');
32763 }
32764 return er;
32765}
32766
32767// if it's past the high water mark, we can push in some more.
32768// Also, if we have no data yet, we can stand some
32769// more bytes. This is to work around cases where hwm=0,
32770// such as the repl. Also, if the push() triggered a
32771// readable event, and the user called read(largeNumber) such that
32772// needReadable was set, then we ought to push more, so that another
32773// 'readable' event will be triggered.
32774function needMoreData(state) {
32775 return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
32776}
32777
32778Readable.prototype.isPaused = function () {
32779 return this._readableState.flowing === false;
32780};
32781
32782// backwards compatibility.
32783Readable.prototype.setEncoding = function (enc) {
32784 if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
32785 this._readableState.decoder = new StringDecoder(enc);
32786 this._readableState.encoding = enc;
32787 return this;
32788};
32789
32790// Don't raise the hwm > 8MB
32791var MAX_HWM = 0x800000;
32792function computeNewHighWaterMark(n) {
32793 if (n >= MAX_HWM) {
32794 n = MAX_HWM;
32795 } else {
32796 // Get the next highest power of 2 to prevent increasing hwm excessively in
32797 // tiny amounts
32798 n--;
32799 n |= n >>> 1;
32800 n |= n >>> 2;
32801 n |= n >>> 4;
32802 n |= n >>> 8;
32803 n |= n >>> 16;
32804 n++;
32805 }
32806 return n;
32807}
32808
32809// This function is designed to be inlinable, so please take care when making
32810// changes to the function body.
32811function howMuchToRead(n, state) {
32812 if (n <= 0 || state.length === 0 && state.ended) return 0;
32813 if (state.objectMode) return 1;
32814 if (n !== n) {
32815 // Only flow one buffer at a time
32816 if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
32817 }
32818 // If we're asking for more than the current hwm, then raise the hwm.
32819 if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
32820 if (n <= state.length) return n;
32821 // Don't have enough
32822 if (!state.ended) {
32823 state.needReadable = true;
32824 return 0;
32825 }
32826 return state.length;
32827}
32828
32829// you can override either this method, or the async _read(n) below.
32830Readable.prototype.read = function (n) {
32831 debug('read', n);
32832 n = parseInt(n, 10);
32833 var state = this._readableState;
32834 var nOrig = n;
32835
32836 if (n !== 0) state.emittedReadable = false;
32837
32838 // if we're doing read(0) to trigger a readable event, but we
32839 // already have a bunch of data in the buffer, then just trigger
32840 // the 'readable' event and move on.
32841 if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
32842 debug('read: emitReadable', state.length, state.ended);
32843 if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
32844 return null;
32845 }
32846
32847 n = howMuchToRead(n, state);
32848
32849 // if we've ended, and we're now clear, then finish it up.
32850 if (n === 0 && state.ended) {
32851 if (state.length === 0) endReadable(this);
32852 return null;
32853 }
32854
32855 // All the actual chunk generation logic needs to be
32856 // *below* the call to _read. The reason is that in certain
32857 // synthetic stream cases, such as passthrough streams, _read
32858 // may be a completely synchronous operation which may change
32859 // the state of the read buffer, providing enough data when
32860 // before there was *not* enough.
32861 //
32862 // So, the steps are:
32863 // 1. Figure out what the state of things will be after we do
32864 // a read from the buffer.
32865 //
32866 // 2. If that resulting state will trigger a _read, then call _read.
32867 // Note that this may be asynchronous, or synchronous. Yes, it is
32868 // deeply ugly to write APIs this way, but that still doesn't mean
32869 // that the Readable class should behave improperly, as streams are
32870 // designed to be sync/async agnostic.
32871 // Take note if the _read call is sync or async (ie, if the read call
32872 // has returned yet), so that we know whether or not it's safe to emit
32873 // 'readable' etc.
32874 //
32875 // 3. Actually pull the requested chunks out of the buffer and return.
32876
32877 // if we need a readable event, then we need to do some reading.
32878 var doRead = state.needReadable;
32879 debug('need readable', doRead);
32880
32881 // if we currently have less than the highWaterMark, then also read some
32882 if (state.length === 0 || state.length - n < state.highWaterMark) {
32883 doRead = true;
32884 debug('length less than watermark', doRead);
32885 }
32886
32887 // however, if we've ended, then there's no point, and if we're already
32888 // reading, then it's unnecessary.
32889 if (state.ended || state.reading) {
32890 doRead = false;
32891 debug('reading or ended', doRead);
32892 } else if (doRead) {
32893 debug('do read');
32894 state.reading = true;
32895 state.sync = true;
32896 // if the length is currently zero, then we *need* a readable event.
32897 if (state.length === 0) state.needReadable = true;
32898 // call internal read method
32899 this._read(state.highWaterMark);
32900 state.sync = false;
32901 // If _read pushed data synchronously, then `reading` will be false,
32902 // and we need to re-evaluate how much data we can return to the user.
32903 if (!state.reading) n = howMuchToRead(nOrig, state);
32904 }
32905
32906 var ret;
32907 if (n > 0) ret = fromList(n, state);else ret = null;
32908
32909 if (ret === null) {
32910 state.needReadable = true;
32911 n = 0;
32912 } else {
32913 state.length -= n;
32914 }
32915
32916 if (state.length === 0) {
32917 // If we have nothing in the buffer, then we want to know
32918 // as soon as we *do* get something into the buffer.
32919 if (!state.ended) state.needReadable = true;
32920
32921 // If we tried to read() past the EOF, then emit end on the next tick.
32922 if (nOrig !== n && state.ended) endReadable(this);
32923 }
32924
32925 if (ret !== null) this.emit('data', ret);
32926
32927 return ret;
32928};
32929
32930function onEofChunk(stream, state) {
32931 if (state.ended) return;
32932 if (state.decoder) {
32933 var chunk = state.decoder.end();
32934 if (chunk && chunk.length) {
32935 state.buffer.push(chunk);
32936 state.length += state.objectMode ? 1 : chunk.length;
32937 }
32938 }
32939 state.ended = true;
32940
32941 // emit 'readable' now to make sure it gets picked up.
32942 emitReadable(stream);
32943}
32944
32945// Don't emit readable right away in sync mode, because this can trigger
32946// another read() call => stack overflow. This way, it might trigger
32947// a nextTick recursion warning, but that's not so bad.
32948function emitReadable(stream) {
32949 var state = stream._readableState;
32950 state.needReadable = false;
32951 if (!state.emittedReadable) {
32952 debug('emitReadable', state.flowing);
32953 state.emittedReadable = true;
32954 if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);
32955 }
32956}
32957
32958function emitReadable_(stream) {
32959 debug('emit readable');
32960 stream.emit('readable');
32961 flow(stream);
32962}
32963
32964// at this point, the user has presumably seen the 'readable' event,
32965// and called read() to consume some data. that may have triggered
32966// in turn another _read(n) call, in which case reading = true if
32967// it's in progress.
32968// However, if we're not ended, or reading, and the length < hwm,
32969// then go ahead and try to read some more preemptively.
32970function maybeReadMore(stream, state) {
32971 if (!state.readingMore) {
32972 state.readingMore = true;
32973 pna.nextTick(maybeReadMore_, stream, state);
32974 }
32975}
32976
32977function maybeReadMore_(stream, state) {
32978 var len = state.length;
32979 while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
32980 debug('maybeReadMore read 0');
32981 stream.read(0);
32982 if (len === state.length)
32983 // didn't get any data, stop spinning.
32984 break;else len = state.length;
32985 }
32986 state.readingMore = false;
32987}
32988
32989// abstract method. to be overridden in specific implementation classes.
32990// call cb(er, data) where data is <= n in length.
32991// for virtual (non-string, non-buffer) streams, "length" is somewhat
32992// arbitrary, and perhaps not very meaningful.
32993Readable.prototype._read = function (n) {
32994 this.emit('error', new Error('_read() is not implemented'));
32995};
32996
32997Readable.prototype.pipe = function (dest, pipeOpts) {
32998 var src = this;
32999 var state = this._readableState;
33000
33001 switch (state.pipesCount) {
33002 case 0:
33003 state.pipes = dest;
33004 break;
33005 case 1:
33006 state.pipes = [state.pipes, dest];
33007 break;
33008 default:
33009 state.pipes.push(dest);
33010 break;
33011 }
33012 state.pipesCount += 1;
33013 debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
33014
33015 var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
33016
33017 var endFn = doEnd ? onend : unpipe;
33018 if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);
33019
33020 dest.on('unpipe', onunpipe);
33021 function onunpipe(readable, unpipeInfo) {
33022 debug('onunpipe');
33023 if (readable === src) {
33024 if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
33025 unpipeInfo.hasUnpiped = true;
33026 cleanup();
33027 }
33028 }
33029 }
33030
33031 function onend() {
33032 debug('onend');
33033 dest.end();
33034 }
33035
33036 // when the dest drains, it reduces the awaitDrain counter
33037 // on the source. This would be more elegant with a .once()
33038 // handler in flow(), but adding and removing repeatedly is
33039 // too slow.
33040 var ondrain = pipeOnDrain(src);
33041 dest.on('drain', ondrain);
33042
33043 var cleanedUp = false;
33044 function cleanup() {
33045 debug('cleanup');
33046 // cleanup event handlers once the pipe is broken
33047 dest.removeListener('close', onclose);
33048 dest.removeListener('finish', onfinish);
33049 dest.removeListener('drain', ondrain);
33050 dest.removeListener('error', onerror);
33051 dest.removeListener('unpipe', onunpipe);
33052 src.removeListener('end', onend);
33053 src.removeListener('end', unpipe);
33054 src.removeListener('data', ondata);
33055
33056 cleanedUp = true;
33057
33058 // if the reader is waiting for a drain event from this
33059 // specific writer, then it would cause it to never start
33060 // flowing again.
33061 // So, if this is awaiting a drain, then we just call it now.
33062 // If we don't know, then assume that we are waiting for one.
33063 if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
33064 }
33065
33066 // If the user pushes more data while we're writing to dest then we'll end up
33067 // in ondata again. However, we only want to increase awaitDrain once because
33068 // dest will only emit one 'drain' event for the multiple writes.
33069 // => Introduce a guard on increasing awaitDrain.
33070 var increasedAwaitDrain = false;
33071 src.on('data', ondata);
33072 function ondata(chunk) {
33073 debug('ondata');
33074 increasedAwaitDrain = false;
33075 var ret = dest.write(chunk);
33076 if (false === ret && !increasedAwaitDrain) {
33077 // If the user unpiped during `dest.write()`, it is possible
33078 // to get stuck in a permanently paused state if that write
33079 // also returned false.
33080 // => Check whether `dest` is still a piping destination.
33081 if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
33082 debug('false write response, pause', src._readableState.awaitDrain);
33083 src._readableState.awaitDrain++;
33084 increasedAwaitDrain = true;
33085 }
33086 src.pause();
33087 }
33088 }
33089
33090 // if the dest has an error, then stop piping into it.
33091 // however, don't suppress the throwing behavior for this.
33092 function onerror(er) {
33093 debug('onerror', er);
33094 unpipe();
33095 dest.removeListener('error', onerror);
33096 if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
33097 }
33098
33099 // Make sure our error handler is attached before userland ones.
33100 prependListener(dest, 'error', onerror);
33101
33102 // Both close and finish should trigger unpipe, but only once.
33103 function onclose() {
33104 dest.removeListener('finish', onfinish);
33105 unpipe();
33106 }
33107 dest.once('close', onclose);
33108 function onfinish() {
33109 debug('onfinish');
33110 dest.removeListener('close', onclose);
33111 unpipe();
33112 }
33113 dest.once('finish', onfinish);
33114
33115 function unpipe() {
33116 debug('unpipe');
33117 src.unpipe(dest);
33118 }
33119
33120 // tell the dest that it's being piped to
33121 dest.emit('pipe', src);
33122
33123 // start the flow if it hasn't been started already.
33124 if (!state.flowing) {
33125 debug('pipe resume');
33126 src.resume();
33127 }
33128
33129 return dest;
33130};
33131
33132function pipeOnDrain(src) {
33133 return function () {
33134 var state = src._readableState;
33135 debug('pipeOnDrain', state.awaitDrain);
33136 if (state.awaitDrain) state.awaitDrain--;
33137 if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
33138 state.flowing = true;
33139 flow(src);
33140 }
33141 };
33142}
33143
33144Readable.prototype.unpipe = function (dest) {
33145 var state = this._readableState;
33146 var unpipeInfo = { hasUnpiped: false };
33147
33148 // if we're not piping anywhere, then do nothing.
33149 if (state.pipesCount === 0) return this;
33150
33151 // just one destination. most common case.
33152 if (state.pipesCount === 1) {
33153 // passed in one, but it's not the right one.
33154 if (dest && dest !== state.pipes) return this;
33155
33156 if (!dest) dest = state.pipes;
33157
33158 // got a match.
33159 state.pipes = null;
33160 state.pipesCount = 0;
33161 state.flowing = false;
33162 if (dest) dest.emit('unpipe', this, unpipeInfo);
33163 return this;
33164 }
33165
33166 // slow case. multiple pipe destinations.
33167
33168 if (!dest) {
33169 // remove all.
33170 var dests = state.pipes;
33171 var len = state.pipesCount;
33172 state.pipes = null;
33173 state.pipesCount = 0;
33174 state.flowing = false;
33175
33176 for (var i = 0; i < len; i++) {
33177 dests[i].emit('unpipe', this, unpipeInfo);
33178 }return this;
33179 }
33180
33181 // try to find the right one.
33182 var index = indexOf(state.pipes, dest);
33183 if (index === -1) return this;
33184
33185 state.pipes.splice(index, 1);
33186 state.pipesCount -= 1;
33187 if (state.pipesCount === 1) state.pipes = state.pipes[0];
33188
33189 dest.emit('unpipe', this, unpipeInfo);
33190
33191 return this;
33192};
33193
33194// set up data events if they are asked for
33195// Ensure readable listeners eventually get something
33196Readable.prototype.on = function (ev, fn) {
33197 var res = Stream.prototype.on.call(this, ev, fn);
33198
33199 if (ev === 'data') {
33200 // Start flowing on next tick if stream isn't explicitly paused
33201 if (this._readableState.flowing !== false) this.resume();
33202 } else if (ev === 'readable') {
33203 var state = this._readableState;
33204 if (!state.endEmitted && !state.readableListening) {
33205 state.readableListening = state.needReadable = true;
33206 state.emittedReadable = false;
33207 if (!state.reading) {
33208 pna.nextTick(nReadingNextTick, this);
33209 } else if (state.length) {
33210 emitReadable(this);
33211 }
33212 }
33213 }
33214
33215 return res;
33216};
33217Readable.prototype.addListener = Readable.prototype.on;
33218
33219function nReadingNextTick(self) {
33220 debug('readable nexttick read 0');
33221 self.read(0);
33222}
33223
33224// pause() and resume() are remnants of the legacy readable stream API
33225// If the user uses them, then switch into old mode.
33226Readable.prototype.resume = function () {
33227 var state = this._readableState;
33228 if (!state.flowing) {
33229 debug('resume');
33230 state.flowing = true;
33231 resume(this, state);
33232 }
33233 return this;
33234};
33235
33236function resume(stream, state) {
33237 if (!state.resumeScheduled) {
33238 state.resumeScheduled = true;
33239 pna.nextTick(resume_, stream, state);
33240 }
33241}
33242
33243function resume_(stream, state) {
33244 if (!state.reading) {
33245 debug('resume read 0');
33246 stream.read(0);
33247 }
33248
33249 state.resumeScheduled = false;
33250 state.awaitDrain = 0;
33251 stream.emit('resume');
33252 flow(stream);
33253 if (state.flowing && !state.reading) stream.read(0);
33254}
33255
33256Readable.prototype.pause = function () {
33257 debug('call pause flowing=%j', this._readableState.flowing);
33258 if (false !== this._readableState.flowing) {
33259 debug('pause');
33260 this._readableState.flowing = false;
33261 this.emit('pause');
33262 }
33263 return this;
33264};
33265
33266function flow(stream) {
33267 var state = stream._readableState;
33268 debug('flow', state.flowing);
33269 while (state.flowing && stream.read() !== null) {}
33270}
33271
33272// wrap an old-style stream as the async data source.
33273// This is *not* part of the readable stream interface.
33274// It is an ugly unfortunate mess of history.
33275Readable.prototype.wrap = function (stream) {
33276 var _this = this;
33277
33278 var state = this._readableState;
33279 var paused = false;
33280
33281 stream.on('end', function () {
33282 debug('wrapped end');
33283 if (state.decoder && !state.ended) {
33284 var chunk = state.decoder.end();
33285 if (chunk && chunk.length) _this.push(chunk);
33286 }
33287
33288 _this.push(null);
33289 });
33290
33291 stream.on('data', function (chunk) {
33292 debug('wrapped data');
33293 if (state.decoder) chunk = state.decoder.write(chunk);
33294
33295 // don't skip over falsy values in objectMode
33296 if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
33297
33298 var ret = _this.push(chunk);
33299 if (!ret) {
33300 paused = true;
33301 stream.pause();
33302 }
33303 });
33304
33305 // proxy all the other methods.
33306 // important when wrapping filters and duplexes.
33307 for (var i in stream) {
33308 if (this[i] === undefined && typeof stream[i] === 'function') {
33309 this[i] = function (method) {
33310 return function () {
33311 return stream[method].apply(stream, arguments);
33312 };
33313 }(i);
33314 }
33315 }
33316
33317 // proxy certain important events.
33318 for (var n = 0; n < kProxyEvents.length; n++) {
33319 stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
33320 }
33321
33322 // when we try to consume some more bytes, simply unpause the
33323 // underlying stream.
33324 this._read = function (n) {
33325 debug('wrapped _read', n);
33326 if (paused) {
33327 paused = false;
33328 stream.resume();
33329 }
33330 };
33331
33332 return this;
33333};
33334
33335Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
33336 // making it explicit this property is not enumerable
33337 // because otherwise some prototype manipulation in
33338 // userland will fail
33339 enumerable: false,
33340 get: function () {
33341 return this._readableState.highWaterMark;
33342 }
33343});
33344
33345// exposed for testing purposes only.
33346Readable._fromList = fromList;
33347
33348// Pluck off n bytes from an array of buffers.
33349// Length is the combined lengths of all the buffers in the list.
33350// This function is designed to be inlinable, so please take care when making
33351// changes to the function body.
33352function fromList(n, state) {
33353 // nothing buffered
33354 if (state.length === 0) return null;
33355
33356 var ret;
33357 if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
33358 // read it all, truncate the list
33359 if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);
33360 state.buffer.clear();
33361 } else {
33362 // read part of list
33363 ret = fromListPartial(n, state.buffer, state.decoder);
33364 }
33365
33366 return ret;
33367}
33368
33369// Extracts only enough buffered data to satisfy the amount requested.
33370// This function is designed to be inlinable, so please take care when making
33371// changes to the function body.
33372function fromListPartial(n, list, hasStrings) {
33373 var ret;
33374 if (n < list.head.data.length) {
33375 // slice is the same for buffers and strings
33376 ret = list.head.data.slice(0, n);
33377 list.head.data = list.head.data.slice(n);
33378 } else if (n === list.head.data.length) {
33379 // first chunk is a perfect match
33380 ret = list.shift();
33381 } else {
33382 // result spans more than one buffer
33383 ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
33384 }
33385 return ret;
33386}
33387
33388// Copies a specified amount of characters from the list of buffered data
33389// chunks.
33390// This function is designed to be inlinable, so please take care when making
33391// changes to the function body.
33392function copyFromBufferString(n, list) {
33393 var p = list.head;
33394 var c = 1;
33395 var ret = p.data;
33396 n -= ret.length;
33397 while (p = p.next) {
33398 var str = p.data;
33399 var nb = n > str.length ? str.length : n;
33400 if (nb === str.length) ret += str;else ret += str.slice(0, n);
33401 n -= nb;
33402 if (n === 0) {
33403 if (nb === str.length) {
33404 ++c;
33405 if (p.next) list.head = p.next;else list.head = list.tail = null;
33406 } else {
33407 list.head = p;
33408 p.data = str.slice(nb);
33409 }
33410 break;
33411 }
33412 ++c;
33413 }
33414 list.length -= c;
33415 return ret;
33416}
33417
33418// Copies a specified amount of bytes from the list of buffered data chunks.
33419// This function is designed to be inlinable, so please take care when making
33420// changes to the function body.
33421function copyFromBuffer(n, list) {
33422 var ret = Buffer.allocUnsafe(n);
33423 var p = list.head;
33424 var c = 1;
33425 p.data.copy(ret);
33426 n -= p.data.length;
33427 while (p = p.next) {
33428 var buf = p.data;
33429 var nb = n > buf.length ? buf.length : n;
33430 buf.copy(ret, ret.length - n, 0, nb);
33431 n -= nb;
33432 if (n === 0) {
33433 if (nb === buf.length) {
33434 ++c;
33435 if (p.next) list.head = p.next;else list.head = list.tail = null;
33436 } else {
33437 list.head = p;
33438 p.data = buf.slice(nb);
33439 }
33440 break;
33441 }
33442 ++c;
33443 }
33444 list.length -= c;
33445 return ret;
33446}
33447
33448function endReadable(stream) {
33449 var state = stream._readableState;
33450
33451 // If we get here before consuming all the bytes, then that is a
33452 // bug in node. Should never happen.
33453 if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
33454
33455 if (!state.endEmitted) {
33456 state.ended = true;
33457 pna.nextTick(endReadableNT, state, stream);
33458 }
33459}
33460
33461function endReadableNT(state, stream) {
33462 // Check that we didn't get one last unshift.
33463 if (!state.endEmitted && state.length === 0) {
33464 state.endEmitted = true;
33465 stream.readable = false;
33466 stream.emit('end');
33467 }
33468}
33469
33470function indexOf(xs, x) {
33471 for (var i = 0, l = xs.length; i < l; i++) {
33472 if (xs[i] === x) return i;
33473 }
33474 return -1;
33475}
33476}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
33477},{"./_stream_duplex":384,"./internal/streams/BufferList":389,"./internal/streams/destroy":390,"./internal/streams/stream":391,"_process":374,"core-util-is":52,"events":102,"inherits":119,"isarray":121,"process-nextick-args":373,"safe-buffer":398,"string_decoder/":392,"util":20}],387:[function(require,module,exports){
33478// Copyright Joyent, Inc. and other Node contributors.
33479//
33480// Permission is hereby granted, free of charge, to any person obtaining a
33481// copy of this software and associated documentation files (the
33482// "Software"), to deal in the Software without restriction, including
33483// without limitation the rights to use, copy, modify, merge, publish,
33484// distribute, sublicense, and/or sell copies of the Software, and to permit
33485// persons to whom the Software is furnished to do so, subject to the
33486// following conditions:
33487//
33488// The above copyright notice and this permission notice shall be included
33489// in all copies or substantial portions of the Software.
33490//
33491// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
33492// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
33493// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
33494// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
33495// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
33496// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
33497// USE OR OTHER DEALINGS IN THE SOFTWARE.
33498
33499// a transform stream is a readable/writable stream where you do
33500// something with the data. Sometimes it's called a "filter",
33501// but that's not a great name for it, since that implies a thing where
33502// some bits pass through, and others are simply ignored. (That would
33503// be a valid example of a transform, of course.)
33504//
33505// While the output is causally related to the input, it's not a
33506// necessarily symmetric or synchronous transformation. For example,
33507// a zlib stream might take multiple plain-text writes(), and then
33508// emit a single compressed chunk some time in the future.
33509//
33510// Here's how this works:
33511//
33512// The Transform stream has all the aspects of the readable and writable
33513// stream classes. When you write(chunk), that calls _write(chunk,cb)
33514// internally, and returns false if there's a lot of pending writes
33515// buffered up. When you call read(), that calls _read(n) until
33516// there's enough pending readable data buffered up.
33517//
33518// In a transform stream, the written data is placed in a buffer. When
33519// _read(n) is called, it transforms the queued up data, calling the
33520// buffered _write cb's as it consumes chunks. If consuming a single
33521// written chunk would result in multiple output chunks, then the first
33522// outputted bit calls the readcb, and subsequent chunks just go into
33523// the read buffer, and will cause it to emit 'readable' if necessary.
33524//
33525// This way, back-pressure is actually determined by the reading side,
33526// since _read has to be called to start processing a new chunk. However,
33527// a pathological inflate type of transform can cause excessive buffering
33528// here. For example, imagine a stream where every byte of input is
33529// interpreted as an integer from 0-255, and then results in that many
33530// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
33531// 1kb of data being output. In this case, you could write a very small
33532// amount of input, and end up with a very large amount of output. In
33533// such a pathological inflating mechanism, there'd be no way to tell
33534// the system to stop doing the transform. A single 4MB write could
33535// cause the system to run out of memory.
33536//
33537// However, even in such a pathological case, only a single written chunk
33538// would be consumed, and then the rest would wait (un-transformed) until
33539// the results of the previous transformed chunk were consumed.
33540
33541'use strict';
33542
33543module.exports = Transform;
33544
33545var Duplex = require('./_stream_duplex');
33546
33547/*<replacement>*/
33548var util = require('core-util-is');
33549util.inherits = require('inherits');
33550/*</replacement>*/
33551
33552util.inherits(Transform, Duplex);
33553
33554function afterTransform(er, data) {
33555 var ts = this._transformState;
33556 ts.transforming = false;
33557
33558 var cb = ts.writecb;
33559
33560 if (!cb) {
33561 return this.emit('error', new Error('write callback called multiple times'));
33562 }
33563
33564 ts.writechunk = null;
33565 ts.writecb = null;
33566
33567 if (data != null) // single equals check for both `null` and `undefined`
33568 this.push(data);
33569
33570 cb(er);
33571
33572 var rs = this._readableState;
33573 rs.reading = false;
33574 if (rs.needReadable || rs.length < rs.highWaterMark) {
33575 this._read(rs.highWaterMark);
33576 }
33577}
33578
33579function Transform(options) {
33580 if (!(this instanceof Transform)) return new Transform(options);
33581
33582 Duplex.call(this, options);
33583
33584 this._transformState = {
33585 afterTransform: afterTransform.bind(this),
33586 needTransform: false,
33587 transforming: false,
33588 writecb: null,
33589 writechunk: null,
33590 writeencoding: null
33591 };
33592
33593 // start out asking for a readable event once data is transformed.
33594 this._readableState.needReadable = true;
33595
33596 // we have implemented the _read method, and done the other things
33597 // that Readable wants before the first _read call, so unset the
33598 // sync guard flag.
33599 this._readableState.sync = false;
33600
33601 if (options) {
33602 if (typeof options.transform === 'function') this._transform = options.transform;
33603
33604 if (typeof options.flush === 'function') this._flush = options.flush;
33605 }
33606
33607 // When the writable side finishes, then flush out anything remaining.
33608 this.on('prefinish', prefinish);
33609}
33610
33611function prefinish() {
33612 var _this = this;
33613
33614 if (typeof this._flush === 'function') {
33615 this._flush(function (er, data) {
33616 done(_this, er, data);
33617 });
33618 } else {
33619 done(this, null, null);
33620 }
33621}
33622
33623Transform.prototype.push = function (chunk, encoding) {
33624 this._transformState.needTransform = false;
33625 return Duplex.prototype.push.call(this, chunk, encoding);
33626};
33627
33628// This is the part where you do stuff!
33629// override this function in implementation classes.
33630// 'chunk' is an input chunk.
33631//
33632// Call `push(newChunk)` to pass along transformed output
33633// to the readable side. You may call 'push' zero or more times.
33634//
33635// Call `cb(err)` when you are done with this chunk. If you pass
33636// an error, then that'll put the hurt on the whole operation. If you
33637// never call cb(), then you'll never get another chunk.
33638Transform.prototype._transform = function (chunk, encoding, cb) {
33639 throw new Error('_transform() is not implemented');
33640};
33641
33642Transform.prototype._write = function (chunk, encoding, cb) {
33643 var ts = this._transformState;
33644 ts.writecb = cb;
33645 ts.writechunk = chunk;
33646 ts.writeencoding = encoding;
33647 if (!ts.transforming) {
33648 var rs = this._readableState;
33649 if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
33650 }
33651};
33652
33653// Doesn't matter what the args are here.
33654// _transform does all the work.
33655// That we got here means that the readable side wants more data.
33656Transform.prototype._read = function (n) {
33657 var ts = this._transformState;
33658
33659 if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
33660 ts.transforming = true;
33661 this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
33662 } else {
33663 // mark that we need a transform, so that any data that comes in
33664 // will get processed, now that we've asked for it.
33665 ts.needTransform = true;
33666 }
33667};
33668
33669Transform.prototype._destroy = function (err, cb) {
33670 var _this2 = this;
33671
33672 Duplex.prototype._destroy.call(this, err, function (err2) {
33673 cb(err2);
33674 _this2.emit('close');
33675 });
33676};
33677
33678function done(stream, er, data) {
33679 if (er) return stream.emit('error', er);
33680
33681 if (data != null) // single equals check for both `null` and `undefined`
33682 stream.push(data);
33683
33684 // if there's nothing in the write buffer, then that means
33685 // that nothing more will ever be provided
33686 if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
33687
33688 if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
33689
33690 return stream.push(null);
33691}
33692},{"./_stream_duplex":384,"core-util-is":52,"inherits":119}],388:[function(require,module,exports){
33693(function (process,global,setImmediate){
33694// Copyright Joyent, Inc. and other Node contributors.
33695//
33696// Permission is hereby granted, free of charge, to any person obtaining a
33697// copy of this software and associated documentation files (the
33698// "Software"), to deal in the Software without restriction, including
33699// without limitation the rights to use, copy, modify, merge, publish,
33700// distribute, sublicense, and/or sell copies of the Software, and to permit
33701// persons to whom the Software is furnished to do so, subject to the
33702// following conditions:
33703//
33704// The above copyright notice and this permission notice shall be included
33705// in all copies or substantial portions of the Software.
33706//
33707// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
33708// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
33709// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
33710// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
33711// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
33712// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
33713// USE OR OTHER DEALINGS IN THE SOFTWARE.
33714
33715// A bit simpler than readable streams.
33716// Implement an async ._write(chunk, encoding, cb), and it'll handle all
33717// the drain event emission and buffering.
33718
33719'use strict';
33720
33721/*<replacement>*/
33722
33723var pna = require('process-nextick-args');
33724/*</replacement>*/
33725
33726module.exports = Writable;
33727
33728/* <replacement> */
33729function WriteReq(chunk, encoding, cb) {
33730 this.chunk = chunk;
33731 this.encoding = encoding;
33732 this.callback = cb;
33733 this.next = null;
33734}
33735
33736// It seems a linked list but it is not
33737// there will be only 2 of these for each stream
33738function CorkedRequest(state) {
33739 var _this = this;
33740
33741 this.next = null;
33742 this.entry = null;
33743 this.finish = function () {
33744 onCorkedFinish(_this, state);
33745 };
33746}
33747/* </replacement> */
33748
33749/*<replacement>*/
33750var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
33751/*</replacement>*/
33752
33753/*<replacement>*/
33754var Duplex;
33755/*</replacement>*/
33756
33757Writable.WritableState = WritableState;
33758
33759/*<replacement>*/
33760var util = require('core-util-is');
33761util.inherits = require('inherits');
33762/*</replacement>*/
33763
33764/*<replacement>*/
33765var internalUtil = {
33766 deprecate: require('util-deprecate')
33767};
33768/*</replacement>*/
33769
33770/*<replacement>*/
33771var Stream = require('./internal/streams/stream');
33772/*</replacement>*/
33773
33774/*<replacement>*/
33775
33776var Buffer = require('safe-buffer').Buffer;
33777var OurUint8Array = global.Uint8Array || function () {};
33778function _uint8ArrayToBuffer(chunk) {
33779 return Buffer.from(chunk);
33780}
33781function _isUint8Array(obj) {
33782 return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
33783}
33784
33785/*</replacement>*/
33786
33787var destroyImpl = require('./internal/streams/destroy');
33788
33789util.inherits(Writable, Stream);
33790
33791function nop() {}
33792
33793function WritableState(options, stream) {
33794 Duplex = Duplex || require('./_stream_duplex');
33795
33796 options = options || {};
33797
33798 // Duplex streams are both readable and writable, but share
33799 // the same options object.
33800 // However, some cases require setting options to different
33801 // values for the readable and the writable sides of the duplex stream.
33802 // These options can be provided separately as readableXXX and writableXXX.
33803 var isDuplex = stream instanceof Duplex;
33804
33805 // object stream flag to indicate whether or not this stream
33806 // contains buffers or objects.
33807 this.objectMode = !!options.objectMode;
33808
33809 if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
33810
33811 // the point at which write() starts returning false
33812 // Note: 0 is a valid value, means that we always return false if
33813 // the entire buffer is not flushed immediately on write()
33814 var hwm = options.highWaterMark;
33815 var writableHwm = options.writableHighWaterMark;
33816 var defaultHwm = this.objectMode ? 16 : 16 * 1024;
33817
33818 if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;
33819
33820 // cast to ints.
33821 this.highWaterMark = Math.floor(this.highWaterMark);
33822
33823 // if _final has been called
33824 this.finalCalled = false;
33825
33826 // drain event flag.
33827 this.needDrain = false;
33828 // at the start of calling end()
33829 this.ending = false;
33830 // when end() has been called, and returned
33831 this.ended = false;
33832 // when 'finish' is emitted
33833 this.finished = false;
33834
33835 // has it been destroyed
33836 this.destroyed = false;
33837
33838 // should we decode strings into buffers before passing to _write?
33839 // this is here so that some node-core streams can optimize string
33840 // handling at a lower level.
33841 var noDecode = options.decodeStrings === false;
33842 this.decodeStrings = !noDecode;
33843
33844 // Crypto is kind of old and crusty. Historically, its default string
33845 // encoding is 'binary' so we have to make this configurable.
33846 // Everything else in the universe uses 'utf8', though.
33847 this.defaultEncoding = options.defaultEncoding || 'utf8';
33848
33849 // not an actual buffer we keep track of, but a measurement
33850 // of how much we're waiting to get pushed to some underlying
33851 // socket or file.
33852 this.length = 0;
33853
33854 // a flag to see when we're in the middle of a write.
33855 this.writing = false;
33856
33857 // when true all writes will be buffered until .uncork() call
33858 this.corked = 0;
33859
33860 // a flag to be able to tell if the onwrite cb is called immediately,
33861 // or on a later tick. We set this to true at first, because any
33862 // actions that shouldn't happen until "later" should generally also
33863 // not happen before the first write call.
33864 this.sync = true;
33865
33866 // a flag to know if we're processing previously buffered items, which
33867 // may call the _write() callback in the same tick, so that we don't
33868 // end up in an overlapped onwrite situation.
33869 this.bufferProcessing = false;
33870
33871 // the callback that's passed to _write(chunk,cb)
33872 this.onwrite = function (er) {
33873 onwrite(stream, er);
33874 };
33875
33876 // the callback that the user supplies to write(chunk,encoding,cb)
33877 this.writecb = null;
33878
33879 // the amount that is being written when _write is called.
33880 this.writelen = 0;
33881
33882 this.bufferedRequest = null;
33883 this.lastBufferedRequest = null;
33884
33885 // number of pending user-supplied write callbacks
33886 // this must be 0 before 'finish' can be emitted
33887 this.pendingcb = 0;
33888
33889 // emit prefinish if the only thing we're waiting for is _write cbs
33890 // This is relevant for synchronous Transform streams
33891 this.prefinished = false;
33892
33893 // True if the error was already emitted and should not be thrown again
33894 this.errorEmitted = false;
33895
33896 // count buffered requests
33897 this.bufferedRequestCount = 0;
33898
33899 // allocate the first CorkedRequest, there is always
33900 // one allocated and free to use, and we maintain at most two
33901 this.corkedRequestsFree = new CorkedRequest(this);
33902}
33903
33904WritableState.prototype.getBuffer = function getBuffer() {
33905 var current = this.bufferedRequest;
33906 var out = [];
33907 while (current) {
33908 out.push(current);
33909 current = current.next;
33910 }
33911 return out;
33912};
33913
33914(function () {
33915 try {
33916 Object.defineProperty(WritableState.prototype, 'buffer', {
33917 get: internalUtil.deprecate(function () {
33918 return this.getBuffer();
33919 }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
33920 });
33921 } catch (_) {}
33922})();
33923
33924// Test _writableState for inheritance to account for Duplex streams,
33925// whose prototype chain only points to Readable.
33926var realHasInstance;
33927if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
33928 realHasInstance = Function.prototype[Symbol.hasInstance];
33929 Object.defineProperty(Writable, Symbol.hasInstance, {
33930 value: function (object) {
33931 if (realHasInstance.call(this, object)) return true;
33932 if (this !== Writable) return false;
33933
33934 return object && object._writableState instanceof WritableState;
33935 }
33936 });
33937} else {
33938 realHasInstance = function (object) {
33939 return object instanceof this;
33940 };
33941}
33942
33943function Writable(options) {
33944 Duplex = Duplex || require('./_stream_duplex');
33945
33946 // Writable ctor is applied to Duplexes, too.
33947 // `realHasInstance` is necessary because using plain `instanceof`
33948 // would return false, as no `_writableState` property is attached.
33949
33950 // Trying to use the custom `instanceof` for Writable here will also break the
33951 // Node.js LazyTransform implementation, which has a non-trivial getter for
33952 // `_writableState` that would lead to infinite recursion.
33953 if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
33954 return new Writable(options);
33955 }
33956
33957 this._writableState = new WritableState(options, this);
33958
33959 // legacy.
33960 this.writable = true;
33961
33962 if (options) {
33963 if (typeof options.write === 'function') this._write = options.write;
33964
33965 if (typeof options.writev === 'function') this._writev = options.writev;
33966
33967 if (typeof options.destroy === 'function') this._destroy = options.destroy;
33968
33969 if (typeof options.final === 'function') this._final = options.final;
33970 }
33971
33972 Stream.call(this);
33973}
33974
33975// Otherwise people can pipe Writable streams, which is just wrong.
33976Writable.prototype.pipe = function () {
33977 this.emit('error', new Error('Cannot pipe, not readable'));
33978};
33979
33980function writeAfterEnd(stream, cb) {
33981 var er = new Error('write after end');
33982 // TODO: defer error events consistently everywhere, not just the cb
33983 stream.emit('error', er);
33984 pna.nextTick(cb, er);
33985}
33986
33987// Checks that a user-supplied chunk is valid, especially for the particular
33988// mode the stream is in. Currently this means that `null` is never accepted
33989// and undefined/non-string values are only allowed in object mode.
33990function validChunk(stream, state, chunk, cb) {
33991 var valid = true;
33992 var er = false;
33993
33994 if (chunk === null) {
33995 er = new TypeError('May not write null values to stream');
33996 } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
33997 er = new TypeError('Invalid non-string/buffer chunk');
33998 }
33999 if (er) {
34000 stream.emit('error', er);
34001 pna.nextTick(cb, er);
34002 valid = false;
34003 }
34004 return valid;
34005}
34006
34007Writable.prototype.write = function (chunk, encoding, cb) {
34008 var state = this._writableState;
34009 var ret = false;
34010 var isBuf = !state.objectMode && _isUint8Array(chunk);
34011
34012 if (isBuf && !Buffer.isBuffer(chunk)) {
34013 chunk = _uint8ArrayToBuffer(chunk);
34014 }
34015
34016 if (typeof encoding === 'function') {
34017 cb = encoding;
34018 encoding = null;
34019 }
34020
34021 if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
34022
34023 if (typeof cb !== 'function') cb = nop;
34024
34025 if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
34026 state.pendingcb++;
34027 ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
34028 }
34029
34030 return ret;
34031};
34032
34033Writable.prototype.cork = function () {
34034 var state = this._writableState;
34035
34036 state.corked++;
34037};
34038
34039Writable.prototype.uncork = function () {
34040 var state = this._writableState;
34041
34042 if (state.corked) {
34043 state.corked--;
34044
34045 if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
34046 }
34047};
34048
34049Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
34050 // node::ParseEncoding() requires lower case.
34051 if (typeof encoding === 'string') encoding = encoding.toLowerCase();
34052 if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
34053 this._writableState.defaultEncoding = encoding;
34054 return this;
34055};
34056
34057function decodeChunk(state, chunk, encoding) {
34058 if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
34059 chunk = Buffer.from(chunk, encoding);
34060 }
34061 return chunk;
34062}
34063
34064Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
34065 // making it explicit this property is not enumerable
34066 // because otherwise some prototype manipulation in
34067 // userland will fail
34068 enumerable: false,
34069 get: function () {
34070 return this._writableState.highWaterMark;
34071 }
34072});
34073
34074// if we're already writing something, then just put this
34075// in the queue, and wait our turn. Otherwise, call _write
34076// If we return false, then we need a drain event, so set that flag.
34077function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
34078 if (!isBuf) {
34079 var newChunk = decodeChunk(state, chunk, encoding);
34080 if (chunk !== newChunk) {
34081 isBuf = true;
34082 encoding = 'buffer';
34083 chunk = newChunk;
34084 }
34085 }
34086 var len = state.objectMode ? 1 : chunk.length;
34087
34088 state.length += len;
34089
34090 var ret = state.length < state.highWaterMark;
34091 // we must ensure that previous needDrain will not be reset to false.
34092 if (!ret) state.needDrain = true;
34093
34094 if (state.writing || state.corked) {
34095 var last = state.lastBufferedRequest;
34096 state.lastBufferedRequest = {
34097 chunk: chunk,
34098 encoding: encoding,
34099 isBuf: isBuf,
34100 callback: cb,
34101 next: null
34102 };
34103 if (last) {
34104 last.next = state.lastBufferedRequest;
34105 } else {
34106 state.bufferedRequest = state.lastBufferedRequest;
34107 }
34108 state.bufferedRequestCount += 1;
34109 } else {
34110 doWrite(stream, state, false, len, chunk, encoding, cb);
34111 }
34112
34113 return ret;
34114}
34115
34116function doWrite(stream, state, writev, len, chunk, encoding, cb) {
34117 state.writelen = len;
34118 state.writecb = cb;
34119 state.writing = true;
34120 state.sync = true;
34121 if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
34122 state.sync = false;
34123}
34124
34125function onwriteError(stream, state, sync, er, cb) {
34126 --state.pendingcb;
34127
34128 if (sync) {
34129 // defer the callback if we are being called synchronously
34130 // to avoid piling up things on the stack
34131 pna.nextTick(cb, er);
34132 // this can emit finish, and it will always happen
34133 // after error
34134 pna.nextTick(finishMaybe, stream, state);
34135 stream._writableState.errorEmitted = true;
34136 stream.emit('error', er);
34137 } else {
34138 // the caller expect this to happen before if
34139 // it is async
34140 cb(er);
34141 stream._writableState.errorEmitted = true;
34142 stream.emit('error', er);
34143 // this can emit finish, but finish must
34144 // always follow error
34145 finishMaybe(stream, state);
34146 }
34147}
34148
34149function onwriteStateUpdate(state) {
34150 state.writing = false;
34151 state.writecb = null;
34152 state.length -= state.writelen;
34153 state.writelen = 0;
34154}
34155
34156function onwrite(stream, er) {
34157 var state = stream._writableState;
34158 var sync = state.sync;
34159 var cb = state.writecb;
34160
34161 onwriteStateUpdate(state);
34162
34163 if (er) onwriteError(stream, state, sync, er, cb);else {
34164 // Check if we're actually ready to finish, but don't emit yet
34165 var finished = needFinish(state);
34166
34167 if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
34168 clearBuffer(stream, state);
34169 }
34170
34171 if (sync) {
34172 /*<replacement>*/
34173 asyncWrite(afterWrite, stream, state, finished, cb);
34174 /*</replacement>*/
34175 } else {
34176 afterWrite(stream, state, finished, cb);
34177 }
34178 }
34179}
34180
34181function afterWrite(stream, state, finished, cb) {
34182 if (!finished) onwriteDrain(stream, state);
34183 state.pendingcb--;
34184 cb();
34185 finishMaybe(stream, state);
34186}
34187
34188// Must force callback to be called on nextTick, so that we don't
34189// emit 'drain' before the write() consumer gets the 'false' return
34190// value, and has a chance to attach a 'drain' listener.
34191function onwriteDrain(stream, state) {
34192 if (state.length === 0 && state.needDrain) {
34193 state.needDrain = false;
34194 stream.emit('drain');
34195 }
34196}
34197
34198// if there's something in the buffer waiting, then process it
34199function clearBuffer(stream, state) {
34200 state.bufferProcessing = true;
34201 var entry = state.bufferedRequest;
34202
34203 if (stream._writev && entry && entry.next) {
34204 // Fast case, write everything using _writev()
34205 var l = state.bufferedRequestCount;
34206 var buffer = new Array(l);
34207 var holder = state.corkedRequestsFree;
34208 holder.entry = entry;
34209
34210 var count = 0;
34211 var allBuffers = true;
34212 while (entry) {
34213 buffer[count] = entry;
34214 if (!entry.isBuf) allBuffers = false;
34215 entry = entry.next;
34216 count += 1;
34217 }
34218 buffer.allBuffers = allBuffers;
34219
34220 doWrite(stream, state, true, state.length, buffer, '', holder.finish);
34221
34222 // doWrite is almost always async, defer these to save a bit of time
34223 // as the hot path ends with doWrite
34224 state.pendingcb++;
34225 state.lastBufferedRequest = null;
34226 if (holder.next) {
34227 state.corkedRequestsFree = holder.next;
34228 holder.next = null;
34229 } else {
34230 state.corkedRequestsFree = new CorkedRequest(state);
34231 }
34232 state.bufferedRequestCount = 0;
34233 } else {
34234 // Slow case, write chunks one-by-one
34235 while (entry) {
34236 var chunk = entry.chunk;
34237 var encoding = entry.encoding;
34238 var cb = entry.callback;
34239 var len = state.objectMode ? 1 : chunk.length;
34240
34241 doWrite(stream, state, false, len, chunk, encoding, cb);
34242 entry = entry.next;
34243 state.bufferedRequestCount--;
34244 // if we didn't call the onwrite immediately, then
34245 // it means that we need to wait until it does.
34246 // also, that means that the chunk and cb are currently
34247 // being processed, so move the buffer counter past them.
34248 if (state.writing) {
34249 break;
34250 }
34251 }
34252
34253 if (entry === null) state.lastBufferedRequest = null;
34254 }
34255
34256 state.bufferedRequest = entry;
34257 state.bufferProcessing = false;
34258}
34259
34260Writable.prototype._write = function (chunk, encoding, cb) {
34261 cb(new Error('_write() is not implemented'));
34262};
34263
34264Writable.prototype._writev = null;
34265
34266Writable.prototype.end = function (chunk, encoding, cb) {
34267 var state = this._writableState;
34268
34269 if (typeof chunk === 'function') {
34270 cb = chunk;
34271 chunk = null;
34272 encoding = null;
34273 } else if (typeof encoding === 'function') {
34274 cb = encoding;
34275 encoding = null;
34276 }
34277
34278 if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
34279
34280 // .end() fully uncorks
34281 if (state.corked) {
34282 state.corked = 1;
34283 this.uncork();
34284 }
34285
34286 // ignore unnecessary end() calls.
34287 if (!state.ending && !state.finished) endWritable(this, state, cb);
34288};
34289
34290function needFinish(state) {
34291 return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
34292}
34293function callFinal(stream, state) {
34294 stream._final(function (err) {
34295 state.pendingcb--;
34296 if (err) {
34297 stream.emit('error', err);
34298 }
34299 state.prefinished = true;
34300 stream.emit('prefinish');
34301 finishMaybe(stream, state);
34302 });
34303}
34304function prefinish(stream, state) {
34305 if (!state.prefinished && !state.finalCalled) {
34306 if (typeof stream._final === 'function') {
34307 state.pendingcb++;
34308 state.finalCalled = true;
34309 pna.nextTick(callFinal, stream, state);
34310 } else {
34311 state.prefinished = true;
34312 stream.emit('prefinish');
34313 }
34314 }
34315}
34316
34317function finishMaybe(stream, state) {
34318 var need = needFinish(state);
34319 if (need) {
34320 prefinish(stream, state);
34321 if (state.pendingcb === 0) {
34322 state.finished = true;
34323 stream.emit('finish');
34324 }
34325 }
34326 return need;
34327}
34328
34329function endWritable(stream, state, cb) {
34330 state.ending = true;
34331 finishMaybe(stream, state);
34332 if (cb) {
34333 if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
34334 }
34335 state.ended = true;
34336 stream.writable = false;
34337}
34338
34339function onCorkedFinish(corkReq, state, err) {
34340 var entry = corkReq.entry;
34341 corkReq.entry = null;
34342 while (entry) {
34343 var cb = entry.callback;
34344 state.pendingcb--;
34345 cb(err);
34346 entry = entry.next;
34347 }
34348 if (state.corkedRequestsFree) {
34349 state.corkedRequestsFree.next = corkReq;
34350 } else {
34351 state.corkedRequestsFree = corkReq;
34352 }
34353}
34354
34355Object.defineProperty(Writable.prototype, 'destroyed', {
34356 get: function () {
34357 if (this._writableState === undefined) {
34358 return false;
34359 }
34360 return this._writableState.destroyed;
34361 },
34362 set: function (value) {
34363 // we ignore the value if the stream
34364 // has not been initialized yet
34365 if (!this._writableState) {
34366 return;
34367 }
34368
34369 // backward compatibility, the user is explicitly
34370 // managing destroyed
34371 this._writableState.destroyed = value;
34372 }
34373});
34374
34375Writable.prototype.destroy = destroyImpl.destroy;
34376Writable.prototype._undestroy = destroyImpl.undestroy;
34377Writable.prototype._destroy = function (err, cb) {
34378 this.end();
34379 cb(err);
34380};
34381}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").setImmediate)
34382},{"./_stream_duplex":384,"./internal/streams/destroy":390,"./internal/streams/stream":391,"_process":374,"core-util-is":52,"inherits":119,"process-nextick-args":373,"safe-buffer":398,"timers":439,"util-deprecate":441}],389:[function(require,module,exports){
34383'use strict';
34384
34385function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
34386
34387var Buffer = require('safe-buffer').Buffer;
34388var util = require('util');
34389
34390function copyBuffer(src, target, offset) {
34391 src.copy(target, offset);
34392}
34393
34394module.exports = function () {
34395 function BufferList() {
34396 _classCallCheck(this, BufferList);
34397
34398 this.head = null;
34399 this.tail = null;
34400 this.length = 0;
34401 }
34402
34403 BufferList.prototype.push = function push(v) {
34404 var entry = { data: v, next: null };
34405 if (this.length > 0) this.tail.next = entry;else this.head = entry;
34406 this.tail = entry;
34407 ++this.length;
34408 };
34409
34410 BufferList.prototype.unshift = function unshift(v) {
34411 var entry = { data: v, next: this.head };
34412 if (this.length === 0) this.tail = entry;
34413 this.head = entry;
34414 ++this.length;
34415 };
34416
34417 BufferList.prototype.shift = function shift() {
34418 if (this.length === 0) return;
34419 var ret = this.head.data;
34420 if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
34421 --this.length;
34422 return ret;
34423 };
34424
34425 BufferList.prototype.clear = function clear() {
34426 this.head = this.tail = null;
34427 this.length = 0;
34428 };
34429
34430 BufferList.prototype.join = function join(s) {
34431 if (this.length === 0) return '';
34432 var p = this.head;
34433 var ret = '' + p.data;
34434 while (p = p.next) {
34435 ret += s + p.data;
34436 }return ret;
34437 };
34438
34439 BufferList.prototype.concat = function concat(n) {
34440 if (this.length === 0) return Buffer.alloc(0);
34441 if (this.length === 1) return this.head.data;
34442 var ret = Buffer.allocUnsafe(n >>> 0);
34443 var p = this.head;
34444 var i = 0;
34445 while (p) {
34446 copyBuffer(p.data, ret, i);
34447 i += p.data.length;
34448 p = p.next;
34449 }
34450 return ret;
34451 };
34452
34453 return BufferList;
34454}();
34455
34456if (util && util.inspect && util.inspect.custom) {
34457 module.exports.prototype[util.inspect.custom] = function () {
34458 var obj = util.inspect({ length: this.length });
34459 return this.constructor.name + ' ' + obj;
34460 };
34461}
34462},{"safe-buffer":398,"util":20}],390:[function(require,module,exports){
34463'use strict';
34464
34465/*<replacement>*/
34466
34467var pna = require('process-nextick-args');
34468/*</replacement>*/
34469
34470// undocumented cb() API, needed for core, not for public API
34471function destroy(err, cb) {
34472 var _this = this;
34473
34474 var readableDestroyed = this._readableState && this._readableState.destroyed;
34475 var writableDestroyed = this._writableState && this._writableState.destroyed;
34476
34477 if (readableDestroyed || writableDestroyed) {
34478 if (cb) {
34479 cb(err);
34480 } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
34481 pna.nextTick(emitErrorNT, this, err);
34482 }
34483 return this;
34484 }
34485
34486 // we set destroyed to true before firing error callbacks in order
34487 // to make it re-entrance safe in case destroy() is called within callbacks
34488
34489 if (this._readableState) {
34490 this._readableState.destroyed = true;
34491 }
34492
34493 // if this is a duplex stream mark the writable part as destroyed as well
34494 if (this._writableState) {
34495 this._writableState.destroyed = true;
34496 }
34497
34498 this._destroy(err || null, function (err) {
34499 if (!cb && err) {
34500 pna.nextTick(emitErrorNT, _this, err);
34501 if (_this._writableState) {
34502 _this._writableState.errorEmitted = true;
34503 }
34504 } else if (cb) {
34505 cb(err);
34506 }
34507 });
34508
34509 return this;
34510}
34511
34512function undestroy() {
34513 if (this._readableState) {
34514 this._readableState.destroyed = false;
34515 this._readableState.reading = false;
34516 this._readableState.ended = false;
34517 this._readableState.endEmitted = false;
34518 }
34519
34520 if (this._writableState) {
34521 this._writableState.destroyed = false;
34522 this._writableState.ended = false;
34523 this._writableState.ending = false;
34524 this._writableState.finished = false;
34525 this._writableState.errorEmitted = false;
34526 }
34527}
34528
34529function emitErrorNT(self, err) {
34530 self.emit('error', err);
34531}
34532
34533module.exports = {
34534 destroy: destroy,
34535 undestroy: undestroy
34536};
34537},{"process-nextick-args":373}],391:[function(require,module,exports){
34538module.exports = require('events').EventEmitter;
34539
34540},{"events":102}],392:[function(require,module,exports){
34541// Copyright Joyent, Inc. and other Node contributors.
34542//
34543// Permission is hereby granted, free of charge, to any person obtaining a
34544// copy of this software and associated documentation files (the
34545// "Software"), to deal in the Software without restriction, including
34546// without limitation the rights to use, copy, modify, merge, publish,
34547// distribute, sublicense, and/or sell copies of the Software, and to permit
34548// persons to whom the Software is furnished to do so, subject to the
34549// following conditions:
34550//
34551// The above copyright notice and this permission notice shall be included
34552// in all copies or substantial portions of the Software.
34553//
34554// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
34555// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
34556// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
34557// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
34558// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
34559// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
34560// USE OR OTHER DEALINGS IN THE SOFTWARE.
34561
34562'use strict';
34563
34564/*<replacement>*/
34565
34566var Buffer = require('safe-buffer').Buffer;
34567/*</replacement>*/
34568
34569var isEncoding = Buffer.isEncoding || function (encoding) {
34570 encoding = '' + encoding;
34571 switch (encoding && encoding.toLowerCase()) {
34572 case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':
34573 return true;
34574 default:
34575 return false;
34576 }
34577};
34578
34579function _normalizeEncoding(enc) {
34580 if (!enc) return 'utf8';
34581 var retried;
34582 while (true) {
34583 switch (enc) {
34584 case 'utf8':
34585 case 'utf-8':
34586 return 'utf8';
34587 case 'ucs2':
34588 case 'ucs-2':
34589 case 'utf16le':
34590 case 'utf-16le':
34591 return 'utf16le';
34592 case 'latin1':
34593 case 'binary':
34594 return 'latin1';
34595 case 'base64':
34596 case 'ascii':
34597 case 'hex':
34598 return enc;
34599 default:
34600 if (retried) return; // undefined
34601 enc = ('' + enc).toLowerCase();
34602 retried = true;
34603 }
34604 }
34605};
34606
34607// Do not cache `Buffer.isEncoding` when checking encoding names as some
34608// modules monkey-patch it to support additional encodings
34609function normalizeEncoding(enc) {
34610 var nenc = _normalizeEncoding(enc);
34611 if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
34612 return nenc || enc;
34613}
34614
34615// StringDecoder provides an interface for efficiently splitting a series of
34616// buffers into a series of JS strings without breaking apart multi-byte
34617// characters.
34618exports.StringDecoder = StringDecoder;
34619function StringDecoder(encoding) {
34620 this.encoding = normalizeEncoding(encoding);
34621 var nb;
34622 switch (this.encoding) {
34623 case 'utf16le':
34624 this.text = utf16Text;
34625 this.end = utf16End;
34626 nb = 4;
34627 break;
34628 case 'utf8':
34629 this.fillLast = utf8FillLast;
34630 nb = 4;
34631 break;
34632 case 'base64':
34633 this.text = base64Text;
34634 this.end = base64End;
34635 nb = 3;
34636 break;
34637 default:
34638 this.write = simpleWrite;
34639 this.end = simpleEnd;
34640 return;
34641 }
34642 this.lastNeed = 0;
34643 this.lastTotal = 0;
34644 this.lastChar = Buffer.allocUnsafe(nb);
34645}
34646
34647StringDecoder.prototype.write = function (buf) {
34648 if (buf.length === 0) return '';
34649 var r;
34650 var i;
34651 if (this.lastNeed) {
34652 r = this.fillLast(buf);
34653 if (r === undefined) return '';
34654 i = this.lastNeed;
34655 this.lastNeed = 0;
34656 } else {
34657 i = 0;
34658 }
34659 if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
34660 return r || '';
34661};
34662
34663StringDecoder.prototype.end = utf8End;
34664
34665// Returns only complete characters in a Buffer
34666StringDecoder.prototype.text = utf8Text;
34667
34668// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
34669StringDecoder.prototype.fillLast = function (buf) {
34670 if (this.lastNeed <= buf.length) {
34671 buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
34672 return this.lastChar.toString(this.encoding, 0, this.lastTotal);
34673 }
34674 buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
34675 this.lastNeed -= buf.length;
34676};
34677
34678// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
34679// continuation byte. If an invalid byte is detected, -2 is returned.
34680function utf8CheckByte(byte) {
34681 if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
34682 return byte >> 6 === 0x02 ? -1 : -2;
34683}
34684
34685// Checks at most 3 bytes at the end of a Buffer in order to detect an
34686// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
34687// needed to complete the UTF-8 character (if applicable) are returned.
34688function utf8CheckIncomplete(self, buf, i) {
34689 var j = buf.length - 1;
34690 if (j < i) return 0;
34691 var nb = utf8CheckByte(buf[j]);
34692 if (nb >= 0) {
34693 if (nb > 0) self.lastNeed = nb - 1;
34694 return nb;
34695 }
34696 if (--j < i || nb === -2) return 0;
34697 nb = utf8CheckByte(buf[j]);
34698 if (nb >= 0) {
34699 if (nb > 0) self.lastNeed = nb - 2;
34700 return nb;
34701 }
34702 if (--j < i || nb === -2) return 0;
34703 nb = utf8CheckByte(buf[j]);
34704 if (nb >= 0) {
34705 if (nb > 0) {
34706 if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
34707 }
34708 return nb;
34709 }
34710 return 0;
34711}
34712
34713// Validates as many continuation bytes for a multi-byte UTF-8 character as
34714// needed or are available. If we see a non-continuation byte where we expect
34715// one, we "replace" the validated continuation bytes we've seen so far with
34716// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
34717// behavior. The continuation byte check is included three times in the case
34718// where all of the continuation bytes for a character exist in the same buffer.
34719// It is also done this way as a slight performance increase instead of using a
34720// loop.
34721function utf8CheckExtraBytes(self, buf, p) {
34722 if ((buf[0] & 0xC0) !== 0x80) {
34723 self.lastNeed = 0;
34724 return '\ufffd';
34725 }
34726 if (self.lastNeed > 1 && buf.length > 1) {
34727 if ((buf[1] & 0xC0) !== 0x80) {
34728 self.lastNeed = 1;
34729 return '\ufffd';
34730 }
34731 if (self.lastNeed > 2 && buf.length > 2) {
34732 if ((buf[2] & 0xC0) !== 0x80) {
34733 self.lastNeed = 2;
34734 return '\ufffd';
34735 }
34736 }
34737 }
34738}
34739
34740// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
34741function utf8FillLast(buf) {
34742 var p = this.lastTotal - this.lastNeed;
34743 var r = utf8CheckExtraBytes(this, buf, p);
34744 if (r !== undefined) return r;
34745 if (this.lastNeed <= buf.length) {
34746 buf.copy(this.lastChar, p, 0, this.lastNeed);
34747 return this.lastChar.toString(this.encoding, 0, this.lastTotal);
34748 }
34749 buf.copy(this.lastChar, p, 0, buf.length);
34750 this.lastNeed -= buf.length;
34751}
34752
34753// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
34754// partial character, the character's bytes are buffered until the required
34755// number of bytes are available.
34756function utf8Text(buf, i) {
34757 var total = utf8CheckIncomplete(this, buf, i);
34758 if (!this.lastNeed) return buf.toString('utf8', i);
34759 this.lastTotal = total;
34760 var end = buf.length - (total - this.lastNeed);
34761 buf.copy(this.lastChar, 0, end);
34762 return buf.toString('utf8', i, end);
34763}
34764
34765// For UTF-8, a replacement character is added when ending on a partial
34766// character.
34767function utf8End(buf) {
34768 var r = buf && buf.length ? this.write(buf) : '';
34769 if (this.lastNeed) return r + '\ufffd';
34770 return r;
34771}
34772
34773// UTF-16LE typically needs two bytes per character, but even if we have an even
34774// number of bytes available, we need to check if we end on a leading/high
34775// surrogate. In that case, we need to wait for the next two bytes in order to
34776// decode the last character properly.
34777function utf16Text(buf, i) {
34778 if ((buf.length - i) % 2 === 0) {
34779 var r = buf.toString('utf16le', i);
34780 if (r) {
34781 var c = r.charCodeAt(r.length - 1);
34782 if (c >= 0xD800 && c <= 0xDBFF) {
34783 this.lastNeed = 2;
34784 this.lastTotal = 4;
34785 this.lastChar[0] = buf[buf.length - 2];
34786 this.lastChar[1] = buf[buf.length - 1];
34787 return r.slice(0, -1);
34788 }
34789 }
34790 return r;
34791 }
34792 this.lastNeed = 1;
34793 this.lastTotal = 2;
34794 this.lastChar[0] = buf[buf.length - 1];
34795 return buf.toString('utf16le', i, buf.length - 1);
34796}
34797
34798// For UTF-16LE we do not explicitly append special replacement characters if we
34799// end on a partial character, we simply let v8 handle that.
34800function utf16End(buf) {
34801 var r = buf && buf.length ? this.write(buf) : '';
34802 if (this.lastNeed) {
34803 var end = this.lastTotal - this.lastNeed;
34804 return r + this.lastChar.toString('utf16le', 0, end);
34805 }
34806 return r;
34807}
34808
34809function base64Text(buf, i) {
34810 var n = (buf.length - i) % 3;
34811 if (n === 0) return buf.toString('base64', i);
34812 this.lastNeed = 3 - n;
34813 this.lastTotal = 3;
34814 if (n === 1) {
34815 this.lastChar[0] = buf[buf.length - 1];
34816 } else {
34817 this.lastChar[0] = buf[buf.length - 2];
34818 this.lastChar[1] = buf[buf.length - 1];
34819 }
34820 return buf.toString('base64', i, buf.length - n);
34821}
34822
34823function base64End(buf) {
34824 var r = buf && buf.length ? this.write(buf) : '';
34825 if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
34826 return r;
34827}
34828
34829// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
34830function simpleWrite(buf) {
34831 return buf.toString(this.encoding);
34832}
34833
34834function simpleEnd(buf) {
34835 return buf && buf.length ? this.write(buf) : '';
34836}
34837},{"safe-buffer":398}],393:[function(require,module,exports){
34838module.exports = require('./readable').PassThrough
34839
34840},{"./readable":394}],394:[function(require,module,exports){
34841exports = module.exports = require('./lib/_stream_readable.js');
34842exports.Stream = exports;
34843exports.Readable = exports;
34844exports.Writable = require('./lib/_stream_writable.js');
34845exports.Duplex = require('./lib/_stream_duplex.js');
34846exports.Transform = require('./lib/_stream_transform.js');
34847exports.PassThrough = require('./lib/_stream_passthrough.js');
34848
34849},{"./lib/_stream_duplex.js":384,"./lib/_stream_passthrough.js":385,"./lib/_stream_readable.js":386,"./lib/_stream_transform.js":387,"./lib/_stream_writable.js":388}],395:[function(require,module,exports){
34850module.exports = require('./readable').Transform
34851
34852},{"./readable":394}],396:[function(require,module,exports){
34853module.exports = require('./lib/_stream_writable.js');
34854
34855},{"./lib/_stream_writable.js":388}],397:[function(require,module,exports){
34856'use strict'
34857var Buffer = require('buffer').Buffer
34858var inherits = require('inherits')
34859var HashBase = require('hash-base')
34860
34861var ARRAY16 = new Array(16)
34862
34863var zl = [
34864 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
34865 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
34866 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
34867 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
34868 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
34869]
34870
34871var zr = [
34872 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
34873 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
34874 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
34875 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
34876 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
34877]
34878
34879var sl = [
34880 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
34881 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
34882 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
34883 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
34884 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
34885]
34886
34887var sr = [
34888 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
34889 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
34890 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
34891 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
34892 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
34893]
34894
34895var hl = [0x00000000, 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xa953fd4e]
34896var hr = [0x50a28be6, 0x5c4dd124, 0x6d703ef3, 0x7a6d76e9, 0x00000000]
34897
34898function RIPEMD160 () {
34899 HashBase.call(this, 64)
34900
34901 // state
34902 this._a = 0x67452301
34903 this._b = 0xefcdab89
34904 this._c = 0x98badcfe
34905 this._d = 0x10325476
34906 this._e = 0xc3d2e1f0
34907}
34908
34909inherits(RIPEMD160, HashBase)
34910
34911RIPEMD160.prototype._update = function () {
34912 var words = ARRAY16
34913 for (var j = 0; j < 16; ++j) words[j] = this._block.readInt32LE(j * 4)
34914
34915 var al = this._a | 0
34916 var bl = this._b | 0
34917 var cl = this._c | 0
34918 var dl = this._d | 0
34919 var el = this._e | 0
34920
34921 var ar = this._a | 0
34922 var br = this._b | 0
34923 var cr = this._c | 0
34924 var dr = this._d | 0
34925 var er = this._e | 0
34926
34927 // computation
34928 for (var i = 0; i < 80; i += 1) {
34929 var tl
34930 var tr
34931 if (i < 16) {
34932 tl = fn1(al, bl, cl, dl, el, words[zl[i]], hl[0], sl[i])
34933 tr = fn5(ar, br, cr, dr, er, words[zr[i]], hr[0], sr[i])
34934 } else if (i < 32) {
34935 tl = fn2(al, bl, cl, dl, el, words[zl[i]], hl[1], sl[i])
34936 tr = fn4(ar, br, cr, dr, er, words[zr[i]], hr[1], sr[i])
34937 } else if (i < 48) {
34938 tl = fn3(al, bl, cl, dl, el, words[zl[i]], hl[2], sl[i])
34939 tr = fn3(ar, br, cr, dr, er, words[zr[i]], hr[2], sr[i])
34940 } else if (i < 64) {
34941 tl = fn4(al, bl, cl, dl, el, words[zl[i]], hl[3], sl[i])
34942 tr = fn2(ar, br, cr, dr, er, words[zr[i]], hr[3], sr[i])
34943 } else { // if (i<80) {
34944 tl = fn5(al, bl, cl, dl, el, words[zl[i]], hl[4], sl[i])
34945 tr = fn1(ar, br, cr, dr, er, words[zr[i]], hr[4], sr[i])
34946 }
34947
34948 al = el
34949 el = dl
34950 dl = rotl(cl, 10)
34951 cl = bl
34952 bl = tl
34953
34954 ar = er
34955 er = dr
34956 dr = rotl(cr, 10)
34957 cr = br
34958 br = tr
34959 }
34960
34961 // update state
34962 var t = (this._b + cl + dr) | 0
34963 this._b = (this._c + dl + er) | 0
34964 this._c = (this._d + el + ar) | 0
34965 this._d = (this._e + al + br) | 0
34966 this._e = (this._a + bl + cr) | 0
34967 this._a = t
34968}
34969
34970RIPEMD160.prototype._digest = function () {
34971 // create padding and handle blocks
34972 this._block[this._blockOffset++] = 0x80
34973 if (this._blockOffset > 56) {
34974 this._block.fill(0, this._blockOffset, 64)
34975 this._update()
34976 this._blockOffset = 0
34977 }
34978
34979 this._block.fill(0, this._blockOffset, 56)
34980 this._block.writeUInt32LE(this._length[0], 56)
34981 this._block.writeUInt32LE(this._length[1], 60)
34982 this._update()
34983
34984 // produce result
34985 var buffer = Buffer.alloc ? Buffer.alloc(20) : new Buffer(20)
34986 buffer.writeInt32LE(this._a, 0)
34987 buffer.writeInt32LE(this._b, 4)
34988 buffer.writeInt32LE(this._c, 8)
34989 buffer.writeInt32LE(this._d, 12)
34990 buffer.writeInt32LE(this._e, 16)
34991 return buffer
34992}
34993
34994function rotl (x, n) {
34995 return (x << n) | (x >>> (32 - n))
34996}
34997
34998function fn1 (a, b, c, d, e, m, k, s) {
34999 return (rotl((a + (b ^ c ^ d) + m + k) | 0, s) + e) | 0
35000}
35001
35002function fn2 (a, b, c, d, e, m, k, s) {
35003 return (rotl((a + ((b & c) | ((~b) & d)) + m + k) | 0, s) + e) | 0
35004}
35005
35006function fn3 (a, b, c, d, e, m, k, s) {
35007 return (rotl((a + ((b | (~c)) ^ d) + m + k) | 0, s) + e) | 0
35008}
35009
35010function fn4 (a, b, c, d, e, m, k, s) {
35011 return (rotl((a + ((b & d) | (c & (~d))) + m + k) | 0, s) + e) | 0
35012}
35013
35014function fn5 (a, b, c, d, e, m, k, s) {
35015 return (rotl((a + (b ^ (c | (~d))) + m + k) | 0, s) + e) | 0
35016}
35017
35018module.exports = RIPEMD160
35019
35020},{"buffer":50,"hash-base":104,"inherits":119}],398:[function(require,module,exports){
35021/* eslint-disable node/no-deprecated-api */
35022var buffer = require('buffer')
35023var Buffer = buffer.Buffer
35024
35025// alternative to using Object.keys for old browsers
35026function copyProps (src, dst) {
35027 for (var key in src) {
35028 dst[key] = src[key]
35029 }
35030}
35031if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
35032 module.exports = buffer
35033} else {
35034 // Copy properties from require('buffer')
35035 copyProps(buffer, exports)
35036 exports.Buffer = SafeBuffer
35037}
35038
35039function SafeBuffer (arg, encodingOrOffset, length) {
35040 return Buffer(arg, encodingOrOffset, length)
35041}
35042
35043// Copy static methods from Buffer
35044copyProps(Buffer, SafeBuffer)
35045
35046SafeBuffer.from = function (arg, encodingOrOffset, length) {
35047 if (typeof arg === 'number') {
35048 throw new TypeError('Argument must not be a number')
35049 }
35050 return Buffer(arg, encodingOrOffset, length)
35051}
35052
35053SafeBuffer.alloc = function (size, fill, encoding) {
35054 if (typeof size !== 'number') {
35055 throw new TypeError('Argument must be a number')
35056 }
35057 var buf = Buffer(size)
35058 if (fill !== undefined) {
35059 if (typeof encoding === 'string') {
35060 buf.fill(fill, encoding)
35061 } else {
35062 buf.fill(fill)
35063 }
35064 } else {
35065 buf.fill(0)
35066 }
35067 return buf
35068}
35069
35070SafeBuffer.allocUnsafe = function (size) {
35071 if (typeof size !== 'number') {
35072 throw new TypeError('Argument must be a number')
35073 }
35074 return Buffer(size)
35075}
35076
35077SafeBuffer.allocUnsafeSlow = function (size) {
35078 if (typeof size !== 'number') {
35079 throw new TypeError('Argument must be a number')
35080 }
35081 return buffer.SlowBuffer(size)
35082}
35083
35084},{"buffer":50}],399:[function(require,module,exports){
35085var Buffer = require('safe-buffer').Buffer
35086
35087// prototype class for hash functions
35088function Hash (blockSize, finalSize) {
35089 this._block = Buffer.alloc(blockSize)
35090 this._finalSize = finalSize
35091 this._blockSize = blockSize
35092 this._len = 0
35093}
35094
35095Hash.prototype.update = function (data, enc) {
35096 if (typeof data === 'string') {
35097 enc = enc || 'utf8'
35098 data = Buffer.from(data, enc)
35099 }
35100
35101 var block = this._block
35102 var blockSize = this._blockSize
35103 var length = data.length
35104 var accum = this._len
35105
35106 for (var offset = 0; offset < length;) {
35107 var assigned = accum % blockSize
35108 var remainder = Math.min(length - offset, blockSize - assigned)
35109
35110 for (var i = 0; i < remainder; i++) {
35111 block[assigned + i] = data[offset + i]
35112 }
35113
35114 accum += remainder
35115 offset += remainder
35116
35117 if ((accum % blockSize) === 0) {
35118 this._update(block)
35119 }
35120 }
35121
35122 this._len += length
35123 return this
35124}
35125
35126Hash.prototype.digest = function (enc) {
35127 var rem = this._len % this._blockSize
35128
35129 this._block[rem] = 0x80
35130
35131 // zero (rem + 1) trailing bits, where (rem + 1) is the smallest
35132 // non-negative solution to the equation (length + 1 + (rem + 1)) === finalSize mod blockSize
35133 this._block.fill(0, rem + 1)
35134
35135 if (rem >= this._finalSize) {
35136 this._update(this._block)
35137 this._block.fill(0)
35138 }
35139
35140 var bits = this._len * 8
35141
35142 // uint32
35143 if (bits <= 0xffffffff) {
35144 this._block.writeUInt32BE(bits, this._blockSize - 4)
35145
35146 // uint64
35147 } else {
35148 var lowBits = (bits & 0xffffffff) >>> 0
35149 var highBits = (bits - lowBits) / 0x100000000
35150
35151 this._block.writeUInt32BE(highBits, this._blockSize - 8)
35152 this._block.writeUInt32BE(lowBits, this._blockSize - 4)
35153 }
35154
35155 this._update(this._block)
35156 var hash = this._hash()
35157
35158 return enc ? hash.toString(enc) : hash
35159}
35160
35161Hash.prototype._update = function () {
35162 throw new Error('_update must be implemented by subclass')
35163}
35164
35165module.exports = Hash
35166
35167},{"safe-buffer":398}],400:[function(require,module,exports){
35168var exports = module.exports = function SHA (algorithm) {
35169 algorithm = algorithm.toLowerCase()
35170
35171 var Algorithm = exports[algorithm]
35172 if (!Algorithm) throw new Error(algorithm + ' is not supported (we accept pull requests)')
35173
35174 return new Algorithm()
35175}
35176
35177exports.sha = require('./sha')
35178exports.sha1 = require('./sha1')
35179exports.sha224 = require('./sha224')
35180exports.sha256 = require('./sha256')
35181exports.sha384 = require('./sha384')
35182exports.sha512 = require('./sha512')
35183
35184},{"./sha":401,"./sha1":402,"./sha224":403,"./sha256":404,"./sha384":405,"./sha512":406}],401:[function(require,module,exports){
35185/*
35186 * A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined
35187 * in FIPS PUB 180-1
35188 * This source code is derived from sha1.js of the same repository.
35189 * The difference between SHA-0 and SHA-1 is just a bitwise rotate left
35190 * operation was added.
35191 */
35192
35193var inherits = require('inherits')
35194var Hash = require('./hash')
35195var Buffer = require('safe-buffer').Buffer
35196
35197var K = [
35198 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
35199]
35200
35201var W = new Array(80)
35202
35203function Sha () {
35204 this.init()
35205 this._w = W
35206
35207 Hash.call(this, 64, 56)
35208}
35209
35210inherits(Sha, Hash)
35211
35212Sha.prototype.init = function () {
35213 this._a = 0x67452301
35214 this._b = 0xefcdab89
35215 this._c = 0x98badcfe
35216 this._d = 0x10325476
35217 this._e = 0xc3d2e1f0
35218
35219 return this
35220}
35221
35222function rotl5 (num) {
35223 return (num << 5) | (num >>> 27)
35224}
35225
35226function rotl30 (num) {
35227 return (num << 30) | (num >>> 2)
35228}
35229
35230function ft (s, b, c, d) {
35231 if (s === 0) return (b & c) | ((~b) & d)
35232 if (s === 2) return (b & c) | (b & d) | (c & d)
35233 return b ^ c ^ d
35234}
35235
35236Sha.prototype._update = function (M) {
35237 var W = this._w
35238
35239 var a = this._a | 0
35240 var b = this._b | 0
35241 var c = this._c | 0
35242 var d = this._d | 0
35243 var e = this._e | 0
35244
35245 for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
35246 for (; i < 80; ++i) W[i] = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]
35247
35248 for (var j = 0; j < 80; ++j) {
35249 var s = ~~(j / 20)
35250 var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0
35251
35252 e = d
35253 d = c
35254 c = rotl30(b)
35255 b = a
35256 a = t
35257 }
35258
35259 this._a = (a + this._a) | 0
35260 this._b = (b + this._b) | 0
35261 this._c = (c + this._c) | 0
35262 this._d = (d + this._d) | 0
35263 this._e = (e + this._e) | 0
35264}
35265
35266Sha.prototype._hash = function () {
35267 var H = Buffer.allocUnsafe(20)
35268
35269 H.writeInt32BE(this._a | 0, 0)
35270 H.writeInt32BE(this._b | 0, 4)
35271 H.writeInt32BE(this._c | 0, 8)
35272 H.writeInt32BE(this._d | 0, 12)
35273 H.writeInt32BE(this._e | 0, 16)
35274
35275 return H
35276}
35277
35278module.exports = Sha
35279
35280},{"./hash":399,"inherits":119,"safe-buffer":398}],402:[function(require,module,exports){
35281/*
35282 * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
35283 * in FIPS PUB 180-1
35284 * Version 2.1a Copyright Paul Johnston 2000 - 2002.
35285 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
35286 * Distributed under the BSD License
35287 * See http://pajhome.org.uk/crypt/md5 for details.
35288 */
35289
35290var inherits = require('inherits')
35291var Hash = require('./hash')
35292var Buffer = require('safe-buffer').Buffer
35293
35294var K = [
35295 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
35296]
35297
35298var W = new Array(80)
35299
35300function Sha1 () {
35301 this.init()
35302 this._w = W
35303
35304 Hash.call(this, 64, 56)
35305}
35306
35307inherits(Sha1, Hash)
35308
35309Sha1.prototype.init = function () {
35310 this._a = 0x67452301
35311 this._b = 0xefcdab89
35312 this._c = 0x98badcfe
35313 this._d = 0x10325476
35314 this._e = 0xc3d2e1f0
35315
35316 return this
35317}
35318
35319function rotl1 (num) {
35320 return (num << 1) | (num >>> 31)
35321}
35322
35323function rotl5 (num) {
35324 return (num << 5) | (num >>> 27)
35325}
35326
35327function rotl30 (num) {
35328 return (num << 30) | (num >>> 2)
35329}
35330
35331function ft (s, b, c, d) {
35332 if (s === 0) return (b & c) | ((~b) & d)
35333 if (s === 2) return (b & c) | (b & d) | (c & d)
35334 return b ^ c ^ d
35335}
35336
35337Sha1.prototype._update = function (M) {
35338 var W = this._w
35339
35340 var a = this._a | 0
35341 var b = this._b | 0
35342 var c = this._c | 0
35343 var d = this._d | 0
35344 var e = this._e | 0
35345
35346 for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
35347 for (; i < 80; ++i) W[i] = rotl1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16])
35348
35349 for (var j = 0; j < 80; ++j) {
35350 var s = ~~(j / 20)
35351 var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0
35352
35353 e = d
35354 d = c
35355 c = rotl30(b)
35356 b = a
35357 a = t
35358 }
35359
35360 this._a = (a + this._a) | 0
35361 this._b = (b + this._b) | 0
35362 this._c = (c + this._c) | 0
35363 this._d = (d + this._d) | 0
35364 this._e = (e + this._e) | 0
35365}
35366
35367Sha1.prototype._hash = function () {
35368 var H = Buffer.allocUnsafe(20)
35369
35370 H.writeInt32BE(this._a | 0, 0)
35371 H.writeInt32BE(this._b | 0, 4)
35372 H.writeInt32BE(this._c | 0, 8)
35373 H.writeInt32BE(this._d | 0, 12)
35374 H.writeInt32BE(this._e | 0, 16)
35375
35376 return H
35377}
35378
35379module.exports = Sha1
35380
35381},{"./hash":399,"inherits":119,"safe-buffer":398}],403:[function(require,module,exports){
35382/**
35383 * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
35384 * in FIPS 180-2
35385 * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
35386 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
35387 *
35388 */
35389
35390var inherits = require('inherits')
35391var Sha256 = require('./sha256')
35392var Hash = require('./hash')
35393var Buffer = require('safe-buffer').Buffer
35394
35395var W = new Array(64)
35396
35397function Sha224 () {
35398 this.init()
35399
35400 this._w = W // new Array(64)
35401
35402 Hash.call(this, 64, 56)
35403}
35404
35405inherits(Sha224, Sha256)
35406
35407Sha224.prototype.init = function () {
35408 this._a = 0xc1059ed8
35409 this._b = 0x367cd507
35410 this._c = 0x3070dd17
35411 this._d = 0xf70e5939
35412 this._e = 0xffc00b31
35413 this._f = 0x68581511
35414 this._g = 0x64f98fa7
35415 this._h = 0xbefa4fa4
35416
35417 return this
35418}
35419
35420Sha224.prototype._hash = function () {
35421 var H = Buffer.allocUnsafe(28)
35422
35423 H.writeInt32BE(this._a, 0)
35424 H.writeInt32BE(this._b, 4)
35425 H.writeInt32BE(this._c, 8)
35426 H.writeInt32BE(this._d, 12)
35427 H.writeInt32BE(this._e, 16)
35428 H.writeInt32BE(this._f, 20)
35429 H.writeInt32BE(this._g, 24)
35430
35431 return H
35432}
35433
35434module.exports = Sha224
35435
35436},{"./hash":399,"./sha256":404,"inherits":119,"safe-buffer":398}],404:[function(require,module,exports){
35437/**
35438 * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
35439 * in FIPS 180-2
35440 * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
35441 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
35442 *
35443 */
35444
35445var inherits = require('inherits')
35446var Hash = require('./hash')
35447var Buffer = require('safe-buffer').Buffer
35448
35449var K = [
35450 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,
35451 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,
35452 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,
35453 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174,
35454 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC,
35455 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,
35456 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7,
35457 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967,
35458 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,
35459 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85,
35460 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3,
35461 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,
35462 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5,
35463 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3,
35464 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,
35465 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2
35466]
35467
35468var W = new Array(64)
35469
35470function Sha256 () {
35471 this.init()
35472
35473 this._w = W // new Array(64)
35474
35475 Hash.call(this, 64, 56)
35476}
35477
35478inherits(Sha256, Hash)
35479
35480Sha256.prototype.init = function () {
35481 this._a = 0x6a09e667
35482 this._b = 0xbb67ae85
35483 this._c = 0x3c6ef372
35484 this._d = 0xa54ff53a
35485 this._e = 0x510e527f
35486 this._f = 0x9b05688c
35487 this._g = 0x1f83d9ab
35488 this._h = 0x5be0cd19
35489
35490 return this
35491}
35492
35493function ch (x, y, z) {
35494 return z ^ (x & (y ^ z))
35495}
35496
35497function maj (x, y, z) {
35498 return (x & y) | (z & (x | y))
35499}
35500
35501function sigma0 (x) {
35502 return (x >>> 2 | x << 30) ^ (x >>> 13 | x << 19) ^ (x >>> 22 | x << 10)
35503}
35504
35505function sigma1 (x) {
35506 return (x >>> 6 | x << 26) ^ (x >>> 11 | x << 21) ^ (x >>> 25 | x << 7)
35507}
35508
35509function gamma0 (x) {
35510 return (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ (x >>> 3)
35511}
35512
35513function gamma1 (x) {
35514 return (x >>> 17 | x << 15) ^ (x >>> 19 | x << 13) ^ (x >>> 10)
35515}
35516
35517Sha256.prototype._update = function (M) {
35518 var W = this._w
35519
35520 var a = this._a | 0
35521 var b = this._b | 0
35522 var c = this._c | 0
35523 var d = this._d | 0
35524 var e = this._e | 0
35525 var f = this._f | 0
35526 var g = this._g | 0
35527 var h = this._h | 0
35528
35529 for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
35530 for (; i < 64; ++i) W[i] = (gamma1(W[i - 2]) + W[i - 7] + gamma0(W[i - 15]) + W[i - 16]) | 0
35531
35532 for (var j = 0; j < 64; ++j) {
35533 var T1 = (h + sigma1(e) + ch(e, f, g) + K[j] + W[j]) | 0
35534 var T2 = (sigma0(a) + maj(a, b, c)) | 0
35535
35536 h = g
35537 g = f
35538 f = e
35539 e = (d + T1) | 0
35540 d = c
35541 c = b
35542 b = a
35543 a = (T1 + T2) | 0
35544 }
35545
35546 this._a = (a + this._a) | 0
35547 this._b = (b + this._b) | 0
35548 this._c = (c + this._c) | 0
35549 this._d = (d + this._d) | 0
35550 this._e = (e + this._e) | 0
35551 this._f = (f + this._f) | 0
35552 this._g = (g + this._g) | 0
35553 this._h = (h + this._h) | 0
35554}
35555
35556Sha256.prototype._hash = function () {
35557 var H = Buffer.allocUnsafe(32)
35558
35559 H.writeInt32BE(this._a, 0)
35560 H.writeInt32BE(this._b, 4)
35561 H.writeInt32BE(this._c, 8)
35562 H.writeInt32BE(this._d, 12)
35563 H.writeInt32BE(this._e, 16)
35564 H.writeInt32BE(this._f, 20)
35565 H.writeInt32BE(this._g, 24)
35566 H.writeInt32BE(this._h, 28)
35567
35568 return H
35569}
35570
35571module.exports = Sha256
35572
35573},{"./hash":399,"inherits":119,"safe-buffer":398}],405:[function(require,module,exports){
35574var inherits = require('inherits')
35575var SHA512 = require('./sha512')
35576var Hash = require('./hash')
35577var Buffer = require('safe-buffer').Buffer
35578
35579var W = new Array(160)
35580
35581function Sha384 () {
35582 this.init()
35583 this._w = W
35584
35585 Hash.call(this, 128, 112)
35586}
35587
35588inherits(Sha384, SHA512)
35589
35590Sha384.prototype.init = function () {
35591 this._ah = 0xcbbb9d5d
35592 this._bh = 0x629a292a
35593 this._ch = 0x9159015a
35594 this._dh = 0x152fecd8
35595 this._eh = 0x67332667
35596 this._fh = 0x8eb44a87
35597 this._gh = 0xdb0c2e0d
35598 this._hh = 0x47b5481d
35599
35600 this._al = 0xc1059ed8
35601 this._bl = 0x367cd507
35602 this._cl = 0x3070dd17
35603 this._dl = 0xf70e5939
35604 this._el = 0xffc00b31
35605 this._fl = 0x68581511
35606 this._gl = 0x64f98fa7
35607 this._hl = 0xbefa4fa4
35608
35609 return this
35610}
35611
35612Sha384.prototype._hash = function () {
35613 var H = Buffer.allocUnsafe(48)
35614
35615 function writeInt64BE (h, l, offset) {
35616 H.writeInt32BE(h, offset)
35617 H.writeInt32BE(l, offset + 4)
35618 }
35619
35620 writeInt64BE(this._ah, this._al, 0)
35621 writeInt64BE(this._bh, this._bl, 8)
35622 writeInt64BE(this._ch, this._cl, 16)
35623 writeInt64BE(this._dh, this._dl, 24)
35624 writeInt64BE(this._eh, this._el, 32)
35625 writeInt64BE(this._fh, this._fl, 40)
35626
35627 return H
35628}
35629
35630module.exports = Sha384
35631
35632},{"./hash":399,"./sha512":406,"inherits":119,"safe-buffer":398}],406:[function(require,module,exports){
35633var inherits = require('inherits')
35634var Hash = require('./hash')
35635var Buffer = require('safe-buffer').Buffer
35636
35637var K = [
35638 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
35639 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
35640 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
35641 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
35642 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
35643 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
35644 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
35645 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
35646 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
35647 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
35648 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
35649 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
35650 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
35651 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
35652 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
35653 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
35654 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
35655 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
35656 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
35657 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
35658 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
35659 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
35660 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
35661 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
35662 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
35663 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
35664 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
35665 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
35666 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
35667 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
35668 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
35669 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
35670 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
35671 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
35672 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
35673 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
35674 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
35675 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
35676 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
35677 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
35678]
35679
35680var W = new Array(160)
35681
35682function Sha512 () {
35683 this.init()
35684 this._w = W
35685
35686 Hash.call(this, 128, 112)
35687}
35688
35689inherits(Sha512, Hash)
35690
35691Sha512.prototype.init = function () {
35692 this._ah = 0x6a09e667
35693 this._bh = 0xbb67ae85
35694 this._ch = 0x3c6ef372
35695 this._dh = 0xa54ff53a
35696 this._eh = 0x510e527f
35697 this._fh = 0x9b05688c
35698 this._gh = 0x1f83d9ab
35699 this._hh = 0x5be0cd19
35700
35701 this._al = 0xf3bcc908
35702 this._bl = 0x84caa73b
35703 this._cl = 0xfe94f82b
35704 this._dl = 0x5f1d36f1
35705 this._el = 0xade682d1
35706 this._fl = 0x2b3e6c1f
35707 this._gl = 0xfb41bd6b
35708 this._hl = 0x137e2179
35709
35710 return this
35711}
35712
35713function Ch (x, y, z) {
35714 return z ^ (x & (y ^ z))
35715}
35716
35717function maj (x, y, z) {
35718 return (x & y) | (z & (x | y))
35719}
35720
35721function sigma0 (x, xl) {
35722 return (x >>> 28 | xl << 4) ^ (xl >>> 2 | x << 30) ^ (xl >>> 7 | x << 25)
35723}
35724
35725function sigma1 (x, xl) {
35726 return (x >>> 14 | xl << 18) ^ (x >>> 18 | xl << 14) ^ (xl >>> 9 | x << 23)
35727}
35728
35729function Gamma0 (x, xl) {
35730 return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7)
35731}
35732
35733function Gamma0l (x, xl) {
35734 return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7 | xl << 25)
35735}
35736
35737function Gamma1 (x, xl) {
35738 return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6)
35739}
35740
35741function Gamma1l (x, xl) {
35742 return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6 | xl << 26)
35743}
35744
35745function getCarry (a, b) {
35746 return (a >>> 0) < (b >>> 0) ? 1 : 0
35747}
35748
35749Sha512.prototype._update = function (M) {
35750 var W = this._w
35751
35752 var ah = this._ah | 0
35753 var bh = this._bh | 0
35754 var ch = this._ch | 0
35755 var dh = this._dh | 0
35756 var eh = this._eh | 0
35757 var fh = this._fh | 0
35758 var gh = this._gh | 0
35759 var hh = this._hh | 0
35760
35761 var al = this._al | 0
35762 var bl = this._bl | 0
35763 var cl = this._cl | 0
35764 var dl = this._dl | 0
35765 var el = this._el | 0
35766 var fl = this._fl | 0
35767 var gl = this._gl | 0
35768 var hl = this._hl | 0
35769
35770 for (var i = 0; i < 32; i += 2) {
35771 W[i] = M.readInt32BE(i * 4)
35772 W[i + 1] = M.readInt32BE(i * 4 + 4)
35773 }
35774 for (; i < 160; i += 2) {
35775 var xh = W[i - 15 * 2]
35776 var xl = W[i - 15 * 2 + 1]
35777 var gamma0 = Gamma0(xh, xl)
35778 var gamma0l = Gamma0l(xl, xh)
35779
35780 xh = W[i - 2 * 2]
35781 xl = W[i - 2 * 2 + 1]
35782 var gamma1 = Gamma1(xh, xl)
35783 var gamma1l = Gamma1l(xl, xh)
35784
35785 // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
35786 var Wi7h = W[i - 7 * 2]
35787 var Wi7l = W[i - 7 * 2 + 1]
35788
35789 var Wi16h = W[i - 16 * 2]
35790 var Wi16l = W[i - 16 * 2 + 1]
35791
35792 var Wil = (gamma0l + Wi7l) | 0
35793 var Wih = (gamma0 + Wi7h + getCarry(Wil, gamma0l)) | 0
35794 Wil = (Wil + gamma1l) | 0
35795 Wih = (Wih + gamma1 + getCarry(Wil, gamma1l)) | 0
35796 Wil = (Wil + Wi16l) | 0
35797 Wih = (Wih + Wi16h + getCarry(Wil, Wi16l)) | 0
35798
35799 W[i] = Wih
35800 W[i + 1] = Wil
35801 }
35802
35803 for (var j = 0; j < 160; j += 2) {
35804 Wih = W[j]
35805 Wil = W[j + 1]
35806
35807 var majh = maj(ah, bh, ch)
35808 var majl = maj(al, bl, cl)
35809
35810 var sigma0h = sigma0(ah, al)
35811 var sigma0l = sigma0(al, ah)
35812 var sigma1h = sigma1(eh, el)
35813 var sigma1l = sigma1(el, eh)
35814
35815 // t1 = h + sigma1 + ch + K[j] + W[j]
35816 var Kih = K[j]
35817 var Kil = K[j + 1]
35818
35819 var chh = Ch(eh, fh, gh)
35820 var chl = Ch(el, fl, gl)
35821
35822 var t1l = (hl + sigma1l) | 0
35823 var t1h = (hh + sigma1h + getCarry(t1l, hl)) | 0
35824 t1l = (t1l + chl) | 0
35825 t1h = (t1h + chh + getCarry(t1l, chl)) | 0
35826 t1l = (t1l + Kil) | 0
35827 t1h = (t1h + Kih + getCarry(t1l, Kil)) | 0
35828 t1l = (t1l + Wil) | 0
35829 t1h = (t1h + Wih + getCarry(t1l, Wil)) | 0
35830
35831 // t2 = sigma0 + maj
35832 var t2l = (sigma0l + majl) | 0
35833 var t2h = (sigma0h + majh + getCarry(t2l, sigma0l)) | 0
35834
35835 hh = gh
35836 hl = gl
35837 gh = fh
35838 gl = fl
35839 fh = eh
35840 fl = el
35841 el = (dl + t1l) | 0
35842 eh = (dh + t1h + getCarry(el, dl)) | 0
35843 dh = ch
35844 dl = cl
35845 ch = bh
35846 cl = bl
35847 bh = ah
35848 bl = al
35849 al = (t1l + t2l) | 0
35850 ah = (t1h + t2h + getCarry(al, t1l)) | 0
35851 }
35852
35853 this._al = (this._al + al) | 0
35854 this._bl = (this._bl + bl) | 0
35855 this._cl = (this._cl + cl) | 0
35856 this._dl = (this._dl + dl) | 0
35857 this._el = (this._el + el) | 0
35858 this._fl = (this._fl + fl) | 0
35859 this._gl = (this._gl + gl) | 0
35860 this._hl = (this._hl + hl) | 0
35861
35862 this._ah = (this._ah + ah + getCarry(this._al, al)) | 0
35863 this._bh = (this._bh + bh + getCarry(this._bl, bl)) | 0
35864 this._ch = (this._ch + ch + getCarry(this._cl, cl)) | 0
35865 this._dh = (this._dh + dh + getCarry(this._dl, dl)) | 0
35866 this._eh = (this._eh + eh + getCarry(this._el, el)) | 0
35867 this._fh = (this._fh + fh + getCarry(this._fl, fl)) | 0
35868 this._gh = (this._gh + gh + getCarry(this._gl, gl)) | 0
35869 this._hh = (this._hh + hh + getCarry(this._hl, hl)) | 0
35870}
35871
35872Sha512.prototype._hash = function () {
35873 var H = Buffer.allocUnsafe(64)
35874
35875 function writeInt64BE (h, l, offset) {
35876 H.writeInt32BE(h, offset)
35877 H.writeInt32BE(l, offset + 4)
35878 }
35879
35880 writeInt64BE(this._ah, this._al, 0)
35881 writeInt64BE(this._bh, this._bl, 8)
35882 writeInt64BE(this._ch, this._cl, 16)
35883 writeInt64BE(this._dh, this._dl, 24)
35884 writeInt64BE(this._eh, this._el, 32)
35885 writeInt64BE(this._fh, this._fl, 40)
35886 writeInt64BE(this._gh, this._gl, 48)
35887 writeInt64BE(this._hh, this._hl, 56)
35888
35889 return H
35890}
35891
35892module.exports = Sha512
35893
35894},{"./hash":399,"inherits":119,"safe-buffer":398}],407:[function(require,module,exports){
35895"use strict";
35896
35897var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
35898
35899var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
35900
35901var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
35902
35903Object.defineProperty(exports, "__esModule", {
35904 value: true
35905});
35906
35907var BigNumber = _interopRequire(require("bignumber.js"));
35908
35909var isString = _interopRequire(require("lodash/isString"));
35910
35911var Keypair = require("./keypair").Keypair;
35912
35913var StrKey = require("./strkey").StrKey;
35914
35915/**
35916 * Create a new Account object.
35917 *
35918 * `Account` represents a single account in Stellar network and its sequence number.
35919 * Account tracks the sequence number as it is used by {@link TransactionBuilder}.
35920 * See [Accounts](https://stellar.org/developers/learn/concepts/accounts.html) for more information about how
35921 * accounts work in Stellar.
35922 * @constructor
35923 * @param {string} accountId ID of the account (ex. `GB3KJPLFUYN5VL6R3GU3EGCGVCKFDSD7BEDX42HWG5BWFKB3KQGJJRMA`)
35924 * @param {string} sequence current sequence number of the account
35925 */
35926
35927var Account = exports.Account = (function () {
35928 function Account(accountId, sequence) {
35929 _classCallCheck(this, Account);
35930
35931 if (!StrKey.isValidEd25519PublicKey(accountId)) {
35932 throw new Error("accountId is invalid");
35933 }
35934 if (!isString(sequence)) {
35935 throw new Error("sequence must be of type string");
35936 }
35937 this._accountId = accountId;
35938 this.sequence = new BigNumber(sequence);
35939 }
35940
35941 _createClass(Account, {
35942 accountId: {
35943
35944 /**
35945 * Returns Stellar account ID, ex. `GB3KJPLFUYN5VL6R3GU3EGCGVCKFDSD7BEDX42HWG5BWFKB3KQGJJRMA`
35946 * @returns {string}
35947 */
35948
35949 value: function accountId() {
35950 return this._accountId;
35951 }
35952 },
35953 sequenceNumber: {
35954
35955 /**
35956 * @returns {string}
35957 */
35958
35959 value: function sequenceNumber() {
35960 return this.sequence.toString();
35961 }
35962 },
35963 incrementSequenceNumber: {
35964
35965 /**
35966 * Increments sequence number in this object by one.
35967 */
35968
35969 value: function incrementSequenceNumber() {
35970 this.sequence = this.sequence.add(1);
35971 }
35972 }
35973 });
35974
35975 return Account;
35976})();
35977},{"./keypair":413,"./strkey":431,"bignumber.js":17,"lodash/isString":337}],408:[function(require,module,exports){
35978"use strict";
35979
35980var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
35981
35982var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
35983
35984var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
35985
35986Object.defineProperty(exports, "__esModule", {
35987 value: true
35988});
35989
35990var xdr = _interopRequire(require("./generated/stellar-xdr_generated"));
35991
35992var Keypair = require("./keypair").Keypair;
35993
35994var StrKey = require("./strkey").StrKey;
35995
35996var clone = _interopRequire(require("lodash/clone"));
35997
35998var padEnd = _interopRequire(require("lodash/padEnd"));
35999
36000var trimEnd = _interopRequire(require("lodash/trimEnd"));
36001
36002/**
36003 * Asset class represents an asset, either the native asset (`XLM`)
36004 * or an asset code / issuer account ID pair.
36005 *
36006 * An asset code describes an asset code and issuer pair. In the case of the native
36007 * asset XLM, the issuer will be null.
36008 *
36009 * @constructor
36010 * @param {string} code - The asset code.
36011 * @param {string} issuer - The account ID of the issuer.
36012 */
36013
36014var Asset = exports.Asset = (function () {
36015 function Asset(code, issuer) {
36016 _classCallCheck(this, Asset);
36017
36018 if (!/^[a-zA-Z0-9]{1,12}$/.test(code)) {
36019 throw new Error("Asset code is invalid (maximum alphanumeric, 12 characters at max)");
36020 }
36021 if (String(code).toLowerCase() !== "xlm" && !issuer) {
36022 throw new Error("Issuer cannot be null");
36023 }
36024 if (issuer && !StrKey.isValidEd25519PublicKey(issuer)) {
36025 throw new Error("Issuer is invalid");
36026 }
36027
36028 this.code = code;
36029 this.issuer = issuer;
36030 }
36031
36032 _createClass(Asset, {
36033 toXDRObject: {
36034
36035 /**
36036 * Returns the xdr object for this asset.
36037 * @returns {xdr.Asset}
36038 */
36039
36040 value: function toXDRObject() {
36041 if (this.isNative()) {
36042 return xdr.Asset.assetTypeNative();
36043 }
36044
36045 var xdrType = undefined,
36046 xdrTypeString = undefined;
36047 if (this.code.length <= 4) {
36048 xdrType = xdr.AssetAlphaNum4;
36049 xdrTypeString = "assetTypeCreditAlphanum4";
36050 } else {
36051 xdrType = xdr.AssetAlphaNum12;
36052 xdrTypeString = "assetTypeCreditAlphanum12";
36053 }
36054
36055 // pad code with null bytes if necessary
36056 var padLength = this.code.length <= 4 ? 4 : 12;
36057 var paddedCode = padEnd(this.code, padLength, "\u0000");
36058
36059 var assetType = new xdrType({
36060 assetCode: paddedCode,
36061 issuer: Keypair.fromPublicKey(this.issuer).xdrAccountId()
36062 });
36063
36064 return new xdr.Asset(xdrTypeString, assetType);
36065 }
36066 },
36067 getCode: {
36068
36069 /**
36070 * Return the asset code
36071 * @returns {string}
36072 */
36073
36074 value: function getCode() {
36075 return clone(this.code);
36076 }
36077 },
36078 getIssuer: {
36079
36080 /**
36081 * Return the asset issuer
36082 * @returns {string}
36083 */
36084
36085 value: function getIssuer() {
36086 return clone(this.issuer);
36087 }
36088 },
36089 getAssetType: {
36090
36091 /**
36092 * Return the asset type. Can be one of following types:
36093 *
36094 * * `native`
36095 * * `credit_alphanum4`
36096 * * `credit_alphanum12`
36097 *
36098 * @see [Assets concept](https://www.stellar.org/developers/learn/concepts/assets.html)
36099 * @returns {string}
36100 */
36101
36102 value: function getAssetType() {
36103 if (this.isNative()) {
36104 return "native";
36105 }
36106 if (this.code.length >= 1 && this.code.length <= 4) {
36107 return "credit_alphanum4";
36108 }
36109 if (this.code.length >= 5 && this.code.length <= 12) {
36110 return "credit_alphanum12";
36111 }
36112 }
36113 },
36114 isNative: {
36115
36116 /**
36117 * Returns true if this asset object is the native asset.
36118 * @returns {boolean}
36119 */
36120
36121 value: function isNative() {
36122 return !this.issuer;
36123 }
36124 },
36125 equals: {
36126
36127 /**
36128 * Returns true if this asset equals the given asset.
36129 * @param {Asset} asset Asset to compare
36130 * @returns {boolean}
36131 */
36132
36133 value: function equals(asset) {
36134 return this.code == asset.getCode() && this.issuer == asset.getIssuer();
36135 }
36136 }
36137 }, {
36138 native: {
36139
36140 /**
36141 * Returns an asset object for the native asset.
36142 * @Return {Asset}
36143 */
36144
36145 value: function native() {
36146 return new Asset("XLM");
36147 }
36148 },
36149 fromOperation: {
36150
36151 /**
36152 * Returns an asset object from its XDR object representation.
36153 * @param {xdr.Asset} assetXdr - The asset xdr object.
36154 * @returns {Asset}
36155 */
36156
36157 value: function fromOperation(assetXdr) {
36158 var anum = undefined,
36159 code = undefined,
36160 issuer = undefined;
36161 switch (assetXdr["switch"]()) {
36162 case xdr.AssetType.assetTypeNative():
36163 return this.native();
36164 case xdr.AssetType.assetTypeCreditAlphanum4():
36165 anum = assetXdr.alphaNum4();
36166 /* falls through */
36167 case xdr.AssetType.assetTypeCreditAlphanum12():
36168 anum = anum || assetXdr.alphaNum12();
36169 issuer = StrKey.encodeEd25519PublicKey(anum.issuer().ed25519());
36170 code = trimEnd(anum.assetCode(), "\u0000");
36171 return new this(code, issuer);
36172 default:
36173 throw new Error("Invalid asset type: " + assetXdr["switch"]().name);
36174 }
36175 }
36176 }
36177 });
36178
36179 return Asset;
36180})();
36181},{"./generated/stellar-xdr_generated":410,"./keypair":413,"./strkey":431,"lodash/clone":310,"lodash/padEnd":345,"lodash/trimEnd":355}],409:[function(require,module,exports){
36182(function (Buffer){
36183"use strict";
36184
36185var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
36186
36187exports.decodeBase58Check = decodeBase58Check;
36188Object.defineProperty(exports, "__esModule", {
36189 value: true
36190});
36191
36192var bs58 = _interopRequire(require("./vendor/bs58"));
36193
36194var isUndefined = _interopRequire(require("lodash/isUndefined"));
36195
36196var hash = require("./hashing").hash;
36197
36198var verifyChecksum = require("./util/checksum").verifyChecksum;
36199
36200var versionBytes = {
36201 accountId: 0, // decimal 0
36202 none: 1, // decimal 1
36203 seed: 33 };
36204
36205function decodeBase58Check(versionByteName, encoded) {
36206 var decoded = bs58.decode(encoded);
36207 var versionByte = decoded[0];
36208 var payload = decoded.slice(0, decoded.length - 4);
36209 var data = payload.slice(1);
36210 var checksum = decoded.slice(decoded.length - 4);
36211
36212 var expectedVersion = versionBytes[versionByteName];
36213
36214 if (isUndefined(expectedVersion)) {
36215 throw new Error("" + versionByteName + " is not a valid version byte name. expected one of \"accountId\", \"seed\", or \"none\"");
36216 }
36217
36218 if (versionByte !== expectedVersion) {
36219 throw new Error("invalid version byte. expected " + expectedVersion + ", got " + versionByte);
36220 }
36221
36222 var expectedChecksum = calculateChecksum(payload);
36223
36224 if (!verifyChecksum(expectedChecksum, checksum)) {
36225 throw new Error("invalid checksum");
36226 }
36227
36228 if (versionByteName === "accountId" && decoded.length !== 37) {
36229 throw new Error("Decoded address length is invalid. Expected 37, got " + decoded.length);
36230 }
36231
36232 return Buffer.from(data);
36233}
36234
36235function calculateChecksum(payload) {
36236 var inner = hash(payload);
36237 var outer = hash(inner);
36238 return outer.slice(0, 4);
36239}
36240// decimal 33
36241}).call(this,require("buffer").Buffer)
36242},{"./hashing":411,"./util/checksum":434,"./vendor/bs58":436,"buffer":50,"lodash/isUndefined":340}],410:[function(require,module,exports){
36243"use strict";var _interopRequireWildcard=function(obj){return obj && obj.__esModule?obj:{"default":obj};};var XDR=_interopRequireWildcard(require("js-xdr"));var types=XDR.config(function(xdr){xdr.typedef("Value", xdr.varOpaque());xdr.struct("ScpBallot", [["counter", xdr.lookup("Uint32")], ["value", xdr.lookup("Value")]]);xdr["enum"]("ScpStatementType", {scpStPrepare:0, scpStConfirm:1, scpStExternalize:2, scpStNominate:3});xdr.struct("ScpNomination", [["quorumSetHash", xdr.lookup("Hash")], ["votes", xdr.varArray(xdr.lookup("Value"), 2147483647)], ["accepted", xdr.varArray(xdr.lookup("Value"), 2147483647)]]);xdr.struct("ScpStatementPrepare", [["quorumSetHash", xdr.lookup("Hash")], ["ballot", xdr.lookup("ScpBallot")], ["prepared", xdr.option(xdr.lookup("ScpBallot"))], ["preparedPrime", xdr.option(xdr.lookup("ScpBallot"))], ["nC", xdr.lookup("Uint32")], ["nH", xdr.lookup("Uint32")]]);xdr.struct("ScpStatementConfirm", [["ballot", xdr.lookup("ScpBallot")], ["nPrepared", xdr.lookup("Uint32")], ["nCommit", xdr.lookup("Uint32")], ["nH", xdr.lookup("Uint32")], ["quorumSetHash", xdr.lookup("Hash")]]);xdr.struct("ScpStatementExternalize", [["commit", xdr.lookup("ScpBallot")], ["nH", xdr.lookup("Uint32")], ["commitQuorumSetHash", xdr.lookup("Hash")]]);xdr.union("ScpStatementPledges", {switchOn:xdr.lookup("ScpStatementType"), switchName:"type", switches:[["scpStPrepare", "prepare"], ["scpStConfirm", "confirm"], ["scpStExternalize", "externalize"], ["scpStNominate", "nominate"]], arms:{prepare:xdr.lookup("ScpStatementPrepare"), confirm:xdr.lookup("ScpStatementConfirm"), externalize:xdr.lookup("ScpStatementExternalize"), nominate:xdr.lookup("ScpNomination")}});xdr.struct("ScpStatement", [["nodeId", xdr.lookup("NodeId")], ["slotIndex", xdr.lookup("Uint64")], ["pledges", xdr.lookup("ScpStatementPledges")]]);xdr.struct("ScpEnvelope", [["statement", xdr.lookup("ScpStatement")], ["signature", xdr.lookup("Signature")]]);xdr.struct("ScpQuorumSet", [["threshold", xdr.lookup("Uint32")], ["validators", xdr.varArray(xdr.lookup("PublicKey"), 2147483647)], ["innerSets", xdr.varArray(xdr.lookup("ScpQuorumSet"), 2147483647)]]);xdr.typedef("AccountId", xdr.lookup("PublicKey"));xdr.typedef("Thresholds", xdr.opaque(4));xdr.typedef("String32", xdr.string(32));xdr.typedef("String64", xdr.string(64));xdr.typedef("SequenceNumber", xdr.lookup("Int64"));xdr.typedef("DataValue", xdr.varOpaque(64));xdr["enum"]("AssetType", {assetTypeNative:0, assetTypeCreditAlphanum4:1, assetTypeCreditAlphanum12:2});xdr.struct("AssetAlphaNum4", [["assetCode", xdr.opaque(4)], ["issuer", xdr.lookup("AccountId")]]);xdr.struct("AssetAlphaNum12", [["assetCode", xdr.opaque(12)], ["issuer", xdr.lookup("AccountId")]]);xdr.union("Asset", {switchOn:xdr.lookup("AssetType"), switchName:"type", switches:[["assetTypeNative", xdr["void"]()], ["assetTypeCreditAlphanum4", "alphaNum4"], ["assetTypeCreditAlphanum12", "alphaNum12"]], arms:{alphaNum4:xdr.lookup("AssetAlphaNum4"), alphaNum12:xdr.lookup("AssetAlphaNum12")}});xdr.struct("Price", [["n", xdr.lookup("Int32")], ["d", xdr.lookup("Int32")]]);xdr.struct("Liabilities", [["buying", xdr.lookup("Int64")], ["selling", xdr.lookup("Int64")]]);xdr["enum"]("ThresholdIndices", {thresholdMasterWeight:0, thresholdLow:1, thresholdMed:2, thresholdHigh:3});xdr["enum"]("LedgerEntryType", {account:0, trustline:1, offer:2, datum:3});xdr.struct("Signer", [["key", xdr.lookup("SignerKey")], ["weight", xdr.lookup("Uint32")]]);xdr["enum"]("AccountFlags", {authRequiredFlag:1, authRevocableFlag:2, authImmutableFlag:4});xdr["const"]("MASK_ACCOUNT_FLAGS", 7);xdr.union("AccountEntryV1Ext", {switchOn:xdr.int(), switchName:"v", switches:[[0, xdr["void"]()]], arms:{}});xdr.struct("AccountEntryV1", [["liabilities", xdr.lookup("Liabilities")], ["ext", xdr.lookup("AccountEntryV1Ext")]]);xdr.union("AccountEntryExt", {switchOn:xdr.int(), switchName:"v", switches:[[0, xdr["void"]()], [1, "v1"]], arms:{v1:xdr.lookup("AccountEntryV1")}});xdr.struct("AccountEntry", [["accountId", xdr.lookup("AccountId")], ["balance", xdr.lookup("Int64")], ["seqNum", xdr.lookup("SequenceNumber")], ["numSubEntries", xdr.lookup("Uint32")], ["inflationDest", xdr.option(xdr.lookup("AccountId"))], ["flags", xdr.lookup("Uint32")], ["homeDomain", xdr.lookup("String32")], ["thresholds", xdr.lookup("Thresholds")], ["signers", xdr.varArray(xdr.lookup("Signer"), 20)], ["ext", xdr.lookup("AccountEntryExt")]]);xdr["enum"]("TrustLineFlags", {authorizedFlag:1});xdr["const"]("MASK_TRUSTLINE_FLAGS", 1);xdr.union("TrustLineEntryV1Ext", {switchOn:xdr.int(), switchName:"v", switches:[[0, xdr["void"]()]], arms:{}});xdr.struct("TrustLineEntryV1", [["liabilities", xdr.lookup("Liabilities")], ["ext", xdr.lookup("TrustLineEntryV1Ext")]]);xdr.union("TrustLineEntryExt", {switchOn:xdr.int(), switchName:"v", switches:[[0, xdr["void"]()], [1, "v1"]], arms:{v1:xdr.lookup("TrustLineEntryV1")}});xdr.struct("TrustLineEntry", [["accountId", xdr.lookup("AccountId")], ["asset", xdr.lookup("Asset")], ["balance", xdr.lookup("Int64")], ["limit", xdr.lookup("Int64")], ["flags", xdr.lookup("Uint32")], ["ext", xdr.lookup("TrustLineEntryExt")]]);xdr["enum"]("OfferEntryFlags", {passiveFlag:1});xdr["const"]("MASK_OFFERENTRY_FLAGS", 1);xdr.union("OfferEntryExt", {switchOn:xdr.int(), switchName:"v", switches:[[0, xdr["void"]()]], arms:{}});xdr.struct("OfferEntry", [["sellerId", xdr.lookup("AccountId")], ["offerId", xdr.lookup("Uint64")], ["selling", xdr.lookup("Asset")], ["buying", xdr.lookup("Asset")], ["amount", xdr.lookup("Int64")], ["price", xdr.lookup("Price")], ["flags", xdr.lookup("Uint32")], ["ext", xdr.lookup("OfferEntryExt")]]);xdr.union("DataEntryExt", {switchOn:xdr.int(), switchName:"v", switches:[[0, xdr["void"]()]], arms:{}});xdr.struct("DataEntry", [["accountId", xdr.lookup("AccountId")], ["dataName", xdr.lookup("String64")], ["dataValue", xdr.lookup("DataValue")], ["ext", xdr.lookup("DataEntryExt")]]);xdr.union("LedgerEntryData", {switchOn:xdr.lookup("LedgerEntryType"), switchName:"type", switches:[["account", "account"], ["trustline", "trustLine"], ["offer", "offer"], ["datum", "data"]], arms:{account:xdr.lookup("AccountEntry"), trustLine:xdr.lookup("TrustLineEntry"), offer:xdr.lookup("OfferEntry"), data:xdr.lookup("DataEntry")}});xdr.union("LedgerEntryExt", {switchOn:xdr.int(), switchName:"v", switches:[[0, xdr["void"]()]], arms:{}});xdr.struct("LedgerEntry", [["lastModifiedLedgerSeq", xdr.lookup("Uint32")], ["data", xdr.lookup("LedgerEntryData")], ["ext", xdr.lookup("LedgerEntryExt")]]);xdr["enum"]("EnvelopeType", {envelopeTypeScp:1, envelopeTypeTx:2, envelopeTypeAuth:3});xdr.typedef("UpgradeType", xdr.varOpaque(128));xdr.union("StellarValueExt", {switchOn:xdr.int(), switchName:"v", switches:[[0, xdr["void"]()]], arms:{}});xdr.struct("StellarValue", [["txSetHash", xdr.lookup("Hash")], ["closeTime", xdr.lookup("Uint64")], ["upgrades", xdr.varArray(xdr.lookup("UpgradeType"), 6)], ["ext", xdr.lookup("StellarValueExt")]]);xdr.union("LedgerHeaderExt", {switchOn:xdr.int(), switchName:"v", switches:[[0, xdr["void"]()]], arms:{}});xdr.struct("LedgerHeader", [["ledgerVersion", xdr.lookup("Uint32")], ["previousLedgerHash", xdr.lookup("Hash")], ["scpValue", xdr.lookup("StellarValue")], ["txSetResultHash", xdr.lookup("Hash")], ["bucketListHash", xdr.lookup("Hash")], ["ledgerSeq", xdr.lookup("Uint32")], ["totalCoins", xdr.lookup("Int64")], ["feePool", xdr.lookup("Int64")], ["inflationSeq", xdr.lookup("Uint32")], ["idPool", xdr.lookup("Uint64")], ["baseFee", xdr.lookup("Uint32")], ["baseReserve", xdr.lookup("Uint32")], ["maxTxSetSize", xdr.lookup("Uint32")], ["skipList", xdr.array(xdr.lookup("Hash"), 4)], ["ext", xdr.lookup("LedgerHeaderExt")]]);xdr["enum"]("LedgerUpgradeType", {ledgerUpgradeVersion:1, ledgerUpgradeBaseFee:2, ledgerUpgradeMaxTxSetSize:3, ledgerUpgradeBaseReserve:4});xdr.union("LedgerUpgrade", {switchOn:xdr.lookup("LedgerUpgradeType"), switchName:"type", switches:[["ledgerUpgradeVersion", "newLedgerVersion"], ["ledgerUpgradeBaseFee", "newBaseFee"], ["ledgerUpgradeMaxTxSetSize", "newMaxTxSetSize"], ["ledgerUpgradeBaseReserve", "newBaseReserve"]], arms:{newLedgerVersion:xdr.lookup("Uint32"), newBaseFee:xdr.lookup("Uint32"), newMaxTxSetSize:xdr.lookup("Uint32"), newBaseReserve:xdr.lookup("Uint32")}});xdr.struct("LedgerKeyAccount", [["accountId", xdr.lookup("AccountId")]]);xdr.struct("LedgerKeyTrustLine", [["accountId", xdr.lookup("AccountId")], ["asset", xdr.lookup("Asset")]]);xdr.struct("LedgerKeyOffer", [["sellerId", xdr.lookup("AccountId")], ["offerId", xdr.lookup("Uint64")]]);xdr.struct("LedgerKeyData", [["accountId", xdr.lookup("AccountId")], ["dataName", xdr.lookup("String64")]]);xdr.union("LedgerKey", {switchOn:xdr.lookup("LedgerEntryType"), switchName:"type", switches:[["account", "account"], ["trustline", "trustLine"], ["offer", "offer"], ["datum", "data"]], arms:{account:xdr.lookup("LedgerKeyAccount"), trustLine:xdr.lookup("LedgerKeyTrustLine"), offer:xdr.lookup("LedgerKeyOffer"), data:xdr.lookup("LedgerKeyData")}});xdr["enum"]("BucketEntryType", {liveentry:0, deadentry:1});xdr.union("BucketEntry", {switchOn:xdr.lookup("BucketEntryType"), switchName:"type", switches:[["liveentry", "liveEntry"], ["deadentry", "deadEntry"]], arms:{liveEntry:xdr.lookup("LedgerEntry"), deadEntry:xdr.lookup("LedgerKey")}});xdr.struct("TransactionSet", [["previousLedgerHash", xdr.lookup("Hash")], ["txes", xdr.varArray(xdr.lookup("TransactionEnvelope"), 2147483647)]]);xdr.struct("TransactionResultPair", [["transactionHash", xdr.lookup("Hash")], ["result", xdr.lookup("TransactionResult")]]);xdr.struct("TransactionResultSet", [["results", xdr.varArray(xdr.lookup("TransactionResultPair"), 2147483647)]]);xdr.union("TransactionHistoryEntryExt", {switchOn:xdr.int(), switchName:"v", switches:[[0, xdr["void"]()]], arms:{}});xdr.struct("TransactionHistoryEntry", [["ledgerSeq", xdr.lookup("Uint32")], ["txSet", xdr.lookup("TransactionSet")], ["ext", xdr.lookup("TransactionHistoryEntryExt")]]);xdr.union("TransactionHistoryResultEntryExt", {switchOn:xdr.int(), switchName:"v", switches:[[0, xdr["void"]()]], arms:{}});xdr.struct("TransactionHistoryResultEntry", [["ledgerSeq", xdr.lookup("Uint32")], ["txResultSet", xdr.lookup("TransactionResultSet")], ["ext", xdr.lookup("TransactionHistoryResultEntryExt")]]);xdr.union("LedgerHeaderHistoryEntryExt", {switchOn:xdr.int(), switchName:"v", switches:[[0, xdr["void"]()]], arms:{}});xdr.struct("LedgerHeaderHistoryEntry", [["hash", xdr.lookup("Hash")], ["header", xdr.lookup("LedgerHeader")], ["ext", xdr.lookup("LedgerHeaderHistoryEntryExt")]]);xdr.struct("LedgerScpMessages", [["ledgerSeq", xdr.lookup("Uint32")], ["messages", xdr.varArray(xdr.lookup("ScpEnvelope"), 2147483647)]]);xdr.struct("ScpHistoryEntryV0", [["quorumSets", xdr.varArray(xdr.lookup("ScpQuorumSet"), 2147483647)], ["ledgerMessages", xdr.lookup("LedgerScpMessages")]]);xdr.union("ScpHistoryEntry", {switchOn:xdr.int(), switchName:"v", switches:[[0, "v0"]], arms:{v0:xdr.lookup("ScpHistoryEntryV0")}});xdr["enum"]("LedgerEntryChangeType", {ledgerEntryCreated:0, ledgerEntryUpdated:1, ledgerEntryRemoved:2, ledgerEntryState:3});xdr.union("LedgerEntryChange", {switchOn:xdr.lookup("LedgerEntryChangeType"), switchName:"type", switches:[["ledgerEntryCreated", "created"], ["ledgerEntryUpdated", "updated"], ["ledgerEntryRemoved", "removed"], ["ledgerEntryState", "state"]], arms:{created:xdr.lookup("LedgerEntry"), updated:xdr.lookup("LedgerEntry"), removed:xdr.lookup("LedgerKey"), state:xdr.lookup("LedgerEntry")}});xdr.typedef("LedgerEntryChanges", xdr.varArray(xdr.lookup("LedgerEntryChange"), 2147483647));xdr.struct("OperationMeta", [["changes", xdr.lookup("LedgerEntryChanges")]]);xdr.struct("TransactionMetaV1", [["txChanges", xdr.lookup("LedgerEntryChanges")], ["operations", xdr.varArray(xdr.lookup("OperationMeta"), 2147483647)]]);xdr.union("TransactionMeta", {switchOn:xdr.int(), switchName:"v", switches:[[0, "operations"], [1, "v1"]], arms:{operations:xdr.varArray(xdr.lookup("OperationMeta"), 2147483647), v1:xdr.lookup("TransactionMetaV1")}});xdr["enum"]("ErrorCode", {errMisc:0, errDatum:1, errConf:2, errAuth:3, errLoad:4});xdr.struct("Error", [["code", xdr.lookup("ErrorCode")], ["msg", xdr.string(100)]]);xdr.struct("AuthCert", [["pubkey", xdr.lookup("Curve25519Public")], ["expiration", xdr.lookup("Uint64")], ["sig", xdr.lookup("Signature")]]);xdr.struct("Hello", [["ledgerVersion", xdr.lookup("Uint32")], ["overlayVersion", xdr.lookup("Uint32")], ["overlayMinVersion", xdr.lookup("Uint32")], ["networkId", xdr.lookup("Hash")], ["versionStr", xdr.string(100)], ["listeningPort", xdr.int()], ["peerId", xdr.lookup("NodeId")], ["cert", xdr.lookup("AuthCert")], ["nonce", xdr.lookup("Uint256")]]);xdr.struct("Auth", [["unused", xdr.int()]]);xdr["enum"]("IpAddrType", {iPv4:0, iPv6:1});xdr.union("PeerAddressIp", {switchOn:xdr.lookup("IpAddrType"), switchName:"type", switches:[["iPv4", "ipv4"], ["iPv6", "ipv6"]], arms:{ipv4:xdr.opaque(4), ipv6:xdr.opaque(16)}});xdr.struct("PeerAddress", [["ip", xdr.lookup("PeerAddressIp")], ["port", xdr.lookup("Uint32")], ["numFailures", xdr.lookup("Uint32")]]);xdr["enum"]("MessageType", {errorMsg:0, auth:2, dontHave:3, getPeer:4, peer:5, getTxSet:6, txSet:7, transaction:8, getScpQuorumset:9, scpQuorumset:10, scpMessage:11, getScpState:12, hello:13});xdr.struct("DontHave", [["type", xdr.lookup("MessageType")], ["reqHash", xdr.lookup("Uint256")]]);xdr.union("StellarMessage", {switchOn:xdr.lookup("MessageType"), switchName:"type", switches:[["errorMsg", "error"], ["hello", "hello"], ["auth", "auth"], ["dontHave", "dontHave"], ["getPeer", xdr["void"]()], ["peer", "peers"], ["getTxSet", "txSetHash"], ["txSet", "txSet"], ["transaction", "transaction"], ["getScpQuorumset", "qSetHash"], ["scpQuorumset", "qSet"], ["scpMessage", "envelope"], ["getScpState", "getScpLedgerSeq"]], arms:{error:xdr.lookup("Error"), hello:xdr.lookup("Hello"), auth:xdr.lookup("Auth"), dontHave:xdr.lookup("DontHave"), peers:xdr.varArray(xdr.lookup("PeerAddress"), 100), txSetHash:xdr.lookup("Uint256"), txSet:xdr.lookup("TransactionSet"), transaction:xdr.lookup("TransactionEnvelope"), qSetHash:xdr.lookup("Uint256"), qSet:xdr.lookup("ScpQuorumSet"), envelope:xdr.lookup("StellarMessage"), getScpLedgerSeq:xdr.lookup("Uint32")}});xdr.struct("AuthenticatedMessageV0", [["sequence", xdr.lookup("Uint64")], ["message", xdr.lookup("StellarMessage")], ["mac", xdr.lookup("HmacSha256Mac")]]);xdr.union("AuthenticatedMessage", {switchOn:xdr.lookup("Uint32"), switchName:"v", switches:[[0, "v0"]], arms:{v0:xdr.lookup("AuthenticatedMessageV0")}});xdr.struct("DecoratedSignature", [["hint", xdr.lookup("SignatureHint")], ["signature", xdr.lookup("Signature")]]);xdr["enum"]("OperationType", {createAccount:0, payment:1, pathPayment:2, manageOffer:3, createPassiveOffer:4, setOption:5, changeTrust:6, allowTrust:7, accountMerge:8, inflation:9, manageDatum:10, bumpSequence:11});xdr.struct("CreateAccountOp", [["destination", xdr.lookup("AccountId")], ["startingBalance", xdr.lookup("Int64")]]);xdr.struct("PaymentOp", [["destination", xdr.lookup("AccountId")], ["asset", xdr.lookup("Asset")], ["amount", xdr.lookup("Int64")]]);xdr.struct("PathPaymentOp", [["sendAsset", xdr.lookup("Asset")], ["sendMax", xdr.lookup("Int64")], ["destination", xdr.lookup("AccountId")], ["destAsset", xdr.lookup("Asset")], ["destAmount", xdr.lookup("Int64")], ["path", xdr.varArray(xdr.lookup("Asset"), 5)]]);xdr.struct("ManageOfferOp", [["selling", xdr.lookup("Asset")], ["buying", xdr.lookup("Asset")], ["amount", xdr.lookup("Int64")], ["price", xdr.lookup("Price")], ["offerId", xdr.lookup("Uint64")]]);xdr.struct("CreatePassiveOfferOp", [["selling", xdr.lookup("Asset")], ["buying", xdr.lookup("Asset")], ["amount", xdr.lookup("Int64")], ["price", xdr.lookup("Price")]]);xdr.struct("SetOptionsOp", [["inflationDest", xdr.option(xdr.lookup("AccountId"))], ["clearFlags", xdr.option(xdr.lookup("Uint32"))], ["setFlags", xdr.option(xdr.lookup("Uint32"))], ["masterWeight", xdr.option(xdr.lookup("Uint32"))], ["lowThreshold", xdr.option(xdr.lookup("Uint32"))], ["medThreshold", xdr.option(xdr.lookup("Uint32"))], ["highThreshold", xdr.option(xdr.lookup("Uint32"))], ["homeDomain", xdr.option(xdr.lookup("String32"))], ["signer", xdr.option(xdr.lookup("Signer"))]]);xdr.struct("ChangeTrustOp", [["line", xdr.lookup("Asset")], ["limit", xdr.lookup("Int64")]]);xdr.union("AllowTrustOpAsset", {switchOn:xdr.lookup("AssetType"), switchName:"type", switches:[["assetTypeCreditAlphanum4", "assetCode4"], ["assetTypeCreditAlphanum12", "assetCode12"]], arms:{assetCode4:xdr.opaque(4), assetCode12:xdr.opaque(12)}});xdr.struct("AllowTrustOp", [["trustor", xdr.lookup("AccountId")], ["asset", xdr.lookup("AllowTrustOpAsset")], ["authorize", xdr.bool()]]);xdr.struct("ManageDataOp", [["dataName", xdr.lookup("String64")], ["dataValue", xdr.option(xdr.lookup("DataValue"))]]);xdr.struct("BumpSequenceOp", [["bumpTo", xdr.lookup("SequenceNumber")]]);xdr.union("OperationBody", {switchOn:xdr.lookup("OperationType"), switchName:"type", switches:[["createAccount", "createAccountOp"], ["payment", "paymentOp"], ["pathPayment", "pathPaymentOp"], ["manageOffer", "manageOfferOp"], ["createPassiveOffer", "createPassiveOfferOp"], ["setOption", "setOptionsOp"], ["changeTrust", "changeTrustOp"], ["allowTrust", "allowTrustOp"], ["accountMerge", "destination"], ["inflation", xdr["void"]()], ["manageDatum", "manageDataOp"], ["bumpSequence", "bumpSequenceOp"]], arms:{createAccountOp:xdr.lookup("CreateAccountOp"), paymentOp:xdr.lookup("PaymentOp"), pathPaymentOp:xdr.lookup("PathPaymentOp"), manageOfferOp:xdr.lookup("ManageOfferOp"), createPassiveOfferOp:xdr.lookup("CreatePassiveOfferOp"), setOptionsOp:xdr.lookup("SetOptionsOp"), changeTrustOp:xdr.lookup("ChangeTrustOp"), allowTrustOp:xdr.lookup("AllowTrustOp"), destination:xdr.lookup("AccountId"), manageDataOp:xdr.lookup("ManageDataOp"), bumpSequenceOp:xdr.lookup("BumpSequenceOp")}});xdr.struct("Operation", [["sourceAccount", xdr.option(xdr.lookup("AccountId"))], ["body", xdr.lookup("OperationBody")]]);xdr["enum"]("MemoType", {memoNone:0, memoText:1, memoId:2, memoHash:3, memoReturn:4});xdr.union("Memo", {switchOn:xdr.lookup("MemoType"), switchName:"type", switches:[["memoNone", xdr["void"]()], ["memoText", "text"], ["memoId", "id"], ["memoHash", "hash"], ["memoReturn", "retHash"]], arms:{text:xdr.string(28), id:xdr.lookup("Uint64"), hash:xdr.lookup("Hash"), retHash:xdr.lookup("Hash")}});xdr.struct("TimeBounds", [["minTime", xdr.lookup("Uint64")], ["maxTime", xdr.lookup("Uint64")]]);xdr.union("TransactionExt", {switchOn:xdr.int(), switchName:"v", switches:[[0, xdr["void"]()]], arms:{}});xdr.struct("Transaction", [["sourceAccount", xdr.lookup("AccountId")], ["fee", xdr.lookup("Uint32")], ["seqNum", xdr.lookup("SequenceNumber")], ["timeBounds", xdr.option(xdr.lookup("TimeBounds"))], ["memo", xdr.lookup("Memo")], ["operations", xdr.varArray(xdr.lookup("Operation"), 100)], ["ext", xdr.lookup("TransactionExt")]]);xdr.union("TransactionSignaturePayloadTaggedTransaction", {switchOn:xdr.lookup("EnvelopeType"), switchName:"type", switches:[["envelopeTypeTx", "tx"]], arms:{tx:xdr.lookup("Transaction")}});xdr.struct("TransactionSignaturePayload", [["networkId", xdr.lookup("Hash")], ["taggedTransaction", xdr.lookup("TransactionSignaturePayloadTaggedTransaction")]]);xdr.struct("TransactionEnvelope", [["tx", xdr.lookup("Transaction")], ["signatures", xdr.varArray(xdr.lookup("DecoratedSignature"), 20)]]);xdr.struct("ClaimOfferAtom", [["sellerId", xdr.lookup("AccountId")], ["offerId", xdr.lookup("Uint64")], ["assetSold", xdr.lookup("Asset")], ["amountSold", xdr.lookup("Int64")], ["assetBought", xdr.lookup("Asset")], ["amountBought", xdr.lookup("Int64")]]);xdr["enum"]("CreateAccountResultCode", {createAccountSuccess:0, createAccountMalformed:-1, createAccountUnderfunded:-2, createAccountLowReserve:-3, createAccountAlreadyExist:-4});xdr.union("CreateAccountResult", {switchOn:xdr.lookup("CreateAccountResultCode"), switchName:"code", switches:[["createAccountSuccess", xdr["void"]()]], arms:{}, defaultArm:xdr["void"]()});xdr["enum"]("PaymentResultCode", {paymentSuccess:0, paymentMalformed:-1, paymentUnderfunded:-2, paymentSrcNoTrust:-3, paymentSrcNotAuthorized:-4, paymentNoDestination:-5, paymentNoTrust:-6, paymentNotAuthorized:-7, paymentLineFull:-8, paymentNoIssuer:-9});xdr.union("PaymentResult", {switchOn:xdr.lookup("PaymentResultCode"), switchName:"code", switches:[["paymentSuccess", xdr["void"]()]], arms:{}, defaultArm:xdr["void"]()});xdr["enum"]("PathPaymentResultCode", {pathPaymentSuccess:0, pathPaymentMalformed:-1, pathPaymentUnderfunded:-2, pathPaymentSrcNoTrust:-3, pathPaymentSrcNotAuthorized:-4, pathPaymentNoDestination:-5, pathPaymentNoTrust:-6, pathPaymentNotAuthorized:-7, pathPaymentLineFull:-8, pathPaymentNoIssuer:-9, pathPaymentTooFewOffer:-10, pathPaymentOfferCrossSelf:-11, pathPaymentOverSendmax:-12});xdr.struct("SimplePaymentResult", [["destination", xdr.lookup("AccountId")], ["asset", xdr.lookup("Asset")], ["amount", xdr.lookup("Int64")]]);xdr.struct("PathPaymentResultSuccess", [["offers", xdr.varArray(xdr.lookup("ClaimOfferAtom"), 2147483647)], ["last", xdr.lookup("SimplePaymentResult")]]);xdr.union("PathPaymentResult", {switchOn:xdr.lookup("PathPaymentResultCode"), switchName:"code", switches:[["pathPaymentSuccess", "success"], ["pathPaymentNoIssuer", "noIssuer"]], arms:{success:xdr.lookup("PathPaymentResultSuccess"), noIssuer:xdr.lookup("Asset")}, defaultArm:xdr["void"]()});xdr["enum"]("ManageOfferResultCode", {manageOfferSuccess:0, manageOfferMalformed:-1, manageOfferSellNoTrust:-2, manageOfferBuyNoTrust:-3, manageOfferSellNotAuthorized:-4, manageOfferBuyNotAuthorized:-5, manageOfferLineFull:-6, manageOfferUnderfunded:-7, manageOfferCrossSelf:-8, manageOfferSellNoIssuer:-9, manageOfferBuyNoIssuer:-10, manageOfferNotFound:-11, manageOfferLowReserve:-12});xdr["enum"]("ManageOfferEffect", {manageOfferCreated:0, manageOfferUpdated:1, manageOfferDeleted:2});xdr.union("ManageOfferSuccessResultOffer", {switchOn:xdr.lookup("ManageOfferEffect"), switchName:"effect", switches:[["manageOfferCreated", "offer"], ["manageOfferUpdated", "offer"]], arms:{offer:xdr.lookup("OfferEntry")}, defaultArm:xdr["void"]()});xdr.struct("ManageOfferSuccessResult", [["offersClaimed", xdr.varArray(xdr.lookup("ClaimOfferAtom"), 2147483647)], ["offer", xdr.lookup("ManageOfferSuccessResultOffer")]]);xdr.union("ManageOfferResult", {switchOn:xdr.lookup("ManageOfferResultCode"), switchName:"code", switches:[["manageOfferSuccess", "success"]], arms:{success:xdr.lookup("ManageOfferSuccessResult")}, defaultArm:xdr["void"]()});xdr["enum"]("SetOptionsResultCode", {setOptionsSuccess:0, setOptionsLowReserve:-1, setOptionsTooManySigner:-2, setOptionsBadFlag:-3, setOptionsInvalidInflation:-4, setOptionsCantChange:-5, setOptionsUnknownFlag:-6, setOptionsThresholdOutOfRange:-7, setOptionsBadSigner:-8, setOptionsInvalidHomeDomain:-9});xdr.union("SetOptionsResult", {switchOn:xdr.lookup("SetOptionsResultCode"), switchName:"code", switches:[["setOptionsSuccess", xdr["void"]()]], arms:{}, defaultArm:xdr["void"]()});xdr["enum"]("ChangeTrustResultCode", {changeTrustSuccess:0, changeTrustMalformed:-1, changeTrustNoIssuer:-2, changeTrustInvalidLimit:-3, changeTrustLowReserve:-4, changeTrustSelfNotAllowed:-5});xdr.union("ChangeTrustResult", {switchOn:xdr.lookup("ChangeTrustResultCode"), switchName:"code", switches:[["changeTrustSuccess", xdr["void"]()]], arms:{}, defaultArm:xdr["void"]()});xdr["enum"]("AllowTrustResultCode", {allowTrustSuccess:0, allowTrustMalformed:-1, allowTrustNoTrustLine:-2, allowTrustTrustNotRequired:-3, allowTrustCantRevoke:-4, allowTrustSelfNotAllowed:-5});xdr.union("AllowTrustResult", {switchOn:xdr.lookup("AllowTrustResultCode"), switchName:"code", switches:[["allowTrustSuccess", xdr["void"]()]], arms:{}, defaultArm:xdr["void"]()});xdr["enum"]("AccountMergeResultCode", {accountMergeSuccess:0, accountMergeMalformed:-1, accountMergeNoAccount:-2, accountMergeImmutableSet:-3, accountMergeHasSubEntry:-4, accountMergeSeqnumTooFar:-5, accountMergeDestFull:-6});xdr.union("AccountMergeResult", {switchOn:xdr.lookup("AccountMergeResultCode"), switchName:"code", switches:[["accountMergeSuccess", "sourceAccountBalance"]], arms:{sourceAccountBalance:xdr.lookup("Int64")}, defaultArm:xdr["void"]()});xdr["enum"]("InflationResultCode", {inflationSuccess:0, inflationNotTime:-1});xdr.struct("InflationPayout", [["destination", xdr.lookup("AccountId")], ["amount", xdr.lookup("Int64")]]);xdr.union("InflationResult", {switchOn:xdr.lookup("InflationResultCode"), switchName:"code", switches:[["inflationSuccess", "payouts"]], arms:{payouts:xdr.varArray(xdr.lookup("InflationPayout"), 2147483647)}, defaultArm:xdr["void"]()});xdr["enum"]("ManageDataResultCode", {manageDataSuccess:0, manageDataNotSupportedYet:-1, manageDataNameNotFound:-2, manageDataLowReserve:-3, manageDataInvalidName:-4});xdr.union("ManageDataResult", {switchOn:xdr.lookup("ManageDataResultCode"), switchName:"code", switches:[["manageDataSuccess", xdr["void"]()]], arms:{}, defaultArm:xdr["void"]()});xdr["enum"]("BumpSequenceResultCode", {bumpSequenceSuccess:0, bumpSequenceBadSeq:-1});xdr.union("BumpSequenceResult", {switchOn:xdr.lookup("BumpSequenceResultCode"), switchName:"code", switches:[["bumpSequenceSuccess", xdr["void"]()]], arms:{}, defaultArm:xdr["void"]()});xdr["enum"]("OperationResultCode", {opInner:0, opBadAuth:-1, opNoAccount:-2, opNotSupported:-3});xdr.union("OperationResultTr", {switchOn:xdr.lookup("OperationType"), switchName:"type", switches:[["createAccount", "createAccountResult"], ["payment", "paymentResult"], ["pathPayment", "pathPaymentResult"], ["manageOffer", "manageOfferResult"], ["createPassiveOffer", "createPassiveOfferResult"], ["setOption", "setOptionsResult"], ["changeTrust", "changeTrustResult"], ["allowTrust", "allowTrustResult"], ["accountMerge", "accountMergeResult"], ["inflation", "inflationResult"], ["manageDatum", "manageDataResult"], ["bumpSequence", "bumpSeqResult"]], arms:{createAccountResult:xdr.lookup("CreateAccountResult"), paymentResult:xdr.lookup("PaymentResult"), pathPaymentResult:xdr.lookup("PathPaymentResult"), manageOfferResult:xdr.lookup("ManageOfferResult"), createPassiveOfferResult:xdr.lookup("ManageOfferResult"), setOptionsResult:xdr.lookup("SetOptionsResult"), changeTrustResult:xdr.lookup("ChangeTrustResult"), allowTrustResult:xdr.lookup("AllowTrustResult"), accountMergeResult:xdr.lookup("AccountMergeResult"), inflationResult:xdr.lookup("InflationResult"), manageDataResult:xdr.lookup("ManageDataResult"), bumpSeqResult:xdr.lookup("BumpSequenceResult")}});xdr.union("OperationResult", {switchOn:xdr.lookup("OperationResultCode"), switchName:"code", switches:[["opInner", "tr"]], arms:{tr:xdr.lookup("OperationResultTr")}, defaultArm:xdr["void"]()});xdr["enum"]("TransactionResultCode", {txSuccess:0, txFailed:-1, txTooEarly:-2, txTooLate:-3, txMissingOperation:-4, txBadSeq:-5, txBadAuth:-6, txInsufficientBalance:-7, txNoAccount:-8, txInsufficientFee:-9, txBadAuthExtra:-10, txInternalError:-11});xdr.union("TransactionResultResult", {switchOn:xdr.lookup("TransactionResultCode"), switchName:"code", switches:[["txSuccess", "results"], ["txFailed", "results"]], arms:{results:xdr.varArray(xdr.lookup("OperationResult"), 2147483647)}, defaultArm:xdr["void"]()});xdr.union("TransactionResultExt", {switchOn:xdr.int(), switchName:"v", switches:[[0, xdr["void"]()]], arms:{}});xdr.struct("TransactionResult", [["feeCharged", xdr.lookup("Int64")], ["result", xdr.lookup("TransactionResultResult")], ["ext", xdr.lookup("TransactionResultExt")]]);xdr.typedef("Hash", xdr.opaque(32));xdr.typedef("Uint256", xdr.opaque(32));xdr.typedef("Uint32", xdr.uint());xdr.typedef("Int32", xdr.int());xdr.typedef("Uint64", xdr.uhyper());xdr.typedef("Int64", xdr.hyper());xdr["enum"]("CryptoKeyType", {keyTypeEd25519:0, keyTypePreAuthTx:1, keyTypeHashX:2});xdr["enum"]("PublicKeyType", {publicKeyTypeEd25519:0});xdr["enum"]("SignerKeyType", {signerKeyTypeEd25519:0, signerKeyTypePreAuthTx:1, signerKeyTypeHashX:2});xdr.union("PublicKey", {switchOn:xdr.lookup("PublicKeyType"), switchName:"type", switches:[["publicKeyTypeEd25519", "ed25519"]], arms:{ed25519:xdr.lookup("Uint256")}});xdr.union("SignerKey", {switchOn:xdr.lookup("SignerKeyType"), switchName:"type", switches:[["signerKeyTypeEd25519", "ed25519"], ["signerKeyTypePreAuthTx", "preAuthTx"], ["signerKeyTypeHashX", "hashX"]], arms:{ed25519:xdr.lookup("Uint256"), preAuthTx:xdr.lookup("Uint256"), hashX:xdr.lookup("Uint256")}});xdr.typedef("Signature", xdr.varOpaque(64));xdr.typedef("SignatureHint", xdr.opaque(4));xdr.typedef("NodeId", xdr.lookup("PublicKey"));xdr.struct("Curve25519Secret", [["key", xdr.opaque(32)]]);xdr.struct("Curve25519Public", [["key", xdr.opaque(32)]]);xdr.struct("HmacSha256Key", [["key", xdr.opaque(32)]]);xdr.struct("HmacSha256Mac", [["mac", xdr.opaque(32)]]);});module.exports = types;
36244},{"js-xdr":131}],411:[function(require,module,exports){
36245"use strict";
36246
36247exports.hash = hash;
36248Object.defineProperty(exports, "__esModule", {
36249 value: true
36250});
36251
36252var sha256 = require("sha.js").sha256;
36253
36254function hash(data) {
36255 var hasher = new sha256();
36256 hasher.update(data, "utf8");
36257 return hasher.digest();
36258}
36259},{"sha.js":400}],412:[function(require,module,exports){
36260"use strict";
36261
36262var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { "default": obj }; };
36263
36264var _defaults = function (obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; };
36265
36266var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
36267
36268Object.defineProperty(exports, "__esModule", {
36269 value: true
36270});
36271
36272var xdr = _interopRequire(require("./generated/stellar-xdr_generated"));
36273
36274exports.xdr = xdr;
36275exports.hash = require("./hashing").hash;
36276
36277var _signing = require("./signing");
36278
36279exports.sign = _signing.sign;
36280exports.verify = _signing.verify;
36281exports.FastSigning = _signing.FastSigning;
36282exports.Keypair = require("./keypair").Keypair;
36283
36284var _jsXdr = require("js-xdr");
36285
36286exports.UnsignedHyper = _jsXdr.UnsignedHyper;
36287exports.Hyper = _jsXdr.Hyper;
36288exports.Transaction = require("./transaction").Transaction;
36289
36290var _transaction_builder = require("./transaction_builder");
36291
36292exports.TransactionBuilder = _transaction_builder.TransactionBuilder;
36293exports.TimeoutInfinite = _transaction_builder.TimeoutInfinite;
36294exports.Asset = require("./asset").Asset;
36295
36296var _operation = require("./operation");
36297
36298exports.Operation = _operation.Operation;
36299exports.AuthRequiredFlag = _operation.AuthRequiredFlag;
36300exports.AuthRevocableFlag = _operation.AuthRevocableFlag;
36301exports.AuthImmutableFlag = _operation.AuthImmutableFlag;
36302
36303_defaults(exports, _interopRequireWildcard(require("./memo")));
36304
36305exports.Account = require("./account").Account;
36306
36307var _network = require("./network");
36308
36309exports.Network = _network.Network;
36310exports.Networks = _network.Networks;
36311exports.StrKey = require("./strkey").StrKey;
36312exports["default"] = module.exports;
36313},{"./account":407,"./asset":408,"./generated/stellar-xdr_generated":410,"./hashing":411,"./keypair":413,"./memo":414,"./network":415,"./operation":416,"./signing":430,"./strkey":431,"./transaction":432,"./transaction_builder":433,"js-xdr":131}],413:[function(require,module,exports){
36314(function (Buffer){
36315"use strict";
36316
36317var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
36318
36319var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { "default": obj }; };
36320
36321var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
36322
36323var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
36324
36325Object.defineProperty(exports, "__esModule", {
36326 value: true
36327});
36328
36329var Network = require("./network").Network;
36330
36331var _signing = require("./signing");
36332
36333var sign = _signing.sign;
36334var verify = _signing.verify;
36335
36336var base58 = _interopRequireWildcard(require("./base58"));
36337
36338var StrKey = require("./strkey").StrKey;
36339
36340var xdr = _interopRequire(require("./generated/stellar-xdr_generated"));
36341
36342var nacl = _interopRequire(require("tweetnacl"));
36343
36344/**
36345 * `Keypair` represents public (and secret) keys of the account.
36346 *
36347 * Currently `Keypair` only supports ed25519 but in a future this class can be abstraction layer for other
36348 * public-key signature systems.
36349 *
36350 * Use more convenient methods to create `Keypair` object:
36351 * * `{@link Keypair.fromPublicKey}`
36352 * * `{@link Keypair.fromSecret}`
36353 * * `{@link Keypair.random}`
36354 *
36355 * @constructor
36356 * @param {object} keys At least one of keys must be provided.
36357 * @param {string} keys.type Public-key signature system name. (currently only `ed25519` keys are supported)
36358 * @param {Buffer} [keys.publicKey] Raw public key
36359 * @param {Buffer} [keys.secretKey] Raw secret key (32-byte secret seed in ed25519`)
36360 */
36361
36362var Keypair = exports.Keypair = (function () {
36363 function Keypair(keys) {
36364 _classCallCheck(this, Keypair);
36365
36366 if (keys.type != "ed25519") {
36367 throw new Error("Invalid keys type");
36368 }
36369
36370 this.type = keys.type;
36371
36372 if (keys.secretKey) {
36373 keys.secretKey = Buffer.from(keys.secretKey);
36374
36375 if (keys.secretKey.length != 32) {
36376 throw new Error("secretKey length is invalid");
36377 }
36378
36379 var secretKeyUint8 = new Uint8Array(keys.secretKey);
36380 var naclKeys = nacl.sign.keyPair.fromSeed(secretKeyUint8);
36381
36382 this._secretSeed = keys.secretKey;
36383 this._secretKey = Buffer.from(naclKeys.secretKey);
36384 this._publicKey = Buffer.from(naclKeys.publicKey);
36385
36386 if (keys.publicKey && !this._publicKey.equals(Buffer.from(keys.publicKey))) {
36387 throw new Error("secretKey does not match publicKey");
36388 }
36389 } else {
36390 this._publicKey = Buffer.from(keys.publicKey);
36391
36392 if (this._publicKey.length != 32) {
36393 throw new Error("publicKey length is invalid");
36394 }
36395 }
36396 }
36397
36398 _createClass(Keypair, {
36399 xdrAccountId: {
36400 value: function xdrAccountId() {
36401 return new xdr.AccountId.publicKeyTypeEd25519(this._publicKey);
36402 }
36403 },
36404 xdrPublicKey: {
36405 value: function xdrPublicKey() {
36406 return new xdr.PublicKey.publicKeyTypeEd25519(this._publicKey);
36407 }
36408 },
36409 rawPublicKey: {
36410
36411 /**
36412 * Returns raw public key
36413 * @returns {Buffer}
36414 */
36415
36416 value: function rawPublicKey() {
36417 return this._publicKey;
36418 }
36419 },
36420 signatureHint: {
36421 value: function signatureHint() {
36422 var a = this.xdrAccountId().toXDR();
36423
36424 return a.slice(a.length - 4);
36425 }
36426 },
36427 publicKey: {
36428
36429 /**
36430 * Returns public key associated with this `Keypair` object.
36431 * @returns {string}
36432 */
36433
36434 value: function publicKey() {
36435 return StrKey.encodeEd25519PublicKey(this._publicKey);
36436 }
36437 },
36438 secret: {
36439
36440 /**
36441 * Returns secret key associated with this `Keypair` object
36442 * @returns {string}
36443 */
36444
36445 value: function secret() {
36446 if (!this._secretSeed) {
36447 throw new Error("no secret key available");
36448 }
36449
36450 if (this.type == "ed25519") {
36451 return StrKey.encodeEd25519SecretSeed(this._secretSeed);
36452 }
36453
36454 throw new Error("Invalid Keypair type");
36455 }
36456 },
36457 rawSecretKey: {
36458
36459 /**
36460 * Returns raw secret key.
36461 * @returns {Buffer}
36462 */
36463
36464 value: function rawSecretKey() {
36465 return this._secretSeed;
36466 }
36467 },
36468 canSign: {
36469
36470 /**
36471 * Returns `true` if this `Keypair` object contains secret key and can sign.
36472 * @returns {boolean}
36473 */
36474
36475 value: function canSign() {
36476 return !!this._secretKey;
36477 }
36478 },
36479 sign: {
36480
36481 /**
36482 * Signs data.
36483 * @param {Buffer} data Data to sign
36484 * @returns {Buffer}
36485 */
36486
36487 value: (function (_sign) {
36488 var _signWrapper = function sign(_x) {
36489 return _sign.apply(this, arguments);
36490 };
36491
36492 _signWrapper.toString = function () {
36493 return _sign.toString();
36494 };
36495
36496 return _signWrapper;
36497 })(function (data) {
36498 if (!this.canSign()) {
36499 throw new Error("cannot sign: no secret key available");
36500 }
36501
36502 return sign(data, this._secretKey);
36503 })
36504 },
36505 verify: {
36506
36507 /**
36508 * Verifies if `signature` for `data` is valid.
36509 * @param {Buffer} data Signed data
36510 * @param {Buffer} signature Signature
36511 * @returns {boolean}
36512 */
36513
36514 value: (function (_verify) {
36515 var _verifyWrapper = function verify(_x2, _x3) {
36516 return _verify.apply(this, arguments);
36517 };
36518
36519 _verifyWrapper.toString = function () {
36520 return _verify.toString();
36521 };
36522
36523 return _verifyWrapper;
36524 })(function (data, signature) {
36525 return verify(data, signature, this._publicKey);
36526 })
36527 },
36528 signDecorated: {
36529 value: function signDecorated(data) {
36530 var signature = this.sign(data);
36531 var hint = this.signatureHint();
36532
36533 return new xdr.DecoratedSignature({ hint: hint, signature: signature });
36534 }
36535 }
36536 }, {
36537 fromSecret: {
36538
36539 /**
36540 * Creates a new `Keypair` instance from secret. This can either be secret key or secret seed depending
36541 * on underlying public-key signature system. Currently `Keypair` only supports ed25519.
36542 * @param {string} secret secret key (ex. `SDAKFNYEIAORZKKCYRILFQKLLOCNPL5SWJ3YY5NM3ZH6GJSZGXHZEPQS`)
36543 * @returns {Keypair}
36544 */
36545
36546 value: function fromSecret(secret) {
36547 var rawSecret = StrKey.decodeEd25519SecretSeed(secret);
36548 return this.fromRawEd25519Seed(rawSecret);
36549 }
36550 },
36551 fromBase58Seed: {
36552
36553 /**
36554 * Base58 address encoding is **DEPRECATED**! Use this method only for transition to strkey encoding.
36555 * @param {string} seed Base58 secret seed
36556 * @deprecated Use {@link Keypair.fromSecret}
36557 * @returns {Keypair}
36558 */
36559
36560 value: function fromBase58Seed(seed) {
36561 var rawSeed = base58.decodeBase58Check("seed", seed);
36562 return this.fromRawEd25519Seed(rawSeed);
36563 }
36564 },
36565 fromRawEd25519Seed: {
36566
36567 /**
36568 * Creates a new `Keypair` object from ed25519 secret key seed raw bytes.
36569 *
36570 * @param {Buffer} rawSeed Raw 32-byte ed25519 secret key seed
36571 * @returns {Keypair}
36572 */
36573
36574 value: function fromRawEd25519Seed(rawSeed) {
36575 return new this({ type: "ed25519", secretKey: rawSeed });
36576 }
36577 },
36578 master: {
36579
36580 /**
36581 * Returns `Keypair` object representing network master key.
36582 * @returns {Keypair}
36583 */
36584
36585 value: function master() {
36586 if (Network.current() === null) {
36587 throw new Error("No network selected. Use `Network.use`, `Network.usePublicNetwork` or `Network.useTestNetwork` helper methods to select network.");
36588 }
36589 return this.fromRawEd25519Seed(Network.current().networkId());
36590 }
36591 },
36592 fromPublicKey: {
36593
36594 /**
36595 * Creates a new `Keypair` object from public key.
36596 * @param {string} publicKey public key (ex. `GB3KJPLFUYN5VL6R3GU3EGCGVCKFDSD7BEDX42HWG5BWFKB3KQGJJRMA`)
36597 * @returns {Keypair}
36598 */
36599
36600 value: function fromPublicKey(publicKey) {
36601 publicKey = StrKey.decodeEd25519PublicKey(publicKey);
36602 if (publicKey.length !== 32) {
36603 throw new Error("Invalid Stellar public key");
36604 }
36605 return new this({ type: "ed25519", publicKey: publicKey });
36606 }
36607 },
36608 random: {
36609
36610 /**
36611 * Create a random `Keypair` object.
36612 * @returns {Keypair}
36613 */
36614
36615 value: function random() {
36616 var secret = nacl.randomBytes(32);
36617 return this.fromRawEd25519Seed(secret);
36618 }
36619 }
36620 });
36621
36622 return Keypair;
36623})();
36624}).call(this,require("buffer").Buffer)
36625},{"./base58":409,"./generated/stellar-xdr_generated":410,"./network":415,"./signing":430,"./strkey":431,"buffer":50,"tweetnacl":440}],414:[function(require,module,exports){
36626(function (Buffer){
36627"use strict";
36628
36629var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
36630
36631var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
36632
36633var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
36634
36635Object.defineProperty(exports, "__esModule", {
36636 value: true
36637});
36638
36639var xdr = _interopRequire(require("./generated/stellar-xdr_generated"));
36640
36641var isUndefined = _interopRequire(require("lodash/isUndefined"));
36642
36643var isNull = _interopRequire(require("lodash/isNull"));
36644
36645var isString = _interopRequire(require("lodash/isString"));
36646
36647var clone = _interopRequire(require("lodash/clone"));
36648
36649var UnsignedHyper = require("js-xdr").UnsignedHyper;
36650
36651var BigNumber = _interopRequire(require("bignumber.js"));
36652
36653/**
36654 * Type of {@link Memo}.
36655 */
36656var MemoNone = "none";
36657exports.MemoNone = MemoNone;
36658/**
36659 * Type of {@link Memo}.
36660 */
36661var MemoID = "id";
36662exports.MemoID = MemoID;
36663/**
36664 * Type of {@link Memo}.
36665 */
36666var MemoText = "text";
36667exports.MemoText = MemoText;
36668/**
36669 * Type of {@link Memo}.
36670 */
36671var MemoHash = "hash";
36672exports.MemoHash = MemoHash;
36673/**
36674 * Type of {@link Memo}.
36675 */
36676var MemoReturn = "return";
36677
36678exports.MemoReturn = MemoReturn;
36679/**
36680 * `Memo` represents memos attached to transactions.
36681 *
36682 * @param {string} type - `MemoNone`, `MemoID`, `MemoText`, `MemoHash` or `MemoReturn`
36683 * @param {*} value - `string` for `MemoID`, `MemoText`, buffer of hex string for `MemoHash` or `MemoReturn`
36684 * @see [Transactions concept](https://www.stellar.org/developers/learn/concepts/transactions.html)
36685 * @class Memo
36686 */
36687
36688var Memo = exports.Memo = (function () {
36689 function Memo(type) {
36690 var value = arguments[1] === undefined ? null : arguments[1];
36691
36692 _classCallCheck(this, Memo);
36693
36694 this._type = type;
36695 this._value = value;
36696
36697 switch (this._type) {
36698 case MemoNone:
36699 break;
36700 case MemoID:
36701 Memo._validateIdValue(value);
36702 break;
36703 case MemoText:
36704 Memo._validateTextValue(value);
36705 break;
36706 case MemoHash:
36707 case MemoReturn:
36708 Memo._validateHashValue(value);
36709 // We want MemoHash and MemoReturn to have Buffer as a value
36710 if (isString(value)) {
36711 this._value = Buffer.from(value, "hex");
36712 }
36713 break;
36714 default:
36715 throw new Error("Invalid memo type");
36716 }
36717 }
36718
36719 _createClass(Memo, {
36720 type: {
36721
36722 /**
36723 * Contains memo type: `MemoNone`, `MemoID`, `MemoText`, `MemoHash` or `MemoReturn`
36724 */
36725
36726 get: function () {
36727 return clone(this._type);
36728 },
36729 set: function (type) {
36730 throw new Error("Memo is immutable");
36731 }
36732 },
36733 value: {
36734
36735 /**
36736 * Contains memo value:
36737 * * `null` for `MemoNone`,
36738 * * `string` for `MemoID`,
36739 * * `Buffer` for `MemoText` after decoding using `fromXDRObject`, original value otherwise,
36740 * * `Buffer` for `MemoHash`, `MemoReturn`.
36741 */
36742
36743 get: function () {
36744 switch (this._type) {
36745 case MemoNone:
36746 return null;
36747 case MemoID:
36748 case MemoText:
36749 return clone(this._value);
36750 case MemoHash:
36751 case MemoReturn:
36752 return Buffer.from(this._value);
36753 default:
36754 throw new Error("Invalid memo type");
36755 }
36756 },
36757 set: function (value) {
36758 throw new Error("Memo is immutable");
36759 }
36760 },
36761 toXDRObject: {
36762
36763 /**
36764 * Returns XDR memo object.
36765 * @returns {xdr.Memo}
36766 */
36767
36768 value: function toXDRObject() {
36769 switch (this._type) {
36770 case MemoNone:
36771 return xdr.Memo.memoNone();
36772 case MemoID:
36773 return xdr.Memo.memoId(UnsignedHyper.fromString(this._value));
36774 case MemoText:
36775 return xdr.Memo.memoText(this._value);
36776 case MemoHash:
36777 return xdr.Memo.memoHash(this._value);
36778 case MemoReturn:
36779 return xdr.Memo.memoReturn(this._value);
36780 }
36781 }
36782 }
36783 }, {
36784 _validateIdValue: {
36785 value: function _validateIdValue(value) {
36786 var error = new Error("Expects a int64 as a string. Got " + value);
36787
36788 if (!isString(value)) {
36789 throw error;
36790 }
36791
36792 var number = undefined;
36793 try {
36794 number = new BigNumber(value);
36795 } catch (e) {
36796 throw error;
36797 }
36798
36799 // Infinity
36800 if (!number.isFinite()) {
36801 throw error;
36802 }
36803
36804 // NaN
36805 if (number.isNaN()) {
36806 throw error;
36807 }
36808 }
36809 },
36810 _validateTextValue: {
36811 value: function _validateTextValue(value) {
36812 if (!xdr.Memo.armTypeForArm("text").isValid(value)) {
36813 throw new Error("Expects string, array or buffer, max 28 bytes");
36814 }
36815 }
36816 },
36817 _validateHashValue: {
36818 value: function _validateHashValue(value) {
36819 var error = new Error("Expects a 32 byte hash value or hex encoded string. Got " + value);
36820
36821 if (value === null || isUndefined(value)) {
36822 throw error;
36823 }
36824
36825 var valueBuffer = undefined;
36826 if (isString(value)) {
36827 if (!/^[0-9A-Fa-f]{64}$/g.test(value)) {
36828 throw error;
36829 }
36830 valueBuffer = Buffer.from(value, "hex");
36831 } else if (Buffer.isBuffer(value)) {
36832 valueBuffer = Buffer.from(value);
36833 } else {
36834 throw error;
36835 }
36836
36837 if (!valueBuffer.length || valueBuffer.length != 32) {
36838 throw error;
36839 }
36840 }
36841 },
36842 none: {
36843
36844 /**
36845 * Returns an empty memo (`MemoNone`).
36846 * @returns {Memo}
36847 */
36848
36849 value: function none() {
36850 return new Memo(MemoNone);
36851 }
36852 },
36853 text: {
36854
36855 /**
36856 * Creates and returns a `MemoText` memo.
36857 * @param {string} text - memo text
36858 * @returns {Memo}
36859 */
36860
36861 value: (function (_text) {
36862 var _textWrapper = function text(_x) {
36863 return _text.apply(this, arguments);
36864 };
36865
36866 _textWrapper.toString = function () {
36867 return _text.toString();
36868 };
36869
36870 return _textWrapper;
36871 })(function (text) {
36872 return new Memo(MemoText, text);
36873 })
36874 },
36875 id: {
36876
36877 /**
36878 * Creates and returns a `MemoID` memo.
36879 * @param {string} id - 64-bit number represented as a string
36880 * @returns {Memo}
36881 */
36882
36883 value: (function (_id) {
36884 var _idWrapper = function id(_x2) {
36885 return _id.apply(this, arguments);
36886 };
36887
36888 _idWrapper.toString = function () {
36889 return _id.toString();
36890 };
36891
36892 return _idWrapper;
36893 })(function (id) {
36894 return new Memo(MemoID, id);
36895 })
36896 },
36897 hash: {
36898
36899 /**
36900 * Creates and returns a `MemoHash` memo.
36901 * @param {array|string} hash - 32 byte hash or hex encoded string
36902 * @returns {Memo}
36903 */
36904
36905 value: (function (_hash) {
36906 var _hashWrapper = function hash(_x3) {
36907 return _hash.apply(this, arguments);
36908 };
36909
36910 _hashWrapper.toString = function () {
36911 return _hash.toString();
36912 };
36913
36914 return _hashWrapper;
36915 })(function (hash) {
36916 return new Memo(MemoHash, hash);
36917 })
36918 },
36919 "return": {
36920
36921 /**
36922 * Creates and returns a `MemoReturn` memo.
36923 * @param {array|string} hash - 32 byte hash or hex encoded string
36924 * @returns {Memo}
36925 */
36926
36927 value: function _return(hash) {
36928 return new Memo(MemoReturn, hash);
36929 }
36930 },
36931 fromXDRObject: {
36932
36933 /**
36934 * Returns {@link Memo} from XDR memo object.
36935 * @param {xdr.Memo}
36936 * @returns {Memo}
36937 */
36938
36939 value: function fromXDRObject(object) {
36940 switch (object.arm()) {
36941 case "id":
36942 return Memo.id(object.value().toString());
36943 case "text":
36944 return Memo.text(object.value());
36945 case "hash":
36946 return Memo.hash(object.value());
36947 case "retHash":
36948 return Memo["return"](object.value());
36949 }
36950
36951 if (typeof object.value() === "undefined") {
36952 return Memo.none();
36953 }
36954
36955 throw new Error("Unknown type");
36956 }
36957 }
36958 });
36959
36960 return Memo;
36961})();
36962}).call(this,require("buffer").Buffer)
36963},{"./generated/stellar-xdr_generated":410,"bignumber.js":17,"buffer":50,"js-xdr":131,"lodash/clone":310,"lodash/isNull":331,"lodash/isString":337,"lodash/isUndefined":340}],415:[function(require,module,exports){
36964"use strict";
36965
36966var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
36967
36968var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
36969
36970Object.defineProperty(exports, "__esModule", {
36971 value: true
36972});
36973
36974var hash = require("./hashing").hash;
36975
36976/**
36977 * Contains passphrases for common networks:
36978 * * `Networks.PUBLIC`: `Public Global Stellar Network ; September 2015`
36979 * * `Networks.TESTNET`: `Test SDF Network ; September 2015`
36980 * @type {{PUBLIC: string, TESTNET: string}}
36981 */
36982var Networks = {
36983 PUBLIC: "Public Global Stellar Network ; September 2015",
36984 TESTNET: "Test SDF Network ; September 2015"
36985};
36986
36987exports.Networks = Networks;
36988var current = null;
36989
36990/**
36991 * The Network class provides helper methods to get the passphrase or id for different
36992 * stellar networks. It also provides the {@link Network.current} class method that returns the network
36993 * that will be used by this process for the purposes of generating signatures.
36994 *
36995 * You should select network your app will use before adding the first signature. You can use the `use`,
36996 * `usePublicNetwork` and `useTestNetwork` helper methods.
36997 *
36998 * Creates a new `Network` object.
36999 * @constructor
37000 * @param {string} networkPassphrase Network passphrase
37001 */
37002
37003var Network = exports.Network = (function () {
37004 function Network(networkPassphrase) {
37005 _classCallCheck(this, Network);
37006
37007 this._networkPassphrase = networkPassphrase;
37008 }
37009
37010 _createClass(Network, {
37011 networkPassphrase: {
37012
37013 /**
37014 * Returns network passphrase.
37015 * @returns {string}
37016 */
37017
37018 value: function networkPassphrase() {
37019 return this._networkPassphrase;
37020 }
37021 },
37022 networkId: {
37023
37024 /**
37025 * Returns Network ID. Network ID is SHA-256 hash of network passphrase.
37026 * @returns {string}
37027 */
37028
37029 value: function networkId() {
37030 return hash(this.networkPassphrase());
37031 }
37032 }
37033 }, {
37034 usePublicNetwork: {
37035
37036 /**
37037 * Use Stellar Public Network
37038 */
37039
37040 value: function usePublicNetwork() {
37041 this.use(new Network(Networks.PUBLIC));
37042 }
37043 },
37044 useTestNetwork: {
37045
37046 /**
37047 * Use test network.
37048 */
37049
37050 value: function useTestNetwork() {
37051 this.use(new Network(Networks.TESTNET));
37052 }
37053 },
37054 use: {
37055
37056 /**
37057 * Use network defined by Network object.
37058 * @param {Network} network Network to use
37059 */
37060
37061 value: function use(network) {
37062 current = network;
37063 }
37064 },
37065 current: {
37066
37067 /**
37068 * Returns currently selected network.
37069 * @returns {Network}
37070 */
37071
37072 value: (function (_current) {
37073 var _currentWrapper = function current() {
37074 return _current.apply(this, arguments);
37075 };
37076
37077 _currentWrapper.toString = function () {
37078 return _current.toString();
37079 };
37080
37081 return _currentWrapper;
37082 })(function () {
37083 return current;
37084 })
37085 }
37086 });
37087
37088 return Network;
37089})();
37090},{"./hashing":411}],416:[function(require,module,exports){
37091"use strict";
37092
37093var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { "default": obj }; };
37094
37095var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
37096
37097var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
37098
37099var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
37100
37101Object.defineProperty(exports, "__esModule", {
37102 value: true
37103});
37104
37105var xdr = _interopRequire(require("./generated/stellar-xdr_generated"));
37106
37107var Keypair = require("./keypair").Keypair;
37108
37109var hash = require("./hashing").hash;
37110
37111var StrKey = require("./strkey").StrKey;
37112
37113var Hyper = require("js-xdr").Hyper;
37114
37115var Asset = require("./asset").Asset;
37116
37117var BigNumber = _interopRequire(require("bignumber.js"));
37118
37119var best_r = require("./util/continued_fraction").best_r;
37120
37121var trimEnd = _interopRequire(require("lodash/trimEnd"));
37122
37123var isUndefined = _interopRequire(require("lodash/isUndefined"));
37124
37125var isString = _interopRequire(require("lodash/isString"));
37126
37127var isNumber = _interopRequire(require("lodash/isNumber"));
37128
37129var isFinite = _interopRequire(require("lodash/isFinite"));
37130
37131var ops = _interopRequireWildcard(require("./operations/index"));
37132
37133var ONE = 10000000;
37134var MAX_INT64 = "9223372036854775807";
37135
37136/**
37137 * When set using `{@link Operation.setOptions}` option, requires the issuing account to
37138 * give other accounts permission before they can hold the issuing account’s credit.
37139 * @constant
37140 * @see [Account flags](https://www.stellar.org/developers/guides/concepts/accounts.html#flags)
37141 */
37142var AuthRequiredFlag = 1 << 0;
37143exports.AuthRequiredFlag = AuthRequiredFlag;
37144/**
37145 * When set using `{@link Operation.setOptions}` option, allows the issuing account to
37146 * revoke its credit held by other accounts.
37147 * @constant
37148 * @see [Account flags](https://www.stellar.org/developers/guides/concepts/accounts.html#flags)
37149 */
37150var AuthRevocableFlag = 1 << 1;
37151exports.AuthRevocableFlag = AuthRevocableFlag;
37152/**
37153 * When set using `{@link Operation.setOptions}` option, then none of the authorization flags
37154 * can be set and the account can never be deleted.
37155 * @constant
37156 * @see [Account flags](https://www.stellar.org/developers/guides/concepts/accounts.html#flags)
37157 */
37158var AuthImmutableFlag = 1 << 2;
37159
37160exports.AuthImmutableFlag = AuthImmutableFlag;
37161/**
37162 * `Operation` class represents [operations](https://www.stellar.org/developers/learn/concepts/operations.html) in Stellar network.
37163 * Use one of static methods to create operations:
37164 * * `{@link Operation.createAccount}`
37165 * * `{@link Operation.payment}`
37166 * * `{@link Operation.pathPayment}`
37167 * * `{@link Operation.manageOffer}`
37168 * * `{@link Operation.createPassiveOffer}`
37169 * * `{@link Operation.setOptions}`
37170 * * `{@link Operation.changeTrust}`
37171 * * `{@link Operation.allowTrust}`
37172 * * `{@link Operation.accountMerge}`
37173 * * `{@link Operation.inflation}`
37174 * * `{@link Operation.manageData}`
37175 * * `{@link Operation.bumpSequence}`
37176 *
37177 * @class Operation
37178 */
37179
37180var Operation = exports.Operation = (function () {
37181 function Operation() {
37182 _classCallCheck(this, Operation);
37183 }
37184
37185 _createClass(Operation, null, {
37186 setSourceAccount: {
37187 value: function setSourceAccount(opAttributes, opts) {
37188 if (opts.source) {
37189 if (!StrKey.isValidEd25519PublicKey(opts.source)) {
37190 throw new Error("Source address is invalid");
37191 }
37192 opAttributes.sourceAccount = Keypair.fromPublicKey(opts.source).xdrAccountId();
37193 }
37194 }
37195 },
37196 fromXDRObject: {
37197
37198 /**
37199 * Converts the XDR Operation object to the opts object used to create the XDR
37200 * operation.
37201 * @param {xdr.Operation} operation - An XDR Operation.
37202 * @return {Operation}
37203 */
37204
37205 value: function fromXDRObject(operation) {
37206 function accountIdtoAddress(accountId) {
37207 return StrKey.encodeEd25519PublicKey(accountId.ed25519());
37208 }
37209
37210 var result = {};
37211 if (operation.sourceAccount()) {
37212 result.source = accountIdtoAddress(operation.sourceAccount());
37213 }
37214
37215 var attrs = operation.body().value();
37216 switch (operation.body()["switch"]().name) {
37217 case "createAccount":
37218 result.type = "createAccount";
37219 result.destination = accountIdtoAddress(attrs.destination());
37220 result.startingBalance = this._fromXDRAmount(attrs.startingBalance());
37221 break;
37222 case "payment":
37223 result.type = "payment";
37224 result.destination = accountIdtoAddress(attrs.destination());
37225 result.asset = Asset.fromOperation(attrs.asset());
37226 result.amount = this._fromXDRAmount(attrs.amount());
37227 break;
37228 case "pathPayment":
37229 result.type = "pathPayment";
37230 result.sendAsset = Asset.fromOperation(attrs.sendAsset());
37231 result.sendMax = this._fromXDRAmount(attrs.sendMax());
37232 result.destination = accountIdtoAddress(attrs.destination());
37233 result.destAsset = Asset.fromOperation(attrs.destAsset());
37234 result.destAmount = this._fromXDRAmount(attrs.destAmount());
37235 var path = attrs.path();
37236 result.path = [];
37237 for (var i in path) {
37238 result.path.push(Asset.fromOperation(path[i]));
37239 }
37240 break;
37241 case "changeTrust":
37242 result.type = "changeTrust";
37243 result.line = Asset.fromOperation(attrs.line());
37244 result.limit = this._fromXDRAmount(attrs.limit());
37245 break;
37246 case "allowTrust":
37247 result.type = "allowTrust";
37248 result.trustor = accountIdtoAddress(attrs.trustor());
37249 result.assetCode = attrs.asset().value().toString();
37250 result.assetCode = trimEnd(result.assetCode, "\u0000");
37251 result.authorize = attrs.authorize();
37252 break;
37253 case "setOption":
37254 result.type = "setOptions";
37255 if (attrs.inflationDest()) {
37256 result.inflationDest = accountIdtoAddress(attrs.inflationDest());
37257 }
37258
37259 result.clearFlags = attrs.clearFlags();
37260 result.setFlags = attrs.setFlags();
37261 result.masterWeight = attrs.masterWeight();
37262 result.lowThreshold = attrs.lowThreshold();
37263 result.medThreshold = attrs.medThreshold();
37264 result.highThreshold = attrs.highThreshold();
37265 // home_domain is checked by iscntrl in stellar-core
37266 result.homeDomain = attrs.homeDomain() !== undefined ? attrs.homeDomain().toString("ascii") : undefined;
37267
37268 if (attrs.signer()) {
37269 var signer = {};
37270 var arm = attrs.signer().key().arm();
37271 if (arm == "ed25519") {
37272 signer.ed25519PublicKey = accountIdtoAddress(attrs.signer().key());
37273 } else if (arm == "preAuthTx") {
37274 signer.preAuthTx = attrs.signer().key().preAuthTx();
37275 } else if (arm == "hashX") {
37276 signer.sha256Hash = attrs.signer().key().hashX();
37277 }
37278
37279 signer.weight = attrs.signer().weight();
37280 result.signer = signer;
37281 }
37282 break;
37283 case "manageOffer":
37284 result.type = "manageOffer";
37285 result.selling = Asset.fromOperation(attrs.selling());
37286 result.buying = Asset.fromOperation(attrs.buying());
37287 result.amount = this._fromXDRAmount(attrs.amount());
37288 result.price = this._fromXDRPrice(attrs.price());
37289 result.offerId = attrs.offerId().toString();
37290 break;
37291 case "createPassiveOffer":
37292 result.type = "createPassiveOffer";
37293 result.selling = Asset.fromOperation(attrs.selling());
37294 result.buying = Asset.fromOperation(attrs.buying());
37295 result.amount = this._fromXDRAmount(attrs.amount());
37296 result.price = this._fromXDRPrice(attrs.price());
37297 break;
37298 case "accountMerge":
37299 result.type = "accountMerge";
37300 result.destination = accountIdtoAddress(attrs);
37301 break;
37302 case "manageDatum":
37303 result.type = "manageData";
37304 // manage_data.name is checked by iscntrl in stellar-core
37305 result.name = attrs.dataName().toString("ascii");
37306 result.value = attrs.dataValue();
37307 break;
37308 case "inflation":
37309 result.type = "inflation";
37310 break;
37311 case "bumpSequence":
37312 result.type = "bumpSequence";
37313 result.bumpTo = attrs.bumpTo().toString();
37314 break;
37315 default:
37316 throw new Error("Unknown operation");
37317 }
37318 return result;
37319 }
37320 },
37321 isValidAmount: {
37322 value: function isValidAmount(value) {
37323 var allowZero = arguments[1] === undefined ? false : arguments[1];
37324
37325 if (!isString(value)) {
37326 return false;
37327 }
37328
37329 var amount = undefined;
37330 try {
37331 amount = new BigNumber(value);
37332 } catch (e) {
37333 return false;
37334 }
37335
37336 switch (true) {
37337 // == 0
37338 case !allowZero && amount.isZero():
37339 // < 0
37340 case amount.isNegative():
37341 // > Max value
37342 case amount.times(ONE).greaterThan(new BigNumber(MAX_INT64).toString()):
37343 // Decimal places (max 7)
37344 case amount.decimalPlaces() > 7:
37345 // NaN or Infinity
37346 case amount.isNaN() || !amount.isFinite():
37347 return false;
37348 default:
37349 return true;
37350 }
37351 }
37352 },
37353 constructAmountRequirementsError: {
37354 value: function constructAmountRequirementsError(arg) {
37355 return "" + arg + " argument must be of type String, represent a positive number and have at most 7 digits after the decimal";
37356 }
37357 },
37358 _checkUnsignedIntValue: {
37359
37360 /**
37361 * Returns value converted to uint32 value or undefined.
37362 * If `value` is not `Number`, `String` or `Undefined` then throws an error.
37363 * Used in {@link Operation.setOptions}.
37364 * @private
37365 * @param {string} name Name of the property (used in error message only)
37366 * @param {*} value Value to check
37367 * @param {function(value, name)} isValidFunction Function to check other constraints (the argument will be a `Number`)
37368 * @returns {undefined|Number}
37369 * @private
37370 */
37371
37372 value: function _checkUnsignedIntValue(name, value) {
37373 var isValidFunction = arguments[2] === undefined ? null : arguments[2];
37374
37375 if (isUndefined(value)) {
37376 return undefined;
37377 }
37378
37379 if (isString(value)) {
37380 value = parseFloat(value);
37381 }
37382
37383 switch (true) {
37384 case !isNumber(value) || !isFinite(value) || value % 1 !== 0:
37385 throw new Error("" + name + " value is invalid");
37386 case value < 0:
37387 throw new Error("" + name + " value must be unsigned");
37388 case !isValidFunction || isValidFunction && isValidFunction(value, name):
37389 return value;
37390 default:
37391 throw new Error("" + name + " value is invalid");
37392 }
37393 }
37394 },
37395 _toXDRAmount: {
37396
37397 /**
37398 * @private
37399 */
37400
37401 value: function _toXDRAmount(value) {
37402 var amount = new BigNumber(value).mul(ONE);
37403 return Hyper.fromString(amount.toString());
37404 }
37405 },
37406 _fromXDRAmount: {
37407
37408 /**
37409 * @private
37410 */
37411
37412 value: function _fromXDRAmount(value) {
37413 return new BigNumber(value).div(ONE).toString();
37414 }
37415 },
37416 _fromXDRPrice: {
37417
37418 /**
37419 * @private
37420 */
37421
37422 value: function _fromXDRPrice(price) {
37423 var n = new BigNumber(price.n());
37424 return n.div(new BigNumber(price.d())).toString();
37425 }
37426 },
37427 _toXDRPrice: {
37428
37429 /**
37430 * @private
37431 */
37432
37433 value: function _toXDRPrice(price) {
37434 var xdrObject = undefined;
37435 if (price.n && price.d) {
37436 xdrObject = new xdr.Price(price);
37437 } else {
37438 price = new BigNumber(price);
37439 var approx = best_r(price);
37440 xdrObject = new xdr.Price({
37441 n: parseInt(approx[0]),
37442 d: parseInt(approx[1])
37443 });
37444 }
37445
37446 if (xdrObject.n() < 0 || xdrObject.d() < 0) {
37447 throw new Error("price must be positive");
37448 }
37449
37450 return xdrObject;
37451 }
37452 }
37453 });
37454
37455 return Operation;
37456})();
37457
37458// Attach all imported operations as static methods on the Operation class
37459Operation.accountMerge = ops.accountMerge;
37460Operation.allowTrust = ops.allowTrust;
37461Operation.bumpSequence = ops.bumpSequence;
37462Operation.changeTrust = ops.changeTrust;
37463Operation.createAccount = ops.createAccount;
37464Operation.createPassiveOffer = ops.createPassiveOffer;
37465Operation.inflation = ops.inflation;
37466Operation.manageData = ops.manageData;
37467Operation.manageOffer = ops.manageOffer;
37468Operation.pathPayment = ops.pathPayment;
37469Operation.payment = ops.payment;
37470Operation.setOptions = ops.setOptions;
37471},{"./asset":408,"./generated/stellar-xdr_generated":410,"./hashing":411,"./keypair":413,"./operations/index":423,"./strkey":431,"./util/continued_fraction":435,"bignumber.js":17,"js-xdr":131,"lodash/isFinite":327,"lodash/isNumber":332,"lodash/isString":337,"lodash/isUndefined":340,"lodash/trimEnd":355}],417:[function(require,module,exports){
37472"use strict";
37473
37474var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
37475
37476Object.defineProperty(exports, "__esModule", {
37477 value: true
37478});
37479
37480var xdr = _interopRequire(require("../generated/stellar-xdr_generated"));
37481
37482var Keypair = require("../keypair").Keypair;
37483
37484var StrKey = require("../strkey").StrKey;
37485
37486/**
37487 * Transfers native balance to destination account.
37488 * @function
37489 * @alias Operation.accountMerge
37490 * @param {object} opts
37491 * @param {string} opts.destination - Destination to merge the source account into.
37492 * @param {string} [opts.source] - The source account (defaults to transaction source).
37493 * @returns {xdr.AccountMergeOp}
37494 */
37495var accountMerge = function accountMerge(opts) {
37496 var opAttributes = {};
37497 if (!StrKey.isValidEd25519PublicKey(opts.destination)) {
37498 throw new Error("destination is invalid");
37499 }
37500 opAttributes.body = xdr.OperationBody.accountMerge(Keypair.fromPublicKey(opts.destination).xdrAccountId());
37501 this.setSourceAccount(opAttributes, opts);
37502
37503 return new xdr.Operation(opAttributes);
37504};
37505exports.accountMerge = accountMerge;
37506},{"../generated/stellar-xdr_generated":410,"../keypair":413,"../strkey":431}],418:[function(require,module,exports){
37507"use strict";
37508
37509var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
37510
37511Object.defineProperty(exports, "__esModule", {
37512 value: true
37513});
37514
37515var xdr = _interopRequire(require("../generated/stellar-xdr_generated"));
37516
37517var Keypair = require("../keypair").Keypair;
37518
37519var StrKey = require("../strkey").StrKey;
37520
37521var padEnd = _interopRequire(require("lodash/padEnd"));
37522
37523/**
37524 * Returns an XDR AllowTrustOp. An "allow trust" operation authorizes another
37525 * account to hold your account's credit for a given asset.
37526 * @function
37527 * @alias Operation.allowTrust
37528 * @param {object} opts
37529 * @param {string} opts.trustor - The trusting account (the one being authorized)
37530 * @param {string} opts.assetCode - The asset code being authorized.
37531 * @param {boolean} opts.authorize - True to authorize the line, false to deauthorize.
37532 * @param {string} [opts.source] - The source account (defaults to transaction source).
37533 * @returns {xdr.AllowTrustOp}
37534 */
37535var allowTrust = function allowTrust(opts) {
37536 if (!StrKey.isValidEd25519PublicKey(opts.trustor)) {
37537 throw new Error("trustor is invalid");
37538 }
37539 var attributes = {};
37540 attributes.trustor = Keypair.fromPublicKey(opts.trustor).xdrAccountId();
37541 if (opts.assetCode.length <= 4) {
37542 var code = padEnd(opts.assetCode, 4, "\u0000");
37543 attributes.asset = xdr.AllowTrustOpAsset.assetTypeCreditAlphanum4(code);
37544 } else if (opts.assetCode.length <= 12) {
37545 var code = padEnd(opts.assetCode, 12, "\u0000");
37546 attributes.asset = xdr.AllowTrustOpAsset.assetTypeCreditAlphanum12(code);
37547 } else {
37548 throw new Error("Asset code must be 12 characters at max.");
37549 }
37550 attributes.authorize = opts.authorize;
37551 var allowTrustOp = new xdr.AllowTrustOp(attributes);
37552
37553 var opAttributes = {};
37554 opAttributes.body = xdr.OperationBody.allowTrust(allowTrustOp);
37555 this.setSourceAccount(opAttributes, opts);
37556
37557 return new xdr.Operation(opAttributes);
37558};
37559exports.allowTrust = allowTrust;
37560},{"../generated/stellar-xdr_generated":410,"../keypair":413,"../strkey":431,"lodash/padEnd":345}],419:[function(require,module,exports){
37561"use strict";
37562
37563var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
37564
37565Object.defineProperty(exports, "__esModule", {
37566 value: true
37567});
37568
37569var xdr = _interopRequire(require("../generated/stellar-xdr_generated"));
37570
37571var Hyper = require("js-xdr").Hyper;
37572
37573var BigNumber = _interopRequire(require("bignumber.js"));
37574
37575var isString = _interopRequire(require("lodash/isString"));
37576
37577/**
37578 * This operation bumps sequence number.
37579 * @function
37580 * @alias Operation.bumpSequence
37581 * @param {object} opts
37582 * @param {string} opts.bumpTo - Sequence number to bump to.
37583 * @param {string} [opts.source] - The optional source account.
37584 * @returns {xdr.BumpSequenceOp}
37585 */
37586var bumpSequence = function bumpSequence(opts) {
37587 var attributes = {};
37588
37589 if (!isString(opts.bumpTo)) {
37590 throw new Error("bumpTo must be a string");
37591 }
37592
37593 try {
37594 new BigNumber(opts.bumpTo);
37595 } catch (e) {
37596 throw new Error("bumpTo must be a stringified number");
37597 }
37598
37599 attributes.bumpTo = Hyper.fromString(opts.bumpTo);
37600
37601 var bumpSequenceOp = new xdr.BumpSequenceOp(attributes);
37602
37603 var opAttributes = {};
37604 opAttributes.body = xdr.OperationBody.bumpSequence(bumpSequenceOp);
37605 this.setSourceAccount(opAttributes, opts);
37606
37607 return new xdr.Operation(opAttributes);
37608};
37609exports.bumpSequence = bumpSequence;
37610},{"../generated/stellar-xdr_generated":410,"bignumber.js":17,"js-xdr":131,"lodash/isString":337}],420:[function(require,module,exports){
37611"use strict";
37612
37613var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
37614
37615Object.defineProperty(exports, "__esModule", {
37616 value: true
37617});
37618
37619var xdr = _interopRequire(require("../generated/stellar-xdr_generated"));
37620
37621var Keypair = require("../keypair").Keypair;
37622
37623var isUndefined = _interopRequire(require("lodash/isUndefined"));
37624
37625var Hyper = require("js-xdr").Hyper;
37626
37627var BigNumber = _interopRequire(require("bignumber.js"));
37628
37629var MAX_INT64 = "9223372036854775807";
37630
37631/**
37632 * Returns an XDR ChangeTrustOp. A "change trust" operation adds, removes, or updates a
37633 * trust line for a given asset from the source account to another. The issuer being
37634 * trusted and the asset code are in the given Asset object.
37635 * @function
37636 * @alias Operation.changeTrust
37637 * @param {object} opts
37638 * @param {Asset} opts.asset - The asset for the trust line.
37639 * @param {string} [opts.limit] - The limit for the asset, defaults to max int64.
37640 * If the limit is set to "0" it deletes the trustline.
37641 * @param {string} [opts.source] - The source account (defaults to transaction source).
37642 * @returns {xdr.ChangeTrustOp}
37643 */
37644var changeTrust = function changeTrust(opts) {
37645 var attributes = {};
37646 attributes.line = opts.asset.toXDRObject();
37647 if (!isUndefined(opts.limit) && !this.isValidAmount(opts.limit, true)) {
37648 throw new TypeError(this.constructAmountRequirementsError("limit"));
37649 }
37650
37651 if (opts.limit) {
37652 attributes.limit = this._toXDRAmount(opts.limit);
37653 } else {
37654 attributes.limit = Hyper.fromString(new BigNumber(MAX_INT64).toString());
37655 }
37656
37657 if (opts.source) {
37658 attributes.source = opts.source.masterKeypair;
37659 }
37660 var changeTrustOP = new xdr.ChangeTrustOp(attributes);
37661
37662 var opAttributes = {};
37663 opAttributes.body = xdr.OperationBody.changeTrust(changeTrustOP);
37664 this.setSourceAccount(opAttributes, opts);
37665
37666 return new xdr.Operation(opAttributes);
37667};
37668exports.changeTrust = changeTrust;
37669},{"../generated/stellar-xdr_generated":410,"../keypair":413,"bignumber.js":17,"js-xdr":131,"lodash/isUndefined":340}],421:[function(require,module,exports){
37670"use strict";
37671
37672var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
37673
37674Object.defineProperty(exports, "__esModule", {
37675 value: true
37676});
37677
37678var xdr = _interopRequire(require("../generated/stellar-xdr_generated"));
37679
37680var Keypair = require("../keypair").Keypair;
37681
37682var StrKey = require("../strkey").StrKey;
37683
37684/**
37685 * Create and fund a non existent account.
37686 * @function
37687 * @alias Operation.createAccount
37688 * @param {object} opts
37689 * @param {string} opts.destination - Destination account ID to create an account for.
37690 * @param {string} opts.startingBalance - Amount in XLM the account should be funded for. Must be greater
37691 * than the [reserve balance amount](https://www.stellar.org/developers/learn/concepts/fees.html).
37692 * @param {string} [opts.source] - The source account for the payment. Defaults to the transaction's source account.
37693 * @returns {xdr.CreateAccountOp}
37694 */
37695var createAccount = (function (_createAccount) {
37696 var _createAccountWrapper = function createAccount(_x) {
37697 return _createAccount.apply(this, arguments);
37698 };
37699
37700 _createAccountWrapper.toString = function () {
37701 return _createAccount.toString();
37702 };
37703
37704 return _createAccountWrapper;
37705})(function (opts) {
37706 if (!StrKey.isValidEd25519PublicKey(opts.destination)) {
37707 throw new Error("destination is invalid");
37708 }
37709 if (!this.isValidAmount(opts.startingBalance)) {
37710 throw new TypeError(this.constructAmountRequirementsError("startingBalance"));
37711 }
37712 var attributes = {};
37713 attributes.destination = Keypair.fromPublicKey(opts.destination).xdrAccountId();
37714 attributes.startingBalance = this._toXDRAmount(opts.startingBalance);
37715 var createAccount = new xdr.CreateAccountOp(attributes);
37716
37717 var opAttributes = {};
37718 opAttributes.body = xdr.OperationBody.createAccount(createAccount);
37719 this.setSourceAccount(opAttributes, opts);
37720
37721 return new xdr.Operation(opAttributes);
37722});
37723exports.createAccount = createAccount;
37724},{"../generated/stellar-xdr_generated":410,"../keypair":413,"../strkey":431}],422:[function(require,module,exports){
37725"use strict";
37726
37727var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
37728
37729Object.defineProperty(exports, "__esModule", {
37730 value: true
37731});
37732
37733var xdr = _interopRequire(require("../generated/stellar-xdr_generated"));
37734
37735var isUndefined = _interopRequire(require("lodash/isUndefined"));
37736
37737/**
37738 * Returns a XDR CreatePasiveOfferOp. A "create passive offer" operation creates an
37739 * offer that won't consume a counter offer that exactly matches this offer. This is
37740 * useful for offers just used as 1:1 exchanges for path payments. Use manage offer
37741 * to manage this offer after using this operation to create it.
37742 * @function
37743 * @alias Operation.createPassiveOffer
37744 * @param {object} opts
37745 * @param {Asset} opts.selling - What you're selling.
37746 * @param {Asset} opts.buying - What you're buying.
37747 * @param {string} opts.amount - The total amount you're selling. If 0, deletes the offer.
37748 * @param {number|string|BigNumber|Object} opts.price - Price of 1 unit of `selling` in terms of `buying`.
37749 * @param {number} opts.price.n - If `opts.price` is an object: the price numerator
37750 * @param {number} opts.price.d - If `opts.price` is an object: the price denominator
37751 * @param {string} [opts.source] - The source account (defaults to transaction source).
37752 * @throws {Error} Throws `Error` when the best rational approximation of `price` cannot be found.
37753 * @returns {xdr.CreatePassiveOfferOp}
37754 */
37755var createPassiveOffer = function createPassiveOffer(opts) {
37756 var attributes = {};
37757 attributes.selling = opts.selling.toXDRObject();
37758 attributes.buying = opts.buying.toXDRObject();
37759 if (!this.isValidAmount(opts.amount)) {
37760 throw new TypeError(this.constructAmountRequirementsError("amount"));
37761 }
37762 attributes.amount = this._toXDRAmount(opts.amount);
37763 if (isUndefined(opts.price)) {
37764 throw new TypeError("price argument is required");
37765 }
37766 attributes.price = this._toXDRPrice(opts.price);
37767 var createPassiveOfferOp = new xdr.CreatePassiveOfferOp(attributes);
37768
37769 var opAttributes = {};
37770 opAttributes.body = xdr.OperationBody.createPassiveOffer(createPassiveOfferOp);
37771 this.setSourceAccount(opAttributes, opts);
37772
37773 return new xdr.Operation(opAttributes);
37774};
37775exports.createPassiveOffer = createPassiveOffer;
37776},{"../generated/stellar-xdr_generated":410,"lodash/isUndefined":340}],423:[function(require,module,exports){
37777"use strict";
37778
37779Object.defineProperty(exports, "__esModule", {
37780 value: true
37781});
37782exports.accountMerge = require("./account_merge").accountMerge;
37783exports.allowTrust = require("./allow_trust").allowTrust;
37784exports.bumpSequence = require("./bump_sequence").bumpSequence;
37785exports.changeTrust = require("./change_trust").changeTrust;
37786exports.createAccount = require("./create_account").createAccount;
37787exports.createPassiveOffer = require("./create_passive_offer").createPassiveOffer;
37788exports.inflation = require("./inflation").inflation;
37789exports.manageData = require("./manage_data").manageData;
37790exports.manageOffer = require("./manage_offer").manageOffer;
37791exports.pathPayment = require("./path_payment").pathPayment;
37792exports.payment = require("./payment").payment;
37793exports.setOptions = require("./set_options").setOptions;
37794},{"./account_merge":417,"./allow_trust":418,"./bump_sequence":419,"./change_trust":420,"./create_account":421,"./create_passive_offer":422,"./inflation":424,"./manage_data":425,"./manage_offer":426,"./path_payment":427,"./payment":428,"./set_options":429}],424:[function(require,module,exports){
37795"use strict";
37796
37797var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
37798
37799Object.defineProperty(exports, "__esModule", {
37800 value: true
37801});
37802
37803var xdr = _interopRequire(require("../generated/stellar-xdr_generated"));
37804
37805/**
37806 * This operation generates the inflation.
37807 * @function
37808 * @alias Operation.inflation
37809 * @param {object} [opts]
37810 * @param {string} [opts.source] - The optional source account.
37811 * @returns {xdr.InflationOp}
37812 */
37813var inflation = function inflation() {
37814 var opts = arguments[0] === undefined ? {} : arguments[0];
37815
37816 var opAttributes = {};
37817 opAttributes.body = xdr.OperationBody.inflation();
37818 this.setSourceAccount(opAttributes, opts);
37819 return new xdr.Operation(opAttributes);
37820};
37821exports.inflation = inflation;
37822},{"../generated/stellar-xdr_generated":410}],425:[function(require,module,exports){
37823(function (Buffer){
37824"use strict";
37825
37826var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
37827
37828Object.defineProperty(exports, "__esModule", {
37829 value: true
37830});
37831
37832var xdr = _interopRequire(require("../generated/stellar-xdr_generated"));
37833
37834var isString = _interopRequire(require("lodash/isString"));
37835
37836/**
37837 * This operation adds data entry to the ledger.
37838 * @function
37839 * @alias Operation.manageData
37840 * @param {object} opts
37841 * @param {string} opts.name - The name of the data entry.
37842 * @param {string|Buffer} opts.value - The value of the data entry.
37843 * @param {string} [opts.source] - The optional source account.
37844 * @returns {xdr.ManageDataOp}
37845 */
37846var manageData = function manageData(opts) {
37847 var attributes = {};
37848
37849 if (!(isString(opts.name) && opts.name.length <= 64)) {
37850 throw new Error("name must be a string, up to 64 characters");
37851 }
37852 attributes.dataName = opts.name;
37853
37854 if (!isString(opts.value) && !Buffer.isBuffer(opts.value) && opts.value !== null) {
37855 throw new Error("value must be a string, Buffer or null");
37856 }
37857
37858 if (isString(opts.value)) {
37859 attributes.dataValue = Buffer.from(opts.value);
37860 } else {
37861 attributes.dataValue = opts.value;
37862 }
37863
37864 if (attributes.dataValue !== null && attributes.dataValue.length > 64) {
37865 throw new Error("value cannot be longer that 64 bytes");
37866 }
37867
37868 var manageDataOp = new xdr.ManageDataOp(attributes);
37869
37870 var opAttributes = {};
37871 opAttributes.body = xdr.OperationBody.manageDatum(manageDataOp);
37872 this.setSourceAccount(opAttributes, opts);
37873
37874 return new xdr.Operation(opAttributes);
37875};
37876exports.manageData = manageData;
37877}).call(this,require("buffer").Buffer)
37878},{"../generated/stellar-xdr_generated":410,"buffer":50,"lodash/isString":337}],426:[function(require,module,exports){
37879"use strict";
37880
37881var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
37882
37883Object.defineProperty(exports, "__esModule", {
37884 value: true
37885});
37886
37887var xdr = _interopRequire(require("../generated/stellar-xdr_generated"));
37888
37889var isUndefined = _interopRequire(require("lodash/isUndefined"));
37890
37891var UnsignedHyper = require("js-xdr").UnsignedHyper;
37892
37893/**
37894 * Returns a XDR ManageOfferOp. A "manage offer" operation creates, updates, or
37895 * deletes an offer.
37896 * @function
37897 * @alias Operation.manageOffer
37898 * @param {object} opts
37899 * @param {Asset} opts.selling - What you're selling.
37900 * @param {Asset} opts.buying - What you're buying.
37901 * @param {string} opts.amount - The total amount you're selling. If 0, deletes the offer.
37902 * @param {number|string|BigNumber|Object} opts.price - Price of 1 unit of `selling` in terms of `buying`.
37903 * @param {number} opts.price.n - If `opts.price` is an object: the price numerator
37904 * @param {number} opts.price.d - If `opts.price` is an object: the price denominator
37905 * @param {number|string} [opts.offerId ] - If `0`, will create a new offer (default). Otherwise, edits an exisiting offer.
37906 * @param {string} [opts.source] - The source account (defaults to transaction source).
37907 * @throws {Error} Throws `Error` when the best rational approximation of `price` cannot be found.
37908 * @returns {xdr.ManageOfferOp}
37909 */
37910var manageOffer = function manageOffer(opts) {
37911 var attributes = {};
37912 attributes.selling = opts.selling.toXDRObject();
37913 attributes.buying = opts.buying.toXDRObject();
37914 if (!this.isValidAmount(opts.amount, true)) {
37915 throw new TypeError(this.constructAmountRequirementsError("amount"));
37916 }
37917 attributes.amount = this._toXDRAmount(opts.amount);
37918 if (isUndefined(opts.price)) {
37919 throw new TypeError("price argument is required");
37920 }
37921 attributes.price = this._toXDRPrice(opts.price);
37922
37923 if (!isUndefined(opts.offerId)) {
37924 opts.offerId = opts.offerId.toString();
37925 } else {
37926 opts.offerId = "0";
37927 }
37928 attributes.offerId = UnsignedHyper.fromString(opts.offerId);
37929 var manageOfferOp = new xdr.ManageOfferOp(attributes);
37930
37931 var opAttributes = {};
37932 opAttributes.body = xdr.OperationBody.manageOffer(manageOfferOp);
37933 this.setSourceAccount(opAttributes, opts);
37934
37935 return new xdr.Operation(opAttributes);
37936};
37937exports.manageOffer = manageOffer;
37938},{"../generated/stellar-xdr_generated":410,"js-xdr":131,"lodash/isUndefined":340}],427:[function(require,module,exports){
37939"use strict";
37940
37941var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
37942
37943Object.defineProperty(exports, "__esModule", {
37944 value: true
37945});
37946
37947var xdr = _interopRequire(require("../generated/stellar-xdr_generated"));
37948
37949var Keypair = require("../keypair").Keypair;
37950
37951var StrKey = require("../strkey").StrKey;
37952
37953/**
37954 * Returns a XDR PaymentOp. A "payment" operation send the specified amount to the
37955 * destination account, optionally through a path. XLM payments create the destination
37956 * account if it does not exist.
37957 * @function
37958 * @alias Operation.pathPayment
37959 * @param {object} opts
37960 * @param {Asset} opts.sendAsset - The asset to pay with.
37961 * @param {string} opts.sendMax - The maximum amount of sendAsset to send.
37962 * @param {string} opts.destination - The destination account to send to.
37963 * @param {Asset} opts.destAsset - The asset the destination will receive.
37964 * @param {string} opts.destAmount - The amount the destination receives.
37965 * @param {Asset[]} opts.path - An array of Asset objects to use as the path.
37966 * @param {string} [opts.source] - The source account for the payment. Defaults to the transaction's source account.
37967 * @returns {xdr.PathPaymentOp}
37968 */
37969var pathPayment = function pathPayment(opts) {
37970 switch (true) {
37971 case !opts.sendAsset:
37972 throw new Error("Must specify a send asset");
37973 case !this.isValidAmount(opts.sendMax):
37974 throw new TypeError(this.constructAmountRequirementsError("sendMax"));
37975 case !StrKey.isValidEd25519PublicKey(opts.destination):
37976 throw new Error("destination is invalid");
37977 case !opts.destAsset:
37978 throw new Error("Must provide a destAsset for a payment operation");
37979 case !this.isValidAmount(opts.destAmount):
37980 throw new TypeError(this.constructAmountRequirementsError("destAmount"));
37981 }
37982
37983 var attributes = {};
37984 attributes.sendAsset = opts.sendAsset.toXDRObject();
37985 attributes.sendMax = this._toXDRAmount(opts.sendMax);
37986 attributes.destination = Keypair.fromPublicKey(opts.destination).xdrAccountId();
37987 attributes.destAsset = opts.destAsset.toXDRObject();
37988 attributes.destAmount = this._toXDRAmount(opts.destAmount);
37989
37990 var path = opts.path ? opts.path : [];
37991 attributes.path = path.map(function (x) {
37992 return x.toXDRObject();
37993 });
37994
37995 var payment = new xdr.PathPaymentOp(attributes);
37996
37997 var opAttributes = {};
37998 opAttributes.body = xdr.OperationBody.pathPayment(payment);
37999 this.setSourceAccount(opAttributes, opts);
38000
38001 return new xdr.Operation(opAttributes);
38002};
38003exports.pathPayment = pathPayment;
38004},{"../generated/stellar-xdr_generated":410,"../keypair":413,"../strkey":431}],428:[function(require,module,exports){
38005"use strict";
38006
38007var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
38008
38009Object.defineProperty(exports, "__esModule", {
38010 value: true
38011});
38012
38013var xdr = _interopRequire(require("../generated/stellar-xdr_generated"));
38014
38015var Keypair = require("../keypair").Keypair;
38016
38017var StrKey = require("../strkey").StrKey;
38018
38019/**
38020 * Create a payment operation.
38021 * @function
38022 * @alias Operation.payment
38023 * @param {object} opts
38024 * @param {string} opts.destination - The destination account ID.
38025 * @param {Asset} opts.asset - The asset to send.
38026 * @param {string} opts.amount - The amount to send.
38027 * @param {string} [opts.source] - The source account for the payment. Defaults to the transaction's source account.
38028 * @returns {xdr.PaymentOp}
38029 */
38030var payment = (function (_payment) {
38031 var _paymentWrapper = function payment(_x) {
38032 return _payment.apply(this, arguments);
38033 };
38034
38035 _paymentWrapper.toString = function () {
38036 return _payment.toString();
38037 };
38038
38039 return _paymentWrapper;
38040})(function (opts) {
38041 if (!StrKey.isValidEd25519PublicKey(opts.destination)) {
38042 throw new Error("destination is invalid");
38043 }
38044 if (!opts.asset) {
38045 throw new Error("Must provide an asset for a payment operation");
38046 }
38047 if (!this.isValidAmount(opts.amount)) {
38048 throw new TypeError(this.constructAmountRequirementsError("amount"));
38049 }
38050
38051 var attributes = {};
38052 attributes.destination = Keypair.fromPublicKey(opts.destination).xdrAccountId();
38053 attributes.asset = opts.asset.toXDRObject();
38054 attributes.amount = this._toXDRAmount(opts.amount);
38055 var payment = new xdr.PaymentOp(attributes);
38056
38057 var opAttributes = {};
38058 opAttributes.body = xdr.OperationBody.payment(payment);
38059 this.setSourceAccount(opAttributes, opts);
38060
38061 return new xdr.Operation(opAttributes);
38062});
38063exports.payment = payment;
38064},{"../generated/stellar-xdr_generated":410,"../keypair":413,"../strkey":431}],429:[function(require,module,exports){
38065(function (Buffer){
38066"use strict";
38067
38068var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
38069
38070Object.defineProperty(exports, "__esModule", {
38071 value: true
38072});
38073
38074var xdr = _interopRequire(require("../generated/stellar-xdr_generated"));
38075
38076var Keypair = require("../keypair").Keypair;
38077
38078var StrKey = require("../strkey").StrKey;
38079
38080var isUndefined = _interopRequire(require("lodash/isUndefined"));
38081
38082var isString = _interopRequire(require("lodash/isString"));
38083
38084/**
38085 * Returns an XDR SetOptionsOp. A "set options" operations set or clear account flags,
38086 * set the account's inflation destination, and/or add new signers to the account.
38087 * The flags used in `opts.clearFlags` and `opts.setFlags` can be the following:
38088 * - `{@link AuthRequiredFlag}`
38089 * - `{@link AuthRevocableFlag}`
38090 * - `{@link AuthImmutableFlag}`
38091 *
38092 * It's possible to set/clear multiple flags at once using logical or.
38093 * @function
38094 * @alias Operation.setOptions
38095 * @param {object} opts
38096 * @param {string} [opts.inflationDest] - Set this account ID as the account's inflation destination.
38097 * @param {(number|string)} [opts.clearFlags] - Bitmap integer for which account flags to clear.
38098 * @param {(number|string)} [opts.setFlags] - Bitmap integer for which account flags to set.
38099 * @param {number|string} [opts.masterWeight] - The master key weight.
38100 * @param {number|string} [opts.lowThreshold] - The sum weight for the low threshold.
38101 * @param {number|string} [opts.medThreshold] - The sum weight for the medium threshold.
38102 * @param {number|string} [opts.highThreshold] - The sum weight for the high threshold.
38103 * @param {object} [opts.signer] - Add or remove a signer from the account. The signer is
38104 * deleted if the weight is 0. Only one of `ed25519PublicKey`, `sha256Hash`, `preAuthTx` should be defined.
38105 * @param {string} [opts.signer.ed25519PublicKey] - The ed25519 public key of the signer.
38106 * @param {Buffer|string} [opts.signer.sha256Hash] - sha256 hash (Buffer or hex string) of preimage that will unlock funds. Preimage should be used as signature of future transaction.
38107 * @param {Buffer|string} [opts.signer.preAuthTx] - Hash (Buffer or hex string) of transaction that will unlock funds.
38108 * @param {number|string} [opts.signer.weight] - The weight of the new signer (0 to delete or 1-255)
38109 * @param {string} [opts.homeDomain] - sets the home domain used for reverse federation lookup.
38110 * @param {string} [opts.source] - The source account (defaults to transaction source).
38111 * @returns {xdr.SetOptionsOp}
38112 * @see [Account flags](https://www.stellar.org/developers/guides/concepts/accounts.html#flags)
38113 */
38114var setOptions = function setOptions(opts) {
38115 var attributes = {};
38116
38117 if (opts.inflationDest) {
38118 if (!StrKey.isValidEd25519PublicKey(opts.inflationDest)) {
38119 throw new Error("inflationDest is invalid");
38120 }
38121 attributes.inflationDest = Keypair.fromPublicKey(opts.inflationDest).xdrAccountId();
38122 }
38123
38124 var weightCheckFunction = function (value, name) {
38125 if (value >= 0 && value <= 255) {
38126 return true;
38127 } else {
38128 throw new Error("" + name + " value must be between 0 and 255");
38129 }
38130 };
38131
38132 attributes.clearFlags = this._checkUnsignedIntValue("clearFlags", opts.clearFlags);
38133 attributes.setFlags = this._checkUnsignedIntValue("setFlags", opts.setFlags);
38134 attributes.masterWeight = this._checkUnsignedIntValue("masterWeight", opts.masterWeight, weightCheckFunction);
38135 attributes.lowThreshold = this._checkUnsignedIntValue("lowThreshold", opts.lowThreshold, weightCheckFunction);
38136 attributes.medThreshold = this._checkUnsignedIntValue("medThreshold", opts.medThreshold, weightCheckFunction);
38137 attributes.highThreshold = this._checkUnsignedIntValue("highThreshold", opts.highThreshold, weightCheckFunction);
38138
38139 if (!isUndefined(opts.homeDomain) && !isString(opts.homeDomain)) {
38140 throw new TypeError("homeDomain argument must be of type String");
38141 }
38142 attributes.homeDomain = opts.homeDomain;
38143
38144 if (opts.signer) {
38145 var weight = this._checkUnsignedIntValue("signer.weight", opts.signer.weight, weightCheckFunction);
38146 var key = undefined;
38147
38148 var setValues = 0;
38149
38150 if (opts.signer.ed25519PublicKey) {
38151 if (!StrKey.isValidEd25519PublicKey(opts.signer.ed25519PublicKey)) {
38152 throw new Error("signer.ed25519PublicKey is invalid.");
38153 }
38154 var rawKey = StrKey.decodeEd25519PublicKey(opts.signer.ed25519PublicKey);
38155 key = new xdr.SignerKey.signerKeyTypeEd25519(rawKey);
38156 setValues++;
38157 }
38158
38159 if (opts.signer.preAuthTx) {
38160 if (isString(opts.signer.preAuthTx)) {
38161 opts.signer.preAuthTx = Buffer.from(opts.signer.preAuthTx, "hex");
38162 }
38163
38164 if (!(Buffer.isBuffer(opts.signer.preAuthTx) && opts.signer.preAuthTx.length == 32)) {
38165 throw new Error("signer.preAuthTx must be 32 bytes Buffer.");
38166 }
38167 key = new xdr.SignerKey.signerKeyTypePreAuthTx(opts.signer.preAuthTx);
38168 setValues++;
38169 }
38170
38171 if (opts.signer.sha256Hash) {
38172 if (isString(opts.signer.sha256Hash)) {
38173 opts.signer.sha256Hash = Buffer.from(opts.signer.sha256Hash, "hex");
38174 }
38175
38176 if (!(Buffer.isBuffer(opts.signer.sha256Hash) && opts.signer.sha256Hash.length == 32)) {
38177 throw new Error("signer.sha256Hash must be 32 bytes Buffer.");
38178 }
38179 key = new xdr.SignerKey.signerKeyTypeHashX(opts.signer.sha256Hash);
38180 setValues++;
38181 }
38182
38183 if (setValues != 1) {
38184 throw new Error("Signer object must contain exactly one of signer.ed25519PublicKey, signer.sha256Hash, signer.preAuthTx.");
38185 }
38186
38187 attributes.signer = new xdr.Signer({ key: key, weight: weight });
38188 }
38189
38190 var setOptionsOp = new xdr.SetOptionsOp(attributes);
38191
38192 var opAttributes = {};
38193 opAttributes.body = xdr.OperationBody.setOption(setOptionsOp);
38194 this.setSourceAccount(opAttributes, opts);
38195
38196 return new xdr.Operation(opAttributes);
38197};
38198exports.setOptions = setOptions;
38199}).call(this,require("buffer").Buffer)
38200},{"../generated/stellar-xdr_generated":410,"../keypair":413,"../strkey":431,"buffer":50,"lodash/isString":337,"lodash/isUndefined":340}],430:[function(require,module,exports){
38201(function (Buffer){
38202"use strict";
38203
38204exports.sign = sign;
38205exports.verify = verify;
38206Object.defineProperty(exports, "__esModule", {
38207 value: true
38208});
38209// This module provides the signing functionality used by the stellar network
38210// The code below may look a little strange... this is because we try to provide
38211// the most efficient signing method possible. First, we try to load the
38212// native ed25519 package for node.js environments, and if that fails we
38213// fallback to tweetnacl.js
38214
38215var actualMethods = {};
38216
38217/**
38218 * Use this flag to check if fast signing (provided by `ed25519` package) is available.
38219 * If your app is signing a large number of transaction or verifying a large number
38220 * of signatures make sure `ed25519` package is installed.
38221 */
38222var FastSigning = checkFastSigning();
38223
38224exports.FastSigning = FastSigning;
38225
38226function sign(data, secretKey) {
38227 return actualMethods.sign(data, secretKey);
38228}
38229
38230function verify(data, signature, publicKey) {
38231 return actualMethods.verify(data, signature, publicKey);
38232}
38233
38234function checkFastSigning() {
38235 return typeof window === "undefined" ? checkFastSigningNode() : checkFastSigningBrowser();
38236}
38237
38238function checkFastSigningNode() {
38239 // NOTE: we use commonjs style require here because es6 imports
38240 // can only occur at the top level. thanks, obama.
38241 var ed25519 = undefined;
38242 try {
38243 ed25519 = require("ed25519");
38244 } catch (err) {
38245 return checkFastSigningBrowser();
38246 }
38247
38248 actualMethods.sign = function (data, secretKey) {
38249 return ed25519.Sign(Buffer.from(data), secretKey);
38250 };
38251
38252 actualMethods.verify = function (data, signature, publicKey) {
38253 data = Buffer.from(data);
38254 try {
38255 return ed25519.Verify(data, signature, publicKey);
38256 } catch (e) {
38257 return false;
38258 }
38259 };
38260
38261 return true;
38262}
38263
38264function checkFastSigningBrowser() {
38265 // fallback to tweetnacl.js if we're in the browser or
38266 // if there was a failure installing ed25519
38267 var nacl = require("tweetnacl");
38268
38269 actualMethods.sign = function (data, secretKey) {
38270 data = Buffer.from(data);
38271 data = new Uint8Array(data.toJSON().data);
38272 secretKey = new Uint8Array(secretKey.toJSON().data);
38273
38274 var signature = nacl.sign.detached(data, secretKey);
38275
38276 return Buffer.from(signature);
38277 };
38278
38279 actualMethods.verify = function (data, signature, publicKey) {
38280 data = Buffer.from(data);
38281 data = new Uint8Array(data.toJSON().data);
38282 signature = new Uint8Array(signature.toJSON().data);
38283 publicKey = new Uint8Array(publicKey.toJSON().data);
38284
38285 return nacl.sign.detached.verify(data, signature, publicKey);
38286 };
38287
38288 return false;
38289}
38290}).call(this,require("buffer").Buffer)
38291},{"buffer":50,"ed25519":20,"tweetnacl":440}],431:[function(require,module,exports){
38292(function (Buffer){
38293"use strict";
38294
38295var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
38296
38297var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
38298
38299var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
38300
38301exports.decodeCheck = decodeCheck;
38302exports.encodeCheck = encodeCheck;
38303Object.defineProperty(exports, "__esModule", {
38304 value: true
38305});
38306
38307var base32 = _interopRequire(require("base32.js"));
38308
38309var crc = _interopRequire(require("crc"));
38310
38311var isUndefined = _interopRequire(require("lodash/isUndefined"));
38312
38313var isNull = _interopRequire(require("lodash/isNull"));
38314
38315var isString = _interopRequire(require("lodash/isString"));
38316
38317var verifyChecksum = require("./util/checksum").verifyChecksum;
38318
38319var versionBytes = {
38320 ed25519PublicKey: 6 << 3, // G
38321 ed25519SecretSeed: 18 << 3, // S
38322 preAuthTx: 19 << 3, // T
38323 sha256Hash: 23 << 3 // X
38324};
38325
38326/**
38327 * StrKey is a helper class that allows encoding and decoding strkey.
38328 */
38329
38330var StrKey = exports.StrKey = (function () {
38331 function StrKey() {
38332 _classCallCheck(this, StrKey);
38333 }
38334
38335 _createClass(StrKey, null, {
38336 encodeEd25519PublicKey: {
38337 /**
38338 * Encodes data to strkey ed25519 public key.
38339 * @param {Buffer} data data to encode
38340 * @returns {string}
38341 */
38342
38343 value: function encodeEd25519PublicKey(data) {
38344 return encodeCheck("ed25519PublicKey", data);
38345 }
38346 },
38347 decodeEd25519PublicKey: {
38348
38349 /**
38350 * Decodes strkey ed25519 public key to raw data.
38351 * @param {string} data data to decode
38352 * @returns {Buffer}
38353 */
38354
38355 value: function decodeEd25519PublicKey(data) {
38356 return decodeCheck("ed25519PublicKey", data);
38357 }
38358 },
38359 isValidEd25519PublicKey: {
38360
38361 /**
38362 * Returns true if the given Stellar public key is a valid ed25519 public key.
38363 * @param {string} publicKey public key to check
38364 * @returns {boolean}
38365 */
38366
38367 value: function isValidEd25519PublicKey(publicKey) {
38368 return isValid("ed25519PublicKey", publicKey);
38369 }
38370 },
38371 encodeEd25519SecretSeed: {
38372
38373 /**
38374 * Encodes data to strkey ed25519 seed.
38375 * @param {Buffer} data data to encode
38376 * @returns {string}
38377 */
38378
38379 value: function encodeEd25519SecretSeed(data) {
38380 return encodeCheck("ed25519SecretSeed", data);
38381 }
38382 },
38383 decodeEd25519SecretSeed: {
38384
38385 /**
38386 * Decodes strkey ed25519 seed to raw data.
38387 * @param {string} data data to decode
38388 * @returns {Buffer}
38389 */
38390
38391 value: function decodeEd25519SecretSeed(data) {
38392 return decodeCheck("ed25519SecretSeed", data);
38393 }
38394 },
38395 isValidEd25519SecretSeed: {
38396
38397 /**
38398 * Returns true if the given Stellar secret key is a valid ed25519 secret seed.
38399 * @param {string} seed seed to check
38400 * @returns {boolean}
38401 */
38402
38403 value: function isValidEd25519SecretSeed(seed) {
38404 return isValid("ed25519SecretSeed", seed);
38405 }
38406 },
38407 encodePreAuthTx: {
38408
38409 /**
38410 * Encodes data to strkey preAuthTx.
38411 * @param {Buffer} data data to encode
38412 * @returns {string}
38413 */
38414
38415 value: function encodePreAuthTx(data) {
38416 return encodeCheck("preAuthTx", data);
38417 }
38418 },
38419 decodePreAuthTx: {
38420
38421 /**
38422 * Decodes strkey PreAuthTx to raw data.
38423 * @param {string} data data to decode
38424 * @returns {Buffer}
38425 */
38426
38427 value: function decodePreAuthTx(data) {
38428 return decodeCheck("preAuthTx", data);
38429 }
38430 },
38431 encodeSha256Hash: {
38432
38433 /**
38434 * Encodes data to strkey sha256 hash.
38435 * @param {Buffer} data data to encode
38436 * @returns {string}
38437 */
38438
38439 value: function encodeSha256Hash(data) {
38440 return encodeCheck("sha256Hash", data);
38441 }
38442 },
38443 decodeSha256Hash: {
38444
38445 /**
38446 * Decodes strkey sha256 hash to raw data.
38447 * @param {string} data data to decode
38448 * @returns {Buffer}
38449 */
38450
38451 value: function decodeSha256Hash(data) {
38452 return decodeCheck("sha256Hash", data);
38453 }
38454 }
38455 });
38456
38457 return StrKey;
38458})();
38459
38460function isValid(versionByteName, encoded) {
38461 if (encoded && encoded.length != 56) {
38462 return false;
38463 }
38464
38465 try {
38466 var decoded = decodeCheck(versionByteName, encoded);
38467 if (decoded.length !== 32) {
38468 return false;
38469 }
38470 } catch (err) {
38471 return false;
38472 }
38473 return true;
38474}
38475
38476function decodeCheck(versionByteName, encoded) {
38477 if (!isString(encoded)) {
38478 throw new TypeError("encoded argument must be of type String");
38479 }
38480
38481 var decoded = base32.decode(encoded);
38482 var versionByte = decoded[0];
38483 var payload = decoded.slice(0, -2);
38484 var data = payload.slice(1);
38485 var checksum = decoded.slice(-2);
38486
38487 if (encoded != base32.encode(decoded)) {
38488 throw new Error("invalid encoded string");
38489 }
38490
38491 var expectedVersion = versionBytes[versionByteName];
38492
38493 if (isUndefined(expectedVersion)) {
38494 throw new Error("" + versionByteName + " is not a valid version byte name. expected one of \"accountId\" or \"seed\"");
38495 }
38496
38497 if (versionByte !== expectedVersion) {
38498 throw new Error("invalid version byte. expected " + expectedVersion + ", got " + versionByte);
38499 }
38500
38501 var expectedChecksum = calculateChecksum(payload);
38502
38503 if (!verifyChecksum(expectedChecksum, checksum)) {
38504 throw new Error("invalid checksum");
38505 }
38506
38507 return Buffer.from(data);
38508}
38509
38510function encodeCheck(versionByteName, data) {
38511 if (isNull(data) || isUndefined(data)) {
38512 throw new Error("cannot encode null data");
38513 }
38514
38515 var versionByte = versionBytes[versionByteName];
38516
38517 if (isUndefined(versionByte)) {
38518 throw new Error("" + versionByteName + " is not a valid version byte name. expected one of \"ed25519PublicKey\", \"ed25519SecretSeed\", \"preAuthTx\", \"sha256Hash\"");
38519 }
38520
38521 data = Buffer.from(data);
38522 var versionBuffer = Buffer.from([versionByte]);
38523 var payload = Buffer.concat([versionBuffer, data]);
38524 var checksum = calculateChecksum(payload);
38525 var unencoded = Buffer.concat([payload, checksum]);
38526
38527 return base32.encode(unencoded);
38528}
38529
38530function calculateChecksum(payload) {
38531 // This code calculates CRC16-XModem checksum of payload
38532 // and returns it as Buffer in little-endian order.
38533 var checksum = Buffer.alloc(2);
38534 checksum.writeUInt16LE(crc.crc16xmodem(payload), 0);
38535 return checksum;
38536}
38537}).call(this,require("buffer").Buffer)
38538},{"./util/checksum":434,"base32.js":15,"buffer":50,"crc":66,"lodash/isNull":331,"lodash/isString":337,"lodash/isUndefined":340}],432:[function(require,module,exports){
38539(function (Buffer){
38540"use strict";
38541
38542var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
38543
38544var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
38545
38546var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
38547
38548Object.defineProperty(exports, "__esModule", {
38549 value: true
38550});
38551
38552var _index = require("./index");
38553
38554var xdr = _index.xdr;
38555var hash = _index.hash;
38556
38557var StrKey = require("./strkey").StrKey;
38558
38559var Operation = require("./operation").Operation;
38560
38561var Network = require("./network").Network;
38562
38563var Memo = require("./memo").Memo;
38564
38565var map = _interopRequire(require("lodash/map"));
38566
38567var each = _interopRequire(require("lodash/each"));
38568
38569var isString = _interopRequire(require("lodash/isString"));
38570
38571var crypto = _interopRequire(require("crypto"));
38572
38573/**
38574 * A new Transaction object is created from a transaction envelope or via {@link TransactionBuilder}.
38575 * Once a Transaction has been created from an envelope, its attributes and operations
38576 * should not be changed. You should only add signers (using {@link Transaction#sign}) to a Transaction object before
38577 * submitting to the network or forwarding on to additional signers.
38578 * @constructor
38579 * @param {string|xdr.TransactionEnvelope} envelope - The transaction envelope object or base64 encoded string.
38580 */
38581
38582var Transaction = exports.Transaction = (function () {
38583 function Transaction(envelope) {
38584 _classCallCheck(this, Transaction);
38585
38586 if (typeof envelope === "string") {
38587 var buffer = Buffer.from(envelope, "base64");
38588 envelope = xdr.TransactionEnvelope.fromXDR(buffer);
38589 }
38590 // since this transaction is immutable, save the tx
38591 this.tx = envelope.tx();
38592 this.source = StrKey.encodeEd25519PublicKey(envelope.tx().sourceAccount().ed25519());
38593 this.fee = this.tx.fee();
38594 this._memo = this.tx.memo();
38595 this.sequence = this.tx.seqNum().toString();
38596
38597 var timeBounds = this.tx.timeBounds();
38598 if (timeBounds) {
38599 this.timeBounds = {
38600 minTime: timeBounds.minTime().toString(),
38601 maxTime: timeBounds.maxTime().toString()
38602 };
38603 }
38604
38605 var operations = this.tx.operations() || [];
38606 this.operations = map(operations, function (op) {
38607 return Operation.fromXDRObject(op);
38608 });
38609
38610 var signatures = envelope.signatures() || [];
38611 this.signatures = map(signatures, function (s) {
38612 return s;
38613 });
38614 }
38615
38616 _createClass(Transaction, {
38617 memo: {
38618 get: function () {
38619 return Memo.fromXDRObject(this._memo);
38620 },
38621 set: function (value) {
38622 throw new Error("Transaction is immutable");
38623 }
38624 },
38625 sign: {
38626
38627 /**
38628 * Signs the transaction with the given {@link Keypair}.
38629 * @param {...Keypair} keypairs Keypairs of signers
38630 * @returns {void}
38631 */
38632
38633 value: function sign() {
38634 var _this = this;
38635
38636 for (var _len = arguments.length, keypairs = Array(_len), _key = 0; _key < _len; _key++) {
38637 keypairs[_key] = arguments[_key];
38638 }
38639
38640 var txHash = this.hash();
38641 var newSigs = each(keypairs, function (kp) {
38642 var sig = kp.signDecorated(txHash);
38643 _this.signatures.push(sig);
38644 });
38645 }
38646 },
38647 signHashX: {
38648
38649 /**
38650 * Add `hashX` signer preimage as signature.
38651 * @param {Buffer|String} preimage Preimage of hash used as signer
38652 * @returns {void}
38653 */
38654
38655 value: function signHashX(preimage) {
38656 if (isString(preimage)) {
38657 preimage = Buffer.from(preimage, "hex");
38658 }
38659
38660 if (preimage.length > 64) {
38661 throw new Error("preimage cannnot be longer than 64 bytes");
38662 }
38663
38664 var signature = preimage;
38665 var hash = crypto.createHash("sha256").update(preimage).digest();
38666 var hint = hash.slice(hash.length - 4);
38667 this.signatures.push(new xdr.DecoratedSignature({ hint: hint, signature: signature }));
38668 }
38669 },
38670 hash: {
38671
38672 /**
38673 * Returns a hash for this transaction, suitable for signing.
38674 * @returns {Buffer}
38675 */
38676
38677 value: (function (_hash) {
38678 var _hashWrapper = function hash() {
38679 return _hash.apply(this, arguments);
38680 };
38681
38682 _hashWrapper.toString = function () {
38683 return _hash.toString();
38684 };
38685
38686 return _hashWrapper;
38687 })(function () {
38688 return hash(this.signatureBase());
38689 })
38690 },
38691 signatureBase: {
38692
38693 /**
38694 * Returns the "signature base" of this transaction, which is the value
38695 * that, when hashed, should be signed to create a signature that
38696 * validators on the Stellar Network will accept.
38697 *
38698 * It is composed of a 4 prefix bytes followed by the xdr-encoded form
38699 * of this transaction.
38700 * @returns {Buffer}
38701 */
38702
38703 value: function signatureBase() {
38704 if (Network.current() === null) {
38705 throw new Error("No network selected. Use `Network.use`, `Network.usePublicNetwork` or `Network.useTestNetwork` helper methods to select network.");
38706 }
38707
38708 return Buffer.concat([Network.current().networkId(), xdr.EnvelopeType.envelopeTypeTx().toXDR(), this.tx.toXDR()]);
38709 }
38710 },
38711 toEnvelope: {
38712
38713 /**
38714 * To envelope returns a xdr.TransactionEnvelope which can be submitted to the network.
38715 * @returns {xdr.TransactionEnvelope}
38716 */
38717
38718 value: function toEnvelope() {
38719 var tx = this.tx;
38720 var signatures = this.signatures;
38721 var envelope = new xdr.TransactionEnvelope({ tx: tx, signatures: signatures });
38722
38723 return envelope;
38724 }
38725 }
38726 });
38727
38728 return Transaction;
38729})();
38730}).call(this,require("buffer").Buffer)
38731},{"./index":412,"./memo":414,"./network":415,"./operation":416,"./strkey":431,"buffer":50,"crypto":72,"lodash/each":312,"lodash/isString":337,"lodash/map":343}],433:[function(require,module,exports){
38732"use strict";
38733
38734var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
38735
38736var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
38737
38738var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
38739
38740Object.defineProperty(exports, "__esModule", {
38741 value: true
38742});
38743
38744var xdr = _interopRequire(require("./generated/stellar-xdr_generated"));
38745
38746var UnsignedHyper = require("js-xdr").UnsignedHyper;
38747
38748var hash = require("./hashing").hash;
38749
38750var Keypair = require("./keypair").Keypair;
38751
38752var Account = require("./account").Account;
38753
38754var Operation = require("./operation").Operation;
38755
38756var Transaction = require("./transaction").Transaction;
38757
38758var Memo = require("./memo").Memo;
38759
38760var BigNumber = _interopRequire(require("bignumber.js"));
38761
38762var clone = _interopRequire(require("lodash/clone"));
38763
38764var map = _interopRequire(require("lodash/map"));
38765
38766var isUndefined = _interopRequire(require("lodash/isUndefined"));
38767
38768var BASE_FEE = 100; // Stroops
38769
38770/**
38771 * @constant
38772 * @see {@link TransactionBuilder#setTimeout}
38773 * @see [Timeout](https://www.stellar.org/developers/horizon/reference/endpoints/transactions-create.html#timeout)
38774 */
38775var TimeoutInfinite = 0;
38776
38777exports.TimeoutInfinite = TimeoutInfinite;
38778/**
38779 * <p>Transaction builder helps constructs a new `{@link Transaction}` using the given {@link Account}
38780 * as the transaction's "source account". The transaction will use the current sequence
38781 * number of the given account as its sequence number and increment the given account's
38782 * sequence number by one. The given source account must include a private key for signing
38783 * the transaction or an error will be thrown.</p>
38784 *
38785 * <p>Operations can be added to the transaction via their corresponding builder methods, and
38786 * each returns the TransactionBuilder object so they can be chained together. After adding
38787 * the desired operations, call the `build()` method on the `TransactionBuilder` to return a fully
38788 * constructed `{@link Transaction}` that can be signed. The returned transaction will contain the
38789 * sequence number of the source account and include the signature from the source account.</p>
38790 *
38791 * <p>The following code example creates a new transaction with {@link Operation.createAccount} and
38792 * {@link Operation.payment} operations.
38793 * The Transaction's source account first funds `destinationA`, then sends
38794 * a payment to `destinationB`. The built transaction is then signed by `sourceKeypair`.</p>
38795 *
38796 * ```
38797 * var transaction = new TransactionBuilder(source)
38798 * .addOperation(Operation.createAccount({
38799 destination: destinationA,
38800 startingBalance: "20"
38801 }) // <- funds and creates destinationA
38802 .addOperation(Operation.payment({
38803 destination: destinationB,
38804 amount: "100"
38805 asset: Asset.native()
38806 }) // <- sends 100 XLM to destinationB
38807 * .setTimeout(30)
38808 * .build();
38809 *
38810 * transaction.sign(sourceKeypair);
38811 * ```
38812 * @constructor
38813 * @param {Account} sourceAccount - The source account for this transaction.
38814 * @param {object} [opts]
38815 * @param {number} [opts.fee] - The max fee willing to pay per operation in this transaction (**in stroops**).
38816 * @param {object} [opts.timebounds] - The timebounds for the validity of this transaction.
38817 * @param {number|string} [opts.timebounds.minTime] - 64 bit unix timestamp
38818 * @param {number|string} [opts.timebounds.maxTime] - 64 bit unix timestamp
38819 * @param {Memo} [opts.memo] - The memo for the transaction
38820 */
38821
38822var TransactionBuilder = exports.TransactionBuilder = (function () {
38823 function TransactionBuilder(sourceAccount) {
38824 var opts = arguments[1] === undefined ? {} : arguments[1];
38825
38826 _classCallCheck(this, TransactionBuilder);
38827
38828 if (!sourceAccount) {
38829 throw new Error("must specify source account for the transaction");
38830 }
38831 this.source = sourceAccount;
38832 this.operations = [];
38833 this.baseFee = isUndefined(opts.fee) ? BASE_FEE : opts.fee;
38834 this.timebounds = clone(opts.timebounds);
38835 this.memo = opts.memo || Memo.none();
38836 this.timeoutSet = false;
38837 }
38838
38839 _createClass(TransactionBuilder, {
38840 addOperation: {
38841
38842 /**
38843 * Adds an operation to the transaction.
38844 * @param {xdr.Operation} operation The xdr operation object, use {@link Operation} static methods.
38845 * @returns {TransactionBuilder}
38846 */
38847
38848 value: function addOperation(operation) {
38849 this.operations.push(operation);
38850 return this;
38851 }
38852 },
38853 addMemo: {
38854
38855 /**
38856 * Adds a memo to the transaction.
38857 * @param {Memo} memo {@link Memo} object
38858 * @returns {TransactionBuilder}
38859 */
38860
38861 value: function addMemo(memo) {
38862 this.memo = memo;
38863 return this;
38864 }
38865 },
38866 setTimeout: {
38867
38868 /**
38869 * Because of the distributed nature of the Stellar network it is possible that the status of your transaction
38870 * will be determined after a long time if the network is highly congested.
38871 * If you want to be sure to receive the status of the transaction within a given period you should set the
38872 * {@link TimeBounds} with <code>maxTime</code> on the transaction (this is what <code>setTimeout</code> does
38873 * internally; if there's <code>minTime</code> set but no <code>maxTime</code> it will be added).
38874 * Call to <code>TransactionBuilder.setTimeout</code> is required if Transaction does not have <code>max_time</code> set.
38875 * If you don't want to set timeout, use <code>{@link TimeoutInfinite}</code>. In general you should set
38876 * <code>{@link TimeoutInfinite}</code> only in smart contracts.
38877 *
38878 * Please note that Horizon may still return <code>504 Gateway Timeout</code> error, even for short timeouts.
38879 * In such case you need to resubmit the same transaction again without making any changes to receive a status.
38880 * This method is using the machine system time (UTC), make sure it is set correctly.
38881 * @param {timeout} Timeout in seconds.
38882 * @return {TransactionBuilder}
38883 * @see TimeoutInfinite
38884 */
38885
38886 value: function setTimeout(timeout) {
38887 if (this.timebounds != null && this.timebounds.maxTime > 0) {
38888 throw new Error("TimeBounds.max_time has been already set - setting timeout would overwrite it.");
38889 }
38890
38891 if (timeout < 0) {
38892 throw new Error("timeout cannot be negative");
38893 }
38894
38895 this.timeoutSet = true;
38896 if (timeout > 0) {
38897 var timeoutTimestamp = Math.floor(Date.now() / 1000) + timeout;
38898 if (this.timebounds == null) {
38899 this.timebounds = { minTime: 0, maxTime: timeoutTimestamp };
38900 } else {
38901 this.timebounds = { minTime: this.timebounds.minTime, maxTime: timeoutTimestamp };
38902 }
38903 }
38904
38905 return this;
38906 }
38907 },
38908 build: {
38909
38910 /**
38911 * This will build the transaction.
38912 * It will also increment the source account's sequence number by 1.
38913 * @returns {Transaction} This method will return the built {@link Transaction}.
38914 */
38915
38916 value: function build() {
38917 // Ensure setTimeout called or maxTime is set
38918 if ((this.timebounds == null || this.timebounds != null && this.timebounds.maxTime == 0) && !this.timeoutSet) {
38919 throw new Error("TimeBounds has to be set or you must call setTimeout(TimeoutInfinite).");
38920 }
38921
38922 var sequenceNumber = new BigNumber(this.source.sequenceNumber()).add(1);
38923
38924 var attrs = {
38925 sourceAccount: Keypair.fromPublicKey(this.source.accountId()).xdrAccountId(),
38926 fee: this.baseFee * this.operations.length,
38927 seqNum: xdr.SequenceNumber.fromString(sequenceNumber.toString()),
38928 memo: this.memo ? this.memo.toXDRObject() : null,
38929 ext: new xdr.TransactionExt(0)
38930 };
38931
38932 if (this.timebounds) {
38933 this.timebounds.minTime = UnsignedHyper.fromString(this.timebounds.minTime.toString());
38934 this.timebounds.maxTime = UnsignedHyper.fromString(this.timebounds.maxTime.toString());
38935 attrs.timeBounds = new xdr.TimeBounds(this.timebounds);
38936 }
38937
38938 var xtx = new xdr.Transaction(attrs);
38939 xtx.operations(this.operations);
38940
38941 var xenv = new xdr.TransactionEnvelope({ tx: xtx });
38942 var tx = new Transaction(xenv);
38943
38944 this.source.incrementSequenceNumber();
38945
38946 return tx;
38947 }
38948 }
38949 });
38950
38951 return TransactionBuilder;
38952})();
38953},{"./account":407,"./generated/stellar-xdr_generated":410,"./hashing":411,"./keypair":413,"./memo":414,"./operation":416,"./transaction":432,"bignumber.js":17,"js-xdr":131,"lodash/clone":310,"lodash/isUndefined":340,"lodash/map":343}],434:[function(require,module,exports){
38954"use strict";
38955
38956exports.verifyChecksum = verifyChecksum;
38957Object.defineProperty(exports, "__esModule", {
38958 value: true
38959});
38960
38961function verifyChecksum(expected, actual) {
38962 if (expected.length !== actual.length) {
38963 return false;
38964 }
38965
38966 if (expected.length === 0) {
38967 return true;
38968 }
38969
38970 for (var i = 0; i < expected.length; i++) {
38971 if (expected[i] !== actual[i]) {
38972 return false;
38973 }
38974 }
38975
38976 return true;
38977}
38978},{}],435:[function(require,module,exports){
38979"use strict";
38980
38981var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
38982
38983var _slicedToArray = function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { var _arr = []; for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { _arr.push(_step.value); if (i && _arr.length === i) break; } return _arr; } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } };
38984
38985/**
38986 * Calculates and returns the best rational approximation of the given real number.
38987 * @private
38988 * @param {string|number|BigNumber} number
38989 * @throws Error Throws `Error` when the best rational approximation cannot be found.
38990 * @returns {array} first element is n (numerator), second element is d (denominator)
38991 */
38992exports.best_r = best_r;
38993Object.defineProperty(exports, "__esModule", {
38994 value: true
38995});
38996
38997var BigNumber = _interopRequire(require("bignumber.js"));
38998
38999var MAX_INT = (1 << 31 >>> 0) - 1;
39000function best_r(number) {
39001 number = new BigNumber(number);
39002 var a;
39003 var f;
39004 var fractions = [[new BigNumber(0), new BigNumber(1)], [new BigNumber(1), new BigNumber(0)]];
39005 var i = 2;
39006 while (true) {
39007 if (number.gt(MAX_INT)) {
39008 break;
39009 }
39010 a = number.floor();
39011 f = number.sub(a);
39012 var h = a.mul(fractions[i - 1][0]).add(fractions[i - 2][0]);
39013 var k = a.mul(fractions[i - 1][1]).add(fractions[i - 2][1]);
39014 if (h.gt(MAX_INT) || k.gt(MAX_INT)) {
39015 break;
39016 }
39017 fractions.push([h, k]);
39018 if (f.eq(0)) {
39019 break;
39020 }
39021 number = new BigNumber(1).div(f);
39022 i++;
39023 }
39024
39025 var _fractions = _slicedToArray(fractions[fractions.length - 1], 2);
39026
39027 var n = _fractions[0];
39028 var d = _fractions[1];
39029
39030 if (n.isZero() || d.isZero()) {
39031 throw new Error("Couldn't find approximation");
39032 }
39033
39034 return [n.toNumber(), d.toNumber()];
39035}
39036},{"bignumber.js":17}],436:[function(require,module,exports){
39037// vendored from http://cryptocoinjs.com/modules/misc/bs58/
39038
39039// Base58 encoding/decoding
39040// Originally written by Mike Hearn for BitcoinJ
39041// Copyright (c) 2011 Google Inc
39042// Ported to JavaScript by Stefan Thomas
39043// Merged Buffer refactorings from base58-native by Stephen Pair
39044// Copyright (c) 2013 BitPay Inc
39045
39046"use strict";
39047
39048var ALPHABET = "gsphnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCr65jkm8oFqi1tuvAxyz";
39049var ALPHABET_MAP = {};
39050for (var i = 0; i < ALPHABET.length; ++i) {
39051 ALPHABET_MAP[ALPHABET.charAt(i)] = i;
39052}
39053var BASE = 58;
39054
39055function decode(string) {
39056 if (string.length === 0) {
39057 return [];
39058 }var i,
39059 j,
39060 bytes = [0];
39061 for (i = 0; i < string.length; ++i) {
39062 var c = string[i];
39063 if (!(c in ALPHABET_MAP)) throw new Error("Non-base58 character");
39064
39065 for (j = 0; j < bytes.length; ++j) bytes[j] *= BASE;
39066 bytes[0] += ALPHABET_MAP[c];
39067
39068 var carry = 0;
39069 for (j = 0; j < bytes.length; ++j) {
39070 bytes[j] += carry;
39071
39072 carry = bytes[j] >> 8;
39073 bytes[j] &= 255;
39074 }
39075
39076 while (carry) {
39077 bytes.push(carry & 255);
39078
39079 carry >>= 8;
39080 }
39081 }
39082
39083 // deal with leading zeros
39084 for (i = 0; string[i] === "g" && i < string.length - 1; ++i) bytes.push(0);
39085
39086 return bytes.reverse();
39087}
39088
39089module.exports = { decode: decode };
39090},{}],437:[function(require,module,exports){
39091// Copyright Joyent, Inc. and other Node contributors.
39092//
39093// Permission is hereby granted, free of charge, to any person obtaining a
39094// copy of this software and associated documentation files (the
39095// "Software"), to deal in the Software without restriction, including
39096// without limitation the rights to use, copy, modify, merge, publish,
39097// distribute, sublicense, and/or sell copies of the Software, and to permit
39098// persons to whom the Software is furnished to do so, subject to the
39099// following conditions:
39100//
39101// The above copyright notice and this permission notice shall be included
39102// in all copies or substantial portions of the Software.
39103//
39104// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
39105// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
39106// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
39107// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
39108// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
39109// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
39110// USE OR OTHER DEALINGS IN THE SOFTWARE.
39111
39112module.exports = Stream;
39113
39114var EE = require('events').EventEmitter;
39115var inherits = require('inherits');
39116
39117inherits(Stream, EE);
39118Stream.Readable = require('readable-stream/readable.js');
39119Stream.Writable = require('readable-stream/writable.js');
39120Stream.Duplex = require('readable-stream/duplex.js');
39121Stream.Transform = require('readable-stream/transform.js');
39122Stream.PassThrough = require('readable-stream/passthrough.js');
39123
39124// Backwards-compat with node 0.4.x
39125Stream.Stream = Stream;
39126
39127
39128
39129// old-style streams. Note that the pipe method (the only relevant
39130// part of this class) is overridden in the Readable class.
39131
39132function Stream() {
39133 EE.call(this);
39134}
39135
39136Stream.prototype.pipe = function(dest, options) {
39137 var source = this;
39138
39139 function ondata(chunk) {
39140 if (dest.writable) {
39141 if (false === dest.write(chunk) && source.pause) {
39142 source.pause();
39143 }
39144 }
39145 }
39146
39147 source.on('data', ondata);
39148
39149 function ondrain() {
39150 if (source.readable && source.resume) {
39151 source.resume();
39152 }
39153 }
39154
39155 dest.on('drain', ondrain);
39156
39157 // If the 'end' option is not supplied, dest.end() will be called when
39158 // source gets the 'end' or 'close' events. Only dest.end() once.
39159 if (!dest._isStdio && (!options || options.end !== false)) {
39160 source.on('end', onend);
39161 source.on('close', onclose);
39162 }
39163
39164 var didOnEnd = false;
39165 function onend() {
39166 if (didOnEnd) return;
39167 didOnEnd = true;
39168
39169 dest.end();
39170 }
39171
39172
39173 function onclose() {
39174 if (didOnEnd) return;
39175 didOnEnd = true;
39176
39177 if (typeof dest.destroy === 'function') dest.destroy();
39178 }
39179
39180 // don't leave dangling pipes when there are errors.
39181 function onerror(er) {
39182 cleanup();
39183 if (EE.listenerCount(this, 'error') === 0) {
39184 throw er; // Unhandled stream error in pipe.
39185 }
39186 }
39187
39188 source.on('error', onerror);
39189 dest.on('error', onerror);
39190
39191 // remove all the event listeners that were added.
39192 function cleanup() {
39193 source.removeListener('data', ondata);
39194 dest.removeListener('drain', ondrain);
39195
39196 source.removeListener('end', onend);
39197 source.removeListener('close', onclose);
39198
39199 source.removeListener('error', onerror);
39200 dest.removeListener('error', onerror);
39201
39202 source.removeListener('end', cleanup);
39203 source.removeListener('close', cleanup);
39204
39205 dest.removeListener('close', cleanup);
39206 }
39207
39208 source.on('end', cleanup);
39209 source.on('close', cleanup);
39210
39211 dest.on('close', cleanup);
39212
39213 dest.emit('pipe', source);
39214
39215 // Allow for unix-like usage: A.pipe(B).pipe(C)
39216 return dest;
39217};
39218
39219},{"events":102,"inherits":119,"readable-stream/duplex.js":383,"readable-stream/passthrough.js":393,"readable-stream/readable.js":394,"readable-stream/transform.js":395,"readable-stream/writable.js":396}],438:[function(require,module,exports){
39220arguments[4][392][0].apply(exports,arguments)
39221},{"dup":392,"safe-buffer":398}],439:[function(require,module,exports){
39222(function (setImmediate,clearImmediate){
39223var nextTick = require('process/browser.js').nextTick;
39224var apply = Function.prototype.apply;
39225var slice = Array.prototype.slice;
39226var immediateIds = {};
39227var nextImmediateId = 0;
39228
39229// DOM APIs, for completeness
39230
39231exports.setTimeout = function() {
39232 return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
39233};
39234exports.setInterval = function() {
39235 return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
39236};
39237exports.clearTimeout =
39238exports.clearInterval = function(timeout) { timeout.close(); };
39239
39240function Timeout(id, clearFn) {
39241 this._id = id;
39242 this._clearFn = clearFn;
39243}
39244Timeout.prototype.unref = Timeout.prototype.ref = function() {};
39245Timeout.prototype.close = function() {
39246 this._clearFn.call(window, this._id);
39247};
39248
39249// Does not start the time, just sets up the members needed.
39250exports.enroll = function(item, msecs) {
39251 clearTimeout(item._idleTimeoutId);
39252 item._idleTimeout = msecs;
39253};
39254
39255exports.unenroll = function(item) {
39256 clearTimeout(item._idleTimeoutId);
39257 item._idleTimeout = -1;
39258};
39259
39260exports._unrefActive = exports.active = function(item) {
39261 clearTimeout(item._idleTimeoutId);
39262
39263 var msecs = item._idleTimeout;
39264 if (msecs >= 0) {
39265 item._idleTimeoutId = setTimeout(function onTimeout() {
39266 if (item._onTimeout)
39267 item._onTimeout();
39268 }, msecs);
39269 }
39270};
39271
39272// That's not how node.js implements it but the exposed api is the same.
39273exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) {
39274 var id = nextImmediateId++;
39275 var args = arguments.length < 2 ? false : slice.call(arguments, 1);
39276
39277 immediateIds[id] = true;
39278
39279 nextTick(function onNextTick() {
39280 if (immediateIds[id]) {
39281 // fn.call() is faster so we optimize for the common use-case
39282 // @see http://jsperf.com/call-apply-segu
39283 if (args) {
39284 fn.apply(null, args);
39285 } else {
39286 fn.call(null);
39287 }
39288 // Prevent ids from leaking
39289 exports.clearImmediate(id);
39290 }
39291 });
39292
39293 return id;
39294};
39295
39296exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) {
39297 delete immediateIds[id];
39298};
39299}).call(this,require("timers").setImmediate,require("timers").clearImmediate)
39300},{"process/browser.js":374,"timers":439}],440:[function(require,module,exports){
39301(function(nacl) {
39302'use strict';
39303
39304// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.
39305// Public domain.
39306//
39307// Implementation derived from TweetNaCl version 20140427.
39308// See for details: http://tweetnacl.cr.yp.to/
39309
39310var gf = function(init) {
39311 var i, r = new Float64Array(16);
39312 if (init) for (i = 0; i < init.length; i++) r[i] = init[i];
39313 return r;
39314};
39315
39316// Pluggable, initialized in high-level API below.
39317var randombytes = function(/* x, n */) { throw new Error('no PRNG'); };
39318
39319var _0 = new Uint8Array(16);
39320var _9 = new Uint8Array(32); _9[0] = 9;
39321
39322var gf0 = gf(),
39323 gf1 = gf([1]),
39324 _121665 = gf([0xdb41, 1]),
39325 D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),
39326 D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),
39327 X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),
39328 Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),
39329 I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);
39330
39331function ts64(x, i, h, l) {
39332 x[i] = (h >> 24) & 0xff;
39333 x[i+1] = (h >> 16) & 0xff;
39334 x[i+2] = (h >> 8) & 0xff;
39335 x[i+3] = h & 0xff;
39336 x[i+4] = (l >> 24) & 0xff;
39337 x[i+5] = (l >> 16) & 0xff;
39338 x[i+6] = (l >> 8) & 0xff;
39339 x[i+7] = l & 0xff;
39340}
39341
39342function vn(x, xi, y, yi, n) {
39343 var i,d = 0;
39344 for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];
39345 return (1 & ((d - 1) >>> 8)) - 1;
39346}
39347
39348function crypto_verify_16(x, xi, y, yi) {
39349 return vn(x,xi,y,yi,16);
39350}
39351
39352function crypto_verify_32(x, xi, y, yi) {
39353 return vn(x,xi,y,yi,32);
39354}
39355
39356function core_salsa20(o, p, k, c) {
39357 var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,
39358 j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,
39359 j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,
39360 j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,
39361 j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,
39362 j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,
39363 j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,
39364 j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,
39365 j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,
39366 j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,
39367 j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,
39368 j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,
39369 j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,
39370 j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,
39371 j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,
39372 j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;
39373
39374 var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
39375 x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,
39376 x15 = j15, u;
39377
39378 for (var i = 0; i < 20; i += 2) {
39379 u = x0 + x12 | 0;
39380 x4 ^= u<<7 | u>>>(32-7);
39381 u = x4 + x0 | 0;
39382 x8 ^= u<<9 | u>>>(32-9);
39383 u = x8 + x4 | 0;
39384 x12 ^= u<<13 | u>>>(32-13);
39385 u = x12 + x8 | 0;
39386 x0 ^= u<<18 | u>>>(32-18);
39387
39388 u = x5 + x1 | 0;
39389 x9 ^= u<<7 | u>>>(32-7);
39390 u = x9 + x5 | 0;
39391 x13 ^= u<<9 | u>>>(32-9);
39392 u = x13 + x9 | 0;
39393 x1 ^= u<<13 | u>>>(32-13);
39394 u = x1 + x13 | 0;
39395 x5 ^= u<<18 | u>>>(32-18);
39396
39397 u = x10 + x6 | 0;
39398 x14 ^= u<<7 | u>>>(32-7);
39399 u = x14 + x10 | 0;
39400 x2 ^= u<<9 | u>>>(32-9);
39401 u = x2 + x14 | 0;
39402 x6 ^= u<<13 | u>>>(32-13);
39403 u = x6 + x2 | 0;
39404 x10 ^= u<<18 | u>>>(32-18);
39405
39406 u = x15 + x11 | 0;
39407 x3 ^= u<<7 | u>>>(32-7);
39408 u = x3 + x15 | 0;
39409 x7 ^= u<<9 | u>>>(32-9);
39410 u = x7 + x3 | 0;
39411 x11 ^= u<<13 | u>>>(32-13);
39412 u = x11 + x7 | 0;
39413 x15 ^= u<<18 | u>>>(32-18);
39414
39415 u = x0 + x3 | 0;
39416 x1 ^= u<<7 | u>>>(32-7);
39417 u = x1 + x0 | 0;
39418 x2 ^= u<<9 | u>>>(32-9);
39419 u = x2 + x1 | 0;
39420 x3 ^= u<<13 | u>>>(32-13);
39421 u = x3 + x2 | 0;
39422 x0 ^= u<<18 | u>>>(32-18);
39423
39424 u = x5 + x4 | 0;
39425 x6 ^= u<<7 | u>>>(32-7);
39426 u = x6 + x5 | 0;
39427 x7 ^= u<<9 | u>>>(32-9);
39428 u = x7 + x6 | 0;
39429 x4 ^= u<<13 | u>>>(32-13);
39430 u = x4 + x7 | 0;
39431 x5 ^= u<<18 | u>>>(32-18);
39432
39433 u = x10 + x9 | 0;
39434 x11 ^= u<<7 | u>>>(32-7);
39435 u = x11 + x10 | 0;
39436 x8 ^= u<<9 | u>>>(32-9);
39437 u = x8 + x11 | 0;
39438 x9 ^= u<<13 | u>>>(32-13);
39439 u = x9 + x8 | 0;
39440 x10 ^= u<<18 | u>>>(32-18);
39441
39442 u = x15 + x14 | 0;
39443 x12 ^= u<<7 | u>>>(32-7);
39444 u = x12 + x15 | 0;
39445 x13 ^= u<<9 | u>>>(32-9);
39446 u = x13 + x12 | 0;
39447 x14 ^= u<<13 | u>>>(32-13);
39448 u = x14 + x13 | 0;
39449 x15 ^= u<<18 | u>>>(32-18);
39450 }
39451 x0 = x0 + j0 | 0;
39452 x1 = x1 + j1 | 0;
39453 x2 = x2 + j2 | 0;
39454 x3 = x3 + j3 | 0;
39455 x4 = x4 + j4 | 0;
39456 x5 = x5 + j5 | 0;
39457 x6 = x6 + j6 | 0;
39458 x7 = x7 + j7 | 0;
39459 x8 = x8 + j8 | 0;
39460 x9 = x9 + j9 | 0;
39461 x10 = x10 + j10 | 0;
39462 x11 = x11 + j11 | 0;
39463 x12 = x12 + j12 | 0;
39464 x13 = x13 + j13 | 0;
39465 x14 = x14 + j14 | 0;
39466 x15 = x15 + j15 | 0;
39467
39468 o[ 0] = x0 >>> 0 & 0xff;
39469 o[ 1] = x0 >>> 8 & 0xff;
39470 o[ 2] = x0 >>> 16 & 0xff;
39471 o[ 3] = x0 >>> 24 & 0xff;
39472
39473 o[ 4] = x1 >>> 0 & 0xff;
39474 o[ 5] = x1 >>> 8 & 0xff;
39475 o[ 6] = x1 >>> 16 & 0xff;
39476 o[ 7] = x1 >>> 24 & 0xff;
39477
39478 o[ 8] = x2 >>> 0 & 0xff;
39479 o[ 9] = x2 >>> 8 & 0xff;
39480 o[10] = x2 >>> 16 & 0xff;
39481 o[11] = x2 >>> 24 & 0xff;
39482
39483 o[12] = x3 >>> 0 & 0xff;
39484 o[13] = x3 >>> 8 & 0xff;
39485 o[14] = x3 >>> 16 & 0xff;
39486 o[15] = x3 >>> 24 & 0xff;
39487
39488 o[16] = x4 >>> 0 & 0xff;
39489 o[17] = x4 >>> 8 & 0xff;
39490 o[18] = x4 >>> 16 & 0xff;
39491 o[19] = x4 >>> 24 & 0xff;
39492
39493 o[20] = x5 >>> 0 & 0xff;
39494 o[21] = x5 >>> 8 & 0xff;
39495 o[22] = x5 >>> 16 & 0xff;
39496 o[23] = x5 >>> 24 & 0xff;
39497
39498 o[24] = x6 >>> 0 & 0xff;
39499 o[25] = x6 >>> 8 & 0xff;
39500 o[26] = x6 >>> 16 & 0xff;
39501 o[27] = x6 >>> 24 & 0xff;
39502
39503 o[28] = x7 >>> 0 & 0xff;
39504 o[29] = x7 >>> 8 & 0xff;
39505 o[30] = x7 >>> 16 & 0xff;
39506 o[31] = x7 >>> 24 & 0xff;
39507
39508 o[32] = x8 >>> 0 & 0xff;
39509 o[33] = x8 >>> 8 & 0xff;
39510 o[34] = x8 >>> 16 & 0xff;
39511 o[35] = x8 >>> 24 & 0xff;
39512
39513 o[36] = x9 >>> 0 & 0xff;
39514 o[37] = x9 >>> 8 & 0xff;
39515 o[38] = x9 >>> 16 & 0xff;
39516 o[39] = x9 >>> 24 & 0xff;
39517
39518 o[40] = x10 >>> 0 & 0xff;
39519 o[41] = x10 >>> 8 & 0xff;
39520 o[42] = x10 >>> 16 & 0xff;
39521 o[43] = x10 >>> 24 & 0xff;
39522
39523 o[44] = x11 >>> 0 & 0xff;
39524 o[45] = x11 >>> 8 & 0xff;
39525 o[46] = x11 >>> 16 & 0xff;
39526 o[47] = x11 >>> 24 & 0xff;
39527
39528 o[48] = x12 >>> 0 & 0xff;
39529 o[49] = x12 >>> 8 & 0xff;
39530 o[50] = x12 >>> 16 & 0xff;
39531 o[51] = x12 >>> 24 & 0xff;
39532
39533 o[52] = x13 >>> 0 & 0xff;
39534 o[53] = x13 >>> 8 & 0xff;
39535 o[54] = x13 >>> 16 & 0xff;
39536 o[55] = x13 >>> 24 & 0xff;
39537
39538 o[56] = x14 >>> 0 & 0xff;
39539 o[57] = x14 >>> 8 & 0xff;
39540 o[58] = x14 >>> 16 & 0xff;
39541 o[59] = x14 >>> 24 & 0xff;
39542
39543 o[60] = x15 >>> 0 & 0xff;
39544 o[61] = x15 >>> 8 & 0xff;
39545 o[62] = x15 >>> 16 & 0xff;
39546 o[63] = x15 >>> 24 & 0xff;
39547}
39548
39549function core_hsalsa20(o,p,k,c) {
39550 var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,
39551 j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,
39552 j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,
39553 j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,
39554 j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,
39555 j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,
39556 j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,
39557 j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,
39558 j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,
39559 j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,
39560 j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,
39561 j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,
39562 j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,
39563 j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,
39564 j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,
39565 j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;
39566
39567 var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
39568 x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,
39569 x15 = j15, u;
39570
39571 for (var i = 0; i < 20; i += 2) {
39572 u = x0 + x12 | 0;
39573 x4 ^= u<<7 | u>>>(32-7);
39574 u = x4 + x0 | 0;
39575 x8 ^= u<<9 | u>>>(32-9);
39576 u = x8 + x4 | 0;
39577 x12 ^= u<<13 | u>>>(32-13);
39578 u = x12 + x8 | 0;
39579 x0 ^= u<<18 | u>>>(32-18);
39580
39581 u = x5 + x1 | 0;
39582 x9 ^= u<<7 | u>>>(32-7);
39583 u = x9 + x5 | 0;
39584 x13 ^= u<<9 | u>>>(32-9);
39585 u = x13 + x9 | 0;
39586 x1 ^= u<<13 | u>>>(32-13);
39587 u = x1 + x13 | 0;
39588 x5 ^= u<<18 | u>>>(32-18);
39589
39590 u = x10 + x6 | 0;
39591 x14 ^= u<<7 | u>>>(32-7);
39592 u = x14 + x10 | 0;
39593 x2 ^= u<<9 | u>>>(32-9);
39594 u = x2 + x14 | 0;
39595 x6 ^= u<<13 | u>>>(32-13);
39596 u = x6 + x2 | 0;
39597 x10 ^= u<<18 | u>>>(32-18);
39598
39599 u = x15 + x11 | 0;
39600 x3 ^= u<<7 | u>>>(32-7);
39601 u = x3 + x15 | 0;
39602 x7 ^= u<<9 | u>>>(32-9);
39603 u = x7 + x3 | 0;
39604 x11 ^= u<<13 | u>>>(32-13);
39605 u = x11 + x7 | 0;
39606 x15 ^= u<<18 | u>>>(32-18);
39607
39608 u = x0 + x3 | 0;
39609 x1 ^= u<<7 | u>>>(32-7);
39610 u = x1 + x0 | 0;
39611 x2 ^= u<<9 | u>>>(32-9);
39612 u = x2 + x1 | 0;
39613 x3 ^= u<<13 | u>>>(32-13);
39614 u = x3 + x2 | 0;
39615 x0 ^= u<<18 | u>>>(32-18);
39616
39617 u = x5 + x4 | 0;
39618 x6 ^= u<<7 | u>>>(32-7);
39619 u = x6 + x5 | 0;
39620 x7 ^= u<<9 | u>>>(32-9);
39621 u = x7 + x6 | 0;
39622 x4 ^= u<<13 | u>>>(32-13);
39623 u = x4 + x7 | 0;
39624 x5 ^= u<<18 | u>>>(32-18);
39625
39626 u = x10 + x9 | 0;
39627 x11 ^= u<<7 | u>>>(32-7);
39628 u = x11 + x10 | 0;
39629 x8 ^= u<<9 | u>>>(32-9);
39630 u = x8 + x11 | 0;
39631 x9 ^= u<<13 | u>>>(32-13);
39632 u = x9 + x8 | 0;
39633 x10 ^= u<<18 | u>>>(32-18);
39634
39635 u = x15 + x14 | 0;
39636 x12 ^= u<<7 | u>>>(32-7);
39637 u = x12 + x15 | 0;
39638 x13 ^= u<<9 | u>>>(32-9);
39639 u = x13 + x12 | 0;
39640 x14 ^= u<<13 | u>>>(32-13);
39641 u = x14 + x13 | 0;
39642 x15 ^= u<<18 | u>>>(32-18);
39643 }
39644
39645 o[ 0] = x0 >>> 0 & 0xff;
39646 o[ 1] = x0 >>> 8 & 0xff;
39647 o[ 2] = x0 >>> 16 & 0xff;
39648 o[ 3] = x0 >>> 24 & 0xff;
39649
39650 o[ 4] = x5 >>> 0 & 0xff;
39651 o[ 5] = x5 >>> 8 & 0xff;
39652 o[ 6] = x5 >>> 16 & 0xff;
39653 o[ 7] = x5 >>> 24 & 0xff;
39654
39655 o[ 8] = x10 >>> 0 & 0xff;
39656 o[ 9] = x10 >>> 8 & 0xff;
39657 o[10] = x10 >>> 16 & 0xff;
39658 o[11] = x10 >>> 24 & 0xff;
39659
39660 o[12] = x15 >>> 0 & 0xff;
39661 o[13] = x15 >>> 8 & 0xff;
39662 o[14] = x15 >>> 16 & 0xff;
39663 o[15] = x15 >>> 24 & 0xff;
39664
39665 o[16] = x6 >>> 0 & 0xff;
39666 o[17] = x6 >>> 8 & 0xff;
39667 o[18] = x6 >>> 16 & 0xff;
39668 o[19] = x6 >>> 24 & 0xff;
39669
39670 o[20] = x7 >>> 0 & 0xff;
39671 o[21] = x7 >>> 8 & 0xff;
39672 o[22] = x7 >>> 16 & 0xff;
39673 o[23] = x7 >>> 24 & 0xff;
39674
39675 o[24] = x8 >>> 0 & 0xff;
39676 o[25] = x8 >>> 8 & 0xff;
39677 o[26] = x8 >>> 16 & 0xff;
39678 o[27] = x8 >>> 24 & 0xff;
39679
39680 o[28] = x9 >>> 0 & 0xff;
39681 o[29] = x9 >>> 8 & 0xff;
39682 o[30] = x9 >>> 16 & 0xff;
39683 o[31] = x9 >>> 24 & 0xff;
39684}
39685
39686function crypto_core_salsa20(out,inp,k,c) {
39687 core_salsa20(out,inp,k,c);
39688}
39689
39690function crypto_core_hsalsa20(out,inp,k,c) {
39691 core_hsalsa20(out,inp,k,c);
39692}
39693
39694var sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);
39695 // "expand 32-byte k"
39696
39697function crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {
39698 var z = new Uint8Array(16), x = new Uint8Array(64);
39699 var u, i;
39700 for (i = 0; i < 16; i++) z[i] = 0;
39701 for (i = 0; i < 8; i++) z[i] = n[i];
39702 while (b >= 64) {
39703 crypto_core_salsa20(x,z,k,sigma);
39704 for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];
39705 u = 1;
39706 for (i = 8; i < 16; i++) {
39707 u = u + (z[i] & 0xff) | 0;
39708 z[i] = u & 0xff;
39709 u >>>= 8;
39710 }
39711 b -= 64;
39712 cpos += 64;
39713 mpos += 64;
39714 }
39715 if (b > 0) {
39716 crypto_core_salsa20(x,z,k,sigma);
39717 for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];
39718 }
39719 return 0;
39720}
39721
39722function crypto_stream_salsa20(c,cpos,b,n,k) {
39723 var z = new Uint8Array(16), x = new Uint8Array(64);
39724 var u, i;
39725 for (i = 0; i < 16; i++) z[i] = 0;
39726 for (i = 0; i < 8; i++) z[i] = n[i];
39727 while (b >= 64) {
39728 crypto_core_salsa20(x,z,k,sigma);
39729 for (i = 0; i < 64; i++) c[cpos+i] = x[i];
39730 u = 1;
39731 for (i = 8; i < 16; i++) {
39732 u = u + (z[i] & 0xff) | 0;
39733 z[i] = u & 0xff;
39734 u >>>= 8;
39735 }
39736 b -= 64;
39737 cpos += 64;
39738 }
39739 if (b > 0) {
39740 crypto_core_salsa20(x,z,k,sigma);
39741 for (i = 0; i < b; i++) c[cpos+i] = x[i];
39742 }
39743 return 0;
39744}
39745
39746function crypto_stream(c,cpos,d,n,k) {
39747 var s = new Uint8Array(32);
39748 crypto_core_hsalsa20(s,n,k,sigma);
39749 var sn = new Uint8Array(8);
39750 for (var i = 0; i < 8; i++) sn[i] = n[i+16];
39751 return crypto_stream_salsa20(c,cpos,d,sn,s);
39752}
39753
39754function crypto_stream_xor(c,cpos,m,mpos,d,n,k) {
39755 var s = new Uint8Array(32);
39756 crypto_core_hsalsa20(s,n,k,sigma);
39757 var sn = new Uint8Array(8);
39758 for (var i = 0; i < 8; i++) sn[i] = n[i+16];
39759 return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);
39760}
39761
39762/*
39763* Port of Andrew Moon's Poly1305-donna-16. Public domain.
39764* https://github.com/floodyberry/poly1305-donna
39765*/
39766
39767var poly1305 = function(key) {
39768 this.buffer = new Uint8Array(16);
39769 this.r = new Uint16Array(10);
39770 this.h = new Uint16Array(10);
39771 this.pad = new Uint16Array(8);
39772 this.leftover = 0;
39773 this.fin = 0;
39774
39775 var t0, t1, t2, t3, t4, t5, t6, t7;
39776
39777 t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;
39778 t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;
39779 t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;
39780 t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;
39781 t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;
39782 this.r[5] = ((t4 >>> 1)) & 0x1ffe;
39783 t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;
39784 t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;
39785 t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;
39786 this.r[9] = ((t7 >>> 5)) & 0x007f;
39787
39788 this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;
39789 this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;
39790 this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;
39791 this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;
39792 this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;
39793 this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;
39794 this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;
39795 this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;
39796};
39797
39798poly1305.prototype.blocks = function(m, mpos, bytes) {
39799 var hibit = this.fin ? 0 : (1 << 11);
39800 var t0, t1, t2, t3, t4, t5, t6, t7, c;
39801 var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;
39802
39803 var h0 = this.h[0],
39804 h1 = this.h[1],
39805 h2 = this.h[2],
39806 h3 = this.h[3],
39807 h4 = this.h[4],
39808 h5 = this.h[5],
39809 h6 = this.h[6],
39810 h7 = this.h[7],
39811 h8 = this.h[8],
39812 h9 = this.h[9];
39813
39814 var r0 = this.r[0],
39815 r1 = this.r[1],
39816 r2 = this.r[2],
39817 r3 = this.r[3],
39818 r4 = this.r[4],
39819 r5 = this.r[5],
39820 r6 = this.r[6],
39821 r7 = this.r[7],
39822 r8 = this.r[8],
39823 r9 = this.r[9];
39824
39825 while (bytes >= 16) {
39826 t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;
39827 t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;
39828 t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;
39829 t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;
39830 t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;
39831 h5 += ((t4 >>> 1)) & 0x1fff;
39832 t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;
39833 t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;
39834 t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;
39835 h9 += ((t7 >>> 5)) | hibit;
39836
39837 c = 0;
39838
39839 d0 = c;
39840 d0 += h0 * r0;
39841 d0 += h1 * (5 * r9);
39842 d0 += h2 * (5 * r8);
39843 d0 += h3 * (5 * r7);
39844 d0 += h4 * (5 * r6);
39845 c = (d0 >>> 13); d0 &= 0x1fff;
39846 d0 += h5 * (5 * r5);
39847 d0 += h6 * (5 * r4);
39848 d0 += h7 * (5 * r3);
39849 d0 += h8 * (5 * r2);
39850 d0 += h9 * (5 * r1);
39851 c += (d0 >>> 13); d0 &= 0x1fff;
39852
39853 d1 = c;
39854 d1 += h0 * r1;
39855 d1 += h1 * r0;
39856 d1 += h2 * (5 * r9);
39857 d1 += h3 * (5 * r8);
39858 d1 += h4 * (5 * r7);
39859 c = (d1 >>> 13); d1 &= 0x1fff;
39860 d1 += h5 * (5 * r6);
39861 d1 += h6 * (5 * r5);
39862 d1 += h7 * (5 * r4);
39863 d1 += h8 * (5 * r3);
39864 d1 += h9 * (5 * r2);
39865 c += (d1 >>> 13); d1 &= 0x1fff;
39866
39867 d2 = c;
39868 d2 += h0 * r2;
39869 d2 += h1 * r1;
39870 d2 += h2 * r0;
39871 d2 += h3 * (5 * r9);
39872 d2 += h4 * (5 * r8);
39873 c = (d2 >>> 13); d2 &= 0x1fff;
39874 d2 += h5 * (5 * r7);
39875 d2 += h6 * (5 * r6);
39876 d2 += h7 * (5 * r5);
39877 d2 += h8 * (5 * r4);
39878 d2 += h9 * (5 * r3);
39879 c += (d2 >>> 13); d2 &= 0x1fff;
39880
39881 d3 = c;
39882 d3 += h0 * r3;
39883 d3 += h1 * r2;
39884 d3 += h2 * r1;
39885 d3 += h3 * r0;
39886 d3 += h4 * (5 * r9);
39887 c = (d3 >>> 13); d3 &= 0x1fff;
39888 d3 += h5 * (5 * r8);
39889 d3 += h6 * (5 * r7);
39890 d3 += h7 * (5 * r6);
39891 d3 += h8 * (5 * r5);
39892 d3 += h9 * (5 * r4);
39893 c += (d3 >>> 13); d3 &= 0x1fff;
39894
39895 d4 = c;
39896 d4 += h0 * r4;
39897 d4 += h1 * r3;
39898 d4 += h2 * r2;
39899 d4 += h3 * r1;
39900 d4 += h4 * r0;
39901 c = (d4 >>> 13); d4 &= 0x1fff;
39902 d4 += h5 * (5 * r9);
39903 d4 += h6 * (5 * r8);
39904 d4 += h7 * (5 * r7);
39905 d4 += h8 * (5 * r6);
39906 d4 += h9 * (5 * r5);
39907 c += (d4 >>> 13); d4 &= 0x1fff;
39908
39909 d5 = c;
39910 d5 += h0 * r5;
39911 d5 += h1 * r4;
39912 d5 += h2 * r3;
39913 d5 += h3 * r2;
39914 d5 += h4 * r1;
39915 c = (d5 >>> 13); d5 &= 0x1fff;
39916 d5 += h5 * r0;
39917 d5 += h6 * (5 * r9);
39918 d5 += h7 * (5 * r8);
39919 d5 += h8 * (5 * r7);
39920 d5 += h9 * (5 * r6);
39921 c += (d5 >>> 13); d5 &= 0x1fff;
39922
39923 d6 = c;
39924 d6 += h0 * r6;
39925 d6 += h1 * r5;
39926 d6 += h2 * r4;
39927 d6 += h3 * r3;
39928 d6 += h4 * r2;
39929 c = (d6 >>> 13); d6 &= 0x1fff;
39930 d6 += h5 * r1;
39931 d6 += h6 * r0;
39932 d6 += h7 * (5 * r9);
39933 d6 += h8 * (5 * r8);
39934 d6 += h9 * (5 * r7);
39935 c += (d6 >>> 13); d6 &= 0x1fff;
39936
39937 d7 = c;
39938 d7 += h0 * r7;
39939 d7 += h1 * r6;
39940 d7 += h2 * r5;
39941 d7 += h3 * r4;
39942 d7 += h4 * r3;
39943 c = (d7 >>> 13); d7 &= 0x1fff;
39944 d7 += h5 * r2;
39945 d7 += h6 * r1;
39946 d7 += h7 * r0;
39947 d7 += h8 * (5 * r9);
39948 d7 += h9 * (5 * r8);
39949 c += (d7 >>> 13); d7 &= 0x1fff;
39950
39951 d8 = c;
39952 d8 += h0 * r8;
39953 d8 += h1 * r7;
39954 d8 += h2 * r6;
39955 d8 += h3 * r5;
39956 d8 += h4 * r4;
39957 c = (d8 >>> 13); d8 &= 0x1fff;
39958 d8 += h5 * r3;
39959 d8 += h6 * r2;
39960 d8 += h7 * r1;
39961 d8 += h8 * r0;
39962 d8 += h9 * (5 * r9);
39963 c += (d8 >>> 13); d8 &= 0x1fff;
39964
39965 d9 = c;
39966 d9 += h0 * r9;
39967 d9 += h1 * r8;
39968 d9 += h2 * r7;
39969 d9 += h3 * r6;
39970 d9 += h4 * r5;
39971 c = (d9 >>> 13); d9 &= 0x1fff;
39972 d9 += h5 * r4;
39973 d9 += h6 * r3;
39974 d9 += h7 * r2;
39975 d9 += h8 * r1;
39976 d9 += h9 * r0;
39977 c += (d9 >>> 13); d9 &= 0x1fff;
39978
39979 c = (((c << 2) + c)) | 0;
39980 c = (c + d0) | 0;
39981 d0 = c & 0x1fff;
39982 c = (c >>> 13);
39983 d1 += c;
39984
39985 h0 = d0;
39986 h1 = d1;
39987 h2 = d2;
39988 h3 = d3;
39989 h4 = d4;
39990 h5 = d5;
39991 h6 = d6;
39992 h7 = d7;
39993 h8 = d8;
39994 h9 = d9;
39995
39996 mpos += 16;
39997 bytes -= 16;
39998 }
39999 this.h[0] = h0;
40000 this.h[1] = h1;
40001 this.h[2] = h2;
40002 this.h[3] = h3;
40003 this.h[4] = h4;
40004 this.h[5] = h5;
40005 this.h[6] = h6;
40006 this.h[7] = h7;
40007 this.h[8] = h8;
40008 this.h[9] = h9;
40009};
40010
40011poly1305.prototype.finish = function(mac, macpos) {
40012 var g = new Uint16Array(10);
40013 var c, mask, f, i;
40014
40015 if (this.leftover) {
40016 i = this.leftover;
40017 this.buffer[i++] = 1;
40018 for (; i < 16; i++) this.buffer[i] = 0;
40019 this.fin = 1;
40020 this.blocks(this.buffer, 0, 16);
40021 }
40022
40023 c = this.h[1] >>> 13;
40024 this.h[1] &= 0x1fff;
40025 for (i = 2; i < 10; i++) {
40026 this.h[i] += c;
40027 c = this.h[i] >>> 13;
40028 this.h[i] &= 0x1fff;
40029 }
40030 this.h[0] += (c * 5);
40031 c = this.h[0] >>> 13;
40032 this.h[0] &= 0x1fff;
40033 this.h[1] += c;
40034 c = this.h[1] >>> 13;
40035 this.h[1] &= 0x1fff;
40036 this.h[2] += c;
40037
40038 g[0] = this.h[0] + 5;
40039 c = g[0] >>> 13;
40040 g[0] &= 0x1fff;
40041 for (i = 1; i < 10; i++) {
40042 g[i] = this.h[i] + c;
40043 c = g[i] >>> 13;
40044 g[i] &= 0x1fff;
40045 }
40046 g[9] -= (1 << 13);
40047
40048 mask = (c ^ 1) - 1;
40049 for (i = 0; i < 10; i++) g[i] &= mask;
40050 mask = ~mask;
40051 for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];
40052
40053 this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;
40054 this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;
40055 this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;
40056 this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;
40057 this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;
40058 this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;
40059 this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;
40060 this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;
40061
40062 f = this.h[0] + this.pad[0];
40063 this.h[0] = f & 0xffff;
40064 for (i = 1; i < 8; i++) {
40065 f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;
40066 this.h[i] = f & 0xffff;
40067 }
40068
40069 mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;
40070 mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;
40071 mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;
40072 mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;
40073 mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;
40074 mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;
40075 mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;
40076 mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;
40077 mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;
40078 mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;
40079 mac[macpos+10] = (this.h[5] >>> 0) & 0xff;
40080 mac[macpos+11] = (this.h[5] >>> 8) & 0xff;
40081 mac[macpos+12] = (this.h[6] >>> 0) & 0xff;
40082 mac[macpos+13] = (this.h[6] >>> 8) & 0xff;
40083 mac[macpos+14] = (this.h[7] >>> 0) & 0xff;
40084 mac[macpos+15] = (this.h[7] >>> 8) & 0xff;
40085};
40086
40087poly1305.prototype.update = function(m, mpos, bytes) {
40088 var i, want;
40089
40090 if (this.leftover) {
40091 want = (16 - this.leftover);
40092 if (want > bytes)
40093 want = bytes;
40094 for (i = 0; i < want; i++)
40095 this.buffer[this.leftover + i] = m[mpos+i];
40096 bytes -= want;
40097 mpos += want;
40098 this.leftover += want;
40099 if (this.leftover < 16)
40100 return;
40101 this.blocks(this.buffer, 0, 16);
40102 this.leftover = 0;
40103 }
40104
40105 if (bytes >= 16) {
40106 want = bytes - (bytes % 16);
40107 this.blocks(m, mpos, want);
40108 mpos += want;
40109 bytes -= want;
40110 }
40111
40112 if (bytes) {
40113 for (i = 0; i < bytes; i++)
40114 this.buffer[this.leftover + i] = m[mpos+i];
40115 this.leftover += bytes;
40116 }
40117};
40118
40119function crypto_onetimeauth(out, outpos, m, mpos, n, k) {
40120 var s = new poly1305(k);
40121 s.update(m, mpos, n);
40122 s.finish(out, outpos);
40123 return 0;
40124}
40125
40126function crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {
40127 var x = new Uint8Array(16);
40128 crypto_onetimeauth(x,0,m,mpos,n,k);
40129 return crypto_verify_16(h,hpos,x,0);
40130}
40131
40132function crypto_secretbox(c,m,d,n,k) {
40133 var i;
40134 if (d < 32) return -1;
40135 crypto_stream_xor(c,0,m,0,d,n,k);
40136 crypto_onetimeauth(c, 16, c, 32, d - 32, c);
40137 for (i = 0; i < 16; i++) c[i] = 0;
40138 return 0;
40139}
40140
40141function crypto_secretbox_open(m,c,d,n,k) {
40142 var i;
40143 var x = new Uint8Array(32);
40144 if (d < 32) return -1;
40145 crypto_stream(x,0,32,n,k);
40146 if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;
40147 crypto_stream_xor(m,0,c,0,d,n,k);
40148 for (i = 0; i < 32; i++) m[i] = 0;
40149 return 0;
40150}
40151
40152function set25519(r, a) {
40153 var i;
40154 for (i = 0; i < 16; i++) r[i] = a[i]|0;
40155}
40156
40157function car25519(o) {
40158 var i, v, c = 1;
40159 for (i = 0; i < 16; i++) {
40160 v = o[i] + c + 65535;
40161 c = Math.floor(v / 65536);
40162 o[i] = v - c * 65536;
40163 }
40164 o[0] += c-1 + 37 * (c-1);
40165}
40166
40167function sel25519(p, q, b) {
40168 var t, c = ~(b-1);
40169 for (var i = 0; i < 16; i++) {
40170 t = c & (p[i] ^ q[i]);
40171 p[i] ^= t;
40172 q[i] ^= t;
40173 }
40174}
40175
40176function pack25519(o, n) {
40177 var i, j, b;
40178 var m = gf(), t = gf();
40179 for (i = 0; i < 16; i++) t[i] = n[i];
40180 car25519(t);
40181 car25519(t);
40182 car25519(t);
40183 for (j = 0; j < 2; j++) {
40184 m[0] = t[0] - 0xffed;
40185 for (i = 1; i < 15; i++) {
40186 m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);
40187 m[i-1] &= 0xffff;
40188 }
40189 m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);
40190 b = (m[15]>>16) & 1;
40191 m[14] &= 0xffff;
40192 sel25519(t, m, 1-b);
40193 }
40194 for (i = 0; i < 16; i++) {
40195 o[2*i] = t[i] & 0xff;
40196 o[2*i+1] = t[i]>>8;
40197 }
40198}
40199
40200function neq25519(a, b) {
40201 var c = new Uint8Array(32), d = new Uint8Array(32);
40202 pack25519(c, a);
40203 pack25519(d, b);
40204 return crypto_verify_32(c, 0, d, 0);
40205}
40206
40207function par25519(a) {
40208 var d = new Uint8Array(32);
40209 pack25519(d, a);
40210 return d[0] & 1;
40211}
40212
40213function unpack25519(o, n) {
40214 var i;
40215 for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);
40216 o[15] &= 0x7fff;
40217}
40218
40219function A(o, a, b) {
40220 for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];
40221}
40222
40223function Z(o, a, b) {
40224 for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];
40225}
40226
40227function M(o, a, b) {
40228 var v, c,
40229 t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,
40230 t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,
40231 t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,
40232 t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,
40233 b0 = b[0],
40234 b1 = b[1],
40235 b2 = b[2],
40236 b3 = b[3],
40237 b4 = b[4],
40238 b5 = b[5],
40239 b6 = b[6],
40240 b7 = b[7],
40241 b8 = b[8],
40242 b9 = b[9],
40243 b10 = b[10],
40244 b11 = b[11],
40245 b12 = b[12],
40246 b13 = b[13],
40247 b14 = b[14],
40248 b15 = b[15];
40249
40250 v = a[0];
40251 t0 += v * b0;
40252 t1 += v * b1;
40253 t2 += v * b2;
40254 t3 += v * b3;
40255 t4 += v * b4;
40256 t5 += v * b5;
40257 t6 += v * b6;
40258 t7 += v * b7;
40259 t8 += v * b8;
40260 t9 += v * b9;
40261 t10 += v * b10;
40262 t11 += v * b11;
40263 t12 += v * b12;
40264 t13 += v * b13;
40265 t14 += v * b14;
40266 t15 += v * b15;
40267 v = a[1];
40268 t1 += v * b0;
40269 t2 += v * b1;
40270 t3 += v * b2;
40271 t4 += v * b3;
40272 t5 += v * b4;
40273 t6 += v * b5;
40274 t7 += v * b6;
40275 t8 += v * b7;
40276 t9 += v * b8;
40277 t10 += v * b9;
40278 t11 += v * b10;
40279 t12 += v * b11;
40280 t13 += v * b12;
40281 t14 += v * b13;
40282 t15 += v * b14;
40283 t16 += v * b15;
40284 v = a[2];
40285 t2 += v * b0;
40286 t3 += v * b1;
40287 t4 += v * b2;
40288 t5 += v * b3;
40289 t6 += v * b4;
40290 t7 += v * b5;
40291 t8 += v * b6;
40292 t9 += v * b7;
40293 t10 += v * b8;
40294 t11 += v * b9;
40295 t12 += v * b10;
40296 t13 += v * b11;
40297 t14 += v * b12;
40298 t15 += v * b13;
40299 t16 += v * b14;
40300 t17 += v * b15;
40301 v = a[3];
40302 t3 += v * b0;
40303 t4 += v * b1;
40304 t5 += v * b2;
40305 t6 += v * b3;
40306 t7 += v * b4;
40307 t8 += v * b5;
40308 t9 += v * b6;
40309 t10 += v * b7;
40310 t11 += v * b8;
40311 t12 += v * b9;
40312 t13 += v * b10;
40313 t14 += v * b11;
40314 t15 += v * b12;
40315 t16 += v * b13;
40316 t17 += v * b14;
40317 t18 += v * b15;
40318 v = a[4];
40319 t4 += v * b0;
40320 t5 += v * b1;
40321 t6 += v * b2;
40322 t7 += v * b3;
40323 t8 += v * b4;
40324 t9 += v * b5;
40325 t10 += v * b6;
40326 t11 += v * b7;
40327 t12 += v * b8;
40328 t13 += v * b9;
40329 t14 += v * b10;
40330 t15 += v * b11;
40331 t16 += v * b12;
40332 t17 += v * b13;
40333 t18 += v * b14;
40334 t19 += v * b15;
40335 v = a[5];
40336 t5 += v * b0;
40337 t6 += v * b1;
40338 t7 += v * b2;
40339 t8 += v * b3;
40340 t9 += v * b4;
40341 t10 += v * b5;
40342 t11 += v * b6;
40343 t12 += v * b7;
40344 t13 += v * b8;
40345 t14 += v * b9;
40346 t15 += v * b10;
40347 t16 += v * b11;
40348 t17 += v * b12;
40349 t18 += v * b13;
40350 t19 += v * b14;
40351 t20 += v * b15;
40352 v = a[6];
40353 t6 += v * b0;
40354 t7 += v * b1;
40355 t8 += v * b2;
40356 t9 += v * b3;
40357 t10 += v * b4;
40358 t11 += v * b5;
40359 t12 += v * b6;
40360 t13 += v * b7;
40361 t14 += v * b8;
40362 t15 += v * b9;
40363 t16 += v * b10;
40364 t17 += v * b11;
40365 t18 += v * b12;
40366 t19 += v * b13;
40367 t20 += v * b14;
40368 t21 += v * b15;
40369 v = a[7];
40370 t7 += v * b0;
40371 t8 += v * b1;
40372 t9 += v * b2;
40373 t10 += v * b3;
40374 t11 += v * b4;
40375 t12 += v * b5;
40376 t13 += v * b6;
40377 t14 += v * b7;
40378 t15 += v * b8;
40379 t16 += v * b9;
40380 t17 += v * b10;
40381 t18 += v * b11;
40382 t19 += v * b12;
40383 t20 += v * b13;
40384 t21 += v * b14;
40385 t22 += v * b15;
40386 v = a[8];
40387 t8 += v * b0;
40388 t9 += v * b1;
40389 t10 += v * b2;
40390 t11 += v * b3;
40391 t12 += v * b4;
40392 t13 += v * b5;
40393 t14 += v * b6;
40394 t15 += v * b7;
40395 t16 += v * b8;
40396 t17 += v * b9;
40397 t18 += v * b10;
40398 t19 += v * b11;
40399 t20 += v * b12;
40400 t21 += v * b13;
40401 t22 += v * b14;
40402 t23 += v * b15;
40403 v = a[9];
40404 t9 += v * b0;
40405 t10 += v * b1;
40406 t11 += v * b2;
40407 t12 += v * b3;
40408 t13 += v * b4;
40409 t14 += v * b5;
40410 t15 += v * b6;
40411 t16 += v * b7;
40412 t17 += v * b8;
40413 t18 += v * b9;
40414 t19 += v * b10;
40415 t20 += v * b11;
40416 t21 += v * b12;
40417 t22 += v * b13;
40418 t23 += v * b14;
40419 t24 += v * b15;
40420 v = a[10];
40421 t10 += v * b0;
40422 t11 += v * b1;
40423 t12 += v * b2;
40424 t13 += v * b3;
40425 t14 += v * b4;
40426 t15 += v * b5;
40427 t16 += v * b6;
40428 t17 += v * b7;
40429 t18 += v * b8;
40430 t19 += v * b9;
40431 t20 += v * b10;
40432 t21 += v * b11;
40433 t22 += v * b12;
40434 t23 += v * b13;
40435 t24 += v * b14;
40436 t25 += v * b15;
40437 v = a[11];
40438 t11 += v * b0;
40439 t12 += v * b1;
40440 t13 += v * b2;
40441 t14 += v * b3;
40442 t15 += v * b4;
40443 t16 += v * b5;
40444 t17 += v * b6;
40445 t18 += v * b7;
40446 t19 += v * b8;
40447 t20 += v * b9;
40448 t21 += v * b10;
40449 t22 += v * b11;
40450 t23 += v * b12;
40451 t24 += v * b13;
40452 t25 += v * b14;
40453 t26 += v * b15;
40454 v = a[12];
40455 t12 += v * b0;
40456 t13 += v * b1;
40457 t14 += v * b2;
40458 t15 += v * b3;
40459 t16 += v * b4;
40460 t17 += v * b5;
40461 t18 += v * b6;
40462 t19 += v * b7;
40463 t20 += v * b8;
40464 t21 += v * b9;
40465 t22 += v * b10;
40466 t23 += v * b11;
40467 t24 += v * b12;
40468 t25 += v * b13;
40469 t26 += v * b14;
40470 t27 += v * b15;
40471 v = a[13];
40472 t13 += v * b0;
40473 t14 += v * b1;
40474 t15 += v * b2;
40475 t16 += v * b3;
40476 t17 += v * b4;
40477 t18 += v * b5;
40478 t19 += v * b6;
40479 t20 += v * b7;
40480 t21 += v * b8;
40481 t22 += v * b9;
40482 t23 += v * b10;
40483 t24 += v * b11;
40484 t25 += v * b12;
40485 t26 += v * b13;
40486 t27 += v * b14;
40487 t28 += v * b15;
40488 v = a[14];
40489 t14 += v * b0;
40490 t15 += v * b1;
40491 t16 += v * b2;
40492 t17 += v * b3;
40493 t18 += v * b4;
40494 t19 += v * b5;
40495 t20 += v * b6;
40496 t21 += v * b7;
40497 t22 += v * b8;
40498 t23 += v * b9;
40499 t24 += v * b10;
40500 t25 += v * b11;
40501 t26 += v * b12;
40502 t27 += v * b13;
40503 t28 += v * b14;
40504 t29 += v * b15;
40505 v = a[15];
40506 t15 += v * b0;
40507 t16 += v * b1;
40508 t17 += v * b2;
40509 t18 += v * b3;
40510 t19 += v * b4;
40511 t20 += v * b5;
40512 t21 += v * b6;
40513 t22 += v * b7;
40514 t23 += v * b8;
40515 t24 += v * b9;
40516 t25 += v * b10;
40517 t26 += v * b11;
40518 t27 += v * b12;
40519 t28 += v * b13;
40520 t29 += v * b14;
40521 t30 += v * b15;
40522
40523 t0 += 38 * t16;
40524 t1 += 38 * t17;
40525 t2 += 38 * t18;
40526 t3 += 38 * t19;
40527 t4 += 38 * t20;
40528 t5 += 38 * t21;
40529 t6 += 38 * t22;
40530 t7 += 38 * t23;
40531 t8 += 38 * t24;
40532 t9 += 38 * t25;
40533 t10 += 38 * t26;
40534 t11 += 38 * t27;
40535 t12 += 38 * t28;
40536 t13 += 38 * t29;
40537 t14 += 38 * t30;
40538 // t15 left as is
40539
40540 // first car
40541 c = 1;
40542 v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;
40543 v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;
40544 v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;
40545 v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;
40546 v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;
40547 v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;
40548 v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;
40549 v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;
40550 v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;
40551 v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;
40552 v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;
40553 v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;
40554 v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;
40555 v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;
40556 v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;
40557 v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;
40558 t0 += c-1 + 37 * (c-1);
40559
40560 // second car
40561 c = 1;
40562 v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;
40563 v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;
40564 v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;
40565 v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;
40566 v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;
40567 v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;
40568 v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;
40569 v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;
40570 v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;
40571 v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;
40572 v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;
40573 v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;
40574 v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;
40575 v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;
40576 v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;
40577 v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;
40578 t0 += c-1 + 37 * (c-1);
40579
40580 o[ 0] = t0;
40581 o[ 1] = t1;
40582 o[ 2] = t2;
40583 o[ 3] = t3;
40584 o[ 4] = t4;
40585 o[ 5] = t5;
40586 o[ 6] = t6;
40587 o[ 7] = t7;
40588 o[ 8] = t8;
40589 o[ 9] = t9;
40590 o[10] = t10;
40591 o[11] = t11;
40592 o[12] = t12;
40593 o[13] = t13;
40594 o[14] = t14;
40595 o[15] = t15;
40596}
40597
40598function S(o, a) {
40599 M(o, a, a);
40600}
40601
40602function inv25519(o, i) {
40603 var c = gf();
40604 var a;
40605 for (a = 0; a < 16; a++) c[a] = i[a];
40606 for (a = 253; a >= 0; a--) {
40607 S(c, c);
40608 if(a !== 2 && a !== 4) M(c, c, i);
40609 }
40610 for (a = 0; a < 16; a++) o[a] = c[a];
40611}
40612
40613function pow2523(o, i) {
40614 var c = gf();
40615 var a;
40616 for (a = 0; a < 16; a++) c[a] = i[a];
40617 for (a = 250; a >= 0; a--) {
40618 S(c, c);
40619 if(a !== 1) M(c, c, i);
40620 }
40621 for (a = 0; a < 16; a++) o[a] = c[a];
40622}
40623
40624function crypto_scalarmult(q, n, p) {
40625 var z = new Uint8Array(32);
40626 var x = new Float64Array(80), r, i;
40627 var a = gf(), b = gf(), c = gf(),
40628 d = gf(), e = gf(), f = gf();
40629 for (i = 0; i < 31; i++) z[i] = n[i];
40630 z[31]=(n[31]&127)|64;
40631 z[0]&=248;
40632 unpack25519(x,p);
40633 for (i = 0; i < 16; i++) {
40634 b[i]=x[i];
40635 d[i]=a[i]=c[i]=0;
40636 }
40637 a[0]=d[0]=1;
40638 for (i=254; i>=0; --i) {
40639 r=(z[i>>>3]>>>(i&7))&1;
40640 sel25519(a,b,r);
40641 sel25519(c,d,r);
40642 A(e,a,c);
40643 Z(a,a,c);
40644 A(c,b,d);
40645 Z(b,b,d);
40646 S(d,e);
40647 S(f,a);
40648 M(a,c,a);
40649 M(c,b,e);
40650 A(e,a,c);
40651 Z(a,a,c);
40652 S(b,a);
40653 Z(c,d,f);
40654 M(a,c,_121665);
40655 A(a,a,d);
40656 M(c,c,a);
40657 M(a,d,f);
40658 M(d,b,x);
40659 S(b,e);
40660 sel25519(a,b,r);
40661 sel25519(c,d,r);
40662 }
40663 for (i = 0; i < 16; i++) {
40664 x[i+16]=a[i];
40665 x[i+32]=c[i];
40666 x[i+48]=b[i];
40667 x[i+64]=d[i];
40668 }
40669 var x32 = x.subarray(32);
40670 var x16 = x.subarray(16);
40671 inv25519(x32,x32);
40672 M(x16,x16,x32);
40673 pack25519(q,x16);
40674 return 0;
40675}
40676
40677function crypto_scalarmult_base(q, n) {
40678 return crypto_scalarmult(q, n, _9);
40679}
40680
40681function crypto_box_keypair(y, x) {
40682 randombytes(x, 32);
40683 return crypto_scalarmult_base(y, x);
40684}
40685
40686function crypto_box_beforenm(k, y, x) {
40687 var s = new Uint8Array(32);
40688 crypto_scalarmult(s, x, y);
40689 return crypto_core_hsalsa20(k, _0, s, sigma);
40690}
40691
40692var crypto_box_afternm = crypto_secretbox;
40693var crypto_box_open_afternm = crypto_secretbox_open;
40694
40695function crypto_box(c, m, d, n, y, x) {
40696 var k = new Uint8Array(32);
40697 crypto_box_beforenm(k, y, x);
40698 return crypto_box_afternm(c, m, d, n, k);
40699}
40700
40701function crypto_box_open(m, c, d, n, y, x) {
40702 var k = new Uint8Array(32);
40703 crypto_box_beforenm(k, y, x);
40704 return crypto_box_open_afternm(m, c, d, n, k);
40705}
40706
40707var K = [
40708 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
40709 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
40710 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
40711 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
40712 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
40713 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
40714 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
40715 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
40716 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
40717 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
40718 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
40719 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
40720 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
40721 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
40722 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
40723 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
40724 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
40725 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
40726 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
40727 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
40728 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
40729 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
40730 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
40731 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
40732 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
40733 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
40734 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
40735 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
40736 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
40737 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
40738 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
40739 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
40740 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
40741 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
40742 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
40743 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
40744 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
40745 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
40746 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
40747 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
40748];
40749
40750function crypto_hashblocks_hl(hh, hl, m, n) {
40751 var wh = new Int32Array(16), wl = new Int32Array(16),
40752 bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,
40753 bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,
40754 th, tl, i, j, h, l, a, b, c, d;
40755
40756 var ah0 = hh[0],
40757 ah1 = hh[1],
40758 ah2 = hh[2],
40759 ah3 = hh[3],
40760 ah4 = hh[4],
40761 ah5 = hh[5],
40762 ah6 = hh[6],
40763 ah7 = hh[7],
40764
40765 al0 = hl[0],
40766 al1 = hl[1],
40767 al2 = hl[2],
40768 al3 = hl[3],
40769 al4 = hl[4],
40770 al5 = hl[5],
40771 al6 = hl[6],
40772 al7 = hl[7];
40773
40774 var pos = 0;
40775 while (n >= 128) {
40776 for (i = 0; i < 16; i++) {
40777 j = 8 * i + pos;
40778 wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];
40779 wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];
40780 }
40781 for (i = 0; i < 80; i++) {
40782 bh0 = ah0;
40783 bh1 = ah1;
40784 bh2 = ah2;
40785 bh3 = ah3;
40786 bh4 = ah4;
40787 bh5 = ah5;
40788 bh6 = ah6;
40789 bh7 = ah7;
40790
40791 bl0 = al0;
40792 bl1 = al1;
40793 bl2 = al2;
40794 bl3 = al3;
40795 bl4 = al4;
40796 bl5 = al5;
40797 bl6 = al6;
40798 bl7 = al7;
40799
40800 // add
40801 h = ah7;
40802 l = al7;
40803
40804 a = l & 0xffff; b = l >>> 16;
40805 c = h & 0xffff; d = h >>> 16;
40806
40807 // Sigma1
40808 h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));
40809 l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));
40810
40811 a += l & 0xffff; b += l >>> 16;
40812 c += h & 0xffff; d += h >>> 16;
40813
40814 // Ch
40815 h = (ah4 & ah5) ^ (~ah4 & ah6);
40816 l = (al4 & al5) ^ (~al4 & al6);
40817
40818 a += l & 0xffff; b += l >>> 16;
40819 c += h & 0xffff; d += h >>> 16;
40820
40821 // K
40822 h = K[i*2];
40823 l = K[i*2+1];
40824
40825 a += l & 0xffff; b += l >>> 16;
40826 c += h & 0xffff; d += h >>> 16;
40827
40828 // w
40829 h = wh[i%16];
40830 l = wl[i%16];
40831
40832 a += l & 0xffff; b += l >>> 16;
40833 c += h & 0xffff; d += h >>> 16;
40834
40835 b += a >>> 16;
40836 c += b >>> 16;
40837 d += c >>> 16;
40838
40839 th = c & 0xffff | d << 16;
40840 tl = a & 0xffff | b << 16;
40841
40842 // add
40843 h = th;
40844 l = tl;
40845
40846 a = l & 0xffff; b = l >>> 16;
40847 c = h & 0xffff; d = h >>> 16;
40848
40849 // Sigma0
40850 h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));
40851 l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));
40852
40853 a += l & 0xffff; b += l >>> 16;
40854 c += h & 0xffff; d += h >>> 16;
40855
40856 // Maj
40857 h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);
40858 l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);
40859
40860 a += l & 0xffff; b += l >>> 16;
40861 c += h & 0xffff; d += h >>> 16;
40862
40863 b += a >>> 16;
40864 c += b >>> 16;
40865 d += c >>> 16;
40866
40867 bh7 = (c & 0xffff) | (d << 16);
40868 bl7 = (a & 0xffff) | (b << 16);
40869
40870 // add
40871 h = bh3;
40872 l = bl3;
40873
40874 a = l & 0xffff; b = l >>> 16;
40875 c = h & 0xffff; d = h >>> 16;
40876
40877 h = th;
40878 l = tl;
40879
40880 a += l & 0xffff; b += l >>> 16;
40881 c += h & 0xffff; d += h >>> 16;
40882
40883 b += a >>> 16;
40884 c += b >>> 16;
40885 d += c >>> 16;
40886
40887 bh3 = (c & 0xffff) | (d << 16);
40888 bl3 = (a & 0xffff) | (b << 16);
40889
40890 ah1 = bh0;
40891 ah2 = bh1;
40892 ah3 = bh2;
40893 ah4 = bh3;
40894 ah5 = bh4;
40895 ah6 = bh5;
40896 ah7 = bh6;
40897 ah0 = bh7;
40898
40899 al1 = bl0;
40900 al2 = bl1;
40901 al3 = bl2;
40902 al4 = bl3;
40903 al5 = bl4;
40904 al6 = bl5;
40905 al7 = bl6;
40906 al0 = bl7;
40907
40908 if (i%16 === 15) {
40909 for (j = 0; j < 16; j++) {
40910 // add
40911 h = wh[j];
40912 l = wl[j];
40913
40914 a = l & 0xffff; b = l >>> 16;
40915 c = h & 0xffff; d = h >>> 16;
40916
40917 h = wh[(j+9)%16];
40918 l = wl[(j+9)%16];
40919
40920 a += l & 0xffff; b += l >>> 16;
40921 c += h & 0xffff; d += h >>> 16;
40922
40923 // sigma0
40924 th = wh[(j+1)%16];
40925 tl = wl[(j+1)%16];
40926 h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);
40927 l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));
40928
40929 a += l & 0xffff; b += l >>> 16;
40930 c += h & 0xffff; d += h >>> 16;
40931
40932 // sigma1
40933 th = wh[(j+14)%16];
40934 tl = wl[(j+14)%16];
40935 h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);
40936 l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));
40937
40938 a += l & 0xffff; b += l >>> 16;
40939 c += h & 0xffff; d += h >>> 16;
40940
40941 b += a >>> 16;
40942 c += b >>> 16;
40943 d += c >>> 16;
40944
40945 wh[j] = (c & 0xffff) | (d << 16);
40946 wl[j] = (a & 0xffff) | (b << 16);
40947 }
40948 }
40949 }
40950
40951 // add
40952 h = ah0;
40953 l = al0;
40954
40955 a = l & 0xffff; b = l >>> 16;
40956 c = h & 0xffff; d = h >>> 16;
40957
40958 h = hh[0];
40959 l = hl[0];
40960
40961 a += l & 0xffff; b += l >>> 16;
40962 c += h & 0xffff; d += h >>> 16;
40963
40964 b += a >>> 16;
40965 c += b >>> 16;
40966 d += c >>> 16;
40967
40968 hh[0] = ah0 = (c & 0xffff) | (d << 16);
40969 hl[0] = al0 = (a & 0xffff) | (b << 16);
40970
40971 h = ah1;
40972 l = al1;
40973
40974 a = l & 0xffff; b = l >>> 16;
40975 c = h & 0xffff; d = h >>> 16;
40976
40977 h = hh[1];
40978 l = hl[1];
40979
40980 a += l & 0xffff; b += l >>> 16;
40981 c += h & 0xffff; d += h >>> 16;
40982
40983 b += a >>> 16;
40984 c += b >>> 16;
40985 d += c >>> 16;
40986
40987 hh[1] = ah1 = (c & 0xffff) | (d << 16);
40988 hl[1] = al1 = (a & 0xffff) | (b << 16);
40989
40990 h = ah2;
40991 l = al2;
40992
40993 a = l & 0xffff; b = l >>> 16;
40994 c = h & 0xffff; d = h >>> 16;
40995
40996 h = hh[2];
40997 l = hl[2];
40998
40999 a += l & 0xffff; b += l >>> 16;
41000 c += h & 0xffff; d += h >>> 16;
41001
41002 b += a >>> 16;
41003 c += b >>> 16;
41004 d += c >>> 16;
41005
41006 hh[2] = ah2 = (c & 0xffff) | (d << 16);
41007 hl[2] = al2 = (a & 0xffff) | (b << 16);
41008
41009 h = ah3;
41010 l = al3;
41011
41012 a = l & 0xffff; b = l >>> 16;
41013 c = h & 0xffff; d = h >>> 16;
41014
41015 h = hh[3];
41016 l = hl[3];
41017
41018 a += l & 0xffff; b += l >>> 16;
41019 c += h & 0xffff; d += h >>> 16;
41020
41021 b += a >>> 16;
41022 c += b >>> 16;
41023 d += c >>> 16;
41024
41025 hh[3] = ah3 = (c & 0xffff) | (d << 16);
41026 hl[3] = al3 = (a & 0xffff) | (b << 16);
41027
41028 h = ah4;
41029 l = al4;
41030
41031 a = l & 0xffff; b = l >>> 16;
41032 c = h & 0xffff; d = h >>> 16;
41033
41034 h = hh[4];
41035 l = hl[4];
41036
41037 a += l & 0xffff; b += l >>> 16;
41038 c += h & 0xffff; d += h >>> 16;
41039
41040 b += a >>> 16;
41041 c += b >>> 16;
41042 d += c >>> 16;
41043
41044 hh[4] = ah4 = (c & 0xffff) | (d << 16);
41045 hl[4] = al4 = (a & 0xffff) | (b << 16);
41046
41047 h = ah5;
41048 l = al5;
41049
41050 a = l & 0xffff; b = l >>> 16;
41051 c = h & 0xffff; d = h >>> 16;
41052
41053 h = hh[5];
41054 l = hl[5];
41055
41056 a += l & 0xffff; b += l >>> 16;
41057 c += h & 0xffff; d += h >>> 16;
41058
41059 b += a >>> 16;
41060 c += b >>> 16;
41061 d += c >>> 16;
41062
41063 hh[5] = ah5 = (c & 0xffff) | (d << 16);
41064 hl[5] = al5 = (a & 0xffff) | (b << 16);
41065
41066 h = ah6;
41067 l = al6;
41068
41069 a = l & 0xffff; b = l >>> 16;
41070 c = h & 0xffff; d = h >>> 16;
41071
41072 h = hh[6];
41073 l = hl[6];
41074
41075 a += l & 0xffff; b += l >>> 16;
41076 c += h & 0xffff; d += h >>> 16;
41077
41078 b += a >>> 16;
41079 c += b >>> 16;
41080 d += c >>> 16;
41081
41082 hh[6] = ah6 = (c & 0xffff) | (d << 16);
41083 hl[6] = al6 = (a & 0xffff) | (b << 16);
41084
41085 h = ah7;
41086 l = al7;
41087
41088 a = l & 0xffff; b = l >>> 16;
41089 c = h & 0xffff; d = h >>> 16;
41090
41091 h = hh[7];
41092 l = hl[7];
41093
41094 a += l & 0xffff; b += l >>> 16;
41095 c += h & 0xffff; d += h >>> 16;
41096
41097 b += a >>> 16;
41098 c += b >>> 16;
41099 d += c >>> 16;
41100
41101 hh[7] = ah7 = (c & 0xffff) | (d << 16);
41102 hl[7] = al7 = (a & 0xffff) | (b << 16);
41103
41104 pos += 128;
41105 n -= 128;
41106 }
41107
41108 return n;
41109}
41110
41111function crypto_hash(out, m, n) {
41112 var hh = new Int32Array(8),
41113 hl = new Int32Array(8),
41114 x = new Uint8Array(256),
41115 i, b = n;
41116
41117 hh[0] = 0x6a09e667;
41118 hh[1] = 0xbb67ae85;
41119 hh[2] = 0x3c6ef372;
41120 hh[3] = 0xa54ff53a;
41121 hh[4] = 0x510e527f;
41122 hh[5] = 0x9b05688c;
41123 hh[6] = 0x1f83d9ab;
41124 hh[7] = 0x5be0cd19;
41125
41126 hl[0] = 0xf3bcc908;
41127 hl[1] = 0x84caa73b;
41128 hl[2] = 0xfe94f82b;
41129 hl[3] = 0x5f1d36f1;
41130 hl[4] = 0xade682d1;
41131 hl[5] = 0x2b3e6c1f;
41132 hl[6] = 0xfb41bd6b;
41133 hl[7] = 0x137e2179;
41134
41135 crypto_hashblocks_hl(hh, hl, m, n);
41136 n %= 128;
41137
41138 for (i = 0; i < n; i++) x[i] = m[b-n+i];
41139 x[n] = 128;
41140
41141 n = 256-128*(n<112?1:0);
41142 x[n-9] = 0;
41143 ts64(x, n-8, (b / 0x20000000) | 0, b << 3);
41144 crypto_hashblocks_hl(hh, hl, x, n);
41145
41146 for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);
41147
41148 return 0;
41149}
41150
41151function add(p, q) {
41152 var a = gf(), b = gf(), c = gf(),
41153 d = gf(), e = gf(), f = gf(),
41154 g = gf(), h = gf(), t = gf();
41155
41156 Z(a, p[1], p[0]);
41157 Z(t, q[1], q[0]);
41158 M(a, a, t);
41159 A(b, p[0], p[1]);
41160 A(t, q[0], q[1]);
41161 M(b, b, t);
41162 M(c, p[3], q[3]);
41163 M(c, c, D2);
41164 M(d, p[2], q[2]);
41165 A(d, d, d);
41166 Z(e, b, a);
41167 Z(f, d, c);
41168 A(g, d, c);
41169 A(h, b, a);
41170
41171 M(p[0], e, f);
41172 M(p[1], h, g);
41173 M(p[2], g, f);
41174 M(p[3], e, h);
41175}
41176
41177function cswap(p, q, b) {
41178 var i;
41179 for (i = 0; i < 4; i++) {
41180 sel25519(p[i], q[i], b);
41181 }
41182}
41183
41184function pack(r, p) {
41185 var tx = gf(), ty = gf(), zi = gf();
41186 inv25519(zi, p[2]);
41187 M(tx, p[0], zi);
41188 M(ty, p[1], zi);
41189 pack25519(r, ty);
41190 r[31] ^= par25519(tx) << 7;
41191}
41192
41193function scalarmult(p, q, s) {
41194 var b, i;
41195 set25519(p[0], gf0);
41196 set25519(p[1], gf1);
41197 set25519(p[2], gf1);
41198 set25519(p[3], gf0);
41199 for (i = 255; i >= 0; --i) {
41200 b = (s[(i/8)|0] >> (i&7)) & 1;
41201 cswap(p, q, b);
41202 add(q, p);
41203 add(p, p);
41204 cswap(p, q, b);
41205 }
41206}
41207
41208function scalarbase(p, s) {
41209 var q = [gf(), gf(), gf(), gf()];
41210 set25519(q[0], X);
41211 set25519(q[1], Y);
41212 set25519(q[2], gf1);
41213 M(q[3], X, Y);
41214 scalarmult(p, q, s);
41215}
41216
41217function crypto_sign_keypair(pk, sk, seeded) {
41218 var d = new Uint8Array(64);
41219 var p = [gf(), gf(), gf(), gf()];
41220 var i;
41221
41222 if (!seeded) randombytes(sk, 32);
41223 crypto_hash(d, sk, 32);
41224 d[0] &= 248;
41225 d[31] &= 127;
41226 d[31] |= 64;
41227
41228 scalarbase(p, d);
41229 pack(pk, p);
41230
41231 for (i = 0; i < 32; i++) sk[i+32] = pk[i];
41232 return 0;
41233}
41234
41235var L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);
41236
41237function modL(r, x) {
41238 var carry, i, j, k;
41239 for (i = 63; i >= 32; --i) {
41240 carry = 0;
41241 for (j = i - 32, k = i - 12; j < k; ++j) {
41242 x[j] += carry - 16 * x[i] * L[j - (i - 32)];
41243 carry = (x[j] + 128) >> 8;
41244 x[j] -= carry * 256;
41245 }
41246 x[j] += carry;
41247 x[i] = 0;
41248 }
41249 carry = 0;
41250 for (j = 0; j < 32; j++) {
41251 x[j] += carry - (x[31] >> 4) * L[j];
41252 carry = x[j] >> 8;
41253 x[j] &= 255;
41254 }
41255 for (j = 0; j < 32; j++) x[j] -= carry * L[j];
41256 for (i = 0; i < 32; i++) {
41257 x[i+1] += x[i] >> 8;
41258 r[i] = x[i] & 255;
41259 }
41260}
41261
41262function reduce(r) {
41263 var x = new Float64Array(64), i;
41264 for (i = 0; i < 64; i++) x[i] = r[i];
41265 for (i = 0; i < 64; i++) r[i] = 0;
41266 modL(r, x);
41267}
41268
41269// Note: difference from C - smlen returned, not passed as argument.
41270function crypto_sign(sm, m, n, sk) {
41271 var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);
41272 var i, j, x = new Float64Array(64);
41273 var p = [gf(), gf(), gf(), gf()];
41274
41275 crypto_hash(d, sk, 32);
41276 d[0] &= 248;
41277 d[31] &= 127;
41278 d[31] |= 64;
41279
41280 var smlen = n + 64;
41281 for (i = 0; i < n; i++) sm[64 + i] = m[i];
41282 for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];
41283
41284 crypto_hash(r, sm.subarray(32), n+32);
41285 reduce(r);
41286 scalarbase(p, r);
41287 pack(sm, p);
41288
41289 for (i = 32; i < 64; i++) sm[i] = sk[i];
41290 crypto_hash(h, sm, n + 64);
41291 reduce(h);
41292
41293 for (i = 0; i < 64; i++) x[i] = 0;
41294 for (i = 0; i < 32; i++) x[i] = r[i];
41295 for (i = 0; i < 32; i++) {
41296 for (j = 0; j < 32; j++) {
41297 x[i+j] += h[i] * d[j];
41298 }
41299 }
41300
41301 modL(sm.subarray(32), x);
41302 return smlen;
41303}
41304
41305function unpackneg(r, p) {
41306 var t = gf(), chk = gf(), num = gf(),
41307 den = gf(), den2 = gf(), den4 = gf(),
41308 den6 = gf();
41309
41310 set25519(r[2], gf1);
41311 unpack25519(r[1], p);
41312 S(num, r[1]);
41313 M(den, num, D);
41314 Z(num, num, r[2]);
41315 A(den, r[2], den);
41316
41317 S(den2, den);
41318 S(den4, den2);
41319 M(den6, den4, den2);
41320 M(t, den6, num);
41321 M(t, t, den);
41322
41323 pow2523(t, t);
41324 M(t, t, num);
41325 M(t, t, den);
41326 M(t, t, den);
41327 M(r[0], t, den);
41328
41329 S(chk, r[0]);
41330 M(chk, chk, den);
41331 if (neq25519(chk, num)) M(r[0], r[0], I);
41332
41333 S(chk, r[0]);
41334 M(chk, chk, den);
41335 if (neq25519(chk, num)) return -1;
41336
41337 if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);
41338
41339 M(r[3], r[0], r[1]);
41340 return 0;
41341}
41342
41343function crypto_sign_open(m, sm, n, pk) {
41344 var i, mlen;
41345 var t = new Uint8Array(32), h = new Uint8Array(64);
41346 var p = [gf(), gf(), gf(), gf()],
41347 q = [gf(), gf(), gf(), gf()];
41348
41349 mlen = -1;
41350 if (n < 64) return -1;
41351
41352 if (unpackneg(q, pk)) return -1;
41353
41354 for (i = 0; i < n; i++) m[i] = sm[i];
41355 for (i = 0; i < 32; i++) m[i+32] = pk[i];
41356 crypto_hash(h, m, n);
41357 reduce(h);
41358 scalarmult(p, q, h);
41359
41360 scalarbase(q, sm.subarray(32));
41361 add(p, q);
41362 pack(t, p);
41363
41364 n -= 64;
41365 if (crypto_verify_32(sm, 0, t, 0)) {
41366 for (i = 0; i < n; i++) m[i] = 0;
41367 return -1;
41368 }
41369
41370 for (i = 0; i < n; i++) m[i] = sm[i + 64];
41371 mlen = n;
41372 return mlen;
41373}
41374
41375var crypto_secretbox_KEYBYTES = 32,
41376 crypto_secretbox_NONCEBYTES = 24,
41377 crypto_secretbox_ZEROBYTES = 32,
41378 crypto_secretbox_BOXZEROBYTES = 16,
41379 crypto_scalarmult_BYTES = 32,
41380 crypto_scalarmult_SCALARBYTES = 32,
41381 crypto_box_PUBLICKEYBYTES = 32,
41382 crypto_box_SECRETKEYBYTES = 32,
41383 crypto_box_BEFORENMBYTES = 32,
41384 crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,
41385 crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,
41386 crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,
41387 crypto_sign_BYTES = 64,
41388 crypto_sign_PUBLICKEYBYTES = 32,
41389 crypto_sign_SECRETKEYBYTES = 64,
41390 crypto_sign_SEEDBYTES = 32,
41391 crypto_hash_BYTES = 64;
41392
41393nacl.lowlevel = {
41394 crypto_core_hsalsa20: crypto_core_hsalsa20,
41395 crypto_stream_xor: crypto_stream_xor,
41396 crypto_stream: crypto_stream,
41397 crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,
41398 crypto_stream_salsa20: crypto_stream_salsa20,
41399 crypto_onetimeauth: crypto_onetimeauth,
41400 crypto_onetimeauth_verify: crypto_onetimeauth_verify,
41401 crypto_verify_16: crypto_verify_16,
41402 crypto_verify_32: crypto_verify_32,
41403 crypto_secretbox: crypto_secretbox,
41404 crypto_secretbox_open: crypto_secretbox_open,
41405 crypto_scalarmult: crypto_scalarmult,
41406 crypto_scalarmult_base: crypto_scalarmult_base,
41407 crypto_box_beforenm: crypto_box_beforenm,
41408 crypto_box_afternm: crypto_box_afternm,
41409 crypto_box: crypto_box,
41410 crypto_box_open: crypto_box_open,
41411 crypto_box_keypair: crypto_box_keypair,
41412 crypto_hash: crypto_hash,
41413 crypto_sign: crypto_sign,
41414 crypto_sign_keypair: crypto_sign_keypair,
41415 crypto_sign_open: crypto_sign_open,
41416
41417 crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,
41418 crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,
41419 crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,
41420 crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,
41421 crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,
41422 crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,
41423 crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,
41424 crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,
41425 crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,
41426 crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,
41427 crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,
41428 crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,
41429 crypto_sign_BYTES: crypto_sign_BYTES,
41430 crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,
41431 crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,
41432 crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,
41433 crypto_hash_BYTES: crypto_hash_BYTES
41434};
41435
41436/* High-level API */
41437
41438function checkLengths(k, n) {
41439 if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');
41440 if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');
41441}
41442
41443function checkBoxLengths(pk, sk) {
41444 if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');
41445 if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');
41446}
41447
41448function checkArrayTypes() {
41449 for (var i = 0; i < arguments.length; i++) {
41450 if (!(arguments[i] instanceof Uint8Array))
41451 throw new TypeError('unexpected type, use Uint8Array');
41452 }
41453}
41454
41455function cleanup(arr) {
41456 for (var i = 0; i < arr.length; i++) arr[i] = 0;
41457}
41458
41459nacl.randomBytes = function(n) {
41460 var b = new Uint8Array(n);
41461 randombytes(b, n);
41462 return b;
41463};
41464
41465nacl.secretbox = function(msg, nonce, key) {
41466 checkArrayTypes(msg, nonce, key);
41467 checkLengths(key, nonce);
41468 var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);
41469 var c = new Uint8Array(m.length);
41470 for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];
41471 crypto_secretbox(c, m, m.length, nonce, key);
41472 return c.subarray(crypto_secretbox_BOXZEROBYTES);
41473};
41474
41475nacl.secretbox.open = function(box, nonce, key) {
41476 checkArrayTypes(box, nonce, key);
41477 checkLengths(key, nonce);
41478 var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);
41479 var m = new Uint8Array(c.length);
41480 for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];
41481 if (c.length < 32) return null;
41482 if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;
41483 return m.subarray(crypto_secretbox_ZEROBYTES);
41484};
41485
41486nacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;
41487nacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;
41488nacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;
41489
41490nacl.scalarMult = function(n, p) {
41491 checkArrayTypes(n, p);
41492 if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');
41493 if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');
41494 var q = new Uint8Array(crypto_scalarmult_BYTES);
41495 crypto_scalarmult(q, n, p);
41496 return q;
41497};
41498
41499nacl.scalarMult.base = function(n) {
41500 checkArrayTypes(n);
41501 if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');
41502 var q = new Uint8Array(crypto_scalarmult_BYTES);
41503 crypto_scalarmult_base(q, n);
41504 return q;
41505};
41506
41507nacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;
41508nacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;
41509
41510nacl.box = function(msg, nonce, publicKey, secretKey) {
41511 var k = nacl.box.before(publicKey, secretKey);
41512 return nacl.secretbox(msg, nonce, k);
41513};
41514
41515nacl.box.before = function(publicKey, secretKey) {
41516 checkArrayTypes(publicKey, secretKey);
41517 checkBoxLengths(publicKey, secretKey);
41518 var k = new Uint8Array(crypto_box_BEFORENMBYTES);
41519 crypto_box_beforenm(k, publicKey, secretKey);
41520 return k;
41521};
41522
41523nacl.box.after = nacl.secretbox;
41524
41525nacl.box.open = function(msg, nonce, publicKey, secretKey) {
41526 var k = nacl.box.before(publicKey, secretKey);
41527 return nacl.secretbox.open(msg, nonce, k);
41528};
41529
41530nacl.box.open.after = nacl.secretbox.open;
41531
41532nacl.box.keyPair = function() {
41533 var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
41534 var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);
41535 crypto_box_keypair(pk, sk);
41536 return {publicKey: pk, secretKey: sk};
41537};
41538
41539nacl.box.keyPair.fromSecretKey = function(secretKey) {
41540 checkArrayTypes(secretKey);
41541 if (secretKey.length !== crypto_box_SECRETKEYBYTES)
41542 throw new Error('bad secret key size');
41543 var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
41544 crypto_scalarmult_base(pk, secretKey);
41545 return {publicKey: pk, secretKey: new Uint8Array(secretKey)};
41546};
41547
41548nacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;
41549nacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;
41550nacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;
41551nacl.box.nonceLength = crypto_box_NONCEBYTES;
41552nacl.box.overheadLength = nacl.secretbox.overheadLength;
41553
41554nacl.sign = function(msg, secretKey) {
41555 checkArrayTypes(msg, secretKey);
41556 if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
41557 throw new Error('bad secret key size');
41558 var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);
41559 crypto_sign(signedMsg, msg, msg.length, secretKey);
41560 return signedMsg;
41561};
41562
41563nacl.sign.open = function(signedMsg, publicKey) {
41564 checkArrayTypes(signedMsg, publicKey);
41565 if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
41566 throw new Error('bad public key size');
41567 var tmp = new Uint8Array(signedMsg.length);
41568 var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);
41569 if (mlen < 0) return null;
41570 var m = new Uint8Array(mlen);
41571 for (var i = 0; i < m.length; i++) m[i] = tmp[i];
41572 return m;
41573};
41574
41575nacl.sign.detached = function(msg, secretKey) {
41576 var signedMsg = nacl.sign(msg, secretKey);
41577 var sig = new Uint8Array(crypto_sign_BYTES);
41578 for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];
41579 return sig;
41580};
41581
41582nacl.sign.detached.verify = function(msg, sig, publicKey) {
41583 checkArrayTypes(msg, sig, publicKey);
41584 if (sig.length !== crypto_sign_BYTES)
41585 throw new Error('bad signature size');
41586 if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
41587 throw new Error('bad public key size');
41588 var sm = new Uint8Array(crypto_sign_BYTES + msg.length);
41589 var m = new Uint8Array(crypto_sign_BYTES + msg.length);
41590 var i;
41591 for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];
41592 for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];
41593 return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);
41594};
41595
41596nacl.sign.keyPair = function() {
41597 var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
41598 var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
41599 crypto_sign_keypair(pk, sk);
41600 return {publicKey: pk, secretKey: sk};
41601};
41602
41603nacl.sign.keyPair.fromSecretKey = function(secretKey) {
41604 checkArrayTypes(secretKey);
41605 if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
41606 throw new Error('bad secret key size');
41607 var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
41608 for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];
41609 return {publicKey: pk, secretKey: new Uint8Array(secretKey)};
41610};
41611
41612nacl.sign.keyPair.fromSeed = function(seed) {
41613 checkArrayTypes(seed);
41614 if (seed.length !== crypto_sign_SEEDBYTES)
41615 throw new Error('bad seed size');
41616 var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
41617 var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
41618 for (var i = 0; i < 32; i++) sk[i] = seed[i];
41619 crypto_sign_keypair(pk, sk, true);
41620 return {publicKey: pk, secretKey: sk};
41621};
41622
41623nacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;
41624nacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;
41625nacl.sign.seedLength = crypto_sign_SEEDBYTES;
41626nacl.sign.signatureLength = crypto_sign_BYTES;
41627
41628nacl.hash = function(msg) {
41629 checkArrayTypes(msg);
41630 var h = new Uint8Array(crypto_hash_BYTES);
41631 crypto_hash(h, msg, msg.length);
41632 return h;
41633};
41634
41635nacl.hash.hashLength = crypto_hash_BYTES;
41636
41637nacl.verify = function(x, y) {
41638 checkArrayTypes(x, y);
41639 // Zero length arguments are considered not equal.
41640 if (x.length === 0 || y.length === 0) return false;
41641 if (x.length !== y.length) return false;
41642 return (vn(x, 0, y, 0, x.length) === 0) ? true : false;
41643};
41644
41645nacl.setPRNG = function(fn) {
41646 randombytes = fn;
41647};
41648
41649(function() {
41650 // Initialize PRNG if environment provides CSPRNG.
41651 // If not, methods calling randombytes will throw.
41652 var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;
41653 if (crypto && crypto.getRandomValues) {
41654 // Browsers.
41655 var QUOTA = 65536;
41656 nacl.setPRNG(function(x, n) {
41657 var i, v = new Uint8Array(n);
41658 for (i = 0; i < n; i += QUOTA) {
41659 crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));
41660 }
41661 for (i = 0; i < n; i++) x[i] = v[i];
41662 cleanup(v);
41663 });
41664 } else if (typeof require !== 'undefined') {
41665 // Node.js.
41666 crypto = require('crypto');
41667 if (crypto && crypto.randomBytes) {
41668 nacl.setPRNG(function(x, n) {
41669 var i, v = crypto.randomBytes(n);
41670 for (i = 0; i < n; i++) x[i] = v[i];
41671 cleanup(v);
41672 });
41673 }
41674 }
41675})();
41676
41677})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));
41678
41679},{"crypto":20}],441:[function(require,module,exports){
41680(function (global){
41681
41682/**
41683 * Module exports.
41684 */
41685
41686module.exports = deprecate;
41687
41688/**
41689 * Mark that a method should not be used.
41690 * Returns a modified function which warns once by default.
41691 *
41692 * If `localStorage.noDeprecation = true` is set, then it is a no-op.
41693 *
41694 * If `localStorage.throwDeprecation = true` is set, then deprecated functions
41695 * will throw an Error when invoked.
41696 *
41697 * If `localStorage.traceDeprecation = true` is set, then deprecated functions
41698 * will invoke `console.trace()` instead of `console.error()`.
41699 *
41700 * @param {Function} fn - the function to deprecate
41701 * @param {String} msg - the string to print to the console when `fn` is invoked
41702 * @returns {Function} a new "deprecated" version of `fn`
41703 * @api public
41704 */
41705
41706function deprecate (fn, msg) {
41707 if (config('noDeprecation')) {
41708 return fn;
41709 }
41710
41711 var warned = false;
41712 function deprecated() {
41713 if (!warned) {
41714 if (config('throwDeprecation')) {
41715 throw new Error(msg);
41716 } else if (config('traceDeprecation')) {
41717 console.trace(msg);
41718 } else {
41719 console.warn(msg);
41720 }
41721 warned = true;
41722 }
41723 return fn.apply(this, arguments);
41724 }
41725
41726 return deprecated;
41727}
41728
41729/**
41730 * Checks `localStorage` for boolean values for the given `name`.
41731 *
41732 * @param {String} name
41733 * @returns {Boolean}
41734 * @api private
41735 */
41736
41737function config (name) {
41738 // accessing global.localStorage can trigger a DOMException in sandboxed iframes
41739 try {
41740 if (!global.localStorage) return false;
41741 } catch (_) {
41742 return false;
41743 }
41744 var val = global.localStorage[name];
41745 if (null == val) return false;
41746 return String(val).toLowerCase() === 'true';
41747}
41748
41749}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
41750},{}],442:[function(require,module,exports){
41751module.exports = function isBuffer(arg) {
41752 return arg && typeof arg === 'object'
41753 && typeof arg.copy === 'function'
41754 && typeof arg.fill === 'function'
41755 && typeof arg.readUInt8 === 'function';
41756}
41757},{}],443:[function(require,module,exports){
41758(function (process,global){
41759// Copyright Joyent, Inc. and other Node contributors.
41760//
41761// Permission is hereby granted, free of charge, to any person obtaining a
41762// copy of this software and associated documentation files (the
41763// "Software"), to deal in the Software without restriction, including
41764// without limitation the rights to use, copy, modify, merge, publish,
41765// distribute, sublicense, and/or sell copies of the Software, and to permit
41766// persons to whom the Software is furnished to do so, subject to the
41767// following conditions:
41768//
41769// The above copyright notice and this permission notice shall be included
41770// in all copies or substantial portions of the Software.
41771//
41772// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
41773// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
41774// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
41775// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
41776// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
41777// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
41778// USE OR OTHER DEALINGS IN THE SOFTWARE.
41779
41780var formatRegExp = /%[sdj%]/g;
41781exports.format = function(f) {
41782 if (!isString(f)) {
41783 var objects = [];
41784 for (var i = 0; i < arguments.length; i++) {
41785 objects.push(inspect(arguments[i]));
41786 }
41787 return objects.join(' ');
41788 }
41789
41790 var i = 1;
41791 var args = arguments;
41792 var len = args.length;
41793 var str = String(f).replace(formatRegExp, function(x) {
41794 if (x === '%%') return '%';
41795 if (i >= len) return x;
41796 switch (x) {
41797 case '%s': return String(args[i++]);
41798 case '%d': return Number(args[i++]);
41799 case '%j':
41800 try {
41801 return JSON.stringify(args[i++]);
41802 } catch (_) {
41803 return '[Circular]';
41804 }
41805 default:
41806 return x;
41807 }
41808 });
41809 for (var x = args[i]; i < len; x = args[++i]) {
41810 if (isNull(x) || !isObject(x)) {
41811 str += ' ' + x;
41812 } else {
41813 str += ' ' + inspect(x);
41814 }
41815 }
41816 return str;
41817};
41818
41819
41820// Mark that a method should not be used.
41821// Returns a modified function which warns once by default.
41822// If --no-deprecation is set, then it is a no-op.
41823exports.deprecate = function(fn, msg) {
41824 // Allow for deprecating things in the process of starting up.
41825 if (isUndefined(global.process)) {
41826 return function() {
41827 return exports.deprecate(fn, msg).apply(this, arguments);
41828 };
41829 }
41830
41831 if (process.noDeprecation === true) {
41832 return fn;
41833 }
41834
41835 var warned = false;
41836 function deprecated() {
41837 if (!warned) {
41838 if (process.throwDeprecation) {
41839 throw new Error(msg);
41840 } else if (process.traceDeprecation) {
41841 console.trace(msg);
41842 } else {
41843 console.error(msg);
41844 }
41845 warned = true;
41846 }
41847 return fn.apply(this, arguments);
41848 }
41849
41850 return deprecated;
41851};
41852
41853
41854var debugs = {};
41855var debugEnviron;
41856exports.debuglog = function(set) {
41857 if (isUndefined(debugEnviron))
41858 debugEnviron = process.env.NODE_DEBUG || '';
41859 set = set.toUpperCase();
41860 if (!debugs[set]) {
41861 if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
41862 var pid = process.pid;
41863 debugs[set] = function() {
41864 var msg = exports.format.apply(exports, arguments);
41865 console.error('%s %d: %s', set, pid, msg);
41866 };
41867 } else {
41868 debugs[set] = function() {};
41869 }
41870 }
41871 return debugs[set];
41872};
41873
41874
41875/**
41876 * Echos the value of a value. Trys to print the value out
41877 * in the best way possible given the different types.
41878 *
41879 * @param {Object} obj The object to print out.
41880 * @param {Object} opts Optional options object that alters the output.
41881 */
41882/* legacy: obj, showHidden, depth, colors*/
41883function inspect(obj, opts) {
41884 // default options
41885 var ctx = {
41886 seen: [],
41887 stylize: stylizeNoColor
41888 };
41889 // legacy...
41890 if (arguments.length >= 3) ctx.depth = arguments[2];
41891 if (arguments.length >= 4) ctx.colors = arguments[3];
41892 if (isBoolean(opts)) {
41893 // legacy...
41894 ctx.showHidden = opts;
41895 } else if (opts) {
41896 // got an "options" object
41897 exports._extend(ctx, opts);
41898 }
41899 // set default options
41900 if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
41901 if (isUndefined(ctx.depth)) ctx.depth = 2;
41902 if (isUndefined(ctx.colors)) ctx.colors = false;
41903 if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
41904 if (ctx.colors) ctx.stylize = stylizeWithColor;
41905 return formatValue(ctx, obj, ctx.depth);
41906}
41907exports.inspect = inspect;
41908
41909
41910// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
41911inspect.colors = {
41912 'bold' : [1, 22],
41913 'italic' : [3, 23],
41914 'underline' : [4, 24],
41915 'inverse' : [7, 27],
41916 'white' : [37, 39],
41917 'grey' : [90, 39],
41918 'black' : [30, 39],
41919 'blue' : [34, 39],
41920 'cyan' : [36, 39],
41921 'green' : [32, 39],
41922 'magenta' : [35, 39],
41923 'red' : [31, 39],
41924 'yellow' : [33, 39]
41925};
41926
41927// Don't use 'blue' not visible on cmd.exe
41928inspect.styles = {
41929 'special': 'cyan',
41930 'number': 'yellow',
41931 'boolean': 'yellow',
41932 'undefined': 'grey',
41933 'null': 'bold',
41934 'string': 'green',
41935 'date': 'magenta',
41936 // "name": intentionally not styling
41937 'regexp': 'red'
41938};
41939
41940
41941function stylizeWithColor(str, styleType) {
41942 var style = inspect.styles[styleType];
41943
41944 if (style) {
41945 return '\u001b[' + inspect.colors[style][0] + 'm' + str +
41946 '\u001b[' + inspect.colors[style][1] + 'm';
41947 } else {
41948 return str;
41949 }
41950}
41951
41952
41953function stylizeNoColor(str, styleType) {
41954 return str;
41955}
41956
41957
41958function arrayToHash(array) {
41959 var hash = {};
41960
41961 array.forEach(function(val, idx) {
41962 hash[val] = true;
41963 });
41964
41965 return hash;
41966}
41967
41968
41969function formatValue(ctx, value, recurseTimes) {
41970 // Provide a hook for user-specified inspect functions.
41971 // Check that value is an object with an inspect function on it
41972 if (ctx.customInspect &&
41973 value &&
41974 isFunction(value.inspect) &&
41975 // Filter out the util module, it's inspect function is special
41976 value.inspect !== exports.inspect &&
41977 // Also filter out any prototype objects using the circular check.
41978 !(value.constructor && value.constructor.prototype === value)) {
41979 var ret = value.inspect(recurseTimes, ctx);
41980 if (!isString(ret)) {
41981 ret = formatValue(ctx, ret, recurseTimes);
41982 }
41983 return ret;
41984 }
41985
41986 // Primitive types cannot have properties
41987 var primitive = formatPrimitive(ctx, value);
41988 if (primitive) {
41989 return primitive;
41990 }
41991
41992 // Look up the keys of the object.
41993 var keys = Object.keys(value);
41994 var visibleKeys = arrayToHash(keys);
41995
41996 if (ctx.showHidden) {
41997 keys = Object.getOwnPropertyNames(value);
41998 }
41999
42000 // IE doesn't make error fields non-enumerable
42001 // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
42002 if (isError(value)
42003 && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
42004 return formatError(value);
42005 }
42006
42007 // Some type of object without properties can be shortcutted.
42008 if (keys.length === 0) {
42009 if (isFunction(value)) {
42010 var name = value.name ? ': ' + value.name : '';
42011 return ctx.stylize('[Function' + name + ']', 'special');
42012 }
42013 if (isRegExp(value)) {
42014 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
42015 }
42016 if (isDate(value)) {
42017 return ctx.stylize(Date.prototype.toString.call(value), 'date');
42018 }
42019 if (isError(value)) {
42020 return formatError(value);
42021 }
42022 }
42023
42024 var base = '', array = false, braces = ['{', '}'];
42025
42026 // Make Array say that they are Array
42027 if (isArray(value)) {
42028 array = true;
42029 braces = ['[', ']'];
42030 }
42031
42032 // Make functions say that they are functions
42033 if (isFunction(value)) {
42034 var n = value.name ? ': ' + value.name : '';
42035 base = ' [Function' + n + ']';
42036 }
42037
42038 // Make RegExps say that they are RegExps
42039 if (isRegExp(value)) {
42040 base = ' ' + RegExp.prototype.toString.call(value);
42041 }
42042
42043 // Make dates with properties first say the date
42044 if (isDate(value)) {
42045 base = ' ' + Date.prototype.toUTCString.call(value);
42046 }
42047
42048 // Make error with message first say the error
42049 if (isError(value)) {
42050 base = ' ' + formatError(value);
42051 }
42052
42053 if (keys.length === 0 && (!array || value.length == 0)) {
42054 return braces[0] + base + braces[1];
42055 }
42056
42057 if (recurseTimes < 0) {
42058 if (isRegExp(value)) {
42059 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
42060 } else {
42061 return ctx.stylize('[Object]', 'special');
42062 }
42063 }
42064
42065 ctx.seen.push(value);
42066
42067 var output;
42068 if (array) {
42069 output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
42070 } else {
42071 output = keys.map(function(key) {
42072 return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
42073 });
42074 }
42075
42076 ctx.seen.pop();
42077
42078 return reduceToSingleString(output, base, braces);
42079}
42080
42081
42082function formatPrimitive(ctx, value) {
42083 if (isUndefined(value))
42084 return ctx.stylize('undefined', 'undefined');
42085 if (isString(value)) {
42086 var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
42087 .replace(/'/g, "\\'")
42088 .replace(/\\"/g, '"') + '\'';
42089 return ctx.stylize(simple, 'string');
42090 }
42091 if (isNumber(value))
42092 return ctx.stylize('' + value, 'number');
42093 if (isBoolean(value))
42094 return ctx.stylize('' + value, 'boolean');
42095 // For some reason typeof null is "object", so special case here.
42096 if (isNull(value))
42097 return ctx.stylize('null', 'null');
42098}
42099
42100
42101function formatError(value) {
42102 return '[' + Error.prototype.toString.call(value) + ']';
42103}
42104
42105
42106function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
42107 var output = [];
42108 for (var i = 0, l = value.length; i < l; ++i) {
42109 if (hasOwnProperty(value, String(i))) {
42110 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
42111 String(i), true));
42112 } else {
42113 output.push('');
42114 }
42115 }
42116 keys.forEach(function(key) {
42117 if (!key.match(/^\d+$/)) {
42118 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
42119 key, true));
42120 }
42121 });
42122 return output;
42123}
42124
42125
42126function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
42127 var name, str, desc;
42128 desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
42129 if (desc.get) {
42130 if (desc.set) {
42131 str = ctx.stylize('[Getter/Setter]', 'special');
42132 } else {
42133 str = ctx.stylize('[Getter]', 'special');
42134 }
42135 } else {
42136 if (desc.set) {
42137 str = ctx.stylize('[Setter]', 'special');
42138 }
42139 }
42140 if (!hasOwnProperty(visibleKeys, key)) {
42141 name = '[' + key + ']';
42142 }
42143 if (!str) {
42144 if (ctx.seen.indexOf(desc.value) < 0) {
42145 if (isNull(recurseTimes)) {
42146 str = formatValue(ctx, desc.value, null);
42147 } else {
42148 str = formatValue(ctx, desc.value, recurseTimes - 1);
42149 }
42150 if (str.indexOf('\n') > -1) {
42151 if (array) {
42152 str = str.split('\n').map(function(line) {
42153 return ' ' + line;
42154 }).join('\n').substr(2);
42155 } else {
42156 str = '\n' + str.split('\n').map(function(line) {
42157 return ' ' + line;
42158 }).join('\n');
42159 }
42160 }
42161 } else {
42162 str = ctx.stylize('[Circular]', 'special');
42163 }
42164 }
42165 if (isUndefined(name)) {
42166 if (array && key.match(/^\d+$/)) {
42167 return str;
42168 }
42169 name = JSON.stringify('' + key);
42170 if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
42171 name = name.substr(1, name.length - 2);
42172 name = ctx.stylize(name, 'name');
42173 } else {
42174 name = name.replace(/'/g, "\\'")
42175 .replace(/\\"/g, '"')
42176 .replace(/(^"|"$)/g, "'");
42177 name = ctx.stylize(name, 'string');
42178 }
42179 }
42180
42181 return name + ': ' + str;
42182}
42183
42184
42185function reduceToSingleString(output, base, braces) {
42186 var numLinesEst = 0;
42187 var length = output.reduce(function(prev, cur) {
42188 numLinesEst++;
42189 if (cur.indexOf('\n') >= 0) numLinesEst++;
42190 return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
42191 }, 0);
42192
42193 if (length > 60) {
42194 return braces[0] +
42195 (base === '' ? '' : base + '\n ') +
42196 ' ' +
42197 output.join(',\n ') +
42198 ' ' +
42199 braces[1];
42200 }
42201
42202 return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
42203}
42204
42205
42206// NOTE: These type checking functions intentionally don't use `instanceof`
42207// because it is fragile and can be easily faked with `Object.create()`.
42208function isArray(ar) {
42209 return Array.isArray(ar);
42210}
42211exports.isArray = isArray;
42212
42213function isBoolean(arg) {
42214 return typeof arg === 'boolean';
42215}
42216exports.isBoolean = isBoolean;
42217
42218function isNull(arg) {
42219 return arg === null;
42220}
42221exports.isNull = isNull;
42222
42223function isNullOrUndefined(arg) {
42224 return arg == null;
42225}
42226exports.isNullOrUndefined = isNullOrUndefined;
42227
42228function isNumber(arg) {
42229 return typeof arg === 'number';
42230}
42231exports.isNumber = isNumber;
42232
42233function isString(arg) {
42234 return typeof arg === 'string';
42235}
42236exports.isString = isString;
42237
42238function isSymbol(arg) {
42239 return typeof arg === 'symbol';
42240}
42241exports.isSymbol = isSymbol;
42242
42243function isUndefined(arg) {
42244 return arg === void 0;
42245}
42246exports.isUndefined = isUndefined;
42247
42248function isRegExp(re) {
42249 return isObject(re) && objectToString(re) === '[object RegExp]';
42250}
42251exports.isRegExp = isRegExp;
42252
42253function isObject(arg) {
42254 return typeof arg === 'object' && arg !== null;
42255}
42256exports.isObject = isObject;
42257
42258function isDate(d) {
42259 return isObject(d) && objectToString(d) === '[object Date]';
42260}
42261exports.isDate = isDate;
42262
42263function isError(e) {
42264 return isObject(e) &&
42265 (objectToString(e) === '[object Error]' || e instanceof Error);
42266}
42267exports.isError = isError;
42268
42269function isFunction(arg) {
42270 return typeof arg === 'function';
42271}
42272exports.isFunction = isFunction;
42273
42274function isPrimitive(arg) {
42275 return arg === null ||
42276 typeof arg === 'boolean' ||
42277 typeof arg === 'number' ||
42278 typeof arg === 'string' ||
42279 typeof arg === 'symbol' || // ES6 symbol
42280 typeof arg === 'undefined';
42281}
42282exports.isPrimitive = isPrimitive;
42283
42284exports.isBuffer = require('./support/isBuffer');
42285
42286function objectToString(o) {
42287 return Object.prototype.toString.call(o);
42288}
42289
42290
42291function pad(n) {
42292 return n < 10 ? '0' + n.toString(10) : n.toString(10);
42293}
42294
42295
42296var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
42297 'Oct', 'Nov', 'Dec'];
42298
42299// 26 Feb 16:19:34
42300function timestamp() {
42301 var d = new Date();
42302 var time = [pad(d.getHours()),
42303 pad(d.getMinutes()),
42304 pad(d.getSeconds())].join(':');
42305 return [d.getDate(), months[d.getMonth()], time].join(' ');
42306}
42307
42308
42309// log is just a thin wrapper to console.log that prepends a timestamp
42310exports.log = function() {
42311 console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
42312};
42313
42314
42315/**
42316 * Inherit the prototype methods from one constructor into another.
42317 *
42318 * The Function.prototype.inherits from lang.js rewritten as a standalone
42319 * function (not on Function.prototype). NOTE: If this file is to be loaded
42320 * during bootstrapping this function needs to be rewritten using some native
42321 * functions as prototype setup using normal JavaScript does not work as
42322 * expected during bootstrapping (see mirror.js in r114903).
42323 *
42324 * @param {function} ctor Constructor function which needs to inherit the
42325 * prototype.
42326 * @param {function} superCtor Constructor function to inherit prototype from.
42327 */
42328exports.inherits = require('inherits');
42329
42330exports._extend = function(origin, add) {
42331 // Don't do anything if add isn't an object
42332 if (!add || !isObject(add)) return origin;
42333
42334 var keys = Object.keys(add);
42335 var i = keys.length;
42336 while (i--) {
42337 origin[keys[i]] = add[keys[i]];
42338 }
42339 return origin;
42340};
42341
42342function hasOwnProperty(obj, prop) {
42343 return Object.prototype.hasOwnProperty.call(obj, prop);
42344}
42345
42346}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
42347},{"./support/isBuffer":442,"_process":374,"inherits":119}],444:[function(require,module,exports){
42348var indexOf = function (xs, item) {
42349 if (xs.indexOf) return xs.indexOf(item);
42350 else for (var i = 0; i < xs.length; i++) {
42351 if (xs[i] === item) return i;
42352 }
42353 return -1;
42354};
42355var Object_keys = function (obj) {
42356 if (Object.keys) return Object.keys(obj)
42357 else {
42358 var res = [];
42359 for (var key in obj) res.push(key)
42360 return res;
42361 }
42362};
42363
42364var forEach = function (xs, fn) {
42365 if (xs.forEach) return xs.forEach(fn)
42366 else for (var i = 0; i < xs.length; i++) {
42367 fn(xs[i], i, xs);
42368 }
42369};
42370
42371var defineProp = (function() {
42372 try {
42373 Object.defineProperty({}, '_', {});
42374 return function(obj, name, value) {
42375 Object.defineProperty(obj, name, {
42376 writable: true,
42377 enumerable: false,
42378 configurable: true,
42379 value: value
42380 })
42381 };
42382 } catch(e) {
42383 return function(obj, name, value) {
42384 obj[name] = value;
42385 };
42386 }
42387}());
42388
42389var globals = ['Array', 'Boolean', 'Date', 'Error', 'EvalError', 'Function',
42390'Infinity', 'JSON', 'Math', 'NaN', 'Number', 'Object', 'RangeError',
42391'ReferenceError', 'RegExp', 'String', 'SyntaxError', 'TypeError', 'URIError',
42392'decodeURI', 'decodeURIComponent', 'encodeURI', 'encodeURIComponent', 'escape',
42393'eval', 'isFinite', 'isNaN', 'parseFloat', 'parseInt', 'undefined', 'unescape'];
42394
42395function Context() {}
42396Context.prototype = {};
42397
42398var Script = exports.Script = function NodeScript (code) {
42399 if (!(this instanceof Script)) return new Script(code);
42400 this.code = code;
42401};
42402
42403Script.prototype.runInContext = function (context) {
42404 if (!(context instanceof Context)) {
42405 throw new TypeError("needs a 'context' argument.");
42406 }
42407
42408 var iframe = document.createElement('iframe');
42409 if (!iframe.style) iframe.style = {};
42410 iframe.style.display = 'none';
42411
42412 document.body.appendChild(iframe);
42413
42414 var win = iframe.contentWindow;
42415 var wEval = win.eval, wExecScript = win.execScript;
42416
42417 if (!wEval && wExecScript) {
42418 // win.eval() magically appears when this is called in IE:
42419 wExecScript.call(win, 'null');
42420 wEval = win.eval;
42421 }
42422
42423 forEach(Object_keys(context), function (key) {
42424 win[key] = context[key];
42425 });
42426 forEach(globals, function (key) {
42427 if (context[key]) {
42428 win[key] = context[key];
42429 }
42430 });
42431
42432 var winKeys = Object_keys(win);
42433
42434 var res = wEval.call(win, this.code);
42435
42436 forEach(Object_keys(win), function (key) {
42437 // Avoid copying circular objects like `top` and `window` by only
42438 // updating existing context properties or new properties in the `win`
42439 // that was only introduced after the eval.
42440 if (key in context || indexOf(winKeys, key) === -1) {
42441 context[key] = win[key];
42442 }
42443 });
42444
42445 forEach(globals, function (key) {
42446 if (!(key in context)) {
42447 defineProp(context, key, win[key]);
42448 }
42449 });
42450
42451 document.body.removeChild(iframe);
42452
42453 return res;
42454};
42455
42456Script.prototype.runInThisContext = function () {
42457 return eval(this.code); // maybe...
42458};
42459
42460Script.prototype.runInNewContext = function (context) {
42461 var ctx = Script.createContext(context);
42462 var res = this.runInContext(ctx);
42463
42464 if (context) {
42465 forEach(Object_keys(ctx), function (key) {
42466 context[key] = ctx[key];
42467 });
42468 }
42469
42470 return res;
42471};
42472
42473forEach(Object_keys(Script.prototype), function (name) {
42474 exports[name] = Script[name] = function (code) {
42475 var s = Script(code);
42476 return s[name].apply(s, [].slice.call(arguments, 1));
42477 };
42478});
42479
42480exports.isContext = function (context) {
42481 return context instanceof Context;
42482};
42483
42484exports.createScript = function (code) {
42485 return exports.Script(code);
42486};
42487
42488exports.createContext = Script.createContext = function (context) {
42489 var copy = new Context();
42490 if(typeof context === 'object') {
42491 forEach(Object_keys(context), function (key) {
42492 copy[key] = context[key];
42493 });
42494 }
42495 return copy;
42496};
42497
42498},{}],445:[function(require,module,exports){
42499const StellarBase = require('stellar-base');
42500const edHd = require('ed25519-hd-key');
42501
42502window.stellarUtil = {
42503 getKeypair: function (path, seed) {
42504 const result = edHd.derivePath(path, seed);
42505 return StellarBase.Keypair.fromRawEd25519Seed(result.key);
42506 },
42507 dummyNetwork: {
42508 bip32: {public: 0, private: 0},
42509 messagePrefix: '',
42510 pubKeyHash: 0,
42511 scriptHash: 0,
42512 wif: 0,
42513 },
42514}
42515
42516},{"ed25519-hd-key":84,"stellar-base":412}]},{},[445]);