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
){
2 var aes
= require('browserify-aes')
3 var assert
= require('assert')
4 var Buffer
= require('safe-buffer').Buffer
5 var bs58check
= require('bs58check')
6 var bs58grscheck
= require('bs58grscheck')
7 var createHash
= require('create-hash')
8 var scrypt
= require('scryptsy')
9 var xor
= require('buffer-xor/inplace')
11 var ecurve
= require('ecurve')
12 var curve
= ecurve
.getCurveByName('secp256k1')
14 var BigInteger
= require('bigi')
18 N: 16384, // specified by BIP38
22 var NULL
= Buffer
.alloc(0)
24 function hash160 (buffer
) {
25 return createHash('rmd160').update(
26 createHash('sha256').update(buffer
).digest()
30 function hash256 (buffer
) {
31 return createHash('sha256').update(
32 createHash('sha256').update(buffer
).digest()
36 function getAddress (d
, compressed
, testnet
) {
37 var Q
= curve
.G
.multiply(d
).getEncoded(compressed
)
39 var payload
= Buffer
.allocUnsafe(21)
40 payload
.writeUInt8(testnet
? 0x6f : 0x24, 0) // XXX TODO FIXME bitcoin only??? damn you BIP38
43 return bs58grscheck
.encode(payload
)
46 function encryptRaw (buffer
, compressed
, passphrase
, progressCallback
, scryptParams
, testnet
) {
47 if (buffer
.length
!== 32) throw new Error('Invalid private key length')
48 scryptParams
= scryptParams
|| SCRYPT_PARAMS
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)
55 var N
= scryptParams
.N
56 var r
= scryptParams
.r
57 var p
= scryptParams
.p
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)
63 var xorBuf
= xor(derivedHalf1
, buffer
)
64 var cipher
= aes
.createCipheriv('aes-256-ecb', derivedHalf2
, NULL
)
65 cipher
.setAutoPadding(false)
68 var cipherText
= cipher
.read()
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)
76 cipherText
.copy(result
, 7)
81 function encrypt (buffer
, compressed
, passphrase
, progressCallback
, scryptParams
, testnet
) {
82 return bs58check
.encode(encryptRaw(buffer
, compressed
, passphrase
, progressCallback
, scryptParams
, testnet
))
85 // some of the techniques borrowed from: https://github.com/pointbiz/bitaddress.org
86 function 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
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')
97 passphrase
= Buffer
.from(passphrase
, 'utf8')
99 var flagByte
= buffer
.readUInt8(2)
100 var compressed
= flagByte
=== 0xe0
101 if (!compressed
&& flagByte
!== 0xc0) throw new Error('Invalid BIP38 compression flag')
103 var N
= scryptParams
.N
104 var r
= scryptParams
.r
105 var p
= scryptParams
.p
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)
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
)
117 var plainText
= decipher
.read()
118 var privateKey
= xor(derivedHalf1
, plainText
)
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
)
127 privateKey: privateKey
,
128 compressed: compressed
132 function decrypt (string
, passphrase
, progressCallback
, scryptParams
, testnet
) {
133 return decryptRaw(bs58check
.decode(string
), passphrase
, progressCallback
, scryptParams
, testnet
)
136 function 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
141 var flag
= buffer
.readUInt8(1)
142 var compressed
= (flag
& 0x20) !== 0
143 var hasLotSeq
= (flag
& 0x04) !== 0
145 assert
.equal((flag
& 0x24), flag
, 'Invalid private key.')
147 var addressHash
= buffer
.slice(2, 6)
148 var ownerEntropy
= buffer
.slice(6, 14)
151 // 4 bytes ownerSalt if 4 bytes lot/sequence
153 ownerSalt
= ownerEntropy
.slice(0, 4)
155 // else, 8 bytes ownerSalt
157 ownerSalt
= ownerEntropy
160 var encryptedPart1
= buffer
.slice(14, 22) // First 8 bytes
161 var encryptedPart2
= buffer
.slice(22, 38) // 16 bytes
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
)
170 var hashTarget
= Buffer
.concat([preFactor
, ownerEntropy
])
171 passFactor
= hash256(hashTarget
)
173 passFactor
= preFactor
176 var passInt
= BigInteger
.fromBuffer(passFactor
)
177 var passPoint
= curve
.G
.multiply(passInt
).getEncoded(true)
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)
183 var decipher
= aes
.createDecipheriv('aes-256-ecb', derivedHalf2
, Buffer
.alloc(0))
184 decipher
.setAutoPadding(false)
185 decipher
.end(encryptedPart2
)
187 var decryptedPart2
= decipher
.read()
188 var tmp
= xor(decryptedPart2
, derivedHalf1
.slice(16, 32))
189 var seedBPart2
= tmp
.slice(8, 16)
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
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
))
200 // d = passFactor * factorB (mod n)
201 var d
= passInt
.multiply(factorB
).mod(curve
.n
)
204 privateKey: d
.toBuffer(32),
205 compressed: compressed
209 function verify (string
) {
210 var decoded
= bs58grscheck
.decodeUnsafe(string
)
211 if (!decoded
) return false
213 if (decoded
.length
!== 39) return false
214 if (decoded
.readUInt8(0) !== 0x01) return false
216 var type
= decoded
.readUInt8(1)
217 var flag
= decoded
.readUInt8(2)
221 if (flag
!== 0xc0 && flag
!== 0xe0) return false
224 } else if (type
=== 0x43) {
225 if ((flag
& ~0x24)) return false
235 decryptECMult: decryptECMult
,
236 decryptRaw: decryptRaw
,
238 encryptRaw: encryptRaw
,
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
){
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.
250 var _Buffer
= require('safe-buffer').Buffer
251 function base (ALPHABET
) {
252 if (ALPHABET
.length
>= 255) { throw new TypeError('Alphabet too long') }
253 var BASE_MAP
= new Uint8Array(256)
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') }
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.
272 var pend
= source
.length
273 while (pbegin
!== pend
&& source
[pbegin
] === 0) {
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".
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
290 if (carry
!== 0) { throw new Error('Non-zero carry') }
294 // Skip leading zeroes in base58 result.
295 var it2
= size
- length
296 while (it2
!== size
&& b58
[it2
] === 0) {
299 // Translate the result into a string.
300 var str
= LEADER
.repeat(zeroes
)
301 for (; it2
< size
; ++it2
) { str
+= ALPHABET
.charAt(b58
[it2
]) }
304 function decodeUnsafe (source
) {
305 if (typeof source
!== 'string') { throw new TypeError('Expected String') }
306 if (source
.length
=== 0) { return _Buffer
.alloc(0) }
308 // Skip leading spaces.
309 if (source
[psz
] === ' ') { return }
310 // Skip and count leading '1's.
313 while (source
[psz
] === LEADER
) {
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
]) {
323 var carry
= BASE_MAP
[source
.charCodeAt(psz
)]
325 if (carry
=== 255) { return }
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
332 if (carry
!== 0) { throw new Error('Non-zero carry') }
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) {
343 var vch
= _Buffer
.allocUnsafe(zeroes
+ (size
- it4
))
344 vch
.fill(0x00, 0, zeroes
)
346 while (it4
!== size
) {
347 vch
[j
++] = b256
[it4
++]
351 function decode (string
) {
352 var buffer
= decodeUnsafe(string
)
353 if (buffer
) { return buffer
}
354 throw new Error('Non-base' + BASE
+ ' character')
358 decodeUnsafe: decodeUnsafe
,
362 module
.exports
= base
364 },{"safe-buffer":47}],3:[function(require
,module
,exports
){
365 // (public) Constructor
366 function BigInteger(a
, b
, c
) {
367 if (!(this instanceof BigInteger
))
368 return new BigInteger(a
, b
, c
)
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
)
377 var proto
= BigInteger
.prototype
379 // duck-typed isBigInteger
380 proto
.__bigi
= require('../package.json').version
381 BigInteger
.isBigInteger = function (obj
, check_ver
) {
382 return obj
&& obj
.__bigi
&& (!check_ver
|| obj
.__bigi
=== proto
.__bigi
)
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.
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)
396 function am1(i
, x
, w
, j
, c
, n
) {
398 var v
= x
* this[i
++] + w
[j
] + c
399 c
= Math
.floor(v
/ 0x4000000)
400 w
[j
++] = v
& 0x3ffffff
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)
407 function am2(i
, x
, w
, j
, c
, n
) {
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
420 // Alternately, set max digit bits to 28 since some
421 // browsers slow down when dealing with 32-bit numbers.
422 function am3(i
, x
, w
, j
, c
, n
) {
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
437 BigInteger
.prototype.am
= am1
440 BigInteger
.prototype.DB
= dbits
441 BigInteger
.prototype.DM
= ((1 << dbits
) - 1)
442 var DV
= BigInteger
.prototype.DV
= (1 << dbits
)
445 BigInteger
.prototype.FV
= Math
.pow(2, BI_FP
)
446 BigInteger
.prototype.F1
= BI_FP
- dbits
447 BigInteger
.prototype.F2
= 2 * dbits
- BI_FP
450 var BI_RM
= "0123456789abcdefghijklmnopqrstuvwxyz"
451 var BI_RC
= new Array()
453 rr
= "0".charCodeAt(0)
454 for (vv
= 0; vv
<= 9; ++vv
) BI_RC
[rr
++] = vv
455 rr
= "a".charCodeAt(0)
456 for (vv
= 10; vv
< 36; ++vv
) BI_RC
[rr
++] = vv
457 rr
= "A".charCodeAt(0)
458 for (vv
= 10; vv
< 36; ++vv
) BI_RC
[rr
++] = vv
460 function int2char(n
) {
461 return BI_RM
.charAt(n
)
464 function intAt(s
, i
) {
465 var c
= BI_RC
[s
.charCodeAt(i
)]
466 return (c
== null) ? -1 : c
469 // (protected) copy this to r
470 function bnpCopyTo(r
) {
471 for (var i
= this.t
- 1; i
>= 0; --i
) r
[i
] = this[i
]
476 // (protected) set from integer value x, -DV <= x < DV
477 function bnpFromInt(x
) {
479 this.s
= (x
< 0) ? -1 : 0
480 if (x
> 0) this[0] = x
481 else if (x
< -1) this[0] = x
+ DV
485 // return bigint initialized to value
487 var r
= new BigInteger()
492 // (protected) set from string and radix
493 function bnpFromString(s
, b
) {
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
513 var x
= (k
== 8) ? s
[i
] & 0xff : intAt(s
, i
)
515 if (s
.charAt(i
) == "-") mi
= true
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
))
525 self
[self
.t
- 1] |= x
<< sh
527 if (sh
>= self
.DB
) sh
-= self
.DB
529 if (k
== 8 && (s
[0] & 0x80) != 0) {
531 if (sh
> 0) self
[self
.t
- 1] |= ((1 << (self
.DB
- sh
)) - 1) << sh
534 if (mi
) BigInteger
.ZERO
.subTo(self
, self
)
537 // (protected) clamp off excess high words
538 function bnpClamp() {
539 var c
= this.s
& this.DM
540 while (this.t
> 0 && this[this.t
- 1] == c
)--this.t
543 // (public) return string representation in given radix
544 function bnToString(b
) {
546 if (self
.s
< 0) return "-" + self
.negate()
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,
559 var p
= self
.DB
- (i
* self
.DB
) % k
561 if (p
< self
.DB
&& (d
= self
[i
] >> p
) > 0) {
567 d
= (self
[i
] & ((1 << p
) - 1)) << (k
- p
)
568 d
|= self
[--i
] >> (p
+= self
.DB
- k
)
570 d
= (self
[i
] >> (p
-= k
)) & km
577 if (m
) r
+= int2char(d
)
584 function bnNegate() {
585 var r
= new BigInteger()
586 BigInteger
.ZERO
.subTo(this, r
)
592 return (this.s
< 0) ? this.negate() : this
595 // (public) return + if this > a, - if this < a, 0 if equal
596 function bnCompareTo(a
) {
601 if (r
!= 0) return (this.s
< 0) ? -r : r
603 if ((r
= this[i
] - a
[i
]) != 0) return r
607 // returns bit length of the integer x
611 if ((t
= x
>>> 16) != 0) {
615 if ((t
= x
>> 8) != 0) {
619 if ((t
= x
>> 4) != 0) {
623 if ((t
= x
>> 2) != 0) {
627 if ((t
= x
>> 1) != 0) {
634 // (public) return the number of bits in "this"
635 function bnBitLength() {
636 if (this.t
<= 0) return 0
637 return this.DB
* (this.t
- 1) + nbits(this[this.t
- 1] ^ (this.s
& this.DM
))
640 // (public) return the number of bytes in "this"
641 function bnByteLength() {
642 return this.bitLength() >> 3
645 // (protected) r = this << n*DB
646 function bnpDLShiftTo(n
, r
) {
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
654 // (protected) r = this >> n*DB
655 function 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)
661 // (protected) r = this << n
662 function bnpLShiftTo(n
, r
) {
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
,
670 for (i
= self
.t
- 1; i
>= 0; --i
) {
671 r
[i
+ ds
+ 1] = (self
[i
] >> cbs
) | c
672 c
= (self
[i
] & bm
) << bs
674 for (i
= ds
- 1; i
>= 0; --i
) r
[i
] = 0
676 r
.t
= self
.t
+ ds
+ 1
681 // (protected) r = this >> n
682 function bnpRShiftTo(n
, r
) {
685 var ds
= Math
.floor(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
698 if (bs
> 0) r
[self
.t
- ds
- 1] |= (self
.s
& bm
) << cbs
703 // (protected) r = this - a
704 function bnpSubTo(a
, r
) {
708 m
= Math
.min(a
.t
, self
.t
)
731 r
.s
= (c
< 0) ? -1 : 0
732 if (c
< -1) r
[i
++] = self
.DV
+ c
733 else if (c
> 0) r
[i
++] = c
738 // (protected) r = this * a, r != this,a (HAC 14.12)
739 // "this" should be the larger one if appropriate.
740 function bnpMultiplyTo(a
, r
) {
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
)
749 if (this.s
!= a
.s
) BigInteger
.ZERO
.subTo(r
, r
)
752 // (protected) r = this^2, r != this (HAC 14.16)
753 function bnpSquareTo(r
) {
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
) {
764 if (r
.t
> 0) r
[r
.t
- 1] += x
.am(i
, x
[i
], r
, 2 * i
, 0, 1)
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.
771 function bnpDivRemTo(m
, q
, r
) {
774 if (pm
.t
<= 0) return
777 if (q
!= null) q
.fromInt(0)
778 if (r
!= null) self
.copyTo(r
)
781 if (r
== null) r
= new BigInteger()
782 var y
= new BigInteger(),
785 var nsh
= self
.DB
- nbits(pm
[pm
.t
- 1]); // normalize modulus
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
,
802 t
= (q
== null) ? new BigInteger() : q
804 if (r
.compareTo(t
) >= 0) {
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
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
817 while (r
[i
] < --qd
) r
.subTo(t
, r
)
822 if (ts
!= ms
) BigInteger
.ZERO
.subTo(q
, q
)
826 if (nsh
> 0) r
.rShiftTo(nsh
, r
); // Denormalize remainder
827 if (ts
< 0) BigInteger
.ZERO
.subTo(r
, r
)
830 // (public) this mod a
832 var r
= new BigInteger()
834 .divRemTo(a
, null, r
)
835 if (this.s
< 0 && r
.compareTo(BigInteger
.ZERO
) > 0) a
.subTo(r
, r
)
839 // Modular reduction using "classic" algorithm
840 function Classic(m
) {
844 function cConvert(x
) {
845 if (x
.s
< 0 || x
.compareTo(this.m
) >= 0) return x
.mod(this.m
)
849 function cRevert(x
) {
853 function cReduce(x
) {
854 x
.divRemTo(this.m
, null, x
)
857 function cMulTo(x
, y
, r
) {
862 function cSqrTo(x
, r
) {
867 Classic
.prototype.convert
= cConvert
868 Classic
.prototype.revert
= cRevert
869 Classic
.prototype.reduce
= cReduce
870 Classic
.prototype.mulTo
= cMulTo
871 Classic
.prototype.sqrTo
= cSqrTo
873 // (protected) return "-1/this % 2^DB"; useful for Mont. reduction
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.
883 function bnpInvDigit() {
884 if (this.t
< 1) return 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
898 // Montgomery reduction
899 function Montgomery(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
909 function montConvert(x
) {
910 var r
= new BigInteger()
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
)
919 function montRevert(x
) {
920 var r
= new BigInteger()
926 // x = x/R mod m (HAC 14.32)
927 function montReduce(x
) {
928 while (x
.t
<= this.mt2
) // pad x so am has enough room later
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
936 x
[j
] += this.m
.am(0, u0
, x
, i
, 0, this.m
.t
)
938 while (x
[j
] >= x
.DV
) {
944 x
.drShiftTo(this.m
.t
, x
)
945 if (x
.compareTo(this.m
) >= 0) x
.subTo(this.m
, x
)
948 // r = "x^2/R mod m"; x != r
949 function montSqrTo(x
, r
) {
954 // r = "xy/R mod m"; x,y != r
955 function montMulTo(x
, y
, r
) {
960 Montgomery
.prototype.convert
= montConvert
961 Montgomery
.prototype.revert
= montRevert
962 Montgomery
.prototype.reduce
= montReduce
963 Montgomery
.prototype.mulTo
= montMulTo
964 Montgomery
.prototype.sqrTo
= montSqrTo
966 // (protected) true iff this is even
967 function bnpIsEven() {
968 return ((this.t
> 0) ? (this[0] & 1) : this.s
) == 0
971 // (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79)
972 function bnpExp(e
, z
) {
973 if (e
> 0xffffffff || e
< 1) return BigInteger
.ONE
974 var r
= new BigInteger(),
975 r2
= new BigInteger(),
981 if ((e
& (1 << i
)) > 0) z
.mulTo(r2
, g
, r
)
991 // (public) this^e % m, 0 <= e < 2^32
992 function bnModPowInt(e
, m
) {
994 if (e
< 256 || m
.isEven()) z
= new Classic(m
)
995 else z
= new Montgomery(m
)
996 return this.exp(e
, z
)
1000 proto
.copyTo
= bnpCopyTo
1001 proto
.fromInt
= bnpFromInt
1002 proto
.fromString
= bnpFromString
1003 proto
.clamp
= bnpClamp
1004 proto
.dlShiftTo
= bnpDLShiftTo
1005 proto
.drShiftTo
= bnpDRShiftTo
1006 proto
.lShiftTo
= bnpLShiftTo
1007 proto
.rShiftTo
= bnpRShiftTo
1008 proto
.subTo
= bnpSubTo
1009 proto
.multiplyTo
= bnpMultiplyTo
1010 proto
.squareTo
= bnpSquareTo
1011 proto
.divRemTo
= bnpDivRemTo
1012 proto
.invDigit
= bnpInvDigit
1013 proto
.isEven
= bnpIsEven
1017 proto
.toString
= bnToString
1018 proto
.negate
= bnNegate
1020 proto
.compareTo
= bnCompareTo
1021 proto
.bitLength
= bnBitLength
1022 proto
.byteLength
= bnByteLength
1024 proto
.modPowInt
= bnModPowInt
1027 function bnClone() {
1028 var r
= new BigInteger()
1033 // (public) return value as integer
1034 function bnIntValue() {
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]
1044 // (public) return value as byte
1045 function bnByteValue() {
1046 return (this.t
== 0) ? this.s : (this[0] << 24) >> 24
1049 // (public) return value as short (assumes DB>=16)
1050 function bnShortValue() {
1051 return (this.t
== 0) ? this.s : (this[0] << 16) >> 16
1054 // (protected) return x s.t. r^x < DV
1055 function bnpChunkSize(r
) {
1056 return Math
.floor(Math
.LN2
* this.DB
/ Math
.log(r
))
1059 // (public) 0 if this == 0, 1 if this > 0
1060 function bnSigNum() {
1061 if (this.s
< 0) return -1
1062 else if (this.t
<= 0 || (this.t
== 1 && this[0] <= 0)) return 0
1066 // (protected) convert to radix string
1067 function 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
)
1073 y
= new BigInteger(),
1074 z
= new BigInteger(),
1076 this.divRemTo(d
, y
, z
)
1077 while (y
.signum() > 0) {
1078 r
= (a
+ z
.intValue())
1087 // (protected) convert from radix string
1088 function bnpFromRadix(s
, b
) {
1091 if (b
== null) b
= 10
1092 var cs
= self
.chunkSize(b
)
1093 var d
= Math
.pow(b
, cs
),
1097 for (var i
= 0; i
< s
.length
; ++i
) {
1100 if (s
.charAt(i
) == "-" && self
.signum() == 0) mi
= true
1106 self
.dAddOffset(w
, 0)
1112 self
.dMultiply(Math
.pow(b
, j
))
1113 self
.dAddOffset(w
, 0)
1115 if (mi
) BigInteger
.ZERO
.subTo(self
, self
)
1118 // (protected) alternate constructor
1119 function bnpFromNumber(a
, b
, c
) {
1121 if ("number" == typeof b
) {
1122 // new BigInteger(int,int,RNG)
1123 if (a
< 2) self
.fromInt(1)
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
)
1135 // new BigInteger(int,RNG)
1136 var x
= new Array(),
1138 x
.length
= (a
>> 3) + 1
1140 if (t
> 0) x
[0] &= ((1 << t
) - 1)
1142 self
.fromString(x
, 256)
1146 // (public) convert to bigendian byte array
1147 function bnToByteArray() {
1152 var p
= self
.DB
- (i
* self
.DB
) % 8,
1155 if (p
< self
.DB
&& (d
= self
[i
] >> p
) != (self
.s
& self
.DM
) >> p
)
1156 r
[k
++] = d
| (self
.s
<< (self
.DB
- p
))
1159 d
= (self
[i
] & ((1 << p
) - 1)) << (8 - p
)
1160 d
|= self
[--i
] >> (p
+= self
.DB
- 8)
1162 d
= (self
[i
] >> (p
-= 8)) & 0xff
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
1176 function bnEquals(a
) {
1177 return (this.compareTo(a
) == 0)
1181 return (this.compareTo(a
) < 0) ? this : a
1185 return (this.compareTo(a
) > 0) ? this : a
1188 // (protected) r = this op a (bitwise)
1189 function bnpBitwiseTo(a
, op
, r
) {
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
])
1195 for (i
= m
; i
< self
.t
; ++i
) r
[i
] = op(self
[i
], f
)
1198 f
= self
.s
& self
.DM
1199 for (i
= m
; i
< a
.t
; ++i
) r
[i
] = op(f
, a
[i
])
1202 r
.s
= op(self
.s
, a
.s
)
1206 // (public) this & a
1207 function op_and(x
, y
) {
1212 var r
= new BigInteger()
1213 this.bitwiseTo(a
, op_and
, r
)
1217 // (public) this | a
1218 function op_or(x
, y
) {
1223 var r
= new BigInteger()
1224 this.bitwiseTo(a
, op_or
, r
)
1228 // (public) this ^ a
1229 function op_xor(x
, y
) {
1234 var r
= new BigInteger()
1235 this.bitwiseTo(a
, op_xor
, r
)
1239 // (public) this & ~a
1240 function op_andnot(x
, y
) {
1244 function bnAndNot(a
) {
1245 var r
= new BigInteger()
1246 this.bitwiseTo(a
, op_andnot
, r
)
1252 var r
= new BigInteger()
1253 for (var i
= 0; i
< this.t
; ++i
) r
[i
] = this.DM
& ~this[i
]
1259 // (public) this << n
1260 function bnShiftLeft(n
) {
1261 var r
= new BigInteger()
1262 if (n
< 0) this.rShiftTo(-n
, r
)
1263 else this.lShiftTo(n
, r
)
1267 // (public) this >> n
1268 function bnShiftRight(n
) {
1269 var r
= new BigInteger()
1270 if (n
< 0) this.lShiftTo(-n
, r
)
1271 else this.rShiftTo(n
, r
)
1275 // return index of lowest 1-bit in x, x < 2^31
1277 if (x
== 0) return -1
1279 if ((x
& 0xffff) == 0) {
1283 if ((x
& 0xff) == 0) {
1287 if ((x
& 0xf) == 0) {
1295 if ((x
& 1) == 0)++r
1299 // (public) returns index of lowest 1-bit (or -1 if none)
1300 function 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
1307 // return number of 1 bits in x
1317 // (public) return number of set bits
1318 function bnBitCount() {
1320 x
= this.s
& this.DM
1321 for (var i
= 0; i
< this.t
; ++i
) r
+= cbit(this[i
] ^ x
)
1325 // (public) true iff nth bit is set
1326 function 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)
1332 // (protected) this op (1<<n)
1333 function bnpChangeBit(n
, op
) {
1334 var r
= BigInteger
.ONE
.shiftLeft(n
)
1335 this.bitwiseTo(r
, op
, r
)
1339 // (public) this | (1<<n)
1340 function bnSetBit(n
) {
1341 return this.changeBit(n
, op_or
)
1344 // (public) this & ~(1<<n)
1345 function bnClearBit(n
) {
1346 return this.changeBit(n
, op_andnot
)
1349 // (public) this ^ (1<<n)
1350 function bnFlipBit(n
) {
1351 return this.changeBit(n
, op_xor
)
1354 // (protected) r = this + a
1355 function bnpAddTo(a
, r
) {
1360 m
= Math
.min(a
.t
, self
.t
)
1363 r
[i
++] = c
& self
.DM
1368 while (i
< self
.t
) {
1370 r
[i
++] = c
& self
.DM
1378 r
[i
++] = c
& self
.DM
1383 r
.s
= (c
< 0) ? -1 : 0
1384 if (c
> 0) r
[i
++] = c
1385 else if (c
< -1) r
[i
++] = self
.DV
+ c
1390 // (public) this + a
1392 var r
= new BigInteger()
1397 // (public) this - a
1398 function bnSubtract(a
) {
1399 var r
= new BigInteger()
1404 // (public) this * a
1405 function bnMultiply(a
) {
1406 var r
= new BigInteger()
1407 this.multiplyTo(a
, r
)
1412 function bnSquare() {
1413 var r
= new BigInteger()
1418 // (public) this / a
1419 function bnDivide(a
) {
1420 var r
= new BigInteger()
1421 this.divRemTo(a
, r
, null)
1425 // (public) this % a
1426 function bnRemainder(a
) {
1427 var r
= new BigInteger()
1428 this.divRemTo(a
, null, r
)
1432 // (public) [this/a,this%a]
1433 function bnDivideAndRemainder(a
) {
1434 var q
= new BigInteger(),
1435 r
= new BigInteger()
1436 this.divRemTo(a
, q
, r
)
1437 return new Array(q
, r
)
1440 // (protected) this *= n, this >= 0, 1 < n < DV
1441 function bnpDMultiply(n
) {
1442 this[this.t
] = this.am(0, n
- 1, this, 0, 0, this.t
)
1447 // (protected) this += n << w words, this >= 0
1448 function bnpDAddOffset(n
, w
) {
1450 while (this.t
<= w
) this[this.t
++] = 0
1452 while (this[w
] >= this.DV
) {
1454 if (++w
>= this.t
) this[this.t
++] = 0
1460 function NullExp() {}
1466 function nMulTo(x
, y
, r
) {
1470 function nSqrTo(x
, r
) {
1474 NullExp
.prototype.convert
= nNop
1475 NullExp
.prototype.revert
= nNop
1476 NullExp
.prototype.mulTo
= nMulTo
1477 NullExp
.prototype.sqrTo
= nSqrTo
1481 return this.exp(e
, new NullExp())
1484 // (protected) r = lower n words of "this * a", a.t <= n
1485 // "this" should be the larger one if appropriate.
1486 function bnpMultiplyLowerTo(a
, n
, r
) {
1487 var i
= Math
.min(this.t
+ a
.t
, n
)
1488 r
.s
= 0; // assumes a,this >= 0
1490 while (i
> 0) r
[--i
] = 0
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
)
1497 // (protected) r = "this * a" without lower n words, n > 0
1498 // "this" should be the larger one if appropriate.
1499 function bnpMultiplyUpperTo(a
, n
, r
) {
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
)
1510 // Barrett modular reduction
1511 function Barrett(m
) {
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
)
1520 function 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
1524 var r
= new BigInteger()
1531 function barrettRevert(x
) {
1535 // x = x mod m (HAC 14.42)
1536 function barrettReduce(x
) {
1538 x
.drShiftTo(self
.m
.t
- 1, self
.r2
)
1539 if (x
.t
> self
.m
.t
+ 1) {
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)
1547 while (x
.compareTo(self
.m
) >= 0) x
.subTo(self
.m
, x
)
1550 // r = x^2 mod m; x != r
1551 function barrettSqrTo(x
, r
) {
1556 // r = x*y mod m; x,y != r
1557 function barrettMulTo(x
, y
, r
) {
1562 Barrett
.prototype.convert
= barrettConvert
1563 Barrett
.prototype.revert
= barrettRevert
1564 Barrett
.prototype.reduce
= barrettReduce
1565 Barrett
.prototype.mulTo
= barrettMulTo
1566 Barrett
.prototype.sqrTo
= barrettSqrTo
1568 // (public) this^e % m (HAC 14.85)
1569 function bnModPow(e
, m
) {
1570 var i
= e
.bitLength(),
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
1581 else if (m
.isEven())
1584 z
= new Montgomery(m
)
1587 var g
= new Array(),
1591 g
[1] = z
.convert(this)
1593 var g2
= new BigInteger()
1596 g
[n
] = new BigInteger()
1597 z
.mulTo(g2
, g
[n
- 2], g
[n
])
1604 r2
= new BigInteger(),
1608 if (i
>= k1
) w
= (e
[j
] >> (i
- k1
)) & km
1610 w
= (e
[j
] & ((1 << (i
+ 1)) - 1)) << (k1
- i
)
1611 if (j
> 0) w
|= e
[j
- 1] >> (this.DB
+ i
- k1
)
1615 while ((w
& 1) == 0) {
1623 if (is1
) { // ret == 1, don't bother squaring or multiplying it
1632 if (n
> 0) z
.sqrTo(r
, r2
)
1638 z
.mulTo(r2
, g
[w
], r
)
1641 while (j
>= 0 && (e
[j
] & (1 << i
)) == 0) {
1655 // (public) gcd(this,a) (HAC 14.54)
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) {
1664 var i
= x
.getLowestSetBit(),
1665 g
= y
.getLowestSetBit()
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) {
1683 if (g
> 0) y
.lShiftTo(g
, y
)
1687 // (protected) this % n, n < 2^26
1688 function bnpModInt(n
) {
1689 if (n
<= 0) return 0
1690 var d
= this.DV
% n
,
1691 r
= (this.s
< 0) ? n
- 1 : 0
1693 if (d
== 0) r
= this[0] % n
1695 for (var i
= this.t
- 1; i
>= 0; --i
) r
= (d
* r
+ this[i
]) % n
1699 // (public) 1/this % m (HAC 14.61)
1700 function bnModInverse(m
) {
1702 if (this.signum() === 0) throw new Error('division by zero')
1703 if ((this.isEven() && ac
) || m
.signum() == 0) return BigInteger
.ZERO
1710 while (u
.signum() != 0) {
1711 while (u
.isEven()) {
1714 if (!a
.isEven() || !b
.isEven()) {
1719 } else if (!b
.isEven()) b
.subTo(m
, b
)
1722 while (v
.isEven()) {
1725 if (!c
.isEven() || !d
.isEven()) {
1730 } else if (!d
.isEven()) d
.subTo(m
, d
)
1733 if (u
.compareTo(v
) >= 0) {
1735 if (ac
) a
.subTo(c
, a
)
1739 if (ac
) c
.subTo(a
, c
)
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
)
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
1763 var lplim
= (1 << 26) / lowprimes
[lowprimes
.length
- 1]
1765 // (public) test primality with certainty >= 1-.5^t
1766 function 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
1773 if (x
.isEven()) return false
1775 while (i
< lowprimes
.length
) {
1776 var m
= lowprimes
[i
],
1778 while (j
< lowprimes
.length
&& m
< lplim
) m
*= lowprimes
[j
++]
1780 while (i
< j
) if (m
% lowprimes
[i
++] == 0) return false
1782 return x
.millerRabin(t
)
1785 // (protected) true if probably prime (HAC 4.24, Miller-Rabin)
1786 function 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
)
1792 if (t
> lowprimes
.length
) t
= lowprimes
.length
1793 var a
= new BigInteger(null)
1795 for (var i
= 0; i
< t
; ++i
) {
1797 j
= lowprimes
[Math
.floor(Math
.random() * lowprimes
.length
)]
1798 if (bases
.indexOf(j
) == -1) break
1802 var y
= a
.modPow(r
, this)
1803 if (y
.compareTo(BigInteger
.ONE
) != 0 && y
.compareTo(n1
) != 0) {
1805 while (j
++ < k
&& y
.compareTo(n1
) != 0) {
1806 y
= y
.modPowInt(2, this)
1807 if (y
.compareTo(BigInteger
.ONE
) == 0) return false
1809 if (y
.compareTo(n1
) != 0) return false
1816 proto
.chunkSize
= bnpChunkSize
1817 proto
.toRadix
= bnpToRadix
1818 proto
.fromRadix
= bnpFromRadix
1819 proto
.fromNumber
= bnpFromNumber
1820 proto
.bitwiseTo
= bnpBitwiseTo
1821 proto
.changeBit
= bnpChangeBit
1822 proto
.addTo
= bnpAddTo
1823 proto
.dMultiply
= bnpDMultiply
1824 proto
.dAddOffset
= bnpDAddOffset
1825 proto
.multiplyLowerTo
= bnpMultiplyLowerTo
1826 proto
.multiplyUpperTo
= bnpMultiplyUpperTo
1827 proto
.modInt
= bnpModInt
1828 proto
.millerRabin
= bnpMillerRabin
1831 proto
.clone
= bnClone
1832 proto
.intValue
= bnIntValue
1833 proto
.byteValue
= bnByteValue
1834 proto
.shortValue
= bnShortValue
1835 proto
.signum
= bnSigNum
1836 proto
.toByteArray
= bnToByteArray
1837 proto
.equals
= bnEquals
1843 proto
.andNot
= bnAndNot
1845 proto
.shiftLeft
= bnShiftLeft
1846 proto
.shiftRight
= bnShiftRight
1847 proto
.getLowestSetBit
= bnGetLowestSetBit
1848 proto
.bitCount
= bnBitCount
1849 proto
.testBit
= bnTestBit
1850 proto
.setBit
= bnSetBit
1851 proto
.clearBit
= bnClearBit
1852 proto
.flipBit
= bnFlipBit
1854 proto
.subtract
= bnSubtract
1855 proto
.multiply
= bnMultiply
1856 proto
.divide
= bnDivide
1857 proto
.remainder
= bnRemainder
1858 proto
.divideAndRemainder
= bnDivideAndRemainder
1859 proto
.modPow
= bnModPow
1860 proto
.modInverse
= bnModInverse
1863 proto
.isProbablePrime
= bnIsProbablePrime
1865 // JSBN-specific extension
1866 proto
.square
= bnSquare
1869 BigInteger
.ZERO
= nbv(0)
1870 BigInteger
.ONE
= nbv(1)
1871 BigInteger
.valueOf
= nbv
1873 module
.exports
= BigInteger
1875 },{"../package.json":6}],4:[function(require
,module
,exports
){
1877 // FIXME: Kind of a weird way to throw exceptions, consider removing
1878 var assert
= require('assert')
1879 var BigInteger
= require('./bigi')
1882 * Turns a byte array into a big integer.
1884 * This function will interpret a byte array as a big integer in big
1887 BigInteger
.fromByteArrayUnsigned = function(byteArray
) {
1888 // BigInteger expects a DER integer conformant byte array
1889 if (byteArray
[0] & 0x80) {
1890 return new BigInteger([0].concat(byteArray
))
1893 return new BigInteger(byteArray
)
1897 * Returns a byte array representation of the big integer.
1899 * This returns the absolute of the contained value in big endian
1900 * form. A value of zero results in an empty array.
1902 BigInteger
.prototype.toByteArrayUnsigned = function() {
1903 var byteArray
= this.toByteArray()
1904 return byteArray
[0] === 0 ? byteArray
.slice(1) : byteArray
1907 BigInteger
.fromDERInteger = function(byteArray
) {
1908 return new BigInteger(byteArray
)
1912 * Converts BigInteger to a DER integer representation.
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.
1932 * -62300 => 0xff0ca4
1934 BigInteger
.prototype.toDERInteger
= BigInteger
.prototype.toByteArray
1936 BigInteger
.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
)
1941 return new BigInteger([0].concat(byteArray
))
1944 return new BigInteger(buffer
)
1947 BigInteger
.fromHex = function(hex
) {
1948 if (hex
=== '') return BigInteger
.ZERO
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)
1955 BigInteger
.prototype.toBuffer = function(size
) {
1956 var byteArray
= this.toByteArrayUnsigned()
1959 var padding
= size
- byteArray
.length
1960 while (zeros
.length
< padding
) zeros
.push(0)
1962 return new Buffer(zeros
.concat(byteArray
))
1965 BigInteger
.prototype.toHex = function(size
) {
1966 return this.toBuffer(size
).toString('hex')
1969 }).call(this,require("buffer").Buffer
)
1970 },{"./bigi":3,"assert":74,"buffer":110}],5:[function(require
,module
,exports
){
1971 var BigInteger
= require('./bigi')
1974 require('./convert')
1976 module
.exports
= BigInteger
1977 },{"./bigi":3,"./convert":4}],6:[function(require
,module
,exports
){
1982 "/home/hashengineering/hashengineering/bip38grs"
1985 "_from": "bigi@>=1.2.0 <2.0.0",
1986 "_id": "bigi@1.4.2",
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"
1996 "email": "jprichardson@gmail.com",
1997 "name": "jprichardson"
1999 "_npmVersion": "3.8.6",
2000 "_phantomChildren": {},
2003 "raw": "bigi@^1.2.0",
2004 "rawSpec": "^1.2.0",
2006 "spec": ">=1.2.0 <2.0.0",
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",
2019 "url": "https://github.com/cryptocoinjs/bigi/issues"
2022 "description": "Big integers.",
2023 "devDependencies": {
2024 "coveralls": "^2.11.2",
2025 "istanbul": "^0.3.5",
2032 "shasum": "9c665a95f88b8b08fc05cfd731f561859d725825",
2033 "tarball": "https://registry.npmjs.org/bigi/-/bigi-1.4.2.tgz"
2035 "gitHead": "c25308081c896ff84702303722bf5ecd8b3f78e3",
2036 "homepage": "https://github.com/cryptocoinjs/bigi#readme",
2054 "main": "./lib/index.js",
2057 "name": "midnightlightning",
2058 "email": "boydb@midnightdesign.ws"
2061 "name": "sidazhang",
2062 "email": "sidazhang89@gmail.com"
2066 "email": "npm@shesek.info"
2069 "name": "jprichardson",
2070 "email": "jprichardson@gmail.com"
2074 "optionalDependencies": {},
2075 "readme": "ERROR: No README data found!",
2078 "url": "git+https://github.com/cryptocoinjs/bigi.git"
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",
2090 "android-browser/4.2..latest",
2094 "iphone/6.0..latest",
2095 "safari/6.0..latest"
2097 "files": "test/*.js",
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/
2109 var Buffer
= require('safe-buffer').Buffer
2111 function asUInt32Array (buf
) {
2112 if (!Buffer
.isBuffer(buf
)) buf
= Buffer
.from(buf
)
2114 var len
= (buf
.length
/ 4) | 0
2115 var out
= new Array(len
)
2117 for (var i
= 0; i
< len
; i
++) {
2118 out
[i
] = buf
.readUInt32BE(i
* 4)
2124 function scrubVec (v
) {
2125 for (var i
= 0; i
< v
.length
; v
++) {
2130 function 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]
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]
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
++]
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
++]
2163 return [t0
, t1
, t2
, t3
]
2167 var RCON
= [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36]
2168 var G
= (function () {
2169 // Compute double table
2170 var d
= new Array(256)
2171 for (var j
= 0; j
< 256; j
++) {
2175 d
[j
] = (j
<< 1) ^ 0x11b
2181 var SUB_MIX
= [[], [], [], []]
2182 var INV_SUB_MIX
= [[], [], [], []]
2187 for (var i
= 0; i
< 256; ++i
) {
2189 var sx
= xi
^ (xi
<< 1) ^ (xi
<< 2) ^ (xi
<< 3) ^ (xi
<< 4)
2190 sx
= (sx
>>> 8) ^ (sx
& 0xff) ^ 0x63
2194 // Compute multiplication
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)
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
2216 x
= x2
^ d
[d
[d
[x8
^ x2
]]]
2225 INV_SUB_MIX: INV_SUB_MIX
2229 function AES (key
) {
2230 this._key
= asUInt32Array(key
)
2234 AES
.blockSize
= 4 * 4
2235 AES
.keySize
= 256 / 8
2236 AES
.prototype.blockSize
= AES
.blockSize
2237 AES
.prototype.keySize
= AES
.keySize
2238 AES
.prototype._reset = function () {
2239 var keyWords
= this._key
2240 var keySize
= keyWords
.length
2241 var nRounds
= keySize
+ 6
2242 var ksRows
= (nRounds
+ 1) * 4
2244 var keySchedule
= []
2245 for (var k
= 0; k
< keySize
; k
++) {
2246 keySchedule
[k
] = keyWords
[k
]
2249 for (k
= keySize
; k
< ksRows
; k
++) {
2250 var t
= keySchedule
[k
- 1]
2252 if (k
% keySize
=== 0) {
2253 t
= (t
<< 8) | (t
>>> 24)
2255 (G
.SBOX
[t
>>> 24] << 24) |
2256 (G
.SBOX
[(t
>>> 16) & 0xff] << 16) |
2257 (G
.SBOX
[(t
>>> 8) & 0xff] << 8) |
2260 t
^= RCON
[(k
/ keySize
) | 0] << 24
2261 } else if (keySize
> 6 && k
% keySize
=== 4) {
2263 (G
.SBOX
[t
>>> 24] << 24) |
2264 (G
.SBOX
[(t
>>> 16) & 0xff] << 16) |
2265 (G
.SBOX
[(t
>>> 8) & 0xff] << 8) |
2269 keySchedule
[k
] = keySchedule
[k
- keySize
] ^ t
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)]
2277 if (ik
< 4 || ksR
<= 4) {
2278 invKeySchedule
[ik
] = tt
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]]
2288 this._nRounds
= nRounds
2289 this._keySchedule
= keySchedule
2290 this._invKeySchedule
= invKeySchedule
2293 AES
.prototype.encryptBlockRaw = function (M
) {
2294 M
= asUInt32Array(M
)
2295 return cryptBlock(M
, this._keySchedule
, G
.SUB_MIX
, G
.SBOX
, this._nRounds
)
2298 AES
.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)
2308 AES
.prototype.decryptBlock = function (M
) {
2309 M
= asUInt32Array(M
)
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)
2325 AES
.prototype.scrub = function () {
2326 scrubVec(this._keySchedule
)
2327 scrubVec(this._invKeySchedule
)
2331 module
.exports
.AES
= AES
2333 },{"safe-buffer":47}],8:[function(require
,module
,exports
){
2334 var aes
= require('./aes')
2335 var Buffer
= require('safe-buffer').Buffer
2336 var Transform
= require('cipher-base')
2337 var inherits
= require('inherits')
2338 var GHASH
= require('./ghash')
2339 var xor
= require('buffer-xor')
2340 var incr32
= require('./incr32')
2342 function xorTest (a
, b
) {
2344 if (a
.length
!== b
.length
) out
++
2346 var len
= Math
.min(a
.length
, b
.length
)
2347 for (var i
= 0; i
< len
; ++i
) {
2348 out
+= (a
[i
] ^ b
[i
])
2354 function 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])])
2359 var ghash
= new GHASH(ck
)
2361 var toPad
= len
% 16
2365 ghash
.update(Buffer
.alloc(toPad
, 0))
2367 ghash
.update(Buffer
.alloc(8, 0))
2368 var ivBits
= len
* 8
2369 var tail
= Buffer
.alloc(8)
2370 tail
.writeUIntBE(ivBits
, 0, 8)
2372 self
._finID
= ghash
.state
2373 var out
= Buffer
.from(self
._finID
)
2377 function StreamCipher (mode
, key
, iv
, decrypt
) {
2378 Transform
.call(this)
2380 var h
= Buffer
.alloc(4, 0)
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
)
2387 this._prev
= Buffer
.from(iv
)
2388 this._cache
= Buffer
.allocUnsafe(0)
2389 this._secCache
= Buffer
.allocUnsafe(0)
2390 this._decrypt
= decrypt
2395 this._authTag
= null
2396 this._called
= false
2399 inherits(StreamCipher
, Transform
)
2401 StreamCipher
.prototype._update = function (chunk
) {
2402 if (!this._called
&& this._alen
) {
2403 var rump
= 16 - (this._alen
% 16)
2405 rump
= Buffer
.alloc(rump
, 0)
2406 this._ghash
.update(rump
)
2411 var out
= this._mode
.encrypt(this, chunk
)
2412 if (this._decrypt
) {
2413 this._ghash
.update(chunk
)
2415 this._ghash
.update(out
)
2417 this._len
+= chunk
.length
2421 StreamCipher
.prototype._final = function () {
2422 if (this._decrypt
&& !this._authTag
) throw new Error('Unsupported state or unable to authenticate data')
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')
2428 this._cipher
.scrub()
2431 StreamCipher
.prototype.getAuthTag
= function getAuthTag () {
2432 if (this._decrypt
|| !Buffer
.isBuffer(this._authTag
)) throw new Error('Attempting to get auth tag in unsupported state')
2434 return this._authTag
2437 StreamCipher
.prototype.setAuthTag
= function setAuthTag (tag
) {
2438 if (!this._decrypt
) throw new Error('Attempting to set auth tag in unsupported state')
2443 StreamCipher
.prototype.setAAD
= function setAAD (buf
) {
2444 if (this._called
) throw new Error('Attempting to set AAD in unsupported state')
2446 this._ghash
.update(buf
)
2447 this._alen
+= buf
.length
2450 module
.exports
= StreamCipher
2452 },{"./aes":7,"./ghash":12,"./incr32":13,"buffer-xor":29,"cipher-base":31,"inherits":44,"safe-buffer":47}],9:[function(require
,module
,exports
){
2453 var ciphers
= require('./encrypter')
2454 var deciphers
= require('./decrypter')
2455 var modes
= require('./modes/list.json')
2457 function getCiphers () {
2458 return Object
.keys(modes
)
2461 exports
.createCipher
= exports
.Cipher
= ciphers
.createCipher
2462 exports
.createCipheriv
= exports
.Cipheriv
= ciphers
.createCipheriv
2463 exports
.createDecipher
= exports
.Decipher
= deciphers
.createDecipher
2464 exports
.createDecipheriv
= exports
.Decipheriv
= deciphers
.createDecipheriv
2465 exports
.listCiphers
= exports
.getCiphers
= getCiphers
2467 },{"./decrypter":10,"./encrypter":11,"./modes/list.json":21}],10:[function(require
,module
,exports
){
2468 var AuthCipher
= require('./authCipher')
2469 var Buffer
= require('safe-buffer').Buffer
2470 var MODES
= require('./modes')
2471 var StreamCipher
= require('./streamCipher')
2472 var Transform
= require('cipher-base')
2473 var aes
= require('./aes')
2474 var ebtk
= require('evp_bytestokey')
2475 var inherits
= require('inherits')
2477 function Decipher (mode
, key
, iv
) {
2478 Transform
.call(this)
2480 this._cache
= new Splitter()
2482 this._cipher
= new aes
.AES(key
)
2483 this._prev
= Buffer
.from(iv
)
2485 this._autopadding
= true
2488 inherits(Decipher
, Transform
)
2490 Decipher
.prototype._update = function (data
) {
2491 this._cache
.add(data
)
2495 while ((chunk
= this._cache
.get(this._autopadding
))) {
2496 thing
= this._mode
.decrypt(this, chunk
)
2499 return Buffer
.concat(out
)
2502 Decipher
.prototype._final = function () {
2503 var chunk
= this._cache
.flush()
2504 if (this._autopadding
) {
2505 return unpad(this._mode
.decrypt(this, chunk
))
2507 throw new Error('data not multiple of block length')
2511 Decipher
.prototype.setAutoPadding = function (setTo
) {
2512 this._autopadding
= !!setTo
2516 function Splitter () {
2517 this.cache
= Buffer
.allocUnsafe(0)
2520 Splitter
.prototype.add = function (data
) {
2521 this.cache
= Buffer
.concat([this.cache
, data
])
2524 Splitter
.prototype.get = function (autoPadding
) {
2527 if (this.cache
.length
> 16) {
2528 out
= this.cache
.slice(0, 16)
2529 this.cache
= this.cache
.slice(16)
2533 if (this.cache
.length
>= 16) {
2534 out
= this.cache
.slice(0, 16)
2535 this.cache
= this.cache
.slice(16)
2543 Splitter
.prototype.flush = function () {
2544 if (this.cache
.length
) return this.cache
2547 function unpad (last
) {
2548 var padded
= last
[15]
2549 if (padded
< 1 || padded
> 16) {
2550 throw new Error('unable to decrypt data')
2553 while (++i
< padded
) {
2554 if (last
[(i
+ (16 - padded
))] !== padded
) {
2555 throw new Error('unable to decrypt data')
2558 if (padded
=== 16) return
2560 return last
.slice(0, 16 - padded
)
2563 function createDecipheriv (suite
, password
, iv
) {
2564 var config
= MODES
[suite
.toLowerCase()]
2565 if (!config
) throw new TypeError('invalid suite type')
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
)
2570 if (typeof password
=== 'string') password
= Buffer
.from(password
)
2571 if (password
.length
!== config
.key
/ 8) throw new TypeError('invalid key length ' + password
.length
)
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)
2579 return new Decipher(config
.module
, password
, iv
)
2582 function createDecipher (suite
, password
) {
2583 var config
= MODES
[suite
.toLowerCase()]
2584 if (!config
) throw new TypeError('invalid suite type')
2586 var keys
= ebtk(password
, false, config
.key
, config
.iv
)
2587 return createDecipheriv(suite
, keys
.key
, keys
.iv
)
2590 exports
.createDecipher
= createDecipher
2591 exports
.createDecipheriv
= createDecipheriv
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
){
2594 var MODES
= require('./modes')
2595 var AuthCipher
= require('./authCipher')
2596 var Buffer
= require('safe-buffer').Buffer
2597 var StreamCipher
= require('./streamCipher')
2598 var Transform
= require('cipher-base')
2599 var aes
= require('./aes')
2600 var ebtk
= require('evp_bytestokey')
2601 var inherits
= require('inherits')
2603 function Cipher (mode
, key
, iv
) {
2604 Transform
.call(this)
2606 this._cache
= new Splitter()
2607 this._cipher
= new aes
.AES(key
)
2608 this._prev
= Buffer
.from(iv
)
2610 this._autopadding
= true
2613 inherits(Cipher
, Transform
)
2615 Cipher
.prototype._update = function (data
) {
2616 this._cache
.add(data
)
2621 while ((chunk
= this._cache
.get())) {
2622 thing
= this._mode
.encrypt(this, chunk
)
2626 return Buffer
.concat(out
)
2629 var PADDING
= Buffer
.alloc(16, 0x10)
2631 Cipher
.prototype._final = function () {
2632 var chunk
= this._cache
.flush()
2633 if (this._autopadding
) {
2634 chunk
= this._mode
.encrypt(this, chunk
)
2635 this._cipher
.scrub()
2639 if (!chunk
.equals(PADDING
)) {
2640 this._cipher
.scrub()
2641 throw new Error('data not multiple of block length')
2645 Cipher
.prototype.setAutoPadding = function (setTo
) {
2646 this._autopadding
= !!setTo
2650 function Splitter () {
2651 this.cache
= Buffer
.allocUnsafe(0)
2654 Splitter
.prototype.add = function (data
) {
2655 this.cache
= Buffer
.concat([this.cache
, data
])
2658 Splitter
.prototype.get = function () {
2659 if (this.cache
.length
> 15) {
2660 var out
= this.cache
.slice(0, 16)
2661 this.cache
= this.cache
.slice(16)
2667 Splitter
.prototype.flush = function () {
2668 var len
= 16 - this.cache
.length
2669 var padBuff
= Buffer
.allocUnsafe(len
)
2673 padBuff
.writeUInt8(len
, i
)
2676 return Buffer
.concat([this.cache
, padBuff
])
2679 function createCipheriv (suite
, password
, iv
) {
2680 var config
= MODES
[suite
.toLowerCase()]
2681 if (!config
) throw new TypeError('invalid suite type')
2683 if (typeof password
=== 'string') password
= Buffer
.from(password
)
2684 if (password
.length
!== config
.key
/ 8) throw new TypeError('invalid key length ' + password
.length
)
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
)
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
)
2695 return new Cipher(config
.module
, password
, iv
)
2698 function createCipher (suite
, password
) {
2699 var config
= MODES
[suite
.toLowerCase()]
2700 if (!config
) throw new TypeError('invalid suite type')
2702 var keys
= ebtk(password
, false, config
.key
, config
.iv
)
2703 return createCipheriv(suite
, keys
.key
, keys
.iv
)
2706 exports
.createCipheriv
= createCipheriv
2707 exports
.createCipher
= createCipher
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
){
2710 var Buffer
= require('safe-buffer').Buffer
2711 var ZEROES
= Buffer
.alloc(16, 0)
2713 function toArray (buf
) {
2715 buf
.readUInt32BE(0),
2716 buf
.readUInt32BE(4),
2717 buf
.readUInt32BE(8),
2718 buf
.readUInt32BE(12)
2722 function 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)
2731 function GHASH (key
) {
2733 this.state
= Buffer
.alloc(16, 0)
2734 this.cache
= Buffer
.allocUnsafe(0)
2737 // from http://bitwiseshiftleft.github.io/sjcl/doc/symbols/src/core_gcm.js.html
2738 // by Juho Vähä-Herttua
2739 GHASH
.prototype.ghash = function (block
) {
2741 while (++i
< block
.length
) {
2742 this.state
[i
] ^= block
[i
]
2747 GHASH
.prototype._multiply = function () {
2748 var Vi
= toArray(this.h
)
2749 var Zi
= [0, 0, 0, 0]
2753 xi
= (this.state
[~~(i
/ 8)] & (1 << (7 - (i
% 8)))) !== 0
2755 // Z_i+1 = Z_i ^ V_i
2762 // Store the value of LSB(V_i)
2763 lsbVi
= (Vi
[3] & 1) !== 0
2766 for (j
= 3; j
> 0; j
--) {
2767 Vi
[j
] = (Vi
[j
] >>> 1) | ((Vi
[j
- 1] & 1) << 31)
2771 // If LSB(V_i) is 1, V_i+1 = (V_i >> 1) ^ R
2773 Vi
[0] = Vi
[0] ^ (0xe1 << 24)
2776 this.state
= fromArray(Zi
)
2779 GHASH
.prototype.update = function (buf
) {
2780 this.cache
= Buffer
.concat([this.cache
, buf
])
2782 while (this.cache
.length
>= 16) {
2783 chunk
= this.cache
.slice(0, 16)
2784 this.cache
= this.cache
.slice(16)
2789 GHASH
.prototype.final = function (abl
, bl
) {
2790 if (this.cache
.length
) {
2791 this.ghash(Buffer
.concat([this.cache
, ZEROES
], 16))
2794 this.ghash(fromArray([0, abl
, 0, bl
]))
2798 module
.exports
= GHASH
2800 },{"safe-buffer":47}],13:[function(require
,module
,exports
){
2801 function incr32 (iv
) {
2805 item
= iv
.readUInt8(len
)
2807 iv
.writeUInt8(0, len
)
2810 iv
.writeUInt8(item
, len
)
2815 module
.exports
= incr32
2817 },{}],14:[function(require
,module
,exports
){
2818 var xor
= require('buffer-xor')
2820 exports
.encrypt = function (self
, block
) {
2821 var data
= xor(block
, self
._prev
)
2823 self
._prev
= self
._cipher
.encryptBlock(data
)
2827 exports
.decrypt = function (self
, block
) {
2828 var pad
= self
._prev
2831 var out
= self
._cipher
.decryptBlock(block
)
2833 return xor(out
, pad
)
2836 },{"buffer-xor":29}],15:[function(require
,module
,exports
){
2837 var Buffer
= require('safe-buffer').Buffer
2838 var xor
= require('buffer-xor')
2840 function 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
])
2848 exports
.encrypt = function (self
, data
, decrypt
) {
2849 var out
= Buffer
.allocUnsafe(0)
2852 while (data
.length
) {
2853 if (self
._cache
.length
=== 0) {
2854 self
._cache
= self
._cipher
.encryptBlock(self
._prev
)
2855 self
._prev
= Buffer
.allocUnsafe(0)
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
)
2863 out
= Buffer
.concat([out
, encryptStart(self
, data
, decrypt
)])
2871 },{"buffer-xor":29,"safe-buffer":47}],16:[function(require
,module
,exports
){
2872 var Buffer
= require('safe-buffer').Buffer
2874 function encryptByte (self
, byteParam
, decrypt
) {
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
)
2890 function shiftIn (buffer
, value
) {
2891 var len
= buffer
.length
2893 var out
= Buffer
.allocUnsafe(buffer
.length
)
2894 buffer
= Buffer
.concat([buffer
, Buffer
.from([value
])])
2897 out
[i
] = buffer
[i
] << 1 | buffer
[i
+ 1] >> (7)
2903 exports
.encrypt = function (self
, chunk
, decrypt
) {
2904 var len
= chunk
.length
2905 var out
= Buffer
.allocUnsafe(len
)
2909 out
[i
] = encryptByte(self
, chunk
[i
], decrypt
)
2915 },{"safe-buffer":47}],17:[function(require
,module
,exports
){
2916 var Buffer
= require('safe-buffer').Buffer
2918 function encryptByte (self
, byteParam
, decrypt
) {
2919 var pad
= self
._cipher
.encryptBlock(self
._prev
)
2920 var out
= pad
[0] ^ byteParam
2922 self
._prev
= Buffer
.concat([
2923 self
._prev
.slice(1),
2924 Buffer
.from([decrypt
? byteParam : out
])
2930 exports
.encrypt = function (self
, chunk
, decrypt
) {
2931 var len
= chunk
.length
2932 var out
= Buffer
.allocUnsafe(len
)
2936 out
[i
] = encryptByte(self
, chunk
[i
], decrypt
)
2942 },{"safe-buffer":47}],18:[function(require
,module
,exports
){
2943 var xor
= require('buffer-xor')
2944 var Buffer
= require('safe-buffer').Buffer
2945 var incr32
= require('../incr32')
2947 function getBlock (self
) {
2948 var out
= self
._cipher
.encryptBlockRaw(self
._prev
)
2954 exports
.encrypt = function (self
, chunk
) {
2955 var chunkNum
= Math
.ceil(chunk
.length
/ blockSize
)
2956 var start
= self
._cache
.length
2957 self
._cache
= Buffer
.concat([
2959 Buffer
.allocUnsafe(chunkNum
* blockSize
)
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)
2969 var pad
= self
._cache
.slice(0, chunk
.length
)
2970 self
._cache
= self
._cache
.slice(chunk
.length
)
2971 return xor(chunk
, pad
)
2974 },{"../incr32":13,"buffer-xor":29,"safe-buffer":47}],19:[function(require
,module
,exports
){
2975 exports
.encrypt = function (self
, block
) {
2976 return self
._cipher
.encryptBlock(block
)
2979 exports
.decrypt = function (self
, block
) {
2980 return self
._cipher
.decryptBlock(block
)
2983 },{}],20:[function(require
,module
,exports
){
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')
2995 var modes
= require('./list.json')
2997 for (var key
in modes
) {
2998 modes
[key
].module
= modeModules
[modes
[key
].mode
]
3001 module
.exports
= modes
3003 },{"./cbc":14,"./cfb":15,"./cfb1":16,"./cfb8":17,"./ctr":18,"./ecb":19,"./list.json":21,"./ofb":22}],21:[function(require
,module
,exports
){
3196 },{}],22:[function(require
,module
,exports
){
3198 var xor
= require('buffer-xor')
3200 function getBlock (self
) {
3201 self
._prev
= self
._cipher
.encryptBlock(self
._prev
)
3205 exports
.encrypt = function (self
, chunk
) {
3206 while (self
._cache
.length
< chunk
.length
) {
3207 self
._cache
= Buffer
.concat([self
._cache
, getBlock(self
)])
3210 var pad
= self
._cache
.slice(0, chunk
.length
)
3211 self
._cache
= self
._cache
.slice(chunk
.length
)
3212 return xor(chunk
, pad
)
3215 }).call(this,require("buffer").Buffer
)
3216 },{"buffer":110,"buffer-xor":29}],23:[function(require
,module
,exports
){
3217 var aes
= require('./aes')
3218 var Buffer
= require('safe-buffer').Buffer
3219 var Transform
= require('cipher-base')
3220 var inherits
= require('inherits')
3222 function StreamCipher (mode
, key
, iv
, decrypt
) {
3223 Transform
.call(this)
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
3233 inherits(StreamCipher
, Transform
)
3235 StreamCipher
.prototype._update = function (chunk
) {
3236 return this._mode
.encrypt(this, chunk
, this._decrypt
)
3239 StreamCipher
.prototype._final = function () {
3240 this._cipher
.scrub()
3243 module
.exports
= StreamCipher
3245 },{"./aes":7,"cipher-base":31,"inherits":44,"safe-buffer":47}],24:[function(require
,module
,exports
){
3246 var basex
= require('base-x')
3247 var ALPHABET
= '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
3249 module
.exports
= basex(ALPHABET
)
3251 },{"base-x":2}],25:[function(require
,module
,exports
){
3254 var base58
= require('bs58')
3255 var Buffer
= require('safe-buffer').Buffer
3257 module
.exports = function (checksumFn
) {
3258 // Encode a buffer as a base58-check encoded string
3259 function encode (payload
) {
3260 var checksum
= checksumFn(payload
)
3262 return base58
.encode(Buffer
.concat([
3265 ], payload
.length
+ 4))
3268 function decodeRaw (buffer
) {
3269 var payload
= buffer
.slice(0, -4)
3270 var checksum
= buffer
.slice(-4)
3271 var newChecksum
= checksumFn(payload
)
3273 if (checksum
[0] ^ newChecksum
[0] |
3274 checksum
[1] ^ newChecksum
[1] |
3275 checksum
[2] ^ newChecksum
[2] |
3276 checksum
[3] ^ newChecksum
[3]) return
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
)
3286 return decodeRaw(buffer
)
3289 function decode (string
) {
3290 var buffer
= base58
.decode(string
)
3291 var payload
= decodeRaw(buffer
, checksumFn
)
3292 if (!payload
) throw new Error('Invalid checksum')
3299 decodeUnsafe: decodeUnsafe
3303 },{"bs58":24,"safe-buffer":47}],26:[function(require
,module
,exports
){
3306 var createHash
= require('create-hash')
3307 var bs58checkBase
= require('./base')
3309 // SHA256(SHA256(buffer))
3310 function sha256x2 (buffer
) {
3311 var tmp
= createHash('sha256').update(buffer
).digest()
3312 return createHash('sha256').update(tmp
).digest()
3315 module
.exports
= bs58checkBase(sha256x2
)
3317 },{"./base":25,"create-hash":32}],27:[function(require
,module
,exports
){
3318 arguments
[4][25][0].apply(exports
,arguments
)
3319 },{"bs58":24,"dup":25,"safe-buffer":47}],28:[function(require
,module
,exports
){
3323 var createHash
= require('create-hash')
3324 var bs58grscheckBase
= require('./base')
3325 var groestlhash
= require('groestl-hash-js')
3327 // GROESTL512(GROESTL512(buffer))
3328 function groestl (buffer
) {
3329 return Buffer(groestlhash
.groestl_2(buffer
, 1, 1))
3332 module
.exports
= bs58grscheckBase(groestl
)
3334 }).call(this,require("buffer").Buffer
)
3335 },{"./base":27,"buffer":110,"create-hash":32,"groestl-hash-js":39}],29:[function(require
,module
,exports
){
3337 module
.exports
= function xor (a
, b
) {
3338 var length
= Math
.min(a
.length
, b
.length
)
3339 var buffer
= new Buffer(length
)
3341 for (var i
= 0; i
< length
; ++i
) {
3342 buffer
[i
] = a
[i
] ^ b
[i
]
3348 }).call(this,require("buffer").Buffer
)
3349 },{"buffer":110}],30:[function(require
,module
,exports
){
3350 module
.exports
= function xorInplace (a
, b
) {
3351 var length
= Math
.min(a
.length
, b
.length
)
3353 for (var i
= 0; i
< length
; ++i
) {
3357 return a
.slice(0, length
)
3360 },{}],31:[function(require
,module
,exports
){
3361 var Buffer
= require('safe-buffer').Buffer
3362 var Transform
= require('stream').Transform
3363 var StringDecoder
= require('string_decoder').StringDecoder
3364 var inherits
= require('inherits')
3366 function CipherBase (hashMode
) {
3367 Transform
.call(this)
3368 this.hashMode
= typeof hashMode
=== 'string'
3369 if (this.hashMode
) {
3370 this[hashMode
] = this._finalOrDigest
3372 this.final
= this._finalOrDigest
3375 this.__final
= this._final
3378 this._decoder
= null
3379 this._encoding
= null
3381 inherits(CipherBase
, Transform
)
3383 CipherBase
.prototype.update = function (data
, inputEnc
, outputEnc
) {
3384 if (typeof data
=== 'string') {
3385 data
= Buffer
.from(data
, inputEnc
)
3388 var outData
= this._update(data
)
3389 if (this.hashMode
) return this
3392 outData
= this._toString(outData
, outputEnc
)
3398 CipherBase
.prototype.setAutoPadding = function () {}
3399 CipherBase
.prototype.getAuthTag = function () {
3400 throw new Error('trying to get auth tag in unsupported state')
3403 CipherBase
.prototype.setAuthTag = function () {
3404 throw new Error('trying to set auth tag in unsupported state')
3407 CipherBase
.prototype.setAAD = function () {
3408 throw new Error('trying to set aad in unsupported state')
3411 CipherBase
.prototype._transform = function (data
, _
, next
) {
3414 if (this.hashMode
) {
3417 this.push(this._update(data
))
3425 CipherBase
.prototype._flush = function (done
) {
3428 this.push(this.__final())
3435 CipherBase
.prototype._finalOrDigest = function (outputEnc
) {
3436 var outData
= this.__final() || Buffer
.alloc(0)
3438 outData
= this._toString(outData
, outputEnc
, true)
3443 CipherBase
.prototype._toString = function (value
, enc
, fin
) {
3444 if (!this._decoder
) {
3445 this._decoder
= new StringDecoder(enc
)
3446 this._encoding
= enc
3449 if (this._encoding
!== enc
) throw new Error('can\'t switch encodings')
3451 var out
= this._decoder
.write(value
)
3453 out
+= this._decoder
.end()
3459 module
.exports
= CipherBase
3461 },{"inherits":44,"safe-buffer":47,"stream":215,"string_decoder":216}],32:[function(require
,module
,exports
){
3463 var inherits
= require('inherits')
3464 var MD5
= require('md5.js')
3465 var RIPEMD160
= require('ripemd160')
3466 var sha
= require('sha.js')
3467 var Base
= require('cipher-base')
3469 function Hash (hash
) {
3470 Base
.call(this, 'digest')
3475 inherits(Hash
, Base
)
3477 Hash
.prototype._update = function (data
) {
3478 this._hash
.update(data
)
3481 Hash
.prototype._final = function () {
3482 return this._hash
.digest()
3485 module
.exports
= function createHash (alg
) {
3486 alg
= alg
.toLowerCase()
3487 if (alg
=== 'md5') return new MD5()
3488 if (alg
=== 'rmd160' || alg
=== 'ripemd160') return new RIPEMD160()
3490 return new Hash(sha(alg
))
3493 },{"cipher-base":31,"inherits":44,"md5.js":45,"ripemd160":46,"sha.js":53}],33:[function(require
,module
,exports
){
3494 var assert
= require('assert')
3495 var BigInteger
= require('bigi')
3497 var Point
= require('./point')
3499 function Curve (p
, a
, b
, Gx
, Gy
, n
, h
) {
3503 this.G
= Point
.fromAffine(this, Gx
, Gy
)
3507 this.infinity
= new Point(this, null, null, BigInteger
.ZERO
)
3510 this.pOverFour
= p
.add(BigInteger
.ONE
).shiftRight(2)
3512 // determine size of p in bytes
3513 this.pLength
= Math
.floor((this.p
.bitLength() + 7) / 8)
3516 Curve
.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
3521 if (beta
.isEven() ^ !isOdd
) {
3522 y
= this.p
.subtract(y
) // -y % p
3525 return Point
.fromAffine(this, x
, y
)
3528 Curve
.prototype.isInfinity = function (Q
) {
3529 if (Q
=== this.infinity
) return true
3531 return Q
.z
.signum() === 0 && Q
.y
.signum() !== 0
3534 Curve
.prototype.isOnCurve = function (Q
) {
3535 if (this.isInfinity(Q
)) return true
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
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
)
3554 * Validate an elliptic curve point.
3556 * See SEC 1, section 3.2.2.1: Elliptic Curve Public Key Validation Primitive
3558 Curve
.prototype.validate = function (Q
) {
3560 assert(!this.isInfinity(Q
), 'Point is at infinity')
3561 assert(this.isOnCurve(Q
), 'Point is not on the curve')
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')
3570 module
.exports
= Curve
3572 },{"./point":37,"assert":74,"bigi":5}],34:[function(require
,module
,exports
){
3575 "p": "fffffffdffffffffffffffffffffffff",
3576 "a": "fffffffdfffffffffffffffffffffffc",
3577 "b": "e87579c11079f43dd824993c2cee5ed3",
3578 "n": "fffffffe0000000075a30d1b9038a115",
3580 "Gx": "161ff7528b899b2d0c28607ca52c5b86",
3581 "Gy": "cf5ac8395bafeb13c02da292dded7a83"
3584 "p": "fffffffffffffffffffffffffffffffeffffac73",
3587 "n": "0100000000000000000001b8fa16dfab9aca16b6b3",
3589 "Gx": "3b4c382ce37aa192a4019e763036f4f5dd4d7ebb",
3590 "Gy": "938cf935318fdced6bc28286531733c3f03c4fee"
3593 "p": "ffffffffffffffffffffffffffffffff7fffffff",
3594 "a": "ffffffffffffffffffffffffffffffff7ffffffc",
3595 "b": "1c97befc54bd7a8b65acf89f81d4d4adc565fa45",
3596 "n": "0100000000000000000001f4c8f927aed3ca752257",
3598 "Gx": "4a96b5688ef573284664698968c38bb913cbfc82",
3599 "Gy": "23a628553168947d59dcc912042351377ac5fb32"
3602 "p": "fffffffffffffffffffffffffffffffffffffffeffffee37",
3605 "n": "fffffffffffffffffffffffe26f2fc170f69466a74defd8d",
3607 "Gx": "db4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d",
3608 "Gy": "9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d"
3611 "p": "fffffffffffffffffffffffffffffffeffffffffffffffff",
3612 "a": "fffffffffffffffffffffffffffffffefffffffffffffffc",
3613 "b": "64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1",
3614 "n": "ffffffffffffffffffffffff99def836146bc9b1b4d22831",
3616 "Gx": "188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012",
3617 "Gy": "07192b95ffc8da78631011ed6b24cdd573f977a11e794811"
3620 "p": "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",
3623 "n": "fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",
3625 "Gx": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
3626 "Gy": "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"
3629 "p": "ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",
3630 "a": "ffffffff00000001000000000000000000000000fffffffffffffffffffffffc",
3631 "b": "5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b",
3632 "n": "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",
3634 "Gx": "6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296",
3635 "Gy": "4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"
3639 },{}],35:[function(require
,module
,exports
){
3640 var Point
= require('./point')
3641 var Curve
= require('./curve')
3643 var getCurveByName
= require('./names')
3648 getCurveByName: getCurveByName
3651 },{"./curve":33,"./names":36,"./point":37}],36:[function(require
,module
,exports
){
3652 var BigInteger
= require('bigi')
3654 var curves
= require('./curves.json')
3655 var Curve
= require('./curve')
3657 function getCurveByName (name
) {
3658 var curve
= curves
[name
]
3659 if (!curve
) return null
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)
3669 return new Curve(p
, a
, b
, Gx
, Gy
, n
, h
)
3672 module
.exports
= getCurveByName
3674 },{"./curve":33,"./curves.json":34,"bigi":5}],37:[function(require
,module
,exports
){
3675 var assert
= require('assert')
3676 var Buffer
= require('safe-buffer').Buffer
3677 var BigInteger
= require('bigi')
3679 var THREE
= BigInteger
.valueOf(3)
3681 function Point (curve
, x
, y
, z
) {
3682 assert
.notStrictEqual(z
, undefined, 'Missing Z coordinate')
3690 this.compressed
= true
3693 Object
.defineProperty(Point
.prototype, 'zInv', {
3695 if (this._zInv
=== null) {
3696 this._zInv
= this.z
.modInverse(this.curve
.p
)
3703 Object
.defineProperty(Point
.prototype, 'affineX', {
3705 return this.x
.multiply(this.zInv
).mod(this.curve
.p
)
3709 Object
.defineProperty(Point
.prototype, 'affineY', {
3711 return this.y
.multiply(this.zInv
).mod(this.curve
.p
)
3715 Point
.fromAffine = function (curve
, x
, y
) {
3716 return new Point(curve
, x
, y
, BigInteger
.ONE
)
3719 Point
.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)
3724 // u = Y2 * Z1 - Y1 * Z2
3725 var u
= other
.y
.multiply(this.z
).subtract(this.y
.multiply(other
.z
)).mod(this.curve
.p
)
3727 if (u
.signum() !== 0) return false
3729 // v = X2 * Z1 - X1 * Z2
3730 var v
= other
.x
.multiply(this.z
).subtract(this.x
.multiply(other
.z
)).mod(this.curve
.p
)
3732 return v
.signum() === 0
3735 Point
.prototype.negate = function () {
3736 var y
= this.curve
.p
.subtract(this.y
)
3738 return new Point(this.curve
, this.x
, y
, this.z
)
3741 Point
.prototype.add = function (b
) {
3742 if (this.curve
.isInfinity(this)) return b
3743 if (this.curve
.isInfinity(b
)) return this
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
)
3755 if (v
.signum() === 0) {
3756 if (u
.signum() === 0) {
3757 return this.twice() // this == b, so double
3760 return this.curve
.infinity
// this = -b, so infinity
3764 var v3
= v2
.multiply(v
)
3765 var x1v2
= x1
.multiply(v2
)
3766 var zu2
= u
.square().multiply(this.z
)
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
)
3775 return new Point(this.curve
, x3
, y3
, z3
)
3778 Point
.prototype.twice = function () {
3779 if (this.curve
.isInfinity(this)) return this
3780 if (this.y
.signum() === 0) return this.curve
.infinity
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
3789 // w = 3 * x1^2 + a * z1^2
3790 var w
= x1
.square().multiply(THREE
)
3792 if (a
.signum() !== 0) {
3793 w
= w
.add(this.z
.square().multiply(a
))
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
)
3804 return new Point(this.curve
, x3
, y3
, z3
)
3807 // Simple NAF (Non-Adjacent Form) multiplication algorithm
3808 // TODO: modularize the multiplication algorithm
3809 Point
.prototype.multiply = function (k
) {
3810 if (this.curve
.isInfinity(this)) return this
3811 if (k
.signum() === 0) return this.curve
.infinity
3814 var h
= e
.multiply(THREE
)
3816 var neg
= this.negate()
3819 for (var i
= h
.bitLength() - 2; i
> 0; --i
) {
3820 var hBit
= h
.testBit(i
)
3821 var eBit
= e
.testBit(i
)
3825 if (hBit
!== eBit
) {
3826 R
= R
.add(hBit
? this : neg
)
3833 // Compute this*j + x*k (simultaneous multiplication)
3834 Point
.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
)
3840 var jBit
= j
.testBit(i
)
3841 var kBit
= k
.testBit(i
)
3860 Point
.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'
3864 var x
= this.affineX
3865 var y
= this.affineY
3866 var byteLength
= this.curve
.pLength
3871 buffer
= Buffer
.allocUnsafe(1 + byteLength
)
3872 buffer
.writeUInt8(y
.isEven() ? 0x02 : 0x03, 0)
3876 buffer
= Buffer
.allocUnsafe(1 + byteLength
+ byteLength
)
3877 buffer
.writeUInt8(0x04, 0)
3879 y
.toBuffer(byteLength
).copy(buffer
, 1 + byteLength
)
3882 x
.toBuffer(byteLength
).copy(buffer
, 1)
3887 Point
.decodeFrom = function (curve
, buffer
) {
3888 var type
= buffer
.readUInt8(0)
3889 var compressed
= (type
!== 4)
3891 var byteLength
= Math
.floor((curve
.p
.bitLength() + 7) / 8)
3892 var x
= BigInteger
.fromBuffer(buffer
.slice(1, 1 + byteLength
))
3896 assert
.equal(buffer
.length
, byteLength
+ 1, 'Invalid sequence length')
3897 assert(type
=== 0x02 || type
=== 0x03, 'Invalid sequence tag')
3899 var isOdd
= (type
=== 0x03)
3900 Q
= curve
.pointFromX(isOdd
, x
)
3902 assert
.equal(buffer
.length
, 1 + byteLength
+ byteLength
, 'Invalid sequence length')
3904 var y
= BigInteger
.fromBuffer(buffer
.slice(1 + byteLength
))
3905 Q
= Point
.fromAffine(curve
, x
, y
)
3908 Q
.compressed
= compressed
3912 Point
.prototype.toString = function () {
3913 if (this.curve
.isInfinity(this)) return '(INFINITY)'
3915 return '(' + this.affineX
.toString() + ',' + this.affineY
.toString() + ')'
3918 module
.exports
= Point
3920 },{"assert":74,"bigi":5,"safe-buffer":47}],38:[function(require
,module
,exports
){
3921 var Buffer
= require('safe-buffer').Buffer
3922 var MD5
= require('md5.js')
3924 /* eslint-disable camelcase */
3925 function EVP_BytesToKey (password
, salt
, keyBits
, ivLen
) {
3926 if (!Buffer
.isBuffer(password
)) password
= Buffer
.from(password
, 'binary')
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')
3932 var keyLen
= keyBits
/ 8
3933 var key
= Buffer
.alloc(keyLen
)
3934 var iv
= Buffer
.alloc(ivLen
|| 0)
3935 var tmp
= Buffer
.alloc(0)
3937 while (keyLen
> 0 || ivLen
> 0) {
3938 var hash
= new MD5()
3940 hash
.update(password
)
3941 if (salt
) hash
.update(salt
)
3947 var keyStart
= key
.length
- keyLen
3948 used
= Math
.min(keyLen
, tmp
.length
)
3949 tmp
.copy(key
, keyStart
, 0, used
)
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
)
3962 return { key: key
, iv: iv
}
3965 module
.exports
= EVP_BytesToKey
3967 },{"md5.js":45,"safe-buffer":47}],39:[function(require
,module
,exports
){
3970 var groestl
= require('./lib/groestl');
3971 var h
= require('./lib/helper');
3973 var x11hash
= module
.exports
;
3975 module
.exports
.groestl512 = function(str
,format
, output
) {
3976 return groestl(str
,format
,output
);
3979 module
.exports
.groestl = function(str
,format
, output
) {
3980 var a
= groestl(str
,format
,2);
3985 else if (output
=== 1) {
3986 return h
.int32Buffer2Bytes(a
);
3989 return h
.int32ArrayToHexString(a
);
3993 module
.exports
.groestl_2 = function(str
,format
, output
) {
3994 var a
= groestl(str
,format
,2);
4000 else if (output
=== 1) {
4001 return h
.int32Buffer2Bytes(a
);
4004 return h
.int32ArrayToHexString(a
);
4007 },{"./lib/groestl":40,"./lib/helper":41}],40:[function(require
,module
,exports
){
4008 /////////////////////////////////////
4009 //////////// groestl ///////////////
4011 //// Written by Quantum Explorer ////
4012 ////////// Dash Foundation //////////
4013 /// Released under the MIT License //
4014 /////////////////////////////////////
4016 var o
= require('./op');
4017 var h
= require('./helper');
4019 var 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+oSPy0bLSQbEh2kuZ65Op4dWMScdJywdFg0RnIucmguNDZBdy13bC023BHNss2jsty0nSnuKXPutFtNFvsWtvtbpKUB9gFT9qR2oddN1+xNdrcUo2GjdWG3fTRJzkn6zn1S3417jaR7Ut2fQj5CoT7dXs2TcZO8cV4TsaKXoiaXE6aiBPUEV/WmuQG4aLhpaLkAAAAAAAAAAMG1dCx0mSzBQOCgYKCAYEDjwiEfId0f43k6Q8hD8sh5tpos7Sx37bbUDdm+2bO+1I1HykbKAUaNZxdw2XDO2Wdyr91L3eRLcpTted55M96UmP9n1Gcr1JiwkyPoI3vosIVb3kreEUqFuwa9a71ta7vFu34qfpEqxU97NOU0nuVP7dc6FjrBFu2G0lTFVBfFhpr4YtdiL9eaZpn/Vf/MVWYRtqeUpyKUEYrASs9KD8+K6dkwEDDJEOkEDgoGCggGBP5mmIGY54H+oKsL8Atb8KB4tMxEzPBEeCXw1brVSrolS3U+4z6W40uirA7zDl/zol1EGf4Zuv5dgNtbwFsbwIAFgIWKhQqKBT/T7K3sfq0/If7fvN9CvCFwqNhI2OBIcPH9DAQM+QTxYxl633rG32N3L1jBWO7Bd68wn3WfRXWvQuelY6WEY0IgcFAwUEAwIOXLLhou0Rrl/e8SDhLhDv2/CLdtt2Vtv4FV1EzUGUyBGCQ8FDwwFBgmeV81X0w1JsOycS9xnS/DvoY44Thn4b41yP2i/WqiNYjHT8xPC8yILmVLOUtcOS6TavlX+T1Xk1VYDfINqvJV/GGdgp3jgvx6s8lHyfRHesgn76zvi6zIuogy5zJv57oyT30rfWQrMuZCpJWk15XmwDv7oPuboMAZqrOYszKYGZ72aNFoJ9GeoyKBf4Fdf6NE7qpmqohmRFTWgn6CqH5UO93mq+Z2qzsLlZ6DnhaDC4zJRcpFA8qMx7x7KXuVKcdrBW7TbtbTayhsRDxEUDwopyyLeYtVeae8gT3iPWPivBYxJx0nLB0WrTeadppBdq3blk07Ta0722Se+lb6yFZkdKbSTtLoTnQUNiIeIigeFJLkdtt2P9uSDBIeCh4YCgxI/LRstJBsSLiPN+Q3a+S4n3jnXeclXZ+9D7JusmFuvUNpKu8qhu9DxDXxpvGTpsQ52uOo43KoOTHG96T3YqQx04pZN1m9N9PydIaLhv+L8tWDVjJWsTLVi07FQ8UNQ4tuhetZ69xZbtoYwrfCr7faAY6PjI8CjAGxHaxkrHlksZzxbdJtI9KcSXI74DuS4EnYH8e0x6u02Ky5FfoVQ/qs8/oJBwn9B/PPoG8lb4Ulz8og6q/qj6/K9H2JjonzjvRHZyDpII7pRxA4KBgoIBgQbwtk1WTe1W/wc4OIg/uI8Er7sW+xlG9KXMqWcpa4clw4VGwkbHAkOFdfCPEIrvFXcyFSx1Lmx3OXZPNR8zVRl8uuZSNljSPLoSWEfIRZfKHoV7+cv8uc6D5dYyFjfCE+lup83Xw33ZZhHn/cf8LcYQ2ckYaRGoYND5uUhZQehQ/gS6uQq9uQ4Hy6xkLG+EJ8cSZXxFfixHHMKeWq5YOqzJDjc9hzO9iQBgkPBQ8MBQb39AMBA/UB9xwqNhI2OBIcwjz+o/6fo8Jqi+Ff4dRfaq6+EPkQR/muaQJr0GvS0GkXv6iRqC6RF5lx6FjoKViZOlNpJ2l0Jzon99C50E65J9mRSDhIqTjZ6941EzXNE+sr5c6zzlazKyJ3VTNVRDMi0gTWu9a/u9KpOZBwkElwqQeHgImADokHM8Hyp/JmpzMt7MG2wVq2LTxaZiJmeCI8Fbitkq0qkhXJqWAgYIkgyYdc20nbFUmHqrAa/xpP/6pQ2Ih4iKB4UKUrjnqOUXqlA4mKj4oGjwNZShP4E7L4WQmSm4CbEoAJGiM5Fzk0FxplEHXadcraZdeEUzFTtTHXhNVRxlETxoTQA9O407u40ILcXsNeH8OCKeLLsMtSsClaw5l3mbR3Wh4tMxEzPBEeez1Gy0b2y3uotx/8H0v8qG0MYdZh2tZtLGJOOk5YOiw="));
4020 var T1
= h
.bytes2Int64Buffer(h
.b64Decode("xsYy9KX0l6X4+G+XhJfrhO7uXrCZsMeZ9vZ6jI2M943//+gXDRflDdbWCty93Le93t4WyLHIp7GRkW38VPw5VGBgkPBQ8MBQAgIHBQMFBAPOzi7gqeCHqVZW0Yd9h6x95+fMKxkr1Rm1tROmYqZxYk1NfDHmMZrm7OxZtZq1w5qPj0DPRc8FRR8fo7ydvD6diYlJwEDACUD6+miSh5Lvh+/v0D8VP8UVsrKUJusmf+uOjs5AyUAHyfv75h0LHe0LQUFuL+wvguyzsxqpZ6l9Z19fQxz9HL79RUVgJeoliuojI/nav9pGv1NTUQL3Aqb35ORFoZah05abm3btW+0tW3V1KF3CXerC4eHFJBwk2Rw9PdTprul6rkxM8r5qvphqbGyC7lru2Fp+fr3DQcP8QfX18wYCBvECg4NS0U/RHU9oaIzkXOTQXFFRVgf0B6L00dGNXDRcuTT5+eEYCBjpCOLiTK6Trt+Tq6s+lXOVTXNiYpf1U/XEUyoqa0E/QVQ/CAgcFAwUEAyVlWP2UvYxUkZG6a9lr4xlnZ1/4l7iIV4wMEh4KHhgKDc3z/ih+G6hCgobEQ8RFA8vL+vEtcRetQ4OFRsJGxwJJCR+WjZaSDYbG622m7Y2m9/fmEc9R6U9zc2naiZqgSZOTvW7abucaX9/M0zNTP7N6upQup+6z58SEj8tGy0kGx0dpLmeuTqeWFjEnHScsHQ0NEZyLnJoLjY2QXctd2wt3NwRzbLNo7K0tJ0p7ilz7ltbTRb7Frb7pKSlAfYBU/Z2dqHXTdfsTbe3FKNho3VhfX00Sc5J+s5SUt+Ne42ke93dn0I+QqE+Xl7Nk3GTvHETE7Gil6Iml6amogT1BFf1ubkBuGi4aWgAAAAAAAAAAMHBtXQsdJksQEDgoGCggGDj48IhHyHdH3l5OkPIQ/LItraaLO0sd+3U1A3Zvtmzvo2NR8pGygFGZ2cXcNlwztlycq/dS93kS5SU7XneeTPemJj/Z9RnK9SwsJMj6CN76IWFW95K3hFKu7sGvWu9bWvFxbt+Kn6RKk9PezTlNJ7l7e3XOhY6wRaGhtJUxVQXxZqa+GLXYi/XZmaZ/1X/zFUREbanlKcilIqKwErPSg/P6enZMBAwyRAEBA4KBgoIBv7+ZpiBmOeBoKCrC/ALW/B4eLTMRMzwRCUl8NW61Uq6S0t1PuM+luOioqwO8w5f811dRBn+Gbr+gIDbW8BbG8AFBYCFioUKij8/0+yt7H6tISH+37zfQrxwcKjYSNjgSPHx/QwEDPkEY2MZet96xt93dy9YwVjuwa+vMJ91n0V1QkLnpWOlhGMgIHBQMFBAMOXlyy4aLtEa/f3vEg4S4Q6/vwi3bbdlbYGBVdRM1BlMGBgkPBQ8MBQmJnlfNV9MNcPDsnEvcZ0vvr6GOOE4Z+E1Ncj9ov1qooiIx0/MTwvMLi5lSzlLXDmTk2r5V/k9V1VVWA3yDary/PxhnYKd44J6erPJR8n0R8jIJ++s74usurqIMucyb+cyMk99K31kK+bmQqSVpNeVwMA7+6D7m6AZGaqzmLMymJ6e9mjRaCfRo6MigX+BXX9ERO6qZqqIZlRU1oJ+gqh+Ozvd5qvmdqsLC5Weg54Wg4yMyUXKRQPKx8e8eyl7lSlrawVu027W0ygobEQ8RFA8p6csi3mLVXm8vIE94j1j4hYWMScdJywdra03mnaaQXbb25ZNO02tO2RknvpW+shWdHSm0k7S6E4UFDYiHiIoHpKS5Hbbdj/bDAwSHgoeGApISPy0bLSQbLi4jzfkN2vkn594513nJV29vQ+ybrJhbkNDaSrvKobvxMQ18abxk6Y5OdrjqONyqDExxvek92Kk09OKWTdZvTfy8nSGi4b/i9XVg1YyVrEyi4tOxUPFDUNuboXrWevcWdraGMK3wq+3AQGOj4yPAoyxsR2sZKx5ZJyc8W3SbSPSSUlyO+A7kuDY2B/HtMertKysuRX6FUP68/P6CQcJ/QfPz6BvJW+FJcrKIOqv6o+v9PR9iY6J845HR2cg6SCO6RAQOCgYKCAYb28LZNVk3tXw8HODiIP7iEpK+7FvsZRvXFzKlnKWuHI4OFRsJGxwJFdXXwjxCK7xc3MhUsdS5seXl2TzUfM1UcvLrmUjZY0joaElhHyEWXzo6Fe/nL/LnD4+XWMhY3whlpbqfN18N91hYR5/3H/C3A0NnJGGkRqGDw+blIWUHoXg4EurkKvbkHx8usZCxvhCcXEmV8RX4sTMzCnlquWDqpCQ43PYczvYBgYJDwUPDAX39/QDAQP1ARwcKjYSNjgSwsI8/qP+n6NqaovhX+HUX66uvhD5EEf5aWkCa9Br0tAXF7+okagukZmZcehY6ClYOjpTaSdpdCcnJ/fQudBOudnZkUg4SKk46+veNRM1zRMrK+XOs85WsyIid1UzVUQz0tIE1rvWv7upqTmQcJBJcAcHh4CJgA6JMzPB8qfyZqctLezBtsFatjw8WmYiZngiFRW4rZKtKpLJyalgIGCJIIeHXNtJ2xVJqqqwGv8aT/9QUNiIeIigeKWlK456jlF6AwOJio+KBo9ZWUoT+BOy+AkJkpuAmxKAGhojORc5NBdlZRB12nXK2tfXhFMxU7UxhITVUcZRE8bQ0APTuNO7uIKC3F7DXh/DKSniy7DLUrBaWsOZd5m0dx4eLTMRMzwRe3s9RstG9suoqLcf/B9L/G1tDGHWYdrWLCxiTjpOWDo="));
4021 var T2
= h
.bytes2Int64Buffer(h
.b64Decode("pcbGMvSl9JeE+Phvl4SX65nu7l6wmbDHjfb2eoyNjPcN///oFw0X5b3W1grcvdy3sd7eFsixyKdUkZFt/FT8OVBgYJDwUPDAAwICBwUDBQSpzs4u4Kngh31WVtGHfYesGefnzCsZK9VitbUTpmKmceZNTXwx5jGamuzsWbWatcNFj49Az0XPBZ0fH6O8nbw+QImJScBAwAmH+vpokoeS7xXv79A/FT/F67KylCbrJn/Jjo7OQMlABwv7++YdCx3t7EFBbi/sL4Jns7MaqWepff1fX0Mc/Ry+6kVFYCXqJYq/IyP52r/aRvdTU1EC9wKmluTkRaGWodNbm5t27VvtLcJ1dShdwl3qHOHhxSQcJNmuPT3U6a7pempMTPK+ar6YWmxsgu5a7thBfn69w0HD/AL19fMGAgbxT4ODUtFP0R1caGiM5Fzk0PRRUVYH9AeiNNHRjVw0XLkI+fnhGAgY6ZPi4kyuk67fc6urPpVzlU1TYmKX9VP1xD8qKmtBP0FUDAgIHBQMFBBSlZVj9lL2MWVGRumvZa+MXp2df+Je4iEoMDBIeCh4YKE3N8/4ofhuDwoKGxEPERS1Ly/rxLXEXgkODhUbCRscNiQkflo2WkibGxuttpu2Nj3f35hHPUelJs3Np2omaoFpTk71u2m7nM1/fzNMzUz+n+rqULqfus8bEhI/LRstJJ4dHaS5nrk6dFhYxJx0nLAuNDRGci5yaC02NkF3LXdsstzcEc2yzaPutLSdKe4pc/tbW00W+xa29qSkpQH2AVNNdnah103X7GG3txSjYaN1zn19NEnOSfp7UlLfjXuNpD7d3Z9CPkKhcV5ezZNxk7yXExOxopeiJvWmpqIE9QRXaLm5AbhouGkAAAAAAAAAACzBwbV0LHSZYEBA4KBgoIAf4+PCIR8h3ch5eTpDyEPy7ba2miztLHe+1NQN2b7Zs0aNjUfKRsoB2WdnF3DZcM5LcnKv3Uvd5N6UlO153nkz1JiY/2fUZyvosLCTI+gje0qFhVveSt4Ra7u7Br1rvW0qxcW7fip+keVPT3s05TSeFu3t1zoWOsHFhobSVMVUF9eamvhi12IvVWZmmf9V/8yUERG2p5SnIs+KisBKz0oPEOnp2TAQMMkGBAQOCgYKCIH+/maYgZjn8KCgqwvwC1tEeHi0zETM8LolJfDVutVK40tLdT7jPpbzoqKsDvMOX/5dXUQZ/hm6wICA21vAWxuKBQWAhYqFCq0/P9Psrex+vCEh/t+830JIcHCo2EjY4ATx8f0MBAz532NjGXrfesbBd3cvWMFY7nWvrzCfdZ9FY0JC56VjpYQwICBwUDBQQBrl5csuGi7RDv397xIOEuFtv78It223ZUyBgVXUTNQZFBgYJDwUPDA1JiZ5XzVfTC/Dw7JxL3Gd4b6+hjjhOGeiNTXI/aL9asyIiMdPzE8LOS4uZUs5S1xXk5Nq+Vf5PfJVVVgN8g2qgvz8YZ2CneNHenqzyUfJ9KzIyCfvrO+L57q6iDLnMm8rMjJPfSt9ZJXm5kKklaTXoMDAO/ug+5uYGRmqs5izMtGenvZo0Wgnf6OjIoF/gV1mRETuqmaqiH5UVNaCfoKoqzs73ear5naDCwuVnoOeFsqMjMlFykUDKcfHvHspe5XTa2sFbtNu1jwoKGxEPERQeaenLIt5i1XivLyBPeI9Yx0WFjEnHScsdq2tN5p2mkE729uWTTtNrVZkZJ76VvrITnR0ptJO0ugeFBQ2Ih4iKNuSkuR223Y/CgwMEh4KHhhsSEj8tGy0kOS4uI835DdrXZ+feOdd5yVuvb0Psm6yYe9DQ2kq7yqGpsTENfGm8ZOoOTna46jjcqQxMcb3pPdiN9PTilk3Wb2L8vJ0houG/zLV1YNWMlaxQ4uLTsVDxQ1Zbm6F61nr3Lfa2hjCt8KvjAEBjo+MjwJksbEdrGSsedKcnPFt0m0j4ElJcjvgO5K02Ngfx7THq/qsrLkV+hVDB/Pz+gkHCf0lz8+gbyVvha/KyiDqr+qPjvT0fYmOifPpR0dnIOkgjhgQEDgoGCgg1W9vC2TVZN6I8PBzg4iD+29KSvuxb7GUclxcypZylrgkODhUbCRscPFXV18I8Qiux3NzIVLHUuZRl5dk81HzNSPLy65lI2WNfKGhJYR8hFmc6OhXv5y/yyE+Pl1jIWN83ZaW6nzdfDfcYWEef9x/woYNDZyRhpEahQ8Pm5SFlB6Q4OBLq5Cr20J8fLrGQsb4xHFxJlfEV+KqzMwp5arlg9iQkONz2HM7BQYGCQ8FDwwB9/f0AwED9RIcHCo2EjY4o8LCPP6j/p9famqL4V/h1Pmurr4Q+RBH0GlpAmvQa9KRFxe/qJGoLliZmXHoWOgpJzo6U2knaXS5Jyf30LnQTjjZ2ZFIOEipE+vr3jUTNc2zKyvlzrPOVjMiIndVM1VEu9LSBNa71r9wqak5kHCQSYkHB4eAiYAOpzMzwfKn8ma2LS3swbbBWiI8PFpmImZ4khUVuK2SrSogycmpYCBgiUmHh1zbSdsV/6qqsBr/Gk94UFDYiHiIoHqlpSuOeo5RjwMDiYqPigb4WVlKE/gTsoAJCZKbgJsSFxoaIzkXOTTaZWUQddp1yjHX14RTMVO1xoSE1VHGURO40NAD07jTu8OCgtxew14fsCkp4suwy1J3WlrDmXeZtBEeHi0zETM8y3t7PUbLRvb8qKi3H/wfS9ZtbQxh1mHaOiwsYk46Tlg="));
4022 var T3
= h
.bytes2Int64Buffer(h
.b64Decode("l6XGxjL0pfTrhPj4b5eEl8eZ7u5esJmw94329nqMjYzlDf//6BcNF7e91tYK3L3cp7He3hbIscg5VJGRbfxU/MBQYGCQ8FDwBAMCAgcFAwWHqc7OLuCp4Kx9VlbRh32H1Rnn58wrGStxYrW1E6ZipprmTU18MeYxw5rs7Fm1mrUFRY+PQM9Fzz6dHx+jvJ28CUCJiUnAQMDvh/r6aJKHksUV7+/QPxU/f+uyspQm6yYHyY6OzkDJQO0L+/vmHQsdguxBQW4v7C99Z7OzGqlnqb79X19DHP0ciupFRWAl6iVGvyMj+dq/2qb3U1NRAvcC05bk5EWhlqEtW5ubdu1b7erCdXUoXcJd2Rzh4cUkHCR6rj091Omu6ZhqTEzyvmq+2FpsbILuWu78QX5+vcNBw/EC9fXzBgIGHU+Dg1LRT9HQXGhojORc5KL0UVFWB/QHuTTR0Y1cNFzpCPn54RgIGN+T4uJMrpOuTXOrqz6Vc5XEU2Jil/VT9VQ/KiprQT9BEAwICBwUDBQxUpWVY/ZS9oxlRkbpr2WvIV6dnX/iXuJgKDAwSHgoeG6hNzfP+KH4FA8KChsRDxFetS8v68S1xBwJDg4VGwkbSDYkJH5aNlo2mxsbrbabtqU939+YRz1HgSbNzadqJmqcaU5O9btpu/7Nf38zTM1Mz5/q6lC6n7okGxISPy0bLTqeHR2kuZ65sHRYWMScdJxoLjQ0RnIucmwtNjZBdy13o7Lc3BHNss1z7rS0nSnuKbb7W1tNFvsWU/akpKUB9gHsTXZ2oddN13Vht7cUo2Gj+s59fTRJzkmke1JS3417jaE+3d2fQj5CvHFeXs2TcZMmlxMTsaKXolf1pqaiBPUEaWi5uQG4aLgAAAAAAAAAAJkswcG1dCx0gGBAQOCgYKDdH+PjwiEfIfLIeXk6Q8hDd+22tpos7SyzvtTUDdm+2QFGjY1HykbKztlnZxdw2XDkS3Jyr91L3TPelJTted55K9SYmP9n1Gd76LCwkyPoIxFKhYVb3krebWu7uwa9a72RKsXFu34qfp7lT097NOU0wRbt7dc6FjoXxYaG0lTFVC/Xmpr4YtdizFVmZpn/Vf8ilBERtqeUpw/PiorASs9KyRDp6dkwEDAIBgQEDgoGCueB/v5mmIGYW/CgoKsL8AvwRHh4tMxEzEq6JSXw1brVluNLS3U+4z5f86KirA7zDrr+XV1EGf4ZG8CAgNtbwFsKigUFgIWKhX6tPz/T7K3sQrwhIf7fvN/gSHBwqNhI2PkE8fH9DAQMxt9jYxl633ruwXd3L1jBWEV1r68wn3WfhGNCQuelY6VAMCAgcFAwUNEa5eXLLhou4Q79/e8SDhJlbb+/CLdttxlMgYFV1EzUMBQYGCQ8FDxMNSYmeV81X50vw8OycS9xZ+G+voY44ThqojU1yP2i/QvMiIjHT8xPXDkuLmVLOUs9V5OTavlX+aryVVVYDfIN44L8/GGdgp30R3p6s8lHyYusyMgn76zvb+e6uogy5zJkKzIyT30rfdeV5uZCpJWkm6DAwDv7oPsymBkZqrOYsyfRnp72aNFoXX+joyKBf4GIZkRE7qpmqqh+VFTWgn6Cdqs7O93mq+YWgwsLlZ6DngPKjIzJRcpFlSnHx7x7KXvW02trBW7TblA8KChsRDxEVXmnpyyLeYtj4ry8gT3iPSwdFhYxJx0nQXatrTeadpqtO9vblk07TchWZGSe+lb66E50dKbSTtIoHhQUNiIeIj/bkpLkdtt2GAoMDBIeCh6QbEhI/LRstGvkuLiPN+Q3JV2fn3jnXedhbr29D7JusobvQ0NpKu8qk6bExDXxpvFyqDk52uOo42KkMTHG96T3vTfT04pZN1n/i/LydIaLhrEy1dWDVjJWDUOLi07FQ8XcWW5uhetZ66+32toYwrfCAowBAY6PjI95ZLGxHaxkrCPSnJzxbdJtkuBJSXI74DurtNjYH8e0x0P6rKy5FfoV/Qfz8/oJBwmFJc/PoG8lb4+vysog6q/q84709H2JjomO6UdHZyDpICAYEBA4KBgo3tVvbwtk1WT7iPDwc4OIg5RvSkr7sW+xuHJcXMqWcpZwJDg4VGwkbK7xV1dfCPEI5sdzcyFSx1I1UZeXZPNR840jy8uuZSNlWXyhoSWEfITLnOjoV7+cv3whPj5dYyFjN92Wlup83XzC3GFhHn/cfxqGDQ2ckYaRHoUPD5uUhZTbkODgS6uQq/hCfHy6xkLG4sRxcSZXxFeDqszMKeWq5TvYkJDjc9hzDAUGBgkPBQ/1Aff39AMBAzgSHBwqNhI2n6PCwjz+o/7UX2pqi+Ff4Uf5rq6+EPkQ0tBpaQJr0GsukRcXv6iRqClYmZlx6FjodCc6OlNpJ2lOuScn99C50Kk42dmRSDhIzRPr6941EzVWsysr5c6zzkQzIiJ3VTNVv7vS0gTWu9ZJcKmpOZBwkA6JBweHgImAZqczM8Hyp/Jati0t7MG2wXgiPDxaZiJmKpIVFbitkq2JIMnJqWAgYBVJh4dc20nbT/+qqrAa/xqgeFBQ2Ih4iFF6paUrjnqOBo8DA4mKj4qy+FlZShP4ExKACQmSm4CbNBcaGiM5FznK2mVlEHXadbUx19eEUzFTE8aEhNVRxlG7uNDQA9O40x/DgoLcXsNeUrApKeLLsMu0d1paw5l3mTwRHh4tMxEz9st7ez1Gy0ZL/Kiotx/8H9rWbW0MYdZhWDosLGJOOk4="));
4023 var T4
= h
.bytes2Int64Buffer(h
.b64Decode("9JelxsYy9KWX64T4+G+XhLDHme7uXrCZjPeN9vZ6jI0X5Q3//+gXDdy3vdbWCty9yKex3t4WyLH8OVSRkW38VPDAUGBgkPBQBQQDAgIHBQPgh6nOzi7gqYesfVZW0Yd9K9UZ5+fMKxmmcWK1tROmYjGa5k1NfDHmtcOa7OxZtZrPBUWPj0DPRbw+nR8fo7ydwAlAiYlJwECS74f6+miShz/FFe/v0D8VJn/rsrKUJutAB8mOjs5AyR3tC/v75h0LL4LsQUFuL+ypfWezsxqpZxy+/V9fQxz9JYrqRUVgJeraRr8jI/navwKm91NTUQL3odOW5ORFoZbtLVubm3btW13qwnV1KF3CJNkc4eHFJBzpeq49PdTprr6YakxM8r5q7thabGyC7lrD/EF+fr3DQQbxAvX18wYC0R1Pg4NS0U/k0FxoaIzkXAei9FFRVgf0XLk00dGNXDQY6Qj5+eEYCK7fk+LiTK6TlU1zq6s+lXP1xFNiYpf1U0FUPyoqa0E/FBAMCAgcFAz2MVKVlWP2Uq+MZUZG6a9l4iFenZ1/4l54YCgwMEh4KPhuoTc3z/ihERQPCgobEQ/EXrUvL+vEtRscCQ4OFRsJWkg2JCR+Wja2NpsbG622m0elPd/fmEc9aoEmzc2naia7nGlOTvW7aUz+zX9/M0zNus+f6upQup8tJBsSEj8tG7k6nh0dpLmenLB0WFjEnHRyaC40NEZyLndsLTY2QXctzaOy3NwRzbIpc+60tJ0p7ha2+1tbTRb7AVP2pKSlAfbX7E12dqHXTaN1Ybe3FKNhSfrOfX00Sc6NpHtSUt+Ne0KhPt3dn0I+k7xxXl7Nk3GiJpcTE7GilwRX9aamogT1uGloubkBuGgAAAAAAAAAAHSZLMHBtXQsoIBgQEDgoGAh3R/j48IhH0PyyHl5OkPILHfttraaLO3Zs77U1A3ZvsoBRo2NR8pGcM7ZZ2cXcNnd5Etycq/dS3kz3pSU7XneZyvUmJj/Z9Qje+iwsJMj6N4RSoWFW95KvW1ru7sGvWt+kSrFxbt+KjSe5U9PezTlOsEW7e3XOhZUF8WGhtJUxWIv15qa+GLX/8xVZmaZ/1WnIpQREbanlEoPz4qKwErPMMkQ6enZMBAKCAYEBA4KBpjngf7+ZpiBC1vwoKCrC/DM8ER4eLTMRNVKuiUl8NW6PpbjS0t1PuMOX/OioqwO8xm6/l1dRBn+WxvAgIDbW8CFCooFBYCFiux+rT8/0+yt30K8ISH+37zY4EhwcKjYSAz5BPHx/QwEesbfY2MZet9Y7sF3dy9YwZ9Fda+vMJ91pYRjQkLnpWNQQDAgIHBQMC7RGuXlyy4aEuEO/f3vEg63ZW2/vwi3bdQZTIGBVdRMPDAUGBgkPBRfTDUmJnlfNXGdL8PDsnEvOGfhvr6GOOH9aqI1Ncj9ok8LzIiIx0/MS1w5Li5lSzn5PVeTk2r5Vw2q8lVVWA3yneOC/PxhnYLJ9Ed6erPJR++LrMjIJ++sMm/nurqIMud9ZCsyMk99K6TXlebmQqSV+5ugwMA7+6CzMpgZGaqzmGgn0Z6e9mjRgV1/o6MigX+qiGZERO6qZoKoflRU1oJ+5narOzvd5queFoMLC5Weg0UDyoyMyUXKe5Upx8e8eylu1tNrawVu00RQPCgobEQ8i1V5p6csi3k9Y+K8vIE94icsHRYWMScdmkF2ra03mnZNrTvb25ZNO/rIVmRknvpW0uhOdHSm0k4iKB4UFDYiHnY/25KS5HbbHhgKDAwSHgq0kGxISPy0bDdr5Li4jzfk5yVdn594512yYW69vQ+ybiqG70NDaSrv8ZOmxMQ18abjcqg5OdrjqPdipDExxvekWb0309OKWTeG/4vy8nSGi1axMtXVg1YyxQ1Di4tOxUPr3FluboXrWcKvt9raGMK3jwKMAQGOj4yseWSxsR2sZG0j0pyc8W3SO5LgSUlyO+DHq7TY2B/HtBVD+qysuRX6Cf0H8/P6CQdvhSXPz6BvJeqPr8rKIOqvifOO9PR9iY4gjulHR2cg6SggGBAQOCgYZN7Vb28LZNWD+4jw8HODiLGUb0pK+7FvlrhyXFzKlnJscCQ4OFRsJAiu8VdXXwjxUubHc3MhUsfzNVGXl2TzUWWNI8vLrmUjhFl8oaElhHy/y5zo6Fe/nGN8IT4+XWMhfDfdlpbqfN1/wtxhYR5/3JEahg0NnJGGlB6FDw+blIWr25Dg4EurkMb4Qnx8usZCV+LEcXEmV8Tlg6rMzCnlqnM72JCQ43PYDwwFBgYJDwUD9QH39/QDATY4EhwcKjYS/p+jwsI8/qPh1F9qaovhXxBH+a6uvhD5a9LQaWkCa9CoLpEXF7+okegpWJmZcehYaXQnOjpTaSfQTrknJ/fQuUipONnZkUg4Nc0T6+veNRPOVrMrK+XOs1VEMyIid1Uz1r+70tIE1ruQSXCpqTmQcIAOiQcHh4CJ8manMzPB8qfBWrYtLezBtmZ4Ijw8WmYirSqSFRW4rZJgiSDJyalgINsVSYeHXNtJGk//qqqwGv+IoHhQUNiIeI5ReqWlK456igaPAwOJio8TsvhZWUoT+JsSgAkJkpuAOTQXGhojORd1ytplZRB12lO1MdfXhFMxURPGhITVUcbTu7jQ0APTuF4fw4KC3F7Dy1KwKSniy7CZtHdaWsOZdzM8ER4eLTMRRvbLe3s9RssfS/yoqLcf/GHa1m1tDGHWTlg6LCxiTjo="));
4024 var T5
= h
.bytes2Int64Buffer(h
.b64Decode("pfSXpcbGMvSEl+uE+Phvl5mwx5nu7l6wjYz3jfb2eowNF+UN///oF73ct73W1grcscinsd7eFshU/DlUkZFt/FDwwFBgYJDwAwUEAwICBwWp4Iepzs4u4H2HrH1WVtGHGSvVGefnzCtipnFitbUTpuYxmuZNTXwxmrXDmuzsWbVFzwVFj49Az528Pp0fH6O8QMAJQImJScCHku+H+vpokhU/xRXv79A/6yZ/67KylCbJQAfJjo7OQAsd7Qv7++Yd7C+C7EFBbi9nqX1ns7Maqf0cvv1fX0Mc6iWK6kVFYCW/2ka/IyP52vcCpvdTU1EClqHTluTkRaFb7S1bm5t27cJd6sJ1dShdHCTZHOHhxSSu6XquPT3U6Wq+mGpMTPK+Wu7YWmxsgu5Bw/xBfn69wwIG8QL19fMGT9EdT4ODUtFc5NBcaGiM5PQHovRRUVYHNFy5NNHRjVwIGOkI+fnhGJOu35Pi4kyuc5VNc6urPpVT9cRTYmKX9T9BVD8qKmtBDBQQDAgIHBRS9jFSlZVj9mWvjGVGRumvXuIhXp2df+IoeGAoMDBIeKH4bqE3N8/4DxEUDwoKGxG1xF61Ly/rxAkbHAkODhUbNlpINiQkflqbtjabGxuttj1HpT3f35hHJmqBJs3Np2ppu5xpTk71u81M/s1/fzNMn7rPn+rqULobLSQbEhI/LZ65Op4dHaS5dJywdFhYxJwucmguNDRGci13bC02NkF3ss2jstzcEc3uKXPutLSdKfsWtvtbW00W9gFT9qSkpQFN1+xNdnah12GjdWG3txSjzkn6zn19NEl7jaR7UlLfjT5CoT7d3Z9CcZO8cV5ezZOXoiaXExOxovUEV/WmpqIEaLhpaLm5AbgAAAAAAAAAACx0mSzBwbV0YKCAYEBA4KAfId0f4+PCIchD8sh5eTpD7Sx37ba2miy+2bO+1NQN2UbKAUaNjUfK2XDO2WdnF3BL3eRLcnKv3d55M96UlO151Gcr1JiY/2foI3vosLCTI0reEUqFhVvea71ta7u7Br0qfpEqxcW7fuU0nuVPT3s0FjrBFu3t1zrFVBfFhobSVNdiL9eamvhiVf/MVWZmmf+UpyKUERG2p89KD8+KisBKEDDJEOnp2TAGCggGBAQOCoGY54H+/maY8Atb8KCgqwtEzPBEeHi0zLrVSrolJfDV4z6W40tLdT7zDl/zoqKsDv4Zuv5dXUQZwFsbwICA21uKhQqKBQWAha3sfq0/P9PsvN9CvCEh/t9I2OBIcHCo2AQM+QTx8f0M33rG32NjGXrBWO7Bd3cvWHWfRXWvrzCfY6WEY0JC56UwUEAwICBwUBou0Rrl5csuDhLhDv397xJtt2Vtv78It0zUGUyBgVXUFDwwFBgYJDw1X0w1JiZ5Xy9xnS/Dw7Jx4Thn4b6+hjii/WqiNTXI/cxPC8yIiMdPOUtcOS4uZUtX+T1Xk5Nq+fINqvJVVVgNgp3jgvz8YZ1HyfRHenqzyazvi6zIyCfv5zJv57q6iDIrfWQrMjJPfZWk15Xm5kKkoPuboMDAO/uYszKYGRmqs9FoJ9GenvZof4Fdf6OjIoFmqohmRETuqn6CqH5UVNaCq+Z2qzs73eaDnhaDCwuVnspFA8qMjMlFKXuVKcfHvHvTbtbTa2sFbjxEUDwoKGxEeYtVeaenLIviPWPivLyBPR0nLB0WFjEndppBdq2tN5o7Ta0729uWTVb6yFZkZJ76TtLoTnR0ptIeIigeFBQ2Itt2P9uSkuR2Ch4YCgwMEh5stJBsSEj8tOQ3a+S4uI83XeclXZ+feOdusmFuvb0Psu8qhu9DQ2kqpvGTpsTENfGo43KoOTna46T3YqQxMcb3N1m9N9PTilmLhv+L8vJ0hjJWsTLV1YNWQ8UNQ4uLTsVZ69xZbm6F67fCr7fa2hjCjI8CjAEBjo9krHlksbEdrNJtI9KcnPFt4DuS4ElJcju0x6u02Ngfx/oVQ/qsrLkVBwn9B/Pz+gklb4Ulz8+gb6/qj6/KyiDqjonzjvT0fYnpII7pR0dnIBgoIBgQEDgo1WTe1W9vC2SIg/uI8PBzg2+xlG9KSvuxcpa4clxcypYkbHAkODhUbPEIrvFXV18Ix1Lmx3NzIVJR8zVRl5dk8yNljSPLy65lfIRZfKGhJYScv8uc6OhXvyFjfCE+Pl1j3Xw33ZaW6nzcf8LcYWEef4aRGoYNDZyRhZQehQ8Pm5SQq9uQ4OBLq0LG+EJ8fLrGxFfixHFxJleq5YOqzMwp5dhzO9iQkONzBQ8MBQYGCQ8BA/UB9/f0AxI2OBIcHCo2o/6fo8LCPP5f4dRfamqL4fkQR/murr4Q0GvS0GlpAmuRqC6RFxe/qFjoKViZmXHoJ2l0Jzo6U2m50E65Jyf30DhIqTjZ2ZFIEzXNE+vr3jWzzlazKyvlzjNVRDMiIndVu9a/u9LSBNZwkElwqak5kImADokHB4eAp/JmpzMzwfK2wVq2LS3swSJmeCI8PFpmkq0qkhUVuK0gYIkgycmpYEnbFUmHh1zb/xpP/6qqsBp4iKB4UFDYiHqOUXqlpSuOj4oGjwMDiYr4E7L4WVlKE4CbEoAJCZKbFzk0FxoaIznadcraZWUQdTFTtTHX14RTxlETxoSE1VG407u40NAD08NeH8OCgtxesMtSsCkp4st3mbR3WlrDmREzPBEeHi0zy0b2y3t7PUb8H0v8qKi3H9Zh2tZtbQxhOk5YOiwsYk4="));
4025 var T6
= h
.bytes2Int64Buffer(h
.b64Decode("9KX0l6XGxjKXhJfrhPj4b7CZsMeZ7u5ejI2M94329noXDRflDf//6Ny93Le91tYKyLHIp7He3hb8VPw5VJGRbfBQ8MBQYGCQBQMFBAMCAgfgqeCHqc7OLod9h6x9VlbRKxkr1Rnn58ymYqZxYrW1EzHmMZrmTU18tZq1w5rs7FnPRc8FRY+PQLydvD6dHx+jwEDACUCJiUmSh5Lvh/r6aD8VP8UV7+/QJusmf+uyspRAyUAHyY6Ozh0LHe0L+/vmL+wvguxBQW6pZ6l9Z7OzGhz9HL79X19DJeoliupFRWDav9pGvyMj+QL3Aqb3U1NRoZah05bk5EXtW+0tW5ubdl3CXerCdXUoJBwk2Rzh4cXprul6rj091L5qvphqTEzy7lru2FpsbILDQcP8QX5+vQYCBvEC9fXz0U/RHU+Dg1LkXOTQXGhojAf0B6L0UVFWXDRcuTTR0Y0YCBjpCPn54a6Trt+T4uJMlXOVTXOrqz71U/XEU2Jil0E/QVQ/KiprFAwUEAwICBz2UvYxUpWVY69lr4xlRkbp4l7iIV6dnX94KHhgKDAwSPih+G6hNzfPEQ8RFA8KChvEtcRetS8v6xsJGxwJDg4VWjZaSDYkJH62m7Y2mxsbrUc9R6U939+YaiZqgSbNzae7abucaU5O9UzNTP7Nf38zup+6z5/q6lAtGy0kGxISP7meuTqeHR2knHScsHRYWMRyLnJoLjQ0Rnctd2wtNjZBzbLNo7Lc3BEp7ilz7rS0nRb7Frb7W1tNAfYBU/akpKXXTdfsTXZ2oaNho3Vht7cUSc5J+s59fTSNe42ke1JS30I+QqE+3d2fk3GTvHFeXs2il6ImlxMTsQT1BFf1pqaiuGi4aWi5uQEAAAAAAAAAAHQsdJkswcG1oGCggGBAQOAhHyHdH+PjwkPIQ/LIeXk6LO0sd+22tprZvtmzvtTUDcpGygFGjY1HcNlwztlnZxfdS93kS3Jyr3neeTPelJTtZ9RnK9SYmP8j6CN76LCwk95K3hFKhYVbvWu9bWu7uwZ+Kn6RKsXFuzTlNJ7lT097OhY6wRbt7ddUxVQXxYaG0mLXYi/Xmpr4/1X/zFVmZpmnlKcilBERtkrPSg/PiorAMBAwyRDp6dkKBgoIBgQEDpiBmOeB/v5mC/ALW/CgoKvMRMzwRHh4tNW61Uq6JSXwPuM+luNLS3UO8w5f86KirBn+Gbr+XV1EW8BbG8CAgNuFioUKigUFgOyt7H6tPz/T37zfQrwhIf7YSNjgSHBwqAwEDPkE8fH9et96xt9jYxlYwVjuwXd3L591n0V1r68wpWOlhGNCQudQMFBAMCAgcC4aLtEa5eXLEg4S4Q79/e+3bbdlbb+/CNRM1BlMgYFVPBQ8MBQYGCRfNV9MNSYmeXEvcZ0vw8OyOOE4Z+G+vob9ov1qojU1yE/MTwvMiIjHSzlLXDkuLmX5V/k9V5OTag3yDaryVVVYnYKd44L8/GHJR8n0R3p6s++s74usyMgnMucyb+e6uoh9K31kKzIyT6SVpNeV5uZC+6D7m6DAwDuzmLMymBkZqmjRaCfRnp72gX+BXX+joyKqZqqIZkRE7oJ+gqh+VFTW5qvmdqs7O92eg54WgwsLlUXKRQPKjIzJeyl7lSnHx7xu027W02trBUQ8RFA8KChsi3mLVXmnpyw94j1j4ry8gScdJywdFhYxmnaaQXatrTdNO02tO9vblvpW+shWZGSe0k7S6E50dKYiHiIoHhQUNnbbdj/bkpLkHgoeGAoMDBK0bLSQbEhI/DfkN2vkuLiP513nJV2fn3iybrJhbr29DyrvKobvQ0Np8abxk6bExDXjqONyqDk52vek92KkMTHGWTdZvTfT04qGi4b/i/LydFYyVrEy1dWDxUPFDUOLi07rWevcWW5uhcK3wq+32toYj4yPAowBAY6sZKx5ZLGxHW3SbSPSnJzxO+A7kuBJSXLHtMertNjYHxX6FUP6rKy5CQcJ/Qfz8/pvJW+FJc/PoOqv6o+vysogiY6J84709H0g6SCO6UdHZygYKCAYEBA4ZNVk3tVvbwuDiIP7iPDwc7FvsZRvSkr7lnKWuHJcXMpsJGxwJDg4VAjxCK7xV1dfUsdS5sdzcyHzUfM1UZeXZGUjZY0jy8uuhHyEWXyhoSW/nL/LnOjoV2MhY3whPj5dfN18N92Wlup/3H/C3GFhHpGGkRqGDQ2clIWUHoUPD5urkKvbkODgS8ZCxvhCfHy6V8RX4sRxcSblquWDqszMKXPYczvYkJDjDwUPDAUGBgkDAQP1Aff39DYSNjgSHBwq/qP+n6PCwjzhX+HUX2pqixD5EEf5rq6+a9Br0tBpaQKokagukRcXv+hY6ClYmZlxaSdpdCc6OlPQudBOuScn90g4SKk42dmRNRM1zRPr697Os85Wsysr5VUzVUQzIiJ31rvWv7vS0gSQcJBJcKmpOYCJgA6JBweH8qfyZqczM8HBtsFati0t7GYiZngiPDxarZKtKpIVFbhgIGCJIMnJqdtJ2xVJh4dcGv8aT/+qqrCIeIigeFBQ2I56jlF6paUrio+KBo8DA4kT+BOy+FlZSpuAmxKACQmSORc5NBcaGiN12nXK2mVlEFMxU7Ux19eEUcZRE8aEhNXTuNO7uNDQA17DXh/DgoLcy7DLUrApKeKZd5m0d1pawzMRMzwRHh4tRstG9st7ez0f/B9L/Kiot2HWYdrWbW0MTjpOWDosLGI="));
4026 var T7
= h
.bytes2Int64Buffer(h
.b64Decode("MvSl9JelxsZvl4SX64T4+F6wmbDHme7ueoyNjPeN9vboFw0X5Q3//wrcvdy3vdbWFsixyKex3t5t/FT8OVSRkZDwUPDAUGBgBwUDBQQDAgIu4Kngh6nOztGHfYesfVZWzCsZK9UZ5+cTpmKmcWK1tXwx5jGa5k1NWbWatcOa7OxAz0XPBUWPj6O8nbw+nR8fScBAwAlAiYlokoeS74f6+tA/FT/FFe/vlCbrJn/rsrLOQMlAB8mOjuYdCx3tC/v7bi/sL4LsQUEaqWepfWezs0Mc/Ry+/V9fYCXqJYrqRUX52r/aRr8jI1EC9wKm91NTRaGWodOW5OR27VvtLVubmyhdwl3qwnV1xSQcJNkc4eHU6a7peq49PfK+ar6YakxMgu5a7thabGy9w0HD/EF+fvMGAgbxAvX1UtFP0R1Pg4OM5Fzk0FxoaFYH9Aei9FFRjVw0XLk00dHhGAgY6Qj5+Uyuk67fk+LiPpVzlU1zq6uX9VP1xFNiYmtBP0FUPyoqHBQMFBAMCAhj9lL2MVKVlemvZa+MZUZGf+Je4iFenZ1IeCh4YCgwMM/4ofhuoTc3GxEPERQPCgrrxLXEXrUvLxUbCRscCQ4Oflo2Wkg2JCSttpu2NpsbG5hHPUelPd/fp2omaoEmzc31u2m7nGlOTjNMzUz+zX9/ULqfus+f6uo/LRstJBsSEqS5nrk6nh0dxJx0nLB0WFhGci5yaC40NEF3LXdsLTY2Ec2yzaOy3NydKe4pc+60tE0W+xa2+1tbpQH2AVP2pKSh103X7E12dhSjYaN1Ybe3NEnOSfrOfX3fjXuNpHtSUp9CPkKhPt3dzZNxk7xxXl6xopeiJpcTE6IE9QRX9aamAbhouGloubkAAAAAAAAAALV0LHSZLMHB4KBgoIBgQEDCIR8h3R/j4zpDyEPyyHl5miztLHfttrYN2b7Zs77U1EfKRsoBRo2NF3DZcM7ZZ2ev3Uvd5Etycu153nkz3pSU/2fUZyvUmJiTI+gje+iwsFveSt4RSoWFBr1rvW1ru7u7fip+kSrFxXs05TSe5U9P1zoWOsEW7e3SVMVUF8WGhvhi12Iv15qamf9V/8xVZma2p5SnIpQREcBKz0oPz4qK2TAQMMkQ6ekOCgYKCAYEBGaYgZjngf7+qwvwC1vwoKC0zETM8ER4ePDVutVKuiUldT7jPpbjS0usDvMOX/OiokQZ/hm6/l1d21vAWxvAgICAhYqFCooFBdPsrex+rT8//t+830K8ISGo2EjY4EhwcP0MBAz5BPHxGXrfesbfY2MvWMFY7sF3dzCfdZ9Fda+v56VjpYRjQkJwUDBQQDAgIMsuGi7RGuXl7xIOEuEO/f0It223ZW2/v1XUTNQZTIGBJDwUPDAUGBh5XzVfTDUmJrJxL3GdL8PDhjjhOGfhvr7I/aL9aqI1NcdPzE8LzIiIZUs5S1w5Li5q+Vf5PVeTk1gN8g2q8lVVYZ2CneOC/PyzyUfJ9Ed6eifvrO+LrMjIiDLnMm/nurpPfSt9ZCsyMkKklaTXlebmO/ug+5ugwMCqs5izMpgZGfZo0Wgn0Z6eIoF/gV1/o6PuqmaqiGZERNaCfoKoflRU3ear5narOzuVnoOeFoMLC8lFykUDyoyMvHspe5Upx8cFbtNu1tNra2xEPERQPCgoLIt5i1V5p6eBPeI9Y+K8vDEnHScsHRYWN5p2mkF2ra2WTTtNrTvb2576VvrIVmRkptJO0uhOdHQ2Ih4iKB4UFOR223Y/25KSEh4KHhgKDAz8tGy0kGxISI835Ddr5Li4eOdd5yVdn58Psm6yYW69vWkq7yqG70NDNfGm8ZOmxMTa46jjcqg5Ocb3pPdipDExilk3Wb0309N0houG/4vy8oNWMlaxMtXVTsVDxQ1Di4uF61nr3FlubhjCt8Kvt9rajo+MjwKMAQEdrGSseWSxsfFt0m0j0pyccjvgO5LgSUkfx7THq7TY2LkV+hVD+qys+gkHCf0H8/OgbyVvhSXPzyDqr+qPr8rKfYmOifOO9PRnIOkgjulHRzgoGCggGBAQC2TVZN7Vb29zg4iD+4jw8Puxb7GUb0pKypZylrhyXFxUbCRscCQ4OF8I8Qiu8VdXIVLHUubHc3Nk81HzNVGXl65lI2WNI8vLJYR8hFl8oaFXv5y/y5zo6F1jIWN8IT4+6nzdfDfdlpYef9x/wtxhYZyRhpEahg0Nm5SFlB6FDw9Lq5Cr25Dg4LrGQsb4Qnx8JlfEV+LEcXEp5arlg6rMzONz2HM72JCQCQ8FDwwFBgb0AwED9QH39yo2EjY4EhwcPP6j/p+jwsKL4V/h1F9qar4Q+RBH+a6uAmvQa9LQaWm/qJGoLpEXF3HoWOgpWJmZU2knaXQnOjr30LnQTrknJ5FIOEipONnZ3jUTNc0T6+vlzrPOVrMrK3dVM1VEMyIiBNa71r+70tI5kHCQSXCpqYeAiYAOiQcHwfKn8manMzPswbbBWrYtLVpmImZ4Ijw8uK2SrSqSFRWpYCBgiSDJyVzbSdsVSYeHsBr/Gk//qqrYiHiIoHhQUCuOeo5ReqWliYqPigaPAwNKE/gTsvhZWZKbgJsSgAkJIzkXOTQXGhoQddp1ytplZYRTMVO1MdfX1VHGURPGhIQD07jTu7jQ0Nxew14fw4KC4suwy1KwKSnDmXeZtHdaWi0zETM8ER4ePUbLRvbLe3u3H/wfS/yoqAxh1mHa1m1tYk46Tlg6LCw="));
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)
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)
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)
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)
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)
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)
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)
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)
5076 var B64 = function(n
, x
) {
5080 var bits
= (7 - n
) * 8;
5081 if (bits
>= 32) { //faster than >= 32
5082 return (x
.hi
>>> (bits
- 32)) & 0xFF;
5085 var bitsOff32
= 32 - bits
,
5086 toMoveDown
= this.hi
<< bitsOff32
>>> bitsOff32
;
5087 return (x
.lo
>>> bits
| (toMoveDown
<< bitsOff32
)) & 0xFF;
5091 var 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)
5096 var 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)
5101 var 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)
5105 var compress = function(int64buf
, state
) {
5106 var g
= new Array(16);
5107 var m
= new Array(16);
5108 for (var u
= 0; u
< 16; u
++) {
5110 g
[u
] = m
[u
].xor(state
[u
]);
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));
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])]);
5125 for (var r
= 0; r
< 14; r
++) {
5126 for (var i
= 0; i
< 16; i
++) {
5127 m
[i
].setxor64(r64
[r
], nj64
[i
]);
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])]);
5136 for (var u
= 0; u
< 16; u
++) {
5137 state
[u
].setxor64(g
[u
], m
[u
]);
5141 var 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
++) {
5147 for (var i
= 0; i
< 16; i
++) {
5148 g
[i
].setxor64(j64
[i
].plus(r64
[r
]).setShiftLeft(56));
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])]);
5158 for (var u
= 0; u
< 16; u
++)
5159 state
[u
].setxor64(g
[u
]);
5162 var groestl = function(ctx
, data
, len
) {
5164 //create a local copy of states
5165 var V
= new Array(16);
5168 if (len
< ctx
.buffer
.length
- ptr
) {
5169 o
.bufferInsert(buf
, ptr
, data
, data
.length
);
5174 //perform a deep copy of current state
5175 o
.bufferInsert(V
, 0, ctx
.state
, 16);
5177 var clen
= ctx
.buffer
.length
- ptr
;
5178 if (clen
> len
) clen
= len
;
5179 o
.bufferInsert(buf
, ptr
, data
, clen
);
5181 data
= data
.slice(clen
);
5183 if (ptr
=== ctx
.buffer
.length
) {
5184 var int64Buf
= h
.bytes2Int64Buffer(buf
);
5185 compress(int64Buf
, V
);
5194 var groestlClose = function(ctx
) {
5195 var buf
= ctx
.buffer
;
5197 var pad
= new Array(136);
5198 var len
= buf
.length
;
5204 count
= ctx
.count
.plus(o
.u(0, 1));
5208 count
= ctx
.count
.plus(o
.u(0, 2));
5210 o
.bufferSet(pad
, 1, 0, padLen
- 9);
5211 h
.bufferEncode64(pad
, padLen
- 8, count
);
5212 groestl(ctx
, pad
, padLen
);
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
;
5222 module
.exports = function(input
, format
, output
) {
5227 else if (format
=== 2) {
5228 msg
= h
.int32Buffer2Bytes(input
);
5231 msg
= h
.string2bytes(input
);
5234 ctx
.state
= new Array(16);
5235 for (var i
= 0; i
< 15; i
++) {
5236 ctx
.state
[i
] = new o
.u64(0, 0);
5238 ctx
.state
[15] = new o
.u64(0, 512);
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);
5248 else if (output
=== 1) {
5249 out
= h
.int32Buffer2Bytes(r
)
5252 out
= h
.int32ArrayToHexString(r
)
5256 },{"./helper":41,"./op":42}],41:[function(require
,module
,exports
){
5260 var op
= require('./op.js');
5262 module
.exports
.int8ArrayToHexString
= function toString(array
) {
5265 for (var i
= 0; i
< array
.length
; i
++) {
5266 if (array
[i
] < 16) {
5267 string
+= '0' + array
[i
].toString(16);
5270 string
+= array
[i
].toString(16);
5276 module
.exports
.int32ArrayToHexString
= function toString(array
) {
5278 var len
= array
.length
;
5279 for (var i
= 0; i
< len
; i
++) {
5282 s
= 0xFFFFFFFF + array
[i
] + 1;
5284 var l
= s
.toString(16);
5286 while (l
.length
< padding
) {
5294 module
.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)));
5300 module
.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));
5306 module.exports.string2hex = function toString(s) {
5308 for (var p = [], len = s.length, i = 0; i < len; i++) {
5309 p.push((256 + s.charCodeAt(i)).toString(16).substring(1));
5314 module
.exports
.string2bytes = function(s
) {
5316 var b
= new Array(len
);
5319 b
[i
] = s
.charCodeAt(i
);
5325 module.exports.bytes2Int16Buffer = function(b) {
5327 var bufferLength = len ? (((len - 1) >>> 1) + 1) : 0;
5328 var buffer = new Array(bufferLength);
5332 buffer[j] = (buffer[j] << 8) | b[i];
5340 module
.exports
.bytes2Int32Buffer = function(b
) {
5342 var len
= b
.length
? (((b
.length
- 1) >>> 2) + 1) : 0;
5343 var buffer
= new Array(len
);
5346 buffer
[j
] = (b
[j
* 4] << 24) | (b
[j
* 4 + 1] << 16) | (b
[j
* 4 + 2] << 8) | b
[j
* 4 + 3];
5352 module.exports.bytes2Int32BufferLeAligned = function(b) {
5354 if (!len) return [];
5355 var len2 = len ? (((len - 1) >>> 2) + 1) : 0;
5356 var buffer = new Array(len);
5359 buffer[j] = (b[j * 4 + 3] << 24) | (b[j * 4 + 2] << 16) | (b[j * 4 + 1] << 8) | b[j * 4];
5365 module
.exports
.bytes2Int64Buffer = function(b
) {
5367 var len
= b
.length
? (((b
.length
- 1) >>> 3) + 1) : 0;
5368 var buffer
= new Array(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]);
5377 module
.exports
.bytes2Int64BufferLeAligned = function(b
) {
5379 var len
= b
.length
? ((( b
.length
- 1) >>> 3) + 1) : 0;
5380 var buffer
= new Array(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]);
5389 module
.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;
5400 module
.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;
5411 module
.exports
.int32Buffer2Bytes = function(b
) {
5412 var buffer
= new Array(b
.length
);
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);
5425 module.exports.int64Buffer2Bytes = function(b) {
5426 var buffer = new Array(b.length);
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);
5443 module
.exports
.string2Int32Buffer = function(s
) {
5444 return this.bytes2Int32Buffer(this.string2bytes(s
));
5447 var keyStr
= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
5449 module
.exports
.b64Encode = function(input
) {
5451 var chr1
, chr2
, chr3
, enc1
, enc2
, enc3
, enc4
;
5454 while (i
< input
.length
) {
5461 enc2
= ((chr1
& 3) << 4) | (chr2
>> 4);
5462 enc3
= ((chr2
& 15) << 2) | (chr3
>> 6);
5468 else if (isNaN(chr3
)) {
5473 keyStr
.charAt(enc1
) + keyStr
.charAt(enc2
) +
5474 keyStr
.charAt(enc3
) + keyStr
.charAt(enc4
);
5480 module
.exports
.b64Decode = function(input
) {
5482 var chr1
, chr2
, chr3
;
5483 var enc1
, enc2
, enc3
, enc4
;
5486 input
= input
.replace(/[^A-Za-z0-9\+\/\=]/g, "");
5488 while (i
< input
.length
) {
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
++));
5495 chr1
= (enc1
<< 2) | (enc2
>> 4);
5496 chr2
= ((enc2
& 15) << 4) | (enc3
>> 2);
5497 chr3
= ((enc3
& 3) << 6) | enc4
;
5510 },{"./op.js":42}],42:[function(require
,module
,exports
){
5512 //the right shift is important, it has to do with 32 bit operations in javascript, it will make things faster
5513 function u64(h
, l
) {
5518 u64
.prototype.set = function(oWord
) {
5523 u64
.prototype.add = function(oWord
) {
5524 var lowest
, lowMid
, highMid
, highest
; //four parts of the whole 64 bit number..
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);
5532 //now set the hgih and the low accordingly..
5533 this.lo
= (lowMid
<< 16) | (lowest
& 0XFFFF
);
5534 this.hi
= (highest
<< 16) | (highMid
& 0XFFFF
);
5536 return this; //for chaining..
5539 u64
.prototype.addOne = function() {
5540 if (this.lo
=== -1 || this.lo
=== 0xFFFFFFFF) {
5549 u64
.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..
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);
5559 //now set the hgih and the low accordingly..
5560 c
.lo
= (lowMid
<< 16) | (lowest
& 0XFFFF
);
5561 c
.hi
= (highest
<< 16) | (highMid
& 0XFFFF
);
5563 return c
; //for chaining..
5566 u64
.prototype.not = function() {
5567 return new u64(~this.hi
, ~this.lo
);
5570 u64
.prototype.one = function() {
5571 return new u64(0x0, 0x1);
5574 u64
.prototype.zero = function() {
5575 return new u64(0x0, 0x0);
5578 u64
.prototype.neg = function() {
5579 return this.not().plus(this.one());
5582 u64
.prototype.minus = function(oWord
) {
5583 return this.plus(oWord
.neg());
5586 u64
.prototype.isZero = function() {
5587 return (this.lo
=== 0) && (this.hi
=== 0);
5590 function isLong(obj
) {
5591 return (obj
&& obj
["__isLong__"]) === true;
5594 function fromNumber(value
) {
5595 if (isNaN(value
) || !isFinite(value
))
5597 var pow32
= (1 << 32);
5598 return new u64((value
% pow32
) | 0, (value
/ pow32
) | 0);
5601 u64
.prototype.multiply = function(multiplier
) {
5604 if (!isLong(multiplier
))
5605 multiplier
= fromNumber(multiplier
);
5606 if (multiplier
.isZero())
5609 // Divide each long into 4 chunks of 16 bits, and then add up 4x4 products.
5610 // We can skip products that would overflow.
5612 var a48
= this.hi
>>> 16;
5613 var a32
= this.hi
& 0xFFFF;
5614 var a16
= this.lo
>>> 16;
5615 var a00
= this.lo
& 0xFFFF;
5617 var b48
= multiplier
.hi
>>> 16;
5618 var b32
= multiplier
.hi
& 0xFFFF;
5619 var b16
= multiplier
.lo
>>> 16;
5620 var b00
= multiplier
.lo
& 0xFFFF;
5644 c48
+= a48
* b00
+ a32
* b16
+ a16
* b32
+ a00
* b48
;
5646 return new u64((c48
<< 16) | c32
, (c16
<< 16) | c00
);
5649 u64
.prototype.shiftLeft = function(bits
) {
5651 var c
= new u64(0, 0);
5653 return this.clone();
5655 else if (bits
> 31) {
5657 c
.hi
= this.lo
<< (bits
- 32);
5660 var toMoveUp
= this.lo
>>> 32 - bits
;
5661 c
.lo
= this.lo
<< bits
;
5662 c
.hi
= (this.hi
<< bits
) | toMoveUp
;
5664 return c
; //for chaining..
5667 u64
.prototype.setShiftLeft = function(bits
) {
5676 this.hi
= this.lo
<< (bits
- 32);
5680 var toMoveUp
= this.lo
>>> 32 - bits
;
5682 this.hi
= (this.hi
<< bits
) | toMoveUp
;
5684 return this; //for chaining..
5686 //Shifts this word by the given number of bits to the right (max 32)..
5687 u64
.prototype.shiftRight = function(bits
) {
5689 var c
= new u64(0, 0);
5691 return this.clone();
5693 else if (bits
>= 32) {
5695 c
.lo
= this.hi
>>> (bits
- 32);
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
);
5703 return c
; //for chaining..
5705 //Rotates the bits of this word round to the left (max 32)..
5706 u64
.prototype.rotateLeft = function(bits
) {
5708 return this.rotateRight(64 - bits
);
5710 var c
= new u64(0, 0);
5712 c
.lo
= this.lo
>>> 0;
5713 c
.hi
= this.hi
>>> 0;
5715 else if (bits
=== 32) { //just switch high and low over in this case..
5720 c
.lo
= (this.lo
<< bits
) | (this.hi
>>> (32 - bits
));
5721 c
.hi
= (this.hi
<< bits
) | (this.lo
>>> (32 - bits
));
5723 return c
; //for chaining..
5726 u64
.prototype.setRotateLeft = function(bits
) {
5728 return this.setRotateRight(64 - bits
);
5734 else if (bits
=== 32) { //just switch high and low over in this case..
5740 newHigh
= (this.hi
<< bits
) | (this.lo
>>> (32 - bits
));
5741 this.lo
= (this.lo
<< bits
) | (this.hi
>>> (32 - bits
));
5744 return this; //for chaining..
5746 //Rotates the bits of this word round to the right (max 32)..
5747 u64
.prototype.rotateRight = function(bits
) {
5749 return this.rotateLeft(64 - bits
);
5751 var c
= new u64(0, 0);
5753 c
.lo
= this.lo
>>> 0;
5754 c
.hi
= this.hi
>>> 0;
5756 else if (bits
=== 32) { //just switch high and low over in this case..
5761 c
.lo
= (this.hi
<< (32 - bits
)) | (this.lo
>>> bits
);
5762 c
.hi
= (this.lo
<< (32 - bits
)) | (this.hi
>>> bits
);
5764 return c
; //for chaining..
5766 u64
.prototype.setFlip = function() {
5773 //Rotates the bits of this word round to the right (max 32)..
5774 u64
.prototype.setRotateRight = function(bits
) {
5776 return this.setRotateLeft(64 - bits
);
5782 else if (bits
=== 32) { //just switch high and low over in this case..
5789 newHigh
= (this.lo
<< (32 - bits
)) | (this.hi
>>> bits
);
5790 this.lo
= (this.hi
<< (32 - bits
)) | (this.lo
>>> bits
);
5793 return this; //for chaining..
5795 //Xors this word with the given other..
5796 u64
.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..
5802 //Xors this word with the given other..
5803 u64
.prototype.setxorOne = function(oWord
) {
5804 this.hi
^= oWord
.hi
;
5805 this.lo
^= oWord
.lo
;
5806 return this; //for chaining..
5808 //Ands this word with the given other..
5809 u64
.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..
5816 //Creates a deep copy of this Word..
5817 u64
.prototype.clone = function() {
5818 return new u64(this.hi
, this.lo
);
5821 u64
.prototype.setxor64 = function() {
5831 module
.exports
.u64
= u64
;
5833 module
.exports
.u = function(h
, l
) {
5834 return new u64(h
, l
);
5837 module.exports.add64 = function(a, b) {
5838 var lowest, lowMid, highMid, highest; //four parts of the whole 64 bit number..
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);
5846 var r = new this.u64((highest << 16) | (highMid & 0XFFFF), (lowMid << 16) | (lowest & 0XFFFF));
5851 module
.exports
.xor64 = function() {
5861 return new this.u64(h
, l
);
5864 module
.exports
.clone64Array = function(array
) {
5866 var len
= array
.length
;
5867 var a
= new Array(len
);
5875 //this shouldn't be a problem, but who knows in the future javascript might support 64bits
5876 module
.exports
.t32 = function(x
) {
5877 return (x
& 0xFFFFFFFF)
5880 module
.exports
.rotl32 = function(x
, c
) {
5881 return (((x
) << (c
)) | ((x
) >>> (32 - (c
)))) & (0xFFFFFFFF);
5884 module
.exports
.rotr32 = function(x
, c
) {
5885 return this.rotl32(x
, (32 - (c
)));
5888 module
.exports
.swap32 = function(val
) {
5889 return ((val
& 0xFF) << 24) |
5890 ((val
& 0xFF00) << 8) |
5891 ((val
>>> 8) & 0xFF00) |
5892 ((val
>>> 24) & 0xFF);
5895 module
.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
);
5900 r
[i
] = (this.swap32(a
[i
]));
5906 module
.exports
.xnd64 = function(x
, y
, z
) {
5907 return new this.u64(x
.hi
^ ((~y
.hi
) & z
.hi
), x
.lo
^ ((~y
.lo
) & z
.lo
));
5910 module.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);
5916 module
.exports
.bufferInsert = function(buffer
, bufferOffset
, data
, len
, dataOffset
) {
5917 dataOffset
= dataOffset
| 0;
5920 buffer
[i
+ bufferOffset
] = data
[i
+ dataOffset
];
5925 module
.exports
.bufferInsert64 = function(buffer
, bufferOffset
, data
, len
) {
5928 buffer
[i
+ bufferOffset
] = data
[i
].clone();
5933 module.exports.buffer2Insert = function(buffer, bufferOffset, bufferOffset2, data, len, len2) {
5937 buffer[len + bufferOffset][j + bufferOffset2] = data[len][j];
5942 module
.exports
.bufferInsertBackwards = function(buffer
, bufferOffset
, data
, len
) {
5945 buffer
[i
+ bufferOffset
] = data
[len
- 1 - i
];
5950 module
.exports
.bufferSet = function(buffer
, bufferOffset
, value
, len
) {
5953 buffer
[i
+ bufferOffset
] = value
;
5958 module
.exports
.bufferXORInsert = function(buffer
, bufferOffset
, data
, dataOffset
, len
) {
5961 buffer
[i
+ bufferOffset
] ^= data
[i
+ dataOffset
];
5966 module
.exports
.xORTable = function(d
, s1
, s2
, len
) {
5969 d
[i
] = s1
[i
] ^ s2
[i
];
5974 },{}],43:[function(require
,module
,exports
){
5976 var Buffer
= require('safe-buffer').Buffer
5977 var Transform
= require('stream').Transform
5978 var inherits
= require('inherits')
5980 function throwIfNotStringOrBuffer (val
, prefix
) {
5981 if (!Buffer
.isBuffer(val
) && typeof val
!== 'string') {
5982 throw new TypeError(prefix
+ ' must be a string or a buffer')
5986 function HashBase (blockSize
) {
5987 Transform
.call(this)
5989 this._block
= Buffer
.allocUnsafe(blockSize
)
5990 this._blockSize
= blockSize
5991 this._blockOffset
= 0
5992 this._length
= [0, 0, 0, 0]
5994 this._finalized
= false
5997 inherits(HashBase
, Transform
)
5999 HashBase
.prototype._transform = function (chunk
, encoding
, callback
) {
6002 this.update(chunk
, encoding
)
6010 HashBase
.prototype._flush = function (callback
) {
6013 this.push(this.digest())
6021 HashBase
.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
)
6027 var block
= this._block
6029 while (this._blockOffset
+ data
.length
- offset
>= this._blockSize
) {
6030 for (var i
= this._blockOffset
; i
< this._blockSize
;) block
[i
++] = data
[offset
++]
6032 this._blockOffset
= 0
6034 while (offset
< data
.length
) block
[this._blockOffset
++] = data
[offset
++]
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
6046 HashBase
.prototype._update = function () {
6047 throw new Error('_update is not implemented')
6050 HashBase
.prototype.digest = function (encoding
) {
6051 if (this._finalized
) throw new Error('Digest already called')
6052 this._finalized
= true
6054 var digest
= this._digest()
6055 if (encoding
!== undefined) digest
= digest
.toString(encoding
)
6059 this._blockOffset
= 0
6060 for (var i
= 0; i
< 4; ++i
) this._length
[i
] = 0
6065 HashBase
.prototype._digest = function () {
6066 throw new Error('_digest is not implemented')
6069 module
.exports
= HashBase
6071 },{"inherits":44,"safe-buffer":47,"stream":215}],44:[function(require
,module
,exports
){
6072 if (typeof Object
.create
=== 'function') {
6073 // implementation from standard node.js 'util' module
6074 module
.exports
= function inherits(ctor
, superCtor
) {
6076 ctor
.super_
= superCtor
6077 ctor
.prototype = Object
.create(superCtor
.prototype, {
6088 // old school shim for old browsers
6089 module
.exports
= function inherits(ctor
, superCtor
) {
6091 ctor
.super_
= superCtor
6092 var TempCtor = function () {}
6093 TempCtor
.prototype = superCtor
.prototype
6094 ctor
.prototype = new TempCtor()
6095 ctor
.prototype.constructor = ctor
6100 },{}],45:[function(require
,module
,exports
){
6102 var inherits
= require('inherits')
6103 var HashBase
= require('hash-base')
6104 var Buffer
= require('safe-buffer').Buffer
6106 var ARRAY16
= new Array(16)
6109 HashBase
.call(this, 64)
6112 this._a
= 0x67452301
6113 this._b
= 0xefcdab89
6114 this._c
= 0x98badcfe
6115 this._d
= 0x10325476
6118 inherits(MD5
, HashBase
)
6120 MD5
.prototype._update = function () {
6122 for (var i
= 0; i
< 16; ++i
) M
[i
] = this._block
.readInt32LE(i
* 4)
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)
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)
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)
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)
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
6203 MD5
.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)
6209 this._blockOffset
= 0
6212 this._block
.fill(0, this._blockOffset
, 56)
6213 this._block
.writeUInt32LE(this._length
[0], 56)
6214 this._block
.writeUInt32LE(this._length
[1], 60)
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)
6226 function rotl (x
, n
) {
6227 return (x
<< n
) | (x
>>> (32 - n
))
6230 function fnF (a
, b
, c
, d
, m
, k
, s
) {
6231 return (rotl((a
+ ((b
& c
) | ((~b
) & d
)) + m
+ k
) | 0, s
) + b
) | 0
6234 function fnG (a
, b
, c
, d
, m
, k
, s
) {
6235 return (rotl((a
+ ((b
& d
) | (c
& (~d
))) + m
+ k
) | 0, s
) + b
) | 0
6238 function fnH (a
, b
, c
, d
, m
, k
, s
) {
6239 return (rotl((a
+ (b
^ c
^ d
) + m
+ k
) | 0, s
) + b
) | 0
6242 function fnI (a
, b
, c
, d
, m
, k
, s
) {
6243 return (rotl((a
+ ((c
^ (b
| (~d
)))) + m
+ k
) | 0, s
) + b
) | 0
6246 module
.exports
= MD5
6248 },{"hash-base":43,"inherits":44,"safe-buffer":47}],46:[function(require
,module
,exports
){
6250 var Buffer
= require('buffer').Buffer
6251 var inherits
= require('inherits')
6252 var HashBase
= require('hash-base')
6254 var ARRAY16
= new Array(16)
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
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
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
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
6288 var hl
= [0x00000000, 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xa953fd4e]
6289 var hr
= [0x50a28be6, 0x5c4dd124, 0x6d703ef3, 0x7a6d76e9, 0x00000000]
6291 function RIPEMD160 () {
6292 HashBase
.call(this, 64)
6295 this._a
= 0x67452301
6296 this._b
= 0xefcdab89
6297 this._c
= 0x98badcfe
6298 this._d
= 0x10325476
6299 this._e
= 0xc3d2e1f0
6302 inherits(RIPEMD160
, HashBase
)
6304 RIPEMD160
.prototype._update = function () {
6306 for (var j
= 0; j
< 16; ++j
) words
[j
] = this._block
.readInt32LE(j
* 4)
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
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
6321 for (var i
= 0; i
< 80; i
+= 1) {
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
])
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
6363 RIPEMD160
.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)
6369 this._blockOffset
= 0
6372 this._block
.fill(0, this._blockOffset
, 56)
6373 this._block
.writeUInt32LE(this._length
[0], 56)
6374 this._block
.writeUInt32LE(this._length
[1], 60)
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)
6387 function rotl (x
, n
) {
6388 return (x
<< n
) | (x
>>> (32 - n
))
6391 function fn1 (a
, b
, c
, d
, e
, m
, k
, s
) {
6392 return (rotl((a
+ (b
^ c
^ d
) + m
+ k
) | 0, s
) + e
) | 0
6395 function fn2 (a
, b
, c
, d
, e
, m
, k
, s
) {
6396 return (rotl((a
+ ((b
& c
) | ((~b
) & d
)) + m
+ k
) | 0, s
) + e
) | 0
6399 function fn3 (a
, b
, c
, d
, e
, m
, k
, s
) {
6400 return (rotl((a
+ ((b
| (~c
)) ^ d
) + m
+ k
) | 0, s
) + e
) | 0
6403 function fn4 (a
, b
, c
, d
, e
, m
, k
, s
) {
6404 return (rotl((a
+ ((b
& d
) | (c
& (~d
))) + m
+ k
) | 0, s
) + e
) | 0
6407 function fn5 (a
, b
, c
, d
, e
, m
, k
, s
) {
6408 return (rotl((a
+ (b
^ (c
| (~d
))) + m
+ k
) | 0, s
) + e
) | 0
6411 module
.exports
= RIPEMD160
6413 },{"buffer":110,"hash-base":43,"inherits":44}],47:[function(require
,module
,exports
){
6414 /* eslint-disable node/no-deprecated-api */
6415 var buffer
= require('buffer')
6416 var Buffer
= buffer
.Buffer
6418 // alternative to using Object.keys for old browsers
6419 function copyProps (src
, dst
) {
6420 for (var key
in src
) {
6424 if (Buffer
.from && Buffer
.alloc
&& Buffer
.allocUnsafe
&& Buffer
.allocUnsafeSlow
) {
6425 module
.exports
= buffer
6427 // Copy properties from require('buffer')
6428 copyProps(buffer
, exports
)
6429 exports
.Buffer
= SafeBuffer
6432 function SafeBuffer (arg
, encodingOrOffset
, length
) {
6433 return Buffer(arg
, encodingOrOffset
, length
)
6436 SafeBuffer
.prototype = Object
.create(Buffer
.prototype)
6438 // Copy static methods from Buffer
6439 copyProps(Buffer
, SafeBuffer
)
6441 SafeBuffer
.from = function (arg
, encodingOrOffset
, length
) {
6442 if (typeof arg
=== 'number') {
6443 throw new TypeError('Argument must not be a number')
6445 return Buffer(arg
, encodingOrOffset
, length
)
6448 SafeBuffer
.alloc = function (size
, fill
, encoding
) {
6449 if (typeof size
!== 'number') {
6450 throw new TypeError('Argument must be a number')
6452 var buf
= Buffer(size
)
6453 if (fill
!== undefined) {
6454 if (typeof encoding
=== 'string') {
6455 buf
.fill(fill
, encoding
)
6465 SafeBuffer
.allocUnsafe = function (size
) {
6466 if (typeof size
!== 'number') {
6467 throw new TypeError('Argument must be a number')
6472 SafeBuffer
.allocUnsafeSlow = function (size
) {
6473 if (typeof size
!== 'number') {
6474 throw new TypeError('Argument must be a number')
6476 return buffer
.SlowBuffer(size
)
6479 },{"buffer":110}],48:[function(require
,module
,exports
){
6480 const scrypt
= require('./scryptSync')
6481 scrypt
.async
= require('./scrypt')
6482 module
.exports
= scrypt
6484 },{"./scrypt":49,"./scryptSync":50}],49:[function(require
,module
,exports
){
6485 const crypto
= require('crypto')
6489 } = require('./utils')
6491 // N = Cpu cost, r = Memory cost, p = parallelization cost
6492 async
function scrypt (key
, salt
, N
, r
, p
, dkLen
, progressCallback
, promiseInterval
) {
6501 } = checkAndInit(key
, salt
, N
, r
, p
, dkLen
, progressCallback
)
6503 for (var i
= 0; i
< p
; i
++) {
6504 await
smix(B
, i
* 128 * r
, r
, N
, V
, XY
, _X
, B32
, x
, tickCallback
, promiseInterval
)
6507 return crypto
.pbkdf2Sync(key
, B
, 1, dkLen
, 'sha256')
6510 module
.exports
= scrypt
6512 },{"./utils":51,"crypto":118}],50:[function(require
,module
,exports
){
6513 const crypto
= require('crypto')
6517 } = require('./utils')
6519 // N = Cpu cost, r = Memory cost, p = parallelization cost
6520 function scrypt (key
, salt
, N
, r
, p
, dkLen
, progressCallback
) {
6529 } = checkAndInit(key
, salt
, N
, r
, p
, dkLen
, progressCallback
)
6531 for (var i
= 0; i
< p
; i
++) {
6532 smixSync(B
, i
* 128 * r
, r
, N
, V
, XY
, _X
, B32
, x
, tickCallback
)
6535 return crypto
.pbkdf2Sync(key
, B
, 1, dkLen
, 'sha256')
6538 module
.exports
= scrypt
6540 },{"./utils":51,"crypto":118}],51:[function(require
,module
,exports
){
6541 (function (Buffer
,setImmediate
){
6542 const crypto
= require('crypto')
6543 const MAX_VALUE
= 0x7fffffff
6544 const DEFAULT_PROMISE_INTERVAL
= 5000
6545 /* eslint-disable camelcase */
6547 function 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')
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')
6553 let XY
= Buffer
.alloc(256 * r
)
6554 let V
= Buffer
.alloc(128 * r
* N
)
6557 let B32
= new Int32Array(16) // salsa20_8
6558 let x
= new Int32Array(16) // salsa20_8
6559 let _X
= Buffer
.alloc(64) // blockmix_salsa8
6562 let B
= crypto
.pbkdf2Sync(key
, salt
, 1, p
* 128 * r
, 'sha256')
6565 if (progressCallback
) {
6566 let totalOps
= p
* N
* 2
6569 tickCallback = function () {
6572 // send progress notifications once every 1,000 ops
6573 if (currentOp
% 1000 === 0) {
6577 percent: (currentOp
/ totalOps
) * 100.0
6593 async
function smix (B
, Bi
, r
, N
, V
, XY
, _X
, B32
, x
, tickCallback
, promiseInterval
) {
6594 promiseInterval
= promiseInterval
|| DEFAULT_PROMISE_INTERVAL
6599 B
.copy(XY
, Xi
, Bi
, Bi
+ Yi
)
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
))
6606 blockmix_salsa8(XY
, Xi
, Yi
, r
, _X
, B32
, x
)
6608 if (tickCallback
) tickCallback()
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
))
6618 blockmix_salsa8(XY
, Xi
, Yi
, r
, _X
, B32
, x
)
6620 if (tickCallback
) tickCallback()
6623 XY
.copy(B
, Bi
, Xi
, Xi
+ Yi
)
6626 function smixSync (B
, Bi
, r
, N
, V
, XY
, _X
, B32
, x
, tickCallback
) {
6631 B
.copy(XY
, Xi
, Bi
, Bi
+ Yi
)
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
)
6637 if (tickCallback
) tickCallback()
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
)
6646 if (tickCallback
) tickCallback()
6649 XY
.copy(B
, Bi
, Xi
, Xi
+ Yi
)
6652 function blockmix_salsa8 (BY
, Bi
, Yi
, r
, _X
, B32
, x
) {
6655 arraycopy(BY
, Bi
+ (2 * r
- 1) * 64, _X
, 0, 64)
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)
6663 for (i
= 0; i
< r
; i
++) {
6664 arraycopy(BY
, Yi
+ (i
* 2) * 64, BY
, Bi
+ (i
* 64), 64)
6667 for (i
= 0; i
< r
; i
++) {
6668 arraycopy(BY
, Yi
+ (i
* 2 + 1) * 64, BY
, Bi
+ (i
+ r
) * 64, 64)
6673 return (a
<< b
) | (a
>>> (32 - b
))
6676 function salsa20_8 (B
, B32
, x
) {
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
6687 arraycopy(B32
, 0, x
, 0, 16)
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)
6724 for (i
= 0; i
< 16; ++i
) B32
[i
] = x
[i
] + B32
[i
]
6726 for (i
= 0; i
< 16; i
++) {
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
6736 // naive approach... going back to loop unrolling may yield additional performance
6737 function blockxor (S
, Si
, D
, Di
, len
) {
6738 for (let i
= 0; i
< len
; i
++) {
6739 D
[Di
+ i
] ^= S
[Si
+ i
]
6743 function arraycopy (src
, srcPos
, dest
, destPos
, length
) {
6744 if (Buffer
.isBuffer(src
) && Buffer
.isBuffer(dest
)) {
6745 src
.copy(dest
, destPos
, srcPos
, srcPos
+ length
)
6748 dest
[destPos
++] = src
[srcPos
++]
6759 }).call(this,require("buffer").Buffer
,require("timers").setImmediate
)
6760 },{"buffer":110,"crypto":118,"timers":217}],52:[function(require
,module
,exports
){
6761 var Buffer
= require('safe-buffer').Buffer
6763 // prototype class for hash functions
6764 function Hash (blockSize
, finalSize
) {
6765 this._block
= Buffer
.alloc(blockSize
)
6766 this._finalSize
= finalSize
6767 this._blockSize
= blockSize
6771 Hash
.prototype.update = function (data
, enc
) {
6772 if (typeof data
=== 'string') {
6774 data
= Buffer
.from(data
, enc
)
6777 var block
= this._block
6778 var blockSize
= this._blockSize
6779 var length
= data
.length
6780 var accum
= this._len
6782 for (var offset
= 0; offset
< length
;) {
6783 var assigned
= accum
% blockSize
6784 var remainder
= Math
.min(length
- offset
, blockSize
- assigned
)
6786 for (var i
= 0; i
< remainder
; i
++) {
6787 block
[assigned
+ i
] = data
[offset
+ i
]
6793 if ((accum
% blockSize
) === 0) {
6802 Hash
.prototype.digest = function (enc
) {
6803 var rem
= this._len
% this._blockSize
6805 this._block
[rem
] = 0x80
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)
6811 if (rem
>= this._finalSize
) {
6812 this._update(this._block
)
6816 var bits
= this._len
* 8
6819 if (bits
<= 0xffffffff) {
6820 this._block
.writeUInt32BE(bits
, this._blockSize
- 4)
6824 var lowBits
= (bits
& 0xffffffff) >>> 0
6825 var highBits
= (bits
- lowBits
) / 0x100000000
6827 this._block
.writeUInt32BE(highBits
, this._blockSize
- 8)
6828 this._block
.writeUInt32BE(lowBits
, this._blockSize
- 4)
6831 this._update(this._block
)
6832 var hash
= this._hash()
6834 return enc
? hash
.toString(enc
) : hash
6837 Hash
.prototype._update = function () {
6838 throw new Error('_update must be implemented by subclass')
6841 module
.exports
= Hash
6843 },{"safe-buffer":47}],53:[function(require
,module
,exports
){
6844 var exports
= module
.exports
= function SHA (algorithm
) {
6845 algorithm
= algorithm
.toLowerCase()
6847 var Algorithm
= exports
[algorithm
]
6848 if (!Algorithm
) throw new Error(algorithm
+ ' is not supported (we accept pull requests)')
6850 return new Algorithm()
6853 exports
.sha
= require('./sha')
6854 exports
.sha1
= require('./sha1')
6855 exports
.sha224
= require('./sha224')
6856 exports
.sha256
= require('./sha256')
6857 exports
.sha384
= require('./sha384')
6858 exports
.sha512
= require('./sha512')
6860 },{"./sha":54,"./sha1":55,"./sha224":56,"./sha256":57,"./sha384":58,"./sha512":59}],54:[function(require
,module
,exports
){
6862 * A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined
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.
6869 var inherits
= require('inherits')
6870 var Hash
= require('./hash')
6871 var Buffer
= require('safe-buffer').Buffer
6874 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
6877 var W
= new Array(80)
6883 Hash
.call(this, 64, 56)
6888 Sha
.prototype.init = function () {
6889 this._a
= 0x67452301
6890 this._b
= 0xefcdab89
6891 this._c
= 0x98badcfe
6892 this._d
= 0x10325476
6893 this._e
= 0xc3d2e1f0
6898 function rotl5 (num
) {
6899 return (num
<< 5) | (num
>>> 27)
6902 function rotl30 (num
) {
6903 return (num
<< 30) | (num
>>> 2)
6906 function 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
)
6912 Sha
.prototype._update = function (M
) {
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]
6924 for (var j
= 0; j
< 80; ++j
) {
6926 var t
= (rotl5(a
) + ft(s
, b
, c
, d
) + e
+ W
[j
] + K
[s
]) | 0
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
6942 Sha
.prototype._hash = function () {
6943 var H
= Buffer
.allocUnsafe(20)
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)
6954 module
.exports
= Sha
6956 },{"./hash":52,"inherits":44,"safe-buffer":47}],55:[function(require
,module
,exports
){
6958 * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
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.
6966 var inherits
= require('inherits')
6967 var Hash
= require('./hash')
6968 var Buffer
= require('safe-buffer').Buffer
6971 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
6974 var W
= new Array(80)
6980 Hash
.call(this, 64, 56)
6983 inherits(Sha1
, Hash
)
6985 Sha1
.prototype.init = function () {
6986 this._a
= 0x67452301
6987 this._b
= 0xefcdab89
6988 this._c
= 0x98badcfe
6989 this._d
= 0x10325476
6990 this._e
= 0xc3d2e1f0
6995 function rotl1 (num
) {
6996 return (num
<< 1) | (num
>>> 31)
6999 function rotl5 (num
) {
7000 return (num
<< 5) | (num
>>> 27)
7003 function rotl30 (num
) {
7004 return (num
<< 30) | (num
>>> 2)
7007 function 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
)
7013 Sha1
.prototype._update = function (M
) {
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])
7025 for (var j
= 0; j
< 80; ++j
) {
7027 var t
= (rotl5(a
) + ft(s
, b
, c
, d
) + e
+ W
[j
] + K
[s
]) | 0
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
7043 Sha1
.prototype._hash = function () {
7044 var H
= Buffer
.allocUnsafe(20)
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)
7055 module
.exports
= Sha1
7057 },{"./hash":52,"inherits":44,"safe-buffer":47}],56:[function(require
,module
,exports
){
7059 * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
7061 * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
7062 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
7066 var inherits
= require('inherits')
7067 var Sha256
= require('./sha256')
7068 var Hash
= require('./hash')
7069 var Buffer
= require('safe-buffer').Buffer
7071 var W
= new Array(64)
7073 function Sha224 () {
7076 this._w
= W
// new Array(64)
7078 Hash
.call(this, 64, 56)
7081 inherits(Sha224
, Sha256
)
7083 Sha224
.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
7096 Sha224
.prototype._hash = function () {
7097 var H
= Buffer
.allocUnsafe(28)
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)
7110 module
.exports
= Sha224
7112 },{"./hash":52,"./sha256":57,"inherits":44,"safe-buffer":47}],57:[function(require
,module
,exports
){
7114 * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
7116 * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
7117 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
7121 var inherits
= require('inherits')
7122 var Hash
= require('./hash')
7123 var Buffer
= require('safe-buffer').Buffer
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
7144 var W
= new Array(64)
7146 function Sha256 () {
7149 this._w
= W
// new Array(64)
7151 Hash
.call(this, 64, 56)
7154 inherits(Sha256
, Hash
)
7156 Sha256
.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
7169 function ch (x
, y
, z
) {
7170 return z
^ (x
& (y
^ z
))
7173 function maj (x
, y
, z
) {
7174 return (x
& y
) | (z
& (x
| y
))
7177 function sigma0 (x
) {
7178 return (x
>>> 2 | x
<< 30) ^ (x
>>> 13 | x
<< 19) ^ (x
>>> 22 | x
<< 10)
7181 function sigma1 (x
) {
7182 return (x
>>> 6 | x
<< 26) ^ (x
>>> 11 | x
<< 21) ^ (x
>>> 25 | x
<< 7)
7185 function gamma0 (x
) {
7186 return (x
>>> 7 | x
<< 25) ^ (x
>>> 18 | x
<< 14) ^ (x
>>> 3)
7189 function gamma1 (x
) {
7190 return (x
>>> 17 | x
<< 15) ^ (x
>>> 19 | x
<< 13) ^ (x
>>> 10)
7193 Sha256
.prototype._update = function (M
) {
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
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
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
7232 Sha256
.prototype._hash = function () {
7233 var H
= Buffer
.allocUnsafe(32)
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)
7247 module
.exports
= Sha256
7249 },{"./hash":52,"inherits":44,"safe-buffer":47}],58:[function(require
,module
,exports
){
7250 var inherits
= require('inherits')
7251 var SHA512
= require('./sha512')
7252 var Hash
= require('./hash')
7253 var Buffer
= require('safe-buffer').Buffer
7255 var W
= new Array(160)
7257 function Sha384 () {
7261 Hash
.call(this, 128, 112)
7264 inherits(Sha384
, SHA512
)
7266 Sha384
.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
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
7288 Sha384
.prototype._hash = function () {
7289 var H
= Buffer
.allocUnsafe(48)
7291 function writeInt64BE (h
, l
, offset
) {
7292 H
.writeInt32BE(h
, offset
)
7293 H
.writeInt32BE(l
, offset
+ 4)
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)
7306 module
.exports
= Sha384
7308 },{"./hash":52,"./sha512":59,"inherits":44,"safe-buffer":47}],59:[function(require
,module
,exports
){
7309 var inherits
= require('inherits')
7310 var Hash
= require('./hash')
7311 var Buffer
= require('safe-buffer').Buffer
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
7356 var W
= new Array(160)
7358 function Sha512 () {
7362 Hash
.call(this, 128, 112)
7365 inherits(Sha512
, Hash
)
7367 Sha512
.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
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
7389 function Ch (x
, y
, z
) {
7390 return z
^ (x
& (y
^ z
))
7393 function maj (x
, y
, z
) {
7394 return (x
& y
) | (z
& (x
| y
))
7397 function sigma0 (x
, xl
) {
7398 return (x
>>> 28 | xl
<< 4) ^ (xl
>>> 2 | x
<< 30) ^ (xl
>>> 7 | x
<< 25)
7401 function sigma1 (x
, xl
) {
7402 return (x
>>> 14 | xl
<< 18) ^ (x
>>> 18 | xl
<< 14) ^ (xl
>>> 9 | x
<< 23)
7405 function Gamma0 (x
, xl
) {
7406 return (x
>>> 1 | xl
<< 31) ^ (x
>>> 8 | xl
<< 24) ^ (x
>>> 7)
7409 function Gamma0l (x
, xl
) {
7410 return (x
>>> 1 | xl
<< 31) ^ (x
>>> 8 | xl
<< 24) ^ (x
>>> 7 | xl
<< 25)
7413 function Gamma1 (x
, xl
) {
7414 return (x
>>> 19 | xl
<< 13) ^ (xl
>>> 29 | x
<< 3) ^ (x
>>> 6)
7417 function Gamma1l (x
, xl
) {
7418 return (x
>>> 19 | xl
<< 13) ^ (xl
>>> 29 | x
<< 3) ^ (x
>>> 6 | xl
<< 26)
7421 function getCarry (a
, b
) {
7422 return (a
>>> 0) < (b
>>> 0) ? 1 : 0
7425 Sha512
.prototype._update = function (M
) {
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
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
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)
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
)
7457 xl
= W
[i
- 2 * 2 + 1]
7458 var gamma1
= Gamma1(xh
, xl
)
7459 var gamma1l
= Gamma1l(xl
, xh
)
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]
7465 var Wi16h
= W
[i
- 16 * 2]
7466 var Wi16l
= W
[i
- 16 * 2 + 1]
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
7479 for (var j
= 0; j
< 160; j
+= 2) {
7483 var majh
= maj(ah
, bh
, ch
)
7484 var majl
= maj(al
, bl
, cl
)
7486 var sigma0h
= sigma0(ah
, al
)
7487 var sigma0l
= sigma0(al
, ah
)
7488 var sigma1h
= sigma1(eh
, el
)
7489 var sigma1l
= sigma1(el
, eh
)
7491 // t1 = h + sigma1 + ch + K[j] + W[j]
7495 var chh
= Ch(eh
, fh
, gh
)
7496 var chl
= Ch(el
, fl
, gl
)
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
7507 // t2 = sigma0 + maj
7508 var t2l
= (sigma0l
+ majl
) | 0
7509 var t2h
= (sigma0h
+ majh
+ getCarry(t2l
, sigma0l
)) | 0
7518 eh
= (dh
+ t1h
+ getCarry(el
, dl
)) | 0
7525 al
= (t1l
+ t2l
) | 0
7526 ah
= (t1h
+ t2h
+ getCarry(al
, t1l
)) | 0
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
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
7548 Sha512
.prototype._hash = function () {
7549 var H
= Buffer
.allocUnsafe(64)
7551 function writeInt64BE (h
, l
, offset
) {
7552 H
.writeInt32BE(h
, offset
)
7553 H
.writeInt32BE(l
, offset
+ 4)
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)
7568 module
.exports
= Sha512
7570 },{"./hash":52,"inherits":44,"safe-buffer":47}],60:[function(require
,module
,exports
){
7573 asn1
.bignum
= require('bn.js');
7575 asn1
.define
= require('./asn1/api').define
;
7576 asn1
.base
= require('./asn1/base');
7577 asn1
.constants
= require('./asn1/constants');
7578 asn1
.decoders
= require('./asn1/decoders');
7579 asn1
.encoders
= require('./asn1/encoders');
7581 },{"./asn1/api":61,"./asn1/base":63,"./asn1/constants":67,"./asn1/decoders":69,"./asn1/encoders":72,"bn.js":79}],61:[function(require
,module
,exports
){
7582 var asn1
= require('../asn1');
7583 var inherits
= require('inherits');
7587 api
.define
= function define(name
, body
) {
7588 return new Entity(name
, body
);
7591 function Entity(name
, body
) {
7599 Entity
.prototype._createNamed
= function createNamed(base
) {
7602 named
= require('vm').runInThisContext(
7603 '(function ' + this.name
+ '(entity) {\n' +
7604 ' this._initNamed(entity);\n' +
7608 named = function (entity
) {
7609 this._initNamed(entity
);
7612 inherits(named
, base
);
7613 named
.prototype._initNamed
= function initnamed(entity
) {
7614 base
.call(this, entity
);
7617 return new named(this);
7620 Entity
.prototype._getDecoder
= function _getDecoder(enc
) {
7622 // Lazily create decoder
7623 if (!this.decoders
.hasOwnProperty(enc
))
7624 this.decoders
[enc
] = this._createNamed(asn1
.decoders
[enc
]);
7625 return this.decoders
[enc
];
7628 Entity
.prototype.decode
= function decode(data
, enc
, options
) {
7629 return this._getDecoder(enc
).decode(data
, options
);
7632 Entity
.prototype._getEncoder
= function _getEncoder(enc
) {
7634 // Lazily create encoder
7635 if (!this.encoders
.hasOwnProperty(enc
))
7636 this.encoders
[enc
] = this._createNamed(asn1
.encoders
[enc
]);
7637 return this.encoders
[enc
];
7640 Entity
.prototype.encode
= function encode(data
, enc
, /* internal */ reporter
) {
7641 return this._getEncoder(enc
).encode(data
, reporter
);
7644 },{"../asn1":60,"inherits":162,"vm":219}],62:[function(require
,module
,exports
){
7645 var inherits
= require('inherits');
7646 var Reporter
= require('../base').Reporter
;
7647 var Buffer
= require('buffer').Buffer
;
7649 function DecoderBuffer(base
, options
) {
7650 Reporter
.call(this, options
);
7651 if (!Buffer
.isBuffer(base
)) {
7652 this.error('Input not Buffer');
7658 this.length
= base
.length
;
7660 inherits(DecoderBuffer
, Reporter
);
7661 exports
.DecoderBuffer
= DecoderBuffer
;
7663 DecoderBuffer
.prototype.save
= function save() {
7664 return { offset: this.offset
, reporter: Reporter
.prototype.save
.call(this) };
7667 DecoderBuffer
.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
;
7673 this.offset
= save
.offset
;
7674 Reporter
.prototype.restore
.call(this, save
.reporter
);
7679 DecoderBuffer
.prototype.isEmpty
= function isEmpty() {
7680 return this.offset
=== this.length
;
7683 DecoderBuffer
.prototype.readUInt8
= function readUInt8(fail
) {
7684 if (this.offset
+ 1 <= this.length
)
7685 return this.base
.readUInt8(this.offset
++, true);
7687 return this.error(fail
|| 'DecoderBuffer overrun');
7690 DecoderBuffer
.prototype.skip
= function skip(bytes
, fail
) {
7691 if (!(this.offset
+ bytes
<= this.length
))
7692 return this.error(fail
|| 'DecoderBuffer overrun');
7694 var res
= new DecoderBuffer(this.base
);
7696 // Share reporter state
7697 res
._reporterState
= this._reporterState
;
7699 res
.offset
= this.offset
;
7700 res
.length
= this.offset
+ bytes
;
7701 this.offset
+= bytes
;
7705 DecoderBuffer
.prototype.raw
= function raw(save
) {
7706 return this.base
.slice(save
? save
.offset : this.offset
, this.length
);
7709 function EncoderBuffer(value
, reporter
) {
7710 if (Array
.isArray(value
)) {
7712 this.value
= value
.map(function(item
) {
7713 if (!(item
instanceof EncoderBuffer
))
7714 item
= new EncoderBuffer(item
, reporter
);
7715 this.length
+= item
.length
;
7718 } else if (typeof value
=== 'number') {
7719 if (!(0 <= value
&& value
<= 0xff))
7720 return reporter
.error('non-byte EncoderBuffer value');
7723 } else if (typeof value
=== 'string') {
7725 this.length
= Buffer
.byteLength(value
);
7726 } else if (Buffer
.isBuffer(value
)) {
7728 this.length
= value
.length
;
7730 return reporter
.error('Unsupported type: ' + typeof value
);
7733 exports
.EncoderBuffer
= EncoderBuffer
;
7735 EncoderBuffer
.prototype.join
= function join(out
, offset
) {
7737 out
= new Buffer(this.length
);
7741 if (this.length
=== 0)
7744 if (Array
.isArray(this.value
)) {
7745 this.value
.forEach(function(item
) {
7746 item
.join(out
, offset
);
7747 offset
+= item
.length
;
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
;
7762 },{"../base":63,"buffer":110,"inherits":162}],63:[function(require
,module
,exports
){
7765 base
.Reporter
= require('./reporter').Reporter
;
7766 base
.DecoderBuffer
= require('./buffer').DecoderBuffer
;
7767 base
.EncoderBuffer
= require('./buffer').EncoderBuffer
;
7768 base
.Node
= require('./node');
7770 },{"./buffer":62,"./node":64,"./reporter":65}],64:[function(require
,module
,exports
){
7771 var Reporter
= require('../base').Reporter
;
7772 var EncoderBuffer
= require('../base').EncoderBuffer
;
7773 var DecoderBuffer
= require('../base').DecoderBuffer
;
7774 var assert
= require('minimalistic-assert');
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'
7784 // Public methods list
7786 'key', 'obj', 'use', 'optional', 'explicit', 'implicit', 'def', 'choice',
7790 // Overrided methods list
7792 '_peekTag', '_decodeTag', '_use',
7793 '_decodeStr', '_decodeObjid', '_decodeTime',
7794 '_decodeNull', '_decodeInt', '_decodeBool', '_decodeList',
7796 '_encodeComposite', '_encodeStr', '_encodeObjid', '_encodeTime',
7797 '_encodeNull', '_encodeInt', '_encodeBool'
7800 function Node(enc
, parent
) {
7802 this._baseState
= state
;
7806 state
.parent
= parent
|| null;
7807 state
.children
= null;
7812 state
.reverseArgs
= null;
7813 state
.choice
= null;
7814 state
.optional
= false;
7818 state
.useDecoder
= null;
7820 state
['default'] = null;
7821 state
.explicit
= null;
7822 state
.implicit
= null;
7823 state
.contains
= null;
7825 // Should create new instance on each method
7826 if (!state
.parent
) {
7827 state
.children
= [];
7831 module
.exports
= Node
;
7834 'enc', 'parent', 'children', 'tag', 'args', 'reverseArgs', 'choice',
7835 'optional', 'any', 'obj', 'use', 'alteredUse', 'key', 'default', 'explicit',
7836 'implicit', 'contains'
7839 Node
.prototype.clone
= function clone() {
7840 var state
= this._baseState
;
7842 stateProps
.forEach(function(prop
) {
7843 cstate
[prop
] = state
[prop
];
7845 var res
= new this.constructor(cstate
.parent
);
7846 res
._baseState
= cstate
;
7850 Node
.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
);
7861 Node
.prototype._init
= function init(body
) {
7862 var state
= this._baseState
;
7864 assert(state
.parent
=== null);
7868 state
.children
= state
.children
.filter(function(child
) {
7869 return child
._baseState
.parent
=== this;
7871 assert
.equal(state
.children
.length
, 1, 'Root node can have only one child');
7874 Node
.prototype._useArgs
= function useArgs(args
) {
7875 var state
= this._baseState
;
7877 // Filter children and args
7878 var children
= args
.filter(function(arg
) {
7879 return arg
instanceof this.constructor;
7881 args
= args
.filter(function(arg
) {
7882 return !(arg
instanceof this.constructor);
7885 if (children
.length
!== 0) {
7886 assert(state
.children
=== null);
7887 state
.children
= children
;
7889 // Replace parent to maintain backward link
7890 children
.forEach(function(child
) {
7891 child
._baseState
.parent
= this;
7894 if (args
.length
!== 0) {
7895 assert(state
.args
=== null);
7897 state
.reverseArgs
= args
.map(function(arg
) {
7898 if (typeof arg
!== 'object' || arg
.constructor !== Object
)
7902 Object
.keys(arg
).forEach(function(key
) {
7903 if (key
== (key
| 0))
7905 var value
= arg
[key
];
7914 // Overrided methods
7917 overrided
.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
);
7928 tags
.forEach(function(tag
) {
7929 Node
.prototype[tag
] = function _tagMethod() {
7930 var state
= this._baseState
;
7931 var args
= Array
.prototype.slice
.call(arguments
);
7933 assert(state
.tag
=== null);
7936 this._useArgs(args
);
7942 Node
.prototype.use = function use(item
) {
7944 var state
= this._baseState
;
7946 assert(state
.use === null);
7952 Node
.prototype.optional
= function optional() {
7953 var state
= this._baseState
;
7955 state
.optional
= true;
7960 Node
.prototype.def
= function def(val
) {
7961 var state
= this._baseState
;
7963 assert(state
['default'] === null);
7964 state
['default'] = val
;
7965 state
.optional
= true;
7970 Node
.prototype.explicit
= function explicit(num
) {
7971 var state
= this._baseState
;
7973 assert(state
.explicit
=== null && state
.implicit
=== null);
7974 state
.explicit
= num
;
7979 Node
.prototype.implicit
= function implicit(num
) {
7980 var state
= this._baseState
;
7982 assert(state
.explicit
=== null && state
.implicit
=== null);
7983 state
.implicit
= num
;
7988 Node
.prototype.obj
= function obj() {
7989 var state
= this._baseState
;
7990 var args
= Array
.prototype.slice
.call(arguments
);
7994 if (args
.length
!== 0)
7995 this._useArgs(args
);
8000 Node
.prototype.key
= function key(newKey
) {
8001 var state
= this._baseState
;
8003 assert(state
.key
=== null);
8009 Node
.prototype.any
= function any() {
8010 var state
= this._baseState
;
8017 Node
.prototype.choice
= function choice(obj
) {
8018 var state
= this._baseState
;
8020 assert(state
.choice
=== null);
8022 this._useArgs(Object
.keys(obj
).map(function(key
) {
8029 Node
.prototype.contains
= function contains(item
) {
8030 var state
= this._baseState
;
8032 assert(state
.use === null);
8033 state
.contains
= item
;
8042 Node
.prototype._decode
= function decode(input
, options
) {
8043 var state
= this._baseState
;
8046 if (state
.parent
=== null)
8047 return input
.wrapResult(state
.children
[0]._decode(input
, options
));
8049 var result
= state
['default'];
8053 if (state
.key
!== null)
8054 prevKey
= input
.enterKey(state
.key
);
8056 // Check if tag is there
8057 if (state
.optional
) {
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)
8066 if (tag
=== null && !state
.any
) {
8068 var save
= input
.save();
8070 if (state
.choice
=== null)
8071 this._decodeGeneric(state
.tag
, input
, options
);
8073 this._decodeChoice(input
, options
);
8078 input
.restore(save
);
8080 present
= this._peekTag(input
, tag
, state
.any
);
8082 if (input
.isError(present
))
8087 // Push object on stack
8089 if (state
.obj
&& present
)
8090 prevObj
= input
.enterObject();
8093 // Unwrap explicit values
8094 if (state
.explicit
!== null) {
8095 var explicit
= this._decodeTag(input
, state
.explicit
);
8096 if (input
.isError(explicit
))
8101 var start
= input
.offset
;
8103 // Unwrap implicit and normal values
8104 if (state
.use === null && state
.choice
=== null) {
8106 var save
= input
.save();
8107 var body
= this._decodeTag(
8109 state
.implicit
!== null ? state
.implicit : state
.tag
,
8112 if (input
.isError(body
))
8116 result
= input
.raw(save
);
8121 if (options
&& options
.track
&& state
.tag
!== null)
8122 options
.track(input
.path(), start
, input
.length
, 'tagged');
8124 if (options
&& options
.track
&& state
.tag
!== null)
8125 options
.track(input
.path(), input
.offset
, input
.length
, 'content');
8127 // Select proper method for tag
8130 else if (state
.choice
=== null)
8131 result
= this._decodeGeneric(state
.tag
, input
, options
);
8133 result
= this._decodeChoice(input
, options
);
8135 if (input
.isError(result
))
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
);
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
);
8156 if (state
.obj
&& present
)
8157 result
= input
.leaveObject(prevObj
);
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
);
8168 Node
.prototype._decodeGeneric
= function decodeGeneric(tag
, input
, options
) {
8169 var state
= this._baseState
;
8171 if (tag
=== 'seq' || tag
=== 'set')
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
);
8192 if (state
.use !== null) {
8193 return this._getUse(state
.use, input
._reporterState
.obj
)
8194 ._decode(input
, options
);
8196 return input
.error('unknown tag: ' + tag
);
8200 Node
.prototype._getUse
= function _getUse(entity
, obj
) {
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
;
8211 return state
.useDecoder
;
8214 Node
.prototype._decodeChoice
= function decodeChoice(input
, options
) {
8215 var state
= this._baseState
;
8219 Object
.keys(state
.choice
).some(function(key
) {
8220 var save
= input
.save();
8221 var node
= state
.choice
[key
];
8223 var value
= node
._decode(input
, options
);
8224 if (input
.isError(value
))
8227 result
= { type: key
, value: value
};
8230 input
.restore(save
);
8237 return input
.error('Choice not matched');
8246 Node
.prototype._createEncoderBuffer
= function createEncoderBuffer(data
) {
8247 return new EncoderBuffer(data
, this.reporter
);
8250 Node
.prototype._encode
= function encode(data
, reporter
, parent
) {
8251 var state
= this._baseState
;
8252 if (state
['default'] !== null && state
['default'] === data
)
8255 var result
= this._encodeValue(data
, reporter
, parent
);
8256 if (result
=== undefined)
8259 if (this._skipDefault(result
, reporter
, parent
))
8265 Node
.prototype._encodeValue
= function encode(data
, reporter
, parent
) {
8266 var state
= this._baseState
;
8269 if (state
.parent
=== null)
8270 return state
.children
[0]._encode(data
, reporter
|| new Reporter());
8274 // Set reporter to share it with a child class
8275 this.reporter
= reporter
;
8277 // Check if data is there
8278 if (state
.optional
&& data
=== undefined) {
8279 if (state
['default'] !== null)
8280 data
= state
['default']
8285 // Encode children first
8287 var primitive
= false;
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
);
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
);
8301 if (child
._baseState
.key
=== null)
8302 return reporter
.error('Child should have a key');
8303 var prevKey
= reporter
.enterKey(child
._baseState
.key
);
8305 if (typeof data
!== 'object')
8306 return reporter
.error('Child expected, but input is not object');
8308 var res
= child
._encode(data
[child
._baseState
.key
], reporter
, data
);
8309 reporter
.leaveKey(prevKey
);
8312 }, this).filter(function(child
) {
8315 content
= this._createEncoderBuffer(content
);
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
);
8322 if (!Array
.isArray(data
))
8323 return reporter
.error('seqof/setof, but data is not Array');
8325 var child
= this.clone();
8326 child
._baseState
.implicit
= null;
8327 content
= this._createEncoderBuffer(data
.map(function(item
) {
8328 var state
= this._baseState
;
8330 return this._getUse(state
.args
[0], data
)._encode(item
, reporter
);
8332 } else if (state
.use !== null) {
8333 result
= this._getUse(state
.use, parent
)._encode(data
, reporter
);
8335 content
= this._encodePrimitive(state
.tag
, data
);
8340 // Encode data itself
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';
8347 if (state
.use === null)
8348 reporter
.error('Tag could be omitted only for .use()');
8350 if (state
.use === null)
8351 result
= this._encodeComposite(tag
, primitive
, cls
, content
);
8356 if (state
.explicit
!== null)
8357 result
= this._encodeComposite(state
.explicit
, false, 'context', result
);
8362 Node
.prototype._encodeChoice
= function encodeChoice(data
, reporter
) {
8363 var state
= this._baseState
;
8365 var node
= state
.choice
[data
.type
];
8369 data
.type
+ ' not found in ' +
8370 JSON
.stringify(Object
.keys(state
.choice
)));
8372 return node
._encode(data
.value
, reporter
);
8375 Node
.prototype._encodePrimitive
= function encodePrimitive(tag
, data
) {
8376 var state
= this._baseState
;
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
);
8395 throw new Error('Unsupported tag: ' + tag
);
8398 Node
.prototype._isNumstr
= function isNumstr(str
) {
8399 return /^[0-9 ]*$/.test(str
);
8402 Node
.prototype._isPrintstr
= function isPrintstr(str
) {
8403 return /^[A
-Za
-z0
-9 '\(\)\+,\-\.\/:=\?]*$/.test(str);
8406 },{"../base":63,"minimalistic-assert":167}],65:[function(require,module,exports){
8407 var inherits = require('inherits
');
8409 function Reporter(options) {
8410 this._reporterState = {
8413 options: options || {},
8417 exports.Reporter = Reporter;
8419 Reporter.prototype.isError = function isError(obj) {
8420 return obj instanceof ReporterError;
8423 Reporter.prototype.save = function save() {
8424 var state = this._reporterState;
8426 return { obj: state.obj, pathLen: state.path.length };
8429 Reporter.prototype.restore = function restore(data) {
8430 var state = this._reporterState;
8432 state.obj = data.obj;
8433 state.path = state.path.slice(0, data.pathLen);
8436 Reporter.prototype.enterKey = function enterKey(key) {
8437 return this._reporterState.path.push(key);
8440 Reporter.prototype.exitKey = function exitKey(index) {
8441 var state = this._reporterState;
8443 state.path = state.path.slice(0, index - 1);
8446 Reporter.prototype.leaveKey = function leaveKey(index, key, value) {
8447 var state = this._reporterState;
8449 this.exitKey(index);
8450 if (state.obj !== null)
8451 state.obj[key] = value;
8454 Reporter.prototype.path = function path() {
8455 return this._reporterState.path.join('/');
8458 Reporter.prototype.enterObject = function enterObject() {
8459 var state = this._reporterState;
8461 var prev = state.obj;
8466 Reporter.prototype.leaveObject = function leaveObject(prev) {
8467 var state = this._reporterState;
8469 var now = state.obj;
8474 Reporter.prototype.error = function error(msg) {
8476 var state = this._reporterState;
8478 var inherited = msg instanceof ReporterError;
8482 err = new ReporterError(state.path.map(function(elem) {
8483 return '[' + JSON.stringify(elem) + ']';
8484 }).join(''), msg.message || msg, msg.stack);
8487 if (!state.options.partial)
8491 state.errors.push(err);
8496 Reporter.prototype.wrapResult = function wrapResult(result) {
8497 var state = this._reporterState;
8498 if (!state.options.partial)
8502 result: this.isError(result) ? null : result,
8503 errors: state.errors
8507 function ReporterError(path, msg) {
8511 inherits(ReporterError, Error);
8513 ReporterError.prototype.rethrow = function rethrow(msg) {
8514 this.message = msg + ' at: ' + (this.path || '(shallow
)');
8515 if (Error.captureStackTrace)
8516 Error.captureStackTrace(this, ReporterError);
8520 // IE only adds stack when thrown
8521 throw new Error(this.message);
8523 this.stack = e.stack;
8529 },{"inherits":162}],66:[function(require,module,exports){
8530 var constants = require('../constants
');
8532 exports.tagClass = {
8538 exports.tagClassByName = constants._reverse(exports.tagClass);
8554 0x0d: 'relativeOid
',
8571 exports.tagByName = constants._reverse(exports.tag);
8573 },{"../constants":67}],67:[function(require,module,exports){
8574 var constants = exports;
8577 constants._reverse = function reverse(map) {
8580 Object.keys(map).forEach(function(key) {
8581 // Convert key to integer if it is stringified
8582 if ((key | 0) == key)
8585 var value = map[key];
8592 constants.der = require('./der
');
8594 },{"./der":66}],68:[function(require,module,exports){
8595 var inherits = require('inherits
');
8597 var asn1 = require('../../asn1');
8598 var base = asn1.base;
8599 var bignum = asn1.bignum;
8601 // Import DER constants
8602 var der = asn1.constants.der;
8604 function DERDecoder(entity) {
8606 this.name = entity.name;
8607 this.entity = entity;
8609 // Construct base tree
8610 this.tree = new DERNode();
8611 this.tree._init(entity.body);
8613 module.exports = DERDecoder;
8615 DERDecoder.prototype.decode = function decode(data, options) {
8616 if (!(data instanceof base.DecoderBuffer))
8617 data = new base.DecoderBuffer(data, options);
8619 return this.tree._decode(data, options);
8624 function DERNode(parent) {
8625 base.Node.call(this, 'der
', parent);
8627 inherits(DERNode, base.Node);
8629 DERNode.prototype._peekTag = function peekTag(buffer, tag, any) {
8630 if (buffer.isEmpty())
8633 var state = buffer.save();
8634 var decodedTag = derDecodeTag(buffer, 'Failed to peek
tag: "' + tag + '"');
8635 if (buffer.isError(decodedTag))
8638 buffer.restore(state);
8640 return decodedTag.tag === tag || decodedTag.tagStr === tag ||
8641 (decodedTag.tagStr + 'of') === tag || any;
8644 DERNode.prototype._decodeTag = function decodeTag(buffer, tag, any) {
8645 var decodedTag = derDecodeTag(buffer,
8646 'Failed to decode tag
of "' + tag + '"');
8647 if (buffer.isError(decodedTag))
8650 var len = derDecodeLen(buffer,
8651 decodedTag.primitive,
8652 'Failed to
get length
of "' + tag + '"');
8655 if (buffer.isError(len))
8659 decodedTag.tag !== tag &&
8660 decodedTag.tagStr !== tag &&
8661 decodedTag.tagStr + 'of' !== tag) {
8662 return buffer.error('Failed to match
tag: "' + tag + '"');
8665 if (decodedTag.primitive || len !== null)
8666 return buffer.skip(len, 'Failed to match body
of: "' + tag + '"');
8668 // Indefinite length... find END tag
8669 var state = buffer.save();
8670 var res = this._skipUntilEnd(
8672 'Failed to skip indefinite length
body: "' + this.tag + '"');
8673 if (buffer.isError(res))
8676 len = buffer.offset - state.offset;
8677 buffer.restore(state);
8678 return buffer.skip(len, 'Failed to match body
of: "' + tag + '"');
8681 DERNode.prototype._skipUntilEnd = function skipUntilEnd(buffer, fail) {
8683 var tag = derDecodeTag(buffer, fail);
8684 if (buffer.isError(tag))
8686 var len = derDecodeLen(buffer, tag.primitive, fail);
8687 if (buffer.isError(len))
8691 if (tag.primitive || len !== null)
8692 res = buffer.skip(len)
8694 res = this._skipUntilEnd(buffer, fail);
8697 if (buffer.isError(res))
8700 if (tag.tagStr === 'end
')
8705 DERNode.prototype._decodeList = function decodeList(buffer, tag, decoder,
8708 while (!buffer.isEmpty()) {
8709 var possibleEnd = this._peekTag(buffer, 'end
');
8710 if (buffer.isError(possibleEnd))
8713 var res = decoder.decode(buffer, 'der
', options);
8714 if (buffer.isError(res) && possibleEnd)
8721 DERNode.prototype._decodeStr = function decodeStr(buffer, tag) {
8722 if (tag === 'bitstr
') {
8723 var unused = buffer.readUInt8();
8724 if (buffer.isError(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
');
8733 for (var i = 0; i < raw.length / 2; i++) {
8734 str += String.fromCharCode(raw.readUInt16BE(i * 2));
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
');
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
');
8755 } else if (/str$/.test(tag)) {
8756 return buffer.raw().toString();
8758 return buffer.error('Decoding
of string
type: ' + tag + ' unsupported
');
8762 DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) {
8764 var identifiers = [];
8766 while (!buffer.isEmpty()) {
8767 var subident = buffer.readUInt8();
8769 ident |= subident & 0x7f;
8770 if ((subident & 0x80) === 0) {
8771 identifiers.push(ident);
8775 if (subident & 0x80)
8776 identifiers.push(ident);
8778 var first = (identifiers[0] / 40) | 0;
8779 var second = identifiers[0] % 40;
8782 result = identifiers;
8784 result = [first, second].concat(identifiers.slice(1));
8787 var tmp = values[result.join(' ')];
8788 if (tmp === undefined)
8789 tmp = values[result.join('.')];
8790 if (tmp !== undefined)
8797 DERNode.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;
8818 return buffer.error('Decoding
' + tag + ' time is not supported yet
');
8821 return Date.UTC(year, mon - 1, day, hour, min, sec, 0);
8824 DERNode.prototype._decodeNull = function decodeNull(buffer) {
8828 DERNode.prototype._decodeBool = function decodeBool(buffer) {
8829 var res = buffer.readUInt8();
8830 if (buffer.isError(res))
8836 DERNode.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);
8842 res = values[res.toString(10)] || res;
8847 DERNode.prototype._use = function use(entity, obj) {
8848 if (typeof entity === 'function')
8849 entity = entity(obj);
8850 return entity._getDecoder('der
').tree;
8855 function derDecodeTag(buf, fail) {
8856 var tag = buf.readUInt8(fail);
8857 if (buf.isError(tag))
8860 var cls = der.tagClass[tag >> 6];
8861 var primitive = (tag & 0x20) === 0;
8863 // Multi-octet tag - load
8864 if ((tag & 0x1f) === 0x1f) {
8867 while ((oct & 0x80) === 0x80) {
8868 oct = buf.readUInt8(fail);
8869 if (buf.isError(oct))
8878 var tagStr = der.tag[tag];
8882 primitive: primitive,
8888 function derDecodeLen(buf, primitive, fail) {
8889 var len = buf.readUInt8(fail);
8890 if (buf.isError(len))
8894 if (!primitive && len === 0x80)
8898 if ((len & 0x80) === 0) {
8904 var num = len & 0x7f;
8906 return buf.error('length octect is too
long');
8909 for (var i = 0; i < num; i++) {
8911 var j = buf.readUInt8(fail);
8920 },{"../../asn1":60,"inherits":162}],69:[function(require,module,exports){
8921 var decoders = exports;
8923 decoders.der = require('./der
');
8924 decoders.pem = require('./pem
');
8926 },{"./der":68,"./pem":70}],70:[function(require,module,exports){
8927 var inherits = require('inherits
');
8928 var Buffer = require('buffer
').Buffer;
8930 var DERDecoder = require('./der
');
8932 function PEMDecoder(entity) {
8933 DERDecoder.call(this, entity);
8936 inherits(PEMDecoder, DERDecoder);
8937 module.exports = PEMDecoder;
8939 PEMDecoder.prototype.decode = function decode(data, options) {
8940 var lines = data.toString().split(/[\r\n]+/g);
8942 var label = options.label.toUpperCase();
8944 var re = /^-----(BEGIN|END) ([^-]+)-----$/;
8947 for (var i = 0; i < lines.length; i++) {
8948 var match = lines[i].match(re);
8952 if (match[2] !== label)
8956 if (match[1] !== 'BEGIN
')
8960 if (match[1] !== 'END
')
8966 if (start === -1 || end === -1)
8967 throw new Error('PEM section not found
for: ' + label);
8969 var base64 = lines.slice(start + 1, end).join('');
8970 // Remove excessive symbols
8971 base64.replace(/[^a-z0-9\+\/=]+/gi, '');
8973 var input = new Buffer(base64, 'base64
');
8974 return DERDecoder.prototype.decode.call(this, input, options);
8977 },{"./der":68,"buffer":110,"inherits":162}],71:[function(require,module,exports){
8978 var inherits = require('inherits
');
8979 var Buffer = require('buffer
').Buffer;
8981 var asn1 = require('../../asn1');
8982 var base = asn1.base;
8984 // Import DER constants
8985 var der = asn1.constants.der;
8987 function DEREncoder(entity) {
8989 this.name = entity.name;
8990 this.entity = entity;
8992 // Construct base tree
8993 this.tree = new DERNode();
8994 this.tree._init(entity.body);
8996 module.exports = DEREncoder;
8998 DEREncoder.prototype.encode = function encode(data, reporter) {
8999 return this.tree._encode(data, reporter).join();
9004 function DERNode(parent) {
9005 base.Node.call(this, 'der
', parent);
9007 inherits(DERNode, base.Node);
9009 DERNode.prototype._encodeComposite = function encodeComposite(tag,
9013 var encodedTag = encodeTag(tag, primitive, cls, this.reporter);
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 ]);
9024 // Count octets required to store length
9026 for (var i = content.length; i >= 0x100; i >>= 8)
9029 var header = new Buffer(1 + 1 + lenOctets);
9030 header[0] = encodedTag;
9031 header[1] = 0x80 | lenOctets;
9033 for (var i = 1 + lenOctets, j = content.length; j > 0; i--, j >>= 8)
9034 header[i] = j & 0xff;
9036 return this._createEncoderBuffer([ header, content ]);
9039 DERNode.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);
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
');
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
, ' +
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);
9069 return this.reporter.error('Encoding
of string
type: ' + tag +
9074 DERNode.prototype._encodeObjid = function encodeObjid(id, values, relative) {
9075 if (typeof id === 'string
') {
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++)
9083 } else if (Array.isArray(id)) {
9085 for (var i = 0; i < id.length; i++)
9089 if (!Array.isArray(id)) {
9090 return this.reporter.error('objid() should be either array or string
, ' +
9091 'got: ' + JSON.stringify(id));
9096 return this.reporter.error('Second objid identifier OOB
');
9097 id.splice(0, 2, id[0] * 40 + id[1]);
9100 // Count number of octets
9102 for (var i = 0; i < id.length; i++) {
9104 for (size++; ident >= 0x80; ident >>= 7)
9108 var objid = new Buffer(size);
9109 var offset = objid.length - 1;
9110 for (var i = id.length - 1; i >= 0; i--) {
9112 objid[offset--] = ident & 0x7f;
9113 while ((ident >>= 7) > 0)
9114 objid[offset--] = 0x80 | (ident & 0x7f);
9117 return this._createEncoderBuffer(objid);
9127 DERNode.prototype._encodeTime = function encodeTime(time, tag) {
9129 var date = new Date(time);
9131 if (tag === 'gentime
') {
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()),
9141 } else if (tag === 'utctime
') {
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()),
9152 this.reporter.error('Encoding
' + tag + ' time is not supported yet
');
9155 return this._encodeStr(str, 'octstr
');
9158 DERNode.prototype._encodeNull = function encodeNull() {
9159 return this._createEncoderBuffer('');
9162 DERNode.prototype._encodeInt = function encodeInt(num, values) {
9163 if (typeof num === 'string
') {
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));
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);
9179 num = new Buffer(numArray);
9182 if (Buffer.isBuffer(num)) {
9183 var size = num.length;
9184 if (num.length === 0)
9187 var out = new Buffer(size);
9189 if (num.length === 0)
9191 return this._createEncoderBuffer(out);
9195 return this._createEncoderBuffer(num);
9198 return this._createEncoderBuffer([0, num]);
9201 for (var i = num; i >= 0x100; i >>= 8)
9204 var out = new Array(size);
9205 for (var i = out.length - 1; i >= 0; i--) {
9206 out[i] = num & 0xff;
9213 return this._createEncoderBuffer(new Buffer(out));
9216 DERNode.prototype._encodeBool = function encodeBool(value) {
9217 return this._createEncoderBuffer(value ? 0xff : 0);
9220 DERNode.prototype._use = function use(entity, obj) {
9221 if (typeof entity === 'function')
9222 entity = entity(obj);
9223 return entity._getEncoder('der
').tree;
9226 DERNode.prototype._skipDefault = function skipDefault(dataBuffer, reporter, parent) {
9227 var state = this._baseState;
9229 if (state['default'] === null)
9232 var data = dataBuffer.join();
9233 if (state.defaultBuffer === undefined)
9234 state.defaultBuffer = this._encodeValue(state['default'], reporter, parent).join();
9236 if (data.length !== state.defaultBuffer.length)
9239 for (i=0; i < data.length; i++)
9240 if (data[i] !== state.defaultBuffer[i])
9248 function encodeTag(tag, primitive, cls, reporter) {
9251 if (tag === 'seqof
')
9253 else if (tag === 'setof
')
9256 if (der.tagByName.hasOwnProperty(tag))
9257 res = der.tagByName[tag];
9258 else if (typeof tag === 'number
' && (tag | 0) === tag)
9261 return reporter.error('Unknown
tag: ' + tag);
9264 return reporter.error('Multi
-octet tag encoding unsupported
');
9269 res |= (der.tagClassByName[cls || 'universal
'] << 6);
9274 },{"../../asn1":60,"buffer":110,"inherits":162}],72:[function(require,module,exports){
9275 var encoders = exports;
9277 encoders.der = require('./der
');
9278 encoders.pem = require('./pem
');
9280 },{"./der":71,"./pem":73}],73:[function(require,module,exports){
9281 var inherits = require('inherits
');
9283 var DEREncoder = require('./der
');
9285 function PEMEncoder(entity) {
9286 DEREncoder.call(this, entity);
9289 inherits(PEMEncoder, DEREncoder);
9290 module.exports = PEMEncoder;
9292 PEMEncoder.prototype.encode = function encode(data, options) {
9293 var buf = DEREncoder.prototype.encode.call(this, data);
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');
9303 },{"./der":71,"inherits":162}],74:[function(require,module,exports){
9307 var objectAssign = require('object
-assign
');
9309 // compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js
9313 * The buffer module from node.js, for the browser.
9315 * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
9318 function compare(a, b) {
9326 for (var i = 0, len = Math.min(x, y); i < len; ++i) {
9327 if (a[i] !== b[i]) {
9342 function isBuffer(b) {
9343 if (global.Buffer && typeof global.Buffer.isBuffer === 'function') {
9344 return global.Buffer.isBuffer(b);
9346 return !!(b != null && b._isBuffer);
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.
9353 // http://wiki.commonjs.org/wiki/Unit_Testing/1.0
9355 // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
9357 // Originally from narwhal.js (http://narwhaljs.org)
9358 // Copyright (c) 2009 Thomas Robinson <280north.com>
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:
9367 // The above copyright notice and this permission notice shall be included in
9368 // all copies or substantial portions of the Software.
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.
9377 var util = require('util
/');
9378 var hasOwn = Object.prototype.hasOwnProperty;
9379 var pSlice = Array.prototype.slice;
9380 var functionsHaveNames = (function () {
9381 return function foo() {}.name === 'foo
';
9383 function pToString (obj) {
9384 return Object.prototype.toString.call(obj);
9386 function isView(arrbuf) {
9387 if (isBuffer(arrbuf)) {
9390 if (typeof global.ArrayBuffer !== 'function') {
9393 if (typeof ArrayBuffer.isView === 'function') {
9394 return ArrayBuffer.isView(arrbuf);
9399 if (arrbuf instanceof DataView) {
9402 if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) {
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.
9411 var assert
= module
.exports
= ok
;
9413 // 2. The AssertionError is defined in assert.
9414 // new assert.AssertionError({ message: message,
9416 // expected: expected })
9418 var regex
= /\s*function\s+([^\(\s]*)\s*/;
9419 // based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js
9420 function getName(func
) {
9421 if (!util
.isFunction(func
)) {
9424 if (functionsHaveNames
) {
9427 var str
= func
.toString();
9428 var match
= str
.match(regex
);
9429 return match
&& match
[1];
9431 assert
.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;
9440 this.message
= getMessage(this);
9441 this.generatedMessage
= true;
9443 var stackStartFunction
= options
.stackStartFunction
|| fail
;
9444 if (Error
.captureStackTrace
) {
9445 Error
.captureStackTrace(this, stackStartFunction
);
9447 // non v8 browsers so we can have a stacktrace
9448 var err
= new Error();
9450 var out
= err
.stack
;
9452 // try to strip useless frames
9453 var fn_name
= getName(stackStartFunction
);
9454 var idx
= out
.indexOf('\n' + fn_name
);
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);
9467 // assert.AssertionError instanceof Error
9468 util
.inherits(assert
.AssertionError
, Error
);
9470 function truncate(s
, n
) {
9471 if (typeof s
=== 'string') {
9472 return s
.length
< n
? s : s
.slice(0, n
);
9477 function inspect(something
) {
9478 if (functionsHaveNames
|| !util
.isFunction(something
)) {
9479 return util
.inspect(something
);
9481 var rawname
= getName(something
);
9482 var name
= rawname
? ': ' + rawname : '';
9483 return '[Function' + name
+ ']';
9485 function getMessage(self
) {
9486 return truncate(inspect(self
.actual
), 128) + ' ' +
9487 self
.operator
+ ' ' +
9488 truncate(inspect(self
.expected
), 128);
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
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.
9502 function fail(actual
, expected
, message
, operator
, stackStartFunction
) {
9503 throw new assert
.AssertionError({
9508 stackStartFunction: stackStartFunction
9512 // EXTENSION! allows for well behaved errors defined elsewhere.
9515 // 4. Pure assertion tests whether a value is truthy, as determined
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);.
9522 function ok(value
, message
) {
9523 if (!value
) fail(value
, true, message
, '==', assert
.ok
);
9527 // 5. The equality assertion tests shallow, coercive equality with
9529 // assert.equal(actual, expected, message_opt);
9531 assert
.equal
= function equal(actual
, expected
, message
) {
9532 if (actual
!= expected
) fail(actual
, expected
, message
, '==', assert
.equal
);
9535 // 6. The non-equality assertion tests for whether two objects are not equal
9536 // with != assert.notEqual(actual, expected, message_opt);
9538 assert
.notEqual
= function notEqual(actual
, expected
, message
) {
9539 if (actual
== expected
) {
9540 fail(actual
, expected
, message
, '!=', assert
.notEqual
);
9544 // 7. The equivalence assertion tests a deep equality relation.
9545 // assert.deepEqual(actual, expected, message_opt);
9547 assert
.deepEqual
= function deepEqual(actual
, expected
, message
) {
9548 if (!_deepEqual(actual
, expected
, false)) {
9549 fail(actual
, expected
, message
, 'deepEqual', assert
.deepEqual
);
9553 assert
.deepStrictEqual
= function deepStrictEqual(actual
, expected
, message
) {
9554 if (!_deepEqual(actual
, expected
, true)) {
9555 fail(actual
, expected
, message
, 'deepStrictEqual', assert
.deepStrictEqual
);
9559 function _deepEqual(actual
, expected
, strict
, memos
) {
9560 // 7.1. All identical values are equivalent, as determined by ===.
9561 if (actual
=== expected
) {
9563 } else if (isBuffer(actual
) && isBuffer(expected
)) {
9564 return compare(actual
, expected
) === 0;
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();
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
;
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
;
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;
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
)) {
9609 memos
= memos
|| {actual: [], expected: []};
9611 var actualIndex
= memos
.actual
.indexOf(actual
);
9612 if (actualIndex
!== -1) {
9613 if (actualIndex
=== memos
.expected
.indexOf(expected
)) {
9618 memos
.actual
.push(actual
);
9619 memos
.expected
.push(expected
);
9621 return objEquiv(actual
, expected
, strict
, memos
);
9625 function isArguments(object
) {
9626 return Object
.prototype.toString
.call(object
) == '[object Arguments]';
9629 function objEquiv(a
, b
, strict
, actualVisitedObjects
) {
9630 if (a
=== null || a
=== undefined || b
=== null || b
=== undefined)
9632 // if one is a primitive, the other must be same
9633 if (util
.isPrimitive(a
) || util
.isPrimitive(b
))
9635 if (strict
&& Object
.getPrototypeOf(a
) !== Object
.getPrototypeOf(b
))
9637 var aIsArgs
= isArguments(a
);
9638 var bIsArgs
= isArguments(b
);
9639 if ((aIsArgs
&& !bIsArgs
) || (!aIsArgs
&& bIsArgs
))
9644 return _deepEqual(a
, b
, strict
);
9646 var ka
= objectKeys(a
);
9647 var kb
= objectKeys(b
);
9649 // having the same number of owned properties (keys incorporates
9651 if (ka
.length
!== kb
.length
)
9653 //the same set of keys (although not necessarily the same order),
9657 for (i
= ka
.length
- 1; i
>= 0; i
--) {
9658 if (ka
[i
] !== kb
[i
])
9661 //equivalent values for every corresponding key, and
9662 //~~~possibly expensive deep test
9663 for (i
= ka
.length
- 1; i
>= 0; i
--) {
9665 if (!_deepEqual(a
[key
], b
[key
], strict
, actualVisitedObjects
))
9671 // 8. The non-equivalence assertion tests for any deep inequality.
9672 // assert.notDeepEqual(actual, expected, message_opt);
9674 assert
.notDeepEqual
= function notDeepEqual(actual
, expected
, message
) {
9675 if (_deepEqual(actual
, expected
, false)) {
9676 fail(actual
, expected
, message
, 'notDeepEqual', assert
.notDeepEqual
);
9680 assert
.notDeepStrictEqual
= notDeepStrictEqual
;
9681 function notDeepStrictEqual(actual
, expected
, message
) {
9682 if (_deepEqual(actual
, expected
, true)) {
9683 fail(actual
, expected
, message
, 'notDeepStrictEqual', notDeepStrictEqual
);
9688 // 9. The strict equality assertion tests strict equality, as determined by ===.
9689 // assert.strictEqual(actual, expected, message_opt);
9691 assert
.strictEqual
= function strictEqual(actual
, expected
, message
) {
9692 if (actual
!== expected
) {
9693 fail(actual
, expected
, message
, '===', assert
.strictEqual
);
9697 // 10. The strict non-equality assertion tests for strict inequality, as
9698 // determined by !==. assert.notStrictEqual(actual, expected, message_opt);
9700 assert
.notStrictEqual
= function notStrictEqual(actual
, expected
, message
) {
9701 if (actual
=== expected
) {
9702 fail(actual
, expected
, message
, '!==', assert
.notStrictEqual
);
9706 function expectedException(actual
, expected
) {
9707 if (!actual
|| !expected
) {
9711 if (Object
.prototype.toString
.call(expected
) == '[object RegExp]') {
9712 return expected
.test(actual
);
9716 if (actual
instanceof expected
) {
9720 // Ignore. The instanceof check doesn't work for arrow functions.
9723 if (Error
.isPrototypeOf(expected
)) {
9727 return expected
.call({}, actual
) === true;
9730 function _tryBlock(block
) {
9740 function _throws(shouldThrow
, block
, expected
, message
) {
9743 if (typeof block
!== 'function') {
9744 throw new TypeError('"block" argument must be a function');
9747 if (typeof expected
=== 'string') {
9752 actual
= _tryBlock(block
);
9754 message
= (expected
&& expected
.name
? ' (' + expected
.name
+ ').' : '.') +
9755 (message
? ' ' + message : '.');
9757 if (shouldThrow
&& !actual
) {
9758 fail(actual
, expected
, 'Missing expected exception' + message
);
9761 var userProvidedMessage
= typeof message
=== 'string';
9762 var isUnwantedException
= !shouldThrow
&& util
.isError(actual
);
9763 var isUnexpectedException
= !shouldThrow
&& actual
&& !expected
;
9765 if ((isUnwantedException
&&
9766 userProvidedMessage
&&
9767 expectedException(actual
, expected
)) ||
9768 isUnexpectedException
) {
9769 fail(actual
, expected
, 'Got unwanted exception' + message
);
9772 if ((shouldThrow
&& actual
&& expected
&&
9773 !expectedException(actual
, expected
)) || (!shouldThrow
&& actual
)) {
9778 // 11. Expected to throw an error:
9779 // assert.throws(block, Error_opt, message_opt);
9781 assert
.throws = function(block
, /*optional*/error
, /*optional*/message
) {
9782 _throws(true, block
, error
, message
);
9785 // EXTENSION! This is annoying to write outside this module.
9786 assert
.doesNotThrow = function(block
, /*optional*/error
, /*optional*/message
) {
9787 _throws(false, block
, error
, message
);
9790 assert
.ifError = function(err
) { if (err
) throw err
; };
9792 // Expose a strict only variant of assert
9793 function strict(value
, message
) {
9794 if (!value
) fail(value
, true, message
, '==', strict
);
9796 assert
.strict
= objectAssign(strict
, assert
, {
9797 equal: assert
.strictEqual
,
9798 deepEqual: assert
.deepStrictEqual
,
9799 notEqual: assert
.notStrictEqual
,
9800 notDeepEqual: assert
.notDeepStrictEqual
9802 assert
.strict
.strict
= assert
.strict
;
9804 var objectKeys
= Object
.keys
|| function (obj
) {
9806 for (var key
in obj
) {
9807 if (hasOwn
.call(obj
, key
)) keys
.push(key
);
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
){
9814 if (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, {
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
9838 },{}],76:[function(require
,module
,exports
){
9839 module
.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';
9845 },{}],77:[function(require
,module
,exports
){
9846 (function (process
,global
){
9847 // Copyright Joyent, Inc. and other Node contributors.
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:
9857 // The above copyright notice and this permission notice shall be included
9858 // in all copies or substantial portions of the Software.
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.
9868 var formatRegExp
= /%[sdj%]/g;
9869 exports
.format = function(f
) {
9872 for (var i
= 0; i
< arguments
.length
; i
++) {
9873 objects
.push(inspect(arguments
[i
]));
9875 return objects
.join(' ');
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
;
9885 case '%s': return String(args
[i
++]);
9886 case '%d': return Number(args
[i
++]);
9889 return JSON
.stringify(args
[i
++]);
9891 return '[Circular]';
9897 for (var x
= args
[i
]; i
< len
; x
= args
[++i
]) {
9898 if (isNull(x
) || !isObject(x
)) {
9901 str
+= ' ' + inspect(x
);
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.
9911 exports
.deprecate = function(fn
, msg
) {
9912 // Allow for deprecating things in the process of starting up.
9913 if (isUndefined(global
.process
)) {
9915 return exports
.deprecate(fn
, msg
).apply(this, arguments
);
9919 if (process
.noDeprecation
=== true) {
9924 function deprecated() {
9926 if (process
.throwDeprecation
) {
9927 throw new Error(msg
);
9928 } else if (process
.traceDeprecation
) {
9935 return fn
.apply(this, arguments
);
9944 exports
.debuglog = function(set) {
9945 if (isUndefined(debugEnviron
))
9946 debugEnviron
= process
.env
.NODE_DEBUG
|| '';
9947 set = set.toUpperCase();
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
);
9956 debugs
[set] = function() {};
9964 * Echos the value of a value. Trys to print the value out
9965 * in the best way possible given the different types.
9967 * @param {Object} obj The object to print out.
9968 * @param {Object} opts Optional options object that alters the output.
9970 /* legacy: obj, showHidden, depth, colors*/
9971 function inspect(obj
, opts
) {
9975 stylize: stylizeNoColor
9978 if (arguments
.length
>= 3) ctx
.depth
= arguments
[2];
9979 if (arguments
.length
>= 4) ctx
.colors
= arguments
[3];
9980 if (isBoolean(opts
)) {
9982 ctx
.showHidden
= opts
;
9984 // got an "options" object
9985 exports
._extend(ctx
, opts
);
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
);
9995 exports
.inspect
= inspect
;
9998 // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
10001 'italic' : [3, 23],
10002 'underline' : [4, 24],
10003 'inverse' : [7, 27],
10004 'white' : [37, 39],
10006 'black' : [30, 39],
10009 'green' : [32, 39],
10010 'magenta' : [35, 39],
10012 'yellow' : [33, 39]
10015 // Don't use 'blue' not visible on cmd.exe
10018 'number': 'yellow',
10019 'boolean': 'yellow',
10020 'undefined': 'grey',
10024 // "name": intentionally not styling
10029 function stylizeWithColor(str
, styleType
) {
10030 var style
= inspect
.styles
[styleType
];
10033 return '\u001b[' + inspect
.colors
[style
][0] + 'm' + str
+
10034 '\u001b[' + inspect
.colors
[style
][1] + 'm';
10041 function stylizeNoColor(str
, styleType
) {
10046 function arrayToHash(array
) {
10049 array
.forEach(function(val
, idx
) {
10057 function 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
&&
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
);
10074 // Primitive types cannot have properties
10075 var primitive
= formatPrimitive(ctx
, value
);
10080 // Look up the keys of the object.
10081 var keys
= Object
.keys(value
);
10082 var visibleKeys
= arrayToHash(keys
);
10084 if (ctx
.showHidden
) {
10085 keys
= Object
.getOwnPropertyNames(value
);
10088 // IE doesn't make error fields non-enumerable
10089 // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
10091 && (keys
.indexOf('message') >= 0 || keys
.indexOf('description') >= 0)) {
10092 return formatError(value
);
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');
10101 if (isRegExp(value
)) {
10102 return ctx
.stylize(RegExp
.prototype.toString
.call(value
), 'regexp');
10104 if (isDate(value
)) {
10105 return ctx
.stylize(Date
.prototype.toString
.call(value
), 'date');
10107 if (isError(value
)) {
10108 return formatError(value
);
10112 var base
= '', array
= false, braces
= ['{', '}'];
10114 // Make Array say that they are Array
10115 if (isArray(value
)) {
10117 braces
= ['[', ']'];
10120 // Make functions say that they are functions
10121 if (isFunction(value
)) {
10122 var n
= value
.name
? ': ' + value
.name : '';
10123 base
= ' [Function' + n
+ ']';
10126 // Make RegExps say that they are RegExps
10127 if (isRegExp(value
)) {
10128 base
= ' ' + RegExp
.prototype.toString
.call(value
);
10131 // Make dates with properties first say the date
10132 if (isDate(value
)) {
10133 base
= ' ' + Date
.prototype.toUTCString
.call(value
);
10136 // Make error with message first say the error
10137 if (isError(value
)) {
10138 base
= ' ' + formatError(value
);
10141 if (keys
.length
=== 0 && (!array
|| value
.length
== 0)) {
10142 return braces
[0] + base
+ braces
[1];
10145 if (recurseTimes
< 0) {
10146 if (isRegExp(value
)) {
10147 return ctx
.stylize(RegExp
.prototype.toString
.call(value
), 'regexp');
10149 return ctx
.stylize('[Object]', 'special');
10153 ctx
.seen
.push(value
);
10157 output
= formatArray(ctx
, value
, recurseTimes
, visibleKeys
, keys
);
10159 output
= keys
.map(function(key
) {
10160 return formatProperty(ctx
, value
, recurseTimes
, visibleKeys
, key
, array
);
10166 return reduceToSingleString(output
, base
, braces
);
10170 function 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');
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.
10185 return ctx
.stylize('null', 'null');
10189 function formatError(value
) {
10190 return '[' + Error
.prototype.toString
.call(value
) + ']';
10194 function formatArray(ctx
, value
, recurseTimes
, visibleKeys
, keys
) {
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
,
10204 keys
.forEach(function(key
) {
10205 if (!key
.match(/^\d+$/)) {
10206 output
.push(formatProperty(ctx
, value
, recurseTimes
, visibleKeys
,
10214 function formatProperty(ctx
, value
, recurseTimes
, visibleKeys
, key
, array
) {
10215 var name
, str
, desc
;
10216 desc
= Object
.getOwnPropertyDescriptor(value
, key
) || { value: value
[key
] };
10219 str
= ctx
.stylize('[Getter/Setter]', 'special');
10221 str
= ctx
.stylize('[Getter]', 'special');
10225 str
= ctx
.stylize('[Setter]', 'special');
10228 if (!hasOwnProperty(visibleKeys
, key
)) {
10229 name
= '[' + key
+ ']';
10232 if (ctx
.seen
.indexOf(desc
.value
) < 0) {
10233 if (isNull(recurseTimes
)) {
10234 str
= formatValue(ctx
, desc
.value
, null);
10236 str
= formatValue(ctx
, desc
.value
, recurseTimes
- 1);
10238 if (str
.indexOf('\n') > -1) {
10240 str
= str
.split('\n').map(function(line
) {
10242 }).join('\n').substr(2);
10244 str
= '\n' + str
.split('\n').map(function(line
) {
10250 str
= ctx
.stylize('[Circular]', 'special');
10253 if (isUndefined(name
)) {
10254 if (array
&& key
.match(/^\d+$/)) {
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');
10262 name
= name
.replace(/'/g, "\\'")
10263 .replace(/\\"/g
, '"')
10264 .replace(/(^"|"$)/g, "'");
10265 name
= ctx
.stylize(name
, 'string');
10269 return name
+ ': ' + str
;
10273 function reduceToSingleString(output
, base
, braces
) {
10274 var numLinesEst
= 0;
10275 var length
= output
.reduce(function(prev
, cur
) {
10277 if (cur
.indexOf('\n') >= 0) numLinesEst
++;
10278 return prev
+ cur
.replace(/\u001b\[\d\d?m/g, '').length
+ 1;
10283 (base
=== '' ? '' : base
+ '\n ') +
10285 output
.join(',\n ') +
10290 return braces
[0] + base
+ ' ' + output
.join(', ') + ' ' + braces
[1];
10294 // NOTE: These type checking functions intentionally don't use `instanceof`
10295 // because it is fragile and can be easily faked with `Object.create()`.
10296 function isArray(ar
) {
10297 return Array
.isArray(ar
);
10299 exports
.isArray
= isArray
;
10301 function isBoolean(arg
) {
10302 return typeof arg
=== 'boolean';
10304 exports
.isBoolean
= isBoolean
;
10306 function isNull(arg
) {
10307 return arg
=== null;
10309 exports
.isNull
= isNull
;
10311 function isNullOrUndefined(arg
) {
10312 return arg
== null;
10314 exports
.isNullOrUndefined
= isNullOrUndefined
;
10316 function isNumber(arg
) {
10317 return typeof arg
=== 'number';
10319 exports
.isNumber
= isNumber
;
10321 function isString(arg
) {
10322 return typeof arg
=== 'string';
10324 exports
.isString
= isString
;
10326 function isSymbol(arg
) {
10327 return typeof arg
=== 'symbol';
10329 exports
.isSymbol
= isSymbol
;
10331 function isUndefined(arg
) {
10332 return arg
=== void 0;
10334 exports
.isUndefined
= isUndefined
;
10336 function isRegExp(re
) {
10337 return isObject(re
) && objectToString(re
) === '[object RegExp]';
10339 exports
.isRegExp
= isRegExp
;
10341 function isObject(arg
) {
10342 return typeof arg
=== 'object' && arg
!== null;
10344 exports
.isObject
= isObject
;
10346 function isDate(d
) {
10347 return isObject(d
) && objectToString(d
) === '[object Date]';
10349 exports
.isDate
= isDate
;
10351 function isError(e
) {
10352 return isObject(e
) &&
10353 (objectToString(e
) === '[object Error]' || e
instanceof Error
);
10355 exports
.isError
= isError
;
10357 function isFunction(arg
) {
10358 return typeof arg
=== 'function';
10360 exports
.isFunction
= isFunction
;
10362 function 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';
10370 exports
.isPrimitive
= isPrimitive
;
10372 exports
.isBuffer
= require('./support/isBuffer');
10374 function objectToString(o
) {
10375 return Object
.prototype.toString
.call(o
);
10380 return n
< 10 ? '0' + n
.toString(10) : n
.toString(10);
10384 var months
= ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
10385 'Oct', 'Nov', 'Dec'];
10388 function 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(' ');
10397 // log is just a thin wrapper to console.log that prepends a timestamp
10398 exports
.log = function() {
10399 console
.log('%s - %s', timestamp(), exports
.format
.apply(exports
, arguments
));
10404 * Inherit the prototype methods from one constructor into another.
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).
10412 * @param {function} ctor Constructor function which needs to inherit the
10414 * @param {function} superCtor Constructor function to inherit prototype from.
10416 exports
.inherits
= require('inherits');
10418 exports
._extend = function(origin
, add
) {
10419 // Don't do anything if add isn't an object
10420 if (!add
|| !isObject(add
)) return origin
;
10422 var keys
= Object
.keys(add
);
10423 var i
= keys
.length
;
10425 origin
[keys
[i
]] = add
[keys
[i
]];
10430 function hasOwnProperty(obj
, prop
) {
10431 return Object
.prototype.hasOwnProperty
.call(obj
, prop
);
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
){
10438 exports
.byteLength
= byteLength
10439 exports
.toByteArray
= toByteArray
10440 exports
.fromByteArray
= fromByteArray
10444 var Arr
= typeof Uint8Array
!== 'undefined' ? Uint8Array : Array
10446 var code
= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
10447 for (var i
= 0, len
= code
.length
; i
< len
; ++i
) {
10448 lookup
[i
] = code
[i
]
10449 revLookup
[code
.charCodeAt(i
)] = i
10452 // Support decoding URL-safe base64 strings, as Node.js does.
10453 // See: https://en.wikipedia.org/wiki/Base64#URL_applications
10454 revLookup
['-'.charCodeAt(0)] = 62
10455 revLookup
['_'.charCodeAt(0)] = 63
10457 function getLens (b64
) {
10458 var len
= b64
.length
10461 throw new Error('Invalid string. Length must be a multiple of 4')
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
10469 var placeHoldersLen
= validLen
=== len
10471 : 4 - (validLen
% 4)
10473 return [validLen
, placeHoldersLen
]
10476 // base64 is 4/3 + up to two characters of the original data
10477 function byteLength (b64
) {
10478 var lens
= getLens(b64
)
10479 var validLen
= lens
[0]
10480 var placeHoldersLen
= lens
[1]
10481 return ((validLen
+ placeHoldersLen
) * 3 / 4) - placeHoldersLen
10484 function _byteLength (b64
, validLen
, placeHoldersLen
) {
10485 return ((validLen
+ placeHoldersLen
) * 3 / 4) - placeHoldersLen
10488 function toByteArray (b64
) {
10490 var lens
= getLens(b64
)
10491 var validLen
= lens
[0]
10492 var placeHoldersLen
= lens
[1]
10494 var arr
= new Arr(_byteLength(b64
, validLen
, placeHoldersLen
))
10498 // if there are placeholders, only get up to the last complete 4 chars
10499 var len
= placeHoldersLen
> 0
10504 for (i
= 0; i
< len
; i
+= 4) {
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
10515 if (placeHoldersLen
=== 2) {
10517 (revLookup
[b64
.charCodeAt(i
)] << 2) |
10518 (revLookup
[b64
.charCodeAt(i
+ 1)] >> 4)
10519 arr
[curByte
++] = tmp
& 0xFF
10522 if (placeHoldersLen
=== 1) {
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
10534 function tripletToBase64 (num
) {
10535 return lookup
[num
>> 18 & 0x3F] +
10536 lookup
[num
>> 12 & 0x3F] +
10537 lookup
[num
>> 6 & 0x3F] +
10541 function encodeChunk (uint8
, start
, end
) {
10544 for (var i
= start
; i
< end
; i
+= 3) {
10546 ((uint8
[i
] << 16) & 0xFF0000) +
10547 ((uint8
[i
+ 1] << 8) & 0xFF00) +
10548 (uint8
[i
+ 2] & 0xFF)
10549 output
.push(tripletToBase64(tmp
))
10551 return output
.join('')
10554 function fromByteArray (uint8
) {
10556 var len
= uint8
.length
10557 var extraBytes
= len
% 3 // if we have 1 byte left, pad 2 bytes
10559 var maxChunkLength
= 16383 // must be multiple of 3
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
)
10568 // pad the end with zeros, but make sure to not forget the extra bytes
10569 if (extraBytes
=== 1) {
10570 tmp
= uint8
[len
- 1]
10573 lookup
[(tmp
<< 4) & 0x3F] +
10576 } else if (extraBytes
=== 2) {
10577 tmp
= (uint8
[len
- 2] << 8) + uint8
[len
- 1]
10579 lookup
[tmp
>> 10] +
10580 lookup
[(tmp
>> 4) & 0x3F] +
10581 lookup
[(tmp
<< 2) & 0x3F] +
10586 return parts
.join('')
10589 },{}],79:[function(require
,module
,exports
){
10590 (function (module
, exports
) {
10594 function assert (val
, msg
) {
10595 if (!val
) throw new Error(msg
|| 'Assertion failed');
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
;
10610 function BN (number
, base
, endian
) {
10611 if (BN
.isBN(number
)) {
10619 // Reduction context
10622 if (number
!== null) {
10623 if (base
=== 'le' || base
=== 'be') {
10628 this._init(number
|| 0, base
|| 10, endian
|| 'be');
10631 if (typeof module
=== 'object') {
10632 module
.exports
= BN
;
10642 Buffer
= require('buffer').Buffer
;
10646 BN
.isBN
= function isBN (num
) {
10647 if (num
instanceof BN
) {
10651 return num
!== null && typeof num
=== 'object' &&
10652 num
.constructor.wordSize
=== BN
.wordSize
&& Array
.isArray(num
.words
);
10655 BN
.max
= function max (left
, right
) {
10656 if (left
.cmp(right
) > 0) return left
;
10660 BN
.min
= function min (left
, right
) {
10661 if (left
.cmp(right
) < 0) return left
;
10665 BN
.prototype._init
= function init (number
, base
, endian
) {
10666 if (typeof number
=== 'number') {
10667 return this._initNumber(number
, base
, endian
);
10670 if (typeof number
=== 'object') {
10671 return this._initArray(number
, base
, endian
);
10674 if (base
=== 'hex') {
10677 assert(base
=== (base
| 0) && base
>= 2 && base
<= 36);
10679 number
= number
.toString().replace(/\s+/g, '');
10681 if (number
[0] === '-') {
10686 this._parseHex(number
, start
);
10688 this._parseBase(number
, base
, start
);
10691 if (number
[0] === '-') {
10697 if (endian
!== 'le') return;
10699 this._initArray(this.toArray(), base
, endian
);
10702 BN
.prototype._initNumber
= function _initNumber (number
, base
, endian
) {
10707 if (number
< 0x4000000) {
10708 this.words
= [ number
& 0x3ffffff ];
10710 } else if (number
< 0x10000000000000) {
10712 number
& 0x3ffffff,
10713 (number
/ 0x4000000) & 0x3ffffff
10717 assert(number
< 0x20000000000000); // 2 ^ 53 (unsafe)
10719 number
& 0x3ffffff,
10720 (number
/ 0x4000000) & 0x3ffffff,
10726 if (endian
!== 'le') return;
10728 // Reverse the bytes
10729 this._initArray(this.toArray(), base
, endian
);
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 ];
10741 this.length
= Math
.ceil(number
.length
/ 3);
10742 this.words
= new Array(this.length
);
10743 for (var i
= 0; i
< this.length
; i
++) {
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;
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;
10772 return this.strip();
10775 function parseHex (str
, start
, end
) {
10777 var len
= Math
.min(str
.length
, end
);
10778 for (var i
= start
; i
< len
; i
++) {
10779 var c
= str
.charCodeAt(i
) - 48;
10784 if (c
>= 49 && c
<= 54) {
10788 } else if (c
>= 17 && c
<= 22) {
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
++) {
10808 // Scan 24-bit chunks and add them to the number
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;
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;
10829 function parseBase (str
, start
, end
, mul
) {
10831 var len
= Math
.min(str
.length
, end
);
10832 for (var i
= start
; i
< len
; i
++) {
10833 var c
= str
.charCodeAt(i
) - 48;
10842 } else if (c
>= 17) {
10853 BN
.prototype._parseBase
= function _parseBase (number
, base
, start
) {
10854 // Initialize as zero
10855 this.words
= [ 0 ];
10858 // Find length of limb in base
10859 for (var limbLen
= 0, limbPow
= 1; limbPow
<= 0x3ffffff; limbPow
*= base
) {
10863 limbPow
= (limbPow
/ base
) | 0;
10865 var total
= number
.length
- start
;
10866 var mod
= total
% limbLen
;
10867 var end
= Math
.min(total
, total
- mod
) + start
;
10870 for (var i
= start
; i
< end
; i
+= limbLen
) {
10871 word
= parseBase(number
, i
, i
+ limbLen
, base
);
10873 this.imuln(limbPow
);
10874 if (this.words
[0] + word
< 0x4000000) {
10875 this.words
[0] += word
;
10883 word
= parseBase(number
, i
, number
.length
, base
);
10885 for (i
= 0; i
< mod
; i
++) {
10890 if (this.words
[0] + word
< 0x4000000) {
10891 this.words
[0] += word
;
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
];
10903 dest
.length
= this.length
;
10904 dest
.negative
= this.negative
;
10905 dest
.red
= this.red
;
10908 BN
.prototype.clone
= function clone () {
10909 var r
= new BN(null);
10914 BN
.prototype._expand
= function _expand (size
) {
10915 while (this.length
< size
) {
10916 this.words
[this.length
++] = 0;
10921 // Remove leading `0` from `this`
10922 BN
.prototype.strip
= function strip () {
10923 while (this.length
> 1 && this.words
[this.length
- 1] === 0) {
10926 return this._normSign();
10929 BN
.prototype._normSign
= function _normSign () {
10931 if (this.length
=== 1 && this.words
[0] === 0) {
10937 BN
.prototype.inspect
= function inspect () {
10938 return (this.red
? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';
10944 var groupSizes = [];
10945 var groupBases = [];
10949 while (++i < BN.wordSize) {
10958 while (++base < 36 + 1) {
10961 while (groupBase < (1 << BN.wordSize) / base) {
10965 groupSizes[base] = groupSize;
10966 groupBases[base] = groupBase;
10988 '0000000000000000',
10989 '00000000000000000',
10990 '000000000000000000',
10991 '0000000000000000000',
10992 '00000000000000000000',
10993 '000000000000000000000',
10994 '0000000000000000000000',
10995 '00000000000000000000000',
10996 '000000000000000000000000',
10997 '0000000000000000000000000'
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
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
11018 BN
.prototype.toString
= function toString (base
, padding
) {
11020 padding
= padding
| 0 || 1;
11023 if (base
=== 16 || base
=== 'hex') {
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
;
11043 out
= carry
.toString(16) + out
;
11045 while (out
.length
% padding
!== 0) {
11048 if (this.negative
!== 0) {
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
];
11060 var c
= this.clone();
11062 while (!c
.isZero()) {
11063 var r
= c
.modn(groupBase
).toString(base
);
11064 c
= c
.idivn(groupBase
);
11067 out
= zeros
[groupSize
- r
.length
] + r
+ out
;
11072 if (this.isZero()) {
11075 while (out
.length
% padding
!== 0) {
11078 if (this.negative
!== 0) {
11084 assert(false, 'Base should be between 2 and 36');
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');
11097 return (this.negative
!== 0) ? -ret : ret
;
11100 BN
.prototype.toJSON
= function toJSON () {
11101 return this.toString(16);
11104 BN
.prototype.toBuffer
= function toBuffer (endian
, length
) {
11105 assert(typeof Buffer
!== 'undefined');
11106 return this.toArrayLike(Buffer
, endian
, length
);
11109 BN
.prototype.toArray
= function toArray (endian
, length
) {
11110 return this.toArrayLike(Array
, endian
, length
);
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');
11120 var littleEndian
= endian
=== 'le';
11121 var res
= new ArrayType(reqLength
);
11124 var q
= this.clone();
11125 if (!littleEndian
) {
11126 // Assume big-endian
11127 for (i
= 0; i
< reqLength
- byteLength
; i
++) {
11131 for (i
= 0; !q
.isZero(); i
++) {
11135 res
[reqLength
- i
- 1] = b
;
11138 for (i
= 0; !q
.isZero(); i
++) {
11145 for (; i
< reqLength
; i
++) {
11154 BN
.prototype._countBits
= function _countBits (w
) {
11155 return 32 - Math
.clz32(w
);
11158 BN
.prototype._countBits
= function _countBits (w
) {
11181 BN
.prototype._zeroBits
= function _zeroBits (w
) {
11183 if (w
=== 0) return 26;
11187 if ((t
& 0x1fff) === 0) {
11191 if ((t
& 0x7f) === 0) {
11195 if ((t
& 0xf) === 0) {
11199 if ((t
& 0x3) === 0) {
11203 if ((t
& 0x1) === 0) {
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
;
11216 function toBitArray (num
) {
11217 var w
= new Array(num
.bitLength());
11219 for (var bit
= 0; bit
< w
.length
; bit
++) {
11220 var off
= (bit
/ 26) | 0;
11221 var wbit
= bit
% 26;
11223 w
[bit
] = (num
.words
[off
] & (1 << wbit
)) >>> wbit
;
11229 // Number of trailing zero bits
11230 BN
.prototype.zeroBits
= function zeroBits () {
11231 if (this.isZero()) return 0;
11234 for (var i
= 0; i
< this.length
; i
++) {
11235 var b
= this._zeroBits(this.words
[i
]);
11237 if (b
!== 26) break;
11242 BN
.prototype.byteLength
= function byteLength () {
11243 return Math
.ceil(this.bitLength() / 8);
11246 BN
.prototype.toTwos
= function toTwos (width
) {
11247 if (this.negative
!== 0) {
11248 return this.abs().inotn(width
).iaddn(1);
11250 return this.clone();
11253 BN
.prototype.fromTwos
= function fromTwos (width
) {
11254 if (this.testn(width
- 1)) {
11255 return this.notn(width
).iaddn(1).ineg();
11257 return this.clone();
11260 BN
.prototype.isNeg
= function isNeg () {
11261 return this.negative
!== 0;
11264 // Return negative clone of `this`
11265 BN
.prototype.neg
= function neg () {
11266 return this.clone().ineg();
11269 BN
.prototype.ineg
= function ineg () {
11270 if (!this.isZero()) {
11271 this.negative
^= 1;
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;
11283 for (var i
= 0; i
< num
.length
; i
++) {
11284 this.words
[i
] = this.words
[i
] | num
.words
[i
];
11287 return this.strip();
11290 BN
.prototype.ior
= function ior (num
) {
11291 assert((this.negative
| num
.negative
) === 0);
11292 return this.iuor(num
);
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);
11301 BN
.prototype.uor
= function uor (num
) {
11302 if (this.length
> num
.length
) return this.clone().iuor(num
);
11303 return num
.clone().iuor(this);
11306 // And `num` with `this` in-place
11307 BN
.prototype.iuand
= function iuand (num
) {
11308 // b = min-length(num, this)
11310 if (this.length
> num
.length
) {
11316 for (var i
= 0; i
< b
.length
; i
++) {
11317 this.words
[i
] = this.words
[i
] & num
.words
[i
];
11320 this.length
= b
.length
;
11322 return this.strip();
11325 BN
.prototype.iand
= function iand (num
) {
11326 assert((this.negative
| num
.negative
) === 0);
11327 return this.iuand(num
);
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);
11336 BN
.prototype.uand
= function uand (num
) {
11337 if (this.length
> num
.length
) return this.clone().iuand(num
);
11338 return num
.clone().iuand(this);
11341 // Xor `num` with `this` in-place
11342 BN
.prototype.iuxor
= function iuxor (num
) {
11343 // a.length > b.length
11346 if (this.length
> num
.length
) {
11354 for (var i
= 0; i
< b
.length
; i
++) {
11355 this.words
[i
] = a
.words
[i
] ^ b
.words
[i
];
11359 for (; i
< a
.length
; i
++) {
11360 this.words
[i
] = a
.words
[i
];
11364 this.length
= a
.length
;
11366 return this.strip();
11369 BN
.prototype.ixor
= function ixor (num
) {
11370 assert((this.negative
| num
.negative
) === 0);
11371 return this.iuxor(num
);
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);
11380 BN
.prototype.uxor
= function uxor (num
) {
11381 if (this.length
> num
.length
) return this.clone().iuxor(num
);
11382 return num
.clone().iuxor(this);
11385 // Not ``this`` with ``width`` bitwidth
11386 BN
.prototype.inotn
= function inotn (width
) {
11387 assert(typeof width
=== 'number' && width
>= 0);
11389 var bytesNeeded
= Math
.ceil(width
/ 26) | 0;
11390 var bitsLeft
= width
% 26;
11392 // Extend the buffer with leading zeroes
11393 this._expand(bytesNeeded
);
11395 if (bitsLeft
> 0) {
11399 // Handle complete words
11400 for (var i
= 0; i
< bytesNeeded
; i
++) {
11401 this.words
[i
] = ~this.words
[i
] & 0x3ffffff;
11404 // Handle the residue
11405 if (bitsLeft
> 0) {
11406 this.words
[i
] = ~this.words
[i
] & (0x3ffffff >> (26 - bitsLeft
));
11409 // And remove leading zeroes
11410 return this.strip();
11413 BN
.prototype.notn
= function notn (width
) {
11414 return this.clone().inotn(width
);
11417 // Set `bit` of `this`
11418 BN
.prototype.setn
= function setn (bit
, val
) {
11419 assert(typeof bit
=== 'number' && bit
>= 0);
11421 var off
= (bit
/ 26) | 0;
11422 var wbit
= bit
% 26;
11424 this._expand(off
+ 1);
11427 this.words
[off
] = this.words
[off
] | (1 << wbit
);
11429 this.words
[off
] = this.words
[off
] & ~(1 << wbit
);
11432 return this.strip();
11435 // Add `num` to `this` in-place
11436 BN
.prototype.iadd
= function iadd (num
) {
11439 // negative + positive
11440 if (this.negative
!== 0 && num
.negative
=== 0) {
11442 r
= this.isub(num
);
11443 this.negative
^= 1;
11444 return this._normSign();
11446 // positive + negative
11447 } else if (this.negative
=== 0 && num
.negative
!== 0) {
11449 r
= this.isub(num
);
11451 return r
._normSign();
11454 // a.length > b.length
11456 if (this.length
> num
.length
) {
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;
11470 for (; carry
!== 0 && i
< a
.length
; i
++) {
11471 r
= (a
.words
[i
] | 0) + carry
;
11472 this.words
[i
] = r
& 0x3ffffff;
11476 this.length
= a
.length
;
11478 this.words
[this.length
] = carry
;
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
];
11490 // Add `num` to `this`
11491 BN
.prototype.add
= function add (num
) {
11493 if (num
.negative
!== 0 && this.negative
=== 0) {
11495 res
= this.sub(num
);
11498 } else if (num
.negative
=== 0 && this.negative
!== 0) {
11500 res
= num
.sub(this);
11505 if (this.length
> num
.length
) return this.clone().iadd(num
);
11507 return num
.clone().iadd(this);
11510 // Subtract `num` from `this` in-place
11511 BN
.prototype.isub
= function isub (num
) {
11512 // this - (-num) = this + num
11513 if (num
.negative
!== 0) {
11515 var r
= this.iadd(num
);
11517 return r
._normSign();
11519 // -this - num = -(this + num)
11520 } else if (this.negative
!== 0) {
11524 return this._normSign();
11527 // At this point both numbers are positive
11528 var cmp
= this.cmp(num
);
11530 // Optimization - zeroify
11549 for (var i
= 0; i
< b
.length
; i
++) {
11550 r
= (a
.words
[i
] | 0) - (b
.words
[i
] | 0) + carry
;
11552 this.words
[i
] = r
& 0x3ffffff;
11554 for (; carry
!== 0 && i
< a
.length
; i
++) {
11555 r
= (a
.words
[i
] | 0) + carry
;
11557 this.words
[i
] = r
& 0x3ffffff;
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
];
11567 this.length
= Math
.max(this.length
, i
);
11573 return this.strip();
11576 // Subtract `num` from `this`
11577 BN
.prototype.sub
= function sub (num
) {
11578 return this.clone().isub(num
);
11581 function smallMulTo (self
, num
, out
) {
11582 out
.negative
= num
.negative
^ self
.negative
;
11583 var len
= (self
.length
+ num
.length
) | 0;
11585 len
= (len
- 1) | 0;
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;
11592 var lo
= r
& 0x3ffffff;
11593 var carry
= (r
/ 0x4000000) | 0;
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;
11607 ncarry
+= (r
/ 0x4000000) | 0;
11608 rword
= r
& 0x3ffffff;
11610 out
.words
[k
] = rword
| 0;
11611 carry
= ncarry
| 0;
11614 out
.words
[k
] = carry
| 0;
11619 return out
.strip();
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
;
11634 var al0
= a0
& 0x1fff;
11635 var ah0
= a0
>>> 13;
11637 var al1
= a1
& 0x1fff;
11638 var ah1
= a1
>>> 13;
11640 var al2
= a2
& 0x1fff;
11641 var ah2
= a2
>>> 13;
11643 var al3
= a3
& 0x1fff;
11644 var ah3
= a3
>>> 13;
11646 var al4
= a4
& 0x1fff;
11647 var ah4
= a4
>>> 13;
11649 var al5
= a5
& 0x1fff;
11650 var ah5
= a5
>>> 13;
11652 var al6
= a6
& 0x1fff;
11653 var ah6
= a6
>>> 13;
11655 var al7
= a7
& 0x1fff;
11656 var ah7
= a7
>>> 13;
11658 var al8
= a8
& 0x1fff;
11659 var ah8
= a8
>>> 13;
11661 var al9
= a9
& 0x1fff;
11662 var ah9
= a9
>>> 13;
11664 var bl0
= b0
& 0x1fff;
11665 var bh0
= b0
>>> 13;
11667 var bl1
= b1
& 0x1fff;
11668 var bh1
= b1
>>> 13;
11670 var bl2
= b2
& 0x1fff;
11671 var bh2
= b2
>>> 13;
11673 var bl3
= b3
& 0x1fff;
11674 var bh3
= b3
>>> 13;
11676 var bl4
= b4
& 0x1fff;
11677 var bh4
= b4
>>> 13;
11679 var bl5
= b5
& 0x1fff;
11680 var bh5
= b5
>>> 13;
11682 var bl6
= b6
& 0x1fff;
11683 var bh6
= b6
>>> 13;
11685 var bl7
= b7
& 0x1fff;
11686 var bh7
= b7
>>> 13;
11688 var bl8
= b8
& 0x1fff;
11689 var bh8
= b8
>>> 13;
11691 var bl9
= b9
& 0x1fff;
11692 var bh9
= b9
>>> 13;
11694 out
.negative
= self
.negative
^ num
.negative
;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
12200 comb10MulTo
= smallMulTo
;
12203 function bigMulTo (self
, num
, out
) {
12204 out
.negative
= num
.negative
^ self
.negative
;
12205 out
.length
= self
.length
+ num
.length
;
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
;
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
++) {
12218 var a
= self
.words
[i
] | 0;
12219 var b
= num
.words
[j
] | 0;
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;
12228 hncarry
+= ncarry
>>> 26;
12229 ncarry
&= 0x3ffffff;
12231 out
.words
[k
] = rword
;
12236 out
.words
[k
] = carry
;
12241 return out
.strip();
12244 function jumboMulTo (self
, num
, out
) {
12245 var fftm
= new FFTM();
12246 return fftm
.mulp(self
, num
, out
);
12249 BN
.prototype.mulTo
= function mulTo (num
, out
) {
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
);
12259 res
= jumboMulTo(this, num
, out
);
12265 // Cooley-Tukey algorithm for FFT
12266 // slightly revisited to rely on looping instead of recursion
12268 function FFTM (x
, y
) {
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
);
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
;
12288 for (var i
= 0; i
< l
; i
++) {
12289 rb
|= (x
& 1) << (l
- i
- 1);
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
]];
12305 FFTM
.prototype.transform
= function transform (rws
, iws
, rtws
, itws
, N
, rbt
) {
12306 this.permute(rbt
, rws
, iws
, rtws
, itws
, N
);
12308 for (var s
= 1; s
< N
; s
<<= 1) {
12311 var rtwdf
= Math
.cos(2 * Math
.PI
/ l
);
12312 var itwdf
= Math
.sin(2 * Math
.PI
/ l
);
12314 for (var p
= 0; p
< N
; p
+= l
) {
12315 var rtwdf_
= rtwdf
;
12316 var itwdf_
= itwdf
;
12318 for (var j
= 0; j
< s
; j
++) {
12319 var re
= rtws
[p
+ j
];
12320 var ie
= itws
[p
+ j
];
12322 var ro
= rtws
[p
+ j
+ s
];
12323 var io
= itws
[p
+ j
+ s
];
12325 var rx
= rtwdf_
* ro
- itwdf_
* io
;
12327 io
= rtwdf_
* io
+ itwdf_
* ro
;
12330 rtws
[p
+ j
] = re
+ ro
;
12331 itws
[p
+ j
] = ie
+ io
;
12333 rtws
[p
+ j
+ s
] = re
- ro
;
12334 itws
[p
+ j
+ s
] = ie
- io
;
12336 /* jshint maxdepth : false */
12338 rx
= rtwdf
* rtwdf_
- itwdf
* itwdf_
;
12340 itwdf_
= rtwdf
* itwdf_
+ itwdf
* rtwdf_
;
12348 FFTM
.prototype.guessLen13b
= function guessLen13b (n
, m
) {
12349 var N
= Math
.max(m
, n
) | 1;
12352 for (N
= N
/ 2 | 0; N
; N
= N
>>> 1) {
12356 return 1 << i
+ 1 + odd
;
12359 FFTM
.prototype.conjugate
= function conjugate (rws
, iws
, N
) {
12360 if (N
<= 1) return;
12362 for (var i
= 0; i
< N
/ 2; i
++) {
12365 rws
[i
] = rws
[N
- i
- 1];
12366 rws
[N
- i
- 1] = t
;
12370 iws
[i
] = -iws
[N
- i
- 1];
12371 iws
[N
- i
- 1] = -t
;
12375 FFTM
.prototype.normalize13b
= function normalize13b (ws
, N
) {
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
) +
12382 ws
[i
] = w
& 0x3ffffff;
12384 if (w
< 0x4000000) {
12387 carry
= w
/ 0x4000000 | 0;
12394 FFTM
.prototype.convert13b
= function convert13b (ws
, len
, rws
, N
) {
12396 for (var i
= 0; i
< len
; i
++) {
12397 carry
= carry
+ (ws
[i
] | 0);
12399 rws
[2 * i
] = carry
& 0x1fff; carry
= carry
>>> 13;
12400 rws
[2 * i
+ 1] = carry
& 0x1fff; carry
= carry
>>> 13;
12404 for (i
= 2 * len
; i
< N
; ++i
) {
12408 assert(carry
=== 0);
12409 assert((carry
& ~0x1fff) === 0);
12412 FFTM
.prototype.stub
= function stub (N
) {
12413 var ph
= new Array(N
);
12414 for (var i
= 0; i
< N
; i
++) {
12421 FFTM
.prototype.mulp
= function mulp (x
, y
, out
) {
12422 var N
= 2 * this.guessLen13b(x
.length
, y
.length
);
12424 var rbt
= this.makeRBT(N
);
12426 var _
= this.stub(N
);
12428 var rws
= new Array(N
);
12429 var rwst
= new Array(N
);
12430 var iwst
= new Array(N
);
12432 var nrws
= new Array(N
);
12433 var nrwst
= new Array(N
);
12434 var niwst
= new Array(N
);
12436 var rmws
= out
.words
;
12439 this.convert13b(x
.words
, x
.length
, rws
, N
);
12440 this.convert13b(y
.words
, y
.length
, nrws
, N
);
12442 this.transform(rws
, _
, rwst
, iwst
, N
, rbt
);
12443 this.transform(nrws
, _
, nrwst
, niwst
, N
, rbt
);
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
];
12451 this.conjugate(rwst
, iwst
, N
);
12452 this.transform(rwst
, iwst
, rmws
, _
, N
, rbt
);
12453 this.conjugate(rmws
, _
, N
);
12454 this.normalize13b(rmws
, N
);
12456 out
.negative
= x
.negative
^ y
.negative
;
12457 out
.length
= x
.length
+ y
.length
;
12458 return out
.strip();
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
);
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
);
12475 // In-place Multiplication
12476 BN
.prototype.imul
= function imul (num
) {
12477 return this.clone().mulTo(num
, this);
12480 BN
.prototype.imuln
= function imuln (num
) {
12481 assert(typeof num
=== 'number');
12482 assert(num
< 0x4000000);
12486 for (var i
= 0; i
< this.length
; i
++) {
12487 var w
= (this.words
[i
] | 0) * num
;
12488 var lo
= (w
& 0x3ffffff) + (carry
& 0x3ffffff);
12490 carry
+= (w
/ 0x4000000) | 0;
12491 // NOTE: lo is 27bit maximum
12492 carry
+= lo
>>> 26;
12493 this.words
[i
] = lo
& 0x3ffffff;
12497 this.words
[i
] = carry
;
12504 BN
.prototype.muln
= function muln (num
) {
12505 return this.clone().imuln(num
);
12509 BN
.prototype.sqr
= function sqr () {
12510 return this.mul(this);
12513 // `this` * `this` in-place
12514 BN
.prototype.isqr
= function isqr () {
12515 return this.imul(this.clone());
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);
12523 // Skip leading zeroes
12525 for (var i
= 0; i
< w
.length
; i
++, res
= res
.sqr()) {
12526 if (w
[i
] !== 0) break;
12529 if (++i
< w
.length
) {
12530 for (var q
= res
.sqr(); i
< w
.length
; i
++, q
= q
.sqr()) {
12531 if (w
[i
] === 0) continue;
12540 // Shift-left in-place
12541 BN
.prototype.iushln
= function iushln (bits
) {
12542 assert(typeof bits
=== 'number' && bits
>= 0);
12544 var s
= (bits
- r
) / 26;
12545 var carryMask
= (0x3ffffff >>> (26 - r
)) << (26 - r
);
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
);
12559 this.words
[i
] = carry
;
12565 for (i
= this.length
- 1; i
>= 0; i
--) {
12566 this.words
[i
+ s
] = this.words
[i
];
12569 for (i
= 0; i
< s
; i
++) {
12576 return this.strip();
12579 BN
.prototype.ishln
= function ishln (bits
) {
12580 // TODO(indutny): implement me
12581 assert(this.negative
=== 0);
12582 return this.iushln(bits
);
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);
12592 h
= (hint
- (hint
% 26)) / 26;
12598 var s
= Math
.min((bits
- r
) / 26, this.length
);
12599 var mask
= 0x3ffffff ^ ((0x3ffffff >>> r
) << r
);
12600 var maskedWords
= extended
;
12603 h
= Math
.max(0, h
);
12605 // Extended mode, copy masked part
12607 for (var i
= 0; i
< s
; i
++) {
12608 maskedWords
.words
[i
] = this.words
[i
];
12610 maskedWords
.length
= s
;
12614 // No-op, we should not move anything at all
12615 } else if (this.length
> s
) {
12617 for (i
= 0; i
< this.length
; i
++) {
12618 this.words
[i
] = this.words
[i
+ s
];
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
;
12632 // Push carried bits as a mask
12633 if (maskedWords
&& carry
!== 0) {
12634 maskedWords
.words
[maskedWords
.length
++] = carry
;
12637 if (this.length
=== 0) {
12642 return this.strip();
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
);
12652 BN
.prototype.shln
= function shln (bits
) {
12653 return this.clone().ishln(bits
);
12656 BN
.prototype.ushln
= function ushln (bits
) {
12657 return this.clone().iushln(bits
);
12661 BN
.prototype.shrn
= function shrn (bits
) {
12662 return this.clone().ishrn(bits
);
12665 BN
.prototype.ushrn
= function ushrn (bits
) {
12666 return this.clone().iushrn(bits
);
12669 // Test if n bit is set
12670 BN
.prototype.testn
= function testn (bit
) {
12671 assert(typeof bit
=== 'number' && bit
>= 0);
12673 var s
= (bit
- r
) / 26;
12676 // Fast case: bit is much higher than all existing words
12677 if (this.length
<= s
) return false;
12679 // Check bit and return
12680 var w
= this.words
[s
];
12685 // Return only lowers bits of number (in-place)
12686 BN
.prototype.imaskn
= function imaskn (bits
) {
12687 assert(typeof bits
=== 'number' && bits
>= 0);
12689 var s
= (bits
- r
) / 26;
12691 assert(this.negative
=== 0, 'imaskn works only with positive numbers');
12693 if (this.length
<= s
) {
12700 this.length
= Math
.min(s
, this.length
);
12703 var mask
= 0x3ffffff ^ ((0x3ffffff >>> r
) << r
);
12704 this.words
[this.length
- 1] &= mask
;
12707 return this.strip();
12710 // Return only lowers bits of number
12711 BN
.prototype.maskn
= function maskn (bits
) {
12712 return this.clone().imaskn(bits
);
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
);
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);
12735 // Add without checks
12736 return this._iaddn(num
);
12739 BN
.prototype._iaddn
= function _iaddn (num
) {
12740 this.words
[0] += num
;
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;
12748 this.words
[i
+ 1]++;
12751 this.length
= Math
.max(this.length
, i
+ 1);
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
);
12762 if (this.negative
!== 0) {
12769 this.words
[0] -= num
;
12771 if (this.length
=== 1 && this.words
[0] < 0) {
12772 this.words
[0] = -this.words
[0];
12776 for (var i
= 0; i
< this.length
&& this.words
[i
] < 0; i
++) {
12777 this.words
[i
] += 0x4000000;
12778 this.words
[i
+ 1] -= 1;
12782 return this.strip();
12785 BN
.prototype.addn
= function addn (num
) {
12786 return this.clone().iaddn(num
);
12789 BN
.prototype.subn
= function subn (num
) {
12790 return this.clone().isubn(num
);
12793 BN
.prototype.iabs
= function iabs () {
12799 BN
.prototype.abs
= function abs () {
12800 return this.clone().iabs();
12803 BN
.prototype._ishlnsubmul
= function _ishlnsubmul (num
, mul
, shift
) {
12804 var len
= num
.length
+ shift
;
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;
12818 for (; i
< this.length
- shift
; i
++) {
12819 w
= (this.words
[i
+ shift
] | 0) + carry
;
12821 this.words
[i
+ shift
] = w
& 0x3ffffff;
12824 if (carry
=== 0) return this.strip();
12826 // Subtraction overflow
12827 assert(carry
=== -1);
12829 for (i
= 0; i
< this.length
; i
++) {
12830 w
= -(this.words
[i
] | 0) + carry
;
12832 this.words
[i
] = w
& 0x3ffffff;
12836 return this.strip();
12839 BN
.prototype._wordDiv
= function _wordDiv (num
, mode
) {
12840 var shift
= this.length
- num
.length
;
12842 var a
= this.clone();
12846 var bhi
= b
.words
[b
.length
- 1] | 0;
12847 var bhiBits
= this._countBits(bhi
);
12848 shift
= 26 - bhiBits
;
12850 b
= b
.ushln(shift
);
12852 bhi
= b
.words
[b
.length
- 1] | 0;
12855 // Initialize quotient
12856 var m
= a
.length
- b
.length
;
12859 if (mode
!== 'mod') {
12862 q
.words
= new Array(q
.length
);
12863 for (var i
= 0; i
< q
.length
; i
++) {
12868 var diff
= a
.clone()._ishlnsubmul(b
, 1, m
);
12869 if (diff
.negative
=== 0) {
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);
12880 // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max
12882 qj
= Math
.min((qj
/ bhi
) | 0, 0x3ffffff);
12884 a
._ishlnsubmul(b
, qj
, j
);
12885 while (a
.negative
!== 0) {
12888 a
._ishlnsubmul(b
, 1, j
);
12903 if (mode
!== 'div' && shift
!== 0) {
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());
12920 if (this.isZero()) {
12928 if (this.negative
!== 0 && num
.negative
=== 0) {
12929 res
= this.neg().divmod(num
, mode
);
12931 if (mode
!== 'mod') {
12932 div
= res
.div
.neg();
12935 if (mode
!== 'div') {
12936 mod
= res
.mod
.neg();
12937 if (positive
&& mod
.negative
!== 0) {
12948 if (this.negative
=== 0 && num
.negative
!== 0) {
12949 res
= this.divmod(num
.neg(), mode
);
12951 if (mode
!== 'mod') {
12952 div
= res
.div
.neg();
12961 if ((this.negative
& num
.negative
) !== 0) {
12962 res
= this.neg().divmod(num
.neg(), mode
);
12964 if (mode
!== 'div') {
12965 mod
= res
.mod
.neg();
12966 if (positive
&& mod
.negative
!== 0) {
12977 // Both numbers are positive at this point
12979 // Strip both numbers to approximate shift value
12980 if (num
.length
> this.length
|| this.cmp(num
) < 0) {
12987 // Very short reduction
12988 if (num
.length
=== 1) {
12989 if (mode
=== 'div') {
12991 div: this.divn(num
.words
[0]),
12996 if (mode
=== 'mod') {
12999 mod: new BN(this.modn(num
.words
[0]))
13004 div: this.divn(num
.words
[0]),
13005 mod: new BN(this.modn(num
.words
[0]))
13009 return this._wordDiv(num
, mode
);
13012 // Find `this` / `num`
13013 BN
.prototype.div
= function div (num
) {
13014 return this.divmod(num
, 'div', false).div
;
13017 // Find `this` % `num`
13018 BN
.prototype.mod
= function mod (num
) {
13019 return this.divmod(num
, 'mod', false).mod
;
13022 BN
.prototype.umod
= function umod (num
) {
13023 return this.divmod(num
, 'mod', true).mod
;
13026 // Find Round(`this` / `num`)
13027 BN
.prototype.divRound
= function divRound (num
) {
13028 var dm
= this.divmod(num
);
13030 // Fast case - exact division
13031 if (dm
.mod
.isZero()) return dm
.div
;
13033 var mod
= dm
.div
.negative
!== 0 ? dm
.mod
.isub(num
) : dm
.mod
;
13035 var half
= num
.ushrn(1);
13036 var r2
= num
.andln(1);
13037 var cmp
= mod
.cmp(half
);
13040 if (cmp
< 0 || r2
=== 1 && cmp
=== 0) return dm
.div
;
13043 return dm
.div
.negative
!== 0 ? dm
.div
.isubn(1) : dm
.div
.iaddn(1);
13046 BN
.prototype.modn
= function modn (num
) {
13047 assert(num
<= 0x3ffffff);
13048 var p
= (1 << 26) % num
;
13051 for (var i
= this.length
- 1; i
>= 0; i
--) {
13052 acc
= (p
* acc
+ (this.words
[i
] | 0)) % num
;
13058 // In-place division by number
13059 BN
.prototype.idivn
= function idivn (num
) {
13060 assert(num
<= 0x3ffffff);
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;
13069 return this.strip();
13072 BN
.prototype.divn
= function divn (num
) {
13073 return this.clone().idivn(num
);
13076 BN
.prototype.egcd
= function egcd (p
) {
13077 assert(p
.negative
=== 0);
13078 assert(!p
.isZero());
13083 if (x
.negative
!== 0) {
13089 // A * x + B * y = x
13093 // C * x + D * y = y
13099 while (x
.isEven() && y
.isEven()) {
13105 var yp
= y
.clone();
13106 var xp
= x
.clone();
13108 while (!x
.isZero()) {
13109 for (var i
= 0, im
= 1; (x
.words
[0] & im
) === 0 && i
< 26; ++i
, im
<<= 1);
13113 if (A
.isOdd() || B
.isOdd()) {
13123 for (var j
= 0, jm
= 1; (y
.words
[0] & jm
) === 0 && j
< 26; ++j
, jm
<<= 1);
13127 if (C
.isOdd() || D
.isOdd()) {
13137 if (x
.cmp(y
) >= 0) {
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());
13165 if (a
.negative
!== 0) {
13171 var x1
= new BN(1);
13172 var x2
= new BN(0);
13174 var delta
= b
.clone();
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);
13189 for (var j
= 0, jm
= 1; (b
.words
[0] & jm
) === 0 && j
< 26; ++j
, jm
<<= 1);
13201 if (a
.cmp(b
) >= 0) {
13211 if (a
.cmpn(1) === 0) {
13217 if (res
.cmpn(0) < 0) {
13224 BN
.prototype.gcd
= function gcd (num
) {
13225 if (this.isZero()) return num
.abs();
13226 if (num
.isZero()) return this.abs();
13228 var a
= this.clone();
13229 var b
= num
.clone();
13233 // Remove common factor of two
13234 for (var shift
= 0; a
.isEven() && b
.isEven(); shift
++) {
13240 while (a
.isEven()) {
13243 while (b
.isEven()) {
13249 // Swap `a` and `b` to make `a` always bigger than `b`
13253 } else if (r
=== 0 || b
.cmpn(1) === 0) {
13260 return b
.iushln(shift
);
13263 // Invert number in the field F(num)
13264 BN
.prototype.invm
= function invm (num
) {
13265 return this.egcd(num
).a
.umod(num
);
13268 BN
.prototype.isEven
= function isEven () {
13269 return (this.words
[0] & 1) === 0;
13272 BN
.prototype.isOdd
= function isOdd () {
13273 return (this.words
[0] & 1) === 1;
13276 // And first word and num
13277 BN
.prototype.andln
= function andln (num
) {
13278 return this.words
[0] & num
;
13281 // Increment at the bit position in-line
13282 BN
.prototype.bincn
= function bincn (bit
) {
13283 assert(typeof bit
=== 'number');
13285 var s
= (bit
- r
) / 26;
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
;
13295 // Add bit and propagate, if needed
13297 for (var i
= s
; carry
!== 0 && i
< this.length
; i
++) {
13298 var w
= this.words
[i
] | 0;
13305 this.words
[i
] = carry
;
13311 BN
.prototype.isZero
= function isZero () {
13312 return this.length
=== 1 && this.words
[0] === 0;
13315 BN
.prototype.cmpn
= function cmpn (num
) {
13316 var negative
= num
< 0;
13318 if (this.negative
!== 0 && !negative
) return -1;
13319 if (this.negative
=== 0 && negative
) return 1;
13324 if (this.length
> 1) {
13331 assert(num
<= 0x3ffffff, 'Number is too big');
13333 var w
= this.words
[0] | 0;
13334 res
= w
=== num
? 0 : w
< num
? -1 : 1;
13336 if (this.negative
!== 0) return -res
| 0;
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;
13348 var res
= this.ucmp(num
);
13349 if (this.negative
!== 0) return -res
| 0;
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;
13360 for (var i
= this.length
- 1; i
>= 0; i
--) {
13361 var a
= this.words
[i
] | 0;
13362 var b
= num
.words
[i
] | 0;
13364 if (a
=== b
) continue;
13367 } else if (a
> b
) {
13375 BN
.prototype.gtn
= function gtn (num
) {
13376 return this.cmpn(num
) === 1;
13379 BN
.prototype.gt
= function gt (num
) {
13380 return this.cmp(num
) === 1;
13383 BN
.prototype.gten
= function gten (num
) {
13384 return this.cmpn(num
) >= 0;
13387 BN
.prototype.gte
= function gte (num
) {
13388 return this.cmp(num
) >= 0;
13391 BN
.prototype.ltn
= function ltn (num
) {
13392 return this.cmpn(num
) === -1;
13395 BN
.prototype.lt
= function lt (num
) {
13396 return this.cmp(num
) === -1;
13399 BN
.prototype.lten
= function lten (num
) {
13400 return this.cmpn(num
) <= 0;
13403 BN
.prototype.lte
= function lte (num
) {
13404 return this.cmp(num
) <= 0;
13407 BN
.prototype.eqn
= function eqn (num
) {
13408 return this.cmpn(num
) === 0;
13411 BN
.prototype.eq
= function eq (num
) {
13412 return this.cmp(num
) === 0;
13416 // A reduce context, could be using montgomery or something better, depending
13417 // on the `m` itself.
13419 BN
.red
= function red (num
) {
13420 return new Red(num
);
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
);
13429 BN
.prototype.fromRed
= function fromRed () {
13430 assert(this.red
, 'fromRed works only with numbers in reduction context');
13431 return this.red
.convertFrom(this);
13434 BN
.prototype._forceRed
= function _forceRed (ctx
) {
13439 BN
.prototype.forceRed
= function forceRed (ctx
) {
13440 assert(!this.red
, 'Already a number in reduction context');
13441 return this._forceRed(ctx
);
13444 BN
.prototype.redAdd
= function redAdd (num
) {
13445 assert(this.red
, 'redAdd works only with red numbers');
13446 return this.red
.add(this, num
);
13449 BN
.prototype.redIAdd
= function redIAdd (num
) {
13450 assert(this.red
, 'redIAdd works only with red numbers');
13451 return this.red
.iadd(this, num
);
13454 BN
.prototype.redSub
= function redSub (num
) {
13455 assert(this.red
, 'redSub works only with red numbers');
13456 return this.red
.sub(this, num
);
13459 BN
.prototype.redISub
= function redISub (num
) {
13460 assert(this.red
, 'redISub works only with red numbers');
13461 return this.red
.isub(this, num
);
13464 BN
.prototype.redShl
= function redShl (num
) {
13465 assert(this.red
, 'redShl works only with red numbers');
13466 return this.red
.shl(this, num
);
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
);
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
);
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);
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);
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);
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);
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);
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
);
13519 // Prime numbers with efficient reduction
13527 // Pseudo-Mersenne prime
13528 function MPrime (name
, p
) {
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
);
13535 this.tmp
= this._tmp();
13538 MPrime
.prototype._tmp
= function _tmp () {
13539 var tmp
= new BN(null);
13540 tmp
.words
= new Array(Math
.ceil(this.n
/ 13));
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)
13551 this.split(r
, this.tmp
);
13553 r
= r
.iadd(this.tmp
);
13554 rlen
= r
.bitLength();
13555 } while (rlen
> this.n
);
13557 var cmp
= rlen
< this.n
? -1 : r
.ucmp(this.p
);
13561 } else if (cmp
> 0) {
13570 MPrime
.prototype.split
= function split (input
, out
) {
13571 input
.iushrn(this.n
, 0, out
);
13574 MPrime
.prototype.imulK
= function imulK (num
) {
13575 return num
.imul(this.k
);
13582 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');
13584 inherits(K256
, MPrime
);
13586 K256
.prototype.split
= function split (input
, output
) {
13587 // 256 = 9 * 26 + 22
13588 var mask
= 0x3fffff;
13590 var outLen
= Math
.min(input
.length
, 9);
13591 for (var i
= 0; i
< outLen
; i
++) {
13592 output
.words
[i
] = input
.words
[i
];
13594 output
.length
= outLen
;
13596 if (input
.length
<= 9) {
13597 input
.words
[0] = 0;
13602 // Shift by 9 limbs
13603 var prev
= input
.words
[9];
13604 output
.words
[output
.length
++] = prev
& mask
;
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);
13612 input
.words
[i
- 10] = prev
;
13613 if (prev
=== 0 && input
.length
> 10) {
13614 input
.length
-= 10;
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;
13626 // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390
13628 for (var i
= 0; i
< num
.length
; i
++) {
13629 var w
= num
.words
[i
] | 0;
13631 num
.words
[i
] = lo
& 0x3ffffff;
13632 lo
= w
* 0x40 + ((lo
/ 0x4000000) | 0);
13635 // Fast length reduction
13636 if (num
.words
[num
.length
- 1] === 0) {
13638 if (num
.words
[num
.length
- 1] === 0) {
13649 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');
13651 inherits(P224
, MPrime
);
13657 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');
13659 inherits(P192
, MPrime
);
13661 function P25519 () {
13666 '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');
13668 inherits(P25519
, MPrime
);
13670 P25519
.prototype.imulK
= function imulK (num
) {
13673 for (var i
= 0; i
< num
.length
; i
++) {
13674 var hi
= (num
.words
[i
] | 0) * 0x13 + carry
;
13675 var lo
= hi
& 0x3ffffff;
13682 num
.words
[num
.length
++] = carry
;
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
];
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();
13702 throw new Error('Unknown prime ' + name
);
13704 primes
[name
] = prime
;
13710 // Base reduction engine
13713 if (typeof m
=== 'string') {
13714 var prime
= BN
._prime(m
);
13716 this.prime
= prime
;
13718 assert(m
.gtn(1), 'modulus must be greater than 1');
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');
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');
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);
13740 Red
.prototype.neg
= function neg (a
) {
13745 return this.m
.sub(a
)._forceRed(this);
13748 Red
.prototype.add
= function add (a
, b
) {
13749 this._verify2(a
, b
);
13751 var res
= a
.add(b
);
13752 if (res
.cmp(this.m
) >= 0) {
13755 return res
._forceRed(this);
13758 Red
.prototype.iadd
= function iadd (a
, b
) {
13759 this._verify2(a
, b
);
13761 var res
= a
.iadd(b
);
13762 if (res
.cmp(this.m
) >= 0) {
13768 Red
.prototype.sub
= function sub (a
, b
) {
13769 this._verify2(a
, b
);
13771 var res
= a
.sub(b
);
13772 if (res
.cmpn(0) < 0) {
13775 return res
._forceRed(this);
13778 Red
.prototype.isub
= function isub (a
, b
) {
13779 this._verify2(a
, b
);
13781 var res
= a
.isub(b
);
13782 if (res
.cmpn(0) < 0) {
13788 Red
.prototype.shl
= function shl (a
, num
) {
13790 return this.imod(a
.ushln(num
));
13793 Red
.prototype.imul
= function imul (a
, b
) {
13794 this._verify2(a
, b
);
13795 return this.imod(a
.imul(b
));
13798 Red
.prototype.mul
= function mul (a
, b
) {
13799 this._verify2(a
, b
);
13800 return this.imod(a
.mul(b
));
13803 Red
.prototype.isqr
= function isqr (a
) {
13804 return this.imul(a
, a
.clone());
13807 Red
.prototype.sqr
= function sqr (a
) {
13808 return this.mul(a
, a
);
13811 Red
.prototype.sqrt
= function sqrt (a
) {
13812 if (a
.isZero()) return a
.clone();
13814 var mod3
= this.m
.andln(3);
13815 assert(mod3
% 2 === 1);
13819 var pow
= this.m
.add(new BN(1)).iushrn(2);
13820 return this.pow(a
, pow
);
13823 // Tonelli-Shanks algorithm (Totally unoptimized and slow)
13825 // Find Q and S, that Q * 2 ^ S = (P - 1)
13826 var q
= this.m
.subn(1);
13828 while (!q
.isZero() && q
.andln(1) === 0) {
13832 assert(!q
.isZero());
13834 var one
= new BN(1).toRed(this);
13835 var nOne
= one
.redNeg();
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);
13843 while (this.pow(z
, lpow
).cmp(nOne
) !== 0) {
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
);
13851 while (t
.cmp(one
) !== 0) {
13853 for (var i
= 0; tmp
.cmp(one
) !== 0; i
++) {
13854 tmp
= tmp
.redSqr();
13857 var b
= this.pow(c
, new BN(1).iushln(m
- i
- 1));
13868 Red
.prototype.invm
= function invm (a
) {
13869 var inv
= a
._invmp(this.m
);
13870 if (inv
.negative
!== 0) {
13872 return this.imod(inv
).redNeg();
13874 return this.imod(inv
);
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();
13882 var windowSize
= 4;
13883 var wnd
= new Array(1 << windowSize
);
13884 wnd
[0] = new BN(1).toRed(this);
13886 for (var i
= 2; i
< wnd
.length
; i
++) {
13887 wnd
[i
] = this.mul(wnd
[i
- 1], a
);
13892 var currentLen
= 0;
13893 var start
= num
.bitLength() % 26;
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
);
13906 if (bit
=== 0 && current
=== 0) {
13914 if (currentLen
!== windowSize
&& (i
!== 0 || j
!== 0)) continue;
13916 res
= this.mul(res
, wnd
[current
]);
13926 Red
.prototype.convertTo
= function convertTo (num
) {
13927 var r
= num
.umod(this.m
);
13929 return r
=== num
? r
.clone() : r
;
13932 Red
.prototype.convertFrom
= function convertFrom (num
) {
13933 var res
= num
.clone();
13939 // Montgomery method engine
13942 BN
.mont
= function mont (num
) {
13943 return new Mont(num
);
13946 function Mont (m
) {
13949 this.shift
= this.m
.bitLength();
13950 if (this.shift
% 26 !== 0) {
13951 this.shift
+= 26 - (this.shift
% 26);
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
);
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
);
13962 inherits(Mont
, Red
);
13964 Mont
.prototype.convertTo
= function convertTo (num
) {
13965 return this.imod(num
.ushln(this.shift
));
13968 Mont
.prototype.convertFrom
= function convertFrom (num
) {
13969 var r
= this.imod(num
.mul(this.rinv
));
13974 Mont
.prototype.imul
= function imul (a
, b
) {
13975 if (a
.isZero() || b
.isZero()) {
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
);
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
);
13992 return res
._forceRed(this);
13995 Mont
.prototype.mul
= function mul (a
, b
) {
13996 if (a
.isZero() || b
.isZero()) return new BN(0)._forceRed(this);
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
);
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
);
14008 return res
._forceRed(this);
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);
14016 })(typeof module
=== 'undefined' || module
, this);
14018 },{"buffer":81}],80:[function(require
,module
,exports
){
14021 module
.exports
= function rand(len
) {
14023 r
= new Rand(null);
14025 return r
.generate(len
);
14028 function Rand(rand
) {
14031 module
.exports
.Rand
= Rand
;
14033 Rand
.prototype.generate
= function generate(len
) {
14034 return this._rand(len
);
14037 // Emulate crypto API using randy
14038 Rand
.prototype._rand
= function _rand(n
) {
14039 if (this.rand
.getBytes
)
14040 return this.rand
.getBytes(n
);
14042 var res
= new Uint8Array(n
);
14043 for (var i
= 0; i
< res
.length
; i
++)
14044 res
[i
] = this.rand
.getByte();
14048 if (typeof self
=== 'object') {
14049 if (self
.crypto
&& self
.crypto
.getRandomValues
) {
14051 Rand
.prototype._rand
= function _rand(n
) {
14052 var arr
= new Uint8Array(n
);
14053 self
.crypto
.getRandomValues(arr
);
14056 } else if (self
.msCrypto
&& self
.msCrypto
.getRandomValues
) {
14058 Rand
.prototype._rand
= function _rand(n
) {
14059 var arr
= new Uint8Array(n
);
14060 self
.msCrypto
.getRandomValues(arr
);
14064 // Safari's WebWorkers do not have `crypto`
14065 } else if (typeof window
=== 'object') {
14067 Rand
.prototype._rand = function() {
14068 throw new Error('Not implemented yet');
14072 // Node.js or Web worker with no crypto support
14074 var crypto
= require('crypto');
14075 if (typeof crypto
.randomBytes
!== 'function')
14076 throw new Error('Not supported');
14078 Rand
.prototype._rand
= function _rand(n
) {
14079 return crypto
.randomBytes(n
);
14085 },{"crypto":81}],81:[function(require
,module
,exports
){
14087 },{}],82:[function(require
,module
,exports
){
14088 arguments
[4][7][0].apply(exports
,arguments
)
14089 },{"dup":7,"safe-buffer":206}],83:[function(require
,module
,exports
){
14090 arguments
[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
){
14092 arguments
[4][9][0].apply(exports
,arguments
)
14093 },{"./decrypter":85,"./encrypter":86,"./modes/list.json":96,"dup":9}],85:[function(require
,module
,exports
){
14094 arguments
[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
){
14096 arguments
[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
){
14098 arguments
[4][12][0].apply(exports
,arguments
)
14099 },{"dup":12,"safe-buffer":206}],88:[function(require
,module
,exports
){
14100 arguments
[4][13][0].apply(exports
,arguments
)
14101 },{"dup":13}],89:[function(require
,module
,exports
){
14102 arguments
[4][14][0].apply(exports
,arguments
)
14103 },{"buffer-xor":109,"dup":14}],90:[function(require
,module
,exports
){
14104 arguments
[4][15][0].apply(exports
,arguments
)
14105 },{"buffer-xor":109,"dup":15,"safe-buffer":206}],91:[function(require
,module
,exports
){
14106 arguments
[4][16][0].apply(exports
,arguments
)
14107 },{"dup":16,"safe-buffer":206}],92:[function(require
,module
,exports
){
14108 arguments
[4][17][0].apply(exports
,arguments
)
14109 },{"dup":17,"safe-buffer":206}],93:[function(require
,module
,exports
){
14110 arguments
[4][18][0].apply(exports
,arguments
)
14111 },{"../incr32":88,"buffer-xor":109,"dup":18,"safe-buffer":206}],94:[function(require
,module
,exports
){
14112 arguments
[4][19][0].apply(exports
,arguments
)
14113 },{"dup":19}],95:[function(require
,module
,exports
){
14114 arguments
[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
){
14116 arguments
[4][21][0].apply(exports
,arguments
)
14117 },{"dup":21}],97:[function(require
,module
,exports
){
14118 arguments
[4][22][0].apply(exports
,arguments
)
14119 },{"buffer":110,"buffer-xor":109,"dup":22}],98:[function(require
,module
,exports
){
14120 arguments
[4][23][0].apply(exports
,arguments
)
14121 },{"./aes":82,"cipher-base":111,"dup":23,"inherits":162,"safe-buffer":206}],99:[function(require
,module
,exports
){
14122 var DES
= require('browserify-des')
14123 var aes
= require('browserify-aes/browser')
14124 var aesModes
= require('browserify-aes/modes')
14125 var desModes
= require('browserify-des/modes')
14126 var ebtk
= require('evp_bytestokey')
14128 function createCipher (suite
, password
) {
14129 suite
= suite
.toLowerCase()
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
14139 throw new TypeError('invalid suite type')
14142 var keys
= ebtk(password
, false, keyLen
, ivLen
)
14143 return createCipheriv(suite
, keys
.key
, keys
.iv
)
14146 function createDecipher (suite
, password
) {
14147 suite
= suite
.toLowerCase()
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
14157 throw new TypeError('invalid suite type')
14160 var keys
= ebtk(password
, false, keyLen
, ivLen
)
14161 return createDecipheriv(suite
, keys
.key
, keys
.iv
)
14164 function 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
})
14169 throw new TypeError('invalid suite type')
14172 function 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 })
14177 throw new TypeError('invalid suite type')
14180 function getCiphers () {
14181 return Object
.keys(desModes
).concat(aes
.getCiphers())
14184 exports
.createCipher
= exports
.Cipher
= createCipher
14185 exports
.createCipheriv
= exports
.Cipheriv
= createCipheriv
14186 exports
.createDecipher
= exports
.Decipher
= createDecipher
14187 exports
.createDecipheriv
= exports
.Decipheriv
= createDecipheriv
14188 exports
.listCiphers
= exports
.getCiphers
= getCiphers
14190 },{"browserify-aes/browser":84,"browserify-aes/modes":95,"browserify-des":100,"browserify-des/modes":101,"evp_bytestokey":146}],100:[function(require
,module
,exports
){
14191 var CipherBase
= require('cipher-base')
14192 var des
= require('des.js')
14193 var inherits
= require('inherits')
14194 var Buffer
= require('safe-buffer').Buffer
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
),
14204 modes
.des
= modes
['des-cbc']
14205 modes
.des3
= modes
['des-ede3-cbc']
14206 module
.exports
= DES
14207 inherits(DES
, CipherBase
)
14208 function DES (opts
) {
14209 CipherBase
.call(this)
14210 var modeName
= opts
.mode
.toLowerCase()
14211 var mode
= modes
[modeName
]
14213 if (opts
.decrypt
) {
14219 if (!Buffer
.isBuffer(key
)) {
14220 key
= Buffer
.from(key
)
14222 if (modeName
=== 'des-ede' || modeName
=== 'des-ede-cbc') {
14223 key
= Buffer
.concat([key
, key
.slice(0, 8)])
14226 if (!Buffer
.isBuffer(iv
)) {
14227 iv
= Buffer
.from(iv
)
14229 this._des
= mode
.create({
14235 DES
.prototype._update = function (data
) {
14236 return Buffer
.from(this._des
.update(data
))
14238 DES
.prototype._final = function () {
14239 return Buffer
.from(this._des
.final())
14242 },{"cipher-base":111,"des.js":119,"inherits":162,"safe-buffer":206}],101:[function(require
,module
,exports
){
14243 exports
['des-ecb'] = {
14247 exports
['des-cbc'] = exports
.des
= {
14251 exports
['des-ede3-cbc'] = exports
.des3
= {
14255 exports
['des-ede3'] = {
14259 exports
['des-ede-cbc'] = {
14263 exports
['des-ede'] = {
14268 },{}],102:[function(require
,module
,exports
){
14269 (function (Buffer
){
14270 var bn
= require('bn.js');
14271 var randomBytes
= require('randombytes');
14272 module
.exports
= crt
;
14273 function blind(priv
) {
14274 var r
= getr(priv
);
14275 var blinder
= r
.toRed(bn
.mont(priv
.modulus
))
14276 .redPow(new bn(priv
.publicExponent
)).fromRed();
14279 unblinder:r
.invm(priv
.modulus
)
14282 function 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
);
14296 var h
= m1
.isub(m2
).imul(qinv
).umod(p
);
14299 return new Buffer(m2
.imul(blinds
.unblinder
).umod(priv
.modulus
).toArray(false, len
));
14302 function 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
));
14311 }).call(this,require("buffer").Buffer
)
14312 },{"bn.js":79,"buffer":110,"randombytes":188}],103:[function(require
,module
,exports
){
14313 module
.exports
= require('./browser/algorithms.json')
14315 },{"./browser/algorithms.json":104}],104:[function(require
,module
,exports
){
14317 "sha224WithRSAEncryption": {
14320 "id": "302d300d06096086480165030402040500041c"
14323 "sign": "ecdsa/rsa",
14325 "id": "302d300d06096086480165030402040500041c"
14327 "sha256WithRSAEncryption": {
14330 "id": "3031300d060960864801650304020105000420"
14333 "sign": "ecdsa/rsa",
14335 "id": "3031300d060960864801650304020105000420"
14337 "sha384WithRSAEncryption": {
14340 "id": "3041300d060960864801650304020205000430"
14343 "sign": "ecdsa/rsa",
14345 "id": "3041300d060960864801650304020205000430"
14347 "sha512WithRSAEncryption": {
14350 "id": "3051300d060960864801650304020305000440"
14353 "sign": "ecdsa/rsa",
14355 "id": "3051300d060960864801650304020305000440"
14360 "id": "3021300906052b0e03021a05000414"
14362 "ecdsa-with-SHA1": {
14402 "DSA-WITH-SHA224": {
14412 "DSA-WITH-SHA256": {
14422 "DSA-WITH-SHA384": {
14432 "DSA-WITH-SHA512": {
14447 "ripemd160WithRSA": {
14450 "id": "3021300906052b2403020105000414"
14455 "id": "3021300906052b2403020105000414"
14457 "md5WithRSAEncryption": {
14460 "id": "3020300c06082a864886f70d020505000410"
14465 "id": "3020300c06082a864886f70d020505000410"
14469 },{}],105:[function(require
,module
,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"
14479 },{}],106:[function(require
,module
,exports
){
14480 (function (Buffer
){
14481 var createHash
= require('create-hash')
14482 var stream
= require('stream')
14483 var inherits
= require('inherits')
14484 var sign
= require('./sign')
14485 var verify
= require('./verify')
14487 var algorithms
= require('./algorithms.json')
14488 Object
.keys(algorithms
).forEach(function (key
) {
14489 algorithms
[key
].id
= new Buffer(algorithms
[key
].id
, 'hex')
14490 algorithms
[key
.toLowerCase()] = algorithms
[key
]
14493 function Sign (algorithm
) {
14494 stream
.Writable
.call(this)
14496 var data
= algorithms
[algorithm
]
14497 if (!data
) throw new Error('Unknown message digest')
14499 this._hashType
= data
.hash
14500 this._hash
= createHash(data
.hash
)
14501 this._tag
= data
.id
14502 this._signType
= data
.sign
14504 inherits(Sign
, stream
.Writable
)
14506 Sign
.prototype._write
= function _write (data
, _
, done
) {
14507 this._hash
.update(data
)
14511 Sign
.prototype.update
= function update (data
, enc
) {
14512 if (typeof data
=== 'string') data
= new Buffer(data
, enc
)
14514 this._hash
.update(data
)
14518 Sign
.prototype.sign
= function signMethod (key
, enc
) {
14520 var hash
= this._hash
.digest()
14521 var sig
= sign(hash
, key
, this._hashType
, this._signType
, this._tag
)
14523 return enc
? sig
.toString(enc
) : sig
14526 function Verify (algorithm
) {
14527 stream
.Writable
.call(this)
14529 var data
= algorithms
[algorithm
]
14530 if (!data
) throw new Error('Unknown message digest')
14532 this._hash
= createHash(data
.hash
)
14533 this._tag
= data
.id
14534 this._signType
= data
.sign
14536 inherits(Verify
, stream
.Writable
)
14538 Verify
.prototype._write
= function _write (data
, _
, done
) {
14539 this._hash
.update(data
)
14543 Verify
.prototype.update
= function update (data
, enc
) {
14544 if (typeof data
=== 'string') data
= new Buffer(data
, enc
)
14546 this._hash
.update(data
)
14550 Verify
.prototype.verify
= function verifyMethod (key
, sig
, enc
) {
14551 if (typeof sig
=== 'string') sig
= new Buffer(sig
, enc
)
14554 var hash
= this._hash
.digest()
14555 return verify(sig
, hash
, key
, this._signType
, this._tag
)
14558 function createSign (algorithm
) {
14559 return new Sign(algorithm
)
14562 function createVerify (algorithm
) {
14563 return new Verify(algorithm
)
14568 Verify: createVerify
,
14569 createSign: createSign
,
14570 createVerify: createVerify
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
14577 var createHmac
= require('create-hmac')
14578 var crt
= require('browserify-rsa')
14579 var EC
= require('elliptic').ec
14580 var BN
= require('bn.js')
14581 var parseKeys
= require('parse-asn1')
14582 var curves
= require('./curves.json')
14584 function sign (hash
, key
, hashType
, signType
, tag
) {
14585 var priv
= parseKeys(key
)
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
)
14594 if (signType
!== 'rsa' && signType
!== 'ecdsa/rsa') throw new Error('wrong private key type')
14596 hash
= Buffer
.concat([tag
, hash
])
14597 var len
= priv
.modulus
.byteLength()
14599 while (hash
.length
+ pad
.length
+ 1 < len
) pad
.push(0xff)
14602 while (++i
< hash
.length
) pad
.push(hash
[i
])
14604 var out
= crt(pad
, priv
)
14608 function ecSign (hash
, priv
) {
14609 var curveId
= curves
[priv
.curve
.join('.')]
14610 if (!curveId
) throw new Error('unknown curve ' + priv
.curve
.join('.'))
14612 var curve
= new EC(curveId
)
14613 var key
= curve
.keyFromPrivate(priv
.privateKey
)
14614 var out
= key
.sign(hash
)
14616 return new Buffer(out
.toDER())
14619 function 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
14626 var H
= bits2int(hash
, q
).mod(q
)
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) {
14641 function toDER (r
, s
) {
14646 if (r
[0] & 0x80) r
= [ 0 ].concat(r
)
14647 if (s
[0] & 0x80) s
= [ 0 ].concat(s
)
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
)
14655 function 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
)
14660 x
= Buffer
.concat([ zeros
, x
])
14662 var hlen
= hash
.length
14663 var hbits
= bits2octets(hash
, q
)
14664 var v
= new Buffer(hlen
)
14666 var k
= new Buffer(hlen
)
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
}
14675 function bits2int (obits
, q
) {
14676 var bits
= new BN(obits
)
14677 var shift
= (obits
.length
<< 3) - q
.bitLength()
14678 if (shift
> 0) bits
.ishrn(shift
)
14682 function bits2octets (bits
, q
) {
14683 bits
= bits2int(bits
, q
)
14685 var out
= new Buffer(bits
.toArray())
14686 if (out
.length
< q
.byteLength()) {
14687 var zeros
= new Buffer(q
.byteLength() - out
.length
)
14689 out
= Buffer
.concat([ zeros
, out
])
14694 function makeKey (q
, kv
, algo
) {
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
])
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)
14714 function makeR (g
, k
, p
, q
) {
14715 return g
.toRed(BN
.mont(p
)).redPow(k
).fromRed().mod(q
)
14718 module
.exports
= sign
14719 module
.exports
.getKey
= getKey
14720 module
.exports
.makeKey
= makeKey
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
14726 var BN
= require('bn.js')
14727 var EC
= require('elliptic').ec
14728 var parseKeys
= require('parse-asn1')
14729 var curves
= require('./curves.json')
14731 function 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
)
14741 if (signType
!== 'rsa' && signType
!== 'ecdsa/rsa') throw new Error('wrong public key type')
14743 hash
= Buffer
.concat([tag
, hash
])
14744 var len
= pub
.modulus
.byteLength()
14747 while (hash
.length
+ pad
.length
+ 2 < len
) {
14753 while (++i
< hash
.length
) {
14756 pad
= new Buffer(pad
)
14757 var red
= BN
.mont(pub
.modulus
)
14758 sig
= new BN(sig
).toRed(red
)
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
14767 while (++i
< len
) out
|= sig
[i
] ^ pad
[i
]
14771 function 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('.'))
14775 var curve
= new EC(curveId
)
14776 var pubkey
= pub
.data
.subjectPrivateKey
.data
14778 return curve
.verify(hash
, sig
, pubkey
)
14781 function dsaVerify (sig
, hash
, pub
) {
14785 var y
= pub
.data
.pub_key
14786 var unpacked
= parseKeys
.signature
.decode(sig
, 'der')
14791 var montp
= BN
.mont(p
)
14793 var v
= g
.toRed(montp
)
14794 .redPow(new BN(hash
).mul(w
).mod(q
))
14796 .mul(y
.toRed(montp
).redPow(r
.mul(w
).mod(q
)).fromRed())
14799 return v
.cmp(r
) === 0
14802 function 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')
14807 module
.exports
= verify
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
){
14811 arguments
[4][29][0].apply(exports
,arguments
)
14812 },{"buffer":110,"dup":29}],110:[function(require
,module
,exports
){
14813 (function (Buffer
){
14815 * The buffer module from node.js, for the browser.
14817 * @author Feross Aboukhadijeh <https://feross.org>
14820 /* eslint-disable no-proto */
14824 var base64
= require('base64-js')
14825 var ieee754
= require('ieee754')
14826 var customInspectSymbol
=
14827 (typeof Symbol
=== 'function' && typeof Symbol
.for === 'function')
14828 ? Symbol
.for('nodejs.util.inspect.custom')
14831 exports
.Buffer
= Buffer
14832 exports
.SlowBuffer
= SlowBuffer
14833 exports
.INSPECT_MAX_BYTES
= 50
14835 var K_MAX_LENGTH
= 0x7fffffff
14836 exports
.kMaxLength
= K_MAX_LENGTH
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)
14844 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
14845 * Opera 11.6+, iOS 4.2+.
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.
14852 Buffer
.TYPED_ARRAY_SUPPORT
= typedArraySupport()
14854 if (!Buffer
.TYPED_ARRAY_SUPPORT
&& typeof console
!== 'undefined' &&
14855 typeof console
.error
=== 'function') {
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.'
14862 function typedArraySupport () {
14863 // Can typed array instances can be augmented?
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
14875 Object
.defineProperty(Buffer
.prototype, 'parent', {
14878 if (!Buffer
.isBuffer(this)) return undefined
14883 Object
.defineProperty(Buffer
.prototype, 'offset', {
14886 if (!Buffer
.isBuffer(this)) return undefined
14887 return this.byteOffset
14891 function createBuffer (length
) {
14892 if (length
> K_MAX_LENGTH
) {
14893 throw new RangeError('The value "' + length
+ '" is invalid for option "size"')
14895 // Return an augmented `Uint8Array` instance
14896 var buf
= new Uint8Array(length
)
14897 Object
.setPrototypeOf(buf
, Buffer
.prototype)
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.
14908 * The `Uint8Array` prototype remains unmodified.
14911 function Buffer (arg
, encodingOrOffset
, length
) {
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'
14919 return allocUnsafe(arg
)
14921 return from(arg
, encodingOrOffset
, length
)
14924 // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
14925 if (typeof Symbol
!== 'undefined' && Symbol
.species
!= null &&
14926 Buffer
[Symbol
.species
] === Buffer
) {
14927 Object
.defineProperty(Buffer
, Symbol
.species
, {
14929 configurable: true,
14935 Buffer
.poolSize
= 8192 // not used by this implementation
14937 function from (value
, encodingOrOffset
, length
) {
14938 if (typeof value
=== 'string') {
14939 return fromString(value
, encodingOrOffset
)
14942 if (ArrayBuffer
.isView(value
)) {
14943 return fromArrayLike(value
)
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
)
14953 if (isInstance(value
, ArrayBuffer
) ||
14954 (value
&& isInstance(value
.buffer
, ArrayBuffer
))) {
14955 return fromArrayBuffer(value
, encodingOrOffset
, length
)
14958 if (typeof value
=== 'number') {
14959 throw new TypeError(
14960 'The "value" argument must not be of type number. Received type number'
14964 var valueOf
= value
.valueOf
&& value
.valueOf()
14965 if (valueOf
!= null && valueOf
!== value
) {
14966 return Buffer
.from(valueOf
, encodingOrOffset
, length
)
14969 var b
= fromObject(value
)
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
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
)
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]])
14993 Buffer
.from = function (value
, encodingOrOffset
, length
) {
14994 return from(value
, encodingOrOffset
, length
)
14997 // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
14998 // https://github.com/feross/buffer/pull/148
14999 Object
.setPrototypeOf(Buffer
.prototype, Uint8Array
.prototype)
15000 Object
.setPrototypeOf(Buffer
, Uint8Array
)
15002 function 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"')
15010 function alloc (size
, fill
, encoding
) {
15013 return createBuffer(size
)
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
)
15023 return createBuffer(size
)
15027 * Creates a new filled Buffer instance.
15028 * alloc(size[, fill[, encoding]])
15030 Buffer
.alloc = function (size
, fill
, encoding
) {
15031 return alloc(size
, fill
, encoding
)
15034 function allocUnsafe (size
) {
15036 return createBuffer(size
< 0 ? 0 : checked(size
) | 0)
15040 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
15042 Buffer
.allocUnsafe = function (size
) {
15043 return allocUnsafe(size
)
15046 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
15048 Buffer
.allocUnsafeSlow = function (size
) {
15049 return allocUnsafe(size
)
15052 function fromString (string
, encoding
) {
15053 if (typeof encoding
!== 'string' || encoding
=== '') {
15057 if (!Buffer
.isEncoding(encoding
)) {
15058 throw new TypeError('Unknown encoding: ' + encoding
)
15061 var length
= byteLength(string
, encoding
) | 0
15062 var buf
= createBuffer(length
)
15064 var actual
= buf
.write(string
, encoding
)
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
)
15076 function 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
15085 function fromArrayBuffer (array
, byteOffset
, length
) {
15086 if (byteOffset
< 0 || array
.byteLength
< byteOffset
) {
15087 throw new RangeError('"offset" is outside of buffer bounds')
15090 if (array
.byteLength
< byteOffset
+ (length
|| 0)) {
15091 throw new RangeError('"length" is outside of buffer bounds')
15095 if (byteOffset
=== undefined && length
=== undefined) {
15096 buf
= new Uint8Array(array
)
15097 } else if (length
=== undefined) {
15098 buf
= new Uint8Array(array
, byteOffset
)
15100 buf
= new Uint8Array(array
, byteOffset
, length
)
15103 // Return an augmented `Uint8Array` instance
15104 Object
.setPrototypeOf(buf
, Buffer
.prototype)
15109 function fromObject (obj
) {
15110 if (Buffer
.isBuffer(obj
)) {
15111 var len
= checked(obj
.length
) | 0
15112 var buf
= createBuffer(len
)
15114 if (buf
.length
=== 0) {
15118 obj
.copy(buf
, 0, 0, len
)
15122 if (obj
.length
!== undefined) {
15123 if (typeof obj
.length
!== 'number' || numberIsNaN(obj
.length
)) {
15124 return createBuffer(0)
15126 return fromArrayLike(obj
)
15129 if (obj
.type
=== 'Buffer' && Array
.isArray(obj
.data
)) {
15130 return fromArrayLike(obj
.data
)
15134 function 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')
15144 function SlowBuffer (length
) {
15145 if (+length
!= length
) { // eslint-disable-line eqeqeq
15148 return Buffer
.alloc(+length
)
15151 Buffer
.isBuffer
= function isBuffer (b
) {
15152 return b
!= null && b
._isBuffer
=== true &&
15153 b
!== Buffer
.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
15156 Buffer
.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'
15165 if (a
=== b
) return 0
15170 for (var i
= 0, len
= Math
.min(x
, y
); i
< len
; ++i
) {
15171 if (a
[i
] !== b
[i
]) {
15178 if (x
< y
) return -1
15179 if (y
< x
) return 1
15183 Buffer
.isEncoding
= function isEncoding (encoding
) {
15184 switch (String(encoding
).toLowerCase()) {
15202 Buffer
.concat
= function concat (list
, length
) {
15203 if (!Array
.isArray(list
)) {
15204 throw new TypeError('"list" argument must be an Array of Buffers')
15207 if (list
.length
=== 0) {
15208 return Buffer
.alloc(0)
15212 if (length
=== undefined) {
15214 for (i
= 0; i
< list
.length
; ++i
) {
15215 length
+= list
[i
].length
15219 var buffer
= Buffer
.allocUnsafe(length
)
15221 for (i
= 0; i
< list
.length
; ++i
) {
15223 if (isInstance(buf
, Uint8Array
)) {
15224 buf
= Buffer
.from(buf
)
15226 if (!Buffer
.isBuffer(buf
)) {
15227 throw new TypeError('"list" argument must be an Array of Buffers')
15229 buf
.copy(buffer
, pos
)
15235 function byteLength (string
, encoding
) {
15236 if (Buffer
.isBuffer(string
)) {
15237 return string
.length
15239 if (ArrayBuffer
.isView(string
) || isInstance(string
, ArrayBuffer
)) {
15240 return string
.byteLength
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
15249 var len
= string
.length
15250 var mustMatch
= (arguments
.length
> 2 && arguments
[2] === true)
15251 if (!mustMatch
&& len
=== 0) return 0
15253 // Use a for loop to avoid recursion
15254 var loweredCase
= false
15256 switch (encoding
) {
15263 return utf8ToBytes(string
).length
15272 return base64ToBytes(string
).length
15275 return mustMatch
? -1 : utf8ToBytes(string
).length
// assume utf8
15277 encoding
= ('' + encoding
).toLowerCase()
15282 Buffer
.byteLength
= byteLength
15284 function slowToString (encoding
, start
, end
) {
15285 var loweredCase
= false
15287 // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
15288 // property of a typed array.
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) {
15297 // Return early if start > this.length. Done here to prevent potential uint32
15298 // coercion fail below.
15299 if (start
> this.length
) {
15303 if (end
=== undefined || end
> this.length
) {
15311 // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
15315 if (end
<= start
) {
15319 if (!encoding
) encoding
= 'utf8'
15322 switch (encoding
) {
15324 return hexSlice(this, start
, end
)
15328 return utf8Slice(this, start
, end
)
15331 return asciiSlice(this, start
, end
)
15335 return latin1Slice(this, start
, end
)
15338 return base64Slice(this, start
, end
)
15344 return utf16leSlice(this, start
, end
)
15347 if (loweredCase
) throw new TypeError('Unknown encoding: ' + encoding
)
15348 encoding
= (encoding
+ '').toLowerCase()
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
15360 Buffer
.prototype._isBuffer
= true
15362 function swap (b
, n
, m
) {
15368 Buffer
.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')
15373 for (var i
= 0; i
< len
; i
+= 2) {
15374 swap(this, i
, i
+ 1)
15379 Buffer
.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')
15384 for (var i
= 0; i
< len
; i
+= 4) {
15385 swap(this, i
, i
+ 3)
15386 swap(this, i
+ 1, i
+ 2)
15391 Buffer
.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')
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)
15405 Buffer
.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
)
15412 Buffer
.prototype.toLocaleString
= Buffer
.prototype.toString
15414 Buffer
.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
15420 Buffer
.prototype.inspect
= function inspect () {
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
+ '>'
15427 if (customInspectSymbol
) {
15428 Buffer
.prototype[customInspectSymbol
] = Buffer
.prototype.inspect
15431 Buffer
.prototype.compare
= function compare (target
, start
, end
, thisStart
, thisEnd
) {
15432 if (isInstance(target
, Uint8Array
)) {
15433 target
= Buffer
.from(target
, target
.offset
, target
.byteLength
)
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
)
15442 if (start
=== undefined) {
15445 if (end
=== undefined) {
15446 end
= target
? target
.length : 0
15448 if (thisStart
=== undefined) {
15451 if (thisEnd
=== undefined) {
15452 thisEnd
= this.length
15455 if (start
< 0 || end
> target
.length
|| thisStart
< 0 || thisEnd
> this.length
) {
15456 throw new RangeError('out of range index')
15459 if (thisStart
>= thisEnd
&& start
>= end
) {
15462 if (thisStart
>= thisEnd
) {
15465 if (start
>= end
) {
15474 if (this === target
) return 0
15476 var x
= thisEnd
- thisStart
15477 var y
= end
- start
15478 var len
= Math
.min(x
, y
)
15480 var thisCopy
= this.slice(thisStart
, thisEnd
)
15481 var targetCopy
= target
.slice(start
, end
)
15483 for (var i
= 0; i
< len
; ++i
) {
15484 if (thisCopy
[i
] !== targetCopy
[i
]) {
15491 if (x
< y
) return -1
15492 if (y
< x
) return 1
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`.
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
15505 function bidirectionalIndexOf (buffer
, val
, byteOffset
, encoding
, dir
) {
15506 // Empty buffer means no match
15507 if (buffer
.length
=== 0) return -1
15509 // Normalize byteOffset
15510 if (typeof byteOffset
=== 'string') {
15511 encoding
= byteOffset
15513 } else if (byteOffset
> 0x7fffffff) {
15514 byteOffset
= 0x7fffffff
15515 } else if (byteOffset
< -0x80000000) {
15516 byteOffset
= -0x80000000
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)
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
) {
15528 else byteOffset
= buffer
.length
- 1
15529 } else if (byteOffset
< 0) {
15530 if (dir
) byteOffset
= 0
15535 if (typeof val
=== 'string') {
15536 val
= Buffer
.from(val
, encoding
)
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) {
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') {
15550 return Uint8Array
.prototype.indexOf
.call(buffer
, val
, byteOffset
)
15552 return Uint8Array
.prototype.lastIndexOf
.call(buffer
, val
, byteOffset
)
15555 return arrayIndexOf(buffer
, [val
], byteOffset
, encoding
, dir
)
15558 throw new TypeError('val must be string, number or Buffer')
15561 function arrayIndexOf (arr
, val
, byteOffset
, encoding
, dir
) {
15563 var arrLength
= arr
.length
15564 var valLength
= val
.length
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) {
15580 function read (buf
, i
) {
15581 if (indexSize
=== 1) {
15584 return buf
.readUInt16BE(i
* indexSize
)
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
15596 if (foundIndex
!== -1) i
-= i
- foundIndex
15601 if (byteOffset
+ valLength
> arrLength
) byteOffset
= arrLength
- valLength
15602 for (i
= byteOffset
; i
>= 0; i
--) {
15604 for (var j
= 0; j
< valLength
; j
++) {
15605 if (read(arr
, i
+ j
) !== read(val
, j
)) {
15610 if (found
) return i
15617 Buffer
.prototype.includes
= function includes (val
, byteOffset
, encoding
) {
15618 return this.indexOf(val
, byteOffset
, encoding
) !== -1
15621 Buffer
.prototype.indexOf
= function indexOf (val
, byteOffset
, encoding
) {
15622 return bidirectionalIndexOf(this, val
, byteOffset
, encoding
, true)
15625 Buffer
.prototype.lastIndexOf
= function lastIndexOf (val
, byteOffset
, encoding
) {
15626 return bidirectionalIndexOf(this, val
, byteOffset
, encoding
, false)
15629 function hexWrite (buf
, string
, offset
, length
) {
15630 offset
= Number(offset
) || 0
15631 var remaining
= buf
.length
- offset
15635 length
= Number(length
)
15636 if (length
> remaining
) {
15641 var strLen
= string
.length
15643 if (length
> strLen
/ 2) {
15644 length
= strLen
/ 2
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
15654 function utf8Write (buf
, string
, offset
, length
) {
15655 return blitBuffer(utf8ToBytes(string
, buf
.length
- offset
), buf
, offset
, length
)
15658 function asciiWrite (buf
, string
, offset
, length
) {
15659 return blitBuffer(asciiToBytes(string
), buf
, offset
, length
)
15662 function latin1Write (buf
, string
, offset
, length
) {
15663 return asciiWrite(buf
, string
, offset
, length
)
15666 function base64Write (buf
, string
, offset
, length
) {
15667 return blitBuffer(base64ToBytes(string
), buf
, offset
, length
)
15670 function ucs2Write (buf
, string
, offset
, length
) {
15671 return blitBuffer(utf16leToBytes(string
, buf
.length
- offset
), buf
, offset
, length
)
15674 Buffer
.prototype.write
= function write (string
, offset
, length
, encoding
) {
15675 // Buffer#write(string)
15676 if (offset
=== undefined) {
15678 length
= this.length
15680 // Buffer#write(string, encoding)
15681 } else if (length
=== undefined && typeof offset
=== 'string') {
15683 length
= this.length
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'
15697 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
15701 var remaining
= this.length
- offset
15702 if (length
=== undefined || length
> remaining
) length
= remaining
15704 if ((string
.length
> 0 && (length
< 0 || offset
< 0)) || offset
> this.length
) {
15705 throw new RangeError('Attempt to write outside buffer bounds')
15708 if (!encoding
) encoding
= 'utf8'
15710 var loweredCase
= false
15712 switch (encoding
) {
15714 return hexWrite(this, string
, offset
, length
)
15718 return utf8Write(this, string
, offset
, length
)
15721 return asciiWrite(this, string
, offset
, length
)
15725 return latin1Write(this, string
, offset
, length
)
15728 // Warning: maxLength not taken into account in base64Write
15729 return base64Write(this, string
, offset
, length
)
15735 return ucs2Write(this, string
, offset
, length
)
15738 if (loweredCase
) throw new TypeError('Unknown encoding: ' + encoding
)
15739 encoding
= ('' + encoding
).toLowerCase()
15745 Buffer
.prototype.toJSON
= function toJSON () {
15748 data: Array
.prototype.slice
.call(this._arr
|| this, 0)
15752 function base64Slice (buf
, start
, end
) {
15753 if (start
=== 0 && end
=== buf
.length
) {
15754 return base64
.fromByteArray(buf
)
15756 return base64
.fromByteArray(buf
.slice(start
, end
))
15760 function utf8Slice (buf
, start
, end
) {
15761 end
= Math
.min(buf
.length
, end
)
15766 var firstByte
= buf
[i
]
15767 var codePoint
= null
15768 var bytesPerSequence
= (firstByte
> 0xEF) ? 4
15769 : (firstByte
> 0xDF) ? 3
15770 : (firstByte
> 0xBF) ? 2
15773 if (i
+ bytesPerSequence
<= end
) {
15774 var secondByte
, thirdByte
, fourthByte
, tempCodePoint
15776 switch (bytesPerSequence
) {
15778 if (firstByte
< 0x80) {
15779 codePoint
= firstByte
15783 secondByte
= buf
[i
+ 1]
15784 if ((secondByte
& 0xC0) === 0x80) {
15785 tempCodePoint
= (firstByte
& 0x1F) << 0x6 | (secondByte
& 0x3F)
15786 if (tempCodePoint
> 0x7F) {
15787 codePoint
= tempCodePoint
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
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
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
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
15826 res
.push(codePoint
)
15827 i
+= bytesPerSequence
15830 return decodeCodePointsArray(res
)
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
15836 var MAX_ARGUMENTS_LENGTH
= 0x1000
15838 function decodeCodePointsArray (codePoints
) {
15839 var len
= codePoints
.length
15840 if (len
<= MAX_ARGUMENTS_LENGTH
) {
15841 return String
.fromCharCode
.apply(String
, codePoints
) // avoid extra slice()
15844 // Decode in chunks to avoid "call stack size exceeded".
15848 res
+= String
.fromCharCode
.apply(
15850 codePoints
.slice(i
, i
+= MAX_ARGUMENTS_LENGTH
)
15856 function asciiSlice (buf
, start
, end
) {
15858 end
= Math
.min(buf
.length
, end
)
15860 for (var i
= start
; i
< end
; ++i
) {
15861 ret
+= String
.fromCharCode(buf
[i
] & 0x7F)
15866 function latin1Slice (buf
, start
, end
) {
15868 end
= Math
.min(buf
.length
, end
)
15870 for (var i
= start
; i
< end
; ++i
) {
15871 ret
+= String
.fromCharCode(buf
[i
])
15876 function hexSlice (buf
, start
, end
) {
15877 var len
= buf
.length
15879 if (!start
|| start
< 0) start
= 0
15880 if (!end
|| end
< 0 || end
> len
) end
= len
15883 for (var i
= start
; i
< end
; ++i
) {
15884 out
+= toHex(buf
[i
])
15889 function utf16leSlice (buf
, start
, end
) {
15890 var bytes
= buf
.slice(start
, end
)
15892 for (var i
= 0; i
< bytes
.length
; i
+= 2) {
15893 res
+= String
.fromCharCode(bytes
[i
] + (bytes
[i
+ 1] * 256))
15898 Buffer
.prototype.slice
= function slice (start
, end
) {
15899 var len
= this.length
15901 end
= end
=== undefined ? len : ~~end
15905 if (start
< 0) start
= 0
15906 } else if (start
> len
) {
15912 if (end
< 0) end
= 0
15913 } else if (end
> len
) {
15917 if (end
< start
) end
= start
15919 var newBuf
= this.subarray(start
, end
)
15920 // Return an augmented `Uint8Array` instance
15921 Object
.setPrototypeOf(newBuf
, Buffer
.prototype)
15927 * Need to make sure that buffer isn't trying to write out of bounds.
15929 function 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')
15934 Buffer
.prototype.readUIntLE
= function readUIntLE (offset
, byteLength
, noAssert
) {
15935 offset
= offset
>>> 0
15936 byteLength
= byteLength
>>> 0
15937 if (!noAssert
) checkOffset(offset
, byteLength
, this.length
)
15939 var val
= this[offset
]
15942 while (++i
< byteLength
&& (mul
*= 0x100)) {
15943 val
+= this[offset
+ i
] * mul
15949 Buffer
.prototype.readUIntBE
= function readUIntBE (offset
, byteLength
, noAssert
) {
15950 offset
= offset
>>> 0
15951 byteLength
= byteLength
>>> 0
15953 checkOffset(offset
, byteLength
, this.length
)
15956 var val
= this[offset
+ --byteLength
]
15958 while (byteLength
> 0 && (mul
*= 0x100)) {
15959 val
+= this[offset
+ --byteLength
] * mul
15965 Buffer
.prototype.readUInt8
= function readUInt8 (offset
, noAssert
) {
15966 offset
= offset
>>> 0
15967 if (!noAssert
) checkOffset(offset
, 1, this.length
)
15968 return this[offset
]
15971 Buffer
.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)
15977 Buffer
.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]
15983 Buffer
.prototype.readUInt32LE
= function readUInt32LE (offset
, noAssert
) {
15984 offset
= offset
>>> 0
15985 if (!noAssert
) checkOffset(offset
, 4, this.length
)
15987 return ((this[offset
]) |
15988 (this[offset
+ 1] << 8) |
15989 (this[offset
+ 2] << 16)) +
15990 (this[offset
+ 3] * 0x1000000)
15993 Buffer
.prototype.readUInt32BE
= function readUInt32BE (offset
, noAssert
) {
15994 offset
= offset
>>> 0
15995 if (!noAssert
) checkOffset(offset
, 4, this.length
)
15997 return (this[offset
] * 0x1000000) +
15998 ((this[offset
+ 1] << 16) |
15999 (this[offset
+ 2] << 8) |
16003 Buffer
.prototype.readIntLE
= function readIntLE (offset
, byteLength
, noAssert
) {
16004 offset
= offset
>>> 0
16005 byteLength
= byteLength
>>> 0
16006 if (!noAssert
) checkOffset(offset
, byteLength
, this.length
)
16008 var val
= this[offset
]
16011 while (++i
< byteLength
&& (mul
*= 0x100)) {
16012 val
+= this[offset
+ i
] * mul
16016 if (val
>= mul
) val
-= Math
.pow(2, 8 * byteLength
)
16021 Buffer
.prototype.readIntBE
= function readIntBE (offset
, byteLength
, noAssert
) {
16022 offset
= offset
>>> 0
16023 byteLength
= byteLength
>>> 0
16024 if (!noAssert
) checkOffset(offset
, byteLength
, this.length
)
16028 var val
= this[offset
+ --i
]
16029 while (i
> 0 && (mul
*= 0x100)) {
16030 val
+= this[offset
+ --i
] * mul
16034 if (val
>= mul
) val
-= Math
.pow(2, 8 * byteLength
)
16039 Buffer
.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)
16046 Buffer
.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
16053 Buffer
.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
16060 Buffer
.prototype.readInt32LE
= function readInt32LE (offset
, noAssert
) {
16061 offset
= offset
>>> 0
16062 if (!noAssert
) checkOffset(offset
, 4, this.length
)
16064 return (this[offset
]) |
16065 (this[offset
+ 1] << 8) |
16066 (this[offset
+ 2] << 16) |
16067 (this[offset
+ 3] << 24)
16070 Buffer
.prototype.readInt32BE
= function readInt32BE (offset
, noAssert
) {
16071 offset
= offset
>>> 0
16072 if (!noAssert
) checkOffset(offset
, 4, this.length
)
16074 return (this[offset
] << 24) |
16075 (this[offset
+ 1] << 16) |
16076 (this[offset
+ 2] << 8) |
16080 Buffer
.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)
16086 Buffer
.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)
16092 Buffer
.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)
16098 Buffer
.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)
16104 function 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')
16110 Buffer
.prototype.writeUIntLE
= function writeUIntLE (value
, offset
, byteLength
, noAssert
) {
16112 offset
= offset
>>> 0
16113 byteLength
= byteLength
>>> 0
16115 var maxBytes
= Math
.pow(2, 8 * byteLength
) - 1
16116 checkInt(this, value
, offset
, byteLength
, maxBytes
, 0)
16121 this[offset
] = value
& 0xFF
16122 while (++i
< byteLength
&& (mul
*= 0x100)) {
16123 this[offset
+ i
] = (value
/ mul
) & 0xFF
16126 return offset
+ byteLength
16129 Buffer
.prototype.writeUIntBE
= function writeUIntBE (value
, offset
, byteLength
, noAssert
) {
16131 offset
= offset
>>> 0
16132 byteLength
= byteLength
>>> 0
16134 var maxBytes
= Math
.pow(2, 8 * byteLength
) - 1
16135 checkInt(this, value
, offset
, byteLength
, maxBytes
, 0)
16138 var i
= byteLength
- 1
16140 this[offset
+ i
] = value
& 0xFF
16141 while (--i
>= 0 && (mul
*= 0x100)) {
16142 this[offset
+ i
] = (value
/ mul
) & 0xFF
16145 return offset
+ byteLength
16148 Buffer
.prototype.writeUInt8
= function writeUInt8 (value
, offset
, noAssert
) {
16150 offset
= offset
>>> 0
16151 if (!noAssert
) checkInt(this, value
, offset
, 1, 0xff, 0)
16152 this[offset
] = (value
& 0xff)
16156 Buffer
.prototype.writeUInt16LE
= function writeUInt16LE (value
, offset
, noAssert
) {
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)
16165 Buffer
.prototype.writeUInt16BE
= function writeUInt16BE (value
, offset
, noAssert
) {
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)
16174 Buffer
.prototype.writeUInt32LE
= function writeUInt32LE (value
, offset
, noAssert
) {
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)
16185 Buffer
.prototype.writeUInt32BE
= function writeUInt32BE (value
, offset
, noAssert
) {
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)
16196 Buffer
.prototype.writeIntLE
= function writeIntLE (value
, offset
, byteLength
, noAssert
) {
16198 offset
= offset
>>> 0
16200 var limit
= Math
.pow(2, (8 * byteLength
) - 1)
16202 checkInt(this, value
, offset
, byteLength
, limit
- 1, -limit
)
16208 this[offset
] = value
& 0xFF
16209 while (++i
< byteLength
&& (mul
*= 0x100)) {
16210 if (value
< 0 && sub
=== 0 && this[offset
+ i
- 1] !== 0) {
16213 this[offset
+ i
] = ((value
/ mul
) >> 0) - sub
& 0xFF
16216 return offset
+ byteLength
16219 Buffer
.prototype.writeIntBE
= function writeIntBE (value
, offset
, byteLength
, noAssert
) {
16221 offset
= offset
>>> 0
16223 var limit
= Math
.pow(2, (8 * byteLength
) - 1)
16225 checkInt(this, value
, offset
, byteLength
, limit
- 1, -limit
)
16228 var i
= byteLength
- 1
16231 this[offset
+ i
] = value
& 0xFF
16232 while (--i
>= 0 && (mul
*= 0x100)) {
16233 if (value
< 0 && sub
=== 0 && this[offset
+ i
+ 1] !== 0) {
16236 this[offset
+ i
] = ((value
/ mul
) >> 0) - sub
& 0xFF
16239 return offset
+ byteLength
16242 Buffer
.prototype.writeInt8
= function writeInt8 (value
, offset
, noAssert
) {
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)
16251 Buffer
.prototype.writeInt16LE
= function writeInt16LE (value
, offset
, noAssert
) {
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)
16260 Buffer
.prototype.writeInt16BE
= function writeInt16BE (value
, offset
, noAssert
) {
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)
16269 Buffer
.prototype.writeInt32LE
= function writeInt32LE (value
, offset
, noAssert
) {
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)
16280 Buffer
.prototype.writeInt32BE
= function writeInt32BE (value
, offset
, noAssert
) {
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)
16292 function 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')
16297 function writeFloat (buf
, value
, offset
, littleEndian
, noAssert
) {
16299 offset
= offset
>>> 0
16301 checkIEEE754(buf
, value
, offset
, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
16303 ieee754
.write(buf
, value
, offset
, littleEndian
, 23, 4)
16307 Buffer
.prototype.writeFloatLE
= function writeFloatLE (value
, offset
, noAssert
) {
16308 return writeFloat(this, value
, offset
, true, noAssert
)
16311 Buffer
.prototype.writeFloatBE
= function writeFloatBE (value
, offset
, noAssert
) {
16312 return writeFloat(this, value
, offset
, false, noAssert
)
16315 function writeDouble (buf
, value
, offset
, littleEndian
, noAssert
) {
16317 offset
= offset
>>> 0
16319 checkIEEE754(buf
, value
, offset
, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
16321 ieee754
.write(buf
, value
, offset
, littleEndian
, 52, 8)
16325 Buffer
.prototype.writeDoubleLE
= function writeDoubleLE (value
, offset
, noAssert
) {
16326 return writeDouble(this, value
, offset
, true, noAssert
)
16329 Buffer
.prototype.writeDoubleBE
= function writeDoubleBE (value
, offset
, noAssert
) {
16330 return writeDouble(this, value
, offset
, false, noAssert
)
16333 // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
16334 Buffer
.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
16342 // Copy 0 bytes; we're done
16343 if (end
=== start
) return 0
16344 if (target
.length
=== 0 || this.length
=== 0) return 0
16346 // Fatal error conditions
16347 if (targetStart
< 0) {
16348 throw new RangeError('targetStart out of bounds')
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')
16354 if (end
> this.length
) end
= this.length
16355 if (target
.length
- targetStart
< end
- start
) {
16356 end
= target
.length
- targetStart
+ start
16359 var len
= end
- start
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
]
16370 Uint8Array
.prototype.set.call(
16372 this.subarray(start
, end
),
16381 // buffer.fill(number[, offset[, end]])
16382 // buffer.fill(buffer[, offset[, end]])
16383 // buffer.fill(string[, offset[, end]][, encoding])
16384 Buffer
.prototype.fill
= function fill (val
, start
, end
, encoding
) {
16385 // Handle string cases:
16386 if (typeof val
=== 'string') {
16387 if (typeof start
=== 'string') {
16391 } else if (typeof end
=== 'string') {
16395 if (encoding
!== undefined && typeof encoding
!== 'string') {
16396 throw new TypeError('encoding must be a string')
16398 if (typeof encoding
=== 'string' && !Buffer
.isEncoding(encoding
)) {
16399 throw new TypeError('Unknown encoding: ' + encoding
)
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.
16409 } else if (typeof val
=== 'number') {
16411 } else if (typeof val
=== 'boolean') {
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')
16420 if (end
<= start
) {
16424 start
= start
>>> 0
16425 end
= end
=== undefined ? this.length : end
>>> 0
16430 if (typeof val
=== 'number') {
16431 for (i
= start
; i
< end
; ++i
) {
16435 var bytes
= Buffer
.isBuffer(val
)
16437 : Buffer
.from(val
, encoding
)
16438 var len
= bytes
.length
16440 throw new TypeError('The value "' + val
+
16441 '" is invalid for argument "value"')
16443 for (i
= 0; i
< end
- start
; ++i
) {
16444 this[i
+ start
] = bytes
[i
% len
]
16451 // HELPER FUNCTIONS
16452 // ================
16454 var INVALID_BASE64_RE
= /[^+/0-9A
-Za
-z
-_
]/g
16456 function 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) {
16470 function toHex (n
) {
16471 if (n
< 16) return '0' + n
.toString(16)
16472 return n
.toString(16)
16475 function utf8ToBytes (string
, units
) {
16476 units
= units
|| Infinity
16478 var length
= string
.length
16479 var leadSurrogate
= null
16482 for (var i
= 0; i
< length
; ++i
) {
16483 codePoint
= string
.charCodeAt(i
)
16485 // is surrogate component
16486 if (codePoint
> 0xD7FF && codePoint
< 0xE000) {
16487 // last char was a lead
16488 if (!leadSurrogate
) {
16490 if (codePoint
> 0xDBFF) {
16491 // unexpected trail
16492 if ((units
-= 3) > -1) bytes
.push(0xEF, 0xBF, 0xBD)
16494 } else if (i
+ 1 === length
) {
16496 if ((units
-= 3) > -1) bytes
.push(0xEF, 0xBF, 0xBD)
16501 leadSurrogate
= codePoint
16506 // 2 leads in a row
16507 if (codePoint
< 0xDC00) {
16508 if ((units
-= 3) > -1) bytes
.push(0xEF, 0xBF, 0xBD)
16509 leadSurrogate
= codePoint
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)
16520 leadSurrogate
= null
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
16529 codePoint
>> 0x6 | 0xC0,
16530 codePoint
& 0x3F | 0x80
16532 } else if (codePoint
< 0x10000) {
16533 if ((units
-= 3) < 0) break
16535 codePoint
>> 0xC | 0xE0,
16536 codePoint
>> 0x6 & 0x3F | 0x80,
16537 codePoint
& 0x3F | 0x80
16539 } else if (codePoint
< 0x110000) {
16540 if ((units
-= 4) < 0) break
16542 codePoint
>> 0x12 | 0xF0,
16543 codePoint
>> 0xC & 0x3F | 0x80,
16544 codePoint
>> 0x6 & 0x3F | 0x80,
16545 codePoint
& 0x3F | 0x80
16548 throw new Error('Invalid code point')
16555 function asciiToBytes (str
) {
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)
16564 function utf16leToBytes (str
, units
) {
16567 for (var i
= 0; i
< str
.length
; ++i
) {
16568 if ((units
-= 2) < 0) break
16570 c
= str
.charCodeAt(i
)
16580 function base64ToBytes (str
) {
16581 return base64
.toByteArray(base64clean(str
))
16584 function 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
]
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
16595 function isInstance (obj
, type
) {
16596 return obj
instanceof type
||
16597 (obj
!= null && obj
.constructor != null && obj
.constructor.name
!= null &&
16598 obj
.constructor.name
=== type
.name
)
16600 function numberIsNaN (obj
) {
16601 // For IE11 support
16602 return obj
!== obj
// eslint-disable-line no-self-compare
16605 }).call(this,require("buffer").Buffer
)
16606 },{"base64-js":78,"buffer":110,"ieee754":161}],111:[function(require
,module
,exports
){
16607 arguments
[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.
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:
16620 // The above copyright notice and this permission notice shall be included
16621 // in all copies or substantial portions of the Software.
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.
16631 // NOTE: These type checking functions intentionally don't use `instanceof`
16632 // because it is fragile and can be easily faked with `Object.create()`.
16634 function isArray(arg
) {
16635 if (Array
.isArray
) {
16636 return Array
.isArray(arg
);
16638 return objectToString(arg
) === '[object Array]';
16640 exports
.isArray
= isArray
;
16642 function isBoolean(arg
) {
16643 return typeof arg
=== 'boolean';
16645 exports
.isBoolean
= isBoolean
;
16647 function isNull(arg
) {
16648 return arg
=== null;
16650 exports
.isNull
= isNull
;
16652 function isNullOrUndefined(arg
) {
16653 return arg
== null;
16655 exports
.isNullOrUndefined
= isNullOrUndefined
;
16657 function isNumber(arg
) {
16658 return typeof arg
=== 'number';
16660 exports
.isNumber
= isNumber
;
16662 function isString(arg
) {
16663 return typeof arg
=== 'string';
16665 exports
.isString
= isString
;
16667 function isSymbol(arg
) {
16668 return typeof arg
=== 'symbol';
16670 exports
.isSymbol
= isSymbol
;
16672 function isUndefined(arg
) {
16673 return arg
=== void 0;
16675 exports
.isUndefined
= isUndefined
;
16677 function isRegExp(re
) {
16678 return objectToString(re
) === '[object RegExp]';
16680 exports
.isRegExp
= isRegExp
;
16682 function isObject(arg
) {
16683 return typeof arg
=== 'object' && arg
!== null;
16685 exports
.isObject
= isObject
;
16687 function isDate(d
) {
16688 return objectToString(d
) === '[object Date]';
16690 exports
.isDate
= isDate
;
16692 function isError(e
) {
16693 return (objectToString(e
) === '[object Error]' || e
instanceof Error
);
16695 exports
.isError
= isError
;
16697 function isFunction(arg
) {
16698 return typeof arg
=== 'function';
16700 exports
.isFunction
= isFunction
;
16702 function 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';
16710 exports
.isPrimitive
= isPrimitive
;
16712 exports
.isBuffer
= Buffer
.isBuffer
;
16714 function objectToString(o
) {
16715 return Object
.prototype.toString
.call(o
);
16718 }).call(this,{"isBuffer":require("../../is-buffer/index.js")})
16719 },{"../../is-buffer/index.js":163}],113:[function(require
,module
,exports
){
16720 (function (Buffer
){
16721 var elliptic
= require('elliptic')
16722 var BN
= require('bn.js')
16724 module
.exports
= function createECDH (curve
) {
16725 return new ECDH(curve
)
16759 aliases
.p224
= aliases
.secp224r1
16760 aliases
.p256
= aliases
.secp256r1
= aliases
.prime256v1
16761 aliases
.p192
= aliases
.secp192r1
= aliases
.prime192v1
16762 aliases
.p384
= aliases
.secp384r1
16763 aliases
.p521
= aliases
.secp521r1
16765 function ECDH (curve
) {
16766 this.curveType
= aliases
[curve
]
16767 if (!this.curveType
) {
16772 this.curve
= new elliptic
.ec(this.curveType
.name
) // eslint-disable-line new-cap
16776 ECDH
.prototype.generateKeys = function (enc
, format
) {
16777 this.keys
= this.curve
.genKeyPair()
16778 return this.getPublicKey(enc
, format
)
16781 ECDH
.prototype.computeSecret = function (other
, inenc
, enc
) {
16782 inenc
= inenc
|| 'utf8'
16783 if (!Buffer
.isBuffer(other
)) {
16784 other
= new Buffer(other
, inenc
)
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
)
16791 ECDH
.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) {
16800 return formatReturnValue(key
, enc
)
16803 ECDH
.prototype.getPrivateKey = function (enc
) {
16804 return formatReturnValue(this.keys
.getPrivate(), enc
)
16807 ECDH
.prototype.setPublicKey = function (pub
, enc
) {
16808 enc
= enc
|| 'utf8'
16809 if (!Buffer
.isBuffer(pub
)) {
16810 pub
= new Buffer(pub
, enc
)
16812 this.keys
._importPublic(pub
)
16816 ECDH
.prototype.setPrivateKey = function (priv
, enc
) {
16817 enc
= enc
|| 'utf8'
16818 if (!Buffer
.isBuffer(priv
)) {
16819 priv
= new Buffer(priv
, enc
)
16822 var _priv
= new BN(priv
)
16823 _priv
= _priv
.toString(16)
16824 this.keys
= this.curve
.genKeyPair()
16825 this.keys
._importPrivate(_priv
)
16829 function formatReturnValue (bn
, enc
, len
) {
16830 if (!Array
.isArray(bn
)) {
16833 var buf
= new Buffer(bn
)
16834 if (len
&& buf
.length
< len
) {
16835 var zeros
= new Buffer(len
- buf
.length
)
16837 buf
= Buffer
.concat([zeros
, buf
])
16842 return buf
.toString(enc
)
16846 }).call(this,require("buffer").Buffer
)
16847 },{"bn.js":79,"buffer":110,"elliptic":129}],114:[function(require
,module
,exports
){
16848 arguments
[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
){
16850 var MD5
= require('md5.js')
16852 module
.exports = function (buffer
) {
16853 return new MD5().update(buffer
).digest()
16856 },{"md5.js":165}],116:[function(require
,module
,exports
){
16858 var inherits
= require('inherits')
16859 var Legacy
= require('./legacy')
16860 var Base
= require('cipher-base')
16861 var Buffer
= require('safe-buffer').Buffer
16862 var md5
= require('create-hash/md5')
16863 var RIPEMD160
= require('ripemd160')
16865 var sha
= require('sha.js')
16867 var ZEROS
= Buffer
.alloc(128)
16869 function Hmac (alg
, key
) {
16870 Base
.call(this, 'digest')
16871 if (typeof key
=== 'string') {
16872 key
= Buffer
.from(key
)
16875 var blocksize
= (alg
=== 'sha512' || alg
=== 'sha384') ? 128 : 64
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
)
16886 var ipad
= this._ipad
= Buffer
.allocUnsafe(blocksize
)
16887 var opad
= this._opad
= Buffer
.allocUnsafe(blocksize
)
16889 for (var i
= 0; i
< blocksize
; i
++) {
16890 ipad
[i
] = key
[i
] ^ 0x36
16891 opad
[i
] = key
[i
] ^ 0x5C
16893 this._hash
= alg
=== 'rmd160' ? new RIPEMD160() : sha(alg
)
16894 this._hash
.update(ipad
)
16897 inherits(Hmac
, Base
)
16899 Hmac
.prototype._update = function (data
) {
16900 this._hash
.update(data
)
16903 Hmac
.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()
16909 module
.exports
= function createHmac (alg
, key
) {
16910 alg
= alg
.toLowerCase()
16911 if (alg
=== 'rmd160' || alg
=== 'ripemd160') {
16912 return new Hmac('rmd160', key
)
16914 if (alg
=== 'md5') {
16915 return new Legacy(md5
, key
)
16917 return new Hmac(alg
, key
)
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
){
16922 var inherits
= require('inherits')
16923 var Buffer
= require('safe-buffer').Buffer
16925 var Base
= require('cipher-base')
16927 var ZEROS
= Buffer
.alloc(128)
16930 function Hmac (alg
, key
) {
16931 Base
.call(this, 'digest')
16932 if (typeof key
=== 'string') {
16933 key
= Buffer
.from(key
)
16939 if (key
.length
> blocksize
) {
16941 } else if (key
.length
< blocksize
) {
16942 key
= Buffer
.concat([key
, ZEROS
], blocksize
)
16945 var ipad
= this._ipad
= Buffer
.allocUnsafe(blocksize
)
16946 var opad
= this._opad
= Buffer
.allocUnsafe(blocksize
)
16948 for (var i
= 0; i
< blocksize
; i
++) {
16949 ipad
[i
] = key
[i
] ^ 0x36
16950 opad
[i
] = key
[i
] ^ 0x5C
16953 this._hash
= [ipad
]
16956 inherits(Hmac
, Base
)
16958 Hmac
.prototype._update = function (data
) {
16959 this._hash
.push(data
)
16962 Hmac
.prototype._final = function () {
16963 var h
= this._alg(Buffer
.concat(this._hash
))
16964 return this._alg(Buffer
.concat([this._opad
, h
]))
16966 module
.exports
= Hmac
16968 },{"cipher-base":111,"inherits":162,"safe-buffer":206}],118:[function(require
,module
,exports
){
16971 exports
.randomBytes
= exports
.rng
= exports
.pseudoRandomBytes
= exports
.prng
= require('randombytes')
16972 exports
.createHash
= exports
.Hash
= require('create-hash')
16973 exports
.createHmac
= exports
.Hmac
= require('create-hmac')
16975 var algos
= require('browserify-sign/algos')
16976 var algoKeys
= Object
.keys(algos
)
16977 var hashes
= ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160'].concat(algoKeys
)
16978 exports
.getHashes = function () {
16982 var p
= require('pbkdf2')
16983 exports
.pbkdf2
= p
.pbkdf2
16984 exports
.pbkdf2Sync
= p
.pbkdf2Sync
16986 var aes
= require('browserify-cipher')
16988 exports
.Cipher
= aes
.Cipher
16989 exports
.createCipher
= aes
.createCipher
16990 exports
.Cipheriv
= aes
.Cipheriv
16991 exports
.createCipheriv
= aes
.createCipheriv
16992 exports
.Decipher
= aes
.Decipher
16993 exports
.createDecipher
= aes
.createDecipher
16994 exports
.Decipheriv
= aes
.Decipheriv
16995 exports
.createDecipheriv
= aes
.createDecipheriv
16996 exports
.getCiphers
= aes
.getCiphers
16997 exports
.listCiphers
= aes
.listCiphers
16999 var dh
= require('diffie-hellman')
17001 exports
.DiffieHellmanGroup
= dh
.DiffieHellmanGroup
17002 exports
.createDiffieHellmanGroup
= dh
.createDiffieHellmanGroup
17003 exports
.getDiffieHellman
= dh
.getDiffieHellman
17004 exports
.createDiffieHellman
= dh
.createDiffieHellman
17005 exports
.DiffieHellman
= dh
.DiffieHellman
17007 var sign
= require('browserify-sign')
17009 exports
.createSign
= sign
.createSign
17010 exports
.Sign
= sign
.Sign
17011 exports
.createVerify
= sign
.createVerify
17012 exports
.Verify
= sign
.Verify
17014 exports
.createECDH
= require('create-ecdh')
17016 var publicEncrypt
= require('public-encrypt')
17018 exports
.publicEncrypt
= publicEncrypt
.publicEncrypt
17019 exports
.privateEncrypt
= publicEncrypt
.privateEncrypt
17020 exports
.publicDecrypt
= publicEncrypt
.publicDecrypt
17021 exports
.privateDecrypt
= publicEncrypt
.privateDecrypt
17023 // the least I can do is make error messages for the rest of the node.js/crypto api.
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'
17036 var rf
= require('randomfill')
17038 exports
.randomFill
= rf
.randomFill
17039 exports
.randomFillSync
= rf
.randomFillSync
17041 exports
.createCredentials = function () {
17043 'sorry, createCredentials is not implemented yet',
17044 'we accept pull requests',
17045 'https://github.com/crypto-browserify/crypto-browserify'
17049 exports
.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,
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
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
){
17070 exports
.utils
= require('./des/utils');
17071 exports
.Cipher
= require('./des/cipher');
17072 exports
.DES
= require('./des/des');
17073 exports
.CBC
= require('./des/cbc');
17074 exports
.EDE
= require('./des/ede');
17076 },{"./des/cbc":120,"./des/cipher":121,"./des/des":122,"./des/ede":123,"./des/utils":124}],120:[function(require
,module
,exports
){
17079 var assert
= require('minimalistic-assert');
17080 var inherits
= require('inherits');
17084 function CBCState(iv
) {
17085 assert
.equal(iv
.length
, 8, 'Invalid IV length');
17087 this.iv
= new Array(8);
17088 for (var i
= 0; i
< this.iv
.length
; i
++)
17089 this.iv
[i
] = iv
[i
];
17092 function instantiate(Base
) {
17093 function CBC(options
) {
17094 Base
.call(this, options
);
17097 inherits(CBC
, Base
);
17099 var keys
= Object
.keys(proto
);
17100 for (var i
= 0; i
< keys
.length
; i
++) {
17102 CBC
.prototype[key
] = proto
[key
];
17105 CBC
.create
= function create(options
) {
17106 return new CBC(options
);
17112 exports
.instantiate
= instantiate
;
17114 proto
._cbcInit
= function _cbcInit() {
17115 var state
= new CBCState(this.options
.iv
);
17116 this._cbcState
= state
;
17119 proto
._update
= function _update(inp
, inOff
, out
, outOff
) {
17120 var state
= this._cbcState
;
17121 var superProto
= this.constructor.super_
.prototype;
17124 if (this.type
=== 'encrypt') {
17125 for (var i
= 0; i
< this.blockSize
; i
++)
17126 iv
[i
] ^= inp
[inOff
+ i
];
17128 superProto
._update
.call(this, iv
, 0, out
, outOff
);
17130 for (var i
= 0; i
< this.blockSize
; i
++)
17131 iv
[i
] = out
[outOff
+ i
];
17133 superProto
._update
.call(this, inp
, inOff
, out
, outOff
);
17135 for (var i
= 0; i
< this.blockSize
; i
++)
17136 out
[outOff
+ i
] ^= iv
[i
];
17138 for (var i
= 0; i
< this.blockSize
; i
++)
17139 iv
[i
] = inp
[inOff
+ i
];
17143 },{"inherits":162,"minimalistic-assert":167}],121:[function(require
,module
,exports
){
17146 var assert
= require('minimalistic-assert');
17148 function Cipher(options
) {
17149 this.options
= options
;
17151 this.type
= this.options
.type
;
17152 this.blockSize
= 8;
17155 this.buffer
= new Array(this.blockSize
);
17156 this.bufferOff
= 0;
17158 module
.exports
= Cipher
;
17160 Cipher
.prototype._init
= function _init() {
17161 // Might be overrided
17164 Cipher
.prototype.update
= function update(data
) {
17165 if (data
.length
=== 0)
17168 if (this.type
=== 'decrypt')
17169 return this._updateDecrypt(data
);
17171 return this._updateEncrypt(data
);
17174 Cipher
.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
;
17185 Cipher
.prototype._flushBuffer
= function _flushBuffer(out
, off
) {
17186 this._update(this.buffer
, 0, out
, off
);
17187 this.bufferOff
= 0;
17188 return this.blockSize
;
17191 Cipher
.prototype._updateEncrypt
= function _updateEncrypt(data
) {
17195 var count
= ((this.bufferOff
+ data
.length
) / this.blockSize
) | 0;
17196 var out
= new Array(count
* this.blockSize
);
17198 if (this.bufferOff
!== 0) {
17199 inputOff
+= this._buffer(data
, inputOff
);
17201 if (this.bufferOff
=== this.buffer
.length
)
17202 outputOff
+= this._flushBuffer(out
, outputOff
);
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
;
17213 for (; inputOff
< data
.length
; inputOff
++, this.bufferOff
++)
17214 this.buffer
[this.bufferOff
] = data
[inputOff
];
17219 Cipher
.prototype._updateDecrypt
= function _updateDecrypt(data
) {
17223 var count
= Math
.ceil((this.bufferOff
+ data
.length
) / this.blockSize
) - 1;
17224 var out
= new Array(count
* this.blockSize
);
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
);
17232 // Buffer rest of the input
17233 inputOff
+= this._buffer(data
, inputOff
);
17238 Cipher
.prototype.final
= function final(buffer
) {
17241 first
= this.update(buffer
);
17244 if (this.type
=== 'encrypt')
17245 last
= this._finalEncrypt();
17247 last
= this._finalDecrypt();
17250 return first
.concat(last
);
17255 Cipher
.prototype._pad
= function _pad(buffer
, off
) {
17259 while (off
< buffer
.length
)
17265 Cipher
.prototype._finalEncrypt
= function _finalEncrypt() {
17266 if (!this._pad(this.buffer
, this.bufferOff
))
17269 var out
= new Array(this.blockSize
);
17270 this._update(this.buffer
, 0, out
, 0);
17274 Cipher
.prototype._unpad
= function _unpad(buffer
) {
17278 Cipher
.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);
17283 return this._unpad(out
);
17286 },{"minimalistic-assert":167}],122:[function(require
,module
,exports
){
17289 var assert
= require('minimalistic-assert');
17290 var inherits
= require('inherits');
17292 var des
= require('../des');
17293 var utils
= des
.utils
;
17294 var Cipher
= des
.Cipher
;
17296 function DESState() {
17297 this.tmp
= new Array(2);
17301 function DES(options
) {
17302 Cipher
.call(this, options
);
17304 var state
= new DESState();
17305 this._desState
= state
;
17307 this.deriveKeys(state
, options
.key
);
17309 inherits(DES
, Cipher
);
17310 module
.exports
= DES
;
17312 DES
.create
= function create(options
) {
17313 return new DES(options
);
17317 1, 1, 2, 2, 2, 2, 2, 2,
17318 1, 2, 2, 2, 2, 2, 2, 1
17321 DES
.prototype.deriveKeys
= function deriveKeys(state
, key
) {
17322 state
.keys
= new Array(16 * 2);
17324 assert
.equal(key
.length
, this.blockSize
, 'Invalid key length');
17326 var kL
= utils
.readUInt32BE(key
, 0);
17327 var kR
= utils
.readUInt32BE(key
, 4);
17329 utils
.pc1(kL
, kR
, state
.tmp
, 0);
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
);
17340 DES
.prototype._update
= function _update(inp
, inOff
, out
, outOff
) {
17341 var state
= this._desState
;
17343 var l
= utils
.readUInt32BE(inp
, inOff
);
17344 var r
= utils
.readUInt32BE(inp
, inOff
+ 4);
17346 // Initial Permutation
17347 utils
.ip(l
, r
, state
.tmp
, 0);
17351 if (this.type
=== 'encrypt')
17352 this._encrypt(state
, l
, r
, state
.tmp
, 0);
17354 this._decrypt(state
, l
, r
, state
.tmp
, 0);
17359 utils
.writeUInt32BE(out
, l
, outOff
);
17360 utils
.writeUInt32BE(out
, r
, outOff
+ 4);
17363 DES
.prototype._pad
= function _pad(buffer
, off
) {
17364 var value
= buffer
.length
- off
;
17365 for (var i
= off
; i
< buffer
.length
; i
++)
17371 DES
.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
);
17376 return buffer
.slice(0, buffer
.length
- pad
);
17379 DES
.prototype._encrypt
= function _encrypt(state
, lStart
, rStart
, out
, off
) {
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];
17389 utils
.expand(r
, state
.tmp
, 0);
17391 keyL
^= state
.tmp
[0];
17392 keyR
^= state
.tmp
[1];
17393 var s
= utils
.substitute(keyL
, keyR
);
17394 var f
= utils
.permute(s
);
17401 // Reverse Initial Permutation
17402 utils
.rip(r
, l
, out
, off
);
17405 DES
.prototype._decrypt
= function _decrypt(state
, lStart
, rStart
, out
, off
) {
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];
17415 utils
.expand(l
, state
.tmp
, 0);
17417 keyL
^= state
.tmp
[0];
17418 keyR
^= state
.tmp
[1];
17419 var s
= utils
.substitute(keyL
, keyR
);
17420 var f
= utils
.permute(s
);
17427 // Reverse Initial Permutation
17428 utils
.rip(l
, r
, out
, off
);
17431 },{"../des":119,"inherits":162,"minimalistic-assert":167}],123:[function(require
,module
,exports
){
17434 var assert
= require('minimalistic-assert');
17435 var inherits
= require('inherits');
17437 var des
= require('../des');
17438 var Cipher
= des
.Cipher
;
17441 function EDEState(type
, key
) {
17442 assert
.equal(key
.length
, 24, 'Invalid key length');
17444 var k1
= key
.slice(0, 8);
17445 var k2
= key
.slice(8, 16);
17446 var k3
= key
.slice(16, 24);
17448 if (type
=== 'encrypt') {
17450 DES
.create({ type: 'encrypt', key: k1
}),
17451 DES
.create({ type: 'decrypt', key: k2
}),
17452 DES
.create({ type: 'encrypt', key: k3
})
17456 DES
.create({ type: 'decrypt', key: k3
}),
17457 DES
.create({ type: 'encrypt', key: k2
}),
17458 DES
.create({ type: 'decrypt', key: k1
})
17463 function EDE(options
) {
17464 Cipher
.call(this, options
);
17466 var state
= new EDEState(this.type
, this.options
.key
);
17467 this._edeState
= state
;
17469 inherits(EDE
, Cipher
);
17471 module
.exports
= EDE
;
17473 EDE
.create
= function create(options
) {
17474 return new EDE(options
);
17477 EDE
.prototype._update
= function _update(inp
, inOff
, out
, outOff
) {
17478 var state
= this._edeState
;
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
);
17485 EDE
.prototype._pad
= DES
.prototype._pad
;
17486 EDE
.prototype._unpad
= DES
.prototype._unpad
;
17488 },{"../des":119,"inherits":162,"minimalistic-assert":167}],124:[function(require
,module
,exports
){
17491 exports
.readUInt32BE
= function readUInt32BE(bytes
, off
) {
17492 var res
= (bytes
[0 + off
] << 24) |
17493 (bytes
[1 + off
] << 16) |
17494 (bytes
[2 + off
] << 8) |
17499 exports
.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;
17506 exports
.ip
= function ip(inL
, inR
, out
, off
) {
17510 for (var i
= 6; i
>= 0; i
-= 2) {
17511 for (var j
= 0; j
<= 24; j
+= 8) {
17513 outL
|= (inR
>>> (j
+ i
)) & 1;
17515 for (var j
= 0; j
<= 24; j
+= 8) {
17517 outL
|= (inL
>>> (j
+ i
)) & 1;
17521 for (var i
= 6; i
>= 0; i
-= 2) {
17522 for (var j
= 1; j
<= 25; j
+= 8) {
17524 outR
|= (inR
>>> (j
+ i
)) & 1;
17526 for (var j
= 1; j
<= 25; j
+= 8) {
17528 outR
|= (inL
>>> (j
+ i
)) & 1;
17532 out
[off
+ 0] = outL
>>> 0;
17533 out
[off
+ 1] = outR
>>> 0;
17536 exports
.rip
= function rip(inL
, inR
, out
, off
) {
17540 for (var i
= 0; i
< 4; i
++) {
17541 for (var j
= 24; j
>= 0; j
-= 8) {
17543 outL
|= (inR
>>> (j
+ i
)) & 1;
17545 outL
|= (inL
>>> (j
+ i
)) & 1;
17548 for (var i
= 4; i
< 8; i
++) {
17549 for (var j
= 24; j
>= 0; j
-= 8) {
17551 outR
|= (inR
>>> (j
+ i
)) & 1;
17553 outR
|= (inL
>>> (j
+ i
)) & 1;
17557 out
[off
+ 0] = outL
>>> 0;
17558 out
[off
+ 1] = outR
>>> 0;
17561 exports
.pc1
= function pc1(inL
, inR
, out
, off
) {
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
17569 for (var i
= 7; i
>= 5; i
--) {
17570 for (var j
= 0; j
<= 24; j
+= 8) {
17572 outL
|= (inR
>> (j
+ i
)) & 1;
17574 for (var j
= 0; j
<= 24; j
+= 8) {
17576 outL
|= (inL
>> (j
+ i
)) & 1;
17579 for (var j
= 0; j
<= 24; j
+= 8) {
17581 outL
|= (inR
>> (j
+ i
)) & 1;
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
17588 for (var i
= 1; i
<= 3; i
++) {
17589 for (var j
= 0; j
<= 24; j
+= 8) {
17591 outR
|= (inR
>> (j
+ i
)) & 1;
17593 for (var j
= 0; j
<= 24; j
+= 8) {
17595 outR
|= (inL
>> (j
+ i
)) & 1;
17598 for (var j
= 0; j
<= 24; j
+= 8) {
17600 outR
|= (inL
>> (j
+ i
)) & 1;
17603 out
[off
+ 0] = outL
>>> 0;
17604 out
[off
+ 1] = outR
>>> 0;
17607 exports
.r28shl
= function r28shl(num
, shift
) {
17608 return ((num
<< shift
) & 0xfffffff) | (num
>>> (28 - shift
));
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,
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
17623 exports
.pc2
= function pc2(inL
, inR
, out
, off
) {
17627 var len
= pc2table
.length
>>> 1;
17628 for (var i
= 0; i
< len
; i
++) {
17630 outL
|= (inL
>>> pc2table
[i
]) & 0x1;
17632 for (var i
= len
; i
< pc2table
.length
; i
++) {
17634 outR
|= (inR
>>> pc2table
[i
]) & 0x1;
17637 out
[off
+ 0] = outL
>>> 0;
17638 out
[off
+ 1] = outR
>>> 0;
17641 exports
.expand
= function expand(r
, out
, off
) {
17645 outL
= ((r
& 1) << 5) | (r
>>> 27);
17646 for (var i
= 23; i
>= 15; i
-= 4) {
17648 outL
|= (r
>>> i
) & 0x3f;
17650 for (var i
= 11; i
>= 3; i
-= 4) {
17651 outR
|= (r
>>> i
) & 0x3f;
17654 outR
|= ((r
& 0x1f) << 1) | (r
>>> 31);
17656 out
[off
+ 0] = outL
>>> 0;
17657 out
[off
+ 1] = outR
>>> 0;
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,
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,
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,
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,
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,
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,
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,
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
17702 exports
.substitute
= function substitute(inL
, inR
) {
17704 for (var i
= 0; i
< 4; i
++) {
17705 var b
= (inL
>>> (18 - i
* 6)) & 0x3f;
17706 var sb
= sTable
[i
* 0x40 + b
];
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
];
17721 var 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
17726 exports
.permute
= function permute(num
) {
17728 for (var i
= 0; i
< permuteTable
.length
; i
++) {
17730 out
|= (num
>>> permuteTable
[i
]) & 0x1;
17735 exports
.padSplit
= function padSplit(num
, size
, group
) {
17736 var str
= num
.toString(2);
17737 while (str
.length
< size
)
17741 for (var i
= 0; i
< size
; i
+= group
)
17742 out
.push(str
.slice(i
, i
+ group
));
17743 return out
.join(' ');
17746 },{}],125:[function(require
,module
,exports
){
17747 (function (Buffer
){
17748 var generatePrime
= require('./lib/generatePrime')
17749 var primes
= require('./lib/primes.json')
17751 var DH
= require('./lib/dh')
17753 function getDiffieHellman (mod
) {
17754 var prime
= new Buffer(primes
[mod
].prime
, 'hex')
17755 var gen
= new Buffer(primes
[mod
].gen
, 'hex')
17757 return new DH(prime
, gen
)
17761 'binary': true, 'hex': true, 'base64': true
17764 function createDiffieHellman (prime
, enc
, generator
, genc
) {
17765 if (Buffer
.isBuffer(enc
) || ENCODINGS
[enc
] === undefined) {
17766 return createDiffieHellman(prime
, 'binary', enc
, generator
)
17769 enc
= enc
|| 'binary'
17770 genc
= genc
|| 'binary'
17771 generator
= generator
|| new Buffer([2])
17773 if (!Buffer
.isBuffer(generator
)) {
17774 generator
= new Buffer(generator
, genc
)
17777 if (typeof prime
=== 'number') {
17778 return new DH(generatePrime(prime
, generator
), generator
, true)
17781 if (!Buffer
.isBuffer(prime
)) {
17782 prime
= new Buffer(prime
, enc
)
17785 return new DH(prime
, generator
, true)
17788 exports
.DiffieHellmanGroup
= exports
.createDiffieHellmanGroup
= exports
.getDiffieHellman
= getDiffieHellman
17789 exports
.createDiffieHellman
= exports
.DiffieHellman
= createDiffieHellman
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
){
17794 var BN
= require('bn.js');
17795 var MillerRabin
= require('miller-rabin');
17796 var millerRabin
= new MillerRabin();
17797 var TWENTYFOUR
= new BN(24);
17798 var ELEVEN
= new BN(11);
17799 var TEN
= new BN(10);
17800 var THREE
= new BN(3);
17801 var SEVEN
= new BN(7);
17802 var primes
= require('./generatePrime');
17803 var randomBytes
= require('randombytes');
17804 module
.exports
= DH
;
17806 function setPublicKey(pub
, enc
) {
17807 enc
= enc
|| 'utf8';
17808 if (!Buffer
.isBuffer(pub
)) {
17809 pub
= new Buffer(pub
, enc
);
17811 this._pub
= new BN(pub
);
17815 function setPrivateKey(priv
, enc
) {
17816 enc
= enc
|| 'utf8';
17817 if (!Buffer
.isBuffer(priv
)) {
17818 priv
= new Buffer(priv
, enc
);
17820 this._priv
= new BN(priv
);
17824 var primeCache
= {};
17825 function 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
];
17833 if (prime
.isEven() ||
17834 !primes
.simpleSieve
||
17835 !primes
.fermatTest(prime
) ||
17836 !millerRabin
.test(prime
)) {
17837 //not a prime so +1
17840 if (gen
=== '02' || gen
=== '05') {
17841 // we'd be able to check the generator
17842 // it would fail so +8
17845 //we wouldn't be able to test the generator
17849 primeCache
[hex
] = error
;
17852 if (!millerRabin
.test(prime
.shrn(1))) {
17859 if (prime
.mod(TWENTYFOUR
).cmp(ELEVEN
)) {
17860 // unsuidable generator
17865 rem
= prime
.mod(TEN
);
17866 if (rem
.cmp(THREE
) && rem
.cmp(SEVEN
)) {
17867 // prime mod 10 needs to equal 3 or 7
17874 primeCache
[hex
] = error
;
17878 function 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;
17887 this.setPublicKey
= setPublicKey
;
17888 this.setPrivateKey
= setPrivateKey
;
17890 this._primeCode
= 8;
17893 Object
.defineProperty(DH
.prototype, 'verifyError', {
17896 if (typeof this._primeCode
!== 'number') {
17897 this._primeCode
= checkPrime(this.__prime
, this.__gen
);
17899 return this._primeCode
;
17902 DH
.prototype.generateKeys = function () {
17904 this._priv
= new BN(randomBytes(this._primeLen
));
17906 this._pub
= this._gen
.toRed(this._prime
).redPow(this._priv
).fromRed();
17907 return this.getPublicKey();
17910 DH
.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
);
17919 out
= Buffer
.concat([front
, out
]);
17924 DH
.prototype.getPublicKey
= function getPublicKey(enc
) {
17925 return formatReturnValue(this._pub
, enc
);
17928 DH
.prototype.getPrivateKey
= function getPrivateKey(enc
) {
17929 return formatReturnValue(this._priv
, enc
);
17932 DH
.prototype.getPrime = function (enc
) {
17933 return formatReturnValue(this.__prime
, enc
);
17936 DH
.prototype.getGenerator = function (enc
) {
17937 return formatReturnValue(this._gen
, enc
);
17940 DH
.prototype.setGenerator = function (gen
, enc
) {
17941 enc
= enc
|| 'utf8';
17942 if (!Buffer
.isBuffer(gen
)) {
17943 gen
= new Buffer(gen
, enc
);
17946 this._gen
= new BN(gen
);
17950 function formatReturnValue(bn
, enc
) {
17951 var buf
= new Buffer(bn
.toArray());
17955 return buf
.toString(enc
);
17959 }).call(this,require("buffer").Buffer
)
17960 },{"./generatePrime":127,"bn.js":79,"buffer":110,"miller-rabin":166,"randombytes":188}],127:[function(require
,module
,exports
){
17961 var randomBytes
= require('randombytes');
17962 module
.exports
= findPrime
;
17963 findPrime
.simpleSieve
= simpleSieve
;
17964 findPrime
.fermatTest
= fermatTest
;
17965 var BN
= require('bn.js');
17966 var TWENTYFOUR
= new BN(24);
17967 var MillerRabin
= require('miller-rabin');
17968 var millerRabin
= new MillerRabin();
17969 var ONE
= new BN(1);
17970 var TWO
= new BN(2);
17971 var FIVE
= new BN(5);
17972 var SIXTEEN
= new BN(16);
17973 var EIGHT
= new BN(8);
17974 var TEN
= new BN(10);
17975 var THREE
= new BN(3);
17976 var SEVEN
= new BN(7);
17977 var ELEVEN
= new BN(11);
17978 var FOUR
= new BN(4);
17979 var TWELVE
= new BN(12);
17982 function _getPrimes() {
17983 if (primes
!== null)
17986 var limit
= 0x100000;
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)
17995 if (i
!== j
&& res
[j
] <= sqrt
)
18004 function simpleSieve(p
) {
18005 var primes
= _getPrimes();
18007 for (var i
= 0; i
< primes
.length
; i
++)
18008 if (p
.modn(primes
[i
]) === 0) {
18009 if (p
.cmpn(primes
[i
]) === 0) {
18019 function fermatTest(p
) {
18020 var red
= BN
.mont(p
);
18021 return TWO
.toRed(red
).redPow(p
.subn(1)).fromRed().cmpn(1) === 0;
18024 function findPrime(bits
, gen
) {
18026 // this is what openssl does
18027 if (gen
=== 2 || gen
=== 5) {
18028 return new BN([0x8c, 0x7b]);
18030 return new BN([0x8c, 0x27]);
18038 num
= new BN(randomBytes(Math
.ceil(bits
/ 8)));
18039 while (num
.bitLength() > bits
) {
18042 if (num
.isEven()) {
18045 if (!num
.testn(1)) {
18048 if (!gen
.cmp(TWO
)) {
18049 while (num
.mod(TWENTYFOUR
).cmp(ELEVEN
)) {
18052 } else if (!gen
.cmp(FIVE
)) {
18053 while (num
.mod(TEN
).cmp(THREE
)) {
18058 if (simpleSieve(n2
) && simpleSieve(num
) &&
18059 fermatTest(n2
) && fermatTest(num
) &&
18060 millerRabin
.test(n2
) && millerRabin
.test(num
)) {
18067 },{"bn.js":79,"miller-rabin":166,"randombytes":188}],128:[function(require
,module
,exports
){
18071 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"
18075 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"
18079 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"
18083 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"
18087 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"
18091 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"
18095 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"
18099 "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"
18102 },{}],129:[function(require
,module
,exports
){
18105 var elliptic
= exports
;
18107 elliptic
.version
= require('../package.json').version
;
18108 elliptic
.utils
= require('./elliptic/utils');
18109 elliptic
.rand
= require('brorand');
18110 elliptic
.curve
= require('./elliptic/curve');
18111 elliptic
.curves
= require('./elliptic/curves');
18114 elliptic
.ec
= require('./elliptic/ec');
18115 elliptic
.eddsa
= require('./elliptic/eddsa');
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
){
18120 var BN
= require('bn.js');
18121 var utils
= require('../utils');
18122 var getNAF
= utils
.getNAF
;
18123 var getJSF
= utils
.getJSF
;
18124 var assert
= utils
.assert
;
18126 function BaseCurve(type
, conf
) {
18128 this.p
= new BN(conf
.p
, 16);
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
);
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
);
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
);
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);
18148 // Generalized Greg Maxwell's trick
18149 var adjustCount
= this.n
&& this.p
.div(this.n
);
18150 if (!adjustCount
|| adjustCount
.cmpn(100) > 0) {
18153 this._maxwellTrick
= true;
18154 this.redN
= this.n
.toRed(this.red
);
18157 module
.exports
= BaseCurve
;
18159 BaseCurve
.prototype.point
= function point() {
18160 throw new Error('Not implemented');
18163 BaseCurve
.prototype.validate
= function validate() {
18164 throw new Error('Not implemented');
18167 BaseCurve
.prototype._fixedNafMul
= function _fixedNafMul(p
, k
) {
18168 assert(p
.precomputed
);
18169 var doubles
= p
._getDoubles();
18171 var naf
= getNAF(k
, 1);
18172 var I
= (1 << (doubles
.step
+ 1)) - (doubles
.step
% 2 === 0 ? 2 : 1);
18175 // Translate into more windowed form
18177 for (var j
= 0; j
< naf
.length
; j
+= doubles
.step
) {
18179 for (var k
= j
+ doubles
.step
- 1; k
>= j
; k
--)
18180 nafW
= (nafW
<< 1) + naf
[k
];
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
];
18190 b
= b
.mixedAdd(doubles
.points
[j
]);
18191 else if (nafW
=== -i
)
18192 b
= b
.mixedAdd(doubles
.points
[j
].neg());
18199 BaseCurve
.prototype._wnafMul
= function _wnafMul(p
, k
) {
18202 // Precompute window
18203 var nafPoints
= p
._getNAFPoints(w
);
18205 var wnd
= nafPoints
.points
;
18208 var naf
= getNAF(k
, w
);
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
--) {
18214 for (var k
= 0; i
>= 0 && naf
[i
] === 0; i
--)
18224 if (p
.type
=== 'affine') {
18227 acc
= acc
.mixedAdd(wnd
[(z
- 1) >> 1]);
18229 acc
= acc
.mixedAdd(wnd
[(-z
- 1) >> 1].neg());
18233 acc
= acc
.add(wnd
[(z
- 1) >> 1]);
18235 acc
= acc
.add(wnd
[(-z
- 1) >> 1].neg());
18238 return p
.type
=== 'affine' ? acc
.toP() : acc
;
18241 BaseCurve
.prototype._wnafMulAdd
= function _wnafMulAdd(defW
,
18246 var wndWidth
= this._wnafT1
;
18247 var wnd
= this._wnafT2
;
18248 var naf
= this._wnafT3
;
18252 for (var i
= 0; i
< len
; i
++) {
18254 var nafPoints
= p
._getNAFPoints(defW
);
18255 wndWidth
[i
] = nafPoints
.wnd
;
18256 wnd
[i
] = nafPoints
.points
;
18259 // Comb small window NAFs
18260 for (var i
= len
- 1; i
>= 1; i
-= 2) {
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
);
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());
18286 comb
[1] = points
[a
].toJ().mixedAdd(points
[b
]);
18287 comb
[2] = points
[a
].toJ().mixedAdd(points
[b
].neg());
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;
18310 naf
[a
][j
] = index
[(ja
+ 1) * 3 + (jb
+ 1)];
18316 var acc
= this.jpoint(null, null, null);
18317 var tmp
= this._wnafT4
;
18318 for (var i
= max
; i
>= 0; i
--) {
18323 for (var j
= 0; j
< len
; j
++) {
18324 tmp
[j
] = naf
[j
][i
] | 0;
18339 for (var j
= 0; j
< len
; j
++) {
18345 p
= wnd
[j
][(z
- 1) >> 1];
18347 p
= wnd
[j
][(-z
- 1) >> 1].neg();
18349 if (p
.type
=== 'affine')
18350 acc
= acc
.mixedAdd(p
);
18355 // Zeroify references
18356 for (var i
= 0; i
< len
; i
++)
18359 if (jacobianResult
)
18365 function BasePoint(curve
, type
) {
18366 this.curve
= curve
;
18368 this.precomputed
= null;
18370 BaseCurve
.BasePoint
= BasePoint
;
18372 BasePoint
.prototype.eq
= function eq(/*other*/) {
18373 throw new Error('Not implemented');
18376 BasePoint
.prototype.validate
= function validate() {
18377 return this.curve
.validate(this);
18380 BaseCurve
.prototype.decodePoint
= function decodePoint(bytes
, enc
) {
18381 bytes
= utils
.toArray(bytes
, enc
);
18383 var len
= this.p
.byteLength();
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);
18393 var res
= this.point(bytes
.slice(1, 1 + len
),
18394 bytes
.slice(1 + len
, 1 + 2 * len
));
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);
18401 throw new Error('Unknown point format');
18404 BasePoint
.prototype.encodeCompressed
= function encodeCompressed(enc
) {
18405 return this.encode(enc
, true);
18408 BasePoint
.prototype._encode
= function _encode(compact
) {
18409 var len
= this.curve
.p
.byteLength();
18410 var x
= this.getX().toArray('be', len
);
18413 return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x
);
18415 return [ 0x04 ].concat(x
, this.getY().toArray('be', len
)) ;
18418 BasePoint
.prototype.encode
= function encode(enc
, compact
) {
18419 return utils
.encode(this._encode(compact
), enc
);
18422 BasePoint
.prototype.precompute
= function precompute(power
) {
18423 if (this.precomputed
)
18426 var precomputed
= {
18431 precomputed
.naf
= this._getNAFPoints(8);
18432 precomputed
.doubles
= this._getDoubles(4, power
);
18433 precomputed
.beta
= this._getBeta();
18434 this.precomputed
= precomputed
;
18439 BasePoint
.prototype._hasDoubles
= function _hasDoubles(k
) {
18440 if (!this.precomputed
)
18443 var doubles
= this.precomputed
.doubles
;
18447 return doubles
.points
.length
>= Math
.ceil((k
.bitLength() + 1) / doubles
.step
);
18450 BasePoint
.prototype._getDoubles
= function _getDoubles(step
, power
) {
18451 if (this.precomputed
&& this.precomputed
.doubles
)
18452 return this.precomputed
.doubles
;
18454 var doubles
= [ this ];
18456 for (var i
= 0; i
< power
; i
+= step
) {
18457 for (var j
= 0; j
< step
; j
++)
18467 BasePoint
.prototype._getNAFPoints
= function _getNAFPoints(wnd
) {
18468 if (this.precomputed
&& this.precomputed
.naf
)
18469 return this.precomputed
.naf
;
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
);
18482 BasePoint
.prototype._getBeta
= function _getBeta() {
18486 BasePoint
.prototype.dblp
= function dblp(k
) {
18488 for (var i
= 0; i
< k
; i
++)
18493 },{"../utils":143,"bn.js":79}],131:[function(require
,module
,exports
){
18496 var utils
= require('../utils');
18497 var BN
= require('bn.js');
18498 var inherits
= require('inherits');
18499 var Base
= require('./base');
18501 var assert
= utils
.assert
;
18503 function 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
;
18509 Base
.call(this, 'edwards', conf
);
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
);
18518 assert(!this.twisted
|| this.c
.fromRed().cmpn(1) === 0);
18519 this.oneC
= (conf
.c
| 0) === 1;
18521 inherits(EdwardsCurve
, Base
);
18522 module
.exports
= EdwardsCurve
;
18524 EdwardsCurve
.prototype._mulA
= function _mulA(num
) {
18526 return num
.redNeg();
18528 return this.a
.redMul(num
);
18531 EdwardsCurve
.prototype._mulC
= function _mulC(num
) {
18535 return this.c
.redMul(num
);
18538 // Just for compatibility with Short curve
18539 EdwardsCurve
.prototype.jpoint
= function jpoint(x
, y
, z
, t
) {
18540 return this.point(x
, y
, z
, t
);
18543 EdwardsCurve
.prototype.pointFromX
= function pointFromX(x
, odd
) {
18546 x
= x
.toRed(this.red
);
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
));
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');
18557 var isOdd
= y
.fromRed().isOdd();
18558 if (odd
&& !isOdd
|| !odd
&& isOdd
)
18561 return this.point(x
, y
);
18564 EdwardsCurve
.prototype.pointFromY
= function pointFromY(y
, odd
) {
18567 y
= y
.toRed(this.red
);
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());
18575 if (x2
.cmp(this.zero
) === 0) {
18577 throw new Error('invalid point');
18579 return this.point(this.zero
, y
);
18582 var x
= x2
.redSqrt();
18583 if (x
.redSqr().redSub(x2
).cmp(this.zero
) !== 0)
18584 throw new Error('invalid point');
18586 if (x
.fromRed().isOdd() !== odd
)
18589 return this.point(x
, y
);
18592 EdwardsCurve
.prototype.validate
= function validate(point
) {
18593 if (point
.isInfinity())
18596 // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2)
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
)));
18604 return lhs
.cmp(rhs
) === 0;
18607 function 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
;
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);
18621 this.x
= this.x
.toRed(this.curve
.red
);
18623 this.y
= this.y
.toRed(this.curve
.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
;
18630 // Use extended coordinates
18631 if (this.curve
.extended
&& !this.t
) {
18632 this.t
= this.x
.redMul(this.y
);
18634 this.t
= this.t
.redMul(this.z
.redInvm());
18638 inherits(Point
, Base
.BasePoint
);
18640 EdwardsCurve
.prototype.pointFromJSON
= function pointFromJSON(obj
) {
18641 return Point
.fromJSON(this, obj
);
18644 EdwardsCurve
.prototype.point
= function point(x
, y
, z
, t
) {
18645 return new Point(this, x
, y
, z
, t
);
18648 Point
.fromJSON
= function fromJSON(curve
, obj
) {
18649 return new Point(curve
, obj
[0], obj
[1], obj
[2]);
18652 Point
.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) + '>';
18660 Point
.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));
18667 Point
.prototype._extDbl
= function _extDbl() {
18668 // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
18669 // #doubling-dbl-2008-hwcd
18673 var a
= this.x
.redSqr();
18675 var b
= this.y
.redSqr();
18677 var c
= this.z
.redSqr();
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
);
18684 var g
= d
.redAdd(b
);
18686 var f
= g
.redSub(c
);
18688 var h
= d
.redSub(b
);
18690 var nx
= e
.redMul(f
);
18692 var ny
= g
.redMul(h
);
18694 var nt
= e
.redMul(h
);
18696 var nz
= f
.redMul(g
);
18697 return this.curve
.point(nx
, ny
, nz
, nt
);
18700 Point
.prototype._projDbl
= function _projDbl() {
18701 // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
18702 // #doubling-dbl-2008-bbjlp
18703 // #doubling-dbl-2007-bl
18705 // Generally 3M + 4S or 2M + 4S
18708 var b
= this.x
.redAdd(this.y
).redSqr();
18710 var c
= this.x
.redSqr();
18712 var d
= this.y
.redSqr();
18717 if (this.curve
.twisted
) {
18719 var e
= this.curve
._mulA(c
);
18721 var f
= e
.redAdd(d
);
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
);
18731 var h
= this.z
.redSqr();
18733 var j
= f
.redSub(h
).redISub(h
);
18735 nx
= b
.redSub(c
).redISub(d
).redMul(j
);
18736 // Y3 = F * (E - D)
18737 ny
= f
.redMul(e
.redSub(d
));
18743 var e
= c
.redAdd(d
);
18745 var h
= this.curve
._mulC(this.z
).redSqr();
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
));
18755 return this.curve
.point(nx
, ny
, nz
);
18758 Point
.prototype.dbl
= function dbl() {
18759 if (this.isInfinity())
18762 // Double in extended coordinates
18763 if (this.curve
.extended
)
18764 return this._extDbl();
18766 return this._projDbl();
18769 Point
.prototype._extAdd
= function _extAdd(p
) {
18770 // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
18771 // #addition-add-2008-hwcd-3
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
));
18779 var c
= this.t
.redMul(this.curve
.dd
).redMul(p
.t
);
18781 var d
= this.z
.redMul(p
.z
.redAdd(p
.z
));
18783 var e
= b
.redSub(a
);
18785 var f
= d
.redSub(c
);
18787 var g
= d
.redAdd(c
);
18789 var h
= b
.redAdd(a
);
18791 var nx
= e
.redMul(f
);
18793 var ny
= g
.redMul(h
);
18795 var nt
= e
.redMul(h
);
18797 var nz
= f
.redMul(g
);
18798 return this.curve
.point(nx
, ny
, nz
, nt
);
18801 Point
.prototype._projAdd
= function _projAdd(p
) {
18802 // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
18803 // #addition-add-2008-bbjlp
18804 // #addition-add-2007-bl
18808 var a
= this.z
.redMul(p
.z
);
18810 var b
= a
.redSqr();
18812 var c
= this.x
.redMul(p
.x
);
18814 var d
= this.y
.redMul(p
.y
);
18816 var e
= this.curve
.d
.redMul(c
).redMul(d
);
18818 var f
= b
.redSub(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
);
18826 if (this.curve
.twisted
) {
18827 // Y3 = A * G * (D - a * C)
18828 ny
= a
.redMul(g
).redMul(d
.redSub(this.curve
._mulA(c
)));
18832 // Y3 = A * G * (D - C)
18833 ny
= a
.redMul(g
).redMul(d
.redSub(c
));
18835 nz
= this.curve
._mulC(f
).redMul(g
);
18837 return this.curve
.point(nx
, ny
, nz
);
18840 Point
.prototype.add
= function add(p
) {
18841 if (this.isInfinity())
18843 if (p
.isInfinity())
18846 if (this.curve
.extended
)
18847 return this._extAdd(p
);
18849 return this._projAdd(p
);
18852 Point
.prototype.mul
= function mul(k
) {
18853 if (this._hasDoubles(k
))
18854 return this.curve
._fixedNafMul(this, k
);
18856 return this.curve
._wnafMul(this, k
);
18859 Point
.prototype.mulAdd
= function mulAdd(k1
, p
, k2
) {
18860 return this.curve
._wnafMulAdd(1, [ this, p
], [ k1
, k2
], 2, false);
18863 Point
.prototype.jmulAdd
= function jmulAdd(k1
, p
, k2
) {
18864 return this.curve
._wnafMulAdd(1, [ this, p
], [ k1
, k2
], 2, true);
18867 Point
.prototype.normalize
= function normalize() {
18871 // Normalize coordinates
18872 var zi
= this.z
.redInvm();
18873 this.x
= this.x
.redMul(zi
);
18874 this.y
= this.y
.redMul(zi
);
18876 this.t
= this.t
.redMul(zi
);
18877 this.z
= this.curve
.one
;
18882 Point
.prototype.neg
= function neg() {
18883 return this.curve
.point(this.x
.redNeg(),
18886 this.t
&& this.t
.redNeg());
18889 Point
.prototype.getX
= function getX() {
18891 return this.x
.fromRed();
18894 Point
.prototype.getY
= function getY() {
18896 return this.y
.fromRed();
18899 Point
.prototype.eq
= function eq(other
) {
18900 return this === other
||
18901 this.getX().cmp(other
.getX()) === 0 &&
18902 this.getY().cmp(other
.getY()) === 0;
18905 Point
.prototype.eqXToP
= function eqXToP(x
) {
18906 var rx
= x
.toRed(this.curve
.red
).redMul(this.z
);
18907 if (this.x
.cmp(rx
) === 0)
18910 var xc
= x
.clone();
18911 var t
= this.curve
.redN
.redMul(this.z
);
18913 xc
.iadd(this.curve
.n
);
18914 if (xc
.cmp(this.curve
.p
) >= 0)
18918 if (this.x
.cmp(rx
) === 0)
18923 // Compatibility with BaseCurve
18924 Point
.prototype.toP
= Point
.prototype.normalize
;
18925 Point
.prototype.mixedAdd
= Point
.prototype.add
;
18927 },{"../utils":143,"./base":130,"bn.js":79,"inherits":162}],132:[function(require
,module
,exports
){
18930 var curve
= exports
;
18932 curve
.base
= require('./base');
18933 curve
.short = require('./short');
18934 curve
.mont
= require('./mont');
18935 curve
.edwards
= require('./edwards');
18937 },{"./base":130,"./edwards":131,"./mont":133,"./short":134}],133:[function(require
,module
,exports
){
18940 var BN
= require('bn.js');
18941 var inherits
= require('inherits');
18942 var Base
= require('./base');
18944 var utils
= require('../utils');
18946 function MontCurve(conf
) {
18947 Base
.call(this, 'mont', conf
);
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
));
18955 inherits(MontCurve
, Base
);
18956 module
.exports
= MontCurve
;
18958 MontCurve
.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();
18964 return y
.redSqr().cmp(rhs
) === 0;
18967 function 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
;
18973 this.x
= new BN(x
, 16);
18974 this.z
= new BN(z
, 16);
18976 this.x
= this.x
.toRed(this.curve
.red
);
18978 this.z
= this.z
.toRed(this.curve
.red
);
18981 inherits(Point
, Base
.BasePoint
);
18983 MontCurve
.prototype.decodePoint
= function decodePoint(bytes
, enc
) {
18984 return this.point(utils
.toArray(bytes
, enc
), 1);
18987 MontCurve
.prototype.point
= function point(x
, z
) {
18988 return new Point(this, x
, z
);
18991 MontCurve
.prototype.pointFromJSON
= function pointFromJSON(obj
) {
18992 return Point
.fromJSON(this, obj
);
18995 Point
.prototype.precompute
= function precompute() {
18999 Point
.prototype._encode
= function _encode() {
19000 return this.getX().toArray('be', this.curve
.p
.byteLength());
19003 Point
.fromJSON
= function fromJSON(curve
, obj
) {
19004 return new Point(curve
, obj
[0], obj
[1] || curve
.one
);
19007 Point
.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) + '>';
19014 Point
.prototype.isInfinity
= function isInfinity() {
19015 // XXX This code assumes that zero is always zero in red
19016 return this.z
.cmpn(0) === 0;
19019 Point
.prototype.dbl
= function dbl() {
19020 // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3
19024 var a
= this.x
.redAdd(this.z
);
19026 var aa
= a
.redSqr();
19028 var b
= this.x
.redSub(this.z
);
19030 var bb
= b
.redSqr();
19032 var c
= aa
.redSub(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
);
19040 Point
.prototype.add
= function add() {
19041 throw new Error('Not supported on Montgomery curve');
19044 Point
.prototype.diffAdd
= function diffAdd(p
, diff
) {
19045 // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3
19049 var a
= this.x
.redAdd(this.z
);
19051 var b
= this.x
.redSub(this.z
);
19053 var c
= p
.x
.redAdd(p
.z
);
19055 var d
= p
.x
.redSub(p
.z
);
19057 var da
= d
.redMul(a
);
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
);
19067 Point
.prototype.mul
= function mul(k
) {
19069 var a
= this; // (N / 2) * Q + Q
19070 var b
= this.curve
.point(null, null); // (N / 2) * Q
19073 for (var bits
= []; t
.cmpn(0) !== 0; t
.iushrn(1))
19074 bits
.push(t
.andln(1));
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))
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)
19092 Point
.prototype.mulAdd
= function mulAdd() {
19093 throw new Error('Not supported on Montgomery curve');
19096 Point
.prototype.jumlAdd
= function jumlAdd() {
19097 throw new Error('Not supported on Montgomery curve');
19100 Point
.prototype.eq
= function eq(other
) {
19101 return this.getX().cmp(other
.getX()) === 0;
19104 Point
.prototype.normalize
= function normalize() {
19105 this.x
= this.x
.redMul(this.z
.redInvm());
19106 this.z
= this.curve
.one
;
19110 Point
.prototype.getX
= function getX() {
19111 // Normalize coordinates
19114 return this.x
.fromRed();
19117 },{"../utils":143,"./base":130,"bn.js":79,"inherits":162}],134:[function(require
,module
,exports
){
19120 var utils
= require('../utils');
19121 var BN
= require('bn.js');
19122 var inherits
= require('inherits');
19123 var Base
= require('./base');
19125 var assert
= utils
.assert
;
19127 function ShortCurve(conf
) {
19128 Base
.call(this, 'short', conf
);
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();
19134 this.zeroA
= this.a
.fromRed().cmpn(0) === 0;
19135 this.threeA
= this.a
.fromRed().sub(this.p
).cmpn(-3) === 0;
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);
19142 inherits(ShortCurve
, Base
);
19143 module
.exports
= ShortCurve
;
19145 ShortCurve
.prototype._getEndomorphism
= function _getEndomorphism(conf
) {
19146 // No efficient endomorphism
19147 if (!this.zeroA
|| !this.g
|| !this.n
|| this.p
.modn(3) !== 1)
19150 // Compute beta and lambda, that lambda * P = (beta * Px; Py)
19154 beta
= new BN(conf
.beta
, 16).toRed(this.red
);
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
);
19162 lambda
= new BN(conf
.lambda
, 16);
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];
19169 lambda
= lambdas
[1];
19170 assert(this.g
.mul(lambda
).x
.cmp(this.g
.x
.redMul(beta
)) === 0);
19174 // Get basis vectors, used for balanced length-two representation
19177 basis
= conf
.basis
.map(function(vec
) {
19179 a: new BN(vec
.a
, 16),
19180 b: new BN(vec
.b
, 16)
19184 basis
= this._getEndoBasis(lambda
);
19194 ShortCurve
.prototype._getEndoRoots
= function _getEndoRoots(num
) {
19195 // Find roots of for x^2 + x + 1 in F
19196 // Root = (-1 +- Sqrt(-3)) / 2
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();
19202 var s
= new BN(3).toRed(red
).redNeg().redSqrt().redMul(tinv
);
19204 var l1
= ntinv
.redAdd(s
).fromRed();
19205 var l2
= ntinv
.redSub(s
).fromRed();
19209 ShortCurve
.prototype._getEndoBasis
= function _getEndoBasis(lambda
) {
19210 // aprxSqrt >= sqrt(this.n)
19211 var aprxSqrt
= this.n
.ushrn(Math
.floor(this.n
.bitLength() / 2));
19214 // Run EGCD, until r(L + 1) < aprxSqrt
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);
19222 // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n)
19236 while (u
.cmpn(0) !== 0) {
19238 r
= v
.sub(q
.mul(u
));
19239 x
= x2
.sub(q
.mul(x1
));
19240 var y
= y2
.sub(q
.mul(y1
));
19242 if (!a1
&& r
.cmp(aprxSqrt
) < 0) {
19247 } else if (a1
&& ++i
=== 2) {
19262 var len1
= a1
.sqr().add(b1
.sqr());
19263 var len2
= a2
.sqr().add(b2
.sqr());
19264 if (len2
.cmp(len1
) >= 0) {
19285 ShortCurve
.prototype._endoSplit
= function _endoSplit(k
) {
19286 var basis
= this.endo
.basis
;
19290 var c1
= v2
.b
.mul(k
).divRound(this.n
);
19291 var c2
= v1
.b
.neg().mul(k
).divRound(this.n
);
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
);
19298 // Calculate answer
19299 var k1
= k
.sub(p1
).sub(p2
);
19300 var k2
= q1
.add(q2
).neg();
19301 return { k1: k1
, k2: k2
};
19304 ShortCurve
.prototype.pointFromX
= function pointFromX(x
, odd
) {
19307 x
= x
.toRed(this.red
);
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');
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
)
19320 return this.point(x
, y
);
19323 ShortCurve
.prototype.validate
= function validate(point
) {
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;
19335 ShortCurve
.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
]);
19342 var beta
= p
._getBeta();
19344 if (split
.k1
.negative
) {
19348 if (split
.k2
.negative
) {
19350 beta
= beta
.neg(true);
19353 npoints
[i
* 2] = p
;
19354 npoints
[i
* 2 + 1] = beta
;
19355 ncoeffs
[i
* 2] = split
.k1
;
19356 ncoeffs
[i
* 2 + 1] = split
.k2
;
19358 var res
= this._wnafMulAdd(1, npoints
, ncoeffs
, i
* 2, jacobianResult
);
19360 // Clean-up references to points and coefficients
19361 for (var j
= 0; j
< i
* 2; j
++) {
19368 function Point(curve
, x
, y
, isRed
) {
19369 Base
.BasePoint
.call(this, curve
, 'affine');
19370 if (x
=== null && y
=== null) {
19375 this.x
= new BN(x
, 16);
19376 this.y
= new BN(y
, 16);
19377 // Force redgomery representation when loading from JSON
19379 this.x
.forceRed(this.curve
.red
);
19380 this.y
.forceRed(this.curve
.red
);
19383 this.x
= this.x
.toRed(this.curve
.red
);
19385 this.y
= this.y
.toRed(this.curve
.red
);
19389 inherits(Point
, Base
.BasePoint
);
19391 ShortCurve
.prototype.point
= function point(x
, y
, isRed
) {
19392 return new Point(this, x
, y
, isRed
);
19395 ShortCurve
.prototype.pointFromJSON
= function pointFromJSON(obj
, red
) {
19396 return Point
.fromJSON(this, obj
, red
);
19399 Point
.prototype._getBeta
= function _getBeta() {
19400 if (!this.curve
.endo
)
19403 var pre
= this.precomputed
;
19404 if (pre
&& pre
.beta
)
19407 var beta
= this.curve
.point(this.x
.redMul(this.curve
.endo
.beta
), this.y
);
19409 var curve
= this.curve
;
19410 var endoMul = function(p
) {
19411 return curve
.point(p
.x
.redMul(curve
.endo
.beta
), p
.y
);
19414 beta
.precomputed
= {
19418 points: pre
.naf
.points
.map(endoMul
)
19420 doubles: pre
.doubles
&& {
19421 step: pre
.doubles
.step
,
19422 points: pre
.doubles
.points
.map(endoMul
)
19429 Point
.prototype.toJSON
= function toJSON() {
19430 if (!this.precomputed
)
19431 return [ this.x
, this.y
];
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)
19438 naf: this.precomputed
.naf
&& {
19439 wnd: this.precomputed
.naf
.wnd
,
19440 points: this.precomputed
.naf
.points
.slice(1)
19445 Point
.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
);
19452 function obj2point(obj
) {
19453 return curve
.point(obj
[0], obj
[1], red
);
19457 res
.precomputed
= {
19459 doubles: pre
.doubles
&& {
19460 step: pre
.doubles
.step
,
19461 points: [ res
].concat(pre
.doubles
.points
.map(obj2point
))
19465 points: [ res
].concat(pre
.naf
.points
.map(obj2point
))
19471 Point
.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) + '>';
19478 Point
.prototype.isInfinity
= function isInfinity() {
19482 Point
.prototype.add
= function add(p
) {
19496 if (this.neg().eq(p
))
19497 return this.curve
.point(null, null);
19500 if (this.x
.cmp(p
.x
) === 0)
19501 return this.curve
.point(null, null);
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
);
19511 Point
.prototype.dbl
= function dbl() {
19516 var ys1
= this.y
.redAdd(this.y
);
19517 if (ys1
.cmpn(0) === 0)
19518 return this.curve
.point(null, null);
19520 var a
= this.curve
.a
;
19522 var x2
= this.x
.redSqr();
19523 var dyinv
= ys1
.redInvm();
19524 var c
= x2
.redAdd(x2
).redIAdd(x2
).redIAdd(a
).redMul(dyinv
);
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
);
19531 Point
.prototype.getX
= function getX() {
19532 return this.x
.fromRed();
19535 Point
.prototype.getY
= function getY() {
19536 return this.y
.fromRed();
19539 Point
.prototype.mul
= function mul(k
) {
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
]);
19547 return this.curve
._wnafMul(this, k
);
19550 Point
.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
);
19556 return this.curve
._wnafMulAdd(1, points
, coeffs
, 2);
19559 Point
.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);
19565 return this.curve
._wnafMulAdd(1, points
, coeffs
, 2, true);
19568 Point
.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);
19574 Point
.prototype.neg
= function neg(_precompute
) {
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
) {
19584 res
.precomputed
= {
19587 points: pre
.naf
.points
.map(negate
)
19589 doubles: pre
.doubles
&& {
19590 step: pre
.doubles
.step
,
19591 points: pre
.doubles
.points
.map(negate
)
19598 Point
.prototype.toJ
= function toJ() {
19600 return this.curve
.jpoint(null, null, null);
19602 var res
= this.curve
.jpoint(this.x
, this.y
, this.curve
.one
);
19606 function 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);
19613 this.x
= new BN(x
, 16);
19614 this.y
= new BN(y
, 16);
19615 this.z
= new BN(z
, 16);
19618 this.x
= this.x
.toRed(this.curve
.red
);
19620 this.y
= this.y
.toRed(this.curve
.red
);
19622 this.z
= this.z
.toRed(this.curve
.red
);
19624 this.zOne
= this.z
=== this.curve
.one
;
19626 inherits(JPoint
, Base
.BasePoint
);
19628 ShortCurve
.prototype.jpoint
= function jpoint(x
, y
, z
) {
19629 return new JPoint(this, x
, y
, z
);
19632 JPoint
.prototype.toP
= function toP() {
19633 if (this.isInfinity())
19634 return this.curve
.point(null, null);
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
);
19641 return this.curve
.point(ax
, ay
);
19644 JPoint
.prototype.neg
= function neg() {
19645 return this.curve
.jpoint(this.x
, this.y
.redNeg(), this.z
);
19648 JPoint
.prototype.add
= function add(p
) {
19650 if (this.isInfinity())
19654 if (p
.isInfinity())
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
));
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);
19674 var h2
= h
.redSqr();
19675 var h3
= h2
.redMul(h
);
19676 var v
= u1
.redMul(h2
);
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
);
19682 return this.curve
.jpoint(nx
, ny
, nz
);
19685 JPoint
.prototype.mixedAdd
= function mixedAdd(p
) {
19687 if (this.isInfinity())
19691 if (p
.isInfinity())
19695 var z2
= this.z
.redSqr();
19697 var u2
= p
.x
.redMul(z2
);
19699 var s2
= p
.y
.redMul(z2
).redMul(this.z
);
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);
19710 var h2
= h
.redSqr();
19711 var h3
= h2
.redMul(h
);
19712 var v
= u1
.redMul(h2
);
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
);
19718 return this.curve
.jpoint(nx
, ny
, nz
);
19721 JPoint
.prototype.dblp
= function dblp(pow
) {
19724 if (this.isInfinity())
19729 if (this.curve
.zeroA
|| this.curve
.threeA
) {
19731 for (var i
= 0; i
< pow
; i
++)
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
;
19744 var jz4
= jz
.redSqr().redSqr();
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
));
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
);
19761 jz4
= jz4
.redMul(jyd4
);
19768 return this.curve
.jpoint(jx
, jyd
.redMul(tinv
), jz
);
19771 JPoint
.prototype.dbl
= function dbl() {
19772 if (this.isInfinity())
19775 if (this.curve
.zeroA
)
19776 return this._zeroDbl();
19777 else if (this.curve
.threeA
)
19778 return this._threeDbl();
19780 return this._dbl();
19783 JPoint
.prototype._zeroDbl
= function _zeroDbl() {
19789 // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
19790 // #doubling-mdbl-2007-bl
19794 var xx
= this.x
.redSqr();
19796 var yy
= this.y
.redSqr();
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
);
19802 // M = 3 * XX + a; a = 0
19803 var m
= xx
.redAdd(xx
).redIAdd(xx
);
19805 var t
= m
.redSqr().redISub(s
).redISub(s
);
19808 var yyyy8
= yyyy
.redIAdd(yyyy
);
19809 yyyy8
= yyyy8
.redIAdd(yyyy8
);
19810 yyyy8
= yyyy8
.redIAdd(yyyy8
);
19814 // Y3 = M * (S - T) - 8 * YYYY
19815 ny
= m
.redMul(s
.redISub(t
)).redISub(yyyy8
);
19817 nz
= this.y
.redAdd(this.y
);
19819 // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
19820 // #doubling-dbl-2009-l
19824 var a
= this.x
.redSqr();
19826 var b
= this.y
.redSqr();
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
);
19833 var e
= a
.redAdd(a
).redIAdd(a
);
19835 var f
= e
.redSqr();
19838 var c8
= c
.redIAdd(c
);
19839 c8
= c8
.redIAdd(c8
);
19840 c8
= c8
.redIAdd(c8
);
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
);
19851 return this.curve
.jpoint(nx
, ny
, nz
);
19854 JPoint
.prototype._threeDbl
= function _threeDbl() {
19860 // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html
19861 // #doubling-mdbl-2007-bl
19865 var xx
= this.x
.redSqr();
19867 var yy
= this.y
.redSqr();
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
);
19874 var m
= xx
.redAdd(xx
).redIAdd(xx
).redIAdd(this.curve
.a
);
19876 var t
= m
.redSqr().redISub(s
).redISub(s
);
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
);
19885 nz
= this.y
.redAdd(this.y
);
19887 // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b
19891 var delta
= this.z
.redSqr();
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
);
19914 return this.curve
.jpoint(nx
, ny
, nz
);
19917 JPoint
.prototype._dbl
= function _dbl() {
19918 var a
= this.curve
.a
;
19924 var jz4
= jz
.redSqr().redSqr();
19926 var jx2
= jx
.redSqr();
19927 var jy2
= jy
.redSqr();
19929 var c
= jx2
.redAdd(jx2
).redIAdd(jx2
).redIAdd(a
.redMul(jz4
));
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
);
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
);
19944 return this.curve
.jpoint(nx
, ny
, nz
);
19947 JPoint
.prototype.trpl
= function trpl() {
19948 if (!this.curve
.zeroA
)
19949 return this.dbl().add(this);
19951 // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl
19955 var xx
= this.x
.redSqr();
19957 var yy
= this.y
.redSqr();
19959 var zz
= this.z
.redSqr();
19961 var yyyy
= yy
.redSqr();
19962 // M = 3 * XX + a * ZZ2; a = 0
19963 var m
= xx
.redAdd(xx
).redIAdd(xx
);
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
);
19969 e
= e
.redAdd(e
).redIAdd(e
);
19972 var ee
= e
.redSqr();
19974 var t
= yyyy
.redIAdd(yyyy
);
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
);
19995 return this.curve
.jpoint(nx
, ny
, nz
);
19998 JPoint
.prototype.mul
= function mul(k
, kbase
) {
19999 k
= new BN(k
, kbase
);
20001 return this.curve
._wnafMul(this, k
);
20004 JPoint
.prototype.eq
= function eq(p
) {
20005 if (p
.type
=== 'affine')
20006 return this.eq(p
.toJ());
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)
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;
20023 JPoint
.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)
20029 var xc
= x
.clone();
20030 var t
= this.curve
.redN
.redMul(zs
);
20032 xc
.iadd(this.curve
.n
);
20033 if (xc
.cmp(this.curve
.p
) >= 0)
20037 if (this.x
.cmp(rx
) === 0)
20042 JPoint
.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) + '>';
20050 JPoint
.prototype.isInfinity
= function isInfinity() {
20051 // XXX This code assumes that zero is always zero in red
20052 return this.z
.cmpn(0) === 0;
20055 },{"../utils":143,"./base":130,"bn.js":79,"inherits":162}],135:[function(require
,module
,exports
){
20058 var curves
= exports
;
20060 var hash
= require('hash.js');
20061 var curve
= require('./curve');
20062 var utils
= require('./utils');
20064 var assert
= utils
.assert
;
20066 function 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
);
20072 this.curve
= new curve
.mont(options
);
20073 this.g
= this.curve
.g
;
20074 this.n
= this.curve
.n
;
20075 this.hash
= options
.hash
;
20077 assert(this.g
.validate(), 'Invalid curve');
20078 assert(this.g
.mul(this.n
).isInfinity(), 'Invalid curve, G*N != O');
20080 curves
.PresetCurve
= PresetCurve
;
20082 function defineCurve(name
, options
) {
20083 Object
.defineProperty(curves
, name
, {
20084 configurable: true,
20087 var curve
= new PresetCurve(options
);
20088 Object
.defineProperty(curves
, name
, {
20089 configurable: true,
20098 defineCurve('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',
20108 '188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012',
20109 '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811'
20113 defineCurve('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',
20123 'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21',
20124 'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34'
20128 defineCurve('p256', {
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',
20138 '6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296',
20139 '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5'
20143 defineCurve('p384', {
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',
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'
20164 defineCurve('p521', {
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',
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'
20191 defineCurve('curve25519', {
20194 p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
20197 n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
20205 defineCurve('ed25519', {
20208 p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
20211 // -121665 * (121666^(-1)) (mod P)
20212 d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3',
20213 n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
20217 '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a',
20220 '6666666666666666666666666666666666666666666666666666666666666658'
20226 pre
= require('./precomputed/secp256k1');
20231 defineCurve('secp256k1', {
20234 p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f',
20237 n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141',
20241 // Precomputed endomorphism
20242 beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee',
20243 lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72',
20246 a: '3086d221a7d46bcde86c90e49284eb15',
20247 b: '-e4437ed6010e88286f547fa90abfe4c3'
20250 a: '114ca50f7a8e2f3f657c1108d9d44cfd8',
20251 b: '3086d221a7d46bcde86c90e49284eb15'
20257 '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
20258 '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8',
20263 },{"./curve":132,"./precomputed/secp256k1":142,"./utils":143,"hash.js":148}],136:[function(require
,module
,exports
){
20266 var BN
= require('bn.js');
20267 var HmacDRBG
= require('hmac-drbg');
20268 var utils
= require('../utils');
20269 var curves
= require('../curves');
20270 var rand
= require('brorand');
20271 var assert
= utils
.assert
;
20273 var KeyPair
= require('./key');
20274 var Signature
= require('./signature');
20276 function EC(options
) {
20277 if (!(this instanceof EC
))
20278 return new EC(options
);
20280 // Shortcut `elliptic.ec(curve-name)`
20281 if (typeof options
=== 'string') {
20282 assert(curves
.hasOwnProperty(options
), 'Unknown curve ' + options
);
20284 options
= curves
[options
];
20287 // Shortcut for `elliptic.ec(elliptic.curves.curveName)`
20288 if (options
instanceof curves
.PresetCurve
)
20289 options
= { curve: options
};
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
;
20297 this.g
= options
.curve
.g
;
20298 this.g
.precompute(options
.curve
.n
.bitLength() + 1);
20300 // Hash for function for DRBG
20301 this.hash
= options
.hash
|| options
.curve
.hash
;
20303 module
.exports
= EC
;
20305 EC
.prototype.keyPair
= function keyPair(options
) {
20306 return new KeyPair(this, options
);
20309 EC
.prototype.keyFromPrivate
= function keyFromPrivate(priv
, enc
) {
20310 return KeyPair
.fromPrivate(this, priv
, enc
);
20313 EC
.prototype.keyFromPublic
= function keyFromPublic(pub
, enc
) {
20314 return KeyPair
.fromPublic(this, pub
, enc
);
20317 EC
.prototype.genKeyPair
= function genKeyPair(options
) {
20321 // Instantiate Hmac_DRBG
20322 var drbg
= new HmacDRBG({
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()
20331 var bytes
= this.n
.byteLength();
20332 var ns2
= this.n
.sub(new BN(2));
20334 var priv
= new BN(drbg
.generate(bytes
));
20335 if (priv
.cmp(ns2
) > 0)
20339 return this.keyFromPrivate(priv
);
20343 EC
.prototype._truncateToN
= function truncateToN(msg
, truncOnly
) {
20344 var delta
= msg
.byteLength() * 8 - this.n
.bitLength();
20346 msg
= msg
.ushrn(delta
);
20347 if (!truncOnly
&& msg
.cmp(this.n
) >= 0)
20348 return msg
.sub(this.n
);
20353 EC
.prototype.sign
= function sign(msg
, key
, enc
, options
) {
20354 if (typeof enc
=== 'object') {
20361 key
= this.keyFromPrivate(key
, enc
);
20362 msg
= this._truncateToN(new BN(msg
, 16));
20364 // Zero-extend key to provide enough entropy
20365 var bytes
= this.n
.byteLength();
20366 var bkey
= key
.getPrivate().toArray('be', bytes
);
20368 // Zero-extend nonce to have the same byte size as N
20369 var nonce
= msg
.toArray('be', bytes
);
20371 // Instantiate Hmac_DRBG
20372 var drbg
= new HmacDRBG({
20376 pers: options
.pers
,
20377 persEnc: options
.persEnc
|| 'utf8'
20380 // Number of bytes to generate
20381 var ns1
= this.n
.sub(new BN(1));
20383 for (var iter
= 0; true; iter
++) {
20384 var k
= options
.k
?
20386 new BN(drbg
.generate(this.n
.byteLength()));
20387 k
= this._truncateToN(k
, true);
20388 if (k
.cmpn(1) <= 0 || k
.cmp(ns1
) >= 0)
20391 var kp
= this.g
.mul(k
);
20392 if (kp
.isInfinity())
20395 var kpX
= kp
.getX();
20396 var r
= kpX
.umod(this.n
);
20397 if (r
.cmpn(0) === 0)
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)
20405 var recoveryParam
= (kp
.getY().isOdd() ? 1 : 0) |
20406 (kpX
.cmp(r
) !== 0 ? 2 : 0);
20408 // Use complement of `s`, if it is > `n / 2`
20409 if (options
.canonical
&& s
.cmp(this.nh
) > 0) {
20411 recoveryParam
^= 1;
20414 return new Signature({ r: r
, s: s
, recoveryParam: recoveryParam
});
20418 EC
.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');
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)
20428 if (s
.cmpn(1) < 0 || s
.cmp(this.n
) >= 0)
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
);
20436 if (!this.curve
._maxwellTrick
) {
20437 var p
= this.g
.mulAdd(u1
, key
.getPublic(), u2
);
20438 if (p
.isInfinity())
20441 return p
.getX().umod(this.n
).cmp(r
) === 0;
20444 // NOTE: Greg Maxwell's trick, inspired by:
20445 // https://git.io/vad3K
20447 var p
= this.g
.jmulAdd(u1
, key
.getPublic(), u2
);
20448 if (p
.isInfinity())
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
);
20457 EC
.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
);
20462 var e
= new BN(msg
);
20463 var r
= signature
.r
;
20464 var s
= signature
.s
;
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');
20472 // 1.1. Let x = r + jn.
20474 r
= this.curve
.pointFromX(r
.add(this.curve
.n
), isYOdd
);
20476 r
= this.curve
.pointFromX(r
, isYOdd
);
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
);
20482 // 1.6.1 Compute Q = r^-1 (sR - eG)
20483 // Q = r^-1 (sR + -eG)
20484 return this.g
.mulAdd(s1
, r
, s2
);
20487 EC
.prototype.getKeyRecoveryParam = function(e
, signature
, Q
, enc
) {
20488 signature
= new Signature(signature
, enc
);
20489 if (signature
.recoveryParam
!== null)
20490 return signature
.recoveryParam
;
20492 for (var i
= 0; i
< 4; i
++) {
20495 Qprime
= this.recoverPubKey(e
, signature
, i
);
20503 throw new Error('Unable to find valid recovery factor');
20506 },{"../curves":135,"../utils":143,"./key":137,"./signature":138,"bn.js":79,"brorand":80,"hmac-drbg":160}],137:[function(require
,module
,exports
){
20509 var BN
= require('bn.js');
20510 var utils
= require('../utils');
20511 var assert
= utils
.assert
;
20513 function KeyPair(ec
, options
) {
20518 // KeyPair(ec, { priv: ..., pub: ... })
20520 this._importPrivate(options
.priv
, options
.privEnc
);
20522 this._importPublic(options
.pub
, options
.pubEnc
);
20524 module
.exports
= KeyPair
;
20526 KeyPair
.fromPublic
= function fromPublic(ec
, pub
, enc
) {
20527 if (pub
instanceof KeyPair
)
20530 return new KeyPair(ec
, {
20536 KeyPair
.fromPrivate
= function fromPrivate(ec
, priv
, enc
) {
20537 if (priv
instanceof KeyPair
)
20540 return new KeyPair(ec
, {
20546 KeyPair
.prototype.validate
= function validate() {
20547 var pub
= this.getPublic();
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' };
20556 return { result: true, reason: null };
20559 KeyPair
.prototype.getPublic
= function getPublic(compact
, enc
) {
20560 // compact is optional argument
20561 if (typeof compact
=== 'string') {
20567 this.pub
= this.ec
.g
.mul(this.priv
);
20572 return this.pub
.encode(enc
, compact
);
20575 KeyPair
.prototype.getPrivate
= function getPrivate(enc
) {
20577 return this.priv
.toString(16, 2);
20582 KeyPair
.prototype._importPrivate
= function _importPrivate(key
, enc
) {
20583 this.priv
= new BN(key
, enc
|| 16);
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
);
20590 KeyPair
.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');
20601 this.pub
= this.ec
.curve
.point(key
.x
, key
.y
);
20604 this.pub
= this.ec
.curve
.decodePoint(key
, enc
);
20608 KeyPair
.prototype.derive
= function derive(pub
) {
20609 return pub
.mul(this.priv
).getX();
20613 KeyPair
.prototype.sign
= function sign(msg
, enc
, options
) {
20614 return this.ec
.sign(msg
, this, enc
, options
);
20617 KeyPair
.prototype.verify
= function verify(msg
, signature
) {
20618 return this.ec
.verify(msg
, signature
, this);
20621 KeyPair
.prototype.inspect
= function inspect() {
20622 return '<Key priv: ' + (this.priv
&& this.priv
.toString(16, 2)) +
20623 ' pub: ' + (this.pub
&& this.pub
.inspect()) + ' >';
20626 },{"../utils":143,"bn.js":79}],138:[function(require
,module
,exports
){
20629 var BN
= require('bn.js');
20631 var utils
= require('../utils');
20632 var assert
= utils
.assert
;
20634 function Signature(options
, enc
) {
20635 if (options
instanceof Signature
)
20638 if (this._importDER(options
, enc
))
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;
20647 this.recoveryParam
= options
.recoveryParam
;
20649 module
.exports
= Signature
;
20651 function Position() {
20655 function getLength(buf
, p
) {
20656 var initial
= buf
[p
.place
++];
20657 if (!(initial
& 0x80)) {
20660 var octetLen
= initial
& 0xf;
20662 for (var i
= 0, off
= p
.place
; i
< octetLen
; i
++, off
++) {
20670 function rmPadding(buf
) {
20672 var len
= buf
.length
- 1;
20673 while (!buf
[i
] && !(buf
[i
+ 1] & 0x80) && i
< len
) {
20679 return buf
.slice(i
);
20682 Signature
.prototype._importDER
= function _importDER(data
, enc
) {
20683 data
= utils
.toArray(data
, enc
);
20684 var p
= new Position();
20685 if (data
[p
.place
++] !== 0x30) {
20688 var len
= getLength(data
, p
);
20689 if ((len
+ p
.place
) !== data
.length
) {
20692 if (data
[p
.place
++] !== 0x02) {
20695 var rlen
= getLength(data
, p
);
20696 var r
= data
.slice(p
.place
, rlen
+ p
.place
);
20698 if (data
[p
.place
++] !== 0x02) {
20701 var slen
= getLength(data
, p
);
20702 if (data
.length
!== slen
+ p
.place
) {
20705 var s
= data
.slice(p
.place
, slen
+ p
.place
);
20706 if (r
[0] === 0 && (r
[1] & 0x80)) {
20709 if (s
[0] === 0 && (s
[1] & 0x80)) {
20713 this.r
= new BN(r
);
20714 this.s
= new BN(s
);
20715 this.recoveryParam
= null;
20720 function constructLength(arr
, len
) {
20725 var octets
= 1 + (Math
.log(len
) / Math
.LN2
>>> 3);
20726 arr
.push(octets
| 0x80);
20728 arr
.push((len
>>> (octets
<< 3)) & 0xff);
20733 Signature
.prototype.toDER
= function toDER(enc
) {
20734 var r
= this.r
.toArray();
20735 var s
= this.s
.toArray();
20739 r
= [ 0 ].concat(r
);
20742 s
= [ 0 ].concat(s
);
20747 while (!s
[0] && !(s
[1] & 0x80)) {
20750 var arr
= [ 0x02 ];
20751 constructLength(arr
, r
.length
);
20752 arr
= arr
.concat(r
);
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
);
20762 },{"../utils":143,"bn.js":79}],139:[function(require
,module
,exports
){
20765 var hash
= require('hash.js');
20766 var curves
= require('../curves');
20767 var utils
= require('../utils');
20768 var assert
= utils
.assert
;
20769 var parseBytes
= utils
.parseBytes
;
20770 var KeyPair
= require('./key');
20771 var Signature
= require('./signature');
20773 function EDDSA(curve
) {
20774 assert(curve
=== 'ed25519', 'only tested with ed25519 so far');
20776 if (!(this instanceof EDDSA
))
20777 return new EDDSA(curve
);
20779 var curve
= curves
[curve
].curve
;
20780 this.curve
= curve
;
20782 this.g
.precompute(curve
.n
.bitLength() + 1);
20784 this.pointClass
= curve
.point().constructor;
20785 this.encodingLength
= Math
.ceil(curve
.n
.bitLength() / 8);
20786 this.hash
= hash
.sha512
;
20789 module
.exports
= EDDSA
;
20792 * @param {Array|String} message - message bytes
20793 * @param {Array|String|KeyPair} secret - secret bytes or a keypair
20794 * @returns {Signature} - signature
20796 EDDSA
.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
)
20804 var S
= r
.add(s_
).umod(this.curve
.n
);
20805 return this.makeSignature({ R: R
, S: S
, Rencoded: Rencoded
});
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
20814 EDDSA
.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
);
20824 EDDSA
.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
);
20831 EDDSA
.prototype.keyFromPublic
= function keyFromPublic(pub
) {
20832 return KeyPair
.fromPublic(this, pub
);
20835 EDDSA
.prototype.keyFromSecret
= function keyFromSecret(secret
) {
20836 return KeyPair
.fromSecret(this, secret
);
20839 EDDSA
.prototype.makeSignature
= function makeSignature(sig
) {
20840 if (sig
instanceof Signature
)
20842 return new Signature(this, sig
);
20846 * * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.2
20848 * EDDSA defines methods for encoding and decoding points and integers. These are
20849 * helper convenience methods, that pass along to utility functions implied
20853 EDDSA
.prototype.encodePoint
= function encodePoint(point
) {
20854 var enc
= point
.getY().toArray('le', this.encodingLength
);
20855 enc
[this.encodingLength
- 1] |= point
.getX().isOdd() ? 0x80 : 0;
20859 EDDSA
.prototype.decodePoint
= function decodePoint(bytes
) {
20860 bytes
= utils
.parseBytes(bytes
);
20862 var lastIx
= bytes
.length
- 1;
20863 var normed
= bytes
.slice(0, lastIx
).concat(bytes
[lastIx
] & ~0x80);
20864 var xIsOdd
= (bytes
[lastIx
] & 0x80) !== 0;
20866 var y
= utils
.intFromLE(normed
);
20867 return this.curve
.pointFromY(y
, xIsOdd
);
20870 EDDSA
.prototype.encodeInt
= function encodeInt(num
) {
20871 return num
.toArray('le', this.encodingLength
);
20874 EDDSA
.prototype.decodeInt
= function decodeInt(bytes
) {
20875 return utils
.intFromLE(bytes
);
20878 EDDSA
.prototype.isPoint
= function isPoint(val
) {
20879 return val
instanceof this.pointClass
;
20882 },{"../curves":135,"../utils":143,"./key":140,"./signature":141,"hash.js":148}],140:[function(require
,module
,exports
){
20885 var utils
= require('../utils');
20886 var assert
= utils
.assert
;
20887 var parseBytes
= utils
.parseBytes
;
20888 var cachedProperty
= utils
.cachedProperty
;
20891 * @param {EDDSA} eddsa - instance
20892 * @param {Object} params - public/private key parameters
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
20899 function KeyPair(eddsa
, params
) {
20900 this.eddsa
= eddsa
;
20901 this._secret
= parseBytes(params
.secret
);
20902 if (eddsa
.isPoint(params
.pub
))
20903 this._pub
= params
.pub
;
20905 this._pubBytes
= parseBytes(params
.pub
);
20908 KeyPair
.fromPublic
= function fromPublic(eddsa
, pub
) {
20909 if (pub
instanceof KeyPair
)
20911 return new KeyPair(eddsa
, { pub: pub
});
20914 KeyPair
.fromSecret
= function fromSecret(eddsa
, secret
) {
20915 if (secret
instanceof KeyPair
)
20917 return new KeyPair(eddsa
, { secret: secret
});
20920 KeyPair
.prototype.secret
= function secret() {
20921 return this._secret
;
20924 cachedProperty(KeyPair
, 'pubBytes', function pubBytes() {
20925 return this.eddsa
.encodePoint(this.pub());
20928 cachedProperty(KeyPair
, 'pub', function pub() {
20929 if (this._pubBytes
)
20930 return this.eddsa
.decodePoint(this._pubBytes
);
20931 return this.eddsa
.g
.mul(this.priv());
20934 cachedProperty(KeyPair
, 'privBytes', function privBytes() {
20935 var eddsa
= this.eddsa
;
20936 var hash
= this.hash();
20937 var lastIx
= eddsa
.encodingLength
- 1;
20939 var a
= hash
.slice(0, eddsa
.encodingLength
);
20947 cachedProperty(KeyPair
, 'priv', function priv() {
20948 return this.eddsa
.decodeInt(this.privBytes());
20951 cachedProperty(KeyPair
, 'hash', function hash() {
20952 return this.eddsa
.hash().update(this.secret()).digest();
20955 cachedProperty(KeyPair
, 'messagePrefix', function messagePrefix() {
20956 return this.hash().slice(this.eddsa
.encodingLength
);
20959 KeyPair
.prototype.sign
= function sign(message
) {
20960 assert(this._secret
, 'KeyPair can only verify');
20961 return this.eddsa
.sign(message
, this);
20964 KeyPair
.prototype.verify
= function verify(message
, sig
) {
20965 return this.eddsa
.verify(message
, sig
, this);
20968 KeyPair
.prototype.getSecret
= function getSecret(enc
) {
20969 assert(this._secret
, 'KeyPair is public only');
20970 return utils
.encode(this.secret(), enc
);
20973 KeyPair
.prototype.getPublic
= function getPublic(enc
) {
20974 return utils
.encode(this.pubBytes(), enc
);
20977 module
.exports
= KeyPair
;
20979 },{"../utils":143}],141:[function(require
,module
,exports
){
20982 var BN
= require('bn.js');
20983 var utils
= require('../utils');
20984 var assert
= utils
.assert
;
20985 var cachedProperty
= utils
.cachedProperty
;
20986 var parseBytes
= utils
.parseBytes
;
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
20996 function Signature(eddsa
, sig
) {
20997 this.eddsa
= eddsa
;
20999 if (typeof sig
!== 'object')
21000 sig
= parseBytes(sig
);
21002 if (Array
.isArray(sig
)) {
21004 R: sig
.slice(0, eddsa
.encodingLength
),
21005 S: sig
.slice(eddsa
.encodingLength
)
21009 assert(sig
.R
&& sig
.S
, 'Signature without R or S');
21011 if (eddsa
.isPoint(sig
.R
))
21013 if (sig
.S
instanceof BN
)
21016 this._Rencoded
= Array
.isArray(sig
.R
) ? sig
.R : sig
.Rencoded
;
21017 this._Sencoded
= Array
.isArray(sig
.S
) ? sig
.S : sig
.Sencoded
;
21020 cachedProperty(Signature
, 'S', function S() {
21021 return this.eddsa
.decodeInt(this.Sencoded());
21024 cachedProperty(Signature
, 'R', function R() {
21025 return this.eddsa
.decodePoint(this.Rencoded());
21028 cachedProperty(Signature
, 'Rencoded', function Rencoded() {
21029 return this.eddsa
.encodePoint(this.R());
21032 cachedProperty(Signature
, 'Sencoded', function Sencoded() {
21033 return this.eddsa
.encodeInt(this.S());
21036 Signature
.prototype.toBytes
= function toBytes() {
21037 return this.Rencoded().concat(this.Sencoded());
21040 Signature
.prototype.toHex
= function toHex() {
21041 return utils
.encode(this.toBytes(), 'hex').toUpperCase();
21044 module
.exports
= Signature
;
21046 },{"../utils":143,"bn.js":79}],142:[function(require
,module
,exports
){
21052 'e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a',
21053 'f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821'
21056 '8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508',
21057 '11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf'
21060 '175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739',
21061 'd3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695'
21064 '363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640',
21065 '4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9'
21068 '8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c',
21069 '4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36'
21072 '723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda',
21073 '96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f'
21076 'eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa',
21077 '5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999'
21080 '100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0',
21081 'cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09'
21084 'e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d',
21085 '9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d'
21088 'feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d',
21089 'e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088'
21092 'da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1',
21093 '9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d'
21096 '53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0',
21097 '5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8'
21100 '8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047',
21101 '10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a'
21104 '385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862',
21105 '283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453'
21108 '6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7',
21109 '7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160'
21112 '3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd',
21113 '56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0'
21116 '85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83',
21117 '7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6'
21120 '948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a',
21121 '53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589'
21124 '6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8',
21125 'bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17'
21128 'e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d',
21129 '4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda'
21132 'e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725',
21133 '7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd'
21136 '213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754',
21137 '4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2'
21140 '4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c',
21141 '17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6'
21144 'fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6',
21145 '6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f'
21148 '76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39',
21149 'c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01'
21152 'c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891',
21153 '893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3'
21156 'd895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b',
21157 'febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f'
21160 'b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03',
21161 '2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7'
21164 'e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d',
21165 'eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78'
21168 'a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070',
21169 '7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1'
21172 '90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4',
21173 'e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150'
21176 '8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da',
21177 '662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82'
21180 'e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11',
21181 '1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc'
21184 '8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e',
21185 'efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b'
21188 'e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41',
21189 '2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51'
21192 'b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef',
21193 '67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45'
21196 'd68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8',
21197 'db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120'
21200 '324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d',
21201 '648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84'
21204 '4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96',
21205 '35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d'
21208 '9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd',
21209 'ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d'
21212 '6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5',
21213 '9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8'
21216 'a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266',
21217 '40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8'
21220 '7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71',
21221 '34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac'
21224 '928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac',
21225 'c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f'
21228 '85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751',
21229 '1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962'
21232 'ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e',
21233 '493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907'
21236 '827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241',
21237 'c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec'
21240 'eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3',
21241 'be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d'
21244 'e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f',
21245 '4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414'
21248 '1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19',
21249 'aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd'
21252 '146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be',
21253 'b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0'
21256 'fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9',
21257 '6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811'
21260 'da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2',
21261 '8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1'
21264 'a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13',
21265 '7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c'
21268 '174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c',
21269 'ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73'
21272 '959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba',
21273 '2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd'
21276 'd2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151',
21277 'e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405'
21280 '64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073',
21281 'd99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589'
21284 '8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458',
21285 '38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e'
21288 '13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b',
21289 '69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27'
21292 'bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366',
21293 'd3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1'
21296 '8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa',
21297 '40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482'
21300 '8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0',
21301 '620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945'
21304 'dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787',
21305 '7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573'
21308 'f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e',
21309 'ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82'
21317 'f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9',
21318 '388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672'
21321 '2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4',
21322 'd8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6'
21325 '5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc',
21326 '6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da'
21329 'acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe',
21330 'cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37'
21333 '774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb',
21334 'd984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b'
21337 'f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8',
21338 'ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81'
21341 'd7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e',
21342 '581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58'
21345 'defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34',
21346 '4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77'
21349 '2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c',
21350 '85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a'
21353 '352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5',
21354 '321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c'
21357 '2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f',
21358 '2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67'
21361 '9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714',
21362 '73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402'
21365 'daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729',
21366 'a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55'
21369 'c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db',
21370 '2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482'
21373 '6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4',
21374 'e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82'
21377 '1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5',
21378 'b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396'
21381 '605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479',
21382 '2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49'
21385 '62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d',
21386 '80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf'
21389 '80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f',
21390 '1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a'
21393 '7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb',
21394 'd0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7'
21397 'd528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9',
21398 'eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933'
21401 '49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963',
21402 '758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a'
21405 '77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74',
21406 '958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6'
21409 'f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530',
21410 'e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37'
21413 '463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b',
21414 '5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e'
21417 'f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247',
21418 'cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6'
21421 'caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1',
21422 'cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476'
21425 '2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120',
21426 '4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40'
21429 '7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435',
21430 '91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61'
21433 '754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18',
21434 '673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683'
21437 'e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8',
21438 '59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5'
21441 '186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb',
21442 '3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b'
21445 'df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f',
21446 '55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417'
21449 '5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143',
21450 'efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868'
21453 '290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba',
21454 'e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a'
21457 'af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45',
21458 'f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6'
21461 '766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a',
21462 '744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996'
21465 '59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e',
21466 'c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e'
21469 'f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8',
21470 'e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d'
21473 '7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c',
21474 '30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2'
21477 '948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519',
21478 'e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e'
21481 '7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab',
21482 '100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437'
21485 '3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca',
21486 'ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311'
21489 'd3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf',
21490 '8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4'
21493 '1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610',
21494 '68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575'
21497 '733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4',
21498 'f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d'
21501 '15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c',
21502 'd56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d'
21505 'a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940',
21506 'edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629'
21509 'e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980',
21510 'a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06'
21513 '311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3',
21514 '66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374'
21517 '34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf',
21518 '9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee'
21521 'f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63',
21522 '4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1'
21525 'd7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448',
21526 'fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b'
21529 '32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf',
21530 '5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661'
21533 '7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5',
21534 '8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6'
21537 'ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6',
21538 '8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e'
21541 '16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5',
21542 '5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d'
21545 'eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99',
21546 'f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc'
21549 '78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51',
21550 'f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4'
21553 '494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5',
21554 '42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c'
21557 'a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5',
21558 '204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b'
21561 'c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997',
21562 '4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913'
21565 '841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881',
21566 '73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154'
21569 '5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5',
21570 '39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865'
21573 '36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66',
21574 'd2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc'
21577 '336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726',
21578 'ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224'
21581 '8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede',
21582 '6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e'
21585 '1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94',
21586 '60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6'
21589 '85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31',
21590 '3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511'
21593 '29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51',
21594 'b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b'
21597 'a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252',
21598 'ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2'
21601 '4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5',
21602 'cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c'
21605 'd24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b',
21606 '6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3'
21609 'ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4',
21610 '322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d'
21613 'af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f',
21614 '6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700'
21617 'e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889',
21618 '2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4'
21621 '591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246',
21622 'b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196'
21625 '11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984',
21626 '998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4'
21629 '3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a',
21630 'b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257'
21633 'cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030',
21634 'bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13'
21637 'c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197',
21638 '6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096'
21641 'c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593',
21642 'c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38'
21645 'a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef',
21646 '21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f'
21649 '347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38',
21650 '60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448'
21653 'da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a',
21654 '49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a'
21657 'c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111',
21658 '5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4'
21661 '4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502',
21662 '7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437'
21665 '3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea',
21666 'be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7'
21669 'cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26',
21670 '8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d'
21673 'b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986',
21674 '39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a'
21677 'd4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e',
21678 '62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54'
21681 '48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4',
21682 '25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77'
21685 'dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda',
21686 'ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517'
21689 '6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859',
21690 'cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10'
21693 'e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f',
21694 'f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125'
21697 'eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c',
21698 '6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e'
21701 '13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942',
21702 'fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1'
21705 'ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a',
21706 '1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2'
21709 'b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80',
21710 '5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423'
21713 'ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d',
21714 '438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8'
21717 '8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1',
21718 'cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758'
21721 '52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63',
21722 'c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375'
21725 'e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352',
21726 '6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d'
21729 '7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193',
21730 'ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec'
21733 '5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00',
21734 '9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0'
21737 '32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58',
21738 'ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c'
21741 'e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7',
21742 'd3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4'
21745 '8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8',
21746 'c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f'
21749 '4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e',
21750 '67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649'
21753 '3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d',
21754 'cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826'
21757 '674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b',
21758 '299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5'
21761 'd32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f',
21762 'f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87'
21765 '30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6',
21766 '462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b'
21769 'be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297',
21770 '62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc'
21773 '93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a',
21774 '7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c'
21777 'b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c',
21778 'ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f'
21781 'd5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52',
21782 '4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a'
21785 'd3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb',
21786 'bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46'
21789 '463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065',
21790 'bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f'
21793 '7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917',
21794 '603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03'
21797 '74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9',
21798 'cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08'
21801 '30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3',
21802 '553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8'
21805 '9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57',
21806 '712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373'
21809 '176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66',
21810 'ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3'
21813 '75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8',
21814 '9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8'
21817 '809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721',
21818 '9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1'
21821 '1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180',
21822 '4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9'
21828 },{}],143:[function(require
,module
,exports
){
21831 var utils
= exports
;
21832 var BN
= require('bn.js');
21833 var minAssert
= require('minimalistic-assert');
21834 var minUtils
= require('minimalistic-crypto-utils');
21836 utils
.assert
= minAssert
;
21837 utils
.toArray
= minUtils
.toArray
;
21838 utils
.zero2
= minUtils
.zero2
;
21839 utils
.toHex
= minUtils
.toHex
;
21840 utils
.encode
= minUtils
.encode
;
21842 // Represent num in a w-NAF form
21843 function getNAF(num
, w
) {
21845 var ws
= 1 << (w
+ 1);
21846 var k
= num
.clone();
21847 while (k
.cmpn(1) >= 0) {
21850 var mod
= k
.andln(ws
- 1);
21851 if (mod
> (ws
>> 1) - 1)
21852 z
= (ws
>> 1) - mod
;
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
++)
21870 utils
.getNAF
= getNAF
;
21872 // Represent k1, k2 in a Joint Sparse Form
21873 function getJSF(k1
, k2
) {
21883 while (k1
.cmpn(-d1
) > 0 || k2
.cmpn(-d2
) > 0) {
21886 var m14
= (k1
.andln(3) + d1
) & 3;
21887 var m24
= (k2
.andln(3) + d2
) & 3;
21893 if ((m14
& 1) === 0) {
21896 var m8
= (k1
.andln(7) + d1
) & 7;
21897 if ((m8
=== 3 || m8
=== 5) && m24
=== 2)
21905 if ((m24
& 1) === 0) {
21908 var m8
= (k2
.andln(7) + d2
) & 7;
21909 if ((m8
=== 3 || m8
=== 5) && m14
=== 2)
21917 if (2 * d1
=== u1
+ 1)
21919 if (2 * d2
=== u2
+ 1)
21927 utils
.getJSF
= getJSF
;
21929 function 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);
21936 utils
.cachedProperty
= cachedProperty
;
21938 function parseBytes(bytes
) {
21939 return typeof bytes
=== 'string' ? utils
.toArray(bytes
, 'hex') :
21942 utils
.parseBytes
= parseBytes
;
21944 function intFromLE(bytes
) {
21945 return new BN(bytes
, 'hex', 'le');
21947 utils
.intFromLE
= intFromLE
;
21950 },{"bn.js":79,"minimalistic-assert":167,"minimalistic-crypto-utils":168}],144:[function(require
,module
,exports
){
21955 "/usr/local/lib/node_modules/browserify/node_modules/browserify-sign"
21958 "_from": "elliptic@>=6.0.0 <7.0.0",
21959 "_hasShrinkwrap": false,
21960 "_id": "elliptic@6.5.0",
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"
21970 "email": "fedor@indutny.com",
21973 "_npmVersion": "6.9.0",
21974 "_phantomChildren": {},
21976 "name": "elliptic",
21977 "raw": "elliptic@^6.0.0",
21978 "rawSpec": "^6.0.0",
21980 "spec": ">=6.0.0 <7.0.0",
21984 "/browserify/browserify-sign",
21985 "/browserify/create-ecdh"
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",
21993 "email": "fedor@indutny.com",
21994 "name": "Fedor Indutny"
21997 "url": "https://github.com/indutny/elliptic/issues"
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"
22008 "description": "EC cryptography",
22009 "devDependencies": {
22011 "coveralls": "^2.11.3",
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",
22022 "jshint": "^2.6.0",
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
22034 "gitHead": "475f066aebd14681591f0f0f18a2abc0ded8c390",
22035 "homepage": "https://github.com/indutny/elliptic",
22043 "main": "lib/elliptic.js",
22047 "email": "fedor@indutny.com"
22050 "name": "elliptic",
22051 "optionalDependencies": {},
22052 "readme": "ERROR: No README data found!",
22055 "url": "git+ssh://git@github.com/indutny/elliptic.git"
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/"
22068 },{}],145:[function(require
,module
,exports
){
22069 // Copyright Joyent, Inc. and other Node contributors.
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:
22079 // The above copyright notice and this permission notice shall be included
22080 // in all copies or substantial portions of the Software.
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.
22090 var objectCreate
= Object
.create
|| objectCreatePolyfill
22091 var objectKeys
= Object
.keys
|| objectKeysPolyfill
22092 var bind
= Function
.prototype.bind
|| functionBindPolyfill
22094 function EventEmitter() {
22095 if (!this._events
|| !Object
.prototype.hasOwnProperty
.call(this, '_events')) {
22096 this._events
= objectCreate(null);
22097 this._eventsCount
= 0;
22100 this._maxListeners
= this._maxListeners
|| undefined;
22102 module
.exports
= EventEmitter
;
22104 // Backwards-compat with node 0.10.x
22105 EventEmitter
.EventEmitter
= EventEmitter
;
22107 EventEmitter
.prototype._events
= undefined;
22108 EventEmitter
.prototype._maxListeners
= undefined;
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.
22112 var defaultMaxListeners
= 10;
22114 var hasDefineProperty
;
22117 if (Object
.defineProperty
) Object
.defineProperty(o
, 'x', { value: 0 });
22118 hasDefineProperty
= o
.x
=== 0;
22119 } catch (err
) { hasDefineProperty
= false }
22120 if (hasDefineProperty
) {
22121 Object
.defineProperty(EventEmitter
, 'defaultMaxListeners', {
22124 return defaultMaxListeners
;
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
;
22135 EventEmitter
.defaultMaxListeners
= defaultMaxListeners
;
22138 // Obviously not all Emitters should be limited to 10. This function allows
22139 // that to be increased. Set to zero for unlimited.
22140 EventEmitter
.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
;
22147 function $getMaxListeners(that
) {
22148 if (that
._maxListeners
=== undefined)
22149 return EventEmitter
.defaultMaxListeners
;
22150 return that
._maxListeners
;
22153 EventEmitter
.prototype.getMaxListeners
= function getMaxListeners() {
22154 return $getMaxListeners(this);
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.
22162 function emitNone(handler
, isFn
, self
) {
22164 handler
.call(self
);
22166 var len
= handler
.length
;
22167 var listeners
= arrayClone(handler
, len
);
22168 for (var i
= 0; i
< len
; ++i
)
22169 listeners
[i
].call(self
);
22172 function emitOne(handler
, isFn
, self
, arg1
) {
22174 handler
.call(self
, arg1
);
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
);
22182 function emitTwo(handler
, isFn
, self
, arg1
, arg2
) {
22184 handler
.call(self
, arg1
, arg2
);
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
);
22192 function emitThree(handler
, isFn
, self
, arg1
, arg2
, arg3
) {
22194 handler
.call(self
, arg1
, arg2
, arg3
);
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
);
22203 function emitMany(handler
, isFn
, self
, args
) {
22205 handler
.apply(self
, args
);
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
);
22214 EventEmitter
.prototype.emit
= function emit(type
) {
22215 var er
, handler
, len
, args
, i
, events
;
22216 var doError
= (type
=== 'error');
22218 events
= this._events
;
22220 doError
= (doError
&& events
.error
== null);
22224 // If there is no 'error' event listener then throw.
22226 if (arguments
.length
> 1)
22228 if (er
instanceof Error
) {
22229 throw er
; // Unhandled 'error' event
22231 // At least give some kind of context to the user
22232 var err
= new Error('Unhandled "error" event. (' + er
+ ')');
22239 handler
= events
[type
];
22244 var isFn
= typeof handler
=== 'function';
22245 len
= arguments
.length
;
22249 emitNone(handler
, isFn
, this);
22252 emitOne(handler
, isFn
, this, arguments
[1]);
22255 emitTwo(handler
, isFn
, this, arguments
[1], arguments
[2]);
22258 emitThree(handler
, isFn
, this, arguments
[1], arguments
[2], arguments
[3]);
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
);
22271 function _addListener(target
, type
, listener
, prepend
) {
22276 if (typeof listener
!== 'function')
22277 throw new TypeError('"listener" argument must be a function');
22279 events
= target
._events
;
22281 events
= target
._events
= objectCreate(null);
22282 target
._eventsCount
= 0;
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
);
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
;
22294 existing
= events
[type
];
22298 // Optimize the case of one listener. Don't need the extra array object.
22299 existing
= events
[type
] = listener
;
22300 ++target
._eventsCount
;
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
];
22307 // If we've already got an array, just append.
22309 existing
.unshift(listener
);
22311 existing
.push(listener
);
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
;
22327 w
.count
= existing
.length
;
22328 if (typeof console
=== 'object' && console
.warn
) {
22329 console
.warn('%s: %s', w
.name
, w
.message
);
22338 EventEmitter
.prototype.addListener
= function addListener(type
, listener
) {
22339 return _addListener(this, type
, listener
, false);
22342 EventEmitter
.prototype.on
= EventEmitter
.prototype.addListener
;
22344 EventEmitter
.prototype.prependListener
=
22345 function prependListener(type
, listener
) {
22346 return _addListener(this, type
, listener
, true);
22349 function onceWrapper() {
22351 this.target
.removeListener(this.type
, this.wrapFn
);
22353 switch (arguments
.length
) {
22355 return this.listener
.call(this.target
);
22357 return this.listener
.call(this.target
, arguments
[0]);
22359 return this.listener
.call(this.target
, arguments
[0], arguments
[1]);
22361 return this.listener
.call(this.target
, arguments
[0], arguments
[1],
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
);
22372 function _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
;
22380 EventEmitter
.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
));
22387 EventEmitter
.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
));
22395 // Emits a 'removeListener' event if and only if the listener was removed.
22396 EventEmitter
.prototype.removeListener
=
22397 function removeListener(type
, listener
) {
22398 var list
, events
, position
, i
, originalListener
;
22400 if (typeof listener
!== 'function')
22401 throw new TypeError('"listener" argument must be a function');
22403 events
= this._events
;
22407 list
= events
[type
];
22411 if (list
=== listener
|| list
.listener
=== listener
) {
22412 if (--this._eventsCount
=== 0)
22413 this._events
= objectCreate(null);
22415 delete events
[type
];
22416 if (events
.removeListener
)
22417 this.emit('removeListener', type
, list
.listener
|| listener
);
22419 } else if (typeof list
!== 'function') {
22422 for (i
= list
.length
- 1; i
>= 0; i
--) {
22423 if (list
[i
] === listener
|| list
[i
].listener
=== listener
) {
22424 originalListener
= list
[i
].listener
;
22433 if (position
=== 0)
22436 spliceOne(list
, position
);
22438 if (list
.length
=== 1)
22439 events
[type
] = list
[0];
22441 if (events
.removeListener
)
22442 this.emit('removeListener', type
, originalListener
|| listener
);
22448 EventEmitter
.prototype.removeAllListeners
=
22449 function removeAllListeners(type
) {
22450 var listeners
, events
, i
;
22452 events
= this._events
;
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);
22465 delete events
[type
];
22470 // emit removeListener for all listeners on all events
22471 if (arguments
.length
=== 0) {
22472 var keys
= objectKeys(events
);
22474 for (i
= 0; i
< keys
.length
; ++i
) {
22476 if (key
=== 'removeListener') continue;
22477 this.removeAllListeners(key
);
22479 this.removeAllListeners('removeListener');
22480 this._events
= objectCreate(null);
22481 this._eventsCount
= 0;
22485 listeners
= events
[type
];
22487 if (typeof listeners
=== 'function') {
22488 this.removeListener(type
, listeners
);
22489 } else if (listeners
) {
22491 for (i
= listeners
.length
- 1; i
>= 0; i
--) {
22492 this.removeListener(type
, listeners
[i
]);
22499 function _listeners(target
, type
, unwrap
) {
22500 var events
= target
._events
;
22505 var evlistener
= events
[type
];
22509 if (typeof evlistener
=== 'function')
22510 return unwrap
? [evlistener
.listener
|| evlistener
] : [evlistener
];
22512 return unwrap
? unwrapListeners(evlistener
) : arrayClone(evlistener
, evlistener
.length
);
22515 EventEmitter
.prototype.listeners
= function listeners(type
) {
22516 return _listeners(this, type
, true);
22519 EventEmitter
.prototype.rawListeners
= function rawListeners(type
) {
22520 return _listeners(this, type
, false);
22523 EventEmitter
.listenerCount = function(emitter
, type
) {
22524 if (typeof emitter
.listenerCount
=== 'function') {
22525 return emitter
.listenerCount(type
);
22527 return listenerCount
.call(emitter
, type
);
22531 EventEmitter
.prototype.listenerCount
= listenerCount
;
22532 function listenerCount(type
) {
22533 var events
= this._events
;
22536 var evlistener
= events
[type
];
22538 if (typeof evlistener
=== 'function') {
22540 } else if (evlistener
) {
22541 return evlistener
.length
;
22548 EventEmitter
.prototype.eventNames
= function eventNames() {
22549 return this._eventsCount
> 0 ? Reflect
.ownKeys(this._events
) : [];
22552 // About 1.5x faster than the two-arg version of Array#splice().
22553 function spliceOne(list
, index
) {
22554 for (var i
= index
, k
= i
+ 1, n
= list
.length
; k
< n
; i
+= 1, k
+= 1)
22559 function arrayClone(arr
, n
) {
22560 var copy
= new Array(n
);
22561 for (var i
= 0; i
< n
; ++i
)
22566 function 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
];
22574 function objectCreatePolyfill(proto
) {
22575 var F = function() {};
22576 F
.prototype = proto
;
22579 function objectKeysPolyfill(obj
) {
22581 for (var k
in obj
) if (Object
.prototype.hasOwnProperty
.call(obj
, k
)) {
22586 function functionBindPolyfill(context
) {
22588 return function () {
22589 return fn
.apply(context
, arguments
);
22593 },{}],146:[function(require
,module
,exports
){
22594 arguments
[4][38][0].apply(exports
,arguments
)
22595 },{"dup":38,"md5.js":165,"safe-buffer":206}],147:[function(require
,module
,exports
){
22596 arguments
[4][43][0].apply(exports
,arguments
)
22597 },{"dup":43,"inherits":162,"safe-buffer":206,"stream":215}],148:[function(require
,module
,exports
){
22598 var hash
= exports
;
22600 hash
.utils
= require('./hash/utils');
22601 hash
.common
= require('./hash/common');
22602 hash
.sha
= require('./hash/sha');
22603 hash
.ripemd
= require('./hash/ripemd');
22604 hash
.hmac
= require('./hash/hmac');
22606 // Proxy hash functions to the main object
22607 hash
.sha1
= hash
.sha
.sha1
;
22608 hash
.sha256
= hash
.sha
.sha256
;
22609 hash
.sha224
= hash
.sha
.sha224
;
22610 hash
.sha384
= hash
.sha
.sha384
;
22611 hash
.sha512
= hash
.sha
.sha512
;
22612 hash
.ripemd160
= hash
.ripemd
.ripemd160
;
22614 },{"./hash/common":149,"./hash/hmac":150,"./hash/ripemd":151,"./hash/sha":152,"./hash/utils":159}],149:[function(require
,module
,exports
){
22617 var utils
= require('./utils');
22618 var assert
= require('minimalistic-assert');
22620 function 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';
22629 this._delta8
= this.blockSize
/ 8;
22630 this._delta32
= this.blockSize
/ 32;
22632 exports
.BlockHash
= BlockHash
;
22634 BlockHash
.prototype.update
= function update(msg
, enc
) {
22635 // Convert message to array, pad it, and join into 32bit blocks
22636 msg
= utils
.toArray(msg
, enc
);
22638 this.pending
= msg
;
22640 this.pending
= this.pending
.concat(msg
);
22641 this.pendingTotal
+= msg
.length
;
22643 // Enough data, try updating
22644 if (this.pending
.length
>= this._delta8
) {
22645 msg
= this.pending
;
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;
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
);
22661 BlockHash
.prototype.digest
= function digest(enc
) {
22662 this.update(this._pad());
22663 assert(this.pending
=== null);
22665 return this._digest(enc
);
22668 BlockHash
.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
);
22674 for (var i
= 1; i
< k
; i
++)
22679 if (this.endian
=== 'big') {
22680 for (var t
= 8; t
< this.padLength
; t
++)
22687 res
[i
++] = (len
>>> 24) & 0xff;
22688 res
[i
++] = (len
>>> 16) & 0xff;
22689 res
[i
++] = (len
>>> 8) & 0xff;
22690 res
[i
++] = len
& 0xff;
22692 res
[i
++] = len
& 0xff;
22693 res
[i
++] = (len
>>> 8) & 0xff;
22694 res
[i
++] = (len
>>> 16) & 0xff;
22695 res
[i
++] = (len
>>> 24) & 0xff;
22701 for (t
= 8; t
< this.padLength
; t
++)
22708 },{"./utils":159,"minimalistic-assert":167}],150:[function(require
,module
,exports
){
22711 var utils
= require('./utils');
22712 var assert
= require('minimalistic-assert');
22714 function Hmac(hash
, key
, enc
) {
22715 if (!(this instanceof Hmac
))
22716 return new Hmac(hash
, key
, enc
);
22718 this.blockSize
= hash
.blockSize
/ 8;
22719 this.outSize
= hash
.outSize
/ 8;
22723 this._init(utils
.toArray(key
, enc
));
22725 module
.exports
= Hmac
;
22727 Hmac
.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
);
22733 // Add padding to key
22734 for (var i
= key
.length
; i
< this.blockSize
; i
++)
22737 for (i
= 0; i
< key
.length
; i
++)
22739 this.inner
= new this.Hash().update(key
);
22741 // 0x36 ^ 0x5c = 0x6a
22742 for (i
= 0; i
< key
.length
; i
++)
22744 this.outer
= new this.Hash().update(key
);
22747 Hmac
.prototype.update
= function update(msg
, enc
) {
22748 this.inner
.update(msg
, enc
);
22752 Hmac
.prototype.digest
= function digest(enc
) {
22753 this.outer
.update(this.inner
.digest());
22754 return this.outer
.digest(enc
);
22757 },{"./utils":159,"minimalistic-assert":167}],151:[function(require
,module
,exports
){
22760 var utils
= require('./utils');
22761 var common
= require('./common');
22763 var rotl32
= utils
.rotl32
;
22764 var sum32
= utils
.sum32
;
22765 var sum32_3
= utils
.sum32_3
;
22766 var sum32_4
= utils
.sum32_4
;
22767 var BlockHash
= common
.BlockHash
;
22769 function RIPEMD160() {
22770 if (!(this instanceof RIPEMD160
))
22771 return new RIPEMD160();
22773 BlockHash
.call(this);
22775 this.h
= [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ];
22776 this.endian
= 'little';
22778 utils
.inherits(RIPEMD160
, BlockHash
);
22779 exports
.ripemd160
= RIPEMD160
;
22781 RIPEMD160
.blockSize
= 512;
22782 RIPEMD160
.outSize
= 160;
22783 RIPEMD160
.hmacStrength
= 192;
22784 RIPEMD160
.padLength
= 64;
22786 RIPEMD160
.prototype._update
= function update(msg
, start
) {
22797 for (var j
= 0; j
< 80; j
++) {
22800 sum32_4(A
, f(j
, B
, C
, D
), msg
[r
[j
] + start
], K(j
)),
22810 sum32_4(Ah
, f(79 - j
, Bh
, Ch
, Dh
), msg
[rh
[j
] + start
], Kh(j
)),
22815 Dh
= rotl32(Ch
, 10);
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
);
22827 RIPEMD160
.prototype._digest
= function digest(enc
) {
22829 return utils
.toHex32(this.h
, 'little');
22831 return utils
.split32(this.h
, 'little');
22834 function f(j
, x
, y
, z
) {
22838 return (x
& y
) | ((~x
) & z
);
22840 return (x
| (~y
)) ^ z
;
22842 return (x
& z
) | (y
& (~z
));
22844 return x
^ (y
| (~z
));
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
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
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
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
22905 },{"./common":149,"./utils":159}],152:[function(require
,module
,exports
){
22908 exports
.sha1
= require('./sha/1');
22909 exports
.sha224
= require('./sha/224');
22910 exports
.sha256
= require('./sha/256');
22911 exports
.sha384
= require('./sha/384');
22912 exports
.sha512
= require('./sha/512');
22914 },{"./sha/1":153,"./sha/224":154,"./sha/256":155,"./sha/384":156,"./sha/512":157}],153:[function(require
,module
,exports
){
22917 var utils
= require('../utils');
22918 var common
= require('../common');
22919 var shaCommon
= require('./common');
22921 var rotl32
= utils
.rotl32
;
22922 var sum32
= utils
.sum32
;
22923 var sum32_5
= utils
.sum32_5
;
22924 var ft_1
= shaCommon
.ft_1
;
22925 var BlockHash
= common
.BlockHash
;
22928 0x5A827999, 0x6ED9EBA1,
22929 0x8F1BBCDC, 0xCA62C1D6
22933 if (!(this instanceof SHA1
))
22936 BlockHash
.call(this);
22938 0x67452301, 0xefcdab89, 0x98badcfe,
22939 0x10325476, 0xc3d2e1f0 ];
22940 this.W
= new Array(80);
22943 utils
.inherits(SHA1
, BlockHash
);
22944 module
.exports
= SHA1
;
22946 SHA1
.blockSize
= 512;
22947 SHA1
.outSize
= 160;
22948 SHA1
.hmacStrength
= 80;
22949 SHA1
.padLength
= 64;
22951 SHA1
.prototype._update
= function _update(msg
, start
) {
22954 for (var i
= 0; i
< 16; i
++)
22955 W
[i
] = msg
[start
+ i
];
22957 for(; i
< W
.length
; i
++)
22958 W
[i
] = rotl32(W
[i
- 3] ^ W
[i
- 8] ^ W
[i
- 14] ^ W
[i
- 16], 1);
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
]);
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
);
22983 SHA1
.prototype._digest
= function digest(enc
) {
22985 return utils
.toHex32(this.h
, 'big');
22987 return utils
.split32(this.h
, 'big');
22990 },{"../common":149,"../utils":159,"./common":158}],154:[function(require
,module
,exports
){
22993 var utils
= require('../utils');
22994 var SHA256
= require('./256');
22996 function SHA224() {
22997 if (!(this instanceof SHA224
))
22998 return new SHA224();
23002 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
23003 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 ];
23005 utils
.inherits(SHA224
, SHA256
);
23006 module
.exports
= SHA224
;
23008 SHA224
.blockSize
= 512;
23009 SHA224
.outSize
= 224;
23010 SHA224
.hmacStrength
= 192;
23011 SHA224
.padLength
= 64;
23013 SHA224
.prototype._digest
= function digest(enc
) {
23014 // Just truncate output
23016 return utils
.toHex32(this.h
.slice(0, 7), 'big');
23018 return utils
.split32(this.h
.slice(0, 7), 'big');
23022 },{"../utils":159,"./256":155}],155:[function(require
,module
,exports
){
23025 var utils
= require('../utils');
23026 var common
= require('../common');
23027 var shaCommon
= require('./common');
23028 var assert
= require('minimalistic-assert');
23030 var sum32
= utils
.sum32
;
23031 var sum32_4
= utils
.sum32_4
;
23032 var sum32_5
= utils
.sum32_5
;
23033 var ch32
= shaCommon
.ch32
;
23034 var maj32
= shaCommon
.maj32
;
23035 var s0_256
= shaCommon
.s0_256
;
23036 var s1_256
= shaCommon
.s1_256
;
23037 var g0_256
= shaCommon
.g0_256
;
23038 var g1_256
= shaCommon
.g1_256
;
23040 var BlockHash
= common
.BlockHash
;
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
23061 function SHA256() {
23062 if (!(this instanceof SHA256
))
23063 return new SHA256();
23065 BlockHash
.call(this);
23067 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
23068 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
23071 this.W
= new Array(64);
23073 utils
.inherits(SHA256
, BlockHash
);
23074 module
.exports
= SHA256
;
23076 SHA256
.blockSize
= 512;
23077 SHA256
.outSize
= 256;
23078 SHA256
.hmacStrength
= 192;
23079 SHA256
.padLength
= 64;
23081 SHA256
.prototype._update
= function _update(msg
, start
) {
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]);
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
));
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
);
23122 SHA256
.prototype._digest
= function digest(enc
) {
23124 return utils
.toHex32(this.h
, 'big');
23126 return utils
.split32(this.h
, 'big');
23129 },{"../common":149,"../utils":159,"./common":158,"minimalistic-assert":167}],156:[function(require
,module
,exports
){
23132 var utils
= require('../utils');
23134 var SHA512
= require('./512');
23136 function SHA384() {
23137 if (!(this instanceof SHA384
))
23138 return new SHA384();
23142 0xcbbb9d5d, 0xc1059ed8,
23143 0x629a292a, 0x367cd507,
23144 0x9159015a, 0x3070dd17,
23145 0x152fecd8, 0xf70e5939,
23146 0x67332667, 0xffc00b31,
23147 0x8eb44a87, 0x68581511,
23148 0xdb0c2e0d, 0x64f98fa7,
23149 0x47b5481d, 0xbefa4fa4 ];
23151 utils
.inherits(SHA384
, SHA512
);
23152 module
.exports
= SHA384
;
23154 SHA384
.blockSize
= 1024;
23155 SHA384
.outSize
= 384;
23156 SHA384
.hmacStrength
= 192;
23157 SHA384
.padLength
= 128;
23159 SHA384
.prototype._digest
= function digest(enc
) {
23161 return utils
.toHex32(this.h
.slice(0, 12), 'big');
23163 return utils
.split32(this.h
.slice(0, 12), 'big');
23166 },{"../utils":159,"./512":157}],157:[function(require
,module
,exports
){
23169 var utils
= require('../utils');
23170 var common
= require('../common');
23171 var assert
= require('minimalistic-assert');
23173 var rotr64_hi
= utils
.rotr64_hi
;
23174 var rotr64_lo
= utils
.rotr64_lo
;
23175 var shr64_hi
= utils
.shr64_hi
;
23176 var shr64_lo
= utils
.shr64_lo
;
23177 var sum64
= utils
.sum64
;
23178 var sum64_hi
= utils
.sum64_hi
;
23179 var sum64_lo
= utils
.sum64_lo
;
23180 var sum64_4_hi
= utils
.sum64_4_hi
;
23181 var sum64_4_lo
= utils
.sum64_4_lo
;
23182 var sum64_5_hi
= utils
.sum64_5_hi
;
23183 var sum64_5_lo
= utils
.sum64_5_lo
;
23185 var BlockHash
= common
.BlockHash
;
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
23230 function SHA512() {
23231 if (!(this instanceof SHA512
))
23232 return new SHA512();
23234 BlockHash
.call(this);
23236 0x6a09e667, 0xf3bcc908,
23237 0xbb67ae85, 0x84caa73b,
23238 0x3c6ef372, 0xfe94f82b,
23239 0xa54ff53a, 0x5f1d36f1,
23240 0x510e527f, 0xade682d1,
23241 0x9b05688c, 0x2b3e6c1f,
23242 0x1f83d9ab, 0xfb41bd6b,
23243 0x5be0cd19, 0x137e2179 ];
23245 this.W
= new Array(160);
23247 utils
.inherits(SHA512
, BlockHash
);
23248 module
.exports
= SHA512
;
23250 SHA512
.blockSize
= 1024;
23251 SHA512
.outSize
= 512;
23252 SHA512
.hmacStrength
= 192;
23253 SHA512
.padLength
= 128;
23255 SHA512
.prototype._prepareBlock
= function _prepareBlock(msg
, start
) {
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];
23276 W
[i
+ 1] = sum64_4_lo(
23284 SHA512
.prototype._update
= function _update(msg
, start
) {
23285 this._prepareBlock(msg
, start
);
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];
23306 assert(this.k
.length
=== W
.length
);
23307 for (var i
= 0; i
< W
.length
; i
+= 2) {
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];
23317 var c4_lo
= W
[i
+ 1];
23319 var T1_hi
= sum64_5_hi(
23325 var T1_lo
= sum64_5_lo(
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
);
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
);
23349 eh
= sum64_hi(dh
, dl
, T1_hi
, T1_lo
);
23350 el
= sum64_lo(dl
, dl
, T1_hi
, T1_lo
);
23361 ah
= sum64_hi(T1_hi
, T1_lo
, T2_hi
, T2_lo
);
23362 al
= sum64_lo(T1_hi
, T1_lo
, T2_hi
, T2_lo
);
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
);
23375 SHA512
.prototype._digest
= function digest(enc
) {
23377 return utils
.toHex32(this.h
, 'big');
23379 return utils
.split32(this.h
, 'big');
23382 function ch64_hi(xh
, xl
, yh
, yl
, zh
) {
23383 var r
= (xh
& yh
) ^ ((~xh
) & zh
);
23389 function ch64_lo(xh
, xl
, yh
, yl
, zh
, zl
) {
23390 var r
= (xl
& yl
) ^ ((~xl
) & zl
);
23396 function maj64_hi(xh
, xl
, yh
, yl
, zh
) {
23397 var r
= (xh
& yh
) ^ (xh
& zh
) ^ (yh
& zh
);
23403 function maj64_lo(xh
, xl
, yh
, yl
, zh
, zl
) {
23404 var r
= (xl
& yl
) ^ (xl
& zl
) ^ (yl
& zl
);
23410 function 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
23415 var r
= c0_hi
^ c1_hi
^ c2_hi
;
23421 function 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
23426 var r
= c0_lo
^ c1_lo
^ c2_lo
;
23432 function 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
23437 var r
= c0_hi
^ c1_hi
^ c2_hi
;
23443 function 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
23448 var r
= c0_lo
^ c1_lo
^ c2_lo
;
23454 function 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);
23459 var r
= c0_hi
^ c1_hi
^ c2_hi
;
23465 function 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);
23470 var r
= c0_lo
^ c1_lo
^ c2_lo
;
23476 function 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);
23481 var r
= c0_hi
^ c1_hi
^ c2_hi
;
23487 function 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);
23492 var r
= c0_lo
^ c1_lo
^ c2_lo
;
23498 },{"../common":149,"../utils":159,"minimalistic-assert":167}],158:[function(require
,module
,exports
){
23501 var utils
= require('../utils');
23502 var rotr32
= utils
.rotr32
;
23504 function ft_1(s
, x
, y
, z
) {
23506 return ch32(x
, y
, z
);
23507 if (s
=== 1 || s
=== 3)
23508 return p32(x
, y
, z
);
23510 return maj32(x
, y
, z
);
23512 exports
.ft_1
= ft_1
;
23514 function ch32(x
, y
, z
) {
23515 return (x
& y
) ^ ((~x
) & z
);
23517 exports
.ch32
= ch32
;
23519 function maj32(x
, y
, z
) {
23520 return (x
& y
) ^ (x
& z
) ^ (y
& z
);
23522 exports
.maj32
= maj32
;
23524 function p32(x
, y
, z
) {
23529 function s0_256(x
) {
23530 return rotr32(x
, 2) ^ rotr32(x
, 13) ^ rotr32(x
, 22);
23532 exports
.s0_256
= s0_256
;
23534 function s1_256(x
) {
23535 return rotr32(x
, 6) ^ rotr32(x
, 11) ^ rotr32(x
, 25);
23537 exports
.s1_256
= s1_256
;
23539 function g0_256(x
) {
23540 return rotr32(x
, 7) ^ rotr32(x
, 18) ^ (x
>>> 3);
23542 exports
.g0_256
= g0_256
;
23544 function g1_256(x
) {
23545 return rotr32(x
, 17) ^ rotr32(x
, 19) ^ (x
>>> 10);
23547 exports
.g1_256
= g1_256
;
23549 },{"../utils":159}],159:[function(require
,module
,exports
){
23552 var assert
= require('minimalistic-assert');
23553 var inherits
= require('inherits');
23555 exports
.inherits
= inherits
;
23557 function isSurrogatePair(msg
, i
) {
23558 if ((msg
.charCodeAt(i
) & 0xFC00) !== 0xD800) {
23561 if (i
< 0 || i
+ 1 >= msg
.length
) {
23564 return (msg
.charCodeAt(i
+ 1) & 0xFC00) === 0xDC00;
23567 function toArray(msg
, enc
) {
23568 if (Array
.isArray(msg
))
23569 return msg
.slice();
23573 if (typeof msg
=== 'string') {
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
23580 for (var i
= 0; i
< msg
.length
; i
++) {
23581 var c
= msg
.charCodeAt(i
);
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;
23594 res
[p
++] = (c
>> 12) | 224;
23595 res
[p
++] = ((c
>> 6) & 63) | 128;
23596 res
[p
++] = (c
& 63) | 128;
23599 } else if (enc
=== 'hex') {
23600 msg
= msg
.replace(/[^a-z0-9]+/ig, '');
23601 if (msg
.length
% 2 !== 0)
23603 for (i
= 0; i
< msg
.length
; i
+= 2)
23604 res
.push(parseInt(msg
[i
] + msg
[i
+ 1], 16));
23607 for (i
= 0; i
< msg
.length
; i
++)
23608 res
[i
] = msg
[i
] | 0;
23612 exports
.toArray
= toArray
;
23614 function toHex(msg
) {
23616 for (var i
= 0; i
< msg
.length
; i
++)
23617 res
+= zero2(msg
[i
].toString(16));
23620 exports
.toHex
= toHex
;
23622 function htonl(w
) {
23623 var res
= (w
>>> 24) |
23624 ((w
>>> 8) & 0xff00) |
23625 ((w
<< 8) & 0xff0000) |
23626 ((w
& 0xff) << 24);
23629 exports
.htonl
= htonl
;
23631 function toHex32(msg
, endian
) {
23633 for (var i
= 0; i
< msg
.length
; i
++) {
23635 if (endian
=== 'little')
23637 res
+= zero8(w
.toString(16));
23641 exports
.toHex32
= toHex32
;
23643 function zero2(word
) {
23644 if (word
.length
=== 1)
23649 exports
.zero2
= zero2
;
23651 function zero8(word
) {
23652 if (word
.length
=== 7)
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
;
23669 exports
.zero8
= zero8
;
23671 function 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) {
23677 if (endian
=== 'big')
23678 w
= (msg
[k
] << 24) | (msg
[k
+ 1] << 16) | (msg
[k
+ 2] << 8) | msg
[k
+ 3];
23680 w
= (msg
[k
+ 3] << 24) | (msg
[k
+ 2] << 16) | (msg
[k
+ 1] << 8) | msg
[k
];
23685 exports
.join32
= join32
;
23687 function split32(msg
, endian
) {
23688 var res
= new Array(msg
.length
* 4);
23689 for (var i
= 0, k
= 0; i
< msg
.length
; i
++, k
+= 4) {
23691 if (endian
=== 'big') {
23693 res
[k
+ 1] = (m
>>> 16) & 0xff;
23694 res
[k
+ 2] = (m
>>> 8) & 0xff;
23695 res
[k
+ 3] = m
& 0xff;
23697 res
[k
+ 3] = m
>>> 24;
23698 res
[k
+ 2] = (m
>>> 16) & 0xff;
23699 res
[k
+ 1] = (m
>>> 8) & 0xff;
23705 exports
.split32
= split32
;
23707 function rotr32(w
, b
) {
23708 return (w
>>> b
) | (w
<< (32 - b
));
23710 exports
.rotr32
= rotr32
;
23712 function rotl32(w
, b
) {
23713 return (w
<< b
) | (w
>>> (32 - b
));
23715 exports
.rotl32
= rotl32
;
23717 function sum32(a
, b
) {
23718 return (a
+ b
) >>> 0;
23720 exports
.sum32
= sum32
;
23722 function sum32_3(a
, b
, c
) {
23723 return (a
+ b
+ c
) >>> 0;
23725 exports
.sum32_3
= sum32_3
;
23727 function sum32_4(a
, b
, c
, d
) {
23728 return (a
+ b
+ c
+ d
) >>> 0;
23730 exports
.sum32_4
= sum32_4
;
23732 function sum32_5(a
, b
, c
, d
, e
) {
23733 return (a
+ b
+ c
+ d
+ e
) >>> 0;
23735 exports
.sum32_5
= sum32_5
;
23737 function sum64(buf
, pos
, ah
, al
) {
23739 var bl
= buf
[pos
+ 1];
23741 var lo
= (al
+ bl
) >>> 0;
23742 var hi
= (lo
< al
? 1 : 0) + ah
+ bh
;
23743 buf
[pos
] = hi
>>> 0;
23746 exports
.sum64
= sum64
;
23748 function sum64_hi(ah
, al
, bh
, bl
) {
23749 var lo
= (al
+ bl
) >>> 0;
23750 var hi
= (lo
< al
? 1 : 0) + ah
+ bh
;
23753 exports
.sum64_hi
= sum64_hi
;
23755 function sum64_lo(ah
, al
, bh
, bl
) {
23759 exports
.sum64_lo
= sum64_lo
;
23761 function sum64_4_hi(ah
, al
, bh
, bl
, ch
, cl
, dh
, dl
) {
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;
23771 var hi
= ah
+ bh
+ ch
+ dh
+ carry
;
23774 exports
.sum64_4_hi
= sum64_4_hi
;
23776 function sum64_4_lo(ah
, al
, bh
, bl
, ch
, cl
, dh
, dl
) {
23777 var lo
= al
+ bl
+ cl
+ dl
;
23780 exports
.sum64_4_lo
= sum64_4_lo
;
23782 function sum64_5_hi(ah
, al
, bh
, bl
, ch
, cl
, dh
, dl
, eh
, el
) {
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;
23794 var hi
= ah
+ bh
+ ch
+ dh
+ eh
+ carry
;
23797 exports
.sum64_5_hi
= sum64_5_hi
;
23799 function sum64_5_lo(ah
, al
, bh
, bl
, ch
, cl
, dh
, dl
, eh
, el
) {
23800 var lo
= al
+ bl
+ cl
+ dl
+ el
;
23804 exports
.sum64_5_lo
= sum64_5_lo
;
23806 function rotr64_hi(ah
, al
, num
) {
23807 var r
= (al
<< (32 - num
)) | (ah
>>> num
);
23810 exports
.rotr64_hi
= rotr64_hi
;
23812 function rotr64_lo(ah
, al
, num
) {
23813 var r
= (ah
<< (32 - num
)) | (al
>>> num
);
23816 exports
.rotr64_lo
= rotr64_lo
;
23818 function shr64_hi(ah
, al
, num
) {
23821 exports
.shr64_hi
= shr64_hi
;
23823 function shr64_lo(ah
, al
, num
) {
23824 var r
= (ah
<< (32 - num
)) | (al
>>> num
);
23827 exports
.shr64_lo
= shr64_lo
;
23829 },{"inherits":162,"minimalistic-assert":167}],160:[function(require
,module
,exports
){
23832 var hash
= require('hash.js');
23833 var utils
= require('minimalistic-crypto-utils');
23834 var assert
= require('minimalistic-assert');
23836 function HmacDRBG(options
) {
23837 if (!(this instanceof HmacDRBG
))
23838 return new HmacDRBG(options
);
23839 this.hash
= options
.hash
;
23840 this.predResist
= !!options
.predResist
;
23842 this.outLen
= this.hash
.outSize
;
23843 this.minEntropy
= options
.minEntropy
|| this.hash
.hmacStrength
;
23845 this._reseed
= null;
23846 this.reseedInterval
= null;
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
);
23857 module
.exports
= HmacDRBG
;
23859 HmacDRBG
.prototype._init
= function init(entropy
, nonce
, pers
) {
23860 var seed
= entropy
.concat(nonce
).concat(pers
);
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
++) {
23869 this._update(seed
);
23871 this.reseedInterval
= 0x1000000000000; // 2^48
23874 HmacDRBG
.prototype._hmac
= function hmac() {
23875 return new hash
.hmac(this.hash
, this.K
);
23878 HmacDRBG
.prototype._update
= function update(seed
) {
23879 var kmac
= this._hmac()
23883 kmac
= kmac
.update(seed
);
23884 this.K
= kmac
.digest();
23885 this.V
= this._hmac().update(this.V
).digest();
23889 this.K
= this._hmac()
23894 this.V
= this._hmac().update(this.V
).digest();
23897 HmacDRBG
.prototype.reseed
= function reseed(entropy
, entropyEnc
, add
, addEnc
) {
23898 // Optional entropy enc
23899 if (typeof entropyEnc
!== 'string') {
23905 entropy
= utils
.toArray(entropy
, entropyEnc
);
23906 add
= utils
.toArray(add
, addEnc
);
23908 assert(entropy
.length
>= (this.minEntropy
/ 8),
23909 'Not enough entropy. Minimum is: ' + this.minEntropy
+ ' bits');
23911 this._update(entropy
.concat(add
|| []));
23915 HmacDRBG
.prototype.generate
= function generate(len
, enc
, add
, addEnc
) {
23916 if (this._reseed
> this.reseedInterval
)
23917 throw new Error('Reseed is required');
23919 // Optional encoding
23920 if (typeof enc
!== 'string') {
23926 // Optional additional data
23928 add
= utils
.toArray(add
, addEnc
|| 'hex');
23933 while (temp
.length
< len
) {
23934 this.V
= this._hmac().update(this.V
).digest();
23935 temp
= temp
.concat(this.V
);
23938 var res
= temp
.slice(0, len
);
23941 return utils
.encode(res
, enc
);
23944 },{"hash.js":148,"minimalistic-assert":167,"minimalistic-crypto-utils":168}],161:[function(require
,module
,exports
){
23945 exports
.read = function (buffer
, offset
, isLE
, mLen
, nBytes
) {
23947 var eLen
= (nBytes
* 8) - mLen
- 1
23948 var eMax
= (1 << eLen
) - 1
23949 var eBias
= eMax
>> 1
23951 var i
= isLE
? (nBytes
- 1) : 0
23952 var d
= isLE
? -1 : 1
23953 var s
= buffer
[offset
+ i
]
23957 e
= s
& ((1 << (-nBits
)) - 1)
23960 for (; nBits
> 0; e
= (e
* 256) + buffer
[offset
+ i
], i
+= d
, nBits
-= 8) {}
23962 m
= e
& ((1 << (-nBits
)) - 1)
23965 for (; nBits
> 0; m
= (m
* 256) + buffer
[offset
+ i
], i
+= d
, nBits
-= 8) {}
23969 } else if (e
=== eMax
) {
23970 return m
? NaN : ((s
? -1 : 1) * Infinity
)
23972 m
= m
+ Math
.pow(2, mLen
)
23975 return (s
? -1 : 1) * m
* Math
.pow(2, e
- mLen
)
23978 exports
.write = function (buffer
, value
, offset
, isLE
, mLen
, nBytes
) {
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
23988 value
= Math
.abs(value
)
23990 if (isNaN(value
) || value
=== Infinity
) {
23991 m
= isNaN(value
) ? 1 : 0
23994 e
= Math
.floor(Math
.log(value
) / Math
.LN2
)
23995 if (value
* (c
= Math
.pow(2, -e
)) < 1) {
23999 if (e
+ eBias
>= 1) {
24002 value
+= rt
* Math
.pow(2, 1 - eBias
)
24004 if (value
* c
>= 2) {
24009 if (e
+ eBias
>= eMax
) {
24012 } else if (e
+ eBias
>= 1) {
24013 m
= ((value
* c
) - 1) * Math
.pow(2, mLen
)
24016 m
= value
* Math
.pow(2, eBias
- 1) * Math
.pow(2, mLen
)
24021 for (; mLen
>= 8; buffer
[offset
+ i
] = m
& 0xff, i
+= d
, m
/= 256, mLen
-= 8) {}
24023 e
= (e
<< mLen
) | m
24025 for (; eLen
> 0; buffer
[offset
+ i
] = e
& 0xff, i
+= d
, e
/= 256, eLen
-= 8) {}
24027 buffer
[offset
+ i
- d
] |= s
* 128
24030 },{}],162:[function(require
,module
,exports
){
24031 arguments
[4][44][0].apply(exports
,arguments
)
24032 },{"dup":44}],163:[function(require
,module
,exports
){
24034 * Determine if an object is a Buffer
24036 * @author Feross Aboukhadijeh <https://feross.org>
24040 // The _isBuffer check is for Safari 5-7 support, because it's missing
24041 // Object.prototype.constructor. Remove this eventually
24042 module
.exports = function (obj
) {
24043 return obj
!= null && (isBuffer(obj
) || isSlowBuffer(obj
) || !!obj
._isBuffer
)
24046 function isBuffer (obj
) {
24047 return !!obj
.constructor && typeof obj
.constructor.isBuffer
=== 'function' && obj
.constructor.isBuffer(obj
)
24050 // For Node v0.10 support. Remove this eventually.
24051 function isSlowBuffer (obj
) {
24052 return typeof obj
.readFloatLE
=== 'function' && typeof obj
.slice
=== 'function' && isBuffer(obj
.slice(0, 0))
24055 },{}],164:[function(require
,module
,exports
){
24056 var toString
= {}.toString
;
24058 module
.exports
= Array
.isArray
|| function (arr
) {
24059 return toString
.call(arr
) == '[object Array]';
24062 },{}],165:[function(require
,module
,exports
){
24063 arguments
[4][45][0].apply(exports
,arguments
)
24064 },{"dup":45,"hash-base":147,"inherits":162,"safe-buffer":206}],166:[function(require
,module
,exports
){
24065 var bn
= require('bn.js');
24066 var brorand
= require('brorand');
24068 function MillerRabin(rand
) {
24069 this.rand
= rand
|| new brorand
.Rand();
24071 module
.exports
= MillerRabin
;
24073 MillerRabin
.create
= function create(rand
) {
24074 return new MillerRabin(rand
);
24077 MillerRabin
.prototype._randbelow
= function _randbelow(n
) {
24078 var len
= n
.bitLength();
24079 var min_bytes
= Math
.ceil(len
/ 8);
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.
24084 var a
= new bn(this.rand
.generate(min_bytes
));
24085 while (a
.cmp(n
) >= 0);
24090 MillerRabin
.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
));
24096 MillerRabin
.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
);
24102 k
= Math
.max(1, (len
/ 48) | 0);
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
++) {}
24109 var rn1
= n1
.toRed(red
);
24112 for (; k
> 0; k
--) {
24113 var a
= this._randrange(new bn(2), n1
);
24117 var x
= a
.toRed(red
).redPow(d
);
24118 if (x
.cmp(rone
) === 0 || x
.cmp(rn1
) === 0)
24121 for (var i
= 1; i
< s
; i
++) {
24124 if (x
.cmp(rone
) === 0)
24126 if (x
.cmp(rn1
) === 0)
24137 MillerRabin
.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
);
24143 k
= Math
.max(1, (len
/ 48) | 0);
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
++) {}
24150 var rn1
= n1
.toRed(red
);
24152 for (; k
> 0; k
--) {
24153 var a
= this._randrange(new bn(2), n1
);
24156 if (g
.cmpn(1) !== 0)
24159 var x
= a
.toRed(red
).redPow(d
);
24160 if (x
.cmp(rone
) === 0 || x
.cmp(rn1
) === 0)
24163 for (var i
= 1; i
< s
; i
++) {
24166 if (x
.cmp(rone
) === 0)
24167 return x
.fromRed().subn(1).gcd(n
);
24168 if (x
.cmp(rn1
) === 0)
24174 return x
.fromRed().subn(1).gcd(n
);
24181 },{"bn.js":79,"brorand":80}],167:[function(require
,module
,exports
){
24182 module
.exports
= assert
;
24184 function assert(val
, msg
) {
24186 throw new Error(msg
|| 'Assertion failed');
24189 assert
.equal
= function assertEqual(l
, r
, msg
) {
24191 throw new Error(msg
|| ('Assertion failed: ' + l
+ ' != ' + r
));
24194 },{}],168:[function(require
,module
,exports
){
24197 var utils
= exports
;
24199 function toArray(msg
, enc
) {
24200 if (Array
.isArray(msg
))
24201 return msg
.slice();
24205 if (typeof msg
!== 'string') {
24206 for (var i
= 0; i
< msg
.length
; i
++)
24207 res
[i
] = msg
[i
] | 0;
24210 if (enc
=== 'hex') {
24211 msg
= msg
.replace(/[^a-z0-9]+/ig, '');
24212 if (msg
.length
% 2 !== 0)
24214 for (var i
= 0; i
< msg
.length
; i
+= 2)
24215 res
.push(parseInt(msg
[i
] + msg
[i
+ 1], 16));
24217 for (var i
= 0; i
< msg
.length
; i
++) {
24218 var c
= msg
.charCodeAt(i
);
24229 utils
.toArray
= toArray
;
24231 function zero2(word
) {
24232 if (word
.length
=== 1)
24237 utils
.zero2
= zero2
;
24239 function toHex(msg
) {
24241 for (var i
= 0; i
< msg
.length
; i
++)
24242 res
+= zero2(msg
[i
].toString(16));
24245 utils
.toHex
= toHex
;
24247 utils
.encode
= function encode(arr
, enc
) {
24254 },{}],169:[function(require
,module
,exports
){
24262 /* eslint-disable no-unused-vars */
24263 var getOwnPropertySymbols
= Object
.getOwnPropertySymbols
;
24264 var hasOwnProperty
= Object
.prototype.hasOwnProperty
;
24265 var propIsEnumerable
= Object
.prototype.propertyIsEnumerable
;
24267 function toObject(val
) {
24268 if (val
=== null || val
=== undefined) {
24269 throw new TypeError('Object.assign cannot be called with null or undefined');
24272 return Object(val
);
24275 function shouldUseNative() {
24277 if (!Object
.assign
) {
24281 // Detect buggy property enumeration order in older V8 versions.
24283 // https://bugs.chromium.org/p/v8/issues/detail?id=4118
24284 var test1
= new String('abc'); // eslint-disable-line no-new-wrappers
24286 if (Object
.getOwnPropertyNames(test1
)[0] === '5') {
24290 // https://bugs.chromium.org/p/v8/issues/detail?id=3056
24292 for (var i
= 0; i
< 10; i
++) {
24293 test2
['_' + String
.fromCharCode(i
)] = i
;
24295 var order2
= Object
.getOwnPropertyNames(test2
).map(function (n
) {
24298 if (order2
.join('') !== '0123456789') {
24302 // https://bugs.chromium.org/p/v8/issues/detail?id=3056
24304 'abcdefghijklmnopqrst'.split('').forEach(function (letter
) {
24305 test3
[letter
] = letter
;
24307 if (Object
.keys(Object
.assign({}, test3
)).join('') !==
24308 'abcdefghijklmnopqrst') {
24314 // We don't expect any of the above to throw, but better to be safe.
24319 module
.exports
= shouldUseNative() ? Object
.assign : function (target
, source
) {
24321 var to
= toObject(target
);
24324 for (var s
= 1; s
< arguments
.length
; s
++) {
24325 from = Object(arguments
[s
]);
24327 for (var key
in from) {
24328 if (hasOwnProperty
.call(from, key
)) {
24329 to
[key
] = from[key
];
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
]];
24346 },{}],170:[function(require
,module
,exports
){
24347 module
.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"
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.
24365 var asn1
= require('asn1.js')
24367 exports
.certificate
= require('./certificate')
24369 var RSAPrivateKey
= asn1
.define('RSAPrivateKey', function () {
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()
24382 exports
.RSAPrivateKey
= RSAPrivateKey
24384 var RSAPublicKey
= asn1
.define('RSAPublicKey', function () {
24386 this.key('modulus').int(),
24387 this.key('publicExponent').int()
24390 exports
.RSAPublicKey
= RSAPublicKey
24392 var PublicKey
= asn1
.define('SubjectPublicKeyInfo', function () {
24394 this.key('algorithm').use(AlgorithmIdentifier
),
24395 this.key('subjectPublicKey').bitstr()
24398 exports
.PublicKey
= PublicKey
24400 var AlgorithmIdentifier
= asn1
.define('AlgorithmIdentifier', function () {
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()
24413 var PrivateKeyInfo
= asn1
.define('PrivateKeyInfo', function () {
24415 this.key('version').int(),
24416 this.key('algorithm').use(AlgorithmIdentifier
),
24417 this.key('subjectPrivateKey').octstr()
24420 exports
.PrivateKey
= PrivateKeyInfo
24421 var EncryptedPrivateKeyInfo
= asn1
.define('EncryptedPrivateKeyInfo', function () {
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()
24433 this.key('cipher').seq().obj(
24434 this.key('algo').objid(),
24435 this.key('iv').octstr()
24439 this.key('subjectPrivateKey').octstr()
24443 exports
.EncryptedPrivateKey
= EncryptedPrivateKeyInfo
24445 var DSAPrivateKey
= asn1
.define('DSAPrivateKey', function () {
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()
24455 exports
.DSAPrivateKey
= DSAPrivateKey
24457 exports
.DSAparam
= asn1
.define('DSAparam', function () {
24461 var ECPrivateKey
= asn1
.define('ECPrivateKey', function () {
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()
24469 exports
.ECPrivateKey
= ECPrivateKey
24471 var ECParameters
= asn1
.define('ECParameters', function () {
24473 namedCurve: this.objid()
24477 exports
.signature
= asn1
.define('signature', function () {
24479 this.key('r').int(),
24480 this.key('s').int()
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
24490 var asn
= require('asn1.js')
24492 var Time
= asn
.define('Time', function () {
24494 utcTime: this.utctime(),
24495 generalTime: this.gentime()
24499 var AttributeTypeValue
= asn
.define('AttributeTypeValue', function () {
24501 this.key('type').objid(),
24502 this.key('value').any()
24506 var AlgorithmIdentifier
= asn
.define('AlgorithmIdentifier', function () {
24508 this.key('algorithm').objid(),
24509 this.key('parameters').optional(),
24510 this.key('curve').objid().optional()
24514 var SubjectPublicKeyInfo
= asn
.define('SubjectPublicKeyInfo', function () {
24516 this.key('algorithm').use(AlgorithmIdentifier
),
24517 this.key('subjectPublicKey').bitstr()
24521 var RelativeDistinguishedName
= asn
.define('RelativeDistinguishedName', function () {
24522 this.setof(AttributeTypeValue
)
24525 var RDNSequence
= asn
.define('RDNSequence', function () {
24526 this.seqof(RelativeDistinguishedName
)
24529 var Name
= asn
.define('Name', function () {
24531 rdnSequence: this.use(RDNSequence
)
24535 var Validity
= asn
.define('Validity', function () {
24537 this.key('notBefore').use(Time
),
24538 this.key('notAfter').use(Time
)
24542 var Extension
= asn
.define('Extension', function () {
24544 this.key('extnID').objid(),
24545 this.key('critical').bool().def(false),
24546 this.key('extnValue').octstr()
24550 var TBSCertificate
= asn
.define('TBSCertificate', function () {
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()
24565 var X509Certificate
= asn
.define('X509Certificate', function () {
24567 this.key('tbsCertificate').use(TBSCertificate
),
24568 this.key('signatureAlgorithm').use(AlgorithmIdentifier
),
24569 this.key('signatureValue').bitstr()
24573 module
.exports
= X509Certificate
24575 },{"asn1.js":60}],173:[function(require
,module
,exports
){
24576 // adapted from https://github.com/apatil/pemstrip
24577 var 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
24578 var startRegex
= /^-----BEGIN ((?:.*? KEY
)|CERTIFICATE
)-----/m
24579 var fullRegex
= /^-----BEGIN ((?:.*? KEY
)|CERTIFICATE
)-----([0-9A
-z
\n\r\+\/\=]+)-----END
\1-----$/m
24580 var evp
= require('evp_bytestokey')
24581 var ciphers
= require('browserify-aes')
24582 var Buffer
= require('safe-buffer').Buffer
24583 module
.exports = function (okey
, password
) {
24584 var key
= okey
.toString()
24585 var match
= key
.match(findProc
)
24588 var match2
= key
.match(fullRegex
)
24589 decrypted
= new Buffer(match2
[2].replace(/[\r\n]/g, ''), 'base64')
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
24596 var cipher
= ciphers
.createDecipheriv(suite
, cipherKey
, iv
)
24597 out
.push(cipher
.update(cipherText
))
24598 out
.push(cipher
.final())
24599 decrypted
= Buffer
.concat(out
)
24601 var tag
= key
.match(startRegex
)[1]
24608 },{"browserify-aes":84,"evp_bytestokey":146,"safe-buffer":206}],174:[function(require
,module
,exports
){
24609 var asn1
= require('./asn1')
24610 var aesid
= require('./aesid.json')
24611 var fixProc
= require('./fixProc')
24612 var ciphers
= require('browserify-aes')
24613 var compat
= require('pbkdf2')
24614 var Buffer
= require('safe-buffer').Buffer
24615 module
.exports
= parseKeys
24617 function parseKeys (buffer
) {
24619 if (typeof buffer
=== 'object' && !Buffer
.isBuffer(buffer
)) {
24620 password
= buffer
.passphrase
24621 buffer
= buffer
.key
24623 if (typeof buffer
=== 'string') {
24624 buffer
= Buffer
.from(buffer
)
24627 var stripped
= fixProc(buffer
, password
)
24629 var type
= stripped
.tag
24630 var data
= stripped
.data
24633 case 'CERTIFICATE':
24634 ndata
= asn1
.certificate
.decode(data
, 'der').tbsCertificate
.subjectPublicKeyInfo
24638 ndata
= asn1
.PublicKey
.decode(data
, 'der')
24640 subtype
= ndata
.algorithm
.algorithm
.join('.')
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
24650 case '1.2.840.10040.4.1':
24651 ndata
.algorithm
.params
.pub_key
= asn1
.DSAparam
.decode(ndata
.subjectPublicKey
.data
, 'der')
24654 data: ndata
.algorithm
.params
24656 default: throw new Error('unknown key id ' + subtype
)
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
)
24663 case 'PRIVATE KEY':
24664 ndata
= asn1
.PrivateKey
.decode(data
, 'der')
24665 subtype
= ndata
.algorithm
.algorithm
.join('.')
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':
24671 curve: ndata
.algorithm
.curve
,
24672 privateKey: asn1
.ECPrivateKey
.decode(ndata
.subjectPrivateKey
, 'der').privateKey
24674 case '1.2.840.10040.4.1':
24675 ndata
.algorithm
.params
.priv_key
= asn1
.DSAparam
.decode(ndata
.subjectPrivateKey
, 'der')
24678 params: ndata
.algorithm
.params
24680 default: throw new Error('unknown key id ' + subtype
)
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':
24690 params: asn1
.DSAPrivateKey
.decode(data
, 'der')
24692 case 'EC PRIVATE KEY':
24693 data
= asn1
.ECPrivateKey
.decode(data
, 'der')
24695 curve: data
.parameters
.value
,
24696 privateKey: data
.privateKey
24698 default: throw new Error('unknown key type ' + type
)
24701 parseKeys
.signature
= asn1
.signature
24702 function 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
)
24712 out
.push(cipher
.update(cipherText
))
24713 out
.push(cipher
.final())
24714 return Buffer
.concat(out
)
24717 },{"./aesid.json":170,"./asn1":171,"./fixProc":173,"browserify-aes":84,"pbkdf2":175,"safe-buffer":206}],175:[function(require
,module
,exports
){
24718 exports
.pbkdf2
= require('./lib/async')
24719 exports
.pbkdf2Sync
= require('./lib/sync')
24721 },{"./lib/async":176,"./lib/sync":179}],176:[function(require
,module
,exports
){
24722 (function (process
,global
){
24723 var checkParameters
= require('./precondition')
24724 var defaultEncoding
= require('./default-encoding')
24725 var sync
= require('./sync')
24726 var Buffer
= require('safe-buffer').Buffer
24729 var subtle
= global
.crypto
&& global
.crypto
.subtle
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'
24742 function checkNative (algo
) {
24743 if (global
.process
&& !global
.process
.browser
) {
24744 return Promise
.resolve(false)
24746 if (!subtle
|| !subtle
.importKey
|| !subtle
.deriveBits
) {
24747 return Promise
.resolve(false)
24749 if (checks
[algo
] !== undefined) {
24750 return checks
[algo
]
24752 ZERO_BUF
= ZERO_BUF
|| Buffer
.alloc(8)
24753 var prom
= browserPbkdf2(ZERO_BUF
, ZERO_BUF
, 10, 128, algo
)
24754 .then(function () {
24756 }).catch(function () {
24759 checks
[algo
] = prom
24763 function 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({
24770 iterations: iterations
,
24774 }, key
, length
<< 3)
24775 }).then(function (res
) {
24776 return Buffer
.from(res
)
24780 function resolvePromise (promise
, callback
) {
24781 promise
.then(function (out
) {
24782 process
.nextTick(function () {
24783 callback(null, out
)
24786 process
.nextTick(function () {
24791 module
.exports = function (password
, salt
, iterations
, keylen
, digest
, callback
) {
24792 if (typeof digest
=== 'function') {
24797 digest
= digest
|| 'sha1'
24798 var algo
= toBrowser
[digest
.toLowerCase()]
24800 if (!algo
|| typeof global
.Promise
!== 'function') {
24801 return process
.nextTick(function () {
24804 out
= sync(password
, salt
, iterations
, keylen
, digest
)
24808 callback(null, out
)
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
)
24817 resolvePromise(checkNative(algo
).then(function (resp
) {
24818 if (resp
) return browserPbkdf2(password
, salt
, iterations
, keylen
, algo
)
24820 return sync(password
, salt
, iterations
, keylen
, digest
)
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
){
24827 var defaultEncoding
24828 /* istanbul ignore next */
24829 if (process
.browser
) {
24830 defaultEncoding
= 'utf-8'
24832 var pVersionMajor
= parseInt(process
.version
.split('.')[0].slice(1), 10)
24834 defaultEncoding
= pVersionMajor
>= 6 ? 'utf-8' : 'binary'
24836 module
.exports
= defaultEncoding
24838 }).call(this,require('_process'))
24839 },{"_process":181}],178:[function(require
,module
,exports
){
24840 (function (Buffer
){
24841 var MAX_ALLOC
= Math
.pow(2, 30) - 1 // default in iojs
24843 function checkBuffer (buf
, name
) {
24844 if (typeof buf
!== 'string' && !Buffer
.isBuffer(buf
)) {
24845 throw new TypeError(name
+ ' must be a buffer or string')
24849 module
.exports = function (password
, salt
, iterations
, keylen
) {
24850 checkBuffer(password
, 'Password')
24851 checkBuffer(salt
, 'Salt')
24853 if (typeof iterations
!== 'number') {
24854 throw new TypeError('Iterations not a number')
24857 if (iterations
< 0) {
24858 throw new TypeError('Bad iterations')
24861 if (typeof keylen
!== 'number') {
24862 throw new TypeError('Key length not a number')
24865 if (keylen
< 0 || keylen
> MAX_ALLOC
|| keylen
!== keylen
) { /* eslint no-self-compare: 0 */
24866 throw new TypeError('Bad key length')
24870 }).call(this,{"isBuffer":require("../../is-buffer/index.js")})
24871 },{"../../is-buffer/index.js":163}],179:[function(require
,module
,exports
){
24872 var md5
= require('create-hash/md5')
24873 var RIPEMD160
= require('ripemd160')
24874 var sha
= require('sha.js')
24876 var checkParameters
= require('./precondition')
24877 var defaultEncoding
= require('./default-encoding')
24878 var Buffer
= require('safe-buffer').Buffer
24879 var ZEROS
= Buffer
.alloc(128)
24891 function Hmac (alg
, key
, saltLen
) {
24892 var hash
= getDigest(alg
)
24893 var blocksize
= (alg
=== 'sha512' || alg
=== 'sha384') ? 128 : 64
24895 if (key
.length
> blocksize
) {
24897 } else if (key
.length
< blocksize
) {
24898 key
= Buffer
.concat([key
, ZEROS
], blocksize
)
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
24908 var ipad1
= Buffer
.allocUnsafe(blocksize
+ saltLen
+ 4)
24909 ipad
.copy(ipad1
, 0, 0, blocksize
)
24914 this.blocksize
= blocksize
24916 this.size
= sizes
[alg
]
24919 Hmac
.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
)
24926 function getDigest (alg
) {
24927 function shaFunc (data
) {
24928 return sha(alg
).update(data
).digest()
24930 function rmd160Func (data
) {
24931 return new RIPEMD160().update(data
).digest()
24934 if (alg
=== 'rmd160' || alg
=== 'ripemd160') return rmd160Func
24935 if (alg
=== 'md5') return md5
24939 function pbkdf2 (password
, salt
, iterations
, keylen
, digest
) {
24940 checkParameters(password
, salt
, iterations
, keylen
)
24942 if (!Buffer
.isBuffer(password
)) password
= Buffer
.from(password
, defaultEncoding
)
24943 if (!Buffer
.isBuffer(salt
)) salt
= Buffer
.from(salt
, defaultEncoding
)
24945 digest
= digest
|| 'sha1'
24947 var hmac
= new Hmac(digest
, password
, salt
.length
)
24949 var DK
= Buffer
.allocUnsafe(keylen
)
24950 var block1
= Buffer
.allocUnsafe(salt
.length
+ 4)
24951 salt
.copy(block1
, 0, 0, salt
.length
)
24954 var hLen
= sizes
[digest
]
24955 var l
= Math
.ceil(keylen
/ hLen
)
24957 for (var i
= 1; i
<= l
; i
++) {
24958 block1
.writeUInt32BE(i
, salt
.length
)
24960 var T
= hmac
.run(block1
, hmac
.ipad1
)
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
]
24968 T
.copy(DK
, destPos
)
24975 module
.exports
= pbkdf2
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
){
24981 if (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
};
24987 module
.exports
= process
24990 function nextTick(fn
, arg1
, arg2
, arg3
) {
24991 if (typeof fn
!== 'function') {
24992 throw new TypeError('"callback" argument must be a function');
24994 var len
= arguments
.length
;
24999 return process
.nextTick(fn
);
25001 return process
.nextTick(function afterTickOne() {
25002 fn
.call(null, arg1
);
25005 return process
.nextTick(function afterTickTwo() {
25006 fn
.call(null, arg1
, arg2
);
25009 return process
.nextTick(function afterTickThree() {
25010 fn
.call(null, arg1
, arg2
, arg3
);
25013 args
= new Array(len
- 1);
25015 while (i
< args
.length
) {
25016 args
[i
++] = arguments
[i
];
25018 return process
.nextTick(function afterTick() {
25019 fn
.apply(null, args
);
25025 }).call(this,require('_process'))
25026 },{"_process":181}],181:[function(require
,module
,exports
){
25027 // shim for using process in browser
25028 var process
= module
.exports
= {};
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.
25035 var cachedSetTimeout
;
25036 var cachedClearTimeout
;
25038 function defaultSetTimout() {
25039 throw new Error('setTimeout has not been defined');
25041 function defaultClearTimeout () {
25042 throw new Error('clearTimeout has not been defined');
25046 if (typeof setTimeout
=== 'function') {
25047 cachedSetTimeout
= setTimeout
;
25049 cachedSetTimeout
= defaultSetTimout
;
25052 cachedSetTimeout
= defaultSetTimout
;
25055 if (typeof clearTimeout
=== 'function') {
25056 cachedClearTimeout
= clearTimeout
;
25058 cachedClearTimeout
= defaultClearTimeout
;
25061 cachedClearTimeout
= defaultClearTimeout
;
25064 function runTimeout(fun
) {
25065 if (cachedSetTimeout
=== setTimeout
) {
25066 //normal enviroments in sane situations
25067 return setTimeout(fun
, 0);
25069 // if setTimeout wasn't available but was latter defined
25070 if ((cachedSetTimeout
=== defaultSetTimout
|| !cachedSetTimeout
) && setTimeout
) {
25071 cachedSetTimeout
= setTimeout
;
25072 return setTimeout(fun
, 0);
25075 // when when somebody has screwed with setTimeout but no I.E. maddness
25076 return cachedSetTimeout(fun
, 0);
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);
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);
25089 function runClearTimeout(marker
) {
25090 if (cachedClearTimeout
=== clearTimeout
) {
25091 //normal enviroments in sane situations
25092 return clearTimeout(marker
);
25094 // if clearTimeout wasn't available but was latter defined
25095 if ((cachedClearTimeout
=== defaultClearTimeout
|| !cachedClearTimeout
) && clearTimeout
) {
25096 cachedClearTimeout
= clearTimeout
;
25097 return clearTimeout(marker
);
25100 // when when somebody has screwed with setTimeout but no I.E. maddness
25101 return cachedClearTimeout(marker
);
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
);
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
);
25117 var draining
= false;
25119 var queueIndex
= -1;
25121 function cleanUpNextTick() {
25122 if (!draining
|| !currentQueue
) {
25126 if (currentQueue
.length
) {
25127 queue
= currentQueue
.concat(queue
);
25131 if (queue
.length
) {
25136 function drainQueue() {
25140 var timeout
= runTimeout(cleanUpNextTick
);
25143 var len
= queue
.length
;
25145 currentQueue
= queue
;
25147 while (++queueIndex
< len
) {
25148 if (currentQueue
) {
25149 currentQueue
[queueIndex
].run();
25153 len
= queue
.length
;
25155 currentQueue
= null;
25157 runClearTimeout(timeout
);
25160 process
.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
];
25167 queue
.push(new Item(fun
, args
));
25168 if (queue
.length
=== 1 && !draining
) {
25169 runTimeout(drainQueue
);
25173 // v8 likes predictible objects
25174 function Item(fun
, array
) {
25176 this.array
= array
;
25178 Item
.prototype.run = function () {
25179 this.fun
.apply(null, this.array
);
25181 process
.title
= 'browser';
25182 process
.browser
= true;
25185 process
.version
= ''; // empty string to avoid regexp issues
25186 process
.versions
= {};
25191 process
.addListener
= noop
;
25192 process
.once
= noop
;
25193 process
.off
= noop
;
25194 process
.removeListener
= noop
;
25195 process
.removeAllListeners
= noop
;
25196 process
.emit
= noop
;
25197 process
.prependListener
= noop
;
25198 process
.prependOnceListener
= noop
;
25200 process
.listeners = function (name
) { return [] }
25202 process
.binding = function (name
) {
25203 throw new Error('process.binding is not supported');
25206 process
.cwd = function () { return '/' };
25207 process
.chdir = function (dir
) {
25208 throw new Error('process.chdir is not supported');
25210 process
.umask = function() { return 0; };
25212 },{}],182:[function(require
,module
,exports
){
25213 exports
.publicEncrypt
= require('./publicEncrypt')
25214 exports
.privateDecrypt
= require('./privateDecrypt')
25216 exports
.privateEncrypt
= function privateEncrypt (key
, buf
) {
25217 return exports
.publicEncrypt(key
, buf
, true)
25220 exports
.publicDecrypt
= function publicDecrypt (key
, buf
) {
25221 return exports
.privateDecrypt(key
, buf
, true)
25224 },{"./privateDecrypt":184,"./publicEncrypt":185}],183:[function(require
,module
,exports
){
25225 var createHash
= require('create-hash')
25226 var Buffer
= require('safe-buffer').Buffer
25228 module
.exports = function (seed
, len
) {
25229 var t
= Buffer
.alloc(0)
25232 while (t
.length
< len
) {
25234 t
= Buffer
.concat([t
, createHash('sha1').update(seed
).update(c
).digest()])
25236 return t
.slice(0, len
)
25239 function i2ops (c
) {
25240 var out
= Buffer
.allocUnsafe(4)
25241 out
.writeUInt32BE(c
, 0)
25245 },{"create-hash":114,"safe-buffer":206}],184:[function(require
,module
,exports
){
25246 var parseKeys
= require('parse-asn1')
25247 var mgf
= require('./mgf')
25248 var xor
= require('./xor')
25249 var BN
= require('bn.js')
25250 var crt
= require('browserify-rsa')
25251 var createHash
= require('create-hash')
25252 var withPublic
= require('./withPublic')
25253 var Buffer
= require('safe-buffer').Buffer
25255 module
.exports
= function privateDecrypt (privateKey
, enc
, reverse
) {
25257 if (privateKey
.padding
) {
25258 padding
= privateKey
.padding
25259 } else if (reverse
) {
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')
25272 msg
= withPublic(new BN(enc
), key
)
25274 msg
= crt(enc
, key
)
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) {
25285 throw new Error('unknown padding')
25289 function 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')
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')
25304 while (db
[i
] === 0) {
25307 if (db
[i
++] !== 1) {
25308 throw new Error('decryption error')
25313 function pkcs1 (key
, msg
, reverse
) {
25314 var p1
= msg
.slice(0, 2)
25317 while (msg
[i
++] !== 0) {
25318 if (i
>= msg
.length
) {
25323 var ps
= msg
.slice(2, i
- 1)
25325 if ((p1
.toString('hex') !== '0002' && !reverse
) || (p1
.toString('hex') !== '0001' && reverse
)) {
25328 if (ps
.length
< 8) {
25332 throw new Error('decryption error')
25334 return msg
.slice(i
)
25336 function compare (a
, b
) {
25341 if (a
.length
!== b
.length
) {
25343 len
= Math
.min(a
.length
, b
.length
)
25346 while (++i
< len
) {
25347 dif
+= (a
[i
] ^ b
[i
])
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
){
25353 var parseKeys
= require('parse-asn1')
25354 var randomBytes
= require('randombytes')
25355 var createHash
= require('create-hash')
25356 var mgf
= require('./mgf')
25357 var xor
= require('./xor')
25358 var BN
= require('bn.js')
25359 var withPublic
= require('./withPublic')
25360 var crt
= require('browserify-rsa')
25361 var Buffer
= require('safe-buffer').Buffer
25363 module
.exports
= function publicEncrypt (publicKey
, msg
, reverse
) {
25365 if (publicKey
.padding
) {
25366 padding
= publicKey
.padding
25367 } else if (reverse
) {
25372 var key
= parseKeys(publicKey
)
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')
25384 throw new Error('unknown padding')
25387 return crt(paddedMsg
, key
)
25389 return withPublic(paddedMsg
, key
)
25393 function 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')
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
))
25409 function 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')
25417 ps
= Buffer
.alloc(k
- mLen
- 3, 0xff)
25419 ps
= nonZero(k
- mLen
- 3)
25421 return new BN(Buffer
.concat([Buffer
.from([0, reverse
? 1 : 2]), ps
, Buffer
.alloc(1), msg
], k
))
25423 function nonZero (len
) {
25424 var out
= Buffer
.allocUnsafe(len
)
25426 var cache
= randomBytes(len
* 2)
25430 if (cur
=== cache
.length
) {
25431 cache
= randomBytes(len
* 2)
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
){
25443 var BN
= require('bn.js')
25444 var Buffer
= require('safe-buffer').Buffer
25446 function withPublic (paddedMsg
, key
) {
25447 return Buffer
.from(paddedMsg
25448 .toRed(BN
.mont(key
.modulus
))
25449 .redPow(new BN(key
.publicExponent
))
25454 module
.exports
= withPublic
25456 },{"bn.js":79,"safe-buffer":206}],187:[function(require
,module
,exports
){
25457 module
.exports
= function xor (a
, b
) {
25460 while (++i
< len
) {
25466 },{}],188:[function(require
,module
,exports
){
25467 (function (process
,global
){
25470 // limit of Crypto.getRandomValues()
25471 // https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues
25472 var MAX_BYTES
= 65536
25474 // Node supports requesting up to this number of bytes
25475 // https://github.com/nodejs/node/blob/master/lib/internal/crypto/random.js#L48
25476 var MAX_UINT32
= 4294967295
25478 function oldBrowser () {
25479 throw new Error('Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11')
25482 var Buffer
= require('safe-buffer').Buffer
25483 var crypto
= global
.crypto
|| global
.msCrypto
25485 if (crypto
&& crypto
.getRandomValues
) {
25486 module
.exports
= randomBytes
25488 module
.exports
= oldBrowser
25491 function randomBytes (size
, cb
) {
25492 // phantomjs needs to throw
25493 if (size
> MAX_UINT32
) throw new RangeError('requested too many random bytes')
25495 var bytes
= Buffer
.allocUnsafe(size
)
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
))
25506 crypto
.getRandomValues(bytes
)
25510 if (typeof cb
=== 'function') {
25511 return process
.nextTick(function () {
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
){
25524 function oldBrowser () {
25525 throw new Error('secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11')
25527 var safeBuffer
= require('safe-buffer')
25528 var randombytes
= require('randombytes')
25529 var Buffer
= safeBuffer
.Buffer
25530 var kBufferMaxLength
= safeBuffer
.kMaxLength
25531 var crypto
= global
.crypto
|| global
.msCrypto
25532 var kMaxUint32
= Math
.pow(2, 32) - 1
25533 function 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')
25538 if (offset
> kMaxUint32
|| offset
< 0) {
25539 throw new TypeError('offset must be a uint32')
25542 if (offset
> kBufferMaxLength
|| offset
> length
) {
25543 throw new RangeError('offset out of range')
25547 function 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')
25552 if (size
> kMaxUint32
|| size
< 0) {
25553 throw new TypeError('size must be a uint32')
25556 if (size
+ offset
> length
|| size
> kBufferMaxLength
) {
25557 throw new RangeError('buffer too small')
25560 if ((crypto
&& crypto
.getRandomValues
) || !process
.browser
) {
25561 exports
.randomFill
= randomFill
25562 exports
.randomFillSync
= randomFillSync
25564 exports
.randomFill
= oldBrowser
25565 exports
.randomFillSync
= oldBrowser
25567 function 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')
25572 if (typeof offset
=== 'function') {
25576 } else if (typeof size
=== 'function') {
25578 size
= buf
.length
- offset
25579 } else if (typeof cb
!== 'function') {
25580 throw new TypeError('"cb" argument must be a function')
25582 assertOffset(offset
, buf
.length
)
25583 assertSize(size
, offset
, buf
.length
)
25584 return actualFill(buf
, offset
, size
, cb
)
25587 function 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)
25593 process
.nextTick(function () {
25601 randombytes(size
, function (err
, bytes
) {
25605 bytes
.copy(buf
, offset
)
25610 var bytes
= randombytes(size
)
25611 bytes
.copy(buf
, offset
)
25614 function randomFillSync (buf
, offset
, size
) {
25615 if (typeof offset
=== 'undefined') {
25618 if (!Buffer
.isBuffer(buf
) && !(buf
instanceof global
.Uint8Array
)) {
25619 throw new TypeError('"buf" argument must be a Buffer or Uint8Array')
25622 assertOffset(offset
, buf
.length
)
25624 if (size
=== undefined) size
= buf
.length
- offset
25626 assertSize(size
, offset
, buf
.length
)
25628 return actualFill(buf
, offset
, size
)
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
){
25633 module
.exports
= require('./lib/_stream_duplex.js');
25635 },{"./lib/_stream_duplex.js":191}],191:[function(require
,module
,exports
){
25636 // Copyright Joyent, Inc. and other Node contributors.
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:
25646 // The above copyright notice and this permission notice shall be included
25647 // in all copies or substantial portions of the Software.
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.
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
25666 var pna
= require('process-nextick-args');
25670 var objectKeys
= Object
.keys
|| function (obj
) {
25672 for (var key
in obj
) {
25678 module.exports = Duplex;
25681 var util
= require('core-util-is');
25682 util
.inherits
= require('inherits');
25685 var Readable = require('./_stream_readable');
25686 var Writable = require('./_stream_writable');
25688 util.inherits(Duplex, Readable);
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];
25699 function Duplex(options) {
25700 if (!(this instanceof Duplex)) return new Duplex(options);
25702 Readable.call(this, options);
25703 Writable.call(this, options);
25705 if (options && options.readable === false) this.readable = false;
25707 if (options && options.writable === false) this.writable = false;
25709 this.allowHalfOpen = true;
25710 if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
25712 this.once('end', onend);
25715 Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
25716 // making it explicit this property is not enumerable
25717 // because otherwise some prototype manipulation in
25718 // userland will fail
25721 return this._writableState.highWaterMark;
25725 // the no-half-open enforcer
25727 // if we allow half-open state, or if the writable side ended,
25729 if (this.allowHalfOpen || this._writableState.ended) return;
25731 // no more data can be written.
25732 // But allow more writes to happen in this tick.
25733 pna.nextTick(onEndNT, this);
25736 function onEndNT(self) {
25740 Object.defineProperty(Duplex.prototype, 'destroyed', {
25742 if (this._readableState === undefined || this._writableState === undefined) {
25745 return this._readableState.destroyed && this._writableState.destroyed;
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) {
25754 // backward compatibility, the user is explicitly
25755 // managing destroyed
25756 this._readableState.destroyed = value;
25757 this._writableState.destroyed = value;
25761 Duplex.prototype._destroy = function (err, cb) {
25765 pna.nextTick(cb, err);
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.
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:
25778 // The above copyright notice and this permission notice shall be included
25779 // in all copies or substantial portions of the Software.
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.
25789 // a passthrough stream.
25790 // basically just the most minimal sort of Transform stream.
25791 // Every written chunk gets output as-is.
25795 module.exports = PassThrough;
25797 var Transform = require('./_stream_transform');
25800 var util
= require('core-util-is');
25801 util
.inherits
= require('inherits');
25804 util.inherits(PassThrough, Transform);
25806 function PassThrough(options) {
25807 if (!(this instanceof PassThrough)) return new PassThrough(options);
25809 Transform.call(this, options);
25812 PassThrough.prototype._transform = function (chunk, encoding, cb) {
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.
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:
25827 // The above copyright notice and this permission notice shall be included
25828 // in all copies or substantial portions of the Software.
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.
25842 var pna
= require('process-nextick-args');
25845 module.exports = Readable;
25848 var isArray
= require('isarray');
25855 Readable.ReadableState = ReadableState;
25858 var EE
= require('events').EventEmitter
;
25860 var EElistenerCount = function (emitter
, type
) {
25861 return emitter
.listeners(type
).length
;
25866 var Stream
= require('./internal/streams/stream');
25871 var Buffer
= require('safe-buffer').Buffer
;
25872 var OurUint8Array
= global
.Uint8Array
|| function () {};
25873 function _uint8ArrayToBuffer(chunk
) {
25874 return Buffer
.from(chunk
);
25876 function _isUint8Array(obj
) {
25877 return Buffer
.isBuffer(obj
) || obj
instanceof OurUint8Array
;
25883 var util
= require('core-util-is');
25884 util
.inherits
= require('inherits');
25888 var debugUtil
= require('util');
25889 var debug
= void 0;
25890 if (debugUtil
&& debugUtil
.debuglog
) {
25891 debug
= debugUtil
.debuglog('stream');
25893 debug = function () {};
25897 var BufferList = require('./internal/streams/BufferList');
25898 var destroyImpl = require('./internal/streams/destroy');
25901 util.inherits(Readable, Stream);
25903 var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
25905 function 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);
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]];
25917 function ReadableState(options, stream) {
25918 Duplex = Duplex || require('./_stream_duplex');
25920 options = options || {};
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;
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;
25933 if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
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;
25941 if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;
25944 this.highWaterMark = Math.floor(this.highWaterMark);
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
25949 this.buffer = new BufferList();
25952 this.pipesCount = 0;
25953 this.flowing = null;
25954 this.ended = false;
25955 this.endEmitted = false;
25956 this.reading = false;
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.
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;
25971 // has it been destroyed
25972 this.destroyed = false;
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';
25979 // the number of writers that are awaiting a drain event in .pipe()s
25980 this.awaitDrain = 0;
25982 // if true, a maybeReadMore has been scheduled
25983 this.readingMore = false;
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;
25994 function Readable(options) {
25995 Duplex = Duplex || require('./_stream_duplex');
25997 if (!(this instanceof Readable)) return new Readable(options);
25999 this._readableState = new ReadableState(options, this);
26002 this.readable = true;
26005 if (typeof options.read === 'function') this._read = options.read;
26007 if (typeof options.destroy === 'function') this._destroy = options.destroy;
26013 Object.defineProperty(Readable.prototype, 'destroyed', {
26015 if (this._readableState === undefined) {
26018 return this._readableState.destroyed;
26020 set: function (value) {
26021 // we ignore the value if the stream
26022 // has not been initialized yet
26023 if (!this._readableState) {
26027 // backward compatibility, the user is explicitly
26028 // managing destroyed
26029 this._readableState.destroyed = value;
26033 Readable.prototype.destroy = destroyImpl.destroy;
26034 Readable.prototype._undestroy = destroyImpl.undestroy;
26035 Readable.prototype._destroy = function (err, cb) {
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.
26044 Readable.prototype.push = function (chunk, encoding) {
26045 var state = this._readableState;
26046 var skipChunkCheck;
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);
26055 skipChunkCheck = true;
26058 skipChunkCheck = true;
26061 return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
26064 // Unshift should *always* be something directly out of read()
26065 Readable.prototype.unshift = function (chunk) {
26066 return readableAddChunk(this, chunk, null, true, false);
26069 function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
26070 var state = stream._readableState;
26071 if (chunk === null) {
26072 state.reading = false;
26073 onEofChunk(stream, state);
26076 if (!skipChunkCheck) er = chunkInvalid(state, chunk);
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);
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'));
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);
26094 addChunk(stream, state, chunk, false);
26097 } else if (!addToFront) {
26098 state.reading = false;
26102 return needMoreData(state);
26105 function addChunk(stream, state, chunk, addToFront) {
26106 if (state.flowing && state.length === 0 && !state.sync) {
26107 stream.emit('data', chunk);
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);
26114 if (state.needReadable) emitReadable(stream);
26116 maybeReadMore(stream, state);
26119 function chunkInvalid(state, chunk) {
26121 if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
26122 er = new TypeError('Invalid non-string/buffer chunk');
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.
26134 function needMoreData(state) {
26135 return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
26138 Readable.prototype.isPaused = function () {
26139 return this._readableState.flowing === false;
26142 // backwards compatibility.
26143 Readable.prototype.setEncoding = function (enc) {
26144 if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
26145 this._readableState.decoder = new StringDecoder(enc);
26146 this._readableState.encoding = enc;
26150 // Don't raise the hwm > 8MB
26151 var MAX_HWM = 0x800000;
26152 function computeNewHighWaterMark(n) {
26153 if (n >= MAX_HWM) {
26156 // Get the next highest power of 2 to prevent increasing hwm excessively in
26169 // This function is designed to be inlinable, so please take care when making
26170 // changes to the function body.
26171 function howMuchToRead(n, state) {
26172 if (n <= 0 || state.length === 0 && state.ended) return 0;
26173 if (state.objectMode) return 1;
26175 // Only flow one buffer at a time
26176 if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
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;
26186 return state.length;
26189 // you can override either this method, or the async _read(n) below.
26190 Readable.prototype.read = function (n) {
26192 n = parseInt(n, 10);
26193 var state = this._readableState;
26196 if (n !== 0) state.emittedReadable = false;
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);
26207 n = howMuchToRead(n, state);
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);
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.
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.
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
26235 // 3. Actually pull the requested chunks out of the buffer and return.
26237 // if we need a readable event, then we need to do some reading.
26238 var doRead = state.needReadable;
26239 debug('need readable', doRead);
26241 // if we currently have less than the highWaterMark, then also read some
26242 if (state.length === 0 || state.length - n < state.highWaterMark) {
26244 debug('length less than watermark', doRead);
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) {
26251 debug('reading or ended', doRead);
26252 } else if (doRead) {
26254 state.reading = 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);
26267 if (n > 0) ret = fromList(n, state);else ret = null;
26269 if (ret === null) {
26270 state.needReadable = true;
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;
26281 // If we tried to read() past the EOF, then emit end on the next tick.
26282 if (nOrig !== n && state.ended) endReadable(this);
26285 if (ret !== null) this.emit('data', ret);
26290 function 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;
26299 state.ended = true;
26301 // emit 'readable' now to make sure it gets picked up.
26302 emitReadable(stream);
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.
26308 function 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);
26318 function emitReadable_(stream) {
26319 debug('emit readable');
26320 stream.emit('readable');
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.
26330 function maybeReadMore(stream, state) {
26331 if (!state.readingMore) {
26332 state.readingMore = true;
26333 pna.nextTick(maybeReadMore_, stream, state);
26337 function 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');
26342 if (len === state.length)
26343 // didn't get any data, stop spinning.
26344 break;else len = state.length;
26346 state.readingMore = false;
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.
26353 Readable.prototype._read = function (n) {
26354 this.emit('error', new Error('_read() is not implemented'));
26357 Readable.prototype.pipe = function (dest, pipeOpts) {
26359 var state = this._readableState;
26361 switch (state.pipesCount) {
26363 state.pipes = dest;
26366 state.pipes = [state.pipes, dest];
26369 state.pipes.push(dest);
26372 state.pipesCount += 1;
26373 debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
26375 var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
26377 var endFn = doEnd ? onend : unpipe;
26378 if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);
26380 dest.on('unpipe', onunpipe);
26381 function onunpipe(readable, unpipeInfo) {
26383 if (readable === src) {
26384 if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
26385 unpipeInfo.hasUnpiped = true;
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
26400 var ondrain = pipeOnDrain(src);
26401 dest.on('drain', ondrain);
26403 var cleanedUp = false;
26404 function 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);
26418 // if the reader is waiting for a drain event from this
26419 // specific writer, then it would cause it to never start
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();
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) {
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;
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);
26455 dest.removeListener('error', onerror);
26456 if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
26459 // Make sure our error handler is attached before userland ones.
26460 prependListener(dest, 'error', onerror);
26462 // Both close and finish should trigger unpipe, but only once.
26463 function onclose() {
26464 dest.removeListener('finish', onfinish);
26467 dest.once('close', onclose);
26468 function onfinish() {
26470 dest.removeListener('close', onclose);
26473 dest.once('finish', onfinish);
26475 function unpipe() {
26480 // tell the dest that it's being piped to
26481 dest.emit('pipe', src);
26483 // start the flow if it hasn't been started already.
26484 if (!state.flowing) {
26485 debug('pipe resume');
26492 function 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;
26504 Readable.prototype.unpipe = function (dest) {
26505 var state = this._readableState;
26506 var unpipeInfo = { hasUnpiped: false };
26508 // if we're not piping anywhere, then do nothing.
26509 if (state.pipesCount === 0) return this;
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;
26516 if (!dest) dest = state.pipes;
26519 state.pipes = null;
26520 state.pipesCount = 0;
26521 state.flowing = false;
26522 if (dest) dest.emit('unpipe', this, unpipeInfo);
26526 // slow case. multiple pipe destinations.
26530 var dests = state.pipes;
26531 var len = state.pipesCount;
26532 state.pipes = null;
26533 state.pipesCount = 0;
26534 state.flowing = false;
26536 for (var i = 0; i < len; i++) {
26537 dests[i].emit('unpipe', this, unpipeInfo);
26541 // try to find the right one.
26542 var index = indexOf(state.pipes, dest);
26543 if (index === -1) return this;
26545 state.pipes.splice(index, 1);
26546 state.pipesCount -= 1;
26547 if (state.pipesCount === 1) state.pipes = state.pipes[0];
26549 dest.emit('unpipe', this, unpipeInfo);
26554 // set up data events if they are asked for
26555 // Ensure readable listeners eventually get something
26556 Readable.prototype.on = function (ev, fn) {
26557 var res = Stream.prototype.on.call(this, ev, fn);
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);
26577 Readable.prototype.addListener = Readable.prototype.on;
26579 function nReadingNextTick(self) {
26580 debug('readable nexttick read 0');
26584 // pause() and resume() are remnants of the legacy readable stream API
26585 // If the user uses them, then switch into old mode.
26586 Readable.prototype.resume = function () {
26587 var state = this._readableState;
26588 if (!state.flowing) {
26590 state.flowing = true;
26591 resume(this, state);
26596 function resume(stream, state) {
26597 if (!state.resumeScheduled) {
26598 state.resumeScheduled = true;
26599 pna.nextTick(resume_, stream, state);
26603 function resume_(stream, state) {
26604 if (!state.reading) {
26605 debug('resume read 0');
26609 state.resumeScheduled = false;
26610 state.awaitDrain = 0;
26611 stream.emit('resume');
26613 if (state.flowing && !state.reading) stream.read(0);
26616 Readable.prototype.pause = function () {
26617 debug('call pause flowing=%j', this._readableState.flowing);
26618 if (false !== this._readableState.flowing) {
26620 this._readableState.flowing = false;
26621 this.emit('pause');
26626 function flow(stream) {
26627 var state = stream._readableState;
26628 debug('flow', state.flowing);
26629 while (state.flowing && stream.read() !== null) {}
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.
26635 Readable.prototype.wrap = function (stream) {
26638 var state = this._readableState;
26639 var paused = false;
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);
26651 stream.on('data', function (chunk) {
26652 debug('wrapped data');
26653 if (state.decoder) chunk = state.decoder.write(chunk);
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;
26658 var ret = _this.push(chunk);
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);
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]));
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);
26695 Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
26696 // making it explicit this property is not enumerable
26697 // because otherwise some prototype manipulation in
26698 // userland will fail
26701 return this._readableState.highWaterMark;
26705 // exposed for testing purposes only.
26706 Readable._fromList = fromList;
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.
26712 function fromList(n, state) {
26713 // nothing buffered
26714 if (state.length === 0) return null;
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();
26722 // read part of list
26723 ret = fromListPartial(n, state.buffer, state.decoder);
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.
26732 function fromListPartial(n, list, hasStrings) {
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();
26742 // result spans more than one buffer
26743 ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
26748 // Copies a specified amount of characters from the list of buffered data
26750 // This function is designed to be inlinable, so please take care when making
26751 // changes to the function body.
26752 function copyFromBufferString(n, list) {
26757 while (p = p.next) {
26759 var nb = n > str.length ? str.length : n;
26760 if (nb === str.length) ret += str;else ret += str.slice(0, n);
26763 if (nb === str.length) {
26765 if (p.next) list.head = p.next;else list.head = list.tail = null;
26768 p.data = str.slice(nb);
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.
26781 function copyFromBuffer(n, list) {
26782 var ret = Buffer.allocUnsafe(n);
26786 n -= p.data.length;
26787 while (p = p.next) {
26789 var nb = n > buf.length ? buf.length : n;
26790 buf.copy(ret, ret.length - n, 0, nb);
26793 if (nb === buf.length) {
26795 if (p.next) list.head = p.next;else list.head = list.tail = null;
26798 p.data = buf.slice(nb);
26808 function endReadable(stream) {
26809 var state = stream._readableState;
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');
26815 if (!state.endEmitted) {
26816 state.ended = true;
26817 pna.nextTick(endReadableNT, state, stream);
26821 function 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');
26830 function indexOf(xs, x) {
26831 for (var i = 0, l = xs.length; i < l; i++) {
26832 if (xs[i] === x) return i;
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.
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:
26848 // The above copyright notice and this permission notice shall be included
26849 // in all copies or substantial portions of the Software.
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.
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.)
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.
26870 // Here's how this works:
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.
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.
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.
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.
26903 module.exports = Transform;
26905 var Duplex = require('./_stream_duplex');
26908 var util
= require('core-util-is');
26909 util
.inherits
= require('inherits');
26912 util.inherits(Transform, Duplex);
26914 function afterTransform(er, data) {
26915 var ts = this._transformState;
26916 ts.transforming = false;
26918 var cb = ts.writecb;
26921 return this.emit('error', new Error('write callback called multiple times'));
26924 ts.writechunk = null;
26927 if (data != null) // single equals check for both `null` and `undefined`
26932 var rs = this._readableState;
26933 rs.reading = false;
26934 if (rs.needReadable || rs.length < rs.highWaterMark) {
26935 this._read(rs.highWaterMark);
26939 function Transform(options) {
26940 if (!(this instanceof Transform)) return new Transform(options);
26942 Duplex.call(this, options);
26944 this._transformState = {
26945 afterTransform: afterTransform.bind(this),
26946 needTransform: false,
26947 transforming: false,
26950 writeencoding: null
26953 // start out asking for a readable event once data is transformed.
26954 this._readableState.needReadable = true;
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;
26962 if (typeof options.transform === 'function') this._transform = options.transform;
26964 if (typeof options.flush === 'function') this._flush = options.flush;
26967 // When the writable side finishes, then flush out anything remaining.
26968 this.on('prefinish', prefinish);
26971 function prefinish() {
26974 if (typeof this._flush === 'function') {
26975 this._flush(function (er, data) {
26976 done(_this, er, data);
26979 done(this, null, null);
26983 Transform.prototype.push = function (chunk, encoding) {
26984 this._transformState.needTransform = false;
26985 return Duplex.prototype.push.call(this, chunk, encoding);
26988 // This is the part where you do stuff!
26989 // override this function in implementation classes.
26990 // 'chunk' is an input chunk.
26992 // Call `push(newChunk)` to pass along transformed output
26993 // to the readable side. You may call 'push' zero or more times.
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.
26998 Transform.prototype._transform = function (chunk, encoding, cb) {
26999 throw new Error('_transform() is not implemented');
27002 Transform.prototype._write = function (chunk, encoding, cb) {
27003 var ts = this._transformState;
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);
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.
27016 Transform.prototype._read = function (n) {
27017 var ts = this._transformState;
27019 if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
27020 ts.transforming = true;
27021 this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
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;
27029 Transform.prototype._destroy = function (err, cb) {
27032 Duplex.prototype._destroy.call(this, err, function (err2) {
27034 _this2.emit('close');
27038 function done(stream, er, data) {
27039 if (er) return stream.emit('error', er);
27041 if (data != null) // single equals check for both `null` and `undefined`
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');
27048 if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
27050 return stream.push(null);
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.
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:
27064 // The above copyright notice and this permission notice shall be included
27065 // in all copies or substantial portions of the Software.
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.
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.
27083 var pna
= require('process-nextick-args');
27086 module.exports = Writable;
27088 /* <replacement> */
27089 function WriteReq(chunk
, encoding
, cb
) {
27090 this.chunk
= chunk
;
27091 this.encoding
= encoding
;
27092 this.callback
= cb
;
27096 // It seems a linked list but it is not
27097 // there will be only 2 of these for each stream
27098 function CorkedRequest(state
) {
27103 this.finish = function () {
27104 onCorkedFinish(_this
, state
);
27107 /* </replacement> */
27110 var asyncWrite
= !process
.browser
&& ['v0.10', 'v0.9.'].indexOf(process
.version
.slice(0, 5)) > -1 ? setImmediate : pna
.nextTick
;
27117 Writable.WritableState = WritableState;
27120 var util
= require('core-util-is');
27121 util
.inherits
= require('inherits');
27125 var internalUtil
= {
27126 deprecate: require('util-deprecate')
27131 var Stream
= require('./internal/streams/stream');
27136 var Buffer
= require('safe-buffer').Buffer
;
27137 var OurUint8Array
= global
.Uint8Array
|| function () {};
27138 function _uint8ArrayToBuffer(chunk
) {
27139 return Buffer
.from(chunk
);
27141 function _isUint8Array(obj
) {
27142 return Buffer
.isBuffer(obj
) || obj
instanceof OurUint8Array
;
27147 var destroyImpl = require('./internal/streams/destroy');
27149 util.inherits(Writable, Stream);
27153 function WritableState(options, stream) {
27154 Duplex = Duplex || require('./_stream_duplex');
27156 options = options || {};
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;
27165 // object stream flag to indicate whether or not this stream
27166 // contains buffers or objects.
27167 this.objectMode = !!options.objectMode;
27169 if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
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;
27178 if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;
27181 this.highWaterMark = Math.floor(this.highWaterMark);
27183 // if _final has been called
27184 this.finalCalled = false;
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;
27195 // has it been destroyed
27196 this.destroyed = false;
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;
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';
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
27214 // a flag to see when we're in the middle of a write.
27215 this.writing = false;
27217 // when true all writes will be buffered until .uncork() call
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.
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;
27231 // the callback that's passed to _write(chunk,cb)
27232 this.onwrite = function (er) {
27233 onwrite(stream, er);
27236 // the callback that the user supplies to write(chunk,encoding,cb)
27237 this.writecb = null;
27239 // the amount that is being written when _write is called.
27242 this.bufferedRequest = null;
27243 this.lastBufferedRequest = null;
27245 // number of pending user-supplied write callbacks
27246 // this must be 0 before 'finish' can be emitted
27247 this.pendingcb = 0;
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;
27253 // True if the error was already emitted and should not be thrown again
27254 this.errorEmitted = false;
27256 // count buffered requests
27257 this.bufferedRequestCount = 0;
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);
27264 WritableState.prototype.getBuffer = function getBuffer() {
27265 var current = this.bufferedRequest;
27269 current = current.next;
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')
27284 // Test _writableState for inheritance to account for Duplex streams,
27285 // whose prototype chain only points to Readable.
27286 var realHasInstance;
27287 if (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;
27294 return object && object._writableState instanceof WritableState;
27298 realHasInstance = function (object) {
27299 return object instanceof this;
27303 function Writable(options) {
27304 Duplex = Duplex || require('./_stream_duplex');
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.
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);
27317 this._writableState = new WritableState(options, this);
27320 this.writable = true;
27323 if (typeof options.write === 'function') this._write = options.write;
27325 if (typeof options.writev === 'function') this._writev = options.writev;
27327 if (typeof options.destroy === 'function') this._destroy = options.destroy;
27329 if (typeof options.final === 'function') this._final = options.final;
27335 // Otherwise people can pipe Writable streams, which is just wrong.
27336 Writable.prototype.pipe = function () {
27337 this.emit('error', new Error('Cannot pipe, not readable'));
27340 function 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);
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.
27350 function validChunk(stream, state, chunk, cb) {
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');
27360 stream.emit('error', er);
27361 pna.nextTick(cb, er);
27367 Writable.prototype.write = function (chunk, encoding, cb) {
27368 var state = this._writableState;
27370 var isBuf = !state.objectMode && _isUint8Array(chunk);
27372 if (isBuf && !Buffer.isBuffer(chunk)) {
27373 chunk = _uint8ArrayToBuffer(chunk);
27376 if (typeof encoding === 'function') {
27381 if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
27383 if (typeof cb !== 'function') cb = nop;
27385 if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
27387 ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
27393 Writable.prototype.cork = function () {
27394 var state = this._writableState;
27399 Writable.prototype.uncork = function () {
27400 var state = this._writableState;
27402 if (state.corked) {
27405 if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
27409 Writable.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;
27417 function decodeChunk(state, chunk, encoding) {
27418 if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
27419 chunk = Buffer.from(chunk, encoding);
27424 Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
27425 // making it explicit this property is not enumerable
27426 // because otherwise some prototype manipulation in
27427 // userland will fail
27430 return this._writableState.highWaterMark;
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.
27437 function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
27439 var newChunk = decodeChunk(state, chunk, encoding);
27440 if (chunk !== newChunk) {
27442 encoding = 'buffer';
27446 var len = state.objectMode ? 1 : chunk.length;
27448 state.length += len;
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;
27454 if (state.writing || state.corked) {
27455 var last = state.lastBufferedRequest;
27456 state.lastBufferedRequest = {
27458 encoding: encoding,
27464 last.next = state.lastBufferedRequest;
27466 state.bufferedRequest = state.lastBufferedRequest;
27468 state.bufferedRequestCount += 1;
27470 doWrite(stream, state, false, len, chunk, encoding, cb);
27476 function doWrite(stream, state, writev, len, chunk, encoding, cb) {
27477 state.writelen = len;
27478 state.writecb = cb;
27479 state.writing = true;
27481 if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
27482 state.sync = false;
27485 function onwriteError(stream, state, sync, er, cb) {
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
27494 pna.nextTick(finishMaybe, stream, state);
27495 stream._writableState.errorEmitted = true;
27496 stream.emit('error', er);
27498 // the caller expect this to happen before if
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);
27509 function onwriteStateUpdate(state) {
27510 state.writing = false;
27511 state.writecb = null;
27512 state.length -= state.writelen;
27513 state.writelen = 0;
27516 function onwrite(stream, er) {
27517 var state = stream._writableState;
27518 var sync = state.sync;
27519 var cb = state.writecb;
27521 onwriteStateUpdate(state);
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);
27527 if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
27528 clearBuffer(stream, state);
27533 asyncWrite(afterWrite
, stream
, state
, finished
, cb
);
27536 afterWrite(stream, state, finished, cb);
27541 function afterWrite(stream, state, finished, cb) {
27542 if (!finished) onwriteDrain(stream, state);
27545 finishMaybe(stream, state);
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.
27551 function onwriteDrain(stream, state) {
27552 if (state.length === 0 && state.needDrain) {
27553 state.needDrain = false;
27554 stream.emit('drain');
27558 // if there's something in the buffer waiting, then process it
27559 function clearBuffer(stream, state) {
27560 state.bufferProcessing = true;
27561 var entry = state.bufferedRequest;
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;
27571 var allBuffers = true;
27573 buffer[count] = entry;
27574 if (!entry.isBuf) allBuffers = false;
27575 entry = entry.next;
27578 buffer.allBuffers = allBuffers;
27580 doWrite(stream, state, true, state.length, buffer, '', holder.finish);
27582 // doWrite is almost always async, defer these to save a bit of time
27583 // as the hot path ends with doWrite
27585 state.lastBufferedRequest = null;
27587 state.corkedRequestsFree = holder.next;
27588 holder.next = null;
27590 state.corkedRequestsFree = new CorkedRequest(state);
27592 state.bufferedRequestCount = 0;
27594 // Slow case, write chunks one-by-one
27596 var chunk = entry.chunk;
27597 var encoding = entry.encoding;
27598 var cb = entry.callback;
27599 var len = state.objectMode ? 1 : chunk.length;
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) {
27613 if (entry === null) state.lastBufferedRequest = null;
27616 state.bufferedRequest = entry;
27617 state.bufferProcessing = false;
27620 Writable.prototype._write = function (chunk, encoding, cb) {
27621 cb(new Error('_write() is not implemented'));
27624 Writable.prototype._writev = null;
27626 Writable.prototype.end = function (chunk, encoding, cb) {
27627 var state = this._writableState;
27629 if (typeof chunk === 'function') {
27633 } else if (typeof encoding === 'function') {
27638 if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
27640 // .end() fully uncorks
27641 if (state.corked) {
27646 // ignore unnecessary end() calls.
27647 if (!state.ending && !state.finished) endWritable(this, state, cb);
27650 function needFinish(state) {
27651 return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
27653 function callFinal(stream, state) {
27654 stream._final(function (err) {
27657 stream.emit('error', err);
27659 state.prefinished = true;
27660 stream.emit('prefinish');
27661 finishMaybe(stream, state);
27664 function prefinish(stream, state) {
27665 if (!state.prefinished && !state.finalCalled) {
27666 if (typeof stream._final === 'function') {
27668 state.finalCalled = true;
27669 pna.nextTick(callFinal, stream, state);
27671 state.prefinished = true;
27672 stream.emit('prefinish');
27677 function finishMaybe(stream, state) {
27678 var need = needFinish(state);
27680 prefinish(stream, state);
27681 if (state.pendingcb === 0) {
27682 state.finished = true;
27683 stream.emit('finish');
27689 function endWritable(stream, state, cb) {
27690 state.ending = true;
27691 finishMaybe(stream, state);
27693 if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
27695 state.ended = true;
27696 stream.writable = false;
27699 function onCorkedFinish(corkReq, state, err) {
27700 var entry = corkReq.entry;
27701 corkReq.entry = null;
27703 var cb = entry.callback;
27706 entry = entry.next;
27708 if (state.corkedRequestsFree) {
27709 state.corkedRequestsFree.next = corkReq;
27711 state.corkedRequestsFree = corkReq;
27715 Object.defineProperty(Writable.prototype, 'destroyed', {
27717 if (this._writableState === undefined) {
27720 return this._writableState.destroyed;
27722 set: function (value) {
27723 // we ignore the value if the stream
27724 // has not been initialized yet
27725 if (!this._writableState) {
27729 // backward compatibility, the user is explicitly
27730 // managing destroyed
27731 this._writableState.destroyed = value;
27735 Writable.prototype.destroy = destroyImpl.destroy;
27736 Writable.prototype._undestroy = destroyImpl.undestroy;
27737 Writable.prototype._destroy = function (err, cb) {
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){
27745 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
27747 var Buffer = require('safe-buffer').Buffer;
27748 var util = require('util');
27750 function copyBuffer(src, target, offset) {
27751 src.copy(target, offset);
27754 module.exports = function () {
27755 function BufferList() {
27756 _classCallCheck(this, BufferList);
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;
27770 BufferList.prototype.unshift = function unshift(v) {
27771 var entry = { data: v, next: this.head };
27772 if (this.length === 0) this.tail = entry;
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;
27785 BufferList.prototype.clear = function clear() {
27786 this.head = this.tail = null;
27790 BufferList.prototype.join = function join(s) {
27791 if (this.length === 0) return '';
27793 var ret = '' + p.data;
27794 while (p = p.next) {
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);
27806 copyBuffer(p.data, ret, i);
27807 i += p.data.length;
27816 if (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;
27822 },{"safe-buffer":199,"util":81}],197:[function(require,module,exports){
27827 var pna
= require('process-nextick-args');
27830 // undocumented cb() API, needed for core, not for public API
27831 function destroy(err, cb) {
27834 var readableDestroyed = this._readableState && this._readableState.destroyed;
27835 var writableDestroyed = this._writableState && this._writableState.destroyed;
27837 if (readableDestroyed || writableDestroyed) {
27840 } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
27841 pna.nextTick(emitErrorNT, this, err);
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
27849 if (this._readableState) {
27850 this._readableState.destroyed = true;
27853 // if this is a duplex stream mark the writable part as destroyed as well
27854 if (this._writableState) {
27855 this._writableState.destroyed = true;
27858 this._destroy(err || null, function (err) {
27860 pna.nextTick(emitErrorNT, _this, err);
27861 if (_this._writableState) {
27862 _this._writableState.errorEmitted = true;
27872 function 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;
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;
27889 function emitErrorNT(self, err) {
27890 self.emit('error', err);
27895 undestroy: undestroy
27897 },{"process-nextick-args":180}],198:[function(require,module,exports){
27898 module.exports = require('events').EventEmitter;
27900 },{"events":145}],199:[function(require,module,exports){
27901 /* eslint-disable node/no-deprecated-api */
27902 var buffer
= require('buffer')
27903 var Buffer
= buffer
.Buffer
27905 // alternative to using Object.keys for old browsers
27906 function copyProps (src
, dst
) {
27907 for (var key
in src
) {
27908 dst
[key
] = src
[key
]
27911 if (Buffer
.from && Buffer
.alloc
&& Buffer
.allocUnsafe
&& Buffer
.allocUnsafeSlow
) {
27912 module
.exports
= buffer
27914 // Copy properties from require('buffer')
27915 copyProps(buffer
, exports
)
27916 exports
.Buffer
= SafeBuffer
27919 function SafeBuffer (arg
, encodingOrOffset
, length
) {
27920 return Buffer(arg
, encodingOrOffset
, length
)
27923 // Copy static methods from Buffer
27924 copyProps(Buffer
, SafeBuffer
)
27926 SafeBuffer
.from = function (arg
, encodingOrOffset
, length
) {
27927 if (typeof arg
=== 'number') {
27928 throw new TypeError('Argument must not be a number')
27930 return Buffer(arg
, encodingOrOffset
, length
)
27933 SafeBuffer
.alloc = function (size
, fill
, encoding
) {
27934 if (typeof size
!== 'number') {
27935 throw new TypeError('Argument must be a number')
27937 var buf
= Buffer(size
)
27938 if (fill
!== undefined) {
27939 if (typeof encoding
=== 'string') {
27940 buf
.fill(fill
, encoding
)
27950 SafeBuffer
.allocUnsafe = function (size
) {
27951 if (typeof size
!== 'number') {
27952 throw new TypeError('Argument must be a number')
27954 return Buffer(size
)
27957 SafeBuffer
.allocUnsafeSlow = function (size
) {
27958 if (typeof size
!== 'number') {
27959 throw new TypeError('Argument must be a number')
27961 return buffer
.SlowBuffer(size
)
27964 },{"buffer":110}],200:[function(require
,module
,exports
){
27965 // Copyright Joyent, Inc. and other Node contributors.
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:
27975 // The above copyright notice and this permission notice shall be included
27976 // in all copies or substantial portions of the Software.
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.
27990 var Buffer
= require('safe-buffer').Buffer
;
27993 var 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':
28003 function _normalizeEncoding(enc) {
28004 if (!enc) return 'utf8';
28024 if (retried) return; // undefined
28025 enc = ('' + enc).toLowerCase();
28031 // Do not cache `Buffer.isEncoding` when checking encoding names as some
28032 // modules monkey-patch it to support additional encodings
28033 function 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;
28039 // StringDecoder provides an interface for efficiently splitting a series of
28040 // buffers into a series of JS strings without breaking apart multi-byte
28042 exports.StringDecoder = StringDecoder;
28043 function StringDecoder(encoding) {
28044 this.encoding = normalizeEncoding(encoding);
28046 switch (this.encoding) {
28048 this.text = utf16Text;
28049 this.end = utf16End;
28053 this.fillLast = utf8FillLast;
28057 this.text = base64Text;
28058 this.end = base64End;
28062 this.write = simpleWrite;
28063 this.end = simpleEnd;
28067 this.lastTotal = 0;
28068 this.lastChar = Buffer.allocUnsafe(nb);
28071 StringDecoder.prototype.write = function (buf) {
28072 if (buf.length === 0) return '';
28075 if (this.lastNeed) {
28076 r = this.fillLast(buf);
28077 if (r === undefined) return '';
28083 if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
28087 StringDecoder.prototype.end = utf8End;
28089 // Returns only complete characters in a Buffer
28090 StringDecoder.prototype.text = utf8Text;
28092 // Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
28093 StringDecoder.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);
28098 buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
28099 this.lastNeed -= buf.length;
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.
28104 function 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;
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.
28112 function utf8CheckIncomplete(self, buf, i) {
28113 var j = buf.length - 1;
28114 if (j < i) return 0;
28115 var nb = utf8CheckByte(buf[j]);
28117 if (nb > 0) self.lastNeed = nb - 1;
28120 if (--j < i || nb === -2) return 0;
28121 nb = utf8CheckByte(buf[j]);
28123 if (nb > 0) self.lastNeed = nb - 2;
28126 if (--j < i || nb === -2) return 0;
28127 nb = utf8CheckByte(buf[j]);
28130 if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
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
28145 function utf8CheckExtraBytes(self, buf, p) {
28146 if ((buf[0] & 0xC0) !== 0x80) {
28150 if (self.lastNeed > 1 && buf.length > 1) {
28151 if ((buf[1] & 0xC0) !== 0x80) {
28155 if (self.lastNeed > 2 && buf.length > 2) {
28156 if ((buf[2] & 0xC0) !== 0x80) {
28164 // Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
28165 function 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);
28173 buf.copy(this.lastChar, p, 0, buf.length);
28174 this.lastNeed -= buf.length;
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.
28180 function 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);
28189 // For UTF-8, a replacement character is added when ending on a partial
28191 function utf8End(buf) {
28192 var r = buf && buf.length ? this.write(buf) : '';
28193 if (this.lastNeed) return r + '\ufffd';
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.
28201 function utf16Text(buf, i) {
28202 if ((buf.length - i) % 2 === 0) {
28203 var r = buf.toString('utf16le', i);
28205 var c = r.charCodeAt(r.length - 1);
28206 if (c >= 0xD800 && c <= 0xDBFF) {
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);
28217 this.lastTotal = 2;
28218 this.lastChar[0] = buf[buf.length - 1];
28219 return buf.toString('utf16le', i, buf.length - 1);
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.
28224 function 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);
28233 function 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;
28239 this.lastChar[0] = buf[buf.length - 1];
28241 this.lastChar[0] = buf[buf.length - 2];
28242 this.lastChar[1] = buf[buf.length - 1];
28244 return buf.toString('base64', i, buf.length - n);
28247 function 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);
28253 // Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
28254 function simpleWrite(buf) {
28255 return buf.toString(this.encoding);
28258 function simpleEnd(buf) {
28259 return buf && buf.length ? this.write(buf) : '';
28261 },{"safe-buffer":199}],201:[function(require,module,exports){
28262 module.exports = require('./readable').PassThrough
28264 },{"./readable":202}],202:[function(require,module,exports){
28265 exports = module.exports = require('./lib/_stream_readable.js');
28266 exports.Stream = exports;
28267 exports.Readable = exports;
28268 exports.Writable = require('./lib/_stream_writable.js');
28269 exports.Duplex = require('./lib/_stream_duplex.js');
28270 exports.Transform = require('./lib/_stream_transform.js');
28271 exports.PassThrough = require('./lib/_stream_passthrough.js');
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){
28274 module.exports = require('./readable').Transform
28276 },{"./readable":202}],204:[function(require,module,exports){
28277 module.exports = require('./lib/_stream_writable.js');
28279 },{"./lib/_stream_writable.js":195}],205:[function(require,module,exports){
28280 arguments[4][46][0].apply(exports,arguments)
28281 },{"buffer":110,"dup":46,"hash-base":147,"inherits":162}],206:[function(require,module,exports){
28282 arguments[4][47][0].apply(exports,arguments)
28283 },{"buffer":110,"dup":47}],207:[function(require,module,exports){
28284 arguments[4][52][0].apply(exports,arguments)
28285 },{"dup":52,"safe-buffer":206}],208:[function(require,module,exports){
28286 arguments[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){
28288 arguments[4][54][0].apply(exports,arguments)
28289 },{"./hash":207,"dup":54,"inherits":162,"safe-buffer":206}],210:[function(require,module,exports){
28290 arguments[4][55][0].apply(exports,arguments)
28291 },{"./hash":207,"dup":55,"inherits":162,"safe-buffer":206}],211:[function(require,module,exports){
28292 arguments[4][56][0].apply(exports,arguments)
28293 },{"./hash":207,"./sha256":212,"dup":56,"inherits":162,"safe-buffer":206}],212:[function(require,module,exports){
28294 arguments[4][57][0].apply(exports,arguments)
28295 },{"./hash":207,"dup":57,"inherits":162,"safe-buffer":206}],213:[function(require,module,exports){
28296 arguments[4][58][0].apply(exports,arguments)
28297 },{"./hash":207,"./sha512":214,"dup":58,"inherits":162,"safe-buffer":206}],214:[function(require,module,exports){
28298 arguments[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.
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:
28310 // The above copyright notice and this permission notice shall be included
28311 // in all copies or substantial portions of the Software.
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.
28321 module.exports = Stream;
28323 var EE = require('events').EventEmitter;
28324 var inherits = require('inherits');
28326 inherits(Stream, EE);
28327 Stream.Readable = require('readable-stream/readable.js');
28328 Stream.Writable = require('readable-stream/writable.js');
28329 Stream.Duplex = require('readable-stream/duplex.js');
28330 Stream.Transform = require('readable-stream/transform.js');
28331 Stream.PassThrough = require('readable-stream/passthrough.js');
28333 // Backwards-compat with node 0.4.x
28334 Stream.Stream = Stream;
28338 // old-style streams. Note that the pipe method (the only relevant
28339 // part of this class) is overridden in the Readable class.
28341 function Stream() {
28345 Stream.prototype.pipe = function(dest, options) {
28348 function ondata(chunk) {
28349 if (dest.writable) {
28350 if (false === dest.write(chunk) && source.pause) {
28356 source.on('data', ondata);
28358 function ondrain() {
28359 if (source.readable && source.resume) {
28364 dest.on('drain', ondrain);
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);
28373 var didOnEnd = false;
28375 if (didOnEnd) return;
28382 function onclose() {
28383 if (didOnEnd) return;
28386 if (typeof dest.destroy === 'function') dest.destroy();
28389 // don't leave dangling pipes when there are errors.
28390 function onerror(er) {
28392 if (EE.listenerCount(this, 'error') === 0) {
28393 throw er; // Unhandled stream error in pipe.
28397 source.on('error', onerror);
28398 dest.on('error', onerror);
28400 // remove all the event listeners that were added.
28401 function cleanup() {
28402 source.removeListener('data', ondata);
28403 dest.removeListener('drain', ondrain);
28405 source.removeListener('end', onend);
28406 source.removeListener('close', onclose);
28408 source.removeListener('error', onerror);
28409 dest.removeListener('error', onerror);
28411 source.removeListener('end', cleanup);
28412 source.removeListener('close', cleanup);
28414 dest.removeListener('close', cleanup);
28417 source.on('end', cleanup);
28418 source.on('close', cleanup);
28420 dest.on('close', cleanup);
28422 dest.emit('pipe', source);
28424 // Allow for unix-like usage: A.pipe(B).pipe(C)
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){
28429 arguments[4][200][0].apply(exports,arguments)
28430 },{"dup":200,"safe-buffer":206}],217:[function(require,module,exports){
28431 (function (setImmediate,clearImmediate){
28432 var nextTick = require('process/browser.js').nextTick;
28433 var apply = Function.prototype.apply;
28434 var slice = Array.prototype.slice;
28435 var immediateIds = {};
28436 var nextImmediateId = 0;
28438 // DOM APIs, for completeness
28440 exports.setTimeout = function() {
28441 return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
28443 exports.setInterval = function() {
28444 return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
28446 exports.clearTimeout =
28447 exports.clearInterval = function(timeout) { timeout.close(); };
28449 function Timeout(id, clearFn) {
28451 this._clearFn = clearFn;
28453 Timeout.prototype.unref = Timeout.prototype.ref = function() {};
28454 Timeout.prototype.close = function() {
28455 this._clearFn.call(window, this._id);
28458 // Does not start the time, just sets up the members needed.
28459 exports.enroll = function(item, msecs) {
28460 clearTimeout(item._idleTimeoutId);
28461 item._idleTimeout = msecs;
28464 exports.unenroll = function(item) {
28465 clearTimeout(item._idleTimeoutId);
28466 item._idleTimeout = -1;
28469 exports._unrefActive = exports.active = function(item) {
28470 clearTimeout(item._idleTimeoutId);
28472 var msecs = item._idleTimeout;
28474 item._idleTimeoutId = setTimeout(function onTimeout() {
28475 if (item._onTimeout)
28481 // That's not how node.js implements it but the exposed api is the same.
28482 exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) {
28483 var id = nextImmediateId++;
28484 var args = arguments.length < 2 ? false : slice.call(arguments, 1);
28486 immediateIds[id] = true;
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
28493 fn.apply(null, args);
28497 // Prevent ids from leaking
28498 exports.clearImmediate(id);
28505 exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) {
28506 delete immediateIds[id];
28508 }).call(this,require("timers").setImmediate,require("timers").clearImmediate)
28509 },{"process/browser.js":181,"timers":217}],218:[function(require,module,exports){
28510 (function (global){
28516 module
.exports
= deprecate
;
28519 * Mark that a method should not be used.
28520 * Returns a modified function which warns once by default.
28522 * If `localStorage.noDeprecation = true` is set, then it is a no-op.
28524 * If `localStorage.throwDeprecation = true` is set, then deprecated functions
28525 * will throw an Error when invoked.
28527 * If `localStorage.traceDeprecation = true` is set, then deprecated functions
28528 * will invoke `console.trace()` instead of `console.error()`.
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`
28536 function deprecate (fn
, msg
) {
28537 if (config('noDeprecation')) {
28541 var warned
= false;
28542 function deprecated() {
28544 if (config('throwDeprecation')) {
28545 throw new Error(msg
);
28546 } else if (config('traceDeprecation')) {
28547 console
.trace(msg
);
28553 return fn
.apply(this, arguments
);
28560 * Checks `localStorage` for boolean values for the given `name`.
28562 * @param {String} name
28563 * @returns {Boolean}
28567 function config (name
) {
28568 // accessing global.localStorage can trigger a DOMException in sandboxed iframes
28570 if (!global
.localStorage
) return false;
28574 var val
= global
.localStorage
[name
];
28575 if (null == val
) return false;
28576 return String(val
).toLowerCase() === 'true';
28579 }).call(this,typeof global
!== "undefined" ? global : typeof self
!== "undefined" ? self : typeof window
!== "undefined" ? window : {})
28580 },{}],219:[function(require
,module
,exports
){
28581 var 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
;
28588 var Object_keys = function (obj
) {
28589 if (Object
.keys
) return Object
.keys(obj
)
28592 for (var key
in obj
) res
.push(key
)
28597 var forEach = function (xs
, fn
) {
28598 if (xs
.forEach
) return xs
.forEach(fn
)
28599 else for (var i
= 0; i
< xs
.length
; i
++) {
28604 var defineProp
= (function() {
28606 Object
.defineProperty({}, '_', {});
28607 return function(obj
, name
, value
) {
28608 Object
.defineProperty(obj
, name
, {
28611 configurable: true,
28616 return function(obj
, name
, value
) {
28622 var 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'];
28628 function Context() {}
28629 Context
.prototype = {};
28631 var Script
= exports
.Script
= function NodeScript (code
) {
28632 if (!(this instanceof Script
)) return new Script(code
);
28636 Script
.prototype.runInContext = function (context
) {
28637 if (!(context
instanceof Context
)) {
28638 throw new TypeError("needs a 'context' argument.");
28641 var iframe
= document
.createElement('iframe');
28642 if (!iframe
.style
) iframe
.style
= {};
28643 iframe
.style
.display
= 'none';
28645 document
.body
.appendChild(iframe
);
28647 var win
= iframe
.contentWindow
;
28648 var wEval
= win
.eval
, wExecScript
= win
.execScript
;
28650 if (!wEval
&& wExecScript
) {
28651 // win.eval() magically appears when this is called in IE:
28652 wExecScript
.call(win
, 'null');
28656 forEach(Object_keys(context
), function (key
) {
28657 win
[key
] = context
[key
];
28659 forEach(globals
, function (key
) {
28660 if (context
[key
]) {
28661 win
[key
] = context
[key
];
28665 var winKeys
= Object_keys(win
);
28667 var res
= wEval
.call(win
, this.code
);
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
];
28678 forEach(globals
, function (key
) {
28679 if (!(key
in context
)) {
28680 defineProp(context
, key
, win
[key
]);
28684 document
.body
.removeChild(iframe
);
28689 Script
.prototype.runInThisContext = function () {
28690 return eval(this.code
); // maybe...
28693 Script
.prototype.runInNewContext = function (context
) {
28694 var ctx
= Script
.createContext(context
);
28695 var res
= this.runInContext(ctx
);
28698 forEach(Object_keys(ctx
), function (key
) {
28699 context
[key
] = ctx
[key
];
28706 forEach(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));
28713 exports
.isContext = function (context
) {
28714 return context
instanceof Context
;
28717 exports
.createScript = function (code
) {
28718 return exports
.Script(code
);
28721 exports
.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
];